调整设备类型
This commit is contained in:
@@ -3,9 +3,11 @@ package com.njcn.gather.detection.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.njcn.common.bean.CustomCacheUtil;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.gather.detection.handler.SocketDevResponseService;
|
||||
|
||||
@@ -221,13 +221,13 @@ public class PqDevController extends BaseController {
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
|
||||
@GetMapping("/documented")
|
||||
@PostMapping("/documented")
|
||||
@ApiOperation("设备归档")
|
||||
@ApiImplicitParam(name = "id", value = "设备id", required = true)
|
||||
public HttpResult<List<PqDev>> documented(@RequestParam String id) {
|
||||
public HttpResult<List<PqDev>> documented(@RequestBody List<String> ids) {
|
||||
String methodDescribe = getMethodDescribe("documented");
|
||||
LogUtil.njcnDebug(log, "{},设备id为:{}", methodDescribe, id);
|
||||
boolean result = pqDevService.documented(id);
|
||||
LogUtil.njcnDebug(log, "{},设备id为:{}", methodDescribe, ids);
|
||||
boolean result = pqDevService.documented(ids);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
|
||||
@@ -170,7 +170,7 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
* @param id 设备id
|
||||
* @return 归档成功返回true,否则返回false
|
||||
*/
|
||||
boolean documented(String id);
|
||||
boolean documented(List<String> id);
|
||||
|
||||
/**
|
||||
* 修改监测状态
|
||||
|
||||
@@ -446,10 +446,18 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean documented(String id) {
|
||||
public boolean documented(List<String> ids) {
|
||||
if (CollUtil.isNotEmpty(ids)) {
|
||||
for (String id : ids) {
|
||||
// 只有检测完成的设备才可以进行归档
|
||||
PqDev pqDev = this.getById(id);
|
||||
if (ObjectUtil.isNotNull(pqDev) && !pqDev.getCheckState().equals(CheckStateEnum.CHECKED.getValue())) {
|
||||
if (ObjectUtil.isNotNull(pqDev)) {
|
||||
if(!pqDev.getCheckState().equals(CheckStateEnum.CHECKED.getValue())){
|
||||
throw new BusinessException(DevResponseEnum.DEV_UN_CHECKED);
|
||||
}
|
||||
if(!pqDev.getReportState().equals(DevReportStateEnum.GENERATED.getValue())){
|
||||
throw new BusinessException(DevResponseEnum.DEV_UN_REPORT);
|
||||
}
|
||||
boolean update = this.lambdaUpdate()
|
||||
.set(PqDev::getCheckState, CheckStateEnum.DOCUMENTED.getValue())
|
||||
.eq(PqDev::getId, id)
|
||||
@@ -467,11 +475,13 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
this.baseMapper.finishPlan(pqDev.getPlanId());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
throw new BusinessException(DevResponseEnum.DEV_UN_CHECKED);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateCheckState(List<String> ids) {
|
||||
|
||||
@@ -20,6 +20,7 @@ public enum DevResponseEnum {
|
||||
IMPORT_SOURCE_ERROR("A001012","当前模式下一个检测计划只能有一个检测源" ),
|
||||
IMPORT_DATASOURCE_ERROR("A001013","当前模式下一个检测计划只能有一个数据源" ),
|
||||
DEV_UN_CHECKED("A001013","装置还未检测完成!" ),
|
||||
DEV_UN_REPORT("A001013","装置报告未生成!" ),
|
||||
DEVICE_DIS_ERROR("A001014","装置配置异常" );
|
||||
|
||||
private final String message;
|
||||
|
||||
Reference in New Issue
Block a user