Browse Source

修改库存导入功能

lwx_dev
erdanergou 3 years ago
parent
commit
beafa1c34a
  1. 39
      src/main/java/com/dreamchaser/depository_manage/service/impl/ExcelServiceImpl.java

39
src/main/java/com/dreamchaser/depository_manage/service/impl/ExcelServiceImpl.java

@ -99,7 +99,7 @@ public class ExcelServiceImpl implements ExcelService {
param.put("texture", excelVo.getTexture()); param.put("texture", excelVo.getTexture());
param.put("materialTypeId", excelVo.getTypeId()); param.put("materialTypeId", excelVo.getTypeId());
param.put("id", excelVo.getId()); param.put("id", excelVo.getId());
param.put("price",excelVo.getPrice() == null ? "0" : excelVo.getPrice()); param.put("price", excelVo.getPrice() == null ? "0" : excelVo.getPrice());
materialService.insertMaterial(param); materialService.insertMaterial(param);
success.add(excelVo); success.add(excelVo);
} }
@ -244,14 +244,16 @@ public class ExcelServiceImpl implements ExcelService {
// 获取当前库存明细规格 // 获取当前库存明细规格
String version = excelInfoByInventory.getVersion(); String version = excelInfoByInventory.getVersion();
// 用于查询当前物料中是否存在该记录 // 用于查询当前物料中是否存在该记录
Map<String,Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("mname",mname); map.put("mname", mname);
map.put("version",version); map.put("version", version);
List<Material> materialPByCondition = materialService.findMaterialPByConditionForTable(map); List<Material> materialPByCondition = materialService.findMaterialPByConditionForTable(map);
if(materialPByCondition.size() == 0){ if (materialPByCondition.size() == 0) {
Material materialByCode = null;
Material materialByCode = materialService.findMaterialByCode(excelInfoByInventory.getCode()); if (excelInfoByInventory.getCode() != null && !"".equals(excelInfoByInventory.getCode())) {
if(materialByCode == null){ materialByCode = materialService.findMaterialByCode(excelInfoByInventory.getCode());
}
if (materialByCode == null) {
// 如果没有当前物料 // 如果没有当前物料
String s = dataIndex.get(i); String s = dataIndex.get(i);
String msg = s + "出现异常:" + excelInfoByInventory.getMname() + " 系统中并未存在该物料"; String msg = s + "出现异常:" + excelInfoByInventory.getMname() + " 系统中并未存在该物料";
@ -273,7 +275,7 @@ public class ExcelServiceImpl implements ExcelService {
// 如果有库位 // 如果有库位
Place place = placeByCondition.get(0); Place place = placeByCondition.get(0);
// 如果库位有物料且该库位存放的物料为当前物料 // 如果库位有物料且该库位存放的物料为当前物料
int quantity = (int)(ObjectFormatUtil.toDouble(excelInfoByInventory.getQuantity()) * 100); int quantity = (int) (ObjectFormatUtil.toDouble(excelInfoByInventory.getQuantity()) * 100);
if (quantity > place.getMax() - place.getQuantity()) { if (quantity > place.getMax() - place.getQuantity()) {
// 如果当前库位无法放下 // 如果当前库位无法放下
String s = dataIndex.get(i); String s = dataIndex.get(i);
@ -307,12 +309,11 @@ public class ExcelServiceImpl implements ExcelService {
ExcelInfoByInventory excelInfoByInventory = excelVos.get(i); ExcelInfoByInventory excelInfoByInventory = excelVos.get(i);
Map<String, Object> insert = new HashMap<>(); Map<String, Object> insert = new HashMap<>();
insert.put("mname", excelInfoByInventory.getMname()); insert.put("mname", excelInfoByInventory.getMname());
insert.put("version",excelInfoByInventory.getVersion()); insert.put("version", excelInfoByInventory.getVersion());
Material material = materialService.findMaterialByMnameAndVersion(insert); Material material = materialService.findMaterialByMnameAndVersion(insert);
if(material == null) if (material == null) {
{
material = materialService.findMaterialByCode(excelInfoByInventory.getCode()); material = materialService.findMaterialByCode(excelInfoByInventory.getCode());
} }
@ -334,7 +335,7 @@ public class ExcelServiceImpl implements ExcelService {
if (isNew) { if (isNew) {
SplitInfo baseSplitInfoForMid = splitUnitService.findBaseSplitInfoForMid(material.getId()); SplitInfo baseSplitInfoForMid = splitUnitService.findBaseSplitInfoForMid(material.getId());
double quantity_residue = 0; double quantity_residue = 0;
if(baseSplitInfoForMid != null){ if (baseSplitInfoForMid != null) {
quantity_residue = quantity - Math.floor(quantity); quantity_residue = quantity - Math.floor(quantity);
quantity = quantity - quantity_residue; quantity = quantity - quantity_residue;
} }
@ -345,12 +346,12 @@ public class ExcelServiceImpl implements ExcelService {
// 获取默认库位 // 获取默认库位
Place placeById = placeService.findPlaceById(0); Place placeById = placeService.findPlaceById(0);
// 修改默认库位库存 // 修改默认库位库存
placeById.setQuantity(placeById.getQuantity() + (int)(quantity * 100)); placeById.setQuantity(placeById.getQuantity() + (int) (quantity * 100));
placeService.UpdatePlace(placeById); placeService.UpdatePlace(placeById);
// 添加库位与物料的映射 // 添加库位与物料的映射
param.put("mid", insert.get("id")); param.put("mid", insert.get("id"));
param.put("pid", 0); param.put("pid", 0);
param.put("quantity", (int)(quantity * 100)); param.put("quantity", (int) (quantity * 100));
placeService.addMaterialOnPlace(param); placeService.addMaterialOnPlace(param);
placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialById(ObjectFormatUtil.toInteger(param.get("id"))); placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialById(ObjectFormatUtil.toInteger(param.get("id")));
} else { } else {
@ -362,19 +363,19 @@ public class ExcelServiceImpl implements ExcelService {
Place placeByCondition = placeService.findPlaceByCondition(param).get(0); Place placeByCondition = placeService.findPlaceByCondition(param).get(0);
// 修改库位物料数量 // 修改库位物料数量
placeByCondition.setQuantity(placeByCondition.getQuantity() + (int)(quantity * 100)); placeByCondition.setQuantity(placeByCondition.getQuantity() + (int) (quantity * 100));
placeService.UpdatePlace(placeByCondition); placeService.UpdatePlace(placeByCondition);
// 如果没有对应关系 // 如果没有对应关系
param.put("pid", placeByCondition.getId()); param.put("pid", placeByCondition.getId());
param.put("mid", insert.get("id")); param.put("mid", insert.get("id"));
param.put("quantity", (int)(quantity * 100)); param.put("quantity", (int) (quantity * 100));
// 添加对应关系 // 添加对应关系
placeService.addMaterialOnPlace(param); placeService.addMaterialOnPlace(param);
placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialById(ObjectFormatUtil.toInteger(param.get("id"))); placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialById(ObjectFormatUtil.toInteger(param.get("id")));
} }
if(baseSplitInfoForMid != null){ if (baseSplitInfoForMid != null) {
Map<String, Object> insertForSplitInfoStringObjectMap = new HashMap<>(); Map<String, Object> insertForSplitInfoStringObjectMap = new HashMap<>();
insertForSplitInfoStringObjectMap.put("depositoryId", depositoryId); insertForSplitInfoStringObjectMap.put("depositoryId", depositoryId);
insertForSplitInfoStringObjectMap.put("quantity", quantity_residue); insertForSplitInfoStringObjectMap.put("quantity", quantity_residue);
@ -382,7 +383,7 @@ public class ExcelServiceImpl implements ExcelService {
insertForSplitInfoStringObjectMap.put("mid", material.getId()); insertForSplitInfoStringObjectMap.put("mid", material.getId());
insertForSplitInfoStringObjectMap.put("unit", baseSplitInfoForMid.getNewUnit()); insertForSplitInfoStringObjectMap.put("unit", baseSplitInfoForMid.getNewUnit());
SplitInventory splitInventoryByIidAndSid = splitUnitService.findSplitInventoryByIidAndSid(placeAndMaterialByMidAndPid.getId(), baseSplitInfoForMid.getId()); SplitInventory splitInventoryByIidAndSid = splitUnitService.findSplitInventoryByIidAndSid(placeAndMaterialByMidAndPid.getId(), baseSplitInfoForMid.getId());
int splitInfoScaleQuantity = splitUnitService.findSplitInfoScaleQuantity(baseSplitInfoForMid,-1); int splitInfoScaleQuantity = splitUnitService.findSplitInfoScaleQuantity(baseSplitInfoForMid, -1);
splitUnitService.realInInventoryToDepository(quantity_residue * splitInfoScaleQuantity, splitInventoryByIidAndSid, insertForSplitInfoStringObjectMap, baseSplitInfoForMid, placeAndMaterialByMidAndPid, true); splitUnitService.realInInventoryToDepository(quantity_residue * splitInfoScaleQuantity, splitInventoryByIidAndSid, insertForSplitInfoStringObjectMap, baseSplitInfoForMid, placeAndMaterialByMidAndPid, true);
if (insertForSplitInfoStringObjectMap.containsKey("applicationInId")) { if (insertForSplitInfoStringObjectMap.containsKey("applicationInId")) {
depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(insertForSplitInfoStringObjectMap.get("applicationInId"))); depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(insertForSplitInfoStringObjectMap.get("applicationInId")));

Loading…
Cancel
Save