TVoyageMapper.xml 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  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.TVoyageMapper">
  6. <resultMap type="TVoyage" id="TVoyageResult">
  7. <result property="fId" column="f_id"/>
  8. <result property="fPid" column="f_pid"/>
  9. <result property="fNo" column="f_no"/>
  10. <result property="fPortofloadid" column="f_portofloadid"/>
  11. <result property="fPortofdischargeid" column="f_portofdischargeid"/>
  12. <result property="fDistinationid" column="f_distinationid"/>
  13. <result property="fPortoftransshipment" column="f_portoftransshipment"/>
  14. <result property="fEtd" column="f_ETD"/>
  15. <result property="fAtd" column="f_ATD"/>
  16. <result property="fEta" column="f_ETA"/>
  17. <result property="fAta" column="f_ATA"/>
  18. <result property="fDays" column="f_days"/>
  19. <result property="fDucomentrayoffdate" column="f_ducomentrayoffdate"/>
  20. <result property="fCutoffdate" column="f_cutoffdate"/>
  21. <result property="fTeu" column="f_teu"/>
  22. <result property="fManageid" column="f_manageid"/>
  23. <result property="fTel" column="f_tel"/>
  24. <result property="fStatus" column="f_status"/>
  25. <result property="createBy" column="create_by"/>
  26. <result property="createTime" column="create_time"/>
  27. <result property="updateBy" column="update_by"/>
  28. <result property="updateTime" column="update_time"/>
  29. <result property="remark" column="remark"/>
  30. <result property="fLaneid" column="f_laneid"/>
  31. </resultMap>
  32. <sql id="selectTVoyageVo">
  33. select f_id, f_pid, f_no, f_portofloadid, f_portofdischargeid, f_distinationid, f_portoftransshipment, f_ETD, f_ATD, f_ETA, f_ATA, f_days, f_ducomentrayoffdate, f_cutoffdate, f_teu, f_manageid, f_tel, case when f_status = 'T' then '正常' else '停用' end as f_status, create_by, create_time, update_by, update_time, remark,f_laneid from t_voyage
  34. </sql>
  35. <select id="selectTVoyageList" parameterType="TVoyage" resultMap="TVoyageResult">
  36. SELECT
  37. DISTINCT
  38. tv.f_id,
  39. tv.f_pid,
  40. te.f_name pidName,
  41. tv.f_no,
  42. tv.f_portofloadid,
  43. ta.f_name portofloadidName,
  44. tv.f_portofdischargeid,
  45. td.f_name portofdischargeidName,
  46. tv.f_distinationid,
  47. tr.f_name distinationidName,
  48. tv.f_portoftransshipment,
  49. ts.f_name portoftransshipmentName,
  50. tv.f_ETD,
  51. tv.f_ATD,
  52. tv.f_ETA,
  53. tv.f_ATA,
  54. tv.f_days,
  55. tv.f_ducomentrayoffdate,
  56. tv.f_cutoffdate,
  57. tv.f_teu,
  58. tv.f_manageid,
  59. su.user_name manageidName,
  60. tv.f_tel,
  61. CASE
  62. WHEN tv.f_status = 'T' THEN
  63. '正常' ELSE '停用'
  64. END AS f_status,
  65. TIMESTAMPDIFF(DAY,tv.f_ETD,DATE_FORMAT(tv.f_ducomentrayoffdate, '%Y-%m-%d %H:%i:%S')) closing,
  66. tv.create_by,
  67. tv.create_time,
  68. tv.update_by,
  69. tv.update_time,
  70. tv.remark,
  71. tv.f_laneid,
  72. tes.f_name as fLaneName
  73. FROM
  74. t_voyage tv
  75. LEFT JOIN t_vessel te ON tv.f_pid = te.f_id
  76. LEFT JOIN t_address ta ON tv.f_portofloadid = ta.f_id
  77. LEFT JOIN t_address td ON tv.f_portofdischargeid = td.f_id
  78. LEFT JOIN t_address tr ON tv.f_distinationid = tr.f_id
  79. LEFT JOIN t_address ts ON tv.f_portoftransshipment = ts.f_id
  80. LEFT JOIN sys_user su ON tv.f_manageid = su.user_id
  81. LEFT JOIN t_address tes ON tv.f_laneid = tes.f_id
  82. <where>
  83. <if test="fPid != null ">and tv.f_pid = #{fPid}</if>
  84. <if test="fNo != null and fNo != ''">and tv.f_no = #{fNo}</if>
  85. <if test="fPortofloadid != null ">and tv.f_portofloadid = #{fPortofloadid}</if>
  86. <if test="fPortofdischargeid != null ">and tv.f_portofdischargeid = #{fPortofdischargeid}</if>
  87. <if test="fDistinationid != null ">and tv.f_distinationid = #{fDistinationid}</if>
  88. <if test="fPortoftransshipment != null ">and tv.f_portoftransshipment = #{fPortoftransshipment}</if>
  89. <if test="fPortoftransshipment == null and empty != null">and tv.f_portoftransshipment IS NULL</if>
  90. <if test="fEtd != null ">and tv.f_ETD = #{fEtd}</if>
  91. <if test="fAtd != null ">and tv.f_ATD = #{fAtd}</if>
  92. <if test="fEta != null ">and tv.f_ETA = #{fEta}</if>
  93. <if test="fAta != null ">and tv.f_ATA = #{fAta}</if>
  94. <if test="fDays != null ">and tv.f_days = #{fDays}</if>
  95. <if test="fDucomentrayoffdate != null ">and tv.f_ducomentrayoffdate = #{fDucomentrayoffdate}</if>
  96. <if test="fCutoffdate != null ">and tv.f_cutoffdate = #{fCutoffdate}</if>
  97. <if test="fTeu != null and fTeu != ''">and tv.f_teu = #{fTeu}</if>
  98. <if test="fManageid != null ">and tv.f_manageid = #{fManageid}</if>
  99. <if test="fTel != null and fTel != ''">and tv.f_tel = #{fTel}</if>
  100. <if test="fStatus != null and fStatus != ''">and tv.f_status = #{fStatus}</if>
  101. <if test="createBy != null and createBy != ''">and tv.create_by like concat('%', #{createBy}, '%')</if>
  102. <if test="remark != null and remark != ''">and tv.remark like concat('%', #{remark}, '%')</if>
  103. <if test="pidName != null and pidName != ''">and te.f_name = #{pidName}</if>
  104. <if test="portofloadidName != null and portofloadidName != ''">and ta.f_name = #{portofloadidName}</if>
  105. <if test="portofdischargeidName != null and portofdischargeidName != ''">and td.f_name =
  106. #{portofdischargeidName}
  107. </if>
  108. <if test="distinationidName != null and distinationidName != ''">and tr.f_name = #{distinationidName}</if>
  109. <if test="portoftransshipmentName != null and portoftransshipmentName != ''">and ts.f_name =
  110. #{portoftransshipmentName}
  111. </if>
  112. <if test='cLoadDate != null and cLoadDate[0] != null and cLoadDate[0]!= ""'>
  113. and tv.create_time &gt;= #{cLoadDate[0]}
  114. </if>
  115. <if test='cLoadDate != null and cLoadDate[1] != null and cLoadDate[1]!= ""'>
  116. and tv.create_time &lt;= #{cLoadDate[1]}
  117. </if>
  118. <if test="fLaneid != null ">and f_laneid = #{fLaneid}</if>
  119. </where>
  120. </select>
  121. <select id="selectMessage" parameterType="TVoyage" resultMap="TVoyageResult">
  122. SELECT
  123. tv.f_id,
  124. tv.f_pid,
  125. te.f_name pidName,
  126. tv.f_no,
  127. tv.f_portofloadid,
  128. ta.f_name portofloadidName,
  129. tv.f_portofdischargeid,
  130. td.f_name portofdischargeidName,
  131. tv.f_distinationid,
  132. tr.f_name distinationidName,
  133. tv.f_portoftransshipment,
  134. ts.f_name portoftransshipmentName,
  135. tv.f_ETD,
  136. tv.f_ATD,
  137. tv.f_ETA,
  138. tv.f_ATA,
  139. tv.f_days,
  140. tv.f_ducomentrayoffdate,
  141. tv.f_cutoffdate,
  142. tv.f_teu,
  143. tv.f_manageid,
  144. su.user_name manageidName,
  145. tv.f_tel,
  146. CASE
  147. WHEN tv.f_status = 'T' THEN
  148. '正常' ELSE '停用'
  149. END AS f_status,
  150. TIMESTAMPDIFF(DAY,tv.f_ETD,DATE_FORMAT(tv.f_ducomentrayoffdate, '%Y-%m-%d %H:%i:%S')) closing,
  151. tv.create_by,
  152. tv.create_time,
  153. tv.update_by,
  154. tv.update_time,
  155. tv.remark,
  156. tv.f_laneid
  157. FROM
  158. t_voyage tv
  159. LEFT JOIN t_vessel te ON tv.f_pid = te.f_id
  160. LEFT JOIN t_address ta ON tv.f_portofloadid = ta.f_id
  161. LEFT JOIN t_address td ON tv.f_portofdischargeid = td.f_id
  162. LEFT JOIN t_address tr ON tv.f_distinationid = tr.f_id
  163. LEFT JOIN t_address ts ON tv.f_portoftransshipment = ts.f_id
  164. LEFT JOIN sys_user su ON tv.f_manageid = su.user_id
  165. <where>
  166. tv.f_status = 'T'
  167. AND (date(tv.f_ATD) >= DATE_SUB(CURDATE(), INTERVAL 2 DAY)
  168. OR tv.f_ATD IS NULL)
  169. <if test="fId != null ">and tv.f_id = #{fId}</if>
  170. <if test="fPid != null ">and tv.f_pid = #{fPid}</if>
  171. <if test="fNo != null and fNo != ''">and tv.f_no = #{fNo}</if>
  172. <if test="fPortofloadid != null ">and tv.f_portofloadid = #{fPortofloadid}</if>
  173. <if test="fPortofdischargeid != null ">and tv.f_portofdischargeid = #{fPortofdischargeid}</if>
  174. <if test="fDistinationid != null ">and tv.f_distinationid = #{fDistinationid}</if>
  175. <if test="fPortoftransshipment != null ">and tv.f_portoftransshipment = #{fPortoftransshipment}</if>
  176. <if test="fPortoftransshipment == null and empty != null">and tv.f_portoftransshipment IS NULL</if>
  177. <if test="fEtd != null ">and tv.f_ETD = #{fEtd}</if>
  178. <if test="fAtd != null ">and tv.f_ATD = #{fAtd}</if>
  179. <if test="fEta != null ">and tv.f_ETA = #{fEta}</if>
  180. <if test="fAta != null ">and tv.f_ATA = #{fAta}</if>
  181. <if test="fDays != null ">and tv.f_days = #{fDays}</if>
  182. <if test="fDucomentrayoffdate != null ">and tv.f_ducomentrayoffdate = #{fDucomentrayoffdate}</if>
  183. <if test="fCutoffdate != null ">and tv.f_cutoffdate = #{fCutoffdate}</if>
  184. <if test="fTeu != null and fTeu != ''">and tv.f_teu = #{fTeu}</if>
  185. <if test="fManageid != null ">and tv.f_manageid = #{fManageid}</if>
  186. <if test="fTel != null and fTel != ''">and tv.f_tel = #{fTel}</if>
  187. <if test="fStatus != null and fStatus != ''">and tv.f_status = #{fStatus}</if>
  188. <if test="createBy != null and createBy != ''">and tv.create_by like concat('%', #{createBy}, '%')</if>
  189. <if test="remark != null and remark != ''">and tv.remark like concat('%', #{remark}, '%')</if>
  190. <if test="pidName != null and pidName != ''">and te.f_name = #{pidName}</if>
  191. <if test="portofloadidName != null and portofloadidName != ''">and ta.f_name = #{portofloadidName}</if>
  192. <if test="portofdischargeidName != null and portofdischargeidName != ''">and td.f_name =
  193. #{portofdischargeidName}
  194. </if>
  195. <if test="distinationidName != null and distinationidName != ''">and tr.f_name = #{distinationidName}</if>
  196. <if test="portoftransshipmentName != null and portoftransshipmentName != ''">and ts.f_name =
  197. #{portoftransshipmentName}
  198. </if>
  199. <if test='cLoadDate != null and cLoadDate[0] != null and cLoadDate[0]!= ""'>
  200. and tv.create_time &gt;= #{cLoadDate[0]}
  201. </if>
  202. <if test='cLoadDate != null and cLoadDate[1] != null and cLoadDate[1]!= ""'>
  203. and tv.create_time &lt;= #{cLoadDate[1]}
  204. </if>
  205. <if test="fLaneid != null ">and f_laneid = #{fLaneid}</if>
  206. </where>
  207. </select>
  208. <select id="selectTVoyageListNew" parameterType="TVoyage" resultMap="TVoyageResult">
  209. SELECT
  210. tv.f_id,
  211. tv.f_pid,
  212. te.f_name pidName,
  213. tv.f_no,
  214. tv.f_portofloadid,
  215. ta.f_name portofloadidName,
  216. tv.f_portofdischargeid,
  217. td.f_name portofdischargeidName,
  218. tv.f_distinationid,
  219. tr.f_name distinationidName,
  220. tv.f_portoftransshipment,
  221. ts.f_name portoftransshipmentName,
  222. tv.f_ETD,
  223. tv.f_ATD,
  224. tv.f_ETA,
  225. tv.f_ATA,
  226. tv.f_days,
  227. tv.f_ducomentrayoffdate,
  228. tv.f_cutoffdate,
  229. tv.f_teu,
  230. tv.f_manageid,
  231. su.user_name manageidName,
  232. tv.f_tel,
  233. CASE
  234. WHEN tv.f_status = 'T' THEN
  235. '正常' ELSE '停用'
  236. END AS f_status,
  237. TIMESTAMPDIFF(DAY,tv.f_ETD,DATE_FORMAT(tv.f_ducomentrayoffdate, '%Y-%m-%d %H:%i:%S')) closing,
  238. tv.create_by,
  239. tv.create_time,
  240. tv.update_by,
  241. tv.update_time,
  242. tv.remark,
  243. tv.f_laneid
  244. FROM
  245. t_voyage tv
  246. LEFT JOIN t_vessel te ON tv.f_pid = te.f_id
  247. LEFT JOIN t_address ta ON tv.f_portofloadid = ta.f_id
  248. LEFT JOIN t_address td ON tv.f_portofdischargeid = td.f_id
  249. LEFT JOIN t_address tr ON tv.f_distinationid = tr.f_id
  250. LEFT JOIN t_address ts ON tv.f_portoftransshipment = ts.f_id
  251. LEFT JOIN sys_user su ON tv.f_manageid = su.user_id
  252. <where>
  253. tv.f_status = 'T'
  254. AND (date(tv.f_ATD) >= DATE_SUB(CURDATE(), INTERVAL 2 DAY)
  255. OR tv.f_ATD IS NULL)
  256. <if test="fPid != null ">and tv.f_pid = #{fPid}</if>
  257. <if test="fNo != null and fNo != ''">and tv.f_no = #{fNo}</if>
  258. <if test="fPortofloadid != null ">and tv.f_portofloadid = #{fPortofloadid}</if>
  259. <if test="fPortofdischargeid != null ">and tv.f_portofdischargeid = #{fPortofdischargeid}</if>
  260. <if test="fDistinationid != null ">and tv.f_distinationid = #{fDistinationid}</if>
  261. <if test="fPortoftransshipment != null ">and tv.f_portoftransshipment = #{fPortoftransshipment}</if>
  262. <if test="fPortoftransshipment == null and empty != null">and tv.f_portoftransshipment IS NULL</if>
  263. <if test="fEtd != null ">and tv.f_ETD = #{fEtd}</if>
  264. <if test="fAtd != null ">and tv.f_ATD = #{fAtd}</if>
  265. <if test="fEta != null ">and tv.f_ETA = #{fEta}</if>
  266. <if test="fAta != null ">and tv.f_ATA = #{fAta}</if>
  267. <if test="fDays != null ">and tv.f_days = #{fDays}</if>
  268. <if test="fDucomentrayoffdate != null ">and tv.f_ducomentrayoffdate = #{fDucomentrayoffdate}</if>
  269. <if test="fCutoffdate != null ">and tv.f_cutoffdate = #{fCutoffdate}</if>
  270. <if test="fTeu != null and fTeu != ''">and tv.f_teu = #{fTeu}</if>
  271. <if test="fManageid != null ">and tv.f_manageid = #{fManageid}</if>
  272. <if test="fTel != null and fTel != ''">and tv.f_tel = #{fTel}</if>
  273. <if test="fStatus != null and fStatus != ''">and tv.f_status = #{fStatus}</if>
  274. <if test="createBy != null and createBy != ''">and tv.create_by like concat('%', #{createBy}, '%')</if>
  275. <if test="remark != null and remark != ''">and tv.remark like concat('%', #{remark}, '%')</if>
  276. <if test="pidName != null and pidName != ''">and te.f_name = #{pidName}</if>
  277. <if test="portofloadidName != null and portofloadidName != ''">and ta.f_name = #{portofloadidName}</if>
  278. <if test="portofdischargeidName != null and portofdischargeidName != ''">and td.f_name =
  279. #{portofdischargeidName}
  280. </if>
  281. <if test="distinationidName != null and distinationidName != ''">and tr.f_name = #{distinationidName}</if>
  282. <if test="portoftransshipmentName != null and portoftransshipmentName != ''">and ts.f_name =
  283. #{portoftransshipmentName}
  284. </if>
  285. <if test='cLoadDate != null and cLoadDate[0] != null and cLoadDate[0]!= ""'>
  286. and tv.create_time &gt;= #{cLoadDate[0]}
  287. </if>
  288. <if test='cLoadDate != null and cLoadDate[1] != null and cLoadDate[1]!= ""'>
  289. and tv.create_time &lt;= #{cLoadDate[1]}
  290. </if>
  291. <if test="fLaneid != null ">and f_laneid = #{fLaneid}</if>
  292. </where>
  293. </select>
  294. <select id="selectTVoyageById" parameterType="Long" resultMap="TVoyageResult">
  295. SELECT
  296. tv.f_id,
  297. tv.f_pid,
  298. te.f_name pidName,
  299. tv.f_no,
  300. tv.f_portofloadid,
  301. ta.f_name portofloadidName,
  302. tv.f_portofdischargeid,
  303. td.f_name portofdischargeidName,
  304. tv.f_distinationid,
  305. tr.f_name distinationidName,
  306. tv.f_portoftransshipment,
  307. ts.f_name portoftransshipmentName,
  308. tv.f_ETD,
  309. tv.f_ATD,
  310. tv.f_ETA,
  311. tv.f_ATA,
  312. tv.f_days,
  313. tv.f_ducomentrayoffdate,
  314. tv.f_cutoffdate,
  315. tv.f_teu,
  316. tv.f_manageid,
  317. su.user_name manageidName,
  318. tv.f_tel,
  319. tv.f_status,
  320. TIMESTAMPDIFF(
  321. DAY,
  322. tv.f_ETD,
  323. DATE_FORMAT( tv.f_cutoffdate, '%Y-%m-%d %H:%i:%S' )) closing,
  324. tv.create_by,
  325. tv.create_time,
  326. tv.update_by,
  327. tv.update_time,
  328. tv.remark,
  329. tv.f_laneid
  330. FROM
  331. t_voyage tv
  332. LEFT JOIN t_vessel te ON tv.f_pid = te.f_id
  333. LEFT JOIN t_address ta ON tv.f_portofloadid = ta.f_id
  334. LEFT JOIN t_address td ON tv.f_portofdischargeid = td.f_id
  335. LEFT JOIN t_address tr ON tv.f_distinationid = tr.f_id
  336. LEFT JOIN t_address ts ON tv.f_portoftransshipment = ts.f_id
  337. LEFT JOIN sys_user su ON tv.f_manageid = su.user_id
  338. WHERE
  339. tv.f_id = #{fId}
  340. </select>
  341. <insert id="insertTVoyage" parameterType="TVoyage" useGeneratedKeys="true" keyProperty="fId">
  342. insert into t_voyage
  343. <trim prefix="(" suffix=")" suffixOverrides=",">
  344. <if test="fPid != null">f_pid,</if>
  345. <if test="fNo != null and fNo != ''">f_no,</if>
  346. <if test="fPortofloadid != null">f_portofloadid,</if>
  347. <if test="fPortofdischargeid != null">f_portofdischargeid,</if>
  348. <if test="fDistinationid != null">f_distinationid,</if>
  349. <if test="fPortoftransshipment != null">f_portoftransshipment,</if>
  350. <if test="fEtd != null">f_ETD,</if>
  351. <if test="fAtd != null">f_ATD,</if>
  352. <if test="fEta != null">f_ETA,</if>
  353. <if test="fAta != null">f_ATA,</if>
  354. <if test="fDays != null">f_days,</if>
  355. <if test="fDucomentrayoffdate != null">f_ducomentrayoffdate,</if>
  356. <if test="fCutoffdate != null">f_cutoffdate,</if>
  357. <if test="fTeu != null">f_teu,</if>
  358. <if test="fManageid != null">f_manageid,</if>
  359. <if test="fTel != null and fTel != ''">f_tel,</if>
  360. <if test="fStatus != null">f_status,</if>
  361. <if test="createBy != null">create_by,</if>
  362. <if test="createTime != null">create_time,</if>
  363. <if test="updateBy != null">update_by,</if>
  364. <if test="updateTime != null">update_time,</if>
  365. <if test="remark != null">remark,</if>
  366. <if test="fLaneid != null">f_laneid,</if>
  367. </trim>
  368. <trim prefix="values (" suffix=")" suffixOverrides=",">
  369. <if test="fPid != null">#{fPid},</if>
  370. <if test="fNo != null and fNo != ''">#{fNo},</if>
  371. <if test="fPortofloadid != null">#{fPortofloadid},</if>
  372. <if test="fPortofdischargeid != null">#{fPortofdischargeid},</if>
  373. <if test="fDistinationid != null">#{fDistinationid},</if>
  374. <if test="fPortoftransshipment != null">#{fPortoftransshipment},</if>
  375. <if test="fEtd != null">#{fEtd},</if>
  376. <if test="fAtd != null">#{fAtd},</if>
  377. <if test="fEta != null">#{fEta},</if>
  378. <if test="fAta != null">#{fAta},</if>
  379. <if test="fDays != null">#{fDays},</if>
  380. <if test="fDucomentrayoffdate != null">#{fDucomentrayoffdate},</if>
  381. <if test="fCutoffdate != null">#{fCutoffdate},</if>
  382. <if test="fTeu != null">#{fTeu},</if>
  383. <if test="fManageid != null">#{fManageid},</if>
  384. <if test="fTel != null and fTel != ''">#{fTel},</if>
  385. <if test="fStatus != null">#{fStatus},</if>
  386. <if test="createBy != null">#{createBy},</if>
  387. <if test="createTime != null">#{createTime},</if>
  388. <if test="updateBy != null">#{updateBy},</if>
  389. <if test="updateTime != null">#{updateTime},</if>
  390. <if test="remark != null">#{remark},</if>
  391. <if test="fLaneid != null">#{fLaneid},</if>
  392. </trim>
  393. </insert>
  394. <update id="updateTVoyage" parameterType="TVoyage">
  395. update t_voyage
  396. <trim prefix="SET" suffixOverrides=",">
  397. <if test="fPid != null">f_pid = #{fPid},</if>
  398. <if test="fNo != null and fNo != ''">f_no = #{fNo},</if>
  399. <if test="fPortofloadid != null">f_portofloadid = #{fPortofloadid},</if>
  400. <if test="fPortofdischargeid != null">f_portofdischargeid = #{fPortofdischargeid},</if>
  401. <if test="fPortofdischargeid == null">f_portofdischargeid = null,</if>
  402. <if test="fDistinationid != null">f_distinationid = #{fDistinationid},</if>
  403. <if test="fPortoftransshipment != null">f_portoftransshipment = #{fPortoftransshipment},</if>
  404. <if test="fPortoftransshipment == null">f_portoftransshipment = null,</if>
  405. <if test="fEtd != null">f_ETD = #{fEtd},</if>
  406. <if test="fAtd != null">f_ATD = #{fAtd},</if>
  407. <if test="fEta != null">f_ETA = #{fEta},</if>
  408. <if test="fAta != null">f_ATA = #{fAta},</if>
  409. <if test="fDays != null">f_days = #{fDays},</if>
  410. <if test="fDucomentrayoffdate != null">f_ducomentrayoffdate = #{fDucomentrayoffdate},</if>
  411. <if test="fCutoffdate != null">f_cutoffdate = #{fCutoffdate},</if>
  412. <if test="fTeu != null">f_teu = #{fTeu},</if>
  413. <if test="fManageid != null">f_manageid = #{fManageid},</if>
  414. <if test="fTel != null and fTel != ''">f_tel = #{fTel},</if>
  415. <if test="fStatus != null">f_status = #{fStatus},</if>
  416. <if test="createBy != null">create_by = #{createBy},</if>
  417. <if test="createTime != null">create_time = #{createTime},</if>
  418. <if test="updateBy != null">update_by = #{updateBy},</if>
  419. <if test="updateTime != null">update_time = #{updateTime},</if>
  420. <if test="remark != null">remark = #{remark},</if>
  421. <if test="fLaneid != null">f_laneid = #{fLaneid},</if>
  422. </trim>
  423. where f_id = #{fId}
  424. </update>
  425. <delete id="deleteTVoyageById" parameterType="Long">
  426. delete from t_voyage where f_id = #{fId}
  427. </delete>
  428. <delete id="deleteTVoyageByIds" parameterType="String">
  429. delete from t_voyage where f_id in
  430. <foreach item="fId" collection="array" open="(" separator="," close=")">
  431. #{fId}
  432. </foreach>
  433. </delete>
  434. <select id="selectTVoyagefNo" parameterType="TVoyage" resultMap="TVoyageResult">
  435. SELECT
  436. f_id,
  437. f_no
  438. FROM
  439. t_voyage
  440. WHERE
  441. f_no = #{fNo}
  442. </select>
  443. <select id="selectTVoyagefNumber" resultType="map">
  444. SELECT
  445. f_id fId,
  446. f_no fNo
  447. FROM
  448. t_voyage
  449. WHERE
  450. f_status = 'T'
  451. <if test="fPid != null ">and f_pid = #{fPid}</if>
  452. <if test="fNo != null and fNo != ''">and f_no = #{fNo}</if>
  453. <if test="fPortofloadid != null ">and f_portofloadid = #{fPortofloadid}</if>
  454. <if test="fPortofdischargeid != null ">and f_portofdischargeid = #{fPortofdischargeid}</if>
  455. <if test="fDistinationid != null ">and f_distinationid = #{fDistinationid}</if>
  456. <if test="fPortoftransshipment != null ">and f_portoftransshipment = #{fPortoftransshipment}</if>
  457. <if test="fEtd != null ">and f_ETD = #{fEtd}</if>
  458. <if test="fAtd != null ">and f_ATD = #{fAtd}</if>
  459. <if test="fEta != null ">and f_ETA = #{fEta}</if>
  460. <if test="fAta != null ">and f_ATA = #{fAta}</if>
  461. <if test="fDays != null ">and f_days = #{fDays}</if>
  462. <if test="fDucomentrayoffdate != null ">and f_ducomentrayoffdate = #{fDucomentrayoffdate}</if>
  463. <if test="fCutoffdate != null ">and f_cutoffdate = #{fCutoffdate}</if>
  464. <if test="fTeu != null and fTeu != ''">and f_teu = #{fTeu}</if>
  465. <if test="fManageid != null ">and f_manageid = #{fManageid}</if>
  466. <if test="fTel != null and fTel != ''">and f_tel = #{fTel}</if>
  467. <if test="fStatus != null and fStatus != ''">and f_status = #{fStatus}</if>
  468. <if test="fLaneid != null ">and f_laneid = #{fLaneid}</if>
  469. </select>
  470. <!--查询航次信息是否重复-->
  471. <select id="selectTVoyageMessage" parameterType="Long" resultMap="TVoyageResult">
  472. <include refid="selectTVoyageVo"/>
  473. where f_no = #{fNo}
  474. and f_portofloadid = #{fPortofloadid}
  475. and f_distinationid = #{fDistinationid}
  476. and f_ETD = #{fEtd}
  477. <if test="fPortoftransshipment != null ">and f_portoftransshipment = #{fPortoftransshipment}</if>
  478. <if test="fPortoftransshipment == null ">and f_portoftransshipment IS NULL</if>
  479. </select>
  480. <select id="selectTVoyageIds" parameterType="TVoyage" resultType="long">
  481. SELECT
  482. tv.f_id
  483. FROM
  484. t_voyage tv
  485. <where>
  486. tv.f_status = 'T'
  487. AND (date(tv.f_ATD) >= DATE_SUB(CURDATE(), INTERVAL 2 DAY)
  488. OR tv.f_ATD IS NULL)
  489. <if test="fPortofloadid != null ">and tv.f_portofloadid = #{fPortofloadid}</if>
  490. <if test="fDistinationid != null ">and tv.f_distinationid = #{fDistinationid}</if>
  491. <if test="fPortoftransshipment != null ">and tv.f_portoftransshipment = #{fPortoftransshipment}</if>
  492. <if test="fPortoftransshipment == null">and tv.f_portoftransshipment IS NULL</if>
  493. </where>
  494. </select>
  495. <select id="selectTVoyageByFid" parameterType="TVoyage" resultMap="TVoyageResult">
  496. SELECT
  497. tv.f_id,
  498. tv.f_pid,
  499. te.f_name pidName,
  500. tv.f_no,
  501. tv.f_portofloadid,
  502. ta.f_name portofloadidName,
  503. tv.f_portofdischargeid,
  504. td.f_name portofdischargeidName,
  505. tv.f_distinationid,
  506. tr.f_name distinationidName,
  507. tv.f_portoftransshipment,
  508. ts.f_name portoftransshipmentName,
  509. tv.f_ETD,
  510. tv.f_ATD,
  511. tv.f_ETA,
  512. tv.f_ATA,
  513. tv.f_days,
  514. tv.f_ducomentrayoffdate,
  515. tv.f_cutoffdate,
  516. tv.f_teu,
  517. tv.f_manageid,
  518. su.user_name manageidName,
  519. tv.f_tel,
  520. CASE
  521. WHEN tv.f_status = 'T' THEN
  522. '正常' ELSE '停用'
  523. END AS f_status,
  524. TIMESTAMPDIFF(
  525. DAY,
  526. tv.f_ETD,
  527. DATE_FORMAT( tv.f_ducomentrayoffdate, '%Y-%m-%d %H:%i:%S' )) closing,
  528. tv.create_by,
  529. tv.create_time,
  530. tv.update_by,
  531. tv.update_time,
  532. tv.remark,
  533. tv.f_laneid,
  534. SUM( CASE WHEN tc.fNo = '20GP' THEN tc.price ELSE 0 END ) AS twenty,
  535. SUM( CASE WHEN tc.fNo = '40HC' THEN tc.price ELSE 0 END ) AS fortyHc,
  536. SUM( CASE WHEN tc.fNo = '40RH' THEN tc.price ELSE 0 END ) AS fortyRh
  537. FROM
  538. t_voyage tv
  539. LEFT JOIN t_vessel te ON tv.f_pid = te.f_id
  540. LEFT JOIN t_address ta ON tv.f_portofloadid = ta.f_id
  541. LEFT JOIN t_address td ON tv.f_portofdischargeid = td.f_id
  542. LEFT JOIN t_address tr ON tv.f_distinationid = tr.f_id
  543. LEFT JOIN t_address ts ON tv.f_portoftransshipment = ts.f_id
  544. LEFT JOIN sys_user su ON tv.f_manageid = su.user_id
  545. LEFT JOIN (
  546. SELECT
  547. ti.f_pid pId,
  548. ti.f_price price,
  549. tc.f_no fNo
  550. FROM
  551. t_ctnprice_items ti
  552. LEFT JOIN t_cntr tc ON ti.f_cntrid = tc.f_id
  553. ) tc
  554. ON tv.f_id = tc.pId
  555. <where>
  556. tv.f_status = 'T'
  557. AND (date(tv.f_ATD) >= DATE_SUB(CURDATE(), INTERVAL 2 DAY)
  558. OR tv.f_ATD IS NULL)
  559. AND tv.f_id = #{fId}
  560. </where>
  561. </select>
  562. <select id="shipDynamic" resultType="map">
  563. SELECT
  564. ta.fName fName, /*船名*/
  565. ta.fNo fNo,/*航次*/
  566. ta.portofloadName portofloadName,/*起运港*/
  567. ta.distinationName distinationName,/*目的港*/
  568. IFNULL(ta.fWeight,0) fWeight,/*容量*/
  569. IFNULL(tb.boxNumber,0) boxNumber,/*实际容量*/
  570. ta.fETD fETD,/*预计开船*/
  571. ta.fETA fETA,/*预计到港*/
  572. ta.fATD fATD,/*实际开船*/
  573. ta.fATA fATA,/*实际到港*/
  574. ta.fDays fDays/*航程*/
  575. FROM
  576. (
  577. SELECT
  578. tv.f_name fName, /*船名*/
  579. ty.f_no fNo,/*航次*/
  580. ta.f_name portofloadName,/*起运港*/
  581. tr.f_name distinationName,/*目的港*/
  582. tv.f_weight fWeight,/*容量*/
  583. ty.f_ETD fETD,/*预计开船*/
  584. ty.f_ETA fETA,/*预计到港*/
  585. ty.f_ATD fATD,/*实际开船*/
  586. ty.f_ATA fATA,/*实际到港*/
  587. ty.f_days fDays,/*航程*/
  588. ty.f_id voyid,/*航线ID*/
  589. tv.f_id vslid/*航ID*/
  590. FROM
  591. t_voyage ty
  592. LEFT JOIN t_vessel tv ON ty.f_pid = tv.f_id
  593. LEFT JOIN t_address ta ON ty.f_portofloadid = ta.f_id
  594. LEFT JOIN t_address tr ON ty.f_distinationid = tr.f_id
  595. )ta
  596. LEFT JOIN
  597. (
  598. SELECT
  599. tc.vesselName,
  600. tc.voyageName,
  601. SUM(tc.boxNumber)boxNumber
  602. FROM
  603. (
  604. SELECT
  605. tc.f_cntrno fCntrno,
  606. tr.f_no fNo,
  607. tw.f_vslid vesselName,
  608. tw.f_voyid voyageName,
  609. CASE
  610. WHEN SUBSTR(tr.f_no,1,2) = '20' THEN 1
  611. WHEN SUBSTR(tr.f_no,1,2) ='40' THEN 2
  612. ELSE 0
  613. END AS boxNumber
  614. FROM
  615. t_warehousebills_cntritems tc
  616. LEFT JOIN t_cntrno tn ON tn.f_no = tc.f_cntrno
  617. LEFT JOIN t_cntr tr ON tn.f_typeid = tr.f_id
  618. LEFT JOIN t_warehousebills tw ON tw.f_id = tc.f_pid
  619. WHERE tr.f_no IS NOT NULL
  620. )tc
  621. GROUP BY tc.vesselName,tc.voyageName
  622. )tb
  623. ON ta.voyid = tb.voyageName AND ta.vslid = tb.vesselName
  624. ORDER BY ta.fETA DESC
  625. LIMIT 10
  626. </select>
  627. </mapper>