归档前如果设备没有生成报告则自动生成报告
This commit is contained in:
@@ -182,19 +182,4 @@ public class PqDevController extends BaseController {
|
||||
});
|
||||
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);
|
||||
|
||||
/**
|
||||
* 设备归档操作
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
@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
|
||||
public boolean updateResult(List<String> ids, List<String> valueType, String code, String userId, Float temperature, Float humidity) {
|
||||
|
||||
Reference in New Issue
Block a user