|
|
|
@ -46,6 +46,7 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 用于添加一条拆单记录 |
|
|
|
* |
|
|
|
* @param map 待添加数据 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@ -56,7 +57,7 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
|
// 获取物料id
|
|
|
|
paramForUnit.put("mid", map.get("mid")); |
|
|
|
// 获取拆单前的计量单位
|
|
|
|
paramForUnit.put("oldUnit",map.get("oldUnit")); |
|
|
|
paramForUnit.put("newUnit", map.get("oldUnit")); |
|
|
|
// 查询当前要拆单的记录是否已经是拆单过的
|
|
|
|
SplitInfo splitInfoForUnit = splitUnitMapper.findSplitInfoByMidAndUnit(paramForUnit); |
|
|
|
if (splitInfoForUnit != null) { |
|
|
|
@ -73,6 +74,7 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 用于添加一条拆单库存处理记录 |
|
|
|
* |
|
|
|
* @param map 待添加数据 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@ -86,9 +88,15 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
|
// 查询当前拆单是否存在
|
|
|
|
SplitInfo splitInfoForUnit = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo); |
|
|
|
|
|
|
|
|
|
|
|
// 用于存储最终计算结果
|
|
|
|
Integer result = 0; |
|
|
|
if (splitInfoForUnit != null) { |
|
|
|
|
|
|
|
// 获取当前进制
|
|
|
|
// Integer scale = findSplitInfoQuantity(splitInfoForUnit);
|
|
|
|
Integer scale = findSplitInfoQuantity(splitInfoForUnit); |
|
|
|
|
|
|
|
// 获取当前处理的类型
|
|
|
|
String type = (String) map.get("type"); |
|
|
|
|
|
|
|
@ -108,8 +116,9 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
|
splitInventory = splitUnitMapper.findSplitInventoryByIidAndSid(paramForInsertSplitInventory); |
|
|
|
// 获取对应的库存记录
|
|
|
|
inventory = materialMapper.findInventoryById(iid); |
|
|
|
} |
|
|
|
else{ |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
|
param.put("depositoryId", map.get("depositoryId")); |
|
|
|
param.put("mid", map.get("mid")); |
|
|
|
@ -131,27 +140,26 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
|
// 如果是入库操作
|
|
|
|
|
|
|
|
// 计算处理数量(下取整)
|
|
|
|
int disposeQuantity = (int) Math.round(Math.floor(quantity / splitInfoForUnit.getQuantity())); |
|
|
|
int disposeQuantity = (int) Math.round(Math.floor(quantity / scale)); |
|
|
|
|
|
|
|
// 最终存储到拆单处理的数量
|
|
|
|
double saveQuantity = quantity - disposeQuantity * splitInfoForUnit.getQuantity(); |
|
|
|
double saveQuantity = quantity - disposeQuantity * scale; |
|
|
|
if (splitInventory != null) { |
|
|
|
// 如果有过记录
|
|
|
|
|
|
|
|
// 最终存储数量
|
|
|
|
int realQuantity = (int) Math.round(saveQuantity) + splitInventory.getSaveQuantity(); |
|
|
|
|
|
|
|
if(realQuantity > splitInfoForUnit.getQuantity()){ |
|
|
|
if (realQuantity > scale) { |
|
|
|
// 如果当前入库的数量大于拆单规定的进制数量
|
|
|
|
int quantity_in = realQuantity - (realQuantity / splitInfoForUnit.getQuantity()); |
|
|
|
int quantity_in = realQuantity - (realQuantity / scale); |
|
|
|
disposeQuantity += quantity_in; |
|
|
|
realQuantity = realQuantity - quantity_in * splitInfoForUnit.getQuantity(); |
|
|
|
realQuantity = realQuantity - quantity_in * scale; |
|
|
|
} |
|
|
|
// 设置当前计量单位的库存
|
|
|
|
splitInventory.setSaveQuantity(realQuantity); |
|
|
|
// 设置当前计量单位的入库数目
|
|
|
|
if (splitInventory.getInQuantity() != null) { |
|
|
|
|
|
|
|
// 如果当前库存不为空
|
|
|
|
splitInventory.setInQuantity((int) Math.round(splitInventory.getInQuantity() + quantity)); |
|
|
|
} else { |
|
|
|
splitInventory.setInQuantity((int) Math.round(quantity)); |
|
|
|
@ -175,8 +183,7 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
|
if (disposeQuantity != 0) { |
|
|
|
// 用于更改库存的数量
|
|
|
|
map.put("quantity", String.valueOf(disposeQuantity)); |
|
|
|
} |
|
|
|
else{ |
|
|
|
} else { |
|
|
|
map.put("quantity", "0"); |
|
|
|
} |
|
|
|
// 实际入库数量
|
|
|
|
@ -191,11 +198,31 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 用于计算当前拆单单位与基础单位之间的进率 |
|
|
|
* |
|
|
|
* @param splitInfo 待查询拆单记录 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private int findSplitInfoQuantity(SplitInfo splitInfo) { |
|
|
|
int quantity = 1; |
|
|
|
quantity *= splitInfo.getQuantity(); |
|
|
|
if (splitInfo.getParentId() != null) { |
|
|
|
SplitInfo splitInfoById = splitUnitMapper.findSplitInfoById(splitInfo.getParentId()); |
|
|
|
return quantity * findSplitInfoQuantity(splitInfoById); |
|
|
|
} else { |
|
|
|
return quantity; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据条件查询对应拆单详细信息 |
|
|
|
* |
|
|
|
* @param map 查询条件 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@ -220,6 +247,7 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据条件查询对应拆单数量 |
|
|
|
* |
|
|
|
* @param map 查询条件 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@ -230,6 +258,7 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据主键删除拆单信息(软删除) |
|
|
|
* |
|
|
|
* @param id 待删除id |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@ -262,6 +291,7 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据主键删除拆单信息(硬删除) |
|
|
|
* |
|
|
|
* @param id 待删除id |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@ -293,6 +323,7 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据条件修改拆单信息 |
|
|
|
* |
|
|
|
* @param map 待修改数据 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@ -304,6 +335,7 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据主键id获取拆单信息 |
|
|
|
* |
|
|
|
* @param id 待查询主键 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@ -314,6 +346,7 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据主键id获取拆单详细信息 |
|
|
|
* |
|
|
|
* @param id 待查询主键 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@ -324,6 +357,7 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据物料id查询对应的拆单记录 |
|
|
|
* |
|
|
|
* @param mid 待查询物料id |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@ -335,6 +369,7 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 通过物料id与拆单前的计量单位获取对应拆单记录 |
|
|
|
* |
|
|
|
* @param map 查询条件 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@ -345,6 +380,7 @@ public class SplitUnitServiceImpl implements SplitUnitService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据库存id获取对应拆单库存处理记录 |
|
|
|
* |
|
|
|
* @param Iid 待查询库存id |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
|