提交 ae2b603b authored 作者: zhoushaopan's avatar zhoushaopan

feat(所有模块): 设置创建bean的顺序

设置创建bean的顺序
上级 f5c6cef9
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;
}
}
......@@ -38,6 +38,7 @@ public class DeviceModelSort {
return mapUnitNameToDisName.get(unitName);
}else {
throw new ApiException("没有找到对应的单位名称替换简称:"+unitName);
// return unitName;
}
}
......
......@@ -120,7 +120,8 @@ public class SelfCheckBillServiceImpl implements SelfCheckBillService {
private Specification<SelfCheckBill> getSelectSpecification(SelfCheckSelectVo selfCheckSelectVo) {
PredicateBuilder<SelfCheckBill> predicateBuilder = Specifications.and();
predicateBuilder.eq("checkUnit",userUtils.getCurrentUserUnitName());
// predicateBuilder.eq("checkUnit",userUtils.getCurrentUserUnitName());
predicateBuilder.eq("checkUnitId",userUtils.getCurrentUnitId());
if (selfCheckSelectVo != null) {
if (selfCheckSelectVo.getCheckStatus() != null) {
predicateBuilder.eq("checkStatus", selfCheckSelectVo.getCheckStatus());
......
......@@ -91,6 +91,7 @@ public class SelfCheckBill {
@Column(name = "check_detail",columnDefinition = "TEXT")
@ApiModelProperty(value = "自查详情(装备主键id+核对结果(0缺失1无误2新增,字符x作为分隔符)),例如10x21x32,意为主键id为1的装备缺失,为2的无误,为3的新增")
private String checkDetail;
@Column(name = "un_stock_detail",columnDefinition = "TEXT")
@ApiModelProperty(value = "非在库装备转JSon")
private String unStockDetail;
......
......@@ -4,6 +4,8 @@ import com.tykj.dev.statistical.service.BigScreenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.core.annotation.Order;
/**
* BigScreenCacheConfig.
......@@ -17,13 +19,12 @@ public class BigScreenCacheConfig {
@Autowired
private BigScreenService bigScreenService;
// @Bean
// public BigScreenCache initBigScreenCache(){
// return new BigScreenCache(bigScreenService.getAllDeviceNum(),bigScreenService.getBusinessNum(2),bigScreenService.getCenterNum(),bigScreenService.getRepairNum(),bigScreenService.getRepairDevices(),bigScreenService.getSelfCheckNum(),bigScreenService.selectUserDataScreen());
// }
@Bean
@Order(value = 20)
@DependsOn("init2")
public BigScreenCache initBigScreenCache(){
return new BigScreenCache();
return new BigScreenCache(bigScreenService.getAllDeviceNum(),bigScreenService.getBusinessNum(2),bigScreenService.getCenterNum(),bigScreenService.getRepairNum(),bigScreenService.getRepairDevices(),bigScreenService.getSelfCheckNum(),bigScreenService.selectUserDataScreen());
}
}
......@@ -19,26 +19,22 @@ import java.text.ParseException;
*/
//@Configuration
@Component
@Order(value = 10)
public class CacheConfig {
@Autowired
private StatisticalService statisticalService;
// @Bean
// public StatisticalCache initStatisticalCache() throws ParseException, InterruptedException {
//
// return new StatisticalCache(statisticalService.getDeviceNum(), statisticalService.getLifeStatus(1),
// statisticalService.getLifeStatus(2), statisticalService.getSelfCheck(), statisticalService.getYearSelfCheck(),
// statisticalService.getRfidWarning(), statisticalService.getRfidWarningDetail(1),
// statisticalService.getRfidWarningDetail(2), statisticalService.getCheckNum(),
// statisticalService.getConfirmCheck(1), statisticalService.getConfirmCheck(2),
// statisticalService.getUserGeneralSituation(), statisticalService.getSelfCheckStat());
// }
@Bean
@DependsOn("init2")
public StatisticalCache initStatisticalCache() throws ParseException, InterruptedException {
return new StatisticalCache();
return new StatisticalCache(statisticalService.getDeviceNum(), statisticalService.getLifeStatus(1),
statisticalService.getLifeStatus(2), statisticalService.getSelfCheck(), statisticalService.getYearSelfCheck(),
statisticalService.getRfidWarning(), statisticalService.getRfidWarningDetail(1),
statisticalService.getRfidWarningDetail(2), statisticalService.getCheckNum(),
statisticalService.getConfirmCheck(1), statisticalService.getConfirmCheck(2),
statisticalService.getUserGeneralSituation(), statisticalService.getSelfCheckStat());
}
}
......@@ -4,6 +4,8 @@ import com.tykj.dev.device.allot.repository.AllotBackBillDao;
import com.tykj.dev.device.allot.repository.AllotBillDao;
import com.tykj.dev.device.allot.subject.domin.AllotBackBill;
import com.tykj.dev.device.allot.subject.domin.AllotBill;
import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckDetail;
import com.tykj.dev.device.confirmcheck.repository.DeviceCheckDetailDao;
import com.tykj.dev.device.repair.repository.RepairBackBillDao;
import com.tykj.dev.device.repair.repository.RepairBillDao;
import com.tykj.dev.device.repair.repository.RepairDetailDao;
......@@ -21,17 +23,20 @@ import com.tykj.dev.device.usereport.subject.domin.DeviceUseReport;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.DependsOn;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
@Slf4j
@Component
@Order(value = 1)
public class DataInit implements CommandLineRunner {
public class DataInit {
@Resource
private UnitsDao unitsDao;
......@@ -196,10 +201,35 @@ public class DataInit implements CommandLineRunner {
return units.size() == 1 ? units.get(0).getUnitId() : -1;
}
@Override
@Order(100)
public void run(String... args) throws Exception {
@Bean
@DependsOn("userUtils")
public void init2(){
log.info("单位名称初始化-----");
initCheckDetailUnitName();
initCheckDetailUnitName2();
}
@Autowired
private DeviceCheckDetailDao
deviceCheckDetailDao;
private void initCheckDetailUnitName2() {
// 对现有的数据补充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);
}
}
// @Override
// @Order(value = 1)
// public void run(String... args) throws Exception {
// log.info("单位名称初始化-----");
// initCheckDetailUnitName();
// }
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论