归档前如果设备没有生成报告则自动生成报告
This commit is contained in:
@@ -182,19 +182,4 @@ public class PqDevController extends BaseController {
|
|||||||
});
|
});
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
|
|
||||||
@PostMapping("/documented")
|
|
||||||
@ApiOperation("设备归档")
|
|
||||||
@ApiImplicitParam(name = "id", value = "设备id", required = true)
|
|
||||||
public HttpResult<Boolean> documented(@RequestBody List<String> ids) {
|
|
||||||
String methodDescribe = getMethodDescribe("documented");
|
|
||||||
LogUtil.njcnDebug(log, "{},设备id为:{}", methodDescribe, ids);
|
|
||||||
boolean result = pqDevService.documented(ids);
|
|
||||||
if (result) {
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
|
||||||
} else {
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,13 +137,6 @@ public interface IPqDevService extends IService<PqDev> {
|
|||||||
*/
|
*/
|
||||||
List<PreDetection> getDevInfo(@Param("devIds") List<String> devIds);
|
List<PreDetection> getDevInfo(@Param("devIds") List<String> devIds);
|
||||||
|
|
||||||
/**
|
|
||||||
* 设备归档操作
|
|
||||||
*
|
|
||||||
* @param id 设备id
|
|
||||||
* @return 归档成功返回true,否则返回false
|
|
||||||
*/
|
|
||||||
boolean documented(List<String> id);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 正式监测完成,修改中断状态
|
* 正式监测完成,修改中断状态
|
||||||
|
|||||||
@@ -485,40 +485,6 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
|||||||
return preDetections;
|
return preDetections;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public boolean documented(List<String> ids) {
|
|
||||||
if (CollUtil.isNotEmpty(ids)) {
|
|
||||||
for (String id : ids) {
|
|
||||||
// 只有检测完成的设备才可以进行归档
|
|
||||||
PqDev pqDev = this.getById(id);
|
|
||||||
if (ObjectUtil.isNotNull(pqDev)) {
|
|
||||||
// 只有检测完成、且已生成报告的设备才可以进行归档
|
|
||||||
if (!pqDev.getCheckState().equals(CheckStateEnum.CHECKED.getValue()) || !pqDev.getReportState().equals(DevReportStateEnum.GENERATED.getValue())) {
|
|
||||||
throw new BusinessException(DetectionResponseEnum.DEV_UN_CHECKED);
|
|
||||||
}
|
|
||||||
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,则更新计划已完成
|
|
||||||
this.baseMapper.finishPlan(pqDev.getPlanId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateResult(List<String> ids, List<String> valueType, String code, String userId, Float temperature, Float humidity) {
|
public boolean updateResult(List<String> ids, List<String> valueType, String code, String userId, Float temperature, Float humidity) {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.njcn.gather.report.controller;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
import com.njcn.common.pojo.constant.OperateType;
|
import com.njcn.common.pojo.constant.OperateType;
|
||||||
|
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
import com.njcn.common.pojo.response.HttpResult;
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
import com.njcn.common.utils.LogUtil;
|
import com.njcn.common.utils.LogUtil;
|
||||||
@@ -140,4 +141,19 @@ public class ReportController extends BaseController {
|
|||||||
String methodDescribe = getMethodDescribe("listAllName");
|
String methodDescribe = getMethodDescribe("listAllName");
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pqReportService.listAllName(), methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pqReportService.listAllName(), methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
|
||||||
|
@PostMapping("/documented")
|
||||||
|
@ApiOperation("设备归档")
|
||||||
|
@ApiImplicitParam(name = "id", value = "设备id", required = true)
|
||||||
|
public HttpResult<Boolean> documented(@RequestBody List<String> ids) {
|
||||||
|
String methodDescribe = getMethodDescribe("documented");
|
||||||
|
LogUtil.njcnDebug(log, "{},设备id为:{}", methodDescribe, ids);
|
||||||
|
boolean result = pqReportService.documented(ids);
|
||||||
|
if (result) {
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||||
|
} else {
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import com.njcn.gather.report.pojo.vo.PqReportVO;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author makejava
|
* @author makejava
|
||||||
@@ -67,5 +66,11 @@ public interface IPqReportService extends IService<PqReport> {
|
|||||||
|
|
||||||
void downloadReport(DevReportParam devReportParam, HttpServletResponse response);
|
void downloadReport(DevReportParam devReportParam, HttpServletResponse response);
|
||||||
|
|
||||||
//Map<String, Object> getMap(DevReportParam devReportParam);
|
/**
|
||||||
|
* 设备归档操作
|
||||||
|
*
|
||||||
|
* @param id 设备id
|
||||||
|
* @return 归档成功返回true,否则返回false
|
||||||
|
*/
|
||||||
|
boolean documented(List<String> id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,10 @@ 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.enums.DetectionCodeEnum;
|
import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
|
||||||
import com.njcn.gather.detection.pojo.vo.DetectionData;
|
import com.njcn.gather.detection.pojo.vo.DetectionData;
|
||||||
|
import com.njcn.gather.device.mapper.PqDevMapper;
|
||||||
|
import com.njcn.gather.device.pojo.enums.CheckStateEnum;
|
||||||
import com.njcn.gather.device.pojo.enums.DevReportStateEnum;
|
import com.njcn.gather.device.pojo.enums.DevReportStateEnum;
|
||||||
|
import com.njcn.gather.device.pojo.po.PqDev;
|
||||||
import com.njcn.gather.device.pojo.vo.PqDevVO;
|
import com.njcn.gather.device.pojo.vo.PqDevVO;
|
||||||
import com.njcn.gather.device.service.IPqDevService;
|
import com.njcn.gather.device.service.IPqDevService;
|
||||||
import com.njcn.gather.err.service.IPqErrSysDtlsService;
|
import com.njcn.gather.err.service.IPqErrSysDtlsService;
|
||||||
@@ -115,6 +118,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
|||||||
private final String BLACK = "000000";
|
private final String BLACK = "000000";
|
||||||
|
|
||||||
private final IPqDevService iPqDevService;
|
private final IPqDevService iPqDevService;
|
||||||
|
private final PqDevMapper pqDevMapper;
|
||||||
|
|
||||||
private final IDictDataService dictDataService;
|
private final IDictDataService dictDataService;
|
||||||
|
|
||||||
@@ -1058,6 +1062,55 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public boolean documented(List<String> ids) {
|
||||||
|
if (CollUtil.isNotEmpty(ids)) {
|
||||||
|
List<String> devIds = new ArrayList<>();
|
||||||
|
PqDev tempPqDev = null;
|
||||||
|
for (String id : ids) {
|
||||||
|
// 只有检测完成的设备才可以进行归档
|
||||||
|
PqDev pqDev = iPqDevService.getById(id);
|
||||||
|
if (ObjectUtil.isNotNull(pqDev)) {
|
||||||
|
// 只有检测完成、且已生成报告的设备才可以进行归档
|
||||||
|
if (!pqDev.getCheckState().equals(CheckStateEnum.CHECKED.getValue())) {
|
||||||
|
throw new BusinessException(DetectionResponseEnum.DEV_UN_CHECKED);
|
||||||
|
}
|
||||||
|
if (!pqDev.getReportState().equals(DevReportStateEnum.GENERATED.getValue())) {
|
||||||
|
devIds.add(id);
|
||||||
|
tempPqDev = pqDev;
|
||||||
|
}
|
||||||
|
boolean update = iPqDevService.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 = iPqDevService.count(queryWrapper);
|
||||||
|
if (count == 0) {
|
||||||
|
// 如果非归档状态的设备数量为0,则更新计划已完成
|
||||||
|
pqDevMapper.finishPlan(pqDev.getPlanId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (CollUtil.isNotEmpty(devIds)) {
|
||||||
|
DevReportParam devReportParam = new DevReportParam();
|
||||||
|
devReportParam.setDevIdList(devIds);
|
||||||
|
devReportParam.setPlanId(tempPqDev.getPlanId());
|
||||||
|
AdPlan plan = adPlanService.getById(tempPqDev.getPlanId());
|
||||||
|
devReportParam.setScriptId(plan.getScriptId());
|
||||||
|
devReportParam.setPlanCode(String.valueOf(plan.getCode()));
|
||||||
|
this.generateReport(devReportParam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理基础模版中的信息,非数据页报告
|
* 处理基础模版中的信息,非数据页报告
|
||||||
|
|||||||
Reference in New Issue
Block a user