From 87b91382a8090e091f1f252c3ef5322cfe200d55 Mon Sep 17 00:00:00 2001 From: caozehui <2427765068@qq.com> Date: Thu, 23 Apr 2026 08:47:19 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=A8=8B=E5=BA=8F=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=88=86=E9=A1=B5=E7=A8=8B=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../param/CsEquipmentDeliveryAddParm.java | 5 + .../param/CsEquipmentDeliveryAuditParm.java | 6 + .../param/CsEquipmentDeliveryQueryParm.java | 6 + .../pojo/po/CsEquipmentDeliveryPO.java | 11 + .../njcn/csdevice/pojo/vo/DevVersionVO.java | 26 ++- .../equipment/DevModelController.java | 32 +-- .../EquipmentDeliveryController.java | 2 +- .../service/CsEquipmentDeliveryService.java | 2 +- .../service/impl/CsEdDataServiceImpl.java | 1 + .../impl/CsEquipmentDeliveryServiceImpl.java | 199 +++++++----------- 10 files changed, 146 insertions(+), 144 deletions(-) diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/CsEquipmentDeliveryAddParm.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/CsEquipmentDeliveryAddParm.java index c39259a..2c211e8 100644 --- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/CsEquipmentDeliveryAddParm.java +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/CsEquipmentDeliveryAddParm.java @@ -106,4 +106,9 @@ public class CsEquipmentDeliveryAddParm implements Serializable { @ApiModelProperty(value="所属项目") private String associatedProject; + @ApiModelProperty(value="icd") + private String icd; + + @ApiModelProperty(value="是否支持升级(0:否 1:是)") + private Integer upgrade; } \ No newline at end of file diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/CsEquipmentDeliveryAuditParm.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/CsEquipmentDeliveryAuditParm.java index 0bb0327..3216740 100644 --- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/CsEquipmentDeliveryAuditParm.java +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/CsEquipmentDeliveryAuditParm.java @@ -110,4 +110,10 @@ public class CsEquipmentDeliveryAuditParm { @ApiModelProperty(value="所属项目") private String associatedProject; + + @ApiModelProperty(value="icd") + private String icd; + + @ApiModelProperty(value="是否支持升级(0:否 1:是)") + private Integer upgrade; } \ No newline at end of file diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/CsEquipmentDeliveryQueryParm.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/CsEquipmentDeliveryQueryParm.java index a7b54e4..000eee7 100644 --- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/CsEquipmentDeliveryQueryParm.java +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/CsEquipmentDeliveryQueryParm.java @@ -2,6 +2,7 @@ package com.njcn.csdevice.pojo.param; import com.njcn.web.pojo.param.BaseParam; import io.swagger.annotations.ApiModelProperty; +import io.swagger.models.auth.In; import lombok.Data; import lombok.EqualsAndHashCode; @@ -40,4 +41,9 @@ public class CsEquipmentDeliveryQueryParm extends BaseParam { @ApiModelProperty("物联通讯状态 0:未连接 1:已连接") private Integer connectStatus; + @ApiModelProperty("ICD") + private String icd; + + @ApiModelProperty("是否支持升级(0:否 1:是)") + private Integer upgrade; } \ No newline at end of file diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/CsEquipmentDeliveryPO.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/CsEquipmentDeliveryPO.java index 488cf68..ac92fe9 100644 --- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/CsEquipmentDeliveryPO.java +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/CsEquipmentDeliveryPO.java @@ -147,4 +147,15 @@ public class CsEquipmentDeliveryPO extends BaseEntity { */ @TableField(value = "associated_project") private String associatedProject; + + /** + * icd模型 + */ + @TableField(value = "icd") + private String icd; + + /** + * 是否支持升级(0:否 1:是) + */ + private Integer upgrade; } \ No newline at end of file diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/DevVersionVO.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/DevVersionVO.java index d702893..c0af57a 100644 --- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/DevVersionVO.java +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/DevVersionVO.java @@ -1,5 +1,6 @@ package com.njcn.csdevice.pojo.vo; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import java.time.LocalDateTime; @@ -43,10 +44,10 @@ public class DevVersionVO { /** * 设备类型名称 */ - private String devTypeName; + private String devModelName; /** - * ICD型号 + * icd型号 */ private String icd; @@ -69,10 +70,31 @@ public class DevVersionVO { /** * 更新时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime updateTime; /** * 修改人员 */ private String updateBy; + + /** + * 修改人名称 + */ + private String updateByName; + + /** + * 设备运行状态(0:删除 1:离线 2:在线) + */ + private Integer runStatus; + + /** + * 是否支持升级(0:否 1:是) + */ + private Integer upgrade; + + /** + * 设备与MQTT服务器连接状态 (0:未连接 1:已连接) + */ + private Integer connectStatus; } diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/DevModelController.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/DevModelController.java index c7dab08..839f322 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/DevModelController.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/DevModelController.java @@ -23,6 +23,8 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import java.util.List; + /** * Description: * 接口文档访问地址:http://serverIP:port/swagger-ui.html @@ -45,9 +47,9 @@ public class DevModelController extends BaseController { @ApiOperation("新增设备模板") @ApiImplicitParam(name = "csDevModelAddParm", value = "新增设备模板参数", required = true) @Deprecated - public HttpResult addDevModel(@RequestBody @Validated CsDevModelAddParm csDevModelAddParm){ + public HttpResult addDevModel(@RequestBody @Validated CsDevModelAddParm csDevModelAddParm) { String methodDescribe = getMethodDescribe("addDevModel"); - CsDevModelPO flag = csDevModelService.addDevModel (csDevModelAddParm); + CsDevModelPO flag = csDevModelService.addDevModel(csDevModelAddParm); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe); } @@ -56,7 +58,7 @@ public class DevModelController extends BaseController { @PostMapping("/AuditDevModel") @ApiOperation("更新/删除设备模板参数") @ApiImplicitParam(name = "csDevModelAuditParm", value = "更新/删除设备模板参数", required = true) - public HttpResult AuditDevModel(@RequestBody @Validated CsDevModelAuditParm csDevModelAuditParm ){ + public HttpResult AuditDevModel(@RequestBody @Validated CsDevModelAuditParm csDevModelAuditParm) { String methodDescribe = getMethodDescribe("AuditDevModel"); Boolean flag = csDevModelService.AuditDevModel(csDevModelAuditParm); @@ -64,15 +66,14 @@ public class DevModelController extends BaseController { } - @OperateInfo(info = LogEnum.BUSINESS_COMMON) @PostMapping("/queryDevModelPage") @ApiOperation("设备模板分页查询") @ApiImplicitParam(name = "csDevModelQueryParm", value = "设备模板查询参数", required = true) - public HttpResult> queryDevModelPage(@RequestBody @Validated CsDevModelQueryParm csDevModelQueryParm ){ + public HttpResult> queryDevModelPage(@RequestBody @Validated CsDevModelQueryParm csDevModelQueryParm) { String methodDescribe = getMethodDescribe("queryDevModelPage"); - IPage page = csDevModelService.queryPage (csDevModelQueryParm); + IPage page = csDevModelService.queryPage(csDevModelQueryParm); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe); } @@ -80,10 +81,10 @@ public class DevModelController extends BaseController { @PostMapping("/queryDevModelOne") @ApiOperation("设备模板查询") @ApiImplicitParam(name = "csDevModelQueryListParm", value = "设备模板信息", required = true) - public HttpResult queryDevModelOne(@RequestBody CsDevModelQueryListParm csDevModelQueryListParm){ + public HttpResult queryDevModelOne(@RequestBody CsDevModelQueryListParm csDevModelQueryListParm) { String methodDescribe = getMethodDescribe("queryDevModelOne"); - CsDevModelPageVO csDevModelPageVO = csDevModelService.queryDevModelOne(csDevModelQueryListParm); + CsDevModelPageVO csDevModelPageVO = csDevModelService.queryDevModelOne(csDevModelQueryListParm); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, csDevModelPageVO, methodDescribe); } @@ -91,13 +92,13 @@ public class DevModelController extends BaseController { @PostMapping("/findModel") @ApiOperation("根据条件查询模板") @ApiImplicitParams({ - @ApiImplicitParam(name = "devType", value = "装置类型", required = true), - @ApiImplicitParam(name = "version", value = "版本", required = true), - @ApiImplicitParam(name = "time", value = "时间", required = true) + @ApiImplicitParam(name = "devType", value = "装置类型", required = true), + @ApiImplicitParam(name = "version", value = "版本", required = true), + @ApiImplicitParam(name = "time", value = "时间", required = true) }) - public HttpResult findModel(@RequestParam("devType") String devType,@RequestParam("version") String version,@RequestParam("time") String time){ + public HttpResult findModel(@RequestParam("devType") String devType, @RequestParam("version") String version, @RequestParam("time") String time) { String methodDescribe = getMethodDescribe("findModel"); - CsDevModelPO csDevModelPo = csDevModelService.findModel(devType,version,time); + CsDevModelPO csDevModelPo = csDevModelService.findModel(devType, version, time); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, csDevModelPo, methodDescribe); } @@ -105,10 +106,9 @@ public class DevModelController extends BaseController { @PostMapping("/getModelById") @ApiOperation("根据模板Id获取模板数据") @ApiImplicitParam(name = "id", value = "模板id", required = true) - public HttpResult getModelById(@RequestParam("id") String id){ + public HttpResult getModelById(@RequestParam("id") String id) { String methodDescribe = getMethodDescribe("getModelById"); - CsDevModelPO po = csDevModelService.getModelById(id); + CsDevModelPO po = csDevModelService.getModelById(id); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe); } - } diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/EquipmentDeliveryController.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/EquipmentDeliveryController.java index b5bccf6..ba3b888 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/EquipmentDeliveryController.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/EquipmentDeliveryController.java @@ -425,7 +425,7 @@ public class EquipmentDeliveryController extends BaseController { @PostMapping("/version/page") @ApiOperation("查询设备版本信息") @ApiImplicitParam(name = "baseParam", value = "查询日志参数", required = true) - public HttpResult> versionPage(@RequestBody BaseParam baseParam) { + public HttpResult> versionPage(@RequestBody CsEquipmentDeliveryQueryParm baseParam) { String methodDescribe = getMethodDescribe("versionPage"); IPage list = csEquipmentDeliveryService.versionPage(baseParam); diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/CsEquipmentDeliveryService.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/CsEquipmentDeliveryService.java index 5070965..8763605 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/CsEquipmentDeliveryService.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/CsEquipmentDeliveryService.java @@ -196,5 +196,5 @@ public interface CsEquipmentDeliveryService extends IService getRunPortableDev(String userId); - IPage versionPage(BaseParam baseParam); + IPage versionPage(CsEquipmentDeliveryQueryParm baseParam); } diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsEdDataServiceImpl.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsEdDataServiceImpl.java index a60d24c..7eca960 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsEdDataServiceImpl.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsEdDataServiceImpl.java @@ -45,6 +45,7 @@ public class CsEdDataServiceImpl extends ServiceImpl BeanUtils.copyProperties(csEdDataAddParm, csEdDataPO); String remoteDir = OssPath.EDDATA + csEdDataAddParm.getDevTypeName() + StrUtil.SLASH + csEdDataAddParm.getVersionNo() + StrUtil.SLASH; String filePath = fileStorageUtil.uploadMultipart(csEdDataAddParm.getFile(), remoteDir); + csEdDataPO.setCrc(csEdDataAddParm.getCrcInfo()); csEdDataPO.setFilePath(filePath); csEdDataPO.setStatus("1"); boolean save = this.save(csEdDataPO); diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsEquipmentDeliveryServiceImpl.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsEquipmentDeliveryServiceImpl.java index 889ac35..bf10368 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsEquipmentDeliveryServiceImpl.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsEquipmentDeliveryServiceImpl.java @@ -10,7 +10,6 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.date.DatePattern; import cn.hutool.core.text.StrPool; -import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONArray; @@ -27,6 +26,7 @@ import com.njcn.access.utils.MqttUtil; import com.njcn.common.pojo.dto.DeviceLogDTO; import com.njcn.common.pojo.exception.BusinessException; import com.njcn.csdevice.api.CsLogsFeignClient; +import com.njcn.csdevice.api.EngineeringFeignClient; import com.njcn.csdevice.constant.DataParam; import com.njcn.csdevice.enums.AlgorithmResponseEnum; import com.njcn.csdevice.mapper.CsEquipmentDeliveryMapper; @@ -57,9 +57,10 @@ import com.njcn.system.enums.DicDataEnum; import com.njcn.system.enums.DicDataTypeEnum; import com.njcn.system.pojo.po.SysDicTreePO; import com.njcn.system.pojo.vo.DictTreeVO; +import com.njcn.user.api.UserFeignClient; import com.njcn.user.enums.AppRoleEnum; +import com.njcn.user.pojo.po.User; import com.njcn.web.factory.PageFactory; -import com.njcn.web.pojo.param.BaseParam; import com.njcn.web.utils.RequestUtil; import lombok.RequiredArgsConstructor; import org.apache.commons.lang.StringUtils; @@ -122,6 +123,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl one = this.lambdaQuery() - .eq(CsEquipmentDeliveryPO::getName, csEquipmentDeliveryAddParm.getName()) - .ne(CsEquipmentDeliveryPO::getRunStatus, 0) - .eq(CsEquipmentDeliveryPO::getDevAccessMethod, "MQTT") - .list(); + List one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getName, csEquipmentDeliveryAddParm.getName()).ne(CsEquipmentDeliveryPO::getRunStatus, 0).eq(CsEquipmentDeliveryPO::getDevAccessMethod, "MQTT").list(); if (CollUtil.isNotEmpty(one)) { throw new BusinessException("设备名称不能重复"); } @@ -171,12 +169,12 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(CsEquipmentDeliveryPO::getId,id); + wrapper.eq(CsEquipmentDeliveryPO::getId, id); CsEquipmentDeliveryPO po = this.getOne(wrapper); if (po != null) { update = this.remove(wrapper); - redisUtil.deleteKeysByString(AppRedisKey.LINE_POSITION+po.getNdid()); + redisUtil.deleteKeysByString(AppRedisKey.LINE_POSITION + po.getNdid()); } //删除监测点表、监测点拓扑图关系 List list = csLedgerService.lambdaQuery().eq(CsLedger::getPid, id).list(); @@ -216,7 +214,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl csLedgerLambdaQueryWrapper = new LambdaQueryWrapper<>(); + LambdaQueryWrapper csLedgerLambdaQueryWrapper = new LambdaQueryWrapper<>(); csLedgerLambdaQueryWrapper.clear(); csLedgerLambdaQueryWrapper.eq(CsLedger::getId, id); csLedgerService.remove(csLedgerLambdaQueryWrapper); @@ -226,12 +224,12 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl csDevModelRelationPOQueryWrapper = new LambdaQueryWrapper<>(); csDevModelRelationPOQueryWrapper.clear(); - csDevModelRelationPOQueryWrapper.eq(CsDevModelRelationPO::getDevId,id); + csDevModelRelationPOQueryWrapper.eq(CsDevModelRelationPO::getDevId, id); csDevModelRelationService.remove(csDevModelRelationPOQueryWrapper); //删除设备/用户关系 QueryWrapper csDeviceUserPOQueryWrapper = new QueryWrapper<>(); csDeviceUserPOQueryWrapper.clear(); - csDeviceUserPOQueryWrapper.eq("device_id",id); + csDeviceUserPOQueryWrapper.eq("device_id", id); csDeviceUserPOService.remove(csDeviceUserPOQueryWrapper); //删除游客 QueryWrapper queryWrap = new QueryWrapper<>(); @@ -251,11 +249,11 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl eventList = eventUserFeignClient.queryTempEventDetail(param).getData(); - Map> eventMap = Optional.ofNullable(eventList) - .orElse(Collections.emptyList()) - .stream() - .collect(Collectors.groupingBy(CsEventPO::getDeviceId)); + Map> eventMap = Optional.ofNullable(eventList).orElse(Collections.emptyList()).stream().collect(Collectors.groupingBy(CsEventPO::getDeviceId)); List recordList = new ArrayList<>(); - list.getRecords().forEach(temp->{ + list.getRecords().forEach(temp -> { temp.setIsPrimaryUser(csDeviceUserPOService.isPrimaryUser(temp.getEquipmentId())); //获取设备类型 SysDicTreePO po = dictTreeFeignClient.queryById(temp.getDevType()).getData(); temp.setDevType(po.getCode()); temp.setLineList(lineIds.stream().filter(line -> line.getDevId().equals(temp.getEquipmentId())).sorted(Comparator.comparing(CsLinePO::getLineId)).collect(Collectors.toList())); - if (!Objects.equals(DicDataEnum.PORTABLE.getCode(),temp.getDevType())) { + if (!Objects.equals(DicDataEnum.PORTABLE.getCode(), temp.getDevType())) { recordList.add(temp); } //判断设备是否存在告警 @@ -307,10 +302,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl topList = csUserPinsService.getPinToTopList(); - List targetIdList = topList.stream() - .filter(item -> Objects.equals(item.getTargetType(), 1)) - .map(CsUserPins::getTargetId) - .collect(Collectors.toList()); + List targetIdList = topList.stream().filter(item -> Objects.equals(item.getTargetType(), 1)).map(CsUserPins::getTargetId).collect(Collectors.toList()); if (CollectionUtil.isNotEmpty(targetIdList)) { List matchedList = new ArrayList<>(); List unmatchedList = new ArrayList<>(); @@ -341,9 +333,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNdid, csEquipmentDeliveryAuditParm.getNdid()) - .in(CsEquipmentDeliveryPO::getStatus, Arrays.asList(1, 2, 3)) - .ne(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId()); + lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNdid, csEquipmentDeliveryAuditParm.getNdid()).in(CsEquipmentDeliveryPO::getStatus, Arrays.asList(1, 2, 3)).ne(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId()); int countByAccount = this.count(lambdaQueryWrapper); //大于等于1个则表示重复 if (countByAccount >= 1) { @@ -352,11 +342,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl lambdaQueryWrapper2 = new LambdaQueryWrapper<>(); lambdaQueryWrapper2.eq(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId()); CsEquipmentDeliveryPO po = this.baseMapper.selectOne(lambdaQueryWrapper2); - List list = this.lambdaQuery() - .ne(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId()) - .ne(CsEquipmentDeliveryPO::getNdid, csEquipmentDeliveryAuditParm.getNdid()) - .eq(CsEquipmentDeliveryPO::getName, csEquipmentDeliveryAuditParm.getName()) - .ne(CsEquipmentDeliveryPO::getRunStatus, 0).list(); + List list = this.lambdaQuery().ne(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId()).ne(CsEquipmentDeliveryPO::getNdid, csEquipmentDeliveryAuditParm.getNdid()).eq(CsEquipmentDeliveryPO::getName, csEquipmentDeliveryAuditParm.getName()).ne(CsEquipmentDeliveryPO::getRunStatus, 0).list(); if (!CollectionUtils.isEmpty(list)) { throw new BusinessException("设备名称不能重复"); } @@ -406,13 +392,13 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl 0) { List recordList = this.baseMapper.getList(queryParam); //新增逻辑(针对便携式设备、监测设备):修改设备中的未注册状态(status = 1)改为5(前端定义的字典也即未接入) - for(CsEquipmentDeliveryVO csEquipmentDeliveryVO : recordList){ + for (CsEquipmentDeliveryVO csEquipmentDeliveryVO : recordList) { String code = dictTreeFeignClient.queryById(csEquipmentDeliveryVO.getDevType()).getData().getCode(); - if((Objects.equals(code, DicDataEnum.PORTABLE.getCode()) && csEquipmentDeliveryVO.getStatus() == 1) - || (Objects.equals(code, DicDataEnum.DEV_CLD.getCode()) && csEquipmentDeliveryVO.getStatus() == 1)){ + if ((Objects.equals(code, DicDataEnum.PORTABLE.getCode()) && csEquipmentDeliveryVO.getStatus() == 1) + || (Objects.equals(code, DicDataEnum.DEV_CLD.getCode()) && csEquipmentDeliveryVO.getStatus() == 1)) { csEquipmentDeliveryVO.setStatus(5); - } else if((Objects.equals(code, DicDataEnum.PORTABLE.getCode()) && csEquipmentDeliveryVO.getStatus() == 2) - || (Objects.equals(code, DicDataEnum.DEV_CLD.getCode()) && csEquipmentDeliveryVO.getStatus() == 2)){ + } else if ((Objects.equals(code, DicDataEnum.PORTABLE.getCode()) && csEquipmentDeliveryVO.getStatus() == 2) + || (Objects.equals(code, DicDataEnum.DEV_CLD.getCode()) && csEquipmentDeliveryVO.getStatus() == 2)) { csEquipmentDeliveryVO.setStatus(6); } //判断装置是否已经连接上mqtt服务器 @@ -425,11 +411,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl queryParam.getConnectStatus() == 0 - ? "未连接".equals(item.getConnectStatus()) - : "已连接".equals(item.getConnectStatus())) - .collect(Collectors.toList()); + recordList = recordList.stream().filter(item -> queryParam.getConnectStatus() == 0 ? "未连接".equals(item.getConnectStatus()) : "已连接".equals(item.getConnectStatus())).collect(Collectors.toList()); } page.setTotal(CollectionUtil.isEmpty(recordList) ? 0 : recordList.size()); page.setRecords(recordList); @@ -454,7 +436,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl dataSet = new ArrayList<>(); //如果没有传lineId(测点ID) 则根据设备ID获取对应的模板 select modelId from cs_dev_model_relation where dev_id = ? List modelId = csDevModelRelationService.findModelByDevId(deviceId); - if (CollUtil.isNotEmpty(modelId)){ + if (CollUtil.isNotEmpty(modelId)) { for (CsDevModelRelationPO item : modelId) { //再根据模板ID获取数据集 作为页面展示的Tab项 SELECT * FROM cs_data_set WHERE (pid = ? AND type IN (0,2)) dataSet.addAll(csDataSetService.findDataSetByModelId(item.getModelId())); @@ -532,9 +514,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl strings = JSONArray.parseArray(role, String.class); - if (strings.contains(AppRoleEnum.ENGINEERING_USER.getCode()) - || strings.contains(AppRoleEnum.OPERATION_MANAGER.getCode()) - || strings.contains(AppRoleEnum.ROOT.getCode())) { + if (strings.contains(AppRoleEnum.ENGINEERING_USER.getCode()) || strings.contains(AppRoleEnum.OPERATION_MANAGER.getCode()) || strings.contains(AppRoleEnum.ROOT.getCode())) { addDataSet(dataSetList, item, "模块数据", "moduleData"); } } @@ -744,20 +724,12 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl list = csEquipmentProcessPOService.lambdaQuery().eq(CsEquipmentProcessPO::getDevId, one.getNdid()). - eq(CsEquipmentProcessPO::getProcess, type).orderByDesc(CsEquipmentProcessPO::getStartTime).list(); + List list = csEquipmentProcessPOService.lambdaQuery().eq(CsEquipmentProcessPO::getDevId, one.getNdid()).eq(CsEquipmentProcessPO::getProcess, type).orderByDesc(CsEquipmentProcessPO::getStartTime).list(); //获取最新一条数据; CsEquipmentProcessPO csEquipmentProcessPO = list.get(0); - csEquipmentProcessPOService.lambdaUpdate().eq(CsEquipmentProcessPO::getId, csEquipmentProcessPO.getId()). - set(CsEquipmentProcessPO::getStatus, 1). - set(CsEquipmentProcessPO::getEndTime, LocalDateTime.now()). - set(CsEquipmentProcessPO::getRemark, remark). - update(); + csEquipmentProcessPOService.lambdaUpdate().eq(CsEquipmentProcessPO::getId, csEquipmentProcessPO.getId()).set(CsEquipmentProcessPO::getStatus, 1).set(CsEquipmentProcessPO::getEndTime, LocalDateTime.now()).set(CsEquipmentProcessPO::getRemark, remark).update(); } @Override @@ -768,24 +740,17 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl list = csEquipmentProcessPOService.lambdaQuery().eq(CsEquipmentProcessPO::getDevId, one.getNdid()). - eq(CsEquipmentProcessPO::getProcess, type).orderByDesc(CsEquipmentProcessPO::getStartTime).list(); + List list = csEquipmentProcessPOService.lambdaQuery().eq(CsEquipmentProcessPO::getDevId, one.getNdid()).eq(CsEquipmentProcessPO::getProcess, type).orderByDesc(CsEquipmentProcessPO::getStartTime).list(); //获取最新一条数据; CsEquipmentProcessPO csEquipmentProcessPO = list.get(0); - csEquipmentProcessPOService.lambdaUpdate().eq(CsEquipmentProcessPO::getId, csEquipmentProcessPO.getId()). - set(CsEquipmentProcessPO::getStatus, 0). - set(CsEquipmentProcessPO::getEndTime, LocalDateTime.now()). - set(CsEquipmentProcessPO::getRemark, remark). - update(); + csEquipmentProcessPOService.lambdaUpdate().eq(CsEquipmentProcessPO::getId, csEquipmentProcessPO.getId()).set(CsEquipmentProcessPO::getStatus, 0).set(CsEquipmentProcessPO::getEndTime, LocalDateTime.now()).set(CsEquipmentProcessPO::getRemark, remark).update(); } @Override public void updateSoftInfo(String nDid, String id) { boolean result; LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper<>(); - lambdaUpdateWrapper.eq(CsEquipmentDeliveryPO::getNdid, nDid) - .ne(CsEquipmentDeliveryPO::getRunStatus, 0) - .set(CsEquipmentDeliveryPO::getSoftinfoId, id); + lambdaUpdateWrapper.eq(CsEquipmentDeliveryPO::getNdid, nDid).ne(CsEquipmentDeliveryPO::getRunStatus, 0).set(CsEquipmentDeliveryPO::getSoftinfoId, id); result = this.update(lambdaUpdateWrapper); if (result) { refreshDeviceDataCache(); @@ -796,9 +761,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl lambdaUpdateWrapper = new LambdaUpdateWrapper<>(); - lambdaUpdateWrapper.eq(CsEquipmentDeliveryPO::getNdid, nDid) - .ne(CsEquipmentDeliveryPO::getRunStatus, 0) - .set(CsEquipmentDeliveryPO::getModuleNumber, number); + lambdaUpdateWrapper.eq(CsEquipmentDeliveryPO::getNdid, nDid).ne(CsEquipmentDeliveryPO::getRunStatus, 0).set(CsEquipmentDeliveryPO::getModuleNumber, number); result = this.update(lambdaUpdateWrapper); if (result) { refreshDeviceDataCache(); @@ -832,11 +795,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl getAllOnline() { - return this.lambdaQuery() - .ne(CsEquipmentDeliveryPO::getRunStatus, 0) - .eq(CsEquipmentDeliveryPO::getUsageStatus, 1) - .isNotNull(CsEquipmentDeliveryPO::getNodeId) - .list(); + return this.lambdaQuery().ne(CsEquipmentDeliveryPO::getRunStatus, 0).eq(CsEquipmentDeliveryPO::getUsageStatus, 1).isNotNull(CsEquipmentDeliveryPO::getNodeId).list(); } @Override @@ -974,9 +933,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNdid, param.getNdid()) - .in(CsEquipmentDeliveryPO::getStatus, Arrays.asList(1, 2, 3)) - .ne(CsEquipmentDeliveryPO::getId, param.getId()); + lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNdid, param.getNdid()).in(CsEquipmentDeliveryPO::getStatus, Arrays.asList(1, 2, 3)).ne(CsEquipmentDeliveryPO::getId, param.getId()); int countByAccount = this.count(lambdaQueryWrapper); //大于等于1个则表示重复 if (countByAccount >= 1) { @@ -985,11 +942,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl lambdaQueryWrapper2 = new LambdaQueryWrapper<>(); lambdaQueryWrapper2.eq(CsEquipmentDeliveryPO::getId, param.getId()); CsEquipmentDeliveryPO po = this.baseMapper.selectOne(lambdaQueryWrapper2); - List list = this.lambdaQuery() - .ne(CsEquipmentDeliveryPO::getId, param.getId()) - .ne(CsEquipmentDeliveryPO::getNdid, param.getNdid()) - .eq(CsEquipmentDeliveryPO::getName, param.getName()) - .ne(CsEquipmentDeliveryPO::getRunStatus, 0).list(); + List list = this.lambdaQuery().ne(CsEquipmentDeliveryPO::getId, param.getId()).ne(CsEquipmentDeliveryPO::getNdid, param.getNdid()).eq(CsEquipmentDeliveryPO::getName, param.getName()).ne(CsEquipmentDeliveryPO::getRunStatus, 0).list(); if (!CollectionUtils.isEmpty(list)) { throw new BusinessException("设备名称不能重复"); } @@ -1041,9 +994,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId,id) - .in(ObjectUtil.isNotEmpty(state),CsEquipmentDeliveryPO::getUsageStatus,state) - .eq(CsEquipmentDeliveryPO::getDevAccessMethod,"CLD"); + lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId, id).in(ObjectUtil.isNotEmpty(state), CsEquipmentDeliveryPO::getUsageStatus, state).eq(CsEquipmentDeliveryPO::getDevAccessMethod, "CLD"); return this.list(lambdaQueryWrapper); } @@ -1052,10 +1003,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId, nodeId) - .eq(CsEquipmentDeliveryPO::getNodeProcess, processNo) - .eq(CsEquipmentDeliveryPO::getUsageStatus, 1) - .eq(CsEquipmentDeliveryPO::getRunStatus, 2); + lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId, nodeId).eq(CsEquipmentDeliveryPO::getNodeProcess, processNo).eq(CsEquipmentDeliveryPO::getUsageStatus, 1).eq(CsEquipmentDeliveryPO::getRunStatus, 2); List devList = this.list(lambdaQueryWrapper); if (CollectionUtil.isNotEmpty(devList)) { //修改设备运行状态 @@ -1071,9 +1019,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getId, devId) - .eq(CsEquipmentDeliveryPO::getUsageStatus, 1) - .ne(CsEquipmentDeliveryPO::getUsageStatus, 0); + lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getId, devId).eq(CsEquipmentDeliveryPO::getUsageStatus, 1).ne(CsEquipmentDeliveryPO::getUsageStatus, 0); CsEquipmentDeliveryPO po = this.getOne(lambdaQueryWrapper); if (ObjectUtil.isNotNull(po)) { po.setRunStatus(status); @@ -1109,9 +1055,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl getDataByNodeIdAndProcessNo(String nodeId, Integer processNo) { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId, nodeId) - .ne(CsEquipmentDeliveryPO::getRunStatus, 0) - .eq(CsEquipmentDeliveryPO::getDevAccessMethod, "CLD"); + lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId, nodeId).ne(CsEquipmentDeliveryPO::getRunStatus, 0).eq(CsEquipmentDeliveryPO::getDevAccessMethod, "CLD"); if (ObjectUtil.isNotNull(processNo)) { lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeProcess, processNo); } @@ -1124,23 +1068,29 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl versionPage(BaseParam baseParam) { + public IPage versionPage(CsEquipmentDeliveryQueryParm baseParam) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.ne(CsEquipmentDeliveryPO::getRunStatus, 0) + .eq(StrUtil.isNotBlank(baseParam.getDevModel()), CsEquipmentDeliveryPO::getDevModel, baseParam.getDevModel()) + .eq(StrUtil.isNotBlank(baseParam.getIcd()), CsEquipmentDeliveryPO::getIcd, baseParam.getIcd()) + .eq(ObjectUtil.isNotNull(baseParam.getUpgrade()), CsEquipmentDeliveryPO::getUpgrade, baseParam.getUpgrade()) .like(StrUtil.isNotBlank(baseParam.getSearchValue()), CsEquipmentDeliveryPO::getName, baseParam.getSearchValue()); Page page = this.page(new Page<>(PageFactory.getPageNum(baseParam), PageFactory.getPageSize(baseParam)), wrapper); List records = new ArrayList<>(); + List finalRecords = records; page.getRecords().forEach(item -> { DevVersionVO devVersionVO = BeanUtil.copyProperties(item, DevVersionVO.class); + List userData = userFeignClient.getUserByIdList(Collections.singletonList(item.getUpdateBy())).getData(); + if (CollectionUtil.isNotEmpty(userData)) { + devVersionVO.setUpdateByName(userData.get(0).getName()); + } 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()); @@ -1149,11 +1099,11 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl resultPage = new Page<>(PageFactory.getPageNum(baseParam), PageFactory.getPageSize(baseParam)); - + if (ObjectUtil.isNotNull(baseParam.getConnectStatus())) { + records = records.stream().filter(item -> baseParam.getConnectStatus().equals(item.getConnectStatus())).collect(Collectors.toList()); + } + resultPage.setTotal(CollectionUtil.isEmpty(records) ? 0 : records.size()); resultPage.setRecords(records); resultPage.setTotal(page.getTotal()); resultPage.setMaxLimit(page.getMaxLimit()); @@ -1184,9 +1146,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getDevType, vo.getId()) - .ne(CsEquipmentDeliveryPO::getRunStatus, 0) - .eq(CsEquipmentDeliveryPO::getUsageStatus, 1); + lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getDevType, vo.getId()).ne(CsEquipmentDeliveryPO::getRunStatus, 0).eq(CsEquipmentDeliveryPO::getUsageStatus, 1); //获取用户已经绑定的便携式设备 List devList = csDeviceUserPOService.findDevByUserId(userId); if (CollectionUtil.isNotEmpty(devList)) { @@ -1200,12 +1160,8 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl list = csLedgerService.list(queryWrapper); if (CollectionUtil.isNotEmpty(list)) { - Set idSet = list.stream() - .map(CsLedger::getId) - .collect(Collectors.toSet()); - return result.stream() - .filter(data -> idSet.contains(data.getId())) - .collect(Collectors.toList()); + Set idSet = list.stream().map(CsLedger::getId).collect(Collectors.toSet()); + return result.stream().filter(data -> idSet.contains(data.getId())).collect(Collectors.toList()); } else { result.clear(); return result; @@ -1217,22 +1173,17 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl getListByNodeId(String nodeId) { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId, nodeId) - .in(CsEquipmentDeliveryPO::getRunStatus, Arrays.asList(1, 2)); + lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId, nodeId).in(CsEquipmentDeliveryPO::getRunStatus, Arrays.asList(1, 2)); return this.list(lambdaQueryWrapper); } public int findLeastFrequentProcess(List items, Integer process) { - Map processCounts = items.stream() - .collect(Collectors.groupingBy(CsEquipmentDeliveryPO::getNodeProcess, Collectors.counting())); + Map processCounts = items.stream().collect(Collectors.groupingBy(CsEquipmentDeliveryPO::getNodeProcess, Collectors.counting())); for (int i = 1; i <= process; i++) { processCounts.putIfAbsent(i, 0L); } //如果列表为空,默认返回1 - return processCounts.entrySet().stream() - .min(Comparator.comparingLong(Map.Entry::getValue)) - .map(Map.Entry::getKey) - .orElse(1); + return processCounts.entrySet().stream().min(Comparator.comparingLong(Map.Entry::getValue)).map(Map.Entry::getKey).orElse(1); } /**