提交 0e87123b authored 作者: Matrix's avatar Matrix

[核查模块] 修正了回退相关的bug

上级 10fa7458
...@@ -45,6 +45,7 @@ import io.swagger.annotations.ApiOperation; ...@@ -45,6 +45,7 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.domain.Specification;
...@@ -71,7 +72,7 @@ import static java.util.stream.Collectors.*; ...@@ -71,7 +72,7 @@ import static java.util.stream.Collectors.*;
@RestController @RestController
@RequestMapping(value = "/check/confirm") @RequestMapping(value = "/check/confirm")
@AutoDocument @AutoDocument
@Transactional(rollbackFor = Exception.class) //@Transactional(rollbackFor = Exception.class)
@Slf4j @Slf4j
@Api(tags = "核查模块", description = "核查模块", position = 1) @Api(tags = "核查模块", description = "核查模块", position = 1)
public class DeviceCheckController { public class DeviceCheckController {
...@@ -357,6 +358,34 @@ public class DeviceCheckController { ...@@ -357,6 +358,34 @@ public class DeviceCheckController {
int i = 0; int i = 0;
for (Task child : childTask) { for (Task child : childTask) {
LinkExamDetail led = getLed(endTime, updateTime, child);
//设置名称
led.setExamName(groupNames.get(i));
led.setExamUser(userNames.get(i));
ledList.add(led);
i++;
}
i = 0;
linkVo.setLcDetail(lcdList);
linkVo.setLeDetail(ledList);
}
}
// type = 8 跳转
if (type.equals(CONFIRM_CHECK_DETAIL.id)) {
linkVo.setType(3);
linkVo.setDetailId(billId);
}
return ResponseEntity.ok(linkVo);
}
@NotNull
private LinkExamDetail getLed(LocalDateTime endTime, LocalDateTime updateTime, Task child) {
Integer childBusType = child.getBusinessType(); Integer childBusType = child.getBusinessType();
Integer childBusId = child.getBillId(); Integer childBusId = child.getBillId();
...@@ -370,11 +399,6 @@ public class DeviceCheckController { ...@@ -370,11 +399,6 @@ public class DeviceCheckController {
//自查的areaName要从detail里找 //自查的areaName要从detail里找
String areaName = childDetail.getCheckUnit(); String areaName = childDetail.getCheckUnit();
CheckAreaStatVo cas; CheckAreaStatVo cas;
// if (casList.isEmpty()) {
// cas = new CheckAreaStatVo("默认地区", 0, 0, 0, 0, 0, 0);
// } else {
// cas = combineCaList(casList, areaName);
// }
if (casList.isEmpty()) { if (casList.isEmpty()) {
cas = new CheckAreaStatVo("默认地区", 0, 0, 0, 0, 0, 0); cas = new CheckAreaStatVo("默认地区", 0, 0, 0, 0, 0, 0);
...@@ -382,42 +406,11 @@ public class DeviceCheckController { ...@@ -382,42 +406,11 @@ public class DeviceCheckController {
cas = casList.get(0); cas = casList.get(0);
} }
//
// CheckAreaStatVo cas = parseStatString2Vo(child.parse2Bto(), childDetail).stream()
// .map(CheckDeviceStatVo::getAreaStatList)
// .flatMap(checkAreaStatVos -> checkAreaStatVos.stream())
// .reduce(CheckAreaStatVo::combine)
// .get();
// LinkExamDetail led = rev2led(child, endTime, updateTime, cas.reverse());
LinkExamDetail led = cas2led(cas, child, endTime, updateTime); LinkExamDetail led = cas2led(cas, child, endTime, updateTime);
led.setCheckUnit(unitName); led.setCheckUnit(unitName);
return led;
//设置名称
led.setExamName(groupNames.get(i));
led.setExamUser(userNames.get(i));
ledList.add(led);
i++;
}
i = 0;
linkVo.setLcDetail(lcdList);
linkVo.setLeDetail(ledList);
}
}
// type = 8 跳转
if (type.equals(CONFIRM_CHECK_DETAIL.id)) {
linkVo.setType(3);
linkVo.setDetailId(billId);
}
return ResponseEntity.ok(linkVo);
} }
//进行了更新 使用修改时间去做是否逾期判断 //进行了更新 使用修改时间去做是否逾期判断
...@@ -501,7 +494,7 @@ public class DeviceCheckController { ...@@ -501,7 +494,7 @@ public class DeviceCheckController {
boolean waitStart = casList.stream() boolean waitStart = casList.stream()
.allMatch(cas -> cas.getComProgress() == 0); .allMatch(cas -> cas.getComProgress() == 0);
boolean isFinished = casList.stream() boolean isFinished = casList.stream()
.allMatch(cas -> cas.getComProgress() == 2); .allMatch(cas -> cas.getComProgress() == 2) || task.getBillStatus().equals(END);
if (waitStart) { if (waitStart) {
lcd.setCheckSituation("等待核查"); lcd.setCheckSituation("等待核查");
...@@ -690,7 +683,7 @@ public class DeviceCheckController { ...@@ -690,7 +683,7 @@ public class DeviceCheckController {
Integer provId = taskService.get(examJobId).getParentTaskId(); Integer provId = taskService.get(examJobId).getParentTaskId();
// 检查的job id 找到 father 进而找到 father的billid 进而找到title Id // 检查的job id 找到 father 进而找到 father的billid 进而找到title Id
Integer statId = taskService.get(provId).getBillId(); Integer statId = taskService.get(provId).getBillId();
DeviceCheckStat deviceCheckStat = statRepo.getOne(statId); DeviceCheckStat deviceCheckStat = statRepo.findById(statId).get();
String title = deviceCheckStat.getTitle(); String title = deviceCheckStat.getTitle();
String remark = deviceCheckStat.getRemark(); String remark = deviceCheckStat.getRemark();
return ResponseEntity.ok(new CheckTitleAndTimeVo(title, deviceCheckStat.getEndTime(), remark)); return ResponseEntity.ok(new CheckTitleAndTimeVo(title, deviceCheckStat.getEndTime(), remark));
...@@ -720,8 +713,8 @@ public class DeviceCheckController { ...@@ -720,8 +713,8 @@ public class DeviceCheckController {
@ApiOperation(value = "检查地区是否发起核查", notes = "检查地区是否发起核查") @ApiOperation(value = "检查地区是否发起核查", notes = "检查地区是否发起核查")
@PostMapping("/checkPossible") @PostMapping("/checkPossible")
public ResponseEntity checkPossible(@RequestBody UnitIds uuid) { public ResponseEntity checkPossible(@RequestBody UnitIds unitIds) {
List<String> unitNames = uuid.getIds().stream() List<String> unitNames = unitIds.getIds().stream()
.map(id -> auService.findOne(AuExample.UnitId, id)) .map(id -> auService.findOne(AuExample.UnitId, id))
.map(AreaUnit::getUnitName) .map(AreaUnit::getUnitName)
.collect(toList()); .collect(toList());
...@@ -889,12 +882,15 @@ public class DeviceCheckController { ...@@ -889,12 +882,15 @@ public class DeviceCheckController {
} }
List<String> tmpString = new ArrayList<>(); List<String> tmpString = new ArrayList<>();
// 拼接检查组和检查组成员
for (CheckExamDetailVo vo : examDetailVos) { for (CheckExamDetailVo vo : examDetailVos) {
for (Integer u : vo.getUnitIds()) {
tmpString.add(vo.getGroupName() + "," + vo.getUserNames().stream().collect(joining(","))); tmpString.add(vo.getGroupName() + "," + vo.getUserNames().stream().collect(joining(",")));
} }
}
String groupUserString = tmpString.stream().collect(joining("|")); String groupUserString = tmpString.stream().collect(joining("|"));
List<Integer> unitIds = examDetailVos.stream().map(CheckExamDetailVo::getUnitId).collect(toList()); List<Integer> unitIds = examDetailVos.stream().flatMap(cv -> cv.getUnitIds().stream()).collect(toList());
List<Units> checkedUnits = unitsRepo.findAllById(unitIds); List<Units> checkedUnits = unitsRepo.findAllById(unitIds);
List<String> checkedUnitNames = checkedUnits.stream().map(Units::getName).collect(toList()); List<String> checkedUnitNames = checkedUnits.stream().map(Units::getName).collect(toList());
...@@ -963,8 +959,12 @@ public class DeviceCheckController { ...@@ -963,8 +959,12 @@ public class DeviceCheckController {
// 3. 构建被核查单位的详情账单与Task // 3. 构建被核查单位的详情账单与Task
// 对每个需要核查的单位构建其detail账单与task // 对每个需要核查的单位构建其detail账单与task
for (CheckExamDetailVo ed : examDetailVos) { for (CheckExamDetailVo ed : examDetailVos) {
Units unit = unitsRepo.findById(ed.getUnitId()).get(); List<Integer> uid = ed.getUnitIds();
for (Integer u : uid) {
Units unit = unitsRepo.findById(u).get();
String names = ed.getUserNames().stream().collect(joining(",")); String names = ed.getUserNames().stream().collect(joining(","));
// 3-1 构建被查单位的 自查账单 // 3-1 构建被查单位的 自查账单
DeviceCheckDetail unitDetailDoc = DeviceCheckDetail.EmptyWithChecker(names + "|" + ed.getRemark(), ceVo.getTitle() + "%^&" + ed.getRemark(), 0, 0, 0, 0, unit.getName(), devInLib.getOrDefault(unit.getName(), new ArrayList<>()), devNotInLib.getOrDefault(unit.getName(), new ArrayList<>())); DeviceCheckDetail unitDetailDoc = DeviceCheckDetail.EmptyWithChecker(names + "|" + ed.getRemark(), ceVo.getTitle() + "%^&" + ed.getRemark(), 0, 0, 0, 0, unit.getName(), devInLib.getOrDefault(unit.getName(), new ArrayList<>()), devNotInLib.getOrDefault(unit.getName(), new ArrayList<>()));
DeviceCheckDetail detail = detailRepo.save(unitDetailDoc); DeviceCheckDetail detail = detailRepo.save(unitDetailDoc);
...@@ -989,6 +989,9 @@ public class DeviceCheckController { ...@@ -989,6 +989,9 @@ public class DeviceCheckController {
desMap.put(checkedTask.getId(), ed.getRemark()); desMap.put(checkedTask.getId(), ed.getRemark());
} }
}
// 4. 重新设置并保存统计账单 // 4. 重新设置并保存统计账单
provinceCheckStat.setStatInfo(JacksonUtil.toJSon(deviceStatVos)); provinceCheckStat.setStatInfo(JacksonUtil.toJSon(deviceStatVos));
statRepo.save(provinceCheckStat); statRepo.save(provinceCheckStat);
...@@ -1202,9 +1205,9 @@ public class DeviceCheckController { ...@@ -1202,9 +1205,9 @@ public class DeviceCheckController {
@ApiOperation(value = "新的回退接口,目前用于测试") @ApiOperation(value = "新的回退接口,目前用于测试")
@PutMapping("/test/rollback/{id}") @PutMapping("/test/rollback/{id}")
public ResponseEntity rollBack(@PathVariable Integer id){ public ResponseEntity rollBack(@PathVariable Integer id) {
//1. bill单的自查将百位数变为3 //1. bill单的自查将百位数变为3
DeviceCheckDetail detail = detailRepo.getOne(id); DeviceCheckDetail detail = detailRepo.findById(id).get();
String detailString = detail.getCheckDetail(); String detailString = detail.getCheckDetail();
String initalDetail = Arrays.stream(detailString.split(",")) String initalDetail = Arrays.stream(detailString.split(","))
.map(s -> s.split("-")[0] + "-" + 119) .map(s -> s.split("-")[0] + "-" + 119)
...@@ -1213,20 +1216,21 @@ public class DeviceCheckController { ...@@ -1213,20 +1216,21 @@ public class DeviceCheckController {
String updateDetail = Arrays.stream(detailString.split(",")) String updateDetail = Arrays.stream(detailString.split(","))
.map(s -> { .map(s -> {
Integer number = Integer.valueOf(s.split("-")[1]); Integer number = Integer.valueOf(s.split("-")[1]);
int digit= number % 10; int digit = number % 10;
int tens = number / 10 % 10; int tens = number / 10 % 10;
number = 300 + tens * 10 + digit; number = 300 + tens * 10 + digit;
return s.split("-")[0] + "-" + number; return s.split("-")[0] + "-" + number;
} ) })
.collect(joining(",")); .collect(joining(","));
detailRepo.updateCheckDetail(id, updateDetail, "", 0, 0, 0); detailRepo.updateCheckDetail(id, updateDetail, "", 0, 0, 0);
//2.当前任务结束,开启一个新的 退回任务(连带一个新的detail) //2. 当前任务结束,开启一个新的 退回任务(连带一个新的detail)
TaskBto currentTask = taskService.get(id, CONFIRM_CHECK_DETAIL.id); TaskBto currentTask = taskService.get(id, CONFIRM_CHECK_DETAIL.id);
TaskBto newTask = currentTask.toDo().copy().parse2Bto(); TaskBto newTask = currentTask.toDo().copy().parse2Bto();
currentTask.setCustomInfo(currentTask.getCustomInfo());
taskService.moveToEnd(currentTask); taskService.moveToEnd(currentTask);
// 创建新的detail // 创建新的detail 新的detail会在B的时候加入,所以老的stat要去除掉
DeviceCheckDetail cDetail = detail.copyWithoutId(); DeviceCheckDetail cDetail = detail.copyWithoutId();
cDetail.setId(null); cDetail.setId(null);
cDetail.setCheckDetail(initalDetail); cDetail.setCheckDetail(initalDetail);
...@@ -1235,11 +1239,44 @@ public class DeviceCheckController { ...@@ -1235,11 +1239,44 @@ public class DeviceCheckController {
newTask.setBillStatus(CHECK_EXAM_DETAIL_0.id); newTask.setBillStatus(CHECK_EXAM_DETAIL_0.id);
newTask.setBillId(cDetail.getId()); newTask.setBillId(cDetail.getId());
newTask.setId(0); newTask.setId(0);
newTask.setCustomInfo(newTask.getCustomInfo());
newTask.getInvolveUserIdList().add(0);
newTask.setCurrentPoint(newTask.getInvolveUserIdList().size()-1);
taskService.start(newTask); taskService.start(newTask);
//3.父级任务变为进行中 //3. 在stat的remark中追加信息 - 找到currentTask在其中的顺位
TaskBto fatherTask = taskService.get(currentTask.getParentTaskId()); TaskBto fatherTask = taskService.get(currentTask.getParentTaskId());
fatherTask.setBillStatus(CHECK_EXAM_STAT_0.id); List<Task> childTask = taskRepo.findAllByParentTaskId(fatherTask.getId());
int pos = 0;
for (int i = 0; i < childTask.size(); i++) {
if (childTask.get(i).getId().equals(currentTask.getId())) {
log.info("[核查模块] 记录remark的pos位置 = {}", i);
}
}
DeviceCheckStat dcs = statRepo.findById(fatherTask.getBillId()).get();
String[] groups = dcs.getRemark().split("\\|");
String pading = groups[pos];
dcs.setRemark(dcs.getRemark() + "|" + pading);
log.info("[核查模块] 补充remark = {}", pading);
// 老的stat要去除掉对应areaName的数据
String areaName = auService.findOne(AuExample.UnitName, detail.getCheckUnit()).getName();
CheckStatVo csv = transUtil.checkStatDo2Vo(dcs);
for (CheckDeviceStatVo vo : csv.getDeviceStatVoList()) {
List<CheckAreaStatVo> filterList = vo.getAreaStatList().stream()
.filter(casv -> !casv.getAreaName().equals(areaName)).collect(toList());
if (filterList.size() != vo.getAreaStatList().size()){
log.info("[核查模块] 回退操作-将退回的数据从统计中去除了.");
vo.setAreaStatList(filterList);
}
}
statRepo.save(csv.toDo());
//4.父级任务变为进行中
fatherTask.setBillStatus(CHECK_EXAM_STAT_1.id);
taskRepo.save(fatherTask.toDo());
return ResponseEntity.ok(new ResultObj<>("回退操作成功!")); return ResponseEntity.ok(new ResultObj<>("回退操作成功!"));
...@@ -1298,7 +1335,7 @@ public class DeviceCheckController { ...@@ -1298,7 +1335,7 @@ public class DeviceCheckController {
log.info("[核查模块] 进行检查回退操作,要回退的检查detail id为 {}", id); log.info("[核查模块] 进行检查回退操作,要回退的检查detail id为 {}", id);
//1. 回退device-detail数据 包括 detail String,checkResult,userAId,userBid,checkedCount //1. 回退device-detail数据 包括 detail String,checkResult,userAId,userBid,checkedCount
// 将原来的checkDetail 的检查状态统一更改为 8 - 已退回 // 将原来的checkDetail 的检查状态统一更改为 8 - 已退回
String detail = detailRepo.getOne(id).getCheckDetail(); String detail = detailRepo.findById(id).get().getCheckDetail();
String updateDetail = Arrays.stream(detail.split(",")) String updateDetail = Arrays.stream(detail.split(","))
.map(s -> s.split("-")[0] + "-" + "8") .map(s -> s.split("-")[0] + "-" + "8")
.collect(joining(",")); .collect(joining(","));
...@@ -1625,12 +1662,12 @@ public class DeviceCheckController { ...@@ -1625,12 +1662,12 @@ public class DeviceCheckController {
checkAreaStatVo = new CheckAreaStatVo(areaName, 1, 1, 2, 10, statId, detailId); checkAreaStatVo = new CheckAreaStatVo(areaName, 1, 1, 2, 10, statId, detailId);
} }
// 百位数判断审核情况 // 百位数判断审核情况 0,1未检查 2是无误 3是未通过
if (huns == 0 || huns ==1){ if (huns == 0 || huns == 1) {
checkAreaStatVo.setComSituation(10); checkAreaStatVo.setComSituation(10);
}else if (huns == 2){ } else if (huns == 2) {
checkAreaStatVo.setComSituation(12); checkAreaStatVo.setComSituation(12);
}else if (huns ==3){ } else if (huns == 3) {
checkAreaStatVo.setComSituation(13); checkAreaStatVo.setComSituation(13);
} }
......
...@@ -6,6 +6,7 @@ import lombok.AllArgsConstructor; ...@@ -6,6 +6,7 @@ import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.util.Collections;
import java.util.List; import java.util.List;
/** /**
...@@ -27,12 +28,12 @@ public class CheckExamDetailVo { ...@@ -27,12 +28,12 @@ public class CheckExamDetailVo {
private List<String> userNames; private List<String> userNames;
@ApiModelProperty(name = "需要被检查的区域id") @ApiModelProperty(name = "需要被检查的区域id")
private Integer unitId; private List<Integer> unitIds;
@ApiModelProperty(name = "备注") @ApiModelProperty(name = "备注")
private String remark; private String remark;
public CheckExamDetailVo copy(Integer unitId,String remark) { public CheckExamDetailVo copy(Integer unitId,String remark) {
return new CheckExamDetailVo(this.groupName, this.userNames, unitId, remark); return new CheckExamDetailVo(this.groupName, this.userNames, Collections.singletonList(unitId), remark);
} }
} }
...@@ -317,16 +317,16 @@ public class TaskServiceImpl implements TaskService { ...@@ -317,16 +317,16 @@ public class TaskServiceImpl implements TaskService {
@ExceptionHandler(Exception.class) @ExceptionHandler(Exception.class)
@Log @Log
public TaskBto start(TaskBto taskBto) { public TaskBto start(TaskBto taskBto) {
Task t = taskBto.toDo(); Task task = taskDao.save(taskBto.toDo());
Task task = taskDao.save(t);
myWebSocket.sendMessage1(); myWebSocket.sendMessage1();
Task task1 = taskDao.findById(task.getId()).get();
CompletableFuture.runAsync(() -> { CompletableFuture.runAsync(() -> {
try { try {
Thread.sleep(2000); Thread.sleep(2000);
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }
Task task1 = taskDao.findById(task.getId()).get();
BcHash bcText = blockChainUtil.sendHash(1000, JacksonUtil.toJSon(task1)); BcHash bcText = blockChainUtil.sendHash(1000, JacksonUtil.toJSon(task1));
String recordId = bcText.getData().getRecordID(); String recordId = bcText.getData().getRecordID();
task1.setRecordId(recordId); task1.setRecordId(recordId);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论