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

合并分支 'dev' 到 'master'

Dev to master 查看合并请求 !64
......@@ -112,8 +112,8 @@ public class DeviceApplyController {
@Autowired
private PackingController packingController;
@Autowired
private DeviceLibraryDao deviceLibraryDao;
// @Autowired
// private DeviceLibraryDao deviceLibraryDao;
@ApiOperation(value = "发起装备申请", notes = "可以通过这个接口发起装备申请")
@PostMapping("/addDeviceApplyBill")
......@@ -500,7 +500,8 @@ public class DeviceApplyController {
seqs.addAll(DeviceSeqUtil.selectDeviceSeqs(r.getSeqInterval()));
}
}
deviceLibraryDao.upDateSeqNumbersApplyTaskId(taskBto.getId(), seqs);
// deviceLibraryDao.upDateSeqNumbersApplyTaskId(taskBto.getId(), seqs);
deviceLibraryService.upDateSeqNumbersApplyTaskId(taskBto.getId(),seqs);
}
}
return ResponseEntity.ok("ok");
......
package com.tykj.dev.config;
import java.lang.annotation.*;
/**
* UpdateCache注解
*
* @author zsp
*/
@Target({ElementType.METHOD,ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface UpdateCache {
String type() default "";
}
package com.tykj.dev.device.confirmcheck.common;
import com.tykj.dev.device.confirmcheck.entity.vo.LinkVo;
import lombok.Data;
import java.util.HashMap;
import java.util.Map;
/**
* CcDataCache. 核查模块自用缓存
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/9/23 at 5:32 下午
*/
@Data
public class CcDataCache {
public static Map<Integer, LinkVo> linkVoCache = new HashMap<>();
}
package com.tykj.dev.device.confirmcheck.common;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import java.util.HashMap;
/**
* CcInitRunner.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/9/23 at 5:30 下午
*/
@Order(99)
public class CcInitRunner implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
//初始化Map 从DB里面拿数据
CcDataCache.linkVoCache = new HashMap<>(32);
}
}
package com.tykj.dev.device.confirmcheck.controller;
import com.alibaba.fastjson.JSON;
import com.github.wenhao.jpa.Specifications;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
......@@ -10,10 +11,12 @@ import com.tykj.dev.device.confirmcheck.common.CheckChart;
import com.tykj.dev.device.confirmcheck.common.CheckType;
import com.tykj.dev.device.confirmcheck.common.TaskPeriod;
import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckDetail;
import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckLink;
import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckStat;
import com.tykj.dev.device.confirmcheck.entity.vo.*;
import com.tykj.dev.device.confirmcheck.repository.DeviceCheckBillDao;
import com.tykj.dev.device.confirmcheck.repository.DeviceCheckDetailDao;
import com.tykj.dev.device.confirmcheck.repository.DeviceCheckLinkDao;
import com.tykj.dev.device.confirmcheck.repository.DeviceCheckStatDao;
import com.tykj.dev.device.confirmcheck.service.ConfirmCheckService;
import com.tykj.dev.device.confirmcheck.utils.ObjTransUtil;
......@@ -30,6 +33,7 @@ import com.tykj.dev.device.task.subject.bto.TaskBto;
import com.tykj.dev.device.task.subject.bto.TaskLogBto;
import com.tykj.dev.device.task.subject.domin.Task;
import com.tykj.dev.device.user.base.enums.AuExample;
import com.tykj.dev.device.user.base.ret.UserShenRe;
import com.tykj.dev.device.user.cache.AreaCache;
import com.tykj.dev.device.user.read.service.MessageService;
import com.tykj.dev.device.user.read.subject.bto.MessageBto;
......@@ -87,6 +91,11 @@ public class DeviceCheckController {
final String CHECK_RESULT_DONE = "已查阅";
Map<Integer, String> desMap = new HashMap<>();
Map<Integer, String> desBillMap = new HashMap<>();
private int specialDetailId = 0;
private List<String> specialUnits = new ArrayList<>();
@Autowired
private DeviceCheckLinkDao linkRepo;
@Autowired
private DeviceCheckStatDao statRepo;
@Autowired
......@@ -121,8 +130,6 @@ public class DeviceCheckController {
private MyWebSocket myWebSocket;
@Autowired
private SelfCheckController selfCheckController;
private int specialDetailId = 0;
private List<String> specialUnits = new ArrayList<>();
@Autowired
private MessageService messageService;
@Autowired
......@@ -135,14 +142,19 @@ public class DeviceCheckController {
}
/**
* @return level = 0 ,1 ,2 的单位
* 查询默认的可以被核查单位的清单(省本直,省直属,市局),同时过滤掉那些已经被代管的单位
*
* @return type = 2 and level in (1,2) ,filter escrow = 1 的单位
*/
@GetMapping("/unit")
@ApiOperation(value = "查询默认的可以被核查单位的清单(省本直,省直属,市局)")
@ApiOperation(value = "查询默认的可以被核查单位的清单(省本直,省直属,市局),同时过滤掉那些已经被代管的单位")
public ResponseEntity findDefaultUnits() {
return ResponseEntity.ok(new ResultObj<>(unitsRepo.findAllByTypeInOrLevelIn(
Lists.newArrayList(2),
Lists.newArrayList(1, 2))));
List<Units> units = unitsRepo.findAllByTypeInOrLevelIn(Lists.newArrayList(2), Lists.newArrayList(1, 2))
.stream().filter(Units::isNotEscrow)
.collect(toList());
// 需要去除掉被托管的单位
return ResponseEntity.ok(new ResultObj<>(units));
}
/**
......@@ -232,7 +244,7 @@ public class DeviceCheckController {
return ccService.findAllStatTable(checkBillSelectVo);
}
@ApiOperation(value = "根据id查询核查详情数据", notes = "可以通过这个接口查询核查详情数据")
@ApiOperation(value = "根据billId查询核查详情数据", notes = "可以通过这个接口查询核查详情数据")
@GetMapping("/detail/{id}")
public ResponseEntity<ResultObj<CheckDetailVo>> findDetail(@PathVariable Integer id) {
CheckDetailVo detailVoList = detailRepo.findById(id)
......@@ -241,6 +253,20 @@ public class DeviceCheckController {
return ResponseEntity.ok(new ResultObj<>(detailVoList));
}
@ApiOperation(value = "提供taskId,该接口返回可以跳转到详情页面的数据", notes = "提供taskId,该接口返回可以跳转到详情页面的数据")
@GetMapping("/msgLink")
public ResponseEntity msgLink(@RequestParam Integer taskId) {
// 如果是businessType = 7 走unionLink 否则走detail接口
Task task = taskRepo.findById(taskId).orElseThrow(() -> new ApiException(String.format("没有找到taskId = %d 的任务", taskId)));
if (task.getBusinessType().equals(CONFIRM_CHECK_STAT.id)) {
return unionLink(7, task.getBillId());
} else if (task.getBusinessType().equals(CONFIRM_CHECK_DETAIL.id)) {
return findDetail(task.getBillId());
}
return ResponseEntity.status(400).body("该businessType不在处理范围内!本接口处理的type = 7 ,8");
}
@ApiOperation(value = "根据id查询核查详情数据", notes = "可以通过这个接口查询核查详情数据")
@GetMapping("/detail/unit/{unitId}")
public ResponseEntity<ResultObj<List<CheckDetailVo>>> findDetailsByUnitId(@PathVariable Integer unitId) {
......@@ -325,6 +351,22 @@ public class DeviceCheckController {
devNotInLib.addAll(specialLib.get(false));
}
}
// 代管 - 如果当前自查为省本级自查,则需要将被代管的装备加入到省本级
Units unit = unitsRepo.findByName(checkUnit);
boolean isProv = unit.getLevel() == 1 && unit.getType() == 1;
if (isProv) {
//获得所有的需要被代管的单位的在库与非在库装备,添加到省本级的在库与非在库中去
List<Units> escrowUnits = unitsRepo.findByTypeAndEscrow(2, 1);
for (Units eu : escrowUnits) {
log.info("[核查模块] 正在将 {} 单位的装备托管代理到 {} 单位", checkUnit, eu.getName());
Map<Boolean, List<DeviceLibrary>> libMap = getDevLibMap(eu.getName(), allDevices);
devInLib.addAll(libMap.get(true));
devNotInLib.addAll(libMap.get(false));
}
}
detail.updateDevice(devInLib, devNotInLib);
//更新应查装备数量
......@@ -336,78 +378,61 @@ public class DeviceCheckController {
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)));
List<DeviceLibrary> devInLib = locationMap.get(true);
// filter ls == 11 join to 非在库
List<DeviceLibrary> ls11Lib = devInLib.stream().filter(d -> d.getLifeStatus() == 11).collect(toList());
// filter ls == 10
devInLib = devInLib.stream()
.filter(d -> d.getLifeStatus() != 10 && d.getLifeStatus() != 11)
.collect(toList());
// 非在库 = not A and in B
List<DeviceLibrary> devNotInLib = locationMap.get(false)
.stream().filter(d -> d.getOwnUnit().equals(checkUnit))
.collect(toList());
devNotInLib.addAll(ls11Lib);
Map<Boolean, List<DeviceLibrary>> devLib = new HashMap<>();
devLib.put(true, devInLib);
devLib.put(false, devNotInLib);
return devLib;
}
/**
* 该接口负责处理以下跳转情况
* 1 - 统计跳转
* 1-1 省核查页面 - 市的检查以及省直属的自查任务
* 2 - 详情跳转
*
* @param type 7 统计 8 详情
* @param type 7 统计
* @param billId 业务id
* @return
*/
@ApiOperation(value = "统一跳转接口", notes = "可以通过这个接口进行跳转")
@GetMapping("/link")
public ResponseEntity unionLink(@RequestParam Integer type, @RequestParam Integer billId) {
public ResponseEntity<LinkVo> unionLink(@RequestParam Integer type, @RequestParam Integer billId) {
if (type != CONFIRM_CHECK_STAT.id) {
throw new ApiException("link跳转接口提供的type应当为7,你提供的是 " + type);
}
LinkVo linkVo = new LinkVo();
// 默认的shutDown状态为false
linkVo.setShutDown(false);
//type = 7 统计
if (type.equals(CONFIRM_CHECK_STAT.id)) {
DeviceCheckStat ct = statRepo.findById(billId).get();
CheckStatVo ctVo = transUtil.checkStatDo2Vo(ct);
linkVo.setTitle(ctVo.getTitle());
LocalDateTime endTime = ctVo.getEndTime();
endTime = LocalDateTime.of(ctVo.getEndTime().toLocalDate(), LocalTime.MAX);
// LocalDateTime endTime = ctVo.getEndTime().plusDays(1);
//新增修改时间
LocalDateTime updateTime = ctVo.getUpdateTime();
// linkVo.setEndTime(ctVo.getEndTime().toLocalDate());
linkVo.setEndTime(LocalDateTime.of(ctVo.getEndTime().toLocalDate(), LocalTime.MAX).toLocalDate());
List<LinkCheckDetail> lcdList = new ArrayList<>();
List<LinkExamDetail> ledList = new ArrayList<>();
// if else 结果 1.核查页面(市检查and省直属单位自查) 2.检查页面 (均为单位自查)
// check type = 0 核查页面 看见的是市检查与省直属自查
//是否要走缓存,如果该任务taskId = 20000,则调用上次保存的结果(取另外一张表),否则即时计算并保存结果
// 获取核查/检查的任务节点
Task rootTask = taskRepo.findAllByBillIdAndBusinessType(billId, type).stream()
.filter(task -> Objects.nonNull(task.getCustomInfo()) && ("exam".equals(task.getCustomInfo()) || "check".equals(task.getCustomInfo())))
.findFirst()
.orElseThrow(() -> new ApiException("[核查模块]没有找到对应billId的统计任务,您给的billId = " + billId));
// key = stat id ,value = LinkVo
if (rootTask.getBillStatus().equals(CHECK_SHUT_DOWN.id)) {
// 拿之前保存的缓存
linkVo = linkRepo.findByStatId(billId)
.orElseThrow(() -> new ApiException(String.format("没有找到stat id = %d 的统计缓存,请检查数据", billId)))
.toVo()
.getLinkVo();
linkVo.setShutDown(true);
} else {
// 正常处理,即时计算
// checkType = 0 核查,checkType = 1 检查
if (ctVo.getCheckType() == 0) {
linkVo.setType(1);
// 根据tpye和billId找到父级节点 - 默认了最顶级的省核查节点应当为一个
Task rootTask = taskRepo.findAllByBillIdAndBusinessType(billId, type).get(0);
// 先检出所有类型为7或者8的Task集合 方便后续操作
Specification<Task> pred = Specifications.<Task>and()
......@@ -531,11 +556,7 @@ public class DeviceCheckController {
} else {
linkVo.setType(3);
}
//看到的都是自查 根据tpye和billId找到父级节点 这里的根节点只能是检查节点
Task rootTask = taskRepo.findAllByBillIdAndBusinessType(billId, type).stream()
.filter(task -> Objects.nonNull(task.getCustomInfo()) && task.getCustomInfo().contains("exam"))
.findFirst()
.orElseThrow(() -> new ApiException("[核查模块]没有找到对应billId的检查任务,您给的billId = " + billId));
// 找到所有的子节点
List<Task> childTask = taskRepo.findAllByParentTaskId(rootTask.getId());
......@@ -578,389 +599,139 @@ public class DeviceCheckController {
}
}
// type = 8 跳转
if (type.equals(CONFIRM_CHECK_DETAIL.id)) {
linkVo.setType(4);
linkVo.setDetailId(billId);
}
//将此次使用的linkVo更新
DeviceCheckLink updateLink = linkRepo.findByStatId(billId).orElse(new DeviceCheckLink());
updateLink.setLinkText(JSON.toJSONStringWithDateFormat(linkVo, "yyyy-MM-dd"));
updateLink.setStatId(billId);
linkRepo.save(updateLink);
return ResponseEntity.ok(linkVo);
}
@NotNull
private LinkExamDetail getLed(LocalDateTime endTime, LocalDateTime updateTime, Task child) {
Integer childBusType = child.getBusinessType();
Integer childBusId = child.getBillId();
DeviceCheckDetail childDetail = detailRepo.findById(childBusId).get();
String unitName = childDetail.getCheckUnit();
/**
* @param periodId 1-月度 2-季度 3-年度
* @return
*/
@ApiOperation(value = "更新自动核查周期", notes = "更新自动核查周期")
@PutMapping("/task/{periodId}")
public ResponseEntity updateTaskPeriod(
@PathVariable @ApiParam(value = "核查周期,1-月度 2-季度 3-年度", example = "1") Integer periodId) {
if (periodId < 1 || periodId > 3) {
return ResponseEntity.status(400).body(new ResultObj<>("提供了错误的周期参数!应该是 1/2/3 , 您提供的是" + periodId));
}
TaskPeriod period = TaskPeriod.values()[periodId - 1];
List<CheckAreaStatVo> casList = parseStatString2Vo(child.parse2Bto(), childDetail).stream()
.map(CheckDeviceStatVo::getAreaStatList)
.flatMap(checkAreaStatVos -> checkAreaStatVos.stream())
.collect(toList());
//自查的areaName要从detail里找
String areaName = childDetail.getCheckUnit();
CheckAreaStatVo cas;
// 更新最新的周期
ccService.updateTaskPeriod(period);
// 结束当前任务,开启下轮任务
ccService.stopAutoCheckCron();
boolean startSuccess = ccService.startAutoCheckCron();
if (casList.isEmpty()) {
cas = new CheckAreaStatVo("默认地区", 0, 0, 0, 0, 0, 0);
if (startSuccess) {
String nextTime = ccService.getNextTaskDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
return ResponseEntity.ok(new ResultObj<>(String.format("更新自动核查周期成功,下一次任务的执行时间为%s", nextTime)));
} else {
cas = casList.get(0);
return ResponseEntity.status(400).body("自动核查更新周期失败了!");
}
}
LinkExamDetail led = cas2led(cas, child, endTime, updateTime);
@ApiOperation(value = "获取下一次自动核查任务执行的具体时间", notes = "获取下一次自动核查任务执行的具体时间")
@GetMapping("/task/next")
public Map<String, LocalDate> getNextTaskTime() {
return ImmutableMap.of("nextTaskTime", ccService.getNextTaskDate());
}
led.setCheckUnit(unitName);
return led;
@ApiOperation(value = "获取当前自动核查的核查周期", notes = "monthly-月度,quarterly-季度,yearly-年度")
@GetMapping("/task/current")
public Map<String, String> getCurrentTaskPeriod() {
String periodName = ccService.getCurrentTaskPeriod().getCronExpression().name();
return ImmutableMap.of("currentTaskPeriod", periodName);
}
/**
* lcd 里的列表都为检查,因此是集合对
* 发起检查时获取核查的标题
*
* @param examJobId
* @return
*/
private LinkCheckDetail cas2lcd(List<CheckAreaStatVo> casList, Task task, List<Task> detailTasks, String finalCityName) {
LinkCheckDetail lcd = new LinkCheckDetail();
lcd.setId(task.getBillId());
String finalSituation = "";
// 核查结果的判断具体细节可以查看 docs/confirmCheck.md文档
List<String> situationList = detailTasks.stream()
.map(this::getDetailSituation)
.collect(toList());
// 如果 size = 0 或全都是 无 ,则无
if (situationList.size() == 0) {
finalSituation = "无";
} else {
boolean allIsNothing = situationList.stream().allMatch(s -> s.equals("无"));
if (allIsNothing) {
finalSituation = "无";
}
//如果 有任意一个区状态是待审核
boolean anyIsAudit = situationList.stream().anyMatch(s -> s.equals("等待市审核"));
if (anyIsAudit) {
finalSituation = "等待市审核";
}
//如果 全都是 完成,那么是完成
boolean allIsFinish = situationList.stream().allMatch(s -> s.equals("完成"));
if (allIsFinish) {
finalSituation = "完成";
@GetMapping("/title/{examJobId}")
public ResponseEntity getNames(@PathVariable Integer examJobId) {
// 根据检查的主键id 查询到prov city Stat的title
Integer provId = taskService.get(examJobId).getParentTaskId();
// 检查的job id 找到 father 进而找到 father的billid 进而找到title Id
Integer statId = taskService.get(provId).getBillId();
DeviceCheckStat deviceCheckStat = statRepo.findById(statId).get();
String title = deviceCheckStat.getTitle();
String remark = deviceCheckStat.getRemark();
return ResponseEntity.ok(new CheckTitleAndTimeVo(title, deviceCheckStat.getEndTime(), remark));
}
// 其他情况,则是进行中
if (StringUtils.isEmpty(finalSituation)) {
finalSituation = "进行中";
}
@ApiOperation(value = "发起自动核查", notes = "发起自动核查")
@PostMapping("/auto")
public ResultObj<Map<String, List<Integer>>> startAutoCheck() {
Map<String, List<Integer>> resultIds = ccService.autoCheck();
return new ResultObj<>(resultIds, "自动核查任务发起成功");
}
lcd.setCheckSituation(finalSituation);
// 核查情况 所有子任务都是初始状态 = 无 10=未
String checkReuslt = "";
// Task 先将历史数据给过滤掉 - 方法是按照billId分组排序,跳出主键id最大的即最新的一条
detailTasks = detailTasks.stream()
.collect(groupingBy(Task::getTitle,
collectingAndThen(maxBy(Comparator.comparing(Task::getId)), Optional::get)))
.values().stream()
@ApiOperation(value = "根据地区ID获取下级的单位", notes = "根据地区ID获取下级的单位")
@GetMapping("/under/{areaId}")
public ResponseEntity getUnitsUnderAreaId(@PathVariable Integer areaId, @RequestParam(defaultValue = "true") boolean filter) {
//1.获取child AreaId List
List<Integer> areaIds = areaRepo.findAllByFatherId(areaId).stream()
.map(Area::getId)
.collect(toList());
// 不能存在有9999的任务
boolean notExistsEnd = detailTasks.stream()
.allMatch(t -> !t.getBillStatus().equals(END.id));
//2. 根据childId 获得对应的unit
List<Units> unitsList = unitsRepo.findAllByAreaIdIn(areaIds);
if (notExistsEnd) {
checkReuslt = "无";
} else {
// 任意一个是10则是待审核
boolean waitAudit = casList.stream()
.anyMatch(cas -> cas.getComSituation() == 10);
// 根据filter 决定是否将没有数据的装备给过滤掉
if (filter) {
unitsList = unitsList.stream()
.filter(unit -> deviceRepo.findAllByOwnUnit(unit.getName()).size() != 0)
.collect(toList());
}
boolean notPassed = casList.stream()
.anyMatch(cas -> cas.getComSituation() == 13);
return ResponseEntity.ok(unitsList);
}
// 需要每一个城市都有无误(即12) 才算无误
Map<String, List<CheckAreaStatVo>> map = casList.stream()
.collect(groupingBy(CheckAreaStatVo::getAreaName));
@ApiOperation(value = "检查地区是否可以发起核查", notes = "检查地区是否可以发起核查")
@PostMapping("/checkPossible")
public ResponseEntity checkPossible(@RequestBody UnitIds unitIds) {
List<String> unitNames = unitIds.getIds().stream()
.map(id -> auService.findOne(AuExample.UnitId, id))
.map(AreaUnit::getUnitName)
.collect(toList());
long okCount = 0;
boolean findEmpty = false;
String alertString = "[";
for (List<CheckAreaStatVo> vos : map.values()) {
boolean containsOk = vos.stream()
.anyMatch(checkAreaStatVo -> checkAreaStatVo.getComSituation() == 12);
if (containsOk) {
okCount++;
for (String unitName : unitNames) {
List<DeviceLibrary> devices = deviceRepo.findAllByOwnUnit(unitName);
if (devices.size() == 0) {
findEmpty = true;
alertString += unitName + " ";
}
}
boolean allOk = okCount >= map.size();
alertString += "]";
alertString += "单位没有装备数据,请重新勾选!";
if (waitAudit) {
checkReuslt = CHECK_RESULT_WAIT;
} else if (allOk) {
checkReuslt = CHECK_RESULT_DONE;
} else if (notPassed) {
checkReuslt = "未通过";
} else {
checkReuslt = "进行中";
}
return ResponseEntity.ok(ImmutableMap.of("empty", findEmpty, "msg", alertString));
}
lcd.setCheckResult(checkReuslt);
lcd.setCheckUnit(finalCityName + "局");
@ApiOperation(value = "发起核查", notes = "对指定单位发起核查任务")
@PostMapping("/startCheck")
public ResponseEntity startCheck(@RequestBody CheckCheckVo ccVO) {
// 构建省的统计账单
Integer startUnitId = ccVO.getUnitId();
Units startUnit = unitsRepo.findById(startUnitId).get();
List<Units> checkedUnits = unitsRepo.findAllById(ccVO.getUnitRange());
// 1.发起自己的自查 (市,tpye=2,省 level = 0,1,2)
// 2.发起自己的检查(只是市级别的 level=2)
List<String> checkedUnitNames = checkedUnits.stream().map(Units::getName).collect(toList());
return lcd;
}
@GetMapping("/test/test")
private String justForTest() {
CheckChart.taskStatus2Situation.forEach((k, v) -> System.out.println(v));
return "test";
}
/**
* 获得自查的核查情况
*/
private String getDetailSituation(Task task) {
Integer taskStatus = task.getBillStatus();
String situation = CheckChart.taskStatus2Situation.get(taskStatus);
// 无的情况要分两种 一种是初始的无 一种是重做导致的无 通过判断task的remark
String remark = task.getRemark();
if (situation.equals("无")) {
if (Objects.nonNull(remark) && remark.contains("ROLLBACK")) {
situation = "未通过";
}
}
return situation;
}
/**
* led 里的列表都为自查,因此都是单个对象
*
* @return
*/
private LinkExamDetail cas2led(CheckAreaStatVo cas, Task task, LocalDateTime endTime, LocalDateTime updateTime) {
LinkExamDetail led = new LinkExamDetail();
led.setId(task.getBillId());
int comProgress = cas.getComProgress();
int comSituation = cas.getComSituation();
// 核查情况依照 新的与task status来对应 详情可以查看docs/confirmcheck.md里的对应表 对照表
String situation = getDetailSituation(task);
// 逾期的处理,只在完成的那一步才判断
if (situation.equals("完成") && updateTime.isAfter(endTime)) {
situation = "逾期完成";
}
led.setCheckSituation(situation);
String checkResult = "";
String remark = task.getRemark();
// 核查结果 - 如果省的自查任务,核查情况是完成了之后,核查结果就是无误
String unitName = detailRepo.findById(task.getBillId()).get().getCheckUnit();
Integer areaType = auService.findOne(AuExample.UnitName, unitName).getType();
if (!situation.contains("完成")) {
checkResult = "无";
} else if (comSituation == 10) {
// 再判断一下 是2级结构(检查统计)还是3级结构(核查统计)
Integer rootId = taskService.findByTaskId(task.getParentTaskId()).getParentTaskId();
boolean isTwoLevel = rootId == null || rootId == 0;
// 2级结构 - 检查统计 发起人单位是省,结果为等待省审核,发起人是市则是无
if (isTwoLevel) {
Integer startUnitId = userService.findById(task.getCreateUserId()).getUnitsId();
if (startUnitId != 1) {
checkResult = "无";
} else {
//根据detail userC为省且任务状态是完结状态时 变为无误 否则是等待省审核
Integer detailId = task.getBillId();
Integer userCId = detailRepo.findById(detailId).get().getUserCId();
if (task.getBillStatus().equals(END.id) && userIsProv(userCId)) {
checkResult = CHECK_RESULT_DONE;
} else {
checkResult = CHECK_RESULT_WAIT;
}
}
} else {
checkResult = CHECK_RESULT_WAIT;
}
} else if (comSituation == 12) {
checkResult = CHECK_RESULT_DONE;
} else if (comSituation == 13) {
int redoTime = 1;
if (Objects.nonNull(remark) && remark.contains("ROLLBACK")) {
redoTime = Integer.valueOf(remark.split("-")[1]);
}
checkResult = redoTime + "次未通过";
} else if (comSituation == 0) {
if (task.getBillStatus().equals(END.id)) {
int redoTime = 1;
if (Objects.nonNull(remark) && remark.contains("ROLLBACK")) {
redoTime = Integer.valueOf(remark.split("-")[1]);
}
checkResult = redoTime + "次未通过";
} else {
checkResult = CHECK_RESULT_WAIT;
}
} else {
checkResult = "状态异常";
}
led.setCheckResult(checkResult);
led.setCheckUnit(cas.getAreaName() + "局");
return led;
}
/**
* 判断用户是否是省级用户
*
* @return
*/
private boolean userIsProv(Integer userId) {
if (Objects.isNull(userId) || userId == 0) {
return false;
}
Integer unitsId = userService.findById(userId).getUnitsId();
Integer level = unitsRepo.findById(unitsId).get().getLevel();
return level == 1;
}
/**
* @param periodId 1-月度 2-季度 3-年度
* @return
*/
@ApiOperation(value = "更新自动核查周期", notes = "更新自动核查周期")
@PutMapping("/task/{periodId}")
public ResponseEntity updateTaskPeriod(
@PathVariable @ApiParam(value = "核查周期,1-月度 2-季度 3-年度", example = "1") Integer periodId) {
if (periodId < 1 || periodId > 3) {
return ResponseEntity.status(400).body(new ResultObj<>("提供了错误的周期参数!应该是 1/2/3 , 您提供的是" + periodId));
}
TaskPeriod period = TaskPeriod.values()[periodId - 1];
// 更新最新的周期
ccService.updateTaskPeriod(period);
// 结束当前任务,开启下轮任务
ccService.stopAutoCheckCron();
boolean startSuccess = ccService.startAutoCheckCron();
if (startSuccess) {
String nextTime = ccService.getNextTaskDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
return ResponseEntity.ok(new ResultObj<>(String.format("更新自动核查周期成功,下一次任务的执行时间为%s", nextTime)));
} else {
return ResponseEntity.status(400).body("自动核查更新周期失败了!");
}
}
@ApiOperation(value = "获取下一次自动核查任务执行的具体时间", notes = "获取下一次自动核查任务执行的具体时间")
@GetMapping("/task/next")
public Map<String, LocalDate> getNextTaskTime() {
return ImmutableMap.of("nextTaskTime", ccService.getNextTaskDate());
}
@ApiOperation(value = "获取当前自动核查的核查周期", notes = "monthly-月度,quarterly-季度,yearly-年度")
@GetMapping("/task/current")
public Map<String, String> getCurrentTaskPeriod() {
String periodName = ccService.getCurrentTaskPeriod().getCronExpression().name();
return ImmutableMap.of("currentTaskPeriod", periodName);
}
/**
* 发起检查时获取核查的标题
*
* @param examJobId
* @return
*/
@GetMapping("/title/{examJobId}")
public ResponseEntity getNames(@PathVariable Integer examJobId) {
// 根据检查的主键id 查询到prov city Stat的title
Integer provId = taskService.get(examJobId).getParentTaskId();
// 检查的job id 找到 father 进而找到 father的billid 进而找到title Id
Integer statId = taskService.get(provId).getBillId();
DeviceCheckStat deviceCheckStat = statRepo.findById(statId).get();
String title = deviceCheckStat.getTitle();
String remark = deviceCheckStat.getRemark();
return ResponseEntity.ok(new CheckTitleAndTimeVo(title, deviceCheckStat.getEndTime(), remark));
}
@ApiOperation(value = "发起自动核查", notes = "发起自动核查")
@PostMapping("/auto")
public ResultObj<Map<String, List<Integer>>> startAutoCheck() {
Map<String, List<Integer>> resultIds = ccService.autoCheck();
return new ResultObj<>(resultIds, "自动核查任务发起成功");
}
@ApiOperation(value = "根据地区ID获取下级的单位", notes = "根据地区ID获取下级的单位")
@GetMapping("/under/{areaId}")
public ResponseEntity getUnitsUnderAreaId(@PathVariable Integer areaId, @RequestParam(defaultValue = "true") boolean filter) {
//1.获取child AreaId List
List<Integer> areaIds = areaRepo.findAllByFatherId(areaId).stream()
.map(Area::getId)
.collect(toList());
//2. 根据childId 获得对应的unit
List<Units> unitsList = unitsRepo.findAllByAreaIdIn(areaIds);
// 根据filter 决定是否将没有数据的装备给过滤掉
if (filter) {
unitsList = unitsList.stream()
.filter(unit -> deviceRepo.findAllByOwnUnit(unit.getName()).size() != 0)
.collect(toList());
}
return ResponseEntity.ok(unitsList);
}
@ApiOperation(value = "检查地区是否可以发起核查", notes = "检查地区是否可以发起核查")
@PostMapping("/checkPossible")
public ResponseEntity checkPossible(@RequestBody UnitIds unitIds) {
List<String> unitNames = unitIds.getIds().stream()
.map(id -> auService.findOne(AuExample.UnitId, id))
.map(AreaUnit::getUnitName)
.collect(toList());
boolean findEmpty = false;
String alertString = "[";
for (String unitName : unitNames) {
List<DeviceLibrary> devices = deviceRepo.findAllByOwnUnit(unitName);
if (devices.size() == 0) {
findEmpty = true;
alertString += unitName + " ";
}
}
alertString += "]";
alertString += "单位没有装备数据,请重新勾选!";
return ResponseEntity.ok(ImmutableMap.of("empty", findEmpty, "msg", alertString));
}
private String getUnitDateString(Units units, String title) {
return "[" + units.getUnitDesc() + "]" + title;
}
@ApiOperation(value = "发起核查", notes = "对指定单位发起核查任务")
@PostMapping("/startCheck")
public ResponseEntity startCheck(@RequestBody CheckCheckVo ccVO) {
// 构建省的统计账单
Integer startUnitId = ccVO.getUnitId();
Units startUnit = unitsRepo.findById(startUnitId).get();
List<Units> checkedUnits = unitsRepo.findAllById(ccVO.getUnitRange());
// 1.发起自己的自查 (市,tpye=2,省 level = 0,1,2)
// 2.发起自己的检查(只是市级别的 level=2)
List<String> checkedUnitNames = checkedUnits.stream().map(Units::getName).collect(toList());
log.info("[核查模块]发起核查,发起单位为{},被查单位为{}", startUnit.getName(), checkedUnitNames);
log.info("[核查模块]发起核查,发起单位为{},被查单位为{}", startUnit.getName(), checkedUnitNames);
// 构建省的统计账单,所有的checkedUnits都要被包含到统计中去
DeviceCheckStat provinceCheckStat = initStatData(ccVO.getTitle(), ccVO.getRemark(), 0, 0, startUnit.getName(), checkedUnits, ccVO.getEndTime().atStartOfDay());
......@@ -974,7 +745,7 @@ public class DeviceCheckController {
TaskBto provStatTask = new Task(CHECK_STAT_1.id, getUnitDateString(startUnit, ccVO.getTitle()), 0, ".0.", CONFIRM_CHECK_STAT.id, statId, startUnitId)
.parse2Bto();
provStatTask.getInvolveUserIdList().add(authenticationUtils.getAuthentication().getCurrentUserInfo().getUserId());
provStatTask.getInvolveUserIdList().add(-1);
provStatTask.getInvolveUserIdList().add(0);
provStatTask.setCurrentPoint(1);
provStatTask.setCustomInfo("check");
provStatTask = taskService.start(provStatTask);
......@@ -1282,14 +1053,6 @@ public class DeviceCheckController {
return ResponseEntity.ok(desBillMap.get(billId));
}
private TaskBto selectProvTask(Integer taskId) {
TaskBto taskBto = taskService.get(taskId);
if (taskBto.getParentTaskId() == 0) {
return taskBto;
}
return selectProvTask(taskBto.getParentTaskId());
}
/**
* 对于专员A来说的逻辑
* 1. 修改detailString
......@@ -1521,59 +1284,511 @@ public class DeviceCheckController {
}
/**
* 尝试自动完结检查任务(市/省的)
* 1. 当且仅当该检查任务的状态等于@link{CHECK_EXAM_STAT_1}时且其下的所有子任务均为完结状态,自动推进
* 省专管员审核自查数据的方法
*
* @param exam的taskId
* @param detailId 自查主键id
* @param pass 是否通过 true - 通过 ,false - 未通过
* @return
*/
private void advanceExamTask(Integer examTaskId) {
TaskBto parentTask = taskService.findByTaskId(examTaskId);
if (parentTask.getBillStatus().equals(CHECK_EXAM_STAT_1.id) && taskService.TaskTreeIsOver(examTaskId)) {
log.info("[核查模块] 检测到task id = {}的检查任务已经可以自动推进了,自动推进至下一步", examTaskId);
statConfirm(parentTask.getBillId());
@PutMapping("/prov/audit/{id}")
@ApiOperation(value = "省专管人员审核区自查数据的接口")
public ResponseEntity provAudit(
@PathVariable(name = "id") Integer detailId,
@RequestParam boolean pass) {
if (pass) {
log.info("[核查模块] 省专管员审查detailId = {} 的自查数据-审核通过", detailId);
return provAuditPass(detailId);
} else {
log.info("[核查模块] 省专管员审查detailId = {} 的自查数据-审核未通过", detailId);
return provAuitNotPassed(detailId);
}
}
@ApiOperation(value = "终结stat任务,多指核查任务")
@PutMapping("/stat/shutdown/{statId}")
public ResponseEntity shutDown(@PathVariable Integer statId) {
log.info("[核查模块] 终止任务 - 正在终止statId = {} 的统计任务", statId);
Task checkTask = taskRepo.findByBillIdAndBusinessType(statId, CONFIRM_CHECK_STAT.id).get();
// 将该stat任务置为20000,即终止
unionLink(7, statId);
taskService.moveToSpecial(checkTask.parse2Bto(), CHECK_SHUT_DOWN);
supplyLogMsg(checkTask);
// 检验所有还没有end的节点
// 1级节点分为两类 自查类节点&统计数据确认节点 以及 检查类节点
List<Task> l1Childs = taskRepo.findAllByParentTaskId(checkTask.getId());
for (Task c1 : l1Childs) {
if (predNodeType(c1).equals(CcNodeType.EXAM)) {
// c1里的检查节点也shutDown掉 并保存掉
unionLink(7, c1.getBillId());//save
taskService.moveToSpecial(c1.parse2Bto(), CHECK_SHUT_DOWN);
supplyLogMsg(c1);
List<Task> c2Childs = taskRepo.findAllByParentTaskId(c1.getId());
c2Childs.forEach(c2 -> shutDownNode(c2));
} else {
shutDownNode(c1);
}
}
return ResponseEntity.ok(String.format("任务节点task id = %d 的任务已经成功关闭", checkTask.getId()));
}
/**
* @param taskId 待办任务id
* @param statId 市级统计的STAT ID
* @return
*/
@ApiOperation(value = "跟踪任务待办办结确认")
@PostMapping("/stat/done")
public ResponseEntity confirmDone(@RequestParam int taskId, @RequestParam int statId) {
log.info("[核查模块] 正在进行办结任务确认,任务id为 : {}", taskId);
TaskBto cityDoneTask = taskService.get(taskId);
//市的task 且statId保持一致 省待办 需要的是 市的统计taskId
Specification<Task> pred = Specifications.<Task>and()
.eq("billId", statId)
.eq("businessType", CONFIRM_CHECK_STAT.id)
.build();
// 找到child任务 -> 市级任务 如果是2级的则直接找自己
List<Task> tasks = taskRepo.findAll(pred);
Task cityTask = tasks.stream()
.filter(task -> task.getParentTaskId() != 0 && task.getParentTaskId() != null)
.findFirst()
.orElse(tasks.get(0));
// 如果没有父统计TASK 则证明是两级
boolean doubleLevel = cityTask.getParentTaskId() == 0 || cityTask.getParentTaskId() == null;
if (doubleLevel) {
log.info("[核查模块] 办结确认两级检查任务");
} else {
log.info("[核查模块] 办结确认三级检查任务");
//1.累加数据 累加市级数据数据到省级
CheckStatVo cityStat = transUtil.checkStatDo2Vo(statRepo.findById(statId).get());
Integer provStatId = taskService.get(cityTask.getParentTaskId()).getBillId();
CheckStatVo provinceStat = transUtil.checkStatDo2Vo(statRepo.findById(provStatId).get());
String cityName = areaCache.findById(unitsRepo.findAreaId(cityTask.getOwnUnit())).getName();
// 将区级信息合并到市中
List<CheckDeviceStatVo> mergedVo = cityStat.getDeviceStatVoList().stream()
.map(vo -> vo.combine(cityName, cityStat.getId()))
.collect(toList());
// 如果是第一个市,则替换,否则累加
boolean firstCity = taskService.TaskTreeIsStart(cityTask.getParentTaskId(), true);
if (firstCity) {
provinceStat.setDeviceStatVoList(mergedVo);
log.info("[核查模块] 检测到该任务的合并状态为第一个市统计任务,因此直接替换省级统计数据");
} else {
provinceStat.cleanReduce(mergedVo);
log.info("[核查模块] 数据累加成功");
}
DeviceCheckStat dcs = provinceStat.toDo();
statRepo.save(dcs);
}
//2.办结待办
taskService.moveToEnd(cityDoneTask);
//3.如果所有省级的子任务都完成了
boolean over = taskService.TaskTreeIsOver(cityTask.getParentTaskId());
if (over) {
log.info("[核查模块] 所有的省级子任务都完成了,将省统计任务变为待办");
TaskBto provTask = taskService.get(cityTask.getParentTaskId());
provTask.getInvolveUserIdList().add(0);
provTask.setCurrentPoint(provTask.getCurrentPoint() + 1);
taskService.update(provTask);
}
log.info("[核查模块] 办结统计待办操作成功");
return ResponseEntity.ok(new ResultObj<>("办结统计待办确认完毕"));
}
/**
* @param statId 统计账单主键id
*/
@ApiOperation(value = "统计数据确认")
@PostMapping("/stat/verify")
public ResponseEntity<ResultObj> statConfirm(@RequestParam int statId) {
log.info("[核查模块] 正在进行统计数据确认,统计账单id为 : {}", statId);
//将当前的统计task办结
TaskBto currentTask = taskService.get(statId, CONFIRM_CHECK_STAT.id);
currentTask = taskService.moveToEnd(currentTask);
Integer parentTaskId = currentTask.getParentTaskId();
boolean hasParent = parentTaskId != 0;
//尝试寻找老的市办结任务,如果有的话就删除加END
//5.需要将上一次市的确认任务给清理掉 统计确认任务关联的是statId 找到billId -> exam Task ->
// 父级的父级,就是省的任务,然后子child里名字包含 统计数据确认任务 的任务给 END 吧
Map<Integer, List<Task>> doneTaskList = taskRepo.findAllByParentTaskId(parentTaskId)
.stream()
.filter(task -> task.getTitle().contains("统计数据确认任务"))
.collect(groupingBy(Task::getBillId));
List<Task> existsDone = doneTaskList.get(statId);
if (Objects.nonNull(existsDone)) {
for (Task d : existsDone) {
log.info("[核查模块] 发现了id = {}市的重复的统计确认任务,将其完结并剔除整个树节点", d.getId());
d.setParentTaskId(0);
taskService.moveToEnd(d.parse2Bto());
}
}
log.info("[核查模块] 统计数据确认操作成功");
return ResponseEntity.ok(new ResultObj<>("统计数据确认完毕"));
}
/**
* 获得指定单位的在库装备与非在库装备
* lifeStatus 10 = 已销毁 11 = 丢失
*
* @param checkUnit 单位名
* @param allDevices 装备列表
* @return true -> 在库装备,false -> 非在库装备
* @see DeviceLibrary#lifeStatus
*/
@NotNull
private Map<Boolean, List<DeviceLibrary>> getDevLibMap(String checkUnit, List<DeviceLibrary> allDevices) {
// 在库装备 = 所在在本单位 (过滤掉生命状态为10(已销毁)的装备)
// 非在库装备 = 所属是本单位,但是所在不在本单位里 + 原本是在库装备但是生命状态是11(丢失)的装备
Map<Boolean, List<DeviceLibrary>> locationMap = allDevices.stream()
.collect(partitioningBy(d -> d.getLocationUnit().equals(checkUnit)));
List<DeviceLibrary> devInLib = locationMap.get(true);
// filter ls == 11 join to 非在库
List<DeviceLibrary> ls11Lib = devInLib.stream().filter(d -> d.getLifeStatus() == 11).collect(toList());
// filter ls == 10
devInLib = devInLib.stream()
.filter(d -> d.getLifeStatus() != 10 && d.getLifeStatus() != 11)
.collect(toList());
// 非在库 = not A and in B
List<DeviceLibrary> devNotInLib = locationMap.get(false)
.stream().filter(d -> d.getOwnUnit().equals(checkUnit))
.collect(toList());
devNotInLib.addAll(ls11Lib);
Map<Boolean, List<DeviceLibrary>> devLib = new HashMap<>();
devLib.put(true, devInLib);
devLib.put(false, devNotInLib);
return devLib;
}
@NotNull
private LinkExamDetail getLed(LocalDateTime endTime, LocalDateTime updateTime, Task child) {
Integer childBusType = child.getBusinessType();
Integer childBusId = child.getBillId();
DeviceCheckDetail childDetail = detailRepo.findById(childBusId).get();
String unitName = childDetail.getCheckUnit();
List<CheckAreaStatVo> casList = parseStatString2Vo(child.parse2Bto(), childDetail).stream()
.map(CheckDeviceStatVo::getAreaStatList)
.flatMap(checkAreaStatVos -> checkAreaStatVos.stream())
.collect(toList());
//自查的areaName要从detail里找
String areaName = childDetail.getCheckUnit();
CheckAreaStatVo cas;
if (casList.isEmpty()) {
cas = new CheckAreaStatVo("默认地区", 0, 0, 0, 0, 0, 0);
} else {
cas = casList.get(0);
}
LinkExamDetail led = cas2led(cas, child, endTime, updateTime);
led.setCheckUnit(unitName);
return led;
}
/**
* lcd 里的列表都为检查,因此是集合对
*
* @return
*/
private LinkCheckDetail cas2lcd(List<CheckAreaStatVo> casList, Task task, List<Task> detailTasks, String finalCityName) {
LinkCheckDetail lcd = new LinkCheckDetail();
lcd.setId(task.getBillId());
String finalSituation = "";
// 核查结果的判断具体细节可以查看 docs/confirmCheck.md文档
List<String> situationList = detailTasks.stream()
.map(this::getDetailSituation)
.collect(toList());
// 如果 size = 0 或全都是 无 ,则无
if (situationList.size() == 0) {
finalSituation = "无";
} else {
boolean allIsNothing = situationList.stream().allMatch(s -> s.equals("无"));
if (allIsNothing) {
finalSituation = "无";
}
//如果 有任意一个区状态是待审核
boolean anyIsAudit = situationList.stream().anyMatch(s -> s.equals("等待市审核"));
if (anyIsAudit) {
finalSituation = "等待市审核";
}
//如果 全都是 完成,那么是完成
boolean allIsFinish = situationList.stream().allMatch(s -> s.equals("完成"));
if (allIsFinish) {
finalSituation = "完成";
}
// 其他情况,则是进行中
if (StringUtils.isEmpty(finalSituation)) {
finalSituation = "进行中";
}
}
lcd.setCheckSituation(finalSituation);
// 核查情况 所有子任务都是初始状态 = 无 10=未
String checkReuslt = "";
// Task 先将历史数据给过滤掉 - 方法是按照billId分组排序,跳出主键id最大的即最新的一条
detailTasks = detailTasks.stream()
.collect(groupingBy(Task::getTitle,
collectingAndThen(maxBy(Comparator.comparing(Task::getId)), Optional::get)))
.values().stream()
.collect(toList());
// 不能存在有9999的任务
boolean notExistsEnd = detailTasks.stream()
.allMatch(t -> !t.getBillStatus().equals(END.id));
if (notExistsEnd) {
checkReuslt = "无";
} else {
// 任意一个是10则是待审核
boolean waitAudit = casList.stream()
.anyMatch(cas -> cas.getComSituation() == 10);
boolean notPassed = casList.stream()
.anyMatch(cas -> cas.getComSituation() == 13);
// 需要每一个城市都有无误(即12) 才算无误
Map<String, List<CheckAreaStatVo>> map = casList.stream()
.collect(groupingBy(CheckAreaStatVo::getAreaName));
long okCount = 0;
for (List<CheckAreaStatVo> vos : map.values()) {
boolean containsOk = vos.stream()
.anyMatch(checkAreaStatVo -> checkAreaStatVo.getComSituation() == 12);
if (containsOk) {
okCount++;
}
}
boolean allOk = okCount >= map.size();
if (waitAudit) {
checkReuslt = CHECK_RESULT_WAIT;
} else if (allOk) {
checkReuslt = CHECK_RESULT_DONE;
} else if (notPassed) {
checkReuslt = "未通过";
} else {
checkReuslt = "进行中";
}
}
lcd.setCheckResult(checkReuslt);
lcd.setCheckUnit(finalCityName + "局");
return lcd;
}
private TaskBto selectProvTask(Integer taskId) {
TaskBto taskBto = taskService.get(taskId);
if (taskBto.getParentTaskId() == 0) {
return taskBto;
}
return selectProvTask(taskBto.getParentTaskId());
}
/**
* 获得自查的核查情况
*/
private String getDetailSituation(Task task) {
Integer taskStatus = task.getBillStatus();
String situation = CheckChart.taskStatus2Situation.get(taskStatus);
// 无的情况要分两种 一种是初始的无 一种是重做导致的无 通过判断task的remark
String remark = task.getRemark();
if (situation.equals("无")) {
if (Objects.nonNull(remark) && remark.contains("ROLLBACK")) {
situation = "未通过";
}
}
return situation;
}
/**
* led 里的列表都为自查,因此都是单个对象
*
* @return
*/
private LinkExamDetail cas2led(CheckAreaStatVo cas, Task task, LocalDateTime endTime, LocalDateTime updateTime) {
LinkExamDetail led = new LinkExamDetail();
led.setId(task.getBillId());
int comProgress = cas.getComProgress();
int comSituation = cas.getComSituation();
// 核查情况依照 新的与task status来对应 详情可以查看docs/confirmcheck.md里的对应表 对照表
String situation = getDetailSituation(task);
// 逾期的处理,只在完成的那一步才判断
if (situation.equals("完成") && updateTime.isAfter(endTime)) {
situation = "逾期完成";
}
led.setCheckSituation(situation);
String checkResult = "";
String remark = task.getRemark();
// 核查结果 - 如果省的自查任务,核查情况是完成了之后,核查结果就是无误
String unitName = detailRepo.findById(task.getBillId()).get().getCheckUnit();
Integer areaType = auService.findOne(AuExample.UnitName, unitName).getType();
if (!situation.contains("完成")) {
checkResult = "无";
} else if (comSituation == 10) {
// 再判断一下 是2级结构(检查统计)还是3级结构(核查统计)
Integer rootId = taskService.findByTaskId(task.getParentTaskId()).getParentTaskId();
boolean isTwoLevel = rootId == null || rootId == 0;
// 2级结构 - 检查统计 发起人单位是省,结果为等待省审核,发起人是市则是无
if (isTwoLevel) {
Integer startUnitId = userService.findById(task.getCreateUserId()).getUnitsId();
if (startUnitId != 1) {
checkResult = "无";
} else {
//根据detail userC为省且任务状态是完结状态时 变为无误 否则是等待省审核
Integer detailId = task.getBillId();
Integer userCId = detailRepo.findById(detailId).get().getUserCId();
if (task.getBillStatus().equals(END.id) && userIsProv(userCId)) {
checkResult = CHECK_RESULT_DONE;
} else {
checkResult = CHECK_RESULT_WAIT;
}
}
} else {
checkResult = CHECK_RESULT_WAIT;
}
} else if (comSituation == 12) {
checkResult = CHECK_RESULT_DONE;
} else if (comSituation == 13) {
int redoTime = 1;
if (Objects.nonNull(remark) && remark.contains("ROLLBACK")) {
redoTime = Integer.valueOf(remark.split("-")[1]);
}
checkResult = redoTime + "次未通过";
} else if (comSituation == 0) {
if (task.getBillStatus().equals(END.id)) {
int redoTime = 1;
if (Objects.nonNull(remark) && remark.contains("ROLLBACK")) {
redoTime = Integer.valueOf(remark.split("-")[1]);
}
checkResult = redoTime + "次未通过";
} else {
checkResult = CHECK_RESULT_WAIT;
}
} else {
checkResult = "状态异常";
}
led.setCheckResult(checkResult);
led.setCheckUnit(cas.getAreaName() + "局");
return led;
}
/**
* 省专管员审核自查数据的方法
* 判断用户是否是省级用户
*
* @param detailId 自查主键id
* @param pass 是否通过 true - 通过 ,false - 未通过
* @return
*/
@PutMapping("/prov/audit/{id}")
@ApiOperation(value = "省专管人员审核区自查数据的接口")
public ResponseEntity provAudit(
@PathVariable(name = "id") Integer detailId,
@RequestParam boolean pass) {
private boolean userIsProv(Integer userId) {
if (Objects.isNull(userId) || userId == 0) {
return false;
}
Integer unitsId = userService.findById(userId).getUnitsId();
Integer level = unitsRepo.findById(unitsId).get().getLevel();
return level == 1;
}
if (pass) {
log.info("[核查模块] 省专管员审查detailId = {} 的自查数据-审核通过", detailId);
return provAuditPass(detailId);
} else {
log.info("[核查模块] 省专管员审查detailId = {} 的自查数据-审核未通过", detailId);
return provAuitNotPassed(detailId);
private String getUnitDateString(Units units, String title) {
return "[" + units.getUnitDesc() + "]" + title;
}
/**
* 尝试自动完结检查任务(市/省的)
* 1. 当且仅当该检查任务的状态等于@link{CHECK_EXAM_STAT_1}时 并且该检查是三级结构里的核查(即父Id !=0 )且其下的所有子任务均为完结状态,自动推进
*
* @param exam的taskId
*/
private void advanceExamTask(Integer examTaskId) {
TaskBto parentTask = taskService.findByTaskId(examTaskId);
if (parentTask.getBillStatus().equals(CHECK_EXAM_STAT_1.id) && parentTask.getParentTaskId() != 0 && taskService.TaskTreeIsOver(examTaskId)) {
log.info("[核查模块] 检测到task id = {}的检查任务已经可以自动推进了,自动推进至下一步", examTaskId);
statConfirm(parentTask.getBillId());
}
}
@ApiOperation(value = "终结stat任务,多指核查任务")
@PutMapping("/stat/shutdown/{statId}")
public ResponseEntity shutDown(@PathVariable Integer statId) {
//
Task checkTask = taskRepo.findByBillIdAndBusinessType(statId, CONFIRM_CHECK_STAT.id).get();
// 检验所有还没有end的节点
// 1级节点分为两类 自查类节点&统计数据确认节点 以及 检查类节点
List<Task> l1Childs = taskRepo.findAllByParentTaskId(checkTask.getId());
for (Task c1 : l1Childs) {
if (predNodeType(c1).equals(CcNodeType.EXAM)) {
List<Task> c2Childs = taskRepo.findAllByParentTaskId(c1.getId());
c2Childs.forEach(c2 -> shutDownNode(c2));
} else {
shutDownNode(c1);
/**
* 关闭某个节点,该节点下必须没有子节点树了
* <p>1.将该任务进度推进至9999</>
* <p>2.手动补充终结日志</>
* <p>3.将终结信息添加阅知列表里面</>
*
* @param node
*/
private void shutDownNode(Task node) {
log.info("[核查模块] 终止任务-正在关闭 task id = {} 的任务节点");
// 如果是核查类捡点,抛出异常
if (node.getCustomInfo().equals("check") || node.getCustomInfo().equals("exam")) {
throw new ApiException("关闭节点里不处理核查/核查节点...,你提供的任务节点id = " + node.getId());
}
// 其余节点,执行关闭策略
// 1.将该任务进度推进至9999
TaskBto nodeBto = node.parse2Bto();
taskService.moveToEnd(nodeBto);
supplyLogMsg(node);
log.info("[核查模块] 终止任务-task id = {} 成功关闭");
}
return ResponseEntity.ok(String.format("任务节点task id = %d 的任务已经成功关闭", checkTask.getId()));
/**
* 补充任务的终结日志与阅知信息
*
* @param node
*/
private void supplyLogMsg(Task node) {
// 手动补充终结日志
String adminUser = authenticationUtils.getAuthentication().getCurrentUserInfo().getName();
String shutDownMsg = String.format("专管员[%s]终止了该任务", adminUser);
TaskLogBto taskLog = new TaskLogBto(node.getId(), shutDownMsg);
taskLogService.addLog(taskLog);
// 添加阅知信息
List<Integer> involveUserIds = node.parse2Bto().getInvolveUserIdList();
int lastUserId = involveUserIds.get(involveUserIds.size() - 1) == null ? 0 : involveUserIds.get(involveUserIds.size() - 1);
List<Integer> msgUserIds;
if (lastUserId == 0) {
msgUserIds = userService.findByUniteId(node.getOwnUnit()).stream()
.map(UserShenRe::getUserId)
.collect(toList());
} else {
msgUserIds = new ArrayList<>(lastUserId);
}
MessageBto msgBto = new MessageBto(node.getId(), node.getBusinessType(), shutDownMsg, msgUserIds);
messageService.add(msgBto);
}
/**
......@@ -1778,35 +1993,6 @@ public class DeviceCheckController {
statRepo.save(statVo.toDo());
}
/**
* 关闭某个节点,该节点下必须没有子节点树了
* <p>1.将该任务进度推进至9999</>
* <p>2.手动补充终结日志</>
* <p>3.将终结信息添加阅知列表里面</>
*
* @param node
*/
private void shutDownNode(Task node) {
log.info("[核查模块] 终止任务-正在关闭 task id = {} 的任务节点");
// 如果是核查类捡点,抛出异常
if (node.getCustomInfo().equals("check") || node.getCustomInfo().equals("exam")) {
throw new ApiException("关闭节点里不处理核查/核查节点...,你提供的任务节点id = " + node.getId());
}
// 其余节点,执行关闭策略
// 1.将该任务进度推进至9999
TaskBto nodeBto = node.parse2Bto();
taskService.moveToEnd(nodeBto);
// 2.手动补充终结日志
String adminUser = authenticationUtils.getAuthentication().getCurrentUserInfo().getName();
String shutDownMsg = String.format("专管员[%s]终止了该任务", adminUser);
TaskLogBto taskLog = new TaskLogBto(node.getId(), shutDownMsg);
taskLogService.addLog(taskLog);
// 3.添加阅知信息
MessageBto msgBto = new MessageBto(node.getId(), node.getBusinessType(), shutDownMsg, nodeBto.getInvolveUserIdList());
messageService.add(msgBto);
log.info("[核查模块] 终止任务-task id = {} 成功关闭");
}
/**
* 用来判断该节点类型
*
......@@ -1841,128 +2027,6 @@ public class DeviceCheckController {
}
/**
* @param taskId 待办任务id
* @param statId 市级统计的STAT ID
* @return
*/
@ApiOperation(value = "跟踪任务待办办结确认")
@PostMapping("/stat/done")
public ResponseEntity confirmDone(@RequestParam int taskId, @RequestParam int statId) {
log.info("[核查模块] 正在进行办结任务确认,任务id为 : {}", taskId);
TaskBto cityDoneTask = taskService.get(taskId);
//市的task 且statId保持一致 省待办 需要的是 市的统计taskId
Specification<Task> pred = Specifications.<Task>and()
.eq("billId", statId)
.eq("businessType", CONFIRM_CHECK_STAT.id)
.build();
// 找到child任务 -> 市级任务 如果是2级的则直接找自己
List<Task> tasks = taskRepo.findAll(pred);
Task cityTask = tasks.stream()
.filter(task -> task.getParentTaskId() != 0 && task.getParentTaskId() != null)
.findFirst()
.orElse(tasks.get(0));
// 如果没有父统计TASK 则证明是两级
boolean doubleLevel = cityTask.getParentTaskId() == 0 || cityTask.getParentTaskId() == null;
if (doubleLevel) {
log.info("[核查模块] 办结确认两级检查任务");
} else {
log.info("[核查模块] 办结确认三级检查任务");
//1.累加数据 累加市级数据数据到省级
CheckStatVo cityStat = transUtil.checkStatDo2Vo(statRepo.findById(statId).get());
Integer provStatId = taskService.get(cityTask.getParentTaskId()).getBillId();
CheckStatVo provinceStat = transUtil.checkStatDo2Vo(statRepo.findById(provStatId).get());
String cityName = areaCache.findById(unitsRepo.findAreaId(cityTask.getOwnUnit())).getName();
// 将区级信息合并到市中
List<CheckDeviceStatVo> mergedVo = cityStat.getDeviceStatVoList().stream()
.map(vo -> vo.combine(cityName, cityStat.getId()))
.collect(toList());
// 如果是第一个市,则替换,否则累加
boolean firstCity = taskService.TaskTreeIsStart(cityTask.getParentTaskId(), true);
if (firstCity) {
provinceStat.setDeviceStatVoList(mergedVo);
log.info("[核查模块] 检测到该任务的合并状态为第一个市统计任务,因此直接替换省级统计数据");
} else {
provinceStat.cleanReduce(mergedVo);
log.info("[核查模块] 数据累加成功");
}
DeviceCheckStat dcs = provinceStat.toDo();
statRepo.save(dcs);
}
//2.办结待办
taskService.moveToEnd(cityDoneTask);
//3.如果所有省级的子任务都完成了
boolean over = taskService.TaskTreeIsOver(cityTask.getParentTaskId());
if (over) {
log.info("[核查模块] 所有的省级子任务都完成了,将省统计任务变为待办");
TaskBto provTask = taskService.get(cityTask.getParentTaskId());
provTask.getInvolveUserIdList().add(0);
provTask.setCurrentPoint(provTask.getCurrentPoint() + 1);
taskService.update(provTask);
}
log.info("[核查模块] 办结统计待办操作成功");
return ResponseEntity.ok(new ResultObj<>("办结统计待办确认完毕"));
}
/**
* @param statId 统计账单主键id
*/
@ApiOperation(value = "统计数据确认")
@PostMapping("/stat/verify")
public ResponseEntity<ResultObj> statConfirm(@RequestParam int statId) {
log.info("[核查模块] 正在进行统计数据确认,统计账单id为 : {}", statId);
//将当前的统计task办结
TaskBto currentTask = taskService.get(statId, CONFIRM_CHECK_STAT.id);
currentTask = taskService.moveToEnd(currentTask);
Integer parentTaskId = currentTask.getParentTaskId();
boolean hasParent = parentTaskId != 0;
//尝试寻找老的市办结任务,如果有的话就删除加END
//5.需要将上一次市的确认任务给清理掉 统计确认任务关联的是statId 找到billId -> exam Task ->
// 父级的父级,就是省的任务,然后子child里名字包含 统计数据确认任务 的任务给 END 吧
Map<Integer, List<Task>> doneTaskList = taskRepo.findAllByParentTaskId(parentTaskId)
.stream()
.filter(task -> task.getTitle().contains("统计数据确认任务"))
.collect(groupingBy(Task::getBillId));
List<Task> existsDone = doneTaskList.get(statId);
if (Objects.nonNull(existsDone)) {
for (Task d : existsDone) {
log.info("[核查模块] 发现了id = {}市的重复的统计确认任务,将其完结并剔除整个树节点", d.getId());
d.setParentTaskId(0);
taskService.moveToEnd(d.parse2Bto());
}
}
if (hasParent) {
//市统计的办结 -> 开启对应市 数据确认任务for 省s
Units units = unitsRepo.findById(currentTask.getOwnUnit()).get();
String areaName = auService.findOne(AuExample.UnitId, currentTask.getOwnUnit()).getName();
Integer provId = areaRepo.findAreasByType(1).stream()
.min(Comparator.comparing(Area::getId))
.get()
.getId();
String provTitle = taskRepo.findById(parentTaskId).get().getTitle();
TaskBto cityDoneTask = new TaskBto(CONFIRM_STAT_0.id, provTitle + "统计数据确认任务", parentTaskId, ".", CONFIRM_CHECK_STAT.id, statId, provId, 0);
cityDoneTask.getInvolveUserIdList().add(0);
cityDoneTask.setCurrentPoint(cityDoneTask.getCurrentPoint() + 1);
cityDoneTask.setCustomInfo("");
cityDoneTask = taskService.start(cityDoneTask);
log.info("[核查模块] 统计确认待办任务生成成功, id为 : {}", cityDoneTask.getId());
}
log.info("[核查模块] 统计数据确认操作成功");
return ResponseEntity.ok(new ResultObj<>("统计数据确认完毕"));
}
/**
* 任务结束后需要将当前城市的统计信息汇总上
*
......@@ -2022,17 +2086,17 @@ public class DeviceCheckController {
boolean over = taskService.TaskTreeIsOver(fatherTaskId);
// 如果汇总完毕则将父级的统计任务推进
if (over) {
log.info("[核查模块] 父节点 = {} 的所有子任务均已经完结,推动父节点的任务", fatherTaskId);
TaskBto fatherTask = taskService.get(fatherTaskId);
//如果上一个id是-1 则证明是所有人的跟踪统计,即自动核查,那么下一步推进到所有人的跟踪,否则设置为-2,即维持跟踪者id
//Integer lastUserId = fatherTask.getLastUserId() == -1 ? -1 : -2;
//TaskBto newFatherTask = taskService.moveToNext(fatherTask, lastUserId);
// 将父级的统计任务变为待办
fatherTask.getInvolveUserIdList().add(0);
fatherTask.setCurrentPoint(fatherTask.getCurrentPoint() + 1);
taskService.update(fatherTask);
}
// if (over) {
// log.info("[核查模块] 父节点 = {} 的所有子任务均已经完结,推动父节点的任务", fatherTaskId);
// TaskBto fatherTask = taskService.get(fatherTaskId);
// //如果上一个id是-1 则证明是所有人的跟踪统计,即自动核查,那么下一步推进到所有人的跟踪,否则设置为-2,即维持跟踪者id
// //Integer lastUserId = fatherTask.getLastUserId() == -1 ? -1 : -2;
// //TaskBto newFatherTask = taskService.moveToNext(fatherTask, lastUserId);
// // 将父级的统计任务变为待办
// fatherTask.getInvolveUserIdList().add(0);
// fatherTask.setCurrentPoint(fatherTask.getCurrentPoint() + 1);
// taskService.update(fatherTask);
// }
log.info("[核查模块] 数据汇总完毕");
}
......
package com.tykj.dev.device.confirmcheck.entity.domain;
import com.tykj.dev.device.confirmcheck.entity.vo.DeviceCheckLinkVo;
import com.tykj.dev.device.confirmcheck.entity.vo.LinkVo;
import com.tykj.dev.device.confirmcheck.utils.MapperHelper;
import com.tykj.dev.misc.base.BaseEntity;
import com.tykj.dev.misc.utils.JacksonUtil;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.SQLDelete;
import org.modelmapper.ModelMapper;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.time.LocalDateTime;
/**
* DeviceCheckLink.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/9/23 at 5:40 下午
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Entity
@SQLDelete(sql = "update device_check_link set delete_tag = 1 where id = ?")
@ApiModel("核查检查列表的缓存表")
@NoArgsConstructor
@Table(name = "device_check_link")
public class DeviceCheckLink extends BaseEntity {
private Integer statId;
@Column(name = "link_text", columnDefinition = "TEXT")
private String linkText;
public DeviceCheckLinkVo toVo() {
ModelMapper mapper = MapperHelper.getMapper();
DeviceCheckLinkVo dcLinkVo = mapper.map(this, DeviceCheckLinkVo.class);
LinkVo linkVo = JacksonUtil.readValue(linkText, LinkVo.class);
dcLinkVo.setLinkVo(linkVo);
return dcLinkVo;
}
public DeviceCheckLink(Integer statId , String linkText) {
this.statId = statId;
this.linkText = linkText;
}
public DeviceCheckLink(Integer id, Integer createUserId, Integer updateUserId, LocalDateTime createTime, LocalDateTime updateTime, Integer deleteTag, Integer statId, String linkText) {
super(id, createUserId, updateUserId, createTime, updateTime, deleteTag);
this.statId = statId;
this.linkText = linkText;
}
}
package com.tykj.dev.device.confirmcheck.entity.vo;
import com.alibaba.fastjson.JSON;
import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckLink;
import com.tykj.dev.device.confirmcheck.utils.MapperHelper;
import com.tykj.dev.misc.base.BaseVo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.modelmapper.ModelMapper;
import java.time.LocalDateTime;
/**
* DeviceCheckLinkVo.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/9/24 at 10:58 上午
*/
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
public class DeviceCheckLinkVo extends BaseVo {
private Integer statId;
private LinkVo linkVo;
public DeviceCheckLinkVo(Integer statId, LinkVo linkVo) {
this.statId = statId;
this.linkVo = linkVo;
}
public DeviceCheckLinkVo(Integer id, Integer createUserId, Integer updateUserId, LocalDateTime createTime, LocalDateTime updateTime, Integer deleteTag, Integer statId, LinkVo linkVo) {
super(id, createUserId, updateUserId, createTime, updateTime, deleteTag);
this.statId = statId;
this.linkVo = linkVo;
}
public DeviceCheckLink toDo() {
ModelMapper mapper = MapperHelper.getMapper();
DeviceCheckLink dcLink = mapper.map(this, DeviceCheckLink.class);
String linkText = JSON.toJSONStringWithDateFormat(this.linkVo, "yyyy-MM-dd HH:mm:ss");
dcLink.setLinkText(linkText);
return dcLink;
}
}
package com.tykj.dev.device.confirmcheck.entity.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDate;
import java.util.List;
......@@ -25,11 +31,19 @@ public class LinkVo {
*/
private int type;
/**
* 是否终结 true = 已终结 ,false = 未终结
*/
private boolean isShutDown;
/**
* 核查/检查总标题
*/
private String title;
@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonSerialize(using = LocalDateSerializer.class)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
private LocalDate endTime;
/**
......@@ -48,4 +62,13 @@ public class LinkVo {
this.type = type;
this.endTime = endTime;
}
// public LinkVo(int type, String title, String endTime, List<LinkCheckDetail> lcDetail, List<LinkExamDetail> leDetail, int detailId) {
// this.type = type;
// this.title = title;
// this.endTime = LocalDate.parse(endTime);
// this.lcDetail = lcDetail;
// this.leDetail = leDetail;
// this.detailId = detailId;
// }
}
package com.tykj.dev.device.confirmcheck.repository;
import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckLink;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;
import java.util.Optional;
/**
* DeviceCheckLinkDao.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/9/24 at 11:05 上午
*/
@Repository
public interface DeviceCheckLinkDao extends JpaRepository<DeviceCheckLink, Integer>, JpaSpecificationExecutor<DeviceCheckLink> {
Optional<DeviceCheckLink> findByStatId(Integer statId);
}
......@@ -42,6 +42,7 @@ import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import static com.tykj.dev.misc.base.StatusEnum.*;
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toMap;
......@@ -143,16 +144,6 @@ public class ObjTransUtil {
List<Task> childTask = taskDao.findAllByParentTaskId(fatherTaskId);
boolean flag = false;
boolean confirmTaskisDone = false;
for (Task task : childTask) {
if (task.getTitle().contains("统计数据确认任务")) {
if (task.getBillStatus() != 9999) {
flag = true;
} else {
confirmTaskisDone = true;
}
}
}
// 3/3 -> 统计待确认 -> 省统计任务待完结
......@@ -164,28 +155,25 @@ public class ObjTransUtil {
long total = childTask.size();
long done = childTask.stream()
.filter(task -> task.getBillStatus().equals(9999))
.filter(task -> task.getBillStatus().equals(END.id) || task.getBillStatus().equals(CHECK_SHUT_DOWN.id))
.count();
//如果是检查统计的话那么还要看一下他的父节点是不是已经完成了
String completion;
if (done == total) {
if (stat.getCheckType() == CheckType.CT_EXAM && !fatherTask.getBillStatus().equals(9999)) {
boolean examFinish = fatherTask.getBillStatus().equals(END.id) || fatherTask.getBillStatus().equals(CHECK_SHUT_DOWN.id);
if (stat.getCheckType() == CheckType.CT_EXAM && !examFinish) {
completion = "核查完成待办结";
} else {
if (flag) {
completion = "核查完成待确认";
} else {
// confirmTaskidDone 为true 代表此时等待最后的father任务 为false代表 flag = false 且isDone为false 代表整个节点里没有确认节点直接完结
if (confirmTaskisDone) {
if (fatherTask.getBillStatus() == 9999) {
if (fatherTask.getBillStatus().equals(END.id) || fatherTask.getBillStatus().equals(CHECK_SHUT_DOWN.id)) {
completion = "核查完成";
} else {
completion = "核查完成待办结";
}
} else {
completion = "核查完成";
}
}
}
} else {
......
......@@ -867,7 +867,7 @@ public class DeviceLibraryController {
@ApiOperation(value = "修改装备的存放位置")
@PostMapping("/updateDeviceLibraryLocation")
@CacheEvict(value = "devicesLibraryList",key = "'device'",allEntries = true)
// @CacheEvict(value = "devicesLibraryList",key = "'device'",allEntries = true)
public void updateDeviceLibraryLocation(@RequestBody DeviceStorageLocation deviceStorageLocation){
DeviceLibrary deviceLibrary = deviceLibraryService.getOne(deviceStorageLocation.getDevId());
//添加修改存放装备位置
......@@ -875,12 +875,12 @@ public class DeviceLibraryController {
DeviceLogDto deviceLogDto = new DeviceLogDto(deviceStorageLocation.getDevId(), "将存放位置改为"+deviceStorageLocation.getStorageLocation(), null,null,null);
deviceLogService.addLog(deviceLogDto);
deviceLibraryService.update(deviceLibrary);
//异步去查询数据库
executor.execute(
()->{
cacheLibraryService.getAllDeviceLibraryList();
}
);
// //异步去查询数据库
// executor.execute(
// ()->{
// cacheLibraryService.getAllDeviceLibraryList();
// }
// );
}
@ApiOperation("根据装备id修改装备的序列号")
......@@ -944,6 +944,29 @@ public class DeviceLibraryController {
return deviceNewVoList;
}
@ApiOperation(value = "查询可进行绑定的装备", notes = "查询可进行绑定的装备")
@GetMapping("/selectBindingDevice")
public List<DeviceLibrary> selectBindingDevice(){
List<DeviceLibrary> deviceLibraries = cacheLibraryService.getAllDeviceLibraryList().stream()
.filter(deviceLibrary -> deviceLibrary.getPartParentId() == null).collect(Collectors.toList());
// cacheLibraryService.asyncUpdateCache();
return deviceLibraries;
}
@ApiOperation(value = "解除装备绑定", notes = "解除装备绑定")
@GetMapping("/relieveDevice/{deviceId}")
public ResponseEntity relieveDevice(@PathVariable("deviceId") Integer deviceId){
deviceLibraryService.relieveDevice(deviceId);
return ResponseEntity.ok("解除成功");
}
@ApiOperation(value = "进行装备绑定", notes = "进行装备绑定")
@PostMapping("/bindingDevice")
public ResponseEntity bindingDevice(BindingDeviceVo bindingDeviceVo){
deviceLibraryService.bindingDevice(bindingDeviceVo);
return ResponseEntity.ok("绑定成功");
}
/**
* 测试
*/
......
......@@ -191,5 +191,22 @@ public interface DeviceLibraryDao extends JpaRepository<DeviceLibrary, Integer>,
int updateMatchingRange2(Integer matchingRange,@Param("deviceIds") List<Integer> deviceIds);
List<DeviceLibrary> findByModelAndIsPart(String model,Integer isPart);
List<DeviceLibrary> findAllByPartParentId(Integer partParentId);
@Transactional
@Modifying
@Query("update DeviceLibrary o set o.model = :newModel,o.packingId = :packingId where o.id in :deviceIds")
int updateModelAndPackingId(
@Param("newModel") String newModel,
@Param("packingId") Integer packingId,
@Param("deviceIds") List<Integer> deviceIds);
@Transactional
@Modifying
@Query("update DeviceLibrary o set o.packingId = :packingId where o.id in :deviceIds")
int updatePackingId(
@Param("packingId") Integer packingId,
@Param("deviceIds") List<Integer> deviceIds);
}
......@@ -26,4 +26,6 @@ public interface DeviceLibraryCacheService {
void deletAllDeviceLibraryList();
void asyncUpdateCache();
}
package com.tykj.dev.device.library.service;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.library.subject.vo.BindingDeviceVo;
import com.tykj.dev.device.library.subject.vo.DeviceLibrarySelectVo;
import com.tykj.dev.device.library.subject.vo.DeviceStatisticsVo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.repository.query.Param;
import java.util.List;
import java.util.Map;
......@@ -206,11 +208,6 @@ public interface DeviceLibraryService {
*/
DeviceLibrary findBySeqNumber(String seqNumber);
// /**
// *
// */
// List<DeviceLibrary> findByIds2(List<Integer> ids);
/**
* 得到所有的装备
*/
......@@ -245,7 +242,8 @@ public interface DeviceLibraryService {
void updateDevicesOwnUnit(List<Integer> deviceIds);
/**
* @param
* @param localUnit 所在单位
* @param deviceIds 装备id的集合
*/
void updateLocalAndOwn(String localUnit,List<Integer> deviceIds);
......@@ -254,6 +252,9 @@ public interface DeviceLibraryService {
*/
int getMaxSeqNumber(String model);
List<DeviceLibrary> findAllDeviceLibraryList();
List<String> getMaxPartSeqNumber(String model,Integer isPart);
......@@ -264,6 +265,173 @@ public interface DeviceLibraryService {
*/
List<DeviceLibrary> findDevicesByPacking(Integer packing);
/**
* 更新配用范围
* @param libraries 装备的集合
*/
void updateMatchingRange(List<DeviceLibrary> libraries);
/**
* 装备的解除
* @param deviceId 装备id
*/
void relieveDevice(int deviceId);
/**
* 装备的绑定
* @param
*/
void bindingDevice(BindingDeviceVo bindingDeviceVo);
/**
* 以下接口都为缓存做铺垫
*/
/**
* 更新设备序列号
* @param taskId 任务id
* @param seqNumbers 序列号的集合
*/
void upDateSeqNumbersApplyTaskId(Integer taskId,List<String> seqNumbers);
List<DeviceLibrary> findAllByOwnUnit(String ownUnit);
List<DeviceLibrary> getAllByRfidCardId(String rfidCardId);
/**
* 根据装备id的集合更新装备的生命状态
* @param lifeStatus 生命状态
* @param idList 装备id的集合
* @return
*/
int upDateLeftStatus(Integer lifeStatus,@Param("idList") List<Integer> idList);
/**
* 根据装备id的集合更新装备的生命状态
* @param lifeStatus 生命状态
* @param seqNumbers 装备序列号的集合
* @return 影响行数
*/
int upDateSeqNumbersLeftStatus(Integer lifeStatus,@Param("seqNumbers") List<String> seqNumbers);
/**
* 根据装备id的集合更新装备的生命状态和lock
* @param lifeStatus 生命状态
* @param lock 是否解锁
* @param idList 装备id的集合
* @return 影响行数
*/
int upDateLeftStatusAndLockStatus(Integer lifeStatus,Integer lock,@Param("idList") List<Integer> idList);
/**
* 根据装备id的集合更新lock
* @param lock 解锁
* @param idList 装备id的集合
* @return 影响行数
*/
int upDateLockStatus(Integer lock,@Param("idList") List<Integer> idList);
/**
* 根据装备id的集合更新生命状态和单位名称
* @param lifeStatus
* @param unitName
* @param lock
* @param idList
* @return 影响行数
*/
int upDateLeftStatusAndUnitNameAndLockStatus(Integer lifeStatus,String unitName,Integer lock,@Param("idList") List<Integer> idList);
/**
* 根据装备的序列号的集合更新生命状态和单位名称和锁
* @param lifeStatus 生命状态
* @param unitName 单位名称
* @param lock 锁
* @param seqNumbers 装备序列号的集合
* @return 影响行数
*/
int upDateSeqNumbersLeftStatusAndUnitNameAndLockStatus(Integer lifeStatus,String unitName,Integer lock,@Param("seqNumbers") List<String> seqNumbers);
/**
* 根据装备id的集合更新生命状态和所属单位
* @param lifeStatus 生命状态
* @param unitName 所属单位
* @param idList 装备id的集合
* @return 影响行数
*/
int upDateLeftStatusAndOwnUnitName(Integer lifeStatus,String unitName,@Param("idList") List<Integer> idList);
/**
* 根据装备id的集合更新RFID表面号
* @param idList 装备id的集合
* @return 影响行数
*/
int upDateRfidSurfaceIdAsSeqNumber(@Param("idList") List<Integer> idList);
/**
* 根据列装id更新名称
* @param name 名称
* @param packingId 列装id
* @return 影响行数
*/
int upDateName(String name,Integer packingId);
/**
* 根据列装id更新配用范围
* @param matchingRange 配用范围
* @param packingId 列装id
* @return 影响函数
*/
int upDateMatchingRange(Integer matchingRange,Integer packingId);
/**
* 根据装备id更新生命状态
* @param lifeStatus 生命状态
* @param id 装备id
* @return
*/
int batchUpdate(Integer lifeStatus,Integer id);
/**
* 根据装备id更新生命状态
* @param lifeStatus 生命状态
* @param ids 装备id的集合
* @return
*/
int batchUpdate2(Integer lifeStatus,List<Integer> ids);
/**
* 根据列装id更新配用范围
* @param matchingRange 配用范围
* @param packingId 列装id
* @return 影响行数
*/
int updateMatchingRange(Integer matchingRange,Integer packingId);
/**
* 根据列装id更新配用范围
* @param matchingRange 配用范围
* @param deviceIds 装备id的集合
* @return 影响行数
*/
int updateMatchingRange2(Integer matchingRange,@Param("deviceIds") List<Integer> deviceIds);
/**
* 更新型号和列装id
* @param newModel 新的型号
* @param packingId 列装id
* @param deviceIds 装备id集合
* @return 影响行数
*/
int updateModelAndPackingId(String newModel,Integer packingId,List<Integer> deviceIds);
/**
* 根据装备id的集合更新列装id
* @param packingId 列装id
* @param deviceIds 装备id的集合
* @return 影响行数
*/
int updatePackingId(Integer packingId,List<Integer> deviceIds);
/**
* 查询所有装备
*/
List<DeviceLibrary> findAllDevices();
}
......@@ -3,7 +3,9 @@ package com.tykj.dev.device.library.service.impl;
import com.tykj.dev.device.library.repository.DeviceLibraryDao;
import com.tykj.dev.device.library.service.DeviceLibraryCacheService;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
......@@ -13,6 +15,7 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executor;
import java.util.function.Function;
import java.util.stream.Collectors;
......@@ -22,21 +25,26 @@ import java.util.stream.Collectors;
*/
@Service
@CacheConfig(cacheNames = "devicesLibraryList")
@Slf4j
public class CacheLibraryServiceImpl implements DeviceLibraryCacheService {
@Autowired
private DeviceLibraryDao deviceLibraryDao;
@Autowired
@Qualifier("taskExecutor")
private Executor executor;
// @Autowired
// private ConcurrentMapCacheManager mapCacheManager;
@Autowired
private DeviceLibraryCacheService deviceLibraryCacheService;
@Override
@Cacheable(key = "'device'")
public List<DeviceLibrary> getAllDeviceLibraryList() {
long l = System.currentTimeMillis();
long start = System.currentTimeMillis();
List<DeviceLibrary> all = deviceLibraryDao.findAll();
System.out.println("缓存时间"+(System.currentTimeMillis()-l));
log.info("缓存时间:{}", System.currentTimeMillis() - start);
return all;
}
......@@ -64,4 +72,14 @@ public class CacheLibraryServiceImpl implements DeviceLibraryCacheService {
// List<DeviceLibrary> all = deviceLibraryDao.findAll();
// System.out.println("更新缓存时间"+(System.currentTimeMillis()-l));
}
@Override
@CacheEvict(key = "'device'",allEntries=true)
public void asyncUpdateCache() {
executor.execute(()->{
deviceLibraryCacheService.getAllDeviceLibraryList();
});
}
}
......@@ -5,12 +5,16 @@ import com.github.wenhao.jpa.Specifications;
import com.tykj.dev.blockcha.subject.entity.BcHash;
import com.tykj.dev.blockcha.subject.service.BlockChainUtil;
import com.tykj.dev.config.TaskBeanConfig;
import com.tykj.dev.config.UpdateCache;
import com.tykj.dev.config.base.DeviceLifeStatus;
import com.tykj.dev.device.library.controller.CacheLibraryController;
import com.tykj.dev.device.library.repository.DeviceLibraryDao;
import com.tykj.dev.device.library.service.DeviceLibraryCacheService;
import com.tykj.dev.device.library.service.DeviceLibraryService;
import com.tykj.dev.device.library.service.DeviceLogService;
import com.tykj.dev.device.library.subject.Dto.DeviceLogDto;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.library.subject.vo.BindingDeviceVo;
import com.tykj.dev.device.library.subject.vo.DeviceLibrarySelectVo;
import com.tykj.dev.device.library.subject.vo.DeviceStatisticsVo;
import com.tykj.dev.device.library.utils.DeviceNumberUtils;
......@@ -61,7 +65,14 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
@Autowired
private DeviceLibraryCacheService cacheLibraryService;
@Autowired
private DeviceLogService deviceLogService;
@Autowired
private DeviceLibraryCacheService deviceLibraryCacheService;
@Override
@UpdateCache
public DeviceLibrary addEntity(DeviceLibrary deviceLibraryEntity) {
DeviceLibrary deviceLibrary = deviceLibraryDao.save(deviceLibraryEntity);
CompletableFuture.runAsync(()->{
......@@ -550,7 +561,8 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
@Override
public Map<Integer, DeviceLibrary> getAllDeviceMap() {
List<DeviceLibrary> libraries = deviceLibraryDao.findAll();
// List<DeviceLibrary> libraries = deviceLibraryDao.findAll();
List<DeviceLibrary> libraries = cacheLibraryService.getAllDeviceLibraryList();
libraries.forEach(DeviceLibrary::setConfigName);
return libraries.stream().collect(Collectors.toMap(DeviceLibrary::getId, Function.identity()));
}
......@@ -560,7 +572,8 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
*/
@Override
public Map<String, DeviceLibrary> getAllDeviceSeqMap() {
List<DeviceLibrary> libraries = deviceLibraryDao.findAll();
// List<DeviceLibrary> libraries = deviceLibraryDao.findAll();
List<DeviceLibrary> libraries = cacheLibraryService.getAllDeviceLibraryList();
List<String> seqs = new ArrayList<>();
Iterator<DeviceLibrary> iterator = libraries.iterator();
while (iterator.hasNext()){
......@@ -606,11 +619,13 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
}
@Override
@UpdateCache
public void updateLifeStatus(Integer lifeStatus,Integer id) {
deviceLibraryDao.batchUpdate(lifeStatus,id);
}
@Override
@UpdateCache
public void updateLifeStatus2(Integer lifeStatus, List<Integer> ids) {
deviceLibraryDao.batchUpdate2(lifeStatus,ids);
}
......@@ -630,7 +645,8 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
@Cacheable()
public List<DeviceLibrary> getAllDeviceList(DeviceLibrarySelectVo deviceLibrarySelectVo) {
long l = System.currentTimeMillis();
List<DeviceLibrary> all = deviceLibraryDao.findAll();
// List<DeviceLibrary> all = deviceLibraryDao.findAll();
List<DeviceLibrary> all = cacheLibraryService.getAllDeviceLibraryList();
System.out.println("查询时间为"+(System.currentTimeMillis()-l));
return all;
}
......@@ -675,6 +691,7 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
}
@Override
@UpdateCache
public void batchUpdateDevices(String oldModel,String newModel) {
deviceLibraryDao.batchUpdateDevices(oldModel,newModel);
}
......@@ -742,11 +759,18 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
}
@Override
@UpdateCache
public void updateDevicesOwnUnit(List<Integer> deviceIds) {
deviceLibraryDao.updateDevicesOwnUnit(deviceIds);
}
@Override
public List<DeviceLibrary> findAllDeviceLibraryList() {
return deviceLibraryDao.findAll().stream().map(DeviceLibrary::setConfigName).collect(Collectors.toList());
}
@UpdateCache
public void updateLocalAndOwn(String localUnit,List<Integer> deviceIds) {
deviceLibraryDao.updateDevicesOwnUnit(localUnit,deviceIds);
}
......@@ -787,12 +811,158 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
}
@Override
@UpdateCache
public void updateMatchingRange(List<DeviceLibrary> libraries) {
}
@Override
@UpdateCache
public void relieveDevice(int deviceId) {
Integer currentUserId = userUtils.getCurrentUserId();
//根据装备id查询附件
List<DeviceLibrary> deviceLibraries = deviceLibraryDao.findAllByPartParentId(deviceId);
deviceLibraries.forEach(deviceLibrary -> {
deviceLibrary.setPartParentId(null);
update(deviceLibrary);
//添加日志
String remark = "该装备进行解绑";
DeviceLogDto deviceLogDto = new DeviceLogDto(deviceId, remark, null,currentUserId,null);
deviceLogService.addLog(deviceLogDto);
});
}
@Override
@UpdateCache
public void bindingDevice(BindingDeviceVo bindingDeviceVo) {
Integer currentUserId = userUtils.getCurrentUserId();
//查询需要绑定的装备的型号和被绑定的装备的型号
DeviceLibrary originDev = deviceLibraryDao.findById(bindingDeviceVo.getOriginDeviceId()).get();
DeviceLibrary toDev = deviceLibraryDao.findById(bindingDeviceVo.getToDeviceId()).get();
if (!originDev.getModel().equals(toDev.getModel())){
//型号进行修改
List<DeviceLibrary> libraries = deviceLibraryDao.findAllByPartParentId(originDev.getId());
libraries.forEach(deviceLibrary -> {
deviceLibrary.setModel(toDev.getModel());
update(deviceLibrary);
});
String remark = "由于需要进行装备的绑定,原来型号修改为"+toDev.getModel();
DeviceLogDto deviceLogDto = new DeviceLogDto(toDev.getId(), remark, null,currentUserId,null);
deviceLogService.addLog(deviceLogDto);
}
originDev.setModel(toDev.getModel());
originDev.setPartParentId(toDev.getId());
update(originDev);
//添加日志
String remark = "原装备和"+toDev.getName()+"的装备进行绑定";
DeviceLogDto deviceLogDto = new DeviceLogDto(toDev.getId(), remark, null,currentUserId,null);
deviceLogService.addLog(deviceLogDto);
}
@Override
@UpdateCache
public void upDateSeqNumbersApplyTaskId(Integer taskId, List<String> seqNumbers) {
deviceLibraryDao.upDateSeqNumbersApplyTaskId(taskId,seqNumbers);
}
@Override
public List<DeviceLibrary> findAllByOwnUnit(String ownUnit) {
return deviceLibraryDao.findAllByOwnUnit(ownUnit);
}
@Override
public List<DeviceLibrary> getAllByRfidCardId(String rfidCardId) {
return deviceLibraryDao.getAllByRfidCardId(rfidCardId);
}
@Override
public int upDateLeftStatus(Integer lifeStatus, List<Integer> idList) {
return deviceLibraryDao.upDateLeftStatus(lifeStatus,idList);
}
@Override
public int upDateSeqNumbersLeftStatus(Integer lifeStatus, List<String> seqNumbers) {
return deviceLibraryDao.upDateSeqNumbersLeftStatus(lifeStatus,seqNumbers);
}
@Override
public int upDateLeftStatusAndLockStatus(Integer lifeStatus, Integer lock, List<Integer> idList) {
return deviceLibraryDao.upDateLeftStatusAndLockStatus(lifeStatus,lock,idList);
}
@Override
public int upDateLockStatus(Integer lock, List<Integer> idList) {
return deviceLibraryDao.upDateLockStatus(lock,idList);
}
@Override
public int upDateLeftStatusAndUnitNameAndLockStatus(Integer lifeStatus, String unitName, Integer lock, List<Integer> idList) {
return deviceLibraryDao.upDateLeftStatusAndUnitNameAndLockStatus(lifeStatus,unitName,lock,idList);
}
@Override
public int upDateSeqNumbersLeftStatusAndUnitNameAndLockStatus(Integer lifeStatus, String unitName, Integer lock, List<String> seqNumbers) {
return deviceLibraryDao.upDateSeqNumbersLeftStatusAndUnitNameAndLockStatus(lifeStatus,unitName,lock,seqNumbers);
}
@Override
public int upDateLeftStatusAndOwnUnitName(Integer lifeStatus, String unitName, List<Integer> idList) {
return deviceLibraryDao.upDateLeftStatusAndOwnUnitName(lifeStatus,unitName,idList);
}
@Override
public int upDateRfidSurfaceIdAsSeqNumber(List<Integer> idList) {
return deviceLibraryDao.upDateRfidSurfaceIdAsSeqNumber(idList);
}
@Override
public int upDateName(String name, Integer packingId) {
return deviceLibraryDao.upDateName(name,packingId);
}
@Override
public int upDateMatchingRange(Integer matchingRange, Integer packingId) {
return deviceLibraryDao.upDateMatchingRange(matchingRange,packingId);
}
@Override
public int batchUpdate(Integer lifeStatus, Integer id) {
return deviceLibraryDao.batchUpdate(lifeStatus,id);
}
@Override
public int batchUpdate2(Integer lifeStatus, List<Integer> ids) {
return deviceLibraryDao.batchUpdate2(lifeStatus,ids);
}
@Override
public int updateMatchingRange(Integer matchingRange, Integer packingId) {
return deviceLibraryDao.updateMatchingRange(matchingRange,packingId);
}
@Override
public int updateMatchingRange2(Integer matchingRange, List<Integer> deviceIds) {
return deviceLibraryDao.updateMatchingRange2(matchingRange,deviceIds);
}
@Override
public int updateModelAndPackingId(String newModel, Integer packingId, List<Integer> deviceIds) {
return deviceLibraryDao.updateModelAndPackingId(newModel,packingId,deviceIds);
}
@Override
public int updatePackingId(Integer packingId, List<Integer> deviceIds) {
return deviceLibraryDao.updatePackingId(packingId,deviceIds);
}
@Override
public List<DeviceLibrary> findAllDevices() {
return cacheLibraryService.getAllDeviceLibraryList();
}
@Override
@UpdateCache
public DeviceLibrary update(DeviceLibrary deviceLibraryEntity) {
DeviceLibrary deviceLibrary = deviceLibraryDao.save(deviceLibraryEntity);
CompletableFuture.runAsync(()->blockChainUtil.appendHash(JacksonUtil.toJSon(deviceLibrary),deviceLibrary.getRecordId()),TaskBeanConfig.getThreadPoolTaskScheduler());
......@@ -811,6 +981,7 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
}
@Override
@UpdateCache
public void delete(Integer id) {
deviceLibraryDao.deleteById(id);
}
......
package com.tykj.dev.device.library.subject.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("装备绑定的vo")
public class BindingDeviceVo {
@ApiModelProperty(value = "要绑定的装备id")
private Integer originDeviceId;
@ApiModelProperty(value = "需要绑定到的装备id")
private Integer toDeviceId;
}
......@@ -9,6 +9,7 @@ import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.*;
import java.time.LocalDateTime;
......@@ -52,12 +53,14 @@ public class BaseEntity {
* 创建时间
*/
@CreatedDate
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
/**
* 更新时间
*/
@LastModifiedDate
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
/**
......
package com.tykj.dev.misc.base;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.time.LocalDateTime;
/**
* BaseVo.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/9/24 at 11:02 上午
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class BaseVo {
/**
* 主键id
*/
private Integer id;
/**
* 创建用户id
*/
private Integer createUserId;
/**
* 更新用户id
*/
private Integer updateUserId;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 更新时间
*/
private LocalDateTime updateTime;
/**
* 删除标记(0:未删除,1:已删除)
*/
private Integer deleteTag = 0;
}
......@@ -65,6 +65,9 @@ public enum StatusEnum {
CHECK_DETAIL_CITY_0(160, "等待专管员A处理"),
CHECK_DETAIL_CITY_1(161, "等待专管员B处理"),
// 核查任务终止状态
CHECK_SHUT_DOWN(20001,"任务终止"),
/**
* 清退任务
*/
......
......@@ -1237,7 +1237,10 @@ public class TaskServiceImpl implements TaskService {
// .map(Task::parse2Bto)
// .collect(Collectors.toList());
List<TaskBto> taskBtos = taskDao.findAll().stream()
.filter(task -> (!task.getBillStatus().equals(StatusEnum.END.id)) && (!task.getBillStatus().equals(StatusEnum.ARCHIVE.id)) && (!task.getBillStatus().equals(StatusEnum.REVOKEALLOTTASK.id)))
.filter(task -> (!task.getBillStatus().equals(StatusEnum.END.id))
&& (!task.getBillStatus().equals(StatusEnum.ARCHIVE.id))
&& (!task.getBillStatus().equals(StatusEnum.REVOKEALLOTTASK.id))
&& (!task.getBillStatus().equals(StatusEnum.CHECK_SHUT_DOWN.id)))
.map(Task::parse2Bto)
.collect(Collectors.toList());
//查询待办
......@@ -1460,7 +1463,8 @@ public class TaskServiceImpl implements TaskService {
predicateBuilder.lt("createTime", taskSelectVo.getEndTime());
}
if (taskSelectVo.getSelectNum() == 4) {
predicateBuilder.eq("billStatus", StatusEnum.END.id);
// predicateBuilder.eq("billStatus", StatusEnum.END.id);
predicateBuilder.in("billStatus", StatusEnum.END.id,StatusEnum.CHECK_SHUT_DOWN.id);
}
if (taskSelectVo.getSelectNum() == 5) {
predicateBuilder.eq("billStatus", StatusEnum.ARCHIVE.id);
......
package com.tykj.dev.union;
import com.tykj.dev.device.library.service.DeviceLibraryCacheService;
import com.tykj.dev.device.library.subject.vo.FileVo;
import com.tykj.dev.device.matching.service.MatchingDeviceBillService;
import com.tykj.dev.device.matching.subject.domin.MatchingDeviceBill;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 增强更新缓存aop
*
* @author zsp
*/
@Slf4j
@Aspect
@Component
public class UpdateCacheAspect {
/**
* 业务新状态
*/
@Autowired
private DeviceLibraryCacheService deviceLibraryCacheService;
/**
* 更新缓存定义切入点
*/
@Pointcut("@annotation(com.tykj.dev.config.UpdateCache)")
public void operationLog() {
}
/**
* 新增结果返回后触发
*/
@AfterReturning(pointcut = "operationLog()")
public void doAfterReturning(JoinPoint point) {
log.info("开始更新缓存");
deviceLibraryCacheService.asyncUpdateCache();
}
}
......@@ -48,4 +48,6 @@ public interface UnitsDao extends JpaRepository<Units, Integer>, JpaSpecificatio
List<Units> findAllByType(Integer type);
List<Units> findByTypeAndEscrow(int type, int escrow);
}
......@@ -95,6 +95,9 @@ public class Units {
@ApiModelProperty(value = "装备配用范围的指定")
private Integer packingMatchingRange;
@ApiModelProperty(value = "是否代管")
private Integer escrow;
/**
* 区域对象
*/
......@@ -113,6 +116,7 @@ public class Units {
null,
null,
null,
null,
null
);
}
......@@ -130,4 +134,18 @@ public class Units {
public LeftNavigation toLeftNavigation(){
return new LeftNavigation(unitId,name,null, UUID.randomUUID().toString(),2,showOrder,null);
}
/**
* @return true = 是代管单位,false = 不是代管单位
*/
public boolean isEscrow(){
return escrow == 1;
}
/**
* @return true = 不是代管单位,false = 是代管单位
*/
public boolean isNotEscrow(){
return escrow == 0;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论