提交 1d0702e4 authored 作者: zjm's avatar zjm

fix(核查模块): 修改了缓存对象 unitareabean

修改了缓存对象 unitareabean
上级 a84e65a4
package com.tykj.dev.device.confirmcheck.common; package com.tykj.dev.device.confirmcheck.common;
import com.tykj.dev.device.user.cache.AreaCache;
import com.tykj.dev.device.user.cache.UnitsCache;
import com.tykj.dev.device.user.subject.dao.AreaDao; import com.tykj.dev.device.user.subject.dao.AreaDao;
import com.tykj.dev.device.user.subject.dao.UnitsDao; import com.tykj.dev.device.user.subject.dao.UnitsDao;
import com.tykj.dev.device.user.subject.entity.Area; import com.tykj.dev.device.user.subject.entity.Area;
...@@ -21,21 +23,23 @@ import java.util.stream.Collectors; ...@@ -21,21 +23,23 @@ import java.util.stream.Collectors;
@Configuration @Configuration
public class UnitAreaBean { public class UnitAreaBean {
@Autowired
private AreaDao areaDao;
@Autowired @Autowired
private UnitsDao unitsDao; private UnitsCache unitsCache;
@Autowired
private AreaCache areaCache;
@Bean(name = "unMap")
public Map<String, AreaUnit> unitNameMap() { public Map<String, AreaUnit> unitNameMap() {
return unitsDao.findAll().stream() return unitsCache.findAll().stream()
// .filter(units -> units.getType() == 1) // .filter(units -> units.getType() == 1)
.map(unit -> { .map(unit -> {
int areaId = unitsDao.findAreaIdByName(unit.getName()); // int areaId = unitsDao.findAreaIdByName(unit.getName());
Area area = areaDao.findById(areaId) int areaId= unit.getAreaId();
.orElse(new Area(0, "省直属", 9999, "9999", 0, "")); Area area = areaCache.findById(areaId);
if (area==null){
area= new Area(0, "省直属", 9999, "9999", 0, "");
}
return new AreaUnit(area, unit); return new AreaUnit(area, unit);
}).collect(Collectors.toMap(AreaUnit::getUnitName, Function.identity())); }).collect(Collectors.toMap(AreaUnit::getUnitName, Function.identity()));
......
...@@ -4,6 +4,7 @@ package com.tykj.dev.device.confirmcheck.utils; ...@@ -4,6 +4,7 @@ package com.tykj.dev.device.confirmcheck.utils;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.tykj.dev.device.confirmcheck.common.CheckType; import com.tykj.dev.device.confirmcheck.common.CheckType;
import com.tykj.dev.device.confirmcheck.common.UnitAreaBean;
import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckBill; import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckBill;
import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckDetail; import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckDetail;
import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckStat; import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckStat;
...@@ -79,8 +80,8 @@ public class ObjTransUtil { ...@@ -79,8 +80,8 @@ public class ObjTransUtil {
@Autowired @Autowired
private DeviceLibraryCacheService dlcService; private DeviceLibraryCacheService dlcService;
@Resource(name = "unMap") @Autowired
private Map<String, AreaUnit> unMap; UnitAreaBean unitAreaBean;
@Autowired @Autowired
private PackingLibraryService packingLibraryService; private PackingLibraryService packingLibraryService;
...@@ -95,7 +96,7 @@ public class ObjTransUtil { ...@@ -95,7 +96,7 @@ public class ObjTransUtil {
public CheckDeviceStatVo device2InitStatVo(DeviceLibrary device) { public CheckDeviceStatVo device2InitStatVo(DeviceLibrary device) {
String ownUnit = device.getOwnUnit(); String ownUnit = device.getOwnUnit();
// 这里选择从初始化集合中获取 // 这里选择从初始化集合中获取
String areaName = unMap.get(ownUnit).getName(); String areaName = unitAreaBean.unitNameMap().get(ownUnit).getName();
List<CheckAreaStatVo> areaStatList = Lists.newArrayList(new CheckAreaStatVo(areaName, 0, 1, 0, 0, 0, 0)); List<CheckAreaStatVo> areaStatList = Lists.newArrayList(new CheckAreaStatVo(areaName, 0, 1, 0, 0, 0, 0));
return new CheckDeviceStatVo(device.getModel(), device.getName(), 1, areaStatList); return new CheckDeviceStatVo(device.getModel(), device.getName(), 1, areaStatList);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论