|
@@ -0,0 +1,189 @@
|
|
|
|
+package org.dromara.web.service.impl;
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import com.google.common.collect.Lists;
|
|
|
|
+
|
|
|
|
+import java.util.*;
|
|
|
|
+
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.dromara.common.core.domain.R;
|
|
|
|
+import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
|
+import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
|
+import org.dromara.system.mapper.*;
|
|
|
|
+import org.dromara.web.domain.*;
|
|
|
|
+import org.dromara.web.domain.bo.*;
|
|
|
|
+import org.dromara.web.domain.vo.CookbookVo;
|
|
|
|
+import org.dromara.web.domain.vo.DietaryPrescriptionVo;
|
|
|
|
+import org.dromara.web.domain.vo.MealPeriodVo;
|
|
|
|
+import org.dromara.web.mapper.*;
|
|
|
|
+import org.dromara.web.service.ReportService;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+
|
|
|
|
+import java.sql.Timestamp;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @Author: Huanyi
|
|
|
|
+ * @CreateTime: 2025-08-18
|
|
|
|
+ * @Description:
|
|
|
|
+ * @Version: 1.0
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+@Service
|
|
|
|
+@RequiredArgsConstructor
|
|
|
|
+@Slf4j
|
|
|
|
+public class ReportServiceImpl implements ReportService {
|
|
|
|
+
|
|
|
|
+ private final DailyMealPlanMapper dailyMealPlanMapper;
|
|
|
|
+ private final DailyMealRecipeMapper dailyMealRecipeMapper;
|
|
|
|
+ private final HospitalMealPlanMapper hospitalMealPlanMapper;
|
|
|
|
+ private final HospitalMealRecipeMapper hospitalMealRecipeMapper;
|
|
|
|
+ private final SysRecipeMapper sysRecipeMapper;
|
|
|
|
+ private final SysRecipeFoodIngredientMapper sysRecipeFoodIngredientMapper;
|
|
|
|
+ private final SysFoodIngredientMapper sysFoodIngredientMapper;
|
|
|
|
+ private final TreatmentUserMapper treatmentUserMapper;
|
|
|
|
+ private final SysDeptMapper sysDeptMapper;
|
|
|
|
+ private final SysUserMapper sysUserMapper;
|
|
|
|
+ private final SettlementMapper settlementMapper;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public R getNutritionalQualityControl(Timestamp start, Timestamp end) {
|
|
|
|
+ return R.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public TableDataInfo listPageDietaryPrescription(DietaryPrescriptionBo bo, PageQuery pageQuery) {
|
|
|
|
+
|
|
|
|
+// hospitalMealPlanMapper.listPageMealPlan(
|
|
|
|
+// bo.getTradeDateEarliest(),
|
|
|
|
+// bo.getTradeDateLatest(),
|
|
|
|
+// bo.getCalculationDateEarliest(),
|
|
|
|
+// bo.getCalculationDateLatest(),
|
|
|
|
+// bo.getDoctorDepartmentId(),
|
|
|
|
+// bo.getPatientDepartmentId(),
|
|
|
|
+// bo.getName(),
|
|
|
|
+// bo.getConsultationType(),
|
|
|
|
+// pageQuery.getPageNum(),
|
|
|
|
+// pageQuery.getPageSize()
|
|
|
|
+// );
|
|
|
|
+ List<Long> ids = new ArrayList<>();
|
|
|
|
+ treatmentUserMapper.selectList(
|
|
|
|
+ Wrappers.lambdaQuery(TreatmentUser.class).like(TreatmentUser::getTreatName, bo.getName())
|
|
|
|
+ ).forEach(e -> ids.add(e.getId()));
|
|
|
|
+
|
|
|
|
+ Page<HospitalMealPlan> page = hospitalMealPlanMapper.selectPage(
|
|
|
|
+ pageQuery.build(),
|
|
|
|
+ Wrappers.lambdaQuery(HospitalMealPlan.class)
|
|
|
|
+ .ge(HospitalMealPlan::getCreateTime, bo.getCalculationDateEarliest())
|
|
|
|
+ .le(HospitalMealPlan::getCreateTime, bo.getCalculationDateLatest())
|
|
|
|
+ .in(HospitalMealPlan::getPatientId, ids)
|
|
|
|
+ .eq(HospitalMealPlan::getDeptId, bo.getPatientDepartmentId())
|
|
|
|
+ .eq(HospitalMealPlan::getCreateDept, bo.getDoctorDepartmentId())
|
|
|
|
+ .isNotNull(HospitalMealPlan::getSettlementId)
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ Map<Long, String> deptMap = new HashMap<>();
|
|
|
|
+ Map<Long, String> userMap = new HashMap<>();
|
|
|
|
+ Map<Long, String> patientMap = new HashMap<>();
|
|
|
|
+ Map<Long, String> settlementMap = new HashMap<>();
|
|
|
|
+ // 食谱 ID 食谱名称
|
|
|
|
+ Map<Long, String> recipeMap = new HashMap<>();
|
|
|
|
+ // 食谱 ID 所需食材 ID
|
|
|
|
+ Map<Long, List<Long>> recipeToIngredientMap = new HashMap<>();
|
|
|
|
+ // 食材 ID 食材名称
|
|
|
|
+ Map<Long, String> ingredientMap = new HashMap<>();
|
|
|
|
+
|
|
|
|
+ sysDeptMapper.selectList().forEach(e -> deptMap.put(e.getDeptId(), e.getDeptName()));
|
|
|
|
+ sysUserMapper.selectList().forEach(e -> userMap.put(e.getUserId(), e.getName()));
|
|
|
|
+ treatmentUserMapper.selectList().forEach(e -> patientMap.put(e.getId(), e.getTreatName()));
|
|
|
|
+ settlementMapper.selectList().forEach(e -> settlementMap.put(e.getId(), e.getPaymentStatus()));
|
|
|
|
+ sysRecipeMapper.selectList().forEach(e -> recipeMap.put(e.getRecipeId(), e.getName()));
|
|
|
|
+ sysRecipeFoodIngredientMapper.selectList().forEach(e -> {
|
|
|
|
+ if (recipeToIngredientMap.containsKey(e.getRecipeId())) {
|
|
|
|
+ recipeToIngredientMap.get(e.getRecipeId()).add(e.getFoodIngredientId());
|
|
|
|
+ } else {
|
|
|
|
+ recipeToIngredientMap.put(e.getRecipeId(), List.of(e.getFoodIngredientId()));
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ sysFoodIngredientMapper.selectList().forEach(e -> ingredientMap.put(e.getFoodIngredientId(), e.getName()));
|
|
|
|
+
|
|
|
|
+ Map<String, List<String>> foodMap = new HashMap<>();
|
|
|
|
+ recipeToIngredientMap.forEach((k, v) -> {
|
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
|
+ v.forEach( e -> list.add(ingredientMap.get(e)));
|
|
|
|
+ foodMap.put(recipeMap.get(k), list);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ return TableDataInfo.build(page.convert(e -> {
|
|
|
|
+ DietaryPrescriptionVo vo = new DietaryPrescriptionVo();
|
|
|
|
+ vo.setId(e.getId());
|
|
|
|
+ vo.setTradeDate(new Date());
|
|
|
|
+ vo.setCalculationDate(e.getCreateTime());
|
|
|
|
+ vo.setConsultationType(Objects.equals(e.getType(), "0") ? "门诊" : "住院");
|
|
|
|
+ vo.setCalculationDoctorDepartment(deptMap.get(e.getDeptId()));
|
|
|
|
+ vo.setCalculationDoctor(userMap.get(e.getCreateBy()));
|
|
|
|
+ vo.setPatientDepartment(deptMap.get(e.getDeptId()));
|
|
|
|
+ vo.setPatientName(patientMap.get(e.getPatientId()));
|
|
|
|
+ vo.setPayStatus(settlementMap.get(e.getSettlementId()));
|
|
|
|
+
|
|
|
|
+ List<CookbookVo> breakfast = new ArrayList<>();
|
|
|
|
+ List<CookbookVo> breakfastExtra = new ArrayList<>();
|
|
|
|
+ List<CookbookVo> lunch = new ArrayList<>();
|
|
|
|
+ List<CookbookVo> lunchExtra = new ArrayList<>();
|
|
|
|
+ List<CookbookVo> dinner = new ArrayList<>();
|
|
|
|
+ List<CookbookVo> dinnerExtra = new ArrayList<>();
|
|
|
|
+ hospitalMealRecipeMapper.selectList(
|
|
|
|
+ Wrappers.lambdaQuery(HospitalMealRecipe.class).eq(HospitalMealRecipe::getPlanId, e.getId())
|
|
|
|
+ ).forEach(t -> {
|
|
|
|
+ switch (t.getMealTime()) {
|
|
|
|
+ case "早餐" -> breakfast.add(new CookbookVo(t.getFoodName(), foodMap.get(t.getFoodName())));
|
|
|
|
+ case "早中" -> breakfastExtra.add(new CookbookVo(t.getFoodName(), foodMap.get(t.getFoodName())));
|
|
|
|
+ case "中餐" -> lunch.add(new CookbookVo(t.getFoodName(), foodMap.get(t.getFoodName())));
|
|
|
|
+ case "中加" -> lunchExtra.add(new CookbookVo(t.getFoodName(), foodMap.get(t.getFoodName())));
|
|
|
|
+ case "晚餐" -> dinner.add(new CookbookVo(t.getFoodName(), foodMap.get(t.getFoodName())));
|
|
|
|
+ case "晚加" -> dinnerExtra.add(new CookbookVo(t.getFoodName(), foodMap.get(t.getFoodName())));
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ vo.setBreakfast(breakfast);
|
|
|
|
+ vo.setBreakfastExtra(breakfastExtra);
|
|
|
|
+ vo.setLunch(lunch);
|
|
|
|
+ vo.setLunchExtra(lunchExtra);
|
|
|
|
+ vo.setDinner(dinner);
|
|
|
|
+ vo.setDinnerExtra(dinnerExtra);
|
|
|
|
+ return vo;
|
|
|
|
+ }));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public TableDataInfo listPageDietaryInventory(DietaryInventoryBo bo, PageQuery pageQuery) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public TableDataInfo listPageInventory(InventoryBo bo, PageQuery pageQuery) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public TableDataInfo listPageInHospitalBillingReconciliation(InHospitalBillingReconciliationBo bo, PageQuery pageQuery) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public TableDataInfo listCost(CostBo bo, PageQuery pageQuery) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public TableDataInfo listPageProgressNote(ProgressNoteBo bo, PageQuery pageQuery) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public R getIntraHospitalData(Timestamp start, Timestamp end, Long id) {
|
|
|
|
+ return R.ok();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|