|
@@ -1,5 +1,6 @@
|
|
package org.dromara.web.service.impl;
|
|
package org.dromara.web.service.impl;
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
@@ -9,23 +10,36 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.dromara.system.domain.SysDept;
|
|
|
|
+import org.dromara.system.domain.SysDiseaseLabel;
|
|
import org.dromara.system.domain.SysMenu;
|
|
import org.dromara.system.domain.SysMenu;
|
|
|
|
+import org.dromara.system.domain.SysUser;
|
|
|
|
+import org.dromara.system.domain.vo.SysDiseaseLabelVo;
|
|
import org.dromara.system.domain.vo.SysMenuVo;
|
|
import org.dromara.system.domain.vo.SysMenuVo;
|
|
|
|
+import org.dromara.system.mapper.SysDiseaseLabelMapper;
|
|
import org.dromara.system.mapper.SysMenuMapper;
|
|
import org.dromara.system.mapper.SysMenuMapper;
|
|
|
|
+import org.dromara.system.mapper.SysUserMapper;
|
|
|
|
+import org.dromara.system.service.ISysDiseaseLabelService;
|
|
import org.dromara.web.domain.ConsultantResultTemplate;
|
|
import org.dromara.web.domain.ConsultantResultTemplate;
|
|
import org.dromara.web.domain.ConsultantResultTemplateType;
|
|
import org.dromara.web.domain.ConsultantResultTemplateType;
|
|
import org.dromara.web.domain.NutritionDiagnosis;
|
|
import org.dromara.web.domain.NutritionDiagnosis;
|
|
import org.dromara.web.domain.bo.NutritionDiagnosisBo;
|
|
import org.dromara.web.domain.bo.NutritionDiagnosisBo;
|
|
import org.dromara.web.domain.vo.ConsultantResultTemplateVo;
|
|
import org.dromara.web.domain.vo.ConsultantResultTemplateVo;
|
|
import org.dromara.web.domain.vo.NutritionDiagnosisVo;
|
|
import org.dromara.web.domain.vo.NutritionDiagnosisVo;
|
|
|
|
+import org.dromara.web.domain.vo.TreatmentUserVo;
|
|
import org.dromara.web.mapper.ConsultantResultTemplateMapper;
|
|
import org.dromara.web.mapper.ConsultantResultTemplateMapper;
|
|
import org.dromara.web.mapper.ConsultantResultTemplateTypeMapper;
|
|
import org.dromara.web.mapper.ConsultantResultTemplateTypeMapper;
|
|
import org.dromara.web.mapper.NutritionDiagnosisMapper;
|
|
import org.dromara.web.mapper.NutritionDiagnosisMapper;
|
|
import org.dromara.web.service.INutritionDiagnosisService;
|
|
import org.dromara.web.service.INutritionDiagnosisService;
|
|
|
|
+import org.dromara.web.service.ITreatmentUserService;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
|
|
+import java.net.URLDecoder;
|
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 营养诊断Service业务层处理
|
|
* 营养诊断Service业务层处理
|
|
@@ -40,8 +54,16 @@ public class NutritionDiagnosisServiceImpl implements INutritionDiagnosisService
|
|
|
|
|
|
private final NutritionDiagnosisMapper baseMapper;
|
|
private final NutritionDiagnosisMapper baseMapper;
|
|
|
|
|
|
|
|
+ private final SysUserMapper userMapper;
|
|
|
|
+
|
|
|
|
+ private final SysDiseaseLabelMapper labelMapper;
|
|
|
|
+
|
|
|
|
+ private final ITreatmentUserService treatmentUserService;
|
|
|
|
+
|
|
private final ConsultantResultTemplateMapper templateMapper;
|
|
private final ConsultantResultTemplateMapper templateMapper;
|
|
|
|
|
|
|
|
+ private final ISysDiseaseLabelService diseaseLabelService;
|
|
|
|
+
|
|
private final ConsultantResultTemplateTypeMapper templateTypeMapper;
|
|
private final ConsultantResultTemplateTypeMapper templateTypeMapper;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -52,6 +74,7 @@ public class NutritionDiagnosisServiceImpl implements INutritionDiagnosisService
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public NutritionDiagnosisVo queryById(Long id) {
|
|
public NutritionDiagnosisVo queryById(Long id) {
|
|
|
|
+
|
|
return baseMapper.selectVoById(id);
|
|
return baseMapper.selectVoById(id);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -66,6 +89,33 @@ public class NutritionDiagnosisServiceImpl implements INutritionDiagnosisService
|
|
public TableDataInfo<NutritionDiagnosisVo> queryPageList(NutritionDiagnosisBo bo, PageQuery pageQuery) {
|
|
public TableDataInfo<NutritionDiagnosisVo> queryPageList(NutritionDiagnosisBo bo, PageQuery pageQuery) {
|
|
LambdaQueryWrapper<NutritionDiagnosis> lqw = buildQueryWrapper(bo);
|
|
LambdaQueryWrapper<NutritionDiagnosis> lqw = buildQueryWrapper(bo);
|
|
Page<NutritionDiagnosisVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
Page<NutritionDiagnosisVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
|
|
+ List<SysUser> userList = userMapper.selectList(Wrappers.lambdaQuery(SysUser.class).select(SysUser::getUserId, SysUser::getUserName));
|
|
|
|
+ Map<Long, String> userMap = userList.stream().collect(Collectors.toMap(k1 -> k1.getUserId(), k2 -> String.valueOf(k2.getUserName()), (k1, k2) -> k1));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ List<NutritionDiagnosisVo> records = result.getRecords();
|
|
|
|
+ if (CollUtil.isNotEmpty(records)) {
|
|
|
|
+ String labelIdsStr = null;
|
|
|
|
+ List<String> labelNames = null;
|
|
|
|
+ for (NutritionDiagnosisVo record : records) {
|
|
|
|
+ record.setCreateByUser(userMap.get(record.getCreateBy()));
|
|
|
|
+ labelIdsStr = record.getDiagnosisLableId();
|
|
|
|
+ // 处理产品标签
|
|
|
|
+ if (StringUtils.isNotBlank(labelIdsStr)) {
|
|
|
|
+ labelNames = Arrays.stream(labelIdsStr.split(",")).map(String::trim).filter(StringUtils::isNotBlank).map(labelid -> {
|
|
|
|
+ try {
|
|
|
|
+ return diseaseLabelService.queryById(Long.parseLong(labelid));
|
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ }).filter(Objects::nonNull).map(SysDiseaseLabelVo::getLabelName).filter(StringUtils::isNotBlank).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ if (!labelNames.isEmpty()) {
|
|
|
|
+ record.setDiagnosisLabelStr(String.join(",", labelNames));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return TableDataInfo.build(result);
|
|
return TableDataInfo.build(result);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -83,13 +133,22 @@ public class NutritionDiagnosisServiceImpl implements INutritionDiagnosisService
|
|
|
|
|
|
private LambdaQueryWrapper<NutritionDiagnosis> buildQueryWrapper(NutritionDiagnosisBo bo) {
|
|
private LambdaQueryWrapper<NutritionDiagnosis> buildQueryWrapper(NutritionDiagnosisBo bo) {
|
|
Map<String, Object> params = bo.getParams();
|
|
Map<String, Object> params = bo.getParams();
|
|
|
|
+ List<Date> dateRange = bo.getDateRange();
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
LambdaQueryWrapper<NutritionDiagnosis> lqw = Wrappers.lambdaQuery();
|
|
LambdaQueryWrapper<NutritionDiagnosis> lqw = Wrappers.lambdaQuery();
|
|
lqw.orderByAsc(NutritionDiagnosis::getId);
|
|
lqw.orderByAsc(NutritionDiagnosis::getId);
|
|
lqw.eq(bo.getTreatmentUserId() != null, NutritionDiagnosis::getTreatmentUserId, bo.getTreatmentUserId());
|
|
lqw.eq(bo.getTreatmentUserId() != null, NutritionDiagnosis::getTreatmentUserId, bo.getTreatmentUserId());
|
|
- lqw.eq(bo.getConsultantTemplateId() != null, NutritionDiagnosis::getConsultantTemplateId, bo.getConsultantTemplateId());
|
|
|
|
- lqw.eq(StringUtils.isNotBlank(bo.getDiagnosisLableId()), NutritionDiagnosis::getDiagnosisLableId, bo.getDiagnosisLableId());
|
|
|
|
- lqw.eq(StringUtils.isNotBlank(bo.getDiagnosisBasisId()), NutritionDiagnosis::getDiagnosisBasisId, bo.getDiagnosisBasisId());
|
|
|
|
- lqw.eq(StringUtils.isNotBlank(bo.getMedicalOrder()), NutritionDiagnosis::getMedicalOrder, bo.getMedicalOrder());
|
|
|
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getType()), NutritionDiagnosis::getType, bo.getType());
|
|
|
|
+ lqw.like(StringUtils.isNotBlank(bo.getSearchValue()), NutritionDiagnosis::getOutpatientNo, bo.getSearchValue());
|
|
|
|
+
|
|
|
|
+ if (dateRange != null && dateRange.size() == 2) {
|
|
|
|
+ String startTime = sdf.format(dateRange.get(0)) + " 00:00:00"; // 开始时间
|
|
|
|
+ String endTime = sdf.format(dateRange.get(1)) + " 23:59:59"; // 结束时间
|
|
|
|
+ if (StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)) {
|
|
|
|
+ lqw.between(NutritionDiagnosis::getCreateTime, startTime, endTime);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return lqw;
|
|
return lqw;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -101,6 +160,16 @@ public class NutritionDiagnosisServiceImpl implements INutritionDiagnosisService
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public Boolean insertByBo(NutritionDiagnosisBo bo) {
|
|
public Boolean insertByBo(NutritionDiagnosisBo bo) {
|
|
|
|
+ bo.setDiagnosisLableId(String.join(",", bo.getLabelList()));
|
|
|
|
+ Long treatmentUserId = bo.getTreatmentUserId();
|
|
|
|
+ if (null != treatmentUserId) {
|
|
|
|
+ TreatmentUserVo treatmentUserVo = treatmentUserService.queryById(treatmentUserId);
|
|
|
|
+ if (null != treatmentUserVo) {
|
|
|
|
+ bo.setType(treatmentUserVo.getType());
|
|
|
|
+ bo.setOutpatientNo(treatmentUserVo.getOutpatientNo());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ bo.setConsultantResult(URLDecoder.decode(new String(Base64.getDecoder().decode(bo.getConsultantResultStr()), StandardCharsets.UTF_8)));
|
|
NutritionDiagnosis add = MapstructUtils.convert(bo, NutritionDiagnosis.class);
|
|
NutritionDiagnosis add = MapstructUtils.convert(bo, NutritionDiagnosis.class);
|
|
validEntityBeforeSave(add);
|
|
validEntityBeforeSave(add);
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
@@ -118,6 +187,8 @@ public class NutritionDiagnosisServiceImpl implements INutritionDiagnosisService
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public Boolean updateByBo(NutritionDiagnosisBo bo) {
|
|
public Boolean updateByBo(NutritionDiagnosisBo bo) {
|
|
|
|
+ bo.setDiagnosisLableId(String.join(",", bo.getLabelList()));
|
|
|
|
+ bo.setConsultantResult(URLDecoder.decode(new String(Base64.getDecoder().decode(bo.getConsultantResultStr()), StandardCharsets.UTF_8)));
|
|
NutritionDiagnosis update = MapstructUtils.convert(bo, NutritionDiagnosis.class);
|
|
NutritionDiagnosis update = MapstructUtils.convert(bo, NutritionDiagnosis.class);
|
|
validEntityBeforeSave(update);
|
|
validEntityBeforeSave(update);
|
|
return baseMapper.updateById(update) > 0;
|
|
return baseMapper.updateById(update) > 0;
|
|
@@ -171,6 +242,7 @@ public class NutritionDiagnosisServiceImpl implements INutritionDiagnosisService
|
|
List<Map<String, Object>> templateChildren = new ArrayList<>();
|
|
List<Map<String, Object>> templateChildren = new ArrayList<>();
|
|
for (ConsultantResultTemplateVo template : templates) {
|
|
for (ConsultantResultTemplateVo template : templates) {
|
|
Map<String, Object> templateNode = new HashMap<>();
|
|
Map<String, Object> templateNode = new HashMap<>();
|
|
|
|
+ templateNode.put("id", template.getId()); // 模板名称
|
|
templateNode.put("label", template.getTemplateName()); // 模板名称
|
|
templateNode.put("label", template.getTemplateName()); // 模板名称
|
|
templateNode.put("template", template.getContent());
|
|
templateNode.put("template", template.getContent());
|
|
templateChildren.add(templateNode);
|
|
templateChildren.add(templateNode);
|