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

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

上级 ade710ca
......@@ -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.subject.bto.TaskBto;
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.UnitsDao;
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.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.misc.base.ResultObj;
import com.tykj.dev.misc.base.StatusEnum;
......@@ -32,6 +35,7 @@ import com.tykj.dev.misc.utils.MapperUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
......@@ -58,31 +62,30 @@ import static java.util.stream.Collectors.*;
@Slf4j
public class DeviceCheckController {
private final DeviceCheckStatRepo statRepo;
private final DeviceCheckBillDao billRepo;
private final AreaDao areaRepo;
private final UnitsDao unitsRepo;
private final DeviceLibraryDao deviceRepo;
private final DeviceCheckDetailDao detailRepo;
private final ObjTransUtil transUtil;
private final TaskDao taskRepo;
private final TaskService taskService;
private final AuthenticationUtils AuthenticationUtils;
private final AreaCache areaCache;
public DeviceCheckController(DeviceCheckBillDao billRepo, DeviceCheckStatRepo statRepo, AreaDao areaRepo, UnitsDao unitsRepo, DeviceLibraryDao deviceRepo, DeviceCheckDetailDao detailRepo, ObjTransUtil transUtil, TaskDao taskRepo, TaskService taskService, AuthenticationUtils AuthenticationUtils, AreaCache areaCache) {
this.billRepo = billRepo;
this.statRepo = statRepo;
this.areaRepo = areaRepo;
this.unitsRepo = unitsRepo;
this.deviceRepo = deviceRepo;
this.detailRepo = detailRepo;
this.transUtil = transUtil;
this.taskRepo = taskRepo;
this.taskService = taskService;
this.AuthenticationUtils = AuthenticationUtils;
this.areaCache = areaCache;
}
@Autowired
private DeviceCheckStatRepo statRepo;
@Autowired
private DeviceCheckBillDao billRepo;
@Autowired
private AreaDao areaRepo;
@Autowired
private UnitsDao unitsRepo;
@Autowired
private DeviceLibraryDao deviceRepo;
@Autowired
private DeviceCheckDetailDao detailRepo;
@Autowired
private ObjTransUtil transUtil;
@Autowired
private TaskDao taskRepo;
@Autowired
private TaskService taskService;
@Autowired
private AuthenticationUtils AuthenticationUtils;
@Autowired
private AreaCache areaCache;
@Autowired
private AuService auService;
@GetMapping("/area/{fatherId}")
@ApiOperation(value = "查询指定区域下的所有区域信息")
......@@ -247,7 +250,10 @@ public class DeviceCheckController {
//把相同型号的区级的数据merge到市级即可,没有的话改个名加进去
Integer cityStatId = areaStatIdMap.get(cityName);
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里的数据全部取出来展平一层并累加
......@@ -374,25 +380,55 @@ public class DeviceCheckController {
taskService.moveToNext(currentTask, assignUserId);
log.info("[核查模块] A岗核查操作成功");
//3.将父级以及父级的父级的状态更改为正在进行 找到父级的stat对象
Integer fatherId = currentTask.getParentTaskId();
Task cityTask = taskRepo.findById(fatherId).get();
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();
CheckStatVo cityVo = transUtil.checkStatDo2Vo(cityStat);
//这里需要只对本城市的area开启start
String finalCityName = cityName;
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());
//尝试寻找父级的父级
Integer taskProvTaskId = cityTask.getParentTaskId();
if (taskProvTaskId != 0) {
if (areaUnit.getType() == 3) {
//如果是县级城市,那么名字要替换成上级城市
cityName = auService.findOne(AuExample.AreaId, areaUnit.getFatherId()).getName();
}
Integer provStatId = taskRepo.findById(taskProvTaskId).get().getBillId();
DeviceCheckStat provStat = statRepo.findById(provStatId).get();
CheckStatVo provVO = transUtil.checkStatDo2Vo(provStat);
provVO.getDeviceStatVoList()
.forEach(c -> c.getAreaStatList().forEach(CheckAreaStatVo::start));
statRepo.save(cityVo.toDo());
CheckStatVo provVo = transUtil.checkStatDo2Vo(provStat);
String finalName = cityName;
provVo.getDeviceStatVoList()
.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());
}
return ResponseEntity.ok(new ResultObj<>("专管员A操作成功"));
......
......@@ -70,7 +70,7 @@ public class CheckAreaStatVo implements Cloneable {
}
public void start() {
comProgress = 1;
this.comProgress = 1;
}
/**
......
......@@ -78,6 +78,7 @@ class DeviceCheckControllerTest extends BaseTest {
@Autowired
private AuService auService;
@Test
void startAutoCheck() throws Exception {
// 测试
......@@ -129,13 +130,57 @@ class DeviceCheckControllerTest extends BaseTest {
}
@Test
void checkUserA2D() throws Exception {
void checkUserA() throws Exception{
// checkUserA 接口
// initTask = taskRepo.findAll(Specifications.<Task>and()
// .eq("billStatus", StatusEnum.CHECK_DETAIL_0.id)
// .build())
// .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();
......@@ -173,6 +218,7 @@ class DeviceCheckControllerTest extends BaseTest {
initTask.getId(),
initTask.getBillId())));
// checkUserB 接口 测试审核通过
String url_b = baseUrl + "B/" + detailBillId + "?" + "checkStatus=1";
request = put(url_b)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论