MsReportMapper.java 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. package com.bofeng.dao;
  2. import com.baomidou.mybatisplus.mapper.BaseMapper;
  3. import com.bofeng.entity.MsReport;
  4. import com.bofeng.entity.MsSuspected;
  5. import com.bofeng.entity.MsTrip;
  6. import com.bofeng.entity.MsTripDet;
  7. import org.apache.ibatis.annotations.Mapper;
  8. import org.apache.ibatis.annotations.Param;
  9. import org.apache.ibatis.annotations.Select;
  10. import org.springframework.stereotype.Repository;
  11. import java.util.List;
  12. import java.util.Map;
  13. /**
  14. * @Author: xielianghe
  15. * @Date: 2020/2/4 15:45
  16. */
  17. @Mapper
  18. @Repository
  19. public interface MsReportMapper extends BaseMapper<MsReport> {
  20. List<MsReport> selectByReportDate(@Param("reportDate") String reportDate, @Param("userCreate") Long userCreate);
  21. List<MsReport> selectByReportDateStatus(@Param("reportDate") String reportDate, @Param("userCreate") Long userCreate);
  22. List<MsReport> selectByReportDateTest(Map<String, Object> queryParam);
  23. List<MsSuspected> selectByReportDateTestxq(Map<String, Object> queryParam);
  24. @Select("select * from ms_report where report_date<curdate() and user_create=#{userCreate} ORDER BY report_date desc LIMIT 1")
  25. List<MsReport> getNowByYesterdayDate(@Param("userCreate") Long userCreate);
  26. @Select("select user_create from ms_report where report_date<curdate() GROUP BY user_create limit #{start}, #{count}")
  27. List<Long> getUserByYesterdayDate(@Param("start") Long start, @Param("count") Long count);
  28. @Select("select property_id from sys_user_role where user_id=#{userId} and role_id=1")
  29. Long selectHouseIdByUserId(@Param("userId") Long userId);
  30. @Select("select property_id from sys_user_role where user_id=#{userId} and role_id=1")
  31. List<Long> selectHouseIdsByUserId(@Param("userId") Long userId);
  32. //确诊
  33. @Select("select count(suspected_id) from ms_suspected where report_id=#{reportId} and medical=1")
  34. Integer selectSuspectedNum(@Param("reportId") Long reportId);
  35. //隔离
  36. @Select("select count(suspected_id) from ms_suspected where report_id=#{reportId} and single_room=1")
  37. Integer selectSingleRoomNum(@Param("reportId") Long reportId);
  38. //正常
  39. @Select("select count(suspected_id) from ms_suspected where report_id=#{reportId} and suspected_status=0")
  40. Integer selectisSuspectedNum(@Param("reportId") Long reportId);
  41. //疑似
  42. @Select("select count(suspected_id) from ms_suspected where report_id=#{reportId} and suspected_status=1")
  43. Integer selectisNoSuspectedNum(@Param("reportId") Long reportId);
  44. //异常
  45. @Select("select count(suspected_id) from ms_suspected where report_id=#{reportId} and medical in (1,2,3)")
  46. Integer selectAbnormalNum(@Param("reportId") Long reportId);
  47. /**
  48. * 导出word
  49. */
  50. //工作驻地
  51. @Select("select a.*\n" +
  52. "from ms_trip a\n" +
  53. "LEFT JOIN ms_suspected b on a.trip_id=b.suspected_id\n" +
  54. "LEFT JOIN ms_report c on b.report_id=c.report_id\n" +
  55. "where c.report_status=1 and c.user_create=#{userId} ORDER BY c.report_date desc LIMIT 1")
  56. MsTrip selectWorkByUserId(@Param("userId") Long userId);
  57. //是否离开
  58. @Select("select a.*\n" +
  59. "from ms_trip a\n" +
  60. "LEFT JOIN ms_suspected b on a.trip_id=b.suspected_id\n" +
  61. "LEFT JOIN ms_report c on b.report_id=c.report_id\n" +
  62. "where c.report_status=1 and c.user_create=#{userId} and (a.work_local!=a.today_local or a.work_local_other!=a.today_local_other) ORDER BY c.report_date desc LIMIT 1")
  63. MsTrip selectIsTripByUserId(@Param("userId") Long userId);
  64. //十五日居住地
  65. @Select("select * from (\n" +
  66. "select a.today_local,a.today_local_other\n" +
  67. "from ms_trip a\n" +
  68. "LEFT JOIN ms_suspected b on a.trip_id=b.suspected_id\n" +
  69. "LEFT JOIN ms_report c on b.report_id=c.report_id\n" +
  70. "where c.report_status=1 and c.user_create=#{userId} ORDER BY c.report_date desc LIMIT 15 ) tt GROUP BY tt.today_local,tt.today_local_other")
  71. List<MsTrip> select15TripByUserId(@Param("userId") Long userId);
  72. //返回驻地时间
  73. @Select("select a.report_date,a.report_id,c.today_local,c.today_local_other \n" +
  74. "from ms_report a \n" +
  75. "LEFT JOIN ms_suspected b on a.report_id=b.report_id\n" +
  76. "left join ms_trip c on b.suspected_id=c.trip_id\n" +
  77. "where (c.work_local =c.today_local or c.work_local_other =c.today_local_other) and c.is_trip=1 and a.report_status=1 and a.user_create=#{userId}\n" +
  78. "ORDER BY a.report_date desc LIMIT 1")
  79. MsReport selectBackTripByUserId(@Param("userId") Long userId);
  80. //返回驻地交通方式
  81. @Select("select a.trip_type\n" +
  82. "from ms_trip_det a\n" +
  83. "left JOIN ms_suspected b on a.trip_id=b.suspected_id where b.report_id=#{reportId} GROUP BY a.trip_type\n")
  84. List<MsTripDet> selectBackTripByReportrId(@Param("reportId") Long reportId);
  85. //近5日的
  86. @Select("select b.temperature\n" +
  87. "from ms_report a\n" +
  88. "LEFT JOIN ms_suspected b on a.report_id=b.report_id\n" +
  89. "where a.report_status=1 and a.user_create=#{userId} and a.report_date=#{reportDate}\n")
  90. MsSuspected select5ByReportrId(@Param("userId") Long userId, @Param("reportDate") String reportDate);
  91. //是否有其他症状
  92. @Select("select b.*\n" +
  93. "from ms_report a\n" +
  94. "LEFT JOIN ms_suspected b on a.report_id=b.report_id\n" +
  95. "where a.report_status=1 and a.user_create=#{userId} and (b.cough>0 or b.muscle>0 or b.dyspnea>0 or b.fatigue>0 or b.diarrhea>0)\n")
  96. List<MsSuspected> selectOtherSymptomByReportrId(@Param("userId") Long userId);
  97. //是否确诊
  98. @Select("select count(a.suspected_id) from ms_suspected a inner join ms_report b on a.report_id=b.report_id where a.medical in (1,2,3) and b.report_status=1 and b.user_create=#{userId}")
  99. Integer selectAbnormalNumUserId(@Param("userId") Long userId);
  100. //性别
  101. @Select("select a.* from ms_suspected a inner join ms_report b on a.report_id=b.report_id where b.report_status=1 and b.user_create=#{userId}")
  102. List<MsSuspected> selectGrenderUserId(@Param("userId") Long userId);
  103. /**
  104. * 最近3天是否都有上报
  105. *
  106. * @param userId
  107. * @return
  108. */
  109. @Select("select * from ms_report where report_status=1 and report_date=date_sub(curdate(),interval 1 day) and user_create=#{userId}\n" +
  110. "union\n" +
  111. "select * from ms_report where report_status=1 and report_date=date_sub(curdate(),interval 2 day) and user_create=#{userId}\n" +
  112. "union\n" +
  113. "select * from ms_report where report_status=1 and report_date=date_sub(curdate(),interval 3 day) and user_create=#{userId}")
  114. List<MsReport> selectMsReportLate(@Param("userId") Long userId);
  115. /**
  116. * 最近提交的日报, msStatus 健康状态:1正常,2异常
  117. *
  118. * @param userId
  119. * @return
  120. */
  121. @Select("select * from ms_report where user_create=#{userId} and report_status=1 order by report_date desc limit 1")
  122. MsReport selectMsReportToday(@Param("userId") Long userId);
  123. @Select("select * from (select * from ms_report where report_status=1 and report_date=date_sub(curdate(),interval 1 day) and user_create=#{userId}\n" +
  124. "union select * from ms_report where report_status=1 and report_date=date_sub(curdate(),interval 2 day) and user_create=#{userId}\n" +
  125. "union select * from ms_report where report_status=1 and report_date=date_sub(curdate(),interval 3 day) and user_create=#{userId}) aa where aa.ms_status = 2")
  126. List<MsReport> selectMsReportThereError(@Param("userId") Long userId);
  127. /**
  128. * 最近15天确诊,疑似,密切接触者
  129. * @param userId
  130. * @return
  131. */
  132. @Select("select * from ms_report where report_status=1 and report_date > date_sub(curdate(),interval 15 day) and ms_status=2 and user_create=#{userId}")
  133. List<MsReport> queryMsReportBySure(@Param("userId") Long userId);
  134. /**
  135. * 最近是否填过确诊,疑似,密切接触者
  136. * @param userId
  137. * @return
  138. */
  139. @Select("select a.* from ms_report a LEFT JOIN ms_suspected b on a.report_id=b.report_id where a.report_status=1 and b.medical in (1,2,3) and a.user_create=#{userId} ORDER BY a.time_create DESC LIMIT 1")
  140. MsReport queryMsReportIsXG(@Param("userId") Long userId);
  141. /**
  142. * 最近状态 0无,1确诊,2疑似,3密切接触者,4解除隔离
  143. * @param userId
  144. * @return
  145. */
  146. @Select("select a.* from ms_report a LEFT JOIN ms_suspected b on a.report_id=b.report_id where a.report_status=1 and a.user_create=#{userId} and b.medical = 4 and a.report_date > #{reportDate}")
  147. List<MsReport> queryLateStatus(@Param("userId") Long userId, @Param("reportDate") String reportDate);
  148. /**
  149. * 最近去工作驻地的时间
  150. * @param userId
  151. * @return
  152. */
  153. @Select("select DATE_FORMAT(a.report_date,'%Y-%m-%d') from ms_report a LEFT JOIN ms_suspected b on a.report_id=b.report_id left join ms_trip c on b.suspected_id=c.trip_id where " +
  154. "(c.work_local =c.today_local or c.work_local_other =c.today_local_other) and c.is_trip=1 and a.report_status=1 and a.user_create=#{userId} ORDER BY a.report_date desc LIMIT 1")
  155. String returnWork(@Param("userId") Long userId);
  156. /**
  157. * 最近去工作驻地的时间
  158. * @param userId
  159. * @return
  160. */
  161. @Select("select a.* from ms_report a LEFT JOIN ms_suspected b on a.report_id=b.report_id left join ms_trip c on b.suspected_id=c.trip_id where (c.work_local " +
  162. "=c.today_local or c.work_local_other =c.today_local_other) and c.is_trip=0 and a.report_status=1 and a.user_create=#{userId} and a.report_date>#{reportDate} ORDER BY a.report_date desc LIMIT 15")
  163. List<MsReport> returnWorkTime(@Param("reportDate") String reportDate, @Param("userId") Long userId);
  164. /**
  165. * 当前人员今天的地址
  166. * @param userId
  167. * @return
  168. */
  169. @Select("SELECT a.*,CASE WHEN c.work_local = 4 THEN c.work_local_other ELSE c.work_local END as workMsg,CASE WHEN c.today_local = 4 THEN c.today_local_other ELSE c.today_local END as todayMsg " +
  170. "FROM ms_report a LEFT JOIN ms_suspected b ON a.report_id = b.report_id LEFT JOIN ms_trip c ON b.suspected_id = c.trip_id WHERE a.report_status = 1 AND a.user_create = #{userId} ORDER BY a.report_date DESC LIMIT 1")
  171. MsReport msAddr(@Param("userId") Long userId);
  172. }