MsReportMapper.java 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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. /**
  13. * @Author: xielianghe
  14. * @Date: 2020/2/4 15:45
  15. */
  16. @Mapper
  17. @Repository
  18. public interface MsReportMapper extends BaseMapper<MsReport> {
  19. List<MsReport> selectByReportDate(@Param("reportDate") String reportDate, @Param("userCreate") Long userCreate);
  20. @Select("select * from ms_report where report_date<curdate() and user_create=#{userCreate} ORDER BY report_date desc LIMIT 1")
  21. List<MsReport> getNowByYesterdayDate(@Param("userCreate") Long userCreate);
  22. @Select("select user_create from ms_report where report_date<curdate() GROUP BY user_create limit #{start}, #{count}")
  23. List<Long> getUserByYesterdayDate(@Param("start") Long start, @Param("count") Long count);
  24. @Select("select property_id from sys_user_role where user_id=#{userId} and role_id=1")
  25. Long selectHouseIdByUserId(@Param("userId") Long userId);
  26. @Select("select property_id from sys_user_role where user_id=#{userId} and role_id=1")
  27. List<Long> selectHouseIdsByUserId(@Param("userId") Long userId);
  28. //确诊
  29. @Select("select count(suspected_id) from ms_suspected where report_id=#{reportId} and medical=1")
  30. Integer selectSuspectedNum(@Param("reportId") Long reportId);
  31. //隔离
  32. @Select("select count(suspected_id) from ms_suspected where report_id=#{reportId} and single_room=1")
  33. Integer selectSingleRoomNum(@Param("reportId") Long reportId);
  34. //正常
  35. @Select("select count(suspected_id) from ms_suspected where report_id=#{reportId} and suspected_status=0")
  36. Integer selectisSuspectedNum(@Param("reportId") Long reportId);
  37. //疑似
  38. @Select("select count(suspected_id) from ms_suspected where report_id=#{reportId} and suspected_status=1")
  39. Integer selectisNoSuspectedNum(@Param("reportId") Long reportId);
  40. //异常
  41. @Select("select count(suspected_id) from ms_suspected where report_id=#{reportId} and medical in (1,2,3)")
  42. Integer selectAbnormalNum(@Param("reportId") Long reportId);
  43. /**
  44. * 导出word
  45. */
  46. //工作驻地
  47. @Select("select a.*\n" +
  48. "from ms_trip a\n" +
  49. "LEFT JOIN ms_suspected b on a.trip_id=b.suspected_id\n" +
  50. "LEFT JOIN ms_report c on b.report_id=c.report_id\n" +
  51. "where c.report_status=1 and c.user_create=#{userId} ORDER BY c.report_date desc LIMIT 1")
  52. MsTrip selectWorkByUserId(@Param("userId") Long userId);
  53. //是否离开
  54. @Select("select a.*\n" +
  55. "from ms_trip a\n" +
  56. "LEFT JOIN ms_suspected b on a.trip_id=b.suspected_id\n" +
  57. "LEFT JOIN ms_report c on b.report_id=c.report_id\n" +
  58. "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")
  59. MsTrip selectIsTripByUserId(@Param("userId") Long userId);
  60. //十五日居住地
  61. @Select("select * from (\n" +
  62. "select a.today_local,a.today_local_other\n" +
  63. "from ms_trip a\n" +
  64. "LEFT JOIN ms_suspected b on a.trip_id=b.suspected_id\n" +
  65. "LEFT JOIN ms_report c on b.report_id=c.report_id\n" +
  66. "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")
  67. List<MsTrip> select15TripByUserId(@Param("userId") Long userId);
  68. //返回驻地时间
  69. @Select("select a.report_date,a.report_id,c.today_local,c.today_local_other \n" +
  70. "from ms_report a \n" +
  71. "LEFT JOIN ms_suspected b on a.report_id=b.report_id\n" +
  72. "left join ms_trip c on b.suspected_id=c.trip_id\n" +
  73. "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" +
  74. "ORDER BY a.report_date desc LIMIT 1")
  75. MsReport selectBackTripByUserId(@Param("userId") Long userId);
  76. //返回驻地交通方式
  77. @Select("select a.trip_type\n" +
  78. "from ms_trip_det a\n" +
  79. "left JOIN ms_suspected b on a.trip_id=b.suspected_id where b.report_id=#{reportId} GROUP BY a.trip_type\n")
  80. List<MsTripDet> selectBackTripByReportrId(@Param("reportId") Long reportId);
  81. //近5日的
  82. @Select("select b.temperature\n" +
  83. "from ms_report a\n" +
  84. "LEFT JOIN ms_suspected b on a.report_id=b.report_id\n" +
  85. "where a.report_status=1 and a.user_create=#{userId} and a.report_date=#{reportDate}\n")
  86. MsSuspected select5ByReportrId(@Param("userId") Long userId, @Param("reportDate") String reportDate);
  87. //是否有其他症状
  88. @Select("select b.*\n" +
  89. "from ms_report a\n" +
  90. "LEFT JOIN ms_suspected b on a.report_id=b.report_id\n" +
  91. "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")
  92. List<MsSuspected> selectOtherSymptomByReportrId(@Param("userId") Long userId);
  93. //是否确诊
  94. @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}")
  95. Integer selectAbnormalNumUserId(@Param("userId") Long userId);
  96. //性别
  97. @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}")
  98. List<MsSuspected> selectGrenderUserId(@Param("userId") Long userId);
  99. /**
  100. * 最近3天是否都有上报
  101. *
  102. * @param userId
  103. * @return
  104. */
  105. @Select("select * from ms_report where report_status=1 and report_date=date_sub(curdate(),interval 1 day) and user_create=#{userId}\n" +
  106. "union\n" +
  107. "select * from ms_report where report_status=1 and report_date=date_sub(curdate(),interval 2 day) and user_create=#{userId}\n" +
  108. "union\n" +
  109. "select * from ms_report where report_status=1 and report_date=curdate() and user_create=#{userId}")
  110. List<MsReport> selectMsReportLate(@Param("userId") Long userId);
  111. /**
  112. * 最近提交的日报, msStatus 健康状态:1正常,2异常
  113. *
  114. * @param userId
  115. * @return
  116. */
  117. @Select("select * from ms_report where user_create=#{userId} and report_status=1 order by report_date desc limit 1")
  118. MsReport selectMsReportToday(@Param("userId") Long userId);
  119. @Select("select * from ms_report where user_create=#{userId} and ms_status = 2 and report_status=1 order by report_date desc limit 3")
  120. List<MsReport> selectMsReportThereError(@Param("userId") Long userId);
  121. /**
  122. * 最近15天确诊,疑似,密切接触者
  123. * @param userId
  124. * @return
  125. */
  126. @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}")
  127. List<MsReport> queryMsReportBySure(@Param("userId") Long userId);
  128. /**
  129. * 最近是否填过确诊,疑似,密切接触者
  130. * @param userId
  131. * @return
  132. */
  133. @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}")
  134. List<MsReport> queryMsReportIsXG(@Param("userId") Long userId);
  135. /**
  136. * 最近状态 0无,1确诊,2疑似,3密切接触者,4解除隔离
  137. * @param userId
  138. * @return
  139. */
  140. @Select("select b.medical 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} ORDER BY report_date desc LIMIT 1")
  141. Integer queryLateStatus(@Param("userId") Long userId);
  142. /**
  143. * 最近去工作驻地的时间
  144. * @param userId
  145. * @return
  146. */
  147. @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 " +
  148. "(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")
  149. String returnWork(@Param("userId") Long userId);
  150. /**
  151. * 最近去工作驻地的时间
  152. * @param userId
  153. * @return
  154. */
  155. @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 " +
  156. "=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")
  157. List<MsReport> returnWorkTime(@Param("reportDate") String reportDate, @Param("userId") Long userId);
  158. }