Merge remote-tracking branch 'origin/test' into test

# Conflicts:
#	zt-module-qms/zt-module-qms-api/src/main/java/com/zt/plat/module/qms/enums/QmsCommonConstant.java
This commit is contained in:
FCL
2025-11-26 08:44:33 +08:00
11 changed files with 270 additions and 11 deletions

View File

@@ -191,4 +191,7 @@ public interface QmsCommonConstant {
String SAMPLE_STORAGE_OPERATION_TYPE_TRANSFER = "dispatch";
String SAMPLE_STORAGE_OPERATION_TYPE_TAKEN_OFF = "take_off";
/** 允许提交 **/
String ALLOW_SUBMIT = "allow_submit";
}

View File

@@ -0,0 +1,12 @@
package com.zt.plat.module.qms.business.bus.controller.vo;
import lombok.Data;
@Data
public class BusinessAssayParameterDataExtendRespVO extends BusinessAssayParameterDataRespVO {
private String parameterName;
private String parameterKey;
}

View File

@@ -18,6 +18,9 @@ public class BusinessAssayTaskDataExtendRespVO extends BusinessAssayTaskDataResp
@Schema(description = "分析方法名称")
private String configAssayMethodName;
@Schema(description = "子样配置id")
private Long configSubSampleId;
@Schema(description = "样品名称")
private String sampleName;

View File

@@ -84,4 +84,13 @@ public interface BusinessAssayParameterDataMapper extends BaseMapperX<BusinessAs
.in(BusinessAssayParameterDataDO::getBusinessAssayProjectDataId, businessAssayProjectDataIds));
}
default List<BusinessAssayParameterDataExtendRespVO> selectExtendByBusinessAssayProjectDataIds(List<Long> businessAssayProjectDataIds) {
return selectJoinList(BusinessAssayParameterDataExtendRespVO.class, new MPJLambdaWrapperX<BusinessAssayParameterDataDO>()
.leftJoin(DictionaryParameterDO.class, DictionaryParameterDO::getId, BusinessAssayParameterDataDO::getDictionaryParameterId)
.selectAll(BusinessAssayParameterDataDO.class)
.selectAs(DictionaryParameterDO::getName, BusinessAssayParameterDataExtendRespVO::getParameterName)
.selectAs(DictionaryParameterDO::getKey, BusinessAssayParameterDataExtendRespVO::getParameterKey)
.in(BusinessAssayParameterDataDO::getBusinessAssayProjectDataId, businessAssayProjectDataIds));
}
}

View File

@@ -47,6 +47,7 @@ public interface BusinessAssayTaskDataMapper extends BaseMapperX<BusinessAssayTa
.selectAs(BusinessSubSampleDO::getSampleName, BusinessAssayTaskDataExtendRespVO::getSampleName)
.selectAs(BusinessSubSampleDO::getSampleCode, BusinessAssayTaskDataExtendRespVO::getSampleCode)
.selectAs(BusinessSubSampleDO::getSampleAssayCode, BusinessAssayTaskDataExtendRespVO::getSampleAssayCode)
.selectAs(BusinessSubSampleDO::getConfigSubSampleId, BusinessAssayTaskDataExtendRespVO::getConfigSubSampleId)
.eqIfPresent(BusinessAssayTaskDataDO::getBusinessBaseSampleId, reqVO.getBusinessBaseSampleId())
.eqIfPresent(BusinessAssayTaskDataDO::getBusinessSubParentSampleId, reqVO.getBusinessSubParentSampleId())
.eqIfPresent(BusinessAssayTaskDataDO::getBusinessSubSampleId, reqVO.getBusinessSubSampleId())
@@ -84,6 +85,7 @@ public interface BusinessAssayTaskDataMapper extends BaseMapperX<BusinessAssayTa
.selectAs(BusinessSubSampleDO::getSampleName, BusinessAssayTaskDataExtendRespVO::getSampleName)
.selectAs(BusinessSubSampleDO::getSampleCode, BusinessAssayTaskDataExtendRespVO::getSampleCode)
.selectAs(BusinessSubSampleDO::getSampleAssayCode, BusinessAssayTaskDataExtendRespVO::getSampleAssayCode)
.selectAs(BusinessSubSampleDO::getConfigSubSampleId, BusinessAssayTaskDataExtendRespVO::getConfigSubSampleId)
.eqIfPresent(BusinessAssayTaskDataDO::getBusinessBaseSampleId, reqVO.getBusinessBaseSampleId())
.eqIfPresent(BusinessAssayTaskDataDO::getBusinessSubParentSampleId, reqVO.getBusinessSubParentSampleId())
.eqIfPresent(BusinessAssayTaskDataDO::getBusinessSubSampleId, reqVO.getBusinessSubSampleId())

View File

@@ -0,0 +1,18 @@
package com.zt.plat.module.qms.business.config.controller.vo;
import java.util.List;
import lombok.Data;
@Data
public class ConfigSubSampleMethodConfInfo {
/** 分析方法参数取值配置 **/
private List<ConfigSubSampleMethodConfItem> getParam;
/** 分析方法下发配料配置 **/
private List<ConfigSubSampleMethodConfItem> downIngredients;
/** 分析方法配料上传配置 **/
private List<ConfigSubSampleMethodConfItem> upIngredients;
}

View File

@@ -0,0 +1,16 @@
package com.zt.plat.module.qms.business.config.controller.vo;
import lombok.Data;
@Data
public class ConfigSubSampleMethodConfItem {
/** 来源 **/
private ConfigSubSampleMethodConfPoint source;
/** 目标 **/
private ConfigSubSampleMethodConfPoint target;
/** 是否必须 **/
private Boolean required;
}

View File

@@ -0,0 +1,20 @@
package com.zt.plat.module.qms.business.config.controller.vo;
import lombok.Data;
@Data
public class ConfigSubSampleMethodConfPoint {
/** 分析方法id **/
private Long methodId;
/** 检测项目 **/
private String project;
/** 参数 **/
private String parameter;
/** 字段 **/
private String field;
}

View File

@@ -54,4 +54,10 @@ public interface ConfigSubSampleMethodMapper extends BaseMapperX<ConfigSubSample
.eq(ConfigSubSampleMethodDO::getConfigAssayMethodId, configAssayMethodId));
}
default List<ConfigSubSampleMethodDO> selectByConfigSubSampleIdsAndConfigAssayMethodId(List<Long> configSubSampleIds, Long configAssayMethodId) {
return selectList(new LambdaQueryWrapper<ConfigSubSampleMethodDO>()
.in(ConfigSubSampleMethodDO::getConfigSubSampleId, configSubSampleIds)
.eq(ConfigSubSampleMethodDO::getConfigAssayMethodId, configAssayMethodId));
}
}

View File

@@ -46,7 +46,7 @@ public class AutoIngredientsController {
@PostMapping("/submit-assay-result")
@Operation(summary = "检测结果同步")
public CommonResult<?> submitAssayResult(@RequestBody AutoIngredientsTaskAssayResultReqVO body) {
System.out.println(com.alibaba.fastjson2.JSON.toJSONString(body));
// System.out.println(com.alibaba.fastjson2.JSON.toJSONString(body));
autoIngredientsService.submitAssayResult(body);
return CommonResult.success("成功");
}

View File

@@ -1,32 +1,59 @@
package com.zt.plat.module.qms.thirdpartyapi.service;
import java.lang.reflect.Field;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson2.JSON;
import com.zt.plat.framework.common.util.object.BeanUtils;
import com.zt.plat.module.qms.business.bus.controller.vo.BusinessAssayParameterDataExtendRespVO;
import com.zt.plat.module.qms.business.bus.controller.vo.BusinessAssayProjectDataExtendRespVO;
import com.zt.plat.module.qms.business.bus.controller.vo.BusinessAssayTaskDataExtendRespVO;
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.dal.dataobject.BusinessAssayTaskDetailDO;
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.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.BusinessSubSampleMapper;
import com.zt.plat.module.qms.business.config.controller.vo.ConfigSubSampleMethodConfInfo;
import com.zt.plat.module.qms.business.config.controller.vo.ConfigSubSampleMethodConfItem;
import com.zt.plat.module.qms.business.config.controller.vo.ConfigSubSampleMethodConfPoint;
import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigSubSampleMethodDO;
import com.zt.plat.module.qms.business.config.dal.mapper.ConfigSubSampleMethodMapper;
import com.zt.plat.module.qms.enums.QmsCommonConstant;
import com.zt.plat.module.qms.thirdpartyapi.controller.vo.AutoIngredientsTaskAssayResultReqVO;
import com.zt.plat.module.qms.thirdpartyapi.controller.vo.AutoIngredientsTaskDetailAssayResultReqVO;
import com.zt.plat.module.qms.thirdpartyapi.controller.vo.AutoIngredientsTaskDetailRespVO;
import com.zt.plat.module.qms.thirdpartyapi.controller.vo.AutoIngredientsTaskQueryReqVO;
import com.zt.plat.module.qms.thirdpartyapi.controller.vo.AutoIngredientsTaskRespVO;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ReflectUtil;
import jakarta.annotation.Resource;
@Service
public class AutoIngredientsServiceImpl implements AutoIngredientsService {
@Resource
private BusinessSubSampleMapper businessSubSampleMapper;
@Resource
private BusinessAssayTaskMapper businessAssayTaskMapper;
@@ -36,6 +63,9 @@ public class AutoIngredientsServiceImpl implements AutoIngredientsService {
@Resource
private BusinessAssayTaskDataMapper businessAssayTaskDataMapper;
@Resource
private ConfigSubSampleMethodMapper configSubSampleMethodMapper;
@Resource
private BusinessAssayProjectDataMapper businessAssayProjectDataMapper;
@@ -58,22 +88,162 @@ public class AutoIngredientsServiceImpl implements AutoIngredientsService {
@Override
public List<AutoIngredientsTaskDetailRespVO> taskDetailList(Long taskId) {
// List<BusinessAssayTaskDetailDO> list = businessAssayTaskDetailMapper.selectByBusinessAssayTaskId(taskId);
// businessAssayTaskDataMapper.selectByBusinessAssayTaskId(taskId)
List<AutoIngredientsTaskDetailRespVO> resultList = new ArrayList<>();
// for (BusinessAssayTaskDetailDO businessAssayTaskDetailDO : list) {
// AutoIngredientsTaskDetailRespVO autoIngredientsTaskDetailRespVO = new AutoIngredientsTaskDetailRespVO();
// autoIngredientsTaskDetailRespVO.setAssayOperator(null)
// resultList.add(autoIngredientsTaskDetailRespVO);
//
// }
//查询任务分配信息
BusinessAssayTaskDO businessAssayTaskDO = businessAssayTaskMapper.selectById(taskId);
//查询子样检测任务
BusinessAssayTaskDataReqVO search = new BusinessAssayTaskDataReqVO();
search.setBusinessAssayTaskId(taskId);
List<BusinessAssayTaskDataExtendRespVO> list = businessAssayTaskDataMapper.selectList(search);
//子样配置id列表
List<Long> configSubSampleIdList = list.stream().map(m -> m.getConfigSubSampleId()).distinct().collect(Collectors.toList());
//子样配置方法
List<ConfigSubSampleMethodDO> configSubSampleMethodList = configSubSampleMethodMapper.selectByConfigSubSampleIdsAndConfigAssayMethodId(configSubSampleIdList, businessAssayTaskDO.getConfigAssayMethodId());
//分析任务id列表
List<Long> businessAssayTaskDataIdList = list.stream().map(m -> m.getId()).collect(Collectors.toList());
//查询检测项目
List<BusinessAssayProjectDataExtendRespVO> businessAssayProjectDataList = businessAssayProjectDataMapper.selectByBusinessAssayTaskDataIds(businessAssayTaskDataIdList);
List<Long> businessAssayProjectDataIdList = businessAssayProjectDataList.stream().map(m -> m.getId()).collect(Collectors.toList());
//查询检测项目参数
List<BusinessAssayParameterDataExtendRespVO> businessAssayParameterDataList = businessAssayParameterDataMapper.selectExtendByBusinessAssayProjectDataIds(businessAssayProjectDataIdList);
List<AutoIngredientsTaskDetailRespVO> resultList = list.stream().map(m -> {
//子样配置信息
ConfigSubSampleMethodDO configSubSampleMethodDO = configSubSampleMethodList.stream().filter(f -> f.getConfigSubSampleId().equals(m.getConfigSubSampleId())).findFirst().orElse(null);
String configInfomation = configSubSampleMethodDO.getConfigInfomation();
//当前检测项目列表
List<BusinessAssayProjectDataExtendRespVO> currentBusinessAssayProjectDataList = businessAssayProjectDataList.stream().filter(f -> f.getBusinessAssayTaskDataId().equals(m.getId())).collect(Collectors.toList());
AutoIngredientsTaskDetailRespVO autoIngredientsTaskDetailRespVO = new AutoIngredientsTaskDetailRespVO();
autoIngredientsTaskDetailRespVO.setId(m.getId());
autoIngredientsTaskDetailRespVO.setTaskId(m.getBusinessAssayTaskId());
autoIngredientsTaskDetailRespVO.setSampleCode(m.getSampleAssayCode());
autoIngredientsTaskDetailRespVO.setSampleName(m.getSampleName());
if (StringUtils.isNotBlank(configInfomation)) {
ConfigSubSampleMethodConfInfo configSubSampleMethodConfInfo = JSON.parseObject(configInfomation, ConfigSubSampleMethodConfInfo.class);
//获取下发配置
List<ConfigSubSampleMethodConfItem> downIngredients = configSubSampleMethodConfInfo.getDownIngredients();
for (ConfigSubSampleMethodConfItem configSubSampleMethodConfItem : downIngredients) {
if (configSubSampleMethodConfItem.getRequired()) {
ConfigSubSampleMethodConfPoint source = configSubSampleMethodConfItem.getSource();
String project = source.getProject();
String parameter = source.getParameter();
BusinessAssayProjectDataExtendRespVO currentBusinessAssayProjectData = currentBusinessAssayProjectDataList.stream().filter(f -> f.getSimpleName().equals(project)).findFirst().orElse(null);
BusinessAssayParameterDataExtendRespVO currentBusinessAssayParameterData = businessAssayParameterDataList.stream().filter(f -> f.getBusinessAssayProjectDataId().equals(currentBusinessAssayProjectData.getId()) && f.getParameterKey().equals(parameter)).findFirst().orElse(null);
ConfigSubSampleMethodConfPoint target = configSubSampleMethodConfItem.getTarget();
String field = target.getField();
BeanUtil.setFieldValue(autoIngredientsTaskDetailRespVO, field, currentBusinessAssayParameterData.getValue());
}
}
}
autoIngredientsTaskDetailRespVO.setAssayProject(m.getAssayProject());
autoIngredientsTaskDetailRespVO.setAssayOperator(m.getAssayOperator());
autoIngredientsTaskDetailRespVO.setAssayOperatorName(m.getAssayOperator());
autoIngredientsTaskDetailRespVO.setRemark(m.getRemark());
return autoIngredientsTaskDetailRespVO;
}).collect(Collectors.toList());
return resultList;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void submitAssayResult(AutoIngredientsTaskAssayResultReqVO body) {
List<BusinessAssayTaskDataDO> updateBusinessAssayTaskDataDOList = new ArrayList<>();
List<BusinessAssayProjectDataDO> updateBusinessAssayProjectDataDOList = new ArrayList<>();
List<BusinessAssayParameterDataDO> updateBusinessAssayParameterDataDOList = new ArrayList<>();
//任务id
Long taskId = body.getTaskId();
//查询任务分配信息
BusinessAssayTaskDO businessAssayTaskDO = businessAssayTaskMapper.selectById(taskId);
List<AutoIngredientsTaskDetailAssayResultReqVO> sampleList = body.getSampleList();
//获取检测任务id
List<Long> businessAssayTaskDataIdList = sampleList.stream().map(m -> m.getId()).collect(Collectors.toList());
List<BusinessAssayTaskDataDO> businessAssayTaskDataDOList = businessAssayTaskDataMapper.selectByIds(businessAssayTaskDataIdList);
//获取子样id列表
List<Long> businessSubSampleIdList = businessAssayTaskDataDOList.stream().map(m -> m.getBusinessSubSampleId()).distinct().collect(Collectors.toList());
//获取子样
List<BusinessSubSampleDO> businessSubSampleDOList = businessSubSampleMapper.selectByIds(businessSubSampleIdList);
//子样配置id列表
List<Long> configSubSampleIdList = businessSubSampleDOList.stream().map(m -> m.getConfigSubSampleId()).distinct().collect(Collectors.toList());
//子样配置方法
List<ConfigSubSampleMethodDO> configSubSampleMethodList = configSubSampleMethodMapper.selectByConfigSubSampleIdsAndConfigAssayMethodId(configSubSampleIdList, businessAssayTaskDO.getConfigAssayMethodId());
List<BusinessAssayProjectDataExtendRespVO> businessAssayProjectDataList = businessAssayProjectDataMapper.selectByBusinessAssayTaskDataIds(businessAssayTaskDataIdList);
List<Long> businessAssayProjectDataIdList = businessAssayProjectDataList.stream().map(m -> m.getId()).collect(Collectors.toList());
//查询检测项目参数
List<BusinessAssayParameterDataExtendRespVO> businessAssayParameterDataList = businessAssayParameterDataMapper.selectExtendByBusinessAssayProjectDataIds(businessAssayProjectDataIdList);
for (AutoIngredientsTaskDetailAssayResultReqVO autoIngredientsTaskDetailAssayResultReqVO : sampleList) {
//获取子样检测任务
BusinessAssayTaskDataDO businessAssayTaskDataDO = businessAssayTaskDataDOList.stream().filter(f -> f.getId().equals(autoIngredientsTaskDetailAssayResultReqVO.getId())).findFirst().orElse(null);
//获取子样
BusinessSubSampleDO businessSubSampleDO = businessSubSampleDOList.stream().filter(f -> f.getId().equals(businessAssayTaskDataDO.getBusinessSubSampleId())).findFirst().orElse(null);
//子样配置信息
ConfigSubSampleMethodDO configSubSampleMethodDO = configSubSampleMethodList.stream().filter(f -> f.getConfigSubSampleId().equals(businessSubSampleDO.getConfigSubSampleId())).findFirst().orElse(null);
String configInfomation = configSubSampleMethodDO.getConfigInfomation();
if (StringUtils.isNotBlank(configInfomation)) {
ConfigSubSampleMethodConfInfo configSubSampleMethodConfInfo = JSON.parseObject(configInfomation, ConfigSubSampleMethodConfInfo.class);
//获取上传配置
List<ConfigSubSampleMethodConfItem> upIngredients = configSubSampleMethodConfInfo.getUpIngredients();
for (ConfigSubSampleMethodConfItem configSubSampleMethodConfItem : upIngredients) {
if (configSubSampleMethodConfItem.getRequired()) {
ConfigSubSampleMethodConfPoint source = configSubSampleMethodConfItem.getSource();
String field = source.getField();
// System.out.println("field:" + field);
// Field field2 = ReflectUtil.getField(autoIngredientsTaskDetailAssayResultReqVO.getClass(), field);
// Map<String, Field> fieldMap = ReflectUtil.getFieldMap(autoIngredientsTaskDetailAssayResultReqVO.getClass());
// Object fieldValue2 = ReflectUtil.getFieldValue(autoIngredientsTaskDetailAssayResultReqVO, fieldMap.get(field));
Object fieldValue = BeanUtil.getFieldValue(autoIngredientsTaskDetailAssayResultReqVO, field);
if (fieldValue == null) {
fieldValue = "";
}
// System.out.println("fieldValue:" + fieldValue);
ConfigSubSampleMethodConfPoint target = configSubSampleMethodConfItem.getTarget();
String project = target.getProject();
BusinessAssayProjectDataExtendRespVO currentBusinessAssayProjectData = businessAssayProjectDataList.stream().filter(f -> f.getBusinessAssayTaskDataId().equals(autoIngredientsTaskDetailAssayResultReqVO.getId()) && f.getSimpleName().equals(project)).findFirst().orElse(null);
String parameter = target.getParameter();
if (StringUtils.isBlank(parameter)) {
currentBusinessAssayProjectData.setValue(fieldValue.toString());
updateBusinessAssayProjectDataDOList.add(BeanUtils.toBean(currentBusinessAssayProjectData, BusinessAssayProjectDataDO.class));
} else {
BusinessAssayParameterDataExtendRespVO currentBusinessAssayParameterData = businessAssayParameterDataList.stream().filter(f -> f.getBusinessAssayProjectDataId().equals(currentBusinessAssayProjectData.getId()) && f.getParameterKey().equals(parameter)).findFirst().orElse(null);
currentBusinessAssayParameterData.setValue(fieldValue.toString());
updateBusinessAssayParameterDataDOList.add(BeanUtils.toBean(currentBusinessAssayParameterData, BusinessAssayParameterDataDO.class));
}
}
}
}
String remark = CollUtil.join(Arrays.asList(autoIngredientsTaskDetailAssayResultReqVO.getRemark()), "");
businessAssayTaskDataDO.setRemark(remark);
updateBusinessAssayTaskDataDOList.add(businessAssayTaskDataDO);
}
businessAssayTaskDO.setIngredientsStatus(QmsCommonConstant.ALLOW_SUBMIT);
businessAssayTaskMapper.updateById(businessAssayTaskDO);
if (CollUtil.isNotEmpty(updateBusinessAssayTaskDataDOList)) {
businessAssayTaskDataMapper.updateBatch(updateBusinessAssayTaskDataDOList);
}
if (CollUtil.isNotEmpty(updateBusinessAssayProjectDataDOList)) {
businessAssayProjectDataMapper.updateBatch(updateBusinessAssayProjectDataDOList);
}
if (CollUtil.isNotEmpty(updateBusinessAssayParameterDataDOList)) {
businessAssayParameterDataMapper.updateBatch(updateBusinessAssayParameterDataDOList);
}
}
}