TCntrnoMapper.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ruoyi.shipping.mapper.TCntrnoMapper">
  6. <resultMap type="TCntrno" id="TCntrnoResult">
  7. <result property="fId" column="f_id"/>
  8. <result property="fNo" column="f_no"/>
  9. <result property="fTypeid" column="f_typeid"/>
  10. <result property="fOwner" column="f_owner"/>
  11. <result property="fSource" column="f_source"/>
  12. <result property="fRent" column="f_rent"/>
  13. <result property="fUpdatetime" column="f_updatetime"/>
  14. <result property="fUpdateaddress" column="f_updateaddress"/>
  15. <result property="fUpdateef" column="f_updateEF"/>
  16. <result property="fCntrstatus" column="f_cntrstatus"/>
  17. <result property="fStatus" column="f_status"/>
  18. <result property="createBy" column="create_by"/>
  19. <result property="createTime" column="create_time"/>
  20. <result property="updateBy" column="update_by"/>
  21. <result property="updateTime" column="update_time"/>
  22. <result property="remark" column="remark"/>
  23. </resultMap>
  24. <sql id="selectTCntrnoVo">
  25. select f_id, f_no, f_typeid, f_owner, f_source, f_rent, f_updatetime, f_updateaddress, f_updateEF, f_cntrstatus, case when f_status = 'T' then '正常' else '停用' end as f_status, create_by, create_time, update_by, update_time, remark from t_cntrno
  26. </sql>
  27. <select id="selectTCntrnoList" parameterType="TCntrno" resultMap="TCntrnoResult">
  28. <include refid="selectTCntrnoVo"/>
  29. <where>
  30. <if test="fNo != null and fNo != ''">and f_no = #{fNo}</if>
  31. <if test="fTypeid != null ">and f_typeid = #{fTypeid}</if>
  32. <if test="fOwner != null and fOwner != ''">and f_owner = #{fOwner}</if>
  33. <if test="fSource != null and fSource != ''">and f_source = #{fSource}</if>
  34. <if test="fRent != null and fRent != ''">and f_rent = #{fRent}</if>
  35. <if test="fUpdatetime != null ">and f_updatetime = #{fUpdatetime}</if>
  36. <if test="fUpdateaddress != null and fUpdateaddress != ''">and f_updateaddress = #{fUpdateaddress}</if>
  37. <if test="fUpdateef != null and fUpdateef != ''">and f_updateEF = #{fUpdateef}</if>
  38. <if test="fCntrstatus != null and fCntrstatus != ''">and f_cntrstatus = #{fCntrstatus}</if>
  39. <if test="fStatus != null and fStatus != ''">and f_status = #{fStatus}</if>
  40. <if test='cLoadDate != null and cLoadDate[0] != null and cLoadDate[0]!= ""'>
  41. and create_time &gt;= #{cLoadDate[0]}
  42. </if>
  43. <if test='cLoadDate != null and cLoadDate[1] != null and cLoadDate[1]!= ""'>
  44. and create_time &lt;= #{cLoadDate[1]}
  45. </if>
  46. </where>
  47. </select>
  48. <select id="selectTcntrnoMessage" parameterType="TCntrno" resultMap="TCntrnoResult">
  49. SELECT
  50. tc.f_id,
  51. tc.f_no,
  52. tc.f_typeid,
  53. t.f_no typeidName,
  54. t.f_cntrsize cntrsize,
  55. prs.dict_label cntrsizeName,
  56. tc.f_owner,
  57. pro.dict_label ownerName,
  58. tc.f_source,
  59. sd.dict_label sourceName,
  60. tc.f_rent,
  61. sdd.dict_label rentName,
  62. tc.f_updatetime,
  63. tc.f_updateaddress,
  64. address.f_name addressName,
  65. tc.f_updateEF,
  66. sdda.dict_label updateEFName,
  67. tc.f_cntrstatus,
  68. pr.dict_label cntrstatusName,
  69. case when tc.f_status = 'T' then '正常' else '停用' end as f_status,
  70. tc.create_by,
  71. tc.create_time,
  72. tc.update_by,
  73. tc.update_time,
  74. tc.remark
  75. FROM
  76. t_cntrno tc
  77. LEFT JOIN sys_dict_data pro ON pro.dict_value = tc.f_owner
  78. AND pro.dict_type = 'f_owner'
  79. LEFT JOIN sys_dict_data sd ON sd.dict_value = tc.f_source
  80. AND sd.dict_type = 'f_source'
  81. LEFT JOIN sys_dict_data sdd ON sdd.dict_value = tc.f_rent
  82. AND sdd.dict_type = 'f_rent'
  83. LEFT JOIN sys_dict_data sdda ON sdda.dict_value = tc.f_updateEF
  84. AND sdda.dict_type = 'f_updateEF'
  85. LEFT JOIN sys_dict_data pr ON pr.dict_value = tc.f_cntrstatus
  86. AND pr.dict_type = 'f_cntrstatus'
  87. LEFT JOIN t_cntr t ON tc.f_typeid = t.f_id
  88. LEFT JOIN sys_dict_data prs ON prs.dict_value = t.f_cntrsize
  89. AND prs.dict_type = 'f_cntrsize'
  90. LEFT JOIN t_address address ON address.f_id = tc.f_updateaddress
  91. <where>
  92. tc.f_status = 'T'
  93. <if test="tc.fNo != null and tc.fNo != ''">and tc.f_no = #{tc.fNo}</if>
  94. <if test="tc.fTypeid != null ">and tc.f_typeid = #{tc.fTypeid}</if>
  95. <if test="tc.fOwner != null and tc.fOwner != ''">and tc.f_owner = #{tc.fOwner}</if>
  96. <if test="tc.fSource != null and tc.fSource != ''">and tc.f_source = #{tc.fSource}</if>
  97. <if test="tc.fRent != null and tc.fRent != ''">and tc.f_rent = #{tc.fRent}</if>
  98. <if test="tc.fUpdatetime != null ">and tc.f_updatetime = #{tc.fUpdatetime}</if>
  99. <if test="tc.fUpdateaddress != null and tc.fUpdateaddress != ''">and tc.f_updateaddress = #{tc.fUpdateaddress}</if>
  100. <if test="tc.fUpdateef != null and tc.fUpdateef != ''">and tc.f_updateEF = #{tc.fUpdateef}</if>
  101. <if test="tc.fCntrstatus != null and tc.fCntrstatus != ''">and tc.f_cntrstatus = #{tc.fCntrstatus}</if>
  102. <if test="tc.fStatus != null and tc.fStatus != ''">and tc.f_status = #{tc.fStatus}</if>
  103. <if test='tc.cLoadDate != null and tc.cLoadDate[0] != null and tc.cLoadDate[0]!= ""'>
  104. and tc.create_time &gt;= #{tc.cLoadDate[0]}
  105. </if>
  106. <if test='tc.cLoadDate != null and tc.cLoadDate[1] != null and tc.cLoadDate[1]!= ""'>
  107. and tc.create_time &lt;= #{tc.cLoadDate[1]}
  108. </if>
  109. <if test="address != null and address != ''">and address.f_name = #{address}</if>
  110. <if test="typeidName != null and typeidName != ''">and t.f_name = #{typeidName}</if>
  111. <if test="cntrstatusName != null and cntrstatusName != ''">and pr.dict_label = #{cntrstatusName}</if>
  112. <if test="updateEFName != null and updateEFName != ''">and sdda.dict_label = #{updateEFName}</if>
  113. </where>
  114. ORDER BY tc.f_no,CONVERT(tc.f_updateaddress USING gbk),CONVERT(t.f_no USING gbk),
  115. tc.f_updateEF,tc.f_cntrstatus,tc.f_owner
  116. </select>
  117. <select id="selectTCntrnoById" parameterType="Long" resultMap="TCntrnoResult">
  118. SELECT
  119. tc.f_id,
  120. tc.f_no,
  121. tc.f_typeid,
  122. t.f_name typeidName,
  123. t.f_cntrsize cntrsize,
  124. prs.dict_label cntrsizeName,
  125. tc.f_owner,
  126. pro.dict_label ownerName,
  127. tc.f_source,
  128. sd.dict_label sourceName,
  129. tc.f_rent,
  130. sdd.dict_label rentName,
  131. tc.f_updatetime,
  132. tc.f_updateaddress,
  133. address.f_name addressName,
  134. tc.f_updateEF,
  135. sdda.dict_label updateEFName,
  136. tc.f_cntrstatus,
  137. pr.dict_label cntrstatusName,
  138. case when tc.f_status = 'T' then '正常' else '停用' end as f_status,
  139. tc.create_by,
  140. tc.create_time,
  141. tc.update_by,
  142. tc.update_time,
  143. tc.remark
  144. FROM
  145. t_cntrno tc
  146. LEFT JOIN sys_dict_data pro ON pro.dict_value = tc.f_owner
  147. AND pro.dict_type = 'f_owner'
  148. LEFT JOIN sys_dict_data sd ON sd.dict_value = tc.f_source
  149. AND sd.dict_type = 'f_source'
  150. LEFT JOIN sys_dict_data sdd ON sdd.dict_value = tc.f_rent
  151. AND sdd.dict_type = 'f_rent'
  152. LEFT JOIN sys_dict_data sdda ON sdda.dict_value = tc.f_updateEF
  153. AND sdda.dict_type = 'f_updateEF'
  154. LEFT JOIN sys_dict_data pr ON pr.dict_value = tc.f_cntrstatus
  155. AND pr.dict_type = 'f_cntrstatus'
  156. LEFT JOIN t_cntr t ON tc.f_typeid = t.f_id
  157. LEFT JOIN sys_dict_data prs ON prs.dict_value = t.f_cntrsize
  158. AND prs.dict_type = 'f_cntrsize'
  159. LEFT JOIN t_address address ON address.f_id = tc.f_updateaddress
  160. where tc.f_id = #{fId}
  161. </select>
  162. <insert id="insertTCntrno" parameterType="TCntrno">
  163. insert into t_cntrno
  164. <trim prefix="(" suffix=")" suffixOverrides=",">
  165. <if test="fId != null">f_id,</if>
  166. <if test="fNo != null and fNo != ''">f_no,</if>
  167. <if test="fTypeid != null">f_typeid,</if>
  168. <if test="fOwner != null and fOwner != ''">f_owner,</if>
  169. <if test="fSource != null">f_source,</if>
  170. <if test="fRent != null">f_rent,</if>
  171. <if test="fUpdatetime != null">f_updatetime,</if>
  172. <if test="fUpdateaddress != null and fUpdateaddress != ''">f_updateaddress,</if>
  173. <if test="fUpdateef != null and fUpdateef != ''">f_updateEF,</if>
  174. <if test="fCntrstatus != null and fCntrstatus != ''">f_cntrstatus,</if>
  175. <if test="fStatus != null">f_status,</if>
  176. <if test="createBy != null">create_by,</if>
  177. <if test="createTime != null">create_time,</if>
  178. <if test="updateBy != null">update_by,</if>
  179. <if test="updateTime != null">update_time,</if>
  180. <if test="remark != null">remark,</if>
  181. </trim>
  182. <trim prefix="values (" suffix=")" suffixOverrides=",">
  183. <if test="fId != null">#{fId},</if>
  184. <if test="fNo != null and fNo != ''">#{fNo},</if>
  185. <if test="fTypeid != null">#{fTypeid},</if>
  186. <if test="fOwner != null and fOwner != ''">#{fOwner},</if>
  187. <if test="fSource != null">#{fSource},</if>
  188. <if test="fRent != null">#{fRent},</if>
  189. <if test="fUpdatetime != null">#{fUpdatetime},</if>
  190. <if test="fUpdateaddress != null and fUpdateaddress != ''">#{fUpdateaddress},</if>
  191. <if test="fUpdateef != null and fUpdateef != ''">#{fUpdateef},</if>
  192. <if test="fCntrstatus != null and fCntrstatus != ''">#{fCntrstatus},</if>
  193. <if test="fStatus != null">#{fStatus},</if>
  194. <if test="createBy != null">#{createBy},</if>
  195. <if test="createTime != null">#{createTime},</if>
  196. <if test="updateBy != null">#{updateBy},</if>
  197. <if test="updateTime != null">#{updateTime},</if>
  198. <if test="remark != null">#{remark},</if>
  199. </trim>
  200. </insert>
  201. <update id="updateTCntrno" parameterType="TCntrno">
  202. update t_cntrno
  203. <trim prefix="SET" suffixOverrides=",">
  204. <if test="fNo != null and fNo != ''">f_no = #{fNo},</if>
  205. <if test="fTypeid != null">f_typeid = #{fTypeid},</if>
  206. <if test="fOwner != null and fOwner != ''">f_owner = #{fOwner},</if>
  207. <if test="fSource != null">f_source = #{fSource},</if>
  208. <if test="fRent != null">f_rent = #{fRent},</if>
  209. <if test="fUpdatetime != null">f_updatetime = #{fUpdatetime},</if>
  210. <if test="fUpdateaddress != null and fUpdateaddress != ''">f_updateaddress = #{fUpdateaddress},</if>
  211. <if test="fUpdateef != null and fUpdateef != ''">f_updateEF = #{fUpdateef},</if>
  212. <if test="fCntrstatus != null and fCntrstatus != ''">f_cntrstatus = #{fCntrstatus},</if>
  213. <if test="fStatus != null">f_status = #{fStatus},</if>
  214. <if test="createBy != null">create_by = #{createBy},</if>
  215. <if test="createTime != null">create_time = #{createTime},</if>
  216. <if test="updateBy != null">update_by = #{updateBy},</if>
  217. <if test="updateTime != null">update_time = #{updateTime},</if>
  218. <if test="remark != null">remark = #{remark},</if>
  219. </trim>
  220. where f_id = #{fId}
  221. </update>
  222. <delete id="deleteTCntrnoById" parameterType="Long">
  223. delete from t_cntrno where f_id = #{fId}
  224. </delete>
  225. <delete id="deleteTCntrnoByIds" parameterType="String">
  226. delete from t_cntrno where f_id in
  227. <foreach item="fId" collection="array" open="(" separator="," close=")">
  228. #{fId}
  229. </foreach>
  230. </delete>
  231. <!--批量更新数据状态-->
  232. <update id="updateTcntrnoStatus" parameterType="string">
  233. update t_cntrno
  234. set f_status = 'F'
  235. where f_id in
  236. <foreach item="fId" collection="array" open="(" separator="," close=")">
  237. #{fId}
  238. </foreach>
  239. </update>
  240. <!--获取集装动态分布信息 -->
  241. <select id="getTCntrnoMessage" parameterType="string" resultType="map">
  242. SELECT
  243. container.*,
  244. box.`空`,
  245. box.`重`,
  246. car.`好`,
  247. car.`坏`
  248. FROM
  249. (
  250. SELECT
  251. tt.f_updateaddress AS 地点
  252. <if test=" sql != null and sql != ''">
  253. ,${sql}
  254. </if>
  255. FROM
  256. (
  257. SELECT
  258. tc.f_updateaddress f_updateaddress,
  259. tc.typeidCount typeidCount,
  260. t.f_no f_no
  261. FROM
  262. (
  263. SELECT
  264. ta.f_name f_updateaddress,
  265. tcn.f_typeid,
  266. COUNT( tcn.f_updateaddress ) typeidCount
  267. FROM
  268. t_cntrno tcn
  269. LEFT JOIN t_address ta ON tcn.f_updateaddress = ta.f_id
  270. WHERE
  271. tcn.f_status = 'T'
  272. GROUP BY
  273. tcn.f_updateaddress,
  274. tcn.f_typeid
  275. ) tc
  276. LEFT JOIN t_cntr t ON tc.f_typeid = t.f_id
  277. ) tt
  278. GROUP BY
  279. tt.f_updateaddress
  280. ) container
  281. LEFT JOIN (
  282. SELECT
  283. a.f_updateaddress,
  284. MAX( CASE WHEN a.dict_label = '空' THEN a.efCount ELSE 0 END ) AS 空,
  285. MAX( CASE WHEN a.dict_label = '重' THEN a.efCount ELSE 0 END ) AS 重
  286. FROM
  287. (
  288. SELECT
  289. tc.f_updateaddress f_updateaddress,
  290. tc.f_updateEF f_updateEF,
  291. tc.efCount efCount,
  292. sdda.dict_label dict_label
  293. FROM
  294. (
  295. SELECT
  296. ta.f_name f_updateaddress,
  297. tct.f_updateEF,
  298. COUNT( tct.f_updateaddress ) efCount
  299. FROM
  300. t_cntrno tct
  301. LEFT JOIN t_address ta ON tct.f_updateaddress = ta.f_id
  302. WHERE
  303. tct.f_status = 'T'
  304. GROUP BY
  305. tct.f_updateaddress,
  306. tct.f_updateEF
  307. ) tc
  308. LEFT JOIN sys_dict_data sdda ON sdda.dict_value = tc.f_updateEF
  309. AND sdda.dict_type = 'f_updateEF'
  310. ) a
  311. GROUP BY
  312. a.f_updateaddress
  313. ) box ON container.地点 = box.f_updateaddress
  314. LEFT JOIN (
  315. SELECT
  316. b.f_updateaddress,
  317. MAX( CASE WHEN b.dict_label = '好' THEN b.statusCount ELSE 0 END ) AS 好,
  318. MAX( CASE WHEN b.dict_label = '坏' THEN b.statusCount ELSE 0 END ) AS 坏
  319. FROM
  320. (
  321. SELECT
  322. tc.f_updateaddress f_updateaddress,
  323. tc.f_cntrstatus f_cntrstatus,
  324. tc.statusCount statusCount,
  325. sdda.dict_label dict_label
  326. FROM
  327. (
  328. SELECT
  329. ta.f_name f_updateaddress,
  330. tct.f_cntrstatus,
  331. COUNT( tct.f_updateaddress ) statusCount
  332. FROM
  333. t_cntrno tct
  334. LEFT JOIN t_address ta ON tct.f_updateaddress = ta.f_id
  335. WHERE
  336. tct.f_status = 'T'
  337. GROUP BY
  338. tct.f_updateaddress,
  339. tct.f_cntrstatus
  340. ) tc
  341. LEFT JOIN sys_dict_data sdda ON sdda.dict_value = tc.f_cntrstatus
  342. AND sdda.dict_type = 'f_cntrstatus'
  343. ) b
  344. GROUP BY
  345. b.f_updateaddress
  346. ) car ON container.地点 = car.f_updateaddress
  347. <where>
  348. <if test="tCntrno.fUpdateaddress != null and tCntrno.fUpdateaddress != ''">
  349. container.地点 like concat('%', #{tCntrno.fUpdateaddress}, '%')</if>
  350. </where>
  351. </select>
  352. <select id="selectTCntrnoFNo" parameterType="TCntrno" resultMap="TCntrnoResult">
  353. SELECT
  354. f_id,
  355. f_no
  356. FROM
  357. t_cntrno
  358. WHERE
  359. f_no = #{fNo}
  360. </select>
  361. </mapper>