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.core.date.DateUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.gather.detection.pojo.vo.DetectionData; import com.njcn.gather.detection.pojo.vo.DetectionData;
import com.njcn.gather.device.device.pojo.vo.PqDevVO; import com.njcn.gather.device.device.pojo.vo.PqDevVO;
import com.njcn.gather.device.device.service.IPqDevService; 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.PqScript;
import com.njcn.gather.device.script.pojo.po.PqScriptCheckData; import com.njcn.gather.device.script.pojo.po.PqScriptCheckData;
import com.njcn.gather.device.script.pojo.po.PqScriptDtls; import com.njcn.gather.device.script.pojo.po.PqScriptDtls;
@@ -99,6 +101,16 @@ public class ReportServiceImpl implements IReportService {
// 将改设备的报告生成状态调整为已生成 // 将改设备的报告生成状态调整为已生成
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) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

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

View File

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

View File

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

View File

@@ -189,4 +189,6 @@ public interface IPqDevService extends IService<PqDev> {
boolean updateResult(List<String> ids,String code); boolean updateResult(List<String> ids,String code);
void updatePqDevReportState(String devId, int i); 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.pojo.vo.PqMonitorExcel;
import com.njcn.gather.device.monitor.service.IPqMonitorService; import com.njcn.gather.device.monitor.service.IPqMonitorService;
import com.njcn.gather.device.pojo.enums.*; 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.storage.service.DetectionDataDealService;
import com.njcn.gather.system.dictionary.pojo.po.DictData; import com.njcn.gather.system.dictionary.pojo.po.DictData;
import com.njcn.gather.system.dictionary.service.IDictDataService; 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 IDictDataService dictDataService;
private final IPqMonitorService pqMonitorService; private final IPqMonitorService pqMonitorService;
private final DetectionDataDealService detectionDataDealService; private final DetectionDataDealService detectionDataDealService;
private final IAdPlanService adPlanService;
@Override @Override
@@ -463,7 +461,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
int count = this.count(queryWrapper); int count = this.count(queryWrapper);
if (count == 0) { if (count == 0) {
// 如果非归档状态的设备数量为0则更新计划已完成 // 如果非归档状态的设备数量为0则更新计划已完成
adPlanService.finishPlan(pqDev.getPlanId()); this.baseMapper.finishPlan(pqDev.getPlanId());
} }
} }
return true; return true;
@@ -511,6 +509,16 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
this.update(updateWrapper); 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);
}
/** /**
* 获取检测状态饼状图数据 * 获取检测状态饼状图数据
* *