|
|
|
@ -1,17 +1,26 @@
|
|
|
|
|
package com.supervision.manage.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.supervision.manage.pojo.vo.PhysicalToolReqVO;
|
|
|
|
|
import com.supervision.exception.BusinessException;
|
|
|
|
|
import com.supervision.manage.pojo.vo.PhysicalToolVO;
|
|
|
|
|
import com.supervision.manage.service.PhysicalToolManageService;
|
|
|
|
|
import com.supervision.model.ConfigPhysicalTool;
|
|
|
|
|
import com.supervision.model.DefaultPhysicalIndicator;
|
|
|
|
|
import com.supervision.model.DiseasePhysical;
|
|
|
|
|
import com.supervision.service.ConfigPhysicalToolService;
|
|
|
|
|
import com.supervision.service.DefaultPhysicalIndicatorService;
|
|
|
|
|
import com.supervision.service.DiseasePhysicalService;
|
|
|
|
|
import com.supervision.vo.ask.ConfigPhysicalToolResVO;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
@ -22,6 +31,10 @@ public class PhysicalToolManageServiceImpl implements PhysicalToolManageService
|
|
|
|
|
|
|
|
|
|
private final ConfigPhysicalToolService configPhysicalToolService;
|
|
|
|
|
|
|
|
|
|
private final DefaultPhysicalIndicatorService defaultPhysicalIndicatorService;
|
|
|
|
|
|
|
|
|
|
private final DiseasePhysicalService diseasePhysicalService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<ConfigPhysicalToolResVO> queryPhysicalToolList() {
|
|
|
|
|
return configPhysicalToolService.queryPhysicalToolList();
|
|
|
|
@ -29,16 +42,87 @@ public class PhysicalToolManageServiceImpl implements PhysicalToolManageService
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public IPage<ConfigPhysicalTool> queryConfigPhysicalToolPage(String toolName, String type, Integer requireLocation,
|
|
|
|
|
Integer pageNum, Integer pageSize) {
|
|
|
|
|
return configPhysicalToolService.lambdaQuery().like(StrUtil.isNotBlank(toolName),ConfigPhysicalTool::getToolName,toolName)
|
|
|
|
|
.eq(StrUtil.isNotBlank(type),ConfigPhysicalTool::getType,type)
|
|
|
|
|
.eq(ObjectUtil.isNotEmpty(requireLocation),ConfigPhysicalTool::getRequireLocation,requireLocation)
|
|
|
|
|
.page(new Page<>(pageNum,pageSize));
|
|
|
|
|
Integer pageNum, Integer pageSize) {
|
|
|
|
|
return configPhysicalToolService.lambdaQuery().like(StrUtil.isNotBlank(toolName), ConfigPhysicalTool::getToolName, toolName)
|
|
|
|
|
.eq(StrUtil.isNotBlank(type), ConfigPhysicalTool::getType, type)
|
|
|
|
|
.eq(ObjectUtil.isNotEmpty(requireLocation), ConfigPhysicalTool::getRequireLocation, requireLocation)
|
|
|
|
|
.page(new Page<>(pageNum, pageSize));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public PhysicalToolVO queryConfigPhysicalToolDetail(String id) {
|
|
|
|
|
ConfigPhysicalTool configPhysicalTool = configPhysicalToolService.getById(id);
|
|
|
|
|
PhysicalToolVO bean = BeanUtil.toBean(configPhysicalTool, PhysicalToolVO.class);
|
|
|
|
|
List<DefaultPhysicalIndicator> list = defaultPhysicalIndicatorService.lambdaQuery().eq(DefaultPhysicalIndicator::getItemId, id).list();
|
|
|
|
|
if (CollUtil.isNotEmpty(list)) {
|
|
|
|
|
bean.setDefaultPhysicalIndicatorList(list);
|
|
|
|
|
}
|
|
|
|
|
return bean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void saveConfigPhysicalTool(PhysicalToolReqVO physicalToolReqVO) {
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void saveConfigPhysicalTool(PhysicalToolVO physicalToolVO) {
|
|
|
|
|
Assert.notBlank(physicalToolVO.getToolName(), () -> new BusinessException("体格检查工具名称不能为空"));
|
|
|
|
|
Assert.notBlank(physicalToolVO.getType(), () -> new BusinessException("体格检查工具类型不能为空"));
|
|
|
|
|
// 校验,相同类型下,不允许存在相同名称的工具
|
|
|
|
|
Integer nameCount = configPhysicalToolService.lambdaQuery().eq(ConfigPhysicalTool::getType, physicalToolVO.getType())
|
|
|
|
|
.eq(ConfigPhysicalTool::getToolName, physicalToolVO.getToolName()).count();
|
|
|
|
|
if (nameCount > 0) {
|
|
|
|
|
throw new BusinessException("体格检查工具类型:" + physicalToolVO.getType() + " 存在重复名称");
|
|
|
|
|
}
|
|
|
|
|
// 保存体格检查工具
|
|
|
|
|
configPhysicalToolService.save(physicalToolVO);
|
|
|
|
|
// 保存体格检查工具的正常值
|
|
|
|
|
if (CollUtil.isNotEmpty(physicalToolVO.getDefaultPhysicalIndicatorList())) {
|
|
|
|
|
List<DefaultPhysicalIndicator> defaultPhysicalIndicatorList = physicalToolVO.getDefaultPhysicalIndicatorList();
|
|
|
|
|
for (DefaultPhysicalIndicator defaultPhysicalIndicator : defaultPhysicalIndicatorList) {
|
|
|
|
|
defaultPhysicalIndicator.setItemId(physicalToolVO.getId());
|
|
|
|
|
if (physicalToolVO.getRequireLocation() == 1) {
|
|
|
|
|
Assert.notEmpty(defaultPhysicalIndicator.getLocationId(), () -> new BusinessException("需检查位的体格检查项,检查位置不能为空"));
|
|
|
|
|
}
|
|
|
|
|
defaultPhysicalIndicatorService.save(defaultPhysicalIndicator);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void modifyConfigPhysicalTool(PhysicalToolVO physicalToolVO) {
|
|
|
|
|
Assert.notBlank(physicalToolVO.getId(), () -> new BusinessException("体格检查工具ID不能为空"));
|
|
|
|
|
Assert.notBlank(physicalToolVO.getToolName(), () -> new BusinessException("体格检查工具名称不能为空"));
|
|
|
|
|
Assert.notBlank(physicalToolVO.getType(), () -> new BusinessException("体格检查工具类型不能为空"));
|
|
|
|
|
// 校验,相同类型下,不允许存在除这个ID相同名称的工具
|
|
|
|
|
Integer nameCount = configPhysicalToolService.lambdaQuery().eq(ConfigPhysicalTool::getType, physicalToolVO.getType())
|
|
|
|
|
.ne(ConfigPhysicalTool::getId, physicalToolVO.getId())
|
|
|
|
|
.eq(ConfigPhysicalTool::getToolName, physicalToolVO.getToolName()).count();
|
|
|
|
|
if (nameCount > 0) {
|
|
|
|
|
throw new BusinessException("体格检查工具类型:" + physicalToolVO.getType() + " 存在重复名称");
|
|
|
|
|
}
|
|
|
|
|
// 保存体格检查工具的正常值
|
|
|
|
|
if (CollUtil.isNotEmpty(physicalToolVO.getDefaultPhysicalIndicatorList())) {
|
|
|
|
|
List<DefaultPhysicalIndicator> defaultPhysicalIndicatorList = physicalToolVO.getDefaultPhysicalIndicatorList();
|
|
|
|
|
for (DefaultPhysicalIndicator defaultPhysicalIndicator : defaultPhysicalIndicatorList) {
|
|
|
|
|
defaultPhysicalIndicator.setItemId(physicalToolVO.getId());
|
|
|
|
|
if (physicalToolVO.getRequireLocation() == 1) {
|
|
|
|
|
Assert.notEmpty(defaultPhysicalIndicator.getLocationId(), () -> new BusinessException("需检查位的体格检查项,检查位置不能为空"));
|
|
|
|
|
}
|
|
|
|
|
defaultPhysicalIndicatorService.saveOrUpdate(defaultPhysicalIndicator);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void deleteConfigPhysicalTool(String id) {
|
|
|
|
|
// 删除之前,校验这个工具是否在某些地方已经被配置了,如果配置了,就不允许删除
|
|
|
|
|
Integer count = diseasePhysicalService.lambdaQuery().eq(DiseasePhysical::getToolId, id).count();
|
|
|
|
|
if (0 > count) {
|
|
|
|
|
throw new BusinessException("工具已被使用,不允许删除");
|
|
|
|
|
}
|
|
|
|
|
configPhysicalToolService.removeById(id);
|
|
|
|
|
defaultPhysicalIndicatorService.lambdaUpdate().eq(DefaultPhysicalIndicator::getItemId, id).remove();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|