|
|
@ -106,7 +106,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
//构造单号
|
|
|
//构造单号
|
|
|
String code = createCode(depositoryRecordById.getDname(), "InOrderNumber", "in", ""); |
|
|
String code = createCode(depositoryRecordById.getDname(), "InOrderNumber", "in", ""); |
|
|
Double quantity = Double.parseDouble((String) map.get("quantity")); |
|
|
Double quantity = Double.parseDouble((String) map.get("quantity")); |
|
|
Double price = Double.parseDouble((String) map.get("price")); |
|
|
double price = Double.parseDouble((String) map.get("price")); |
|
|
Integer mid = ObjectFormatUtil.toInteger(map.get("mid")); |
|
|
Integer mid = ObjectFormatUtil.toInteger(map.get("mid")); |
|
|
// 根据物料id查询物料
|
|
|
// 根据物料id查询物料
|
|
|
Material material = materialMapper.findMaterialById(mid); |
|
|
Material material = materialMapper.findMaterialById(mid); |
|
|
@ -115,11 +115,11 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
// 获取当前填写的生产日期
|
|
|
// 获取当前填写的生产日期
|
|
|
Long producedDate = Long.valueOf(0); |
|
|
long producedDate = 0L; |
|
|
if (map.containsKey("producedDate")) { |
|
|
if (map.containsKey("producedDate")) { |
|
|
Object s = map.get("producedDate"); |
|
|
Object s = map.get("producedDate"); |
|
|
if (s == null || "".equals(s.toString())) { |
|
|
if (s == null || "".equals(s.toString())) { |
|
|
producedDate = Long.valueOf(0); |
|
|
producedDate = 0L; |
|
|
} else { |
|
|
} else { |
|
|
producedDate = DateUtil.DateTimeByDayToTimeStamp(s.toString()); |
|
|
producedDate = DateUtil.DateTimeByDayToTimeStamp(s.toString()); |
|
|
} |
|
|
} |
|
|
@ -564,10 +564,10 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
insertProducedDate.put("inid", InId); |
|
|
insertProducedDate.put("inid", InId); |
|
|
insertProducedDate.put("mid", newInMid); |
|
|
insertProducedDate.put("mid", newInMid); |
|
|
if (map.containsKey("producedDate")) { |
|
|
if (map.containsKey("producedDate")) { |
|
|
Long producedDate = Long.valueOf(0); |
|
|
Long producedDate = 0L; |
|
|
Object s = map.get("producedDate"); |
|
|
Object s = map.get("producedDate"); |
|
|
if (s == null || "".equals(s.toString())) { |
|
|
if (s == null || "".equals(s.toString())) { |
|
|
producedDate = Long.valueOf(0); |
|
|
producedDate = 0L; |
|
|
} else { |
|
|
} else { |
|
|
producedDate = DateUtil.DateTimeByDayToTimeStamp(s.toString()); |
|
|
producedDate = DateUtil.DateTimeByDayToTimeStamp(s.toString()); |
|
|
insertProducedDate.put("producedDate", producedDate); |
|
|
insertProducedDate.put("producedDate", producedDate); |
|
|
@ -854,6 +854,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
map.put("quantity", trueOut.toString()); |
|
|
map.put("quantity", trueOut.toString()); |
|
|
map.put("applicantId", record.getApplicantId()); |
|
|
map.put("applicantId", record.getApplicantId()); |
|
|
map.put("minRecordId", applicationOutMinById.getId()); // 出库订单编号
|
|
|
map.put("minRecordId", applicationOutMinById.getId()); // 出库订单编号
|
|
|
|
|
|
map.put("unit", applicationOutMinById.getUnit()); |
|
|
transferMaterial(map); |
|
|
transferMaterial(map); |
|
|
} |
|
|
} |
|
|
restResponse.setStatus(200); |
|
|
restResponse.setStatus(200); |
|
|
@ -893,8 +894,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
restResponse.setData(""); |
|
|
restResponse.setData(""); |
|
|
restResponse.setStatusInfo(new StatusInfo("出库失败", "出库失败,库存不足")); |
|
|
restResponse.setStatusInfo(new StatusInfo("出库失败", "出库失败,库存不足")); |
|
|
} |
|
|
} |
|
|
} |
|
|
} else { |
|
|
else { |
|
|
|
|
|
// 如果是拆单后的出库
|
|
|
// 如果是拆单后的出库
|
|
|
|
|
|
|
|
|
// 用于获取对应的拆单记录
|
|
|
// 用于获取对应的拆单记录
|
|
|
@ -904,10 +904,16 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
// 获取对应拆单记录
|
|
|
// 获取对应拆单记录
|
|
|
SplitInfo splitInfo = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo); |
|
|
SplitInfo splitInfo = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo); |
|
|
|
|
|
|
|
|
|
|
|
// 获取当前出库物料所在库位的对应关系
|
|
|
|
|
|
Map<String, Object> paramForInventoryToPlace = new HashMap<>(); |
|
|
|
|
|
paramForInventoryToPlace.put("mid", inventory.getId()); |
|
|
|
|
|
paramForInventoryToPlace.put("pid", placeId); |
|
|
|
|
|
// 获取当前物料所存放库位的数量
|
|
|
|
|
|
placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(paramForInventoryToPlace); |
|
|
// 获取当前拆单库存
|
|
|
// 获取当前拆单库存
|
|
|
Map<String, Object> paramForSplitInventory = new HashMap<>(); |
|
|
Map<String, Object> paramForSplitInventory = new HashMap<>(); |
|
|
paramForSplitInventory.put("sid", splitInfo.getId()); |
|
|
paramForSplitInventory.put("sid", splitInfo.getId()); |
|
|
paramForSplitInventory.put("iid", inventory.getId()); |
|
|
paramForSplitInventory.put("iid", placeAndMaterialByMidAndPid.getId()); |
|
|
SplitInventory splitInventory = splitUnitMapper.findSplitInventoryByIidAndSid(paramForSplitInventory); |
|
|
SplitInventory splitInventory = splitUnitMapper.findSplitInventoryByIidAndSid(paramForSplitInventory); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -929,6 +935,16 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
// 修改库存处理记录
|
|
|
// 修改库存处理记录
|
|
|
splitUnitMapper.updateSplitInventory(splitInventory); |
|
|
splitUnitMapper.updateSplitInventory(splitInventory); |
|
|
|
|
|
|
|
|
|
|
|
// 如果是库存转移订单
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
|
if (record.getIstransfer() == 1) { |
|
|
|
|
|
map.put("quantity", trueOut.toString()); |
|
|
|
|
|
map.put("applicantId", record.getApplicantId()); |
|
|
|
|
|
map.put("minRecordId", applicationOutMinById.getId()); // 出库订单编号
|
|
|
|
|
|
map.put("unit", applicationOutMinById.getUnit()); |
|
|
|
|
|
transferMaterial(map); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 进行子订单的相关处理
|
|
|
// 进行子订单的相关处理
|
|
|
updateApplicationMinOutInfo(id, applicationOutMinById, record, trueOut, userByPort, placeId, userAgent); |
|
|
updateApplicationMinOutInfo(id, applicationOutMinById, record, trueOut, userByPort, placeId, userAgent); |
|
|
|
|
|
|
|
|
@ -966,7 +982,20 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
// 获取当前父级拆单记录
|
|
|
// 获取当前父级拆单记录
|
|
|
SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(splitInfoById.getParentId()); |
|
|
SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(splitInfoById.getParentId()); |
|
|
|
|
|
|
|
|
restResponse = updateSplitInventoryInfo(parentSplitInfo, inventory, trueOut, surplus, splitInfo); |
|
|
|
|
|
|
|
|
restResponse = updateOutSplitInventoryInfo(parentSplitInfo, placeAndMaterialByMidAndPid, trueOut, surplus, splitInfo); |
|
|
|
|
|
|
|
|
|
|
|
// 如果成功出库
|
|
|
|
|
|
if (restResponse.getStatus() == 200) { |
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
|
if (record.getIstransfer() == 1) { |
|
|
|
|
|
map.put("quantity", trueOut.toString()); |
|
|
|
|
|
map.put("applicantId", record.getApplicantId()); |
|
|
|
|
|
map.put("minRecordId", applicationOutMinById.getId()); // 出库订单编号
|
|
|
|
|
|
map.put("unit", applicationOutMinById.getUnit()); |
|
|
|
|
|
transferMaterial(map); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
updateApplicationMinOutInfo(id, applicationOutMinById, record, trueOut, userByPort, placeId, userAgent); |
|
|
updateApplicationMinOutInfo(id, applicationOutMinById, record, trueOut, userByPort, placeId, userAgent); |
|
|
} else { |
|
|
} else { |
|
|
@ -1043,6 +1072,16 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
splitInventory.setOutQuantity(splitInventory.getOutQuantity() + trueOut); |
|
|
splitInventory.setOutQuantity(splitInventory.getOutQuantity() + trueOut); |
|
|
splitUnitMapper.updateSplitInventory(splitInventory); |
|
|
splitUnitMapper.updateSplitInventory(splitInventory); |
|
|
|
|
|
|
|
|
|
|
|
// 如果是库存转移订单
|
|
|
|
|
|
if (record.getIstransfer() == 1) { |
|
|
|
|
|
map.put("quantity", trueOut.toString()); |
|
|
|
|
|
map.put("applicantId", record.getApplicantId()); |
|
|
|
|
|
map.put("minRecordId", applicationOutMinById.getId()); // 出库订单编号
|
|
|
|
|
|
map.put("unit", applicationOutMinById.getUnit()); |
|
|
|
|
|
transferMaterial(map); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateApplicationMinOutInfo(id, applicationOutMinById, record, trueOut, userByPort, placeId, userAgent); |
|
|
updateApplicationMinOutInfo(id, applicationOutMinById, record, trueOut, userByPort, placeId, userAgent); |
|
|
|
|
|
|
|
|
restResponse.setStatus(200); |
|
|
restResponse.setStatus(200); |
|
|
@ -1184,7 +1223,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
// 添加拆单库存处理记录
|
|
|
// 添加拆单库存处理记录
|
|
|
Map<String, Object> insertSplitInventory = new HashMap<>(); |
|
|
Map<String, Object> insertSplitInventory = new HashMap<>(); |
|
|
insertSplitInventory.put("sid", splitInfo.getId()); |
|
|
insertSplitInventory.put("sid", splitInfo.getId()); |
|
|
insertSplitInventory.put("iid", inventory.getId()); |
|
|
insertSplitInventory.put("iid", placeAndMaterialByMidAndPid.getId()); |
|
|
insertSplitInventory.put("outQuantity", trueOut); |
|
|
insertSplitInventory.put("outQuantity", trueOut); |
|
|
insertSplitInventory.put("inQuantity", 0); |
|
|
insertSplitInventory.put("inQuantity", 0); |
|
|
insertSplitInventory.put("saveQuantity", splitInfo.getQuantity() - residue_realQuantity); |
|
|
insertSplitInventory.put("saveQuantity", splitInfo.getQuantity() - residue_realQuantity); |
|
|
@ -1222,20 +1261,20 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
/** |
|
|
/** |
|
|
* 用于有父级拆单记录的出库处理 |
|
|
* 用于有父级拆单记录的出库处理 |
|
|
* |
|
|
* |
|
|
* @param splitInfo 父级拆单记录 |
|
|
* @param splitInfo 父级拆单记录 |
|
|
* @param inventory 当前库存记录 |
|
|
* @param materialAndPlace 当前库存记录 |
|
|
* @param quantity 当前出库总量 |
|
|
* @param quantity 当前出库总量 |
|
|
* @param nowQuantity 当前未出库数量 |
|
|
* @param nowQuantity 当前未出库数量 |
|
|
* @param realSplitInfo 实际出库的拆单记录 |
|
|
* @param realSplitInfo 实际出库的拆单记录 |
|
|
* @return |
|
|
* @return |
|
|
*/ |
|
|
*/ |
|
|
RestResponse updateSplitInventoryInfo(SplitInfo splitInfo, Inventory inventory, int quantity, int nowQuantity, SplitInfo realSplitInfo) { |
|
|
RestResponse updateOutSplitInventoryInfo(SplitInfo splitInfo, MaterialAndPlace materialAndPlace, int quantity, int nowQuantity, SplitInfo realSplitInfo) { |
|
|
// 定义返回值
|
|
|
// 定义返回值
|
|
|
RestResponse restResponse = new RestResponse(); |
|
|
RestResponse restResponse = new RestResponse(); |
|
|
// 用于获取当前拆单记录对应的拆单库存记录
|
|
|
// 用于获取当前拆单记录对应的拆单库存记录
|
|
|
Map<String, Object> paramForSplitInventory = new HashMap<>(); |
|
|
Map<String, Object> paramForSplitInventory = new HashMap<>(); |
|
|
paramForSplitInventory.put("sid", splitInfo.getId()); |
|
|
paramForSplitInventory.put("sid", splitInfo.getId()); |
|
|
paramForSplitInventory.put("iid", inventory.getId()); |
|
|
paramForSplitInventory.put("iid", materialAndPlace.getId()); |
|
|
SplitInventory splitInventoryForSplitInfo = splitUnitMapper.findSplitInventoryByIidAndSid(paramForSplitInventory); |
|
|
SplitInventory splitInventoryForSplitInfo = splitUnitMapper.findSplitInventoryByIidAndSid(paramForSplitInventory); |
|
|
// 获取当前拆单记录与实际出库拆单之间的进制
|
|
|
// 获取当前拆单记录与实际出库拆单之间的进制
|
|
|
int parentScale = splitUnitService.findSplitInfoScaleQuantity(realSplitInfo, splitInfo.getId()); |
|
|
int parentScale = splitUnitService.findSplitInfoScaleQuantity(realSplitInfo, splitInfo.getId()); |
|
|
@ -1268,7 +1307,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
// 如果当前库存拆单记录的库存不能满足需要
|
|
|
// 如果当前库存拆单记录的库存不能满足需要
|
|
|
|
|
|
|
|
|
// 获取当前物料的库存
|
|
|
// 获取当前物料的库存
|
|
|
int allInventoryForSplitInfo = splitUnitService.findAllInventoryForSplitInfo(-1, inventory, realSplitInfo.getId(), 0, true); |
|
|
|
|
|
|
|
|
int allInventoryForSplitInfo = splitUnitService.findAllInventoryForSplitInfo(-1, materialAndPlace, realSplitInfo.getId(), 0, true); |
|
|
// 判断当前所有库存是否可以满足需求
|
|
|
// 判断当前所有库存是否可以满足需求
|
|
|
if (allInventoryForSplitInfo >= nowQuantity) { |
|
|
if (allInventoryForSplitInfo >= nowQuantity) { |
|
|
// 如果当前库存数可以满足需求
|
|
|
// 如果当前库存数可以满足需求
|
|
|
@ -1350,7 +1390,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
// 如果当前还有父级
|
|
|
// 如果当前还有父级
|
|
|
|
|
|
|
|
|
// 进行递归
|
|
|
// 进行递归
|
|
|
RestResponse restResponse1 = updateSplitInventoryInfo(parentSplitInfo, inventory, quantity, nowQuantity, splitInfo); |
|
|
RestResponse restResponse1 = updateOutSplitInventoryInfo(parentSplitInfo, materialAndPlace, quantity, nowQuantity, splitInfo); |
|
|
// 获取其父级减少与实际出库的拆单记录的数量
|
|
|
// 获取其父级减少与实际出库的拆单记录的数量
|
|
|
Object data = restResponse1.getData(); |
|
|
Object data = restResponse1.getData(); |
|
|
// 计算当前与最底层的进制
|
|
|
// 计算当前与最底层的进制
|
|
|
@ -1391,7 +1431,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
// 获取当前拆单单位与顶级之间的进制
|
|
|
// 获取当前拆单单位与顶级之间的进制
|
|
|
int splitInfoQuantity = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1); |
|
|
int splitInfoQuantity = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1); |
|
|
// 获取所有当前单位的拆单库存
|
|
|
// 获取所有当前单位的拆单库存
|
|
|
realQuantity = inventory.getQuantity() * splitInfoQuantity + realQuantity; |
|
|
realQuantity = materialAndPlace.getQuantity() * splitInfoQuantity + realQuantity; |
|
|
if (realQuantity > nowQuantity) { |
|
|
if (realQuantity > nowQuantity) { |
|
|
// 如果可以出库
|
|
|
// 如果可以出库
|
|
|
|
|
|
|
|
|
@ -1401,13 +1441,17 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
// 计算库存需要减少的数量
|
|
|
// 计算库存需要减少的数量
|
|
|
int inventory_quantity = (int) Math.ceil((double) residue_quantity / splitInfoQuantity); |
|
|
int inventory_quantity = (int) Math.ceil((double) residue_quantity / splitInfoQuantity); |
|
|
|
|
|
|
|
|
|
|
|
// 获取对应的库存
|
|
|
|
|
|
Inventory inventory = materialMapper.findInventoryById(materialAndPlace.getMid()); |
|
|
|
|
|
|
|
|
// 重新设置库存数量
|
|
|
// 重新设置库存数量
|
|
|
|
|
|
materialAndPlace.setQuantity(materialAndPlace.getQuantity() - inventory_quantity); |
|
|
inventory.setQuantity(inventory.getQuantity() - inventory_quantity); |
|
|
inventory.setQuantity(inventory.getQuantity() - inventory_quantity); |
|
|
|
|
|
|
|
|
// 重新设置总额
|
|
|
// 重新设置总额
|
|
|
inventory.setAmounts(inventory.getAmounts() - inventory_quantity * inventory.getPrice()); |
|
|
inventory.setAmounts(inventory.getAmounts() - inventory_quantity * inventory.getPrice()); |
|
|
|
|
|
|
|
|
if (Integer.compare(inventory.getQuantity(), 0) != 0) { |
|
|
if (Integer.compare(materialAndPlace.getQuantity(), 0) != 0) { |
|
|
// 重新计算单价
|
|
|
// 重新计算单价
|
|
|
BigDecimal decimal = BigDecimal.valueOf(inventory.getAmounts() / inventory.getQuantity()); |
|
|
BigDecimal decimal = BigDecimal.valueOf(inventory.getAmounts() / inventory.getQuantity()); |
|
|
Double price = decimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
Double price = decimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
@ -1415,6 +1459,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
} |
|
|
} |
|
|
// 修改库存数量
|
|
|
// 修改库存数量
|
|
|
materialMapper.updateInventory(inventory); |
|
|
materialMapper.updateInventory(inventory); |
|
|
|
|
|
placeMapper.updateMaterialAndPlace(materialAndPlace); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
@ -1434,7 +1479,11 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
// 计算库存减少的数目
|
|
|
// 计算库存减少的数目
|
|
|
int surplus_redundant = (int) Math.ceil(nowQuantity / splitInfoScaleQuantityForAll); |
|
|
int surplus_redundant = (int) Math.ceil(nowQuantity / splitInfoScaleQuantityForAll); |
|
|
|
|
|
|
|
|
|
|
|
// 获取对应的库存
|
|
|
|
|
|
Inventory inventory = materialMapper.findInventoryById(materialAndPlace.getMid()); |
|
|
|
|
|
|
|
|
// 设置当前库存数量
|
|
|
// 设置当前库存数量
|
|
|
|
|
|
materialAndPlace.setQuantity(materialAndPlace.getQuantity() - surplus_redundant); |
|
|
inventory.setQuantity(inventory.getQuantity() - surplus_redundant); |
|
|
inventory.setQuantity(inventory.getQuantity() - surplus_redundant); |
|
|
// 设置当前总额
|
|
|
// 设置当前总额
|
|
|
inventory.setAmounts(inventory.getPrice() * inventory.getQuantity()); |
|
|
inventory.setAmounts(inventory.getPrice() * inventory.getQuantity()); |
|
|
@ -1446,6 +1495,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
} |
|
|
} |
|
|
// 修改库存数量
|
|
|
// 修改库存数量
|
|
|
materialMapper.updateInventory(inventory); |
|
|
materialMapper.updateInventory(inventory); |
|
|
|
|
|
placeMapper.updateMaterialAndPlace(materialAndPlace); |
|
|
|
|
|
|
|
|
restResponse.setData(surplus_redundant); |
|
|
restResponse.setData(surplus_redundant); |
|
|
} |
|
|
} |
|
|
@ -2349,69 +2399,386 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
// 获取子订单
|
|
|
// 获取子订单
|
|
|
ApplicationOutRecordMin recordMin = depositoryRecordMapper.findApplicationOutMinById(minRecordId); |
|
|
ApplicationOutRecordMin recordMin = depositoryRecordMapper.findApplicationOutMinById(minRecordId); |
|
|
// 获取转移详情
|
|
|
// 获取转移详情
|
|
|
TransferRecord transferRecor = transferRecordMapper.findTransferRecordById(recordMin.getTransferId()); |
|
|
TransferRecord transferRecord = transferRecordMapper.findTransferRecordById(recordMin.getTransferId()); |
|
|
Integer mid = transferRecor.getMid(); |
|
|
Integer mid = transferRecord.getMid(); |
|
|
// 获取库存信息
|
|
|
// 获取转出时库存信息
|
|
|
Inventory material = materialMapper.findInventoryById(mid); |
|
|
Inventory material = materialMapper.findInventoryById(mid); |
|
|
|
|
|
|
|
|
param.put("mcode", material.getCode()); |
|
|
param.put("mcode", material.getCode()); |
|
|
param.put("depositoryId", transferRecor.getToId()); |
|
|
param.put("depositoryId", transferRecord.getToId()); |
|
|
List<Inventory> materiallist = materialMapper.findInventory(param); |
|
|
List<Inventory> inventories = materialMapper.findInventory(param); |
|
|
if (materiallist.size() > 0) { |
|
|
// 获取当前处理的单位
|
|
|
// 如果在该仓库
|
|
|
String unit = recordMin.getUnit(); |
|
|
map.put("price", material.getPrice().toString()); |
|
|
map.put("mid", material.getMid()); |
|
|
map.put("depositoryId", transferRecor.getToId()); |
|
|
map.put("depositoryId", transferRecord.getToId()); |
|
|
map.put("placeId", transferRecor.getToPlaceId()); |
|
|
map.put("placeId", transferRecord.getToPlaceId()); |
|
|
map.put("mid", material.getMid()); |
|
|
if ("-1".equals(unit)) { |
|
|
applicationInPlace(map); |
|
|
// 如果是基础单位
|
|
|
} else { |
|
|
|
|
|
// 如果不在该仓库,插入一条新记录
|
|
|
if (inventories.size() > 0) { |
|
|
Map<String, Object> insert = new HashMap<>(); |
|
|
// 如果在该仓库
|
|
|
Material materialById = materialMapper.findMaterialById(material.getMid()); |
|
|
|
|
|
|
|
|
map.put("price", material.getPrice().toString()); |
|
|
|
|
|
applicationInPlace(map); |
|
|
|
|
|
} else { |
|
|
|
|
|
// 如果不在该仓库,插入一条新记录
|
|
|
|
|
|
Map<String, Object> insert = new HashMap<>(); |
|
|
|
|
|
Integer quantity = ObjectFormatUtil.toInteger(map.get("quantity")); |
|
|
|
|
|
insert.put("depositoryId", transferRecord.getToId()); |
|
|
|
|
|
insert.put("price", material.getPrice()); |
|
|
|
|
|
insert.put("mid", material.getMid()); |
|
|
|
|
|
insert.put("quantity", quantity); |
|
|
|
|
|
insert.put("amounts", quantity * material.getPrice()); |
|
|
|
|
|
insert.put("depositoryCode", material.getDepositoryCode()); |
|
|
|
|
|
insert.put("producedDate", material.getProducedDate()); |
|
|
|
|
|
materialMapper.insertInventory(insert); |
|
|
|
|
|
|
|
|
|
|
|
// 查询该记录
|
|
|
|
|
|
// 获取该库存记录
|
|
|
|
|
|
Inventory inventory = materialMapper.findInventoryById(ObjectFormatUtil.toInteger(insert.get("id"))); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> fromPlaceTemp = new HashMap<>(); |
|
|
|
|
|
Map<String, Object> toPlaceTemp = new HashMap<>(); |
|
|
|
|
|
// 转入库位
|
|
|
|
|
|
Place toPlace = placeMapper.findPlaceById(transferRecord.getToPlaceId()); |
|
|
|
|
|
toPlace.setQuantity(toPlace.getQuantity() + quantity); |
|
|
|
|
|
placeMapper.UpdatePlace(toPlace); // 修改转入库位额度
|
|
|
|
|
|
|
|
|
|
|
|
toPlaceTemp.put("mid", inventory.getId()); |
|
|
|
|
|
toPlaceTemp.put("pid", toPlace.getId()); |
|
|
|
|
|
toPlaceTemp.put("quantity", quantity); |
|
|
|
|
|
// 获取转入物料具体所在库位
|
|
|
|
|
|
MaterialAndPlace toMaterialAndPlace = placeMapper.findPlaceAndMaterialByMidAndPid(toPlaceTemp); |
|
|
|
|
|
if (toMaterialAndPlace == null) { |
|
|
|
|
|
placeMapper.addMaterialOnPlace(toPlaceTemp); |
|
|
|
|
|
} else { |
|
|
|
|
|
toMaterialAndPlace.setQuantity(toMaterialAndPlace.getQuantity() + quantity); |
|
|
|
|
|
placeMapper.updateMaterialAndPlace(toMaterialAndPlace); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
// 如果是拆单单位
|
|
|
|
|
|
|
|
|
|
|
|
// 用于获取当前拆单记录
|
|
|
|
|
|
Map<String, Object> paramForSplitInfo = new HashMap<>(); |
|
|
|
|
|
paramForSplitInfo.put("mid", material.getMid()); |
|
|
|
|
|
paramForSplitInfo.put("newUnit", unit); |
|
|
|
|
|
// 获取当前拆单记录
|
|
|
|
|
|
SplitInfo splitInfo = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo); |
|
|
|
|
|
|
|
|
|
|
|
// 获取当前拆单与顶级之间的进制
|
|
|
|
|
|
int scaleQuantity = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1); |
|
|
|
|
|
// 获取当前转移的数量
|
|
|
Integer quantity = ObjectFormatUtil.toInteger(map.get("quantity")); |
|
|
Integer quantity = ObjectFormatUtil.toInteger(map.get("quantity")); |
|
|
insert.put("depositoryId", transferRecor.getToId()); |
|
|
|
|
|
insert.put("price", material.getPrice()); |
|
|
|
|
|
insert.put("mid", materialById.getId()); |
|
|
|
|
|
insert.put("quantity", quantity); |
|
|
|
|
|
insert.put("amounts", quantity * material.getPrice()); |
|
|
|
|
|
insert.put("depositoryCode", material.getDepositoryCode()); |
|
|
|
|
|
insert.put("producedDate", material.getProducedDate()); |
|
|
|
|
|
materialMapper.insertInventory(insert); |
|
|
|
|
|
|
|
|
|
|
|
// 查询该记录
|
|
|
if (inventories.size() > 0) { |
|
|
/*Integer id =ObjectFormatUtil.toInteger(insert.get("id")); |
|
|
// 如果在转入的仓库中存在该物料的库存记录
|
|
|
Material byId = materialMapper.findMaterialById(id); |
|
|
|
|
|
*/ |
|
|
// 获取当前库存记录
|
|
|
Map<String, Object> temp = new HashMap<>(); |
|
|
Inventory inventory = inventories.get(0); |
|
|
temp.put("mcode", materialById.getCode()); |
|
|
// 用于查询物料所在库位
|
|
|
temp.put("depositoryId", transferRecor.getToId()); |
|
|
Map<String, Object> paramForInventoryToPlace = new HashMap<>(); |
|
|
temp.put("mname", materialById.getMname()); |
|
|
paramForInventoryToPlace.put("pid", transferRecord.getToPlaceId()); |
|
|
List<Inventory> inventoryList = materialMapper.findInventory(temp); |
|
|
paramForInventoryToPlace.put("mid", inventory.getId()); |
|
|
// 获取该库存记录
|
|
|
// 获取当前物料是否存在于当前库位
|
|
|
Inventory inventory = inventoryList.get(0); |
|
|
MaterialAndPlace placeAndMaterial = placeMapper.findPlaceAndMaterialByMidAndPid(paramForInventoryToPlace); |
|
|
|
|
|
if (placeAndMaterial != null) { |
|
|
Map<String, Object> fromPlaceTemp = new HashMap<>(); |
|
|
// 如果存在于当前库位
|
|
|
Map<String, Object> toPlaceTemp = new HashMap<>(); |
|
|
|
|
|
// 转入库位
|
|
|
// 用于查询当前拆单记录的库存记录
|
|
|
Place toPlace = placeMapper.findPlaceById(transferRecor.getToPlaceId()); |
|
|
Map<String, Object> paramForSplitInventory = new HashMap<>(); |
|
|
toPlace.setQuantity(toPlace.getQuantity() + quantity); |
|
|
paramForSplitInventory.put("sid", splitInfo.getId()); |
|
|
placeMapper.UpdatePlace(toPlace); // 修改转入库位额度
|
|
|
paramForSplitInventory.put("iid", placeAndMaterial.getId()); |
|
|
|
|
|
// 获取当前拆单记录的库存记录
|
|
|
toPlaceTemp.put("mid", inventory.getId()); |
|
|
SplitInventory splitInventory = splitUnitMapper.findSplitInventoryByIidAndSid(paramForSplitInventory); |
|
|
toPlaceTemp.put("pid", toPlace.getId()); |
|
|
if (splitInventory != null) { |
|
|
toPlaceTemp.put("quantity", quantity); |
|
|
// 如果存在该库存记录
|
|
|
// 获取转入物料具体所在库位
|
|
|
if (splitInfo.getQuantity() >= splitInventory.getSaveQuantity() + quantity) { |
|
|
MaterialAndPlace toMaterialAndPlace = placeMapper.findPlaceAndMaterialByMidAndPid(toPlaceTemp); |
|
|
// 如果没达到当前进制数量
|
|
|
if (toMaterialAndPlace == null) { |
|
|
|
|
|
placeMapper.addMaterialOnPlace(toPlaceTemp); |
|
|
// 设置当前转移后的库存数量
|
|
|
|
|
|
splitInventory.setSaveQuantity(splitInventory.getSaveQuantity() + quantity); |
|
|
|
|
|
// 设置当前增加的数量
|
|
|
|
|
|
splitInventory.setInQuantity(splitInventory.getInQuantity() + quantity); |
|
|
|
|
|
// 修改当前拆单库存处理记录
|
|
|
|
|
|
splitUnitMapper.updateSplitInventory(splitInventory); |
|
|
|
|
|
} else { |
|
|
|
|
|
// 如果大于当前进制数量
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 计算处理数量(下取整)
|
|
|
|
|
|
int disposeQuantity = (int) Math.round(Math.floor(quantity / (double) splitInfo.getQuantity())); |
|
|
|
|
|
|
|
|
|
|
|
// 最终存储到拆单处理的数量
|
|
|
|
|
|
double saveQuantity = quantity - disposeQuantity * splitInfo.getQuantity(); |
|
|
|
|
|
|
|
|
|
|
|
// 最终存储数量
|
|
|
|
|
|
int realQuantity = (int) Math.round(saveQuantity) + splitInventory.getSaveQuantity(); |
|
|
|
|
|
|
|
|
|
|
|
if (realQuantity >= splitInfo.getQuantity()) { |
|
|
|
|
|
// 如果当前入库的数量大于拆单规定的进制数量
|
|
|
|
|
|
|
|
|
|
|
|
// 计算要进的数目
|
|
|
|
|
|
int quantity_in = (realQuantity / splitInfo.getQuantity()); |
|
|
|
|
|
// 更新处理数量
|
|
|
|
|
|
disposeQuantity += quantity_in; |
|
|
|
|
|
// 拆单库存实际入库的数量
|
|
|
|
|
|
realQuantity = realQuantity - quantity_in * splitInfo.getQuantity(); |
|
|
|
|
|
} |
|
|
|
|
|
// 设置当前计量单位的库存
|
|
|
|
|
|
splitInventory.setSaveQuantity(realQuantity); |
|
|
|
|
|
// 更新当前数据
|
|
|
|
|
|
splitUnitMapper.updateSplitInventory(splitInventory); |
|
|
|
|
|
if (disposeQuantity != 0) { |
|
|
|
|
|
// 用于更改库存的数量
|
|
|
|
|
|
map.put("quantity", String.valueOf(disposeQuantity)); |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
map.put("quantity", "0"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 进行修改当前拆单库存数量
|
|
|
|
|
|
map.put("newInMid", placeAndMaterial.getId()); |
|
|
|
|
|
map.put("price", material.getPrice() / scaleQuantity); |
|
|
|
|
|
|
|
|
|
|
|
// 实际入库数量
|
|
|
|
|
|
map.put("realQuantity", quantity.toString()); |
|
|
|
|
|
if (splitInfo.getParentId() != null) { |
|
|
|
|
|
SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(splitInfo.getParentId()); |
|
|
|
|
|
splitUnitService.updateSplitInfoSaveQuantity(parentSplitInfo, disposeQuantity, placeAndMaterial.getId(), map, quantity, splitInfo); |
|
|
|
|
|
} else { |
|
|
|
|
|
applicationInPlace(map); |
|
|
|
|
|
map.remove("id"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
// 如果不存在该库存记录
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 用于插入拆单库存记录
|
|
|
|
|
|
Map<String, Object> insertForSplitInventory = new HashMap<>(); |
|
|
|
|
|
insertForSplitInventory.put("iid", placeAndMaterial.getId()); |
|
|
|
|
|
insertForSplitInventory.put("sid", splitInfo.getId()); |
|
|
|
|
|
insertForSplitInventory.put("outQuantity", 0); |
|
|
|
|
|
|
|
|
|
|
|
if (quantity < splitInfo.getQuantity()) { |
|
|
|
|
|
// 如果当前转移数量小于进制数量
|
|
|
|
|
|
|
|
|
|
|
|
// 设置入库数量
|
|
|
|
|
|
insertForSplitInventory.put("inQuantity", quantity); |
|
|
|
|
|
// 设置当前库存数
|
|
|
|
|
|
insertForSplitInventory.put("saveQuantity", quantity); |
|
|
|
|
|
splitUnitMapper.addSplitInventory(insertForSplitInventory); |
|
|
|
|
|
} else { |
|
|
|
|
|
// 如果不小于
|
|
|
|
|
|
|
|
|
|
|
|
// 计算处理数量(下取整)
|
|
|
|
|
|
int disposeQuantity = (int) Math.round(Math.floor(quantity / (double) splitInfo.getQuantity())); |
|
|
|
|
|
|
|
|
|
|
|
// 最终存储到拆单处理的数量
|
|
|
|
|
|
double saveQuantity = quantity - disposeQuantity * splitInfo.getQuantity(); |
|
|
|
|
|
|
|
|
|
|
|
// 最终存储数量
|
|
|
|
|
|
int realQuantity = (int) Math.round(saveQuantity); |
|
|
|
|
|
|
|
|
|
|
|
if (realQuantity >= splitInfo.getQuantity()) { |
|
|
|
|
|
// 如果当前入库的数量大于拆单规定的进制数量
|
|
|
|
|
|
|
|
|
|
|
|
// 计算要进的数目
|
|
|
|
|
|
int quantity_in = (realQuantity / splitInfo.getQuantity()); |
|
|
|
|
|
// 更新处理数量
|
|
|
|
|
|
disposeQuantity += quantity_in; |
|
|
|
|
|
// 拆单库存实际入库的数量
|
|
|
|
|
|
realQuantity = realQuantity - quantity_in * splitInfo.getQuantity(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 设置入库数量
|
|
|
|
|
|
insertForSplitInventory.put("inQuantity", 0); |
|
|
|
|
|
// 设置当前计量单位的库存
|
|
|
|
|
|
insertForSplitInventory.put("saveQuantity", realQuantity); |
|
|
|
|
|
|
|
|
|
|
|
// 先添加一条拆单库存记录
|
|
|
|
|
|
splitUnitMapper.addSplitInventory(insertForSplitInventory); |
|
|
|
|
|
|
|
|
|
|
|
if (disposeQuantity != 0) { |
|
|
|
|
|
// 用于更改库存的数量
|
|
|
|
|
|
map.put("quantity", String.valueOf(disposeQuantity)); |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
map.put("quantity", "0"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 进行修改当前拆单库存数量
|
|
|
|
|
|
map.put("newInMid", placeAndMaterial.getId()); |
|
|
|
|
|
map.put("price", material.getPrice() / scaleQuantity); |
|
|
|
|
|
|
|
|
|
|
|
// 实际入库数量
|
|
|
|
|
|
map.put("realQuantity", quantity.toString()); |
|
|
|
|
|
if (splitInfo.getParentId() != null) { |
|
|
|
|
|
SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(splitInfo.getParentId()); |
|
|
|
|
|
splitUnitService.updateSplitInfoSaveQuantity(parentSplitInfo, disposeQuantity, placeAndMaterial.getId(), map, quantity, splitInfo); |
|
|
|
|
|
} else { |
|
|
|
|
|
applicationInPlace(map); |
|
|
|
|
|
map.remove("id"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
// 如果不存在于当前库位
|
|
|
|
|
|
|
|
|
|
|
|
// 用于添加一条物料于库位的对应关系
|
|
|
|
|
|
Map<String, Object> insertForMaterialAndPlace = new HashMap<>(); |
|
|
|
|
|
insertForMaterialAndPlace.put("mid", inventory.getId()); |
|
|
|
|
|
insertForMaterialAndPlace.put("pid", transferRecord.getToPlaceId()); |
|
|
|
|
|
insertForMaterialAndPlace.put("quantity", 0); |
|
|
|
|
|
// 先添加一条记录
|
|
|
|
|
|
placeMapper.addMaterialOnPlace(insertForMaterialAndPlace); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 用于插入拆单库存记录
|
|
|
|
|
|
Map<String, Object> insertForSplitInventory = new HashMap<>(); |
|
|
|
|
|
insertForSplitInventory.put("iid", insertForMaterialAndPlace.get("id")); |
|
|
|
|
|
insertForSplitInventory.put("sid", splitInfo.getId()); |
|
|
|
|
|
insertForSplitInventory.put("outQuantity", 0); |
|
|
|
|
|
|
|
|
|
|
|
if (quantity < splitInfo.getQuantity()) { |
|
|
|
|
|
// 如果当前转移数量小于进制数量
|
|
|
|
|
|
|
|
|
|
|
|
// 设置入库数量
|
|
|
|
|
|
insertForSplitInventory.put("inQuantity", quantity); |
|
|
|
|
|
// 设置当前库存数
|
|
|
|
|
|
insertForSplitInventory.put("saveQuantity", quantity); |
|
|
|
|
|
splitUnitMapper.addSplitInventory(insertForSplitInventory); |
|
|
|
|
|
} else { |
|
|
|
|
|
// 如果不小于
|
|
|
|
|
|
|
|
|
|
|
|
map.put("price", material.getPrice() / scaleQuantity); |
|
|
|
|
|
updateSplitInventoryForMoreScale(material, map, splitInfo, quantity, insertForMaterialAndPlace, insertForSplitInventory); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
toMaterialAndPlace.setQuantity(toMaterialAndPlace.getQuantity() + quantity); |
|
|
// 如果在转入的仓库中不存在该物料的库存记录
|
|
|
placeMapper.updateMaterialAndPlace(toMaterialAndPlace); |
|
|
|
|
|
|
|
|
// 用于添加一条库存记录
|
|
|
|
|
|
Map<String, Object> insertForInventory = new HashMap<>(); |
|
|
|
|
|
insertForInventory.put("depositoryId", transferRecord.getToId()); |
|
|
|
|
|
insertForInventory.put("price", material.getPrice()); |
|
|
|
|
|
insertForInventory.put("mid", material.getMid()); |
|
|
|
|
|
insertForInventory.put("quantity", 0); |
|
|
|
|
|
insertForInventory.put("amounts", 0); |
|
|
|
|
|
insertForInventory.put("depositoryCode", material.getDepositoryCode()); |
|
|
|
|
|
insertForInventory.put("producedDate", material.getProducedDate()); |
|
|
|
|
|
// 添加一条库存记录
|
|
|
|
|
|
materialMapper.insertInventory(insertForInventory); |
|
|
|
|
|
|
|
|
|
|
|
// 用于添加物料与库位的对应关系
|
|
|
|
|
|
Map<String, Object> insertForMaterialAndPlace = new HashMap<>(); |
|
|
|
|
|
insertForMaterialAndPlace.put("mid", insertForInventory.get("id")); |
|
|
|
|
|
insertForMaterialAndPlace.put("pid", transferRecord.getToPlaceId()); |
|
|
|
|
|
insertForMaterialAndPlace.put("quantity", 0); |
|
|
|
|
|
|
|
|
|
|
|
// 添加一条物料与库位的对应关系记录
|
|
|
|
|
|
placeMapper.addMaterialOnPlace(insertForMaterialAndPlace); |
|
|
|
|
|
|
|
|
|
|
|
// 用于插入拆单库存记录
|
|
|
|
|
|
Map<String, Object> insertForSplitInventory = new HashMap<>(); |
|
|
|
|
|
insertForSplitInventory.put("iid", insertForMaterialAndPlace.get("id")); |
|
|
|
|
|
insertForSplitInventory.put("sid", splitInfo.getId()); |
|
|
|
|
|
insertForSplitInventory.put("outQuantity", 0); |
|
|
|
|
|
|
|
|
|
|
|
if (quantity < splitInfo.getQuantity()) { |
|
|
|
|
|
// 如果当前转移数量小于进制数量
|
|
|
|
|
|
|
|
|
|
|
|
// 设置入库数量
|
|
|
|
|
|
insertForSplitInventory.put("inQuantity", quantity); |
|
|
|
|
|
// 设置当前库存数
|
|
|
|
|
|
insertForSplitInventory.put("saveQuantity", quantity); |
|
|
|
|
|
splitUnitMapper.addSplitInventory(insertForSplitInventory); |
|
|
|
|
|
} else { |
|
|
|
|
|
// 如果不小于
|
|
|
|
|
|
map.put("price", material.getPrice() / scaleQuantity); |
|
|
|
|
|
updateSplitInventoryForMoreScale(material, map, splitInfo, quantity, insertForMaterialAndPlace, insertForSplitInventory); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 用于处理超出进制的拆单库存处理记录 |
|
|
|
|
|
* |
|
|
|
|
|
* @param material 转移的物料 |
|
|
|
|
|
* @param map 存储的部分数据 |
|
|
|
|
|
* @param splitInfo 当前拆单记录 |
|
|
|
|
|
* @param quantity 超出的数量 |
|
|
|
|
|
* @param insertForMaterialAndPlace 用于添加物料与库位对应关系的数据 |
|
|
|
|
|
* @param insertForSplitInventory 用于添加一条新的拆单库存处理记录 |
|
|
|
|
|
*/ |
|
|
|
|
|
void updateSplitInventoryForMoreScale(Inventory material, Map<String, Object> map, SplitInfo splitInfo, Integer quantity, Map<String, Object> insertForMaterialAndPlace, Map<String, Object> insertForSplitInventory) { |
|
|
|
|
|
|
|
|
|
|
|
// 计算处理数量(下取整)
|
|
|
|
|
|
int disposeQuantity = (int) Math.round(Math.floor(quantity / (double) splitInfo.getQuantity())); |
|
|
|
|
|
|
|
|
|
|
|
// 最终存储到拆单处理的数量
|
|
|
|
|
|
double saveQuantity = quantity - disposeQuantity * splitInfo.getQuantity(); |
|
|
|
|
|
|
|
|
|
|
|
// 最终存储数量
|
|
|
|
|
|
int realQuantity = (int) Math.round(saveQuantity); |
|
|
|
|
|
|
|
|
|
|
|
if (realQuantity >= splitInfo.getQuantity()) { |
|
|
|
|
|
// 如果当前入库的数量大于拆单规定的进制数量
|
|
|
|
|
|
|
|
|
|
|
|
// 计算要进的数目
|
|
|
|
|
|
int quantity_in = (realQuantity / splitInfo.getQuantity()); |
|
|
|
|
|
// 更新处理数量
|
|
|
|
|
|
disposeQuantity += quantity_in; |
|
|
|
|
|
// 拆单库存实际入库的数量
|
|
|
|
|
|
realQuantity = realQuantity - quantity_in * splitInfo.getQuantity(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 设置入库数量
|
|
|
|
|
|
insertForSplitInventory.put("inQuantity", 0); |
|
|
|
|
|
// 设置当前计量单位的库存
|
|
|
|
|
|
insertForSplitInventory.put("saveQuantity", realQuantity); |
|
|
|
|
|
|
|
|
|
|
|
// 先添加一条拆单库存记录
|
|
|
|
|
|
splitUnitMapper.addSplitInventory(insertForSplitInventory); |
|
|
|
|
|
|
|
|
|
|
|
if (disposeQuantity != 0) { |
|
|
|
|
|
// 用于更改库存的数量
|
|
|
|
|
|
map.put("quantity", String.valueOf(disposeQuantity)); |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
map.put("quantity", "0"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 进行修改当前拆单库存数量
|
|
|
|
|
|
map.put("newInMid", insertForMaterialAndPlace.get("id")); |
|
|
|
|
|
|
|
|
|
|
|
// 实际入库数量
|
|
|
|
|
|
map.put("realQuantity", quantity.toString()); |
|
|
|
|
|
if (splitInfo.getParentId() != null) { |
|
|
|
|
|
SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(splitInfo.getParentId()); |
|
|
|
|
|
splitUnitService.updateSplitInfoSaveQuantity(parentSplitInfo, disposeQuantity, ObjectFormatUtil.toInteger(insertForMaterialAndPlace.get("id")), map, quantity, splitInfo); |
|
|
|
|
|
} else { |
|
|
|
|
|
applicationInPlace(map); |
|
|
|
|
|
map.remove("id"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 根据id修改仓库调度记录 |
|
|
* 根据id修改仓库调度记录 |
|
|
* |
|
|
* |
|
|
|