提交 c0dc335d authored 作者: zjm's avatar zjm

合并分支 'bug' 到 'master'

fix(核查模块): 增加关于省本级与省直属的特殊接口的处理问题 查看合并请求 !50
......@@ -14,11 +14,11 @@ import lombok.Getter;
public enum CheckType {
/**
* 自动核查
* 核查
*/
CT_CHECK(0, "核查"),
/**
* 手动核
*
*/
CT_EXAM(1, "检查");
......
......@@ -37,6 +37,7 @@ import com.tykj.dev.device.user.subject.entity.bto.AreaUnit;
import com.tykj.dev.device.user.subject.service.AuService;
import com.tykj.dev.device.user.subject.service.UserService;
import com.tykj.dev.device.user.util.AuthenticationUtils;
import com.tykj.dev.misc.base.BusinessEnum;
import com.tykj.dev.misc.base.ResultObj;
import com.tykj.dev.misc.base.StatusEnum;
import com.tykj.dev.misc.exception.ApiException;
......@@ -117,6 +118,10 @@ public class DeviceCheckController {
@Autowired
private SelfCheckController selfCheckController;
final String CHECK_RESULT_WAIT = "等待省查阅";
final String CHECK_RESULT_DONE = "已查阅";
@GetMapping("/area/{fatherId}")
@ApiOperation(value = "查询指定区域下的所有区域信息")
public ResponseEntity<ResultObj<List<Area>>> findAreaUnderId(@PathVariable Integer fatherId) {
......@@ -242,6 +247,44 @@ public class DeviceCheckController {
return ResponseEntity.ok(new ResultObj<>(detailVoList));
}
private int specialDetailId = 0;
private List<String> specialUnits = new ArrayList<>();
@GetMapping("/detail/refresh/remove/{checkId}/{detailId}")
public ResponseEntity<String> removeUnitTask(@PathVariable Integer checkId,@PathVariable Integer detailId){
log.info("[核查模块] 移除billId = {} 中 detailId = {}的数据 ",checkId,detailId);
DeviceCheckDetail detail = detailRepo.findById(detailId).get();
DeviceCheckStat dcs = statRepo.findById(checkId).get();
removeDetailFromDcs(detail,dcs);
log.info("[核查模块] 从stat id = {} 中删除detail id = {}的数据",checkId,detailId);
// 删除task
Task task = taskRepo.findByBillIdAndBusinessType(detailId, CONFIRM_CHECK_DETAIL.id).get();
taskRepo.deleteById(task.getId());
log.info("[核查模块] 删除task id = {} 的任务",task.getId());
return ResponseEntity.ok("成功删除数据");
}
@GetMapping("/detail/refresh/active/{id}")
public ResponseEntity<String> activeSpecialData(@PathVariable Integer id,@RequestParam String unitName1,@RequestParam(defaultValue = "") String unitName2){
log.info("[核查模块] 特殊数据处理,设置specialDetailId = {},specialUnits = {} {} ",id,unitName1,unitName2);
specialDetailId = id;
specialUnits.add(unitName1);
if (!StringUtils.isEmpty(unitName2)){
specialUnits.add(unitName2);
}
return ResponseEntity.ok("设置特殊数据处理成功");
}
@GetMapping("/detail/refresh/reset")
public ResponseEntity<String> resetSpecialData(){
log.info("[核查模块] 重置特殊数据! ");
specialDetailId = 0;
specialUnits = new ArrayList<>();
return ResponseEntity.ok("设置特殊数据处理成功");
}
@ApiOperation(value = "根据id 刷新 核查详情数据", notes = "可以通过这个接口 刷新 核查详情数据")
@GetMapping("/detail/refresh/{id}")
public ResponseEntity<ResultObj<CheckDetailVo>> refreshDetail(@PathVariable Integer id) {
......@@ -250,6 +293,41 @@ public class DeviceCheckController {
String checkUnit = detail.getCheckUnit();
//查出所有装备 分为4类 A 所在是本单位 B 所属是本单位 其中
List<DeviceLibrary> allDevices = dcService.getAllDeviceLibraryList();
Map<Boolean, List<DeviceLibrary>> devLib = getDevLibMap(checkUnit, allDevices);
// 更新detail
List<DeviceLibrary> devInLib = devLib.get(true);
List<DeviceLibrary> devNotInLib = devLib.get(false);
// 特殊单位处理 if DetailId = x , 则补充添加 name=[],[]单位的装备进来
if (specialDetailId !=0 && specialUnits.size() != 0 && id == specialDetailId){
String unitsString = specialUnits.stream().collect(joining(",", "[", "]"));
log.info("[核查模块] 特殊数据处理,要补充特殊数据的省本级detail Id ={},要补充的单位名 = {}",id,unitsString);
for (String specialUnit : specialUnits) {
log.info("[核查模块] 正在补充 {} 的数据",specialUnit);
Map<Boolean, List<DeviceLibrary>> specialLib = getDevLibMap(specialUnit, allDevices);
devInLib.addAll(specialLib.get(true));
devNotInLib.addAll(specialLib.get(false));
}
}
detail.updateDevice(devInLib, devNotInLib);
detail = detailRepo.save(detail);
CheckDetailVo cdVo = transUtil.CheckDetailDo2Vo(detail);
return ResponseEntity.ok(new ResultObj<>(cdVo));
}
/**
* 获得指定单位的在库装备与非在库装备
* @param checkUnit 单位名
* @param allDevices 装备列表
* @return true -> 在库装备,false -> 非在库装备
*/
@NotNull
private Map<Boolean, List<DeviceLibrary>> getDevLibMap(String checkUnit, List<DeviceLibrary> allDevices) {
//在库 = A and B & not B 去除掉ls = 10 的装备 把ls = 11 的装备加入到非在库
Map<Boolean, List<DeviceLibrary>> locationMap = allDevices.stream()
.collect(partitioningBy(d -> d.getLocationUnit().equals(checkUnit)));
......@@ -271,14 +349,10 @@ public class DeviceCheckController {
devNotInLib.addAll(ls11Lib);
// 更新detail
detail.updateDevice(devInLib, devNotInLib);
detail = detailRepo.save(detail);
CheckDetailVo cdVo = transUtil.CheckDetailDo2Vo(detail);
return ResponseEntity.ok(new ResultObj<>(cdVo));
Map<Boolean, List<DeviceLibrary>> devLib = new HashMap<>();
devLib.put(true, devInLib);
devLib.put(false, devNotInLib);
return devLib;
}
/**
......@@ -434,7 +508,12 @@ public class DeviceCheckController {
}
// check type = 1 检查页面 看见的是自查
if (ctVo.getCheckType() == 1) {
Integer createUserId = ctVo.getCreateUserId();
if (userIsProv(createUserId)){
linkVo.setType(2);
}else {
linkVo.setType(3);
}
//看到的都是自查 根据tpye和billId找到父级节点 这里的根节点只能是检查节点
Task rootTask = taskRepo.findAllByBillIdAndBusinessType(billId, type).stream()
.filter(task -> Objects.nonNull(task.getCustomInfo()) &&task.getCustomInfo().contains("exam"))
......@@ -484,7 +563,7 @@ public class DeviceCheckController {
// type = 8 跳转
if (type.equals(CONFIRM_CHECK_DETAIL.id)) {
linkVo.setType(3);
linkVo.setType(4);
linkVo.setDetailId(billId);
}
......@@ -605,9 +684,9 @@ public class DeviceCheckController {
boolean allOk = okCount >= map.size();
if (waitAudit) {
checkReuslt = "等待省审核";
checkReuslt = CHECK_RESULT_WAIT;
} else if (allOk) {
checkReuslt = "无误";
checkReuslt = CHECK_RESULT_DONE;
} else if (notPassed) {
checkReuslt = "未通过";
} else {
......@@ -687,16 +766,16 @@ public class DeviceCheckController {
Integer detailId = task.getBillId();
Integer userCId = detailRepo.findById(detailId).get().getUserCId();
if (task.getBillStatus().equals(END.id) && userIsProv(userCId)){
checkResult = "无误";
checkResult = CHECK_RESULT_DONE;
}else {
checkResult = "等待省审核";
checkResult = CHECK_RESULT_WAIT;
}
}
} else {
checkResult = "等待省审核";
checkResult = CHECK_RESULT_WAIT;
}
} else if (comSituation == 12) {
checkResult = "无误";
checkResult = CHECK_RESULT_DONE;
} else if (comSituation == 13) {
int redoTime = 1;
if (Objects.nonNull(remark) && remark.contains("ROLLBACK")) {
......@@ -711,7 +790,7 @@ public class DeviceCheckController {
}
checkResult = redoTime + "次未通过";
} else {
checkResult = "等待省审核";
checkResult = CHECK_RESULT_WAIT;
}
} else {
checkResult = "状态异常";
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论