diff --git a/detection/src/main/java/com/njcn/gather/detection/handler/SocketSourceResponseService.java b/detection/src/main/java/com/njcn/gather/detection/handler/SocketSourceResponseService.java index eddd90aa..d5095b43 100644 --- a/detection/src/main/java/com/njcn/gather/detection/handler/SocketSourceResponseService.java +++ b/detection/src/main/java/com/njcn/gather/detection/handler/SocketSourceResponseService.java @@ -147,7 +147,6 @@ public class SocketSourceResponseService { switch (dictDataEnumByCode) { case SUCCESS: - //todo 前端推送收到的消息暂未处理好 webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketDataMsg)); String s = param.getUserPageId() + DEV; diff --git a/detection/src/main/java/com/njcn/gather/plan/service/IAdPlanService.java b/detection/src/main/java/com/njcn/gather/plan/service/IAdPlanService.java index 8c4eeaa0..66006b9e 100644 --- a/detection/src/main/java/com/njcn/gather/plan/service/IAdPlanService.java +++ b/detection/src/main/java/com/njcn/gather/plan/service/IAdPlanService.java @@ -99,4 +99,6 @@ public interface IAdPlanService extends IService { * @return */ boolean updateTestState(String planId); + + void finishPlan(String planId); } diff --git a/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java b/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java index 26d1f7eb..e2f91745 100644 --- a/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/plan/service/impl/AdPlanServiceImpl.java @@ -337,6 +337,13 @@ public class AdPlanServiceImpl extends ServiceImpl impleme .eq(AdPlan::getId,planId)); } + @Override + public void finishPlan(String planId) { + this.lambdaUpdate().eq(AdPlan::getId, planId) + .set(AdPlan::getTestState, CheckStateEnum.CHECKED.getValue()); + } + + /** * 逆向可视化 * diff --git a/detection/src/main/java/com/njcn/gather/report/service/impl/ReportServiceImpl.java b/detection/src/main/java/com/njcn/gather/report/service/impl/ReportServiceImpl.java index a2e44add..c528f361 100644 --- a/detection/src/main/java/com/njcn/gather/report/service/impl/ReportServiceImpl.java +++ b/detection/src/main/java/com/njcn/gather/report/service/impl/ReportServiceImpl.java @@ -96,6 +96,9 @@ public class ReportServiceImpl implements IReportService { baseModelDocument.write(response.getOutputStream()); response.getOutputStream().flush(); System.out.println("报告生成成功!"); + + // 将改设备的报告生成状态调整为已生成 + iPqDevService.updatePqDevReportState(devReportParam.getDevId(),1); } catch (Exception e) { throw new RuntimeException(e); } diff --git a/device/pom.xml b/device/pom.xml index eeaf245c..3fc98b80 100644 --- a/device/pom.xml +++ b/device/pom.xml @@ -34,6 +34,12 @@ 1.0.0 compile + + com.njcn.gather + detection + 1.0.0 + compile + com.alibaba fastjson diff --git a/device/src/main/java/com/njcn/gather/device/device/service/IPqDevService.java b/device/src/main/java/com/njcn/gather/device/device/service/IPqDevService.java index 7abe1a55..5a083360 100644 --- a/device/src/main/java/com/njcn/gather/device/device/service/IPqDevService.java +++ b/device/src/main/java/com/njcn/gather/device/device/service/IPqDevService.java @@ -187,4 +187,6 @@ public interface IPqDevService extends IService { * @return */ boolean updateResult(List ids,String code); + + void updatePqDevReportState(String devId, int i); } diff --git a/device/src/main/java/com/njcn/gather/device/device/service/impl/PqDevServiceImpl.java b/device/src/main/java/com/njcn/gather/device/device/service/impl/PqDevServiceImpl.java index 32afb639..717ee0a4 100644 --- a/device/src/main/java/com/njcn/gather/device/device/service/impl/PqDevServiceImpl.java +++ b/device/src/main/java/com/njcn/gather/device/device/service/impl/PqDevServiceImpl.java @@ -26,6 +26,7 @@ import com.njcn.gather.device.monitor.pojo.po.PqMonitor; import com.njcn.gather.device.monitor.pojo.vo.PqMonitorExcel; import com.njcn.gather.device.monitor.service.IPqMonitorService; import com.njcn.gather.device.pojo.enums.*; +import com.njcn.gather.plan.service.IAdPlanService; import com.njcn.gather.storage.service.DetectionDataDealService; import com.njcn.gather.system.dictionary.pojo.po.DictData; import com.njcn.gather.system.dictionary.service.IDictDataService; @@ -52,6 +53,7 @@ public class PqDevServiceImpl extends ServiceImpl implements private final IDictDataService dictDataService; private final IPqMonitorService pqMonitorService; private final DetectionDataDealService detectionDataDealService; + private final IAdPlanService adPlanService; @Override @@ -447,13 +449,27 @@ public class PqDevServiceImpl extends ServiceImpl implements // 只有检测完成的设备才可以进行归档 PqDev pqDev = this.getById(id); if (ObjectUtil.isNotNull(pqDev) && !pqDev.getCheckState().equals(CheckStateEnum.CHECKED.getValue())) { - return this.lambdaUpdate() -// .set(PqDev::getDocumentState, DevDocumentStateEnum.DOCUMENTED.getValue()) + boolean update = this.lambdaUpdate() .set(PqDev::getCheckState, CheckStateEnum.DOCUMENTED.getValue()) .eq(PqDev::getId, id) .update(); + if (update) { + // 判断计划下所有设备是否都已归档,如果是则将计划改为已完成 + // 查询该计划下所有设备的检测状态,是否有不为归档的 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(PqDev::getPlanId, pqDev.getPlanId()) + .eq(PqDev::getState, DataStateEnum.ENABLE.getCode()) + .ne(PqDev::getCheckState, CheckStateEnum.DOCUMENTED.getValue()); + int count = this.count(queryWrapper); + if(count == 0 ){ + // 如果非归档状态的设备数量为0,则更新计划已完成 + adPlanService.finishPlan(pqDev.getPlanId()); + } + } + return true; + } else { + throw new BusinessException(DevResponseEnum.DEV_UN_CHECKED); } - return false; } @Override @@ -468,14 +484,14 @@ public class PqDevServiceImpl extends ServiceImpl implements } @Override - public boolean updateResult(List ids,String code) { - if(CollUtil.isNotEmpty(ids)){ + public boolean updateResult(List ids, String code) { + if (CollUtil.isNotEmpty(ids)) { Map result = detectionDataDealService.devResult(ids, code); List list = this.list(new LambdaQueryWrapper().in(PqDev::getId, ids)); for (PqDev pqDev : list) { - if(result.containsKey(pqDev.getId())){ + if (result.containsKey(pqDev.getId())) { this.update(new LambdaUpdateWrapper() - .set(PqDev::getReCheckNum, pqDev.getReCheckNum()+1) + .set(PqDev::getReCheckNum, pqDev.getReCheckNum() + 1) .set(PqDev::getCheckState, CheckStateEnum.CHECKED.getValue()) .set(PqDev::getCheckResult, result.get(pqDev.getId())) .set(PqDev::getReportState, DevReportStateEnum.NOT_GENERATED.getValue()) @@ -487,6 +503,14 @@ public class PqDevServiceImpl extends ServiceImpl implements return true; } + @Override + public void updatePqDevReportState(String devId, int reportState) { + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.eq(PqDev::getId, devId) + .set(PqDev::getReportState, reportState); + this.update(updateWrapper); + } + /** * 获取检测状态饼状图数据 * diff --git a/device/src/main/java/com/njcn/gather/device/pojo/enums/DevResponseEnum.java b/device/src/main/java/com/njcn/gather/device/pojo/enums/DevResponseEnum.java index 3604cac9..a6786499 100644 --- a/device/src/main/java/com/njcn/gather/device/pojo/enums/DevResponseEnum.java +++ b/device/src/main/java/com/njcn/gather/device/pojo/enums/DevResponseEnum.java @@ -19,6 +19,7 @@ public enum DevResponseEnum { IMPORT_DATA_FORMAT_FAIL("A001011", "导入数据格式错误"), IMPORT_SOURCE_ERROR("A001012","当前模式下一个检测计划只能有一个检测源" ), IMPORT_DATASOURCE_ERROR("A001013","当前模式下一个检测计划只能有一个数据源" ), + DEV_UN_CHECKED("A001013","装置还未检测完成!" ), DEVICE_DIS_ERROR("A001014","装置配置异常" ); private final String message; diff --git a/device/src/main/java/com/njcn/gather/device/type/controller/DevTypeController.java b/device/src/main/java/com/njcn/gather/device/type/controller/DevTypeController.java new file mode 100644 index 00000000..ba7fffd1 --- /dev/null +++ b/device/src/main/java/com/njcn/gather/device/type/controller/DevTypeController.java @@ -0,0 +1,65 @@ +package com.njcn.gather.device.type.controller; + + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.njcn.common.pojo.annotation.OperateInfo; +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.LogUtil; +import com.njcn.gather.device.type.entity.DevType; +import com.njcn.gather.device.type.service.IDevTypeService; +import com.njcn.gather.system.dictionary.pojo.param.DictDataParam; +import com.njcn.gather.system.dictionary.pojo.po.DictData; +import com.njcn.gather.system.dictionary.service.IDictDataService; +import com.njcn.web.utils.HttpResultUtil; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; + +import org.springframework.web.bind.annotation.RestController; +import com.njcn.web.controller.BaseController; + +import java.util.List; + +/** + *

+ * 前端控制器 + *

+ * + * @author hongawen + * @since 2025-01-13 + */ +@Validated +@Slf4j +@Api(tags = "设备类型操作") +@RestController +@RequiredArgsConstructor +@RequestMapping("/devType") +public class DevTypeController extends BaseController { + + private final IDevTypeService devTypeService; + + /** + * 获取所有有效设备类型集合 + */ + @OperateInfo(info = LogEnum.SYSTEM_COMMON) + @PostMapping("/list") + @ApiOperation("获取所有有效设备类型集合") + public HttpResult> listAll() { + String methodDescribe = getMethodDescribe("listAll"); + List result = devTypeService.listAll(); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); + } + + + + +} + diff --git a/device/src/main/java/com/njcn/gather/device/type/entity/DevType.java b/device/src/main/java/com/njcn/gather/device/type/entity/DevType.java new file mode 100644 index 00000000..fdd8fa28 --- /dev/null +++ b/device/src/main/java/com/njcn/gather/device/type/entity/DevType.java @@ -0,0 +1,61 @@ +package com.njcn.gather.device.type.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.njcn.db.mybatisplus.bo.BaseEntity; +import lombok.Getter; +import lombok.Setter; + +/** + * + * @author hongawen + * @since 2025-01-13 + */ +@Getter +@Setter +@TableName("pq_dev_type") +public class DevType extends BaseEntity { + + private static final long serialVersionUID = 1L; + + /** + * 设备类型id + */ + private String id; + + /** + * 设备类型名称 + */ + private String name; + + /** + * 设备关联的ICD + */ + private String icd; + + /** + * 工作电源 + */ + private String power; + + /** + * 额定电压 + */ + private Double devVolt; + + /** + * 额定电流 + */ + private Double devCurr; + + /** + * 通道数 + */ + private Integer devChns; + + /** + * 状态:0-删除 1-正常 + */ + private Integer state; + +} diff --git a/device/src/main/java/com/njcn/gather/device/type/mapper/DevTypeMapper.java b/device/src/main/java/com/njcn/gather/device/type/mapper/DevTypeMapper.java new file mode 100644 index 00000000..8bb72349 --- /dev/null +++ b/device/src/main/java/com/njcn/gather/device/type/mapper/DevTypeMapper.java @@ -0,0 +1,17 @@ +package com.njcn.gather.device.type.mapper; + + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.njcn.gather.device.type.entity.DevType; + +/** + *

+ * Mapper 接口 + *

+ * + * @author hongawen + * @since 2025-01-13 + */ +public interface DevTypeMapper extends BaseMapper { + +} diff --git a/device/src/main/java/com/njcn/gather/device/type/mapper/mapping/DevTypeMapper.xml b/device/src/main/java/com/njcn/gather/device/type/mapper/mapping/DevTypeMapper.xml new file mode 100644 index 00000000..2c0fe0ee --- /dev/null +++ b/device/src/main/java/com/njcn/gather/device/type/mapper/mapping/DevTypeMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/device/src/main/java/com/njcn/gather/device/type/service/IDevTypeService.java b/device/src/main/java/com/njcn/gather/device/type/service/IDevTypeService.java new file mode 100644 index 00000000..0c501b7a --- /dev/null +++ b/device/src/main/java/com/njcn/gather/device/type/service/IDevTypeService.java @@ -0,0 +1,19 @@ +package com.njcn.gather.device.type.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.njcn.gather.device.type.entity.DevType; + +import java.util.List; + +/** + *

+ * 服务类 + *

+ * + * @author hongawen + * @since 2025-01-13 + */ +public interface IDevTypeService extends IService { + + List listAll(); +} diff --git a/device/src/main/java/com/njcn/gather/device/type/service/impl/DevTypeServiceImpl.java b/device/src/main/java/com/njcn/gather/device/type/service/impl/DevTypeServiceImpl.java new file mode 100644 index 00000000..cd0150c5 --- /dev/null +++ b/device/src/main/java/com/njcn/gather/device/type/service/impl/DevTypeServiceImpl.java @@ -0,0 +1,31 @@ +package com.njcn.gather.device.type.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.njcn.common.pojo.enums.common.DataStateEnum; +import com.njcn.gather.device.type.entity.DevType; +import com.njcn.gather.device.type.mapper.DevTypeMapper; +import com.njcn.gather.device.type.service.IDevTypeService; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + *

+ * 服务实现类 + *

+ * + * @author hongawen + * @since 2025-01-13 + */ +@Service +public class DevTypeServiceImpl extends ServiceImpl implements IDevTypeService { + + @Override + public List listAll() { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(DevType::getState, DataStateEnum.ENABLE.getCode()); + List devTypes = this.baseMapper.selectList(queryWrapper); + return devTypes; + } +} diff --git a/system/src/main/java/com/njcn/gather/system/config/pojo/po/SysTestConfig.java b/system/src/main/java/com/njcn/gather/system/config/pojo/po/SysTestConfig.java index 1f5fd35f..1b27fa43 100644 --- a/system/src/main/java/com/njcn/gather/system/config/pojo/po/SysTestConfig.java +++ b/system/src/main/java/com/njcn/gather/system/config/pojo/po/SysTestConfig.java @@ -41,6 +41,13 @@ public class SysTestConfig extends BaseEntity implements Serializable { @TableField("Data_Rule") private String dataRule; + /** + * 业务场景 + */ + @TableField("Scene") + private String scene; + + /** * 状态:0-删除 1-正常 */