From 02a6be177d9556a5d6b6da680f1f5f948de997d5 Mon Sep 17 00:00:00 2001 From: xs Date: Thu, 31 Oct 2024 08:49:50 +0800 Subject: [PATCH] =?UTF-8?q?3.4.0=20PDA=E6=8E=A5=E5=8F=A3=EF=BC=9A=20?= =?UTF-8?q?=E5=8E=9F=E6=9D=90=E6=96=99=E8=B4=A8=E6=A3=80=EF=BC=9A=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E6=9D=A1=E7=A0=81=E7=B1=BB=E5=9E=8B=EF=BC=8C=E5=A6=82?= =?UTF-8?q?=E6=9E=9C=E6=98=AF=E5=90=88=E5=B9=B6=E6=9D=A1=E7=A0=81=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E9=9C=80=E8=A6=81=E6=89=BE=E5=88=B0=E4=BB=BB=E6=84=8F?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E7=89=A9=E6=96=99=E7=9A=84=E8=B4=A8=E6=A3=80?= =?UTF-8?q?=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hw-modules/hw-qms/pom.xml | 4 + .../qms/controller/QmsMobileController.java | 21 ++--- .../com/hw/qms/domain/MesBaseBarcodeInfo.java | 17 +++- .../hw/qms/service/IQmsCheckRuleService.java | 11 +++ .../impl/QmsCheckResultServiceImpl.java | 2 +- .../service/impl/QmsCheckRuleServiceImpl.java | 83 +++++++++++++++++-- .../impl/QmsQualityInstanceServiceImpl.java | 2 +- .../mapper/qms/MesBaseBarcodeInfoMapper.xml | 5 +- 8 files changed, 115 insertions(+), 30 deletions(-) diff --git a/hw-modules/hw-qms/pom.xml b/hw-modules/hw-qms/pom.xml index cd137cd..4f5e972 100644 --- a/hw-modules/hw-qms/pom.xml +++ b/hw-modules/hw-qms/pom.xml @@ -77,6 +77,10 @@ com.hw hw-common-swagger + + com.hw + hw-api-mes + diff --git a/hw-modules/hw-qms/src/main/java/com/hw/qms/controller/QmsMobileController.java b/hw-modules/hw-qms/src/main/java/com/hw/qms/controller/QmsMobileController.java index 796fb8d..70da62b 100644 --- a/hw-modules/hw-qms/src/main/java/com/hw/qms/controller/QmsMobileController.java +++ b/hw-modules/hw-qms/src/main/java/com/hw/qms/controller/QmsMobileController.java @@ -72,25 +72,16 @@ public class QmsMobileController extends BaseController { //扫描物料条码进入获取 String materialBarcode = qmsMaterialCheckVo.getMaterialBarcode(); + MesBaseBarcodeInfo baseBarcodeInfo = mesBaseBarcodeInfoService.selectMesBaseBarcodeInfoByBarcodeInfo(materialBarcode); + if (baseBarcodeInfo == null) { + throw new ServiceException("物料条码有误"); + } + QmsCheckResultDetail qmsCheckResultDetail = qmsCheckResultDetailService.getCheckResultDetail(materialBarcode); if (qmsCheckResultDetail != null) {//如果有质检结果,则返回已经保存的质检结果,否则返回需要质检的项目 return success(qmsCheckResultDetail); } else { - MesBaseBarcodeInfo baseBarcodeInfo = mesBaseBarcodeInfoService.selectMesBaseBarcodeInfoByBarcodeInfo(materialBarcode); - if (baseBarcodeInfo == null) { - throw new ServiceException("物料条码有误"); - } - Long materialId = baseBarcodeInfo.getMaterialId(); - QmsCheckRuleDetail queryCheckRuleDetail = new QmsCheckRuleDetail(); - queryCheckRuleDetail.setTargetId(materialId); - queryCheckRuleDetail.setTargetType(QmsConstants.QMS_CHECK_RULE_DETAIL_TARGET_TYPE_MATERIAL); - QmsCheckRule qmsCheckRule = qmsCheckRuleService.selectQmsCheckRuleByTarget(queryCheckRuleDetail); - if (qmsCheckRule == null) { - throw new ServiceException("无此物料的质检规则"); - } - qmsCheckRule.setMaterialId(materialId); - qmsCheckRule.setMaterialCode(baseBarcodeInfo.getMaterialCode()); - qmsCheckRule.setMaterialName(baseBarcodeInfo.getMaterialName()); + QmsCheckRule qmsCheckRule = qmsCheckRuleService.selectQmsCheckRuleByBarcode(baseBarcodeInfo); Long checkResultId = qmsCheckResultService.insertCheckResult(baseBarcodeInfo, qmsCheckRule); qmsCheckRule.setCheckResultId(checkResultId); return success(qmsCheckRule); diff --git a/hw-modules/hw-qms/src/main/java/com/hw/qms/domain/MesBaseBarcodeInfo.java b/hw-modules/hw-qms/src/main/java/com/hw/qms/domain/MesBaseBarcodeInfo.java index a2b3bd8..77f486a 100644 --- a/hw-modules/hw-qms/src/main/java/com/hw/qms/domain/MesBaseBarcodeInfo.java +++ b/hw-modules/hw-qms/src/main/java/com/hw/qms/domain/MesBaseBarcodeInfo.java @@ -95,7 +95,7 @@ public class MesBaseBarcodeInfo extends BaseEntity private String planDetailCode; /** 销售订单ID;适合生产出入库等 */ - private String saleOrderId; + private Long saleOrderId; /** 销售订单编号;适合生产出入库等 */ @Excel(name = "销售订单编号;适合生产出入库等") @@ -126,6 +126,9 @@ public class MesBaseBarcodeInfo extends BaseEntity private String materialName; + private String singleFlag; + + public void setBarcodeId(Long barcodeId) { this.barcodeId = barcodeId; @@ -289,11 +292,11 @@ public class MesBaseBarcodeInfo extends BaseEntity return planDetailCode; } - public String getSaleOrderId() { + public Long getSaleOrderId() { return saleOrderId; } - public void setSaleOrderId(String saleOrderId) { + public void setSaleOrderId(Long saleOrderId) { this.saleOrderId = saleOrderId; } @@ -368,6 +371,14 @@ public class MesBaseBarcodeInfo extends BaseEntity this.materialName = materialName; } + public String getSingleFlag() { + return singleFlag; + } + + public void setSingleFlag(String singleFlag) { + this.singleFlag = singleFlag; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/hw-modules/hw-qms/src/main/java/com/hw/qms/service/IQmsCheckRuleService.java b/hw-modules/hw-qms/src/main/java/com/hw/qms/service/IQmsCheckRuleService.java index 7135a61..4894ac2 100644 --- a/hw-modules/hw-qms/src/main/java/com/hw/qms/service/IQmsCheckRuleService.java +++ b/hw-modules/hw-qms/src/main/java/com/hw/qms/service/IQmsCheckRuleService.java @@ -1,6 +1,8 @@ package com.hw.qms.service; import java.util.List; + +import com.hw.qms.domain.MesBaseBarcodeInfo; import com.hw.qms.domain.QmsCheckRule; import com.hw.qms.domain.QmsCheckRuleDetail; import com.hw.qms.domain.QmsCheckRuleProject; @@ -81,4 +83,13 @@ public interface IQmsCheckRuleService * @return 检验规则维护 */ public QmsCheckRule selectQmsCheckRuleByTarget(QmsCheckRuleDetail qmsCheckRuleDetail); + + + /** + * 查询检验规则维护,连接check_rule_project + * + * @param baseBarcodeInfo 物料条码 + * @return 检验规则维护 + */ + public QmsCheckRule selectQmsCheckRuleByBarcode(MesBaseBarcodeInfo baseBarcodeInfo); } diff --git a/hw-modules/hw-qms/src/main/java/com/hw/qms/service/impl/QmsCheckResultServiceImpl.java b/hw-modules/hw-qms/src/main/java/com/hw/qms/service/impl/QmsCheckResultServiceImpl.java index 764c6a8..7013925 100644 --- a/hw-modules/hw-qms/src/main/java/com/hw/qms/service/impl/QmsCheckResultServiceImpl.java +++ b/hw-modules/hw-qms/src/main/java/com/hw/qms/service/impl/QmsCheckResultServiceImpl.java @@ -156,7 +156,7 @@ public class QmsCheckResultServiceImpl implements IQmsCheckResultService { qmsCheckResult.setCheckSample(qmsCheckRule.getCheckSample()); qmsCheckResult.setPlanCode(mesBaseBarcodeInfo.getPlanCode()); qmsCheckResult.setPlanDetailCode(mesBaseBarcodeInfo.getPlanDetailCode()); - qmsCheckResult.setSaleOrderId(mesBaseBarcodeInfo.getSaleOrderId()); + qmsCheckResult.setSaleOrderId(mesBaseBarcodeInfo.getSaleOrderId() == null ? "" : String.valueOf(mesBaseBarcodeInfo.getSaleOrderId())); qmsCheckResult.setSaleorderCode(mesBaseBarcodeInfo.getSaleorderCode()); qmsCheckResult.setPoNo(mesBaseBarcodeInfo.getPoNo()); qmsCheckResult.setCheckStatus(QmsConstants.QMS_CHECK_RESULT_CHECK_STATUS_CHECKED); diff --git a/hw-modules/hw-qms/src/main/java/com/hw/qms/service/impl/QmsCheckRuleServiceImpl.java b/hw-modules/hw-qms/src/main/java/com/hw/qms/service/impl/QmsCheckRuleServiceImpl.java index 6e7e0e2..9e6681b 100644 --- a/hw-modules/hw-qms/src/main/java/com/hw/qms/service/impl/QmsCheckRuleServiceImpl.java +++ b/hw-modules/hw-qms/src/main/java/com/hw/qms/service/impl/QmsCheckRuleServiceImpl.java @@ -3,10 +3,16 @@ package com.hw.qms.service.impl; import java.util.Date; import java.util.List; +import com.hw.common.core.constant.MesConstants; import com.hw.common.core.constant.QmsConstants; +import com.hw.common.core.constant.SecurityConstants; import com.hw.common.core.constant.WmsConstants; +import com.hw.common.core.domain.R; +import com.hw.common.core.exception.ServiceException; import com.hw.common.core.utils.DateUtils; import com.hw.common.security.utils.SecurityUtils; +import com.hw.mes.api.RemoteMesService; +import com.hw.mes.api.domain.MesSaleOrderRelate; import com.hw.qms.domain.*; import com.hw.qms.domain.vo.QmsMaterialCheckVo; import com.hw.qms.mapper.*; @@ -19,6 +25,8 @@ import com.hw.common.core.utils.StringUtils; import org.springframework.transaction.annotation.Transactional; import com.hw.qms.service.IQmsCheckRuleService; +import javax.annotation.Resource; + /** * 检验规则维护Service业务层处理 * @@ -33,6 +41,12 @@ public class QmsCheckRuleServiceImpl implements IQmsCheckRuleService { @Autowired private QmsCheckResultDetailMapper qmsCheckResultDetailMapper; + @Autowired + private MesBaseBarcodeInfoMapper mesBaseBarcodeInfoMapper; + + @Resource + private RemoteMesService remoteMesService; + /** * 查询检验规则维护 @@ -127,20 +141,16 @@ public class QmsCheckRuleServiceImpl implements IQmsCheckRuleService { * * @param qmsCheckRule 检验规则维护对象 */ - public void insertQmsCheckRuleProject(QmsCheckRule qmsCheckRule) - { + public void insertQmsCheckRuleProject(QmsCheckRule qmsCheckRule) { List qmsCheckRuleProjectList = qmsCheckRule.getQmsCheckRuleProjectList(); Long checkRuleId = qmsCheckRule.getCheckRuleId(); - if (StringUtils.isNotNull(qmsCheckRuleProjectList)) - { + if (StringUtils.isNotNull(qmsCheckRuleProjectList)) { List list = new ArrayList(); - for (QmsCheckRuleProject qmsCheckRuleProject : qmsCheckRuleProjectList) - { + for (QmsCheckRuleProject qmsCheckRuleProject : qmsCheckRuleProjectList) { qmsCheckRuleProject.setCheckRuleId(checkRuleId); list.add(qmsCheckRuleProject); } - if (list.size() > 0) - { + if (list.size() > 0) { qmsCheckRuleMapper.batchQmsCheckRuleProject(list); } } @@ -149,6 +159,7 @@ public class QmsCheckRuleServiceImpl implements IQmsCheckRuleService { /** * 批量插入检验规则明细 + * * @param checkRuleDetailList */ @Override @@ -159,6 +170,7 @@ public class QmsCheckRuleServiceImpl implements IQmsCheckRuleService { /** * 批量插入检验规则项目 + * * @param checkRuleProjectList */ @Override @@ -179,4 +191,59 @@ public class QmsCheckRuleServiceImpl implements IQmsCheckRuleService { } + /** + * 查询检验规则维护,连接check_rule_project + * + * @param baseBarcodeInfo 物料条码 + * @return 检验规则维护 + */ + @Override + public QmsCheckRule selectQmsCheckRuleByBarcode(MesBaseBarcodeInfo baseBarcodeInfo) { + Long materialId = 0L; + if (baseBarcodeInfo.getSingleFlag().equals(MesConstants.MES_BARCODE_SINGLE_FLAG_MERGE)) {//如果是合并的物料 + if (baseBarcodeInfo.getBarcodeType().equals(MesConstants.MES_BARCODE_TYPE_RAW)) { + R> materialSaleOrderRelateListData = remoteMesService.getRelateMaterialsBySaleOrderId(baseBarcodeInfo.getSaleOrderId(), SecurityConstants.INNER); + if (materialSaleOrderRelateListData == null) { + throw new ServiceException("未找到拆分物料信息"); + } + List materialSaleOrderRelateList = materialSaleOrderRelateListData.getData(); + if (materialSaleOrderRelateList == null || materialSaleOrderRelateList.isEmpty()) { + throw new ServiceException("未找到拆分物料信息!"); + } + MesSaleOrderRelate materialSaleOrderRelate = materialSaleOrderRelateList.get(0); + materialId = materialSaleOrderRelate.getMaterialId(); + } else if (baseBarcodeInfo.getBarcodeType().equals(MesConstants.MES_BARCODE_TYPE_PRODUCT)) { + R> productSaleOrderRelateListData = remoteMesService.getRelateProductsBySaleOrderId(baseBarcodeInfo.getSaleOrderId(), SecurityConstants.INNER); + if (productSaleOrderRelateListData == null) { + throw new ServiceException("未找到拆分成品信息"); + } + List productSaleOrderRelateList = productSaleOrderRelateListData.getData(); + if (productSaleOrderRelateList == null || productSaleOrderRelateList.isEmpty()) { + throw new ServiceException("未找到拆分成品信息"); + } + + MesSaleOrderRelate productSaleOrderRelate = productSaleOrderRelateList.get(0); + materialId = productSaleOrderRelate.getProductId(); + } + + } else { + materialId = baseBarcodeInfo.getMaterialId(); + } + + QmsCheckRuleDetail queryCheckRuleDetail = new QmsCheckRuleDetail(); + queryCheckRuleDetail.setTargetId(materialId); + queryCheckRuleDetail.setTargetType(QmsConstants.QMS_CHECK_RULE_DETAIL_TARGET_TYPE_MATERIAL); + QmsCheckRule qmsCheckRule = qmsCheckRuleMapper.selectQmsCheckRuleByTarget(queryCheckRuleDetail); + if (qmsCheckRule == null) { + throw new ServiceException("无此物料的质检规则"); + } + qmsCheckRule.setMaterialId(materialId); + qmsCheckRule.setMaterialCode(baseBarcodeInfo.getMaterialCode()); + qmsCheckRule.setMaterialName(baseBarcodeInfo.getMaterialName()); + + return qmsCheckRule; + + } + + } diff --git a/hw-modules/hw-qms/src/main/java/com/hw/qms/service/impl/QmsQualityInstanceServiceImpl.java b/hw-modules/hw-qms/src/main/java/com/hw/qms/service/impl/QmsQualityInstanceServiceImpl.java index a9e5cf0..804ab63 100644 --- a/hw-modules/hw-qms/src/main/java/com/hw/qms/service/impl/QmsQualityInstanceServiceImpl.java +++ b/hw-modules/hw-qms/src/main/java/com/hw/qms/service/impl/QmsQualityInstanceServiceImpl.java @@ -75,7 +75,7 @@ public class QmsQualityInstanceServiceImpl implements IQmsQualityInstanceService * @param qmsQualityInstance 质检工单 * @return 结果 */ - @Transactional + @Transactional(rollbackFor = Exception.class) @Override public int insertQmsQualityInstance(QmsQualityInstance qmsQualityInstance) { qmsQualityInstance.setCreateTime(DateUtils.getNowDate()); diff --git a/hw-modules/hw-qms/src/main/resources/mapper/qms/MesBaseBarcodeInfoMapper.xml b/hw-modules/hw-qms/src/main/resources/mapper/qms/MesBaseBarcodeInfoMapper.xml index 7115fcf..c63eb2b 100644 --- a/hw-modules/hw-qms/src/main/resources/mapper/qms/MesBaseBarcodeInfoMapper.xml +++ b/hw-modules/hw-qms/src/main/resources/mapper/qms/MesBaseBarcodeInfoMapper.xml @@ -35,10 +35,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + - select barcode_id, print_time, print_person, batch_flag, barcode_type, barcode_info, batch_code, pallet_info_code, material_id, manufacturer_id, amount, machine_name, po_no, production_date, accepted_date, last_outstock_date, plan_code, plan_detail_code, sale_order_id, saleorder_code, project_no, serial_number, remark, bind_status, bind_by, bind_time, update_by, update_time from mes_base_barcode_info + select barcode_id, print_time, print_person, batch_flag, barcode_type, barcode_info, batch_code, pallet_info_code, material_id, manufacturer_id, amount, machine_name, po_no, production_date, accepted_date, last_outstock_date, plan_code, plan_detail_code, sale_order_id, saleorder_code, project_no, serial_number, remark, bind_status, bind_by, bind_time, update_by, update_time,single_flag from mes_base_barcode_info - select mbbi.barcode_id, mbbi.batch_flag, mbbi.barcode_type, mbbi.barcode_info, mbbi.batch_code, + select mbbi.barcode_id, mbbi.batch_flag, mbbi.barcode_type, mbbi.barcode_info, mbbi.batch_code,mbbi.single_flag, mbbi.material_id, mbbi.amount, mbbi.po_no,mbbi.plan_code, mbbi.plan_detail_code, mbbi.sale_order_id, mbbi.saleorder_code, mbmi.material_code,mbmi.material_name from mes_base_barcode_info mbbi left join mes_base_material_info mbmi on mbbi.material_id = mbmi.material_id