|
|
@ -31,6 +31,7 @@ import com.glxp.api.util.IntUtil;
|
|
|
|
import com.glxp.api.util.OrderNoTypeBean;
|
|
|
|
import com.glxp.api.util.OrderNoTypeBean;
|
|
|
|
import com.glxp.api.util.StringUtils;
|
|
|
|
import com.glxp.api.util.StringUtils;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
|
@ -72,10 +73,13 @@ public class IoSplitCodeService extends ServiceImpl<IoSplitCodeMapper, IoSplitCo
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
IoCollectLedGroupService ioCollectLedGroupService;
|
|
|
|
IoCollectLedGroupService ioCollectLedGroupService;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
IoCollectOrderBackupService collectOrderBackupService;
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
SysWorkplacePutRelService workplacePutRelService;
|
|
|
|
SysWorkplacePutRelService workplacePutRelService;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private IoCollectCodeBackService ioCollectCodeBackService;
|
|
|
|
|
|
|
|
|
|
|
|
public List<IoSplitCodeEntity> filterList(IoSplitCodeRequest splitCodeRequest) {
|
|
|
|
public List<IoSplitCodeEntity> filterList(IoSplitCodeRequest splitCodeRequest) {
|
|
|
|
if (splitCodeRequest == null) {
|
|
|
|
if (splitCodeRequest == null) {
|
|
|
@ -128,7 +132,6 @@ public class IoSplitCodeService extends ServiceImpl<IoSplitCodeMapper, IoSplitCo
|
|
|
|
unCount = IntUtil.value(collectOrderBiz.getUnTagCount());
|
|
|
|
unCount = IntUtil.value(collectOrderBiz.getUnTagCount());
|
|
|
|
for (IoSplitCodeEntity ioSplitCodeEntity : ioSplitCodeEntities) {
|
|
|
|
for (IoSplitCodeEntity ioSplitCodeEntity : ioSplitCodeEntities) {
|
|
|
|
count = IntUtil.value(ioSplitCodeEntity.getRemainCount()) - unCount;
|
|
|
|
count = IntUtil.value(ioSplitCodeEntity.getRemainCount()) - unCount;
|
|
|
|
collectOrderCodeAutoService.save(IoCollectOrderCodeAuto.builder().codeIdFk(ioSplitCodeEntity.getId()).udiCode(ioSplitCodeEntity.getCode()).orderIdFk(collectOrder.getBillNo()).batchNo(ioSplitCodeEntity.getBatchNo()).productDate(ioSplitCodeEntity.getProduceDate()).expireDate(ioSplitCodeEntity.getExpireDate()).serialNo(ioSplitCodeEntity.getSerialNo()).relId(collectOrderBiz.getRelId()).bizIdFk(collectOrderBiz.getId()).fifoSplit(1).createTime(new Date()).updateTime(new Date()).count(count > 0 ? count : 0).reCount(unCount).build());
|
|
|
|
|
|
|
|
if (count > 0) {
|
|
|
|
if (count > 0) {
|
|
|
|
ioSplitCodeEntity.setRemainCount(count);
|
|
|
|
ioSplitCodeEntity.setRemainCount(count);
|
|
|
|
unCount = 0;
|
|
|
|
unCount = 0;
|
|
|
@ -140,6 +143,7 @@ public class IoSplitCodeService extends ServiceImpl<IoSplitCodeMapper, IoSplitCo
|
|
|
|
ioSplitCodeEntity.setRemainCount(0);
|
|
|
|
ioSplitCodeEntity.setRemainCount(0);
|
|
|
|
unCount = -count;
|
|
|
|
unCount = -count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
collectOrderCodeAutoService.save(IoCollectOrderCodeAuto.builder().codeIdFk(ioSplitCodeEntity.getId()).udiCode(ioSplitCodeEntity.getCode()).orderIdFk(collectOrder.getBillNo()).batchNo(ioSplitCodeEntity.getBatchNo()).productDate(ioSplitCodeEntity.getProduceDate()).expireDate(ioSplitCodeEntity.getExpireDate()).serialNo(ioSplitCodeEntity.getSerialNo()).relId(collectOrderBiz.getRelId()).bizIdFk(collectOrderBiz.getId()).fifoSplit(1).createTime(new Date()).updateTime(new Date()).count(count > 0 ? count : 0).reCount(unCount).build());
|
|
|
|
splitCodeMapper.updateById(ioSplitCodeEntity);
|
|
|
|
splitCodeMapper.updateById(ioSplitCodeEntity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -364,7 +368,7 @@ public class IoSplitCodeService extends ServiceImpl<IoSplitCodeMapper, IoSplitCo
|
|
|
|
IoCollectCodeBackService collectCodeBackService;
|
|
|
|
IoCollectCodeBackService collectCodeBackService;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 自动赋码与手动赋码冲突时解决方案
|
|
|
|
* 手动赋码与自动赋码冲突时解决方案
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public void dealOrderReplace(List<IoCollectOrderCodeMan> collectOrderCodeManList, IoCollectOrder collectOrder) {
|
|
|
|
public void dealOrderReplace(List<IoCollectOrderCodeMan> collectOrderCodeManList, IoCollectOrder collectOrder) {
|
|
|
|
for (IoCollectOrderCodeMan collectOrderCodeMan : collectOrderCodeManList) {
|
|
|
|
for (IoCollectOrderCodeMan collectOrderCodeMan : collectOrderCodeManList) {
|
|
|
@ -411,61 +415,248 @@ public class IoSplitCodeService extends ServiceImpl<IoSplitCodeMapper, IoSplitCo
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// public void workReturnReplace(IoCodeEntity codeEntity, Long workPlaceCode) {
|
|
|
|
/**
|
|
|
|
//
|
|
|
|
* 工位退货扫码与自动赋码冲突解决方案
|
|
|
|
// IoSplitFifoCodeEntity ioSplitFifoCodeEntity = splitFifoCodeService.findByCode(codeEntity.getCode(), workPlaceCode);
|
|
|
|
*/
|
|
|
|
// if (ioSplitFifoCodeEntity == null) {
|
|
|
|
public void workReturnReplace(IoCodeEntity codeEntity, Long workPlaceCode) {
|
|
|
|
// // 1.判断工位库存是否足够
|
|
|
|
|
|
|
|
// // 2.工位库存足够的话,判断已完成单是否存在,
|
|
|
|
IoSplitFifoCodeEntity ioSplitFifoCodeEntity = splitFifoCodeService.findByCode(codeEntity.getCode(), workPlaceCode);
|
|
|
|
// // 3.存在的话,判断已完成单是否已上传医保
|
|
|
|
if (ioSplitFifoCodeEntity == null) {
|
|
|
|
// // 4.已上传医保的话,调用医保删除接口
|
|
|
|
// 1.判断工位库存是否足够
|
|
|
|
//
|
|
|
|
// 2.工位库存足够的话,判断已完成单是否存在,
|
|
|
|
// List<IoSplitFifoCodeEntity> splitFifoCodeEntitys = splitFifoCodeService.findByRelId(workPlaceCode, codeEntity.getRelId(), codeEntity.getBatchNo(), null);
|
|
|
|
// 3.存在的话,判断已完成单是否已上传医保
|
|
|
|
// if (CollUtil.isEmpty(splitFifoCodeEntitys)) {
|
|
|
|
// 4.已上传医保的话,调用医保删除接口
|
|
|
|
// throw new JsonException(500, "工位库存不足!");
|
|
|
|
|
|
|
|
// }
|
|
|
|
List<IoSplitFifoCodeEntity> splitFifoCodeEntitys = splitFifoCodeService.findByRelId(workPlaceCode, codeEntity.getRelId(), codeEntity.getBatchNo(), null);
|
|
|
|
|
|
|
|
if (CollUtil.isEmpty(splitFifoCodeEntitys)) {
|
|
|
|
|
|
|
|
throw new JsonException(500, "工位库存不足!");
|
|
|
|
|
|
|
|
}
|
|
|
|
// ioSplitFifoCodeEntity = splitFifoCodeEntitys.get(0);
|
|
|
|
// ioSplitFifoCodeEntity = splitFifoCodeEntitys.get(0);
|
|
|
|
//
|
|
|
|
|
|
|
|
// List<IoCollectCodeBackup> collectCodeBackups = collectCodeBackMapper.selectList(new LambdaQueryWrapper<IoCollectCodeBackup>().eq(IoCollectCodeBackup::getCode, ioSplitFifoCodeEntity.getCode()));
|
|
|
|
|
|
|
|
// if (CollUtil.isNotEmpty(collectCodeBackups)) {
|
|
|
|
|
|
|
|
// IoCollectCodeBackup collectCodeBackup = collectCodeBackups.get(0);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// if (IntUtil.value(collectCodeBackup.getFifoSplit()) == 3) {
|
|
|
|
|
|
|
|
// throw new JsonException(500, collectCodeBackup.getCode() + "重复扫码,请盘查后重试!");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// IoCollectOrderBackup collectOrderBackup = collectOrderBackupMapper.selectOne(new LambdaQueryWrapper<IoCollectOrderBackup>().eq(IoCollectOrderBackup::getBillNo, collectCodeBackup.getBillNo()));
|
|
|
|
|
|
|
|
// // 单据已被上传至医保
|
|
|
|
|
|
|
|
// if (IntUtil.value(collectOrderBackup.getUploadStatus()) == 2) {
|
|
|
|
|
|
|
|
// IoSplitFifoCodeEntity splitFifoCodeEntity = removeInvByCode(collectOrderCodeMan, collectOrder.getWorkPlaceCode());
|
|
|
|
|
|
|
|
// if (splitFifoCodeEntity == null) {
|
|
|
|
|
|
|
|
// throw new JsonException(500, "工位存量不足!");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// IoCollectErrorLog ioCollectErrorLog = IoCollectErrorLog.builder().orderId(codeEntity.getOrderId()).autoCode(splitFifoCodeEntity.getCode()).manuCode(ioSplitFifoCodeEntity.getCode()).type(4) //已上传医保替换码
|
|
|
|
|
|
|
|
// .updateTime(new Date()).build();
|
|
|
|
|
|
|
|
// collectErrorLogMapper.insert(ioCollectErrorLog);
|
|
|
|
|
|
|
|
// collectCodeBackup.setCode(splitFifoCodeEntity.getCode());
|
|
|
|
|
|
|
|
// collectCodeBackMapper.updateById(collectCodeBackup);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// //单据未上传医保,上传医保失败
|
|
|
|
|
|
|
|
// IoSplitFifoCodeEntity splitFifoCodeEntity = removeInvByCode(collectOrderCodeMan, collectOrder.getWorkPlaceCode());
|
|
|
|
|
|
|
|
// if (splitFifoCodeEntity == null) {
|
|
|
|
|
|
|
|
// throw new JsonException(500, "工位存量不足!");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// IoCollectErrorLog ioCollectErrorLog = IoCollectErrorLog.builder().orderId(collectOrder.getId()).autoCode(splitFifoCodeEntity.getCode()).manuCode(collectOrderCodeMan.getUdiCode()).type(3) //未上传医保替换码
|
|
|
|
|
|
|
|
// .updateTime(new Date()).build();
|
|
|
|
|
|
|
|
// collectErrorLogMapper.insert(ioCollectErrorLog);
|
|
|
|
|
|
|
|
// //替换已完成单据的码
|
|
|
|
|
|
|
|
// collectCodeBackup.setCode(splitFifoCodeEntity.getCode());
|
|
|
|
|
|
|
|
// collectCodeBackMapper.updateById(collectCodeBackup);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<IoCollectCodeBackup> collectCodeBackups = collectCodeBackMapper.selectList(new LambdaQueryWrapper<IoCollectCodeBackup>().eq(IoCollectCodeBackup::getCode, ioSplitFifoCodeEntity.getCode()));
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(collectCodeBackups)) {
|
|
|
|
|
|
|
|
IoCollectCodeBackup collectCodeBackup = collectCodeBackups.get(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (IntUtil.value(collectCodeBackup.getFifoSplit()) == 3) {
|
|
|
|
|
|
|
|
throw new JsonException(500, collectCodeBackup.getCode() + "重复扫码,请盘查后重试!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IoCollectOrderBackup collectOrderBackup = collectOrderBackupMapper.selectOne(new LambdaQueryWrapper<IoCollectOrderBackup>().eq(IoCollectOrderBackup::getBillNo, collectCodeBackup.getBillNo()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (IntUtil.value(collectOrderBackup.getUploadStatus()) == 2) {
|
|
|
|
|
|
|
|
// 单据已被上传至医保 ---- 取当前库存的码替换至已完成单的码,并退库,以当前的码为退库单的码,并生成替换日志
|
|
|
|
|
|
|
|
IoSplitFifoCodeEntity splitFifoCodeEntity = removeInvByCode(ioSplitFifoCodeEntity);
|
|
|
|
|
|
|
|
if (splitFifoCodeEntity == null) {
|
|
|
|
|
|
|
|
throw new JsonException(500, "工位存量不足!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IoCollectErrorLog ioCollectErrorLog = IoCollectErrorLog.builder().orderId(codeEntity.getOrderId()).autoCode(splitFifoCodeEntity.getCode()).manuCode(ioSplitFifoCodeEntity.getCode()).type(4) //退货已上传医保替换码
|
|
|
|
|
|
|
|
.updateTime(new Date()).build();
|
|
|
|
|
|
|
|
collectErrorLogMapper.insert(ioCollectErrorLog);
|
|
|
|
|
|
|
|
collectCodeBackup.setCode(splitFifoCodeEntity.getCode());
|
|
|
|
|
|
|
|
collectCodeBackMapper.updateById(collectCodeBackup);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 若已完成单已上传医保,则当前已完成单的码就与医保实际已上传的码不匹配;
|
|
|
|
|
|
|
|
// 解决方案1: 调用医保接口删除当前单据,并重新把最新的单据上传;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 解决方案2: 不管,保留替换记录
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
//单据未上传医保,上传医保失败
|
|
|
|
|
|
|
|
IoSplitFifoCodeEntity splitFifoCodeEntity = removeInvByCode(ioSplitFifoCodeEntity);
|
|
|
|
|
|
|
|
if (splitFifoCodeEntity == null) {
|
|
|
|
|
|
|
|
throw new JsonException(500, "工位存量不足!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
IoCollectErrorLog ioCollectErrorLog = IoCollectErrorLog.builder().orderId(codeEntity.getOrderId()).autoCode(splitFifoCodeEntity.getCode()).manuCode(codeEntity.getCode()).type(3) //退货未上传医保替换码
|
|
|
|
|
|
|
|
.updateTime(new Date()).build();
|
|
|
|
|
|
|
|
collectErrorLogMapper.insert(ioCollectErrorLog);
|
|
|
|
|
|
|
|
//替换已完成单据的码
|
|
|
|
|
|
|
|
collectCodeBackup.setCode(splitFifoCodeEntity.getCode());
|
|
|
|
|
|
|
|
collectCodeBackMapper.updateById(collectCodeBackup);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 后置拆零问题-1:校验是否需要后置拆零,更改单据状态
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public void delaySplitVail(IoCollectOrderBackup collectOrder) {
|
|
|
|
|
|
|
|
List<IoCollectOrderBizBackup> collectOrderBizBackups = ioCollectOrderBizBackupService.listByBillNo(collectOrder.getBillNo());
|
|
|
|
|
|
|
|
for (IoCollectOrderBizBackup collectOrderBizBackup : collectOrderBizBackups) {
|
|
|
|
|
|
|
|
int unTagCount = collectOrderBizBackup.getUnTagCount();
|
|
|
|
|
|
|
|
int remainder = 0;
|
|
|
|
|
|
|
|
FilterUdiRelRequest filterUdiRelRequest = new FilterUdiRelRequest();
|
|
|
|
|
|
|
|
filterUdiRelRequest.setId(collectOrderBizBackup.getRelId());
|
|
|
|
|
|
|
|
filterUdiRelRequest.setPackLevel("1");
|
|
|
|
|
|
|
|
UdiRelevanceResponse udiRelevanceResponse = udiRelevanceService.selectOneUdi(filterUdiRelRequest);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (IntUtil.value(udiRelevanceResponse.getBhxjsl()) != 0) {
|
|
|
|
|
|
|
|
remainder = unTagCount % IntUtil.value(udiRelevanceResponse.getBhxjsl());
|
|
|
|
|
|
|
|
if (remainder > 0) {
|
|
|
|
|
|
|
|
collectOrder.setTagStatus(6); //拆零未赋码
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
collectOrderBackupService.updateByBillNo(collectOrder);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 后置拆零问题-2:后置拆零赋码
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public void delaySplitTagCode() {
|
|
|
|
|
|
|
|
List<IoCollectOrderBackup> collectOrderBackups = collectOrderBackupMapper.selectList(new LambdaQueryWrapper<IoCollectOrderBackup>().eq(IoCollectOrderBackup::getTagStatus, 6));
|
|
|
|
|
|
|
|
for (IoCollectOrderBackup collectOrderBackup : collectOrderBackups) {
|
|
|
|
|
|
|
|
List<IoCollectOrderBizBackup> collectOrderBizBackups = ioCollectOrderBizBackupService.listByBillNo(collectOrderBackup.getBillNo());
|
|
|
|
|
|
|
|
Boolean isFullTag = true;
|
|
|
|
|
|
|
|
for (IoCollectOrderBizBackup collectOrderBizBackup : collectOrderBizBackups) {
|
|
|
|
|
|
|
|
int unTagCount = IntUtil.value(collectOrderBizBackup.getUnTagCount());
|
|
|
|
|
|
|
|
int remainder = 0;
|
|
|
|
|
|
|
|
FilterUdiRelRequest filterUdiRelRequest = new FilterUdiRelRequest();
|
|
|
|
|
|
|
|
filterUdiRelRequest.setId(collectOrderBizBackup.getRelId());
|
|
|
|
|
|
|
|
filterUdiRelRequest.setPackLevel("1");
|
|
|
|
|
|
|
|
UdiRelevanceResponse udiRelevanceResponse = udiRelevanceService.selectOneUdi(filterUdiRelRequest);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (IntUtil.value(udiRelevanceResponse.getBhxjsl()) != 0) {
|
|
|
|
|
|
|
|
remainder = unTagCount % IntUtil.value(udiRelevanceResponse.getBhxjsl());
|
|
|
|
|
|
|
|
if (remainder > 0) {
|
|
|
|
|
|
|
|
splitTagCode(collectOrderBizBackup, collectOrderBackup, null, false, null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
remainder = IntUtil.value(collectOrderBizBackup.getUnTagCount()) % IntUtil.value(udiRelevanceResponse.getBhxjsl());
|
|
|
|
|
|
|
|
if (remainder != 0) {
|
|
|
|
|
|
|
|
isFullTag = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isFullTag) {
|
|
|
|
|
|
|
|
collectOrderBackup.setTagStatus(3);
|
|
|
|
|
|
|
|
collectOrderBackup.setTagMsg("赋码完成!");
|
|
|
|
|
|
|
|
collectOrderBackupMapper.updateById(collectOrderBackup);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void splitTagCode(IoCollectOrderBizBackup collectOrderBiz, IoCollectOrderBackup collectOrder, Long putWorkPlaceCode, Boolean isAuto, String confirmSplitCode) {
|
|
|
|
|
|
|
|
//1.按照先进先出原则,查询拆零表,获取拆零表ID
|
|
|
|
|
|
|
|
List<IoSplitCodeEntity> ioSplitCodeEntities = findSplitCodes(collectOrderBiz.getRelId(), collectOrderBiz.getBatchNo(), putWorkPlaceCode);
|
|
|
|
|
|
|
|
List<IoCollectOrderCodeAuto> codeAutoList = new ArrayList<>();
|
|
|
|
|
|
|
|
//2.如果拆零表为空,则自动从预出库队列中获拉取数据
|
|
|
|
|
|
|
|
if (CollUtil.isEmpty(ioSplitCodeEntities)) {
|
|
|
|
|
|
|
|
addFifoCode(collectOrderBiz.getRelId(), collectOrderBiz.getBatchNo(), IntUtil.value(collectOrderBiz.getUnTagCount()), putWorkPlaceCode, confirmSplitCode);
|
|
|
|
|
|
|
|
ioSplitCodeEntities = findSplitCodes(collectOrderBiz.getRelId(), collectOrderBiz.getBatchNo(), putWorkPlaceCode);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//3.如果拆零表不为空,则开始扣除数量
|
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
int unCount = 0; //剩余未扣减数量
|
|
|
|
|
|
|
|
unCount = IntUtil.value(collectOrderBiz.getUnTagCount());
|
|
|
|
|
|
|
|
for (IoSplitCodeEntity ioSplitCodeEntity : ioSplitCodeEntities) {
|
|
|
|
|
|
|
|
count = IntUtil.value(ioSplitCodeEntity.getRemainCount()) - unCount;
|
|
|
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
|
|
|
ioSplitCodeEntity.setRemainCount(count);
|
|
|
|
|
|
|
|
unCount = 0;
|
|
|
|
|
|
|
|
splitCodeMapper.updateById(ioSplitCodeEntity);
|
|
|
|
|
|
|
|
} else if (count == 0) {
|
|
|
|
|
|
|
|
ioSplitCodeEntity.setRemainCount(0);
|
|
|
|
|
|
|
|
unCount = 0;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
ioSplitCodeEntity.setRemainCount(0);
|
|
|
|
|
|
|
|
unCount = -count;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
IoCollectOrderCodeAuto collectOrderCodeAuto = IoCollectOrderCodeAuto.builder().codeIdFk(ioSplitCodeEntity.getId()).udiCode(ioSplitCodeEntity.getCode()).orderIdFk(collectOrder.getBillNo()).batchNo(ioSplitCodeEntity.getBatchNo()).productDate(ioSplitCodeEntity.getProduceDate()).expireDate(ioSplitCodeEntity.getExpireDate()).serialNo(ioSplitCodeEntity.getSerialNo()).relId(collectOrderBiz.getRelId()).bizIdFk(collectOrderBiz.getId()).fifoSplit(1).createTime(new Date()).updateTime(new Date()).count(count > 0 ? count : 0).reCount(unCount).build();
|
|
|
|
|
|
|
|
collectOrderCodeAutoService.save(collectOrderCodeAuto);
|
|
|
|
|
|
|
|
codeAutoList.add(collectOrderCodeAuto);
|
|
|
|
|
|
|
|
splitCodeMapper.updateById(ioSplitCodeEntity);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (unCount > 0) {
|
|
|
|
|
|
|
|
//4.拆零表数量不足,则从预出库队列中获取数据
|
|
|
|
|
|
|
|
Integer fifoCount = addFifoCode(collectOrderBiz.getRelId(), collectOrderBiz.getBatchNo(), unCount, putWorkPlaceCode, confirmSplitCode);
|
|
|
|
|
|
|
|
if (fifoCount == 0) {
|
|
|
|
|
|
|
|
//预出库队列数量不足
|
|
|
|
|
|
|
|
collectOrderBiz.setTagStatus(2);
|
|
|
|
|
|
|
|
collectOrderBiz.setTagMsg("预出库队列码数量不足,赋码失败!");
|
|
|
|
|
|
|
|
if (isAuto)
|
|
|
|
|
|
|
|
throw new JsonException(500, "提交失败," + collectOrderBiz.getCpmctymc() + "工位库存数量不足!");
|
|
|
|
|
|
|
|
else return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
//再次执行赋码
|
|
|
|
|
|
|
|
ioSplitCodeEntities = findSplitCodes(collectOrderBiz.getRelId(), collectOrderBiz.getBatchNo(), putWorkPlaceCode);
|
|
|
|
|
|
|
|
for (IoSplitCodeEntity ioSplitCodeEntity : ioSplitCodeEntities) {
|
|
|
|
|
|
|
|
if (IntUtil.value(ioSplitCodeEntity.getRemainCount()) > 0) {
|
|
|
|
|
|
|
|
count = IntUtil.value(ioSplitCodeEntity.getRemainCount()) - unCount;
|
|
|
|
|
|
|
|
IoCollectOrderCodeAuto collectOrderCodeAuto = IoCollectOrderCodeAuto.builder().codeIdFk(ioSplitCodeEntity.getId()).udiCode(ioSplitCodeEntity.getCode()).orderIdFk(collectOrder.getBillNo()).batchNo(ioSplitCodeEntity.getBatchNo()).productDate(ioSplitCodeEntity.getProduceDate()).expireDate(ioSplitCodeEntity.getExpireDate()).serialNo(ioSplitCodeEntity.getSerialNo()).relId(collectOrderBiz.getRelId()).bizIdFk(collectOrderBiz.getId()).fifoSplit(count > 0 ? count : 0).reCount(count).createTime(new Date()).updateTime(new Date()).build();
|
|
|
|
|
|
|
|
collectOrderCodeAutoService.save(collectOrderCodeAuto);
|
|
|
|
|
|
|
|
codeAutoList.add(collectOrderCodeAuto);
|
|
|
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
|
|
|
ioSplitCodeEntity.setRemainCount(count);
|
|
|
|
|
|
|
|
splitCodeMapper.updateById(ioSplitCodeEntity);
|
|
|
|
|
|
|
|
unCount = 0;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
} else if (count == 0) {
|
|
|
|
|
|
|
|
ioSplitCodeEntity.setRemainCount(0);
|
|
|
|
|
|
|
|
unCount = 0;
|
|
|
|
|
|
|
|
splitCodeMapper.updateById(ioSplitCodeEntity);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
ioSplitCodeEntity.setRemainCount(0);
|
|
|
|
|
|
|
|
splitCodeMapper.updateById(ioSplitCodeEntity);
|
|
|
|
|
|
|
|
unCount = -count;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (unCount > 0) {
|
|
|
|
|
|
|
|
collectOrderBiz.setTagStatus(2);
|
|
|
|
|
|
|
|
collectOrderBiz.setTagMsg("预出库队列码数量不足,赋码失败!");
|
|
|
|
|
|
|
|
if (isAuto) throw new JsonException(500, "工位库存数量不足!");
|
|
|
|
|
|
|
|
else return;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
collectOrderBiz.setTagStatus(3);
|
|
|
|
|
|
|
|
collectOrderBiz.setTagMsg("赋码完成!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
collectOrderBiz.setTagStatus(3);
|
|
|
|
|
|
|
|
collectOrderBiz.setTagMsg("赋码完成!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
collectOrderBiz.setUnTagCount(unCount);
|
|
|
|
|
|
|
|
ioCollectOrderBizBackupService.updateById(collectOrderBiz);
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(codeAutoList)) {
|
|
|
|
|
|
|
|
saveSplitCode(codeAutoList, collectOrder);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void saveSplitCode(List<IoCollectOrderCodeAuto> codeAutoList, IoCollectOrderBackup collectOrder) {
|
|
|
|
|
|
|
|
if (CollUtil.isEmpty(codeAutoList))
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
List<IoCollectCodeBackup> ioCollectCodes = new ArrayList<>();
|
|
|
|
|
|
|
|
for (IoCollectOrderCodeAuto collectOrderCodeAuto : codeAutoList) {
|
|
|
|
|
|
|
|
UdiRelevanceResponse udiRelevanceResponse = udiRelevanceService.selectByRelId(collectOrderCodeAuto.getRelId() + "");
|
|
|
|
|
|
|
|
ioCollectCodes.add(IoCollectCodeBackup.builder().code(collectOrderCodeAuto.getUdiCode())
|
|
|
|
|
|
|
|
.fromType(collectOrder.getFromType())
|
|
|
|
|
|
|
|
.busType(collectOrder.getBusType())
|
|
|
|
|
|
|
|
.billNo(collectOrder.getBillNo())
|
|
|
|
|
|
|
|
.fromCorp(collectOrder.getFromCorp())
|
|
|
|
|
|
|
|
.operTime(collectOrder.getUpdateTime())
|
|
|
|
|
|
|
|
.operUser(collectOrder.getCreateUser())
|
|
|
|
|
|
|
|
.fifoSplit(1)
|
|
|
|
|
|
|
|
.relId(collectOrderCodeAuto.getRelId())
|
|
|
|
|
|
|
|
.workPlaceCode(collectOrder.getWorkPlaceCode())
|
|
|
|
|
|
|
|
.remark(collectOrder.getRemark())
|
|
|
|
|
|
|
|
.purType(udiRelevanceResponse.getPurType())
|
|
|
|
|
|
|
|
.inBatchNo(System.currentTimeMillis())
|
|
|
|
|
|
|
|
.reCount(collectOrderCodeAuto.getReCount())
|
|
|
|
|
|
|
|
.build());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
collectCodeBackService.saveBatch(ioCollectCodes);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
IoCollectErrorLogMapper collectErrorLogMapper;
|
|
|
|
IoCollectErrorLogMapper collectErrorLogMapper;
|
|
|
|