MsSuspectedMapper.java 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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.MsTripDet;
  6. import org.apache.ibatis.annotations.Mapper;
  7. import org.apache.ibatis.annotations.Param;
  8. import org.apache.ibatis.annotations.Select;
  9. import org.springframework.stereotype.Repository;
  10. import java.util.List;
  11. /**
  12. * @Author: xielianghe
  13. * @Date: 2020/2/4 15:39
  14. */
  15. @Mapper
  16. @Repository
  17. public interface MsSuspectedMapper extends BaseMapper<MsSuspected> {
  18. List<MsSuspected> selectByReportId(@Param("reportId") Long reportId);
  19. //判断家人姓名是否重复
  20. @Select("select a.* from ms_suspected a LEFT JOIN ms_report b on a.report_id=b.report_id where a.report_id=#{reportId} and a.user_name=#{userName} and b.report_date=#{reportDate}")
  21. List<MsSuspected> selectUserNameNum(@Param("reportId") Long reportId, @Param("userName") String userName, @Param("reportDate") String reportDate);
  22. //判断家人是否有历史评分
  23. @Select("select score from ms_suspected where user_create=#{userCreate} and user_name=#{userName} and suspected_id !=#{suspectedId} order by time_update desc limit 1")
  24. Integer selectUserNameScore(@Param("userCreate") Long userCreate, @Param("userName") String userName, @Param("suspectedId") Long suspectedId);
  25. //判断家人是否有历史评分
  26. @Select("select a.* \n" +
  27. "from ms_suspected a \n" +
  28. "INNER JOIN ms_report b on a.report_id=b.report_id \n" +
  29. "where b.user_create=#{userCreate} and b.report_date=(select report_date from ms_report where user_create=#{userCreate} and report_date<curdate() ORDER BY report_date desc LIMIT 1)\n" +
  30. "and a.user_name not in (select a.user_name from ms_suspected a INNER JOIN ms_report b on a.report_id=b.report_id where b.user_create=#{userCreate} and b.report_date=curdate())\n" +
  31. " ORDER by a.time_create LIMIT 1")
  32. MsSuspected selectAddSuspected(@Param("userCreate") Long userCreate);
  33. //获取最近的一个人一个家人
  34. @Select("select a.*,c.* \n" +
  35. "from ms_suspected a \n" +
  36. "INNER JOIN ms_report b on a.report_id=b.report_id \n" +
  37. "left JOIN ms_trip c on a.suspected_id=c.trip_id \n" +
  38. "where b.user_create=#{userCreate} and b.report_date=(select report_date from ms_report where user_create=#{userCreate} and report_date<curdate() ORDER BY report_date desc LIMIT 1)\n" +
  39. "ORDER by a.time_create ")
  40. List<MsSuspected> selectNextSuspected(@Param("userCreate") Long userCreate);
  41. //选择家人
  42. @Select("select a.*,b.* from ms_suspected a LEFT JOIN ms_trip b on a.suspected_id=b.trip_id where a.suspected_id =#{suspectedId}")
  43. MsSuspected selectBySuspectedId(@Param("suspectedId") Long suspectedId);
  44. @Select("select * from ms_trip_det where trip_id =#{suspectedId}")
  45. List<MsTripDet> selectTripSuspected(@Param("suspectedId") Long suspectedId);
  46. }