Browse Source

修改库存盘点处理功能

lwx_dev
erdanergou 3 years ago
parent
commit
ed8b7eaed8
  1. 9
      src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java
  2. 80
      src/main/java/com/dreamchaser/depository_manage/service/impl/StockTakingServiceImpl.java
  3. 7
      src/test/java/com/dreamchaser/depository_manage/TestForOther.java

9
src/main/java/com/dreamchaser/depository_manage/service/impl/DepositoryRecordServiceImpl.java

@ -1052,7 +1052,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
restResponse.setData("");
restResponse.setStatusInfo(new StatusInfo("出库失败", "出库失败,库存不足"));
}
} else {
}
else {
// 如果是拆单后的出库
// 用于获取对应的拆单记录
@ -1325,7 +1326,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
}
}
} else {
}
else {
// 如果拆单库存处理记录不存在
int scale = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1);
@ -1391,7 +1393,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService {
restResponse.setStatusInfo(new StatusInfo("出库成功", "出库成功"));
} else {
}
else {
restResponse.setStatus(508);
restResponse.setData("");
restResponse.setStatusInfo(new StatusInfo("出库失败", "出库失败,库存不足"));

80
src/main/java/com/dreamchaser/depository_manage/service/impl/StockTakingServiceImpl.java

@ -826,24 +826,80 @@ public class StockTakingServiceImpl implements StockTakingService {
// 查找当前拆单记录对应的库存记录
SplitInventory splitInventory = splitUnitService.findSplitInventoryByIidAndSid(placeAndMaterialByMidAndPid.getId(), splitInfo.getId());
if (splitInventory.getSaveQuantity() - inventory > 0) {
// 如果当前数量没有下溢
if(splitInventory != null){
// 如果存在拆单记录
// 设置当前拆单库存的数量
splitInventory.setSaveQuantity(splitInventory.getSaveQuantity() - inventory);
// 修改拆单库存
splitUnitMapper.updateSplitInventory(splitInventory);
} else {
// 如果发生下溢
if (splitInventory.getSaveQuantity() - inventory > 0) {
// 如果当前数量没有下溢
// 设置当前拆单库存的数量
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);
}
}
}

7
src/test/java/com/dreamchaser/depository_manage/TestForOther.java

@ -25,11 +25,6 @@ public class TestForOther {
@Test
public void run() {
Set<String> keys = redisTemplate.keys("wms_stockTaking_78_20230306*");
if (keys != null) {
for (String key : keys) {
System.out.println(key);
}
}
System.out.println(Math.ceil(8.3));
}
}

Loading…
Cancel
Save