From c8f9015145723067a7da2714220c842af1b1f99c Mon Sep 17 00:00:00 2001 From: fengyuan_yang <1976974459@qq.com> Date: Wed, 22 Jul 2026 13:39:16 +0800 Subject: [PATCH] =?UTF-8?q?2026-07-22=20Lab=20Test=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../spring/modules/lab/entity/LabEntity.java | 6 ++ .../lab/service/impl/LabServiceImpl.java | 69 +++++++++++++++++++ .../sys/controller/DictDataController.java | 10 ++- src/main/resources/mapper/lab/LabMapper.xml | 19 ++++- 4 files changed, 98 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/spring/modules/lab/entity/LabEntity.java b/src/main/java/com/spring/modules/lab/entity/LabEntity.java index b207e66f..68438709 100644 --- a/src/main/java/com/spring/modules/lab/entity/LabEntity.java +++ b/src/main/java/com/spring/modules/lab/entity/LabEntity.java @@ -258,6 +258,12 @@ public class LabEntity implements Serializable { @TableField(exist = false) private String labApproverName; + /** + * 测试实验室名称(字典标签) + */ + @TableField(exist = false) + private String testLabName; + /** * 属性信息 */ diff --git a/src/main/java/com/spring/modules/lab/service/impl/LabServiceImpl.java b/src/main/java/com/spring/modules/lab/service/impl/LabServiceImpl.java index d6c5b003..7587b538 100644 --- a/src/main/java/com/spring/modules/lab/service/impl/LabServiceImpl.java +++ b/src/main/java/com/spring/modules/lab/service/impl/LabServiceImpl.java @@ -1,6 +1,7 @@ package com.spring.modules.lab.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.spring.common.utils.Constant; @@ -30,7 +31,9 @@ import com.spring.modules.request.vo.PlmRequestDetailVo; import com.spring.modules.sift.utils.QueryCriteriaConstructorDefault; import com.spring.modules.sift.vo.QuerySavedVo; import com.spring.modules.sys.dao.SysUserDao; +import com.spring.modules.sys.entity.DictData; import com.spring.modules.sys.entity.SysUserEntity; +import com.spring.modules.sys.service.DictDataService; import org.apache.commons.lang.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -52,10 +55,15 @@ import static com.spring.modules.base.utils.CommonUtils.getPropertyValue; @Service("labService") public class LabServiceImpl extends ServiceImpl implements LabService { private static final String LAB_PROPERTY_TYPE = "LAB"; + private static final String LAB_TEST_LAB_DICT_TYPE = "lab_test_lab"; + private static final String LAB_TEST_LAB_DICT_SITE = "41"; @Autowired private SysUserDao sysUserDao; + @Autowired + private DictDataService dictDataService; + @Autowired private ChangeManagementMapper changeManagementMapper; @@ -74,6 +82,18 @@ public class LabServiceImpl extends ServiceImpl implements @Value("${oa-api.api-url}") private String apiUrlOa; + @Override + public boolean save(LabEntity entity) { + normalizeTestLabForPersist(entity); + return super.save(entity); + } + + @Override + public boolean update(LabEntity entity, Wrapper updateWrapper) { + normalizeTestLabForPersist(entity); + return super.update(entity, updateWrapper); + } + @Override public PageUtils queryPage(Map params) { params.put("referenceNo", trimToNull((String) params.get("referenceNo"))); @@ -574,6 +594,55 @@ public class LabServiceImpl extends ServiceImpl implements throw new RuntimeException(e.getMessage()); } + private void normalizeTestLabForPersist(LabEntity entity) { + if (entity == null || entity.getTestLab() == null) { + return; + } + entity.setTestLab(normalizeTestLabLabel(entity.getTestLab())); + } + + private String normalizeTestLabLabel(String rawValue) { + String value = StringUtils.trimToEmpty(rawValue); + if (StringUtils.isBlank(value)) { + return value; + } + String labelByValue = queryLabTestLabLabelByValue(value); + if (StringUtils.isNotBlank(labelByValue)) { + return labelByValue; + } + String labelByLabel = queryLabTestLabLabelByLabel(value); + if (StringUtils.isNotBlank(labelByLabel)) { + return labelByLabel; + } + return value; + } + + private String queryLabTestLabLabelByValue(String dictValue) { + List dictRows = dictDataService.lambdaQuery() + .eq(DictData::getSite, LAB_TEST_LAB_DICT_SITE) + .eq(DictData::getDictType, LAB_TEST_LAB_DICT_TYPE) + .eq(DictData::getStatus, "Y") + .eq(DictData::getDictValue, dictValue) + .list(); + if (dictRows == null || dictRows.isEmpty()) { + return ""; + } + return StringUtils.trimToEmpty(dictRows.get(0).getDictLabel()); + } + + private String queryLabTestLabLabelByLabel(String dictLabel) { + List dictRows = dictDataService.lambdaQuery() + .eq(DictData::getSite, LAB_TEST_LAB_DICT_SITE) + .eq(DictData::getDictType, LAB_TEST_LAB_DICT_TYPE) + .eq(DictData::getStatus, "Y") + .eq(DictData::getDictLabel, dictLabel) + .list(); + if (dictRows == null || dictRows.isEmpty()) { + return ""; + } + return StringUtils.trimToEmpty(dictRows.get(0).getDictLabel()); + } + private String trimToNull(String value) { if (StringUtils.isBlank(value)) { return null; diff --git a/src/main/java/com/spring/modules/sys/controller/DictDataController.java b/src/main/java/com/spring/modules/sys/controller/DictDataController.java index 8a24a098..0e694b75 100644 --- a/src/main/java/com/spring/modules/sys/controller/DictDataController.java +++ b/src/main/java/com/spring/modules/sys/controller/DictDataController.java @@ -174,10 +174,14 @@ public class DictDataController { */ @PostMapping("/list") public R selectDictDataList(@RequestBody DictDataVo dictDataVo){ + if (Objects.isNull(dictDataVo)){ + throw new RuntimeException("请求参数为空!"); + } if (!StringUtils.hasText(dictDataVo.getSite())){ throw new RuntimeException("工厂编码为空!"); } - if (!StringUtils.hasText(dictDataVo.getDictType()) && dictDataVo.getDictTypeList().isEmpty()){ + List dictTypeList = dictDataVo.getDictTypeList(); + if (!StringUtils.hasText(dictDataVo.getDictType()) && (Objects.isNull(dictTypeList) || dictTypeList.isEmpty())){ throw new RuntimeException("字典类型为空!"); } LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); @@ -185,8 +189,8 @@ public class DictDataController { if (StringUtils.hasText(dictDataVo.getDictType())){ wrapper.eq(DictData::getDictType,dictDataVo.getDictType()); } - if (!dictDataVo.getDictTypeList().isEmpty()){ - wrapper.in(DictData::getDictType,dictDataVo.getDictTypeList()); + if (!Objects.isNull(dictTypeList) && !dictTypeList.isEmpty()){ + wrapper.in(DictData::getDictType,dictTypeList); } wrapper.orderByAsc(DictData::getDictSort); return R.ok().put("rows",dictDataService.list(wrapper)); diff --git a/src/main/resources/mapper/lab/LabMapper.xml b/src/main/resources/mapper/lab/LabMapper.xml index 19059364..cfe55c31 100644 --- a/src/main/resources/mapper/lab/LabMapper.xml +++ b/src/main/resources/mapper/lab/LabMapper.xml @@ -47,6 +47,7 @@ + @@ -72,7 +73,11 @@ dbo.plm_get_customer_desc(a.site, a.customer_id) as customerName, dbo.plm_get_project_name(a.site, a.project_id) as projectName, dbo.get_userDisPlay(a.tester) as testerName, - dbo.get_userDisPlay(a.lab_approver) as labApproverName + dbo.get_userDisPlay(a.lab_approver) as labApproverName, + case + when isnull(dbo.plm_get_dictDataLabel('lab_test_lab', a.test_lab, '41'), '') = '' then a.test_lab + else dbo.plm_get_dictDataLabel('lab_test_lab', a.test_lab, '41') + end as testLabName from plm_lab a left join plm_request_header prh on a.site = prh.site and prh.menu_id = #{params.menuId} and prh.status = 'Y' left join plm_request_node d on a.site = d.site and prh.classification_no = d.classification_no and prh.workflow_id = d.workflow_id and a.step_id = d.step_id @@ -108,7 +113,11 @@ dbo.plm_get_customer_desc(a.site, a.customer_id) as customerName, dbo.plm_get_project_name(a.site, a.project_id) as projectName, dbo.get_userDisPlay(a.tester) as testerName, - dbo.get_userDisPlay(a.lab_approver) as labApproverName + dbo.get_userDisPlay(a.lab_approver) as labApproverName, + case + when isnull(dbo.plm_get_dictDataLabel('lab_test_lab', a.test_lab, '41'), '') = '' then a.test_lab + else dbo.plm_get_dictDataLabel('lab_test_lab', a.test_lab, '41') + end as testLabName from plm_lab a left join plm_request_header prh on a.site = prh.site and prh.menu_id = #{params.menuId} and prh.status = 'Y' left join plm_request_node d on a.site = d.site and prh.classification_no = d.classification_no and prh.workflow_id = d.workflow_id and a.step_id = d.step_id @@ -130,7 +139,11 @@ dbo.plm_get_customer_desc(a.site, a.customer_id) as customerName, dbo.plm_get_project_name(a.site, a.project_id) as projectName, dbo.get_userDisPlay(a.tester) as testerName, - dbo.get_userDisPlay(a.lab_approver) as labApproverName + dbo.get_userDisPlay(a.lab_approver) as labApproverName, + case + when isnull(dbo.plm_get_dictDataLabel('lab_test_lab', a.test_lab, '41'), '') = '' then a.test_lab + else dbo.plm_get_dictDataLabel('lab_test_lab', a.test_lab, '41') + end as testLabName from plm_lab a where a.site = #{site} and a.reference_no = #{referenceNo}