Browse Source

2026-07-22

Lab Test优化
master
fengyuan_yang 6 days ago
parent
commit
c8f9015145
  1. 6
      src/main/java/com/spring/modules/lab/entity/LabEntity.java
  2. 69
      src/main/java/com/spring/modules/lab/service/impl/LabServiceImpl.java
  3. 10
      src/main/java/com/spring/modules/sys/controller/DictDataController.java
  4. 19
      src/main/resources/mapper/lab/LabMapper.xml

6
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;
/**
* 属性信息
*/

69
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<LabMapper, LabEntity> 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<LabMapper, LabEntity> 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<LabEntity> updateWrapper) {
normalizeTestLabForPersist(entity);
return super.update(entity, updateWrapper);
}
@Override
public PageUtils queryPage(Map<String, Object> params) {
params.put("referenceNo", trimToNull((String) params.get("referenceNo")));
@ -574,6 +594,55 @@ public class LabServiceImpl extends ServiceImpl<LabMapper, LabEntity> 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<DictData> 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<DictData> 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;

10
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<String> dictTypeList = dictDataVo.getDictTypeList();
if (!StringUtils.hasText(dictDataVo.getDictType()) && (Objects.isNull(dictTypeList) || dictTypeList.isEmpty())){
throw new RuntimeException("字典类型为空!");
}
LambdaQueryWrapper<DictData> 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));

19
src/main/resources/mapper/lab/LabMapper.xml

@ -47,6 +47,7 @@
<result column="projectName" property="projectName"/>
<result column="testerName" property="testerName"/>
<result column="labApproverName" property="labApproverName"/>
<result column="testLabName" property="testLabName"/>
</resultMap>
<sql id="Base_Column_List">
@ -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}

Loading…
Cancel
Save