1、报告生成修改状态;

2、设备全部归档,修改计划完成状态;
This commit is contained in:
2025-01-13 18:25:40 +08:00
parent 03c245758d
commit 54c909324c
6 changed files with 35 additions and 13 deletions

View File

@@ -5,11 +5,13 @@ import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.gather.detection.pojo.vo.DetectionData;
import com.njcn.gather.device.device.pojo.vo.PqDevVO;
import com.njcn.gather.device.device.service.IPqDevService;
import com.njcn.gather.device.pojo.enums.DevReportStateEnum;
import com.njcn.gather.device.script.pojo.po.PqScript;
import com.njcn.gather.device.script.pojo.po.PqScriptCheckData;
import com.njcn.gather.device.script.pojo.po.PqScriptDtls;
@@ -98,7 +100,17 @@ public class ReportServiceImpl implements IReportService {
System.out.println("报告生成成功!");
// 将改设备的报告生成状态调整为已生成
iPqDevService.updatePqDevReportState(devReportParam.getDevId(),1);
iPqDevService.updatePqDevReportState(devReportParam.getDevId(), 1);
// 判断该计划下是否所有设备报告已生成,如果已生成则将计划状态改为已完成
int count = iPqDevService.countUnReportDev(devReportParam.getPlanId());
if(count == 0){
LambdaUpdateWrapper<AdPlan> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(AdPlan::getId, devReportParam.getPlanId())
.set(AdPlan::getReportState, DevReportStateEnum.GENERATED.getValue());
adPlanService.update(updateWrapper);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -355,7 +367,7 @@ public class ReportServiceImpl implements IReportService {
private String devValue(String dataJson, double baseValue) {
DetectionData tempA = JSONUtil.toBean(dataJson, DetectionData.class);
if (Objects.nonNull(tempA) && Objects.nonNull(tempA.getData())) {
return doubleRound(4, (tempA.getData()/100) * baseValue);
return doubleRound(4, (tempA.getData() / 100) * baseValue);
}
return "/";
}

View File

@@ -34,12 +34,6 @@
<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

@@ -21,5 +21,7 @@ public interface PqDevMapper extends MPJBaseMapper<PqDev> {
* @Date: 2024/12/12 11:46
*/
List<PreDetection> selectDevInfo(@Param("devIds") List<String> devIds);
void finishPlan(@Param("planId")String planId);
}

View File

@@ -48,5 +48,9 @@
</if>
</where>
</select>
<update id="finishPlan" >
update ad_plan set Test_State = 2 where id = #{planId}
</update>
</mapper>

View File

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

View File

@@ -26,7 +26,6 @@ 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;
@@ -53,7 +52,6 @@ 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
@@ -461,9 +459,9 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode())
.ne(PqDev::getCheckState, CheckStateEnum.DOCUMENTED.getValue());
int count = this.count(queryWrapper);
if(count == 0 ){
if (count == 0) {
// 如果非归档状态的设备数量为0则更新计划已完成
adPlanService.finishPlan(pqDev.getPlanId());
this.baseMapper.finishPlan(pqDev.getPlanId());
}
}
return true;
@@ -511,6 +509,16 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
this.update(updateWrapper);
}
@Override
public int countUnReportDev(String planId) {
// 查询该计划下所有设备的检测状态,是否有未生成的
LambdaQueryWrapper<PqDev> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PqDev::getPlanId, planId)
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode())
.ne(PqDev::getReportState, DevReportStateEnum.GENERATED.getValue());
return this.count(queryWrapper);
}
/**
* 获取检测状态饼状图数据
*