|
|
|
@ -1201,9 +1201,74 @@ public class QcServiceImpl implements QcService { |
|
|
|
/** |
|
|
|
* 新增物料属性模板 |
|
|
|
**/ |
|
|
|
/** |
|
|
|
* 保存物料属性模板关联,并将模板检验项目写入物料检验标准(已存在项目跳过) |
|
|
|
*/ |
|
|
|
private void savePartAttributeDetailAndSync(QcTemplateData partData, Set<String> syncedTemplateKeys) { |
|
|
|
qcMapper.savePartAttributeDetails(partData); |
|
|
|
String syncKey = partData.getSite() + "|" + partData.getBuNo() + "|" |
|
|
|
+ partData.getAttributeNo() + "|" + partData.getTemplateId(); |
|
|
|
if (syncedTemplateKeys.add(syncKey)) { |
|
|
|
syncPartAttrDetailedFromTemplate(partData); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据检验模板检验项目同步到物料属性检验标准(qc_part_attr_detailed) |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void syncPartAttrDetailedFromTemplate(QcTemplateData partData) { |
|
|
|
if (partData == null || StringUtils.isBlank(partData.getTemplateId()) |
|
|
|
|| StringUtils.isBlank(partData.getAttributeNo())) { |
|
|
|
return; |
|
|
|
} |
|
|
|
QcTemplateData query = new QcTemplateData(); |
|
|
|
query.setSite(partData.getSite()); |
|
|
|
query.setBuNo(partData.getBuNo()); |
|
|
|
query.setTemplateId(partData.getTemplateId()); |
|
|
|
query.setAttributeNo(partData.getAttributeNo()); |
|
|
|
query.setItemType("D"); |
|
|
|
List<QcTemplateData> itemList = qcMapper.templateDetailsSearch(query); |
|
|
|
if (itemList == null || itemList.isEmpty()) { |
|
|
|
return; |
|
|
|
} |
|
|
|
boolean inserted = false; |
|
|
|
for (QcTemplateData item : itemList) { |
|
|
|
if (StringUtils.isBlank(item.getItemNo())) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
QcTemplateData attrItem = new QcTemplateData(); |
|
|
|
attrItem.setSite(partData.getSite()); |
|
|
|
attrItem.setBuNo(partData.getBuNo()); |
|
|
|
attrItem.setAttributeNo(partData.getAttributeNo()); |
|
|
|
attrItem.setItemNo(item.getItemNo()); |
|
|
|
if (qcMapper.selectPartAttrItemDetails(attrItem) != null) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
attrItem.setInspectionTypeNo(partData.getInspectionTypeNo()); |
|
|
|
attrItem.setDefaultValue(item.getDefaultValue()); |
|
|
|
attrItem.setMaxValue(item.getMaxValue()); |
|
|
|
attrItem.setMinValue(item.getMinValue()); |
|
|
|
attrItem.setObjectID(item.getObjectID()); |
|
|
|
attrItem.setOrderId(qcMapper.getPartAttrDetailedMaxOrderId(attrItem)); |
|
|
|
qcMapper.insertPartAttrDetailed(attrItem); |
|
|
|
inserted = true; |
|
|
|
} |
|
|
|
if (inserted) { |
|
|
|
QcTemplateData timeData = new QcTemplateData(); |
|
|
|
timeData.setSite(partData.getSite()); |
|
|
|
timeData.setBuNo(partData.getBuNo()); |
|
|
|
timeData.setAttributeNo(partData.getAttributeNo()); |
|
|
|
timeData.setAttributeType(partData.getAttributeType()); |
|
|
|
timeData.setUpdateBy(partData.getUpdateBy()); |
|
|
|
qcMapper.updatePartAttributeTime(timeData); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public void savePartAttributeDetails (QcTemplateData data) { |
|
|
|
Set<String> syncedTemplateKeys = new HashSet<>(); |
|
|
|
// 与 boying-vue 一致:支持 IPQC/FQC 多工序×多机台、IQC 多供应商、OQC 多客户 |
|
|
|
for (QcTemplateData partData : data.getItemList()) { |
|
|
|
partData.setSite(data.getSite()); |
|
|
|
@ -1237,7 +1302,7 @@ public class QcServiceImpl implements QcService { |
|
|
|
if (!paList.isEmpty()) { |
|
|
|
throw new RuntimeException("工序【" + operation + "】和机台【" + resourceId + "】的组合已存在!"); |
|
|
|
} |
|
|
|
qcMapper.savePartAttributeDetails(partData); |
|
|
|
savePartAttributeDetailAndSync(partData, syncedTemplateKeys); |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (hasOperations && !hasResources) { |
|
|
|
@ -1248,14 +1313,14 @@ public class QcServiceImpl implements QcService { |
|
|
|
if (!paList.isEmpty()) { |
|
|
|
throw new RuntimeException("工序【" + operation + "】已存在!"); |
|
|
|
} |
|
|
|
qcMapper.savePartAttributeDetails(partData); |
|
|
|
savePartAttributeDetailAndSync(partData, syncedTemplateKeys); |
|
|
|
} |
|
|
|
} else if (!hasOperations && hasResources) { |
|
|
|
throw new RuntimeException("如果想选择机台,必须要先选择工序!"); |
|
|
|
} else { |
|
|
|
partData.setOperation(null); |
|
|
|
partData.setResourceID(null); |
|
|
|
qcMapper.savePartAttributeDetails(partData); |
|
|
|
savePartAttributeDetailAndSync(partData, syncedTemplateKeys); |
|
|
|
} |
|
|
|
} else if ("105".equals(partData.getInspectionTypeNo())) { |
|
|
|
if (data.getManufacturerList() != null && !data.getManufacturerList().isEmpty()) { |
|
|
|
@ -1265,11 +1330,11 @@ public class QcServiceImpl implements QcService { |
|
|
|
if (!paList2.isEmpty()) { |
|
|
|
throw new RuntimeException("待新增的供应商已存在!"); |
|
|
|
} |
|
|
|
qcMapper.savePartAttributeDetails(partData); |
|
|
|
savePartAttributeDetailAndSync(partData, syncedTemplateKeys); |
|
|
|
} |
|
|
|
} else { |
|
|
|
partData.setManufacturerID(null); |
|
|
|
qcMapper.savePartAttributeDetails(partData); |
|
|
|
savePartAttributeDetailAndSync(partData, syncedTemplateKeys); |
|
|
|
} |
|
|
|
} else if ("110".equals(partData.getInspectionTypeNo())) { |
|
|
|
if (data.getCustomerList() != null && !data.getCustomerList().isEmpty()) { |
|
|
|
@ -1279,14 +1344,14 @@ public class QcServiceImpl implements QcService { |
|
|
|
if (!paList3.isEmpty()) { |
|
|
|
throw new RuntimeException("待新增的客户已存在!"); |
|
|
|
} |
|
|
|
qcMapper.savePartAttributeDetails(partData); |
|
|
|
savePartAttributeDetailAndSync(partData, syncedTemplateKeys); |
|
|
|
} |
|
|
|
} else { |
|
|
|
partData.setCustomerID(null); |
|
|
|
qcMapper.savePartAttributeDetails(partData); |
|
|
|
savePartAttributeDetailAndSync(partData, syncedTemplateKeys); |
|
|
|
} |
|
|
|
} else if ("108".equals(partData.getInspectionTypeNo()) || "109".equals(partData.getInspectionTypeNo())) { |
|
|
|
qcMapper.savePartAttributeDetails(partData); |
|
|
|
savePartAttributeDetailAndSync(partData, syncedTemplateKeys); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -1539,6 +1604,7 @@ public class QcServiceImpl implements QcService { |
|
|
|
templateData.setResourceID(resourceId); |
|
|
|
// 新增 |
|
|
|
qcMapper.savePartAttributeDetails(templateData); |
|
|
|
syncPartAttrDetailedFromTemplate(templateData); |
|
|
|
} |
|
|
|
}catch (Exception e){ |
|
|
|
throw new RuntimeException("导入失败:"+e.getMessage()); |
|
|
|
|