Browse Source

2026-09-23

优化iqc的【任务重载】
master
fengyuan_yang 1 day ago
parent
commit
7711e570f5
  1. 2
      src/main/java/com/heai/modules/pms/mapper/QcMapper.java
  2. 203
      src/main/java/com/heai/modules/pms/service/Impl/QcServiceImpl.java
  3. 30
      src/main/resources/mapper/pms/QcMapper.xml

2
src/main/java/com/heai/modules/pms/mapper/QcMapper.java

@ -283,6 +283,8 @@ public interface QcMapper {
List<QcFAIRecordData> selectPartAttributeByPartNo(@Param("site") String site, @Param("buNo") String buNo, @Param("partNo") String partNo, @Param("attributeType") String attributeType, @Param("inspectionTypeNo") String inspectionTypeNo, @Param("supplierNo") String supplierNo, @Param("ipqcInspectionMethod") String ipqcInspectionMethod);
List<QcFAIRecordData> selectPartAttributeByEmptySupplier(@Param("site") String site, @Param("buNo") String buNo, @Param("partNo") String partNo, @Param("attributeType") String attributeType, @Param("inspectionTypeNo") String inspectionTypeNo, @Param("ipqcInspectionMethod") String ipqcInspectionMethod);
void saveFAIRecord(QcFAIRecordData data);
IPage<QcFAIRecordData> qcFAIInspectionSearch(Page<QcFAIRecordData> qcFAIRecordDataPage,@Param("query") QcFAIRecordData data);

203
src/main/java/com/heai/modules/pms/service/Impl/QcServiceImpl.java

@ -3869,156 +3869,85 @@ public class QcServiceImpl implements QcService {
}
/**
* 任务重载
* 按物料属性设置重新生成 IQC 任务单和检验明细
*/
@Override
@Transactional
public void iqcRecordOverLoad(QcFAIRecordData data) {
// 新建对象存放主记录
QcFAIRecordData qcFAIRecordData = new QcFAIRecordData();
for (QcFAIRecordData recordData : data.getSubmitList()) {
// 删除明细记录信息
qcMapper.deleteIQCDetailedRecord(recordData);
// 删除子明细记录信息
qcMapper.deleteIQCSubDetailedRecord(recordData);
// 删除数据采集的数据
//qcMapper.deleteEquipmentDataAcquisition(recordData);
// 删除文件
qcMapper.deleteInspectionFiles(recordData);
// 拿到供应商编码
String supplierNo = "";
if (StringUtils.isNotBlank(recordData.getSupplierNo())) {
supplierNo = recordData.getSupplierNo();
if (recordData.getRollCount() == null) {
recordData.setRollCount(recordData.getRollQty() == null ? BigDecimal.ZERO : recordData.getRollQty());
}
// 主记录信息赋值
qcFAIRecordData.setSite(recordData.getSite());
qcFAIRecordData.setBuNo(recordData.getBuNo());
qcFAIRecordData.setInspectionNo(recordData.getInspectionNo()); // 检验单号
qcFAIRecordData.setInspectionTypeNo(recordData.getInspectionTypeNo()); // 检验类型编码
qcFAIRecordData.setPartNo(recordData.getPartNo());
qcFAIRecordData.setPartDesc(recordData.getPartDesc());
qcFAIRecordData.setRollQty(recordData.getRollQty());
qcFAIRecordData.setSupplierNo(supplierNo);
qcFAIRecordData.setActionDate(null);
// 明细记录信息赋值
String partNo = recordData.getPartNo();
String attributeType1 = "A";
String supplierNo = StringUtils.defaultString(recordData.getSupplierNo(), "");
String inspectionMethod = resolveIqcInspectionMethod(recordData);
// 优先按partNo走模板匹配 selectTemplateByPartNo 逻辑保持一致
recordData.setInspectionTypeNo(qcFAIRecordData.getInspectionTypeNo());
List<QcFAIRecordData> partAttribute = null;
if (StringUtils.isBlank(inspectionMethod)) {
partAttribute = qcMapper.selectTemplateByPartNoForOverLoad(recordData);
}
// 兼容老逻辑未匹配到时回退到属性模板有检验方式时直接按检验方式匹配
if (partAttribute == null || partAttribute.isEmpty()) {
partAttribute = qcMapper.selectPartAttributeByPartNo(recordData.getSite(), recordData.getBuNo(), partNo, attributeType1, qcFAIRecordData.getInspectionTypeNo(), supplierNo, inspectionMethod);
}
if (partAttribute != null && !partAttribute.isEmpty()) {
// 检验周期
if (partAttribute.get(0).getInspectionCycle() != null) {
qcFAIRecordData.setInspectionCycle(partAttribute.get(0).getInspectionCycle());
}
// 获取抽样数量
// 如果该检验模板有维护抽样方案
if (StringUtils.isNotBlank(partAttribute.get(0).getSamplingProgrammeNo())) {
QcSamplingInspectionProgrammeData samplingInspectionProgrammeData = new QcSamplingInspectionProgrammeData();
samplingInspectionProgrammeData.setSite(partAttribute.get(0).getSite());
samplingInspectionProgrammeData.setBuNo(partAttribute.get(0).getBuNo());
samplingInspectionProgrammeData.setSamplingProgrammeNo(partAttribute.get(0).getSamplingProgrammeNo());
// 获取抽样方案维护的矩阵详情
List<QcSamplingInspectionProgrammeData> dataList = qcMapper.searchSamplingProgrammeDetails(samplingInspectionProgrammeData);
// 根据抽样方案确定抽样数
for (QcSamplingInspectionProgrammeData programmeData : dataList) {
if (programmeData.getSamplingLevelNo().equals(partAttribute.get(0).getSamplingLevelNo()) && (recordData.getRollCount().compareTo(programmeData.getMinQty()) > 0 || recordData.getRollCount().compareTo(programmeData.getMinQty()) == 0) && (recordData.getRollCount().compareTo(programmeData.getMaxQty()) < 0 || recordData.getRollCount().compareTo(programmeData.getMaxQty()) == 0) ){
qcFAIRecordData.setSamplingQty(programmeData.getSamplingQty());
}
}
} else if (partAttribute.get(0).getDefaultSamplingQuantity() != null) {
// 没有维护抽样方案再根据默认抽样数来确定
qcFAIRecordData.setSamplingQty(partAttribute.get(0).getDefaultSamplingQuantity());
} else if (partAttribute.get(0).getDefaultSamplingProportion() != null) {
// 也没有维护默认抽样数最后根据默认抽样比例来确定
BigDecimal d = partAttribute.get(0).getDefaultSamplingProportion().multiply(recordData.getRollCount()).divide(new BigDecimal(100), 3, BigDecimal.ROUND_HALF_UP);
qcFAIRecordData.setSamplingQty(d);
}
// 按模板批量写入明细默认值优先取 qc_part_attr_detailed
for (QcFAIRecordData template : partAttribute) {
QcFAIRecordData detailData = new QcFAIRecordData();
detailData.setSite(recordData.getSite());
detailData.setBuNo(recordData.getBuNo());
detailData.setInspectionNo(qcFAIRecordData.getInspectionNo());
detailData.setTemplateId(template.getTemplateId());
detailData.setSamplingLevelNo(template.getSamplingLevelNo());
detailData.setSamplingLevelDesc(template.getSamplingLevelDesc());
detailData.setSamplingProgrammeNo(template.getSamplingProgrammeNo());
detailData.setSamplingProgrammeDesc(template.getSamplingProgrammeDesc());
detailData.setAql(template.getAql());
detailData.setAc(template.getAc());
detailData.setRe(template.getRe());
detailData.setSamplingQty(qcFAIRecordData.getSamplingQty());
detailData.setPartNo(partNo);
qcMapper.saveIQCDetailedRecordByTemplate(detailData);
}
} else {
// 获取物料的类别编码
String familyId = qcMapper.selectFamilyIdByPartNo(partNo,recordData.getSite());
String attributeType2 = "B";
// 获取该类别属性下维护的IQC检验模板
List<QcFAIRecordData> familyAttribute = qcMapper.selectPartAttributeByPartNo(recordData.getSite(), recordData.getBuNo(), familyId, attributeType2, qcFAIRecordData.getInspectionTypeNo(), supplierNo, inspectionMethod);
if (!familyAttribute.isEmpty()) {
// 获取检验周期
if (familyAttribute.get(0).getInspectionCycle() != null) {
qcFAIRecordData.setInspectionCycle(familyAttribute.get(0).getInspectionCycle());
}
// 获取抽样数量
// 如果该检验模板有维护抽样方案
if (StringUtils.isNotBlank(familyAttribute.get(0).getSamplingProgrammeNo())) {
QcSamplingInspectionProgrammeData samplingInspectionProgrammeData = new QcSamplingInspectionProgrammeData();
samplingInspectionProgrammeData.setSite(familyAttribute.get(0).getSite());
samplingInspectionProgrammeData.setBuNo(familyAttribute.get(0).getBuNo());
samplingInspectionProgrammeData.setSamplingProgrammeNo(familyAttribute.get(0).getSamplingProgrammeNo());
// 获取抽样方案维护的矩阵详情
List<QcSamplingInspectionProgrammeData> dataList = qcMapper.searchSamplingProgrammeDetails(samplingInspectionProgrammeData);
// 根据抽样方案确定抽样数
for (QcSamplingInspectionProgrammeData programmeData : dataList) {
if (programmeData.getSamplingLevelNo().equals(familyAttribute.get(0).getSamplingLevelNo()) && (recordData.getRollCount().compareTo(programmeData.getMinQty()) > 0 || recordData.getRollCount().compareTo(programmeData.getMinQty()) == 0) && (recordData.getRollCount().compareTo(programmeData.getMaxQty()) < 0 || recordData.getRollCount().compareTo(programmeData.getMaxQty()) == 0) ){
qcFAIRecordData.setSamplingQty(programmeData.getSamplingQty());
}
}
} else if (familyAttribute.get(0).getDefaultSamplingQuantity() != null) {
// 没有维护抽样方案再根据默认抽样数来确定
qcFAIRecordData.setSamplingQty(familyAttribute.get(0).getDefaultSamplingQuantity());
} else if (familyAttribute.get(0).getDefaultSamplingProportion() != null) {
// 也没有维护默认抽样数最后根据默认抽样比例来确定
qcFAIRecordData.setSamplingQty(familyAttribute.get(0).getDefaultSamplingProportion().multiply(qcFAIRecordData.getRollCount()).divide(new BigDecimal(100),3,BigDecimal.ROUND_HALF_UP));
}
// 按模板批量写入明细默认值优先取 qc_part_attr_detailed
for (QcFAIRecordData template : familyAttribute) {
QcFAIRecordData detailData = new QcFAIRecordData();
detailData.setSite(recordData.getSite());
detailData.setBuNo(recordData.getBuNo());
detailData.setInspectionNo(qcFAIRecordData.getInspectionNo());
detailData.setTemplateId(template.getTemplateId());
detailData.setSamplingLevelNo(template.getSamplingLevelNo());
detailData.setSamplingLevelDesc(template.getSamplingLevelDesc());
detailData.setSamplingProgrammeNo(template.getSamplingProgrammeNo());
detailData.setSamplingProgrammeDesc(template.getSamplingProgrammeDesc());
detailData.setAql(template.getAql());
detailData.setAc(template.getAc());
detailData.setRe(template.getRe());
detailData.setSamplingQty(qcFAIRecordData.getSamplingQty());
detailData.setPartNo(partNo);
qcMapper.saveIQCDetailedRecordByTemplate(detailData);
}
}
String inspectionTypeNo = StringUtils.defaultIfBlank(recordData.getInspectionTypeNo(), "105");
QcFAIRecordData masterData = new QcFAIRecordData();
masterData.setSite(recordData.getSite());
masterData.setBuNo(recordData.getBuNo());
masterData.setInspectionNo(recordData.getInspectionNo());
masterData.setInspectionTypeNo(inspectionTypeNo);
masterData.setPartNo(recordData.getPartNo());
masterData.setPartDesc(recordData.getPartDesc());
masterData.setRollQty(recordData.getRollQty());
masterData.setSupplierNo(supplierNo);
masterData.setActionDate(null);
List<QcFAIRecordData> templates = selectIqcTemplatesForReload(recordData, inspectionTypeNo, supplierNo, inspectionMethod);
if (templates == null || templates.isEmpty()) {
String methodTip = StringUtils.isBlank(inspectionMethod) ? "" : "、检验方式【" + inspectionMethod + "】";
throw new RuntimeException("检验单【" + recordData.getInspectionNo() + "】未找到物料【" + recordData.getPartNo() + "】" + methodTip + "的IQC检验模板,请先在物料属性设置中维护");
}
applySamplingFromTemplate(masterData, recordData, templates.get(0));
for (QcFAIRecordData template : templates) {
QcFAIRecordData sampling = new QcFAIRecordData();
applySamplingFromTemplate(sampling, recordData, template);
QcFAIRecordData detailData = new QcFAIRecordData();
detailData.setSite(recordData.getSite());
detailData.setBuNo(recordData.getBuNo());
detailData.setInspectionNo(masterData.getInspectionNo());
detailData.setTemplateId(template.getTemplateId());
detailData.setSamplingLevelNo(template.getSamplingLevelNo());
detailData.setSamplingLevelDesc(template.getSamplingLevelDesc());
detailData.setSamplingProgrammeNo(template.getSamplingProgrammeNo());
detailData.setSamplingProgrammeDesc(template.getSamplingProgrammeDesc());
detailData.setAql(template.getAql());
detailData.setAc(template.getAc());
detailData.setRe(template.getRe());
detailData.setSamplingQty(sampling.getSamplingQty() != null ? sampling.getSamplingQty() : masterData.getSamplingQty());
detailData.setPartNo(recordData.getPartNo());
qcMapper.saveIQCDetailedRecordByTemplate(detailData);
}
qcMapper.updateIQCRecord(masterData);
}
}
/**
* 按物料属性检验模板清单匹配有供应商时优先供应商模板没有再取未填供应商的模板
*/
private List<QcFAIRecordData> selectIqcTemplatesForReload(QcFAIRecordData recordData, String inspectionTypeNo, String supplierNo, String inspectionMethod) {
List<QcFAIRecordData> templates = selectIqcAttributeTemplates(recordData.getSite(), recordData.getBuNo(), recordData.getPartNo(), "A", inspectionTypeNo, supplierNo, inspectionMethod);
if (templates == null || templates.isEmpty()) {
String familyId = qcMapper.selectFamilyIdByPartNo(recordData.getPartNo(), recordData.getSite());
if (StringUtils.isNotBlank(familyId)) {
templates = selectIqcAttributeTemplates(recordData.getSite(), recordData.getBuNo(), familyId, "B", inspectionTypeNo, supplierNo, inspectionMethod);
}
// 更新IQC主记录信息
qcMapper.updateIQCRecord(qcFAIRecordData);
}
return templates;
}
private List<QcFAIRecordData> selectIqcAttributeTemplates(String site, String buNo, String attributeNo, String attributeType, String inspectionTypeNo, String supplierNo, String inspectionMethod) {
List<QcFAIRecordData> templates = null;
if (StringUtils.isNotBlank(supplierNo)) {
templates = qcMapper.selectPartAttributeByPartNo(site, buNo, attributeNo, attributeType, inspectionTypeNo, supplierNo, inspectionMethod);
}
if (templates == null || templates.isEmpty()) {
templates = qcMapper.selectPartAttributeByEmptySupplier(site, buNo, attributeNo, attributeType, inspectionTypeNo, inspectionMethod);
}
return templates;
}
@Override

30
src/main/resources/mapper/pms/QcMapper.xml

@ -1892,6 +1892,36 @@
</if>
</select>
<select id="selectPartAttributeByEmptySupplier" resultType="com.heai.modules.pms.data.QcFAIRecordData">
SELECT
qat.site,
qat.bu_no,
qat.attribute_no,
qat.template_id,
qat.sampling_level_no,
qsil.sampling_level_desc,
qat.inspection_cycle,
qat.sampling_programme_no,
qsip.sampling_programme_desc,
qat.AQL,
qat.AC,
qat.RE,
qt.default_sampling_quantity,
qt.default_sampling_proportion
FROM qc_attribute_template as qat
LEFT JOIN qc_template as qt ON qat.template_id = qt.template_id and qat.site = qt.site and qat.bu_no = qt.bu_no
LEFT JOIN qc_sampling_inspection_level as qsil ON qat.sampling_level_no = qsil.sampling_level_no and qat.site = qsil.site and qat.bu_no = qsil.bu_no
LEFT JOIN qc_sampling_inspection_programme as qsip ON qat.sampling_programme_no = qsip.sampling_programme_no and qat.site = qsip.site and qat.bu_no = qsip.bu_no
WHERE qat.site = #{site} and qat.bu_no = #{buNo}
AND qat.attribute_no = #{partNo}
AND qat.attribute_type = #{attributeType}
AND qt.inspection_type_no = #{inspectionTypeNo}
AND (qat.manufacturer_id IS NULL OR qat.manufacturer_id = '')
<if test="ipqcInspectionMethod != null and ipqcInspectionMethod != ''">
AND qat.ipqc_inspection_method = #{ipqcInspectionMethod}
</if>
</select>
<!-- 获取该物料属性下维护的ipqc -->
<select id="selectPartAttributeByOperationAndResource" resultType="com.heai.modules.pms.data.QcFAIRecordData">
SELECT

Loading…
Cancel
Save