|
|
@ -21,6 +21,7 @@ import com.glxp.api.req.collect.AddInvDesDetaiRequest;
|
|
|
|
import com.glxp.api.req.collect.CollectOrderRequest;
|
|
|
|
import com.glxp.api.req.collect.CollectOrderRequest;
|
|
|
|
import com.glxp.api.req.inout.IoSplitCodeRequest;
|
|
|
|
import com.glxp.api.req.inout.IoSplitCodeRequest;
|
|
|
|
import com.glxp.api.res.basic.UdiRelevanceResponse;
|
|
|
|
import com.glxp.api.res.basic.UdiRelevanceResponse;
|
|
|
|
|
|
|
|
import com.glxp.api.res.collect.ConfirmResponse;
|
|
|
|
import com.glxp.api.service.basic.UdiRelevanceService;
|
|
|
|
import com.glxp.api.service.basic.UdiRelevanceService;
|
|
|
|
import com.glxp.api.service.collect.*;
|
|
|
|
import com.glxp.api.service.collect.*;
|
|
|
|
import com.glxp.api.service.thrsys.SysWorkplacePutRelService;
|
|
|
|
import com.glxp.api.service.thrsys.SysWorkplacePutRelService;
|
|
|
@ -114,13 +115,13 @@ public class IoSplitCodeService extends ServiceImpl<IoSplitCodeMapper, IoSplitCo
|
|
|
|
.eq(IoSplitCodeEntity::getCode, code).last("limit 1"));
|
|
|
|
.eq(IoSplitCodeEntity::getCode, code).last("limit 1"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void splitRemove(IoCollectOrderBiz collectOrderBiz, IoCollectOrder collectOrder, Long putWorkPlaceCode, Boolean isAuto) {
|
|
|
|
public void splitRemove(IoCollectOrderBiz collectOrderBiz, IoCollectOrder collectOrder, Long putWorkPlaceCode, Boolean isAuto, String confirmSplitCode) {
|
|
|
|
//1.按照先进先出原则,查询拆零表,获取拆零表ID
|
|
|
|
//1.按照先进先出原则,查询拆零表,获取拆零表ID
|
|
|
|
List<IoSplitCodeEntity> ioSplitCodeEntities = findSplitCodes(collectOrderBiz.getRelId(), collectOrderBiz.getBatchNo(), putWorkPlaceCode);
|
|
|
|
List<IoSplitCodeEntity> ioSplitCodeEntities = findSplitCodes(collectOrderBiz.getRelId(), collectOrderBiz.getBatchNo(), putWorkPlaceCode);
|
|
|
|
|
|
|
|
|
|
|
|
//2.如果拆零表为空,则自动从预出库队列中获拉取数据
|
|
|
|
//2.如果拆零表为空,则自动从预出库队列中获拉取数据
|
|
|
|
if (CollUtil.isEmpty(ioSplitCodeEntities)) {
|
|
|
|
if (CollUtil.isEmpty(ioSplitCodeEntities)) {
|
|
|
|
addFifoCode(collectOrderBiz.getRelId(), collectOrderBiz.getBatchNo(), IntUtil.value(collectOrderBiz.getUnTagCount()), putWorkPlaceCode);
|
|
|
|
addFifoCode(collectOrderBiz.getRelId(), collectOrderBiz.getBatchNo(), IntUtil.value(collectOrderBiz.getUnTagCount()), putWorkPlaceCode, confirmSplitCode);
|
|
|
|
ioSplitCodeEntities = findSplitCodes(collectOrderBiz.getRelId(), collectOrderBiz.getBatchNo(), putWorkPlaceCode);
|
|
|
|
ioSplitCodeEntities = findSplitCodes(collectOrderBiz.getRelId(), collectOrderBiz.getBatchNo(), putWorkPlaceCode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//3.如果拆零表不为空,则开始扣除数量
|
|
|
|
//3.如果拆零表不为空,则开始扣除数量
|
|
|
@ -160,7 +161,7 @@ public class IoSplitCodeService extends ServiceImpl<IoSplitCodeMapper, IoSplitCo
|
|
|
|
|
|
|
|
|
|
|
|
if (unCount > 0) {
|
|
|
|
if (unCount > 0) {
|
|
|
|
//4.拆零表数量不足,则从预出库队列中获取数据
|
|
|
|
//4.拆零表数量不足,则从预出库队列中获取数据
|
|
|
|
Integer fifoCount = addFifoCode(collectOrderBiz.getRelId(), collectOrderBiz.getBatchNo(), unCount, putWorkPlaceCode);
|
|
|
|
Integer fifoCount = addFifoCode(collectOrderBiz.getRelId(), collectOrderBiz.getBatchNo(), unCount, putWorkPlaceCode, confirmSplitCode);
|
|
|
|
if (fifoCount == 0) {
|
|
|
|
if (fifoCount == 0) {
|
|
|
|
//预出库队列数量不足
|
|
|
|
//预出库队列数量不足
|
|
|
|
collectOrderBiz.setTagStatus(2);
|
|
|
|
collectOrderBiz.setTagStatus(2);
|
|
|
@ -207,7 +208,7 @@ public class IoSplitCodeService extends ServiceImpl<IoSplitCodeMapper, IoSplitCo
|
|
|
|
collectOrderBiz.setTagStatus(2);
|
|
|
|
collectOrderBiz.setTagStatus(2);
|
|
|
|
collectOrderBiz.setTagMsg("预出库队列码数量不足,赋码失败!");
|
|
|
|
collectOrderBiz.setTagMsg("预出库队列码数量不足,赋码失败!");
|
|
|
|
if (isAuto)
|
|
|
|
if (isAuto)
|
|
|
|
throw new JsonException(500, "提交失败,工位库存数量不足!");
|
|
|
|
throw new JsonException(500, "工位库存数量不足!");
|
|
|
|
else return;
|
|
|
|
else return;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
collectOrderBiz.setTagStatus(3);
|
|
|
|
collectOrderBiz.setTagStatus(3);
|
|
|
@ -389,7 +390,7 @@ public class IoSplitCodeService extends ServiceImpl<IoSplitCodeMapper, IoSplitCo
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//.如果拆零,拆零表扣除
|
|
|
|
//.如果拆零,拆零表扣除
|
|
|
|
if (remainder > 0) {
|
|
|
|
if (remainder > 0) {
|
|
|
|
splitRemove(collectOrderBiz, collectOrder, putWorkPlaceCode, isAuto);
|
|
|
|
splitRemove(collectOrderBiz, collectOrder, putWorkPlaceCode, isAuto, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -407,8 +408,8 @@ public class IoSplitCodeService extends ServiceImpl<IoSplitCodeMapper, IoSplitCo
|
|
|
|
IoCollectOrderService collectOrderService;
|
|
|
|
IoCollectOrderService collectOrderService;
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
public void confirmBizAutiTagCode(IoCollectOrderBiz collectOrderBiz, String queueCode) {
|
|
|
|
public ConfirmResponse confirmBizAutiTagCode(IoCollectOrderBiz collectOrderBiz, String queueCode, String confirmSplitCode, Boolean skipSplitConfirm) {
|
|
|
|
|
|
|
|
ConfirmResponse confirmResponse = new ConfirmResponse();
|
|
|
|
IoCollectOrder collectOrder = collectOrderService.getByBillNo(collectOrderBiz.getOrderIdFk());
|
|
|
|
IoCollectOrder collectOrder = collectOrderService.getByBillNo(collectOrderBiz.getOrderIdFk());
|
|
|
|
SysWorkplacePutRel sysWorkplacePutRel = workplacePutRelService.findPutWorkPlace(collectOrder.getWorkPlaceCode(), collectOrder.getBusType());
|
|
|
|
SysWorkplacePutRel sysWorkplacePutRel = workplacePutRelService.findPutWorkPlace(collectOrder.getWorkPlaceCode(), collectOrder.getBusType());
|
|
|
|
Long putWorkPlaceCode = null;
|
|
|
|
Long putWorkPlaceCode = null;
|
|
|
@ -417,24 +418,82 @@ public class IoSplitCodeService extends ServiceImpl<IoSplitCodeMapper, IoSplitCo
|
|
|
|
FilterUdiRelRequest filterUdiRelRequest = new FilterUdiRelRequest();
|
|
|
|
FilterUdiRelRequest filterUdiRelRequest = new FilterUdiRelRequest();
|
|
|
|
filterUdiRelRequest.setId(collectOrderBiz.getRelId());
|
|
|
|
filterUdiRelRequest.setId(collectOrderBiz.getRelId());
|
|
|
|
filterUdiRelRequest.setPackLevel("1");
|
|
|
|
filterUdiRelRequest.setPackLevel("1");
|
|
|
|
//todo 后面可以 没有搜索到层级为1的
|
|
|
|
|
|
|
|
UdiRelevanceResponse udiRelevanceResponse = udiRelevanceService.selectOneUdi(filterUdiRelRequest);
|
|
|
|
UdiRelevanceResponse udiRelevanceResponse = udiRelevanceService.selectOneUdi(filterUdiRelRequest);
|
|
|
|
//去除掉已经手动扫码的数据,找出需要自动扫码的明细,执行上述的拆零或整取
|
|
|
|
//去除掉已经手动扫码的数据,找出需要自动扫码的明细,执行上述的拆零或整取
|
|
|
|
int unTagCount = collectOrderBiz.getCount() - IntUtil.value(collectOrderBiz.getScanActCount());
|
|
|
|
int unTagCount = collectOrderBiz.getCount() - IntUtil.value(collectOrderBiz.getScanActCount());
|
|
|
|
if (unTagCount > 0) {
|
|
|
|
if (unTagCount > 0) {
|
|
|
|
collectOrderBiz.setUnTagCount(unTagCount);
|
|
|
|
collectOrderBiz.setUnTagCount(unTagCount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int quotient = 0;
|
|
|
|
|
|
|
|
int remainder = 0;
|
|
|
|
|
|
|
|
if (IntUtil.value(udiRelevanceResponse.getBhxjsl()) != 0) {
|
|
|
|
|
|
|
|
quotient = collectOrderBiz.getUnTagCount() / IntUtil.value(udiRelevanceResponse.getBhxjsl());
|
|
|
|
|
|
|
|
remainder = collectOrderBiz.getUnTagCount() % IntUtil.value(udiRelevanceResponse.getBhxjsl());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取所有可用的码列表
|
|
|
|
|
|
|
|
List<IoSplitFifoCodeEntity> availableCodes = splitFifoCodeService.findByRelId(putWorkPlaceCode, collectOrderBiz.getRelId(), collectOrderBiz.getBatchNo(), queueCode);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IoSplitFifoCodeEntity confirmSplitCodeEntity = null;
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(availableCodes) && StrUtil.isNotEmpty(confirmSplitCode)) {
|
|
|
|
|
|
|
|
// 如果有确认的拆零码,直接使用
|
|
|
|
|
|
|
|
String finalConfirmSplitCode = confirmSplitCode;
|
|
|
|
|
|
|
|
confirmSplitCodeEntity = availableCodes.stream().filter(code -> StrUtil.equals(code.getCode(), finalConfirmSplitCode)).findFirst().orElse(null);
|
|
|
|
|
|
|
|
if (confirmSplitCodeEntity == null) {
|
|
|
|
|
|
|
|
throw new JsonException(500, "找不到指定的拆零码");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
availableCodes.remove(confirmSplitCodeEntity);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 检查是否有足够的拆零数量
|
|
|
|
|
|
|
|
boolean hasEnoughSplitCount = false;
|
|
|
|
|
|
|
|
if (remainder > 0 && CollUtil.isNotEmpty(availableCodes)) {
|
|
|
|
|
|
|
|
// 获取第一个码的可用数量
|
|
|
|
|
|
|
|
List<IoSplitCodeEntity> ioSplitCodeEntities = findSplitCodes(collectOrderBiz.getRelId(), collectOrderBiz.getBatchNo(), putWorkPlaceCode);
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(ioSplitCodeEntities)) {
|
|
|
|
|
|
|
|
int firstCodeAvailableCount = IntUtil.value(ioSplitCodeEntities.get(0).getRemainCount());
|
|
|
|
|
|
|
|
hasEnoughSplitCount = firstCodeAvailableCount >= remainder;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 判断是否需要拆零确认:整箱数量大于1且有拆零数量且没有足够的拆零数量
|
|
|
|
|
|
|
|
boolean needSplitConfirm = quotient > 1 && remainder > 0 && !hasEnoughSplitCount;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 如果是第一次调用(confirmSplitCode为空)且需要拆零确认且不跳过拆零确认,只返回拆零信息
|
|
|
|
|
|
|
|
if (StrUtil.isEmpty(confirmSplitCode) && needSplitConfirm && !IntUtil.value(skipSplitConfirm)) {
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(availableCodes)) {
|
|
|
|
|
|
|
|
// 需要的总数量:整箱数量 + 拆零数量
|
|
|
|
|
|
|
|
int totalNeededCount = quotient + (remainder > 0 ? 1 : 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 如果可用码数量小于需要的数量,直接报错
|
|
|
|
|
|
|
|
if (availableCodes.size() < totalNeededCount) {
|
|
|
|
|
|
|
|
throw new JsonException(500, "可用码数量不足!需要" + totalNeededCount + "个码,但只有" + availableCodes.size() + "个可用码。");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int quotient = collectOrderBiz.getUnTagCount() / IntUtil.value(udiRelevanceResponse.getBhxjsl());
|
|
|
|
// 只返回需要的码数量
|
|
|
|
int remainder = collectOrderBiz.getUnTagCount() % IntUtil.value(udiRelevanceResponse.getBhxjsl());
|
|
|
|
List<String> codeInfoList = availableCodes.stream()
|
|
|
|
|
|
|
|
// .limit(totalNeededCount) // 只取需要的数量
|
|
|
|
|
|
|
|
.map(code -> {
|
|
|
|
|
|
|
|
return code.getCode();
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(codeInfoList)) {
|
|
|
|
|
|
|
|
confirmResponse.setNeedSplitConfirm(true);
|
|
|
|
|
|
|
|
confirmResponse.setNeedSplitCodes(codeInfoList);
|
|
|
|
|
|
|
|
return confirmResponse;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 执行实际的确认操作
|
|
|
|
//2.如果整盒,从工位队列扣除 默认最后一个追溯码拆零
|
|
|
|
//2.如果整盒,从工位队列扣除 默认最后一个追溯码拆零
|
|
|
|
if (quotient > 0) {
|
|
|
|
if (quotient > 0) {
|
|
|
|
List<IoSplitFifoCodeEntity> ioSplitFifoCodeEntities = splitFifoCodeService.findByRelId(putWorkPlaceCode, collectOrderBiz.getRelId(), collectOrderBiz.getBatchNo(), queueCode);
|
|
|
|
if (availableCodes.size() < quotient) {
|
|
|
|
if (ioSplitFifoCodeEntities.size() < quotient) {
|
|
|
|
|
|
|
|
throw new JsonException(500, "确认失败,工位库存数量不足!");
|
|
|
|
throw new JsonException(500, "确认失败,工位库存数量不足!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (int i = 0; i < quotient; i++) {
|
|
|
|
for (int i = 0; i < quotient; i++) {
|
|
|
|
IoSplitFifoCodeEntity splitFifoCodeEntity = ioSplitFifoCodeEntities.get(i);
|
|
|
|
IoSplitFifoCodeEntity splitFifoCodeEntity = availableCodes.get(i);
|
|
|
|
collectOrderBiz.setUnTagCount(IntUtil.value(collectOrderBiz.getUnTagCount()) - IntUtil.value(udiRelevanceResponse.getBhxjsl()));
|
|
|
|
collectOrderBiz.setUnTagCount(IntUtil.value(collectOrderBiz.getUnTagCount()) - IntUtil.value(udiRelevanceResponse.getBhxjsl()));
|
|
|
|
collectOrderCodeAutoService.save(IoCollectOrderCodeAuto.builder()
|
|
|
|
collectOrderCodeAutoService.save(IoCollectOrderCodeAuto.builder()
|
|
|
|
.codeIdFk(splitFifoCodeEntity.getId())
|
|
|
|
.codeIdFk(splitFifoCodeEntity.getId())
|
|
|
@ -462,17 +521,31 @@ public class IoSplitCodeService extends ServiceImpl<IoSplitCodeMapper, IoSplitCo
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//.如果拆零,拆零表扣除
|
|
|
|
//.如果拆零,拆零表扣除
|
|
|
|
if (remainder > 0) {
|
|
|
|
if (remainder > 0) {
|
|
|
|
splitRemove(collectOrderBiz, collectOrder, putWorkPlaceCode, false);
|
|
|
|
if (confirmSplitCode == null && (IntUtil.value(skipSplitConfirm) || !needSplitConfirm)) {
|
|
|
|
|
|
|
|
// 如果跳过拆零确认或不需要拆零确认,直接使用第一个可用的拆零码
|
|
|
|
|
|
|
|
if (CollUtil.isEmpty(availableCodes)) {
|
|
|
|
|
|
|
|
throw new JsonException(500, "没有可用的拆零码!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
confirmSplitCode = availableCodes.get(quotient).getCode(); // 使用整箱之后的下一个码
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
splitRemove(collectOrderBiz, collectOrder, putWorkPlaceCode, true, confirmSplitCode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (collectOrderBiz.getTagStatus() == 2) {
|
|
|
|
if (collectOrderBiz.getTagStatus() == 2) {
|
|
|
|
throw new JsonException(500, "确认失败,工位库存数量不足!");
|
|
|
|
throw new JsonException(500, "确认失败,工位库存数量不足!");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
collectOrderBiz.setGetConfirm(true);
|
|
|
|
collectOrderBiz.setGetConfirm(true);
|
|
|
|
collectOrderBizService.updateById(collectOrderBiz);
|
|
|
|
collectOrderBizService.updateById(collectOrderBiz);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 返回确认后的信息
|
|
|
|
|
|
|
|
confirmResponse.setConfirmed(true);
|
|
|
|
|
|
|
|
if (confirmSplitCode != null) {
|
|
|
|
|
|
|
|
confirmResponse.setUsedSplitCode(confirmSplitCode);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return confirmResponse;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -593,15 +666,27 @@ public class IoSplitCodeService extends ServiceImpl<IoSplitCodeMapper, IoSplitCo
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 从预出库队列里面取出数据,添加至拆零表
|
|
|
|
* 从预出库队列里面取出数据,添加至拆零表
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public Integer addFifoCode(Long relId, String batchNo, Integer needCount, Long putWorkPlaceCode) {
|
|
|
|
public Integer addFifoCode(Long relId, String batchNo, Integer needCount, Long putWorkPlaceCode, String confirmSplitCode) {
|
|
|
|
|
|
|
|
|
|
|
|
List<IoSplitFifoCodeEntity> splitFifoCodeEntities = splitFifoCodeService
|
|
|
|
List<IoSplitFifoCodeEntity> splitFifoCodeEntities;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StrUtil.isNotEmpty(confirmSplitCode)) {
|
|
|
|
|
|
|
|
splitFifoCodeEntities = splitFifoCodeService
|
|
|
|
|
|
|
|
.list(new LambdaQueryWrapper<IoSplitFifoCodeEntity>()
|
|
|
|
|
|
|
|
.eq(IoSplitFifoCodeEntity::getCode, confirmSplitCode)
|
|
|
|
|
|
|
|
.eq(putWorkPlaceCode != null, IoSplitFifoCodeEntity::getWorkPlaceCode, putWorkPlaceCode)
|
|
|
|
|
|
|
|
.orderByAsc(IoSplitFifoCodeEntity::getInBactchNo)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
splitFifoCodeEntities = splitFifoCodeService
|
|
|
|
.list(new LambdaQueryWrapper<IoSplitFifoCodeEntity>()
|
|
|
|
.list(new LambdaQueryWrapper<IoSplitFifoCodeEntity>()
|
|
|
|
.eq(IoSplitFifoCodeEntity::getRelId, relId)
|
|
|
|
.eq(IoSplitFifoCodeEntity::getRelId, relId)
|
|
|
|
.eq(StrUtil.isNotEmpty(batchNo), IoSplitFifoCodeEntity::getBatchNo, batchNo)
|
|
|
|
.eq(StrUtil.isNotEmpty(batchNo), IoSplitFifoCodeEntity::getBatchNo, batchNo)
|
|
|
|
.eq(putWorkPlaceCode != null, IoSplitFifoCodeEntity::getWorkPlaceCode, putWorkPlaceCode)
|
|
|
|
.eq(putWorkPlaceCode != null, IoSplitFifoCodeEntity::getWorkPlaceCode, putWorkPlaceCode)
|
|
|
|
.orderByAsc(IoSplitFifoCodeEntity::getInBactchNo)
|
|
|
|
.orderByAsc(IoSplitFifoCodeEntity::getInBactchNo)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Integer count = 0;
|
|
|
|
Integer count = 0;
|
|
|
|
List<IoSplitCodeEntity> addSplitCodeEntities = new ArrayList<>();
|
|
|
|
List<IoSplitCodeEntity> addSplitCodeEntities = new ArrayList<>();
|
|
|
|
List<Long> removeIds = new ArrayList<>();
|
|
|
|
List<Long> removeIds = new ArrayList<>();
|
|
|
|