|
|
@ -2,6 +2,7 @@ package com.dreamchaser.depository_manage.service.impl; |
|
|
|
|
|
|
|
|
import com.dreamchaser.depository_manage.entity.*; |
|
|
import com.dreamchaser.depository_manage.entity.*; |
|
|
import com.dreamchaser.depository_manage.mapper.*; |
|
|
import com.dreamchaser.depository_manage.mapper.*; |
|
|
|
|
|
import com.dreamchaser.depository_manage.pojo.RoleAndDepository; |
|
|
import com.dreamchaser.depository_manage.pojo.SplitInfoP; |
|
|
import com.dreamchaser.depository_manage.pojo.SplitInfoP; |
|
|
import com.dreamchaser.depository_manage.service.DepositoryRecordService; |
|
|
import com.dreamchaser.depository_manage.service.DepositoryRecordService; |
|
|
import com.dreamchaser.depository_manage.service.SplitUnitService; |
|
|
import com.dreamchaser.depository_manage.service.SplitUnitService; |
|
|
@ -39,6 +40,10 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
DepositoryRecordMapper depositoryRecordMapper; |
|
|
DepositoryRecordMapper depositoryRecordMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
RoleMapper roleMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 用于添加一条拆单记录 |
|
|
* 用于添加一条拆单记录 |
|
|
* |
|
|
* |
|
|
@ -83,6 +88,15 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
SplitInfo splitInfoForUnit = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo); |
|
|
SplitInfo splitInfoForUnit = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取当前仓库是否有用户进行管理入库审批
|
|
|
|
|
|
List<RoleAndDepository> roleAndDepositoryByCondition = roleMapper.findRoleAndDepositoryByDepositoryIdForIn(ObjectFormatUtil.toInteger(map.get("depositoryId"))); |
|
|
|
|
|
// 用于标志该仓库是否需要进行审批
|
|
|
|
|
|
boolean flagForApproval = false; // 默认不需要
|
|
|
|
|
|
if (roleAndDepositoryByCondition.size() > 0) { |
|
|
|
|
|
flagForApproval = true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 用于存储最终计算结果
|
|
|
// 用于存储最终计算结果
|
|
|
Integer result = 0; |
|
|
Integer result = 0; |
|
|
|
|
|
|
|
|
@ -148,7 +162,35 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
|
|
|
|
|
|
// 获取要操作的数量
|
|
|
// 获取要操作的数量
|
|
|
Double quantity = ObjectFormatUtil.toDouble(map.get("quantity")); |
|
|
Double quantity = ObjectFormatUtil.toDouble(map.get("quantity")); |
|
|
if ("in".equals(type)) { |
|
|
if ("in".equals(type) && !flagForApproval) { |
|
|
|
|
|
// 如果是入库并且不需要审批
|
|
|
|
|
|
result = realInInventoryToDepository(quantity, splitInventory, map, splitInfoForUnit, placeAndMaterialByMidAndPid); |
|
|
|
|
|
map.remove("applicationInId"); |
|
|
|
|
|
}else if("in".equals(type)){ |
|
|
|
|
|
// 如果是入库且需要审批
|
|
|
|
|
|
result = depositoryRecordService.applicationIn(map); |
|
|
|
|
|
map.put("applicationInId",map.get("id")); |
|
|
|
|
|
map.remove("id"); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Integer realInInventoryToDepository(Double quantity, SplitInventory splitInventory, Map<String, Object> map, SplitInfo splitInfoForUnit, MaterialAndPlace placeAndMaterialByMidAndPid) { |
|
|
|
|
|
Integer result = 0; |
|
|
|
|
|
|
|
|
|
|
|
// 获取当前进制
|
|
|
|
|
|
Integer scale = splitInfoForUnit.getQuantity(); |
|
|
|
|
|
|
|
|
|
|
|
// 用于存储拆单库存处理操作的数据
|
|
|
|
|
|
Map<String, Object> paramForInsertSplitInventory = new HashMap<>(); |
|
|
|
|
|
paramForInsertSplitInventory.put("sid", splitInfoForUnit.getId()); |
|
|
|
|
|
|
|
|
// 如果是入库操作
|
|
|
// 如果是入库操作
|
|
|
|
|
|
|
|
|
// 计算处理数量(下取整)
|
|
|
// 计算处理数量(下取整)
|
|
|
@ -199,13 +241,12 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
} else { |
|
|
} else { |
|
|
map.put("price", Double.toString(0)); |
|
|
map.put("price", Double.toString(0)); |
|
|
depositoryRecordService.applicationInPlace(map); |
|
|
depositoryRecordService.applicationInPlace(map); |
|
|
map.put("applicationInId",map.get("id")); |
|
|
map.put("applicationInId", map.get("id")); |
|
|
map.remove("id"); |
|
|
map.remove("id"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} else { |
|
|
else { |
|
|
|
|
|
// 如果没有记录
|
|
|
// 如果没有记录
|
|
|
|
|
|
|
|
|
// 获取当前拆单记录的父级
|
|
|
// 获取当前拆单记录的父级
|
|
|
@ -234,7 +275,7 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
} else { |
|
|
} else { |
|
|
map.put("price", Double.toString(0)); |
|
|
map.put("price", Double.toString(0)); |
|
|
result += depositoryRecordService.applicationInPlace(map); |
|
|
result += depositoryRecordService.applicationInPlace(map); |
|
|
map.put("applicationInId",map.get("id")); |
|
|
map.put("applicationInId", map.get("id")); |
|
|
map.remove("id"); |
|
|
map.remove("id"); |
|
|
Map<String, Object> paramForInventoryToPlace = new HashMap<>(); |
|
|
Map<String, Object> paramForInventoryToPlace = new HashMap<>(); |
|
|
paramForInventoryToPlace.put("mid", map.get("newInMid")); |
|
|
paramForInventoryToPlace.put("mid", map.get("newInMid")); |
|
|
@ -245,11 +286,10 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
} else { |
|
|
} else { |
|
|
map.put("price", Double.toString(0)); |
|
|
map.put("price", Double.toString(0)); |
|
|
result += depositoryRecordService.applicationInPlace(map); |
|
|
result += depositoryRecordService.applicationInPlace(map); |
|
|
map.put("applicationInId",map.get("id")); |
|
|
map.put("applicationInId", map.get("id")); |
|
|
map.remove("id"); |
|
|
map.remove("id"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} else { |
|
|
else { |
|
|
|
|
|
// 如果不大于设置的进制数量
|
|
|
// 如果不大于设置的进制数量
|
|
|
|
|
|
|
|
|
paramForInsertSplitInventory.put("inQuantity", quantity); |
|
|
paramForInsertSplitInventory.put("inQuantity", quantity); |
|
|
@ -272,14 +312,14 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
// 先插入一条库存记录用于后续操作
|
|
|
// 先插入一条库存记录用于后续操作
|
|
|
map.put("quantity", "0"); |
|
|
map.put("quantity", "0"); |
|
|
depositoryRecordService.applicationInPlace(map); |
|
|
depositoryRecordService.applicationInPlace(map); |
|
|
map.put("applicationInId",map.get("id")); |
|
|
map.put("applicationInId", map.get("id")); |
|
|
depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id"))); |
|
|
depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id"))); |
|
|
map.remove("id"); |
|
|
map.remove("id"); |
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
// 如果没有父级
|
|
|
// 如果没有父级
|
|
|
depositoryRecordService.applicationInPlace(map); |
|
|
depositoryRecordService.applicationInPlace(map); |
|
|
map.put("applicationInId",map.get("id")); |
|
|
map.put("applicationInId", map.get("id")); |
|
|
map.remove("id"); |
|
|
map.remove("id"); |
|
|
} |
|
|
} |
|
|
Map<String, Object> paramForInventoryToPlace = new HashMap<>(); |
|
|
Map<String, Object> paramForInventoryToPlace = new HashMap<>(); |
|
|
@ -299,16 +339,10 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
return result; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 用于计算当前拆单单位与目标拆单单位之间的进率 |
|
|
* 用于计算当前拆单单位与目标拆单单位之间的进率 |
|
|
* |
|
|
* |
|
|
@ -417,8 +451,7 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} else { |
|
|
else { |
|
|
|
|
|
// 如果不是获取所有库存
|
|
|
// 如果不是获取所有库存
|
|
|
// 获取当前基础单位
|
|
|
// 获取当前基础单位
|
|
|
SplitInfo baseSplitInfo = splitUnitMapper.findSplitInfoById(baseSplitInfoId); |
|
|
SplitInfo baseSplitInfo = splitUnitMapper.findSplitInfoById(baseSplitInfoId); |
|
|
@ -487,6 +520,7 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 用于查找当前拆单是否正在使用 |
|
|
* 用于查找当前拆单是否正在使用 |
|
|
|
|
|
* |
|
|
* @param sid 待查询id |
|
|
* @param sid 待查询id |
|
|
* @return |
|
|
* @return |
|
|
*/ |
|
|
*/ |
|
|
@ -570,11 +604,10 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
depositoryRecordService.applicationInPlace(map); |
|
|
depositoryRecordService.applicationInPlace(map); |
|
|
// 删除入库订单
|
|
|
// 删除入库订单
|
|
|
// depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id")));
|
|
|
// depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id")));
|
|
|
map.put("applicationInId",map.get("id")); |
|
|
map.put("applicationInId", map.get("id")); |
|
|
map.remove("id"); |
|
|
map.remove("id"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} else { |
|
|
else { |
|
|
|
|
|
// 当前库存拆单记录与新入库的数目不大于预设的进制
|
|
|
// 当前库存拆单记录与新入库的数目不大于预设的进制
|
|
|
splitInventory.setSaveQuantity(splitInventory.getSaveQuantity() + (int) saveQuantity); |
|
|
splitInventory.setSaveQuantity(splitInventory.getSaveQuantity() + (int) saveQuantity); |
|
|
splitInventory.setInQuantity(splitInventory.getInQuantity() + (int) saveQuantity); |
|
|
splitInventory.setInQuantity(splitInventory.getInQuantity() + (int) saveQuantity); |
|
|
@ -587,11 +620,10 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
depositoryRecordService.applicationInPlace(map); |
|
|
depositoryRecordService.applicationInPlace(map); |
|
|
// 删除入库订单
|
|
|
// 删除入库订单
|
|
|
// depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id")));
|
|
|
// depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id")));
|
|
|
map.put("applicationInId",map.get("id")); |
|
|
map.put("applicationInId", map.get("id")); |
|
|
map.remove("id"); |
|
|
map.remove("id"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} else { |
|
|
else { |
|
|
|
|
|
|
|
|
|
|
|
// 如果为空
|
|
|
// 如果为空
|
|
|
Map<String, Object> paramForInsertSplitInventory = new HashMap<>(); |
|
|
Map<String, Object> paramForInsertSplitInventory = new HashMap<>(); |
|
|
@ -617,15 +649,14 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(parentId); |
|
|
SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(parentId); |
|
|
|
|
|
|
|
|
updateSplitInfoSaveQuantity(parentSplitInfo, quantity_scale, iid, map, inQuantity, baseSplitInfo); |
|
|
updateSplitInfoSaveQuantity(parentSplitInfo, quantity_scale, iid, map, inQuantity, baseSplitInfo); |
|
|
} |
|
|
} else { |
|
|
else { |
|
|
|
|
|
map.put("price", Double.toString(0)); |
|
|
map.put("price", Double.toString(0)); |
|
|
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)); |
|
|
depositoryRecordService.applicationInPlace(map); |
|
|
depositoryRecordService.applicationInPlace(map); |
|
|
// 删除入库订单
|
|
|
// 删除入库订单
|
|
|
// depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id")));
|
|
|
// depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id")));
|
|
|
map.put("applicationInId",map.get("id")); |
|
|
map.put("applicationInId", map.get("id")); |
|
|
map.remove("id"); |
|
|
map.remove("id"); |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
@ -638,7 +669,7 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
depositoryRecordService.applicationInPlace(map); |
|
|
depositoryRecordService.applicationInPlace(map); |
|
|
// 删除入库订单
|
|
|
// 删除入库订单
|
|
|
// depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id")));
|
|
|
// depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(map.get("id")));
|
|
|
map.put("applicationInId",map.get("id")); |
|
|
map.put("applicationInId", map.get("id")); |
|
|
map.remove("id"); |
|
|
map.remove("id"); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|