|
|
@ -826,24 +826,80 @@ public class StockTakingServiceImpl implements StockTakingService { |
|
|
// 查找当前拆单记录对应的库存记录
|
|
|
// 查找当前拆单记录对应的库存记录
|
|
|
SplitInventory splitInventory = splitUnitService.findSplitInventoryByIidAndSid(placeAndMaterialByMidAndPid.getId(), splitInfo.getId()); |
|
|
SplitInventory splitInventory = splitUnitService.findSplitInventoryByIidAndSid(placeAndMaterialByMidAndPid.getId(), splitInfo.getId()); |
|
|
|
|
|
|
|
|
if (splitInventory.getSaveQuantity() - inventory > 0) { |
|
|
if(splitInventory != null){ |
|
|
// 如果当前数量没有下溢
|
|
|
// 如果存在拆单记录
|
|
|
|
|
|
|
|
|
// 设置当前拆单库存的数量
|
|
|
if (splitInventory.getSaveQuantity() - inventory > 0) { |
|
|
splitInventory.setSaveQuantity(splitInventory.getSaveQuantity() - inventory); |
|
|
// 如果当前数量没有下溢
|
|
|
// 修改拆单库存
|
|
|
|
|
|
splitUnitMapper.updateSplitInventory(splitInventory); |
|
|
// 设置当前拆单库存的数量
|
|
|
} else { |
|
|
splitInventory.setSaveQuantity(splitInventory.getSaveQuantity() - inventory); |
|
|
// 如果发生下溢
|
|
|
// 修改拆单库存
|
|
|
|
|
|
splitUnitMapper.updateSplitInventory(splitInventory); |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
// 如果发生下溢
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置当前拆单库存的数量
|
|
|
|
|
|
splitInventory.setSaveQuantity(0); |
|
|
|
|
|
// 修改拆单库存
|
|
|
|
|
|
splitUnitMapper.updateSplitInventory(splitInventory); |
|
|
|
|
|
} |
|
|
|
|
|
}else{ |
|
|
|
|
|
// 如果不存在拆单记录
|
|
|
|
|
|
|
|
|
|
|
|
// 获取当前拆单单位对应的库存数
|
|
|
|
|
|
int splitInfoInventory = splitUnitService.findAllInventoryForSplitInfo(-1,placeAndMaterialByMidAndPid,splitInfo.getId(), 0,true); |
|
|
|
|
|
|
|
|
|
|
|
if(Integer.compare(minRecord.getNewInventory(),0) == 0){ |
|
|
|
|
|
// 如果盘点数量为0
|
|
|
|
|
|
placeById.setQuantity(placeById.getQuantity() - placeAndMaterialByMidAndPid.getQuantity()); |
|
|
|
|
|
|
|
|
|
|
|
inventoryById.setQuantity(inventoryById.getQuantity() - placeAndMaterialByMidAndPid.getQuantity()); |
|
|
|
|
|
|
|
|
|
|
|
placeAndMaterialByMidAndPid.setQuantity(0); |
|
|
|
|
|
}else{ |
|
|
|
|
|
// 如果不是0
|
|
|
|
|
|
|
|
|
|
|
|
// 获取当前拆单单位与基础单位之间的进制
|
|
|
|
|
|
int scale = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1); |
|
|
|
|
|
|
|
|
|
|
|
// 获取当前盘点对应基础单位的数量
|
|
|
|
|
|
int residue = (int) Math.ceil(inventory / (double) scale); |
|
|
|
|
|
|
|
|
|
|
|
// 获取剩余数目
|
|
|
|
|
|
int residue_realQuantity = residue * scale - inventory; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 更新库存数量
|
|
|
|
|
|
inventoryById.setQuantity(inventoryById.getQuantity() - residue); |
|
|
|
|
|
|
|
|
|
|
|
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() - residue); |
|
|
|
|
|
|
|
|
|
|
|
placeById.setQuantity(placeById.getQuantity() - residue); |
|
|
|
|
|
|
|
|
|
|
|
// 插入拆单记录
|
|
|
|
|
|
Map<String, Object> insertForSplitInventory = new HashMap<>(); |
|
|
|
|
|
insertForSplitInventory.put("mid", inventoryById.getMid()); |
|
|
|
|
|
insertForSplitInventory.put("mcode", inventoryById.getCode()); |
|
|
|
|
|
insertForSplitInventory.put("price", 0); |
|
|
|
|
|
insertForSplitInventory.put("quantity", residue_realQuantity); |
|
|
|
|
|
insertForSplitInventory.put("unit", unit); |
|
|
|
|
|
insertForSplitInventory.put("depositoryId",mainRecord.getDepositoryId()); |
|
|
|
|
|
insertForSplitInventory.put("placeId", placeAndMaterialByMidAndPid.getPid()); |
|
|
|
|
|
insertForSplitInventory.put("type", "in"); |
|
|
|
|
|
splitUnitService.addSplitInventory(insertForSplitInventory); |
|
|
|
|
|
Integer new_id = ObjectFormatUtil.toInteger(insertForSplitInventory.get("newInMid")); |
|
|
|
|
|
depositoryRecordMapper.deleteApplicationInRecordById(new_id); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置当前拆单库存的数量
|
|
|
|
|
|
splitInventory.setSaveQuantity(0); |
|
|
|
|
|
// 修改拆单库存
|
|
|
|
|
|
splitUnitMapper.updateSplitInventory(splitInventory); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|