diff --git a/doc/设计文档/数据库设计/mes-qc.sql b/doc/设计文档/数据库设计/mes-qc.sql index 6eb3aa6..e483340 100644 --- a/doc/设计文档/数据库设计/mes-qc.sql +++ b/doc/设计文档/数据库设计/mes-qc.sql @@ -139,6 +139,10 @@ create table qc_iqc ( iqc_code varchar(64) not null comment '来料检验单编号', iqc_name varchar(500) not null comment '来料检验单名称', template_id bigint(20) not null comment '检验模板ID', + source_doc_id bigint(20) comment '来源单据ID', + source_doc_type varchar(64) comment '来源单据类型', + source_doc_code varchar(64) comment '来源单据编号', + source_line_id bigint(20) comment '来源单据行ID', vendor_id bigint(20) not null comment '供应商ID', vendor_code varchar(64) not null comment '供应商编码', vendor_name varchar(255) not null comment '供应商名称', @@ -253,7 +257,10 @@ create table qc_ipqc ( ipqc_name varchar(255) comment '检验单名称', ipqc_type varchar(64) not null comment '检验类型', template_id bigint(20) not null comment '检验模板ID', - + source_doc_id bigint(20) comment '来源单据ID', + source_doc_type varchar(64) comment '来源单据类型', + source_doc_code varchar(64) comment '来源单据编号', + source_line_id bigint(20) comment '来源单据行ID', workorder_id bigint(20) not null comment '工单ID', workorder_code varchar(64) comment '工单编码', workorder_name varchar(255) comment '工单名称', @@ -343,6 +350,10 @@ create table qc_oqc ( oqc_code varchar(64) not null comment '出货检验单编号', oqc_name varchar(500) comment '出货检验单名称', template_id bigint(20) not null comment '检验模板ID', + source_doc_id bigint(20) comment '来源单据ID', + source_doc_type varchar(64) comment '来源单据类型', + source_doc_code varchar(64) comment '来源单据编号', + source_line_id bigint(20) comment '来源单据行ID', client_id bigint(20) not null comment '客户ID', client_code varchar(64) not null comment '客户编码', client_name varchar(255) not null comment '客户名称', diff --git a/doc/设计文档/数据库设计/数据库设计.xlsx b/doc/设计文档/数据库设计/数据库设计.xlsx index 55f1a41..213aefc 100644 Binary files a/doc/设计文档/数据库设计/数据库设计.xlsx and b/doc/设计文档/数据库设计/数据库设计.xlsx differ diff --git a/ktg-mes/src/main/java/com/ktg/mes/qc/controller/QcIqcController.java b/ktg-mes/src/main/java/com/ktg/mes/qc/controller/QcIqcController.java index c1a0560..927cd55 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/qc/controller/QcIqcController.java +++ b/ktg-mes/src/main/java/com/ktg/mes/qc/controller/QcIqcController.java @@ -10,6 +10,9 @@ import com.ktg.mes.pro.domain.ProFeedback; import com.ktg.mes.pro.service.IProFeedbackService; import com.ktg.mes.qc.domain.*; import com.ktg.mes.qc.service.*; +import com.ktg.mes.wm.domain.WmItemRecptLine; +import com.ktg.mes.wm.service.IWmItemRecptLineService; +import com.ktg.mes.wm.service.IWmItemRecptService; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; @@ -53,6 +56,8 @@ public class QcIqcController extends BaseController @Autowired private IQcDefectRecordService qcDefectRecordService; + @Autowired + private IWmItemRecptLineService wmItemRecptLineService; /** @@ -131,6 +136,29 @@ public class QcIqcController extends BaseController return AjaxResult.error("单据编号已存在!"); } + QcTemplateProduct param = new QcTemplateProduct(); + param.setItemId(qcIqc.getItemId()); + List templates = qcTemplateProductService.selectQcTemplateProductList(param); + if(CollUtil.isNotEmpty(templates)){ + qcIqc.setTemplateId(templates.get(0).getTemplateId()); + }else{ + return AjaxResult.error("当前产品未配置检测模板!"); + } + qcIqc.setInspector(getUsername()); + + //如果是完成状态,则根据来源单据更新其对应的检测单 + if(UserConstants.ORDER_STATUS_FINISHED.equals(qcIqc.getStatus())){ + if(StringUtils.isNotNull(qcIqc.getSourceDocCode())){ + //这里默认是采购入库单,后续有其他单据则根据单据类型(sourceDocType)进行区分 + WmItemRecptLine line = wmItemRecptLineService.selectWmItemRecptLineByLineId(qcIqc.getSourceLineId()); + if(StringUtils.isNotNull(line)){ + line.setIqcCode(qcIqc.getIqcCode()); + line.setIqcId(qcIqc.getIqcId()); + wmItemRecptLineService.updateWmItemRecptLine(line); + } + } + } + return toAjax(qcIqcService.updateQcIqc(qcIqc)); } diff --git a/ktg-mes/src/main/java/com/ktg/mes/qc/controller/QcOqcController.java b/ktg-mes/src/main/java/com/ktg/mes/qc/controller/QcOqcController.java index 587214b..eaf2dce 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/qc/controller/QcOqcController.java +++ b/ktg-mes/src/main/java/com/ktg/mes/qc/controller/QcOqcController.java @@ -6,10 +6,14 @@ import javax.servlet.http.HttpServletResponse; import cn.hutool.core.collection.CollUtil; import com.ktg.common.constant.UserConstants; +import com.ktg.common.utils.StringUtils; import com.ktg.mes.qc.domain.*; import com.ktg.mes.qc.service.IQcOqcLineService; import com.ktg.mes.qc.service.IQcTemplateIndexService; import com.ktg.mes.qc.service.IQcTemplateProductService; +import com.ktg.mes.wm.domain.WmProductSalseLine; +import com.ktg.mes.wm.service.IWmProductSalseLineService; +import org.apache.catalina.User; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; @@ -51,6 +55,9 @@ public class QcOqcController extends BaseController @Autowired private IQcTemplateIndexService qcTemplateIndexService; + @Autowired + private IWmProductSalseLineService wmProductSalseLineService; + /** * 查询出货检验单列表 */ @@ -128,6 +135,29 @@ public class QcOqcController extends BaseController if(UserConstants.NOT_UNIQUE.equals(qcOqcService.checkOqcCodeUnique(qcOqc))){ return AjaxResult.error("出货单编号已存在!"); } + + //自动获取对应的检测模板 + QcTemplateProduct param = new QcTemplateProduct(); + param.setItemId(qcOqc.getItemId()); + List templates = qcTemplateProductService.selectQcTemplateProductList(param); + if(CollUtil.isNotEmpty(templates)){ + qcOqc.setTemplateId(templates.get(0).getTemplateId()); + }else{ + return AjaxResult.error("当前产品未配置检测模板!"); + } + //设置检测人 + qcOqc.setInspector(getUsername()); + + if(UserConstants.ORDER_STATUS_FINISHED.equals(qcOqc.getStatus())){ + if(StringUtils.isNotNull(qcOqc.getSourceDocCode())){ + WmProductSalseLine line = wmProductSalseLineService.selectWmProductSalseLineByLineId(qcOqc.getSourceLineId()); + if(StringUtils.isNotNull(line)){ + line.setOqcId(qcOqc.getOqcId()); + line.setOqcCode(qcOqc.getOqcCode()); + wmProductSalseLineService.updateWmProductSalseLine(line); + } + } + } return toAjax(qcOqcService.updateQcOqc(qcOqc)); }