|
|
|
|
@ -10,6 +10,7 @@ import org.dromara.qms.api.dto.InspectionCompleteNotification;
|
|
|
|
|
import org.dromara.qms.domain.bo.QcInspectionMainBo;
|
|
|
|
|
import org.dromara.qms.domain.vo.QcInspectionMainVo;
|
|
|
|
|
import org.dromara.qms.domain.vo.QcInspectionTypeVo;
|
|
|
|
|
import org.dromara.qms.domain.vo.QcUnqualifiedReviewVo;
|
|
|
|
|
import org.dromara.qms.service.IQcInspectionMainService;
|
|
|
|
|
import org.dromara.qms.service.IQcInspectionTypeService;
|
|
|
|
|
import org.dromara.qms.service.IQcWmsCallbackService;
|
|
|
|
|
@ -17,18 +18,27 @@ import org.dromara.wms.api.RemoteWmsInstockService;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* QMS 回调 WMS 服务实现
|
|
|
|
|
* QMS 回调 WMS 服务实现(重构版)
|
|
|
|
|
* <p>
|
|
|
|
|
* 负责 QMS 质检完成后回调 WMS 更新状态的完整业务流程
|
|
|
|
|
* 负责 QMS 质检完成后回调 WMS 更新质检状态(inspectionType)
|
|
|
|
|
* <p>
|
|
|
|
|
* 说明:
|
|
|
|
|
* 1. 此服务为独立抽离的新文件,不修改现有文件(如 QcPDAServiceImpl)
|
|
|
|
|
* 2. 可复用现有服务方法(如 qcInspectionMainService)
|
|
|
|
|
* 3. 便于维护和调试,支持后续扩展其他回调方式
|
|
|
|
|
* 重构说明(2026-01-15):
|
|
|
|
|
* 1. 入库由 PDA 扫码完成,QMS 只更新 WMS 的质检状态
|
|
|
|
|
* 2. 回调方法已独立抽离为 private 方法,便于:
|
|
|
|
|
* - 替换为其他 Dubbo 服务或 REST API
|
|
|
|
|
* - 直接注释掉不使用
|
|
|
|
|
* - 根据检测类型判断是否回调
|
|
|
|
|
* 3. 支持检测类型判断,当前 WMS 默认传 inspectionType=4(原材料检)
|
|
|
|
|
* <p>
|
|
|
|
|
* 状态更新规则:
|
|
|
|
|
* - 全部合格 -> inspectionType='2'(合格)
|
|
|
|
|
* - 全部不合格 -> inspectionType='3'(不合格)
|
|
|
|
|
* - 部分合格部分不合格 -> inspectionType='1'(保持质检中,等待评审)
|
|
|
|
|
* - 让步接收通过 -> inspectionType='2'(合格)
|
|
|
|
|
* - 让步接收不通过 -> inspectionType='2' + 更新 apportion_qty 为合格数量
|
|
|
|
|
*
|
|
|
|
|
* @author zch
|
|
|
|
|
* @date 2026-01-15
|
|
|
|
|
@ -39,178 +49,195 @@ import java.util.List;
|
|
|
|
|
public class QcWmsCallbackServiceImpl implements IQcWmsCallbackService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* WMS 暴露的 Dubbo 回调服务
|
|
|
|
|
* 【可配置】WMS Dubbo 回调服务
|
|
|
|
|
* <p>
|
|
|
|
|
* 说明:WMS 模块的 RemoteWmsInspectionCallbackServiceImpl 实现此接口
|
|
|
|
|
* 说明:可替换为其他 Dubbo 服务或 REST API
|
|
|
|
|
*/
|
|
|
|
|
@DubboReference(timeout = 300000)
|
|
|
|
|
private RemoteWmsInstockService remoteWmsInstockService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 复用现有的质检主表服务
|
|
|
|
|
*/
|
|
|
|
|
private final IQcInspectionMainService qcInspectionMainService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 复用现有的质检类型服务(用于判断是否为入库检)
|
|
|
|
|
*/
|
|
|
|
|
private final IQcInspectionTypeService qcInspectionTypeService;
|
|
|
|
|
|
|
|
|
|
// ==================== 核心方法:质检完成回调 ====================
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 质检完成时回调 WMS(合格场景)
|
|
|
|
|
* 【核心方法】PDA质检完成后回调WMS
|
|
|
|
|
* <p>
|
|
|
|
|
* 说明:调用方需要添加 @GlobalTransactional 注解开启分布式事务
|
|
|
|
|
* 根据质检结果更新 WMS 的 inspectionType 状态:
|
|
|
|
|
* - 全部合格 -> inspectionType='2'
|
|
|
|
|
* - 全部不合格 -> inspectionType='3'
|
|
|
|
|
* - 部分合格部分不合格 -> inspectionType='1'(保持质检中,等待评审)
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public boolean notifyWmsForQualified(QcInspectionMainVo main) {
|
|
|
|
|
// 1. 检查是否来自 WMS 入库
|
|
|
|
|
public boolean notifyWmsInspectionComplete(QcInspectionMainVo main) {
|
|
|
|
|
// 1. 检查是否需要回调 WMS
|
|
|
|
|
if (!isFromWmsInspection(main)) {
|
|
|
|
|
log.info("质检单 {} 不是来自 WMS 入库,跳过回调", main.getInspectionNo());
|
|
|
|
|
return false;
|
|
|
|
|
return true; // 无需回调视为成功
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 2. 检查是否有合格数量
|
|
|
|
|
if (main.getQualifiedQty() == null || main.getQualifiedQty().compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
|
|
log.info("质检单 {} 无合格数量,跳过回调", main.getInspectionNo());
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
// 2. 获取质检类型(用于判断是否回调)
|
|
|
|
|
String qcInspectionType = getQcInspectionType(main);
|
|
|
|
|
|
|
|
|
|
// 3. 判断质检结果并调用对应的回调方法
|
|
|
|
|
BigDecimal qualifiedQty = main.getQualifiedQty() != null ? main.getQualifiedQty() : BigDecimal.ZERO;
|
|
|
|
|
BigDecimal unqualifiedQty = main.getUnqualifiedQty() != null ? main.getUnqualifiedQty() : BigDecimal.ZERO;
|
|
|
|
|
BigDecimal inspectionQty = main.getInspectionQty() != null ? main.getInspectionQty() : BigDecimal.ZERO;
|
|
|
|
|
|
|
|
|
|
// 全部合格:合格数量等于质检数量
|
|
|
|
|
if (qualifiedQty.compareTo(inspectionQty) >= 0 && unqualifiedQty.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
|
|
log.info("质检单 {} 全部合格,回调 WMS 更新为'合格'", main.getInspectionNo());
|
|
|
|
|
return callbackWmsUpdateStatus(main, "2", null, qcInspectionType);
|
|
|
|
|
}
|
|
|
|
|
// 全部不合格:合格数量为0
|
|
|
|
|
else if (qualifiedQty.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
|
|
log.info("质检单 {} 全部不合格,回调 WMS 更新为'不合格'", main.getInspectionNo());
|
|
|
|
|
return callbackWmsUpdateStatus(main, "3", null, qcInspectionType);
|
|
|
|
|
}
|
|
|
|
|
// 部分合格部分不合格:保持质检中,等待评审
|
|
|
|
|
else {
|
|
|
|
|
log.info("质检单 {} 部分合格部分不合格,保持'质检中'等待评审。合格: {}, 不合格: {}",
|
|
|
|
|
main.getInspectionNo(), qualifiedQty, unqualifiedQty);
|
|
|
|
|
// 不回调 WMS,保持原状态 inspectionType='1'
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ==================== 让步接收回调 ====================
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 【可配置】让步接收审核通过后回调WMS
|
|
|
|
|
* <p>
|
|
|
|
|
* 业务逻辑:更新 inspectionType='2',apportion_qty 保持不变
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public boolean notifyWmsForConcessionAccepted(QcUnqualifiedReviewVo review) {
|
|
|
|
|
try {
|
|
|
|
|
// 3. 构建通知参数
|
|
|
|
|
InspectionCompleteNotification notification = (InspectionCompleteNotification) buildNotification(
|
|
|
|
|
main, null, false
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// 4. 调用 WMS Dubbo 接口
|
|
|
|
|
R<Void> result = remoteWmsInstockService.completeInstockAfterInspection(notification);
|
|
|
|
|
if (result == null || result.getCode() != R.SUCCESS) {
|
|
|
|
|
log.error("质检单 {} 回调 WMS 失败: {}", main.getInspectionNo(), result != null ? result.getMsg() : "null");
|
|
|
|
|
// 1. 获取质检主表
|
|
|
|
|
QcInspectionMainVo main = queryByInspectionNo(review.getInspectionNo());
|
|
|
|
|
if (main == null) {
|
|
|
|
|
log.error("让步接收回调失败:质检单不存在 {}", review.getInspectionNo());
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log.info("质检单 {} 回调 WMS 成功,合格数量: {}", main.getInspectionNo(), main.getQualifiedQty());
|
|
|
|
|
if (!isFromWmsInspection(main)) {
|
|
|
|
|
log.info("质检单 {} 不是来自 WMS 入库,跳过回调", review.getInspectionNo());
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String qcInspectionType = getQcInspectionType(main);
|
|
|
|
|
|
|
|
|
|
// 2. 回调 WMS:更新状态为'合格',数量不变
|
|
|
|
|
log.info("让步接收通过,质检单 {} 回调 WMS 更新为'合格'", review.getInspectionNo());
|
|
|
|
|
return callbackWmsUpdateStatus(main, "2", null, qcInspectionType);
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("让步接收通过回调 WMS 失败: {}", e.getMessage(), e);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 【可配置】让步接收审核不通过后回调WMS
|
|
|
|
|
* <p>
|
|
|
|
|
* 业务逻辑:更新 inspectionType='2',同时更新 apportion_qty 为合格数量
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public boolean notifyWmsForConcessionRejected(QcUnqualifiedReviewVo review, BigDecimal qualifiedQty) {
|
|
|
|
|
try {
|
|
|
|
|
// 1. 获取质检主表
|
|
|
|
|
QcInspectionMainVo main = queryByInspectionNo(review.getInspectionNo());
|
|
|
|
|
if (main == null) {
|
|
|
|
|
log.error("让步接收回调失败:质检单不存在 {}", review.getInspectionNo());
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!isFromWmsInspection(main)) {
|
|
|
|
|
log.info("质检单 {} 不是来自 WMS 入库,跳过回调", review.getInspectionNo());
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String qcInspectionType = getQcInspectionType(main);
|
|
|
|
|
|
|
|
|
|
// 2. 回调 WMS:更新状态为'合格',同时更新数量为合格数量
|
|
|
|
|
log.info("让步接收不通过,质检单 {} 回调 WMS 更新为'合格',数量更新为: {}",
|
|
|
|
|
review.getInspectionNo(), qualifiedQty);
|
|
|
|
|
return callbackWmsUpdateStatus(main, "2", qualifiedQty, qcInspectionType);
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("让步接收不通过回调 WMS 失败: {}", e.getMessage(), e);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ==================== 抽离的回调方法(便于替换或注释) ====================
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 【可配置】调用 WMS Dubbo 更新质检状态
|
|
|
|
|
* <p>
|
|
|
|
|
* 说明:此方法已独立抽离,便于:
|
|
|
|
|
* 1. 替换为其他 Dubbo 服务或 REST API
|
|
|
|
|
* 2. 直接注释掉不使用
|
|
|
|
|
* 3. 根据检测类型判断是否回调
|
|
|
|
|
*
|
|
|
|
|
* @param main 质检主表
|
|
|
|
|
* @param targetInspectionType 目标状态(2=合格,3=不合格)
|
|
|
|
|
* @param updateQty 需要更新的数量(null=不更新数量)
|
|
|
|
|
* @param qcInspectionType 检测类型(4=原材料检,7=入库检)
|
|
|
|
|
* @return 是否成功
|
|
|
|
|
*/
|
|
|
|
|
private boolean callbackWmsUpdateStatus(QcInspectionMainVo main, String targetInspectionType,
|
|
|
|
|
BigDecimal updateQty, String qcInspectionType) {
|
|
|
|
|
// 【配置项】只有原材料检(4)或入库检(7)需要回调 WMS
|
|
|
|
|
// 可根据业务需求修改此判断条件,或直接注释掉整个方法体
|
|
|
|
|
if (!"4".equals(qcInspectionType) && !"7".equals(qcInspectionType)) {
|
|
|
|
|
log.info("检测类型 {} 不需要回调 WMS,跳过", qcInspectionType);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// 构建通知参数
|
|
|
|
|
InspectionCompleteNotification notification = (InspectionCompleteNotification)
|
|
|
|
|
buildNotification(main, updateQty, updateQty != null);
|
|
|
|
|
|
|
|
|
|
// 设置目标状态
|
|
|
|
|
notification.setResult("2".equals(targetInspectionType) ? "0" : "1"); // 0=合格, 1=不合格
|
|
|
|
|
|
|
|
|
|
// 如果需要更新数量
|
|
|
|
|
if (updateQty != null) {
|
|
|
|
|
notification.setUpdateQty("1"); // 标记需要更新数量
|
|
|
|
|
notification.setQualifiedQty(updateQty);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 【可替换】调用 WMS Dubbo 接口
|
|
|
|
|
// 可替换为:REST API 调用、其他 Dubbo 服务、或直接注释掉
|
|
|
|
|
R<Void> result = remoteWmsInstockService.completeInstockAfterInspection(notification);
|
|
|
|
|
|
|
|
|
|
if (result == null || result.getCode() != R.SUCCESS) {
|
|
|
|
|
log.error("质检单 {} 回调 WMS 失败: {}", main.getInspectionNo(),
|
|
|
|
|
result != null ? result.getMsg() : "null");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log.info("质检单 {} 回调 WMS 成功,目标状态: {}", main.getInspectionNo(), targetInspectionType);
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("质检单 {} 回调 WMS 失败: {}", main.getInspectionNo(), e.getMessage(), e);
|
|
|
|
|
// 根据业务需求决定是否抛出异常
|
|
|
|
|
// 如果不影响主流程,可以只记录日志
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 让步接收完成时回调 WMS
|
|
|
|
|
* <p>
|
|
|
|
|
* 说明:调用方需要添加 @GlobalTransactional 注解开启分布式事务
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public boolean notifyWmsForConcession(String inspectionNo, BigDecimal concessionQty, String batchCode) {
|
|
|
|
|
try {
|
|
|
|
|
// 1. 获取质检主表信息
|
|
|
|
|
QcInspectionMainVo main = queryByInspectionNo(inspectionNo);
|
|
|
|
|
if (main == null) {
|
|
|
|
|
log.error("质检单不存在: {}", inspectionNo);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 2. 检查是否来自 WMS 入库
|
|
|
|
|
if (!isFromWmsInspection(main)) {
|
|
|
|
|
log.info("质检单 {} 不是来自 WMS 入库,跳过回调", inspectionNo);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 3. 构建通知参数(让步接收视为合格)
|
|
|
|
|
InspectionCompleteNotification notification = (InspectionCompleteNotification) buildNotification(
|
|
|
|
|
main, concessionQty, true
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// 4. 调用 WMS Dubbo 接口
|
|
|
|
|
R<Void> result = remoteWmsInstockService.completeInstockAfterInspection(notification);
|
|
|
|
|
if (result == null || result.getCode() != R.SUCCESS) {
|
|
|
|
|
log.error("让步接收回调 WMS 失败: {}", result != null ? result.getMsg() : "null");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log.info("让步接收回调 WMS 成功,质检单号: {}, 批次号: {}, 数量: {}",
|
|
|
|
|
inspectionNo, batchCode, concessionQty);
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("让步接收回调 WMS 失败: {}", e.getMessage(), e);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// ==================== 工具方法 ====================
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 构建质检完成通知参数
|
|
|
|
|
* 检查是否需要回调 WMS
|
|
|
|
|
* <p>
|
|
|
|
|
* 从 QcInspectionMainVo 转换为 InspectionCompleteNotification
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Object buildNotification(QcInspectionMainVo main, BigDecimal concessionQty, boolean isConcession) {
|
|
|
|
|
InspectionCompleteNotification notification = new InspectionCompleteNotification();
|
|
|
|
|
|
|
|
|
|
// 基本信息
|
|
|
|
|
notification.setInspectionNo(main.getInspectionNo());
|
|
|
|
|
notification.setMaterialCode(main.getMaterialCode());
|
|
|
|
|
|
|
|
|
|
// 获取入库单号(优先从 remark 字段获取)
|
|
|
|
|
String instockCode = main.getRemark();
|
|
|
|
|
if (StringUtils.isBlank(instockCode)) {
|
|
|
|
|
log.warn("质检单 {} 的 remark 字段为空,无法获取入库单号", main.getInspectionNo());
|
|
|
|
|
}
|
|
|
|
|
notification.setInstockCode(instockCode);
|
|
|
|
|
|
|
|
|
|
// 批次号(保持一致性)
|
|
|
|
|
notification.setBatchCode(main.getBatchNo());
|
|
|
|
|
|
|
|
|
|
// 质检结果
|
|
|
|
|
if (isConcession) {
|
|
|
|
|
// 让步接收视为合格
|
|
|
|
|
notification.setResult("0"); // 合格
|
|
|
|
|
notification.setQualifiedQty(concessionQty);
|
|
|
|
|
notification.setUnqualifiedQty(BigDecimal.ZERO);
|
|
|
|
|
} else {
|
|
|
|
|
// 正常质检结果
|
|
|
|
|
notification.setResult(main.getResult()); // 0=合格, 1=不合格
|
|
|
|
|
notification.setQualifiedQty(main.getQualifiedQty());
|
|
|
|
|
notification.setUnqualifiedQty(main.getUnqualifiedQty());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 质检状态
|
|
|
|
|
notification.setStatus("1"); // 已完成
|
|
|
|
|
|
|
|
|
|
// 质检完成时间(使用标准日期格式)
|
|
|
|
|
notification.setInspectionEndTime(main.getInspectionEndTime() != null
|
|
|
|
|
? DateUtils.formatDateTime(main.getInspectionEndTime())
|
|
|
|
|
: DateUtils.getTime());
|
|
|
|
|
|
|
|
|
|
return notification;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据质检单号查询质检主表信息
|
|
|
|
|
* <p>
|
|
|
|
|
* 说明:通过 queryList 方法实现,因为 IQcInspectionMainService 没有 queryByInspectionNo 方法
|
|
|
|
|
*
|
|
|
|
|
* @param inspectionNo 质检单号
|
|
|
|
|
* @return 质检主表信息,不存在则返回 null
|
|
|
|
|
*/
|
|
|
|
|
private QcInspectionMainVo queryByInspectionNo(String inspectionNo) {
|
|
|
|
|
if (StringUtils.isBlank(inspectionNo)) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
QcInspectionMainBo queryBo = new QcInspectionMainBo();
|
|
|
|
|
queryBo.setInspectionNo(inspectionNo);
|
|
|
|
|
List<QcInspectionMainVo> list = qcInspectionMainService.queryList(queryBo);
|
|
|
|
|
return (list != null && !list.isEmpty()) ? list.get(0) : null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 检查质检主表是否来自 WMS 入库
|
|
|
|
|
* <p>
|
|
|
|
|
* 判断依据:质检类型为"入库检"(typeCode='7')
|
|
|
|
|
* 判断依据:
|
|
|
|
|
* 1. 质检类型为原材料检(qc_inspection_type='4')
|
|
|
|
|
* 2. 或质检类型为入库检(qc_inspection_type='7')
|
|
|
|
|
* 3. 且 remark 字段存储了入库单号
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isFromWmsInspection(QcInspectionMainVo main) {
|
|
|
|
|
@ -224,7 +251,96 @@ public class QcWmsCallbackServiceImpl implements IQcWmsCallbackService {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 判断是否为入库检(typeCode='7')
|
|
|
|
|
return "7".equals(typeVo.getTypeCode());
|
|
|
|
|
// 获取质检类型的 qc_inspection_type 字段
|
|
|
|
|
String qcInspectionType = typeVo.getQcInspectionType();
|
|
|
|
|
|
|
|
|
|
// 判断是否为原材料检(4)或入库检(7)
|
|
|
|
|
boolean isWmsType = "4".equals(qcInspectionType) || "7".equals(qcInspectionType);
|
|
|
|
|
|
|
|
|
|
// 同时需要 remark 字段存储了入库单号
|
|
|
|
|
boolean hasInstockCode = StringUtils.isNotBlank(main.getRemark());
|
|
|
|
|
|
|
|
|
|
return isWmsType && hasInstockCode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取质检类型的 qc_inspection_type 字段值
|
|
|
|
|
*/
|
|
|
|
|
private String getQcInspectionType(QcInspectionMainVo main) {
|
|
|
|
|
if (main == null || main.getInspectionType() == null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
QcInspectionTypeVo typeVo = qcInspectionTypeService.queryById(main.getInspectionType());
|
|
|
|
|
return typeVo != null ? typeVo.getQcInspectionType() : null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据质检单号查询质检主表信息
|
|
|
|
|
*/
|
|
|
|
|
private QcInspectionMainVo queryByInspectionNo(String inspectionNo) {
|
|
|
|
|
if (StringUtils.isBlank(inspectionNo)) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
QcInspectionMainBo queryBo = new QcInspectionMainBo();
|
|
|
|
|
queryBo.setInspectionNo(inspectionNo);
|
|
|
|
|
List<QcInspectionMainVo> list = qcInspectionMainService.queryList(queryBo);
|
|
|
|
|
return (list != null && !list.isEmpty()) ? list.get(0) : null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 构建质检完成通知参数
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Object buildNotification(QcInspectionMainVo main, BigDecimal qty, boolean isConcession) {
|
|
|
|
|
InspectionCompleteNotification notification = new InspectionCompleteNotification();
|
|
|
|
|
|
|
|
|
|
// 基本信息
|
|
|
|
|
notification.setInspectionNo(main.getInspectionNo());
|
|
|
|
|
notification.setMaterialCode(main.getMaterialCode());
|
|
|
|
|
notification.setInstockCode(main.getRemark()); // remark 存储入库单号
|
|
|
|
|
notification.setBatchCode(main.getBatchNo());
|
|
|
|
|
|
|
|
|
|
// 质检结果
|
|
|
|
|
if (isConcession) {
|
|
|
|
|
notification.setResult("0"); // 让步接收视为合格
|
|
|
|
|
notification.setQualifiedQty(qty != null ? qty : main.getQualifiedQty());
|
|
|
|
|
notification.setUnqualifiedQty(BigDecimal.ZERO);
|
|
|
|
|
} else {
|
|
|
|
|
notification.setResult(main.getResult());
|
|
|
|
|
notification.setQualifiedQty(main.getQualifiedQty());
|
|
|
|
|
notification.setUnqualifiedQty(main.getUnqualifiedQty());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
notification.setStatus("1"); // 已完成
|
|
|
|
|
notification.setInspectionEndTime(main.getInspectionEndTime() != null
|
|
|
|
|
? DateUtils.formatDateTime(main.getInspectionEndTime())
|
|
|
|
|
: DateUtils.getTime());
|
|
|
|
|
|
|
|
|
|
return notification;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ==================== 兼容旧接口(已废弃) ====================
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @deprecated 已废弃,请使用 {@link #notifyWmsInspectionComplete(QcInspectionMainVo)}
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Deprecated
|
|
|
|
|
public boolean notifyWmsForQualified(QcInspectionMainVo main) {
|
|
|
|
|
return notifyWmsInspectionComplete(main);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @deprecated 已废弃,请使用 {@link #notifyWmsForConcessionAccepted(QcUnqualifiedReviewVo)}
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
@Deprecated
|
|
|
|
|
public boolean notifyWmsForConcession(String inspectionNo, BigDecimal concessionQty, String batchCode) {
|
|
|
|
|
log.warn("调用了已废弃的方法 notifyWmsForConcession,请使用 notifyWmsForConcessionAccepted");
|
|
|
|
|
QcInspectionMainVo main = queryByInspectionNo(inspectionNo);
|
|
|
|
|
if (main == null) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return callbackWmsUpdateStatus(main, "2", concessionQty, getQcInspectionType(main));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|