提交 6592d129 authored 作者: ljj's avatar ljj

fix:修复核查模块bug,省发起检查后市检查列表中无对应数据

上级 64d956f9
......@@ -341,22 +341,22 @@ public class DeviceCheckController {
@GetMapping("/detail/{id}")
public ResponseEntity<ResultObj<CheckDetailVo>> findDetail(@PathVariable Integer id) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
long startTime = System.currentTimeMillis();
Task task = taskRepo.findByBillIdAndBusinessType(id, 8).orElseThrow(() -> new ApiException("给出的bill id 不存在"));
if (task.getBillStatus() == 140 || task.getBillStatus() == 160) {
log.info("[核查] 刷新在库/不在库,bill id :{}", id);
refreshDetail(id);
}
CheckDetailVo detailVoList = detailRepo.findById(id)
.map(transUtil::CheckDetailDo2Vo)
.orElse(null);
log.info("[check] 原方法执行用时:{}ms", stopWatch.getTotalTimeMillis());
long secondTime = System.currentTimeMillis();
CheckDetailVo checkDetailVo = historyCheckDeviceService.replayHistoryDevice(detailVoList, id);
log.info("[check] 查询快照所用的时间:{}ms", stopWatch.getTotalTimeMillis());
log.info("[check] 查询快照的时间:{}", System.currentTimeMillis() - secondTime);
return ResponseEntity.ok(new ResultObj<>(checkDetailVo));
}
......
......@@ -38,8 +38,8 @@ import java.util.*;
import static com.tykj.dev.misc.base.BusinessEnum.CONFIRM_CHECK_DETAIL;
import static com.tykj.dev.misc.base.BusinessEnum.CONFIRM_CHECK_STAT;
import static com.tykj.dev.misc.base.StatusEnum.*;
import static com.tykj.dev.misc.base.StatusEnum.CHECK_DETAIL_CITY_0;
import static java.util.stream.Collectors.*;
import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.toList;
/**
* @author dengdiyi
......@@ -80,6 +80,7 @@ public class ExamController {
@Autowired
AreaExhibitionCache areaExhibitionCache;
@GetMapping("/check/confirm/escrow")
@ApiOperation(value = "判断task是否为代管单位的详情任务")
public ResponseEntity judgeEscrowUnit(@RequestParam Integer billId, @RequestParam Integer type) {
......
package com.tykj.dev.device.confirmcheck.entity.domain;
import com.tykj.dev.device.confirmcheck.entity.vo.DeviceInLibVo;
import com.tykj.dev.misc.base.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
......@@ -63,4 +64,5 @@ public class HistoryCheckDevice {
@ApiModelProperty(value = "生命状态")
private String lifeStatusName;
}
......@@ -31,4 +31,6 @@ public interface HistoryCheckDeviceDao extends JpaRepository<HistoryCheckDevice,
@Query(value = "select * from device_history_device where DETAIL_ID = ?1 and DEVICE_LIBRARY_ID = ?2", nativeQuery = true)
List<HistoryCheckDevice> findAllByDetailIdAndDeviceLibraryId(Integer detailId, Integer deviceLibraryId);
}
......@@ -23,6 +23,7 @@ import com.tykj.dev.device.confirmcheck.service.ConfirmCheckService;
import com.tykj.dev.device.confirmcheck.utils.ObjTransUtil;
import com.tykj.dev.device.library.repository.DeviceLibraryDao;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
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;
......@@ -47,17 +48,16 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.scheduling.support.CronTrigger;
import org.springframework.stereotype.Service;
import org.springframework.util.StopWatch;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.ScheduledFuture;
import java.util.function.Function;
import java.util.stream.Collectors;
......@@ -99,6 +99,9 @@ public class ConfirmCheckServiceImpl implements ConfirmCheckService, CommandLine
@Autowired
private UnitsDao unitsRepo;
@Autowired
private TaskDao taskDao;
@Autowired
private DeviceLibraryDao deviceRepo;
......@@ -323,10 +326,12 @@ public class ConfirmCheckServiceImpl implements ConfirmCheckService, CommandLine
@Override
public Page<CheckStatTableVo> findAllStatTable(CheckBillSelectVo checkBillSelectVo) {
long startTime = System.currentTimeMillis();
//过滤出顶级节点 过滤逻辑是1.自己就是父节点2.自己的customInfo = exam or check
List<TaskBto> topStatList = taskService.findBillType(7);
List<Integer> topIdList = topStatList.stream()
List<Integer> topIdList = topStatList
.parallelStream()
.filter(taskBto -> {
if (unitsService.isProvUnit(checkBillSelectVo.getUnitId())) {
return (taskBto.getParentTaskId().equals(0) || taskBto.getParentTaskId() == null)
......@@ -338,44 +343,70 @@ public class ConfirmCheckServiceImpl implements ConfirmCheckService, CommandLine
.map(TaskBto::getBillId)
.collect(toList());
List<CheckStatTableVo> tableVos = statDao.findAll(checkBillSelectVo.getPageable().getSort())
.stream()
List<CheckStatTableVo> tableVos = statDao.findAll()
.parallelStream()
.map(objTransUtil::stat2TableVo)
.filter(vo -> keywordFilter(vo, checkBillSelectVo.getKeyword()))
.filter(v -> topIdList.contains(v.getId()))
.filter(v1 -> unitIdFilter(v1, checkBillSelectVo.getUnitId()))
.collect(Collectors.toList());
long pointA = System.currentTimeMillis() - startTime;
log.info("[check] 查询账单任务用时:{}ms", pointA);
//市级需要添加详情账单信息
// Units unit = unitsRepo.findById(checkBillSelectVo.getUnitId()).get();
// if (unit.getLevel() == 2) {
// Specification<DeviceCheckDetail> pred = Specifications.<DeviceCheckDetail>and()
// .eq("checkUnitId", checkBillSelectVo.getUnitId())
// .build();
// List<CheckDetailVo> detailVoList = detailRepo.findAll(pred).stream()
// .map(transUtil::CheckDetailDo2Vo)
// .collect(toList());
// List<CheckStatTableVo> cityDetailToStatList = detailVoList.stream().map(checkDetailVo -> {
// CheckStatTableVo checkStatTableVo = new CheckStatTableVo();
// checkStatTableVo.setId(checkDetailVo.getId());
// String[] titles = checkDetailVo.getTitle().split("\\%\\^\\&");
// if (titles.length > 1) {
// checkStatTableVo.setTitle(titles[1]);
// }
//
// checkStatTableVo.setShowType(1);
// checkStatTableVo.setCreateTime(TimestampUtil.dateToLocalDateTime(checkDetailVo.getCheckTime()));
// //设置完成情况
// List<TaskUserVo> taskUserVos = taskService.findByBillIdAndBusinessType(checkDetailVo.getId(), 8)
// .stream().map(Task::parse2Bto).map(TaskBto::toVo).collect(toList());
// if (taskUserVos.size() == 1) {
// checkStatTableVo.setCompletion(taskUserVos.get(0).getStatus());
// }
// return checkStatTableVo;
// }).collect(toList());
// tableVos.addAll(cityDetailToStatList);
// }
Units unit = unitsRepo.findById(checkBillSelectVo.getUnitId()).get();
if (unit.getLevel() == 2) {
Specification<Task> pred = Specifications.<Task>and()
.eq("customInfo", "manual")
.build();
List<Task> tasks = taskDao.findAll(pred);
List<Integer> detailIds = tasks
.parallelStream()
.filter(task -> {
Optional<Task> byId = taskDao.findById(task.getParentTaskId());
return byId.filter(value -> "exam".equals(value.getCustomInfo())).isPresent();
}).map(Task::getBillId).collect(toList());
List<CheckDetailVo> detailVoList = detailRepo.findAllById(detailIds)
.parallelStream()
.map(transUtil::CheckDetailDo2Vo)
.collect(toList());
List<CheckStatTableVo> cityDetailToStatList = detailVoList
.parallelStream()
.map(checkDetailVo -> {
CheckStatTableVo checkStatTableVo = new CheckStatTableVo();
checkStatTableVo.setId(checkDetailVo.getId());
String[] titles = checkDetailVo.getTitle().split("\\%\\^\\&");
if (titles.length > 1) {
checkStatTableVo.setTitle(titles[1]);
}
checkStatTableVo.setShowType(1);
checkStatTableVo.setCreateTime(TimestampUtil.dateToLocalDateTime(checkDetailVo.getCheckTime()));
//设置完成情况
List<TaskUserVo> taskUserVos = taskService.findByBillIdAndBusinessType(checkDetailVo.getId(), 8)
.parallelStream().map(Task::parse2Bto).map(TaskBto::toVo).collect(toList());
if (taskUserVos.size() == 1) {
checkStatTableVo.setCompletion(taskUserVos.get(0).getStatus());
}
return checkStatTableVo;
}).collect(toList());
tableVos.addAll(cityDetailToStatList);
log.info("[check] 查询市级账单任务用时:{}ms", System.currentTimeMillis() - startTime);
}
Sort sort = checkBillSelectVo.getPageable().getSort();
Sort.Order createTime = sort.getOrderFor("createTime");
if (createTime == null || "DESC".equals(createTime.getDirection().name())) {
tableVos.sort(Comparator.comparing(CheckStatTableVo::getCreateTime).reversed());
} else {
tableVos.sort(Comparator.comparing(CheckStatTableVo::getCreateTime));
}
return PageUtil.getPerPage(checkBillSelectVo.getPage(), checkBillSelectVo.getSize(), tableVos, checkBillSelectVo.getPageable());
......
......@@ -17,6 +17,7 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* @author: cnljj1995@gmail.com
......@@ -121,6 +122,7 @@ public class HistoryCheckDeviceServiceImpl implements HistoryCheckDeviceService
return devInLibrary;
}
private List<DeviceNotInLibVo> updateDevNotInLib( List<DeviceNotInLibVo> devNotInLibrary, Integer detailId) {
for (DeviceNotInLibVo deviceNotInLibVo : devNotInLibrary) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论