|
|
|
@ -2817,6 +2817,93 @@ public class QcServiceImpl implements QcService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取IPQC模板列表 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<Map<String, Object>> getIPQCTemplateList(Map<String, Object> params) { |
|
|
|
return qcMapper.getIPQCTemplateList(params); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 导入IPQC模板项目到检验单 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public int importIPQCTemplateItems(Map<String, Object> params) { |
|
|
|
String site = (String) params.get("site"); |
|
|
|
String buNo = (String) params.get("buNo"); |
|
|
|
String inspectionNo = (String) params.get("inspectionNo"); |
|
|
|
String orderNo = (String) params.get("orderNo"); |
|
|
|
List<Map<String, Object>> templateList = (List<Map<String, Object>>) params.get("templateList"); |
|
|
|
|
|
|
|
int importCount = 0; |
|
|
|
|
|
|
|
if (templateList != null && !templateList.isEmpty()) { |
|
|
|
// 查询当前检验单是否已有检验项目 |
|
|
|
Map<String, Object> queryParams = new HashMap<>(); |
|
|
|
queryParams.put("site", site); |
|
|
|
queryParams.put("buNo", buNo); |
|
|
|
queryParams.put("inspectionNo", inspectionNo); |
|
|
|
List<EamPropertiesItemData> existingItems = qcMapper.getExistingIPQCItems(queryParams); |
|
|
|
|
|
|
|
// 确定template_id和foreign_flag |
|
|
|
String targetTemplateId; |
|
|
|
String foreignFlag = "Y"; // 模板导入的项目标记为Y |
|
|
|
|
|
|
|
if (existingItems != null && !existingItems.isEmpty()) { |
|
|
|
// 如果有现有项目,随便取第一条的template_id |
|
|
|
targetTemplateId = existingItems.get(0).getTemplateId(); |
|
|
|
} else { |
|
|
|
// 如果没有现有项目,template_id赋值为"*" |
|
|
|
targetTemplateId = "*"; |
|
|
|
} |
|
|
|
|
|
|
|
// 遍历选中的模板 |
|
|
|
for (Map<String, Object> template : templateList) { |
|
|
|
String templateId = (String) template.get("templateId"); |
|
|
|
|
|
|
|
// 查询模板的所有检验项目 |
|
|
|
Map<String, Object> templateItemParams = new HashMap<>(); |
|
|
|
templateItemParams.put("site", site); |
|
|
|
templateItemParams.put("buNo", buNo); |
|
|
|
templateItemParams.put("templateId", templateId); |
|
|
|
List<EamPropertiesItemData> templateItems = qcMapper.getTemplateItems(templateItemParams); |
|
|
|
|
|
|
|
// 查询当前检验单已有的项目编码,避免重复导入 |
|
|
|
List<String> existingItemNos = qcMapper.getExistingItemNos(queryParams); |
|
|
|
|
|
|
|
// 插入模板项目 |
|
|
|
for (EamPropertiesItemData item : templateItems) { |
|
|
|
// 跳过已存在的项目 |
|
|
|
if (existingItemNos.contains(item.getItemNo())) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
Map<String, Object> insertParams = new HashMap<>(); |
|
|
|
insertParams.put("site", site); |
|
|
|
insertParams.put("buNo", buNo); |
|
|
|
insertParams.put("inspectionNo", inspectionNo); |
|
|
|
insertParams.put("orderNo", orderNo); |
|
|
|
insertParams.put("templateId", targetTemplateId); |
|
|
|
insertParams.put("itemNo", item.getItemNo()); |
|
|
|
insertParams.put("itemDesc", item.getItemDesc()); |
|
|
|
insertParams.put("defaultValue", item.getDefaultValue()); |
|
|
|
insertParams.put("maxValue", item.getMaxValue()); |
|
|
|
insertParams.put("minValue", item.getMinValue()); |
|
|
|
insertParams.put("valueType", item.getValueType()); |
|
|
|
insertParams.put("valueTypeDb", item.getValueTypeDb()); |
|
|
|
insertParams.put("foreignFlag", foreignFlag); |
|
|
|
|
|
|
|
qcMapper.insertIPQCItemDetail(insertParams); |
|
|
|
importCount++; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return importCount; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取检验标准 |
|
|
|
*/ |
|
|
|
|