|
|
|
@ -75,13 +75,13 @@ public class InspectionInboundServiceImpl implements InspectionInboundService { |
|
|
|
private String ifsDBName; |
|
|
|
@Value("${custom.ifs-domainUserID}") |
|
|
|
private String domainUserID; |
|
|
|
|
|
|
|
|
|
|
|
@Value("${ldap-control.control-flag:false}") |
|
|
|
private Boolean ldapFlag; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IfsInspectionHistoryService ifsInspectionHistoryService; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 获取当前用户的域控账号,如果开启了域控账号则获取用户的域控账号,否则使用配置的默认值 |
|
|
|
*/ |
|
|
|
@ -622,24 +622,29 @@ public class InspectionInboundServiceImpl implements InspectionInboundService { |
|
|
|
throw new RuntimeException("确认不合格处理失败: " + e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public List<UnqualifiedInspectionDto> getUnqualifiedInspectionListFromIfs(UnqualifiedInspectionDto unqualifiedInspectionDto) { |
|
|
|
try { |
|
|
|
log.info("开始从IFS获取检验不合格数据"); |
|
|
|
|
|
|
|
|
|
|
|
// 调用IFS服务获取检验历史数据 |
|
|
|
List<IfsInspectionHistoryDto> ifsHistoryList = ifsInspectionHistoryService.getIfsInspectionHistory(); |
|
|
|
|
|
|
|
List<IfsInspectionHistoryDto> ifsHistoryList = ifsInspectionHistoryService.getIfsInspectionHistory(unqualifiedInspectionDto.getSite()); |
|
|
|
|
|
|
|
List<UnqualifiedInspectionDto> result = new ArrayList<>(); |
|
|
|
|
|
|
|
if (unqualifiedInspectionDto.getTransNo() != null) { |
|
|
|
ifsHistoryList = ifsHistoryList.stream() |
|
|
|
.filter(h -> unqualifiedInspectionDto.getTransNo().equals(h.getOrderNo())) |
|
|
|
.toList(); |
|
|
|
|
|
|
|
} |
|
|
|
for (IfsInspectionHistoryDto ifsHistory : ifsHistoryList) { |
|
|
|
// 根据transactionCode判断处理类型 |
|
|
|
String processType = mapTransactionCodeToProcessType(ifsHistory.getTransactionCode()); |
|
|
|
|
|
|
|
|
|
|
|
// 只处理不合格的记录(有退货、报废或换货数量的) |
|
|
|
BigDecimal unqualifiedQty = getUnqualifiedQtyFromIfs(ifsHistory); |
|
|
|
|
|
|
|
|
|
|
|
if (unqualifiedQty != null && unqualifiedQty.compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
UnqualifiedInspectionDto dto = new UnqualifiedInspectionDto(); |
|
|
|
dto.setSite(ifsHistory.getContract()); // 使用contract作为site |
|
|
|
@ -661,20 +666,20 @@ public class InspectionInboundServiceImpl implements InspectionInboundService { |
|
|
|
dto.setUserName(""); // IFS数据中没有用户名 |
|
|
|
dto.setRemark(getRemarkFromIfs(ifsHistory)); // 组合备注信息 |
|
|
|
dto.setProcessType(processType); // 处理类型 |
|
|
|
|
|
|
|
|
|
|
|
result.add(dto); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
log.info("从IFS获取到{}条不合格检验记录", result.size()); |
|
|
|
return result; |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
log.error("从IFS获取检验不合格数据失败: {}", e.getMessage(), e); |
|
|
|
throw new RuntimeException("获取IFS检验不合格数据失败: " + e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 根据transactionCode映射处理类型 |
|
|
|
*/ |
|
|
|
@ -682,7 +687,7 @@ public class InspectionInboundServiceImpl implements InspectionInboundService { |
|
|
|
if (transactionCode == null) { |
|
|
|
return "UNKNOWN"; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
switch (transactionCode.toUpperCase()) { |
|
|
|
case "RETWORK": |
|
|
|
case "RETURN": |
|
|
|
@ -697,44 +702,44 @@ public class InspectionInboundServiceImpl implements InspectionInboundService { |
|
|
|
return "UNKNOWN"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 从IFS历史数据中获取不合格数量 |
|
|
|
*/ |
|
|
|
private BigDecimal getUnqualifiedQtyFromIfs(IfsInspectionHistoryDto ifsHistory) { |
|
|
|
BigDecimal qty = BigDecimal.ZERO; |
|
|
|
|
|
|
|
|
|
|
|
// 退货数量 |
|
|
|
if (ifsHistory.getSourceQtyReturn() != null && ifsHistory.getSourceQtyReturn() > 0) { |
|
|
|
qty = qty.add(BigDecimal.valueOf(ifsHistory.getSourceQtyReturn())); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 报废数量 |
|
|
|
if (ifsHistory.getSourceQtyScrapped() != null && ifsHistory.getSourceQtyScrapped() > 0) { |
|
|
|
qty = qty.add(BigDecimal.valueOf(ifsHistory.getSourceQtyScrapped())); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return qty; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 从IFS历史数据中组合备注信息 |
|
|
|
*/ |
|
|
|
private String getRemarkFromIfs(IfsInspectionHistoryDto ifsHistory) { |
|
|
|
StringBuilder remark = new StringBuilder(); |
|
|
|
|
|
|
|
|
|
|
|
if (ifsHistory.getReturnCauseDesc() != null && !ifsHistory.getReturnCauseDesc().isEmpty()) { |
|
|
|
remark.append("退货原因: ").append(ifsHistory.getReturnCauseDesc()).append("; "); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (ifsHistory.getScrapCauseDesc() != null && !ifsHistory.getScrapCauseDesc().isEmpty()) { |
|
|
|
remark.append("报废原因: ").append(ifsHistory.getScrapCauseDesc()).append("; "); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (ifsHistory.getRejectCode() != null && !ifsHistory.getRejectCode().isEmpty()) { |
|
|
|
remark.append("拒收代码: ").append(ifsHistory.getRejectCode()).append("; "); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return remark.toString(); |
|
|
|
} |
|
|
|
} |