|
|
|
@ -57,10 +57,8 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class IoCollectOrderCodeManService extends ServiceImpl<IoCollectOrderCodeManMapper, IoCollectOrderCodeMan> {
|
|
|
|
@ -833,4 +831,398 @@ public class IoCollectOrderCodeManService extends ServiceImpl<IoCollectOrderCode
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IoCollectOrder prescribeReturnOrderCode(AddTagCodeReqeust addTagCodeReqeust) {
|
|
|
|
|
Long userId = customerService.getUserId();
|
|
|
|
|
String userIds = customerService.getUserId() + "";
|
|
|
|
|
SysWorkplace workPlace = sysWorkPlaceService.getWorkplace(addTagCodeReqeust.getWorkPlaceCode());
|
|
|
|
|
SysWorkplacePutRel sysWorkplacePutRel = workplacePutRelService.findPutWorkPlace(workPlace.getWorkplaceId(), null);
|
|
|
|
|
IoCollectSet collectSet = collectSetService.getSet();
|
|
|
|
|
Long putWorkPlaceCode = null;
|
|
|
|
|
if (sysWorkplacePutRel != null)
|
|
|
|
|
putWorkPlaceCode = sysWorkplacePutRel.getWorkPlaceCode();
|
|
|
|
|
if (workPlace == null) throw new JsonException(500, "请先选择工位");
|
|
|
|
|
|
|
|
|
|
SysWorkplaceDocumentEntity sysWorkplaceDocumentEntity = sysWorkplaceDocumentService.findByWorkplaceCode(workPlace.getWorkplaceId(), addTagCodeReqeust.getBusType());
|
|
|
|
|
IoCollectOrderBiz collectOrderBiz = null;
|
|
|
|
|
IoCollectOrder collectOrder = null;
|
|
|
|
|
// try {
|
|
|
|
|
// Thread.sleep(3*1000);
|
|
|
|
|
// } catch (InterruptedException e) {
|
|
|
|
|
// throw new RuntimeException(e);
|
|
|
|
|
// }
|
|
|
|
|
//1.校验UDI码完整性
|
|
|
|
|
String code = addTagCodeReqeust.getCode();
|
|
|
|
|
if (StringUtils.isBlank(code)) throw new JsonException(ResultEnum.DATA_ERROR.getMessage());
|
|
|
|
|
if (code.endsWith("\u001D")) {
|
|
|
|
|
code = code.replace("\u001D", "");
|
|
|
|
|
}
|
|
|
|
|
UdiEntity udiEntity = FilterUdiUtils.getUdi(code);
|
|
|
|
|
if (udiEntity == null) throw new JsonException(500, "无效条码!");
|
|
|
|
|
|
|
|
|
|
UdiRelevanceResponse udiRelevanceResponse;
|
|
|
|
|
List<UdiRelevanceResponse> udiRelevanceResponses = udiRelevanceService.selectGroupByNameCode(udiEntity.getUdi(), null);
|
|
|
|
|
if (CollUtil.isEmpty(udiRelevanceResponses)) throw new JsonException(500, "产品字典不存在此产品!");
|
|
|
|
|
else udiRelevanceResponse = udiRelevanceResponses.get(0);
|
|
|
|
|
|
|
|
|
|
//如果是处方退药的码 要去校验是 否是 原始单据处方已完成的码
|
|
|
|
|
collectOrder = collectOrderService.getByBillNo(addTagCodeReqeust.getBillNo());
|
|
|
|
|
IoCollectCodeRequest ioCollectCodeRequest = new IoCollectCodeRequest();
|
|
|
|
|
ioCollectCodeRequest.setBillNo(collectOrder.getRemark());
|
|
|
|
|
ioCollectCodeRequest.setCode(code);
|
|
|
|
|
List<IoCollectCodeResponse> ioCollectCodeResponses = ioCollectCodeBackService.filterList(ioCollectCodeRequest);
|
|
|
|
|
if (ioCollectCodeResponses.size() == 0){
|
|
|
|
|
throw new JsonException(500, "当前追溯码非原始处方追溯码");
|
|
|
|
|
}
|
|
|
|
|
IoCollectCodeResponse ioCollectCodeResponse = ioCollectCodeResponses.get(0);
|
|
|
|
|
// if (ioCollectCodeResponse.getReCount() != 0 || ioCollectCodeResponse.getReCount() != null){
|
|
|
|
|
// //扫入的为拆零码
|
|
|
|
|
// //这个为 退货的数量 如果退货数量 是
|
|
|
|
|
// Integer count = collectOrderBiz1.getCount();
|
|
|
|
|
// }
|
|
|
|
|
if (!ioCollectCodeResponse.getCode().equals(code)){
|
|
|
|
|
throw new JsonException(500, "当前追溯码非原始处方追溯码");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//流通数量
|
|
|
|
|
Integer circleCount = calCountUtil.getCirActCount(udiRelevanceResponse);
|
|
|
|
|
//使用数量
|
|
|
|
|
Integer useCount = calCountUtil.getUseActCount(udiRelevanceResponse);
|
|
|
|
|
Integer scanCount = 0;
|
|
|
|
|
|
|
|
|
|
IoCollectOrderCodeMan exitCode = this.findByCode(addTagCodeReqeust.getBillNo(), code);
|
|
|
|
|
if (StrUtil.isNotEmpty(udiEntity.getSerialNo()) && exitCode != null) {
|
|
|
|
|
throw new JsonException(500, "重复扫码!");
|
|
|
|
|
}
|
|
|
|
|
IoSplitCodeEntity splitCodeEntity = splitCodeService.findByCode(code, putWorkPlaceCode);
|
|
|
|
|
List<IoCollectOrderBiz> collectOrderBizs = collectOrderBizService.listByBillNo(addTagCodeReqeust.getBillNo());
|
|
|
|
|
//2.校验是否处方单UDI码
|
|
|
|
|
if (IntUtil.value(sysWorkplaceDocumentEntity.getScanType()) == WorkOperType.TYPE_GEN_ORDER) {
|
|
|
|
|
if (StrUtil.isEmpty(addTagCodeReqeust.getBillNo())) {
|
|
|
|
|
String orderNo = gennerOrderUtils.createWdOrderNo(new OrderNoTypeBean(Constant.SPLIT_ORDER, "yyyyMMdd"));
|
|
|
|
|
collectOrder = IoCollectOrder.builder()
|
|
|
|
|
.billNo(orderNo)
|
|
|
|
|
.busType(sysWorkplaceDocumentEntity.getDocumentTypeCode())
|
|
|
|
|
.fromCorp(addTagCodeReqeust.getFromCorp())
|
|
|
|
|
.fromCorpName(addTagCodeReqeust.getFromCorpName())
|
|
|
|
|
.billTime(new Date())
|
|
|
|
|
.workPlaceCode(workPlace.getWorkplaceId())
|
|
|
|
|
.createTime(new Date())
|
|
|
|
|
.createUser(userIds)
|
|
|
|
|
.shipper(addTagCodeReqeust.getInvCode())
|
|
|
|
|
.updateTime(new Date())
|
|
|
|
|
.orderCirType(sysWorkplaceDocumentEntity.getOrderCirType())
|
|
|
|
|
.tagStatus(1)
|
|
|
|
|
.build();
|
|
|
|
|
if (StrUtil.isNotEmpty(addTagCodeReqeust.getShipper())) {
|
|
|
|
|
collectOrder.setShipper(addTagCodeReqeust.getShipper());
|
|
|
|
|
collectOrder.setShipperName(addTagCodeReqeust.getShipperName());
|
|
|
|
|
}
|
|
|
|
|
if (IntUtil.value(sysWorkplaceDocumentEntity.getIsMatching()) == 1) {
|
|
|
|
|
collectOrder.setFromType("药械追溯管理系统");
|
|
|
|
|
} else {
|
|
|
|
|
ThrBusTypeOriginEntity one = thrBusTypeOriginService.getOne(new LambdaQueryWrapper<ThrBusTypeOriginEntity>()
|
|
|
|
|
.eq(ThrBusTypeOriginEntity::getAction, sysWorkplaceDocumentEntity.getDocumentTypeCode()));
|
|
|
|
|
if (one != null) {
|
|
|
|
|
ThrSystemEntity thrSystemEntity = thrSystemService.getOne(new LambdaQueryWrapper<ThrSystemEntity>().eq(ThrSystemEntity::getThirdId, one.getThirdSys()));
|
|
|
|
|
if (thrSystemEntity != null) {
|
|
|
|
|
collectOrder.setFromType(thrSystemEntity.getThirdName());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
collectOrderService.save(collectOrder);
|
|
|
|
|
} else {
|
|
|
|
|
collectOrder = collectOrderService.getByBillNo(addTagCodeReqeust.getBillNo());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//直接扫码单生成业务单
|
|
|
|
|
collectOrderBiz = scanGenOrder(udiRelevanceResponses, collectOrderBizs, udiEntity, collectOrder);
|
|
|
|
|
collectOrderBiz.setOrderIdFk(collectOrder.getBillNo());
|
|
|
|
|
collectOrderBizService.saveOrUpdate(collectOrderBiz);
|
|
|
|
|
} else if (IntUtil.value(sysWorkplaceDocumentEntity.getScanType()) == WorkOperType.TYPE_VAIL_BATCH) {
|
|
|
|
|
collectOrder = collectOrderService.getByBillNo(addTagCodeReqeust.getBillNo());
|
|
|
|
|
collectOrder.setWorkPlaceCode(addTagCodeReqeust.getWorkPlaceCode());
|
|
|
|
|
if (collectOrder == null)
|
|
|
|
|
throw new JsonException(500, "单据不存在!");
|
|
|
|
|
if (splitCodeEntity != null && StrUtil.isNotEmpty(splitCodeEntity.getSerialNo())) {
|
|
|
|
|
if (IntUtil.value(splitCodeEntity.getRemainCount()) < 1) {
|
|
|
|
|
throw new JsonException(500, "当前追溯码已被拆零!");
|
|
|
|
|
} else {
|
|
|
|
|
circleCount = splitCodeEntity.getRemainCount();
|
|
|
|
|
useCount = splitCodeEntity.getRemainCount();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (IntUtil.value(collectOrder.getOrderCirType()) == 1) {
|
|
|
|
|
scanCount = circleCount;
|
|
|
|
|
} else {
|
|
|
|
|
scanCount = useCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CollectOrderCodeManRequest collectOrderCodeManRequest = new CollectOrderCodeManRequest();
|
|
|
|
|
collectOrderCodeManRequest.setUdiCode(code);
|
|
|
|
|
collectOrderCodeManRequest.setBusType(sysWorkplaceDocumentEntity.getDocumentTypeCode());
|
|
|
|
|
IoCollectOrderCodeMan collectOrderCodeMan = collectOrderCodeManMapper.exitCode(collectOrderCodeManRequest);
|
|
|
|
|
IoCodeLostEntity codeLostEntity = codeLostService.findByCode(code);
|
|
|
|
|
if (codeLostEntity != null) {
|
|
|
|
|
udiEntity.setBatchNo(codeLostEntity.getBatchNo());
|
|
|
|
|
udiEntity.setProduceDate(codeLostEntity.getProduceDate());
|
|
|
|
|
udiEntity.setExpireDate(codeLostEntity.getExpireDate());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (collectOrderCodeMan != null && StrUtil.isNotEmpty(collectOrderCodeMan.getSerialNo())) {
|
|
|
|
|
throw new JsonException(500, "当前追溯码已被其他单据关联!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
collectOrderBiz = vailByBatchNo(udiRelevanceResponses, collectOrderBizs, udiEntity);
|
|
|
|
|
switch (sysWorkplaceDocumentEntity.getCheckInsert()) {
|
|
|
|
|
case 1: //插入
|
|
|
|
|
if (collectOrderBiz == null) {
|
|
|
|
|
collectOrderBiz = scanGenOrder(udiRelevanceResponses, collectOrderBizs, udiEntity, collectOrder);
|
|
|
|
|
collectOrderBiz.setOrderIdFk(collectOrder.getBillNo());
|
|
|
|
|
} else {
|
|
|
|
|
collectOrderBiz.setScanCount(IntUtil.value(collectOrderBiz.getScanCount()) + 1);
|
|
|
|
|
collectOrderBiz.setScanActCount(IntUtil.value(collectOrderBiz.getScanActCount()) + scanCount);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 2: //不插入
|
|
|
|
|
if (collectOrderBiz == null)
|
|
|
|
|
throw new JsonException(500, "非此单据追溯码!");
|
|
|
|
|
int count = IntUtil.value(collectOrderBiz.getScanCount()) + 1;
|
|
|
|
|
|
|
|
|
|
int actCount = 0;
|
|
|
|
|
actCount = IntUtil.value(collectOrderBiz.getScanActCount()) + scanCount;
|
|
|
|
|
if (actCount > IntUtil.value(collectOrderBiz.getCount())) {
|
|
|
|
|
|
|
|
|
|
int needCount = IntUtil.value(collectOrderBiz.getCount()) - IntUtil.value(collectOrderBiz.getScanActCount());
|
|
|
|
|
if (needCount > 0) {
|
|
|
|
|
if (vailInSplit(collectOrderBiz, putWorkPlaceCode, needCount)) {
|
|
|
|
|
throw new JsonException(502, collectOrderBiz.getCpmctymc() + "拆零数量还有剩余,是否继续添加?");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
throw new JsonException(500, collectOrderBiz.getCpmctymc() + "扫码数量超出!");
|
|
|
|
|
}
|
|
|
|
|
collectOrderBiz.setScanCount(count);
|
|
|
|
|
collectOrderBiz.setScanActCount(actCount);
|
|
|
|
|
break;
|
|
|
|
|
case 3: //提醒是否插入
|
|
|
|
|
if (!IntUtil.value(addTagCodeReqeust.getInsert())) {
|
|
|
|
|
if (collectOrderBiz == null)
|
|
|
|
|
throw new JsonException(502, addTagCodeReqeust.getCode() + "非此单据追溯码,是否继续添加!");
|
|
|
|
|
int count1 = IntUtil.value(collectOrderBiz.getScanCount()) + 1;
|
|
|
|
|
int actCount1 = 0;
|
|
|
|
|
actCount1 = IntUtil.value(collectOrderBiz.getScanActCount()) + scanCount;
|
|
|
|
|
if (actCount1 > collectOrderBiz.getCount()) {
|
|
|
|
|
int needCount = IntUtil.value(collectOrderBiz.getCount()) - IntUtil.value(collectOrderBiz.getScanActCount());
|
|
|
|
|
if (needCount > 0) {
|
|
|
|
|
if (vailInSplit(collectOrderBiz, putWorkPlaceCode, needCount)) {
|
|
|
|
|
throw new JsonException(502, collectOrderBiz.getCpmctymc() + "拆零数量还有剩余,是否继续扫码?");
|
|
|
|
|
}
|
|
|
|
|
int myUseCount = calCountUtil.getUseActCount(udiRelevanceResponse);
|
|
|
|
|
if (needCount > myUseCount) {
|
|
|
|
|
throw new JsonException(500, collectOrderBiz.getCpmctymc() + "扫码数量超出!");
|
|
|
|
|
} else {
|
|
|
|
|
collectOrderBiz.setSplitUnCheck(true);
|
|
|
|
|
if (IntUtil.value(collectSet.getLastCodeSplit())) {
|
|
|
|
|
throw new JsonException(503, collectOrderBiz.getId() + ";" + count1 + ";" + collectOrderBiz.getCpmctymc() + ";" + "扫码数量超出!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
collectOrderBiz.setScanCount(count1);
|
|
|
|
|
collectOrderBiz.setScanActCount(actCount1);
|
|
|
|
|
} else {
|
|
|
|
|
if (collectOrderBiz == null) {
|
|
|
|
|
collectOrderBiz = scanGenOrder(udiRelevanceResponses, collectOrderBizs, udiEntity, collectOrder);
|
|
|
|
|
collectOrderBiz.setOrderIdFk(collectOrder.getBillNo());
|
|
|
|
|
} else {
|
|
|
|
|
collectOrderBiz.setScanCount(IntUtil.value(collectOrderBiz.getScanCount()) + 1);
|
|
|
|
|
if (IntUtil.value(collectOrder.getOrderCirType()) == 1) {
|
|
|
|
|
collectOrderBiz.setScanActCount(IntUtil.value(collectOrderBiz.getScanActCount()) + calCountUtil.getCirActCount(udiRelevanceResponse));
|
|
|
|
|
} else {
|
|
|
|
|
collectOrderBiz.setScanActCount(IntUtil.value(collectOrderBiz.getScanActCount()) + calCountUtil.getUseActCount(udiRelevanceResponse));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
collectOrderBizService.saveOrUpdate(collectOrderBiz);
|
|
|
|
|
} else if (IntUtil.value(sysWorkplaceDocumentEntity.getScanType()) == WorkOperType.TYPE_UNVAIL_BATCH) {
|
|
|
|
|
collectOrder = collectOrderService.getByBillNo(addTagCodeReqeust.getBillNo());
|
|
|
|
|
collectOrder.setWorkPlaceCode(addTagCodeReqeust.getWorkPlaceCode());
|
|
|
|
|
if (collectOrder == null)
|
|
|
|
|
throw new JsonException(500, "单据不存在!");
|
|
|
|
|
//按单不校验三期
|
|
|
|
|
collectOrderBiz = vailNoBatchNo(udiRelevanceResponses, collectOrderBizs, udiEntity);
|
|
|
|
|
|
|
|
|
|
CollectOrderCodeManRequest collectOrderCodeManRequest = new CollectOrderCodeManRequest();
|
|
|
|
|
collectOrderCodeManRequest.setUdiCode(code);
|
|
|
|
|
collectOrderCodeManRequest.setBusType(sysWorkplaceDocumentEntity.getDocumentTypeCode());
|
|
|
|
|
IoCollectOrderCodeMan collectOrderCodeMan = collectOrderCodeManMapper.exitCode(collectOrderCodeManRequest);
|
|
|
|
|
if (collectOrderCodeMan != null && StrUtil.isNotEmpty(collectOrderCodeMan.getSerialNo())) {
|
|
|
|
|
throw new JsonException(500, "当前追溯码已被其他单据关联!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (IntUtil.value(collectOrder.getOrderCirType()) == 1) {
|
|
|
|
|
scanCount = circleCount;
|
|
|
|
|
} else {
|
|
|
|
|
scanCount = useCount;
|
|
|
|
|
}
|
|
|
|
|
switch (sysWorkplaceDocumentEntity.getCheckInsert()) {
|
|
|
|
|
case 1: //插入
|
|
|
|
|
if (collectOrderBiz == null) {
|
|
|
|
|
if (collectOrderBiz == null)
|
|
|
|
|
throw new JsonException(500, addTagCodeReqeust.getCode() + "非此单据追溯码,请检查!");
|
|
|
|
|
} else {
|
|
|
|
|
collectOrderBiz.setAddScanCount(1);
|
|
|
|
|
collectOrderBiz.setAddScanActCount(scanCount);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 2: //不插入
|
|
|
|
|
if (collectOrderBiz == null)
|
|
|
|
|
throw new JsonException(500, "非此单据追溯码!");
|
|
|
|
|
int count = IntUtil.value(collectOrderBiz.getScanCount()) + 1;
|
|
|
|
|
int actCount = 0;
|
|
|
|
|
actCount = IntUtil.value(collectOrderBiz.getScanActCount()) + scanCount;
|
|
|
|
|
collectOrderBiz.setAddScanCount(1);
|
|
|
|
|
collectOrderBiz.setAddScanActCount(scanCount);
|
|
|
|
|
break;
|
|
|
|
|
case 3: //提醒是否插入
|
|
|
|
|
if (!IntUtil.value(addTagCodeReqeust.getInsert())) {
|
|
|
|
|
if (collectOrderBiz == null)
|
|
|
|
|
throw new JsonException(500, addTagCodeReqeust.getCode() + "非此单据追溯码,请检查!");
|
|
|
|
|
collectOrderBiz.setAddScanCount(1);
|
|
|
|
|
collectOrderBiz.setAddScanActCount(scanCount);
|
|
|
|
|
} else {
|
|
|
|
|
if (collectOrderBiz == null) {
|
|
|
|
|
collectOrderBiz = scanGenOrder(udiRelevanceResponses, collectOrderBizs, udiEntity, collectOrder);
|
|
|
|
|
collectOrderBiz.setOrderIdFk(collectOrder.getBillNo());
|
|
|
|
|
} else {
|
|
|
|
|
collectOrderBiz.setAddScanCount(1);
|
|
|
|
|
collectOrderBiz.setAddScanActCount(scanCount);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
collectOrderBizService.insertOrUpdate(collectOrderBiz);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
if (StrUtil.isEmpty(udiEntity.getSerialNo()) && exitCode != null) {
|
|
|
|
|
exitCode.setScanCount(IntUtil.value(exitCode.getScanCount()) + 1);
|
|
|
|
|
exitCode.setScanActCount(IntUtil.value(exitCode.getScanActCount()) + scanCount);
|
|
|
|
|
exitCode.setBizIdFk(collectOrderBiz.getId());
|
|
|
|
|
this.updateById(exitCode);
|
|
|
|
|
} else {
|
|
|
|
|
// if (isExitRel(code, collectOrder.getBillNo())) {
|
|
|
|
|
// throw new JsonException(500, "当前追溯码已上传关联关系,请勿重复扫码!");
|
|
|
|
|
// }
|
|
|
|
|
IoCollectOrderCodeMan collectOrderCodeMan =
|
|
|
|
|
IoCollectOrderCodeMan.builder()
|
|
|
|
|
.udiCode(code)
|
|
|
|
|
.orderIdFk(collectOrder.getBillNo())
|
|
|
|
|
.bizIdFk(collectOrderBiz.getId())
|
|
|
|
|
.relId(collectOrderBiz.getRelId())
|
|
|
|
|
.nameCode(udiEntity.getUdi())
|
|
|
|
|
.batchNo(udiEntity.getBatchNo() == null ? collectOrderBiz.getBatchNo() : udiEntity.getBatchNo())
|
|
|
|
|
.serialNo(udiEntity.getSerialNo())
|
|
|
|
|
.productDate(udiEntity.getProduceDate() == null ? collectOrderBiz.getProductDate() : udiEntity.getProduceDate())
|
|
|
|
|
.expireDate(udiEntity.getExpireDate() == null ? collectOrderBiz.getExpireDate() : udiEntity.getExpireDate())
|
|
|
|
|
.createTime(new Date())
|
|
|
|
|
.createUser(userId)
|
|
|
|
|
.updateTime(new Date())
|
|
|
|
|
.updateUser(userId)
|
|
|
|
|
.scanCount(count + 1)
|
|
|
|
|
// .scanCount(scanCount)
|
|
|
|
|
.isSplitCode(addTagCodeReqeust.getIsSplitCode())
|
|
|
|
|
.scanActCount(scanCount)
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// RelCodeDetailResponse codeRelEntity = relCodeDetailService.findByCode(code);
|
|
|
|
|
// if (codeRelEntity != null) {
|
|
|
|
|
// collectOrderCodeMan.setParentCode(codeRelEntity.getParentCode());
|
|
|
|
|
// RelCodeDetail relCodeDetail = relCodeDetailService.getOneByCode(codeRelEntity.getParentCode());
|
|
|
|
|
// if (relCodeDetail != null) {
|
|
|
|
|
// collectOrderCodeMan.setGrantPaCode(relCodeDetail.getParentCode());
|
|
|
|
|
// }
|
|
|
|
|
// //当关联关系存在的时候 以关联关系为准
|
|
|
|
|
// collectOrderCodeMan.setBatchNo(codeRelEntity.getBatchNo());
|
|
|
|
|
// collectOrderCodeMan.setProductDate(codeRelEntity.getMadeDate() + "");
|
|
|
|
|
// collectOrderCodeMan.setExpireDate(codeRelEntity.getValidateDate() + "");
|
|
|
|
|
// }
|
|
|
|
|
this.save(collectOrderCodeMan);
|
|
|
|
|
}
|
|
|
|
|
collectOrder.setTagStatus(2);
|
|
|
|
|
collectOrderService.updateById(collectOrder);
|
|
|
|
|
return collectOrder;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
IoCollectOrderCodeManService collectOrderCodeManService;
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public BaseResponse splitReturnOrderCode(AddTagCodeReqeust addTagCodeReqeust,Integer type) {
|
|
|
|
|
if (StrUtil.isBlank(addTagCodeReqeust.getBillNo())){
|
|
|
|
|
throw new JsonException(500,"单据号不能为空");
|
|
|
|
|
}
|
|
|
|
|
IoCollectOrder collectOrder = collectOrderService.getByBillNo(addTagCodeReqeust.getBillNo());
|
|
|
|
|
if (collectOrder == null){
|
|
|
|
|
throw new JsonException(500,"单据不存在");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<IoCollectOrderBiz> ioCollectOrderBizs = null;
|
|
|
|
|
if (type == 1){
|
|
|
|
|
ioCollectOrderBizs = collectOrderBizService.list(new LambdaQueryWrapper<IoCollectOrderBiz>().eq(IoCollectOrderBiz::getOrderIdFk,collectOrder.getBillNo())
|
|
|
|
|
.eq(IoCollectOrderBiz::getRelId,addTagCodeReqeust.getRelId()));
|
|
|
|
|
}
|
|
|
|
|
if (type == 2){
|
|
|
|
|
ioCollectOrderBizs = collectOrderBizService.list(new LambdaQueryWrapper<IoCollectOrderBiz>().eq(IoCollectOrderBiz::getOrderIdFk,collectOrder.getBillNo()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (IoCollectOrderBiz ioCollectOrderBiz:ioCollectOrderBizs){
|
|
|
|
|
List<IoCollectCodeBackup> ioCollectCodeBackups = ioCollectCodeBackService.list(new LambdaQueryWrapper<IoCollectCodeBackup>()
|
|
|
|
|
.eq(IoCollectCodeBackup::getBillNo, collectOrder.getRemark())
|
|
|
|
|
.eq(IoCollectCodeBackup::getRelId, ioCollectOrderBiz.getRelId()));
|
|
|
|
|
//拆零
|
|
|
|
|
List<IoCollectCodeBackup> spiltList = ioCollectCodeBackups.stream()
|
|
|
|
|
.filter(item -> {
|
|
|
|
|
Integer reCount = item.getReCount();
|
|
|
|
|
return reCount > 0;
|
|
|
|
|
})
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
//所有拆零码 如果type == 2 需要查看manList里面的码 是重复 过滤掉重复的
|
|
|
|
|
if (type == 2){
|
|
|
|
|
List<IoCollectOrderCodeMan> collectOrderCodeManList = collectOrderCodeManService.list(
|
|
|
|
|
new LambdaQueryWrapper<IoCollectOrderCodeMan>()
|
|
|
|
|
.eq(IoCollectOrderCodeMan::getOrderIdFk, addTagCodeReqeust.getBillNo()));
|
|
|
|
|
if (collectOrderCodeManList.size() > 0){
|
|
|
|
|
// 提前将collectOrderCodeManList的udiCode提取到Set中,提升查找效率
|
|
|
|
|
Set<String> udiCodeSet = collectOrderCodeManList.stream()
|
|
|
|
|
.map(IoCollectOrderCodeMan::getUdiCode)
|
|
|
|
|
.collect(Collectors.toSet());
|
|
|
|
|
|
|
|
|
|
// 过滤掉spiltList中code存在于udiCodeSet中的项
|
|
|
|
|
spiltList = spiltList.stream()
|
|
|
|
|
.filter(item -> !udiCodeSet.contains(item.getCode()))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (IoCollectCodeBackup ioCollectCodeBackup : spiltList){
|
|
|
|
|
addTagCodeReqeust.setBusType(collectOrder.getBusType());
|
|
|
|
|
addTagCodeReqeust.setCode(ioCollectCodeBackup.getCode());
|
|
|
|
|
addTagCodeReqeust.setFromCorp(collectOrder.getFromCorp());
|
|
|
|
|
addTagCodeReqeust.setFromCorpName(collectOrder.getFromCorpName());
|
|
|
|
|
addTagCodeReqeust.setShipperName(collectOrder.getShipperName());
|
|
|
|
|
this.prescribeReturnOrderCode(addTagCodeReqeust);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return ResultVOUtils.success();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|