diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/admin/SampleAnalysisController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/admin/SampleAnalysisController.java index 2d2ca38..5b29457 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/admin/SampleAnalysisController.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/admin/SampleAnalysisController.java @@ -71,6 +71,7 @@ public class SampleAnalysisController implements BusinessControllerMarker { return success("成功"); } + //提交分析 @PostMapping("/submitSampleAnalysisByTaskId") public CommonResult submitSampleAnalysisByTaskId(Long businessAssayTaskId) { sampleAnalysisService.submitSampleAnalysisByTaskId(businessAssayTaskId); diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/vo/BusinessAssayTaskDataExtendRespVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/vo/BusinessAssayTaskDataExtendRespVO.java index abb66a9..42e371d 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/vo/BusinessAssayTaskDataExtendRespVO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/controller/vo/BusinessAssayTaskDataExtendRespVO.java @@ -44,4 +44,7 @@ public class BusinessAssayTaskDataExtendRespVO extends BusinessAssayTaskDataResp private Integer asmtIsRecheck; private String asmtReportedStatus; + + @Schema(description = "配料信息") + private String ingredientInfo; } diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/dal/mapper/BusinessAssayTaskDataMapper.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/dal/mapper/BusinessAssayTaskDataMapper.java index 3f7438c..5334e4c 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/dal/mapper/BusinessAssayTaskDataMapper.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/dal/mapper/BusinessAssayTaskDataMapper.java @@ -374,9 +374,11 @@ public interface BusinessAssayTaskDataMapper extends BaseMapperX selectExtendByBusinessAssayTaskId(Long businessAssayTaskId) { return selectJoinList(BusinessAssayTaskDataExtendRespVO.class, new MPJLambdaWrapperX() + .leftJoin(BusinessSubSampleDO.class, BusinessSubSampleDO::getId, BusinessAssayTaskDataDO::getBusinessSubSampleId) .leftJoin(BusinessBaseSampleDO.class, BusinessBaseSampleDO::getId, BusinessAssayTaskDataDO::getBusinessBaseSampleId) .selectAll(BusinessAssayTaskDataDO.class) .selectAs(BusinessBaseSampleDO::getConfigBaseSampleId, BusinessAssayTaskDataExtendRespVO::getConfigBaseSampleId) + .selectAs(BusinessSubSampleDO::getConfigSubSampleId, BusinessAssayTaskDataExtendRespVO::getConfigSubSampleId) .eq(BusinessAssayTaskDataDO::getBusinessAssayTaskId, businessAssayTaskId)); } @@ -390,6 +392,18 @@ public interface BusinessAssayTaskDataMapper extends BaseMapperX selectByBusinessSubSampleIdAndMethodKey(Long businessSubSampleId, String methodKey) { + String inSql = "SELECT tcam.ID FROM T_CFG_ASY_MTHD tcam WHERE tcam.DELETED = 0 AND tcam.DIC_BSN_KY = '" + methodKey + "'"; + return selectList(new LambdaQueryWrapperX() + .eq(BusinessAssayTaskDataDO::getBusinessSubSampleId, businessSubSampleId) + .inSql(BusinessAssayTaskDataDO::getConfigAssayMethodId, inSql)); + } /** * 根据子样及分析部门查询分析任务 diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/service/BusinessAssayTaskDataServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/service/BusinessAssayTaskDataServiceImpl.java index fea9f71..d918301 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/service/BusinessAssayTaskDataServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/service/BusinessAssayTaskDataServiceImpl.java @@ -1,17 +1,30 @@ package com.zt.plat.module.qms.business.bus.service; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import com.zt.plat.module.qms.business.bus.controller.vo.*; + +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import jakarta.annotation.Resource; import org.springframework.validation.annotation.Validated; import java.util.*; +import java.util.stream.Collectors; + import com.zt.plat.module.qms.business.bus.controller.vo.*; import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayTaskDataDO; +import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessAssayParameterDataMapper; +import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessAssayProjectDataMapper; import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessAssayTaskDataMapper; +import com.zt.plat.module.qms.business.config.controller.vo.ConfigSubSampleMethodConfInfo; +import com.zt.plat.module.qms.business.config.controller.vo.ConfigSubSampleMethodConfItem; +import com.zt.plat.module.qms.business.config.controller.vo.ConfigSubSampleMethodConfPoint; +import com.zt.plat.module.qms.business.config.controller.vo.ConfigSubSampleMethodExtendRespVO; +import com.zt.plat.module.qms.business.config.dal.mapper.ConfigSubSampleMethodMapper; import com.zt.plat.framework.common.pojo.PageResult; +import com.alibaba.fastjson2.JSON; import com.zt.plat.framework.common.pojo.PageParam; import com.zt.plat.framework.common.util.object.BeanUtils; import com.zt.plat.framework.security.core.LoginUser; @@ -34,6 +47,15 @@ public class BusinessAssayTaskDataServiceImpl implements BusinessAssayTaskDataSe @Resource private BusinessAssayTaskDataMapper businessAssayTaskDataMapper; + + @Resource + private BusinessAssayProjectDataMapper businessAssayProjectDataMapper; + + @Resource + private BusinessAssayParameterDataMapper businessAssayParameterDataMapper; + + @Resource + private ConfigSubSampleMethodMapper configSubSampleMethodMapper; @Override public BusinessAssayTaskDataRespVO createBusinessAssayTaskData(BusinessAssayTaskDataSaveReqVO createReqVO) { @@ -100,12 +122,86 @@ public class BusinessAssayTaskDataServiceImpl implements BusinessAssayTaskDataSe @Override public List getBusinessAssayTaskDataList(BusinessAssayTaskDataReqVO reqVO) { - return businessAssayTaskDataMapper.selectList(reqVO); + List list = businessAssayTaskDataMapper.selectList(reqVO); + List configSubSampleIdList = list.stream().map(m -> m.getConfigSubSampleId()).collect(Collectors.toList()); + List configSubSampleMethodList = configSubSampleMethodMapper.selectByConfigSubSampleIdsAndConfigAssayMethodId(configSubSampleIdList, reqVO.getConfigAssayMethodId()); + List businessAssayTaskDataIdList = list.stream().map(m -> m.getId()).collect(Collectors.toList()); + //查询检测项目 + List businessAssayProjectDataList = businessAssayProjectDataMapper.selectByBusinessAssayTaskDataIds(businessAssayTaskDataIdList); + List businessAssayProjectDataIdList = businessAssayProjectDataList.stream().map(m -> m.getId()).collect(Collectors.toList()); + //查询检测项目参数 + List businessAssayParameterDataList = businessAssayParameterDataMapper.selectExtendByBusinessAssayProjectDataIds(businessAssayProjectDataIdList); + + for (BusinessAssayTaskDataExtendRespVO businessAssayTaskData : list) { + ConfigSubSampleMethodExtendRespVO configSubSampleMethod = configSubSampleMethodList.stream().filter(f -> f.getConfigSubSampleId().equals(businessAssayTaskData.getConfigSubSampleId()) && f.getConfigAssayMethodId().equals(businessAssayTaskData.getConfigAssayMethodId())).findFirst().orElse(null); + String configInfomation = configSubSampleMethod.getConfigInfomation(); + if (StringUtils.isNotBlank(configInfomation)) { + ConfigSubSampleMethodConfInfo configSubSampleMethodConfInfo = JSON.parseObject(configInfomation, ConfigSubSampleMethodConfInfo.class); + List getParamList = configSubSampleMethodConfInfo.getGetParam(); + StringBuilder ingredientInfoBuilder = new StringBuilder(); + for (ConfigSubSampleMethodConfItem configSubSampleMethodConfItem : getParamList) { + ConfigSubSampleMethodConfPoint target = configSubSampleMethodConfItem.getTarget(); + List projectList = Arrays.asList(target.getProject().split(","));//来源可以有多个 + for (String project : projectList) { + String parameter = target.getParameter(); + BusinessAssayProjectDataExtendRespVO currentBusinessAssayProjectData = businessAssayProjectDataList.stream().filter(f -> f.getBusinessAssayTaskDataId().equals(businessAssayTaskData.getId()) && f.getSimpleName().equals(project)).findFirst().orElse(null); + BusinessAssayParameterDataExtendRespVO currentBusinessAssayParameterData = businessAssayParameterDataList.stream().filter(f -> f.getBusinessAssayProjectDataId().equals(currentBusinessAssayProjectData.getId()) && f.getParameterKey().equals(parameter)).findFirst().orElse(null); + if (currentBusinessAssayParameterData != null && StringUtils.isNotBlank(currentBusinessAssayParameterData.getValue())) { + ingredientInfoBuilder.append(currentBusinessAssayParameterData.getParameterName()).append(":").append(currentBusinessAssayParameterData.getValue()).append("、"); + break; + } + } + } + if (ingredientInfoBuilder.length() > 0) { + ingredientInfoBuilder.delete(ingredientInfoBuilder.length() - 1, ingredientInfoBuilder.length()); + } + businessAssayTaskData.setIngredientInfo(ingredientInfoBuilder.toString()); + } + } + + return list; } @Override public PageResult getBusinessAssayTaskDataPage(BusinessAssayTaskDataPageReqVO pageReqVO) { - return businessAssayTaskDataMapper.selectPage(pageReqVO); + PageResult page = businessAssayTaskDataMapper.selectPage(pageReqVO); + List list = page.getList(); + List configSubSampleIdList = list.stream().map(m -> m.getConfigSubSampleId()).collect(Collectors.toList()); + List configSubSampleMethodList = configSubSampleMethodMapper.selectByConfigSubSampleIdsAndConfigAssayMethodId(configSubSampleIdList, pageReqVO.getConfigAssayMethodId()); + List businessAssayTaskDataIdList = list.stream().map(m -> m.getId()).collect(Collectors.toList()); + //查询检测项目 + List businessAssayProjectDataList = businessAssayProjectDataMapper.selectByBusinessAssayTaskDataIds(businessAssayTaskDataIdList); + List businessAssayProjectDataIdList = businessAssayProjectDataList.stream().map(m -> m.getId()).collect(Collectors.toList()); + //查询检测项目参数 + List businessAssayParameterDataList = businessAssayParameterDataMapper.selectExtendByBusinessAssayProjectDataIds(businessAssayProjectDataIdList); + + for (BusinessAssayTaskDataExtendRespVO businessAssayTaskData : list) { + ConfigSubSampleMethodExtendRespVO configSubSampleMethod = configSubSampleMethodList.stream().filter(f -> f.getConfigSubSampleId().equals(businessAssayTaskData.getConfigSubSampleId()) && f.getConfigAssayMethodId().equals(businessAssayTaskData.getConfigAssayMethodId())).findFirst().orElse(null); + String configInfomation = configSubSampleMethod.getConfigInfomation(); + if (StringUtils.isNotBlank(configInfomation)) { + ConfigSubSampleMethodConfInfo configSubSampleMethodConfInfo = JSON.parseObject(configInfomation, ConfigSubSampleMethodConfInfo.class); + List getParamList = configSubSampleMethodConfInfo.getGetParam(); + StringBuilder ingredientInfoBuilder = new StringBuilder(); + for (ConfigSubSampleMethodConfItem configSubSampleMethodConfItem : getParamList) { + ConfigSubSampleMethodConfPoint target = configSubSampleMethodConfItem.getTarget(); + List projectList = Arrays.asList(target.getProject().split(","));//来源可以有多个 + for (String project : projectList) { + String parameter = target.getParameter(); + BusinessAssayProjectDataExtendRespVO currentBusinessAssayProjectData = businessAssayProjectDataList.stream().filter(f -> f.getBusinessAssayTaskDataId().equals(businessAssayTaskData.getId()) && f.getSimpleName().equals(project)).findFirst().orElse(null); + BusinessAssayParameterDataExtendRespVO currentBusinessAssayParameterData = businessAssayParameterDataList.stream().filter(f -> f.getBusinessAssayProjectDataId().equals(currentBusinessAssayProjectData.getId()) && f.getParameterKey().equals(parameter)).findFirst().orElse(null); + if (currentBusinessAssayParameterData != null && StringUtils.isNotBlank(currentBusinessAssayParameterData.getValue())) { + ingredientInfoBuilder.append(currentBusinessAssayParameterData.getParameterName()).append(":").append(currentBusinessAssayParameterData.getValue()).append("、"); + break; + } + } + } + if (ingredientInfoBuilder.length() > 0) { + ingredientInfoBuilder.delete(ingredientInfoBuilder.length() - 1, ingredientInfoBuilder.length()); + } + businessAssayTaskData.setIngredientInfo(ingredientInfoBuilder.toString()); + } + } + return page; } } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/service/SampleAnalysisServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/service/SampleAnalysisServiceImpl.java index 51778dd..251916b 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/service/SampleAnalysisServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/service/SampleAnalysisServiceImpl.java @@ -21,7 +21,6 @@ import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.zt.plat.framework.common.exception.ServiceException; -import com.zt.plat.framework.common.util.date.DateUtils; import com.zt.plat.framework.common.util.object.BeanUtils; import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX; import com.zt.plat.framework.security.core.LoginUser; @@ -85,7 +84,6 @@ import com.zt.plat.module.qms.business.config.dal.dataobject.BaseSampleDO; import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigAssayMethodDO; import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigAssayMethodProjectCoefficientDO; import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigAssayMethodProjectRangeDO; -import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigSubSampleMethodDO; import com.zt.plat.module.qms.business.config.dal.mapper.BaseSampleMapper; import com.zt.plat.module.qms.business.config.dal.mapper.ConfigAssayMethodMapper; import com.zt.plat.module.qms.business.config.dal.mapper.ConfigAssayMethodProjectCoefficientMapper; @@ -98,9 +96,7 @@ import com.zt.plat.module.qms.common.dic.controller.vo.DictionaryBusinessExtendR import com.zt.plat.module.qms.common.dic.dal.mapper.DictionaryBusinessMapper; import com.zt.plat.module.qms.enums.QmsCommonConstant; -import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; import jakarta.annotation.Resource; @@ -662,85 +658,87 @@ public class SampleAnalysisServiceImpl implements SampleAnalysisService { Long configMethodId = source.getMethodId(); String sourceProject = source.getProject(); //String sourceParameter = source.getParameter(); - - + ConfigSubSampleMethodConfPoint target = configSubSampleMethodConfItem.getTarget();//目标 - String targetProject = target.getProject(); - String targetParameter = target.getParameter(); - - BusinessAssayParameterDataDO businessAssayParameterDataDO = businessAssayParameterDataMapper.selectByBusinessAssayTaskDataIdAndProjectSimpleNameAndParameterKey(businessAssayTaskDataDO.getId(), targetProject, targetParameter); - if (businessAssayParameterDataDO == null) { - throw new ServiceException(1_032_100_000, "子样检测方法映射配置错误"); - } - - if (StringUtils.isBlank(businessAssayParameterDataDO.getValue())) { - //1 查询委托明细 - BusinessSampleEntrustDetailDO businessSampleEntrustDetailDO = businessSampleEntrustDetailMapper.selectByBusinessBaseSampleId(businessAssayTaskDataDO.getBusinessBaseSampleId()); - //2 查询样品大类 - BaseSampleDO baseSampleDO = baseSampleMapper.selectById(businessSampleEntrustDetailDO.getBaseSampleId()); - //3 判断样品大类类型 - if (QmsCommonConstant.ENTRUST_INSPECTION_ANALYSIS_SAMPLE.equals(baseSampleDO.getDictionaryBusinessKey())) {//如果是商检分析样 - //查询当前批次的第一个商检分析样 - BusinessSampleEntrustDetailDO currBatchFirstBusinessSampleEntrustDetailDO = businessSampleEntrustDetailMapper.selectCurrBatchFirstByBusinessBaseSampleIdAndBaseSampleDictionaryBusinessKey(businessAssayTaskDataDO.getBusinessBaseSampleId(), QmsCommonConstant.ENTRUST_INSPECTION_ANALYSIS_SAMPLE); - List currBusinessSubParentSampleDOList = businessSubParentSampleMapper.selectByBusinessBaseSampleId(currBatchFirstBusinessSampleEntrustDetailDO.getBusinessBaseSampleId()); - List currBusinessSubParentSampleIdList = currBusinessSubParentSampleDOList.stream().map(m -> m.getId()).collect(Collectors.toList()); - List businessSubParentSampleAssessmentProjectList = businessSubParentSampleAssessmentProjectMapper.selectByBusinessSubParentSampleIdsAndConfigAssayMethodId(currBusinessSubParentSampleIdList, configMethodId); - BusinessSubParentSampleAssessmentProjectExtendRespVO businessSubParentSampleAssessmentProject = businessSubParentSampleAssessmentProjectList.stream().filter(f -> f.getSimpleName().equals(sourceProject)).findFirst().orElse(null); - if (businessSubParentSampleAssessmentProject != null && StringUtils.isNotBlank(businessSubParentSampleAssessmentProject.getAssessmentValue())) { - businessAssayParameterDataDO.setValue(businessSubParentSampleAssessmentProject.getAssessmentValue()); - } - } else if (QmsCommonConstant.ENTRUST_COMPREHENSIVE_INSPECTION_SAMPLE.equals(baseSampleDO.getDictionaryBusinessKey())) {//如果是商检综合样 - //查询当前样品的其他分析方法的结果 - List businessSubParentSampleIdList = Arrays.asList(businessAssayTaskDataDO.getBusinessSubParentSampleId()); - List businessSubParentSampleAssessmentProjectList = businessSubParentSampleAssessmentProjectMapper.selectByBusinessSubParentSampleIdsAndConfigAssayMethodId(businessSubParentSampleIdList, configMethodId); - BusinessSubParentSampleAssessmentProjectExtendRespVO businessSubParentSampleAssessmentProject = businessSubParentSampleAssessmentProjectList.stream().filter(f -> f.getSimpleName().equals(sourceProject)).findFirst().orElse(null); - if (businessSubParentSampleAssessmentProject != null && StringUtils.isNotBlank(businessSubParentSampleAssessmentProject.getAssessmentValue())) { - businessAssayParameterDataDO.setValue(businessSubParentSampleAssessmentProject.getAssessmentValue()); - } - } else if (QmsCommonConstant.ENTRUST_COMMISSION_INSPECTION_SAMPLE.equals(baseSampleDO.getDictionaryBusinessKey())) {//如果是委检样 - //查询来样品位 - Boolean isForecastS = false; - String forecastValue = null; - String forecastResult = businessSampleEntrustDetailDO.getForecastResult(); - if (StringUtils.isNotBlank(forecastResult)) { - JSONArray array = JSON.parseArray(forecastResult); - for (int i = 0; i < array.size(); i++) { - JSONObject item = array.getJSONObject(i); - if ("S".equals(item.getString("simpleName"))) { - isForecastS = true; - break; - } + + List projectList = Arrays.asList(target.getProject().split(","));//目标可以有多个 + for (String targetProject : projectList) { + String targetParameter = target.getParameter(); + + BusinessAssayParameterDataDO businessAssayParameterDataDO = businessAssayParameterDataMapper.selectByBusinessAssayTaskDataIdAndProjectSimpleNameAndParameterKey(businessAssayTaskDataDO.getId(), targetProject, targetParameter); + if (businessAssayParameterDataDO == null) { + throw new ServiceException(1_032_100_000, "子样检测方法映射配置错误"); + } + + if (StringUtils.isBlank(businessAssayParameterDataDO.getValue())) { + //1 查询委托明细 + BusinessSampleEntrustDetailDO businessSampleEntrustDetailDO = businessSampleEntrustDetailMapper.selectByBusinessBaseSampleId(businessAssayTaskDataDO.getBusinessBaseSampleId()); + //2 查询样品大类 + BaseSampleDO baseSampleDO = baseSampleMapper.selectById(businessSampleEntrustDetailDO.getBaseSampleId()); + //3 判断样品大类类型 + if (QmsCommonConstant.ENTRUST_INSPECTION_ANALYSIS_SAMPLE.equals(baseSampleDO.getDictionaryBusinessKey())) {//如果是商检分析样 + //查询当前批次的第一个商检分析样 + BusinessSampleEntrustDetailDO currBatchFirstBusinessSampleEntrustDetailDO = businessSampleEntrustDetailMapper.selectCurrBatchFirstByBusinessBaseSampleIdAndBaseSampleDictionaryBusinessKey(businessAssayTaskDataDO.getBusinessBaseSampleId(), QmsCommonConstant.ENTRUST_INSPECTION_ANALYSIS_SAMPLE); + List currBusinessSubParentSampleDOList = businessSubParentSampleMapper.selectByBusinessBaseSampleId(currBatchFirstBusinessSampleEntrustDetailDO.getBusinessBaseSampleId()); + List currBusinessSubParentSampleIdList = currBusinessSubParentSampleDOList.stream().map(m -> m.getId()).collect(Collectors.toList()); + List businessSubParentSampleAssessmentProjectList = businessSubParentSampleAssessmentProjectMapper.selectByBusinessSubParentSampleIdsAndConfigAssayMethodId(currBusinessSubParentSampleIdList, configMethodId); + BusinessSubParentSampleAssessmentProjectExtendRespVO businessSubParentSampleAssessmentProject = businessSubParentSampleAssessmentProjectList.stream().filter(f -> f.getSimpleName().equals(sourceProject)).findFirst().orElse(null); + if (businessSubParentSampleAssessmentProject != null && StringUtils.isNotBlank(businessSubParentSampleAssessmentProject.getAssessmentValue())) { + businessAssayParameterDataDO.setValue(businessSubParentSampleAssessmentProject.getAssessmentValue()); } - for (int i = 0; i < array.size(); i++) { - JSONObject item = array.getJSONObject(i); - if (sourceProject.equals(item.getString("simpleName"))) { - forecastValue = item.getString("value"); - break; - } - } - } - if (isForecastS) {//来样品位存在S值, 则取预报的值 - businessAssayParameterDataDO.setValue(forecastValue); - } else { - //查询当前样品的其他方法的结果 + } else if (QmsCommonConstant.ENTRUST_COMPREHENSIVE_INSPECTION_SAMPLE.equals(baseSampleDO.getDictionaryBusinessKey())) {//如果是商检综合样 + //查询当前样品的其他分析方法的结果 List businessSubParentSampleIdList = Arrays.asList(businessAssayTaskDataDO.getBusinessSubParentSampleId()); List businessSubParentSampleAssessmentProjectList = businessSubParentSampleAssessmentProjectMapper.selectByBusinessSubParentSampleIdsAndConfigAssayMethodId(businessSubParentSampleIdList, configMethodId); BusinessSubParentSampleAssessmentProjectExtendRespVO businessSubParentSampleAssessmentProject = businessSubParentSampleAssessmentProjectList.stream().filter(f -> f.getSimpleName().equals(sourceProject)).findFirst().orElse(null); if (businessSubParentSampleAssessmentProject != null && StringUtils.isNotBlank(businessSubParentSampleAssessmentProject.getAssessmentValue())) { businessAssayParameterDataDO.setValue(businessSubParentSampleAssessmentProject.getAssessmentValue()); } + } else if (QmsCommonConstant.ENTRUST_COMMISSION_INSPECTION_SAMPLE.equals(baseSampleDO.getDictionaryBusinessKey())) {//如果是委检样 + //查询来样品位 + Boolean isForecastS = false; + String forecastValue = null; + String forecastResult = businessSampleEntrustDetailDO.getForecastResult(); + if (StringUtils.isNotBlank(forecastResult)) { + JSONArray array = JSON.parseArray(forecastResult); + for (int i = 0; i < array.size(); i++) { + JSONObject item = array.getJSONObject(i); + if ("S".equals(item.getString("simpleName"))) { + isForecastS = true; + break; + } + } + for (int i = 0; i < array.size(); i++) { + JSONObject item = array.getJSONObject(i); + if (sourceProject.equals(item.getString("simpleName"))) { + forecastValue = item.getString("value"); + break; + } + } + } + if (isForecastS) {//来样品位存在S值, 则取预报的值 + businessAssayParameterDataDO.setValue(forecastValue); + } else { + //查询当前样品的其他方法的结果 + List businessSubParentSampleIdList = Arrays.asList(businessAssayTaskDataDO.getBusinessSubParentSampleId()); + List businessSubParentSampleAssessmentProjectList = businessSubParentSampleAssessmentProjectMapper.selectByBusinessSubParentSampleIdsAndConfigAssayMethodId(businessSubParentSampleIdList, configMethodId); + BusinessSubParentSampleAssessmentProjectExtendRespVO businessSubParentSampleAssessmentProject = businessSubParentSampleAssessmentProjectList.stream().filter(f -> f.getSimpleName().equals(sourceProject)).findFirst().orElse(null); + if (businessSubParentSampleAssessmentProject != null && StringUtils.isNotBlank(businessSubParentSampleAssessmentProject.getAssessmentValue())) { + businessAssayParameterDataDO.setValue(businessSubParentSampleAssessmentProject.getAssessmentValue()); + } + } + } - } - - //处理已查询的数据 - BusinessAssayProjectAndParameterRespVO businessAssayProjectAndParameterRespVO = businessAssayParameterDataList.stream().filter(f -> f.getBizId().equals(businessAssayParameterDataDO.getBusinessAssayProjectDataId()) && f.getDicId().equals(businessAssayParameterDataDO.getConfigAssayMethodProjectParameterId()) ).findFirst().orElse(null); - if (businessAssayProjectAndParameterRespVO != null) { - businessAssayProjectAndParameterRespVO.setValue(businessAssayParameterDataDO.getValue()); - } + //处理已查询的数据 + BusinessAssayProjectAndParameterRespVO businessAssayProjectAndParameterRespVO = businessAssayParameterDataList.stream().filter(f -> f.getBizId().equals(businessAssayParameterDataDO.getBusinessAssayProjectDataId()) && f.getDicId().equals(businessAssayParameterDataDO.getConfigAssayMethodProjectParameterId()) ).findFirst().orElse(null); + if (businessAssayProjectAndParameterRespVO != null) { + businessAssayProjectAndParameterRespVO.setValue(businessAssayParameterDataDO.getValue()); + } - //更新 - businessAssayParameterDataMapper.updateById(businessAssayParameterDataDO); + //更新 + businessAssayParameterDataMapper.updateById(businessAssayParameterDataDO); + } } } } @@ -1275,8 +1273,56 @@ public class SampleAnalysisServiceImpl implements SampleAnalysisService { businessAssayTaskDO.setFinishStatus(QmsCommonConstant.IN_PROGRESS); businessAssayTaskDO.setFlowStatus(QmsCommonConstant.IN_PROGRESS); + //设置参数值 + List updateBusinessAssayParameterDataList = new ArrayList<>(); + List businessAssayTaskDataExtendList = businessAssayTaskDataMapper.selectExtendByBusinessAssayTaskId(businessAssayTaskId); + //查询检测项目 + List businessAssayTaskDataIdList = businessAssayTaskDataExtendList.stream().map(m -> m.getId()).collect(Collectors.toList()); + List businessAssayProjectDataExtendList = businessAssayProjectDataMapper.selectByBusinessAssayTaskDataIds(businessAssayTaskDataIdList); + + //子样配置id列表 + List configSubSampleIdList = businessAssayTaskDataExtendList.stream().map(m -> m.getConfigSubSampleId()).distinct().collect(Collectors.toList()); + + //子样方法配置列表 + List configSubSampleMethodDOList = configSubSampleMethodMapper.selectByConfigSubSampleIdsAndConfigAssayMethodId(configSubSampleIdList, businessAssayTaskDO.getConfigAssayMethodId()); + + //循环任务,赋值 + for (BusinessAssayTaskDataExtendRespVO businessAssayTaskData : businessAssayTaskDataExtendList) { + ConfigSubSampleMethodExtendRespVO configSubSampleMethod = configSubSampleMethodDOList.stream().filter(f -> f.getConfigBaseSampleId().equals(businessAssayTaskData.getConfigSubSampleId()) && f.getConfigAssayMethodId().equals(businessAssayTaskData.getConfigAssayMethodId())).findFirst().orElse(null); + String configInfomation = configSubSampleMethod.getConfigInfomation(); + if (StringUtils.isNotBlank(configInfomation)) { + ConfigSubSampleMethodConfInfo configSubSampleMethodConfInfo = JSON.parseObject(configInfomation, ConfigSubSampleMethodConfInfo.class); + List setParamList = configSubSampleMethodConfInfo.getSetParam(); + + String methodKey = setParamList.stream().map(m -> m.getTarget().getMethodKey()).distinct().findFirst().orElse(null); + List targetBusinessAssayTaskDataList = businessAssayTaskDataMapper.selectByBusinessSubSampleIdAndMethodKey(businessAssayTaskData.getBusinessSubSampleId(), methodKey); + List targetBusinessAssayTaskDataIdList = targetBusinessAssayTaskDataList.stream().map(m -> m.getId()).collect(Collectors.toList()); + List targetBusinessAssayProjectDataExtendList = businessAssayProjectDataMapper.selectByBusinessAssayTaskDataIds(targetBusinessAssayTaskDataIdList); + + for (ConfigSubSampleMethodConfItem configSubSampleMethodConfItem : setParamList) { + ConfigSubSampleMethodConfPoint source = configSubSampleMethodConfItem.getSource(); + String project = source.getProject(); + BusinessAssayProjectDataExtendRespVO currentBusinessAssayProjectData = businessAssayProjectDataExtendList.stream().filter(f -> f.getBusinessAssayTaskDataId().equals(businessAssayTaskData.getId()) && f.getSimpleName().equals(project)).findFirst().orElse(null); + ConfigSubSampleMethodConfPoint target = configSubSampleMethodConfItem.getTarget(); + for (BusinessAssayTaskDataDO targetBusinessAssayTaskData : targetBusinessAssayTaskDataList) { + List targetProjectList = Arrays.asList(target.getProject().split(",")); + String targetParameter = target.getParameter(); + for (String targetProject : targetProjectList) { + BusinessAssayProjectDataExtendRespVO targetBusinessAssayProjectData = targetBusinessAssayProjectDataExtendList.stream().filter(f -> f.getBusinessAssayTaskDataId().equals(targetBusinessAssayTaskData.getId()) && f.getSimpleName().equals(targetProject)).findFirst().orElse(null); + BusinessAssayParameterDataDO businessAssayParameterDataDO = businessAssayParameterDataMapper.selectByBusinessAssayTaskDataIdAndProjectSimpleNameAndParameterKey(targetBusinessAssayProjectData.getId(), targetProject, targetParameter); + if (businessAssayParameterDataDO != null) { + businessAssayParameterDataDO.setValue(currentBusinessAssayProjectData.getValue()); + updateBusinessAssayParameterDataList.add(businessAssayParameterDataDO); + } + + } + } + } + } + } + //补正系数列表 List configAssayMethodProjectCoefficientList = new ArrayList<>(); if (businessAssayTaskDO.getIsIngredients().equals(QmsCommonConstant.YES) && QmsCommonConstant.MANUAL.equals(businessAssayTaskDO.getIngredientsWay())) {//如果是需要配料,并且是人工配料的 @@ -1284,8 +1330,6 @@ public class SampleAnalysisServiceImpl implements SampleAnalysisService { configAssayMethodProjectCoefficientList = configAssayMethodProjectCoefficientMapper.selectByConfigBaseSampleIds(configBaseSampleIdList); } - List businessAssayTaskDataIdList = businessAssayTaskDataExtendList.stream().map(m -> m.getId()).collect(Collectors.toList()); - List businessAssayProjectDataExtendList = businessAssayProjectDataMapper.selectByBusinessAssayTaskDataIds(businessAssayTaskDataIdList); for (BusinessAssayProjectDataExtendRespVO businessAssayProjectDataExtend : businessAssayProjectDataExtendList) { if (businessAssayTaskDO.getIsIngredients().equals(QmsCommonConstant.YES) && QmsCommonConstant.MANUAL.equals(businessAssayTaskDO.getIngredientsWay())) { ConfigAssayMethodProjectCoefficientDO configAssayMethodProjectCoefficientDO = configAssayMethodProjectCoefficientList.stream().filter(f -> @@ -1313,6 +1357,10 @@ public class SampleAnalysisServiceImpl implements SampleAnalysisService { businessAssayProjectDataMapper.updateBatch(businessAssayProjectDataList); } + if (updateBusinessAssayParameterDataList.size() > 0) { + businessAssayParameterDataMapper.updateBatch(updateBusinessAssayParameterDataList); + } + businessAssayTaskMapper.updateById(businessAssayTaskDO); } @@ -1461,12 +1509,15 @@ public class SampleAnalysisServiceImpl implements SampleAnalysisService { for (ConfigSubSampleMethodConfItem configSubSampleMethodConfItem : downIngredients) { if (configSubSampleMethodConfItem.getRequired()) { ConfigSubSampleMethodConfPoint source = configSubSampleMethodConfItem.getSource(); - String project = source.getProject(); - String parameter = source.getParameter(); - BusinessAssayProjectDataExtendRespVO currentBusinessAssayProjectData = businessAssayProjectDataList.stream().filter(f -> f.getBusinessAssayTaskDataId().equals(businessAssayTaskDataDO.getId()) && f.getSimpleName().equals(project)).findFirst().orElse(null); - BusinessAssayParameterDataExtendRespVO currentBusinessAssayParameterData = businessAssayParameterDataList.stream().filter(f -> f.getBusinessAssayProjectDataId().equals(currentBusinessAssayProjectData.getId()) && f.getParameterKey().equals(parameter)).findFirst().orElse(null); - if (StringUtils.isBlank(currentBusinessAssayParameterData.getValue())) { - throw new ServiceException(1_032_050_000, "当前分析任务,存在下发配料必填为空情况。请检查后再下发!"); + + List projectList = Arrays.asList(source.getProject().split(","));//来源可以有多个 + for (String project : projectList) { + String parameter = source.getParameter(); + BusinessAssayProjectDataExtendRespVO currentBusinessAssayProjectData = businessAssayProjectDataList.stream().filter(f -> f.getBusinessAssayTaskDataId().equals(businessAssayTaskDataDO.getId()) && f.getSimpleName().equals(project)).findFirst().orElse(null); + BusinessAssayParameterDataExtendRespVO currentBusinessAssayParameterData = businessAssayParameterDataList.stream().filter(f -> f.getBusinessAssayProjectDataId().equals(currentBusinessAssayProjectData.getId()) && f.getParameterKey().equals(parameter)).findFirst().orElse(null); + if (StringUtils.isBlank(currentBusinessAssayParameterData.getValue())) { + throw new ServiceException(1_032_050_000, "当前分析任务,存在下发配料必填为空情况。请检查后再下发!"); + } } } } diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/config/controller/vo/ConfigSubSampleMethodConfInfo.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/config/controller/vo/ConfigSubSampleMethodConfInfo.java index e854bf1..0671743 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/config/controller/vo/ConfigSubSampleMethodConfInfo.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/config/controller/vo/ConfigSubSampleMethodConfInfo.java @@ -10,6 +10,9 @@ public class ConfigSubSampleMethodConfInfo { /** 添加分析任务 **/ private ConfigSubSampleMethodConfAdd addAssayTask; + /** 分析方法参数设置值配置 **/ + private List setParam; + /** 分析方法参数取值配置 **/ private List getParam; diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/config/controller/vo/ConfigSubSampleMethodConfPoint.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/config/controller/vo/ConfigSubSampleMethodConfPoint.java index 72a534d..6acd850 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/config/controller/vo/ConfigSubSampleMethodConfPoint.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/config/controller/vo/ConfigSubSampleMethodConfPoint.java @@ -8,7 +8,10 @@ public class ConfigSubSampleMethodConfPoint { /** 分析方法id **/ private Long methodId; - /** 检测项目 **/ + /** 分析方法Key **/ + private String methodKey; + + /** 检测项目,多个以“,”号分割 **/ private String project; /** 参数 **/ diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/thirdpartyapi/service/AutoIngredientsServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/thirdpartyapi/service/AutoIngredientsServiceImpl.java index 6bf8243..cb8b2f9 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/thirdpartyapi/service/AutoIngredientsServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/thirdpartyapi/service/AutoIngredientsServiceImpl.java @@ -154,13 +154,18 @@ public class AutoIngredientsServiceImpl implements AutoIngredientsService { for (ConfigSubSampleMethodConfItem configSubSampleMethodConfItem : downIngredients) { if (configSubSampleMethodConfItem.getRequired()) { ConfigSubSampleMethodConfPoint source = configSubSampleMethodConfItem.getSource(); - String project = source.getProject(); - String parameter = source.getParameter(); - BusinessAssayProjectDataExtendRespVO currentBusinessAssayProjectData = currentBusinessAssayProjectDataList.stream().filter(f -> f.getSimpleName().equals(project)).findFirst().orElse(null); - BusinessAssayParameterDataExtendRespVO currentBusinessAssayParameterData = businessAssayParameterDataList.stream().filter(f -> f.getBusinessAssayProjectDataId().equals(currentBusinessAssayProjectData.getId()) && f.getParameterKey().equals(parameter)).findFirst().orElse(null); - ConfigSubSampleMethodConfPoint target = configSubSampleMethodConfItem.getTarget(); - String field = target.getField(); - BeanUtil.setFieldValue(autoIngredientsTaskDetailRespVO, field, currentBusinessAssayParameterData.getValue()); + List projectList = Arrays.asList(source.getProject().split(","));//来源可以有多个 + for (String project : projectList) { + String parameter = source.getParameter(); + BusinessAssayProjectDataExtendRespVO currentBusinessAssayProjectData = currentBusinessAssayProjectDataList.stream().filter(f -> f.getSimpleName().equals(project)).findFirst().orElse(null); + BusinessAssayParameterDataExtendRespVO currentBusinessAssayParameterData = businessAssayParameterDataList.stream().filter(f -> f.getBusinessAssayProjectDataId().equals(currentBusinessAssayProjectData.getId()) && f.getParameterKey().equals(parameter)).findFirst().orElse(null); + if (StringUtils.isNotBlank(currentBusinessAssayParameterData.getValue())) { + ConfigSubSampleMethodConfPoint target = configSubSampleMethodConfItem.getTarget(); + String field = target.getField(); + BeanUtil.setFieldValue(autoIngredientsTaskDetailRespVO, field, currentBusinessAssayParameterData.getValue()); + break; + } + } } } } @@ -239,19 +244,19 @@ public class AutoIngredientsServiceImpl implements AutoIngredientsService { // System.out.println("fieldValue:" + fieldValue); ConfigSubSampleMethodConfPoint target = configSubSampleMethodConfItem.getTarget(); - String project = target.getProject(); - - BusinessAssayProjectDataExtendRespVO currentBusinessAssayProjectData = businessAssayProjectDataList.stream().filter(f -> f.getBusinessAssayTaskDataId().equals(autoIngredientsTaskDetailAssayResultReqVO.getId()) && f.getSimpleName().equals(project)).findFirst().orElse(null); - String parameter = target.getParameter(); - if (StringUtils.isBlank(parameter)) { - currentBusinessAssayProjectData.setValue(fieldValue.toString()); - updateBusinessAssayProjectDataDOList.add(BeanUtils.toBean(currentBusinessAssayProjectData, BusinessAssayProjectDataDO.class)); - } else { - BusinessAssayParameterDataExtendRespVO currentBusinessAssayParameterData = businessAssayParameterDataList.stream().filter(f -> f.getBusinessAssayProjectDataId().equals(currentBusinessAssayProjectData.getId()) && f.getParameterKey().equals(parameter)).findFirst().orElse(null); - currentBusinessAssayParameterData.setValue(fieldValue.toString()); - updateBusinessAssayParameterDataDOList.add(BeanUtils.toBean(currentBusinessAssayParameterData, BusinessAssayParameterDataDO.class)); + List projectList = Arrays.asList(target.getProject().split(","));//目标可以有多个 + for (String project : projectList) { + BusinessAssayProjectDataExtendRespVO currentBusinessAssayProjectData = businessAssayProjectDataList.stream().filter(f -> f.getBusinessAssayTaskDataId().equals(autoIngredientsTaskDetailAssayResultReqVO.getId()) && f.getSimpleName().equals(project)).findFirst().orElse(null); + String parameter = target.getParameter(); + if (StringUtils.isBlank(parameter)) { + currentBusinessAssayProjectData.setValue(fieldValue.toString()); + updateBusinessAssayProjectDataDOList.add(BeanUtils.toBean(currentBusinessAssayProjectData, BusinessAssayProjectDataDO.class)); + } else { + BusinessAssayParameterDataExtendRespVO currentBusinessAssayParameterData = businessAssayParameterDataList.stream().filter(f -> f.getBusinessAssayProjectDataId().equals(currentBusinessAssayProjectData.getId()) && f.getParameterKey().equals(parameter)).findFirst().orElse(null); + currentBusinessAssayParameterData.setValue(fieldValue.toString()); + updateBusinessAssayParameterDataDOList.add(BeanUtils.toBean(currentBusinessAssayParameterData, BusinessAssayParameterDataDO.class)); + } } - } } }