提交 b5e661e9 authored 作者: Matrix's avatar Matrix

[核查模块] 修复了初始化统计状态进度异常的问题

上级 ade710ca
...@@ -19,11 +19,14 @@ import com.tykj.dev.device.task.repository.TaskDao; ...@@ -19,11 +19,14 @@ import com.tykj.dev.device.task.repository.TaskDao;
import com.tykj.dev.device.task.service.TaskService; import com.tykj.dev.device.task.service.TaskService;
import com.tykj.dev.device.task.subject.bto.TaskBto; import com.tykj.dev.device.task.subject.bto.TaskBto;
import com.tykj.dev.device.task.subject.domin.Task; import com.tykj.dev.device.task.subject.domin.Task;
import com.tykj.dev.device.user.base.enums.AuExample;
import com.tykj.dev.device.user.subject.dao.AreaDao; import com.tykj.dev.device.user.subject.dao.AreaDao;
import com.tykj.dev.device.user.subject.dao.UnitsDao; import com.tykj.dev.device.user.subject.dao.UnitsDao;
import com.tykj.dev.device.user.subject.entity.Area; import com.tykj.dev.device.user.subject.entity.Area;
import com.tykj.dev.device.user.subject.entity.Units; import com.tykj.dev.device.user.subject.entity.Units;
import com.tykj.dev.device.user.subject.entity.User; import com.tykj.dev.device.user.subject.entity.User;
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.util.AuthenticationUtils; import com.tykj.dev.device.user.util.AuthenticationUtils;
import com.tykj.dev.misc.base.ResultObj; import com.tykj.dev.misc.base.ResultObj;
import com.tykj.dev.misc.base.StatusEnum; import com.tykj.dev.misc.base.StatusEnum;
...@@ -32,6 +35,7 @@ import com.tykj.dev.misc.utils.MapperUtils; ...@@ -32,6 +35,7 @@ import com.tykj.dev.misc.utils.MapperUtils;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -58,31 +62,30 @@ import static java.util.stream.Collectors.*; ...@@ -58,31 +62,30 @@ import static java.util.stream.Collectors.*;
@Slf4j @Slf4j
public class DeviceCheckController { public class DeviceCheckController {
private final DeviceCheckStatRepo statRepo; @Autowired
private final DeviceCheckBillDao billRepo; private DeviceCheckStatRepo statRepo;
private final AreaDao areaRepo; @Autowired
private final UnitsDao unitsRepo; private DeviceCheckBillDao billRepo;
private final DeviceLibraryDao deviceRepo; @Autowired
private final DeviceCheckDetailDao detailRepo; private AreaDao areaRepo;
private final ObjTransUtil transUtil; @Autowired
private final TaskDao taskRepo; private UnitsDao unitsRepo;
private final TaskService taskService; @Autowired
private final AuthenticationUtils AuthenticationUtils; private DeviceLibraryDao deviceRepo;
private final AreaCache areaCache; @Autowired
private DeviceCheckDetailDao detailRepo;
public DeviceCheckController(DeviceCheckBillDao billRepo, DeviceCheckStatRepo statRepo, AreaDao areaRepo, UnitsDao unitsRepo, DeviceLibraryDao deviceRepo, DeviceCheckDetailDao detailRepo, ObjTransUtil transUtil, TaskDao taskRepo, TaskService taskService, AuthenticationUtils AuthenticationUtils, AreaCache areaCache) { @Autowired
this.billRepo = billRepo; private ObjTransUtil transUtil;
this.statRepo = statRepo; @Autowired
this.areaRepo = areaRepo; private TaskDao taskRepo;
this.unitsRepo = unitsRepo; @Autowired
this.deviceRepo = deviceRepo; private TaskService taskService;
this.detailRepo = detailRepo; @Autowired
this.transUtil = transUtil; private AuthenticationUtils AuthenticationUtils;
this.taskRepo = taskRepo; @Autowired
this.taskService = taskService; private AreaCache areaCache;
this.AuthenticationUtils = AuthenticationUtils; @Autowired
this.areaCache = areaCache; private AuService auService;
}
@GetMapping("/area/{fatherId}") @GetMapping("/area/{fatherId}")
@ApiOperation(value = "查询指定区域下的所有区域信息") @ApiOperation(value = "查询指定区域下的所有区域信息")
...@@ -247,7 +250,10 @@ public class DeviceCheckController { ...@@ -247,7 +250,10 @@ public class DeviceCheckController {
//把相同型号的区级的数据merge到市级即可,没有的话改个名加进去 //把相同型号的区级的数据merge到市级即可,没有的话改个名加进去
Integer cityStatId = areaStatIdMap.get(cityName); Integer cityStatId = areaStatIdMap.get(cityName);
map.computeIfPresent(v.getDeviceModel(), (k, value) -> value.reduce(v, cityName, cityStatId)); map.computeIfPresent(v.getDeviceModel(), (k, value) -> value.reduce(v, cityName, cityStatId));
map.putIfAbsent(v.getDeviceModel(), v); map.computeIfAbsent(v.getDeviceModel(), k -> {
v.getAreaStatList().forEach(area -> area.setAreaName(cityName));
return v;
});
} }
//将市级Map里的数据全部取出来展平一层并累加 //将市级Map里的数据全部取出来展平一层并累加
...@@ -374,25 +380,55 @@ public class DeviceCheckController { ...@@ -374,25 +380,55 @@ public class DeviceCheckController {
taskService.moveToNext(currentTask, assignUserId); taskService.moveToNext(currentTask, assignUserId);
log.info("[核查模块] A岗核查操作成功"); log.info("[核查模块] A岗核查操作成功");
//3.将父级以及父级的父级的状态更改为正在进行 找到父级的stat对象 //3.将父级以及父级的父级的状态更改为正在进行 找到父级的stat对象
Integer fatherId = currentTask.getParentTaskId(); Integer fatherId = currentTask.getParentTaskId();
Task cityTask = taskRepo.findById(fatherId).get(); Task cityTask = taskRepo.findById(fatherId).get();
Integer cityStatId = cityTask.getBillId(); Integer cityStatId = cityTask.getBillId();
Integer cityId = currentTask.getOwnUnit();
AreaUnit areaUnit = auService.findOne(AuExample.UnitId, cityId);
String cityName = areaUnit.getName();
DeviceCheckStat cityStat = statRepo.findById(cityStatId).get(); DeviceCheckStat cityStat = statRepo.findById(cityStatId).get();
CheckStatVo cityVo = transUtil.checkStatDo2Vo(cityStat); CheckStatVo cityVo = transUtil.checkStatDo2Vo(cityStat);
//这里需要只对本城市的area开启start
String finalCityName = cityName;
cityVo.getDeviceStatVoList() cityVo.getDeviceStatVoList()
.forEach(c -> c.getAreaStatList().forEach(CheckAreaStatVo::start)); .forEach(c -> c.getAreaStatList().forEach(v -> {
if (v.getAreaName().equals(finalCityName)) {
v.start();
}
}));
List<String> modelNames = devLibVo.getDevInLibrary().stream()
.map(DeviceInLibVo::getModel)
.collect(toList());
statRepo.save(cityVo.toDo()); statRepo.save(cityVo.toDo());
//尝试寻找父级的父级 //尝试寻找父级的父级
Integer taskProvTaskId = cityTask.getParentTaskId(); Integer taskProvTaskId = cityTask.getParentTaskId();
if (taskProvTaskId != 0) { if (taskProvTaskId != 0) {
if (areaUnit.getType() == 3) {
//如果是县级城市,那么名字要替换成上级城市
cityName = auService.findOne(AuExample.AreaId, areaUnit.getFatherId()).getName();
}
Integer provStatId = taskRepo.findById(taskProvTaskId).get().getBillId(); Integer provStatId = taskRepo.findById(taskProvTaskId).get().getBillId();
DeviceCheckStat provStat = statRepo.findById(provStatId).get(); DeviceCheckStat provStat = statRepo.findById(provStatId).get();
CheckStatVo provVO = transUtil.checkStatDo2Vo(provStat); CheckStatVo provVo = transUtil.checkStatDo2Vo(provStat);
provVO.getDeviceStatVoList() String finalName = cityName;
.forEach(c -> c.getAreaStatList().forEach(CheckAreaStatVo::start)); provVo.getDeviceStatVoList()
statRepo.save(cityVo.toDo()); .forEach(c -> {
if (modelNames.contains(c.getDeviceModel())) {
c.getAreaStatList().forEach(vo -> {
if (vo.getAreaName().equals(finalName)) {
vo.start();
}
});
}
});
statRepo.save(provVo.toDo());
log.info("[核查模块 检测到是自动核查任务,将省级统计 id = {} 认为开启]", provStat.getId()); log.info("[核查模块 检测到是自动核查任务,将省级统计 id = {} 认为开启]", provStat.getId());
} }
return ResponseEntity.ok(new ResultObj<>("专管员A操作成功")); return ResponseEntity.ok(new ResultObj<>("专管员A操作成功"));
......
...@@ -70,7 +70,7 @@ public class CheckAreaStatVo implements Cloneable { ...@@ -70,7 +70,7 @@ public class CheckAreaStatVo implements Cloneable {
} }
public void start() { public void start() {
comProgress = 1; this.comProgress = 1;
} }
/** /**
......
...@@ -78,6 +78,7 @@ class DeviceCheckControllerTest extends BaseTest { ...@@ -78,6 +78,7 @@ class DeviceCheckControllerTest extends BaseTest {
@Autowired @Autowired
private AuService auService; private AuService auService;
@Test @Test
void startAutoCheck() throws Exception { void startAutoCheck() throws Exception {
// 测试 // 测试
...@@ -129,13 +130,57 @@ class DeviceCheckControllerTest extends BaseTest { ...@@ -129,13 +130,57 @@ class DeviceCheckControllerTest extends BaseTest {
} }
@Test @Test
void checkUserA2D() throws Exception { void checkUserA() throws Exception{
// checkUserA 接口 // checkUserA 接口
// initTask = taskRepo.findAll(Specifications.<Task>and() // initTask = taskRepo.findAll(Specifications.<Task>and()
// .eq("billStatus", StatusEnum.CHECK_DETAIL_0.id) // .eq("billStatus", StatusEnum.CHECK_DETAIL_0.id)
// .build()) // .build())
// .get(0); // .get(0);
initTask = taskRepo.findById(676).get();
initTask = taskRepo.findById(724).get();
detailBillId = initTask.getBillId();
CheckDetailVo detailVoList = detailRepo.findById(detailBillId)
.map(transUtil::CheckDetailDo2Vo)
.orElse(null);
DevLibVo devLibVo = new DevLibVo(detailVoList.getDevInLibrary(), detailVoList.getDevNotInLibrary());
devLibVo.getDevInLibrary().forEach(d -> d.setProofResult(1));
Map<String, String> paramMap = new HashMap<>();
paramMap.put("assignUserId", "2");
paramMap.put("checkResult", "\"检查结果无误\"");
String url_a = baseUrl + "A/" + detailBillId;
StringJoiner joiner = new StringJoiner("&", "?", "");
for (Map.Entry<String, String> entry : paramMap.entrySet()) {
String k = entry.getKey();
String v = entry.getValue();
joiner.add(k + "=" + v);
}
url_a += joiner.toString();
System.out.println("url is " + url_a);
request = put(url_a)
.header("Origin", "*")
.contentType(MediaType.APPLICATION_JSON)
.content(toJSon(devLibVo));
mockMvc.perform(request)
.andExpect(status().isOk())
.andDo(s -> System.out.println(
String.format("[测试结果] 对任务id=%d的任务执行岗位A详情审核操作成功,审核的详情表id为%d",
initTask.getId(),
initTask.getBillId())));
}
@Test
void checkUserA2D() throws Exception {
initTask = taskRepo.findById(723).get();
detailBillId = initTask.getBillId(); detailBillId = initTask.getBillId();
...@@ -173,6 +218,7 @@ class DeviceCheckControllerTest extends BaseTest { ...@@ -173,6 +218,7 @@ class DeviceCheckControllerTest extends BaseTest {
initTask.getId(), initTask.getId(),
initTask.getBillId()))); initTask.getBillId())));
// checkUserB 接口 测试审核通过 // checkUserB 接口 测试审核通过
String url_b = baseUrl + "B/" + detailBillId + "?" + "checkStatus=1"; String url_b = baseUrl + "B/" + detailBillId + "?" + "checkStatus=1";
request = put(url_b) request = put(url_b)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论