TCntrnoMapper.xml 17 KB

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