1、报告生成修改状态;

2、设备全部归档,修改计划完成状态;
This commit is contained in:
2025-01-13 18:10:14 +08:00
parent 23d8bf8870
commit 9ca34607cc
15 changed files with 257 additions and 8 deletions

View File

@@ -147,7 +147,6 @@ public class SocketSourceResponseService {
switch (dictDataEnumByCode) {
case SUCCESS:
//todo 前端推送收到的消息暂未处理好
webSocketHandler.sendMsgToUser(param.getUserPageId(), JSON.toJSONString(socketDataMsg));
String s = param.getUserPageId() + DEV;

View File

@@ -99,4 +99,6 @@ public interface IAdPlanService extends IService<AdPlan> {
* @return
*/
boolean updateTestState(String planId);
void finishPlan(String planId);
}

View File

@@ -337,6 +337,13 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
.eq(AdPlan::getId,planId));
}
@Override
public void finishPlan(String planId) {
this.lambdaUpdate().eq(AdPlan::getId, planId)
.set(AdPlan::getTestState, CheckStateEnum.CHECKED.getValue());
}
/**
* 逆向可视化
*

View File

@@ -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);
}

View File

@@ -34,6 +34,12 @@
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.njcn.gather</groupId>
<artifactId>detection</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>

View File

@@ -187,4 +187,6 @@ public interface IPqDevService extends IService<PqDev> {
* @return
*/
boolean updateResult(List<String> ids,String code);
void updatePqDevReportState(String devId, int i);
}

View File

@@ -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<PqDevMapper, PqDev> 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<PqDevMapper, PqDev> 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<PqDev> 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<PqDevMapper, PqDev> implements
}
@Override
public boolean updateResult(List<String> ids,String code) {
if(CollUtil.isNotEmpty(ids)){
public boolean updateResult(List<String> ids, String code) {
if (CollUtil.isNotEmpty(ids)) {
Map<String, Integer> result = detectionDataDealService.devResult(ids, code);
List<PqDev> list = this.list(new LambdaQueryWrapper<PqDev>().in(PqDev::getId, ids));
for (PqDev pqDev : list) {
if(result.containsKey(pqDev.getId())){
if (result.containsKey(pqDev.getId())) {
this.update(new LambdaUpdateWrapper<PqDev>()
.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<PqDevMapper, PqDev> implements
return true;
}
@Override
public void updatePqDevReportState(String devId, int reportState) {
LambdaUpdateWrapper<PqDev> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(PqDev::getId, devId)
.set(PqDev::getReportState, reportState);
this.update(updateWrapper);
}
/**
* 获取检测状态饼状图数据
*

View File

@@ -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;

View File

@@ -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;
/**
* <p>
* 前端控制器
* </p>
*
* @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<List<DevType>> listAll() {
String methodDescribe = getMethodDescribe("listAll");
List<DevType> result = devTypeService.listAll();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
}

View File

@@ -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;
}

View File

@@ -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;
/**
* <p>
* Mapper 接口
* </p>
*
* @author hongawen
* @since 2025-01-13
*/
public interface DevTypeMapper extends BaseMapper<DevType> {
}

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.gather.device.type.mapper.DevTypeMapper">
</mapper>

View File

@@ -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;
/**
* <p>
* 服务类
* </p>
*
* @author hongawen
* @since 2025-01-13
*/
public interface IDevTypeService extends IService<DevType> {
List<DevType> listAll();
}

View File

@@ -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;
/**
* <p>
* 服务实现类
* </p>
*
* @author hongawen
* @since 2025-01-13
*/
@Service
public class DevTypeServiceImpl extends ServiceImpl<DevTypeMapper, DevType> implements IDevTypeService {
@Override
public List<DevType> listAll() {
LambdaQueryWrapper<DevType> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(DevType::getState, DataStateEnum.ENABLE.getCode());
List<DevType> devTypes = this.baseMapper.selectList(queryWrapper);
return devTypes;
}
}

View File

@@ -41,6 +41,13 @@ public class SysTestConfig extends BaseEntity implements Serializable {
@TableField("Data_Rule")
private String dataRule;
/**
* 业务场景
*/
@TableField("Scene")
private String scene;
/**
* 状态0-删除 1-正常
*/