|
@ -91,7 +91,7 @@ public class QualityOrderReportServiceImpl implements IQualityOrderReportService |
|
|
* @param qualityOrderReport 品质管理品质单报告 |
|
|
* @param qualityOrderReport 品质管理品质单报告 |
|
|
* @return 结果 |
|
|
* @return 结果 |
|
|
*/ |
|
|
*/ |
|
|
@Transactional |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Override |
|
|
@Override |
|
|
public int updateQualityOrderReport(QualityOrderReport qualityOrderReport) |
|
|
public int updateQualityOrderReport(QualityOrderReport qualityOrderReport) |
|
|
{ |
|
|
{ |
|
@ -115,97 +115,102 @@ public class QualityOrderReportServiceImpl implements IQualityOrderReportService |
|
|
Integer specialConcessionsNum = qualityOrderReport.getSpecialConcessionsNum(); |
|
|
Integer specialConcessionsNum = qualityOrderReport.getSpecialConcessionsNum(); |
|
|
//品质合格数
|
|
|
//品质合格数
|
|
|
Integer qualityQualifiedNum = okAcceptedNum + specialConcessionsNum; |
|
|
Integer qualityQualifiedNum = okAcceptedNum + specialConcessionsNum; |
|
|
|
|
|
//后续要处理这个本次到货数
|
|
|
//本次到货数
|
|
|
//本次到货数
|
|
|
Integer thisArrivedNum = qualityOrderDetail.getThisArrivedNum(); |
|
|
Integer thisArrivedNum = qualityOrderDetail.getThisArrivedNum(); |
|
|
if (qualityQualifiedNum>thisArrivedNum){ |
|
|
if (thisArrivedNum != null){ |
|
|
throw new BusinessException("OK允收数和特采/让步数总和小于等于本次到货数"); |
|
|
if (qualityQualifiedNum>thisArrivedNum){ |
|
|
|
|
|
throw new BusinessException("OK允收数和特采/让步数总和小于等于本次到货数"); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
//更新品质报告详情中的品质合格数的数据
|
|
|
//更新品质报告详情中的品质合格数的数据
|
|
|
qualityOrderDetail.setQualityQualifiedNum(qualityQualifiedNum); |
|
|
qualityOrderDetail.setQualityQualifiedNum(qualityQualifiedNum); |
|
|
|
|
|
|
|
|
|
|
|
//获得品质报告中的不合格数模块数据
|
|
|
List<QualityOrderReportUnqualified> unqualifiedDataList = qualityOrderReport.getUnqualifiedDataList(); |
|
|
List<QualityOrderReportUnqualified> unqualifiedDataList = qualityOrderReport.getUnqualifiedDataList(); |
|
|
|
|
|
|
|
|
/*如果进行品质的订单类型是采购或者委外*/ |
|
|
/*如果进行品质的订单类型是采购或者委外*/ |
|
|
if (qualityOrderDetail.getQualityOrderType().equals("0") || qualityOrderDetail.getQualityOrderType().equals("2")){ |
|
|
// if (qualityOrderDetail.getQualityOrderType().equals("0") || qualityOrderDetail.getQualityOrderType().equals("2")){
|
|
|
/*有品质不合格,需要在退换货入库前退货进行记录*/ |
|
|
// /*有品质不合格,需要在退换货入库前退货进行记录*/
|
|
|
//更改日期格式,以提高可读性
|
|
|
|
|
|
// SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
// String dataPart = df.format(new Date());
|
|
|
|
|
|
//
|
|
|
//
|
|
|
// //移除日期中的分隔符以便于后续处理
|
|
|
// String refundsExchangesCode = redisCache.generateBillNo("ZCGX");
|
|
|
// String prefix = "ZCGX"+dataPart.replace("-","");
|
|
|
// QualityRefundsExchanges qualityRefundsExchanges = new QualityRefundsExchanges();
|
|
|
|
|
|
// qualityRefundsExchanges.setRefundsExchangesCode(refundsExchangesCode);
|
|
|
|
|
|
// qualityRefundsExchanges.setRefundsExchangesStatus("0");
|
|
|
//
|
|
|
//
|
|
|
// //查询数据库中退换货单号最大的编号
|
|
|
// for (QualityOrderReportUnqualified tempQualityOrderReportUnqualified : unqualifiedDataList) {
|
|
|
// String maxCode = refundsExchangesOrderMapper.findMaxRoundCode(prefix);
|
|
|
// QualityRefundsExchangesOrder qualityRefundsExchangesOrder = new QualityRefundsExchangesOrder();
|
|
|
// String newCode = generateNewCode(prefix,maxCode);
|
|
|
// qualityRefundsExchangesOrder.setRefundsExchangesCode(refundsExchangesCode);
|
|
|
String refundsExchangesCode = redisCache.generateBillNo("ZCGX"); |
|
|
// qualityRefundsExchangesOrder.setOkReportUrl(qualityOrderReport.getOkReportUrl());
|
|
|
QualityRefundsExchanges qualityRefundsExchanges = new QualityRefundsExchanges(); |
|
|
// qualityRefundsExchangesOrder.setOkAcceptedNum(qualityOrderReport.getOkAcceptedNum());
|
|
|
qualityRefundsExchanges.setRefundsExchangesCode(refundsExchangesCode); |
|
|
// qualityRefundsExchangesOrder.setSpecialReportUrl(qualityOrderReport.getSpecialReportUrl());
|
|
|
qualityRefundsExchanges.setRefundsExchangesStatus("0"); |
|
|
// qualityRefundsExchangesOrder.setSpecialConcessionsNum(qualityOrderReport.getSpecialConcessionsNum());
|
|
|
|
|
|
// qualityRefundsExchangesOrder.setMaterialNo(materialNo);
|
|
|
for (QualityOrderReportUnqualified tempQualityOrderReportUnqualified : unqualifiedDataList) { |
|
|
// qualityRefundsExchangesOrder.setMaterialName(qualityOrderReport.getMaterialName());
|
|
|
QualityRefundsExchangesOrder qualityRefundsExchangesOrder = new QualityRefundsExchangesOrder(); |
|
|
// qualityRefundsExchangesOrder.setMakeTotal(qualityOrderReport.getMakeTotal());
|
|
|
qualityRefundsExchangesOrder.setRefundsExchangesCode(refundsExchangesCode); |
|
|
// qualityRefundsExchangesOrder.setQualityHasqualifiedNum(qualityOrderReport.getQualityHasqualifiedNum());
|
|
|
qualityRefundsExchangesOrder.setOkReportUrl(qualityOrderReport.getOkReportUrl()); |
|
|
// qualityRefundsExchangesOrder.setProcessBadNum(tempQualityOrderReportUnqualified.getProcessBadNum());
|
|
|
qualityRefundsExchangesOrder.setOkAcceptedNum(qualityOrderReport.getOkAcceptedNum()); |
|
|
// qualityRefundsExchangesOrder.setProcessBadClassification(tempQualityOrderReportUnqualified.getProcessBadClassification());
|
|
|
qualityRefundsExchangesOrder.setSpecialReportUrl(qualityOrderReport.getSpecialReportUrl()); |
|
|
// qualityRefundsExchangesOrder.setProcessBadGrade(tempQualityOrderReportUnqualified.getProcessBadGrade());
|
|
|
qualityRefundsExchangesOrder.setSpecialConcessionsNum(qualityOrderReport.getSpecialConcessionsNum()); |
|
|
// qualityRefundsExchangesOrder.setUpdateBy(loginName);
|
|
|
qualityRefundsExchangesOrder.setMaterialNo(materialNo); |
|
|
// qualityRefundsExchangesOrder.setUpdateTime(new Date());
|
|
|
qualityRefundsExchangesOrder.setMaterialName(qualityOrderReport.getMaterialName()); |
|
|
// refundsExchangesOrderMapper.insertQualityRefundsExchangesOrder(qualityRefundsExchangesOrder);
|
|
|
qualityRefundsExchangesOrder.setMakeTotal(qualityOrderReport.getMakeTotal()); |
|
|
// }
|
|
|
qualityRefundsExchangesOrder.setQualityHasqualifiedNum(qualityOrderReport.getQualityHasqualifiedNum()); |
|
|
// }
|
|
|
qualityRefundsExchangesOrder.setProcessBadNum(tempQualityOrderReportUnqualified.getProcessBadNum()); |
|
|
|
|
|
qualityRefundsExchangesOrder.setProcessBadClassification(tempQualityOrderReportUnqualified.getProcessBadClassification()); |
|
|
|
|
|
qualityRefundsExchangesOrder.setProcessBadGrade(tempQualityOrderReportUnqualified.getProcessBadGrade()); |
|
|
|
|
|
qualityRefundsExchangesOrder.setUpdateBy(loginName); |
|
|
|
|
|
qualityRefundsExchangesOrder.setUpdateTime(new Date()); |
|
|
|
|
|
refundsExchangesOrderMapper.insertQualityRefundsExchangesOrder(qualityRefundsExchangesOrder); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//计算不良数量的合计值
|
|
|
//计算不良数量的合计值
|
|
|
int processBadNumTotal = unqualifiedDataList.stream().mapToInt(QualityOrderReportUnqualified::getProcessBadNum).sum(); |
|
|
int processBadNumTotal = unqualifiedDataList.stream().mapToInt(QualityOrderReportUnqualified::getProcessBadNum).sum(); |
|
|
|
|
|
|
|
|
if (processBadNumTotal>thisArrivedNum){ |
|
|
//后续处理本次到货数
|
|
|
throw new BusinessException("不良数量的总和小于等于本次到货数"); |
|
|
// if (processBadNumTotal>thisArrivedNum){
|
|
|
} |
|
|
// throw new BusinessException("不良数量的总和小于等于本次到货数");
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
//更新品质报告详情品质不合格数
|
|
|
qualityOrderDetail.setQualityUnqualifiedNum(processBadNumTotal); |
|
|
qualityOrderDetail.setQualityUnqualifiedNum(processBadNumTotal); |
|
|
orderDetailMapper.updateQualityOrderDetail(qualityOrderDetail); |
|
|
qualityOrderDetail.setUpdateBy(loginName); |
|
|
|
|
|
qualityOrderDetail.setUpdateTime(new Date()); |
|
|
|
|
|
//更新品质报告详情数据表
|
|
|
|
|
|
int updateQualityOrderDetailResult = orderDetailMapper.updateQualityOrderDetail(qualityOrderDetail); |
|
|
|
|
|
|
|
|
|
|
|
if (updateQualityOrderDetailResult <= 0){ |
|
|
|
|
|
throw new BusinessException("更新品质单详情数据失败"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<QualityOrderReportUnqualified> qualityOrderReportUnqualifieds = unqualifiedMapper.selectQualityOrderReportUnqualifiedByCodeAndNo(tempOrderReportUnqualified); |
|
|
List<QualityOrderReportUnqualified> qualityOrderReportUnqualifieds = unqualifiedMapper.selectQualityOrderReportUnqualifiedByCodeAndNo(tempOrderReportUnqualified); |
|
|
if (StringUtils.isEmpty(qualityOrderReportUnqualifieds)){ |
|
|
if (StringUtils.isEmpty(qualityOrderReportUnqualifieds)){ |
|
|
//如果后端不合格数列表值为空,就新增一个
|
|
|
//如果后端不合格数列表值为空,就新增一个
|
|
|
for (QualityOrderReportUnqualified tempQualityOrderReportUnqualified : unqualifiedDataList) { |
|
|
for (QualityOrderReportUnqualified tempQualityOrderReportUnqualified : unqualifiedDataList) { |
|
|
QualityOrderReportUnqualified qualityOrderReportUnqualified = getQualityOrderReportUnqualified(loginName, materialNo, supplierCode, tempQualityOrderReportUnqualified); |
|
|
QualityOrderReportUnqualified qualityOrderReportUnqualified = getQualityOrderReportUnqualified(materialNo, supplierCode, tempQualityOrderReportUnqualified); |
|
|
|
|
|
qualityOrderReportUnqualified.setCreateBy(loginName); |
|
|
|
|
|
qualityOrderReportUnqualified.setCreateTime(new Date()); |
|
|
unqualifiedMapper.insertQualityOrderReportUnqualified(qualityOrderReportUnqualified); |
|
|
unqualifiedMapper.insertQualityOrderReportUnqualified(qualityOrderReportUnqualified); |
|
|
} |
|
|
} |
|
|
}else { |
|
|
}else { |
|
|
//如果后端不合格数列表值为不空,就更新
|
|
|
//如果后端不合格数列表值为不空,就更新
|
|
|
for (QualityOrderReportUnqualified tempQualityOrderReportUnqualified : unqualifiedDataList) { |
|
|
for (QualityOrderReportUnqualified tempQualityOrderReportUnqualified : unqualifiedDataList) { |
|
|
QualityOrderReportUnqualified qualityOrderReportUnqualified = getQualityOrderReportUnqualified(loginName, materialNo, supplierCode, tempQualityOrderReportUnqualified); |
|
|
QualityOrderReportUnqualified qualityOrderReportUnqualified = getQualityOrderReportUnqualified(materialNo, supplierCode, tempQualityOrderReportUnqualified); |
|
|
|
|
|
qualityOrderReportUnqualified.setUpdateBy(loginName); |
|
|
|
|
|
qualityOrderReportUnqualified.setUpdateTime(new Date()); |
|
|
unqualifiedMapper.updateQualityOrderReportUnqualified(qualityOrderReportUnqualified); |
|
|
unqualifiedMapper.updateQualityOrderReportUnqualified(qualityOrderReportUnqualified); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
qualityOrderReport.setUpdateBy(loginName); |
|
|
qualityOrderReport.setUpdateBy(loginName); |
|
|
qualityOrderReport.setUpdateTime(DateUtils.getNowDate()); |
|
|
qualityOrderReport.setUpdateTime(new Date()); |
|
|
return qualityOrderReportMapper.updateQualityOrderReport(qualityOrderReport); |
|
|
return qualityOrderReportMapper.updateQualityOrderReport(qualityOrderReport); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static QualityOrderReportUnqualified getQualityOrderReportUnqualified(String loginName, String materialNo, String supplierCode, QualityOrderReportUnqualified tempQualityOrderReportUnqualified) { |
|
|
//更新品质报告不合格数量模块的数据
|
|
|
|
|
|
private static QualityOrderReportUnqualified getQualityOrderReportUnqualified(String materialNo, String supplierCode, QualityOrderReportUnqualified tempQualityOrderReportUnqualified) { |
|
|
QualityOrderReportUnqualified qualityOrderReportUnqualified = new QualityOrderReportUnqualified(); |
|
|
QualityOrderReportUnqualified qualityOrderReportUnqualified = new QualityOrderReportUnqualified(); |
|
|
qualityOrderReportUnqualified.setSupplierCode(supplierCode); |
|
|
qualityOrderReportUnqualified.setSupplierCode(supplierCode); |
|
|
qualityOrderReportUnqualified.setMaterialNo(materialNo); |
|
|
qualityOrderReportUnqualified.setMaterialNo(materialNo); |
|
|
qualityOrderReportUnqualified.setProcessBadNum(tempQualityOrderReportUnqualified.getProcessBadNum()); |
|
|
qualityOrderReportUnqualified.setProcessBadNum(tempQualityOrderReportUnqualified.getProcessBadNum()); |
|
|
qualityOrderReportUnqualified.setProcessBadClassification(tempQualityOrderReportUnqualified.getProcessBadClassification()); |
|
|
qualityOrderReportUnqualified.setProcessBadClassification(tempQualityOrderReportUnqualified.getProcessBadClassification()); |
|
|
qualityOrderReportUnqualified.setProcessBadGrade(tempQualityOrderReportUnqualified.getProcessBadGrade()); |
|
|
qualityOrderReportUnqualified.setProcessBadGrade(tempQualityOrderReportUnqualified.getProcessBadGrade()); |
|
|
qualityOrderReportUnqualified.setUpdateBy(loginName); |
|
|
|
|
|
qualityOrderReportUnqualified.setUpdateTime(new Date()); |
|
|
|
|
|
return qualityOrderReportUnqualified; |
|
|
return qualityOrderReportUnqualified; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|