设备程序版本分页程序

This commit is contained in:
caozehui
2026-04-20 14:19:55 +08:00
parent 353a4cc83b
commit 00ccff18c0
14 changed files with 467 additions and 256 deletions

View File

@@ -59,6 +59,11 @@
<version>4.4.0</version> <version>4.4.0</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
<version>1.2.5</version>
</dependency>
</dependencies> </dependencies>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@@ -1,12 +1,16 @@
package com.njcn.csdevice.api; package com.njcn.csdevice.api;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.njcn.common.pojo.constant.ServerInfo; import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.api.fallback.CsEdDataFeignClientFallbackFactory; import com.njcn.csdevice.api.fallback.CsEdDataFeignClientFallbackFactory;
import com.njcn.csdevice.pojo.param.CsEdDataQueryParm;
import com.njcn.csdevice.pojo.po.CsEdDataPO; import com.njcn.csdevice.pojo.po.CsEdDataPO;
import com.njcn.csdevice.pojo.vo.CsEdDataVO; import com.njcn.csdevice.pojo.vo.CsEdDataVO;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import java.util.List; import java.util.List;

View File

@@ -115,4 +115,9 @@ public class CsEquipmentDeliveryDTO {
* 日志等级(NORMAL、DEBUG、WARN、ERROR) * 日志等级(NORMAL、DEBUG、WARN、ERROR)
*/ */
private String devLogLevel; private String devLogLevel;
/**
* 设备软件信息id
*/
private String softinfoId;
} }

View File

@@ -0,0 +1,15 @@
package com.njcn.csdevice.pojo.param;
import com.njcn.web.pojo.param.BaseParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @author caozehui
* @data 2026-04-07
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class DevVersionParam extends BaseParam {
private String keyword;
}

View File

@@ -10,7 +10,6 @@ import lombok.EqualsAndHashCode;
import java.util.Date; import java.util.Date;
/** /**
*
* Description: * Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html * 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2023/4/7 11:29【需求编号】 * Date: 2023/4/7 11:29【需求编号】
@@ -88,6 +87,10 @@ public class CsEdDataPO extends BaseEntity {
@TableField(value = "file_path") @TableField(value = "file_path")
private String filePath; private String filePath;
/**
* crc校验
*/
@TableField(value = "crc")
private String crc;
} }

View File

@@ -147,5 +147,4 @@ public class CsEquipmentDeliveryPO extends BaseEntity {
*/ */
@TableField(value = "associated_project") @TableField(value = "associated_project")
private String associatedProject; private String associatedProject;
} }

View File

@@ -70,12 +70,11 @@ public class CsEdDataVO extends BaseEntity {
@ApiModelProperty(value = "版本类型") @ApiModelProperty(value = "版本类型")
private String versionType; private String versionType;
@ApiModelProperty(value = "crc信息")
private String crcInfo;
@ApiModelProperty(value = ".bin文件") @ApiModelProperty(value = ".bin文件")
private String filePath; private String filePath;
@ApiModelProperty(value = "CRC校验")
private String crc;
} }

View File

@@ -0,0 +1,78 @@
package com.njcn.csdevice.pojo.vo;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.Date;
/**
* @author caozehui
* @data 2026-04-07
*/
@Data
public class DevVersionVO {
/**
* 设备Id
*/
private String id;
/**
* 设备名称
*/
private String name;
/**
* 版本号
*/
private String version;
/**
* 协议版本号
*/
private String protocolVersion;
/**
* 版本日期
*/
private Date versionDate;
/**
* 设备型号
*/
private String devModel;
/**
* 设备类型名称
*/
private String devTypeName;
/**
* ICD型号
*/
private String icd;
/**
* 所属工程
*/
private String associatedEngineering;
/**
* 所属项目
*/
private String associatedProject;
/**
* 装置启用状态(0:停用 1:启用)
*/
private Integer status;
/**
* 更新时间
*/
private LocalDateTime updateTime;
/**
* 修改人员
*/
private String updateBy;
}

View File

@@ -14,7 +14,9 @@ import com.njcn.csdevice.enums.DeviceOperate;
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO; import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
import com.njcn.csdevice.pojo.param.*; import com.njcn.csdevice.pojo.param.*;
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO; import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
import com.njcn.csdevice.pojo.po.CsLogsPO;
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO; import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
import com.njcn.csdevice.pojo.vo.DevVersionVO;
import com.njcn.csdevice.pojo.vo.DeviceManagerVO; import com.njcn.csdevice.pojo.vo.DeviceManagerVO;
import com.njcn.csdevice.pojo.vo.ProjectEquipmentVO; import com.njcn.csdevice.pojo.vo.ProjectEquipmentVO;
import com.njcn.csdevice.service.CsDevModelRelationService; import com.njcn.csdevice.service.CsDevModelRelationService;
@@ -28,6 +30,7 @@ import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.pojo.po.SysDicTreePO; import com.njcn.system.pojo.po.SysDicTreePO;
import com.njcn.web.advice.DeviceLog; import com.njcn.web.advice.DeviceLog;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -46,6 +49,7 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
/** /**
* Description: * Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html * 接口文档访问地址http://serverIP:port/swagger-ui.html
@@ -63,20 +67,20 @@ public class EquipmentDeliveryController extends BaseController {
private final CsEquipmentDeliveryService csEquipmentDeliveryService; private final CsEquipmentDeliveryService csEquipmentDeliveryService;
private final IMqttUserService mqttUserService; private final IMqttUserService mqttUserService;
private final CsDevModelRelationService csDevModelRelationService; private final CsDevModelRelationService csDevModelRelationService;
private final DictTreeFeignClient dictTreeFeignClient; private final DictTreeFeignClient dictTreeFeignClient;
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/addEquipmentDelivery") @PostMapping("/addEquipmentDelivery")
@ApiOperation("新增出厂设备") @ApiOperation("新增出厂设备")
@ApiImplicitParam(name = "csEquipmentDeliveryAddParm", value = "新增项目参数", required = true) @ApiImplicitParam(name = "csEquipmentDeliveryAddParm", value = "新增项目参数", required = true)
@DeviceLog(operateType = DeviceOperate.ADD) @DeviceLog(operateType = DeviceOperate.ADD)
public HttpResult<CsEquipmentDeliveryPO> addEquipmentDelivery(@RequestBody @Validated CsEquipmentDeliveryAddParm csEquipmentDeliveryAddParm){ public HttpResult<CsEquipmentDeliveryPO> addEquipmentDelivery(@RequestBody @Validated CsEquipmentDeliveryAddParm csEquipmentDeliveryAddParm) {
String methodDescribe = getMethodDescribe("addEquipmentDelivery"); String methodDescribe = getMethodDescribe("addEquipmentDelivery");
CsEquipmentDeliveryPO po = csEquipmentDeliveryService.save(csEquipmentDeliveryAddParm); CsEquipmentDeliveryPO po = csEquipmentDeliveryService.save(csEquipmentDeliveryAddParm);
if (Objects.nonNull(po)){ if (Objects.nonNull(po)) {
//查询mqtt用户名和密码是否存在 //查询mqtt用户名和密码是否存在
boolean result = mqttUserService.findMqttUser(csEquipmentDeliveryAddParm.getNdid()); boolean result = mqttUserService.findMqttUser(csEquipmentDeliveryAddParm.getNdid());
if (result){ if (result) {
//初始化装置mqtt连接信息(使用sha256加密) //初始化装置mqtt连接信息(使用sha256加密)
mqttUserService.insertMqttUser(csEquipmentDeliveryAddParm.getNdid()); mqttUserService.insertMqttUser(csEquipmentDeliveryAddParm.getNdid());
} }
@@ -88,7 +92,7 @@ public class EquipmentDeliveryController extends BaseController {
@PostMapping("/AuditEquipmentDelivery") @PostMapping("/AuditEquipmentDelivery")
@ApiOperation("删除出厂设备") @ApiOperation("删除出厂设备")
@DeviceLog(operateType = DeviceOperate.DELETE) @DeviceLog(operateType = DeviceOperate.DELETE)
public HttpResult<Boolean> AuditEquipmentDelivery(@RequestParam("id")String id ){ public HttpResult<Boolean> AuditEquipmentDelivery(@RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("AuditEquipmentDelivery"); String methodDescribe = getMethodDescribe("AuditEquipmentDelivery");
Boolean flag = csEquipmentDeliveryService.AuditEquipmentDelivery(id); Boolean flag = csEquipmentDeliveryService.AuditEquipmentDelivery(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
@@ -99,13 +103,13 @@ public class EquipmentDeliveryController extends BaseController {
@ApiOperation("修改出厂设备") @ApiOperation("修改出厂设备")
@DeviceLog(operateType = DeviceOperate.UPDATE) @DeviceLog(operateType = DeviceOperate.UPDATE)
@ApiImplicitParam(name = "csEquipmentDeliveryAuditParm", value = "新增项目参数", required = true) @ApiImplicitParam(name = "csEquipmentDeliveryAuditParm", value = "新增项目参数", required = true)
public HttpResult<Boolean> updateEquipmentDelivery(@RequestBody @Validated CsEquipmentDeliveryAuditParm csEquipmentDeliveryAuditParm ){ public HttpResult<Boolean> updateEquipmentDelivery(@RequestBody @Validated CsEquipmentDeliveryAuditParm csEquipmentDeliveryAuditParm) {
String methodDescribe = getMethodDescribe("updateEquipmentDelivery"); String methodDescribe = getMethodDescribe("updateEquipmentDelivery");
Boolean flag = csEquipmentDeliveryService.updateEquipmentDelivery(csEquipmentDeliveryAuditParm); Boolean flag = csEquipmentDeliveryService.updateEquipmentDelivery(csEquipmentDeliveryAuditParm);
if (flag){ if (flag) {
//查询mqtt用户名和密码是否存在 //查询mqtt用户名和密码是否存在
boolean result = mqttUserService.findMqttUser(csEquipmentDeliveryAuditParm.getNdid()); boolean result = mqttUserService.findMqttUser(csEquipmentDeliveryAuditParm.getNdid());
if (result){ if (result) {
//初始化装置mqtt连接信息(使用sha256加密) //初始化装置mqtt连接信息(使用sha256加密)
mqttUserService.insertMqttUser(csEquipmentDeliveryAuditParm.getNdid()); mqttUserService.insertMqttUser(csEquipmentDeliveryAuditParm.getNdid());
} }
@@ -117,9 +121,9 @@ public class EquipmentDeliveryController extends BaseController {
@PostMapping("/queryEquipmentByndid") @PostMapping("/queryEquipmentByndid")
@ApiOperation("通过ndid查询出厂设备") @ApiOperation("通过ndid查询出厂设备")
@ApiImplicitParam(name = "ndid", value = "网关识别码", required = true) @ApiImplicitParam(name = "ndid", value = "网关识别码", required = true)
public HttpResult<CsEquipmentDeliveryVO> queryEquipmentByndid(@RequestParam("ndid")String ndid){ public HttpResult<CsEquipmentDeliveryVO> queryEquipmentByndid(@RequestParam("ndid") String ndid) {
String methodDescribe = getMethodDescribe("queryEquipmentByndid"); String methodDescribe = getMethodDescribe("queryEquipmentByndid");
CsEquipmentDeliveryVO csEquipmentDeliveryVO = csEquipmentDeliveryService.queryEquipmentByndid (ndid); CsEquipmentDeliveryVO csEquipmentDeliveryVO = csEquipmentDeliveryService.queryEquipmentByndid(ndid);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, csEquipmentDeliveryVO, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, csEquipmentDeliveryVO, methodDescribe);
} }
@@ -127,9 +131,9 @@ public class EquipmentDeliveryController extends BaseController {
@PostMapping("/queryEquipmentByProject") @PostMapping("/queryEquipmentByProject")
@ApiOperation("通过项目查询出厂设备") @ApiOperation("通过项目查询出厂设备")
@ApiImplicitParam(name = "projectEquipmentQueryParm", value = "项目信息", required = true) @ApiImplicitParam(name = "projectEquipmentQueryParm", value = "项目信息", required = true)
public HttpResult<IPage<ProjectEquipmentVO>> queryEquipmentByProject(@RequestBody ProjectEquipmentQueryParm projectEquipmentQueryParm){ public HttpResult<IPage<ProjectEquipmentVO>> queryEquipmentByProject(@RequestBody ProjectEquipmentQueryParm projectEquipmentQueryParm) {
String methodDescribe = getMethodDescribe("queryEquipmentByProject"); String methodDescribe = getMethodDescribe("queryEquipmentByProject");
IPage<ProjectEquipmentVO> projectEquipmentVos = csEquipmentDeliveryService.queryEquipmentByProject(projectEquipmentQueryParm); IPage<ProjectEquipmentVO> projectEquipmentVos = csEquipmentDeliveryService.queryEquipmentByProject(projectEquipmentQueryParm);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, projectEquipmentVos, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, projectEquipmentVos, methodDescribe);
} }
@@ -141,9 +145,9 @@ public class EquipmentDeliveryController extends BaseController {
@ApiImplicitParam(name = "status", value = "状态", required = true) @ApiImplicitParam(name = "status", value = "状态", required = true)
}) })
@DeviceLog(operateType = DeviceOperate.UPDATESTATUSBYNDID) @DeviceLog(operateType = DeviceOperate.UPDATESTATUSBYNDID)
public HttpResult<Boolean> updateStatusBynDid(@RequestParam("nDId") String nDid,@RequestParam("status") Integer status){ public HttpResult<Boolean> updateStatusBynDid(@RequestParam("nDId") String nDid, @RequestParam("status") Integer status) {
String methodDescribe = getMethodDescribe("updateStatusBynDid"); String methodDescribe = getMethodDescribe("updateStatusBynDid");
csEquipmentDeliveryService.updateStatusBynDid(nDid,status); csEquipmentDeliveryService.updateStatusBynDid(nDid, status);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} }
@@ -151,7 +155,7 @@ public class EquipmentDeliveryController extends BaseController {
@PostMapping("/queryEquipmentById") @PostMapping("/queryEquipmentById")
@ApiOperation("设备查询通过id获取") @ApiOperation("设备查询通过id获取")
@ApiImplicitParam(name = "ids", value = "设备id集合", required = true) @ApiImplicitParam(name = "ids", value = "设备id集合", required = true)
public HttpResult<List<CsEquipmentDeliveryDTO>> queryEquipmentById(@RequestParam List<String> ids){ public HttpResult<List<CsEquipmentDeliveryDTO>> queryEquipmentById(@RequestParam List<String> ids) {
String methodDescribe = getMethodDescribe("queryEquipmentById"); String methodDescribe = getMethodDescribe("queryEquipmentById");
if (CollectionUtil.isEmpty(ids)) { if (CollectionUtil.isEmpty(ids)) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
@@ -171,7 +175,7 @@ public class EquipmentDeliveryController extends BaseController {
@PostMapping("/list") @PostMapping("/list")
@ApiOperation("出厂设备列表") @ApiOperation("出厂设备列表")
@ApiImplicitParam(name = "param", value = "查询参数", required = true) @ApiImplicitParam(name = "param", value = "查询参数", required = true)
public HttpResult<Page<CsEquipmentDeliveryVO>> list(@RequestBody CsEquipmentDeliveryQueryParm param){ public HttpResult<Page<CsEquipmentDeliveryVO>> list(@RequestBody CsEquipmentDeliveryQueryParm param) {
String methodDescribe = getMethodDescribe("list"); String methodDescribe = getMethodDescribe("list");
Page<CsEquipmentDeliveryVO> page = csEquipmentDeliveryService.list(param); Page<CsEquipmentDeliveryVO> page = csEquipmentDeliveryService.list(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
@@ -185,9 +189,9 @@ public class EquipmentDeliveryController extends BaseController {
@ApiImplicitParam(name = "type", value = "类型", required = true), @ApiImplicitParam(name = "type", value = "类型", required = true),
@ApiImplicitParam(name = "lineId", value = "监测点id", required = false) @ApiImplicitParam(name = "lineId", value = "监测点id", required = false)
}) })
public HttpResult<DeviceManagerVO> getDeviceData(@RequestParam String deviceId,@RequestParam String type,@RequestParam String lineId){ public HttpResult<DeviceManagerVO> getDeviceData(@RequestParam String deviceId, @RequestParam String type, @RequestParam String lineId) {
String methodDescribe = getMethodDescribe("getDeviceData"); String methodDescribe = getMethodDescribe("getDeviceData");
DeviceManagerVO vo = csEquipmentDeliveryService.getDeviceData(deviceId,type,lineId); DeviceManagerVO vo = csEquipmentDeliveryService.getDeviceData(deviceId, type, lineId);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, vo, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, vo, methodDescribe);
} }
@@ -200,9 +204,9 @@ public class EquipmentDeliveryController extends BaseController {
@ApiImplicitParam(name = "module", value = "模块个数", required = true) @ApiImplicitParam(name = "module", value = "模块个数", required = true)
}) })
@Deprecated @Deprecated
public HttpResult<Boolean> updateSoftInfoBynDid(@RequestParam("nDId") String nDid,@RequestParam("id") String id,@RequestParam("module") Integer module){ public HttpResult<Boolean> updateSoftInfoBynDid(@RequestParam("nDId") String nDid, @RequestParam("id") String id, @RequestParam("module") Integer module) {
String methodDescribe = getMethodDescribe("updateSoftInfoBynDid"); String methodDescribe = getMethodDescribe("updateSoftInfoBynDid");
csEquipmentDeliveryService.updateSoftInfoBynDid(nDid,id,module); csEquipmentDeliveryService.updateSoftInfoBynDid(nDid, id, module);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} }
@@ -210,9 +214,9 @@ public class EquipmentDeliveryController extends BaseController {
@PostMapping("/findDevByNDid") @PostMapping("/findDevByNDid")
@ApiOperation("通过nDid查询设备信息") @ApiOperation("通过nDid查询设备信息")
@ApiImplicitParam(name = "nDid", value = "网关识别码", required = true) @ApiImplicitParam(name = "nDid", value = "网关识别码", required = true)
public HttpResult<CsEquipmentDeliveryPO> findDevByNDid(@RequestParam("nDid")String nDid){ public HttpResult<CsEquipmentDeliveryPO> findDevByNDid(@RequestParam("nDid") String nDid) {
String methodDescribe = getMethodDescribe("findDevByNDid"); String methodDescribe = getMethodDescribe("findDevByNDid");
CsEquipmentDeliveryPO po = csEquipmentDeliveryService.findDevByNDid(nDid); CsEquipmentDeliveryPO po = csEquipmentDeliveryService.findDevByNDid(nDid);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
} }
@@ -225,13 +229,13 @@ public class EquipmentDeliveryController extends BaseController {
exportParams.setStyle(ExcelStyleUtil.class); exportParams.setStyle(ExcelStyleUtil.class);
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, DeviceExcelTemplete.class, new ArrayList<DeviceExcelTemplete>()); Workbook workbook = ExcelExportUtil.exportExcel(exportParams, DeviceExcelTemplete.class, new ArrayList<DeviceExcelTemplete>());
List<SysDicTreePO> deviceType = dictTreeFeignClient.queryByCodeList(DicDataTypeEnum.DEVICE_TYPE.getCode()).getData(); List<SysDicTreePO> deviceType = dictTreeFeignClient.queryByCodeList(DicDataTypeEnum.DEVICE_TYPE.getCode()).getData();
if(!CollectionUtils.isEmpty(deviceType)){ if (!CollectionUtils.isEmpty(deviceType)) {
List<String> collect = deviceType.get(0).getChildren().stream().map(SysDicTreePO::getName).collect(Collectors.toList()); List<String> collect = deviceType.get(0).getChildren().stream().map(SysDicTreePO::getName).collect(Collectors.toList());
ExcelUtil.selectList(workbook, 2, 2, collect.toArray(new String[]{})); ExcelUtil.selectList(workbook, 2, 2, collect.toArray(new String[]{}));
List<String> collect2 = deviceType.get(0).getChildren().stream().map(SysDicTreePO::getChildren).flatMap(Collection::stream).map(SysDicTreePO::getName).collect(Collectors.toList()); List<String> collect2 = deviceType.get(0).getChildren().stream().map(SysDicTreePO::getChildren).flatMap(Collection::stream).map(SysDicTreePO::getName).collect(Collectors.toList());
ExcelUtil.selectList(workbook, 3, 3, collect2.toArray(new String[]{})); ExcelUtil.selectList(workbook, 3, 3, collect2.toArray(new String[]{}));
} }
ExcelUtil.selectList(workbook, 4, 4, Stream.of("MQTT","CLD").collect(Collectors.toList()).toArray(new String[]{})); ExcelUtil.selectList(workbook, 4, 4, Stream.of("MQTT", "CLD").collect(Collectors.toList()).toArray(new String[]{}));
String fileName = "设备模板.xlsx"; String fileName = "设备模板.xlsx";
ExportParams exportExcel = new ExportParams("设备模板", "设备模板"); ExportParams exportExcel = new ExportParams("设备模板", "设备模板");
PoiUtil.exportFileByWorkbook(workbook, fileName, response); PoiUtil.exportFileByWorkbook(workbook, fileName, response);
@@ -244,11 +248,11 @@ public class EquipmentDeliveryController extends BaseController {
public HttpResult<String> importEquipment(@ApiParam(value = "文件", required = true) @RequestPart("file") MultipartFile file, HttpServletResponse response) { public HttpResult<String> importEquipment(@ApiParam(value = "文件", required = true) @RequestPart("file") MultipartFile file, HttpServletResponse response) {
String methodDescribe = getMethodDescribe("importEquipment"); String methodDescribe = getMethodDescribe("importEquipment");
List<CsEquipmentDeliveryPO> csEquipmentDeliveryPOS = csEquipmentDeliveryService.importEquipment(file, response); List<CsEquipmentDeliveryPO> csEquipmentDeliveryPOS = csEquipmentDeliveryService.importEquipment(file, response);
if (!CollectionUtils.isEmpty(csEquipmentDeliveryPOS)){ if (!CollectionUtils.isEmpty(csEquipmentDeliveryPOS)) {
csEquipmentDeliveryPOS.forEach(temp->{ csEquipmentDeliveryPOS.forEach(temp -> {
//查询mqtt用户名和密码是否存在 //查询mqtt用户名和密码是否存在
boolean result = mqttUserService.findMqttUser(temp.getNdid()); boolean result = mqttUserService.findMqttUser(temp.getNdid());
if (result){ if (result) {
//初始化装置mqtt连接信息(使用sha256加密) //初始化装置mqtt连接信息(使用sha256加密)
mqttUserService.insertMqttUser(temp.getNdid()); mqttUserService.insertMqttUser(temp.getNdid());
} }
@@ -260,18 +264,18 @@ public class EquipmentDeliveryController extends BaseController {
@ResponseBody @ResponseBody
@ApiOperation("联调完成") @ApiOperation("联调完成")
@PostMapping(value = "testcompletion") @PostMapping(value = "testcompletion")
public HttpResult<String> testCompletion(@RequestParam("deviceId") String deviceId,@RequestParam("type") Integer type,@RequestParam("remark") String remark){ public HttpResult<String> testCompletion(@RequestParam("deviceId") String deviceId, @RequestParam("type") Integer type, @RequestParam("remark") String remark) {
String methodDescribe = getMethodDescribe("testCompletion"); String methodDescribe = getMethodDescribe("testCompletion");
csEquipmentDeliveryService.testCompletion(deviceId,type, remark); csEquipmentDeliveryService.testCompletion(deviceId, type, remark);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} }
@ResponseBody @ResponseBody
@ApiOperation("取消联调") @ApiOperation("取消联调")
@PostMapping(value = "deleteTest") @PostMapping(value = "deleteTest")
public HttpResult<String> deleteTest(@RequestParam("deviceId") String deviceId,@RequestParam("type") Integer type,@RequestParam("remark") String remark){ public HttpResult<String> deleteTest(@RequestParam("deviceId") String deviceId, @RequestParam("type") Integer type, @RequestParam("remark") String remark) {
String methodDescribe = getMethodDescribe("deleteTest"); String methodDescribe = getMethodDescribe("deleteTest");
csEquipmentDeliveryService.deleteTest(deviceId,type, remark); csEquipmentDeliveryService.deleteTest(deviceId, type, remark);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} }
@@ -283,9 +287,9 @@ public class EquipmentDeliveryController extends BaseController {
@ApiImplicitParam(name = "id", value = "软件信息id", required = true) @ApiImplicitParam(name = "id", value = "软件信息id", required = true)
}) })
@ApiIgnore @ApiIgnore
public HttpResult<String> updateSoftInfo(@RequestParam("nDid") String nDid,@RequestParam("id") String id){ public HttpResult<String> updateSoftInfo(@RequestParam("nDid") String nDid, @RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("updateSoftInfo"); String methodDescribe = getMethodDescribe("updateSoftInfo");
csEquipmentDeliveryService.updateSoftInfo(nDid,id); csEquipmentDeliveryService.updateSoftInfo(nDid, id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} }
@@ -297,9 +301,9 @@ public class EquipmentDeliveryController extends BaseController {
@ApiImplicitParam(name = "number", value = "模块个数", required = true) @ApiImplicitParam(name = "number", value = "模块个数", required = true)
}) })
@ApiIgnore @ApiIgnore
public HttpResult<String> updateModuleNumber(@RequestParam("nDid") String nDid,@RequestParam("number") Integer number){ public HttpResult<String> updateModuleNumber(@RequestParam("nDid") String nDid, @RequestParam("number") Integer number) {
String methodDescribe = getMethodDescribe("updateModuleNumber"); String methodDescribe = getMethodDescribe("updateModuleNumber");
csEquipmentDeliveryService.updateModuleNumber(nDid,number); csEquipmentDeliveryService.updateModuleNumber(nDid, number);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} }
@@ -307,7 +311,7 @@ public class EquipmentDeliveryController extends BaseController {
@PostMapping("/rebootDevice") @PostMapping("/rebootDevice")
@ApiOperation("重启设备") @ApiOperation("重启设备")
@ApiImplicitParam(name = "nDid", value = "nDid", required = true) @ApiImplicitParam(name = "nDid", value = "nDid", required = true)
public HttpResult<String> rebootDevice(@RequestParam("nDid") String nDid){ public HttpResult<String> rebootDevice(@RequestParam("nDid") String nDid) {
String methodDescribe = getMethodDescribe("rebootDevice"); String methodDescribe = getMethodDescribe("rebootDevice");
boolean result = csEquipmentDeliveryService.rebootDevice(nDid); boolean result = csEquipmentDeliveryService.rebootDevice(nDid);
if (result) { if (result) {
@@ -320,7 +324,7 @@ public class EquipmentDeliveryController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getAll") @PostMapping("/getAll")
@ApiOperation("获取所有装置") @ApiOperation("获取所有装置")
public HttpResult<List<CsEquipmentDeliveryPO>> getAll(){ public HttpResult<List<CsEquipmentDeliveryPO>> getAll() {
String methodDescribe = getMethodDescribe("getAll"); String methodDescribe = getMethodDescribe("getAll");
List<CsEquipmentDeliveryPO> result = csEquipmentDeliveryService.getAll(); List<CsEquipmentDeliveryPO> result = csEquipmentDeliveryService.getAll();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
@@ -329,7 +333,7 @@ public class EquipmentDeliveryController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/judgeDevModel") @PostMapping("/judgeDevModel")
@ApiOperation("判断设备型号") @ApiOperation("判断设备型号")
public HttpResult<Boolean> judgeDevModel(@RequestParam("nDid") String nDid){ public HttpResult<Boolean> judgeDevModel(@RequestParam("nDid") String nDid) {
String methodDescribe = getMethodDescribe("judgeDevModel"); String methodDescribe = getMethodDescribe("judgeDevModel");
boolean result = csEquipmentDeliveryService.judgeDevModel(nDid); boolean result = csEquipmentDeliveryService.judgeDevModel(nDid);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
@@ -338,7 +342,7 @@ public class EquipmentDeliveryController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getDevByLineId") @PostMapping("/getDevByLineId")
@ApiOperation("根据监测点id查询装置信息") @ApiOperation("根据监测点id查询装置信息")
public HttpResult<CsEquipmentDeliveryPO> getDevByLineId(@RequestParam("lineId") String lineId){ public HttpResult<CsEquipmentDeliveryPO> getDevByLineId(@RequestParam("lineId") String lineId) {
String methodDescribe = getMethodDescribe("getDevByLineId"); String methodDescribe = getMethodDescribe("getDevByLineId");
CsEquipmentDeliveryPO po = csEquipmentDeliveryService.getDevByLineId(lineId); CsEquipmentDeliveryPO po = csEquipmentDeliveryService.getDevByLineId(lineId);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
@@ -349,7 +353,7 @@ public class EquipmentDeliveryController extends BaseController {
@ApiOperation("新增云前置设备") @ApiOperation("新增云前置设备")
@ApiImplicitParam(name = "param", value = "参数", required = true) @ApiImplicitParam(name = "param", value = "参数", required = true)
@DeviceLog(operateType = DeviceOperate.ADD) @DeviceLog(operateType = DeviceOperate.ADD)
public HttpResult<CsEquipmentDeliveryPO> addCldDev(@RequestBody @Validated CsEquipmentDeliveryAddParm param){ public HttpResult<CsEquipmentDeliveryPO> addCldDev(@RequestBody @Validated CsEquipmentDeliveryAddParm param) {
String methodDescribe = getMethodDescribe("addCldDev"); String methodDescribe = getMethodDescribe("addCldDev");
CsEquipmentDeliveryPO po = csEquipmentDeliveryService.saveCld(param); CsEquipmentDeliveryPO po = csEquipmentDeliveryService.saveCld(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
@@ -360,7 +364,7 @@ public class EquipmentDeliveryController extends BaseController {
@ApiOperation("删除云前置设备") @ApiOperation("删除云前置设备")
@ApiImplicitParam(name = "id", value = "id", required = true) @ApiImplicitParam(name = "id", value = "id", required = true)
@DeviceLog(operateType = DeviceOperate.DELETE) @DeviceLog(operateType = DeviceOperate.DELETE)
public HttpResult<Boolean> delCldDev(@RequestParam("id") String id){ public HttpResult<Boolean> delCldDev(@RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("delCldDev"); String methodDescribe = getMethodDescribe("delCldDev");
boolean result = csEquipmentDeliveryService.delCldDev(id); boolean result = csEquipmentDeliveryService.delCldDev(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
@@ -371,7 +375,7 @@ public class EquipmentDeliveryController extends BaseController {
@ApiOperation("修改云前置设备") @ApiOperation("修改云前置设备")
@ApiImplicitParam(name = "param", value = "参数", required = true) @ApiImplicitParam(name = "param", value = "参数", required = true)
@DeviceLog(operateType = DeviceOperate.UPDATE) @DeviceLog(operateType = DeviceOperate.UPDATE)
public HttpResult<Boolean> updateCldDev(@RequestBody @Validated CsEquipmentDeliveryAuditParm param){ public HttpResult<Boolean> updateCldDev(@RequestBody @Validated CsEquipmentDeliveryAuditParm param) {
String methodDescribe = getMethodDescribe("updateCldDev"); String methodDescribe = getMethodDescribe("updateCldDev");
boolean result = csEquipmentDeliveryService.updateCldDev(param); boolean result = csEquipmentDeliveryService.updateCldDev(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
@@ -385,9 +389,9 @@ public class EquipmentDeliveryController extends BaseController {
@ApiImplicitParam(name = "processNo", value = "进程号", required = true) @ApiImplicitParam(name = "processNo", value = "进程号", required = true)
}) })
@ApiIgnore @ApiIgnore
public HttpResult<Boolean> updateCldDevStatus(@RequestParam("nodeId") String nodeId, @RequestParam("processNo") Integer processNo){ public HttpResult<Boolean> updateCldDevStatus(@RequestParam("nodeId") String nodeId, @RequestParam("processNo") Integer processNo) {
String methodDescribe = getMethodDescribe("updateCldDevStatus"); String methodDescribe = getMethodDescribe("updateCldDevStatus");
csEquipmentDeliveryService.updateCldDevStatus(nodeId,processNo); csEquipmentDeliveryService.updateCldDevStatus(nodeId, processNo);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} }
@@ -395,14 +399,14 @@ public class EquipmentDeliveryController extends BaseController {
@PostMapping("/flipCldDevStatus") @PostMapping("/flipCldDevStatus")
@ApiOperation("云前置设备状态翻转") @ApiOperation("云前置设备状态翻转")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "date", value = "时间", required = true), @ApiImplicitParam(name = "date", value = "时间", required = true),
@ApiImplicitParam(name = "devId", value = "设备id", required = true), @ApiImplicitParam(name = "devId", value = "设备id", required = true),
@ApiImplicitParam(name = "status", value = "状态", required = true) @ApiImplicitParam(name = "status", value = "状态", required = true)
}) })
@ApiIgnore @ApiIgnore
public HttpResult<Boolean> flipCldDevStatus(@RequestParam("date") String date, @RequestParam("devId") String devId, @RequestParam("status") Integer status){ public HttpResult<Boolean> flipCldDevStatus(@RequestParam("date") String date, @RequestParam("devId") String devId, @RequestParam("status") Integer status) {
String methodDescribe = getMethodDescribe("flipCldDevStatus"); String methodDescribe = getMethodDescribe("flipCldDevStatus");
csEquipmentDeliveryService.flipCldDevStatus(date,devId,status); csEquipmentDeliveryService.flipCldDevStatus(date, devId, status);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} }
@@ -410,10 +414,22 @@ public class EquipmentDeliveryController extends BaseController {
@PostMapping("/getRunPortableDev") @PostMapping("/getRunPortableDev")
@ApiOperation("获取用户未绑定的在运的便携式设备") @ApiOperation("获取用户未绑定的在运的便携式设备")
@ApiImplicitParam(name = "userId", value = "用户id", required = true) @ApiImplicitParam(name = "userId", value = "用户id", required = true)
public HttpResult<List<CsEquipmentDeliveryPO>> getRunPortableDev(@RequestParam("userId") String userId){ public HttpResult<List<CsEquipmentDeliveryPO>> getRunPortableDev(@RequestParam("userId") String userId) {
String methodDescribe = getMethodDescribe("getRunPortableDev"); String methodDescribe = getMethodDescribe("getRunPortableDev");
List<CsEquipmentDeliveryPO> result = csEquipmentDeliveryService.getRunPortableDev(userId); List<CsEquipmentDeliveryPO> result = csEquipmentDeliveryService.getRunPortableDev(userId);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
} }
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/version/page")
@ApiOperation("查询设备版本信息")
@ApiImplicitParam(name = "baseParam", value = "查询日志参数", required = true)
public HttpResult<IPage<DevVersionVO>> versionPage(@RequestBody BaseParam baseParam) {
String methodDescribe = getMethodDescribe("versionPage");
IPage<DevVersionVO> list = csEquipmentDeliveryService.versionPage(baseParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
} }

View File

@@ -48,5 +48,13 @@ public interface CsEdDataService extends IService<CsEdDataPO> {
* @author: xuyang * @author: xuyang
*/ */
CsEdDataVO findByDevTypeId(String devType); CsEdDataVO findByDevTypeId(String devType);
/**
* @Description: 根据装置型号和版本号获取装置类型
* @param devTypeId 装置型号
* @param versionNo 版本号
* @return
*/
CsEdDataPO findByDevTypeIdAndVersionNo(String devTypeId, String versionNo);
} }

View File

@@ -3,14 +3,15 @@ package com.njcn.csdevice.service;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryAddParm; import com.njcn.csdevice.pojo.param.*;
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryAuditParm;
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryQueryParm;
import com.njcn.csdevice.pojo.param.ProjectEquipmentQueryParm;
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO; import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
import com.njcn.csdevice.pojo.po.CsLogsPO;
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO; import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
import com.njcn.csdevice.pojo.vo.DevVersionVO;
import com.njcn.csdevice.pojo.vo.DeviceManagerVO; import com.njcn.csdevice.pojo.vo.DeviceManagerVO;
import com.njcn.csdevice.pojo.vo.ProjectEquipmentVO; import com.njcn.csdevice.pojo.vo.ProjectEquipmentVO;
import com.njcn.web.pojo.param.BaseParam;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@@ -195,4 +196,5 @@ public interface CsEquipmentDeliveryService extends IService<CsEquipmentDelivery
List<CsEquipmentDeliveryPO> getRunPortableDev(String userId); List<CsEquipmentDeliveryPO> getRunPortableDev(String userId);
IPage<DevVersionVO> versionPage(BaseParam baseParam);
} }

View File

@@ -1,5 +1,6 @@
package com.njcn.csdevice.service.impl; package com.njcn.csdevice.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -40,33 +41,34 @@ public class CsEdDataServiceImpl extends ServiceImpl<CsEdDataMapper, CsEdDataPO>
@Override @Override
@Transactional(rollbackFor = {Exception.class}) @Transactional(rollbackFor = {Exception.class})
public boolean addEdData(CsEdDataAddParm csEdDataAddParm) { public boolean addEdData(CsEdDataAddParm csEdDataAddParm) {
CsEdDataPO csEdDataPO = new CsEdDataPO (); CsEdDataPO csEdDataPO = new CsEdDataPO();
BeanUtils.copyProperties (csEdDataAddParm, csEdDataPO); BeanUtils.copyProperties(csEdDataAddParm, csEdDataPO);
String filePath = fileStorageUtil.uploadMultipart (csEdDataAddParm.getFile (), OssPath.EDDATA); String remoteDir = OssPath.EDDATA + csEdDataAddParm.getDevTypeName() + StrUtil.SLASH + csEdDataAddParm.getVersionNo() + StrUtil.SLASH;
csEdDataPO.setFilePath (filePath); String filePath = fileStorageUtil.uploadMultipart(csEdDataAddParm.getFile(), remoteDir);
csEdDataPO.setStatus ("1"); csEdDataPO.setFilePath(filePath);
boolean save = this.save (csEdDataPO); csEdDataPO.setStatus("1");
boolean save = this.save(csEdDataPO);
return save; return save;
} }
@Override @Override
@Transactional(rollbackFor = {Exception.class}) @Transactional(rollbackFor = {Exception.class})
public Boolean auditEdData(CsEdDataAuditParm csEdDataAuditParm) { public Boolean auditEdData(CsEdDataAuditParm csEdDataAuditParm) {
CsEdDataPO csEdDataPO = new CsEdDataPO (); CsEdDataPO csEdDataPO = new CsEdDataPO();
BeanUtils.copyProperties (csEdDataAuditParm, csEdDataPO); BeanUtils.copyProperties(csEdDataAuditParm, csEdDataPO);
if(!Objects.isNull (csEdDataAuditParm.getFile ())){ if (!Objects.isNull(csEdDataAuditParm.getFile())) {
String filePath = fileStorageUtil.uploadMultipart (csEdDataAuditParm.getFile (), OssPath.EDDATA); String filePath = fileStorageUtil.uploadMultipart(csEdDataAuditParm.getFile(), OssPath.EDDATA);
csEdDataPO.setFilePath (filePath); csEdDataPO.setFilePath(filePath);
} }
boolean b = this.updateById (csEdDataPO); boolean b = this.updateById(csEdDataPO);
return b; return b;
} }
@Override @Override
public IPage<CsEdDataVO> queryEdDataPage(CsEdDataQueryParm csEdDataQueryParm) { public IPage<CsEdDataVO> queryEdDataPage(CsEdDataQueryParm csEdDataQueryParm) {
Page<CsEdDataVO> returnpage = new Page<> (csEdDataQueryParm.getPageNum ( ), csEdDataQueryParm.getPageSize ( )); Page<CsEdDataVO> returnpage = new Page<>(csEdDataQueryParm.getPageNum(), csEdDataQueryParm.getPageSize());
returnpage = this.getBaseMapper ().getPage(returnpage,csEdDataQueryParm); returnpage = this.getBaseMapper().getPage(returnpage, csEdDataQueryParm);
return returnpage; return returnpage;
} }
@@ -74,15 +76,21 @@ public class CsEdDataServiceImpl extends ServiceImpl<CsEdDataMapper, CsEdDataPO>
public CsEdDataVO findByDevTypeId(String devType) { public CsEdDataVO findByDevTypeId(String devType) {
CsEdDataPO csEdDataPo = new CsEdDataPO(); CsEdDataPO csEdDataPo = new CsEdDataPO();
LambdaQueryWrapper<CsEdDataPO> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsEdDataPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEdDataPO::getDevType,devType); lambdaQueryWrapper.eq(CsEdDataPO::getDevType, devType);
lambdaQueryWrapper.eq(CsEdDataPO::getStatus,1); lambdaQueryWrapper.eq(CsEdDataPO::getStatus, 1);
List<CsEdDataPO> list = this.baseMapper.selectList(lambdaQueryWrapper); List<CsEdDataPO> list = this.baseMapper.selectList(lambdaQueryWrapper);
if (!CollectionUtils.isEmpty(list)){ if (!CollectionUtils.isEmpty(list)) {
csEdDataPo = list.get(0); csEdDataPo = list.get(0);
} }
CsEdDataVO csEdDataVo = new CsEdDataVO(); CsEdDataVO csEdDataVo = new CsEdDataVO();
BeanUtils.copyProperties(csEdDataPo,csEdDataVo); BeanUtils.copyProperties(csEdDataPo, csEdDataVo);
return csEdDataVo; return csEdDataVo;
} }
public CsEdDataPO findByDevTypeIdAndVersionNo(String devTypeId, String versionNo) {
return this.lambdaQuery().eq(CsEdDataPO::getDevType, devTypeId)
.eq(CsEdDataPO::getVersionNo, versionNo)
.eq(CsEdDataPO::getStatus, 1).one();
}
} }

View File

@@ -5,11 +5,13 @@ import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams; import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.ImportParams; import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DatePattern;
import cn.hutool.core.text.StrPool; import cn.hutool.core.text.StrPool;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.client.naming.utils.CollectionUtils; import com.alibaba.nacos.client.naming.utils.CollectionUtils;
@@ -35,6 +37,7 @@ import com.njcn.csdevice.pojo.dto.PqsCommunicateDto;
import com.njcn.csdevice.pojo.param.*; import com.njcn.csdevice.pojo.param.*;
import com.njcn.csdevice.pojo.po.*; import com.njcn.csdevice.pojo.po.*;
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO; import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
import com.njcn.csdevice.pojo.vo.DevVersionVO;
import com.njcn.csdevice.pojo.vo.DeviceManagerVO; import com.njcn.csdevice.pojo.vo.DeviceManagerVO;
import com.njcn.csdevice.pojo.vo.ProjectEquipmentVO; import com.njcn.csdevice.pojo.vo.ProjectEquipmentVO;
import com.njcn.csdevice.service.*; import com.njcn.csdevice.service.*;
@@ -55,6 +58,8 @@ import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.pojo.po.SysDicTreePO; import com.njcn.system.pojo.po.SysDicTreePO;
import com.njcn.system.pojo.vo.DictTreeVO; import com.njcn.system.pojo.vo.DictTreeVO;
import com.njcn.user.enums.AppRoleEnum; import com.njcn.user.enums.AppRoleEnum;
import com.njcn.web.factory.PageFactory;
import com.njcn.web.pojo.param.BaseParam;
import com.njcn.web.utils.RequestUtil; import com.njcn.web.utils.RequestUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
@@ -76,8 +81,8 @@ import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
*
* Description: * Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html * 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2023/3/30 16:23【需求编号】 * Date: 2023/3/30 16:23【需求编号】
@@ -87,7 +92,7 @@ import java.util.stream.Collectors;
*/ */
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliveryMapper, CsEquipmentDeliveryPO> implements CsEquipmentDeliveryService{ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliveryMapper, CsEquipmentDeliveryPO> implements CsEquipmentDeliveryService {
private final CsDevModelRelationService csDevModelRelationService; private final CsDevModelRelationService csDevModelRelationService;
private final ICsDataSetService csDataSetService; private final ICsDataSetService csDataSetService;
private final ICsLedgerService csLedgerService; private final ICsLedgerService csLedgerService;
@@ -99,7 +104,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
private final DicDataFeignClient dicDataFeignClient; private final DicDataFeignClient dicDataFeignClient;
private final FileStorageUtil fileStorageUtil; private final FileStorageUtil fileStorageUtil;
private final DictTreeFeignClient dictTreeFeignClient; private final DictTreeFeignClient dictTreeFeignClient;
private final CsEquipmentProcessPOService csEquipmentProcessPOService; private final CsEquipmentProcessPOService csEquipmentProcessPOService;
private final AskDeviceDataFeignClient askDeviceDataFeignClient; private final AskDeviceDataFeignClient askDeviceDataFeignClient;
private final RedisUtil redisUtil; private final RedisUtil redisUtil;
private final CsSoftInfoMapper csSoftInfoMapper; private final CsSoftInfoMapper csSoftInfoMapper;
@@ -112,15 +117,19 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
private final CsTerminalLogsMapper csTerminalLogsMapper; private final CsTerminalLogsMapper csTerminalLogsMapper;
private final ICsCommunicateService csCommunicateService; private final ICsCommunicateService csCommunicateService;
private final ICsUserPinsService csUserPinsService; private final ICsUserPinsService csUserPinsService;
private final CsEngineeringService csEngineeringService;
private final AppProjectService appProjectService;
private final CsEdDataService csEdDataService;
private final ICsSoftInfoService csSoftInfoService;
private final EngineeringFeignClient engineeringFeignClient; private final EngineeringFeignClient engineeringFeignClient;
private final EventUserFeignClient eventUserFeignClient; private final EventUserFeignClient eventUserFeignClient;
@Override @Override
public void refreshDeviceDataCache() { public void refreshDeviceDataCache() {
LambdaQueryWrapper<CsEquipmentDeliveryPO> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsEquipmentDeliveryPO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.ne(CsEquipmentDeliveryPO::getRunStatus,0); queryWrapper.ne(CsEquipmentDeliveryPO::getRunStatus, 0);
List<CsEquipmentDeliveryPO> deliveryPOS = this.list(queryWrapper); List<CsEquipmentDeliveryPO> deliveryPOS = this.list(queryWrapper);
redisUtil.saveByKey(AppRedisKey.DEVICE_LIST,deliveryPOS); redisUtil.saveByKey(AppRedisKey.DEVICE_LIST, deliveryPOS);
} }
@Override @Override
@@ -132,17 +141,17 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
.ne(CsEquipmentDeliveryPO::getRunStatus, 0) .ne(CsEquipmentDeliveryPO::getRunStatus, 0)
.eq(CsEquipmentDeliveryPO::getDevAccessMethod, "MQTT") .eq(CsEquipmentDeliveryPO::getDevAccessMethod, "MQTT")
.list(); .list();
if(CollUtil.isNotEmpty(one)){ if (CollUtil.isNotEmpty(one)) {
throw new BusinessException ("设备名称不能重复"); throw new BusinessException("设备名称不能重复");
} }
StringUtil.containsSpecialCharacters(csEquipmentDeliveryAddParm.getNdid()); StringUtil.containsSpecialCharacters(csEquipmentDeliveryAddParm.getNdid());
CsEquipmentDeliveryPO po = this.queryEquipmentPOByndid (csEquipmentDeliveryAddParm.getNdid()); CsEquipmentDeliveryPO po = this.queryEquipmentPOByndid(csEquipmentDeliveryAddParm.getNdid());
if(!Objects.isNull (po)){ if (!Objects.isNull(po)) {
throw new BusinessException (AlgorithmResponseEnum.NDID_ERROR); throw new BusinessException(AlgorithmResponseEnum.NDID_ERROR);
} }
CsEquipmentDeliveryPO csEquipmentDeliveryPo = new CsEquipmentDeliveryPO(); CsEquipmentDeliveryPO csEquipmentDeliveryPo = new CsEquipmentDeliveryPO();
BeanUtils.copyProperties (csEquipmentDeliveryAddParm,csEquipmentDeliveryPo); BeanUtils.copyProperties(csEquipmentDeliveryAddParm, csEquipmentDeliveryPo);
csEquipmentDeliveryPo.setStatus (1); csEquipmentDeliveryPo.setStatus(1);
csEquipmentDeliveryPo.setRunStatus(1); csEquipmentDeliveryPo.setRunStatus(1);
csEquipmentDeliveryPo.setUsageStatus(1); csEquipmentDeliveryPo.setUsageStatus(1);
// String code = dictTreeFeignClient.queryById(csEquipmentDeliveryAddParm.getDevType()).getData().getCode(); // String code = dictTreeFeignClient.queryById(csEquipmentDeliveryAddParm.getDevType()).getData().getCode();
@@ -182,36 +191,36 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
CsEquipmentDeliveryPO one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getId, id).one(); CsEquipmentDeliveryPO one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getId, id).one();
//物理删除 //物理删除
QueryWrapper<CsEquipmentDeliveryPO> wrapper = new QueryWrapper(); QueryWrapper<CsEquipmentDeliveryPO> wrapper = new QueryWrapper();
wrapper.eq ("id", id); wrapper.eq("id", id);
boolean update = this.remove (wrapper); boolean update = this.remove(wrapper);
//删除deviceuser表里的设备游客数据设备,删除监测点相关数据 //删除deviceuser表里的设备游客数据设备,删除监测点相关数据
List<CsLedger> list = csLedgerService.lambdaQuery().eq(CsLedger::getPid, id).list(); List<CsLedger> list = csLedgerService.lambdaQuery().eq(CsLedger::getPid, id).list();
if(!CollectionUtils.isEmpty(list)){ if (!CollectionUtils.isEmpty(list)) {
List<String> collect = list.stream().map(CsLedger::getId).collect(Collectors.toList()); List<String> collect = list.stream().map(CsLedger::getId).collect(Collectors.toList());
LambdaQueryWrapper<CsLinePO> csLinePOLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsLinePO> csLinePOLambdaQueryWrapper = new LambdaQueryWrapper<>();
csLinePOLambdaQueryWrapper.in(CsLinePO::getLineId,collect); csLinePOLambdaQueryWrapper.in(CsLinePO::getLineId, collect);
csLinePOService.remove(csLinePOLambdaQueryWrapper); csLinePOService.remove(csLinePOLambdaQueryWrapper);
QueryWrapper<AppLineTopologyDiagramPO> appLineTopologyDiagramPOQueryWrapper = new QueryWrapper<>(); QueryWrapper<AppLineTopologyDiagramPO> appLineTopologyDiagramPOQueryWrapper = new QueryWrapper<>();
appLineTopologyDiagramPOQueryWrapper.clear(); appLineTopologyDiagramPOQueryWrapper.clear();
appLineTopologyDiagramPOQueryWrapper.in("line_id",collect); appLineTopologyDiagramPOQueryWrapper.in("line_id", collect);
appLineTopologyDiagramService.remove(appLineTopologyDiagramPOQueryWrapper); appLineTopologyDiagramService.remove(appLineTopologyDiagramPOQueryWrapper);
// appLineTopologyDiagramService.lambdaUpdate().in(AppLineTopologyDiagramPO::getLineId,collect).set(AppLineTopologyDiagramPO::getStatus,0).update(); // appLineTopologyDiagramService.lambdaUpdate().in(AppLineTopologyDiagramPO::getLineId,collect).set(AppLineTopologyDiagramPO::getStatus,0).update();
} }
LambdaQueryWrapper<CsLedger> csLedgerLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsLedger> csLedgerLambdaQueryWrapper = new LambdaQueryWrapper<>();
csLedgerLambdaQueryWrapper.clear(); csLedgerLambdaQueryWrapper.clear();
csLedgerLambdaQueryWrapper.eq(CsLedger::getId,id); csLedgerLambdaQueryWrapper.eq(CsLedger::getId, id);
csLedgerService.remove(csLedgerLambdaQueryWrapper); csLedgerService.remove(csLedgerLambdaQueryWrapper);
csLedgerLambdaQueryWrapper.clear(); csLedgerLambdaQueryWrapper.clear();
csLedgerLambdaQueryWrapper.eq(CsLedger::getPid,id); csLedgerLambdaQueryWrapper.eq(CsLedger::getPid, id);
csLedgerService.remove(csLedgerLambdaQueryWrapper); csLedgerService.remove(csLedgerLambdaQueryWrapper);
csDeviceUserPOService.lambdaUpdate().eq(CsDeviceUserPO::getDeviceId,id).set(CsDeviceUserPO::getStatus,0).update(); csDeviceUserPOService.lambdaUpdate().eq(CsDeviceUserPO::getDeviceId, id).set(CsDeviceUserPO::getStatus, 0).update();
QueryWrapper<CsTouristDataPO> queryWrap = new QueryWrapper<>(); QueryWrapper<CsTouristDataPO> queryWrap = new QueryWrapper<>();
queryWrap.eq("device_id",id); queryWrap.eq("device_id", id);
csTouristDataPOService.getBaseMapper().delete(queryWrap); csTouristDataPOService.getBaseMapper().delete(queryWrap);
/*后续徐那边做处理*/ /*后续徐那边做处理*/
// CsEquipmentDeliveryPO csEquipmentDeliveryPO = this.getBaseMapper().selectById(id); // CsEquipmentDeliveryPO csEquipmentDeliveryPO = this.getBaseMapper().selectById(id);
// mqttUserService.deleteUser(csEquipmentDeliveryPO.getNdid()); // mqttUserService.deleteUser(csEquipmentDeliveryPO.getNdid());
csDevModelRelationService.lambdaUpdate().eq(CsDevModelRelationPO::getDevId,id).set(CsDevModelRelationPO::getStatus,0).update(); csDevModelRelationService.lambdaUpdate().eq(CsDevModelRelationPO::getDevId, id).set(CsDevModelRelationPO::getStatus, 0).update();
if (update) { if (update) {
refreshDeviceDataCache(); refreshDeviceDataCache();
} }
@@ -221,10 +230,11 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
@Override @Override
public CsEquipmentDeliveryVO queryEquipmentByndid(String ndid) { public CsEquipmentDeliveryVO queryEquipmentByndid(String ndid) {
CsEquipmentDeliveryVO result = new CsEquipmentDeliveryVO(); CsEquipmentDeliveryVO result = new CsEquipmentDeliveryVO();
CsEquipmentDeliveryPO csEquipmentDeliveryPO = queryEquipmentPOByndid (ndid); CsEquipmentDeliveryPO csEquipmentDeliveryPO = queryEquipmentPOByndid(ndid);
if(Objects.isNull (csEquipmentDeliveryPO)){ if (Objects.isNull(csEquipmentDeliveryPO)) {
return result; return result;
} }
BeanUtils.copyProperties(csEquipmentDeliveryPO, result);
BeanUtils.copyProperties (csEquipmentDeliveryPO,result); BeanUtils.copyProperties (csEquipmentDeliveryPO,result);
if(!Objects.isNull (csEquipmentDeliveryPO.getAssociatedEngineering()) && !Objects.equals(csEquipmentDeliveryPO.getAssociatedEngineering(),"")) { if(!Objects.isNull (csEquipmentDeliveryPO.getAssociatedEngineering()) && !Objects.equals(csEquipmentDeliveryPO.getAssociatedEngineering(),"")) {
result.setAssociatedEngineeringName(csLedgerService.findDataById(csEquipmentDeliveryPO.getAssociatedEngineering()).getName()); result.setAssociatedEngineeringName(csLedgerService.findDataById(csEquipmentDeliveryPO.getAssociatedEngineering()).getName());
@@ -237,20 +247,20 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
public CsEquipmentDeliveryPO queryEquipmentPOByndid(String ndid) { public CsEquipmentDeliveryPO queryEquipmentPOByndid(String ndid) {
QueryWrapper<CsEquipmentDeliveryPO> wrapper = new QueryWrapper(); QueryWrapper<CsEquipmentDeliveryPO> wrapper = new QueryWrapper();
wrapper.eq ("ndid", ndid); wrapper.eq("ndid", ndid);
wrapper.ne("run_status",0); wrapper.ne("run_status", 0);
CsEquipmentDeliveryPO csEquipmentDeliveryPO = this.baseMapper.selectOne (wrapper); CsEquipmentDeliveryPO csEquipmentDeliveryPO = this.baseMapper.selectOne(wrapper);
return csEquipmentDeliveryPO; return csEquipmentDeliveryPO;
} }
@Override @Override
public IPage<ProjectEquipmentVO> queryEquipmentByProject(ProjectEquipmentQueryParm projectEquipmentQueryParm) { public IPage<ProjectEquipmentVO> queryEquipmentByProject(ProjectEquipmentQueryParm projectEquipmentQueryParm) {
Page<ProjectEquipmentVO> returnpage = new Page<> (projectEquipmentQueryParm.getPageNum ( ), projectEquipmentQueryParm.getPageSize ( )); Page<ProjectEquipmentVO> returnpage = new Page<>(projectEquipmentQueryParm.getPageNum(), projectEquipmentQueryParm.getPageSize());
List<String> device = roleEngineerDevService.getDevice(); List<String> device = roleEngineerDevService.getDevice();
if(CollectionUtils.isEmpty(device)){ if (CollectionUtils.isEmpty(device)) {
return returnpage; return returnpage;
} }
Page<ProjectEquipmentVO> list = this.baseMapper.queryProjectEquipmentVO(returnpage,projectEquipmentQueryParm,device); Page<ProjectEquipmentVO> list = this.baseMapper.queryProjectEquipmentVO(returnpage, projectEquipmentQueryParm, device);
//根据设备id获取监测点id集合 //根据设备id获取监测点id集合
List<CsLinePO> lineIds = csLinePOService.getLineByDev(device); List<CsLinePO> lineIds = csLinePOService.getLineByDev(device);
//根据设备获取当日是否存在未读取的暂态事件 //根据设备获取当日是否存在未读取的暂态事件
@@ -315,8 +325,8 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
StringUtil.containsSpecialCharacters(csEquipmentDeliveryAuditParm.getNdid()); StringUtil.containsSpecialCharacters(csEquipmentDeliveryAuditParm.getNdid());
boolean result; boolean result;
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNdid,csEquipmentDeliveryAuditParm.getNdid()) lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNdid, csEquipmentDeliveryAuditParm.getNdid())
.in(CsEquipmentDeliveryPO::getStatus,Arrays.asList(1,2,3)) .in(CsEquipmentDeliveryPO::getStatus, Arrays.asList(1, 2, 3))
.ne(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId()); .ne(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId());
int countByAccount = this.count(lambdaQueryWrapper); int countByAccount = this.count(lambdaQueryWrapper);
//大于等于1个则表示重复 //大于等于1个则表示重复
@@ -331,23 +341,23 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
.ne(CsEquipmentDeliveryPO::getNdid, csEquipmentDeliveryAuditParm.getNdid()) .ne(CsEquipmentDeliveryPO::getNdid, csEquipmentDeliveryAuditParm.getNdid())
.eq(CsEquipmentDeliveryPO::getName, csEquipmentDeliveryAuditParm.getName()) .eq(CsEquipmentDeliveryPO::getName, csEquipmentDeliveryAuditParm.getName())
.ne(CsEquipmentDeliveryPO::getRunStatus, 0).list(); .ne(CsEquipmentDeliveryPO::getRunStatus, 0).list();
if(!CollectionUtils.isEmpty (list)){ if (!CollectionUtils.isEmpty(list)) {
throw new BusinessException ("设备名称不能重复"); throw new BusinessException("设备名称不能重复");
} }
CsEquipmentDeliveryPO csEquipmentDeliveryPo = new CsEquipmentDeliveryPO(); CsEquipmentDeliveryPO csEquipmentDeliveryPo = new CsEquipmentDeliveryPO();
BeanUtils.copyProperties (csEquipmentDeliveryAuditParm, csEquipmentDeliveryPo); BeanUtils.copyProperties(csEquipmentDeliveryAuditParm, csEquipmentDeliveryPo);
result = this.updateById(csEquipmentDeliveryPo); result = this.updateById(csEquipmentDeliveryPo);
//如果是已经接入的设备需要修改台账树中的设备名称 //如果是已经接入的设备需要修改台账树中的设备名称
CsLedger csLedger = csLedgerService.findDataById(csEquipmentDeliveryAuditParm.getId()); CsLedger csLedger = csLedgerService.findDataById(csEquipmentDeliveryAuditParm.getId());
if (ObjectUtil.isNotNull(csLedger)) { if (ObjectUtil.isNotNull(csLedger)) {
CsLedgerParam.Update csLedgerParam = new CsLedgerParam.Update(); CsLedgerParam.Update csLedgerParam = new CsLedgerParam.Update();
BeanUtils.copyProperties (csLedger, csLedgerParam); BeanUtils.copyProperties(csLedger, csLedgerParam);
csLedgerParam.setName(csEquipmentDeliveryAuditParm.getName()); csLedgerParam.setName(csEquipmentDeliveryAuditParm.getName());
csLedgerService.updateLedgerTree(csLedgerParam); csLedgerService.updateLedgerTree(csLedgerParam);
} }
if (result) { if (result) {
refreshDeviceDataCache(); refreshDeviceDataCache();
if (!Objects.equals(po.getUsageStatus(),csEquipmentDeliveryAuditParm.getUsageStatus())) { if (!Objects.equals(po.getUsageStatus(), csEquipmentDeliveryAuditParm.getUsageStatus())) {
DeviceLogDTO dto = new DeviceLogDTO(); DeviceLogDTO dto = new DeviceLogDTO();
dto.setUserName(RequestUtil.getUsername()); dto.setUserName(RequestUtil.getUsername());
dto.setOperate("设备使用状态被修改"); dto.setOperate("设备使用状态被修改");
@@ -360,10 +370,10 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
} }
@Override @Override
public void updateStatusBynDid(String nDId,Integer status) { public void updateStatusBynDid(String nDId, Integer status) {
boolean result; boolean result;
LambdaUpdateWrapper<CsEquipmentDeliveryPO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>(); LambdaUpdateWrapper<CsEquipmentDeliveryPO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
lambdaUpdateWrapper.set(CsEquipmentDeliveryPO::getStatus,status).eq(CsEquipmentDeliveryPO::getNdid,nDId); lambdaUpdateWrapper.set(CsEquipmentDeliveryPO::getStatus, status).eq(CsEquipmentDeliveryPO::getNdid, nDId);
result = this.update(lambdaUpdateWrapper); result = this.update(lambdaUpdateWrapper);
if (result) { if (result) {
refreshDeviceDataCache(); refreshDeviceDataCache();
@@ -372,16 +382,16 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
@Override @Override
public Page<CsEquipmentDeliveryVO> list(CsEquipmentDeliveryQueryParm queryParam) { public Page<CsEquipmentDeliveryVO> list(CsEquipmentDeliveryQueryParm queryParam) {
Page<CsEquipmentDeliveryVO> page = new Page<> (); Page<CsEquipmentDeliveryVO> page = new Page<>();
page.setCurrent(queryParam.getPageNum()); page.setCurrent(queryParam.getPageNum());
page.setSize(queryParam.getPageSize()); page.setSize(queryParam.getPageSize());
queryParam.setPageNum((queryParam.getPageNum()-1)*queryParam.getPageSize()); queryParam.setPageNum((queryParam.getPageNum() - 1) * queryParam.getPageSize());
int total = this.baseMapper.getCounts(queryParam); int total = this.baseMapper.getCounts(queryParam);
if (total > 0) { if (total > 0) {
List<CsEquipmentDeliveryVO> recordList = this.baseMapper.getList(queryParam); List<CsEquipmentDeliveryVO> recordList = this.baseMapper.getList(queryParam);
//新增逻辑(只针对便携式设备):修改设备中的未注册状态(status = 1)改为5(前端定义的字典也即未接入) //新增逻辑(只针对便携式设备):修改设备中的未注册状态(status = 1)改为5(前端定义的字典也即未接入)
for(CsEquipmentDeliveryVO csEquipmentDeliveryVO : recordList){ for (CsEquipmentDeliveryVO csEquipmentDeliveryVO : recordList) {
if(DataParam.portableDevType.equals(csEquipmentDeliveryVO.getDevType()) && csEquipmentDeliveryVO.getStatus() == 1){ if (DataParam.portableDevType.equals(csEquipmentDeliveryVO.getDevType()) && csEquipmentDeliveryVO.getStatus() == 1) {
csEquipmentDeliveryVO.setStatus(5); csEquipmentDeliveryVO.setStatus(5);
} else if (DataParam.portableDevType.equals(csEquipmentDeliveryVO.getDevType()) && csEquipmentDeliveryVO.getStatus() == 2) { } else if (DataParam.portableDevType.equals(csEquipmentDeliveryVO.getDevType()) && csEquipmentDeliveryVO.getStatus() == 2) {
csEquipmentDeliveryVO.setStatus(6); csEquipmentDeliveryVO.setStatus(6);
@@ -409,14 +419,14 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
} }
@Override @Override
public DeviceManagerVO getDeviceData(String deviceId, String type, String lineId) { public DeviceManagerVO getDeviceData(String deviceId, String type, String lineId) {
DeviceManagerVO deviceManagerVo = new DeviceManagerVO(); DeviceManagerVO deviceManagerVo = new DeviceManagerVO();
List<DeviceManagerVO.DataSetVO> dataSetList = new ArrayList<>(); List<DeviceManagerVO.DataSetVO> dataSetList = new ArrayList<>();
CsEquipmentDeliveryPO csEquipmentDeliveryPo = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getId, deviceId).one(); CsEquipmentDeliveryPO csEquipmentDeliveryPo = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getId, deviceId).one();
//获取装置版本信息 //获取装置版本信息
String softInfoId = csEquipmentDeliveryPo.getSoftinfoId(); String softInfoId = csEquipmentDeliveryPo.getSoftinfoId();
if (StringUtils.isNotBlank(softInfoId) && ObjectUtil.isNotNull(softInfoId)) { if (StringUtils.isNotBlank(softInfoId) && ObjectUtil.isNotNull(softInfoId)) {
CsSoftInfoPO po = csSoftInfoMapper.selectById(softInfoId); CsSoftInfoPO po = csSoftInfoMapper.selectById(softInfoId);
deviceManagerVo.setAppVersion(po.getAppVersion()); deviceManagerVo.setAppVersion(po.getAppVersion());
deviceManagerVo.setAppDate(po.getAppDate()); deviceManagerVo.setAppDate(po.getAppDate());
deviceManagerVo.setAppCheck(po.getAppCheck()); deviceManagerVo.setAppCheck(po.getAppCheck());
@@ -425,7 +435,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
List<CsDataSet> dataSet = new ArrayList<>(); List<CsDataSet> dataSet = new ArrayList<>();
//如果没有传lineId(测点ID) 则根据设备ID获取对应的模板 select modelId from cs_dev_model_relation where dev_id = ? //如果没有传lineId(测点ID) 则根据设备ID获取对应的模板 select modelId from cs_dev_model_relation where dev_id = ?
List<CsDevModelRelationPO> modelId = csDevModelRelationService.findModelByDevId(deviceId); List<CsDevModelRelationPO> modelId = csDevModelRelationService.findModelByDevId(deviceId);
if (CollUtil.isNotEmpty(modelId)){ if (CollUtil.isNotEmpty(modelId)) {
for (CsDevModelRelationPO item : modelId) { for (CsDevModelRelationPO item : modelId) {
//再根据模板ID获取数据集 作为页面展示的Tab项 SELECT * FROM cs_data_set WHERE (pid = ? AND type IN (0,2)) //再根据模板ID获取数据集 作为页面展示的Tab项 SELECT * FROM cs_data_set WHERE (pid = ? AND type IN (0,2))
dataSet.addAll(csDataSetService.findDataSetByModelId(item.getModelId())); dataSet.addAll(csDataSetService.findDataSetByModelId(item.getModelId()));
@@ -441,36 +451,36 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
String modelId = ""; String modelId = "";
List<CsDataSet> dataSet = new ArrayList<>(); List<CsDataSet> dataSet = new ArrayList<>();
//治理监测点 //治理监测点
if (Objects.equals(code, DicDataEnum.OUTPUT_SIDE.getCode())){ if (Objects.equals(code, DicDataEnum.OUTPUT_SIDE.getCode())) {
modelId = csDevModelRelationService.getModelByType(deviceId,0); modelId = csDevModelRelationService.getModelByType(deviceId, 0);
dataSet = csDataSetService.findDataSetByModelId(modelId,0); dataSet = csDataSetService.findDataSetByModelId(modelId, 0);
} }
//电网侧监测点 //电网侧监测点
else if (Objects.equals(code, DicDataEnum.GRID_SIDE.getCode())){ else if (Objects.equals(code, DicDataEnum.GRID_SIDE.getCode())) {
modelId = csDevModelRelationService.getModelByType(deviceId,1); modelId = csDevModelRelationService.getModelByType(deviceId, 1);
dataSet = csDataSetService.findDataSetByModelId(modelId,1); dataSet = csDataSetService.findDataSetByModelId(modelId, 1);
} }
//负载侧监测点 //负载侧监测点
else if (Objects.equals(code, DicDataEnum.LOAD_SIDE.getCode())){ else if (Objects.equals(code, DicDataEnum.LOAD_SIDE.getCode())) {
modelId = csDevModelRelationService.getModelByType(deviceId,1); modelId = csDevModelRelationService.getModelByType(deviceId, 1);
dataSet = csDataSetService.findDataSetByModelId(modelId,2); dataSet = csDataSetService.findDataSetByModelId(modelId, 2);
} }
setDataSetValues(csEquipmentDeliveryPo, dataSet, dataSetList, type, deviceManagerVo); setDataSetValues(csEquipmentDeliveryPo, dataSet, dataSetList, type, deviceManagerVo);
} else if(Objects.equals(devTypeCode, DicDataEnum.PORTABLE.getCode())){ } else if (Objects.equals(devTypeCode, DicDataEnum.PORTABLE.getCode())) {
List<CsDataSet> dataSet = new ArrayList<>(); List<CsDataSet> dataSet = new ArrayList<>();
List<CsDevModelRelationPO> modelId = csDevModelRelationService.findModelByDevId(deviceId); List<CsDevModelRelationPO> modelId = csDevModelRelationService.findModelByDevId(deviceId);
if (CollUtil.isNotEmpty(modelId)){ if (CollUtil.isNotEmpty(modelId)) {
for (CsDevModelRelationPO item : modelId) { for (CsDevModelRelationPO item : modelId) {
dataSet.addAll(csDataSetService.findDataSetByModelId(item.getModelId(),line.getClDid())); dataSet.addAll(csDataSetService.findDataSetByModelId(item.getModelId(), line.getClDid()));
} }
setDataSetValues(csEquipmentDeliveryPo, dataSet, dataSetList, type, deviceManagerVo); setDataSetValues(csEquipmentDeliveryPo, dataSet, dataSetList, type, deviceManagerVo);
} }
} else if(Objects.equals(devTypeCode, DicDataEnum.DEV_CLD.getCode())){ } else if (Objects.equals(devTypeCode, DicDataEnum.DEV_CLD.getCode())) {
List<CsDataSet> dataSet = new ArrayList<>(); List<CsDataSet> dataSet = new ArrayList<>();
List<CsDevModelRelationPO> modelId = csDevModelRelationService.findModelByDevId(deviceId); List<CsDevModelRelationPO> modelId = csDevModelRelationService.findModelByDevId(deviceId);
if (CollUtil.isNotEmpty(modelId)){ if (CollUtil.isNotEmpty(modelId)) {
for (CsDevModelRelationPO item : modelId) { for (CsDevModelRelationPO item : modelId) {
dataSet.addAll(csDataSetService.findDataSetByModelId(item.getModelId(),1)); dataSet.addAll(csDataSetService.findDataSetByModelId(item.getModelId(), 1));
} }
setDataSetValues(csEquipmentDeliveryPo, dataSet, dataSetList, type, deviceManagerVo); setDataSetValues(csEquipmentDeliveryPo, dataSet, dataSetList, type, deviceManagerVo);
} }
@@ -525,7 +535,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
} }
deviceManagerVo.setDataSetList(dataSetList); deviceManagerVo.setDataSetList(dataSetList);
List<CsLinePO> csLinePOS = csLinePOService.findByNdid(csEquipmentDeliveryPo.getNdid()); List<CsLinePO> csLinePOS = csLinePOService.findByNdid(csEquipmentDeliveryPo.getNdid());
if(!csLinePOS.isEmpty()){ if (!csLinePOS.isEmpty()) {
Optional<CsLinePO> earliest = csLinePOS.stream().min(Comparator.comparing(CsLinePO::getCreateTime)); Optional<CsLinePO> earliest = csLinePOS.stream().min(Comparator.comparing(CsLinePO::getCreateTime));
deviceManagerVo.setTime(earliest.map(CsLinePO::getCreateTime).orElse(null)); deviceManagerVo.setTime(earliest.map(CsLinePO::getCreateTime).orElse(null));
} }
@@ -544,7 +554,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
public void updateSoftInfoBynDid(String nDid, String id, Integer module) { public void updateSoftInfoBynDid(String nDid, String id, Integer module) {
boolean result; boolean result;
LambdaUpdateWrapper<CsEquipmentDeliveryPO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>(); LambdaUpdateWrapper<CsEquipmentDeliveryPO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
lambdaUpdateWrapper.set(CsEquipmentDeliveryPO::getSoftinfoId,id).set(CsEquipmentDeliveryPO::getModuleNumber,module).eq(CsEquipmentDeliveryPO::getNdid,nDid); lambdaUpdateWrapper.set(CsEquipmentDeliveryPO::getSoftinfoId, id).set(CsEquipmentDeliveryPO::getModuleNumber, module).eq(CsEquipmentDeliveryPO::getNdid, nDid);
result = this.update(lambdaUpdateWrapper); result = this.update(lambdaUpdateWrapper);
if (result) { if (result) {
refreshDeviceDataCache(); refreshDeviceDataCache();
@@ -553,13 +563,13 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
@Override @Override
public CsEquipmentDeliveryPO findDevByNDid(String nDid) { public CsEquipmentDeliveryPO findDevByNDid(String nDid) {
return this.lambdaQuery().eq(CsEquipmentDeliveryPO::getNdid,nDid).ne(CsEquipmentDeliveryPO::getRunStatus,0).one(); return this.lambdaQuery().eq(CsEquipmentDeliveryPO::getNdid, nDid).ne(CsEquipmentDeliveryPO::getRunStatus, 0).one();
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public List<CsEquipmentDeliveryPO> importEquipment(MultipartFile file, HttpServletResponse response) { public List<CsEquipmentDeliveryPO> importEquipment(MultipartFile file, HttpServletResponse response) {
ImportParams params = new ImportParams ( ); ImportParams params = new ImportParams();
params.setHeadRows(1); params.setHeadRows(1);
params.setTitleRows(1); params.setTitleRows(1);
//第一个sheet为台账信息 //第一个sheet为台账信息
@@ -567,31 +577,31 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
params.setSheetNum(1); params.setSheetNum(1);
String regex = "^[A-Za-z0-9]{6,32}$"; String regex = "^[A-Za-z0-9]{6,32}$";
try { try {
ExcelImportResult<DeviceExcelTemplete> terminalBaseList = ExcelImportUtil.importExcelMore (file.getInputStream ( ), DeviceExcelTemplete.class, params); ExcelImportResult<DeviceExcelTemplete> terminalBaseList = ExcelImportUtil.importExcelMore(file.getInputStream(), DeviceExcelTemplete.class, params);
//如果存在非法数据,将不合格的数据导出 //如果存在非法数据,将不合格的数据导出
List<DeviceExcelTemplete> trueCollect = new ArrayList<> ( ); List<DeviceExcelTemplete> trueCollect = new ArrayList<>();
List<DeviceExcelTemplete.IllegalityDeviceExcelTemplete> falseCollect = new ArrayList<> ( ); List<DeviceExcelTemplete.IllegalityDeviceExcelTemplete> falseCollect = new ArrayList<>();
for (int i = 0; i < terminalBaseList.getList ( ).size ( ); i++) { for (int i = 0; i < terminalBaseList.getList().size(); i++) {
DeviceExcelTemplete deviceExcelTemplete = terminalBaseList.getList ( ).get (i); DeviceExcelTemplete deviceExcelTemplete = terminalBaseList.getList().get(i);
if(!deviceExcelTemplete.getNdid().matches(regex)){ if (!deviceExcelTemplete.getNdid().matches(regex)) {
DeviceExcelTemplete.IllegalityDeviceExcelTemplete idlegalityDeviceException = new DeviceExcelTemplete.IllegalityDeviceExcelTemplete(); DeviceExcelTemplete.IllegalityDeviceExcelTemplete idlegalityDeviceException = new DeviceExcelTemplete.IllegalityDeviceExcelTemplete();
BeanUtils.copyProperties(deviceExcelTemplete,idlegalityDeviceException); BeanUtils.copyProperties(deviceExcelTemplete, idlegalityDeviceException);
idlegalityDeviceException.setMsg("网络设备ID只可为数字或字母,长度至少为6位"); idlegalityDeviceException.setMsg("网络设备ID只可为数字或字母,长度至少为6位");
falseCollect.add(idlegalityDeviceException); falseCollect.add(idlegalityDeviceException);
continue; continue;
} }
CsEquipmentDeliveryPO po = this.queryEquipmentPOByndid (deviceExcelTemplete.getNdid ( )); CsEquipmentDeliveryPO po = this.queryEquipmentPOByndid(deviceExcelTemplete.getNdid());
if(!Objects.isNull (po)){ if (!Objects.isNull(po)) {
DeviceExcelTemplete.IllegalityDeviceExcelTemplete idlegalityDeviceException = new DeviceExcelTemplete.IllegalityDeviceExcelTemplete(); DeviceExcelTemplete.IllegalityDeviceExcelTemplete idlegalityDeviceException = new DeviceExcelTemplete.IllegalityDeviceExcelTemplete();
BeanUtils.copyProperties(deviceExcelTemplete,idlegalityDeviceException); BeanUtils.copyProperties(deviceExcelTemplete, idlegalityDeviceException);
idlegalityDeviceException.setMsg("NDID重复"); idlegalityDeviceException.setMsg("NDID重复");
falseCollect.add(idlegalityDeviceException); falseCollect.add(idlegalityDeviceException);
continue; continue;
} }
CsEquipmentDeliveryPO one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getName, deviceExcelTemplete.getName()).ne(CsEquipmentDeliveryPO::getRunStatus, 0).one(); CsEquipmentDeliveryPO one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getName, deviceExcelTemplete.getName()).ne(CsEquipmentDeliveryPO::getRunStatus, 0).one();
if(Objects.nonNull (one)){ if (Objects.nonNull(one)) {
DeviceExcelTemplete.IllegalityDeviceExcelTemplete idlegalityDeviceException = new DeviceExcelTemplete.IllegalityDeviceExcelTemplete(); DeviceExcelTemplete.IllegalityDeviceExcelTemplete idlegalityDeviceException = new DeviceExcelTemplete.IllegalityDeviceExcelTemplete();
BeanUtils.copyProperties(deviceExcelTemplete,idlegalityDeviceException); BeanUtils.copyProperties(deviceExcelTemplete, idlegalityDeviceException);
idlegalityDeviceException.setMsg("NDID重复"); idlegalityDeviceException.setMsg("NDID重复");
falseCollect.add(idlegalityDeviceException); falseCollect.add(idlegalityDeviceException);
continue; continue;
@@ -602,35 +612,35 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
Map<String, SysDicTreePO> map = children.stream().collect(Collectors.toMap(SysDicTreePO::getName, dictTreeVO -> dictTreeVO)); Map<String, SysDicTreePO> map = children.stream().collect(Collectors.toMap(SysDicTreePO::getName, dictTreeVO -> dictTreeVO));
List<SysDicTreePO> collect = children.stream().filter(temp -> Objects.equals(temp.getName(), deviceExcelTemplete.getDevType())).collect(Collectors.toList()); List<SysDicTreePO> collect = children.stream().filter(temp -> Objects.equals(temp.getName(), deviceExcelTemplete.getDevType())).collect(Collectors.toList());
SysDicTreePO sysDicTreePO = map.get(deviceExcelTemplete.getDevType()); SysDicTreePO sysDicTreePO = map.get(deviceExcelTemplete.getDevType());
if(CollectionUtils.isEmpty(collect)){ if (CollectionUtils.isEmpty(collect)) {
DeviceExcelTemplete.IllegalityDeviceExcelTemplete idlegalityDeviceException = new DeviceExcelTemplete.IllegalityDeviceExcelTemplete(); DeviceExcelTemplete.IllegalityDeviceExcelTemplete idlegalityDeviceException = new DeviceExcelTemplete.IllegalityDeviceExcelTemplete();
BeanUtils.copyProperties(deviceExcelTemplete,idlegalityDeviceException); BeanUtils.copyProperties(deviceExcelTemplete, idlegalityDeviceException);
idlegalityDeviceException.setMsg("设备类型不正确"); idlegalityDeviceException.setMsg("设备类型不正确");
falseCollect.add(idlegalityDeviceException); falseCollect.add(idlegalityDeviceException);
continue; continue;
}else { } else {
deviceExcelTemplete.setDevType(map.get(deviceExcelTemplete.getDevType()).getId()); deviceExcelTemplete.setDevType(map.get(deviceExcelTemplete.getDevType()).getId());
} }
//设备型号 //设备型号
List<SysDicTreePO> children1 = sysDicTreePO.getChildren(); List<SysDicTreePO> children1 = sysDicTreePO.getChildren();
Map<String, SysDicTreePO> map2 = children1.stream().collect(Collectors.toMap(SysDicTreePO::getName, dictTreeVO -> dictTreeVO)); Map<String, SysDicTreePO> map2 = children1.stream().collect(Collectors.toMap(SysDicTreePO::getName, dictTreeVO -> dictTreeVO));
List<SysDicTreePO> collect2 = children1.stream().filter(temp -> Objects.equals(temp.getName(), deviceExcelTemplete.getDevModel())).collect(Collectors.toList()); List<SysDicTreePO> collect2 = children1.stream().filter(temp -> Objects.equals(temp.getName(), deviceExcelTemplete.getDevModel())).collect(Collectors.toList());
if(CollectionUtils.isEmpty(collect2)){ if (CollectionUtils.isEmpty(collect2)) {
DeviceExcelTemplete.IllegalityDeviceExcelTemplete idlegalityDeviceException = new DeviceExcelTemplete.IllegalityDeviceExcelTemplete(); DeviceExcelTemplete.IllegalityDeviceExcelTemplete idlegalityDeviceException = new DeviceExcelTemplete.IllegalityDeviceExcelTemplete();
BeanUtils.copyProperties(deviceExcelTemplete,idlegalityDeviceException); BeanUtils.copyProperties(deviceExcelTemplete, idlegalityDeviceException);
idlegalityDeviceException.setMsg("设备类型与设备型号不匹配"); idlegalityDeviceException.setMsg("设备类型与设备型号不匹配");
falseCollect.add(idlegalityDeviceException); falseCollect.add(idlegalityDeviceException);
continue; continue;
}else { } else {
deviceExcelTemplete.setDevModel(map2.get(deviceExcelTemplete.getDevModel()).getId()); deviceExcelTemplete.setDevModel(map2.get(deviceExcelTemplete.getDevModel()).getId());
trueCollect.add(deviceExcelTemplete); trueCollect.add(deviceExcelTemplete);
} }
} }
if (!CollectionUtils.isEmpty (trueCollect)) { if (!CollectionUtils.isEmpty(trueCollect)) {
List<CsEquipmentProcessPO> collect1 = new ArrayList<>(); List<CsEquipmentProcessPO> collect1 = new ArrayList<>();
List<CsEquipmentDeliveryPO> collect = trueCollect.stream ( ).map (temp -> { List<CsEquipmentDeliveryPO> collect = trueCollect.stream().map(temp -> {
CsEquipmentDeliveryPO csEquipmentDeliveryPO = new CsEquipmentDeliveryPO ( ); CsEquipmentDeliveryPO csEquipmentDeliveryPO = new CsEquipmentDeliveryPO();
BeanUtils.copyProperties (temp, csEquipmentDeliveryPO); BeanUtils.copyProperties(temp, csEquipmentDeliveryPO);
String qr = this.createQr(temp.getNdid()); String qr = this.createQr(temp.getNdid());
csEquipmentDeliveryPO.setQrPath(qr); csEquipmentDeliveryPO.setQrPath(qr);
String path = this.createPath(temp.getNdid()); String path = this.createPath(temp.getNdid());
@@ -649,19 +659,19 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
csEquipmentProcess.setStatus(1); csEquipmentProcess.setStatus(1);
collect1.add(csEquipmentProcess); collect1.add(csEquipmentProcess);
return csEquipmentDeliveryPO; return csEquipmentDeliveryPO;
}).collect (Collectors.toList ( )); }).collect(Collectors.toList());
csEquipmentProcessPOService.saveBatch(collect1,500); csEquipmentProcessPOService.saveBatch(collect1, 500);
this.saveOrUpdateBatch (collect, 500); this.saveOrUpdateBatch(collect, 500);
return collect; return collect;
} }
if (!CollectionUtils.isEmpty (falseCollect)) { if (!CollectionUtils.isEmpty(falseCollect)) {
ExportParams exportExcel = new ExportParams ("批量导入模板(请严格按照模板标准填入数据)", "非法设备信息"); ExportParams exportExcel = new ExportParams("批量导入模板(请严格按照模板标准填入数据)", "非法设备信息");
Workbook workbook = ExcelExportUtil.exportExcel (exportExcel, DeviceExcelTemplete.IllegalityDeviceExcelTemplete.class, falseCollect); Workbook workbook = ExcelExportUtil.exportExcel(exportExcel, DeviceExcelTemplete.IllegalityDeviceExcelTemplete.class, falseCollect);
ExcelStyleUtil.exportFileByWorkbook (workbook, "非法设备信息.xlsx", response); ExcelStyleUtil.exportFileByWorkbook(workbook, "非法设备信息.xlsx", response);
return null; return null;
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace ( ); e.printStackTrace();
} }
return null; return null;
} }
@@ -683,29 +693,29 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
* 删除设备 * 删除设备
*/ */
csLedgerQueryWrapper.clear(); csLedgerQueryWrapper.clear();
csLedgerQueryWrapper.eq("id",devId); csLedgerQueryWrapper.eq("id", devId);
csLedgerService.remove(csLedgerQueryWrapper); csLedgerService.remove(csLedgerQueryWrapper);
csLedgerQueryWrapper.clear(); csLedgerQueryWrapper.clear();
csLedgerQueryWrapper.eq("pid",devId); csLedgerQueryWrapper.eq("pid", devId);
List<CsLedger> list = csLedgerService.list(csLedgerQueryWrapper); List<CsLedger> list = csLedgerService.list(csLedgerQueryWrapper);
List<String> collect = list.stream().map(CsLedger::getId).collect(Collectors.toList()); List<String> collect = list.stream().map(CsLedger::getId).collect(Collectors.toList());
csLedgerService.remove(csLedgerQueryWrapper); csLedgerService.remove(csLedgerQueryWrapper);
QueryWrapper<CsDevModelRelationPO> csDevModelRelationPOQueryWrapper = new QueryWrapper<>(); QueryWrapper<CsDevModelRelationPO> csDevModelRelationPOQueryWrapper = new QueryWrapper<>();
csDevModelRelationPOQueryWrapper.clear(); csDevModelRelationPOQueryWrapper.clear();
csDevModelRelationPOQueryWrapper.eq("dev_id",devId); csDevModelRelationPOQueryWrapper.eq("dev_id", devId);
csDevModelRelationService.remove(csDevModelRelationPOQueryWrapper); csDevModelRelationService.remove(csDevModelRelationPOQueryWrapper);
QueryWrapper<CsDeviceUserPO> csDeviceUserPOQueryWrapper = new QueryWrapper<>(); QueryWrapper<CsDeviceUserPO> csDeviceUserPOQueryWrapper = new QueryWrapper<>();
csDeviceUserPOQueryWrapper.clear(); csDeviceUserPOQueryWrapper.clear();
csDeviceUserPOQueryWrapper.eq("device_id",devId); csDeviceUserPOQueryWrapper.eq("device_id", devId);
csDeviceUserPOService.remove(csDeviceUserPOQueryWrapper); csDeviceUserPOService.remove(csDeviceUserPOQueryWrapper);
if (!CollectionUtils.isEmpty(collect)) { if (!CollectionUtils.isEmpty(collect)) {
QueryWrapper<CsLinePO> csLinePOQueryWrapper = new QueryWrapper<>(); QueryWrapper<CsLinePO> csLinePOQueryWrapper = new QueryWrapper<>();
csLinePOQueryWrapper.clear(); csLinePOQueryWrapper.clear();
csLinePOQueryWrapper.in("line_id",collect); csLinePOQueryWrapper.in("line_id", collect);
csLinePOService.remove(csLinePOQueryWrapper); csLinePOService.remove(csLinePOQueryWrapper);
QueryWrapper<AppLineTopologyDiagramPO> appLineTopologyDiagramPOQueryWrapper = new QueryWrapper<>(); QueryWrapper<AppLineTopologyDiagramPO> appLineTopologyDiagramPOQueryWrapper = new QueryWrapper<>();
appLineTopologyDiagramPOQueryWrapper.clear(); appLineTopologyDiagramPOQueryWrapper.clear();
appLineTopologyDiagramPOQueryWrapper.in("line_id",collect); appLineTopologyDiagramPOQueryWrapper.in("line_id", collect);
appLineTopologyDiagramService.remove(appLineTopologyDiagramPOQueryWrapper); appLineTopologyDiagramService.remove(appLineTopologyDiagramPOQueryWrapper);
} }
refreshDeviceDataCache(); refreshDeviceDataCache();
@@ -713,40 +723,40 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void testCompletion(String deviceId,Integer type,String remark) { public void testCompletion(String deviceId, Integer type, String remark) {
CsEquipmentDeliveryPO one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getId, deviceId).one(); CsEquipmentDeliveryPO one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getId, deviceId).one();
this.lambdaUpdate().eq(CsEquipmentDeliveryPO::getId,deviceId). this.lambdaUpdate().eq(CsEquipmentDeliveryPO::getId, deviceId).
set(CsEquipmentDeliveryPO::getStatus,1). set(CsEquipmentDeliveryPO::getStatus, 1).
set(CsEquipmentDeliveryPO::getRunStatus,1). set(CsEquipmentDeliveryPO::getRunStatus, 1).
set(CsEquipmentDeliveryPO::getProcess,type+1).update(); set(CsEquipmentDeliveryPO::getProcess, type + 1).update();
this.delete(deviceId); this.delete(deviceId);
List<CsEquipmentProcessPO> list = csEquipmentProcessPOService.lambdaQuery().eq(CsEquipmentProcessPO::getDevId, one.getNdid()). List<CsEquipmentProcessPO> list = csEquipmentProcessPOService.lambdaQuery().eq(CsEquipmentProcessPO::getDevId, one.getNdid()).
eq(CsEquipmentProcessPO::getProcess, type).orderByDesc(CsEquipmentProcessPO::getStartTime).list(); eq(CsEquipmentProcessPO::getProcess, type).orderByDesc(CsEquipmentProcessPO::getStartTime).list();
//获取最新一条数据; //获取最新一条数据;
CsEquipmentProcessPO csEquipmentProcessPO = list.get(0); CsEquipmentProcessPO csEquipmentProcessPO = list.get(0);
csEquipmentProcessPOService.lambdaUpdate().eq(CsEquipmentProcessPO::getId,csEquipmentProcessPO.getId()). csEquipmentProcessPOService.lambdaUpdate().eq(CsEquipmentProcessPO::getId, csEquipmentProcessPO.getId()).
set(CsEquipmentProcessPO::getStatus,1). set(CsEquipmentProcessPO::getStatus, 1).
set(CsEquipmentProcessPO::getEndTime,LocalDateTime.now()). set(CsEquipmentProcessPO::getEndTime, LocalDateTime.now()).
set(CsEquipmentProcessPO::getRemark,remark). set(CsEquipmentProcessPO::getRemark, remark).
update(); update();
} }
@Override @Override
public void deleteTest(String deviceId, Integer type ,String remark) { public void deleteTest(String deviceId, Integer type, String remark) {
CsEquipmentDeliveryPO one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getId, deviceId).one(); CsEquipmentDeliveryPO one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getId, deviceId).one();
this.lambdaUpdate().eq(CsEquipmentDeliveryPO::getId,deviceId). this.lambdaUpdate().eq(CsEquipmentDeliveryPO::getId, deviceId).
// set(CsEquipmentDeliveryPO::getStatus,1). // set(CsEquipmentDeliveryPO::getStatus,1).
// set(CsEquipmentDeliveryPO::getRunStatus,1). // set(CsEquipmentDeliveryPO::getRunStatus,1).
set(CsEquipmentDeliveryPO::getProcess,type).update(); set(CsEquipmentDeliveryPO::getProcess, type).update();
this.delete(deviceId); this.delete(deviceId);
List<CsEquipmentProcessPO> list = csEquipmentProcessPOService.lambdaQuery().eq(CsEquipmentProcessPO::getDevId, one.getNdid()). List<CsEquipmentProcessPO> list = csEquipmentProcessPOService.lambdaQuery().eq(CsEquipmentProcessPO::getDevId, one.getNdid()).
eq(CsEquipmentProcessPO::getProcess, type).orderByDesc(CsEquipmentProcessPO::getStartTime).list(); eq(CsEquipmentProcessPO::getProcess, type).orderByDesc(CsEquipmentProcessPO::getStartTime).list();
//获取最新一条数据; //获取最新一条数据;
CsEquipmentProcessPO csEquipmentProcessPO = list.get(0); CsEquipmentProcessPO csEquipmentProcessPO = list.get(0);
csEquipmentProcessPOService.lambdaUpdate().eq(CsEquipmentProcessPO::getId,csEquipmentProcessPO.getId()). csEquipmentProcessPOService.lambdaUpdate().eq(CsEquipmentProcessPO::getId, csEquipmentProcessPO.getId()).
set(CsEquipmentProcessPO::getStatus,0). set(CsEquipmentProcessPO::getStatus, 0).
set(CsEquipmentProcessPO::getEndTime,LocalDateTime.now()). set(CsEquipmentProcessPO::getEndTime, LocalDateTime.now()).
set(CsEquipmentProcessPO::getRemark,remark). set(CsEquipmentProcessPO::getRemark, remark).
update(); update();
} }
@@ -754,9 +764,9 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
public void updateSoftInfo(String nDid, String id) { public void updateSoftInfo(String nDid, String id) {
boolean result; boolean result;
LambdaUpdateWrapper<CsEquipmentDeliveryPO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>(); LambdaUpdateWrapper<CsEquipmentDeliveryPO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
lambdaUpdateWrapper.eq(CsEquipmentDeliveryPO::getNdid,nDid) lambdaUpdateWrapper.eq(CsEquipmentDeliveryPO::getNdid, nDid)
.ne(CsEquipmentDeliveryPO::getRunStatus,0) .ne(CsEquipmentDeliveryPO::getRunStatus, 0)
.set(CsEquipmentDeliveryPO::getSoftinfoId,id); .set(CsEquipmentDeliveryPO::getSoftinfoId, id);
result = this.update(lambdaUpdateWrapper); result = this.update(lambdaUpdateWrapper);
if (result) { if (result) {
refreshDeviceDataCache(); refreshDeviceDataCache();
@@ -767,9 +777,9 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
public void updateModuleNumber(String nDid, Integer number) { public void updateModuleNumber(String nDid, Integer number) {
boolean result; boolean result;
LambdaUpdateWrapper<CsEquipmentDeliveryPO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>(); LambdaUpdateWrapper<CsEquipmentDeliveryPO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
lambdaUpdateWrapper.eq(CsEquipmentDeliveryPO::getNdid,nDid) lambdaUpdateWrapper.eq(CsEquipmentDeliveryPO::getNdid, nDid)
.ne(CsEquipmentDeliveryPO::getRunStatus,0) .ne(CsEquipmentDeliveryPO::getRunStatus, 0)
.set(CsEquipmentDeliveryPO::getModuleNumber,number); .set(CsEquipmentDeliveryPO::getModuleNumber, number);
result = this.update(lambdaUpdateWrapper); result = this.update(lambdaUpdateWrapper);
if (result) { if (result) {
refreshDeviceDataCache(); refreshDeviceDataCache();
@@ -786,7 +796,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
Object object = redisUtil.getObjectByKey(key); Object object = redisUtil.getObjectByKey(key);
if (Objects.nonNull(object)) { if (Objects.nonNull(object)) {
String value = object.toString(); String value = object.toString();
if (Objects.equals(value,"success")) { if (Objects.equals(value, "success")) {
result = true; result = true;
} }
} }
@@ -798,14 +808,14 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
@Override @Override
public List<CsEquipmentDeliveryPO> getAll() { public List<CsEquipmentDeliveryPO> getAll() {
return this.lambdaQuery().ne(CsEquipmentDeliveryPO::getRunStatus,0).list(); return this.lambdaQuery().ne(CsEquipmentDeliveryPO::getRunStatus, 0).list();
} }
@Override @Override
public List<CsEquipmentDeliveryPO> getAllOnline() { public List<CsEquipmentDeliveryPO> getAllOnline() {
return this.lambdaQuery() return this.lambdaQuery()
.ne(CsEquipmentDeliveryPO::getRunStatus,0) .ne(CsEquipmentDeliveryPO::getRunStatus, 0)
.eq(CsEquipmentDeliveryPO::getUsageStatus,1) .eq(CsEquipmentDeliveryPO::getUsageStatus, 1)
.isNotNull(CsEquipmentDeliveryPO::getNodeId) .isNotNull(CsEquipmentDeliveryPO::getNodeId)
.list(); .list();
} }
@@ -817,7 +827,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
CsEquipmentDeliveryPO po = findDevByNDid(nDid); CsEquipmentDeliveryPO po = findDevByNDid(nDid);
//设备类型 //设备类型
String code = dictTreeFeignClient.queryById(po.getDevType()).getData().getCode(); String code = dictTreeFeignClient.queryById(po.getDevType()).getData().getCode();
if (Objects.equals(DicDataEnum.DEV_CLD.getCode(),code) || Objects.equals(DicDataEnum.CONNECT_DEV.getCode(),code)) { if (Objects.equals(DicDataEnum.DEV_CLD.getCode(), code) || Objects.equals(DicDataEnum.CONNECT_DEV.getCode(), code)) {
result = true; result = true;
} }
return result; return result;
@@ -826,20 +836,25 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
@Override @Override
public CsEquipmentDeliveryPO getDevByLineId(String lineId) { public CsEquipmentDeliveryPO getDevByLineId(String lineId) {
CsLinePO linePO = csLinePOService.getById(lineId); CsLinePO linePO = csLinePOService.getById(lineId);
return this.lambdaQuery().eq(CsEquipmentDeliveryPO::getId,linePO.getDeviceId()).ne(CsEquipmentDeliveryPO::getRunStatus,0).one(); return this.lambdaQuery().eq(CsEquipmentDeliveryPO::getId, linePO.getDeviceId()).ne(CsEquipmentDeliveryPO::getRunStatus, 0).one();
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public CsEquipmentDeliveryPO saveCld(CsEquipmentDeliveryAddParm param) { public CsEquipmentDeliveryPO saveCld(CsEquipmentDeliveryAddParm param) {
boolean result; boolean result;
//设备名称可以重复
//CsEquipmentDeliveryPO one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getName, param.getName()).ne(CsEquipmentDeliveryPO::getRunStatus, 0).one();
//if(Objects.nonNull (one)){
// throw new BusinessException ("设备名称不能重复");
//}
StringUtil.containsSpecialCharacters(param.getNdid()); StringUtil.containsSpecialCharacters(param.getNdid());
CsEquipmentDeliveryPO po = this.queryEquipmentPOByndid (param.getNdid()); CsEquipmentDeliveryPO po = this.queryEquipmentPOByndid(param.getNdid());
if(!Objects.isNull (po)){ if (!Objects.isNull(po)) {
throw new BusinessException (AlgorithmResponseEnum.NDID_ERROR); throw new BusinessException(AlgorithmResponseEnum.NDID_ERROR);
} }
CsEquipmentDeliveryPO csEquipmentDeliveryPo = new CsEquipmentDeliveryPO(); CsEquipmentDeliveryPO csEquipmentDeliveryPo = new CsEquipmentDeliveryPO();
BeanUtils.copyProperties (param,csEquipmentDeliveryPo); BeanUtils.copyProperties(param, csEquipmentDeliveryPo);
csEquipmentDeliveryPo.setStatus(3); csEquipmentDeliveryPo.setStatus(3);
csEquipmentDeliveryPo.setRunStatus(1); csEquipmentDeliveryPo.setRunStatus(1);
csEquipmentDeliveryPo.setUsageStatus(1); csEquipmentDeliveryPo.setUsageStatus(1);
@@ -852,10 +867,10 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
Node node = nodeService.getNodeById(param.getNodeId()); Node node = nodeService.getNodeById(param.getNodeId());
List<CsEquipmentDeliveryPO> devList = getListByNodeId(param.getNodeId()); List<CsEquipmentDeliveryPO> devList = getListByNodeId(param.getNodeId());
if (ObjectUtil.isNotEmpty(devList) && devList.size() >= node.getNodeDevNum()) { if (ObjectUtil.isNotEmpty(devList) && devList.size() >= node.getNodeDevNum()) {
throw new BusinessException (AlgorithmResponseEnum.OVER_MAX_DEV_COUNT); throw new BusinessException(AlgorithmResponseEnum.OVER_MAX_DEV_COUNT);
} }
//判断2 //判断2
int process = findLeastFrequentProcess(devList,node.getMaxProcessNum()); int process = findLeastFrequentProcess(devList, node.getMaxProcessNum());
csEquipmentDeliveryPo.setNodeProcess(process); csEquipmentDeliveryPo.setNodeProcess(process);
result = this.save(csEquipmentDeliveryPo); result = this.save(csEquipmentDeliveryPo);
@@ -892,23 +907,23 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
public Boolean delCldDev(String id) { public Boolean delCldDev(String id) {
CsEquipmentDeliveryPO one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getId, id).one(); CsEquipmentDeliveryPO one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getId, id).one();
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getId,id); lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getId, id);
boolean update = this.remove(lambdaQueryWrapper); boolean update = this.remove(lambdaQueryWrapper);
List<CsLedger> list = csLedgerService.lambdaQuery().eq(CsLedger::getPid, id).list(); List<CsLedger> list = csLedgerService.lambdaQuery().eq(CsLedger::getPid, id).list();
if(!CollectionUtils.isEmpty(list)){ if (!CollectionUtils.isEmpty(list)) {
List<String> collect = list.stream().map(CsLedger::getId).collect(Collectors.toList()); List<String> collect = list.stream().map(CsLedger::getId).collect(Collectors.toList());
LambdaQueryWrapper<CsLinePO> csLinePOLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsLinePO> csLinePOLambdaQueryWrapper = new LambdaQueryWrapper<>();
csLinePOLambdaQueryWrapper.in(CsLinePO::getLineId,collect); csLinePOLambdaQueryWrapper.in(CsLinePO::getLineId, collect);
csLinePOService.remove(csLinePOLambdaQueryWrapper); csLinePOService.remove(csLinePOLambdaQueryWrapper);
} }
LambdaQueryWrapper<CsLedger> csLedgerLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsLedger> csLedgerLambdaQueryWrapper = new LambdaQueryWrapper<>();
csLedgerLambdaQueryWrapper.clear(); csLedgerLambdaQueryWrapper.clear();
csLedgerLambdaQueryWrapper.eq(CsLedger::getId,id); csLedgerLambdaQueryWrapper.eq(CsLedger::getId, id);
csLedgerService.remove(csLedgerLambdaQueryWrapper); csLedgerService.remove(csLedgerLambdaQueryWrapper);
csLedgerLambdaQueryWrapper.clear(); csLedgerLambdaQueryWrapper.clear();
csLedgerLambdaQueryWrapper.eq(CsLedger::getPid,id); csLedgerLambdaQueryWrapper.eq(CsLedger::getPid, id);
csLedgerService.remove(csLedgerLambdaQueryWrapper); csLedgerService.remove(csLedgerLambdaQueryWrapper);
csDevModelRelationService.lambdaUpdate().eq(CsDevModelRelationPO::getDevId,id).set(CsDevModelRelationPO::getStatus,0).update(); csDevModelRelationService.lambdaUpdate().eq(CsDevModelRelationPO::getDevId, id).set(CsDevModelRelationPO::getStatus, 0).update();
if (update) { if (update) {
refreshDeviceDataCache(); refreshDeviceDataCache();
} }
@@ -940,8 +955,8 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
StringUtil.containsSpecialCharacters(param.getNdid()); StringUtil.containsSpecialCharacters(param.getNdid());
boolean result; boolean result;
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNdid,param.getNdid()) lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNdid, param.getNdid())
.in(CsEquipmentDeliveryPO::getStatus,Arrays.asList(1,2,3)) .in(CsEquipmentDeliveryPO::getStatus, Arrays.asList(1, 2, 3))
.ne(CsEquipmentDeliveryPO::getId, param.getId()); .ne(CsEquipmentDeliveryPO::getId, param.getId());
int countByAccount = this.count(lambdaQueryWrapper); int countByAccount = this.count(lambdaQueryWrapper);
//大于等于1个则表示重复 //大于等于1个则表示重复
@@ -956,11 +971,11 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
.ne(CsEquipmentDeliveryPO::getNdid, param.getNdid()) .ne(CsEquipmentDeliveryPO::getNdid, param.getNdid())
.eq(CsEquipmentDeliveryPO::getName, param.getName()) .eq(CsEquipmentDeliveryPO::getName, param.getName())
.ne(CsEquipmentDeliveryPO::getRunStatus, 0).list(); .ne(CsEquipmentDeliveryPO::getRunStatus, 0).list();
if(!CollectionUtils.isEmpty (list)){ if (!CollectionUtils.isEmpty(list)) {
throw new BusinessException ("设备名称不能重复"); throw new BusinessException("设备名称不能重复");
} }
CsEquipmentDeliveryPO csEquipmentDeliveryPo = new CsEquipmentDeliveryPO(); CsEquipmentDeliveryPO csEquipmentDeliveryPo = new CsEquipmentDeliveryPO();
BeanUtils.copyProperties (param, csEquipmentDeliveryPo); BeanUtils.copyProperties(param, csEquipmentDeliveryPo);
String path = this.createPath(param.getNdid()); String path = this.createPath(param.getNdid());
csEquipmentDeliveryPo.setMac(path); csEquipmentDeliveryPo.setMac(path);
result = this.updateById(csEquipmentDeliveryPo); result = this.updateById(csEquipmentDeliveryPo);
@@ -968,13 +983,13 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
CsLedger csLedger = csLedgerService.findDataById(param.getId()); CsLedger csLedger = csLedgerService.findDataById(param.getId());
if (!Objects.isNull(csLedger)) { if (!Objects.isNull(csLedger)) {
CsLedgerParam.Update csLedgerParam = new CsLedgerParam.Update(); CsLedgerParam.Update csLedgerParam = new CsLedgerParam.Update();
BeanUtils.copyProperties (csLedger, csLedgerParam); BeanUtils.copyProperties(csLedger, csLedgerParam);
csLedgerParam.setName(param.getName()); csLedgerParam.setName(param.getName());
csLedgerService.updateLedgerTree(csLedgerParam); csLedgerService.updateLedgerTree(csLedgerParam);
} }
if (result) { if (result) {
refreshDeviceDataCache(); refreshDeviceDataCache();
if (!Objects.equals(po.getUsageStatus(),param.getUsageStatus())) { if (!Objects.equals(po.getUsageStatus(), param.getUsageStatus())) {
DeviceLogDTO dto = new DeviceLogDTO(); DeviceLogDTO dto = new DeviceLogDTO();
dto.setUserName(RequestUtil.getUsername()); dto.setUserName(RequestUtil.getUsername());
dto.setOperate("设备使用状态被修改"); dto.setOperate("设备使用状态被修改");
@@ -1018,14 +1033,14 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
public void updateCldDevStatus(String nodeId, Integer processNo) { public void updateCldDevStatus(String nodeId, Integer processNo) {
//获取需要修改的设备信息 //获取需要修改的设备信息
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId,nodeId) lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId, nodeId)
.eq(CsEquipmentDeliveryPO::getNodeProcess,processNo) .eq(CsEquipmentDeliveryPO::getNodeProcess, processNo)
.eq(CsEquipmentDeliveryPO::getUsageStatus,1) .eq(CsEquipmentDeliveryPO::getUsageStatus, 1)
.eq(CsEquipmentDeliveryPO::getRunStatus,2); .eq(CsEquipmentDeliveryPO::getRunStatus, 2);
List<CsEquipmentDeliveryPO> devList = this.list(lambdaQueryWrapper); List<CsEquipmentDeliveryPO> devList = this.list(lambdaQueryWrapper);
if (CollectionUtil.isNotEmpty(devList)) { if (CollectionUtil.isNotEmpty(devList)) {
//修改设备运行状态 //修改设备运行状态
devList.forEach(item->{ devList.forEach(item -> {
item.setRunStatus(1); item.setRunStatus(1);
insertPqsCommunicateRecord(LocalDateTime.now().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)), item.getNdid(), 0); insertPqsCommunicateRecord(LocalDateTime.now().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)), item.getNdid(), 0);
}); });
@@ -1037,9 +1052,9 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void flipCldDevStatus(String time, String devId, Integer status) { public void flipCldDevStatus(String time, String devId, Integer status) {
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getId,devId) lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getId, devId)
.eq(CsEquipmentDeliveryPO::getUsageStatus,1) .eq(CsEquipmentDeliveryPO::getUsageStatus, 1)
.ne(CsEquipmentDeliveryPO::getUsageStatus,0); .ne(CsEquipmentDeliveryPO::getUsageStatus, 0);
CsEquipmentDeliveryPO po = this.getOne(lambdaQueryWrapper); CsEquipmentDeliveryPO po = this.getOne(lambdaQueryWrapper);
if (ObjectUtil.isNotNull(po)) { if (ObjectUtil.isNotNull(po)) {
po.setRunStatus(status); po.setRunStatus(status);
@@ -1063,30 +1078,83 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
@Override @Override
public List<CsEquipmentDeliveryPO> getDevListByProjectId(String projectId) { public List<CsEquipmentDeliveryPO> getDevListByProjectId(String projectId) {
QueryWrapper<CsLedger> csLedgerQueryWrapper = new QueryWrapper(); QueryWrapper<CsLedger> csLedgerQueryWrapper = new QueryWrapper();
csLedgerQueryWrapper.lambda().eq(CsLedger::getPid, projectId).eq(CsLedger::getState,1); csLedgerQueryWrapper.lambda().eq(CsLedger::getPid, projectId).eq(CsLedger::getState, 1);
List<CsLedger> csLedgers = csLedgerMapper.selectList(csLedgerQueryWrapper); List<CsLedger> csLedgers = csLedgerMapper.selectList(csLedgerQueryWrapper);
if (CollectionUtil.isEmpty(csLedgers)) { if (CollectionUtil.isEmpty(csLedgers)) {
return new ArrayList<>(); return new ArrayList<>();
} }
List<String> collect = csLedgers.stream().map(CsLedger::getId).collect(Collectors.toList()); List<String> collect = csLedgers.stream().map(CsLedger::getId).collect(Collectors.toList());
return this.lambdaQuery().in(CsEquipmentDeliveryPO::getId,collect).list(); return this.lambdaQuery().in(CsEquipmentDeliveryPO::getId, collect).list();
} }
@Override @Override
public List<CsEquipmentDeliveryPO> getDataByNodeIdAndProcessNo(String nodeId, Integer processNo) { public List<CsEquipmentDeliveryPO> getDataByNodeIdAndProcessNo(String nodeId, Integer processNo) {
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId,nodeId) lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId, nodeId)
.ne(CsEquipmentDeliveryPO::getRunStatus,0) .ne(CsEquipmentDeliveryPO::getRunStatus, 0)
.eq(CsEquipmentDeliveryPO::getDevAccessMethod,"CLD"); .eq(CsEquipmentDeliveryPO::getDevAccessMethod, "CLD");
if (ObjectUtil.isNotNull(processNo)) { if (ObjectUtil.isNotNull(processNo)) {
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeProcess,processNo); lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeProcess, processNo);
} }
return this.list(lambdaQueryWrapper); return this.list(lambdaQueryWrapper);
} }
@Override @Override
public List<CsEquipmentDeliveryPO> getListByIds(List<String> devList) { public List<CsEquipmentDeliveryPO> getListByIds(List<String> devList) {
return this.lambdaQuery().in(CsEquipmentDeliveryPO::getId,devList).list(); return this.lambdaQuery().in(CsEquipmentDeliveryPO::getId, devList).list();
}
@Override
public IPage<DevVersionVO> versionPage(BaseParam baseParam) {
LambdaQueryWrapper<CsEquipmentDeliveryPO> wrapper = new LambdaQueryWrapper<>();
wrapper.ne(CsEquipmentDeliveryPO::getRunStatus, 0)
.like(StrUtil.isNotBlank(baseParam.getSearchValue()), CsEquipmentDeliveryPO::getName, baseParam.getSearchValue());
Page<CsEquipmentDeliveryPO> page = this.page(new Page<>(PageFactory.getPageNum(baseParam), PageFactory.getPageSize(baseParam)), wrapper);
List<DevVersionVO> records = new ArrayList<>();
page.getRecords().forEach(item -> {
DevVersionVO devVersionVO = BeanUtil.copyProperties(item, DevVersionVO.class);
if (StrUtil.isNotBlank(item.getSoftinfoId())) {
// CsEdDataVO csEdDataVO = csEdDataService.findByDevTypeId(item.getDevModel());
CsSoftInfoPO softInfoPO = csSoftInfoService.getById(item.getSoftinfoId());
if (ObjectUtil.isNotNull(softInfoPO)) {
CsEdDataPO csEdDataPO = csEdDataService.findByDevTypeIdAndVersionNo(item.getDevModel(), softInfoPO.getAppVersion());
if (ObjectUtil.isNotNull(csEdDataPO)) {
devVersionVO.setDevTypeName(csEdDataPO.getDevTypeName());
devVersionVO.setVersion(csEdDataPO.getVersionNo());
devVersionVO.setProtocolVersion(csEdDataPO.getVersionAgreement());
devVersionVO.setVersionDate(csEdDataPO.getVersionDate());
}
}
}
devVersionVO.setStatus(item.getUsageStatus());
devVersionVO.setIcd("aaa");
if (StrUtil.isNotBlank(item.getDevModel())) {
SysDicTreePO sysDicTreePO = dictTreeFeignClient.queryById(item.getDevModel()).getData();
if (ObjectUtil.isNotNull(sysDicTreePO)) {
devVersionVO.setDevModel(sysDicTreePO.getName());
}
}
if (StrUtil.isNotBlank(item.getAssociatedEngineering())) {
devVersionVO.setAssociatedEngineering(csEngineeringService.getById(item.getAssociatedEngineering()).getName());
}
if (StrUtil.isNotBlank(item.getAssociatedProject())) {
devVersionVO.setAssociatedProject(appProjectService.getById(item.getAssociatedProject()).getName());
}
records.add(devVersionVO);
});
Page<DevVersionVO> resultPage = new Page<>(PageFactory.getPageNum(baseParam), PageFactory.getPageSize(baseParam));
resultPage.setRecords(records);
resultPage.setTotal(page.getTotal());
resultPage.setMaxLimit(page.getMaxLimit());
resultPage.setPages(page.getPages());
return resultPage;
} }
@Override @Override
@@ -1097,20 +1165,20 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
throw new BusinessException("便携式设备类型字典缺失"); throw new BusinessException("便携式设备类型字典缺失");
} }
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getDevType,vo.getId()) lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getDevType, vo.getId())
.ne(CsEquipmentDeliveryPO::getRunStatus,0) .ne(CsEquipmentDeliveryPO::getRunStatus, 0)
.eq(CsEquipmentDeliveryPO::getUsageStatus,1); .eq(CsEquipmentDeliveryPO::getUsageStatus, 1);
//获取用户已经绑定的便携式设备 //获取用户已经绑定的便携式设备
List<String> devList = csDeviceUserPOService.findDevByUserId(userId); List<String> devList = csDeviceUserPOService.findDevByUserId(userId);
if (CollectionUtil.isNotEmpty(devList)) { if (CollectionUtil.isNotEmpty(devList)) {
lambdaQueryWrapper.notIn(CsEquipmentDeliveryPO::getId,devList); lambdaQueryWrapper.notIn(CsEquipmentDeliveryPO::getId, devList);
} }
result = this.list(lambdaQueryWrapper); result = this.list(lambdaQueryWrapper);
if (CollectionUtil.isNotEmpty(result)) { if (CollectionUtil.isNotEmpty(result)) {
//获取已经接入过系统的设备,未接入的不给分配 //获取已经接入过系统的设备,未接入的不给分配
LambdaQueryWrapper<CsLedger> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsLedger> queryWrapper = new LambdaQueryWrapper<>();
List<String> ids = result.stream().map(CsEquipmentDeliveryPO::getId).collect(Collectors.toList()); List<String> ids = result.stream().map(CsEquipmentDeliveryPO::getId).collect(Collectors.toList());
queryWrapper.in(CsLedger::getId,ids); queryWrapper.in(CsLedger::getId, ids);
List<CsLedger> list = csLedgerService.list(queryWrapper); List<CsLedger> list = csLedgerService.list(queryWrapper);
if (CollectionUtil.isNotEmpty(list)) { if (CollectionUtil.isNotEmpty(list)) {
Set<String> idSet = list.stream() Set<String> idSet = list.stream()
@@ -1130,8 +1198,8 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
//根据前置机id获取装置数量 //根据前置机id获取装置数量
public List<CsEquipmentDeliveryPO> getListByNodeId(String nodeId) { public List<CsEquipmentDeliveryPO> getListByNodeId(String nodeId) {
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId,nodeId) lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId, nodeId)
.in(CsEquipmentDeliveryPO::getRunStatus,Arrays.asList(1,2)); .in(CsEquipmentDeliveryPO::getRunStatus, Arrays.asList(1, 2));
return this.list(lambdaQueryWrapper); return this.list(lambdaQueryWrapper);
} }
@@ -1150,11 +1218,12 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
/** /**
* 根据ndid生成二维码 * 根据ndid生成二维码
*
* @param ndid * @param ndid
* @return * @return
*/ */
private String createQr(String ndid){ private String createQr(String ndid) {
String filePath =""; String filePath = "";
//生成二维码文件 //生成二维码文件
try { try {
QrParam qrParam = new QrParam(); QrParam qrParam = new QrParam();
@@ -1162,7 +1231,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
BufferedImage bufferedImage = QRCodeUtil.getBufferedImage(JSONObject.toJSONString(qrParam)); BufferedImage bufferedImage = QRCodeUtil.getBufferedImage(JSONObject.toJSONString(qrParam));
InputStream inputStream = bufferedImageToInputStream(bufferedImage); InputStream inputStream = bufferedImageToInputStream(bufferedImage);
String fileName = ndid + ".png"; String fileName = ndid + ".png";
filePath = fileStorageUtil.uploadStream(inputStream,OssPath.APP_DEVICE_QR,fileName); filePath = fileStorageUtil.uploadStream(inputStream, OssPath.APP_DEVICE_QR, fileName);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@@ -39,10 +39,10 @@
<!-- <nacos.namespace>b0b0dedf-baa9-407f-bef6-988b9e0a640d</nacos.namespace>--> <!-- <nacos.namespace>b0b0dedf-baa9-407f-bef6-988b9e0a640d</nacos.namespace>-->
<middle.server.url>192.168.1.103</middle.server.url> <middle.server.url>192.168.1.103</middle.server.url>
<service.server.url>192.168.2.126</service.server.url> <service.server.url>192.168.2.124</service.server.url>
<docker.server.url>192.168.1.103</docker.server.url> <docker.server.url>192.168.1.103</docker.server.url>
<nacos.url>${middle.server.url}:18848</nacos.url> <nacos.url>${middle.server.url}:18848</nacos.url>
<nacos.namespace>72972c43-3c20-4452-a261-66624e17da97</nacos.namespace> <nacos.namespace>cb3a03dd-47f6-4a83-9408-b3182b3d0619</nacos.namespace>
<!-- <middle.server.url>192.168.1.103</middle.server.url>--> <!-- <middle.server.url>192.168.1.103</middle.server.url>-->
<!-- <service.server.url>192.168.1.103</service.server.url>--> <!-- <service.server.url>192.168.1.103</service.server.url>-->