HospitalMealPlanMapper.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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.HospitalMealPlanQueryVo;
  7. import org.dromara.web.domain.vo.HospitalMealPlanVo;
  8. import org.springframework.stereotype.Repository;
  9. import java.util.List;
  10. /**
  11. * 院内膳食主Mapper接口
  12. *
  13. * @author Lion Li
  14. * @date 2025-07-23
  15. */
  16. @Repository
  17. public interface HospitalMealPlanMapper extends BaseMapperPlus<HospitalMealPlan, HospitalMealPlanVo> {
  18. @Select("<script>" +
  19. "SELECT " +
  20. " MIN(hmr.id) AS id, " +
  21. " hmp.settlement_id AS settlementId, " +
  22. " GROUP_CONCAT(DISTINCT hmr.id) AS idStr, " +
  23. " GROUP_CONCAT(DISTINCT hmr.food_name) AS productName, " +
  24. " MIN(hmr.create_time) AS prescriptionDate, " +
  25. " hmr.recipe_no AS recipeNo, " +
  26. " MIN(hmr.execute_date) AS executeDate, " +
  27. " MIN(hmr.meal_time) AS mealTime, " +
  28. " hmr.eat_time AS eatTime, " +
  29. " MIN(hmr.execute_time) AS executeTime, " +
  30. " MIN(se.payment_status) AS paymentStatus, " +
  31. " MIN(hmr.execute_status) AS executeStatus, " +
  32. " MIN(hmr.make_status) AS makeStatus, " +
  33. " MIN(hmr.make_time) AS makeTime, " +
  34. " MIN(hmr.make_by) AS makeBy, " +
  35. " MIN(hmr.execute_by) AS executeBy, " +
  36. " MIN(hmr.tag_print_num) AS tagPrintNum, " +
  37. " MIN(sd.dept_name) AS patientDepartment, " +
  38. " MIN(se.visit_type) AS visitType, " +
  39. " MIN(tu.id_card) AS idCard, " +
  40. " MIN(tu.outpatient_no) AS patientNo, " +
  41. " MIN(tu.bed_no) AS bedNo, " +
  42. " MIN(tu.ward_name) AS wardName, " +
  43. " MIN(tu.treat_num) AS treatNum, " +
  44. " MIN(su.user_name) AS makeByName, " +
  45. " MIN(syu.user_name) AS executeByName, " +
  46. " MIN(tu.treat_name) AS patientName, " +
  47. " MIN(se.stop_date) AS stopDate, " +
  48. " MIN(se.patient_id) AS patientId, " +
  49. " MIN(hmp.recommend_start_date) AS recommendStartDate, " +
  50. " MIN(hmp.recommend_end_date) AS recommendEndDate, " +
  51. " MIN(hmr.del_flag) AS delFlag " +
  52. "FROM hospital_meal_recipe hmr " +
  53. "LEFT JOIN hospital_meal_plan hmp ON hmr.plan_id = hmp.id AND IFNULL(hmp.del_Flag, '0') != '1' " +
  54. "LEFT JOIN settlement se ON hmp.settlement_id = se.id AND IFNULL(se.del_Flag, '0') != '1' " +
  55. "LEFT JOIN sys_user su ON hmr.make_by = su.user_id AND IFNULL(su.del_Flag, '0') != '1' " +
  56. "LEFT JOIN sys_user syu ON hmr.execute_by = syu.user_id AND IFNULL(syu.del_Flag, '0') != '1' " +
  57. "LEFT JOIN treatment_user tu ON se.patient_id = tu.id AND IFNULL(tu.del_Flag, '0') != '1' " +
  58. "LEFT JOIN sys_dept sd ON se.door_id = sd.dept_id AND IFNULL(sd.del_Flag, '0') != '1' " +
  59. "WHERE 1 = 1 " +
  60. "<if test='prescriptionType != null and prescriptionType != \"\"'> and se.charge_type = #{prescriptionType} </if> " +
  61. "<if test='visitType != null and visitType != \"\"'> and se.visit_type = #{visitType} </if> " +
  62. "<if test='makeStatus != null and makeStatus != \"\"'> and hmr.make_status = #{makeStatus} </if> " +
  63. "<if test='paymentStatus != null and paymentStatus != \"\"'> and se.payment_status = #{paymentStatus} </if> " +
  64. "<if test='executeStatus != null and executeStatus != \"\"'> and hmr.execute_status = #{executeStatus} </if> " +
  65. "<if test='doorId != null'> and se.door_id = #{doorId} </if> " +
  66. "<if test='wardId != null'> and se.ward_id = #{wardId} </if> " +
  67. "<if test='searchValue != null and searchValue != \"\"'> and (tu.treat_num like concat('%', #{searchValue}, '%') " +
  68. "or tu.treat_name like concat('%', #{searchValue}, '%') or tu.id_card like concat('%', #{searchValue}, '%') " +
  69. "or tu.outpatient_no like concat('%', #{searchValue}, '%') or hmp.settlement_id like concat('%', #{searchValue}, '%')) </if> " +
  70. "<if test='beginTime != null'> and hmr.create_time <![CDATA[>=]]> #{beginTime} </if> " +
  71. "<if test='endTime != null'> and hmr.create_time <![CDATA[<=]]> #{endTime} </if> " +
  72. "<if test='exeBeginTime != null'> and hmr.execute_date <![CDATA[>=]]> #{exeBeginTime} </if> " +
  73. "<if test='exeEndTime != null'> and hmr.execute_date <![CDATA[<=]]> #{exeEndTime} </if> " +
  74. "GROUP BY hmr.plan_id, hmr.recipe_no, hmp.settlement_id, hmr.eat_time " +
  75. "ORDER BY MIN(hmr.create_time) DESC " +
  76. "<if test='offset != null and rows != null'>LIMIT #{offset}, #{rows}</if>" +
  77. "</script>")
  78. List<HospitalMealPlanQueryVo> queryPageVoList(@Param("prescriptionType") String prescriptionType, @Param("visitType") String visitType, @Param("makeStatus") String makeStatus,
  79. @Param("paymentStatus") String paymentStatus, @Param("executeStatus") String executeStatus, @Param("doorId") Long doorId,
  80. @Param("wardId") Long wardId, @Param("searchValue") String searchValue, @Param("beginTime") String beginTime,
  81. @Param("endTime") String endTime, @Param("exeBeginTime") String exeBeginTime,
  82. @Param("exeEndTime") String exeEndTime, @Param("offset") Integer offset, @Param("rows") Integer rows);
  83. @Select("<script>" +
  84. "SELECT COUNT(*) FROM ( SELECT 1 FROM hospital_meal_recipe hmr " +
  85. "LEFT JOIN hospital_meal_plan hmp ON hmr.plan_id = hmp.id AND IFNULL(hmp.del_Flag, '0') != '1' " +
  86. "LEFT JOIN settlement se ON hmp.settlement_id = se.id AND IFNULL(se.del_Flag, '0') != '1' " +
  87. "LEFT JOIN sys_user su ON hmr.make_by = su.user_id AND IFNULL(su.del_Flag, '0') != '1' " +
  88. "LEFT JOIN sys_user syu ON hmr.execute_by = syu.user_id AND IFNULL(syu.del_Flag, '0') != '1' " +
  89. "LEFT JOIN treatment_user tu ON se.patient_id = tu.id AND IFNULL(tu.del_Flag, '0') != '1' " +
  90. "LEFT JOIN sys_dept sd ON se.door_id = sd.dept_id AND IFNULL(sd.del_Flag, '0') != '1' " +
  91. "WHERE 1 = 1 " +
  92. "<if test='prescriptionType != null and prescriptionType != \"\"'> and se.charge_type = #{prescriptionType} </if> " +
  93. "<if test='visitType != null and visitType != \"\"'> and se.visit_type = #{visitType} </if> " +
  94. "<if test='makeStatus != null and makeStatus != \"\"'> and hmr.make_status = #{makeStatus} </if> " +
  95. "<if test='paymentStatus != null and paymentStatus != \"\"'> and se.payment_status = #{paymentStatus} </if> " +
  96. "<if test='executeStatus != null and executeStatus != \"\"'> and hmr.execute_status = #{executeStatus} </if> " +
  97. "<if test='doorId != null '> and se.door_id = #{doorId} </if> " +
  98. "<if test='wardId != null '> and se.ward_id = #{wardId} </if> " +
  99. "<if test='searchValue != null and searchValue != \"\"'> and (tu.treat_num like concat('%', #{searchValue}, '%') " +
  100. "or tu.treat_name like concat('%', #{searchValue}, '%') or tu.id_card like concat('%', #{searchValue}, '%')" +
  101. "or tu.outpatient_no like concat('%', #{searchValue}, '%') or hmp.settlement_id like concat('%', #{searchValue}, '%')) </if> " +
  102. "<if test='beginTime != null'> and hmr.create_time <![CDATA[>=]]> #{beginTime} </if>" +
  103. "<if test='endTime != null'> and hmr.create_time <![CDATA[<=]]> #{endTime} </if>" +
  104. "<if test='exeBeginTime != null'> and hmr.execute_date <![CDATA[>=]]> #{exeBeginTime} </if>" +
  105. "<if test='exeEndTime != null'> and hmr.execute_date <![CDATA[<=]]> #{exeEndTime} </if>" +
  106. "GROUP BY hmr.plan_id, hmr.recipe_no,hmp.settlement_id, hmr.eat_time ) t" +
  107. "</script>")
  108. Integer queryPageVoCount(@Param("prescriptionType") String prescriptionType, @Param("visitType") String visitType, @Param("makeStatus") String makeStatus,
  109. @Param("paymentStatus") String paymentStatus, @Param("executeStatus") String executeStatus, @Param("doorId") Long doorId,
  110. @Param("wardId") Long wardId, @Param("searchValue") String searchValue, @Param("beginTime") String beginTime,
  111. @Param("endTime") String endTime, @Param("exeBeginTime") String exeBeginTime,
  112. @Param("exeEndTime") String exeEndTime);
  113. // @Select(
  114. // """
  115. // SELECT
  116. // `hospital_meal_plan`.`id` AS `id`,
  117. // `settlement`.`create_time` AS `tradeDate`,
  118. // `hospital_meal_plan`.`create_time` AS `calculationDate`,
  119. // `hospital_meal_plan`.`type` AS `consultationType`,
  120. // `doctor_dept`.`dept_name` AS `calculationDoctorDepartment`,
  121. // `sys_user`.`user_name` AS `calculationDoctor`,
  122. // `patient_dept`.`dept_name` AS `patientDepartment`,
  123. // `treatment_user`.`treat_name` AS `patientName`,
  124. // `settlement`.`payment_status` AS `payStatus`,
  125. // JSON_ARRAYAGG(
  126. // JSON_OBJECT(
  127. // `mealName`, `hospital_meal_recipe`.`food_name`,
  128. // `cookbooks`, JSON_ARRAYAGG(
  129. // JSON_OBJECT(
  130. // `cookbookName`, ``
  131. // )
  132. // )
  133. // )
  134. // ) AS `mealPeriods`
  135. // FROM `hospital_meal_plan`
  136. // LEFT JOIN `settlement`
  137. // ON `settlement`.`id` = `hospital_meal_plan`.`settlement_id` AND
  138. // `settlement`.`create_time` >= #{tradeDateEarliest} AND
  139. // `settlement`.`create_time` <= #{tradeDateLatest}
  140. // LEFT JOIN `sys_dept` `patient_dept`
  141. // ON `patient_dept`.`dept_id` = `hospital_meal_plan`.`dept_id`
  142. // LEFT JOIN `sys_dept` `doctor_dept`
  143. // ON `doctor_dept`.`dept_id` = `hospital_meal_plan`.`create_dept`
  144. // LEFT JOIN `sys_user`
  145. // ON `sys_user`.`user_id` = `hospital_meal_plan`.`create_by`
  146. // LEFT JOIN `treatment_user`
  147. // ON `treatment_user`.`id` = `hospital_meal_plan`.`patient_id`
  148. // LEFT JOIN `hospital_meal_recipe`
  149. // ON `hospital_meal_recipe`.`plan_id` = `hospital_meal_plan`.`id`
  150. // LEFT JOIN `sys_recipe`
  151. // ON `hospital_meal_recipe`.`food_id` = `sys_recipe`.`recipe_id`
  152. // WHERE
  153. // `hospital_meal_plan`.`type` = #{consultationType}
  154. // AND `hospital_meal_plan`.`dept_id` = #{patientDepartmentId}
  155. // AND `hospital_meal_plan`.`create_time` >= #{calculationDateEarliest}
  156. // AND `hospital_meal_plan`.`create_time` <= #{calculationDateLatest}
  157. // AND `hospital_meal_plan`.`create_dept` = #{doctorDepartmentId}
  158. // AND `hospital_meal_plan`.`settlement_id` is not null
  159. // LIMIT #{pageNum * pageSize}, #{pageSize};
  160. // """
  161. // )
  162. // DietaryPrescriptionVo listPageMealPlan(
  163. // @Param("tradeDateEarliest") Date tradeDateEarliest, @Param("tradeDateLatest") Date tradeDateLatest,
  164. // @Param("calculationDateEarliest") Date calculationDateEarliest, @Param("calculationDateLatest") Date calculationDateLatest,
  165. // @Param("doctorDepartmentId") Long doctorDepartmentId, @Param("patientDepartmentId") Long patientDepartmentId,
  166. // @Param("name") String name, @Param("consultationType") Integer consultationType,
  167. // @Param("pageNum") Integer pageNum, @Param("pageSize") Integer pageSize
  168. // );
  169. }