|
|
|
@ -12,6 +12,7 @@ import com.glxp.api.dao.inout.IoSplitFifoCodeMapper;
|
|
|
|
|
import com.glxp.api.dao.inout.IoSplitFifoInvMapper;
|
|
|
|
|
import com.glxp.api.entity.auth.SysWorkplace;
|
|
|
|
|
import com.glxp.api.entity.basic.UdiRelevanceEntity;
|
|
|
|
|
import com.glxp.api.entity.collect.IoCollectOrder;
|
|
|
|
|
import com.glxp.api.entity.inout.IoSplitFifoCodeEntity;
|
|
|
|
|
import com.glxp.api.entity.inout.IoSplitFifoInv;
|
|
|
|
|
import com.glxp.api.exception.JsonException;
|
|
|
|
@ -25,6 +26,7 @@ import com.glxp.api.res.collect.IoCollectOrderResponse;
|
|
|
|
|
import com.glxp.api.res.inout.IoSplitCodeResponse;
|
|
|
|
|
import com.glxp.api.res.inout.IoSplitInvResponse;
|
|
|
|
|
import com.glxp.api.service.auth.SysWorkplaceService;
|
|
|
|
|
import com.glxp.api.util.IntUtil;
|
|
|
|
|
import io.swagger.models.auth.In;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
@ -111,16 +113,16 @@ public class IoSplitFifoCodeService extends ServiceImpl<IoSplitFifoCodeMapper, I
|
|
|
|
|
}
|
|
|
|
|
ioSplitInvResponses.forEach(item -> {
|
|
|
|
|
Boolean enableRemind = item.getEnableRemind();
|
|
|
|
|
if (enableRemind){
|
|
|
|
|
if (enableRemind) {
|
|
|
|
|
Integer reCount = item.getReCount();
|
|
|
|
|
Integer invRemindCount = item.getInvRemindCount();
|
|
|
|
|
if (reCount < invRemindCount) {
|
|
|
|
|
String cpmctymc = item.getCpmctymc();
|
|
|
|
|
String batchNo = item.getBatchNo();
|
|
|
|
|
if (StrUtil.isBlank(batchNo)) {
|
|
|
|
|
msg[0] = msg[0] + cpmctymc + "存量为:" + reCount+";";
|
|
|
|
|
msg[0] = msg[0] + cpmctymc + "存量为:" + reCount + ";";
|
|
|
|
|
} else {
|
|
|
|
|
msg[0] = msg[0] + cpmctymc + "[" + batchNo + "]存量为:" + reCount+";";
|
|
|
|
|
msg[0] = msg[0] + cpmctymc + "[" + batchNo + "]存量为:" + reCount + ";";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -159,8 +161,6 @@ public class IoSplitFifoCodeService extends ServiceImpl<IoSplitFifoCodeMapper, I
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 通过 单据 锁定库存
|
|
|
|
|
* lockType 1 上锁 2释放锁
|
|
|
|
@ -168,7 +168,7 @@ public class IoSplitFifoCodeService extends ServiceImpl<IoSplitFifoCodeMapper, I
|
|
|
|
|
* 2、失败 返回false
|
|
|
|
|
*/
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public boolean lockInventoryByOrder(String billNo,Integer lockType){
|
|
|
|
|
public boolean lockInventoryByOrder(String billNo, Integer lockType) {
|
|
|
|
|
|
|
|
|
|
if (StrUtil.isEmpty(billNo)) throw new JsonException("单据号不可以为空!");
|
|
|
|
|
|
|
|
|
@ -180,9 +180,9 @@ public class IoSplitFifoCodeService extends ServiceImpl<IoSplitFifoCodeMapper, I
|
|
|
|
|
IoCollectOrderResponse order = orderList.get(0);
|
|
|
|
|
Integer invAlert1 = order.getInvAlert();
|
|
|
|
|
|
|
|
|
|
if (lockType == 1){
|
|
|
|
|
if (lockType == 1) {
|
|
|
|
|
if (invAlert1 == 1) throw new JsonException("该单据已锁定库存过请勿重复锁定!");
|
|
|
|
|
}else if (lockType == 2){
|
|
|
|
|
} else if (lockType == 2) {
|
|
|
|
|
if (invAlert1 != 1) throw new JsonException("该单据未正常锁定库存过不可进行解锁库存操作!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -201,16 +201,16 @@ public class IoSplitFifoCodeService extends ServiceImpl<IoSplitFifoCodeMapper, I
|
|
|
|
|
Map<Long, List<IoSplitInvResponse>> splitInvMap = ioSplitInvResponses.stream().collect(Collectors.groupingBy(IoSplitInvResponse::getRelId));
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(bizList)) {
|
|
|
|
|
if (lockType == 1){
|
|
|
|
|
if (lockType == 1) {
|
|
|
|
|
//自动分配 工位存量、更新splitMap、更新 bizList上的 缺少存量数
|
|
|
|
|
Integer invAlert = autoAllocationBillNoInv(splitInvMap, bizList);
|
|
|
|
|
collectOrderMapper.updateInvAlert(order.getId(), invAlert);
|
|
|
|
|
if (invAlert == 2){
|
|
|
|
|
if (invAlert == 2) {
|
|
|
|
|
return false;
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}else if (lockType == 2){
|
|
|
|
|
} else if (lockType == 2) {
|
|
|
|
|
unAutoAllocationBillNoInv(splitInvMap, bizList);
|
|
|
|
|
collectOrderMapper.updateInvAlert(order.getId(), 3);
|
|
|
|
|
}
|
|
|
|
@ -219,7 +219,6 @@ public class IoSplitFifoCodeService extends ServiceImpl<IoSplitFifoCodeMapper, I
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// /**
|
|
|
|
|
// * 预分配库存
|
|
|
|
|
// */
|
|
|
|
@ -306,7 +305,6 @@ public class IoSplitFifoCodeService extends ServiceImpl<IoSplitFifoCodeMapper, I
|
|
|
|
|
// return invAlert;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
Integer autoAllocationBillNoInv(Map<Long, List<IoSplitInvResponse>> splitMap, List<CollectOrderBizResponse> bizList) {
|
|
|
|
|
Integer invAlert = 1;
|
|
|
|
@ -316,27 +314,33 @@ public class IoSplitFifoCodeService extends ServiceImpl<IoSplitFifoCodeMapper, I
|
|
|
|
|
CollectOrderBizResponse collectOrderBizResponse = bizList.get(i);
|
|
|
|
|
Long relId = collectOrderBizResponse.getRelId();
|
|
|
|
|
String batchNo = collectOrderBizResponse.getBatchNo();
|
|
|
|
|
Integer count = collectOrderBizResponse.getCount(); //当前明细 需要的数量
|
|
|
|
|
//当前明细 需要的数量
|
|
|
|
|
Integer count = 0;
|
|
|
|
|
if (IntUtil.value(collectOrderBizResponse.getAutoResCount()) < 0) {
|
|
|
|
|
count = 0 - IntUtil.value(collectOrderBizResponse.getAutoResCount());
|
|
|
|
|
} else {
|
|
|
|
|
count = collectOrderBizResponse.getCount();
|
|
|
|
|
}
|
|
|
|
|
Long bizId = collectOrderBizResponse.getId();
|
|
|
|
|
|
|
|
|
|
List<IoSplitInvResponse> ioSplitInvResponses = splitMap.get(relId);
|
|
|
|
|
List<IoSplitInvResponse> newioSplitCodeResponses = new ArrayList<>(ioSplitInvResponses.size());
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(newioSplitCodeResponses)) {
|
|
|
|
|
for (int j = 0; j < newioSplitCodeResponses.size(); j++) {
|
|
|
|
|
IoSplitInvResponse ioSplit = newioSplitCodeResponses.get(j);
|
|
|
|
|
if (CollUtil.isNotEmpty(ioSplitInvResponses)) {
|
|
|
|
|
for (int j = 0; j < ioSplitInvResponses.size(); j++) {
|
|
|
|
|
IoSplitInvResponse ioSplit = ioSplitInvResponses.get(j);
|
|
|
|
|
Integer reCount = ioSplit.getReCount();
|
|
|
|
|
Integer lockCount = ioSplit.getLockCount();
|
|
|
|
|
Integer totalCount = reCount-lockCount;//剩余可分配数量
|
|
|
|
|
Integer totalCount = reCount - lockCount;//剩余可分配数量
|
|
|
|
|
|
|
|
|
|
if ((StrUtil.isBlank(batchNo) || batchNo.equals(ioSplit.getBatchNo())) && count > 0 && totalCount > 0) {
|
|
|
|
|
Integer resCount = totalCount - count;//预分配后剩余 工位存量
|
|
|
|
|
if (resCount >= 0) {//足够分配
|
|
|
|
|
count = 0;
|
|
|
|
|
ioSplit.setLockCount( lockCount + count );
|
|
|
|
|
ioSplit.setLockCount(lockCount + count);
|
|
|
|
|
IoSplitFifoInv bean = new IoSplitFifoInv();
|
|
|
|
|
BeanUtils.copyProperties(ioSplit,bean);
|
|
|
|
|
ioSplit.setAvailableCount(ioSplit.getInCount() - ioSplit.getOutCount() - ioSplit.getLockCount());
|
|
|
|
|
BeanUtils.copyProperties(ioSplit, bean);
|
|
|
|
|
updateIoSplitFifoInv.add(bean);
|
|
|
|
|
count = 0;
|
|
|
|
|
} else {//不够分配
|
|
|
|
|
count = -resCount;
|
|
|
|
|
}
|
|
|
|
@ -353,11 +357,9 @@ public class IoSplitFifoCodeService extends ServiceImpl<IoSplitFifoCodeMapper, I
|
|
|
|
|
collectOrderBizMapper.updateAutoResCount(bizId, collectOrderBizResponse.getCount());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(updateIoSplitFifoInv)){
|
|
|
|
|
if (CollUtil.isNotEmpty(updateIoSplitFifoInv)) {
|
|
|
|
|
splitFifoInvService.updateBatchById(updateIoSplitFifoInv);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return invAlert;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -375,17 +377,18 @@ public class IoSplitFifoCodeService extends ServiceImpl<IoSplitFifoCodeMapper, I
|
|
|
|
|
List<IoSplitInvResponse> ioSplitInvResponses = splitMap.get(relId);
|
|
|
|
|
List<IoSplitInvResponse> newioSplitCodeResponses = new ArrayList<>(ioSplitInvResponses.size());
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(newioSplitCodeResponses)) {
|
|
|
|
|
for (int j = 0; j < newioSplitCodeResponses.size(); j++) {
|
|
|
|
|
IoSplitInvResponse ioSplit = newioSplitCodeResponses.get(j);
|
|
|
|
|
if (CollUtil.isNotEmpty(ioSplitInvResponses)) {
|
|
|
|
|
for (int j = 0; j < ioSplitInvResponses.size(); j++) {
|
|
|
|
|
IoSplitInvResponse ioSplit = ioSplitInvResponses.get(j);
|
|
|
|
|
Integer lockCount = ioSplit.getLockCount();
|
|
|
|
|
|
|
|
|
|
if ((StrUtil.isBlank(batchNo) || batchNo.equals(ioSplit.getBatchNo())) && count > 0 ) {
|
|
|
|
|
ioSplit.setLockCount( lockCount - count );
|
|
|
|
|
IoSplitFifoInv bean = new IoSplitFifoInv();
|
|
|
|
|
BeanUtils.copyProperties(ioSplit,bean);
|
|
|
|
|
updateIoSplitFifoInv.add(bean);
|
|
|
|
|
}
|
|
|
|
|
if ((StrUtil.isBlank(batchNo) || batchNo.equals(ioSplit.getBatchNo())) && count > 0) {
|
|
|
|
|
ioSplit.setLockCount(lockCount - count);
|
|
|
|
|
ioSplit.setAvailableCount(ioSplit.getInCount() - ioSplit.getOutCount() - ioSplit.getLockCount());
|
|
|
|
|
IoSplitFifoInv bean = new IoSplitFifoInv();
|
|
|
|
|
BeanUtils.copyProperties(ioSplit, bean);
|
|
|
|
|
updateIoSplitFifoInv.add(bean);
|
|
|
|
|
}
|
|
|
|
|
newioSplitCodeResponses.add(ioSplit);
|
|
|
|
|
}
|
|
|
|
|
splitMap.put(relId, newioSplitCodeResponses);
|
|
|
|
@ -394,9 +397,29 @@ public class IoSplitFifoCodeService extends ServiceImpl<IoSplitFifoCodeMapper, I
|
|
|
|
|
collectOrderBizMapper.updateAutoResCount(bizId, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(updateIoSplitFifoInv)){
|
|
|
|
|
if (CollUtil.isNotEmpty(updateIoSplitFifoInv)) {
|
|
|
|
|
splitFifoInvService.updateBatchById(updateIoSplitFifoInv);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 更新工位下库存不足单据,进行再次锁定库存
|
|
|
|
|
*
|
|
|
|
|
* @param workPlaceCode
|
|
|
|
|
*/
|
|
|
|
|
public void updateAllInvAlert(Long workPlaceCode) {
|
|
|
|
|
List<IoCollectOrder> collectOrderList =
|
|
|
|
|
collectOrderMapper.selectList(new LambdaQueryWrapper<IoCollectOrder>()
|
|
|
|
|
.eq(IoCollectOrder::getWorkPlaceCode, workPlaceCode)
|
|
|
|
|
.eq(IoCollectOrder::getInvAlert, 2)
|
|
|
|
|
);
|
|
|
|
|
if (CollUtil.isNotEmpty(collectOrderList)) {
|
|
|
|
|
for (IoCollectOrder ioCollectOrder : collectOrderList) {
|
|
|
|
|
lockInventoryByOrder(ioCollectOrder.getBillNo(), 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|