|
|
@ -176,7 +176,7 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
map.put("realQuantity", quantity.toString()); |
|
|
map.put("realQuantity", quantity.toString()); |
|
|
if (splitInfoForUnit.getParentId() != null) { |
|
|
if (splitInfoForUnit.getParentId() != null) { |
|
|
SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(splitInfoForUnit.getParentId()); |
|
|
SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(splitInfoForUnit.getParentId()); |
|
|
updateSplitInfoSaveQuantity(parentSplitInfo, disposeQuantity, inventory.getId(), map, quantity.intValue()); |
|
|
updateSplitInfoSaveQuantity(parentSplitInfo, disposeQuantity, inventory.getId(), map, quantity.intValue(),splitInfoForUnit); |
|
|
} else { |
|
|
} else { |
|
|
Double price = Double.parseDouble((String) map.get("price")); |
|
|
Double price = Double.parseDouble((String) map.get("price")); |
|
|
price = price * findSplitInfoScaleQuantity(splitInfoForUnit, -1); |
|
|
price = price * findSplitInfoScaleQuantity(splitInfoForUnit, -1); |
|
|
@ -210,13 +210,13 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
|
|
|
|
|
|
SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(parentId); |
|
|
SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(parentId); |
|
|
if (inventory != null) { |
|
|
if (inventory != null) { |
|
|
updateSplitInfoSaveQuantity(parentSplitInfo, ObjectFormatUtil.toInteger(String.valueOf(saveQuantity)), inventory.getId(), map, quantity.intValue()); |
|
|
updateSplitInfoSaveQuantity(parentSplitInfo, ObjectFormatUtil.toInteger(String.valueOf(saveQuantity)), inventory.getId(), map, quantity.intValue(),splitInfoForUnit); |
|
|
} else { |
|
|
} else { |
|
|
Double price = Double.parseDouble((String) map.get("price")); |
|
|
Double price = Double.parseDouble((String) map.get("price")); |
|
|
price = price * findSplitInfoScaleQuantity(splitInfoForUnit, -1); |
|
|
price = price * findSplitInfoScaleQuantity(splitInfoForUnit, -1); |
|
|
map.put("price", price.toString()); |
|
|
map.put("price", price.toString()); |
|
|
result += depositoryRecordService.applicationInPlace(map); |
|
|
result += depositoryRecordService.applicationInPlace(map); |
|
|
updateSplitInfoSaveQuantity(parentSplitInfo, ObjectFormatUtil.toInteger(String.valueOf(saveQuantity)), ObjectFormatUtil.toInteger(map.get("newInMid")), map, quantity.intValue()); |
|
|
updateSplitInfoSaveQuantity(parentSplitInfo, ObjectFormatUtil.toInteger(String.valueOf(saveQuantity)), ObjectFormatUtil.toInteger(map.get("newInMid")), map, quantity.intValue(),splitInfoForUnit); |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
Double price = Double.parseDouble((String) map.get("price")); |
|
|
Double price = Double.parseDouble((String) map.get("price")); |
|
|
@ -262,7 +262,7 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
if (parentId != null) { |
|
|
if (parentId != null) { |
|
|
// 获取父级
|
|
|
// 获取父级
|
|
|
SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(splitInfoForUnit.getParentId()); |
|
|
SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(splitInfoForUnit.getParentId()); |
|
|
updateSplitInfoSaveQuantity(parentSplitInfo, disposeQuantity, ObjectFormatUtil.toInteger(map.get("newInMid")), map, quantity.intValue()); |
|
|
updateSplitInfoSaveQuantity(parentSplitInfo, disposeQuantity, ObjectFormatUtil.toInteger(map.get("newInMid")), map, quantity.intValue(),splitInfoForUnit); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -283,17 +283,19 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
*/ |
|
|
*/ |
|
|
public int findSplitInfoScaleQuantity(SplitInfo splitInfo, Integer parentSplitInfoId) { |
|
|
public int findSplitInfoScaleQuantity(SplitInfo splitInfo, Integer parentSplitInfoId) { |
|
|
int quantity = 1; // 定义进制
|
|
|
int quantity = 1; // 定义进制
|
|
|
quantity *= splitInfo.getQuantity(); |
|
|
|
|
|
if (parentSplitInfoId != null && Integer.compare(-1, parentSplitInfoId) != 0) { |
|
|
if (parentSplitInfoId != null && Integer.compare(-1, parentSplitInfoId) != 0) { |
|
|
// 如果待查询的父级不是顶级
|
|
|
// 如果待查询的父级不是顶级
|
|
|
if(Integer.compare(splitInfo.getId(),parentSplitInfoId) == 0){ |
|
|
if (Integer.compare(splitInfo.getParentId(), parentSplitInfoId) == 0) { |
|
|
// 如果当前拆单记录是目标拆单单位
|
|
|
// 如果当前拆单记录是目标拆单单位
|
|
|
|
|
|
quantity *= splitInfo.getQuantity(); |
|
|
|
|
|
|
|
|
return quantity; |
|
|
return quantity; |
|
|
} else { |
|
|
} else { |
|
|
SplitInfo splitInfoById = splitUnitMapper.findSplitInfoById(splitInfo.getParentId()); |
|
|
SplitInfo splitInfoById = splitUnitMapper.findSplitInfoById(splitInfo.getParentId()); |
|
|
return quantity * findSplitInfoScaleQuantity(splitInfoById, parentSplitInfoId); |
|
|
return quantity * findSplitInfoScaleQuantity(splitInfoById, parentSplitInfoId); |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
quantity *= splitInfo.getQuantity(); |
|
|
if (splitInfo.getParentId() != null) { |
|
|
if (splitInfo.getParentId() != null) { |
|
|
SplitInfo splitInfoById = splitUnitMapper.findSplitInfoById(splitInfo.getParentId()); |
|
|
SplitInfo splitInfoById = splitUnitMapper.findSplitInfoById(splitInfo.getParentId()); |
|
|
return quantity * findSplitInfoScaleQuantity(splitInfoById, parentSplitInfoId); |
|
|
return quantity * findSplitInfoScaleQuantity(splitInfoById, parentSplitInfoId); |
|
|
@ -457,9 +459,8 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
* @param map 入库条件 |
|
|
* @param map 入库条件 |
|
|
* @param inQuantity 最终入库数量 |
|
|
* @param inQuantity 最终入库数量 |
|
|
*/ |
|
|
*/ |
|
|
private void updateSplitInfoSaveQuantity(SplitInfo splitInfo, int quantity, int iid, Map<String, Object> map, int inQuantity) { |
|
|
private void updateSplitInfoSaveQuantity(SplitInfo splitInfo, int quantity, int iid, Map<String, Object> map, int inQuantity,SplitInfo baseSplitInfo) { |
|
|
|
|
|
|
|
|
int result = 0; |
|
|
|
|
|
|
|
|
|
|
|
// 获取当前拆单记录的父级拆单记录
|
|
|
// 获取当前拆单记录的父级拆单记录
|
|
|
Integer parentId = splitInfo.getParentId(); |
|
|
Integer parentId = splitInfo.getParentId(); |
|
|
@ -475,14 +476,14 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
int scale = splitInfo.getQuantity(); |
|
|
int scale = splitInfo.getQuantity(); |
|
|
|
|
|
|
|
|
// 计算处理数量(下取整)
|
|
|
// 计算处理数量(下取整)
|
|
|
int disposeQuantity = (int) Math.round(Math.floor(quantity / scale)); |
|
|
int disposeQuantity = (int) Math.round(Math.floor(quantity / (double)scale)); |
|
|
|
|
|
|
|
|
// 最终存储到拆单处理的数量
|
|
|
// 最终存储到拆单处理的数量
|
|
|
double saveQuantity = quantity - disposeQuantity * scale; |
|
|
double saveQuantity = quantity - disposeQuantity * scale; |
|
|
|
|
|
|
|
|
if (splitInventory != null) { |
|
|
if (splitInventory != null) { |
|
|
// 如果拆单库存处理记录不为空
|
|
|
// 如果拆单库存处理记录不为空
|
|
|
if (splitInventory.getSaveQuantity() + saveQuantity > splitInfo.getQuantity()) { |
|
|
if (splitInventory.getSaveQuantity() + saveQuantity >= splitInfo.getQuantity()) { |
|
|
// 当前库存拆单记录与新入库的数目大于预设的进制
|
|
|
// 当前库存拆单记录与新入库的数目大于预设的进制
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -505,25 +506,26 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
// 获取具体父级
|
|
|
// 获取具体父级
|
|
|
SplitInfo splitInfoForParent = splitUnitMapper.findSplitInfoById(parentId); |
|
|
SplitInfo splitInfoForParent = splitUnitMapper.findSplitInfoById(parentId); |
|
|
|
|
|
|
|
|
updateSplitInfoSaveQuantity(splitInfoForParent, disposeQuantity, splitInventory.getIid(), map, inQuantity); |
|
|
updateSplitInfoSaveQuantity(splitInfoForParent, disposeQuantity, splitInventory.getIid(), map, inQuantity,baseSplitInfo); |
|
|
} else { |
|
|
} else { |
|
|
// 如果为空
|
|
|
// 如果为空
|
|
|
Double price = Double.parseDouble((String) map.get("price")); |
|
|
Double price = Double.parseDouble((String) map.get("price")); |
|
|
price = price * findSplitInfoScaleQuantity(splitInfo, -1); |
|
|
price = price * findSplitInfoScaleQuantity(baseSplitInfo, -1); |
|
|
map.put("price", price.toString()); |
|
|
map.put("price", price.toString()); |
|
|
map.put("quantity", String.valueOf(disposeQuantity)); |
|
|
map.put("quantity", String.valueOf(disposeQuantity)); |
|
|
map.put("realQuantity", String.valueOf(inQuantity)); |
|
|
map.put("realQuantity", String.valueOf(inQuantity)); |
|
|
|
|
|
|
|
|
depositoryRecordService.applicationInPlace(map); |
|
|
depositoryRecordService.applicationInPlace(map); |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} |
|
|
|
|
|
else { |
|
|
// 当前库存拆单记录与新入库的数目不大于预设的进制
|
|
|
// 当前库存拆单记录与新入库的数目不大于预设的进制
|
|
|
splitInventory.setSaveQuantity(splitInventory.getSaveQuantity() + disposeQuantity); |
|
|
splitInventory.setSaveQuantity(splitInventory.getSaveQuantity() + (int)saveQuantity); |
|
|
splitInventory.setInQuantity(splitInventory.getInQuantity() + disposeQuantity); |
|
|
splitInventory.setInQuantity(splitInventory.getInQuantity() + (int)saveQuantity); |
|
|
splitUnitMapper.updateSplitInventory(splitInventory); |
|
|
splitUnitMapper.updateSplitInventory(splitInventory); |
|
|
|
|
|
|
|
|
Double price = Double.parseDouble((String) map.get("price")); |
|
|
Double price = Double.parseDouble((String) map.get("price")); |
|
|
price = price * findSplitInfoScaleQuantity(splitInfo, -1); |
|
|
price = price * findSplitInfoScaleQuantity(baseSplitInfo, -1); |
|
|
map.put("price", price.toString()); |
|
|
map.put("price", price.toString()); |
|
|
map.put("quantity", "0"); |
|
|
map.put("quantity", "0"); |
|
|
map.put("realQuantity", String.valueOf(inQuantity)); |
|
|
map.put("realQuantity", String.valueOf(inQuantity)); |
|
|
@ -554,10 +556,10 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
// 获取当前拆单记录的父级
|
|
|
// 获取当前拆单记录的父级
|
|
|
SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(parentId); |
|
|
SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(parentId); |
|
|
|
|
|
|
|
|
updateSplitInfoSaveQuantity(parentSplitInfo, quantity_scale, iid, map, inQuantity); |
|
|
updateSplitInfoSaveQuantity(parentSplitInfo, quantity_scale, iid, map, inQuantity,baseSplitInfo); |
|
|
} else { |
|
|
} else { |
|
|
Double price = Double.parseDouble((String) map.get("price")); |
|
|
Double price = Double.parseDouble((String) map.get("price")); |
|
|
price = price * findSplitInfoScaleQuantity(splitInfo, -1); |
|
|
price = price * findSplitInfoScaleQuantity(baseSplitInfo, -1); |
|
|
map.put("price", price.toString()); |
|
|
map.put("price", price.toString()); |
|
|
map.put("quantity", String.valueOf(quantity_scale)); |
|
|
map.put("quantity", String.valueOf(quantity_scale)); |
|
|
map.put("realQuantity", String.valueOf(inQuantity)); |
|
|
map.put("realQuantity", String.valueOf(inQuantity)); |
|
|
|