MsReportMapper.java 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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}\n" +
  114. // "union\n" +
  115. // "select * from ms_report where report_status=1 and report_date=curdate() and user_create=#{userId}")
  116. List<MsReport> selectMsReportLate(@Param("userId") Long userId, @Param("reportDate") String reportDate);
  117. /**
  118. * 最近提交的日报, msStatus 健康状态:1正常,2异常
  119. *
  120. * @param userId
  121. * @return
  122. */
  123. @Select("select * from ms_report where user_create=#{userId} and report_status=1 order by report_date desc limit 1")
  124. MsReport selectMsReportToday(@Param("userId") Long userId);
  125. // @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" +
  126. // "union select * from ms_report where report_status=1 and report_date=date_sub(curdate(),interval 2 day) and user_create=#{userId}\n" +
  127. // "union select * from ms_report where report_status=1 and report_date=date_sub(curdate(),interval 3 day) and user_create=#{userId} union select * from ms_report where report_status=1 and report_date=curdate() and user_create=#{userId}) aa where aa.ms_status = 2")
  128. List<MsReport> selectMsReportThereError(@Param("userId") Long userId, @Param("reportDate") String reportDate);
  129. @Select("select * from ms_report where report_status=1 and report_date > date_sub(curdate(),interval 29 day) and user_create=#{userId} and ms_status = 2")
  130. List<MsReport> selectMsReportThirtyError(@Param("userId") Long userId);
  131. /**
  132. * 最近15天确诊,疑似,密切接触者
  133. *
  134. * @param userId
  135. * @return
  136. */
  137. @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}")
  138. List<MsReport> queryMsReportBySure(@Param("userId") Long userId);
  139. /**
  140. * 最近是否填过确诊,疑似,密切接触者
  141. *
  142. * @param userId
  143. * @return
  144. */
  145. @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")
  146. MsReport queryMsReportIsXG(@Param("userId") Long userId);
  147. /**
  148. * 家人确诊,疑似,密切接触者
  149. * @param userId
  150. * @return
  151. */
  152. @Select("select * from ms_report a INNER JOIN ms_suspected b on a.report_id=b.report_id where a.report_status=1 and a.user_create=#{userId} and b.is_contact = 1 ORDER BY a.time_create DESC")
  153. List<MsReport> queryMsReportIsXGHome(@Param("userId") Long userId);
  154. /**
  155. * 最近状态 0无,1确诊,2疑似,3密切接触者,4解除隔离
  156. *
  157. * @param userId
  158. * @return
  159. */
  160. @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}")
  161. List<MsReport> queryLateStatus(@Param("userId") Long userId, @Param("reportDate") String reportDate);
  162. /**
  163. * 最近去工作驻地的时间
  164. *
  165. * @param userId
  166. * @return
  167. */
  168. @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 " +
  169. "(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")
  170. String returnWork(@Param("userId") Long userId);
  171. /**
  172. * 最近去工作驻地的时间
  173. *
  174. * @param userId
  175. * @return
  176. */
  177. @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 " +
  178. "=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")
  179. List<MsReport> returnWorkTime(@Param("reportDate") String reportDate, @Param("userId") Long userId);
  180. /**
  181. * 当前人员今天的地址
  182. *
  183. * @param userId
  184. * @return
  185. */
  186. @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 " +
  187. "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")
  188. MsReport msAddr(@Param("userId") Long userId);
  189. //导出Ly异常
  190. @Select("select u.uptown_name,CONCAT(uu.ridgepole,uu.unit) as orgName,uh.linkman as userName,uh.phone,ur.user_id,uh1.doorplate from sys_user_role ur INNER JOIN sys_uptown_home uh on uh.house_id = ur.property_id INNER JOIN sys_uptown_house uh1 on uh1.house_id = ur.property_id INNER JOIN sys_uptown_unit uu on uu.unit_id = uh1.unit_id INNER JOIN sys_uptown u on u.uptown_id = uu.uptown_id where ur.role_id = 1 and u.uptown_id = 1238790987234 ORDER BY uh.linkman,uh1.doorplate")
  191. List<MsReport> selectByReportSuspected();
  192. //确诊、疑似、有接触史
  193. @Select("select count(*)\n" +
  194. "from ms_report a \n" +
  195. "INNER JOIN ms_suspected b on a.report_id=b.report_id\n" +
  196. "where a.report_status=1 and a.user_create=#{userId} and b.medical=#{medical}")
  197. Integer selectNum(@Param("userId") Long userId, @Param("medical") Integer medical);
  198. //家人是否有接触史
  199. @Select("select count(*)\n" +
  200. "from ms_report a \n" +
  201. "INNER JOIN ms_suspected b on a.report_id=b.report_id\n" +
  202. "where a.report_status=1 and a.user_create=#{userId} and b.is_contact=1")
  203. Integer selectFamilyContactNum(@Param("userId") Long userId);
  204. //病史
  205. @Select("select DATE_FORMAT(a.report_date,'%Y-%m-%d') as reportDate,b.*\n" +
  206. "from ms_report a \n" +
  207. "INNER JOIN ms_suspected b on a.report_id=b.report_id\n" +
  208. "where a.report_status=1 and a.user_create=#{userId}\n" +
  209. "and (b.temperature<35 or b.temperature>37.3 or b.cough>0 or b.muscle>0 or b.dyspnea>0 or b.fatigue>0 or b.diarrhea>0)\n" +
  210. "and a.report_date>date_add(NOW(), interval -1 MONTH)")
  211. List<MsSuspected> selectSymptomNum(@Param("userId") Long userId);
  212. }