feat(qms): 更新质检回调功能以支持二维码数量管理
- 修改 ExternalIncomingInspectionApplyQO 中的 qrCodes 类型为 Collection - 新增 MaterialQrCodeDTO 数据传输对象用于二维码质检信息 - 在 NormalPGIController 中优化二维码获取逻辑并使用 Set 集合避免重复 - 为 QmsController 的 iqcIncoming 方法添加事务注解确保数据一致性 - 重构质检回调逻辑,移除异常捕获包装并优化代码结构 - 更新 WmsIncomingInspectionTaskCallbackQO 使用 MaterialQrCodeDTO 替代字符串列表 - 在质检不合格时更新二维码数量信息并处理父级二维码关联关系 - 完善质检结果处理流程,包括合格与不合格情况的数据更新逻辑
This commit is contained in:
parent
e5aff5af5b
commit
3a2d21f3fb
|
|
@ -2,6 +2,7 @@ package com.nflg.qms.admin.service;
|
||||||
|
|
||||||
import com.nflg.wms.common.constant.STATE;
|
import com.nflg.wms.common.constant.STATE;
|
||||||
import com.nflg.wms.common.exception.NflgException;
|
import com.nflg.wms.common.exception.NflgException;
|
||||||
|
import com.nflg.wms.common.pojo.dto.MaterialQrCodeDTO;
|
||||||
import com.nflg.wms.common.pojo.qo.WmsIncomingInspectionTaskCallbackQO;
|
import com.nflg.wms.common.pojo.qo.WmsIncomingInspectionTaskCallbackQO;
|
||||||
import com.nflg.wms.common.pojo.qo.WmsInventoryInspectionTaskCallbackQO;
|
import com.nflg.wms.common.pojo.qo.WmsInventoryInspectionTaskCallbackQO;
|
||||||
import com.nflg.wms.common.pojo.vo.QmsIncomingInspectionTaskVO;
|
import com.nflg.wms.common.pojo.vo.QmsIncomingInspectionTaskVO;
|
||||||
|
|
@ -76,19 +77,26 @@ public class WmsIncomingInspectionTaskCallbackService {
|
||||||
.select(QmsIncomingInspectionTaskRecord::getMaterialUniqueNo, QmsIncomingInspectionTaskRecord::getQualified)
|
.select(QmsIncomingInspectionTaskRecord::getMaterialUniqueNo, QmsIncomingInspectionTaskRecord::getQualified)
|
||||||
.eq(QmsIncomingInspectionTaskRecord::getTaskId, taskVO.getId())
|
.eq(QmsIncomingInspectionTaskRecord::getTaskId, taskVO.getId())
|
||||||
.list();
|
.list();
|
||||||
qo.setQualifiedMaterialUniqueNo(records.stream()
|
|
||||||
.filter(QmsIncomingInspectionTaskRecord::getQualified)
|
|
||||||
.map(QmsIncomingInspectionTaskRecord::getMaterialUniqueNo)
|
|
||||||
.toList()
|
|
||||||
);
|
|
||||||
if (processingResult == 4) {
|
if (processingResult == 4) {
|
||||||
//维修
|
//维修
|
||||||
qo.setUnqualifiedQty(0);
|
qo.setUnqualifiedQty(0);
|
||||||
|
qo.setQrCodes(records.stream()
|
||||||
|
.filter(QmsIncomingInspectionTaskRecord::getQualified)
|
||||||
|
.map(r-> new MaterialQrCodeDTO()
|
||||||
|
.setQrCode(r.getMaterialUniqueNo())
|
||||||
|
.setInspectionQty(r.getInspectionQty())
|
||||||
|
.setUnqualifiedQty(r.getUnqualifiedQty())
|
||||||
|
.setQualifiedQty(r.getQualifiedQty()))
|
||||||
|
.toList()
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
qo.setUnqualifiedQty(taskVO.getUnqualifiedQty());
|
qo.setUnqualifiedQty(taskVO.getUnqualifiedQty());
|
||||||
qo.setUnqualifiedMaterialUniqueNo(records.stream()
|
qo.setQrCodes(records.stream()
|
||||||
.filter(record -> !record.getQualified())
|
.map(r-> new MaterialQrCodeDTO()
|
||||||
.map(QmsIncomingInspectionTaskRecord::getMaterialUniqueNo)
|
.setQrCode(r.getMaterialUniqueNo())
|
||||||
|
.setInspectionQty(r.getInspectionQty())
|
||||||
|
.setUnqualifiedQty(r.getUnqualifiedQty())
|
||||||
|
.setQualifiedQty(r.getQualifiedQty()))
|
||||||
.toList()
|
.toList()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1176,6 +1176,32 @@ public class NormalPGIController extends BaseController {
|
||||||
// srmItem.setInspectionFlag("Y");
|
// srmItem.setInspectionFlag("Y");
|
||||||
// pushDto.getContent().getLineVOList().add(srmItem);
|
// pushDto.getContent().getLineVOList().add(srmItem);
|
||||||
// }
|
// }
|
||||||
|
Set<String> qrCodes = new HashSet<>();
|
||||||
|
if (CollectionUtil.isNotEmpty(codes)) {
|
||||||
|
List<WmsQrCodeMaster> qrCodeMasters = qrCodeMasterService.lambdaQuery()
|
||||||
|
.in(WmsQrCodeMaster::getMaterialCode, codes.stream()
|
||||||
|
.map(SrmMaterialReceiptScanCodes::getCodeId)
|
||||||
|
.toList()
|
||||||
|
).list();
|
||||||
|
qrCodes.addAll(
|
||||||
|
qrCodeMasters.stream()
|
||||||
|
.filter(q -> q.getPackagingType() == 0)
|
||||||
|
.map(WmsQrCodeMaster::getMaterialCode)
|
||||||
|
.toList()
|
||||||
|
);
|
||||||
|
qrCodes.addAll(
|
||||||
|
qrCodeMasterService.lambdaQuery()
|
||||||
|
.in(WmsQrCodeMaster::getParentBarcodeId, qrCodeMasters.stream()
|
||||||
|
.filter(q -> q.getPackagingType() == 1)
|
||||||
|
.map(WmsQrCodeMaster::getId)
|
||||||
|
.toList()
|
||||||
|
)
|
||||||
|
.list()
|
||||||
|
.stream()
|
||||||
|
.map(WmsQrCodeMaster::getMaterialCode)
|
||||||
|
.toList()
|
||||||
|
);
|
||||||
|
}
|
||||||
incomingInspectionApplyQOS.add(
|
incomingInspectionApplyQOS.add(
|
||||||
new ExternalIncomingInspectionApplyQO()
|
new ExternalIncomingInspectionApplyQO()
|
||||||
.setRequestNo(String.valueOf(receiveItemId))
|
.setRequestNo(String.valueOf(receiveItemId))
|
||||||
|
|
@ -1190,13 +1216,7 @@ public class NormalPGIController extends BaseController {
|
||||||
.setFactory(order.getIuCode())
|
.setFactory(order.getIuCode())
|
||||||
.setInspectionQty(item.getReceiptNum() != null ? item.getReceiptNum().intValue() : 0)
|
.setInspectionQty(item.getReceiptNum() != null ? item.getReceiptNum().intValue() : 0)
|
||||||
.setPurchaseGroup(order.getPurchaseGroup())
|
.setPurchaseGroup(order.getPurchaseGroup())
|
||||||
.setQrCodes(
|
.setQrCodes(qrCodes)
|
||||||
CollectionUtil.isNotEmpty(codes)
|
|
||||||
? codes.stream()
|
|
||||||
.map(SrmMaterialReceiptScanCodes::getCodeId)
|
|
||||||
.collect(Collectors.toList())
|
|
||||||
: Collections.emptyList()
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.nflg.wms.common.pojo.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class MaterialQrCodeDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 二维码唯一编号
|
||||||
|
*/
|
||||||
|
private String qrCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检测数量
|
||||||
|
*/
|
||||||
|
private Integer inspectionQty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不合格数量
|
||||||
|
*/
|
||||||
|
private Integer unqualifiedQty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 合格数量
|
||||||
|
*/
|
||||||
|
private Integer qualifiedQty;
|
||||||
|
}
|
||||||
|
|
@ -6,6 +6,7 @@ import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -91,5 +92,5 @@ public class ExternalIncomingInspectionApplyQO {
|
||||||
/**
|
/**
|
||||||
* 二维码列表
|
* 二维码列表
|
||||||
*/
|
*/
|
||||||
private List<String> qrCodes;
|
private Collection<String> qrCodes;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.nflg.wms.common.pojo.qo;
|
package com.nflg.wms.common.pojo.qo;
|
||||||
|
|
||||||
|
import com.nflg.wms.common.pojo.dto.MaterialQrCodeDTO;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
|
@ -90,12 +91,7 @@ public class WmsIncomingInspectionTaskCallbackQO {
|
||||||
private Short processingResult = 0;
|
private Short processingResult = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 合格物料唯一编号列表
|
* 质检结果二维码信息
|
||||||
*/
|
*/
|
||||||
private List<String> qualifiedMaterialUniqueNo;
|
private List<MaterialQrCodeDTO> qrCodes;
|
||||||
|
|
||||||
/**
|
|
||||||
* 不合格物料唯一编号列表
|
|
||||||
*/
|
|
||||||
private List<String> unqualifiedMaterialUniqueNo;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.nflg.wms.common.pojo.ApiResult;
|
import com.nflg.wms.common.pojo.ApiResult;
|
||||||
import com.nflg.wms.common.pojo.dto.InventoryInDTO;
|
import com.nflg.wms.common.pojo.dto.InventoryInDTO;
|
||||||
|
import com.nflg.wms.common.pojo.dto.MaterialQrCodeDTO;
|
||||||
import com.nflg.wms.common.pojo.dto.SRMQualityInspectionResultDTO;
|
import com.nflg.wms.common.pojo.dto.SRMQualityInspectionResultDTO;
|
||||||
import com.nflg.wms.common.pojo.qo.WmsIncomingInspectionTaskCallbackQO;
|
import com.nflg.wms.common.pojo.qo.WmsIncomingInspectionTaskCallbackQO;
|
||||||
import com.nflg.wms.common.util.VUtil;
|
import com.nflg.wms.common.util.VUtil;
|
||||||
|
|
@ -24,6 +25,7 @@ import com.nflg.wms.starter.BaseController;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
@ -64,6 +66,7 @@ public class QmsController extends BaseController {
|
||||||
/**
|
/**
|
||||||
* IQC来料检测回调
|
* IQC来料检测回调
|
||||||
*/
|
*/
|
||||||
|
@Transactional
|
||||||
@PostMapping("/iqc/incoming")
|
@PostMapping("/iqc/incoming")
|
||||||
public ApiResult<Void> iqcIncoming(@RequestBody @NotNull WmsIncomingInspectionTaskCallbackQO qo) {
|
public ApiResult<Void> iqcIncoming(@RequestBody @NotNull WmsIncomingInspectionTaskCallbackQO qo) {
|
||||||
log.info("质检单解析完成, 单号: {}, 物料: {}, 结果: {}", qo.getDeliveryOrderNo(), qo.getMaterialNo(), qo.getInspectionResult());
|
log.info("质检单解析完成, 单号: {}, 物料: {}, 结果: {}", qo.getDeliveryOrderNo(), qo.getMaterialNo(), qo.getInspectionResult());
|
||||||
|
|
@ -75,7 +78,6 @@ public class QmsController extends BaseController {
|
||||||
VUtil.trueThrowBusinessError(true).throwMessage("质检单已存在");
|
VUtil.trueThrowBusinessError(true).throwMessage("质检单已存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer result = 1;
|
|
||||||
// 找到入库的明细
|
// 找到入库的明细
|
||||||
WmsQcReceiveItem receiveItem = qcReceiveItemService.lambdaQuery()
|
WmsQcReceiveItem receiveItem = qcReceiveItemService.lambdaQuery()
|
||||||
.eq(WmsQcReceiveItem::getItemCode, qo.getMaterialNo())
|
.eq(WmsQcReceiveItem::getItemCode, qo.getMaterialNo())
|
||||||
|
|
@ -119,7 +121,7 @@ public class QmsController extends BaseController {
|
||||||
.setReceiveId(receiveItem.getId())
|
.setReceiveId(receiveItem.getId())
|
||||||
.setIsIn(false)
|
.setIsIn(false)
|
||||||
.setAcceptTime(LocalDateTime.now());
|
.setAcceptTime(LocalDateTime.now());
|
||||||
try {
|
|
||||||
short isCheck = 2;
|
short isCheck = 2;
|
||||||
if (qo.getInspectionResult()) {
|
if (qo.getInspectionResult()) {
|
||||||
isCheck = 1;
|
isCheck = 1;
|
||||||
|
|
@ -210,11 +212,23 @@ public class QmsController extends BaseController {
|
||||||
.set(WmsQcReceive::getIsCheck, isCheck)
|
.set(WmsQcReceive::getIsCheck, isCheck)
|
||||||
.update();
|
.update();
|
||||||
qcReceiveItemService.updateCheckNum(inspect.getInspectionQty(), inspect.getNoteNum(), inspect.getLineNumber(), inspect.getItemCode(), inspect.getReceiveNum());
|
qcReceiveItemService.updateCheckNum(inspect.getInspectionQty(), inspect.getNoteNum(), inspect.getLineNumber(), inspect.getItemCode(), inspect.getReceiveNum());
|
||||||
log.info("质检单处理完成: {}, 结果: {}", qo.getTaskNo(), inspect.getInspectionResult());
|
//更新二维码数量
|
||||||
} catch (Exception ex) {
|
if (CollectionUtil.isNotEmpty(qo.getQrCodes())) {
|
||||||
log.error("SRM送货单保存失败", ex);
|
List<WmsQrCodeMaster> qrCodeMasters = qrCodeMasterService.getByCodes(qo.getQrCodes().stream().map(MaterialQrCodeDTO::getQrCode).toList());
|
||||||
VUtil.trueThrowBusinessError(true).throwMessage(ex.getMessage());
|
qrCodeMasters.forEach(qrCodeMaster -> {
|
||||||
|
MaterialQrCodeDTO dto = qo.getQrCodes().stream()
|
||||||
|
.filter(qrCodeDTO -> StrUtil.equals(qrCodeDTO.getQrCode(), qrCodeMaster.getMaterialCode()))
|
||||||
|
.findFirst()
|
||||||
|
.get();
|
||||||
|
qrCodeMaster.setQuantity(qrCodeMaster.getQuantity().subtract(BigDecimal.valueOf(dto.getUnqualifiedQty())));
|
||||||
|
VUtil.trueThrowBusinessError(qrCodeMaster.getQuantity().compareTo(BigDecimal.ZERO) < 0)
|
||||||
|
.throwMessage(dto.getQrCode() + "数据异常");
|
||||||
|
if (qrCodeMaster.getQuantity().compareTo(BigDecimal.ZERO) == 0 || qrCodeMaster.getParentBarcodeId() > 0) {
|
||||||
|
qrCodeMaster.setParentBarcodeId(0L);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
log.info("质检单处理完成: {}, 结果: {}", qo.getTaskNo(), inspect.getInspectionResult());
|
||||||
return ApiResult.success();
|
return ApiResult.success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue