|
|
|
|
@@ -6,27 +6,51 @@ import java.util.Arrays;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
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 jakarta.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class AutoIngredientsServiceImpl implements AutoIngredientsService {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private BusinessSubSampleMapper businessSubSampleMapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private BusinessAssayTaskMapper businessAssayTaskMapper;
|
|
|
|
|
|
|
|
|
|
@@ -36,6 +60,9 @@ public class AutoIngredientsServiceImpl implements AutoIngredientsService {
|
|
|
|
|
@Resource
|
|
|
|
|
private BusinessAssayTaskDataMapper businessAssayTaskDataMapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private ConfigSubSampleMethodMapper configSubSampleMethodMapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private BusinessAssayProjectDataMapper businessAssayProjectDataMapper;
|
|
|
|
|
|
|
|
|
|
@@ -58,22 +85,154 @@ 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();
|
|
|
|
|
Object fieldValue = BeanUtil.getFieldValue(autoIngredientsTaskDetailAssayResultReqVO, field);
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|