Commit c0dc922e authored by chenzhao's avatar chenzhao

优化消防装备导入过慢

parent a24ce4a3
package com.yeejoin.equipmanage.service.impl;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
......@@ -8,6 +9,7 @@ import java.util.stream.Collectors;
import javax.annotation.Resource;
import com.yeejoin.equipmanage.common.utils.*;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
......@@ -305,9 +307,8 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
@Override
// @Transactional(rollbackFor = Exception.class)
public Object uploadListByTemplate(List<EquipmentDetailDownloadTemplateDto> equipmentDetailDownloadVOS, ReginParams reginParams, AgencyUserModel agencyUserModel) {
StringBuffer fireFightSysIdsBuffer = new StringBuffer();
Set<String> bizOrgCodes = new HashSet<>();
StringBuffer errBufferName= new StringBuffer();
StringBuffer erryy= new StringBuffer();
// StringBuffer errNum="0"; //失败条数
......@@ -491,11 +492,28 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
// list.add(equipmentSpecific);
// this.equipmentSpecificIndexSave(equipmentDetail, equipmentSpecific);
// }
List<Equipment> equipmentList;
if (redisUtils.hasKey("equip_equipDefinitions")) {
equipmentList = JSONObject.parseArray(redisUtils.get("equip_equipDefinitions").toString(), Equipment.class);;
} else {
QueryWrapper<Equipment> equipmentQueryWrapper = new QueryWrapper<>();
equipmentQueryWrapper.isNotNull("id");
equipmentList = equipmentMapper.selectList(equipmentQueryWrapper);
redisUtils.set("equip_equipDefinitions", JSONObject.toJSONString(equipmentList));
}
List<WarehouseStructure> warehouseStructures ;
if (redisUtils.hasKey("equip_warehouseStructures")) {
warehouseStructures = JSONObject.parseArray(redisUtils.get("equip_warehouseStructures").toString(), WarehouseStructure.class);
} else {
warehouseStructures = warehouseStructureService.list();
redisUtils.set("equip_warehouseStructures", JSONObject.toJSONString(warehouseStructures));
}
for (int i = 0; i < equipmentDetailDownloadVOS.size(); i++) {
try {
seveRK( equipmentDetailDownloadVOS.get(i), reginParams, agencyUserModel,
fireFightSysIdsBuffer,list, errBufferName ,erryy, i+1 );
fireFightSysIdsBuffer,list, errBufferName ,erryy, i+1,equipmentList ,warehouseStructures,bizOrgCodes);
} catch (Exception e) {
e.printStackTrace();
}
......@@ -526,8 +544,18 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
String[] split = errBufferName.toString().split(",");
String date="上传成功:"+(equipmentDetailDownloadVOS.size()-(split!=null?split.length:0))+"条---上传失败:"+(split!=null?split.length:0)+"条(失败编号:"+errBufferName+"详情:"+erryy+")";
log.error(date);
//添加对于成功数据装备类型统计数据的刷新
StockServiceImpl controllerProxy = SpringUtils.getBean(StockServiceImpl.class);
for (String bizOrgCode : bizOrgCodes) {
controllerProxy.refreshCount(bizOrgCode);
}
return date;
}
//添加对于成功数据装备类型统计数据的刷新 当所有数据完成时对已成功数据的单位进行最终统计 避免每一次循环带来的线程压力
StockServiceImpl controllerProxy = SpringUtils.getBean(StockServiceImpl.class);
for (String bizOrgCode : bizOrgCodes) {
controllerProxy.refreshCount(bizOrgCode);
}
String[] split = errBufferName.toString().split(",");
String date="";
if(split!=null&&split.length>0&&!"".equals(split[0])){
......@@ -555,8 +583,9 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
List<EquipmentSpecific> list,
StringBuffer errBufferName,
StringBuffer erryy,
int rowNum
int rowNum,
List<Equipment> equipmentList,
List<WarehouseStructure> warehouseStructures, Set<String> bizOrgCodes
){
if (StringUtils.isEmpty(equipmentDetailDownloadVOS.getCode())) {
erryy.append("第" + rowNum + "器材编码为空,");
......@@ -576,203 +605,207 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
SimpleDateFormat stf = new SimpleDateFormat("yyyy-MM-dd");
TransactionStatus transactionStatus = platformTransactionManager.getTransaction(transactionDefinition);
try {
//查询装备定义信息
QueryWrapper<Equipment> equipmentQueryWrapper = new QueryWrapper<>();
equipmentQueryWrapper.lambda().eq(Equipment::getCode, equipmentDetailDownloadVOS.getCode());
Equipment equipment = equipmentMapper.selectOne(equipmentQueryWrapper);
if (equipment == null) {
erryy.append(String.format("装备(器材)编码[%S]填写错误,请输入正确的装备(器材)编码!",equipmentDetailDownloadVOS.getCode()) + ",");
throw new RuntimeException(String.format("装备(器材)编码[%S]填写错误,请输入正确的装备(器材)编码!",equipmentDetailDownloadVOS.getCode()));
}
String sysCode = equipmentDetailDownloadVOS.getSystemCode();
if (StringUtils.isNotEmpty(sysCode) && StringUtils.isNotEmpty(sysCode.trim())) {
Integer code = equipmentSpecificMapper.selectCount(new QueryWrapper<EquipmentSpecific>().eq("code", sysCode.trim()));
if (code != 0) {
erryy.append(String.format("设备编码[%S]填写重复,请重新输入!",sysCode)+ ",");
throw new RuntimeException(String.format("设备编码[%S]填写重复,请重新输入!",sysCode));
}
try {
//查询装备定义信息
// equipmentQueryWrapper.lambda().eq(Equipment::getCode, equipmentDetailDownloadVOS.getCode());
// Equipment equipment = equipmentMapper.selectOne(equipmentQueryWrapper);
// 此处由于每次导入都需查装备定义导致导入缓慢,所以优化为加入缓存
Equipment equipment = equipmentList.stream().filter(x -> x.getCode().equals(equipmentDetailDownloadVOS.getCode())).collect(Collectors.toList()).get(0);
if (equipment == null) {
erryy.append(String.format("装备(器材)编码[%S]填写错误,请输入正确的装备(器材)编码!",equipmentDetailDownloadVOS.getCode()) + ",");
throw new RuntimeException(String.format("装备(器材)编码[%S]填写错误,请输入正确的装备(器材)编码!",equipmentDetailDownloadVOS.getCode()));
}
String sysCode = equipmentDetailDownloadVOS.getSystemCode();
if (StringUtils.isNotEmpty(sysCode) && StringUtils.isNotEmpty(sysCode.trim())) {
Integer code = equipmentSpecificMapper.selectCount(new QueryWrapper<EquipmentSpecific>().eq("code", sysCode.trim()));
if (code != 0) {
erryy.append(String.format("设备编码[%S]填写重复,请重新输入!",sysCode)+ ",");
throw new RuntimeException(String.format("设备编码[%S]填写重复,请重新输入!",sysCode));
}
String iotCode = equipmentDetailDownloadVOS.getIotCode();
if (StringUtils.isNotEmpty(iotCode) && StringUtils.isNotEmpty(iotCode.trim())) {
Integer exists = equipmentSpecificMapper.selectCount(new QueryWrapper<EquipmentSpecific>().eq("iot_code", iotCode.trim()));
if (exists != 0) {
erryy.append(String.format("物联编码[%S]填写重复,请重新输入!",iotCode)+ ",");
throw new RuntimeException(String.format("物联编码[%S]填写重复,请重新输入!",iotCode));
}
if(StringUtils.isNotEmpty(haveUsedIotPrefix) && Arrays.stream(haveUsedIotPrefix.split(",")).anyMatch(iotCode::startsWith)){
erryy.append(String.format("物联编码[%S]航班已占用,请重新输入!",iotCode)+ ",");
throw new BadRequest("物联编码航班已占用");
}
}
String iotCode = equipmentDetailDownloadVOS.getIotCode();
if (StringUtils.isNotEmpty(iotCode) && StringUtils.isNotEmpty(iotCode.trim())) {
Integer exists = equipmentSpecificMapper.selectCount(new QueryWrapper<EquipmentSpecific>().eq("iot_code", iotCode.trim()));
if (exists != 0) {
erryy.append(String.format("物联编码[%S]填写重复,请重新输入!",iotCode)+ ",");
throw new RuntimeException(String.format("物联编码[%S]填写重复,请重新输入!",iotCode));
}
AtomicReference<String> fightSysIds = new AtomicReference<>("");
String fightingSysCodes = equipmentDetailDownloadVOS.getFightingSysCodes();
if (StringUtils.isNotBlank(fightingSysCodes)) {
String[] idsArr = fightingSysCodes.split("-");
List<FireFightingSystemEntity> fightingSystemList = fireFightingSystemService.getFightingSysByCodes(idsArr);
if (!fightingSystemList.isEmpty()) {
fightingSystemList.stream().forEach(x -> {
String sysCodes = fightSysIds.get();
if (StringUtils.isNotBlank(sysCodes)) {
fightSysIds.set(String.join(",", sysCodes, String.valueOf(x.getId())));
} else {
fightSysIds.set(String.join(",", String.valueOf(x.getId())));
}
});
}
if(StringUtils.isNotEmpty(haveUsedIotPrefix) && Arrays.stream(haveUsedIotPrefix.split(",")).anyMatch(iotCode::startsWith)){
erryy.append(String.format("物联编码[%S]已占用,请重新输入!",iotCode)+ ",");
throw new BadRequest("物联编码已占用");
}
//插入模板信息
EquipmentDetail equipmentDetail = new EquipmentDetail();
equipmentDetail.setCode(equipmentDetailDownloadVOS.getCode());
equipmentDetail.setBrand(equipmentDetailDownloadVOS.getBrand());
equipmentDetail.setStandard(equipmentDetailDownloadVOS.getStandard());
LambdaQueryWrapper<ManufacturerInfo> queryWrapper = new LambdaQueryWrapper<>();
ManufacturerInfo info = manufacturerInfoService.getOne(queryWrapper.eq(ManufacturerInfo::getName, equipmentDetailDownloadVOS.getManufacturerName()));
if (StringUtil.isNotEmpty(info)) {
// throw new BadRequest("名称为" + equipmentDetailDownloadVOS.get(i).getManufacturerName() + "的生产厂商不存在!");
equipmentDetail.setManufacturerId(info.getId());
equipmentDetail.setManufacturerName(equipmentDetailDownloadVOS.getManufacturerName());
}
AtomicReference<String> fightSysIds = new AtomicReference<>("");
String fightingSysCodes = equipmentDetailDownloadVOS.getFightingSysCodes();
if (StringUtils.isNotBlank(fightingSysCodes)) {
String[] codes = new String[]{};
String[] idsArr1 = fightingSysCodes.split("-");
String[] idsArr2 = fightingSysCodes.split(",");
codes = idsArr1.length >= idsArr2.length ? idsArr1 : idsArr2;
List<FireFightingSystemEntity> fightingSystemList = fireFightingSystemService.getFightingSysByCodes(codes);
if (!fightingSystemList.isEmpty()) {
fightingSystemList.stream().forEach(x -> {
String sysCodes = fightSysIds.get();
if (StringUtils.isNotBlank(sysCodes)) {
fightSysIds.set(String.join(",", sysCodes, String.valueOf(x.getId())));
} else {
fightSysIds.set(String.join(",", String.valueOf(x.getId())));
}
});
}
equipmentDetail.setEquipmentId(equipment.getId());
equipmentDetail.setEquipmentName(equipment.getName());
equipmentDetail.setName(equipmentDetailDownloadVOS.getName());
equipmentDetail.setArea(equipmentDetailDownloadVOS.getDescription());
equipmentDetail.setProductionDate(equipmentDetailDownloadVOS.getProductionDate());
equipmentDetail.setExpiryDate(equipmentDetailDownloadVOS.getExpiryDate());
equipmentDetail.setDeliveryDate(equipmentDetailDownloadVOS.getDeliveryDate());
equipmentDetail.setMaintenanceCycle(equipmentDetailDownloadVOS.getMaintenanceCycle());
// 导入新增所属单位
if (StringUtils.isNotBlank(equipmentDetailDownloadVOS.getCompanyName())) {
String[] company = equipmentDetailDownloadVOS.getCompanyName().split("@");
equipmentDetail.setCompanyName(company[0]);
}
//插入模板信息
EquipmentDetail equipmentDetail = new EquipmentDetail();
equipmentDetail.setCode(equipmentDetailDownloadVOS.getCode());
equipmentDetail.setBrand(equipmentDetailDownloadVOS.getBrand());
equipmentDetail.setStandard(equipmentDetailDownloadVOS.getStandard());
LambdaQueryWrapper<ManufacturerInfo> queryWrapper = new LambdaQueryWrapper<>();
ManufacturerInfo info = manufacturerInfoService.getOne(queryWrapper.eq(ManufacturerInfo::getName, equipmentDetailDownloadVOS.getManufacturerName()));
if (StringUtil.isNotEmpty(info)) {
// throw new BadRequest("名称为" + equipmentDetailDownloadVOS.get(i).getManufacturerName() + "的生产厂商不存在!");
equipmentDetail.setManufacturerId(info.getId());
equipmentDetail.setManufacturerName(equipmentDetailDownloadVOS.getManufacturerName());
}
equipmentDetail.setEquipmentId(equipment.getId());
equipmentDetail.setEquipmentName(equipment.getName());
equipmentDetail.setName(equipmentDetailDownloadVOS.getName());
equipmentDetail.setArea(equipmentDetailDownloadVOS.getDescription());
equipmentDetail.setProductionDate(equipmentDetailDownloadVOS.getProductionDate());
equipmentDetail.setDeliveryDate(equipmentDetailDownloadVOS.getDeliveryDate());
equipmentDetail.setMaintenanceCycle(ObjectUtils.isEmpty(equipment.getMaintenanceCycle()) ? null : BigDecimal.valueOf(equipment.getMaintenanceCycle()));
// 导入新增所属单位
if (StringUtils.isNotBlank(equipmentDetailDownloadVOS.getCompanyName())) {
String[] company = equipmentDetailDownloadVOS.getCompanyName().split("@");
equipmentDetail.setCompanyName(company[0]);
}
equipmentDetailMapper.insert(equipmentDetail);
//生成单件设备信息
String qrCode = QRCodeUtil.generateQRCode();
EquipmentSpecific equipmentSpecific = new EquipmentSpecific();
equipmentSpecific.setQrCode(qrCode);
equipmentSpecific.setEquipmentDetailId(equipmentDetail.getId());
equipmentSpecific.setOrgCode(reginParams.getCompany().getOrgCode());
equipmentSpecific.setEquipmentCode(equipmentDetail.getCode());
equipmentSpecific.setName(equipmentDetail.getName());
iotCode = ExcelUtils.replaceAllBlank(iotCode);
equipmentSpecific.setIotCode(iotCode);
equipmentSpecific.setCode(equipmentDetailDownloadVOS.getSystemCode());
equipmentSpecific.setSystemId(fightSysIds.get());
equipmentSpecific.setNum(1);
equipmentSpecific.setSingle(true);
fireFightSysIdsBuffer.append(fightSysIds.get() + ",");
// 导入新增所属队伍
if (StringUtils.isNotBlank(equipmentDetailDownloadVOS.getFireTeam())) {
String[] fireTeam = equipmentDetailDownloadVOS.getFireTeam().split("@");
equipmentSpecific.setTeamName(fireTeam[0]);
equipmentSpecific.setTeamId(fireTeam[1]);
}
// 导入新增所属单位
if (StringUtils.isNotBlank(equipmentDetailDownloadVOS.getCompanyName())) {
String[] company = equipmentDetailDownloadVOS.getCompanyName().split("@");
equipmentSpecific.setAgencyId(company[1]);
equipmentSpecific.setAgencyName(company[0]);
equipmentSpecific.setBizOrgCode(company[2]);
equipmentSpecific.setBizOrgName(company[0]);
}
// if (StringUtils.isNotBlank(equipmentDetailDownloadVOS.getSystemName())) {
// String[] SystemName = equipmentDetailDownloadVOS.getSystemName().split("@");
// equipmentSpecific.setSystemId(SystemName[1]);
// }
equipmentSpecificMapper.insert(equipmentSpecific);
//位置编码不为空入库
if (equipmentDetailDownloadVOS != null && equipmentDetailDownloadVOS.getWarehouseStructCode() != null) {
// QueryWrapper<WarehouseStructure> warehouseStructureQueryWrapper = new QueryWrapper<>();
// warehouseStructureQueryWrapper.lambda().eq(WarehouseStructure::getCode, equipmentDetailDownloadVOS.getWarehouseStructCode());
// WarehouseStructure warehouseStructure = warehouseStructureService.getOne(warehouseStructureQueryWrapper);
// 入库位置进行优化
WarehouseStructure warehouseStructure = warehouseStructures.stream().filter(x -> x.getCode().equals(equipmentDetailDownloadVOS.getWarehouseStructCode())).collect(Collectors.toList()).get(0);
if (warehouseStructure == null) {
erryy.append(String.format("货位编码[%S]填写错误,请输入正确的货位编码!",equipmentDetailDownloadVOS.getWarehouseStructCode())+ ",");
throw new RuntimeException(String.format("货位编码[%S]填写错误,请输入正确的货位编码!",equipmentDetailDownloadVOS.getWarehouseStructCode()));
} else {
equipmentSpecific.setPosition(warehouseStructure.getFullName());
equipmentSpecific.setWarehouseStructureId(warehouseStructure.getId());
equipmentSpecificMapper.updateById(equipmentSpecific);
}
// 插入库存
Stock stock = new Stock();
stock.setAmount(Double.valueOf(equipmentSpecific.getNum()));
stock.setCompanyName(reginParams.getCompany().getCompanyName());
stock.setCompanyName(reginParams.getCompany().getOrgCode());
stock.setDepartmentOrgcode(reginParams.getDepartment().getOrgCode());
stock.setCompanyName(reginParams.getDepartment().getDepartmentName());
stock.setEquipmentDetailId(equipmentSpecific.getEquipmentDetailId());
stock.setWarehouseId(warehouseStructure.getWarehouseId());
equipmentSpecific.setStock(stock);
this.save(stock);
//库存详情
StockDetail stockDetail = new StockDetail();
stockDetail.setCompanyName(reginParams.getCompany().getCompanyName());
stockDetail.setOrgCode(reginParams.getCompany().getOrgCode());
stockDetail.setDepartmentName(reginParams.getDepartment().getDepartmentName());
stockDetail.setDepartmentOrgcode(reginParams.getDepartment().getOrgCode());
stockDetail.setEquipmentDetailId(equipmentSpecific.getEquipmentDetailId());
stockDetail.setEquipmentSpecificId(equipmentSpecific.getId());
stockDetail.setStockId(stock.getId());
stockDetail.setStatus(StockBillTypeEnum.DBRK.getValue());
stockDetail.setUpdateDate(new Date());
stockDetail.setQrCode(qrCode);
stockDetail.setWarehouseStructureId(warehouseStructure.getId());
stockDetail.setDescription(equipmentDetailDownloadVOS.getDescription());
stockDetail.setWarehouseId(warehouseStructure.getWarehouseId());
stockDetail.setAmount(1.00);
equipmentSpecific.setStockDetail(stockDetail);
stockDetailService.save(stockDetail);
//生成入库单
StockBill stockBill = new StockBill();
stockBill.setCreatorId(Long.valueOf(agencyUserModel.getUserId()));
stockBill.setCreatorName(agencyUserModel.getRealName());
stockBill.setCompanyName(reginParams.getCompany().getCompanyName());
stockBill.setDepartmentName(reginParams.getDepartment().getDepartmentName());
stockBill.setDepartmentOrgcode(String.valueOf(reginParams.getDepartment().getDeptOrgCode()));
stockBill.setOrgCode(reginParams.getCompany().getOrgCode());
stockBill.setWarehouseId(warehouseStructure.getWarehouseId());
stockBill.setBillCode(stockBillService.generateQrCode("RK"));
stockBill.setBillType(StockBillTypeEnum.DBRK.getValue());
stockBillService.save(stockBill);
//生成入库单详情
StockBillDetail stockBillDetail = new StockBillDetail();
stockBillDetail.setAmount(stockDetail.getAmount());
stockBillDetail.setEquipmentDetailId(equipmentDetail.getId());
stockBillDetail.setStockDetailId(stockDetail.getId());
stockBillDetail.setBatchNum(stf.format(new Date()));
stockBillDetail.setCreatorId(Long.valueOf(agencyUserModel.getUserId()));
stockBillDetail.setSingleEquipCode(stockDetail.getQrCode());
stockBillDetail.setStockBillId(stockBill.getId());
stockBillDetail.setWarehouseStructureId(warehouseStructure.getId());
stockBillDetailService.save(stockBillDetail);
}
list.add(equipmentSpecific);
this.equipmentSpecificIndexSave(equipmentDetail, equipmentSpecific);
bizOrgCodes.add(equipmentSpecific.getBizOrgCode());
platformTransactionManager.commit(transactionStatus);
} catch (Exception e) {
platformTransactionManager.rollback(transactionStatus);
errBufferName.append(equipmentDetailDownloadVOS.getCode() + ",");
equipmentDetailMapper.insert(equipmentDetail);
//生成单件设备信息
String qrCode = QRCodeUtil.generateQRCode();
EquipmentSpecific equipmentSpecific = new EquipmentSpecific();
equipmentSpecific.setQrCode(qrCode);
equipmentSpecific.setEquipmentDetailId(equipmentDetail.getId());
equipmentSpecific.setOrgCode(reginParams.getCompany().getOrgCode());
equipmentSpecific.setEquipmentCode(equipmentDetail.getCode());
equipmentSpecific.setName(equipmentDetail.getName());
iotCode = ExcelUtils.replaceAllBlank(iotCode);
equipmentSpecific.setIotCode(iotCode);
equipmentSpecific.setCode(equipmentDetailDownloadVOS.getSystemCode());
equipmentSpecific.setSystemId(fightSysIds.get());
equipmentSpecific.setNum(1);
equipmentSpecific.setSingle(true);
fireFightSysIdsBuffer.append(fightSysIds.get() + ",");
// 导入新增所属队伍
if (StringUtils.isNotBlank(equipmentDetailDownloadVOS.getFireTeam())) {
String[] fireTeam = equipmentDetailDownloadVOS.getFireTeam().split("@");
equipmentSpecific.setTeamName(fireTeam[0]);
equipmentSpecific.setTeamId(fireTeam[1]);
}
// 导入新增所属单位
if (StringUtils.isNotBlank(equipmentDetailDownloadVOS.getCompanyName())) {
String[] company = equipmentDetailDownloadVOS.getCompanyName().split("@");
equipmentSpecific.setAgencyId(company[1]);
equipmentSpecific.setAgencyName(company[0]);
equipmentSpecific.setBizOrgCode(company[2]);
equipmentSpecific.setBizOrgName(company[0]);
}
if (StringUtils.isNotBlank(equipmentDetailDownloadVOS.getSystemName())) {
String[] SystemName = equipmentDetailDownloadVOS.getSystemName().split("@");
equipmentSpecific.setSystemId(SystemName[1]);
}
equipmentSpecificMapper.insert(equipmentSpecific);
StockServiceImpl controllerProxy = SpringUtils.getBean(StockServiceImpl.class);
//添加对于装备类型统计数据的刷新
controllerProxy.refreshCount(equipmentSpecific.getBizOrgCode());
//位置编码不为空入库
if (equipmentDetailDownloadVOS != null && equipmentDetailDownloadVOS.getWarehouseStructCode() != null) {
QueryWrapper<WarehouseStructure> warehouseStructureQueryWrapper = new QueryWrapper<>();
warehouseStructureQueryWrapper.lambda().eq(WarehouseStructure::getCode, equipmentDetailDownloadVOS.getWarehouseStructCode());
WarehouseStructure warehouseStructure = warehouseStructureService.getOne(warehouseStructureQueryWrapper);
if (warehouseStructure == null) {
erryy.append(String.format("货位编码[%S]填写错误,请输入正确的货位编码!",equipmentDetailDownloadVOS.getWarehouseStructCode())+ ",");
throw new RuntimeException(String.format("货位编码[%S]填写错误,请输入正确的货位编码!",equipmentDetailDownloadVOS.getWarehouseStructCode()));
} else {
equipmentSpecific.setPosition(warehouseStructure.getFullName());
equipmentSpecific.setWarehouseStructureId(warehouseStructure.getId());
equipmentSpecificMapper.updateById(equipmentSpecific);
}
// 插入库存
Stock stock = new Stock();
stock.setAmount(Double.valueOf(equipmentSpecific.getNum()));
stock.setCompanyName(reginParams.getCompany().getCompanyName());
stock.setCompanyName(reginParams.getCompany().getOrgCode());
stock.setDepartmentOrgcode(reginParams.getDepartment().getOrgCode());
stock.setCompanyName(reginParams.getDepartment().getDepartmentName());
stock.setEquipmentDetailId(equipmentSpecific.getEquipmentDetailId());
stock.setWarehouseId(warehouseStructure.getWarehouseId());
equipmentSpecific.setStock(stock);
this.save(stock);
//库存详情
StockDetail stockDetail = new StockDetail();
stockDetail.setCompanyName(reginParams.getCompany().getCompanyName());
stockDetail.setOrgCode(reginParams.getCompany().getOrgCode());
stockDetail.setDepartmentName(reginParams.getDepartment().getDepartmentName());
stockDetail.setDepartmentOrgcode(reginParams.getDepartment().getOrgCode());
stockDetail.setEquipmentDetailId(equipmentSpecific.getEquipmentDetailId());
stockDetail.setEquipmentSpecificId(equipmentSpecific.getId());
stockDetail.setStockId(stock.getId());
stockDetail.setStatus(StockBillTypeEnum.DBRK.getValue());
stockDetail.setUpdateDate(new Date());
stockDetail.setQrCode(qrCode);
stockDetail.setWarehouseStructureId(warehouseStructure.getId());
stockDetail.setDescription(equipmentDetailDownloadVOS.getDescription());
stockDetail.setWarehouseId(warehouseStructure.getWarehouseId());
stockDetail.setAmount(1.00);
equipmentSpecific.setStockDetail(stockDetail);
stockDetailService.save(stockDetail);
//生成入库单
StockBill stockBill = new StockBill();
stockBill.setCreatorId(Long.valueOf(agencyUserModel.getUserId()));
stockBill.setCreatorName(agencyUserModel.getRealName());
stockBill.setCompanyName(reginParams.getCompany().getCompanyName());
stockBill.setDepartmentName(reginParams.getDepartment().getDepartmentName());
stockBill.setDepartmentOrgcode(String.valueOf(reginParams.getDepartment().getDeptOrgCode()));
stockBill.setOrgCode(reginParams.getCompany().getOrgCode());
stockBill.setWarehouseId(warehouseStructure.getWarehouseId());
stockBill.setBillCode(stockBillService.generateQrCode("RK"));
stockBill.setBillType(StockBillTypeEnum.DBRK.getValue());
stockBillService.save(stockBill);
//生成入库单详情
StockBillDetail stockBillDetail = new StockBillDetail();
stockBillDetail.setAmount(stockDetail.getAmount());
stockBillDetail.setEquipmentDetailId(equipmentDetail.getId());
stockBillDetail.setStockDetailId(stockDetail.getId());
stockBillDetail.setBatchNum(stf.format(new Date()));
stockBillDetail.setCreatorId(Long.valueOf(agencyUserModel.getUserId()));
stockBillDetail.setSingleEquipCode(stockDetail.getQrCode());
stockBillDetail.setStockBillId(stockBill.getId());
stockBillDetail.setWarehouseStructureId(warehouseStructure.getId());
stockBillDetailService.save(stockBillDetail);
}
list.add(equipmentSpecific);
this.equipmentSpecificIndexSave(equipmentDetail, equipmentSpecific);
platformTransactionManager.commit(transactionStatus);
} catch (Exception e) {
platformTransactionManager.rollback(transactionStatus);
errBufferName.append(equipmentDetailDownloadVOS.getCode() + ",");
e.printStackTrace();
throw new RuntimeException();
}
e.printStackTrace();
throw new RuntimeException();
}
}
......@@ -780,7 +813,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
// @Async
@Async
public void refreshCount(String bizOrgCode) {
equipmentSpecificSerivce.refreshStaData();
try {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment