|
|
@ -972,11 +972,27 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double quantity = Double.parseDouble(map.get("quantity").toString()); |
|
|
double quantity = Double.parseDouble(map.get("quantity").toString()); |
|
|
|
|
|
double quantity_residue = 0; |
|
|
|
|
|
int splitInfoScaleQuantity = 0; |
|
|
|
|
|
SplitInfo baseSplitInfoForMid = null; |
|
|
|
|
|
if (Math.floor(quantity) < quantity) { |
|
|
|
|
|
// 如果当前导入的物料存在小数
|
|
|
|
|
|
|
|
|
|
|
|
// 获取当前物料对应的最小拆单单位
|
|
|
|
|
|
baseSplitInfoForMid = splitUnitService.findBaseSplitInfoForMid(material.getMid()); |
|
|
|
|
|
if (baseSplitInfoForMid != null) { |
|
|
|
|
|
// 获取当前拆单单位与基础单位的进制
|
|
|
|
|
|
splitInfoScaleQuantity = splitUnitService.findSplitInfoScaleQuantity(baseSplitInfoForMid, -1); |
|
|
|
|
|
quantity_residue = quantity - Math.floor(quantity); |
|
|
|
|
|
quantity = quantity - quantity_residue; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
material.setQuantity(material.getQuantity() + (int) (quantity * 100)); |
|
|
material.setQuantity(material.getQuantity() + (int) (quantity * 100)); |
|
|
|
|
|
|
|
|
// 获取当前物料要存入的库位
|
|
|
// 获取当前物料要存入的库位
|
|
|
String tempPlaceCode = (String) map.get("tempPlaceCode"); |
|
|
String tempPlaceCode = (String) map.get("tempPlaceCode"); |
|
|
if ("0".equals(tempPlaceCode)) { |
|
|
if ("0".equals(tempPlaceCode) || "0000".equals(tempPlaceCode) || "000000".equals(tempPlaceCode)) { |
|
|
// 如果当前导入库位是默认库位
|
|
|
// 如果当前导入库位是默认库位
|
|
|
MaterialAndPlace placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialByMidAndPid(0, material.getId()); |
|
|
MaterialAndPlace placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialByMidAndPid(0, material.getId()); |
|
|
|
|
|
|
|
|
@ -984,7 +1000,6 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
// 修改当前库位数目
|
|
|
// 修改当前库位数目
|
|
|
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() + (int) (quantity * 100)); |
|
|
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() + (int) (quantity * 100)); |
|
|
placeService.updateMaterialAndPlace(placeAndMaterialByMidAndPid); |
|
|
placeService.updateMaterialAndPlace(placeAndMaterialByMidAndPid); |
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
// 如果没有对应关系
|
|
|
// 如果没有对应关系
|
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
@ -993,16 +1008,35 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
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"))); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
// 修改库位存放数量
|
|
|
// 修改库位存放数量
|
|
|
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); |
|
|
|
|
|
|
|
|
|
|
|
if (baseSplitInfoForMid != null) { |
|
|
|
|
|
Map<String, Object> insertForSplitInfoStringObjectMap = new HashMap<>(); |
|
|
|
|
|
insertForSplitInfoStringObjectMap.put("depositoryId", map.get("depositoryId")); |
|
|
|
|
|
insertForSplitInfoStringObjectMap.put("quantity", quantity_residue * splitInfoScaleQuantity); |
|
|
|
|
|
insertForSplitInfoStringObjectMap.put("placeId", "0"); |
|
|
|
|
|
insertForSplitInfoStringObjectMap.put("mid", material.getMid().toString()); |
|
|
|
|
|
insertForSplitInfoStringObjectMap.put("newInMid", material.getId()); |
|
|
|
|
|
insertForSplitInfoStringObjectMap.put("unit", baseSplitInfoForMid.getNewUnit()); |
|
|
|
|
|
SplitInventory splitInventoryByIidAndSid = splitUnitService.findSplitInventoryByIidAndSid(placeAndMaterialByMidAndPid.getId(), baseSplitInfoForMid.getId()); |
|
|
|
|
|
splitUnitService.realInInventoryToDepository(quantity_residue * splitInfoScaleQuantity, splitInventoryByIidAndSid, insertForSplitInfoStringObjectMap, baseSplitInfoForMid, placeAndMaterialByMidAndPid, true); |
|
|
|
|
|
if (insertForSplitInfoStringObjectMap.containsKey("applicationInId")) { |
|
|
|
|
|
depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(insertForSplitInfoStringObjectMap.get("applicationInId"))); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
// 如果要导入的不是默认库位
|
|
|
// 如果要导入的不是默认库位
|
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
param.put("depositoryId", material.getDepositoryId()); |
|
|
param.put("depositoryId", material.getDepositoryId()); |
|
|
param.put("code", tempPlaceCode); |
|
|
param.put("kingdeecode", tempPlaceCode); |
|
|
// 获取要导入的库位
|
|
|
// 获取要导入的库位
|
|
|
Place placeByCondition = placeService.findPlaceByCondition(param).get(0); |
|
|
Place placeByCondition = placeService.findPlaceByCondition(param).get(0); |
|
|
// 修改库位物料数量
|
|
|
// 修改库位物料数量
|
|
|
@ -1018,19 +1052,40 @@ public class MaterialServiceImpl implements MaterialService { |
|
|
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"))); |
|
|
} else { |
|
|
} else { |
|
|
// 如果有对应关系
|
|
|
// 如果有对应关系
|
|
|
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() + (int) (quantity * 100)); |
|
|
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() + (int) (quantity * 100)); |
|
|
// 修改数量
|
|
|
// 修改数量
|
|
|
placeService.updateMaterialAndPlace(placeAndMaterialByMidAndPid); |
|
|
placeService.updateMaterialAndPlace(placeAndMaterialByMidAndPid); |
|
|
} |
|
|
} |
|
|
|
|
|
if (baseSplitInfoForMid != null) { |
|
|
|
|
|
Map<String, Object> insertForSplitInfoStringObjectMap = new HashMap<>(); |
|
|
|
|
|
insertForSplitInfoStringObjectMap.put("depositoryId", map.get("depositoryId")); |
|
|
|
|
|
insertForSplitInfoStringObjectMap.put("quantity", quantity_residue * splitInfoScaleQuantity); |
|
|
|
|
|
insertForSplitInfoStringObjectMap.put("placeId", placeByCondition.getId()); |
|
|
|
|
|
insertForSplitInfoStringObjectMap.put("mid", material.getMid().toString()); |
|
|
|
|
|
insertForSplitInfoStringObjectMap.put("newInMid", material.getId()); |
|
|
|
|
|
insertForSplitInfoStringObjectMap.put("type", "in"); |
|
|
|
|
|
insertForSplitInfoStringObjectMap.put("unit", baseSplitInfoForMid.getNewUnit()); |
|
|
|
|
|
SplitInventory splitInventoryByIidAndSid = splitUnitService.findSplitInventoryByIidAndSid(placeAndMaterialByMidAndPid.getId(), baseSplitInfoForMid.getId()); |
|
|
|
|
|
splitUnitService.realInInventoryToDepository(quantity_residue * splitInfoScaleQuantity, splitInventoryByIidAndSid, insertForSplitInfoStringObjectMap, baseSplitInfoForMid, placeAndMaterialByMidAndPid, true); |
|
|
|
|
|
if (insertForSplitInfoStringObjectMap.containsKey("applicationInId")) { |
|
|
|
|
|
depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(insertForSplitInfoStringObjectMap.get("applicationInId"))); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
return materialMapper.updateInventory(material); |
|
|
|
|
|
} |
|
|
} |
|
|
else { |
|
|
return materialMapper.updateInventory(material); |
|
|
|
|
|
} else { |
|
|
// 用于标志是新插入的物料
|
|
|
// 用于标志是新插入的物料
|
|
|
map.put("isNew", true); |
|
|
map.put("isNew", true); |
|
|
map.put("quantity",(int)(ObjectFormatUtil.toDouble(map.get("quantity")) * 100)); |
|
|
Double quantity = ObjectFormatUtil.toDouble(map.get("quantity")); |
|
|
|
|
|
map.put("quantity", (int) (quantity * 100)); |
|
|
|
|
|
|
|
|
|
|
|
SplitInfo baseSplitInfoForMid = splitUnitService.findBaseSplitInfoForMid(ObjectFormatUtil.toInteger(map.get("id"))); |
|
|
|
|
|
if (baseSplitInfoForMid != null) { |
|
|
|
|
|
map.put("quantity", (int) ((quantity - Math.floor(quantity)) * 100)); |
|
|
|
|
|
} |
|
|
if (!map.containsKey("producedDate")) { |
|
|
if (!map.containsKey("producedDate")) { |
|
|
// 如果不包含生产日期
|
|
|
// 如果不包含生产日期
|
|
|
map.put("producedDate", 0); |
|
|
map.put("producedDate", 0); |
|
|
|