提交 5cc6f7ab authored 作者: Matrix's avatar Matrix

[核查模块] bug 修复

上级 9a1ab22a
......@@ -42,8 +42,7 @@ import java.util.Objects;
import static com.tykj.dev.device.task.subject.common.BusinessEnum.CONFIRM_CHECK_DETAIL;
import static com.tykj.dev.device.task.subject.common.BusinessEnum.CONFIRM_CHECK_STAT;
import static com.tykj.dev.device.task.subject.common.StatusEnum.CHECK_DETAIL_0;
import static com.tykj.dev.device.task.subject.common.StatusEnum.CHECK_STAT_0;
import static com.tykj.dev.device.task.subject.common.StatusEnum.*;
import static com.tykj.dev.misc.utils.TimestampUtil.localDateToDate;
import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.toList;
......@@ -128,7 +127,7 @@ public class DeviceCheckController {
List<Units> checkedUnits = unitsRepo.findByAreaIdIn(billVo.getAreaRange());
List<String> checkedUnitNames = checkedUnits.stream().map(Units::getName).collect(toList());
log.info("发起手动核查,发起单位为{},被查单位为{}", startUnit.getName(), checkedUnitNames);
log.info("[核查模块]发起手动核查,发起单位为{},被查单位为{}", startUnit.getName(), checkedUnitNames);
// 2-1 构建发起单位的 统计账单
DeviceCheckStat provinceCheckStat = initStatData(startUnit.getName(), checkedUnits);
Integer billId = statRepo.save(provinceCheckStat).getId();
......@@ -161,8 +160,8 @@ public class DeviceCheckController {
taskService.start(checkedTask);
}
log.info("{}单位成功发起对 {} 单位的核查任务分发", startUnit.getName(), checkedUnitNames);
return ResponseEntity.ok(new ResultObj(String.format("[%s]单位成功发起对 %s 单位的核查任务分发", startUnit.getName(), checkedUnitNames)));
log.info("[核查模块] {}单位成功发起对 {} 单位的核查任务分发", startUnit.getName(), checkedUnitNames);
return ResponseEntity.ok(new ResultObj(String.format("[核查模块] [%s]单位成功发起对 [%s] 单位的核查任务分发", startUnit.getName(), checkedUnitNames)));
}
......@@ -181,6 +180,7 @@ public class DeviceCheckController {
@RequestParam String checkResult,
@RequestBody DevLibVo devLibVo) {
//1. 更新checkDetail
log.info("[核查模块] 专管员A正在进行详情账单核查,且指定下一个审核人B id 为 {}", assignUserId);
String detailString = transUtil.devLib2String(devLibVo.getDevInLibrary(), devLibVo.getDevNotInLibrary());
User currentUser = Objects.requireNonNull(AuthenticationUtils.getAuthentication()).getCurrentUserInfo();
detailRepo.updateCheckDetail(id, detailString, checkResult, currentUser.getUserId(), assignUserId);
......@@ -189,6 +189,7 @@ public class DeviceCheckController {
currentTask.getInvolveUserIdList().set(0, AuthenticationUtils.getAuthentication().getCurrentUserInfo().getUserId());
taskService.moveToNext(currentTask, assignUserId);
logService.addLog(new TaskLogBto(currentTask.getId(), "A岗核查成功"));
log.info("[核查模块] A岗核查操作成功");
return ResponseEntity.ok(new ResultObj("专管员A操作成功"));
}
......@@ -201,7 +202,7 @@ public class DeviceCheckController {
@RequestParam int checkStatus,
@RequestParam(required = false, defaultValue = "0") int checkUserAId,
@RequestParam(required = false, defaultValue = "0") int checkUserBId) {
log.info("[核查模块] 专管员B正在进行核查操作,核查账单id为 {} ,且审核状态为 : {}", id, checkStatus == 1 ? "通过" : "不通过");
if (checkStatus == 0) {
return ResponseEntity.status(400).body(new ResultObj("checkStatus不应该为0!"));
}
......@@ -213,6 +214,10 @@ public class DeviceCheckController {
// 审核通过与不通过的逻辑不同
TaskBto currentTask = taskService.get(id, CONFIRM_CHECK_DETAIL.id);
if (!currentTask.getBillStatus().equals(CHECK_DETAIL_1.id)) {
return ResponseEntity.status(400).body(new ResultObj(String.format("当前任务的状态异常!当前任务状态为 %s , 任务状态应该为 %s", GlobalMap.getStatusEnumMap().get(currentTask.getBillStatus()), CHECK_DETAIL_1.name)));
}
if (checkStatus == 1) {
//依据detail账单对应的checkUserId来判断是2流程还是多流程的
DeviceCheckDetailEntity detailDo = detailRepo.findById(id).get();
......@@ -237,6 +242,7 @@ public class DeviceCheckController {
logService.addLog(new TaskLogBto(currentTask.getId(), "B岗审核失败,跳回A岗人员操作"));
}
log.info("[核查模块] 专管员B操作成功");
return ResponseEntity.ok(new ResultObj("专管B操作成功"));
}
......@@ -249,13 +255,21 @@ public class DeviceCheckController {
DeviceCheckDetailEntity currentDetail = detailRepo.findById(id).get();
if (pass) {
// 如果当前是第3步(利用余数来判断),则需要指定核查组B的人来接受任务
log.info("[核查模块] C 检查组成员A正在进行核查操作,核查详情账单id为 : {}", id);
if (currentTask.getBillStatus() % 10 == 2) {
if (!currentTask.getBillStatus().equals(CHECK_DETAIL_2.id)) {
return ResponseEntity.status(400).body(new ResultObj(String.format("当前任务的状态异常!当前任务状态为 %s , 任务状态应该为 %s", GlobalMap.getStatusEnumMap().get(currentTask.getBillStatus()), CHECK_DETAIL_2.name)));
}
currentTask = taskService.moveToNext(currentTask, currentDetail.getCheckUserBId());
logService.addLog(new TaskLogBto(currentTask.getId(), "核查组A审核成功"));
}
log.info("[核查模块] C 操作完毕");
} else if (currentTask.getBillStatus() % 10 == 3) {
if (!currentTask.getBillStatus().equals(CHECK_DETAIL_3.id)) {
return ResponseEntity.status(400).body(new ResultObj(String.format("当前任务的状态异常!当前任务状态为 %s , 任务状态应该为 %s", GlobalMap.getStatusEnumMap().get(currentTask.getBillStatus()), CHECK_DETAIL_3.name)));
}
// 如果当前是第4步,则直接结束任务,并且进行结果汇总
if (currentTask.getBillStatus() % 10 == 3) {
// 如果当前是第4步,则直接结束任务,并且进行结果汇总
log.info("[核查模块] D 检查组成员A正在进行核查操作,核查详情账单id为 : {}", id);
currentTask = taskService.moveToEnd(currentTask);
logService.addLog(new TaskLogBto(currentTask.getId(), "核查组B审核成功"));
// 任务结束后需要将当前城市的统计信息汇总上去
......@@ -278,8 +292,9 @@ public class DeviceCheckController {
if (over) {
TaskBto fatherTask = taskService.get(fatherTaskId);
TaskBto statTask = taskService.moveToNext(fatherTask, fatherTask.getLastUserId());
logService.addLog(new TaskLogBto(statTask.getId(), "地区数据已统计完毕,等待确认"));
logService.addLog(new TaskLogBto(statTask.getId(), "地区数据已统计完毕,等待确认", new ArrayList<>(), fatherTask.getFirstUserId()));
}
log.info("[核查模块] D 操作完毕");
}
} else {
......@@ -299,6 +314,7 @@ public class DeviceCheckController {
@ApiOperation(value = "统计数据确认")
@PostMapping("/stat/verify")
public ResponseEntity statConfirm(@RequestParam int statId) {
log.info("[核查模块] 正在进行统计数据确认,统计账单id为 : {}", statId);
//将当前的统计task完结
TaskBto currentTask = taskService.get(statId, CONFIRM_CHECK_STAT.id);
currentTask = taskService.moveToEnd(currentTask);
......@@ -318,11 +334,12 @@ public class DeviceCheckController {
// 如果所有子地区统计任务都已经完结,则推进父地区统计任务进度
boolean allOver = taskService.TaskTreeIsOver(parentTaskId);
if (allOver) {
taskService.moveToEnd(parentTask);
TaskBto statTask = taskService.moveToEnd(parentTask);
logService.addLog(new TaskLogBto(statTask.getId(), "统计数据确认操作"));
}
}
log.info("[核查模块] 统计数据确认操作成功");
return ResponseEntity.ok(new ResultObj("统计数据确认完毕"));
}
......
......@@ -117,7 +117,7 @@ public class ObjTransUtil {
Integer deviceId = Integer.valueOf(array[0]);
int proofResult = Integer.parseInt(array[1]);
DeviceLibrary device = deviceRepo.findById(deviceId).orElseThrow(
() -> new ApiException(ResponseEntity.badRequest().body(String.format("检查到装备序号为%d的装备不在库资料中,请先执行入库操作!", deviceId))));
() -> new ApiException(ResponseEntity.badRequest().body(String.format("检查到装备序号为%d的装备不在资料库中,请先执行入库操作!", deviceId))));
//依据proofResult 判断是否是在库装备
if (proofResult == 3) {
// 非在库装备
......
......@@ -45,9 +45,9 @@ public class GlobalExceptionHandler {
@ResponseBody
@ExceptionHandler(ApiException.class)
public ResponseEntity errorMessage(ApiException e) {
e.printStackTrace();
log.warn("[自定义异常] {}", e.toString());
if (e.getResponseEntity() != null) {
return e.getResponseEntity();
return ResponseEntity.status(400).body(e.getResponseEntity().getBody());
}
return ResultUtil.failed();
}
......
......@@ -6,6 +6,7 @@ import com.tykj.dev.device.confirmcheck.entity.vo.CheckBillVo;
import com.tykj.dev.device.confirmcheck.entity.vo.CheckDetailVo;
import com.tykj.dev.device.confirmcheck.entity.vo.DevLibVo;
import com.tykj.dev.device.confirmcheck.repository.DeviceCheckDetailDao;
import com.tykj.dev.device.confirmcheck.repository.DeviceCheckStatRepo;
import com.tykj.dev.device.confirmcheck.utils.ObjTransUtil;
import com.tykj.dev.device.task.repository.TaskDao;
import com.tykj.dev.device.task.subject.common.StatusEnum;
......@@ -45,6 +46,9 @@ class DeviceCheckControllerTest extends BaseTest {
@Autowired
private DeviceCheckDetailDao detailRepo;
@Autowired
private DeviceCheckStatRepo statRepo;
@Autowired
private TaskDao taskRepo;
......@@ -167,5 +171,16 @@ class DeviceCheckControllerTest extends BaseTest {
statTaskId,
statId)));
// 结束之后删除本次建立的数据 包括 task 以及相应的业务表数据
// 删除父级任务
// Task fatherTask = taskRepo.findById(statTaskId).get();
// Integer statBillId = fatherTask.getBillId();
// taskRepo.deleteById(fatherTask.getId());
// statRepo.deleteById(statBillId);
//
// List<Task> childTask = taskRepo.findAllByParentTaskId(statTaskId);
// List<Integer> childTaskIds = childTask.stream().map(Task::getId).collect(toList());
// List<Integer> childBillIds = childTask.stream().map(Task::getBillId).collect(toList());
}
}
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论