|
@@ -1,5 +1,10 @@
|
|
package org.dromara.web.service.impl;
|
|
package org.dromara.web.service.impl;
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
|
+import org.dromara.common.core.constant.BizConst;
|
|
|
|
+import org.dromara.common.core.enums.biz.CheckStatus;
|
|
|
|
+import org.dromara.common.core.enums.biz.FeeType;
|
|
|
|
+import org.dromara.common.core.enums.biz.PaymentStatus;
|
|
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,16 +14,28 @@ 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.SysUser;
|
|
|
|
+import org.dromara.system.mapper.SysDeptMapper;
|
|
|
|
+import org.dromara.system.mapper.SysUserMapper;
|
|
|
|
+import org.dromara.web.domain.EnteralNutrition;
|
|
|
|
+import org.dromara.web.domain.NutritionEvaluation;
|
|
|
|
+import org.dromara.web.domain.NutritionScreening;
|
|
import org.dromara.web.domain.Settlement;
|
|
import org.dromara.web.domain.Settlement;
|
|
import org.dromara.web.domain.bo.SettlementBo;
|
|
import org.dromara.web.domain.bo.SettlementBo;
|
|
|
|
+import org.dromara.web.domain.vo.EnteralNutritionVo;
|
|
|
|
+import org.dromara.web.domain.vo.NutritionEvaluationVo;
|
|
|
|
+import org.dromara.web.domain.vo.NutritionScreeningVo;
|
|
import org.dromara.web.domain.vo.SettlementVo;
|
|
import org.dromara.web.domain.vo.SettlementVo;
|
|
|
|
+import org.dromara.web.mapper.EnteralNutritionMapper;
|
|
|
|
+import org.dromara.web.mapper.NutritionEvaluationMapper;
|
|
|
|
+import org.dromara.web.mapper.NutritionScreeningMapper;
|
|
import org.dromara.web.mapper.SettlementMapper;
|
|
import org.dromara.web.mapper.SettlementMapper;
|
|
import org.dromara.web.service.ISettlementService;
|
|
import org.dromara.web.service.ISettlementService;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
-import java.util.Collection;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 结算管理Service业务层处理
|
|
* 结算管理Service业务层处理
|
|
@@ -33,6 +50,16 @@ public class SettlementServiceImpl implements ISettlementService {
|
|
|
|
|
|
private final SettlementMapper baseMapper;
|
|
private final SettlementMapper baseMapper;
|
|
|
|
|
|
|
|
+ private final SysDeptMapper deptMapper;
|
|
|
|
+
|
|
|
|
+ private final SysUserMapper userMapper;
|
|
|
|
+
|
|
|
|
+ private final EnteralNutritionMapper enteralNutritionMapper;
|
|
|
|
+
|
|
|
|
+ private final NutritionEvaluationMapper evaluationMapper;
|
|
|
|
+
|
|
|
|
+ private final NutritionScreeningMapper screeningMapper;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 查询结算管理
|
|
* 查询结算管理
|
|
*
|
|
*
|
|
@@ -41,7 +68,27 @@ public class SettlementServiceImpl implements ISettlementService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public SettlementVo queryById(Long id) {
|
|
public SettlementVo queryById(Long id) {
|
|
- return baseMapper.selectVoById(id);
|
|
|
|
|
|
+ SettlementVo settlementVo = baseMapper.selectVoById(id);
|
|
|
|
+ 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));
|
|
|
|
+ if (null != settlementVo) {
|
|
|
|
+ List<EnteralNutritionVo> enteralNutritionVoList = enteralNutritionMapper.selectVoList(new LambdaQueryWrapper<EnteralNutrition>().eq(EnteralNutrition::getSettlementId, settlementVo.getId()));
|
|
|
|
+ enteralNutritionVoList.forEach(v->{
|
|
|
|
+ v.setCreateByName(userMap.get(v.getCreateBy()));
|
|
|
|
+ });
|
|
|
|
+ settlementVo.setEnteralNutritionList(enteralNutritionVoList);
|
|
|
|
+ List<NutritionScreeningVo> nutritionScreeningVos = screeningMapper.selectVoList(new LambdaQueryWrapper<NutritionScreening>().eq(NutritionScreening::getSettlementId, settlementVo.getId()));
|
|
|
|
+ nutritionScreeningVos.forEach(v->{
|
|
|
|
+ v.setCreateByName(userMap.get(v.getCreateBy()));
|
|
|
|
+ });
|
|
|
|
+ settlementVo.setNutritionScreeningList(nutritionScreeningVos);
|
|
|
|
+ List<NutritionEvaluationVo> nutritionEvaluationVos = evaluationMapper.selectVoList(new LambdaQueryWrapper<NutritionEvaluation>().eq(NutritionEvaluation::getSettlementId, settlementVo.getId()));
|
|
|
|
+ nutritionEvaluationVos.forEach(v->{
|
|
|
|
+ v.setCreateByName(userMap.get(v.getCreateBy()));
|
|
|
|
+ });
|
|
|
|
+ settlementVo.setNutritionEvaluationList(nutritionEvaluationVos);
|
|
|
|
+ }
|
|
|
|
+ return settlementVo;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -55,6 +102,19 @@ public class SettlementServiceImpl implements ISettlementService {
|
|
public TableDataInfo<SettlementVo> queryPageList(SettlementBo bo, PageQuery pageQuery) {
|
|
public TableDataInfo<SettlementVo> queryPageList(SettlementBo bo, PageQuery pageQuery) {
|
|
LambdaQueryWrapper<Settlement> lqw = buildQueryWrapper(bo);
|
|
LambdaQueryWrapper<Settlement> lqw = buildQueryWrapper(bo);
|
|
Page<SettlementVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
Page<SettlementVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
|
|
+ List<SettlementVo> records = result.getRecords();
|
|
|
|
+ if (CollUtil.isNotEmpty(records)) {
|
|
|
|
+ Set<Long> deptList = CollUtil.newHashSet();
|
|
|
|
+ records.forEach(v -> {
|
|
|
|
+ deptList.add(v.getDoorId());
|
|
|
|
+ });
|
|
|
|
+ Map<Long, String> deptMap = deptMapper.selectList(Wrappers.lambdaQuery(SysDept.class)
|
|
|
|
+ .select(SysDept::getDeptId, SysDept::getDeptName)
|
|
|
|
+ .in(SysDept::getDeptId, deptList)).stream().collect(Collectors.toMap(k1 -> k1.getDeptId(), k2 -> k2.getDeptName(), (k1, k2) -> k1));
|
|
|
|
+ records.forEach(v -> {
|
|
|
|
+ v.setPatientDepartment(deptMap.get(v.getDoorId()));
|
|
|
|
+ });
|
|
|
|
+ }
|
|
return TableDataInfo.build(result);
|
|
return TableDataInfo.build(result);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -78,14 +138,14 @@ public class SettlementServiceImpl implements ISettlementService {
|
|
lqw.eq(StringUtils.isNotBlank(bo.getVisitType()), Settlement::getVisitType, bo.getVisitType());
|
|
lqw.eq(StringUtils.isNotBlank(bo.getVisitType()), Settlement::getVisitType, bo.getVisitType());
|
|
lqw.eq(StringUtils.isNotBlank(bo.getChargeType()), Settlement::getChargeType, bo.getChargeType());
|
|
lqw.eq(StringUtils.isNotBlank(bo.getChargeType()), Settlement::getChargeType, bo.getChargeType());
|
|
lqw.eq(bo.getPatientId() != null, Settlement::getPatientId, bo.getPatientId());
|
|
lqw.eq(bo.getPatientId() != null, Settlement::getPatientId, bo.getPatientId());
|
|
|
|
+ lqw.eq(bo.getDoorId() != null, Settlement::getDoorId, bo.getDoorId());
|
|
lqw.like(StringUtils.isNotBlank(bo.getPatientName()), Settlement::getPatientName, bo.getPatientName());
|
|
lqw.like(StringUtils.isNotBlank(bo.getPatientName()), Settlement::getPatientName, bo.getPatientName());
|
|
lqw.eq(StringUtils.isNotBlank(bo.getPatientNo()), Settlement::getPatientNo, bo.getPatientNo());
|
|
lqw.eq(StringUtils.isNotBlank(bo.getPatientNo()), Settlement::getPatientNo, bo.getPatientNo());
|
|
- lqw.eq(StringUtils.isNotBlank(bo.getPhone()), Settlement::getPhone, bo.getPhone());
|
|
|
|
- lqw.eq(StringUtils.isNotBlank(bo.getIdCard()), Settlement::getIdCard, bo.getIdCard());
|
|
|
|
lqw.eq(bo.getReceivableAmount() != null, Settlement::getReceivableAmount, bo.getReceivableAmount());
|
|
lqw.eq(bo.getReceivableAmount() != null, Settlement::getReceivableAmount, bo.getReceivableAmount());
|
|
lqw.eq(StringUtils.isNotBlank(bo.getPaymentStatus()), Settlement::getPaymentStatus, bo.getPaymentStatus());
|
|
lqw.eq(StringUtils.isNotBlank(bo.getPaymentStatus()), Settlement::getPaymentStatus, bo.getPaymentStatus());
|
|
lqw.eq(StringUtils.isNotBlank(bo.getPaymentMethod()), Settlement::getPaymentMethod, bo.getPaymentMethod());
|
|
lqw.eq(StringUtils.isNotBlank(bo.getPaymentMethod()), Settlement::getPaymentMethod, bo.getPaymentMethod());
|
|
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), Settlement::getStatus, bo.getStatus());
|
|
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), Settlement::getStatus, bo.getStatus());
|
|
|
|
+ lqw.eq(Settlement::getCheckStatus, CheckStatus.STATUS_TWO.getCode());//结算管理查询已经审核通过的处方
|
|
return lqw;
|
|
return lqw;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -119,6 +179,72 @@ public class SettlementServiceImpl implements ISettlementService {
|
|
return baseMapper.updateById(update) > 0;
|
|
return baseMapper.updateById(update) > 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public TableDataInfo<SettlementVo> queryCheckRecipePageList(SettlementBo bo, PageQuery pageQuery) {
|
|
|
|
+ LambdaQueryWrapper<Settlement> lqw = buildCheckRecipeQueryWrapper(bo);
|
|
|
|
+ Page<SettlementVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
|
|
+ List<SettlementVo> records = result.getRecords();
|
|
|
|
+ if (CollUtil.isNotEmpty(records)) {
|
|
|
|
+ Set<Long> deptList = CollUtil.newHashSet();
|
|
|
|
+ Set<Long> userList = CollUtil.newHashSet();
|
|
|
|
+ records.forEach(v -> {
|
|
|
|
+ deptList.add(v.getDoorId());
|
|
|
|
+ userList.add(v.getCreateBy());
|
|
|
|
+ });
|
|
|
|
+ Map<Long, String> deptMap = deptMapper.selectList(Wrappers.lambdaQuery(SysDept.class)
|
|
|
|
+ .select(SysDept::getDeptId, SysDept::getDeptName)
|
|
|
|
+ .in(SysDept::getDeptId, deptList)).stream().collect(Collectors.toMap(k1 -> k1.getDeptId(), k2 -> k2.getDeptName(), (k1, k2) -> k1));
|
|
|
|
+
|
|
|
|
+ Map<Long, String> userMap = userMapper.selectList(Wrappers.lambdaQuery(SysUser.class)
|
|
|
|
+ .select(SysUser::getUserId, SysUser::getUserName)
|
|
|
|
+ .in(SysUser::getUserId, userList)).stream().collect(Collectors.toMap(k1 -> k1.getUserId(), k2 -> k2.getUserName(), (k1, k2) -> k1));
|
|
|
|
+ List<EnteralNutritionVo> enteralNutritionVoList = null;
|
|
|
|
+ for (SettlementVo record : records) {
|
|
|
|
+ enteralNutritionVoList = enteralNutritionMapper.selectVoList(new LambdaQueryWrapper<EnteralNutrition>().eq(EnteralNutrition::getSettlementId, record.getId()));
|
|
|
|
+ String recipeDetail = enteralNutritionVoList.stream()
|
|
|
|
+ .map(EnteralNutritionVo::getNutritionProduct) // 获取每个对象的nutritionProduct字段
|
|
|
|
+ .filter(product -> product != null) // 过滤掉空值
|
|
|
|
+ .collect(Collectors.joining(", ")); // 用逗号和空格拼接
|
|
|
|
+
|
|
|
|
+ record.setPatientDepartment(deptMap.get(record.getDoorId()));
|
|
|
|
+ record.setRecipeDetail(recipeDetail);
|
|
|
|
+ record.setCreateByUser(userMap.get(record.getCreateBy()));
|
|
|
|
+// record.setUpdateByUser(userMap.get(record.getUpdateBy()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return TableDataInfo.build(result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询符合条件的结算管理列表
|
|
|
|
+ *
|
|
|
|
+ * @param bo 查询条件
|
|
|
|
+ * @return 结算管理列表
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public List<SettlementVo> queryCheckRecipeList(SettlementBo bo) {
|
|
|
|
+ LambdaQueryWrapper<Settlement> lqw = buildCheckRecipeQueryWrapper(bo);
|
|
|
|
+ return baseMapper.selectVoList(lqw);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private LambdaQueryWrapper<Settlement> buildCheckRecipeQueryWrapper(SettlementBo bo) {
|
|
|
|
+ Map<String, Object> params = bo.getParams();
|
|
|
|
+ LambdaQueryWrapper<Settlement> lqw = Wrappers.lambdaQuery();
|
|
|
|
+ lqw.orderByDesc(Settlement::getCreateTime);
|
|
|
|
+ lqw.eq(bo.getOrderTime() != null, Settlement::getOrderTime, bo.getOrderTime());
|
|
|
|
+ lqw.eq(bo.getCheckStatus() != null && !CheckStatus.STATUS_NINE.getCode().equals(bo.getCheckStatus()), Settlement::getCheckStatus, bo.getCheckStatus());
|
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getVisitType()), Settlement::getVisitType, bo.getVisitType());
|
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getChargeType()), Settlement::getChargeType, bo.getChargeType());
|
|
|
|
+ lqw.eq(bo.getDoorId() != null, Settlement::getDoorId, bo.getDoorId());
|
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getPatientNo()), Settlement::getPatientNo, bo.getPatientNo());
|
|
|
|
+ lqw.eq(Settlement::getStatus, PaymentStatus.UNPAID.getCode());
|
|
|
|
+ lqw.in(Settlement::getChargeType,
|
|
|
|
+ FeeType.PRE_PACKAGED_PRESCRIPTION.getCode(),
|
|
|
|
+ FeeType.CONFIGURE_PRESCRIPTION.getCode(),
|
|
|
|
+ FeeType.LONG_TERM_PRESCRIPTION.getCode());
|
|
|
|
+ return lqw;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 保存前的数据校验
|
|
* 保存前的数据校验
|
|
*/
|
|
*/
|