fix:获取移库单对应的移入货位时,加上并发锁
This commit is contained in:
@@ -6,6 +6,7 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.SneakyThrows;
|
||||
import org.nl.b_lms.sch.task.dao.SchBaseTask;
|
||||
import org.nl.b_lms.sch.task.service.IschBaseTaskService;
|
||||
import org.nl.b_lms.storage_manage.database.service.IBstIvtBoxinfoService;
|
||||
@@ -16,6 +17,7 @@ import org.nl.b_lms.storage_manage.ios.service.iostorInv.IStIvtIostorinvdtlServi
|
||||
import org.nl.b_lms.storage_manage.ios.service.iostorInv.dao.StIvtIostorinv;
|
||||
import org.nl.b_lms.storage_manage.ios.service.iostorInv.dao.StIvtIostorinvdis;
|
||||
import org.nl.b_lms.storage_manage.ios.service.iostorInv.dao.StIvtIostorinvdtl;
|
||||
import org.nl.b_lms.storage_manage.ios.service.iostorInv.impl.StIvtIostorinvServiceImpl;
|
||||
import org.nl.b_lms.storage_manage.ios.service.iostorInv.util.service.InBussManageService;
|
||||
import org.nl.b_lms.storage_manage.ios.service.iostorInv.util.service.OutBussManageService;
|
||||
import org.nl.b_lms.storage_manage.ios.service.iostorInv.util.service.TwoInBussManageService;
|
||||
@@ -29,6 +31,8 @@ import org.nl.wms.pda.mps.eum.RegionTypeEnum;
|
||||
import org.nl.wms.st.inbill.service.StorPublicService;
|
||||
import org.nl.wms.st.instor.service.HandMoveStorService;
|
||||
import org.nl.wms.st.instor.task.HandMoveStorAcsTask;
|
||||
import org.redisson.api.RLock;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -37,6 +41,7 @@ import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -99,6 +104,9 @@ public class OutBussManageServiceImpl implements OutBussManageService {
|
||||
@Autowired
|
||||
private TwoInBussManageService twoInBussManageService;
|
||||
|
||||
@Autowired
|
||||
private RedissonClient redissonClient;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void lockStruct(List<String> param, JSONObject json) {
|
||||
@@ -175,7 +183,7 @@ public class OutBussManageServiceImpl implements OutBussManageService {
|
||||
updateIvtList.addAll(likeBoxList);
|
||||
|
||||
// 添加生成分配明细
|
||||
List<StIvtIostorinvdis> disDaoList= divDisParam(likeBoxList, dtlDao);
|
||||
List<StIvtIostorinvdis> disDaoList = divDisParam(likeBoxList, dtlDao);
|
||||
resultDisList.addAll(disDaoList);
|
||||
|
||||
}
|
||||
@@ -206,7 +214,7 @@ public class OutBussManageServiceImpl implements OutBussManageService {
|
||||
updateIvtList.addAll(likePcsnBoxList);
|
||||
|
||||
// 添加生成分配明细
|
||||
List<StIvtIostorinvdis> disDaoList= divDisParam(likePcsnBoxList, dtlDao);
|
||||
List<StIvtIostorinvdis> disDaoList = divDisParam(likePcsnBoxList, dtlDao);
|
||||
resultDisList.addAll(disDaoList);
|
||||
|
||||
}
|
||||
@@ -234,12 +242,12 @@ public class OutBussManageServiceImpl implements OutBussManageService {
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add)
|
||||
.doubleValue();
|
||||
|
||||
dtlDao.setAssign_qty(NumberUtil.add(dtlDao.getAssign_qty(),canuse_qty));
|
||||
dtlDao.setAssign_qty(NumberUtil.add(dtlDao.getAssign_qty(), canuse_qty));
|
||||
|
||||
// 减未分配数量
|
||||
dtlDao.setUnassign_qty(NumberUtil.sub(dtlDao.getUnassign_qty(), canuse_qty));
|
||||
|
||||
if (dtlDao.getUnassign_qty().doubleValue() <= 0 ) {
|
||||
if (dtlDao.getUnassign_qty().doubleValue() <= 0) {
|
||||
dtlDao.setUnassign_qty(BigDecimal.valueOf(0));
|
||||
}
|
||||
|
||||
@@ -256,11 +264,12 @@ public class OutBussManageServiceImpl implements OutBussManageService {
|
||||
|
||||
/**
|
||||
* 准备插入分配明细的参数
|
||||
*
|
||||
* @param likeBoxList 相同木箱的库存
|
||||
* @param dtlDao 明细对象
|
||||
* @param dtlDao 明细对象
|
||||
* @return List<StIvtIostorinvdis> 分配明细对象集合
|
||||
*/
|
||||
private List<StIvtIostorinvdis> divDisParam(List<JSONObject> likeBoxList, StIvtIostorinvdtl dtlDao) {
|
||||
private List<StIvtIostorinvdis> divDisParam(List<JSONObject> likeBoxList, StIvtIostorinvdtl dtlDao) {
|
||||
|
||||
List<StIvtIostorinvdis> resultDisList = new ArrayList<>();
|
||||
|
||||
@@ -436,7 +445,7 @@ public class OutBussManageServiceImpl implements OutBussManageService {
|
||||
moveParam.put("height", height);
|
||||
moveParam.put("vehicle_type", boxDao.getVehicle_type());
|
||||
// 移库巷道
|
||||
moveParam.put("move_block_num",json.getString("block_num"));
|
||||
moveParam.put("move_block_num", json.getString("block_num"));
|
||||
|
||||
// TODO JSONObject jsonMove = inBussManageService.getOneStruct(moveParam);
|
||||
JSONObject jsonMove = twoInBussManageService.getOneStruct(moveParam);
|
||||
@@ -474,7 +483,7 @@ public class OutBussManageServiceImpl implements OutBussManageService {
|
||||
JSONObject jsonVeExt = extTab.query("pcsn = '" + json.getString("storagevehicle_code") + "'")
|
||||
.uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(jsonVeExt)) {
|
||||
throw new BadRequestException("此木箱没有绑定托盘号!"+json.getString("storagevehicle_code"));
|
||||
throw new BadRequestException("此木箱没有绑定托盘号!" + json.getString("storagevehicle_code"));
|
||||
}
|
||||
|
||||
// 生成任务
|
||||
@@ -503,35 +512,49 @@ public class OutBussManageServiceImpl implements OutBussManageService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public void createMove2(List<JSONObject> list) {
|
||||
//子卷包装关系表
|
||||
WQLObject subTab = WQLObject.getWQLObject("pdm_bi_subpackagerelation");
|
||||
//物料表
|
||||
WQLObject materTab = WQLObject.getWQLObject("md_me_materialbase");
|
||||
// 获取子卷包装集合
|
||||
String vehilcle_in = list.stream()
|
||||
.map(row -> row.getString("storagevehicle_code"))
|
||||
.collect(Collectors.joining("','"));
|
||||
RLock lock = redissonClient.getLock(StIvtIostorinvServiceImpl.class.getName());
|
||||
boolean tryLock = lock.tryLock(5, TimeUnit.SECONDS);
|
||||
try {
|
||||
if (tryLock) {
|
||||
//子卷包装关系表
|
||||
WQLObject subTab = WQLObject.getWQLObject("pdm_bi_subpackagerelation");
|
||||
//物料表
|
||||
WQLObject materTab = WQLObject.getWQLObject("md_me_materialbase");
|
||||
// 获取子卷包装集合
|
||||
String vehilcle_in = list.stream()
|
||||
.map(row -> row.getString("storagevehicle_code"))
|
||||
.collect(Collectors.joining("','"));
|
||||
|
||||
List<JSONObject> subList = subTab.query("package_box_sn IN ('" + vehilcle_in + "')")
|
||||
.getResultJSONArray(0).toJavaList(JSONObject.class);
|
||||
// 查询物料集合
|
||||
String materialCode_in = subList.stream()
|
||||
.map(row -> row.getString("product_name"))
|
||||
.collect(Collectors.joining("','"));
|
||||
List<JSONObject> materList = materTab.query("material_code IN ('" + materialCode_in + "')")
|
||||
.getResultJSONArray(0).toJavaList(JSONObject.class);
|
||||
OutBussManageService myService = SpringContextHolder.getBean(OutBussManageService.class);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
JSONObject json = list.get(i);
|
||||
myService.createForMove(json,subList,materList);
|
||||
List<JSONObject> subList = subTab.query("package_box_sn IN ('" + vehilcle_in + "')")
|
||||
.getResultJSONArray(0).toJavaList(JSONObject.class);
|
||||
// 查询物料集合
|
||||
String materialCode_in = subList.stream()
|
||||
.map(row -> row.getString("product_name"))
|
||||
.collect(Collectors.joining("','"));
|
||||
List<JSONObject> materList = materTab.query("material_code IN ('" + materialCode_in + "')")
|
||||
.getResultJSONArray(0).toJavaList(JSONObject.class);
|
||||
OutBussManageService myService = SpringContextHolder.getBean(OutBussManageService.class);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
JSONObject json = list.get(i);
|
||||
myService.createForMove(json, subList, materList);
|
||||
}
|
||||
} else {
|
||||
throw new BadRequestException("有单据正在分配中,请稍后在试");
|
||||
}
|
||||
} finally {
|
||||
if (lock.isLocked() && lock.isHeldByCurrentThread()) {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 移库事务处理
|
||||
* @param json 移库仓位个体
|
||||
* @param subList 子卷包装关系集合
|
||||
*
|
||||
* @param json 移库仓位个体
|
||||
* @param subList 子卷包装关系集合
|
||||
* @param materList 物料集合
|
||||
*/
|
||||
@Transactional
|
||||
@@ -588,7 +611,7 @@ public class OutBussManageServiceImpl implements OutBussManageService {
|
||||
moveParam.put("height", height);
|
||||
moveParam.put("vehicle_type", boxDao.getVehicle_type());
|
||||
// 移库巷道
|
||||
moveParam.put("move_block_num",json.getString("block_num"));
|
||||
moveParam.put("move_block_num", json.getString("block_num"));
|
||||
|
||||
// TODO JSONObject jsonMove = inBussManageService.getOneStruct(moveParam);
|
||||
JSONObject jsonMove = twoInBussManageService.getOneStruct(moveParam);
|
||||
@@ -626,7 +649,7 @@ public class OutBussManageServiceImpl implements OutBussManageService {
|
||||
JSONObject jsonVeExt = extTab.query("pcsn = '" + json.getString("storagevehicle_code") + "'")
|
||||
.uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(jsonVeExt)) {
|
||||
throw new BadRequestException("此木箱没有绑定托盘号!"+json.getString("storagevehicle_code"));
|
||||
throw new BadRequestException("此木箱没有绑定托盘号!" + json.getString("storagevehicle_code"));
|
||||
}
|
||||
|
||||
// 生成任务
|
||||
@@ -734,7 +757,7 @@ public class OutBussManageServiceImpl implements OutBussManageService {
|
||||
moveParam.put("height", height);
|
||||
moveParam.put("vehicle_type", boxDao.getVehicle_type());
|
||||
// 移库巷道
|
||||
moveParam.put("move_block_num",json.getString("block_num"));
|
||||
moveParam.put("move_block_num", json.getString("block_num"));
|
||||
|
||||
// TODO JSONObject jsonMove = inBussManageService.getOneStruct(moveParam);
|
||||
JSONObject jsonMove = twoInBussManageService.getOneStruct(moveParam);
|
||||
@@ -772,7 +795,7 @@ public class OutBussManageServiceImpl implements OutBussManageService {
|
||||
JSONObject jsonVeExt = extTab.query("pcsn = '" + json.getString("storagevehicle_code") + "'")
|
||||
.uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(jsonVeExt)) {
|
||||
throw new BadRequestException("此木箱没有绑定托盘号!"+json.getString("storagevehicle_code"));
|
||||
throw new BadRequestException("此木箱没有绑定托盘号!" + json.getString("storagevehicle_code"));
|
||||
}
|
||||
|
||||
// 生成任务
|
||||
@@ -832,6 +855,7 @@ public class OutBussManageServiceImpl implements OutBussManageService {
|
||||
|
||||
/**
|
||||
* 异常出库转库任务
|
||||
*
|
||||
* @param jsonObject {task_code : 任务编码}
|
||||
* @return JSONObject 仓位对象
|
||||
*/
|
||||
@@ -858,7 +882,7 @@ public class OutBussManageServiceImpl implements OutBussManageService {
|
||||
JSONObject jsonSub = subTab.query("package_box_sn = '" + taskDao.getVehicle_code() + "'").uniqueResult(0);
|
||||
JSONObject jsonMater = materTab.query("material_code = '" + jsonSub.getString("product_name") + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(jsonMater)) {
|
||||
throw new BadRequestException("物料编码【"+jsonSub.getString("product_name")+"】信息不存在!");
|
||||
throw new BadRequestException("物料编码【" + jsonSub.getString("product_name") + "】信息不存在!");
|
||||
}
|
||||
|
||||
// 1.更新原仓位为满入异常锁
|
||||
@@ -890,7 +914,7 @@ public class OutBussManageServiceImpl implements OutBussManageService {
|
||||
.eq(BstIvtBoxinfo::getBox_no, taskDao.getVehicle_code())
|
||||
);
|
||||
if (ObjectUtil.isEmpty(boxDao)) {
|
||||
throw new BadRequestException("木箱号为【"+taskDao.getVehicle_code()+"】的木箱信息不存在!");
|
||||
throw new BadRequestException("木箱号为【" + taskDao.getVehicle_code() + "】的木箱信息不存在!");
|
||||
}
|
||||
|
||||
String box_high = boxDao.getBox_high();
|
||||
@@ -905,15 +929,15 @@ public class OutBussManageServiceImpl implements OutBussManageService {
|
||||
moveParam.put("height", height);
|
||||
moveParam.put("vehicle_type", boxDao.getVehicle_type());
|
||||
// 移库巷道
|
||||
moveParam.put("move_block_num",jsonPoint.getString("block_num"));
|
||||
moveParam.put("move_block_num", jsonPoint.getString("block_num"));
|
||||
// TODO JSONObject jsonMove = inBussManageService.getOneStruct(moveParam);
|
||||
JSONObject jsonMove = twoInBussManageService.getOneStruct(moveParam);
|
||||
if (ObjectUtil.isEmpty(jsonMove)) {
|
||||
throw new BadRequestException("当前【"+jsonPoint.getString("block_num")+"】号巷道没有可用仓位!");
|
||||
throw new BadRequestException("当前【" + jsonPoint.getString("block_num") + "】号巷道没有可用仓位!");
|
||||
}
|
||||
|
||||
// 更新新仓位状态
|
||||
jsonMove.put("lock_type",IOSEnum.LOCK_TYPE.code("出库异常锁"));
|
||||
jsonMove.put("lock_type", IOSEnum.LOCK_TYPE.code("出库异常锁"));
|
||||
jsonMove.put("inv_code", taskDao.getVehicle_code());
|
||||
attrTab.update(jsonMove);
|
||||
|
||||
@@ -927,6 +951,7 @@ public class OutBussManageServiceImpl implements OutBussManageService {
|
||||
|
||||
/**
|
||||
* 正常出库转库任务
|
||||
*
|
||||
* @param jsonObject {task_code : 任务编码}
|
||||
* @return JSONObject 仓位对象
|
||||
*/
|
||||
@@ -959,14 +984,14 @@ public class OutBussManageServiceImpl implements OutBussManageService {
|
||||
JSONObject jsonMoveMst = moveMstTab.query("moveinv_id = '" + jsonMoveDtl.getString("moveinv_id") + "' AND bill_status <> '99'")
|
||||
.uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(jsonMoveMst)) {
|
||||
throw new BadRequestException("未找到任务号为【"+taskDao.getTask_code()+"】的移库单,请检查数据!");
|
||||
throw new BadRequestException("未找到任务号为【" + taskDao.getTask_code() + "】的移库单,请检查数据!");
|
||||
}
|
||||
|
||||
// 查询物料信息
|
||||
JSONObject jsonSub = subTab.query("package_box_sn = '" + taskDao.getVehicle_code() + "'").uniqueResult(0);
|
||||
JSONObject jsonMater = materTab.query("material_code = '" + jsonSub.getString("product_name") + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(jsonMater)) {
|
||||
throw new BadRequestException("物料编码【"+jsonSub.getString("product_name")+"】信息不存在!");
|
||||
throw new BadRequestException("物料编码【" + jsonSub.getString("product_name") + "】信息不存在!");
|
||||
}
|
||||
|
||||
// 标记原货位为货位异常锁-并更新库存
|
||||
@@ -1012,7 +1037,7 @@ public class OutBussManageServiceImpl implements OutBussManageService {
|
||||
.eq(BstIvtBoxinfo::getBox_no, taskDao.getVehicle_code())
|
||||
);
|
||||
if (ObjectUtil.isEmpty(boxDao)) {
|
||||
throw new BadRequestException("木箱号为【"+taskDao.getVehicle_code()+"】的木箱信息不存在!");
|
||||
throw new BadRequestException("木箱号为【" + taskDao.getVehicle_code() + "】的木箱信息不存在!");
|
||||
}
|
||||
|
||||
String box_high = boxDao.getBox_high();
|
||||
@@ -1027,11 +1052,11 @@ public class OutBussManageServiceImpl implements OutBussManageService {
|
||||
moveParam.put("height", height);
|
||||
moveParam.put("vehicle_type", boxDao.getVehicle_type());
|
||||
// 移库巷道
|
||||
moveParam.put("move_block_num",jsonAttr.getString("block_num"));
|
||||
moveParam.put("move_block_num", jsonAttr.getString("block_num"));
|
||||
// TODO JSONObject jsonMove = inBussManageService.getOneStruct(moveParam);
|
||||
JSONObject jsonMove = twoInBussManageService.getOneStruct(moveParam);
|
||||
if (ObjectUtil.isEmpty(jsonMove)) {
|
||||
throw new BadRequestException("当前【"+jsonAttr.getString("block_num")+"】号巷道没有可用仓位!");
|
||||
throw new BadRequestException("当前【" + jsonAttr.getString("block_num") + "】号巷道没有可用仓位!");
|
||||
}
|
||||
|
||||
// 更新新移入货位锁类型,更新库存
|
||||
@@ -1045,7 +1070,7 @@ public class OutBussManageServiceImpl implements OutBussManageService {
|
||||
jsonParam2.put("bill_code", jsonMoveMst.getString("bill_code"));
|
||||
jsonParam2.put("bill_type_scode", jsonMoveMst.getString("bill_code"));
|
||||
jsonParam2.put("qty_unit_id", jsonMoveDtl.getString("qty_unit_id"));
|
||||
storPublicService.IOStor(jsonParam2, IOSEnum.IVT_CHANGE.code("加待入"));
|
||||
storPublicService.IOStor(jsonParam2, IOSEnum.IVT_CHANGE.code("加待入"));
|
||||
|
||||
jsonMove.put("lock_type", IOSEnum.LOCK_TYPE.code("移入锁"));
|
||||
attrTab.update(jsonMove);
|
||||
|
||||
Reference in New Issue
Block a user