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

feat(装备模块,配套设备库模块):…

feat(装备模块,配套设备库模块): 入库新增存放位置的id,修改装备存放位置的id,根据装备的存放位置查询装备,入库配套设备新增存放位置的id,修改配套装备存放位置的id,根据配套装备的存放位置查询装备, 入库新增存放位置的id,修改装备存放位置的id,根据装备的存放位置查询装备,入库配套设备新增存放位置的id,修改配套装备存放位置的id,根据配套装备的存放位置查询装备,
上级 a52d1735
......@@ -782,6 +782,7 @@ public class DeviceLibraryController {
DeviceLogDto deviceLogDto = new DeviceLogDto(deviceEditVo.getDeviceId(), "将存放位置改为"+libraryUpdateVo.getStorageLocation(), null,null,null);
deviceLogService.addLog(deviceLogDto);
deviceLibraryEntity.setStorageLocation(libraryUpdateVo.getStorageLocation());
deviceLibraryEntity.setStorageLocationId(libraryUpdateVo.getStorageLocationId());
}
//add 备注
if (libraryUpdateVo.getRecord()!=null && !libraryUpdateVo.getRecord().equals(deviceLibraryEntity.getRecord())){
......@@ -931,6 +932,7 @@ public class DeviceLibraryController {
DeviceLibrary deviceLibrary = deviceLibraryService.getOne(deviceStorageLocation.getDevId());
//添加修改存放装备位置
deviceLibrary.setStorageLocation(deviceStorageLocation.getStorageLocation());
deviceLibrary.setStorageLocationId(deviceStorageLocation.getStorageLocationId());
DeviceLogDto deviceLogDto = new DeviceLogDto(deviceStorageLocation.getDevId(), "将存放位置改为"+deviceStorageLocation.getStorageLocation(), null,null,null);
deviceLogService.addLog(deviceLogDto);
deviceLibraryService.update(deviceLibrary);
......@@ -974,8 +976,15 @@ public class DeviceLibraryController {
@ApiOperation("入库修改试用装备的序列号")
@PostMapping("updateSeq")
@CacheEvict(value = "devicesLibraryList",key = "'device'",allEntries = true)
public ResponseEntity updateSeq(@RequestBody List<DeviceForApplyVo> deviceForApplyVos){
deviceLibraryService.updateSeqNumber(deviceForApplyVos);
//异步去查询数据库
executor.execute(
()->{
cacheLibraryService.getAllDeviceLibraryList();
}
);
return ResponseEntity.ok("更新成功");
}
......
......@@ -225,8 +225,8 @@ public interface DeviceLibraryDao extends JpaRepository<DeviceLibrary, Integer>,
@Transactional
@Modifying
@Query("update DeviceLibrary o set o.storageLocation = :storageLocation where o.id in :deviceIds")
int updateStorageLocation( @Param("storageLocation") String storageLocation,
@Query("update DeviceLibrary o set o.storageLocation = :storageLocation,o.storageLocationId = :storageLocationId where o.id in :deviceIds")
int updateStorageLocation( @Param("storageLocation") String storageLocation,@Param("storageLocationId") Integer storageLocationId,
@Param("deviceIds") List<Integer> deviceIds);
......
......@@ -236,6 +236,7 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
d.setName(deviceLibrarySelectVo.getName());
d.setContent(deviceLibrarySelectVo.getContent());
d.setType(deviceLibrarySelectVo.getType());
d.setStorageLocationId(deviceLibrarySelectVo.getStorageLocationId());
//获取所有的核心装备
List<DeviceLibrary> libraryEntities = getCoreDevicePage(d);
if (libraryEntities.size() > 0) {
......@@ -1156,7 +1157,8 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
updateStorageLocationVo.getStorageLocation(),null,userId);
deviceLogDtos.add(deviceLogDto);
}});
deviceLibraryDao.updateStorageLocation(updateStorageLocationVo.getStorageLocation(),deviceIds);
deviceLibraryDao.updateStorageLocation(updateStorageLocationVo.getStorageLocation(),
updateStorageLocationVo.getStorageLocationId(),deviceIds);
}else {
throw new ApiException("请选择要修改的装备");
}
......@@ -1372,7 +1374,7 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
predicateBuilder.in("seqNumber", DeviceSeqUtil.selectDeviceSeqs(deviceLibrarySelectVo.getSeqInterval()));
}
//新增库房位置
predicateBuilder.eq(deviceLibrarySelectVo.getStorageLocation() != null,"storageLocation",deviceLibrarySelectVo.getStorageLocation());
predicateBuilder.eq(deviceLibrarySelectVo.getStorageLocationId() != null,"storageLocationId",deviceLibrarySelectVo.getStorageLocationId());
//新增装备的形态
predicateBuilder.eq(deviceLibrarySelectVo.getType() != null,"type",deviceLibrarySelectVo.getType());
}
......
......@@ -239,6 +239,9 @@ public class DeviceLibrary implements Serializable {
@ApiModelProperty(value = "装备存放位置",notes = "默认是库房")
private String storageLocation;
@ApiModelProperty(value = "装备存放位置Id",notes = "默认是库房")
private Integer storageLocationId;
@Transient
private List<DeviceLibrary> childs = new ArrayList<>();
......
......@@ -60,6 +60,9 @@ public class DeviceLibrarySaveVo {
@ApiModelProperty(value = "装备存放位置",notes = "默认是库房")
private String storageLocation;
@ApiModelProperty(value = "装备存放位置的id",notes = "默认是库房id")
private Integer storageLocationId;
@ApiModelProperty(value = "是否是试用装备",notes = "0 是正式 1 是测试")
private Integer tryOutDevice = 0;
......
......@@ -123,6 +123,9 @@ public class DeviceLibrarySelectVo extends CustomPage {
@ApiModelProperty(value = "存储位置")
private String storageLocation;
@ApiModelProperty(value = "存储位置")
private Integer storageLocationId;
@ApiModelProperty(value = "存储位置的模糊查询字段")
private String storageLocationDim;
......
......@@ -48,6 +48,9 @@ public class DeviceLibraryUpdateVo {
@ApiModelProperty("库存位置")
private String storageLocation;
@ApiModelProperty("库存位置id")
private Integer storageLocationId;
@ApiModelProperty("备注")
private String record;
......
......@@ -22,4 +22,7 @@ public class DeviceStorageLocation {
@ApiModelProperty(value = "库存位置")
private String storageLocation;
@ApiModelProperty(value = "库存位置id")
private Integer storageLocationId;
}
......@@ -21,4 +21,7 @@ public class UpdateStorageLocationVo {
@ApiModelProperty(value = "要修改的库房位置")
private String storageLocation;
@ApiModelProperty(value = "要修改的库房位置id")
private Integer storageLocationId;
}
......@@ -529,6 +529,16 @@ public class MatchingDeviceController {
m.setDeviceId(0);
}
if (matchingDeviceEditVo.getMatchingDeviceStorageLocation() != null &&
!m.getMatchingDeviceStorageLocation().equals(matchingDeviceEditVo.getMatchingDeviceStorageLocation())) {
//添加设备日志 存放位置
String remark = "将设备的存放位置改为" + matchingDeviceEditVo.getMatchingDeviceStorageLocation();
DeviceLogDto deviceLogDto = new DeviceLogDto(1, matchingDeviceEditVo.getMatchingDeviceId(), remark, null,null);
deviceLogService.addLog(deviceLogDto);
m.setMatchingDeviceStorageLocation(m.getMatchingDeviceStorageLocation());
m.setMatchingDeviceStorageLocationId(m.getMatchingDeviceStorageLocationId());
}
matchingDeviceLibraryService.update(m);
return ResponseEntity.ok("修改成功");
}
......
......@@ -377,6 +377,8 @@ public class MatchingDeviceLibraryServiceImpl implements MatchingDeviceLibrarySe
predicateBuilder.in("rfidCardId", "");
}
}
predicateBuilder.eq(matchingDeviceSelectVo.getMatchingDeviceStorageLocationId() != null,
"matchingDeviceStorageLocationId",matchingDeviceSelectVo.getMatchingDeviceStorageLocationId());
return predicateBuilder;
}
}
......@@ -136,6 +136,12 @@ public class MatchingDeviceLibrary {
@Transient
private String deviceSeqNumber;
@ApiModelProperty(value = "存放位置")
private String matchingDeviceStorageLocation;
@ApiModelProperty(value = "存放位置id")
private Integer matchingDeviceStorageLocationId;
public MatchingDeviceLibrary setConfigName(){
ConfigCache configCache = SpringUtils.getBean("initConfigCache");
......
......@@ -62,4 +62,10 @@ public class MatchingDeviceEditVo {
@ApiModelProperty(value = "删除相关装备id")
private Integer deleteDeviceId;
@ApiModelProperty(value = "存放位置")
private String matchingDeviceStorageLocation;
@ApiModelProperty(value = "存放位置id")
private Integer matchingDeviceStorageLocationId;
}
......@@ -58,6 +58,12 @@ public class MatchingDeviceSaveVo {
@ApiModelProperty(value = "序列号集合")
private List<String> seqList;
@ApiModelProperty(value = "存放位置")
private String matchingDeviceStorageLocation;
@ApiModelProperty(value = "存放位置id")
private Integer matchingDeviceStorageLocationId;
public MatchingDeviceLibrary toDo() {
MatchingDeviceLibrary matchingDeviceLibraryEntity = new MatchingDeviceLibrary();
BeanUtils.copyProperties(this, matchingDeviceLibraryEntity);
......
......@@ -33,6 +33,9 @@ public class MatchingDeviceSelectVo extends CustomPage {
@ApiModelProperty(value = "查询是否打印标签(有没有表面号)装备")
private Integer isPrint;
@ApiModelProperty(value = "存放位置id")
private Integer matchingDeviceStorageLocationId;
private String typeDim;
private String modelDim;
......
......@@ -31,4 +31,6 @@ public class StorageBillDetail {
private String typeName;
@ApiModelProperty(value = "装备存放位置",notes = "默认是库房")
private String storageLocation;
@ApiModelProperty(value = "装备存放位置的id",notes = "默认是库房id")
private Integer storageLocationId;
}
......@@ -16,17 +16,25 @@ public class StorageBillDetailVo {
@ApiModelProperty(value = "配件列表")
List<StorageBillDetailVo> list;
@ApiModelProperty(value = "列装id")
private Integer packingId;
@ApiModelProperty(value = "入库数量")
private Integer storageCount;
@ApiModelProperty(value = "序列号区间")
private String seqInterval;
@ApiModelProperty(value = "生产号区间")
private String prodInterval;
@ApiModelProperty(value = "列装装备")
private PackingLibrary packingLibrary;
@ApiModelProperty(value = "装备存放位置",notes = "默认是库房")
private String storageLocation;
@ApiModelProperty(value = "装备存放位置的id",notes = "默认是库房id")
private Integer storageLocationId;
}
......@@ -118,6 +118,9 @@ public class StorageBillSaveVo {
@ApiModelProperty(value = "装备存放位置",notes = "默认是库房")
private String storageLocation ;
@ApiModelProperty(value = "装备存放位置的id",notes = "默认是库房id")
private Integer storageLocationId;
@ApiModelProperty(value = "是否是试用装备",notes = "0 是正式 1 是测试")
private Integer tryOutDevice = 0;
......
package com.tykj.dev.union;
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.matching.repository.MatchingDeviceLibraryDao;
import com.tykj.dev.device.matching.subject.domin.MatchingDeviceLibrary;
import com.tykj.dev.device.repair.repository.RepairBackBillDao;
import com.tykj.dev.device.repair.repository.RepairBillDao;
import com.tykj.dev.device.repair.repository.RepairDetailDao;
import com.tykj.dev.device.repair.repository.RepairSendBillDao;
import com.tykj.dev.device.repair.subject.domin.RepairBackBill;
import com.tykj.dev.device.repair.subject.domin.RepairBill;
import com.tykj.dev.device.repair.subject.domin.RepairDetail;
import com.tykj.dev.device.repair.subject.domin.RepairSendBill;
import com.tykj.dev.device.selfcheck.repository.SelfCheckBillDao;
import com.tykj.dev.device.selfcheck.subject.domin.SelfCheckBill;
import com.tykj.dev.device.user.subject.dao.UnitsDao;
import com.tykj.dev.device.user.subject.entity.Units;
import com.tykj.dev.device.user.util.AuthenticationUtils;
import com.tykj.dev.device.user.util.UserUtils;
import com.tykj.dev.device.usereport.repository.DeviceUseReportDao;
import com.tykj.dev.device.usereport.subject.domin.DeviceUseReport;
import com.tykj.dev.misc.utils.SpringUtils;
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
public class DataInit {
@Resource
private UnitsDao unitsDao;
@Autowired
private AllotBillDao allotBillDao;
@Autowired
private AllotBackBillDao allotBackBillDao;
@Autowired
private RepairBackBillDao repairBackBillDao;
@Autowired
private RepairDetailDao repairDetailDao;
@Autowired
private RepairSendBillDao repairSendBillDao;
@Autowired
private RepairBillDao repairBillDao;
@Autowired
private SelfCheckBillDao selfCheckBillDao;
@Autowired
private DeviceUseReportDao deviceUseReportDao;
@Autowired
private MatchingDeviceLibraryDao matchingDeviceLibraryDao;
@Autowired
private UserUtils userUtils;
@Autowired
private SpringUtils springUtils;
@Autowired
private com.tykj.dev.device.user.util.AuthenticationUtils AuthenticationUtils;
private void initCheckDetailUnitName() {
// 对现有的数据补充unitId信息
allotBillDao.findAll().forEach(this::saveModifyDetail1);
allotBackBillDao.findAll().forEach(this::saveModifyDetail2);
selfCheckBillDao.findAll().forEach(this::saveModifyDetail3);
repairBillDao.findAll().forEach(this::saveModifyDetail4);
repairSendBillDao.findAll().forEach(this::saveModifyDetail5);
repairDetailDao.findAll().forEach(this::saveModifyDetail6);
repairBackBillDao.findAll().forEach(this::saveModifyDetail7);
deviceUseReportDao.findAll().forEach(this::saveModifyDetail8);
matchingDeviceLibraryDao.findAll().forEach(this::saveModifyDetail9);
}
private void saveModifyDetail1(AllotBill allotBill) {
String receiveUnit = allotBill.getReceiveUnit();
String sendUnit = allotBill.getSendUnit();
Integer receiveUnitId = getUnitId(receiveUnit);
Integer sendUnitId = getUnitId(sendUnit);
if (receiveUnitId != -1 && sendUnitId != -1) {
allotBill.setReceiveUnitId(receiveUnitId);
allotBill.setSendUnitId(sendUnitId);
log.info("[配发] 修正allotBill历史数据,修正的发件单位:{},修正的接收单位:{},发送单位id:{},接收单位id:{}",
sendUnit, receiveUnit,sendUnitId,receiveUnitId);
allotBillDao.save(allotBill);
}
}
private void saveModifyDetail2(AllotBackBill allotBackBill) {
String receiveUnit = allotBackBill.getReceiveUnit();
String sendUnit = allotBackBill.getSendUnit();
Integer receiveUnitId = getUnitId(receiveUnit);
Integer sendUnitId = getUnitId(sendUnit);
if (receiveUnitId != -1 && sendUnitId != -1) {
allotBackBill.setReceiveUnitId(receiveUnitId);
allotBackBill.setSendUnitId(sendUnitId);
log.info("[退回] 修正allotBill历史数据,修正的发件单位:{},修正的接收单位:{},发送单位id:{},接收单位id:{}",
sendUnit, receiveUnit,sendUnitId,receiveUnitId);
allotBackBillDao.save(allotBackBill);
}
}
private void saveModifyDetail3(SelfCheckBill selfCheckBill) {
String receiveUnit = selfCheckBill.getCheckUnit();
Integer receiveUnitId = getUnitId(receiveUnit);
if (receiveUnitId != -1) {
selfCheckBill.setCheckUnitId(receiveUnitId);
log.info("[自查] 修正selfCheckBill历史数据,修正的单位:{},接收单位id:{}",
receiveUnit,receiveUnitId);
selfCheckBillDao.save(selfCheckBill);
}
}
private void saveModifyDetail4(RepairBill allotBill) {
String receiveUnit = allotBill.getReceiveUnit();
String sendUnit = allotBill.getSendUnit();
Integer receiveUnitId = getUnitId(receiveUnit);
Integer sendUnitId = getUnitId(sendUnit);
if (receiveUnitId != -1 && sendUnitId != -1) {
allotBill.setReceiveUnitId(receiveUnitId);
allotBill.setSendUnitId(sendUnitId);
log.info("[维修] 修正RepairBill历史数据,修正的发件单位:{},修正的接收单位:{},发送单位id:{},接收单位id:{}",
sendUnit, receiveUnit,sendUnitId,receiveUnitId);
repairBillDao.save(allotBill);
}
}
private void saveModifyDetail5(RepairSendBill allotBill) {
String receiveUnit = allotBill.getReceiveUnit();
String sendUnit = allotBill.getSendUnit();
Integer receiveUnitId = getUnitId(receiveUnit);
Integer sendUnitId = getUnitId(sendUnit);
if (receiveUnitId != -1 && sendUnitId != -1) {
allotBill.setReceiveUnitId(receiveUnitId);
allotBill.setSendUnitId(sendUnitId);
log.info("[送修] 修正RepairSendBill历史数据,修正的发件单位:{},修正的接收单位:{},发送单位id:{},接收单位id:{}",
sendUnit, receiveUnit,sendUnitId,receiveUnitId);
repairSendBillDao.save(allotBill);
}
}
private void saveModifyDetail6(RepairDetail allotBill) {
String receiveUnit = allotBill.getLocationUnit();
String sendUnit = allotBill.getOwnUnit();
Integer receiveUnitId = getUnitId(receiveUnit);
Integer sendUnitId = getUnitId(sendUnit);
if (receiveUnitId != -1 && sendUnitId != -1) {
allotBill.setLocationUnitId(receiveUnitId);
allotBill.setOwnUnitId(sendUnitId);
log.info("[维修详情] 修正RepairDetail历史数据,修正的发件单位:{},修正的接收单位:{},发送单位id:{},接收单位id:{}",
sendUnit, receiveUnit,sendUnitId,receiveUnitId);
repairDetailDao.save(allotBill);
}
}
private void saveModifyDetail7(RepairBackBill allotBill) {
String receiveUnit = allotBill.getReceiveUnit();
String sendUnit = allotBill.getSendUnit();
Integer receiveUnitId = getUnitId(receiveUnit);
Integer sendUnitId = getUnitId(sendUnit);
if (receiveUnitId != -1 && sendUnitId != -1) {
allotBill.setReceiveUnitId(receiveUnitId);
allotBill.setSendUnitId(sendUnitId);
log.info("[维修退回] 修正RepairBackBill历史数据,修正的发件单位:{},修正的接收单位:{},发送单位id:{},接收单位id:{}",
sendUnit, receiveUnit,sendUnitId,receiveUnitId);
repairBackBillDao.save(allotBill);
}
}
private void saveModifyDetail8(DeviceUseReport allotBill) {
String receiveUnit = allotBill.getUnit();
Integer receiveUnitId = getUnitId(receiveUnit);
if (receiveUnitId != -1 ) {
allotBill.setUnitId(receiveUnitId);
log.info("[用户使用报告] 修正DeviceUseReport历史数据,修正的单位:{},接收单位id:{}",
receiveUnit,receiveUnitId);
deviceUseReportDao.save(allotBill);
}
}
private void saveModifyDetail9(MatchingDeviceLibrary matchingDeviceLibrary) {
String createUnit = matchingDeviceLibrary.getCreateUnit();
Integer createUnitId = getUnitId(createUnit);
if (createUnitId != -1 ) {
matchingDeviceLibrary.setCreateUnitId(createUnitId);
log.info("[配套设备库] 修正MatchingDeviceLibrary历史数据,修正的单位:{},接收单位id:{}",
createUnit,createUnitId);
matchingDeviceLibraryDao.save(matchingDeviceLibrary);
}
}
private Integer getUnitId(String unitName) {
List<Units> units = unitsDao.findAllByName(unitName).orElse(Collections.emptyList());
return units.size() == 1 ? units.get(0).getUnitId() : -1;
}
// @Bean
// @DependsOn("userUtils")
@PostConstruct
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 {
//package com.tykj.dev.union;
//
//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.apply.repository.DeviceApplyBillDao;
//import com.tykj.dev.device.apply.subject.domin.DeviceApplyBill;
//import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckDetail;
//import com.tykj.dev.device.confirmcheck.repository.DeviceCheckDetailDao;
//import com.tykj.dev.device.matching.repository.MatchingDeviceLibraryDao;
//import com.tykj.dev.device.matching.subject.domin.MatchingDeviceLibrary;
//import com.tykj.dev.device.repair.repository.RepairBackBillDao;
//import com.tykj.dev.device.repair.repository.RepairBillDao;
//import com.tykj.dev.device.repair.repository.RepairDetailDao;
//import com.tykj.dev.device.repair.repository.RepairSendBillDao;
//import com.tykj.dev.device.repair.subject.domin.RepairBackBill;
//import com.tykj.dev.device.repair.subject.domin.RepairBill;
//import com.tykj.dev.device.repair.subject.domin.RepairDetail;
//import com.tykj.dev.device.repair.subject.domin.RepairSendBill;
//import com.tykj.dev.device.selfcheck.repository.SelfCheckBillDao;
//import com.tykj.dev.device.selfcheck.subject.domin.SelfCheckBill;
//import com.tykj.dev.device.user.subject.dao.UnitsDao;
//import com.tykj.dev.device.user.subject.entity.Units;
//import com.tykj.dev.device.user.util.AuthenticationUtils;
//import com.tykj.dev.device.user.util.UserUtils;
//import com.tykj.dev.device.usereport.repository.DeviceUseReportDao;
//import com.tykj.dev.device.usereport.subject.domin.DeviceUseReport;
//import com.tykj.dev.misc.utils.SpringUtils;
//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
//public class DataInit {
//
// @Resource
// private UnitsDao unitsDao;
//
// @Autowired
// private AllotBillDao allotBillDao;
// @Autowired
// private AllotBackBillDao allotBackBillDao;
// @Autowired
// private RepairBackBillDao repairBackBillDao;
// @Autowired
// private RepairDetailDao repairDetailDao;
// @Autowired
// private RepairSendBillDao repairSendBillDao;
// @Autowired
// private RepairBillDao repairBillDao;
// @Autowired
// private SelfCheckBillDao selfCheckBillDao;
// @Autowired
// private DeviceUseReportDao deviceUseReportDao;
//
// @Autowired
// private DeviceApplyBillDao deviceApplyBillDao;
//
// @Autowired
// private MatchingDeviceLibraryDao matchingDeviceLibraryDao;
//
// @Autowired
// private UserUtils userUtils;
//
// @Autowired
// private SpringUtils springUtils;
//
// @Autowired
// private com.tykj.dev.device.user.util.AuthenticationUtils AuthenticationUtils;
//
// private void initCheckDetailUnitName() {
// // 对现有的数据补充unitId信息
// allotBillDao.findAll().forEach(this::saveModifyDetail1);
// allotBackBillDao.findAll().forEach(this::saveModifyDetail2);
// selfCheckBillDao.findAll().forEach(this::saveModifyDetail3);
// repairBillDao.findAll().forEach(this::saveModifyDetail4);
// repairSendBillDao.findAll().forEach(this::saveModifyDetail5);
// repairDetailDao.findAll().forEach(this::saveModifyDetail6);
// repairBackBillDao.findAll().forEach(this::saveModifyDetail7);
// deviceUseReportDao.findAll().forEach(this::saveModifyDetail8);
// matchingDeviceLibraryDao.findAll().forEach(this::saveModifyDetail9);
// }
//
//
// private void saveModifyDetail1(AllotBill allotBill) {
// String receiveUnit = allotBill.getReceiveUnit();
// String sendUnit = allotBill.getSendUnit();
//
// Integer receiveUnitId = getUnitId(receiveUnit);
// Integer sendUnitId = getUnitId(sendUnit);
//
// if (receiveUnitId != -1 && sendUnitId != -1) {
// allotBill.setReceiveUnitId(receiveUnitId);
// allotBill.setSendUnitId(sendUnitId);
// log.info("[配发] 修正allotBill历史数据,修正的发件单位:{},修正的接收单位:{},发送单位id:{},接收单位id:{}",
// sendUnit, receiveUnit,sendUnitId,receiveUnitId);
// allotBillDao.save(allotBill);
// }
//
// }
//
// private void saveModifyDetail2(AllotBackBill allotBackBill) {
// String receiveUnit = allotBackBill.getReceiveUnit();
// String sendUnit = allotBackBill.getSendUnit();
//
// Integer receiveUnitId = getUnitId(receiveUnit);
// Integer sendUnitId = getUnitId(sendUnit);
//
// if (receiveUnitId != -1 && sendUnitId != -1) {
// allotBackBill.setReceiveUnitId(receiveUnitId);
// allotBackBill.setSendUnitId(sendUnitId);
// log.info("[退回] 修正allotBill历史数据,修正的发件单位:{},修正的接收单位:{},发送单位id:{},接收单位id:{}",
// sendUnit, receiveUnit,sendUnitId,receiveUnitId);
// allotBackBillDao.save(allotBackBill);
// }
//
// }
//
// private void saveModifyDetail3(SelfCheckBill selfCheckBill) {
// String receiveUnit = selfCheckBill.getCheckUnit();
// Integer receiveUnitId = getUnitId(receiveUnit);
// if (receiveUnitId != -1) {
// selfCheckBill.setCheckUnitId(receiveUnitId);
// log.info("[自查] 修正selfCheckBill历史数据,修正的单位:{},接收单位id:{}",
// receiveUnit,receiveUnitId);
// selfCheckBillDao.save(selfCheckBill);
// }
//
// }
//
// private void saveModifyDetail4(RepairBill allotBill) {
// String receiveUnit = allotBill.getReceiveUnit();
// String sendUnit = allotBill.getSendUnit();
//
// Integer receiveUnitId = getUnitId(receiveUnit);
// Integer sendUnitId = getUnitId(sendUnit);
//
// if (receiveUnitId != -1 && sendUnitId != -1) {
// allotBill.setReceiveUnitId(receiveUnitId);
// allotBill.setSendUnitId(sendUnitId);
// log.info("[维修] 修正RepairBill历史数据,修正的发件单位:{},修正的接收单位:{},发送单位id:{},接收单位id:{}",
// sendUnit, receiveUnit,sendUnitId,receiveUnitId);
// repairBillDao.save(allotBill);
// }
//
// }
//
// private void saveModifyDetail5(RepairSendBill allotBill) {
// String receiveUnit = allotBill.getReceiveUnit();
// String sendUnit = allotBill.getSendUnit();
//
// Integer receiveUnitId = getUnitId(receiveUnit);
// Integer sendUnitId = getUnitId(sendUnit);
//
// if (receiveUnitId != -1 && sendUnitId != -1) {
// allotBill.setReceiveUnitId(receiveUnitId);
// allotBill.setSendUnitId(sendUnitId);
// log.info("[送修] 修正RepairSendBill历史数据,修正的发件单位:{},修正的接收单位:{},发送单位id:{},接收单位id:{}",
// sendUnit, receiveUnit,sendUnitId,receiveUnitId);
// repairSendBillDao.save(allotBill);
// }
//
// }
//
// private void saveModifyDetail6(RepairDetail allotBill) {
// String receiveUnit = allotBill.getLocationUnit();
// String sendUnit = allotBill.getOwnUnit();
//
// Integer receiveUnitId = getUnitId(receiveUnit);
// Integer sendUnitId = getUnitId(sendUnit);
//
// if (receiveUnitId != -1 && sendUnitId != -1) {
// allotBill.setLocationUnitId(receiveUnitId);
// allotBill.setOwnUnitId(sendUnitId);
// log.info("[维修详情] 修正RepairDetail历史数据,修正的发件单位:{},修正的接收单位:{},发送单位id:{},接收单位id:{}",
// sendUnit, receiveUnit,sendUnitId,receiveUnitId);
// repairDetailDao.save(allotBill);
// }
//
// }
// private void saveModifyDetail7(RepairBackBill allotBill) {
// String receiveUnit = allotBill.getReceiveUnit();
// String sendUnit = allotBill.getSendUnit();
//
// Integer receiveUnitId = getUnitId(receiveUnit);
// Integer sendUnitId = getUnitId(sendUnit);
//
// if (receiveUnitId != -1 && sendUnitId != -1) {
// allotBill.setReceiveUnitId(receiveUnitId);
// allotBill.setSendUnitId(sendUnitId);
// log.info("[维修退回] 修正RepairBackBill历史数据,修正的发件单位:{},修正的接收单位:{},发送单位id:{},接收单位id:{}",
// sendUnit, receiveUnit,sendUnitId,receiveUnitId);
// repairBackBillDao.save(allotBill);
// }
//
// }
//
// private void saveModifyDetail8(DeviceUseReport allotBill) {
// String receiveUnit = allotBill.getUnit();
// Integer receiveUnitId = getUnitId(receiveUnit);
// if (receiveUnitId != -1 ) {
// allotBill.setUnitId(receiveUnitId);
// log.info("[用户使用报告] 修正DeviceUseReport历史数据,修正的单位:{},接收单位id:{}",
// receiveUnit,receiveUnitId);
// deviceUseReportDao.save(allotBill);
// }
//
// }
//
// private void saveModifyDetail9(MatchingDeviceLibrary matchingDeviceLibrary) {
// String createUnit = matchingDeviceLibrary.getCreateUnit();
// Integer createUnitId = getUnitId(createUnit);
// if (createUnitId != -1 ) {
// matchingDeviceLibrary.setCreateUnitId(createUnitId);
// log.info("[配套设备库] 修正MatchingDeviceLibrary历史数据,修正的单位:{},接收单位id:{}",
// createUnit,createUnitId);
// matchingDeviceLibraryDao.save(matchingDeviceLibrary);
// }
//
// }
//
// private void saveModifyDetail10(DeviceApplyBill deviceApplyBill) {
// String replyUnit = deviceApplyBill.getReplyUnit();
// String applyUnit = deviceApplyBill.getApplyUnit();
// Integer replyUnitId = getUnitId(replyUnit);
// Integer applyUnitId = getUnitId(applyUnit);
// if (replyUnitId != -1 && applyUnitId != -1) {
// deviceApplyBill.setReplyUnitId(replyUnitId);
// deviceApplyBill.setApplyUnitId(applyUnitId);
// log.info("[装备申请] 修正DeviceApplyBill历史数据,修正的申请单位:{},申请单位id:{},修正的批复单位:{},批复单位id:{}",
// replyUnit,replyUnitId,applyUnit,applyUnitId);
// deviceApplyBillDao.save(deviceApplyBill);
// }
//
// }
//
// private Integer getUnitId(String unitName) {
// List<Units> units = unitsDao.findAllByName(unitName).orElse(Collections.emptyList());
// return units.size() == 1 ? units.get(0).getUnitId() : -1;
// }
//
//// @Bean
//// @DependsOn("userUtils")
// @PostConstruct
// 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();
//// }
//}
package com.tykj.dev.union;
/**
* @author zjm
* @version 1.0.0
* @ClassName AreaController.java
* @Description TODO
* @createTime 2020年09月04日 13:34:00
*/
import com.tykj.dev.config.swagger.AutoDocument;
import com.tykj.dev.device.user.subject.dao.AreaDao;
import com.tykj.dev.device.user.subject.entity.Area;
import com.tykj.dev.device.user.subject.entity.SecurityUser;
import com.tykj.dev.device.user.subject.service.AreaService;
import com.tykj.dev.misc.exception.ApiException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.Optional;
/**
* 区域视图层
*/
@RestController
@RequestMapping("/run")
public class RunController {
@Autowired
DataInit dataInit;
@GetMapping(value = "/init2")
public ResponseEntity addPermissions(@ApiIgnore @AuthenticationPrincipal SecurityUser securityUser) {
dataInit.init2();
return ResponseEntity.ok("ok");
}
}
//package com.tykj.dev.union;
//
///**
// * @author zjm
// * @version 1.0.0
// * @ClassName AreaController.java
// * @Description TODO
// * @createTime 2020年09月04日 13:34:00
// */
//
//import com.tykj.dev.config.swagger.AutoDocument;
//import com.tykj.dev.device.user.subject.dao.AreaDao;
//import com.tykj.dev.device.user.subject.entity.Area;
//import com.tykj.dev.device.user.subject.entity.SecurityUser;
//import com.tykj.dev.device.user.subject.service.AreaService;
//import com.tykj.dev.misc.exception.ApiException;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.ResponseEntity;
//import org.springframework.security.core.annotation.AuthenticationPrincipal;
//import org.springframework.web.bind.annotation.*;
//import springfox.documentation.annotations.ApiIgnore;
//
//import java.util.Optional;
//
///**
// * 区域视图层
// */
//@RestController
//@RequestMapping("/run")
//public class RunController {
// @Autowired
// DataInit dataInit;
// @GetMapping(value = "/init2")
// public ResponseEntity addPermissions(@ApiIgnore @AuthenticationPrincipal SecurityUser securityUser) {
// dataInit.init2();
// return ResponseEntity.ok("ok");
// }
//
//
//}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论