提交 35dd4398 authored 作者: ljj234's avatar ljj234

fix(核查模块):修复核查模块修改单位名称后的显示问题

上级 77669f3d
package com.tykj.dev.device.confirmcheck.common;
import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckDetail;
import com.tykj.dev.device.confirmcheck.repository.DeviceCheckDetailDao;
import com.tykj.dev.device.user.subject.dao.UnitsDao;
import com.tykj.dev.device.user.subject.entity.Units;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import java.util.Collections;
import java.util.List;
/**
* @author Ozoz.L cnljj1995@gmail.com
* on 10/29/21
*/
@Slf4j
@Component
public class CheckInit implements CommandLineRunner {
@Autowired
private UnitsDao unitsDao;
@Autowired
private DeviceCheckDetailDao deviceCheckDetailDao;
@Override
public void run(String... args) throws Exception {
log.info("[核查] 核查模块初进行初始化……");
initCheckDetailUnitName();
}
private void initCheckDetailUnitName() {
// 对现有的数据补充unitId信息
deviceCheckDetailDao.findAll().forEach(this::saveModifyDetail);
}
private void saveModifyDetail(DeviceCheckDetail deviceCheckDetail) {
String checkUnit = deviceCheckDetail.getCheckUnit();
Integer unitId = getUnitId(checkUnit);
if (unitId != -1) {
deviceCheckDetail.setCheckUnitId(unitId);
log.info("[核查] 修正detail历史数据,修正的单位:{},单位id:{}", checkUnit, unitId);
deviceCheckDetailDao.save(deviceCheckDetail);
}
}
private Integer getUnitId(String unitName) {
List<Units> units = unitsDao.findAllByName(unitName).orElse(Collections.emptyList());
return units.size() == 1 ? units.get(0).getUnitId() : -1;
}
}
......@@ -333,7 +333,7 @@ public class DeviceCheckController {
public ResponseEntity<ResultObj<CheckDetailVo>> refreshDetail(@PathVariable Integer id) {
DeviceCheckDetail detail = detailRepo.findById(id)
.orElseThrow(() -> new ApiException("没有找到指定的detail数据,你提供的是 id = " + id));
String checkUnit = detail.getCheckUnit();
String checkUnit = unitsRepo.findById(detail.getCheckUnitId()).get().getName();
//查出所有装备 分为4类 A 所在是本单位 B 所属是本单位 其中
List<DeviceLibrary> allDevices = dcService.getAllDeviceLibraryList();
Map<Boolean, List<DeviceLibrary>> devLib = getDevLibMap(checkUnit, allDevices);
......@@ -518,7 +518,7 @@ public class DeviceCheckController {
// 省直属 ,省本级自查
// 直属自查 -> detail里面找
DeviceCheckDetail childDetail = detailRepo.findById(childBusId).get();
String unitName = childDetail.getCheckUnit();
String unitName = unitsRepo.findById(childDetail.getCheckUnitId()).get().getName();
List<CheckDeviceStatVo> list = parseStatString2Vo(child.parse2Bto(), childDetail);
finalTime = System.currentTimeMillis();
......@@ -827,7 +827,10 @@ public class DeviceCheckController {
}
// 3-1 构建被查单位的 自查账单
DeviceCheckDetail unitDetailDoc = DeviceCheckDetail.EmptyWithChecker(names + "|" + "默认备注", ccVO.getRemark(), 0, 0, 0, 0, unit.getName(), devInLib.getOrDefault(unit.getName(), new ArrayList<>()), devNotInLib.getOrDefault(unit.getName(), new ArrayList<>()));
DeviceCheckDetail unitDetailDoc = DeviceCheckDetail.EmptyWithChecker(names + "|" + "默认备注", ccVO.getRemark(), 0, 0, 0, 0, unit.getName(),
// todo 后期续检查获取UnitI的是否可行
unitsRepo.findByName(unit.getName()).getUnitId(),
devInLib.getOrDefault(unit.getName(), new ArrayList<>()), devNotInLib.getOrDefault(unit.getName(), new ArrayList<>()));
unitDetailDoc.setVar2(String.valueOf(initStatusId));
DeviceCheckDetail detail = detailRepo.save(unitDetailDoc);
// 将id放入统计中去 model -> areaName -> detailId
......@@ -987,9 +990,13 @@ public class DeviceCheckController {
initTaskStatusId = CHECK_DETAIL_CITY_0.id;
}
}
;
// 3-1 构建被查单位的 自查账单
DeviceCheckDetail unitDetailDoc = DeviceCheckDetail.EmptyWithChecker(names + "|" + ed.getRemark(), ceVo.getTitle() + "%^&" + ed.getRemark(), 0, 0, 0, 0, unit.getName(), devInLib.getOrDefault(unit.getName(), new ArrayList<>()), devNotInLib.getOrDefault(unit.getName(), new ArrayList<>()));
DeviceCheckDetail unitDetailDoc = DeviceCheckDetail.EmptyWithChecker(names + "|" + ed.getRemark(), ceVo.getTitle() + "%^&" + ed.getRemark(), 0, 0, 0, 0, unit.getName(),
// todo 后期需要检查是否可以根据单位名称得到unitId,检查逻辑
unitsRepo.findByName(unit.getName()).getUnitId(),
devInLib.getOrDefault(unit.getName(), new ArrayList<>()), devNotInLib.getOrDefault(unit.getName(), new ArrayList<>()));
unitDetailDoc.setVar2(String.valueOf(initTaskStatusId));
DeviceCheckDetail detail = detailRepo.save(unitDetailDoc);
detailIds.add(detail.getId());
......@@ -1104,8 +1111,10 @@ public class DeviceCheckController {
Integer cityStatId = cityTask.getBillId();
//这里是为了修正特殊的直属单位改为从detail里拿单位(城市)名
String unitName = detailRepo.findById(id).get().getCheckUnit();
AreaUnit areaUnit = auService.findOne(AuExample.UnitName, unitName);
// String unitName = unitsRepo.findById(
// detailRepo.findById(id).get().getCheckUnitId()).get().getName();
AreaUnit areaUnit = auService.findOne(AuExample.UnitId, detailRepo.findById(id).get().getCheckUnitId());
String cityName = areaUnit.getName();
DeviceCheckStat cityStat = statRepo.findById(cityStatId).get();
......@@ -1260,7 +1269,7 @@ public class DeviceCheckController {
if (pass) {
// 通过的话就推进任务进度,合并数据
log.info("[核查模块] 市专管员审核通过,结束 {} 区的自查任务并汇总数据", currentDetail.getCheckUnit());
log.info("[核查模块] 市专管员审核通过,结束 {} 区的自查任务并汇总数据", unitsRepo.findById(currentDetail.getCheckUnitId()).get().getName());
taskService.moveToNext(currentTask);
Integer userId = authenticationUtils.getAuthentication().getCurrentUserInfo().getUserId();
currentDetail.setUserCId(userId);
......@@ -1269,7 +1278,7 @@ public class DeviceCheckController {
// // 检查该exam任务是否可以完结推进了
advanceExamTask(currentTask.getParentTaskId(), false);
return ResponseEntity.ok("市专管员审核通过,结束" + currentDetail.getCheckUnit() + " 区的自查任务并汇总数据");
return ResponseEntity.ok("市专管员审核通过,结束" + unitsRepo.findById(currentDetail.getCheckUnitId()).get().getName() + " 区的自查任务并汇总数据");
} else {
log.info("[核查模块] 市专管员审核未通过,回滚该任务到初始状态,任务id = {}", currentTask.getId());
// 重置Task任务本身的任务状态,使其回滚到等待专管员A处理时的状态,并在Task里添加特殊的回滚标记,用来鉴别这是一个回滚任务
......@@ -1528,14 +1537,14 @@ public class DeviceCheckController {
Integer childBusId = child.getBillId();
DeviceCheckDetail childDetail = detailRepo.findById(childBusId).get();
String unitName = childDetail.getCheckUnit();
String unitName = unitsRepo.findById(childDetail.getCheckUnitId()).get().getName();
List<CheckAreaStatVo> casList = parseStatString2Vo(child.parse2Bto(), childDetail).stream()
.map(CheckDeviceStatVo::getAreaStatList)
.flatMap(checkAreaStatVos -> checkAreaStatVos.stream())
.collect(toList());
//自查的areaName要从detail里找
String areaName = childDetail.getCheckUnit();
String areaName = unitsRepo.findById(childDetail.getCheckUnitId()).get().getName();
CheckAreaStatVo cas;
if (casList.isEmpty()) {
......@@ -1700,8 +1709,8 @@ public class DeviceCheckController {
String checkResult = "";
String remark = task.getRemark();
// 核查结果 - 如果省的自查任务,核查情况是完成了之后,核查结果就是无误
String unitName = detailRepo.findById(task.getBillId()).get().getCheckUnit();
Integer areaType = auService.findOne(AuExample.UnitName, unitName).getType();
String unitName = unitsRepo.findById(detailRepo.findById(task.getBillId()).get().getCheckUnitId()).get().getName();
Integer areaType = auService.findOne(AuExample.UnitId, detailRepo.findById(task.getBillId()).get().getCheckUnitId()).getType();
if (!situation.contains("完成")) {
checkResult = "无";
......@@ -1769,6 +1778,7 @@ public class DeviceCheckController {
return level == 1;
}
// todo
private String getUnitDateString(Units units, String title) {
return "[" + units.getUnitDesc() + "]" + title;
......@@ -1908,7 +1918,7 @@ public class DeviceCheckController {
cDetail.setReview(false);
cDetail = detailRepo.save(cDetail);
// 创建新的任务(被拒绝的自查单位如果是区则是140状态,否则是160状态 )
String unitName = cDetail.getCheckUnit();
String unitName = unitsRepo.findById(cDetail.getCheckUnitId()).get().getName();
Integer level = unitsRepo.findByName(unitName).getLevel();
Integer initStatusId = 0;
if (level == 3) {
......@@ -1988,7 +1998,7 @@ public class DeviceCheckController {
detailRepo.save(detail);
//将对应stat中地区的comProgress 改为 2 comsitution 改为12
String areaName = auService.findOne(AuExample.UnitName, detail.getCheckUnit()).getName();
String areaName = auService.findOne(AuExample.UnitId, detail.getCheckUnitId()).getName();
TaskBto currentTask = taskService.get(id, CONFIRM_CHECK_DETAIL.id);
TaskBto fatherTask = taskService.get(currentTask.getParentTaskId());
DeviceCheckStat dcs = statRepo.findById(fatherTask.getBillId()).get();
......@@ -2051,7 +2061,7 @@ public class DeviceCheckController {
}
private void removeDetailFromDcs(DeviceCheckDetail detail, DeviceCheckStat dcs) {
String areaName = auService.findOne(AuExample.UnitName, detail.getCheckUnit()).getName();
String areaName = auService.findOne(AuExample.UnitId, detail.getCheckUnitId()).getName();
CheckStatVo csv = transUtil.checkStatDo2Vo(dcs);
for (CheckDeviceStatVo vo : csv.getDeviceStatVoList()) {
List<CheckAreaStatVo> filterList = vo.getAreaStatList().stream()
......@@ -2172,7 +2182,7 @@ public class DeviceCheckController {
cityStatVo = cityStatVo.cleanReduce(addVos);
// 把cityStatVo里本地区的进度更改为2
String unitName = currentDetail.getCheckUnit();
String unitName = findUnitName(currentDetail);
Integer areaId = unitsRepo.findByName(unitName).getAreaId();
String areaName = areaRepo.findById(areaId).orElse(new Area(0, "省直属", 9999, "9999", 0, ""))
.getName();
......@@ -2238,8 +2248,7 @@ public class DeviceCheckController {
long start1 = System.currentTimeMillis();
// 根这里unid可以从detail里拿,根据unitId 查到 areaId 根据 areaId 查询到 areaName
String areaName = auService.findOne(AuExample.UnitName, detail.getCheckUnit()).getName();
String areaName = findUnitName(detail);
// detailId与statId只需要查询一次
int detailId = Optional.ofNullable(taskRepo.findBillIdByTaskId(task.getId())).orElse(0);
......@@ -2443,7 +2452,6 @@ public class DeviceCheckController {
*/
public CheckAreaStatVo combineCaList(List<CheckAreaStatVo> casList, String finalCityName) {
int supposeCount = 0;
int actualCount = 0;
int progressCount = 0;
......@@ -2495,13 +2503,20 @@ public class DeviceCheckController {
finalSituation = 1;
}
return new CheckAreaStatVo(finalCityName, actualCount, supposeCount, finalProgress, finalSituation, 0, 0);
}
private void findBySystem() {
selfCheckController.findBySystem1();
}
/**
* find unit's name by detail's unitId
* @param deviceCheckDetail detail obj
* @return unit's name
*/
private String findUnitName(DeviceCheckDetail deviceCheckDetail) {
return unitsRepo.findById(deviceCheckDetail.getCheckUnitId()).get().getName();
}
}
......
......@@ -94,16 +94,19 @@ public class DeviceCheckDetail extends BaseEntity {
@ApiModelProperty(value = "核查单位")
private String checkUnit;
@ApiModelProperty(value = "核查单位id")
private Integer checkUnitId;
/**
* 应查数量
*/
@ApiModelProperty(value = "应查数量")
private Integer checkingCount;
/**
* 实查数量
*/
@ApiModelProperty(value = "实查数量")
private Integer checkedCount;
/**
......@@ -183,6 +186,7 @@ public class DeviceCheckDetail extends BaseEntity {
Integer userBId,
Date checkTime,
String checkUnit,
Integer checkUnitId,
Integer checkingCount,
Integer checkedCount,
String checkResult,
......@@ -197,6 +201,7 @@ public class DeviceCheckDetail extends BaseEntity {
this.userBId = userBId;
this.checkTime = checkTime;
this.checkUnit = checkUnit;
this.checkUnitId = checkUnitId;
this.checkingCount = checkingCount;
this.checkedCount = checkedCount;
this.checkResult = checkResult;
......@@ -219,6 +224,7 @@ public class DeviceCheckDetail extends BaseEntity {
Integer userAId,
Integer userBId,
String checkUnit,
Integer checkUnitId,
List<DeviceLibrary> devInLib,
List<DeviceLibrary> devNotInLib) {
//构造checkDetail 分当前在库与不在库的 赋予不同状态
......@@ -249,6 +255,7 @@ public class DeviceCheckDetail extends BaseEntity {
userBId,
TimestampUtil.getNowDate(),
checkUnit,
checkUnitId,
devInLib.size(),
0,
"",
......
......@@ -204,6 +204,7 @@ public class ConfirmCheckServiceImpl implements ConfirmCheckService, CommandLine
baseTitle,
0, 0, 0, 0,
cityUnit.getName(),
cityUnit.getUnitId(),
devInLib.getOrDefault(cityUnit.getName(), new ArrayList<>()),
devNotInLib.getOrDefault(cityUnit.getName(), new ArrayList<>()));
DeviceCheckDetail cityDetail = detailRepo.save(cityDetailDo);
......@@ -230,6 +231,7 @@ public class ConfirmCheckServiceImpl implements ConfirmCheckService, CommandLine
baseTitle,
0, 0, 0, 0,
countyUnit.getName(),
countyUnit.getUnitId(),
devInLib.getOrDefault(countyUnit.getName(), new ArrayList<>()),
devNotInLib.getOrDefault(countyUnit.getName(), new ArrayList<>()));
DeviceCheckDetail countyDetail = detailRepo.save(countyDetailDo);
......
......@@ -360,8 +360,7 @@ public class ObjTransUtil {
detailVo.setDevInLibrary(inLibVoList);
detailVo.setDevNotInLibrary(notInLibVoList);
String unitName = detailDo.getCheckUnit();
String areaName = auService.findOne(AuExample.UnitName, unitName).getName();
String areaName = auService.findOne(AuExample.UnitId, detailDo.getCheckUnitId()).getName();
detailVo.setCheckArea(areaName);
detailVo.setRemark(detailDo.getRemark());
......
......@@ -7,6 +7,7 @@ import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Optional;
@Repository
public interface UnitsDao extends JpaRepository<Units, Integer>, JpaSpecificationExecutor<Units> {
......@@ -14,6 +15,8 @@ public interface UnitsDao extends JpaRepository<Units, Integer>, JpaSpecificatio
List<Units> findAllByAreaId(Integer areaId);
Optional<List<Units>> findAllByName(String unitName);
Units findByName(String unitName);
List<Units> findAllByLevelGreaterThanEqual(Integer level);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论