diff --git a/ruoyi-admin/src/main/java/com/ruoyi/quality/controller/QualityOrderController.java b/ruoyi-admin/src/main/java/com/ruoyi/quality/controller/QualityOrderController.java index c725cbbc..0e998168 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/quality/controller/QualityOrderController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/quality/controller/QualityOrderController.java @@ -165,7 +165,6 @@ public class QualityOrderController extends BaseController public String qualityReport( @RequestParam("materialNo") String materialNo, @RequestParam("supplierCode") String supplierCode, ModelMap mmap) { -// QualityOrder qualityOrder = qualityOrderService.selectQualityOrderById(qualityOrderId); QualityOrderReport qualityOrderReport = orderReportService.selectQualityOrderReportByNoAndCode(materialNo,supplierCode); mmap.put("qualityOrderReport", qualityOrderReport); return prefix + "/qualityOrderReport"; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityOrderDetail.java b/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityOrderDetail.java index 51dbed53..ccd903e2 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityOrderDetail.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityOrderDetail.java @@ -111,23 +111,23 @@ public class QualityOrderDetail extends BaseEntity /** 生产订单数 */ @Excel(name = "生产订单数") - private String makeTotal; + private Integer makeTotal; /** 本次到货数量 */ @Excel(name = "本次到货数量") - private Long thisArrivedNum; + private Integer thisArrivedNum; /** 品质已合格数 */ @Excel(name = "品质已合格数") - private Long qualityHasqualifiedNum; + private Integer qualityHasqualifiedNum; /** 品质合格数 */ @Excel(name = "品质合格数") - private Long qualityQualifiedNum; + private Integer qualityQualifiedNum; /** 品质不合格数 */ @Excel(name = "品质不合格数") - private Long qualityUnqualifiedNum; + private Integer qualityUnqualifiedNum; public void setQualityOrderDetailId(Long qualityOrderDetailId) { @@ -332,56 +332,50 @@ public class QualityOrderDetail extends BaseEntity this.materialProcessMethod = materialProcessMethod; } - public String getMaterialProcessMethod() - { + public String getMaterialProcessMethod() { return materialProcessMethod; } - public void setMakeTotal(String makeTotal) - { - this.makeTotal = makeTotal; - } - public String getMakeTotal() - { + public Integer getMakeTotal() { return makeTotal; } - public void setThisArrivedNum(Long thisArrivedNum) - { - this.thisArrivedNum = thisArrivedNum; + + public void setMakeTotal(Integer makeTotal) { + this.makeTotal = makeTotal; } - public Long getThisArrivedNum() - { + public Integer getThisArrivedNum() { return thisArrivedNum; } - public void setQualityHasqualifiedNum(Long qualityHasqualifiedNum) - { - this.qualityHasqualifiedNum = qualityHasqualifiedNum; + + public void setThisArrivedNum(Integer thisArrivedNum) { + this.thisArrivedNum = thisArrivedNum; } - public Long getQualityHasqualifiedNum() - { + public Integer getQualityHasqualifiedNum() { return qualityHasqualifiedNum; } - public void setQualityQualifiedNum(Long qualityQualifiedNum) - { - this.qualityQualifiedNum = qualityQualifiedNum; + + public void setQualityHasqualifiedNum(Integer qualityHasqualifiedNum) { + this.qualityHasqualifiedNum = qualityHasqualifiedNum; } - public Long getQualityQualifiedNum() - { + public Integer getQualityQualifiedNum() { return qualityQualifiedNum; } - public void setQualityUnqualifiedNum(Long qualityUnqualifiedNum) - { - this.qualityUnqualifiedNum = qualityUnqualifiedNum; + + public void setQualityQualifiedNum(Integer qualityQualifiedNum) { + this.qualityQualifiedNum = qualityQualifiedNum; } - public Long getQualityUnqualifiedNum() - { + public Integer getQualityUnqualifiedNum() { return qualityUnqualifiedNum; } + public void setQualityUnqualifiedNum(Integer qualityUnqualifiedNum) { + this.qualityUnqualifiedNum = qualityUnqualifiedNum; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityOrderReport.java b/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityOrderReport.java index 092e9be8..dc474e86 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityOrderReport.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityOrderReport.java @@ -48,7 +48,7 @@ public class QualityOrderReport extends BaseEntity /** ok允收数 */ @Excel(name = "ok允收数") - private String okAcceptedNum; + private Integer okAcceptedNum; /** ok报告图片 */ @Excel(name = "ok报告图片") @@ -77,7 +77,7 @@ public class QualityOrderReport extends BaseEntity /** 不良数量 */ @Excel(name = "不良数量") - private String processBadNum; + private Integer processBadNum; /** 不合格报告url */ @Excel(name = "不合格报告url") @@ -149,15 +149,7 @@ public class QualityOrderReport extends BaseEntity { return qualityHasqualifiedNum; } - public void setOkAcceptedNum(String okAcceptedNum) - { - this.okAcceptedNum = okAcceptedNum; - } - public String getOkAcceptedNum() - { - return okAcceptedNum; - } public void setOkReportUrl(String okReportUrl) { this.okReportUrl = okReportUrl; @@ -212,15 +204,7 @@ public class QualityOrderReport extends BaseEntity { return processBadGrade; } - public void setProcessBadNum(String processBadNum) - { - this.processBadNum = processBadNum; - } - public String getProcessBadNum() - { - return processBadNum; - } public void setUnqualifiedReportUrl(String unqualifiedReportUrl) { this.unqualifiedReportUrl = unqualifiedReportUrl; @@ -240,6 +224,22 @@ public class QualityOrderReport extends BaseEntity this.unqualifiedDataList = unqualifiedDataList; } + public Integer getOkAcceptedNum() { + return okAcceptedNum; + } + + public void setOkAcceptedNum(Integer okAcceptedNum) { + this.okAcceptedNum = okAcceptedNum; + } + + public Integer getProcessBadNum() { + return processBadNum; + } + + public void setProcessBadNum(Integer processBadNum) { + this.processBadNum = processBadNum; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityOrderReportUnqualified.java b/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityOrderReportUnqualified.java index c7a22f16..d5b7426e 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityOrderReportUnqualified.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/quality/domain/QualityOrderReportUnqualified.java @@ -44,7 +44,7 @@ public class QualityOrderReportUnqualified extends BaseEntity /** 不良数量 */ @Excel(name = "不良数量") - private String processBadNum; + private Integer processBadNum; /** 不合格报告url */ @Excel(name = "不合格报告url") @@ -113,16 +113,16 @@ public class QualityOrderReportUnqualified extends BaseEntity { return processBadGrade; } - public void setProcessBadNum(String processBadNum) - { - this.processBadNum = processBadNum; - } - public String getProcessBadNum() - { + public Integer getProcessBadNum() { return processBadNum; } - public void setUnqualifiedReportUrl(String unqualifiedReportUrl) + + public void setProcessBadNum(Integer processBadNum) { + this.processBadNum = processBadNum; + } + + public void setUnqualifiedReportUrl(String unqualifiedReportUrl) { this.unqualifiedReportUrl = unqualifiedReportUrl; } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/quality/mapper/QualityOrderDetailMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/quality/mapper/QualityOrderDetailMapper.java index d9ade2f9..a9c241ac 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/quality/mapper/QualityOrderDetailMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/quality/mapper/QualityOrderDetailMapper.java @@ -91,4 +91,11 @@ public interface QualityOrderDetailMapper * @return 品质管理品质单详情集合 */ List selectQualityOrderDetailListByCode(String qualityOrderCode); + + /** + * 根据供应商Id和物料号查询品质管理品质单详情 + * + */ + QualityOrderDetail selectQualityOrderDetailListByCodeAndNo(QualityOrderDetail qualityOrderDetail); + } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/quality/service/impl/QualityOrderReportServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/quality/service/impl/QualityOrderReportServiceImpl.java index 74ab6534..467b3fc7 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/quality/service/impl/QualityOrderReportServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/quality/service/impl/QualityOrderReportServiceImpl.java @@ -2,11 +2,16 @@ package com.ruoyi.quality.service.impl; import java.util.Date; import java.util.List; + +import com.ruoyi.common.exception.BusinessException; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.quality.domain.QualityOrderDetail; import com.ruoyi.quality.domain.QualityOrderReportUnqualified; +import com.ruoyi.quality.mapper.QualityOrderDetailMapper; import com.ruoyi.quality.mapper.QualityOrderReportUnqualifiedMapper; +import org.apache.avalon.framework.service.ServiceException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.quality.mapper.QualityOrderReportMapper; @@ -30,6 +35,9 @@ public class QualityOrderReportServiceImpl implements IQualityOrderReportService @Autowired private QualityOrderReportUnqualifiedMapper unqualifiedMapper; + @Autowired + private QualityOrderDetailMapper orderDetailMapper; + /** * 查询品质管理品质单报告 * @@ -86,8 +94,40 @@ public class QualityOrderReportServiceImpl implements IQualityOrderReportService String supplierCode = qualityOrderReport.getSupplierCode(); tempOrderReportUnqualified.setMaterialNo(materialNo); tempOrderReportUnqualified.setSupplierCode(supplierCode); + + QualityOrderDetail tempQualityOrderDetail = new QualityOrderDetail(); + tempQualityOrderDetail.setMaterialNo(materialNo); + tempQualityOrderDetail.setSupplierCode(supplierCode); + + + //从数据库查询品质报告详情数据 + QualityOrderDetail qualityOrderDetail = orderDetailMapper.selectQualityOrderDetailListByCodeAndNo(tempQualityOrderDetail); + //计算品质单详情中的品质合格数量 + Integer okAcceptedNum = qualityOrderReport.getOkAcceptedNum(); + Integer specialConcessionsNum = qualityOrderReport.getSpecialConcessionsNum(); + //品质合格数 + Integer qualityQualifiedNum = okAcceptedNum + specialConcessionsNum; + //本次到货数 + Integer thisArrivedNum = qualityOrderDetail.getThisArrivedNum(); + if (qualityQualifiedNum>thisArrivedNum){ + throw new BusinessException("OK允收数和特采/让步数总和小于等于本次到货数"); + } + //更新品质报告详情中的品质合格数的数据 + qualityOrderDetail.setQualityQualifiedNum(qualityQualifiedNum); + + List unqualifiedDataList = qualityOrderReport.getUnqualifiedDataList(); + //计算不良数量的合计值 + int processBadNumTotal = unqualifiedDataList.stream().mapToInt(QualityOrderReportUnqualified::getProcessBadNum).sum(); + + if (processBadNumTotal>thisArrivedNum){ + throw new BusinessException("不良数量的总和小于等于本次到货数"); + } + + qualityOrderDetail.setQualityUnqualifiedNum(processBadNumTotal); + orderDetailMapper.updateQualityOrderDetail(qualityOrderDetail); + List qualityOrderReportUnqualifieds = unqualifiedMapper.selectQualityOrderReportUnqualifiedByCodeAndNo(tempOrderReportUnqualified); if (StringUtils.isEmpty(qualityOrderReportUnqualifieds)){ diff --git a/ruoyi-admin/src/main/resources/mapper/quality/QualityOrderDetailMapper.xml b/ruoyi-admin/src/main/resources/mapper/quality/QualityOrderDetailMapper.xml index 80864f97..94774c6b 100644 --- a/ruoyi-admin/src/main/resources/mapper/quality/QualityOrderDetailMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/quality/QualityOrderDetailMapper.xml @@ -66,6 +66,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where quality_order_code = #{qualityOrderCode} + + + + insert into quality_order_detail diff --git a/ruoyi-admin/src/main/resources/templates/quality/qualityOrder/qualityOrderReport.html b/ruoyi-admin/src/main/resources/templates/quality/qualityOrder/qualityOrderReport.html index 1e860cec..cca0cb1d 100644 --- a/ruoyi-admin/src/main/resources/templates/quality/qualityOrder/qualityOrderReport.html +++ b/ruoyi-admin/src/main/resources/templates/quality/qualityOrder/qualityOrderReport.html @@ -6,7 +6,7 @@
-
+
@@ -104,13 +104,13 @@ var processBadGradeDatas = [[${@dict.getType('process_bad_grade')}]]; var prefix = ctx + "quality/qualityOrder"; - $("#form-qualityReport-edit").validate({ + $("#form-qualityOrderReport-edit").validate({ focusCleanup: true }); function submitHandler() { // 获取表单数据 - const qualityReportData = $("#form-qualityReport-edit").serializeArray().reduce((obj, item) => { + const qualityReportData = $("#form-qualityOrderReport-edit").serializeArray().reduce((obj, item) => { obj[item.name] = item.value; return obj; }, {});