|
@@ -1,5 +1,14 @@
|
|
package org.dromara.system.service.impl;
|
|
package org.dromara.system.service.impl;
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
|
+import cn.hutool.core.util.NumberUtil;
|
|
|
|
+import cn.hutool.core.util.ObjUtil;
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
+import com.alibaba.fastjson.TypeReference;
|
|
|
|
+import org.dromara.common.core.constant.BizConst;
|
|
|
|
+import org.dromara.common.core.enums.PaymentStatus;
|
|
|
|
+import org.dromara.common.core.exception.ServiceException;
|
|
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,6 +18,14 @@ 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.SysScreeningAssessmentConfig;
|
|
|
|
+import org.dromara.system.domain.SysUser;
|
|
|
|
+import org.dromara.system.domain.bo.SysScreeningAssessmentConfigBo;
|
|
|
|
+import org.dromara.system.domain.bo.SysScreeningAssessmentQuestionBo;
|
|
|
|
+import org.dromara.system.domain.vo.SysDictDataVo;
|
|
|
|
+import org.dromara.system.mapper.SysScreeningAssessmentConfigMapper;
|
|
|
|
+import org.dromara.system.mapper.SysUserMapper;
|
|
|
|
+import org.dromara.system.service.ISysDictDataService;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.dromara.system.domain.bo.NutritionScreeningBo;
|
|
import org.dromara.system.domain.bo.NutritionScreeningBo;
|
|
import org.dromara.system.domain.vo.NutritionScreeningVo;
|
|
import org.dromara.system.domain.vo.NutritionScreeningVo;
|
|
@@ -16,9 +33,13 @@ import org.dromara.system.domain.NutritionScreening;
|
|
import org.dromara.system.mapper.NutritionScreeningMapper;
|
|
import org.dromara.system.mapper.NutritionScreeningMapper;
|
|
import org.dromara.system.service.INutritionScreeningService;
|
|
import org.dromara.system.service.INutritionScreeningService;
|
|
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.Collection;
|
|
import java.util.Collection;
|
|
|
|
+import java.util.Set;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 营养筛查Service业务层处理
|
|
* 营养筛查Service业务层处理
|
|
@@ -32,6 +53,9 @@ import java.util.Collection;
|
|
public class NutritionScreeningServiceImpl implements INutritionScreeningService {
|
|
public class NutritionScreeningServiceImpl implements INutritionScreeningService {
|
|
|
|
|
|
private final NutritionScreeningMapper baseMapper;
|
|
private final NutritionScreeningMapper baseMapper;
|
|
|
|
+ private final SysScreeningAssessmentConfigMapper configMapper;
|
|
|
|
+ private final ISysDictDataService dataService;
|
|
|
|
+ private final SysUserMapper userMapper;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 查询营养筛查
|
|
* 查询营养筛查
|
|
@@ -40,7 +64,7 @@ public class NutritionScreeningServiceImpl implements INutritionScreeningService
|
|
* @return 营养筛查
|
|
* @return 营养筛查
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public NutritionScreeningVo queryById(Long id){
|
|
|
|
|
|
+ public NutritionScreeningVo queryById(Long id) {
|
|
return baseMapper.selectVoById(id);
|
|
return baseMapper.selectVoById(id);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -55,6 +79,35 @@ public class NutritionScreeningServiceImpl implements INutritionScreeningService
|
|
public TableDataInfo<NutritionScreeningVo> queryPageList(NutritionScreeningBo bo, PageQuery pageQuery) {
|
|
public TableDataInfo<NutritionScreeningVo> queryPageList(NutritionScreeningBo bo, PageQuery pageQuery) {
|
|
LambdaQueryWrapper<NutritionScreening> lqw = buildQueryWrapper(bo);
|
|
LambdaQueryWrapper<NutritionScreening> lqw = buildQueryWrapper(bo);
|
|
Page<NutritionScreeningVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
Page<NutritionScreeningVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
|
|
+
|
|
|
|
+ if (CollUtil.isNotEmpty(result.getRecords())) {
|
|
|
|
+ Set<Long> userList = CollUtil.newHashSet();
|
|
|
|
+ Set<Long> configList = CollUtil.newHashSet();
|
|
|
|
+ result.getRecords().forEach(v -> {
|
|
|
|
+ userList.add(v.getCreateBy());
|
|
|
|
+ configList.add(v.getConfigId());
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ Map<Long, String> userMap = userMapper.selectList(Wrappers.lambdaQuery(SysUser.class)
|
|
|
|
+ .select(SysUser::getUserId, SysUser::getNickName)
|
|
|
|
+ .in(SysUser::getUserId, userList)).stream().collect(Collectors.toMap(k1 -> k1.getUserId(), k2 -> k2.getNickName(), (k1, k2) -> k1));
|
|
|
|
+
|
|
|
|
+ Map<Long, String> configMap = configMapper.selectList(Wrappers.lambdaQuery(SysScreeningAssessmentConfig.class)
|
|
|
|
+ .select(SysScreeningAssessmentConfig::getConfigId, SysScreeningAssessmentConfig::getName)
|
|
|
|
+ .in(SysScreeningAssessmentConfig::getConfigId, configList))
|
|
|
|
+ .stream().collect(Collectors.toMap(k1 -> k1.getConfigId(), k2 -> k2.getName(), (k1, k2) -> k1));
|
|
|
|
+ Map<String, List<SysDictDataVo>> dictMap = dataService.selectGroupByType(List.of(BizConst.PAYMENT_STATUS, BizConst.TREATMENT_USER_TYPE)).getData();
|
|
|
|
+
|
|
|
|
+ Map<String, String> paymentMap = dictMap.get(BizConst.PAYMENT_STATUS).stream().collect(Collectors.toMap(k1 -> k1.getDictValue(), k2 -> k2.getDictLabel(), (k1, k2) -> k1));
|
|
|
|
+ Map<String, String> checkMap = dictMap.get(BizConst.TREATMENT_USER_TYPE).stream().collect(Collectors.toMap(k1 -> k1.getDictValue(), k2 -> k2.getDictLabel(), (k1, k2) -> k1));
|
|
|
|
+ result.getRecords().forEach(v -> {
|
|
|
|
+ v.setVisitType(checkMap.get(v.getVisitType()));
|
|
|
|
+ v.setPaymentStatus(paymentMap.get(v.getPaymentStatus()));
|
|
|
|
+ v.setConfigName(configMap.get(v.getConfigId()));
|
|
|
|
+ v.setCreateByName(userMap.get(v.getCreateBy()));
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
return TableDataInfo.build(result);
|
|
return TableDataInfo.build(result);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -73,6 +126,9 @@ public class NutritionScreeningServiceImpl implements INutritionScreeningService
|
|
private LambdaQueryWrapper<NutritionScreening> buildQueryWrapper(NutritionScreeningBo bo) {
|
|
private LambdaQueryWrapper<NutritionScreening> buildQueryWrapper(NutritionScreeningBo bo) {
|
|
Map<String, Object> params = bo.getParams();
|
|
Map<String, Object> params = bo.getParams();
|
|
LambdaQueryWrapper<NutritionScreening> lqw = Wrappers.lambdaQuery();
|
|
LambdaQueryWrapper<NutritionScreening> lqw = Wrappers.lambdaQuery();
|
|
|
|
+ lqw.select(NutritionScreening::getId, NutritionScreening::getConfigId, NutritionScreening::getScreeningTime,
|
|
|
|
+ NutritionScreening::getVisitType, NutritionScreening::getPatientNo, NutritionScreening::getScreeningScore,
|
|
|
|
+ NutritionScreening::getScreeningConclusion, NutritionScreening::getPaymentStatus, NutritionScreening::getCreateBy);
|
|
lqw.orderByDesc(NutritionScreening::getId);
|
|
lqw.orderByDesc(NutritionScreening::getId);
|
|
lqw.eq(bo.getPatientId() != null, NutritionScreening::getPatientId, bo.getPatientId());
|
|
lqw.eq(bo.getPatientId() != null, NutritionScreening::getPatientId, bo.getPatientId());
|
|
lqw.eq(bo.getConfigId() != null, NutritionScreening::getConfigId, bo.getConfigId());
|
|
lqw.eq(bo.getConfigId() != null, NutritionScreening::getConfigId, bo.getConfigId());
|
|
@@ -96,7 +152,42 @@ public class NutritionScreeningServiceImpl implements INutritionScreeningService
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public Boolean insertByBo(NutritionScreeningBo bo) {
|
|
public Boolean insertByBo(NutritionScreeningBo bo) {
|
|
|
|
+ if (StrUtil.isBlank(bo.getContent())) {
|
|
|
|
+ throw new ServiceException("提交的“营养筛查”不能为空!");
|
|
|
|
+ }
|
|
|
|
+ SysScreeningAssessmentConfigBo configBo = JSON.parseObject(bo.getContent(), new TypeReference<SysScreeningAssessmentConfigBo>() {
|
|
|
|
+ });
|
|
|
|
+ if (CollUtil.isEmpty(configBo.getOtherInfo())) {
|
|
|
|
+ throw new ServiceException("没有任何“营养筛查”!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ BigDecimal total = BigDecimal.ZERO;
|
|
|
|
+ for (SysScreeningAssessmentQuestionBo questionBo : configBo.getOtherInfo()) {
|
|
|
|
+ if (ObjUtil.isNull(questionBo.getValue())) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<Integer> valueList = CollUtil.newArrayList();
|
|
|
|
+ String obj = String.valueOf(questionBo.getValue());
|
|
|
|
+ if (NumberUtil.isNumber(obj)) {
|
|
|
|
+ valueList.add(Integer.valueOf(obj));
|
|
|
|
+ } else {
|
|
|
|
+ List objList = (List) questionBo.getValue();
|
|
|
|
+ objList.forEach(v -> valueList.add(Integer.valueOf(String.valueOf(v))));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (Integer index : valueList) {
|
|
|
|
+ SysScreeningAssessmentQuestionBo.QuestionAttrBo attrBo = questionBo.getContentList().get(index);
|
|
|
|
+ if (StrUtil.isNotBlank(attrBo.getScore()) && NumberUtil.isNumber(attrBo.getScore())) {
|
|
|
|
+ total = total.add(new BigDecimal(attrBo.getScore()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
NutritionScreening add = MapstructUtils.convert(bo, NutritionScreening.class);
|
|
NutritionScreening add = MapstructUtils.convert(bo, NutritionScreening.class);
|
|
|
|
+ add.setScreeningScore(NumberUtil.round(total.toString(), 2));
|
|
|
|
+ add.setScreeningTime(new Date());
|
|
|
|
+ add.setPaymentStatus(PaymentStatus.PAID.getCode());
|
|
validEntityBeforeSave(add);
|
|
validEntityBeforeSave(add);
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
if (flag) {
|
|
if (flag) {
|
|
@@ -121,7 +212,7 @@ public class NutritionScreeningServiceImpl implements INutritionScreeningService
|
|
/**
|
|
/**
|
|
* 保存前的数据校验
|
|
* 保存前的数据校验
|
|
*/
|
|
*/
|
|
- private void validEntityBeforeSave(NutritionScreening entity){
|
|
|
|
|
|
+ private void validEntityBeforeSave(NutritionScreening entity) {
|
|
//TODO 做一些数据校验,如唯一约束
|
|
//TODO 做一些数据校验,如唯一约束
|
|
}
|
|
}
|
|
|
|
|
|
@@ -134,7 +225,7 @@ public class NutritionScreeningServiceImpl implements INutritionScreeningService
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
- if(isValid){
|
|
|
|
|
|
+ if (isValid) {
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
|
}
|
|
}
|
|
return baseMapper.deleteByIds(ids) > 0;
|
|
return baseMapper.deleteByIds(ids) > 0;
|