diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/EquipmentFeignClient.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/EquipmentFeignClient.java index 0fcdd4a..48b42c7 100644 --- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/EquipmentFeignClient.java +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/EquipmentFeignClient.java @@ -3,6 +3,7 @@ package com.njcn.csdevice.api; import com.njcn.common.pojo.constant.ServerInfo; import com.njcn.common.pojo.response.HttpResult; import com.njcn.csdevice.api.fallback.EquipmentFeignClientFallbackFactory; +import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO; import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO; import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO; import org.springframework.cloud.openfeign.FeignClient; @@ -23,5 +24,5 @@ public interface EquipmentFeignClient { @PostMapping("/updateStatusBynDid") HttpResult updateStatusBynDid(@RequestParam("nDId") String nDid,@RequestParam("status") Integer status); @PostMapping("/queryEquipmentById") - HttpResult> queryDeviceById(@RequestParam("ids") List ids); + HttpResult> queryDeviceById(@RequestParam("ids") List ids); } diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/fallback/EquipmentFeignClientFallbackFactory.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/fallback/EquipmentFeignClientFallbackFactory.java index 171183d..2de3b1c 100644 --- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/fallback/EquipmentFeignClientFallbackFactory.java +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/fallback/EquipmentFeignClientFallbackFactory.java @@ -4,6 +4,7 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.response.HttpResult; import com.njcn.csdevice.api.EquipmentFeignClient; +import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO; import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO; import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO; import feign.hystrix.FallbackFactory; @@ -42,7 +43,7 @@ public class EquipmentFeignClientFallbackFactory implements FallbackFactory> queryDeviceById(List ids) { + public HttpResult> queryDeviceById(List ids) { log.error("{}异常,降级处理,异常为:{}","查询出厂设备详情",cause.toString()); throw new BusinessException(finalExceptionEnum); } diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/enums/AlgorithmResponseEnum.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/enums/AlgorithmResponseEnum.java index 223bfa0..6b01f57 100644 --- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/enums/AlgorithmResponseEnum.java +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/enums/AlgorithmResponseEnum.java @@ -28,8 +28,8 @@ public enum AlgorithmResponseEnum { LOSE_EFFICACY ("A00509","二维码失效,该设备已绑定"), DATA_LOSE ("A00510","未找到设备与主用户信息"), REPEAT_SHARE ("A00511","设备已分享完成,请勿再次分享"), - DEVICE_LOSE("A00512","设备id缺失") - + DEVICE_LOSE("A00512","设备id缺失"), + CHIRLDREN_EXIST("A00513","工程下存在项目,不能删除"); ; diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/dto/CsEquipmentDeliveryDTO.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/dto/CsEquipmentDeliveryDTO.java new file mode 100644 index 0000000..1ccd6c1 --- /dev/null +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/dto/CsEquipmentDeliveryDTO.java @@ -0,0 +1,115 @@ +package com.njcn.csdevice.pojo.dto; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.njcn.db.bo.BaseEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * + * Description: + * 接口文档访问地址:http://serverIP:port/swagger-ui.html + * Date: 2023/3/30 16:23【需求编号】 + * + * @author clam + * @version V1.0.0 + */ + +/** + * 设备出厂表 + */ +@Data +@NoArgsConstructor +public class CsEquipmentDeliveryDTO { + /** + * id + */ + @TableField(value = "id") + private String id; + + /** + * 装置名称 + */ + @TableField(value = "name") + private String name; + + /** + * 网关识别码 + */ + @TableField(value = "ndid") + private String ndid; + + /** + * 装置mac地址 + */ + @TableField(value = "mac") + private String mac; + + /** + * 装置用途(治理、监测...) + */ +// @TableField(value = "dev_use") +// private String devUse; + + /** + * 装置类型(直连设备、网关设备、装置) + */ + @TableField(value = "dev_type") + private String devType; + + /** + * 装置型号(pqs588、pqs680...) + */ + @TableField(value = "dev_model") + private String devModel; + + /** + * 装置接入方式(mqtt、cloud) + */ + @TableField(value = "dev_access_method") + private String devAccessMethod; + + /** + * 装置程序版本 + */ + @TableField(value = "program_version") + private String programVersion; + + /** + * 调试人员 + */ + @TableField(value = "debug_person") + private String debugPerson; + + + + /** + * 合同号 + */ + @TableField(value = "cntract_no") + private String cntractNo; + + /** + * 营销经理 + */ + @TableField(value = "sales_manager") + private String salesManager; + + /** + * 接入状态(1:未注册 2:注册 3:接入) + */ + @TableField(value = "status") + private String status; + + /** + * 设备状态(0:删除 1:离线 2:在线) + */ + @TableField(value = "run_status") + private Integer runStatus; + + +} \ No newline at end of file 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 3c517a6..b1a05ac 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 @@ -7,6 +7,7 @@ import com.njcn.common.pojo.enums.common.LogEnum; import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.utils.HttpResultUtil; +import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO; import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryAddParm; import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryAuditParm; import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryQueryParm; @@ -24,10 +25,12 @@ import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import java.util.List; +import java.util.stream.Collectors; /** * Description: @@ -121,10 +124,15 @@ public class EquipmentDeliveryController extends BaseController { @PostMapping("/queryEquipmentById") @ApiOperation("设备查询通过id获取") @ApiImplicitParam(name = "ids", value = "设备id集合", required = true) - public HttpResult> queryEquipmentById(@RequestParam List ids){ + public HttpResult> queryEquipmentById(@RequestParam List ids){ String methodDescribe = getMethodDescribe("queryEquipmentById"); List csEquipmentDeliveryPOS = csEquipmentDeliveryService.listByIds(ids); - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, csEquipmentDeliveryPOS, methodDescribe); + List collect = csEquipmentDeliveryPOS.stream().map(temp -> { + CsEquipmentDeliveryDTO csEquipmentDeliveryDTO = new CsEquipmentDeliveryDTO(); + BeanUtils.copyProperties(temp, csEquipmentDeliveryDTO); + return csEquipmentDeliveryDTO; + }).collect(Collectors.toList()); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, collect, methodDescribe); } @OperateInfo(info = LogEnum.BUSINESS_COMMON) diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsDeviceUserPOServiceImpl.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsDeviceUserPOServiceImpl.java index ebe1a75..92e4ecb 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsDeviceUserPOServiceImpl.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsDeviceUserPOServiceImpl.java @@ -1,7 +1,10 @@ package com.njcn.csdevice.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.njcn.common.pojo.exception.BusinessException; import com.njcn.csdevice.enums.AlgorithmResponseEnum; @@ -133,6 +136,7 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl list = this.lambdaQuery().eq(CsDeviceUserPO::getDeviceId, eid).eq(CsDeviceUserPO::getStatus,"1" ).list(); if(CollectionUtils.isEmpty(list)){ throw new BusinessException(AlgorithmResponseEnum.DATA_LOSE); } - this.update(this.lambdaUpdate().eq(CsDeviceUserPO::getDeviceId, eid).set(CsDeviceUserPO::getStatus,"0")); - String userIndex = RequestUtil.getUserIndex(); - list.forEach(temp->{ - temp.setPrimaryUserId(userIndex); - temp.setStatus("1"); - if(temp.getPrimaryUserId().equals(temp.getSubUserId())){ - temp.setSubUserId(userIndex); - } - }); - this.saveBatch(list) ; + this.lambdaUpdate().eq(CsDeviceUserPO::getDeviceId, eid).eq(CsDeviceUserPO::getStatus,"1" ).apply("primary_user_id=sub_user_id").set(CsDeviceUserPO::getPrimaryUserId,userIndex).set(CsDeviceUserPO::getSubUserId,userIndex).update(); + this.lambdaUpdate().eq(CsDeviceUserPO::getDeviceId, eid).eq(CsDeviceUserPO::getStatus,"1" ).apply("primary_user_id<>sub_user_id").set(CsDeviceUserPO::getPrimaryUserId,userIndex).update(); + return true; } @@ -188,7 +187,7 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("status",1).eq("pid",csEngineeringAuditParm.getId()); + List csLedgers = csLedgerMapper.selectList(queryWrapper); + if(!CollectionUtil.isEmpty(csLedgers)){ + throw new BusinessException(AlgorithmResponseEnum.CHIRLDREN_EXIST.getMessage()); + } csLedger1.setState(0); + } if(StringUtils.isNotBlank(csEngineeringAuditParm.getName())){ csLedger1.setName(csEngineeringAuditParm.getName()); diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/mapping/CsConfigurationMapper.xml b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/mapping/CsConfigurationMapper.xml index a5c6a7f..8cae915 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/mapping/CsConfigurationMapper.xml +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/mapping/CsConfigurationMapper.xml @@ -25,7 +25,7 @@ #{item} - AND a.name = #{temp.searchValue} + AND a.name like concat(concat("%",#{temp.searchValue}),"%") AND a.create_time <= #{temp.searchEndTime}" diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsConfigurationServiceImpl.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsConfigurationServiceImpl.java index 8268b6f..72d43e7 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsConfigurationServiceImpl.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsConfigurationServiceImpl.java @@ -51,6 +51,7 @@ public class CsConfigurationServiceImpl extends ServiceImpl projectIds = csConfigurationParm.getProjectIds(); @@ -66,6 +67,12 @@ public class CsConfigurationServiceImpl extends ServiceImpl1){ + throw new BusinessException("存在相同的组态项目名称"); + } return save; } diff --git a/cs-warn/cs-warn-boot/src/main/java/com/njcn/cswarn/service/impl/CsEquipmentAlarmPOServiceImpl.java b/cs-warn/cs-warn-boot/src/main/java/com/njcn/cswarn/service/impl/CsEquipmentAlarmPOServiceImpl.java index 3d95e4d..572b220 100644 --- a/cs-warn/cs-warn-boot/src/main/java/com/njcn/cswarn/service/impl/CsEquipmentAlarmPOServiceImpl.java +++ b/cs-warn/cs-warn-boot/src/main/java/com/njcn/cswarn/service/impl/CsEquipmentAlarmPOServiceImpl.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.njcn.csdevice.api.AppProjectFeignClient; import com.njcn.csdevice.api.EquipmentFeignClient; +import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO; import com.njcn.csdevice.pojo.po.AppProjectPO; import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO; import com.njcn.cswarn.mapper.CsEquipmentAlarmPOMapper; @@ -60,11 +61,11 @@ public class CsEquipmentAlarmPOServiceImpl extends ServiceImpl data = equipmentFeignClient.queryDeviceById(Stream.of(csEquipmentAlarmAddParm.getEquipmentId()).collect(toList())).getData(); + List data = equipmentFeignClient.queryDeviceById(Stream.of(csEquipmentAlarmAddParm.getEquipmentId()).collect(toList())).getData(); List data1 = appProjectFeignClient.queryProjectById(Stream.of(csEquipmentAlarmAddParm.getProjectId()).collect(toList())).getData(); List data3 = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.ALARM_TYPE.getCode()).getData(); - Map collect3 = data.stream().collect(Collectors.toMap(CsEquipmentDeliveryPO::getId, CsEquipmentDeliveryPO::getName)); + Map collect3 = data.stream().collect(Collectors.toMap(CsEquipmentDeliveryDTO::getId, CsEquipmentDeliveryDTO::getName)); Map collect4 = data1.stream().collect(Collectors.toMap(AppProjectPO::getId, AppProjectPO::getName)); Map collect5 = data3.stream().collect(Collectors.toMap(DictData::getId, DictData::getName)); csEquipmentAlarmVO.setEquipmentName(collect3.get(csEquipmentAlarmAddParm.getEquipmentId())); @@ -92,11 +93,11 @@ public class CsEquipmentAlarmPOServiceImpl extends ServiceImpl collect1 = csEquipmentAlarmPOPage.getRecords().stream().map(CsEquipmentAlarmPO::getProjectId).distinct().collect(toList()); List collect2 = csEquipmentAlarmPOPage.getRecords().stream().map(CsEquipmentAlarmPO::getEquipmentId).distinct().collect(toList()); - List data = equipmentFeignClient.queryDeviceById(collect2).getData(); + List data = equipmentFeignClient.queryDeviceById(collect2).getData(); List data1 = appProjectFeignClient.queryProjectById(collect1).getData(); List data3 = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.ALARM_TYPE.getCode()).getData(); - Map collect3 = data.stream().collect(Collectors.toMap(CsEquipmentDeliveryPO::getId, CsEquipmentDeliveryPO::getName)); + Map collect3 = data.stream().collect(Collectors.toMap(CsEquipmentDeliveryDTO::getId, CsEquipmentDeliveryDTO::getName)); Map collect4 = data1.stream().collect(Collectors.toMap(AppProjectPO::getId, AppProjectPO::getName)); Map collect5 = data3.stream().collect(Collectors.toMap(DictData::getId, DictData::getName)); @@ -128,20 +129,21 @@ public class CsEquipmentAlarmPOServiceImpl extends ServiceImpl collect1 = csEquipmentAlarmPOS.stream().map(CsEquipmentAlarmPO::getProjectId).distinct().collect(toList()); List collect2 = csEquipmentAlarmPOS.stream().map(CsEquipmentAlarmPO::getEquipmentId).distinct().collect(toList()); - List data = equipmentFeignClient.queryDeviceById(collect2).getData(); + List data = equipmentFeignClient.queryDeviceById(collect2).getData(); List data1 = appProjectFeignClient.queryProjectById(collect1).getData(); List data3 = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.ALARM_TYPE.getCode()).getData(); - Map collect3 = data.stream().collect(Collectors.toMap(CsEquipmentDeliveryPO::getId, CsEquipmentDeliveryPO::getName)); + Map collect3 = data.stream().collect(Collectors.toMap(CsEquipmentDeliveryDTO::getId, CsEquipmentDeliveryDTO::getName)); Map collect4 = data1.stream().collect(Collectors.toMap(AppProjectPO::getId, AppProjectPO::getName)); Map collect5 = data3.stream().collect(Collectors.toMap(DictData::getId, DictData::getName)); List collect = csEquipmentAlarmPOS.stream().map(temp -> { CsEquipmentAlarmVO csEquipmentAlarmVO = new CsEquipmentAlarmVO(); + BeanUtils.copyProperties(temp, csEquipmentAlarmVO); csEquipmentAlarmVO.setEquipmentName(collect3.get(temp.getEquipmentId())); - csEquipmentAlarmVO.setAlarmLevelName(collect4.get(temp.getAlarmLevel())); - csEquipmentAlarmVO.setProjectName(collect5.get(temp.getProjectId())); + csEquipmentAlarmVO.setAlarmLevelName(collect5.get(temp.getAlarmLevel())); + csEquipmentAlarmVO.setProjectName(collect4.get(temp.getProjectId())); return csEquipmentAlarmVO; }).collect(toList());