HospitalMealPlanMapper.java 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. package org.dromara.web.mapper;
  2. import org.apache.ibatis.annotations.Param;
  3. import org.apache.ibatis.annotations.Select;
  4. import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
  5. import org.dromara.web.domain.HospitalMealPlan;
  6. import org.dromara.web.domain.vo.EnteralNutritionQueryOneVo;
  7. import org.dromara.web.domain.vo.HospitalMealPlanQueryVo;
  8. import org.dromara.web.domain.vo.HospitalMealPlanVo;
  9. import org.springframework.stereotype.Repository;
  10. import java.util.List;
  11. /**
  12. * 院内膳食主Mapper接口
  13. *
  14. * @author Lion Li
  15. * @date 2025-07-23
  16. */
  17. @Repository
  18. public interface HospitalMealPlanMapper extends BaseMapperPlus<HospitalMealPlan, HospitalMealPlanVo> {
  19. @Select("<script>" +
  20. "SELECT " +
  21. " MIN(hmr.id) AS id, " +
  22. " hmp.settlement_id AS settlementId, " +
  23. " GROUP_CONCAT(DISTINCT hmr.id) AS idStr, " +
  24. " GROUP_CONCAT(DISTINCT hmr.food_name) AS productName, " +
  25. " MIN(hmr.create_time) AS prescriptionDate, " +
  26. " hmr.recipe_no AS recipeNo, " +
  27. " MIN(hmr.execute_date) AS executeDate, " +
  28. " MIN(hmr.meal_time) AS mealTime, " +
  29. " hmr.eat_time AS eatTime, " +
  30. " MIN(hmr.execute_time) AS executeTime, " +
  31. " MIN(se.payment_status) AS paymentStatus, " +
  32. " MIN(hmr.execute_status) AS executeStatus, " +
  33. " MIN(hmr.make_status) AS makeStatus, " +
  34. " MIN(hmr.make_time) AS makeTime, " +
  35. " MIN(hmr.make_by) AS makeBy, " +
  36. " MIN(hmr.execute_by) AS executeBy, " +
  37. " MIN(hmr.tag_print_num) AS tagPrintNum, " +
  38. " MIN(sd.dept_name) AS patientDepartment, " +
  39. " MIN(se.visit_type) AS visitType, " +
  40. " MIN(tu.id_card) AS idCard, " +
  41. " MIN(tu.outpatient_no) AS patientNo, " +
  42. " MIN(tu.bed_no) AS bedNo, " +
  43. " MIN(tu.ward_name) AS wardName, " +
  44. " MIN(tu.treat_num) AS treatNum, " +
  45. " MIN(su.user_name) AS makeByName, " +
  46. " MIN(syu.user_name) AS executeByName, " +
  47. " MIN(tu.treat_name) AS patientName, " +
  48. " MIN(se.stop_date) AS stopDate, " +
  49. " MIN(se.patient_id) AS patientId, " +
  50. " MIN(hmp.recommend_start_date) AS recommendStartDate, " +
  51. " MIN(hmp.recommend_end_date) AS recommendEndDate, " +
  52. " MIN(hmr.del_flag) AS delFlag " +
  53. "FROM hospital_meal_recipe hmr " +
  54. "LEFT JOIN hospital_meal_plan hmp ON hmr.plan_id = hmp.id AND IFNULL(hmp.del_Flag, '0') != '1' " +
  55. "LEFT JOIN settlement se ON hmp.settlement_id = se.id AND IFNULL(se.del_Flag, '0') != '1' " +
  56. "LEFT JOIN sys_user su ON hmr.make_by = su.user_id AND IFNULL(su.del_Flag, '0') != '1' " +
  57. "LEFT JOIN sys_user syu ON hmr.execute_by = syu.user_id AND IFNULL(syu.del_Flag, '0') != '1' " +
  58. "LEFT JOIN treatment_user tu ON se.patient_id = tu.id AND IFNULL(tu.del_Flag, '0') != '1' " +
  59. "LEFT JOIN sys_dept sd ON se.door_id = sd.dept_id AND IFNULL(sd.del_Flag, '0') != '1' " +
  60. "WHERE 1 = 1 " +
  61. "<if test='prescriptionType != null and prescriptionType != \"\"'> and se.charge_type = #{prescriptionType} </if> " +
  62. "<if test='visitType != null and visitType != \"\"'> and se.visit_type = #{visitType} </if> " +
  63. "<if test='makeStatus != null and makeStatus != \"\"'> and hmr.make_status = #{makeStatus} </if> " +
  64. "<if test='paymentStatus != null and paymentStatus != \"\"'> and se.payment_status = #{paymentStatus} </if> " +
  65. "<if test='executeStatus != null and executeStatus != \"\"'> and hmr.execute_status = #{executeStatus} </if> " +
  66. "<if test='doorId != null'> and se.door_id = #{doorId} </if> " +
  67. "<if test='wardId != null'> and se.ward_id = #{wardId} </if> " +
  68. "<if test='searchValue != null and searchValue != \"\"'> and (tu.treat_num like concat('%', #{searchValue}, '%') " +
  69. "or tu.treat_name like concat('%', #{searchValue}, '%') or tu.id_card like concat('%', #{searchValue}, '%') " +
  70. "or tu.outpatient_no like concat('%', #{searchValue}, '%') or hmp.settlement_id like concat('%', #{searchValue}, '%')) </if> " +
  71. "<if test='beginTime != null'> and hmr.create_time <![CDATA[>=]]> #{beginTime} </if> " +
  72. "<if test='endTime != null'> and hmr.create_time <![CDATA[<=]]> #{endTime} </if> " +
  73. "<if test='exeBeginTime != null'> and hmr.execute_date <![CDATA[>=]]> #{exeBeginTime} </if> " +
  74. "<if test='exeEndTime != null'> and hmr.execute_date <![CDATA[<=]]> #{exeEndTime} </if> " +
  75. "GROUP BY hmr.plan_id, hmr.recipe_no, hmp.settlement_id, hmr.eat_time " +
  76. "ORDER BY MIN(hmr.create_time) DESC " +
  77. "<if test='offset != null and rows != null'>LIMIT #{offset}, #{rows}</if>" +
  78. "</script>")
  79. List<HospitalMealPlanQueryVo> queryPageVoList(@Param("prescriptionType") String prescriptionType, @Param("visitType") String visitType, @Param("makeStatus") String makeStatus,
  80. @Param("paymentStatus") String paymentStatus, @Param("executeStatus") String executeStatus, @Param("doorId") Long doorId,
  81. @Param("wardId") Long wardId, @Param("searchValue") String searchValue, @Param("beginTime") String beginTime,
  82. @Param("endTime") String endTime, @Param("exeBeginTime") String exeBeginTime,
  83. @Param("exeEndTime") String exeEndTime, @Param("offset") Integer offset, @Param("rows") Integer rows);
  84. @Select("<script>" +
  85. "SELECT COUNT(*) FROM ( SELECT 1 FROM hospital_meal_recipe hmr " +
  86. "LEFT JOIN hospital_meal_plan hmp ON hmr.plan_id = hmp.id AND IFNULL(hmp.del_Flag, '0') != '1' " +
  87. "LEFT JOIN settlement se ON hmp.settlement_id = se.id AND IFNULL(se.del_Flag, '0') != '1' " +
  88. "LEFT JOIN sys_user su ON hmr.make_by = su.user_id AND IFNULL(su.del_Flag, '0') != '1' " +
  89. "LEFT JOIN sys_user syu ON hmr.execute_by = syu.user_id AND IFNULL(syu.del_Flag, '0') != '1' " +
  90. "LEFT JOIN treatment_user tu ON se.patient_id = tu.id AND IFNULL(tu.del_Flag, '0') != '1' " +
  91. "LEFT JOIN sys_dept sd ON se.door_id = sd.dept_id AND IFNULL(sd.del_Flag, '0') != '1' " +
  92. "WHERE 1 = 1 " +
  93. "<if test='prescriptionType != null and prescriptionType != \"\"'> and se.charge_type = #{prescriptionType} </if> " +
  94. "<if test='visitType != null and visitType != \"\"'> and se.visit_type = #{visitType} </if> " +
  95. "<if test='makeStatus != null and makeStatus != \"\"'> and hmr.make_status = #{makeStatus} </if> " +
  96. "<if test='paymentStatus != null and paymentStatus != \"\"'> and se.payment_status = #{paymentStatus} </if> " +
  97. "<if test='executeStatus != null and executeStatus != \"\"'> and hmr.execute_status = #{executeStatus} </if> " +
  98. "<if test='doorId != null '> and se.door_id = #{doorId} </if> " +
  99. "<if test='wardId != null '> and se.ward_id = #{wardId} </if> " +
  100. "<if test='searchValue != null and searchValue != \"\"'> and (tu.treat_num like concat('%', #{searchValue}, '%') " +
  101. "or tu.treat_name like concat('%', #{searchValue}, '%') or tu.id_card like concat('%', #{searchValue}, '%')" +
  102. "or tu.outpatient_no like concat('%', #{searchValue}, '%') or hmp.settlement_id like concat('%', #{searchValue}, '%')) </if> " +
  103. "<if test='beginTime != null'> and hmr.create_time <![CDATA[>=]]> #{beginTime} </if>" +
  104. "<if test='endTime != null'> and hmr.create_time <![CDATA[<=]]> #{endTime} </if>" +
  105. "<if test='exeBeginTime != null'> and hmr.execute_date <![CDATA[>=]]> #{exeBeginTime} </if>" +
  106. "<if test='exeEndTime != null'> and hmr.execute_date <![CDATA[<=]]> #{exeEndTime} </if>" +
  107. "GROUP BY hmr.plan_id, hmr.recipe_no,hmp.settlement_id, hmr.eat_time ) t" +
  108. "</script>")
  109. Integer queryPageVoCount(@Param("prescriptionType") String prescriptionType, @Param("visitType") String visitType, @Param("makeStatus") String makeStatus,
  110. @Param("paymentStatus") String paymentStatus, @Param("executeStatus") String executeStatus, @Param("doorId") Long doorId,
  111. @Param("wardId") Long wardId, @Param("searchValue") String searchValue, @Param("beginTime") String beginTime,
  112. @Param("endTime") String endTime, @Param("exeBeginTime") String exeBeginTime,
  113. @Param("exeEndTime") String exeEndTime);
  114. }