Browse Source

修改同一个仓库不同库位之间物料转移功能

lwx_dev
erdanergou 3 years ago
parent
commit
3014071c57
  1. 2
      src/main/java/com/dreamchaser/depository_manage/controller/PageController.java
  2. 37
      src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java
  3. 4
      src/main/resources/templates/pages/depository/table-stock.html

2
src/main/java/com/dreamchaser/depository_manage/controller/PageController.java

@ -514,7 +514,7 @@ public class PageController {
mv.addObject("placeId", place.getId());
}
Inventory inventoryById = materialService.findInventoryById(mid);
if (unit.equals(inventoryById.getUnit())) {
if ("-1".equals(unit)) {
// 如果转移的基础单位
mv.addObject("quantity", placeAndMaterialByMidAndPid.getQuantity());
} else {

37
src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java

@ -1481,6 +1481,9 @@ public class MaterialServiceImpl implements MaterialService {
paramForSplitInventory.put("iid", pidAndMidForBefore.getId());
// 转移之前的拆单库存记录
SplitInventory splitInventoryForBefore = splitUnitMapper.findSplitInventoryByIidAndSid(paramForSplitInventory);
if(splitInventoryForBefore != null) {
//如果存在
// 设置转移前库存的数量
splitInventoryForBefore.setSaveQuantity(splitInventoryForBefore.getSaveQuantity() - quantity);
// 设置转移前的出库数量
@ -1488,6 +1491,37 @@ public class MaterialServiceImpl implements MaterialService {
// 修改转移前的记录
splitUnitMapper.updateSplitInventory(splitInventoryForBefore);
}
else{
// 如果不存在
// 获取当前单位对应的进制
int scale = splitUnitService.findSplitInfoScaleQuantity(splitInfo, -1);
// 计算当前转移数目对应需要减少的数目
int num = (int)Math.ceil(quantity / (double)scale);
// 修改当前库存数量
inventoryByMid.setQuantity(inventoryByMid.getQuantity() - num);
materialMapper.updateInventory(inventoryByMid);
// 修改当前库位对应关系的数目
pidAndMidForBefore.setQuantity(pidAndMidForBefore.getQuantity() - num);
placeService.updateMaterialAndPlace(pidAndMidForBefore);
Map<String,Object> insertForSplitInventory = new HashMap<>();
insertForSplitInventory.put("mid",inventoryByMid.getMid());
insertForSplitInventory.put("mcode",inventoryByMid.getCode());
insertForSplitInventory.put("price",inventoryByMid.getPrice() / scale);
insertForSplitInventory.put("quantity",num * scale - quantity);
insertForSplitInventory.put("unit",unit);
insertForSplitInventory.put("depositoryId",map.get("depositoryId"));
insertForSplitInventory.put("placeId",pidAndMidForBefore.getPid());
insertForSplitInventory.put("type","in");
splitUnitService.addSplitInventory(insertForSplitInventory);
Integer new_id = ObjectFormatUtil.toInteger(insertForSplitInventory.get("newInMid"));
depositoryRecordMapper.deleteApplicationInRecordById(new_id);
}
// 定义进制时算法需要的参数
Map<String, Object> paramForNewMap = new HashMap<>();
@ -1547,7 +1581,8 @@ public class MaterialServiceImpl implements MaterialService {
// 修改库存数量
splitUnitMapper.updateSplitInventory(splitInventoryForAfter);
}
} else {
}
else {
// 如果不存在转移后的拆单库存记录
// 定义用于添加拆单库存记录

4
src/main/resources/templates/pages/depository/table-stock.html

@ -75,7 +75,7 @@
<!-- 用于计量单位的展示-->
<script id="changeUnit" type="text/html">
<button class="layui-btn layui-btn-primary layui-btn-xs" lay-event="changeUnit" click_num="0"
id="btn_{{d.id}}" value="{{d.unit}}">{{d.unit}}
id="btn_{{d.id}}" value="{{d.unit == d.baseUnit ? -1 : d.unit}}">{{d.unit}}
</button>
</script>
@ -414,7 +414,7 @@
// 当前点击行中的计量单位按钮
let unitBtn = obj.parentNode.parentNode.parentNode.childNodes[5].childNodes[0].childNodes[1];
let unit = unitBtn.innerText;
let unit = unitBtn.value;
var index = layer.open({
title: '选择库位',
type: 2,

Loading…
Cancel
Save