diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/dal/mapper/BusinessAssayProjectDataMapper.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/dal/mapper/BusinessAssayProjectDataMapper.java index 920ade1f..1eefb1c6 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/dal/mapper/BusinessAssayProjectDataMapper.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/dal/mapper/BusinessAssayProjectDataMapper.java @@ -27,6 +27,51 @@ import org.apache.ibatis.annotations.Param; public interface BusinessAssayProjectDataMapper extends BaseMapperX { default List selectProjectAndParameterBy(BusinessAssayProjectDataReqVO reqVO) { + return selectJoinList(BusinessAssayProjectAndParameterRespVO.class, new MPJLambdaWrapperX() + .leftJoin(ConfigAssayMethodProjectDO.class, ConfigAssayMethodProjectDO::getId, BusinessAssayProjectDataDO::getConfigAssayMethodProjectId) + .leftJoin(DictionaryProjectDO.class, DictionaryProjectDO::getId, BusinessAssayProjectDataDO::getDictionaryProjectId) + .leftJoin(DictionaryBusinessDO.class, DictionaryBusinessDO::getId, ConfigAssayMethodProjectDO::getDictionaryBusinessId) + .selectAs(BusinessAssayProjectDataDO::getId, BusinessAssayProjectAndParameterRespVO::getId) + .selectAs(BusinessAssayProjectDataDO::getBusinessAssayTaskDataId, BusinessAssayProjectAndParameterRespVO::getBizId) + .selectAs(BusinessAssayProjectDataDO::getDictionaryProjectId, BusinessAssayProjectAndParameterRespVO::getDicId) + .selectAs(DictionaryProjectDO::getKey, BusinessAssayProjectAndParameterRespVO::getDicKey) + //.selectAs(DictionaryProjectDO::getName, BusinessAssayProjectAndParameterRespVO::getName) + .selectAs(DictionaryProjectDO::getSimpleName, BusinessAssayProjectAndParameterRespVO::getName) + .selectAs(DictionaryProjectDO::getShowName, BusinessAssayProjectAndParameterRespVO::getShowName) + .selectAs(BusinessAssayProjectDataDO::getDataType, BusinessAssayProjectAndParameterRespVO::getDataType) + .selectAs(BusinessAssayProjectDataDO::getDecimalPosition, BusinessAssayProjectAndParameterRespVO::getDecimalPosition) + .selectAs(BusinessAssayProjectDataDO::getValue, BusinessAssayProjectAndParameterRespVO::getValue) + .selectAs(BusinessAssayProjectDataDO::getSymbol, BusinessAssayProjectAndParameterRespVO::getSymbol) + .selectAs(ConfigAssayMethodProjectDO::getDictionaryProjectUnit, BusinessAssayProjectAndParameterRespVO::getUnit) + .selectAs(ConfigAssayMethodProjectDO::getIsNull, BusinessAssayProjectAndParameterRespVO::getIsNull) + .selectAs(ConfigAssayMethodProjectDO::getFormula, BusinessAssayProjectAndParameterRespVO::getFormula) + .selectAs(ConfigAssayMethodProjectDO::getSortNo, BusinessAssayProjectAndParameterRespVO::getParamNo) + .selectAs("'project'", BusinessAssayProjectAndParameterRespVO::getType) + .selectAs(ConfigAssayMethodProjectDO::getDictionaryBusinessId, BusinessAssayProjectAndParameterRespVO::getGroupDictionaryBusinessId) + .selectAs(ConfigAssayMethodProjectDO::getDictionaryBusinessKey, BusinessAssayProjectAndParameterRespVO::getGroupDictionaryBusinessKey) + .selectAs(DictionaryBusinessDO::getName, BusinessAssayProjectAndParameterRespVO::getGroupDictionaryBusinessName) + .eqIfPresent(BusinessAssayProjectDataDO::getBusinessAssayTaskDataId, reqVO.getBusinessAssayTaskDataId()) + .inIfPresent(BusinessAssayProjectDataDO::getBusinessAssayTaskDataId, reqVO.getBusinessAssayTaskDataIdList()) + .eqIfPresent(BusinessAssayProjectDataDO::getConfigAssayMethodProjectId, reqVO.getConfigAssayMethodProjectId()) + .eqIfPresent(BusinessAssayProjectDataDO::getDictionaryProjectId, reqVO.getDictionaryProjectId()) + .eqIfPresent(BusinessAssayProjectDataDO::getUsage, reqVO.getUsage()) + .eqIfPresent(BusinessAssayProjectDataDO::getSymbol, reqVO.getSymbol()) + .eqIfPresent(BusinessAssayProjectDataDO::getValue, reqVO.getValue()) + .eqIfPresent(BusinessAssayProjectDataDO::getConfigAssayMethodProjectCoefficientId, reqVO.getConfigAssayMethodProjectCoefficientId()) + .eqIfPresent(BusinessAssayProjectDataDO::getCoefficient, reqVO.getCoefficient()) + .eqIfPresent(BusinessAssayProjectDataDO::getValueAfter, reqVO.getValueAfter()) + .eqIfPresent(BusinessAssayProjectDataDO::getDataType, reqVO.getDataType()) + .eqIfPresent(BusinessAssayProjectDataDO::getDecimalPosition, reqVO.getDecimalPosition()) + .eqIfPresent(BusinessAssayProjectDataDO::getIsNotAssessment, reqVO.getIsNotAssessment()) + .eqIfPresent(BusinessAssayProjectDataDO::getIsEnabled, reqVO.getIsEnabled()) + .eqIfPresent(BusinessAssayProjectDataDO::getUpdateCount, reqVO.getUpdateCount()) + .eqIfPresent(BusinessAssayProjectDataDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode()) + .betweenIfPresent(BusinessAssayProjectDataDO::getCreateTime, reqVO.getCreateTime()) + .eqIfPresent(BusinessAssayProjectDataDO::getRemark, reqVO.getRemark()) + .orderByAsc(ConfigAssayMethodProjectDO::getSortNo)); + } + + default List selectProjectAndParameterByOld(BusinessAssayProjectDataReqVO reqVO) { return selectJoinList(BusinessAssayProjectAndParameterRespVO.class, new MPJLambdaWrapperX() .leftJoin(ConfigAssayMethodProjectDO.class, ConfigAssayMethodProjectDO::getId, BusinessAssayProjectDataDO::getConfigAssayMethodProjectId) .leftJoin(DictionaryProjectDO.class, DictionaryProjectDO::getId, BusinessAssayProjectDataDO::getDictionaryProjectId) diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/dal/mapper/BusinessAssayTaskParameterDataMapper.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/dal/mapper/BusinessAssayTaskParameterDataMapper.java index cc836206..6cf91856 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/dal/mapper/BusinessAssayTaskParameterDataMapper.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/dal/mapper/BusinessAssayTaskParameterDataMapper.java @@ -6,7 +6,6 @@ import com.zt.plat.framework.common.pojo.PageResult; import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX; import com.zt.plat.framework.mybatis.core.query.MPJLambdaWrapperX; import com.zt.plat.module.qms.business.bus.controller.vo.*; -import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayProjectDataDO; import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayTaskParameterDataDO; import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigAssayMethodParameterDO; import com.zt.plat.module.qms.common.dic.dal.dataobject.DictionaryBusinessDO; @@ -49,9 +48,9 @@ public interface BusinessAssayTaskParameterDataMapper extends BaseMapperX() + .leftJoin(ConfigAssayMethodParameterDO.class, ConfigAssayMethodParameterDO::getId, BusinessAssayTaskParameterDataDO::getConfigAssayMethodParameterId) + .selectAll(BusinessAssayTaskParameterDataDO.class) + .eq(BusinessAssayTaskParameterDataDO::getBusinessAssayTaskDataId, businessAssayTaskDataId) + .eq(ConfigAssayMethodParameterDO::getKey, key)); + } } \ 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/dal/mapper/BusinessQCManagementProjectDataMapper.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/dal/mapper/BusinessQCManagementProjectDataMapper.java index e60ce36d..8ba1fcd0 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/dal/mapper/BusinessQCManagementProjectDataMapper.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/dal/mapper/BusinessQCManagementProjectDataMapper.java @@ -6,7 +6,6 @@ import com.zt.plat.framework.common.pojo.PageResult; import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX; import com.zt.plat.framework.mybatis.core.query.MPJLambdaWrapperX; import com.zt.plat.module.qms.business.bus.controller.vo.*; -import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayTaskParameterDataDO; import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessQCManagementProjectDataDO; import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigAssayMethodProjectDO; import com.zt.plat.module.qms.business.dic.dal.dataobject.DictionaryProjectDO; @@ -42,6 +41,47 @@ public interface BusinessQCManagementProjectDataMapper extends BaseMapperX selectProjectAndParameterBy(BusinessQCManagementProjectDataReqVO reqVO) { + return selectJoinList(BusinessAssayProjectAndParameterRespVO.class, new MPJLambdaWrapperX() + .leftJoin(ConfigAssayMethodProjectDO.class, ConfigAssayMethodProjectDO::getId, BusinessQCManagementProjectDataDO::getConfigAssayMethodProjectId) + .leftJoin(DictionaryProjectDO.class, DictionaryProjectDO::getId, BusinessQCManagementProjectDataDO::getDictionaryProjectId) + .leftJoin(DictionaryBusinessDO.class, DictionaryBusinessDO::getId, ConfigAssayMethodProjectDO::getDictionaryBusinessId) + .selectAs(BusinessQCManagementProjectDataDO::getId, BusinessAssayProjectAndParameterRespVO::getId) + .selectAs(BusinessQCManagementProjectDataDO::getBusinessQCManagementDataId, BusinessAssayProjectAndParameterRespVO::getBizId) + .selectAs(BusinessQCManagementProjectDataDO::getDictionaryProjectId, BusinessAssayProjectAndParameterRespVO::getDicId) + .selectAs(DictionaryProjectDO::getKey, BusinessAssayProjectAndParameterRespVO::getDicKey) + //.selectAs(DictionaryProjectDO::getName, BusinessAssayProjectAndParameterRespVO::getName) + .selectAs(DictionaryProjectDO::getSimpleName, BusinessAssayProjectAndParameterRespVO::getName) + .selectAs(DictionaryProjectDO::getShowName, BusinessAssayProjectAndParameterRespVO::getShowName) + .selectAs(BusinessQCManagementProjectDataDO::getDataType, BusinessAssayProjectAndParameterRespVO::getDataType) + .selectAs(BusinessQCManagementProjectDataDO::getDecimalPosition, BusinessAssayProjectAndParameterRespVO::getDecimalPosition) + .selectAs(BusinessQCManagementProjectDataDO::getValue, BusinessAssayProjectAndParameterRespVO::getValue) + .selectAs(BusinessQCManagementProjectDataDO::getSymbol, BusinessAssayProjectAndParameterRespVO::getSymbol) + .selectAs(ConfigAssayMethodProjectDO::getDictionaryProjectUnit, BusinessAssayProjectAndParameterRespVO::getUnit) + .selectAs(ConfigAssayMethodProjectDO::getIsNull, BusinessAssayProjectAndParameterRespVO::getIsNull) + .selectAs(ConfigAssayMethodProjectDO::getFormula, BusinessAssayProjectAndParameterRespVO::getFormula) + .selectAs(ConfigAssayMethodProjectDO::getSortNo, BusinessAssayProjectAndParameterRespVO::getParamNo) + .selectAs("'project'", BusinessAssayProjectAndParameterRespVO::getType) + .selectAs(ConfigAssayMethodProjectDO::getDictionaryBusinessId, BusinessAssayProjectAndParameterRespVO::getGroupDictionaryBusinessId) + .selectAs(ConfigAssayMethodProjectDO::getDictionaryBusinessKey, BusinessAssayProjectAndParameterRespVO::getGroupDictionaryBusinessKey) + .selectAs(DictionaryBusinessDO::getName, BusinessAssayProjectAndParameterRespVO::getGroupDictionaryBusinessName) + .eqIfPresent(BusinessQCManagementProjectDataDO::getBusinessQCManagementDataId, reqVO.getBusinessQCManagementDataId()) + .eqIfPresent(BusinessQCManagementProjectDataDO::getConfigAssayMethodProjectId, reqVO.getConfigAssayMethodProjectId()) + .eqIfPresent(BusinessQCManagementProjectDataDO::getDictionaryProjectId, reqVO.getDictionaryProjectId()) + .eqIfPresent(BusinessQCManagementProjectDataDO::getUsage, reqVO.getUsage()) + .eqIfPresent(BusinessQCManagementProjectDataDO::getSymbol, reqVO.getSymbol()) + .eqIfPresent(BusinessQCManagementProjectDataDO::getValue, reqVO.getValue()) + .eqIfPresent(BusinessQCManagementProjectDataDO::getDataType, reqVO.getDataType()) + .eqIfPresent(BusinessQCManagementProjectDataDO::getDecimalPosition, reqVO.getDecimalPosition()) + .eqIfPresent(BusinessQCManagementProjectDataDO::getIsNotAssessment, reqVO.getIsNotAssessment()) + .eqIfPresent(BusinessQCManagementProjectDataDO::getIsEnabled, reqVO.getIsEnabled()) + .eqIfPresent(BusinessQCManagementProjectDataDO::getUpdateCount, reqVO.getUpdateCount()) + .eqIfPresent(BusinessQCManagementProjectDataDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode()) + .betweenIfPresent(BusinessQCManagementProjectDataDO::getCreateTime, reqVO.getCreateTime()) + .eqIfPresent(BusinessQCManagementProjectDataDO::getRemark, reqVO.getRemark()) + .orderByAsc(ConfigAssayMethodProjectDO::getSortNo)); + } + + default List selectProjectAndParameterByOld(BusinessQCManagementProjectDataReqVO reqVO) { return selectJoinList(BusinessAssayProjectAndParameterRespVO.class, new MPJLambdaWrapperX() .leftJoin(ConfigAssayMethodProjectDO.class, ConfigAssayMethodProjectDO::getId, BusinessQCManagementProjectDataDO::getConfigAssayMethodProjectId) .leftJoin(DictionaryProjectDO.class, DictionaryProjectDO::getId, BusinessQCManagementProjectDataDO::getDictionaryProjectId) diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/dal/mapper/BusinessQCManagementSampleParameterDataMapper.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/dal/mapper/BusinessQCManagementSampleParameterDataMapper.java index 7dc38959..93d6db88 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/dal/mapper/BusinessQCManagementSampleParameterDataMapper.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/dal/mapper/BusinessQCManagementSampleParameterDataMapper.java @@ -48,9 +48,9 @@ public interface BusinessQCManagementSampleParameterDataMapper extends BaseMappe .selectAs(BusinessQCManagementSampleParameterDataDO::getDataType, BusinessAssayProjectAndParameterRespVO::getDataType) .selectAs(BusinessQCManagementSampleParameterDataDO::getDecimalPosition, BusinessAssayProjectAndParameterRespVO::getDecimalPosition) .selectAs(BusinessQCManagementSampleParameterDataDO::getValue, BusinessAssayProjectAndParameterRespVO::getValue) - //.selectAs(ConfigAssayMethodParameterDO::getDictionaryProjectUnit, BusinessAssayProjectAndParameterRespVO::getUnit) + .selectAs(ConfigAssayMethodParameterDO::getUnit, BusinessAssayProjectAndParameterRespVO::getUnit) .selectAs(ConfigAssayMethodParameterDO::getIsNull, BusinessAssayProjectAndParameterRespVO::getIsNull) - //.selectAs(ConfigAssayMethodParameterDO::getFormula, BusinessAssayProjectAndParameterRespVO::getFormula) + .selectAs(ConfigAssayMethodParameterDO::getFormula, BusinessAssayProjectAndParameterRespVO::getFormula) .selectAs(ConfigAssayMethodParameterDO::getSortNo, BusinessAssayProjectAndParameterRespVO::getParamNo) .selectAs("'attribute'", BusinessAssayProjectAndParameterRespVO::getType) .selectAs(ConfigAssayMethodParameterDO::getDictionaryBusinessId, BusinessAssayProjectAndParameterRespVO::getGroupDictionaryBusinessId) diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/liteflow/sample/entrust/SampleEntrustGenSampleDataCmp.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/liteflow/sample/entrust/SampleEntrustGenSampleDataCmp.java index df914948..bb1be570 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/liteflow/sample/entrust/SampleEntrustGenSampleDataCmp.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/liteflow/sample/entrust/SampleEntrustGenSampleDataCmp.java @@ -439,14 +439,14 @@ public class SampleEntrustGenSampleDataCmp extends NodeComponent { ConfigAssayMethodDO configAssayMethodDO = configAssayMethodList.stream().filter(f -> f.getId().equals(configAssayMethodId)).findFirst().orElse(null); //查询子样对应的分析方法 - ConfigSubSampleMethodExtendRespVO configSubSampleMethodDO = configSubSampleMethodList.stream().filter(f -> f.getIsDefaultUse().equals(QmsCommonConstant.YES) && f.getConfigAssayMethodId().equals(configAssayMethodId) && f.getConfigSubSampleId().equals(configSubSample.getId())).findFirst().orElse(null); + ConfigSubSampleMethodExtendRespVO configSubSampleMethod = configSubSampleMethodList.stream().filter(f -> f.getIsDefaultUse().equals(QmsCommonConstant.YES) && f.getConfigAssayMethodId().equals(configAssayMethodId) && f.getConfigSubSampleId().equals(configSubSample.getId())).findFirst().orElse(null); - if (configSubSampleMethodDO == null) { + if (configSubSampleMethod == null) { throw new ServiceException(1_032_100_000, "未找到子样对应的分析方法配置!"); } //扩展配置信息 - String configInfomation = configSubSampleMethodDO.getConfigInfomation(); + String configInfomation = configSubSampleMethod.getConfigInfomation(); List getParamList = null; if (StringUtils.isNotBlank(configInfomation)) { ConfigSubSampleMethodConfInfo configSubSampleMethodConfInfo = JSON.parseObject(configInfomation, ConfigSubSampleMethodConfInfo.class); @@ -520,7 +520,7 @@ public class SampleEntrustGenSampleDataCmp extends NodeComponent { } //根据任务数判断是平行还是 - String assayType = configSubSampleMethodDO.getTaskCount() > 1 ? QmsCommonConstant.ASSAY_TYPE_SINGLE_PARALLEL : QmsCommonConstant.ASSAY_TYPE_SINGLE_CUP; + String assayType = configSubSampleMethod.getTaskCount() > 1 ? QmsCommonConstant.ASSAY_TYPE_SINGLE_PARALLEL : QmsCommonConstant.ASSAY_TYPE_SINGLE_CUP; //分样判定数据 BusinessSubParentSampleAssessmentDO businessSubParentSampleAssessmentDO = businessSubParentSampleAssessmentDOList.stream().filter(f -> f.getBusinessSubParentSampleId().equals(businessSubSampleDO.getBusinessSubParentSampleId()) && f.getConfigAssayMethodId().equals(configAssayMethodId) && f.getAssayType().equals(assayType)).findFirst().orElse(null);//防止重复添加,先从列表过滤 @@ -551,7 +551,7 @@ public class SampleEntrustGenSampleDataCmp extends NodeComponent { } //根据任务数循环 - for (int i = 0; i < configSubSampleMethodDO.getTaskCount(); i++) { + for (int i = 0; i < configSubSampleMethod.getTaskCount(); i++) { Long businessSubSampleId = businessSubSampleDO.getId(); Long businessSubSampleAssessmentId = businessSubSampleAssessmentDO.getId(); BusinessAssayTaskDataDO businessAssayTaskDataDO = businessAssayTaskDataDOList.stream().filter(f -> { @@ -592,7 +592,27 @@ public class SampleEntrustGenSampleDataCmp extends NodeComponent { businessAssayTaskParameterDataDO.setBusinessAssayTaskDataId(businessAssayTaskDataDO.getId()); businessAssayTaskParameterDataDO.setConfigAssayMethodParameterId(configAssayMethodParameterDO.getId()); businessAssayTaskParameterDataDO.setDataType(configAssayMethodParameterDO.getDataType()); - businessAssayTaskParameterDataDO.setDecimalPosition(configAssayMethodParameterDO.getDecimalPosition()); + businessAssayTaskParameterDataDO.setDecimalPosition(configAssayMethodParameterDO.getDecimalPosition()); + + if (StringUtils.isNotBlank(configAssayMethodParameterDO.getDefaultValue())) { + businessAssayTaskParameterDataDO.setValue(configAssayMethodParameterDO.getDefaultValue()); + } + + //来样品位赋值 + if (getParamList != null) { + List targetAttributeList = getParamList.stream().filter(f -> StringUtils.isNotBlank(f.getTarget().getAttribute()) && f.getTarget().getAttribute().contains(configAssayMethodParameterDO.getKey())).map(m -> m.getTarget().getAttribute()).collect(Collectors.toList()); + String forecastResult = businessSampleEntrustDetailDO.getForecastResult(); + if (StringUtils.isNotBlank(forecastResult)) { + JSONArray array = JSON.parseArray(forecastResult); + for (int forecIndex = 0; forecIndex < array.size(); forecIndex++) { + JSONObject item = array.getJSONObject(forecIndex); + if (targetAttributeList.contains(item.getString("simpleName")) && StringUtils.isNotBlank(configAssayMethodParameterDO.getKey()) && configAssayMethodParameterDO.getKey().equals(item.getString("simpleName"))) { + businessAssayTaskParameterDataDO.setValue(item.getString("value")); + break; + } + } + } + } businessAssayTaskParameterDataDOList.add(businessAssayTaskParameterDataDO); } @@ -652,7 +672,7 @@ public class SampleEntrustGenSampleDataCmp extends NodeComponent { //来样品位赋值 if (getParamList != null) { - List targetParameterList = getParamList.stream().filter(f -> f.getTarget().getProject().contains(configAssayMethodProjectDO.getSimpleName())).map(m -> m.getTarget().getParameter()).collect(Collectors.toList()); + List targetParameterList = getParamList.stream().filter(f -> StringUtils.isNotBlank(f.getTarget().getProject()) && f.getTarget().getProject().contains(configAssayMethodProjectDO.getSimpleName())).map(m -> m.getTarget().getParameter()).collect(Collectors.toList()); String forecastResult = businessSampleEntrustDetailDO.getForecastResult(); if (StringUtils.isNotBlank(forecastResult)) { JSONArray array = JSON.parseArray(forecastResult); @@ -688,7 +708,7 @@ public class SampleEntrustGenSampleDataCmp extends NodeComponent { //来样品位赋值 if (getParamList != null) { - List targetParameterList = getParamList.stream().filter(f -> f.getTarget().getProject().contains(configAssayMethodProjectDO.getSimpleName())).map(m -> m.getTarget().getParameter()).collect(Collectors.toList()); + List targetParameterList = getParamList.stream().filter(f -> StringUtils.isNotBlank(f.getTarget().getProject()) && f.getTarget().getProject().contains(configAssayMethodProjectDO.getSimpleName())).map(m -> m.getTarget().getParameter()).collect(Collectors.toList()); String forecastResult = businessSampleEntrustDetailDO.getForecastResult(); if (StringUtils.isNotBlank(forecastResult)) { JSONArray array = JSON.parseArray(forecastResult); @@ -890,6 +910,10 @@ public class SampleEntrustGenSampleDataCmp extends NodeComponent { businessAssayTaskParameterDataDO.setConfigAssayMethodParameterId(configAssayMethodParameterDO.getId()); businessAssayTaskParameterDataDO.setDataType(configAssayMethodParameterDO.getDataType()); businessAssayTaskParameterDataDO.setDecimalPosition(configAssayMethodParameterDO.getDecimalPosition()); + + if (StringUtils.isNotBlank(configAssayMethodParameterDO.getDefaultValue())) { + businessAssayTaskParameterDataDO.setValue(configAssayMethodParameterDO.getDefaultValue()); + } businessAssayTaskParameterDataDOList.add(businessAssayTaskParameterDataDO); } diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/liteflow/sample/taskassign/SampleTaskAssignQCSampleCmp.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/liteflow/sample/taskassign/SampleTaskAssignQCSampleCmp.java index 660304cd..b49197d5 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/liteflow/sample/taskassign/SampleTaskAssignQCSampleCmp.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/liteflow/sample/taskassign/SampleTaskAssignQCSampleCmp.java @@ -278,6 +278,9 @@ public class SampleTaskAssignQCSampleCmp extends NodeComponent { businessQCManagementParameterDataDO.setDictionaryParameterId(configAssayMethodProjectParameterDO.getDictionaryParameterId()); businessQCManagementParameterDataDO.setDataType(configAssayMethodProjectParameterDO.getDataType()); businessQCManagementParameterDataDO.setDecimalPosition(configAssayMethodProjectParameterDO.getDecimalPosition()); + if (StringUtils.isNotBlank(configAssayMethodProjectParameterDO.getDefaultValue())) { + businessQCManagementParameterDataDO.setValue(configAssayMethodProjectParameterDO.getDefaultValue()); + } businessQCManagementParameterDataDOList.add(businessQCManagementParameterDataDO); } 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 557f67a6..cfc37a5b 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,6 +1,5 @@ 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.*; @@ -13,11 +12,11 @@ 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.bus.dal.mapper.BusinessAssayTaskParameterDataMapper; 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; @@ -25,15 +24,8 @@ import com.zt.plat.module.qms.business.config.controller.vo.ConfigSubSampleMetho 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; -import com.zt.plat.framework.security.core.util.SecurityFrameworkUtils; -import com.zt.plat.framework.tenant.core.context.TenantContextHolder; - import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception; -import static com.zt.plat.framework.common.util.collection.CollectionUtils.convertList; -import static com.zt.plat.framework.common.util.collection.CollectionUtils.diffList; import static com.zt.plat.module.qms.enums.ErrorCodeConstants.*; /** @@ -48,6 +40,9 @@ public class BusinessAssayTaskDataServiceImpl implements BusinessAssayTaskDataSe @Resource private BusinessAssayTaskDataMapper businessAssayTaskDataMapper; + @Resource + private BusinessAssayTaskParameterDataMapper businessAssayTaskParameterDataMapper; + @Resource private BusinessAssayProjectDataMapper businessAssayProjectDataMapper; @@ -148,6 +143,9 @@ public class BusinessAssayTaskDataServiceImpl implements BusinessAssayTaskDataSe List businessAssayProjectDataIdList = businessAssayProjectDataList.stream().map(m -> m.getId()).collect(Collectors.toList()); //查询检测项目参数 List businessAssayParameterDataList = businessAssayParameterDataMapper.selectExtendByBusinessAssayProjectDataIds(businessAssayProjectDataIdList); + //查询分析任务属性 + List businessAssayTaskParameterDataList = businessAssayTaskParameterDataMapper.selectExtendByBusinessAssayTaskDataIds(businessAssayTaskDataIdList); + for (BusinessAssayTaskDataExtendRespVO businessAssayTaskData : list) { ConfigSubSampleMethodExtendRespVO configSubSampleMethod = configSubSampleMethodList.stream().filter(f -> f.getConfigSubSampleId().equals(businessAssayTaskData.getConfigSubSampleId()) && f.getConfigAssayMethodId().equals(businessAssayTaskData.getConfigAssayMethodId())).findFirst().orElse(null); @@ -158,19 +156,28 @@ public class BusinessAssayTaskDataServiceImpl implements BusinessAssayTaskDataSe 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()) && project.equals(f.getSimpleName())).findFirst().orElse(null); - if (currentBusinessAssayProjectData == null) {//如果检测项目为空,则跳出当前循环 - continue; + if (StringUtils.isNotBlank(target.getProject())) {//来自检测项目参数 + 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()) && project.equals(f.getSimpleName())).findFirst().orElse(null); + if (currentBusinessAssayProjectData == null) {//如果检测项目为空,则跳出当前循环 + continue; + } + BusinessAssayParameterDataExtendRespVO currentBusinessAssayParameterData = businessAssayParameterDataList.stream().filter(f -> f.getBusinessAssayProjectDataId().equals(currentBusinessAssayProjectData.getId()) && parameter.equals(f.getParameterKey())).findFirst().orElse(null); + if (currentBusinessAssayParameterData != null && StringUtils.isNotBlank(currentBusinessAssayParameterData.getValue())) { + ingredientInfoBuilder.append(currentBusinessAssayParameterData.getParameterName()).append(":").append(currentBusinessAssayParameterData.getValue()).append("、"); + break; + } } - BusinessAssayParameterDataExtendRespVO currentBusinessAssayParameterData = businessAssayParameterDataList.stream().filter(f -> f.getBusinessAssayProjectDataId().equals(currentBusinessAssayProjectData.getId()) && parameter.equals(f.getParameterKey())).findFirst().orElse(null); - if (currentBusinessAssayParameterData != null && StringUtils.isNotBlank(currentBusinessAssayParameterData.getValue())) { - ingredientInfoBuilder.append(currentBusinessAssayParameterData.getParameterName()).append(":").append(currentBusinessAssayParameterData.getValue()).append("、"); - break; + + } else if (StringUtils.isNotBlank(target.getAttribute())) {//来自分析任务属性 + BusinessAssayTaskParameterDataExtendRespVO currentBusinessAssayTaskParameterData = businessAssayTaskParameterDataList.stream().filter(f -> f.getBusinessAssayTaskDataId().equals(businessAssayTaskData.getId()) && target.getAttribute().endsWith(f.getKey())).findFirst().orElse(null); + if (currentBusinessAssayTaskParameterData != null && StringUtils.isNotBlank(currentBusinessAssayTaskParameterData.getValue())) { + ingredientInfoBuilder.append(currentBusinessAssayTaskParameterData.getParameterName()).append(":").append(currentBusinessAssayTaskParameterData.getValue()).append("、"); } } + } if (ingredientInfoBuilder.length() > 0) { ingredientInfoBuilder.delete(ingredientInfoBuilder.length() - 1, ingredientInfoBuilder.length()); @@ -205,6 +212,8 @@ public class BusinessAssayTaskDataServiceImpl implements BusinessAssayTaskDataSe List businessAssayProjectDataIdList = businessAssayProjectDataList.stream().map(m -> m.getId()).collect(Collectors.toList()); //查询检测项目参数 List businessAssayParameterDataList = businessAssayParameterDataMapper.selectExtendByBusinessAssayProjectDataIds(businessAssayProjectDataIdList); + //查询分析任务属性 + List businessAssayTaskParameterDataList = businessAssayTaskParameterDataMapper.selectExtendByBusinessAssayTaskDataIds(businessAssayTaskDataIdList); for (BusinessAssayTaskDataExtendRespVO businessAssayTaskData : list) { ConfigSubSampleMethodExtendRespVO configSubSampleMethod = configSubSampleMethodList.stream().filter(f -> f.getConfigSubSampleId().equals(businessAssayTaskData.getConfigSubSampleId()) && f.getConfigAssayMethodId().equals(businessAssayTaskData.getConfigAssayMethodId())).findFirst().orElse(null); @@ -215,17 +224,24 @@ public class BusinessAssayTaskDataServiceImpl implements BusinessAssayTaskDataSe 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()) && project.equals(f.getSimpleName())).findFirst().orElse(null); - if (currentBusinessAssayProjectData == null) {//如果检测项目为空,则跳出当前循环 - continue; + if (StringUtils.isNotBlank(target.getProject())) {//来自检测项目参数 + 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()) && project.equals(f.getSimpleName())).findFirst().orElse(null); + if (currentBusinessAssayProjectData == null) {//如果检测项目为空,则跳出当前循环 + continue; + } + BusinessAssayParameterDataExtendRespVO currentBusinessAssayParameterData = businessAssayParameterDataList.stream().filter(f -> f.getBusinessAssayProjectDataId().equals(currentBusinessAssayProjectData.getId()) && parameter.equals(f.getParameterKey())).findFirst().orElse(null); + if (currentBusinessAssayParameterData != null && StringUtils.isNotBlank(currentBusinessAssayParameterData.getValue())) { + ingredientInfoBuilder.append(currentBusinessAssayParameterData.getParameterName()).append(":").append(currentBusinessAssayParameterData.getValue()).append("、"); + break; + } } - BusinessAssayParameterDataExtendRespVO currentBusinessAssayParameterData = businessAssayParameterDataList.stream().filter(f -> f.getBusinessAssayProjectDataId().equals(currentBusinessAssayProjectData.getId()) && parameter.equals(f.getParameterKey())).findFirst().orElse(null); - if (currentBusinessAssayParameterData != null && StringUtils.isNotBlank(currentBusinessAssayParameterData.getValue())) { - ingredientInfoBuilder.append(currentBusinessAssayParameterData.getParameterName()).append(":").append(currentBusinessAssayParameterData.getValue()).append("、"); - break; + } else if (StringUtils.isNotBlank(target.getAttribute())) {//来自分析任务属性 + BusinessAssayTaskParameterDataExtendRespVO currentBusinessAssayTaskParameterData = businessAssayTaskParameterDataList.stream().filter(f -> f.getBusinessAssayTaskDataId().equals(businessAssayTaskData.getId()) && target.getAttribute().endsWith(f.getKey())).findFirst().orElse(null); + if (currentBusinessAssayTaskParameterData != null && StringUtils.isNotBlank(currentBusinessAssayTaskParameterData.getValue())) { + ingredientInfoBuilder.append(currentBusinessAssayTaskParameterData.getParameterName()).append(":").append(currentBusinessAssayTaskParameterData.getValue()).append("、"); } } } diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/service/SampleAnalysisAuditServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/service/SampleAnalysisAuditServiceImpl.java index 70013758..e8dbb830 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/service/SampleAnalysisAuditServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/service/SampleAnalysisAuditServiceImpl.java @@ -37,7 +37,7 @@ import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayProjectDa import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayTaskDO; import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayTaskDataDO; import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayTaskDetailDO; -import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessBaseSampleDO; +import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayTaskParameterDataDO; import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessQCCoefficientDataDO; import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessQCManagementDataDO; import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessSubParentSampleAssessmentDO; @@ -68,7 +68,6 @@ import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessSubSampleAssessmen import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessSubSampleMapper; import com.zt.plat.module.qms.business.config.controller.vo.*; import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigAssayMethodProjectAssessmentDO; -import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigAssayMethodProjectCoefficientDO; import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigAssayMethodProjectParameterDO; import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigRuleDO; import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigSubSampleDO; @@ -196,6 +195,7 @@ public class SampleAnalysisAuditServiceImpl implements SampleAnalysisAuditServic for (BusinessAssayTaskDataExtendRespVO businessAssayTaskDataExtendRespVO : resultAssessmentList) { Map businessAssayTaskDataMap = BeanUtil.beanToMap(businessAssayTaskDataExtendRespVO); + @SuppressWarnings("unchecked") Map businessAssayTaskDataAssessmentMap = BeanUtil.copyProperties(businessAssayTaskDataMap, Map.class); businessAssayTaskDataAssessmentMap.put("assayOperator", "判定结果"); businessAssayTaskDataAssessmentMap.put("reportTime", null); @@ -1094,6 +1094,7 @@ public class SampleAnalysisAuditServiceImpl implements SampleAnalysisAuditServic List newBusinessAssayTaskDataDOList = new ArrayList<>(); + List newBusinessAssayTaskParameterDataDOList = new ArrayList<>(); List newBusinessAssayProjectDataDOList = new ArrayList<>(); List newBusinessAssayParameterDataDOList = new ArrayList<>(); @@ -1105,6 +1106,8 @@ public class SampleAnalysisAuditServiceImpl implements SampleAnalysisAuditServic List businessAssayTaskDataDOList = businessAssayTaskDataMapper.selectMaxRecheckCountByBusinessSubSampleIdAndConfigAssayMethodId(businessSubSampleId, configAssayMethodId); //查询分析任务Id列表 List businessAssayTaskDataDOIdList = businessAssayTaskDataDOList.stream().map(m -> m.getId()).collect(Collectors.toList()); + //查询分析任务属性 + List businessAssayTaskParameterDataList = businessAssayTaskParameterDataMapper.selectExtendByBusinessAssayTaskDataIds(businessAssayTaskDataDOIdList); //查询检测项目 List businessAssayProjectDataDOList = businessAssayProjectDataMapper.selectByBusinessAssayTaskDataIds(businessAssayTaskDataDOIdList); //查询检测项目id列表 @@ -1142,6 +1145,29 @@ public class SampleAnalysisAuditServiceImpl implements SampleAnalysisAuditServic newBusinessAssayTaskDataDO.setRetestCount(businessAssayTaskDataDO.getRetestCount()); newBusinessAssayTaskDataDO.setAssayProject(businessAssayTaskDataDO.getAssayProject()); + //分析任务属性 + List currentBusinessAssayTaskParameterDataList = businessAssayTaskParameterDataList.stream().filter(f -> f.getBusinessAssayTaskDataId().equals(businessAssayTaskDataDO.getId())).collect(Collectors.toList()); + for (BusinessAssayTaskParameterDataExtendRespVO currentBusinessAssayTaskParameterData : currentBusinessAssayTaskParameterDataList) { + BusinessAssayTaskParameterDataDO businessAssayTaskParameterDataDO = new BusinessAssayTaskParameterDataDO(); + businessAssayTaskParameterDataDO.setId(IdWorker.getId()); + businessAssayTaskParameterDataDO.setBusinessAssayTaskDataId(newBusinessAssayTaskDataDO.getId()); + businessAssayTaskParameterDataDO.setConfigAssayMethodParameterId(currentBusinessAssayTaskParameterData.getConfigAssayMethodParameterId()); + businessAssayTaskParameterDataDO.setDataType(currentBusinessAssayTaskParameterData.getDataType()); + businessAssayTaskParameterDataDO.setDecimalPosition(currentBusinessAssayTaskParameterData.getDecimalPosition()); + +// if (StringUtils.isNotBlank(configAssayMethodParameterDO.getDefaultValue())) { +// businessAssayTaskParameterDataDO.setValue(configAssayMethodParameterDO.getDefaultValue()); +// } + if (getParamList != null) { + ConfigSubSampleMethodConfItem targetAttribute = getParamList.stream().filter(f -> StringUtils.isNotBlank(f.getTarget().getAttribute()) && f.getTarget().getAttribute().equals(currentBusinessAssayTaskParameterData.getKey())).findFirst().orElse(null); + if (targetAttribute != null) { + businessAssayTaskParameterDataDO.setValue(currentBusinessAssayTaskParameterData.getValue()); + } + } + + newBusinessAssayTaskParameterDataDOList.add(businessAssayTaskParameterDataDO); + } + List businessAssayProjectDataList = businessAssayProjectDataDOList.stream().filter(f -> f.getBusinessAssayTaskDataId().equals(businessAssayTaskDataDO.getId())).collect(Collectors.toList()); for (BusinessAssayProjectDataExtendRespVO businessAssayProjectData : businessAssayProjectDataList) { //检测项目 @@ -1175,8 +1201,8 @@ public class SampleAnalysisAuditServiceImpl implements SampleAnalysisAuditServic } if (getParamList != null) { - List targetParameterList = getParamList.stream().filter(f -> f.getTarget().getProject().contains(businessAssayProjectData.getSimpleName())).map(m -> m.getTarget().getParameter()).collect(Collectors.toList()); - if (StringUtils.isNotBlank(businessAssayParameterData.getParameterKey()) && targetParameterList.contains(businessAssayParameterData.getParameterKey())) { + List targetParameterList = getParamList.stream().filter(f -> StringUtils.isNotBlank(f.getTarget().getProject()) && f.getTarget().getProject().contains(businessAssayProjectData.getSimpleName())).map(m -> m.getTarget().getParameter()).collect(Collectors.toList()); + if (StringUtils.isNotBlank(businessAssayParameterData.getParameterKey()) && CollUtil.isNotEmpty(targetParameterList) && targetParameterList.contains(businessAssayParameterData.getParameterKey())) { businessAssayParameterDataDO.setValue(businessAssayParameterData.getValue()); } } @@ -1204,6 +1230,9 @@ public class SampleAnalysisAuditServiceImpl implements SampleAnalysisAuditServic if (newBusinessAssayTaskDataDOList.size() > 0) { businessAssayTaskDataMapper.insertBatch(newBusinessAssayTaskDataDOList); } + if (newBusinessAssayTaskParameterDataDOList.size() > 0) { + businessAssayTaskParameterDataMapper.insertBatch(newBusinessAssayTaskParameterDataDOList); + } if (newBusinessAssayProjectDataDOList.size() > 0) { businessAssayProjectDataMapper.insertBatch(newBusinessAssayProjectDataDOList); } 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 cef22d54..ce8e31e6 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 @@ -37,6 +37,7 @@ import com.zt.plat.module.qms.business.bus.controller.vo.BusinessAssayTaskBackSa import com.zt.plat.module.qms.business.bus.controller.vo.BusinessAssayTaskDataExtendRespVO; import com.zt.plat.module.qms.business.bus.controller.vo.BusinessAssayTaskDataExternalInfomation; import com.zt.plat.module.qms.business.bus.controller.vo.BusinessAssayTaskDataExternalInfomation.RollbackDetail; +import com.zt.plat.module.qms.business.bus.controller.vo.BusinessAssayTaskParameterDataExtendRespVO; import com.zt.plat.module.qms.business.bus.controller.vo.BusinessQCCoefficientParameterDataReqVO; import com.zt.plat.module.qms.business.bus.controller.vo.BusinessQCManagementParameterDataReqVO; import com.zt.plat.module.qms.business.bus.controller.vo.BusinessQCManagementProjectDataReqVO; @@ -592,6 +593,252 @@ public class SampleAnalysisServiceImpl implements SampleAnalysisService { List configSubSampleMethodDOList = configSubSampleMethodMapper.selectByConfigSubSampleIdsAndConfigAssayMethodIds(configSubSampleIdList, configAssayMethodIdList); + List businessAssayTaskDataIdList = businessAssayTaskDataList.stream().map(m -> m.getId()).collect(Collectors.toList()); + + //任务参数查询 + List taskParameterList = businessAssayTaskParameterDataMapper.selectByBusinessAssayTaskDataIds(businessAssayTaskDataIdList); + Map> taskParameterMap = taskParameterList.stream().sorted(Comparator.comparing(BusinessAssayProjectAndParameterRespVO::getParamNo)).collect(Collectors.groupingBy(BusinessAssayProjectAndParameterRespVO::getDicKey, + LinkedHashMap::new, // 保持组首次出现的顺序(可选) + Collectors.toList() // ArrayList 保持组内顺序 + )); + for (Map.Entry> entry : taskParameterMap.entrySet()) { + BusinessAssayProjectAndParameterRespVO taskParameter = entry.getValue().get(0); + String fieldIndex = "a_" + taskParameter.getDicKey(); + String title = taskParameter.getShowName() + (StringUtils.isBlank(taskParameter.getUnit()) ? "" : "(" + taskParameter.getUnit() + ")"); + boolean isEdit = StringUtils.isBlank(taskParameter.getFormula()); + cloumns.add(new BatchSampleAnalysisColumnRespVO(fieldIndex, fieldIndex + ".value", title, "", minWidth, taskParameter.getDataType(), taskParameter.getDecimalPosition(), null, taskParameter.getFormula(), taskParameter.getParamNo(), isEdit, taskParameter.getUnit(), "attribute", taskParameter.getFillingWay(), taskParameter.getGroupDictionaryBusinessId(), taskParameter.getGroupDictionaryBusinessKey(), taskParameter.getGroupDictionaryBusinessName())); + } + + //查询检测项目 + BusinessAssayProjectDataReqVO projectDataSearch = new BusinessAssayProjectDataReqVO(); + projectDataSearch.setBusinessAssayTaskDataIdList(businessAssayTaskDataIdList); + List projectAndParameterList = businessAssayProjectDataMapper.selectProjectAndParameterBy(projectDataSearch); + List businessAssayProjectDataIdList = projectAndParameterList.stream().map(m -> m.getId()).collect(Collectors.toList()); + + //检测项目参数 + BusinessAssayParameterDataReqVO parameterDataSearch = new BusinessAssayParameterDataReqVO(); + parameterDataSearch.setBusinessAssayProjectDataIdList(businessAssayProjectDataIdList); + List businessAssayParameterDataList = businessAssayParameterDataMapper.selectProjectAndParameterBy(parameterDataSearch); + + Map> projectAndParameterMap = projectAndParameterList.stream().sorted(Comparator.comparing(BusinessAssayProjectAndParameterRespVO::getParamNo)).collect(Collectors.groupingBy(BusinessAssayProjectAndParameterRespVO::getDicId, + LinkedHashMap::new, // 保持组首次出现的顺序(可选) + Collectors.toList() // ArrayList 保持组内顺序 + )); + for (Map.Entry> entry : projectAndParameterMap.entrySet()) { + BusinessAssayProjectAndParameterRespVO ep = entry.getValue().get(0); + String fieldIndex = "e" + ep.getDicId(); + String title = ep.getShowName() + (StringUtils.isBlank(ep.getUnit()) ? "" : "(" + ep.getUnit() + ")"); + boolean isEdit = StringUtils.isBlank(ep.getFormula()); + if (isEdit) { + minWidth = "280px"; + } + cloumns.add(new BatchSampleAnalysisColumnRespVO(fieldIndex, fieldIndex + ".value", title, "", minWidth, ep.getDataType(), ep.getDecimalPosition(), null, ep.getFormula(), ep.getParamNo(), isEdit, ep.getUnit(), "project", ep.getFillingWay(), ep.getGroupDictionaryBusinessId(), ep.getGroupDictionaryBusinessKey(), ep.getGroupDictionaryBusinessName())); + + if (StringUtils.isNotEmpty(ep.getFormula())) { + //BusinessAssayParameterDataReqVO parameterDataSearch = new BusinessAssayParameterDataReqVO(); + //parameterDataSearch.setBusinessAssayProjectDataId(ep.getId()); + //List plist = businessAssayParameterDataMapper.selectProjectAndParameterBy(parameterDataSearch); + List plist = businessAssayParameterDataList.stream().filter(f -> f.getBizId().equals(ep.getId())).collect(Collectors.toList()); + for (BusinessAssayProjectAndParameterRespVO p : plist) { + fieldIndex = "p" + p.getDicId(); + title = p.getShowName() + (StringUtils.isBlank(p.getUnit()) ? "" : "(" + p.getUnit() + ")"); + isEdit = StringUtils.isBlank(p.getFormula()); + cloumns.add(new BatchSampleAnalysisColumnRespVO(fieldIndex, fieldIndex + ".value", title, "", minWidth, p.getDataType(), p.getDecimalPosition(), null, p.getFormula(), p.getParamNo(), isEdit, p.getUnit(), "parameter", p.getFillingWay(), p.getGroupDictionaryBusinessId(), p.getGroupDictionaryBusinessKey(), p.getGroupDictionaryBusinessName())); + } + } + } + + businessAssayTaskAnalysisDataRespVO.setColumns(cloumns); + + + //处理数据 + List> datas = new ArrayList<>(); + for (BusinessAssayTaskDataDO businessAssayTaskDataDO : businessAssayTaskDataList) { + BusinessAssayTaskDetailDO businessAssayTaskDetailDO = businessAssayTaskDetailList.stream().filter(f -> f.getBusinessAssayTaskDataId().equals(businessAssayTaskDataDO.getId())).findFirst().orElse(null); + + BusinessSubSampleDO businessSubSampleDO = businessSubSampleDOList.stream().filter(f -> f.getId().equals(businessAssayTaskDataDO.getBusinessSubSampleId())).findFirst().orElse(null); + ConfigSubSampleMethodExtendRespVO configSubSampleMethodDO = configSubSampleMethodDOList.stream().filter(f -> f.getConfigAssayMethodId().equals(businessAssayTaskDataDO.getConfigAssayMethodId()) && f.getConfigSubSampleId().equals(businessSubSampleDO.getConfigSubSampleId())).findFirst().orElse(null); + String configInfomation = configSubSampleMethodDO.getConfigInfomation(); + if (StringUtils.isNotBlank(configInfomation)) { + ConfigSubSampleMethodConfInfo configSubSampleMethodConfInfo = JSON.parseObject(configInfomation, ConfigSubSampleMethodConfInfo.class); + List getParamList = configSubSampleMethodConfInfo.getGetParam(); + for (ConfigSubSampleMethodConfItem configSubSampleMethodConfItem: getParamList) { + //Boolean required = configSubSampleMethodConfItem.getRequired();//是否必须 + ConfigSubSampleMethodConfPoint source = configSubSampleMethodConfItem.getSource();//来源 + Long configMethodId = source.getMethodId(); + String sourceProject = source.getProject(); + //String sourceParameter = source.getParameter(); + + ConfigSubSampleMethodConfPoint target = configSubSampleMethodConfItem.getTarget();//目标 + + if (StringUtils.isNotBlank(target.getProject())) { //设置到检测项目参数 + + 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 (businessAssayParameterDataDO != null && 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 businessAssayProjectDataExtendList = businessAssayProjectDataMapper.selectByBusinessBaseSampleIdAndConfigAssayMethodId(currBatchFirstBusinessSampleEntrustDetailDO.getBusinessBaseSampleId(), configMethodId); + + BusinessAssayProjectDataExtendRespVO sourceBusinessAssayProjectDataExtendRespVO = businessAssayProjectDataExtendList.stream().filter(f -> sourceProject.equals(f.getSimpleName())).findFirst().orElse(null); + if (sourceBusinessAssayProjectDataExtendRespVO != null && StringUtils.isNotBlank(sourceBusinessAssayProjectDataExtendRespVO.getValue())) { + businessAssayParameterDataDO.setValue(sourceBusinessAssayProjectDataExtendRespVO.getValue()); + } + } 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); + List businessAssayProjectDataExtendList = businessAssayProjectDataMapper.selectByBusinessBaseSampleIdAndConfigAssayMethodId(businessAssayTaskDataDO.getBusinessBaseSampleId(), configMethodId); + + BusinessAssayProjectDataExtendRespVO sourceBusinessAssayProjectDataExtendRespVO = businessAssayProjectDataExtendList.stream().filter(f -> sourceProject.equals(f.getSimpleName())).findFirst().orElse(null); + if (sourceBusinessAssayProjectDataExtendRespVO != null && StringUtils.isNotBlank(sourceBusinessAssayProjectDataExtendRespVO.getValue())) { + businessAssayParameterDataDO.setValue(sourceBusinessAssayProjectDataExtendRespVO.getValue()); + } + } 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); + List businessAssayProjectDataExtendList = businessAssayProjectDataMapper.selectByBusinessBaseSampleIdAndConfigAssayMethodId(businessAssayTaskDataDO.getBusinessBaseSampleId(), configMethodId); + BusinessAssayProjectDataExtendRespVO sourceBusinessAssayProjectDataExtendRespVO = businessAssayProjectDataExtendList.stream().filter(f -> sourceProject.equals(f.getSimpleName())).findFirst().orElse(null); + if (sourceBusinessAssayProjectDataExtendRespVO != null && StringUtils.isNotBlank(sourceBusinessAssayProjectDataExtendRespVO.getValue())) { + businessAssayParameterDataDO.setValue(sourceBusinessAssayProjectDataExtendRespVO.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); + } + } + } else if (StringUtils.isNotBlank(target.getAttribute())) {//设置到分析任务属性 + //TODO 在前已经设置过值,这里暂时不再设置 + } + + } + } + + + Map map = new HashedMap<>(); + map.put("businessAssayTaskDataId", businessAssayTaskDataDO.getId()); + map.put("businessAssayTaskId", businessAssayTaskDataDO.getBusinessAssayTaskId()); + map.put("businessSubSampleId", businessAssayTaskDataDO.getBusinessSubSampleId()); + map.put("businessSubParentSampleId", businessAssayTaskDataDO.getBusinessSubParentSampleId()); + map.put("configAssayMethodId", businessAssayTaskDataDO.getConfigAssayMethodId()); + map.put("businessAssayTaskDetailId", businessAssayTaskDetailDO.getId()); + map.put("sampleCode", businessAssayTaskDetailDO.getSampleCode()); + map.put("sampleName", businessAssayTaskDetailDO.getSampleName()); + map.put("rollbackStatus", businessAssayTaskDetailDO.getRollbackStatus()); + + + //List taskParameterList2 = businessAssayTaskParameterDataMapper.selectByBusinessAssayTaskDataIds(Arrays.asList(businessAssayTaskDataDO.getId())); + List taskParameterList2 = taskParameterList.stream().filter(f -> f.getBizId().equals(businessAssayTaskDataDO.getId())).collect(Collectors.toList()); + for (BusinessAssayProjectAndParameterRespVO taskParameter : taskParameterList2) { + map.put("a_" + taskParameter.getDicKey(), taskParameter); + } + + //BusinessAssayProjectDataReqVO projectDataSearch2 = new BusinessAssayProjectDataReqVO(); + //projectDataSearch2.setBusinessAssayTaskDataId(businessAssayTaskDataDO.getId()); + //List projectAndParameterList2 = businessAssayProjectDataMapper.selectProjectAndParameterBy(projectDataSearch2); + List projectAndParameterList2 = projectAndParameterList.stream().filter(f -> f.getBizId().equals(businessAssayTaskDataDO.getId())).collect(Collectors.toList()); + for (BusinessAssayProjectAndParameterRespVO ep : projectAndParameterList2) { + map.put("e" + ep.getDicId(), ep); + if (StringUtils.isNotEmpty(ep.getFormula())) { + //BusinessAssayParameterDataReqVO parameterDataSearch = new BusinessAssayParameterDataReqVO(); + //parameterDataSearch.setBusinessAssayProjectDataId(ep.getId()); + //List plist = businessAssayParameterDataMapper.selectProjectAndParameterBy(parameterDataSearch); + List plist = businessAssayParameterDataList.stream().filter(f -> f.getBizId().equals(ep.getId())).collect(Collectors.toList()); + for (BusinessAssayProjectAndParameterRespVO p : plist) { + map.put("p" + p.getDicId(), p); + } + } + + } + datas.add(map); + } + + businessAssayTaskAnalysisDataRespVO.setDatas(datas); + + + return businessAssayTaskAnalysisDataRespVO; + } + + private BusinessAssayTaskAnalysisDataRespVO getAnalysisOld(BusinessAssayTaskDO businessAssayTaskDO) { + BusinessAssayTaskAnalysisDataRespVO businessAssayTaskAnalysisDataRespVO = new BusinessAssayTaskAnalysisDataRespVO(); + businessAssayTaskAnalysisDataRespVO.setAnalysisType("analysis"); + businessAssayTaskAnalysisDataRespVO.setAnalysisName("分析样"); + businessAssayTaskAnalysisDataRespVO.setSortNo(99); + + String minWidth = "200px"; + + //处理列 + List cloumns = new ArrayList<>(); + cloumns.add(new BatchSampleAnalysisColumnRespVO("sampleCode", "sampleCode", "样品编号", minWidth, minWidth, "string", null, null, null, null, false, null, null, null, null, null, null)); + cloumns.add(new BatchSampleAnalysisColumnRespVO("sampleName", "sampleName", "样品名称", minWidth, minWidth, "string", null, null, null, null, false, null, null, null, null, null, null)); + + List businessAssayTaskDetailList = businessAssayTaskDetailMapper.selectList(new LambdaQueryWrapperX().eq(BusinessAssayTaskDetailDO::getBusinessAssayTaskId, businessAssayTaskDO.getId())); +// List businessAssayTaskDataList = businessAssayTaskDataMapper.selectList(new LambdaQueryWrapperX().eq(BusinessAssayTaskDataDO::getBusinessAssayTaskId, businessAssayTaskDO.getId()).eq(BusinessAssayTaskDataDO::getConfigAssayMethodId, businessAssayTaskDO.getConfigAssayMethodId())); + List businessAssayTaskDataList = businessAssayTaskDataMapper.selectByBusinessAssayTaskId(businessAssayTaskDO.getId()); + + //子样Id列表 + List businessSubSampleIdList = businessAssayTaskDataList.stream().map(m -> m.getBusinessSubSampleId()).distinct().collect(Collectors.toList()); + + //子样列表 + List businessSubSampleDOList = businessSubSampleMapper.selectByIds(businessSubSampleIdList); + //子样配置id列表 + List configSubSampleIdList = businessSubSampleDOList.stream().map(m -> m.getConfigSubSampleId()).distinct().collect(Collectors.toList()); + + //子样方法配置列表 +// List configSubSampleMethodDOList = configSubSampleMethodMapper.selectByConfigSubSampleIdsAndConfigAssayMethodId(configSubSampleIdList, businessAssayTaskDO.getConfigAssayMethodId()); + List configAssayMethodIdList = businessAssayTaskDataList.stream().map(m -> m.getConfigAssayMethodId()).distinct().collect(Collectors.toList()); + List configSubSampleMethodDOList = configSubSampleMethodMapper.selectByConfigSubSampleIdsAndConfigAssayMethodIds(configSubSampleIdList, configAssayMethodIdList); + + List businessAssayTaskDataIdList = businessAssayTaskDataList.stream().map(m -> m.getId()).collect(Collectors.toList()); //任务参数查询 @@ -867,6 +1114,163 @@ public class SampleAnalysisServiceImpl implements SampleAnalysisService { BusinessQCManagementDataDO businessQCManagementDataDO = businessQCManagementDataDOList.get(0); + //任务参数查询 + List taskParameterList = businessQCManagementSampleParameterDataMapper.selectByBusinessQCManagementDataIds(Arrays.asList(businessQCManagementDataDO.getId())); + Map> taskParameterMap = taskParameterList.stream().sorted(Comparator.comparing(BusinessAssayProjectAndParameterRespVO::getParamNo)).collect(Collectors.groupingBy(BusinessAssayProjectAndParameterRespVO::getDicKey, + LinkedHashMap::new, // 保持组首次出现的顺序(可选) + Collectors.toList() // ArrayList 保持组内顺序 + )); + for (Map.Entry> entry : taskParameterMap.entrySet()) { + BusinessAssayProjectAndParameterRespVO taskParameter = entry.getValue().get(0); + String fieldIndex = "a_" + taskParameter.getDicKey(); + String title = taskParameter.getShowName() + (StringUtils.isBlank(taskParameter.getUnit()) ? "" : "(" + taskParameter.getUnit() + ")"); + boolean isEdit = StringUtils.isBlank(taskParameter.getFormula()); + cloumns.add(new BatchSampleAnalysisColumnRespVO(fieldIndex, fieldIndex + ".value", title, "", minWidth, taskParameter.getDataType(), taskParameter.getDecimalPosition(), null, taskParameter.getFormula(), taskParameter.getParamNo(), isEdit, taskParameter.getUnit(), "attribute", taskParameter.getFillingWay(), taskParameter.getGroupDictionaryBusinessId(), taskParameter.getGroupDictionaryBusinessKey(), taskParameter.getGroupDictionaryBusinessName())); + } + + + BusinessQCManagementProjectDataReqVO projectDataSearch = new BusinessQCManagementProjectDataReqVO(); + projectDataSearch.setBusinessQCManagementDataId(businessQCManagementDataDO.getId()); + List projectAndParameterList = businessQCManagementProjectDataMapper.selectProjectAndParameterBy(projectDataSearch); + for (BusinessAssayProjectAndParameterRespVO ep : projectAndParameterList) { + String fieldIndex = "e" + ep.getDicId(); + String title = ep.getShowName() + (StringUtils.isBlank(ep.getUnit()) ? "" : "(" + ep.getUnit() + ")"); + boolean isEdit = StringUtils.isBlank(ep.getFormula()); + if ("zkkby".equals(configQCSampleMethodExtendRespVO.getDictionaryBusinessKey()) && StringUtils.isNotBlank(ep.getFormula()) && ep.getFormula().startsWith("From")) { + isEdit = true; + ep.setFormula(null); + } + if (isEdit) { + minWidth = "280px"; + } + cloumns.add(new BatchSampleAnalysisColumnRespVO(fieldIndex, fieldIndex + ".value", title, "", minWidth, ep.getDataType(), ep.getDecimalPosition(), null, ep.getFormula(), ep.getParamNo(), isEdit, ep.getUnit(), "project", ep.getFillingWay(), ep.getGroupDictionaryBusinessId(), ep.getGroupDictionaryBusinessKey(), ep.getGroupDictionaryBusinessName())); + + if (StringUtils.isNotEmpty(ep.getFormula())) { + BusinessQCManagementParameterDataReqVO parameterDataSearch = new BusinessQCManagementParameterDataReqVO(); + parameterDataSearch.setBusinessQCManagementProjectDataId(ep.getId()); + List plist = businessQCManagementParameterDataMapper.selectProjectAndParameterBy(parameterDataSearch); + for (BusinessAssayProjectAndParameterRespVO p : plist) { + fieldIndex = "p" + p.getDicId(); + title = p.getShowName() + (StringUtils.isBlank(p.getUnit()) ? "" : "(" + p.getUnit() + ")"); + isEdit = StringUtils.isBlank(p.getFormula()); + if ("zkkby".equals(configQCSampleMethodExtendRespVO.getDictionaryBusinessKey()) && StringUtils.isNotBlank(p.getFormula()) && p.getFormula().startsWith("From")) { + isEdit = true; + p.setFormula(null); + } + cloumns.add(new BatchSampleAnalysisColumnRespVO(fieldIndex, fieldIndex + ".value", title, "", minWidth, p.getDataType(), p.getDecimalPosition(), null, p.getFormula(), p.getParamNo(), isEdit, p.getUnit(), "parameter", p.getFillingWay(), p.getGroupDictionaryBusinessId(), p.getGroupDictionaryBusinessKey(), p.getGroupDictionaryBusinessName())); + } + } + } + + for (BusinessQCManagementDataDO businessQCManagementData : businessQCManagementDataDOList) { + Map map = new HashedMap<>(); + map.put("businessAssayTaskDataId", businessQCManagementData.getId()); + map.put("businessAssayTaskId", businessQCManagementData.getBusinessAssayTaskId()); + map.put("businessSubSampleId", ""); + map.put("businessSubParentSampleId", ""); + map.put("configAssayMethodId", businessQCManagementData.getConfigAssayMethodId()); + map.put("businessAssayTaskDetailId", ""); + map.put("sampleCode", businessQCManagementData.getSampleCode()); + map.put("sampleName", businessQCManagementData.getSampleName()); + + List taskParameterList2 = businessQCManagementSampleParameterDataMapper.selectByBusinessQCManagementDataIds(Arrays.asList(businessQCManagementData.getId())); + for (BusinessAssayProjectAndParameterRespVO taskParameter : taskParameterList2) { + map.put("a_" + taskParameter.getDicKey(), taskParameter); + } + + + BusinessQCManagementProjectDataReqVO projectDataSearch2 = new BusinessQCManagementProjectDataReqVO(); + projectDataSearch2.setBusinessQCManagementDataId(businessQCManagementData.getId()); + List projectAndParameterList2 = businessQCManagementProjectDataMapper.selectProjectAndParameterBy(projectDataSearch2); + for (BusinessAssayProjectAndParameterRespVO ep : projectAndParameterList2) { + map.put("e" + ep.getDicId(), ep); + if (StringUtils.isNotEmpty(ep.getFormula())) { + BusinessQCManagementParameterDataReqVO parameterDataSearch = new BusinessQCManagementParameterDataReqVO(); + parameterDataSearch.setBusinessQCManagementProjectDataId(ep.getId()); + List plist = businessQCManagementParameterDataMapper.selectProjectAndParameterBy(parameterDataSearch); + for (BusinessAssayProjectAndParameterRespVO p : plist) { + map.put("p" + p.getDicId(), p); + } + } + + } + datas.add(map); + } + + } + businessAssayTaskAnalysisDataRespVO.setColumns(cloumns); + businessAssayTaskAnalysisDataRespVO.setDatas(datas); + list.add(businessAssayTaskAnalysisDataRespVO); + } + return list; + } + + private List getQcAnalysisOld(BusinessAssayTaskDO businessAssayTaskDO) { + List list = new ArrayList<>(); + + String minWidth = "200px"; + List configQCSampleMethodList = configQCSampleMethodMapper.selectByConfigAssayMethodId(businessAssayTaskDO.getConfigAssayMethodId()); + BusinessAssayTaskAnalysisDataRespVO businessAssayTaskAnalysisDataRespVO = null; + for (ConfigQCSampleMethodExtendRespVO configQCSampleMethodExtendRespVO : configQCSampleMethodList) { + businessAssayTaskAnalysisDataRespVO = new BusinessAssayTaskAnalysisDataRespVO(); + businessAssayTaskAnalysisDataRespVO.setAnalysisType(configQCSampleMethodExtendRespVO.getDictionaryBusinessKey()); + businessAssayTaskAnalysisDataRespVO.setAnalysisName(configQCSampleMethodExtendRespVO.getDictionaryBusinessName()); + businessAssayTaskAnalysisDataRespVO.setSortNo(configQCSampleMethodExtendRespVO.getSortNo()); + businessAssayTaskAnalysisDataRespVO.setConfigQCSampleMethod(configQCSampleMethodExtendRespVO); + + //处理列 + List cloumns = new ArrayList<>(); + cloumns.add(new BatchSampleAnalysisColumnRespVO("sampleCode", "sampleCode", "样品编号", minWidth, minWidth, "string", null, null, null, null, false, null, null, null, null, null, null)); + cloumns.add(new BatchSampleAnalysisColumnRespVO("sampleName", "sampleName", "样品名称", minWidth, minWidth, "string", null, null, null, null, false, null, null, null, null, null, null)); + + //处理数据 + List> datas = new ArrayList<>(); + if ("withoutProject".equals(configQCSampleMethodExtendRespVO.getParentDictionaryBusinesskey())) {//不带检测项目 + List businessQCCoefficientDataDOList = businessQCCoefficientDataMapper.selectByBusinessAssayTaskIdAndDictionaryBusinessKey(businessAssayTaskDO.getId(), configQCSampleMethodExtendRespVO.getDictionaryBusinessKey()); + if (CollUtil.isEmpty(businessQCCoefficientDataDOList)) { + break; + } + BusinessQCCoefficientDataDO businessQCCoefficientDataDO = businessQCCoefficientDataDOList.get(0); + + BusinessQCCoefficientParameterDataReqVO parameterDataSearch = new BusinessQCCoefficientParameterDataReqVO(); + parameterDataSearch.setBusinessQCCoefficientDataId(businessQCCoefficientDataDO.getId()); + List plist = businessQCCoefficientParameterDataMapper.selectProjectAndParameterBy(parameterDataSearch); + for (BusinessAssayProjectAndParameterRespVO p : plist) { + String fieldIndex = "p" + p.getDicId(); + String title = p.getShowName() + (StringUtils.isBlank(p.getUnit()) ? "" : "(" + p.getUnit() + ")"); + boolean isEdit = StringUtils.isBlank(p.getFormula()); + cloumns.add(new BatchSampleAnalysisColumnRespVO(fieldIndex, fieldIndex + ".value", title, "", minWidth, p.getDataType(), p.getDecimalPosition(), null, p.getFormula(), p.getParamNo(), isEdit, p.getUnit(), "parameter", p.getFillingWay(), p.getGroupDictionaryBusinessId(), p.getGroupDictionaryBusinessKey(), p.getGroupDictionaryBusinessName())); + } + + + for (BusinessQCCoefficientDataDO businessQCCoefficientData: businessQCCoefficientDataDOList) { + Map map = new HashedMap<>(); + map.put("businessAssayTaskDataId", businessQCCoefficientData.getId()); + map.put("businessAssayTaskId", businessQCCoefficientData.getBusinessAssayTaskId()); + map.put("businessSubSampleId", ""); + map.put("businessSubParentSampleId", ""); + map.put("configAssayMethodId", businessQCCoefficientData.getConfigAssayMethodId()); + map.put("businessAssayTaskDetailId", ""); + map.put("sampleCode", businessQCCoefficientData.getSampleCode()); + map.put("sampleName", businessQCCoefficientData.getSampleName()); + + BusinessQCCoefficientParameterDataReqVO parameterDataSearch2 = new BusinessQCCoefficientParameterDataReqVO(); + parameterDataSearch2.setBusinessQCCoefficientDataId(businessQCCoefficientData.getId()); + List plist2 = businessQCCoefficientParameterDataMapper.selectProjectAndParameterBy(parameterDataSearch2); + for (BusinessAssayProjectAndParameterRespVO p : plist2) { + map.put("p" + p.getDicId(), p); + } + datas.add(map); + } + } else {//带检测项目 + List businessQCManagementDataDOList = businessQCManagementDataMapper.selectByBusinessAssayTaskIdAndDictionaryBusinessKey(businessAssayTaskDO.getId(), configQCSampleMethodExtendRespVO.getDictionaryBusinessKey()); + + if (CollUtil.isEmpty(businessQCManagementDataDOList)) { + break; + } + BusinessQCManagementDataDO businessQCManagementDataDO = businessQCManagementDataDOList.get(0); + + //任务参数查询 List taskParameterList = businessQCManagementSampleParameterDataMapper.selectByBusinessQCManagementDataIds(Arrays.asList(businessQCManagementDataDO.getId())); Map> taskParameterMap = taskParameterList.stream().sorted(Comparator.comparing(BusinessAssayProjectAndParameterRespVO::getParamNo)).collect(Collectors.groupingBy(BusinessAssayProjectAndParameterRespVO::getDicId, @@ -1276,6 +1680,325 @@ public class SampleAnalysisServiceImpl implements SampleAnalysisService { } businessAssayTaskMapper.updateById(businessAssayTaskDO); } + +// @Override + @Transactional(rollbackFor = Exception.class) + public void saveBatchSmpleAndQcAnalysisOld(BusinessAssayTaskAnalysisSampleAndQcProjectRespVO vo) { + BusinessAssayTaskDO businessAssayTaskDO = businessAssayTaskMapper.selectById(vo.getBusinessAssayTaskId()); + businessAssayTaskDO.setFormValue(vo.getFormValue()); + businessAssayTaskDO.setAssayTime(vo.getAssayTime()); + businessAssayTaskDO.setTaskAssayStatus(QmsCommonConstant.SAVED); + //赋值数据集id + if (vo.getDataCollectionId() == null) { + ConfigAssayMethodDO configAssayMethodDO = configAssayMethodMapper.selectById(businessAssayTaskDO.getConfigAssayMethodId()); + DataCollectionDO dataCollectionDO = dataCollectionService.getLatestDataCollectionByKey(configAssayMethodDO.getDataCollectionKey()); + businessAssayTaskDO.setFormDataCollectionId(dataCollectionDO.getId()); + } else { + businessAssayTaskDO.setFormDataCollectionId(vo.getDataCollectionId()); + } + + List assayTaskAnalysisDataList = vo.getAssayTaskAnalysisDataList(); + + List dictionaryBusinessItemList = dictionaryBusinessMapper.selectItemByCategoryKeys(Arrays.asList("withProject", "withoutProject")); + + if (CollUtil.isNotEmpty(assayTaskAnalysisDataList)) { + for (BusinessAssayTaskAnalysisDataRespVO businessAssayTaskAnalysisDataRespVO : assayTaskAnalysisDataList) { + DictionaryBusinessExtendRespVO dictionaryBusinessItem = dictionaryBusinessItemList.stream().filter(f -> f.getKey().equals(businessAssayTaskAnalysisDataRespVO.getAnalysisType())).findFirst().orElse(null); + if ("analysis".equals(businessAssayTaskAnalysisDataRespVO.getAnalysisType())) {//分析样 +// List businessAssayTaskDataList = businessAssayTaskDataMapper.selectList(new LambdaQueryWrapperX().eq(BusinessAssayTaskDataDO::getBusinessAssayTaskId, vo.getBusinessAssayTaskId()).eq(BusinessAssayTaskDataDO::getConfigAssayMethodId, businessAssayTaskDO.getConfigAssayMethodId())); + List businessAssayTaskDataList = businessAssayTaskDataMapper.selectByBusinessAssayTaskId(vo.getBusinessAssayTaskId()); + + List businessAssayTaskDataIdList = businessAssayTaskDataList.stream().map(m -> m.getId()).collect(Collectors.toList()); + + List businessAssayTaskParameterDataList = businessAssayTaskParameterDataMapper.selectList(new LambdaQueryWrapperX().in(BusinessAssayTaskParameterDataDO::getBusinessAssayTaskDataId, businessAssayTaskDataIdList)); + + List businessAssayProjectDataList = businessAssayProjectDataMapper.selectList(new LambdaQueryWrapperX().in(BusinessAssayProjectDataDO::getBusinessAssayTaskDataId, businessAssayTaskDataIdList)); + List businessAssayProjectDataIdList = businessAssayProjectDataList.stream().map(m -> m.getId()).collect(Collectors.toList()); + + List businessAssayParameterDataList = businessAssayParameterDataMapper.selectList(new LambdaQueryWrapperX().in(BusinessAssayParameterDataDO::getBusinessAssayProjectDataId, businessAssayProjectDataIdList)); + + + List> datas = businessAssayTaskAnalysisDataRespVO.getDatas(); + for (Map map : datas) { + + List listBusinessAssayProjectAndParameter = new ArrayList<>(); + for (Map.Entry entry : map.entrySet()) { + Object val = entry.getValue(); + if (val instanceof String || val == null) { + continue; + } + BusinessAssayProjectAndParameterRespVO businessAssayProjectAndParameter = JSON.parseObject(JSON.toJSONString(val), BusinessAssayProjectAndParameterRespVO.class); + listBusinessAssayProjectAndParameter.add(businessAssayProjectAndParameter); + } + + for (BusinessAssayProjectAndParameterRespVO pap : listBusinessAssayProjectAndParameter) { + if ("project".equals(pap.getType())) { + BusinessAssayProjectDataDO businessAssayProjectDataDO = businessAssayProjectDataList.stream().filter(f -> f.getId().equals(pap.getId())).findFirst().orElse(null); + if (StringUtils.isNotBlank(pap.getValue())) { + businessAssayProjectDataDO.setSymbol(pap.getSymbol()); + String dataType = pap.getDataType();//string-字符串,int-整数,decimal-小数,date-日期,datetime-时间 + switch (dataType) { + case "int": + case "date": + case "datetime": + case "string": + businessAssayProjectDataDO.setValue(pap.getValue()); + businessAssayProjectDataDO.setRemark(pap.getShowName() + ": " + pap.getValue()); + break; + case "decimal": + BigDecimal value = new BigDecimal(pap.getValue()); + value = value.setScale(pap.getDecimalPosition(), RoundingMode.HALF_EVEN); + businessAssayProjectDataDO.setValue(value.toPlainString()); + businessAssayProjectDataDO.setRemark(pap.getShowName() + ": " + value.toPlainString()); + break; + default: + throw new IllegalArgumentException("Unexpected value: " + dataType); + } + } else { + businessAssayProjectDataDO.setValue(null); + } + } else if ("parameter".equals(pap.getType())) { + BusinessAssayParameterDataDO businessAssayParameterDataDO = businessAssayParameterDataList.stream().filter(f -> f.getId().equals(pap.getId())).findFirst().orElse(null); + if (StringUtils.isNotBlank(pap.getValue())) { + businessAssayParameterDataDO.setSymbol(pap.getSymbol()); + String dataType = pap.getDataType();//string-字符串,int-整数,decimal-小数,date-日期,datetime-时间 + switch (dataType) { + case "int": + case "date": + case "datetime": + case "string": + businessAssayParameterDataDO.setValue(pap.getValue()); + businessAssayParameterDataDO.setRemark(pap.getShowName() + ": " + pap.getValue()); + break; + case "decimal": + BigDecimal value = new BigDecimal(pap.getValue()); + value = value.setScale(pap.getDecimalPosition(), RoundingMode.HALF_EVEN); + businessAssayParameterDataDO.setValue(value.toPlainString()); + businessAssayParameterDataDO.setRemark(pap.getShowName() + ": " + value.toPlainString()); + break; + default: + throw new IllegalArgumentException("Unexpected value: " + dataType); + } + } else { + businessAssayParameterDataDO.setValue(null); + } + } else if ("attribute".equals(pap.getType())) { + BusinessAssayTaskParameterDataDO businessAssayTaskParameterDataDO = businessAssayTaskParameterDataList.stream().filter(f -> f.getId().equals(pap.getId())).findFirst().orElse(null); + if (StringUtils.isNotBlank(pap.getValue())) { + String dataType = pap.getDataType();//string-字符串,int-整数,decimal-小数,date-日期,datetime-时间 + switch (dataType) { + case "int": + case "date": + case "datetime": + case "string": + businessAssayTaskParameterDataDO.setValue(pap.getValue()); + businessAssayTaskParameterDataDO.setRemark(pap.getShowName() + ": " + pap.getValue()); + break; + case "decimal": + BigDecimal value = new BigDecimal(pap.getValue()); + value = value.setScale(pap.getDecimalPosition(), RoundingMode.HALF_EVEN); + businessAssayTaskParameterDataDO.setValue(value.toPlainString()); + businessAssayTaskParameterDataDO.setRemark(pap.getShowName() + ": " + value.toPlainString()); + break; + default: + throw new IllegalArgumentException("Unexpected value: " + dataType); + } + } else { + businessAssayTaskParameterDataDO.setValue(null); + } + } + } + + } + + if (CollUtil.isNotEmpty(businessAssayTaskParameterDataList)) { + businessAssayTaskParameterDataMapper.updateBatch(businessAssayTaskParameterDataList); + } + + if (CollUtil.isNotEmpty(businessAssayProjectDataList)) { + businessAssayProjectDataMapper.updateBatch(businessAssayProjectDataList); + } + if (CollUtil.isNotEmpty(businessAssayParameterDataList)) { + businessAssayParameterDataMapper.updateBatch(businessAssayParameterDataList); + } + + } else if (dictionaryBusinessItem != null && "withProject".equals(dictionaryBusinessItem.getParentDictionaryBusinesskey())) {//带检测项目 + List BusinessQCManagementDataList = businessQCManagementDataMapper.selectByBusinessAssayTaskId(businessAssayTaskDO.getId()); + + List businessQCManagementDataIdList = BusinessQCManagementDataList.stream().map(m -> m.getId()).collect(Collectors.toList()); + + List businessQCManagementSampleParameterDataDOList = businessQCManagementSampleParameterDataMapper.selectList(new LambdaQueryWrapperX().in(BusinessQCManagementSampleParameterDataDO::getBusinessQCManagementDataId, businessQCManagementDataIdList)); + + List businessQCManagementProjectDataList = businessQCManagementProjectDataMapper.selectByBusinessQCManagementDataIds(businessQCManagementDataIdList); + List businessQCManagementProjectDataIdList = businessQCManagementProjectDataList.stream().map(m -> m.getId()).collect(Collectors.toList()); + + List businessQCManagementParameterDataList = businessQCManagementParameterDataMapper.selectByBusinessQCManagementProjectDataIds(businessQCManagementProjectDataIdList); + + List> datas = businessAssayTaskAnalysisDataRespVO.getDatas(); + for (Map map : datas) { + + List listBusinessAssayProjectAndParameter = new ArrayList<>(); + for (Map.Entry entry : map.entrySet()) { + Object val = entry.getValue(); + if (val instanceof String || val == null) { + continue; + } + BusinessAssayProjectAndParameterRespVO businessAssayProjectAndParameter = JSON.parseObject(JSON.toJSONString(val), BusinessAssayProjectAndParameterRespVO.class); + listBusinessAssayProjectAndParameter.add(businessAssayProjectAndParameter); + } + + for (BusinessAssayProjectAndParameterRespVO pap : listBusinessAssayProjectAndParameter) { + if ("project".equals(pap.getType())) { + BusinessQCManagementProjectDataDO businessQCManagementProjectDataDO = businessQCManagementProjectDataList.stream().filter(f -> f.getId().equals(pap.getId())).findFirst().orElse(null); + if (StringUtils.isNotBlank(pap.getValue())) { + businessQCManagementProjectDataDO.setSymbol(pap.getSymbol()); + String dataType = pap.getDataType();//string-字符串,int-整数,decimal-小数,date-日期,datetime-时间 + switch (dataType) { + case "int": + case "date": + case "datetime": + case "string": + businessQCManagementProjectDataDO.setValue(pap.getValue()); + businessQCManagementProjectDataDO.setRemark(pap.getShowName() + ": " + pap.getValue()); + break; + case "decimal": + BigDecimal value = new BigDecimal(pap.getValue()); + value = value.setScale(pap.getDecimalPosition(), RoundingMode.HALF_EVEN); + businessQCManagementProjectDataDO.setValue(value.toPlainString()); + businessQCManagementProjectDataDO.setRemark(pap.getShowName() + ": " + value.toPlainString()); + break; + default: + throw new IllegalArgumentException("Unexpected value: " + dataType); + } + } else { + businessQCManagementProjectDataDO.setValue(null); + } + } else if ("parameter".equals(pap.getType())) { + BusinessQCManagementParameterDataDO businessQCManagementParameterDataDO = businessQCManagementParameterDataList.stream().filter(f -> f.getId().equals(pap.getId())).findFirst().orElse(null); + if (StringUtils.isNotBlank(pap.getValue())) { + businessQCManagementParameterDataDO.setSymbol(pap.getSymbol()); + String dataType = pap.getDataType();//string-字符串,int-整数,decimal-小数,date-日期,datetime-时间 + switch (dataType) { + case "int": + case "date": + case "datetime": + case "string": + businessQCManagementParameterDataDO.setValue(pap.getValue()); + businessQCManagementParameterDataDO.setRemark(pap.getShowName() + ": " + pap.getValue()); + break; + case "decimal": + BigDecimal value = new BigDecimal(pap.getValue()); + value = value.setScale(pap.getDecimalPosition(), RoundingMode.HALF_EVEN); + businessQCManagementParameterDataDO.setValue(value.toPlainString()); + businessQCManagementParameterDataDO.setRemark(pap.getShowName() + ": " + value.toPlainString()); + break; + default: + throw new IllegalArgumentException("Unexpected value: " + dataType); + } + } else { + businessQCManagementParameterDataDO.setValue(null); + } + } else if ("attribute".equals(pap.getType())) { + BusinessQCManagementSampleParameterDataDO businessQCManagementSampleParameterDataDO = businessQCManagementSampleParameterDataDOList.stream().filter(f -> f.getId().equals(pap.getId())).findFirst().orElse(null); + if (StringUtils.isNotBlank(pap.getValue())) { + String dataType = pap.getDataType();//string-字符串,int-整数,decimal-小数,date-日期,datetime-时间 + switch (dataType) { + case "int": + case "date": + case "datetime": + case "string": + businessQCManagementSampleParameterDataDO.setValue(pap.getValue()); + businessQCManagementSampleParameterDataDO.setRemark(pap.getShowName() + ": " + pap.getValue()); + break; + case "decimal": + BigDecimal value = new BigDecimal(pap.getValue()); + value = value.setScale(pap.getDecimalPosition(), RoundingMode.HALF_EVEN); + businessQCManagementSampleParameterDataDO.setValue(value.toPlainString()); + businessQCManagementSampleParameterDataDO.setRemark(pap.getShowName() + ": " + value.toPlainString()); + break; + default: + throw new IllegalArgumentException("Unexpected value: " + dataType); + } + } else { + businessQCManagementSampleParameterDataDO.setValue(null); + } + } + } + + } + + if (CollUtil.isNotEmpty(businessQCManagementSampleParameterDataDOList)) { + businessQCManagementSampleParameterDataMapper.updateBatch(businessQCManagementSampleParameterDataDOList); + } + + if (CollUtil.isNotEmpty(businessQCManagementProjectDataList)) { + businessQCManagementProjectDataMapper.updateBatch(businessQCManagementProjectDataList); + } + + if (CollUtil.isNotEmpty(businessQCManagementParameterDataList)) { + businessQCManagementParameterDataMapper.updateBatch(businessQCManagementParameterDataList); + } + } else { //不带检测项目的 + List businessQCCoefficientDataList = businessQCCoefficientDataMapper.selectByBusinessAssayTaskId(businessAssayTaskDO.getId()); + + List businessQCCoefficientDataIdList = businessQCCoefficientDataList.stream().map(m -> m.getId()).collect(Collectors.toList()); + + List businessQCCoefficientParameterDataList = businessQCCoefficientParameterDataMapper.selectByBusinessQCCoefficientDataIds(businessQCCoefficientDataIdList); + + List> datas = businessAssayTaskAnalysisDataRespVO.getDatas(); + for (Map map : datas) { + + List listBusinessAssayProjectAndParameter = new ArrayList<>(); + for (Map.Entry entry : map.entrySet()) { + Object val = entry.getValue(); + if (val instanceof String || val == null) { + continue; + } + BusinessAssayProjectAndParameterRespVO businessAssayProjectAndParameter = JSON.parseObject(JSON.toJSONString(val), BusinessAssayProjectAndParameterRespVO.class); + listBusinessAssayProjectAndParameter.add(businessAssayProjectAndParameter); + } + + for (BusinessAssayProjectAndParameterRespVO pap : listBusinessAssayProjectAndParameter) { + if ("parameter".equals(pap.getType())) { + BusinessQCCoefficientParameterDataDO businessQCCoefficientParameterDataDO = businessQCCoefficientParameterDataList.stream().filter(f -> f.getId().equals(pap.getId())).findFirst().orElse(null); + if (StringUtils.isNotBlank(pap.getValue())) { + businessQCCoefficientParameterDataDO.setSymbol(pap.getSymbol()); + String dataType = pap.getDataType();//string-字符串,int-整数,decimal-小数,date-日期,datetime-时间 + switch (dataType) { + case "int": + case "date": + case "datetime": + case "string": + businessQCCoefficientParameterDataDO.setValue(pap.getValue()); + businessQCCoefficientParameterDataDO.setRemark(pap.getShowName() + ": " + pap.getValue()); + break; + case "decimal": + BigDecimal value = new BigDecimal(pap.getValue()); + value = value.setScale(pap.getDecimalPosition(), RoundingMode.HALF_EVEN); + businessQCCoefficientParameterDataDO.setValue(value.toPlainString()); + businessQCCoefficientParameterDataDO.setRemark(pap.getShowName() + ": " + value.toPlainString()); + break; + default: + throw new IllegalArgumentException("Unexpected value: " + dataType); + } + } else { + businessQCCoefficientParameterDataDO.setValue(null); + } + } + } + + } + + if (CollUtil.isNotEmpty(businessQCCoefficientParameterDataList)) { + businessQCCoefficientParameterDataMapper.updateBatch(businessQCCoefficientParameterDataList); + } + + } + } + + } + businessAssayTaskMapper.updateById(businessAssayTaskDO); + } @Override @@ -1287,9 +2010,12 @@ public class SampleAnalysisServiceImpl implements SampleAnalysisService { businessAssayTaskDO.setFinishStatus(QmsCommonConstant.IN_PROGRESS); businessAssayTaskDO.setFlowStatus(QmsCommonConstant.IN_PROGRESS); + //设置分析任务属性 + List updateBusinessAssayTaskParameterDataDOList = new ArrayList<>(); //设置参数值 List updateBusinessAssayParameterDataList = new ArrayList<>(); + List businessAssayTaskDataExtendList = businessAssayTaskDataMapper.selectExtendByBusinessAssayTaskId(businessAssayTaskId); //查询检测项目 @@ -1348,20 +2074,29 @@ public class SampleAnalysisServiceImpl implements SampleAnalysisService { } 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()) && targetProject.equals(f.getSimpleName())).findFirst().orElse(null); - if (targetBusinessAssayProjectData == null) { - continue; + if (StringUtils.isNotBlank(target.getProject())) {//检测项目参数赋值 + 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()) && targetProject.equals(f.getSimpleName())).findFirst().orElse(null); + if (targetBusinessAssayProjectData == null) { + continue; + } + BusinessAssayParameterDataDO businessAssayParameterDataDO = businessAssayParameterDataMapper.selectByBusinessAssayProjectDataIdAndProjectSimpleNameAndParameterKey(targetBusinessAssayProjectData.getId(), targetProject, targetParameter); + if (businessAssayParameterDataDO != null) { + businessAssayParameterDataDO.setValue(currentBusinessAssayProjectData.getValue()); + updateBusinessAssayParameterDataList.add(businessAssayParameterDataDO); + } + + } + } else if (StringUtils.isNotBlank(target.getAttribute())) {//分析任务属性赋值 + BusinessAssayTaskParameterDataDO businessAssayTaskParameterDataDO = businessAssayTaskParameterDataMapper.selectByBusinessAssayTaskDataIdAndKey(targetBusinessAssayTaskData.getId(), target.getAttribute()); + if (businessAssayTaskParameterDataDO != null) { + businessAssayTaskParameterDataDO.setValue(currentBusinessAssayProjectData.getValue()); + updateBusinessAssayTaskParameterDataDOList.add(businessAssayTaskParameterDataDO); } - BusinessAssayParameterDataDO businessAssayParameterDataDO = businessAssayParameterDataMapper.selectByBusinessAssayProjectDataIdAndProjectSimpleNameAndParameterKey(targetBusinessAssayProjectData.getId(), targetProject, targetParameter); - if (businessAssayParameterDataDO != null) { - businessAssayParameterDataDO.setValue(currentBusinessAssayProjectData.getValue()); - updateBusinessAssayParameterDataList.add(businessAssayParameterDataDO); - } - - } + + } } } } else if (QmsCommonConstant.ENTRUST_COMPREHENSIVE_INSPECTION_SAMPLE.equals(baseSampleDO.getDictionaryBusinessKey())) {//如果是商检综合样 @@ -1382,20 +2117,29 @@ public class SampleAnalysisServiceImpl implements SampleAnalysisService { } 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()) && targetProject.equals(f.getSimpleName())).findFirst().orElse(null); - if (targetBusinessAssayProjectData == null) { - continue; + if (StringUtils.isNotBlank(target.getProject())) {//检测项目参数赋值 + 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()) && targetProject.equals(f.getSimpleName())).findFirst().orElse(null); + if (targetBusinessAssayProjectData == null) { + continue; + } + BusinessAssayParameterDataDO businessAssayParameterDataDO = businessAssayParameterDataMapper.selectByBusinessAssayProjectDataIdAndProjectSimpleNameAndParameterKey(targetBusinessAssayProjectData.getId(), targetProject, targetParameter); + if (businessAssayParameterDataDO != null) { + businessAssayParameterDataDO.setValue(currentBusinessAssayProjectData.getValue()); + updateBusinessAssayParameterDataList.add(businessAssayParameterDataDO); + } + + } + } else if (StringUtils.isNotBlank(target.getAttribute())) {//分析任务属性赋值 + BusinessAssayTaskParameterDataDO businessAssayTaskParameterDataDO = businessAssayTaskParameterDataMapper.selectByBusinessAssayTaskDataIdAndKey(targetBusinessAssayTaskData.getId(), target.getAttribute()); + if (businessAssayTaskParameterDataDO != null) { + businessAssayTaskParameterDataDO.setValue(currentBusinessAssayProjectData.getValue()); + updateBusinessAssayTaskParameterDataDOList.add(businessAssayTaskParameterDataDO); } - BusinessAssayParameterDataDO businessAssayParameterDataDO = businessAssayParameterDataMapper.selectByBusinessAssayProjectDataIdAndProjectSimpleNameAndParameterKey(targetBusinessAssayProjectData.getId(), targetProject, targetParameter); - if (businessAssayParameterDataDO != null) { - businessAssayParameterDataDO.setValue(currentBusinessAssayProjectData.getValue()); - updateBusinessAssayParameterDataList.add(businessAssayParameterDataDO); - } - - } + + } } } } else if (QmsCommonConstant.ENTRUST_COMMISSION_INSPECTION_SAMPLE.equals(baseSampleDO.getDictionaryBusinessKey())) {//如果是委检样 @@ -1416,20 +2160,29 @@ public class SampleAnalysisServiceImpl implements SampleAnalysisService { } 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()) && targetProject.equals(f.getSimpleName())).findFirst().orElse(null); - if (targetBusinessAssayProjectData == null) { - continue; + if (StringUtils.isNotBlank(target.getProject())) {//检测项目参数赋值 + 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()) && targetProject.equals(f.getSimpleName())).findFirst().orElse(null); + if (targetBusinessAssayProjectData == null) { + continue; + } + BusinessAssayParameterDataDO businessAssayParameterDataDO = businessAssayParameterDataMapper.selectByBusinessAssayProjectDataIdAndProjectSimpleNameAndParameterKey(targetBusinessAssayProjectData.getId(), targetProject, targetParameter); + if (businessAssayParameterDataDO != null && StringUtils.isBlank(businessAssayParameterDataDO.getValue())) {//值为空,才赋值 + businessAssayParameterDataDO.setValue(currentBusinessAssayProjectData.getValue()); + updateBusinessAssayParameterDataList.add(businessAssayParameterDataDO); + } + + } + } else if (StringUtils.isNotBlank(target.getAttribute())) {//分析任务属性赋值 + BusinessAssayTaskParameterDataDO businessAssayTaskParameterDataDO = businessAssayTaskParameterDataMapper.selectByBusinessAssayTaskDataIdAndKey(targetBusinessAssayTaskData.getId(), target.getAttribute()); + if (businessAssayTaskParameterDataDO != null) { + businessAssayTaskParameterDataDO.setValue(currentBusinessAssayProjectData.getValue()); + updateBusinessAssayTaskParameterDataDOList.add(businessAssayTaskParameterDataDO); } - BusinessAssayParameterDataDO businessAssayParameterDataDO = businessAssayParameterDataMapper.selectByBusinessAssayProjectDataIdAndProjectSimpleNameAndParameterKey(targetBusinessAssayProjectData.getId(), targetProject, targetParameter); - if (businessAssayParameterDataDO != null && StringUtils.isBlank(businessAssayParameterDataDO.getValue())) {//值为空,才赋值 - businessAssayParameterDataDO.setValue(currentBusinessAssayProjectData.getValue()); - updateBusinessAssayParameterDataList.add(businessAssayParameterDataDO); - } - - } + + } } } @@ -1472,6 +2225,10 @@ public class SampleAnalysisServiceImpl implements SampleAnalysisService { businessAssayProjectDataMapper.updateBatch(businessAssayProjectDataList); } + if (updateBusinessAssayTaskParameterDataDOList.size() > 0) { + businessAssayTaskParameterDataMapper.updateBatch(updateBusinessAssayTaskParameterDataDOList); + } + if (updateBusinessAssayParameterDataList.size() > 0) { businessAssayParameterDataMapper.updateBatch(updateBusinessAssayParameterDataList); } @@ -1607,6 +2364,10 @@ public class SampleAnalysisServiceImpl implements SampleAnalysisService { // List configSubSampleMethodList = configSubSampleMethodMapper.selectByConfigSubSampleIdsAndConfigAssayMethodId(configSubSampleIdList, businessAssayTaskDO.getConfigAssayMethodId()); List configSubSampleMethodList = configSubSampleMethodMapper.selectByConfigSubSampleIdsAndConfigAssayMethodIds(configSubSampleIdList, configAssayMethodIdList); + //查询分析任务属性 + List businessAssayTaskParameterDataList = businessAssayTaskParameterDataMapper.selectExtendByBusinessAssayTaskDataIds(businessAssayTaskDataIdList); + + //查询检测项目 List businessAssayProjectDataList = businessAssayProjectDataMapper.selectByBusinessAssayTaskDataIds(businessAssayTaskDataIdList); List businessAssayProjectDataIdList = businessAssayProjectDataList.stream().map(m -> m.getId()).collect(Collectors.toList()); //查询检测项目参数 @@ -1626,13 +2387,19 @@ public class SampleAnalysisServiceImpl implements SampleAnalysisService { for (ConfigSubSampleMethodConfItem configSubSampleMethodConfItem : downIngredients) { if (configSubSampleMethodConfItem.getRequired()) { ConfigSubSampleMethodConfPoint source = configSubSampleMethodConfItem.getSource(); - - 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 (currentBusinessAssayParameterData!=null && StringUtils.isBlank(currentBusinessAssayParameterData.getValue())) { + if (StringUtils.isNotBlank(source.getProject())) {//来自检测项目参数 + 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 (currentBusinessAssayParameterData != null && StringUtils.isBlank(currentBusinessAssayParameterData.getValue())) { + throw new ServiceException(1_032_050_000, "当前分析任务,存在下发配料必填为空情况。请检查后再下发!"); + } + } + } else if (StringUtils.isNotBlank(source.getAttribute())) {//来自分析任务属性 + BusinessAssayTaskParameterDataExtendRespVO currentbAssayTaskParameterData = businessAssayTaskParameterDataList.stream().filter(f -> f.getBusinessAssayTaskDataId().equals(businessAssayTaskDataDO.getId()) && f.getKey().equals(source.getAttribute())).findFirst().orElse(null); + if (currentbAssayTaskParameterData != null && StringUtils.isBlank(currentbAssayTaskParameterData.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/bus/service/SampleTaskAssignServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/service/SampleTaskAssignServiceImpl.java index 26d82b05..00318831 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/service/SampleTaskAssignServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/bus/service/SampleTaskAssignServiceImpl.java @@ -1483,6 +1483,9 @@ public class SampleTaskAssignServiceImpl implements SampleTaskAssignService { businessQCManagementParameterDataDO.setDictionaryParameterId(configAssayMethodProjectParameterDO.getDictionaryParameterId()); businessQCManagementParameterDataDO.setDataType(configAssayMethodProjectParameterDO.getDataType()); businessQCManagementParameterDataDO.setDecimalPosition(configAssayMethodProjectParameterDO.getDecimalPosition()); + if (StringUtils.isNotBlank(configAssayMethodProjectParameterDO.getDefaultValue())) { + businessQCManagementParameterDataDO.setValue(configAssayMethodProjectParameterDO.getDefaultValue()); + } businessQCManagementParameterDataDOList.add(businessQCManagementParameterDataDO); } diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/config/controller/vo/ConfigAssayMethodParameterPageReqVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/config/controller/vo/ConfigAssayMethodParameterPageReqVO.java index a23f3ef8..023b45ed 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/config/controller/vo/ConfigAssayMethodParameterPageReqVO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/config/controller/vo/ConfigAssayMethodParameterPageReqVO.java @@ -28,6 +28,12 @@ public class ConfigAssayMethodParameterPageReqVO extends PageParam { @Schema(description = "键值") private String key; + @Schema(description = "单位ID,UNT表", example = "31081") + private Long unitId; + + @Schema(description = "单位") + private String unit; + @Schema(description = "填写方式,字典表【T_DIC_BSN】人工录入,天平采集,计算") private String fillingWay; @@ -43,6 +49,9 @@ public class ConfigAssayMethodParameterPageReqVO extends PageParam { @Schema(description = "是否允许为空") private Integer isNull; + @Schema(description = "计算公式") + private String formula; + @Schema(description = "pc界面是否显示") private Integer isShow; diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/config/controller/vo/ConfigAssayMethodParameterRespVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/config/controller/vo/ConfigAssayMethodParameterRespVO.java index 154813e2..8164d7d7 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/config/controller/vo/ConfigAssayMethodParameterRespVO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/config/controller/vo/ConfigAssayMethodParameterRespVO.java @@ -36,6 +36,12 @@ public class ConfigAssayMethodParameterRespVO { @ExcelProperty("键值") private String key; + @Schema(description = "单位ID,UNT表", example = "31081") + private Long unitId; + + @Schema(description = "单位") + private String unit; + @Schema(description = "填写方式,字典表【T_DIC_BSN】人工录入,天平采集,计算", requiredMode = Schema.RequiredMode.REQUIRED) @ExcelProperty("填写方式,字典表【T_DIC_BSN】人工录入,天平采集,计算") private String fillingWay; diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/config/controller/vo/ConfigAssayMethodParameterSaveReqVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/config/controller/vo/ConfigAssayMethodParameterSaveReqVO.java index f390c281..9bea21f7 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/config/controller/vo/ConfigAssayMethodParameterSaveReqVO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/config/controller/vo/ConfigAssayMethodParameterSaveReqVO.java @@ -30,6 +30,12 @@ public class ConfigAssayMethodParameterSaveReqVO { @Schema(description = "键值") private String key; + @Schema(description = "单位ID,UNT表", example = "31081") + private Long unitId; + + @Schema(description = "单位") + private String unit; + @Schema(description = "填写方式,字典表【T_DIC_BSN】人工录入,天平采集,计算", requiredMode = Schema.RequiredMode.REQUIRED) @NotEmpty(message = "填写方式,字典表【T_DIC_BSN】人工录入,天平采集,计算不能为空") private String fillingWay; 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 6acd850f..99a1fa5b 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 @@ -17,6 +17,9 @@ public class ConfigSubSampleMethodConfPoint { /** 参数 **/ private String parameter; + /** 分析任务属性,如果有检测项目,则无属性,有属性,则不配检测项目 **/ + private String attribute; + /** 字段 **/ private String field; diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/config/dal/dataobject/ConfigAssayMethodParameterDO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/config/dal/dataobject/ConfigAssayMethodParameterDO.java index 817c5e94..09f9ae84 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/config/dal/dataobject/ConfigAssayMethodParameterDO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/business/config/dal/dataobject/ConfigAssayMethodParameterDO.java @@ -57,6 +57,16 @@ public class ConfigAssayMethodParameterDO extends BusinessBaseDO { @TableField("KY") private String key; /** + * 单位ID,UNT表 + */ + @TableField("UNT_ID") + private Long unitId; + /** + * 单位 + */ + @TableField("UNT") + private String unit; + /** * 填写方式,字典表【T_DIC_BSN】人工录入,天平采集,计算 */ @TableField("FIL_WY") @@ -82,6 +92,11 @@ public class ConfigAssayMethodParameterDO extends BusinessBaseDO { @TableField("IS_NLL") private Integer isNull; /** + * 计算公式 + */ + @TableField("FMU") + private String formula; + /** * pc界面是否显示 */ @TableField("IS_SHW") 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 05ef2446..a69eaa40 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 @@ -20,16 +20,19 @@ import com.zt.plat.module.qms.business.bus.controller.vo.BusinessAssayTaskDataEx import com.zt.plat.module.qms.business.bus.controller.vo.BusinessAssayTaskDataReqVO; import com.zt.plat.module.qms.business.bus.controller.vo.BusinessAssayTaskExtendRespVO; import com.zt.plat.module.qms.business.bus.controller.vo.BusinessAssayTaskPageReqVO; +import com.zt.plat.module.qms.business.bus.controller.vo.BusinessAssayTaskParameterDataExtendRespVO; import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayParameterDataDO; import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayProjectDataDO; import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayTaskDO; import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayTaskDataDO; +import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayTaskParameterDataDO; import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessSubSampleDO; 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.bus.dal.mapper.BusinessAssayTaskDetailMapper; import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessAssayTaskMapper; +import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessAssayTaskParameterDataMapper; import com.zt.plat.module.qms.business.bus.dal.mapper.BusinessSubSampleMapper; import com.zt.plat.module.qms.business.config.controller.vo.ConfigSubSampleMethodConfInfo; import com.zt.plat.module.qms.business.config.controller.vo.ConfigSubSampleMethodConfItem; @@ -67,6 +70,9 @@ public class AutoIngredientsServiceImpl implements AutoIngredientsService { @Resource private BusinessAssayTaskDataMapper businessAssayTaskDataMapper; + @Resource + private BusinessAssayTaskParameterDataMapper businessAssayTaskParameterDataMapper; + @Resource private ConfigSubSampleMethodMapper configSubSampleMethodMapper; @@ -127,6 +133,9 @@ public class AutoIngredientsServiceImpl implements AutoIngredientsService { //查询检测项目参数 List businessAssayParameterDataList = businessAssayParameterDataMapper.selectExtendByBusinessAssayProjectDataIds(businessAssayProjectDataIdList); + //查询任务参数 + List businessAssayTaskParameterDataList = businessAssayTaskParameterDataMapper.selectExtendByBusinessAssayTaskDataIds(businessAssayTaskDataIdList); + CommonResult> userListResult = adminUserApi.getUserList(assayOperatorIdList); if (userListResult.isError()) { throw new ServiceException(userListResult.getCode(), userListResult.getMsg()); @@ -154,16 +163,25 @@ public class AutoIngredientsServiceImpl implements AutoIngredientsService { for (ConfigSubSampleMethodConfItem configSubSampleMethodConfItem : downIngredients) { if (configSubSampleMethodConfItem.getRequired()) { ConfigSubSampleMethodConfPoint source = configSubSampleMethodConfItem.getSource(); - 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())) { + if (StringUtils.isNotBlank(source.getProject())) {//从检测项目参数中来 + 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 (currentBusinessAssayParameterData != null && StringUtils.isNotBlank(currentBusinessAssayParameterData.getValue())) { + ConfigSubSampleMethodConfPoint target = configSubSampleMethodConfItem.getTarget(); + String field = target.getField(); + BeanUtil.setFieldValue(autoIngredientsTaskDetailRespVO, field, currentBusinessAssayParameterData.getValue()); + break; + } + } + } else if (StringUtils.isNotBlank(source.getAttribute())) {//从分析任务属性中来 + BusinessAssayTaskParameterDataExtendRespVO currentBusinessAssayTaskParameterData = businessAssayTaskParameterDataList.stream().filter(f -> f.getBusinessAssayTaskDataId().equals(m.getId()) && f.getKey().equals(source.getAttribute())).findFirst().orElse(null); + if (currentBusinessAssayTaskParameterData != null && StringUtils.isNotBlank(currentBusinessAssayTaskParameterData.getValue())) { ConfigSubSampleMethodConfPoint target = configSubSampleMethodConfItem.getTarget(); String field = target.getField(); - BeanUtil.setFieldValue(autoIngredientsTaskDetailRespVO, field, currentBusinessAssayParameterData.getValue()); - break; + BeanUtil.setFieldValue(autoIngredientsTaskDetailRespVO, field, currentBusinessAssayTaskParameterData.getValue()); } } } @@ -184,6 +202,7 @@ public class AutoIngredientsServiceImpl implements AutoIngredientsService { public void submitAssayResult(AutoIngredientsTaskAssayResultReqVO body) { List updateBusinessAssayTaskDataDOList = new ArrayList<>(); + List updateBusinessAssayTaskParameterDataDOList = new ArrayList<>(); List updateBusinessAssayProjectDataDOList = new ArrayList<>(); List updateBusinessAssayParameterDataDOList = new ArrayList<>(); @@ -214,6 +233,10 @@ public class AutoIngredientsServiceImpl implements AutoIngredientsService { //子样配置方法 List configSubSampleMethodList = configSubSampleMethodMapper.selectByConfigSubSampleIdsAndConfigAssayMethodId(configSubSampleIdList, businessAssayTaskDO.getConfigAssayMethodId()); + //查询分析任务属性 + List businessAssayTaskParameterDataList = businessAssayTaskParameterDataMapper.selectExtendByBusinessAssayTaskDataIds(businessAssayTaskDataIdList); + + //查询检测项目 List businessAssayProjectDataList = businessAssayProjectDataMapper.selectByBusinessAssayTaskDataIds(businessAssayTaskDataIdList); List businessAssayProjectDataIdList = businessAssayProjectDataList.stream().map(m -> m.getId()).collect(Collectors.toList()); //查询检测项目参数 @@ -241,23 +264,35 @@ public class AutoIngredientsServiceImpl implements AutoIngredientsService { // Map fieldMap = ReflectUtil.getFieldMap(autoIngredientsTaskDetailAssayResultReqVO.getClass()); // Object fieldValue2 = ReflectUtil.getFieldValue(autoIngredientsTaskDetailAssayResultReqVO, fieldMap.get(field)); Object fieldValue = BeanUtil.getFieldValue(autoIngredientsTaskDetailAssayResultReqVO, field); - if (fieldValue == null) { + if (fieldValue == null || "/".equals(fieldValue)) { fieldValue = ""; } // System.out.println("fieldValue:" + fieldValue); ConfigSubSampleMethodConfPoint target = configSubSampleMethodConfItem.getTarget(); - 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)); + if (StringUtils.isNotBlank(target.getProject())) {//保存到检测项目参数 + 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); + if (currentBusinessAssayProjectData != 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); + if (currentBusinessAssayParameterData != null) { + currentBusinessAssayParameterData.setValue(fieldValue.toString()); + updateBusinessAssayParameterDataDOList.add(BeanUtils.toBean(currentBusinessAssayParameterData, BusinessAssayParameterDataDO.class)); + } + } + } + } + } else if (StringUtils.isNotBlank(target.getAttribute())) {//保存到分析任务属性 + BusinessAssayTaskParameterDataExtendRespVO currentBusinessAssayTaskParameterData = businessAssayTaskParameterDataList.stream().filter(f -> f.getBusinessAssayTaskDataId().equals(autoIngredientsTaskDetailAssayResultReqVO.getId()) && f.getKey().equals(target.getAttribute())).findFirst().orElse(null); + if (currentBusinessAssayTaskParameterData != null) { + currentBusinessAssayTaskParameterData.setValue(fieldValue.toString()); + updateBusinessAssayTaskParameterDataDOList.add(BeanUtils.toBean(currentBusinessAssayTaskParameterData, BusinessAssayTaskParameterDataDO.class)); } } } @@ -276,6 +311,9 @@ public class AutoIngredientsServiceImpl implements AutoIngredientsService { if (CollUtil.isNotEmpty(updateBusinessAssayTaskDataDOList)) { businessAssayTaskDataMapper.updateBatch(updateBusinessAssayTaskDataDOList); } + if (CollUtil.isNotEmpty(updateBusinessAssayTaskParameterDataDOList)) { + businessAssayTaskParameterDataMapper.updateBatch(updateBusinessAssayTaskParameterDataDOList); + } if (CollUtil.isNotEmpty(updateBusinessAssayProjectDataDOList)) { businessAssayProjectDataMapper.updateBatch(updateBusinessAssayProjectDataDOList); } diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/thirdpartyapi/service/XRFDataServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/thirdpartyapi/service/XRFDataServiceImpl.java index a1396d98..591d148e 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/thirdpartyapi/service/XRFDataServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/thirdpartyapi/service/XRFDataServiceImpl.java @@ -15,7 +15,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.alibaba.fastjson2.JSON; -import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.zt.plat.framework.common.util.object.BeanUtils; import com.zt.plat.module.qms.business.bus.controller.vo.*; @@ -436,20 +435,30 @@ public class XRFDataServiceImpl implements XRFDataService { } 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()) && targetProject.equals(f.getSimpleName())).findFirst().orElse(null); - if (targetBusinessAssayProjectData == null) { - continue; + if (StringUtils.isNotBlank(target.getProject())) {//检测项目参数赋值 + 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()) && targetProject.equals(f.getSimpleName())).findFirst().orElse(null); + if (targetBusinessAssayProjectData == null) { + continue; + } + BusinessAssayParameterDataDO businessAssayParameterDataDO = businessAssayParameterDataMapper.selectByBusinessAssayProjectDataIdAndProjectSimpleNameAndParameterKey(targetBusinessAssayProjectData.getId(), targetProject, targetParameter); + if (businessAssayParameterDataDO != null) { + businessAssayParameterDataDO.setValue(currentBusinessAssayProjectData.getValue()); + updateBusinessAssayParameterDataList.add(businessAssayParameterDataDO); + } + + } + } else if (StringUtils.isNotBlank(target.getAttribute())) {//分析任务属性赋值 + BusinessAssayTaskParameterDataDO businessAssayTaskParameterDataDO = businessAssayTaskParameterDataMapper.selectByBusinessAssayTaskDataIdAndKey(targetBusinessAssayTaskData.getId(), target.getAttribute()); + if (businessAssayTaskParameterDataDO != null) { + businessAssayTaskParameterDataDO.setValue(currentBusinessAssayProjectData.getValue()); + businessAssayTaskParameterDataList.add(businessAssayTaskParameterDataDO); } - BusinessAssayParameterDataDO businessAssayParameterDataDO = businessAssayParameterDataMapper.selectByBusinessAssayProjectDataIdAndProjectSimpleNameAndParameterKey(targetBusinessAssayProjectData.getId(), targetProject, targetParameter); - if (businessAssayParameterDataDO != null) { - businessAssayParameterDataDO.setValue(currentBusinessAssayProjectData.getValue()); - updateBusinessAssayParameterDataList.add(businessAssayParameterDataDO); - } - - } + + } + } } } else if (QmsCommonConstant.ENTRUST_COMPREHENSIVE_INSPECTION_SAMPLE.equals(baseSampleDO.getDictionaryBusinessKey())) {//如果是商检综合样 @@ -470,20 +479,29 @@ public class XRFDataServiceImpl implements XRFDataService { } 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()) && targetProject.equals(f.getSimpleName())).findFirst().orElse(null); - if (targetBusinessAssayProjectData == null) { - continue; + if (StringUtils.isNotBlank(target.getProject())) {//检测项目参数赋值 + 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()) && targetProject.equals(f.getSimpleName())).findFirst().orElse(null); + if (targetBusinessAssayProjectData == null) { + continue; + } + BusinessAssayParameterDataDO businessAssayParameterDataDO = businessAssayParameterDataMapper.selectByBusinessAssayProjectDataIdAndProjectSimpleNameAndParameterKey(targetBusinessAssayProjectData.getId(), targetProject, targetParameter); + if (businessAssayParameterDataDO != null) { + businessAssayParameterDataDO.setValue(currentBusinessAssayProjectData.getValue()); + updateBusinessAssayParameterDataList.add(businessAssayParameterDataDO); + } + + } + } else if (StringUtils.isNotBlank(target.getAttribute())) {//分析任务属性赋值 + BusinessAssayTaskParameterDataDO businessAssayTaskParameterDataDO = businessAssayTaskParameterDataMapper.selectByBusinessAssayTaskDataIdAndKey(targetBusinessAssayTaskData.getId(), target.getAttribute()); + if (businessAssayTaskParameterDataDO != null) { + businessAssayTaskParameterDataDO.setValue(currentBusinessAssayProjectData.getValue()); + businessAssayTaskParameterDataList.add(businessAssayTaskParameterDataDO); } - BusinessAssayParameterDataDO businessAssayParameterDataDO = businessAssayParameterDataMapper.selectByBusinessAssayProjectDataIdAndProjectSimpleNameAndParameterKey(targetBusinessAssayProjectData.getId(), targetProject, targetParameter); - if (businessAssayParameterDataDO != null) { - businessAssayParameterDataDO.setValue(currentBusinessAssayProjectData.getValue()); - updateBusinessAssayParameterDataList.add(businessAssayParameterDataDO); - } - - } + + } } } } else if (QmsCommonConstant.ENTRUST_COMMISSION_INSPECTION_SAMPLE.equals(baseSampleDO.getDictionaryBusinessKey())) {//如果是委检样 @@ -504,20 +522,29 @@ public class XRFDataServiceImpl implements XRFDataService { } 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()) && targetProject.equals(f.getSimpleName())).findFirst().orElse(null); - if (targetBusinessAssayProjectData == null) { - continue; + if (StringUtils.isNotBlank(target.getProject())) {//检测项目参数赋值 + 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()) && targetProject.equals(f.getSimpleName())).findFirst().orElse(null); + if (targetBusinessAssayProjectData == null) { + continue; + } + BusinessAssayParameterDataDO businessAssayParameterDataDO = businessAssayParameterDataMapper.selectByBusinessAssayProjectDataIdAndProjectSimpleNameAndParameterKey(targetBusinessAssayProjectData.getId(), targetProject, targetParameter); + if (businessAssayParameterDataDO != null && StringUtils.isBlank(businessAssayParameterDataDO.getValue())) {//值为空,才赋值 + businessAssayParameterDataDO.setValue(currentBusinessAssayProjectData.getValue()); + updateBusinessAssayParameterDataList.add(businessAssayParameterDataDO); + } + + } + } else if (StringUtils.isNotBlank(target.getAttribute())) {//分析任务属性赋值 + BusinessAssayTaskParameterDataDO businessAssayTaskParameterDataDO = businessAssayTaskParameterDataMapper.selectByBusinessAssayTaskDataIdAndKey(targetBusinessAssayTaskData.getId(), target.getAttribute()); + if (businessAssayTaskParameterDataDO != null) { + businessAssayTaskParameterDataDO.setValue(currentBusinessAssayProjectData.getValue()); + businessAssayTaskParameterDataList.add(businessAssayTaskParameterDataDO); } - BusinessAssayParameterDataDO businessAssayParameterDataDO = businessAssayParameterDataMapper.selectByBusinessAssayProjectDataIdAndProjectSimpleNameAndParameterKey(targetBusinessAssayProjectData.getId(), targetProject, targetParameter); - if (businessAssayParameterDataDO != null && StringUtils.isBlank(businessAssayParameterDataDO.getValue())) {//值为空,才赋值 - businessAssayParameterDataDO.setValue(currentBusinessAssayProjectData.getValue()); - updateBusinessAssayParameterDataList.add(businessAssayParameterDataDO); - } - - } + + } } }