TBCarMapper.xml 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.daju.mix.dao.mapper.TBCarMapper">
  4. <resultMap id="VehiclesCamerasMap" type="com.daju.mix.dto.VehiclesCameras"/>
  5. <resultMap id="CarWorkDtoMap" type="com.daju.mix.dto.CarWorkDto"/>
  6. <resultMap type="com.daju.mix.dto.AllElements" id="AllElements"/>
  7. <!-- 圾车信息及预警-->
  8. <select id="allElementsByCar" resultMap="AllElements">
  9. select tbc.id id,
  10. tbcn.lng longitude,
  11. tbcn.lat latitude,
  12. course direction,
  13. max(tbca.create_date) createDate,
  14. case tbc.type
  15. when 'drygarbage' then 5
  16. when 'wetgarbage' then 6
  17. when 'water' then 7
  18. when 'patrolcar' then 10
  19. when 'clean' then 13
  20. when 'cleaningcar' then 14
  21. when 'WashingCar' then 16
  22. end as "type",
  23. tbca.status warningState,
  24. tbca.content warningMessage,
  25. expected_completion time
  26. from t_b_car tbc
  27. left join t_b_car_now tbcn
  28. on tbc.id = tbcn.carid
  29. left join t_b_car_alarm tbca on tbc.id = tbca.carid
  30. where tbcn.status != 'offline'
  31. and tbcn.status IS NOT NULL
  32. group by tbc.id
  33. </select>
  34. <!-- 根据id查询车辆设备号,name,地址-->
  35. <select id="selectCarVehicleNo" resultMap="VehiclesCamerasMap">
  36. select gpssn vehicleNo, name, tbcn.location, gps_type gpsType
  37. from t_b_car tbc
  38. left join t_b_car_now tbcn on tbc.id = tbcn.carid
  39. where tbc.id = #{id}
  40. </select>
  41. <!-- 获取车辆的作业任务。随机返回一条最近任务-->
  42. <select id="vehiclesWork" resultMap="CarWorkDtoMap">
  43. select tbcsa.description work,concat(date ,' ',start,':00') startTime, concat(date ,' ',end,':00') endTime, tbcsa.status progress
  44. from t_b_car tbc
  45. left join t_b_car_schedule tbcs
  46. on tbc.id = tbcs.carid
  47. left join t_b_car_schedule_arrange tbcsa on tbcs.id = tbcsa.schedule_id
  48. where date = (select max (date) from t_b_car_schedule_arrange)
  49. and tbc.id = #{carId}
  50. order by rand( ) limit 1;
  51. </select>
  52. <select id="getUserPhone" resultType="java.lang.String">
  53. select username phone
  54. from t_s_base_user
  55. where delete_flag = 0
  56. and did is null
  57. </select>
  58. <select id="getUserDid" resultType="com.daju.mix.dto.UserClockDto">
  59. select tu.did, tr.userNum code, tu.id userId, tu.realname name, tu.departid depart, tp.in_postid post
  60. from t_s_base_user tu
  61. left join t_bus_user_personnel tp on tu.id = tp.userid
  62. left join t_s_user tr on tr.id = tu.id
  63. where tu.delete_flag != '1' and tu.did is not null
  64. </select>
  65. <select id="getRemind" resultType="java.lang.String">
  66. select device_code deviceCode from
  67. p_device_defend
  68. where defend_date is not null and
  69. TO_DAYS(IFNULL(defend_date,0)) + IFNULL(defend_split,0) - TO_DAYS(NOW()) &lt;= 7
  70. </select>
  71. <select id="getCarRemind" resultType="java.lang.String">
  72. select car_id carId from
  73. t_b_car_defend
  74. where defend_date is not null and
  75. TO_DAYS(IFNULL(defend_date,0)) + IFNULL(defend_split,0) - TO_DAYS(NOW()) &lt;= 7
  76. </select>
  77. <select id="getDriverRemind" resultType="java.lang.String">
  78. select user_name name from
  79. t_b_car_driver
  80. where
  81. TO_DAYS(effective_date) - TO_DAYS(NOW()) &lt;= 7
  82. </select>
  83. </mapper>