OrderBillsPlansMapper.xml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  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.system.mapper.OrderBillsPlansMapper">
  6. <insert id="insertLoadFeeItems">
  7. Insert Into LoadFeeItems (SysID, EntityID, LineNo, CarID, ItemID, ItemProp, ItemAuditType, Dc, Qty, Price, Amt, AMT1, AMT2, AMTORG,
  8. OpUserID, OpUserName, SrcActID, SrcEntityID, SrcLineNo)
  9. values (1, #{o.loadBillsEntityId}, #{i.lineNo}, #{o.carId}, #{i.itemId}, #{i.itemProp}, #{i.auditType}, 'C', 1,
  10. #{i.amt}, #{i.amt}, #{i.amt}, #{i.amt}, #{i.amt},
  11. #{e.EmplId}, #{e.empl}, #{o.actId}, #{o.entityId}, #{o.lineNo})
  12. </insert>
  13. <insert id="insertAttachMngs">
  14. insert into AttachMngs (SYSID, ENTITYID, ACTID, LINENO, USERNAME,ATTACHNAME)
  15. values (#{loadBillsSysId}, #{loadBillsEntityId}, #{actId}, #{lineNo}, #{userName}, #{attachName})
  16. </insert>
  17. <update id="updateOrderBillsPlansByid">
  18. update OrderBillsPlans
  19. set LoadQty = #{loadQty},
  20. LoadDate = #{loadDate},
  21. UnLoadQty = #{unLoadQty},
  22. UnLoadDate = #{unLoadDate},
  23. ifDetour = #{ifDetour},
  24. <if test="detourEmptyMile != null">
  25. detourEmptyMile = #{detourEmptyMile},
  26. </if>
  27. <if test="detourLoadMile != null">
  28. detourLoadMile = #{detourLoadMile},
  29. </if>
  30. <if test="detourDesc != null">
  31. detourDesc = #{detourDesc},
  32. </if>
  33. driverassdesc = #{driverassdesc}
  34. where sysId = '1'
  35. and OrderNo = #{orderNo}
  36. </update>
  37. <update id="updateOrderBillsPlansByOrderNo">
  38. update OrderBillsPlans
  39. set loadetc = #{loadetc},
  40. loadtoll = #{loadtoll},
  41. oilhomeQty = #{oilhomeQty},
  42. oilhomeAmt = #{oilhomeAmt},
  43. oilappoint1Qty = #{oilappoint1Qty},
  44. oilappoint1Amt = #{oilappoint1Amt},
  45. oilappoint2Qty = #{oilappoint2Qty},
  46. oilappoint2Amt = #{oilappoint2Amt},
  47. oilappoint3Qty = #{oilappoint3Qty},
  48. oilappoint3Amt = #{oilappoint3Amt},
  49. oilcash1Qty = #{oilcash1Qty},
  50. oilcash1Amt = #{oilcash1Amt},
  51. oilcardQty = #{oilcardQty},
  52. oilcardAmt = #{oilcardAmt},
  53. oilcard1Qty = #{oilcardQty},
  54. oilcard1Amt = #{oilcardAmt},
  55. driverassdesc = #{driverassdesc}
  56. where orderNo = #{orderNo}
  57. </update>
  58. <update id="updateOrderBillsPlansBySysidEntityidLineno">
  59. update LoadFeeItems
  60. set Price = #{amt},
  61. Amt = #{amt},
  62. AMT1 = #{amt},
  63. AMT2 = #{amt},
  64. AMTORG = #{amt},
  65. remarks = #{remarks}
  66. where sysId = '1'
  67. AND entityid = #{entityId}
  68. and lineno = #{lineNo}
  69. </update>
  70. <update id="updateLoadBillsByEntityID">
  71. update LoadBills
  72. set gasstation1 = #{gasstation1},
  73. gasstation2 = #{gasstation2},
  74. gasstation3 = #{gasstation3}
  75. where SrcEntityID = #{entityId} and SrcLineNo = #{lineNo}
  76. </update>
  77. <update id="submitAudit">
  78. update OrderBillsPlans
  79. set IfStarted = 'S',
  80. startDate = CURRENT_TIMESTAMP
  81. where sysId = '1'
  82. and OrderNo = #{orderNo}
  83. </update>
  84. <update id="approved">
  85. update OrderBillsPlans
  86. set IfStarted = 'A'
  87. where sysId = '1'
  88. and OrderNo = #{orderNo}
  89. </update>
  90. <update id="theAuditFailed">
  91. update OrderBillsPlans
  92. set IfStarted = 'B'
  93. where sysId = '1'
  94. and OrderNo = #{orderNo}
  95. </update>
  96. <update id="approvedTaskList">
  97. UPDATE wf_TaskList SET status= 2 WHERE SYSID = '1' AND ACTID =#{actId} AND ENTITYID = #{entityId}
  98. </update>
  99. <update id="theAuditFailedTaskList">
  100. UPDATE wf_TaskList SET status= 0 WHERE SYSID = '1' AND ACTID =#{actId} AND ENTITYID = #{entityId}
  101. </update>
  102. <update id="upReceipts">
  103. update OrderBillsPlans set IfOrder2ed = 'S' where sysId = '1' and OrderNo = #{orderNo}
  104. </update>
  105. <update id="addAReviewComment">
  106. update loadbills set ApplyDate = CURRENT_TIMESTAMP, audit2Desc = #{audit2Desc} where SrcEntityID = #{entityId} and SrcLineNo = #{lineNo}
  107. </update>
  108. <update id="approvedTaskListV1">
  109. UPDATE wf_TaskList SET status= #{status} WHERE SYSID = '1' AND ACTID =#{actId} AND ENTITYID = #{entityId}
  110. </update>
  111. <delete id="deleteLoadFeeItemsByEntityId">
  112. delete from LoadFeeItems where sysid = 1 and entityid = #{entityId}
  113. </delete>
  114. <delete id="deleteTmsAttachMngsByAttachId">
  115. delete from AttachMngs where attachId = #{attachId}
  116. </delete>
  117. <select id="getOrderBillsPlansLsit" parameterType="Map" resultType="com.ruoyi.system.domain.WfTaskList">
  118. Select Distinct p.SysID sysId
  119. , p.EntityID entityId
  120. , p.LineNo lineNo
  121. , p.OrderNo orderNo
  122. ,p.CarID carID
  123. , p.CarRegNo carRegNo
  124. ,p.PlanLoadDate planLoadDate
  125. , p.LoadDate loadDate
  126. , p.LoadAddr loadAddr
  127. , p.EMPTYADDR1 emptyAddr1
  128. , p.EMPTYADDR2 emptyAddr2
  129. ,p.PlanUnLoadDate planUnLoadDate
  130. , p.UnLoadDate unLoadDate
  131. , p.UnLoadAddr unLoadAddr
  132. , p.Remarks remarks
  133. ,t.TaskID taskId
  134. , t.Status status
  135. ,t.AuditStatus auditStatus
  136. , t.ActID wfActId
  137. ,c.SName corpSName
  138. , c.CName corpCName
  139. , g.CName goodsCName
  140. ,l.SName loadFactory
  141. , ul.SName unLoadFactory
  142. ,dr1.Empl driver1Name
  143. ,dr1.mobile driver1mobile
  144. , sp.Empl sUPERCARGOName
  145. ,e.Empl transact
  146. , b.BillDate billDate
  147. , p.rightqty
  148. , b.billStatus
  149. , p.ifLoaded ifLoaded
  150. , p.ifUnLoaded ifUnLoaded
  151. , p.ifStarted ifStarted
  152. , p.ifOrder2ed ifOrder2ed
  153. from wf_TaskList t
  154. Left join LoadBills b on (b.SysID=t.SysID and b.EntityID=t.EntityID)
  155. Left join OrderBillsPlans p on (p.SysID=b.SysID and p.EntityID=b.SrcEntityID and p.LineNo=b.SrcLineNo)
  156. Left join Empls e on (e.SysID=b.SysID and e.EmplID=b.TransactID)
  157. Left join Empls dr1 on (dr1.SysID=b.SysID and dr1.EmplID=p.DRIVER1ID)
  158. Left join Empls sp on (sp.SysID=b.SysID and sp.EmplID=p.SUPERCARGOID)
  159. Left join Corps c on (c.SysID=p.SysID and c.CorpID=p.CorpID)
  160. Left join Corps l on (l.SysID=p.SysID and l.CorpID=p.LoadFactoryID)
  161. Left join Corps ul on (ul.SysID=b.SysID and ul.CorpID=p.UnLoadFactoryID)
  162. Left join Goods g on (g.SysID=b.SysID and g.GoodsID=b.GoodsID)
  163. <where>
  164. t.SysID=1
  165. <if test="type == 'BD'">
  166. and t.ActID=317
  167. <if test="flowType == '未装车'">
  168. and p.ifLoaded = 'F' and p.ifUnLoaded = 'F' and (p.ifOrder2ed = 'F' or p.ifOrder2ed = 'T')
  169. </if>
  170. <if test="flowType == '未卸车'">
  171. and p.ifLoaded = 'T' and p.ifUnLoaded = 'F' and (p.ifOrder2ed = 'F' or p.ifOrder2ed = 'T')
  172. </if>
  173. <if test="flowType == '已卸车'">
  174. and p.ifLoaded = 'T' and p.ifUnLoaded = 'T' and (p.ifOrder2ed = 'F' or p.ifOrder2ed = 'T')
  175. </if>
  176. <if test="flowType == '已提交'">
  177. and p.ifLoaded = 'T' and p.ifUnLoaded = 'T' and p.ifOrder2ed = 'S'
  178. </if>
  179. <if test="flowType == '已审核'">
  180. and p.ifLoaded = 'T' and p.ifUnLoaded = 'T' and p.IfOrder2ed = 'O'
  181. </if>
  182. </if>
  183. <if test="type == 'BX'">
  184. and t.ActID = #{actId, jdbcType=VARCHAR}
  185. <if test="flowType == '未提交'">
  186. and p.ifStarted = 'F'
  187. </if>
  188. <if test="flowType == '已提交'">
  189. and p.ifStarted = 'S'
  190. </if>
  191. <if test="flowType == '已通过'">
  192. and p.ifStarted = 'A'
  193. </if>
  194. <if test="flowType == '已退回'">
  195. and p.ifStarted = 'B'
  196. </if>
  197. </if>
  198. and ((b.CarID=-1) or ((b.CarID &lt;&gt; -1))) and p.IfOrder1ed = 'T'
  199. <if test="dataStart != null and dataStart != '' and dataEnd != null and dataEnd != ''">
  200. and b.BillDate >= #{dataStart, jdbcType=VARCHAR} and b.BillDate &lt;= #{dataEnd, jdbcType=VARCHAR}
  201. </if>
  202. <if test="role == 0">
  203. and p.DeptUserID = #{emplId, jdbcType=VARCHAR}
  204. </if>
  205. <if test="role == 1">
  206. and ((p.DRIVER1ID=#{emplId, jdbcType=VARCHAR}) or (p.SUPERCARGOID=#{emplId, jdbcType=VARCHAR}))
  207. </if>
  208. <if test="orderNo != null and orderNo != ''">
  209. and (p.CarRegNo like #{orderNo}
  210. or p.loadAddr like #{orderNo}
  211. or p.unLoadAddr like #{orderNo}
  212. or g.CName like #{orderNo})
  213. </if>
  214. </where>
  215. ORDER BY b.BillDate DESC ROWS #{head} TO #{tail}
  216. </select>
  217. <select id="getsTheQuantityOfTheReturnedOrder" resultType="java.lang.Integer">
  218. Select
  219. COUNT(1)
  220. from wf_TaskList t
  221. Left join LoadBills b on (b.SysID=t.SysID and b.EntityID=t.EntityID)
  222. Left join OrderBillsPlans p on (p.SysID=b.SysID and p.EntityID=b.SrcEntityID and p.LineNo=b.SrcLineNo)
  223. Left join Empls e on (e.SysID=b.SysID and e.EmplID=b.TransactID)
  224. Left join Empls dr1 on (dr1.SysID=b.SysID and dr1.EmplID=p.DRIVER1ID)
  225. Left join Empls sp on (sp.SysID=b.SysID and sp.EmplID=p.SUPERCARGOID)
  226. Left join Corps c on (c.SysID=p.SysID and c.CorpID=p.CorpID)
  227. Left join Corps l on (l.SysID=p.SysID and l.CorpID=p.LoadFactoryID)
  228. Left join Corps ul on (ul.SysID=b.SysID and ul.CorpID=p.UnLoadFactoryID)
  229. Left join Goods g on (g.SysID=b.SysID and g.GoodsID=b.GoodsID)
  230. <where>
  231. t.SysID=1
  232. and t.ActID = #{actId, jdbcType=VARCHAR}
  233. and p.ifStarted = 'B'
  234. and ((b.CarID=-1) or ((b.CarID &lt;&gt; -1))) and p.IfOrder1ed = 'T'
  235. <if test="dataStart != null and dataStart != '' and dataEnd != null and dataEnd != ''">
  236. and b.BillDate >= #{dataStart, jdbcType=VARCHAR} and b.BillDate &lt;= #{dataEnd, jdbcType=VARCHAR}
  237. </if>
  238. <if test="role == 0">
  239. and p.DeptUserID = #{emplId, jdbcType=VARCHAR}
  240. </if>
  241. <if test="role == 1">
  242. and ((p.DRIVER1ID=#{emplId, jdbcType=VARCHAR}) or (p.SUPERCARGOID=#{emplId, jdbcType=VARCHAR}))
  243. </if>
  244. <if test="orderNo != null and orderNo != ''">
  245. and (p.CarRegNo like #{orderNo}
  246. or p.loadAddr like #{orderNo}
  247. or p.unLoadAddr like #{orderNo}
  248. or g.CName like #{orderNo})
  249. </if>
  250. </where>
  251. </select>
  252. <select id="getOrderBillsPlansByid" resultType="com.ruoyi.system.domain.OrderBillsPlans">
  253. Select g.CName goodsCName
  254. , p.LoadAddr loadAddr
  255. , l.SName loadFactory
  256. , p.LoadAttn loadAttn
  257. , p.LoadAttnTel loadAttnTel
  258. , p.UnLoadAddr unLoadAddr
  259. , ul.SName unLoadFactory
  260. , p.UnLoadAttn unLoadAttn
  261. , p.UNLoadAttnTel unLoadAttnTel
  262. , p.planRemarks
  263. , p.orderNo
  264. , p.loadQty
  265. , p.loadDate
  266. , p.unLoadQty
  267. , p.unLoadDate
  268. , p.emptyaddr1
  269. , p.odometerstart
  270. , p.emptyaddr2
  271. , p.odometerend
  272. , p.loadmile
  273. , p.remarks
  274. , p.driverassdesc
  275. , dr1.Empl driver1Name
  276. , dr1.mobile driver1mobile
  277. , p.sysId
  278. , b.entityId loadBillsEntityId
  279. , b.sysId loadBillsSysId
  280. , b.billStatus
  281. , p.detourEmptyMile detourEmptyMile
  282. , p.detourLoadMile detourLoadMile
  283. , p.detourDesc detourDesc
  284. , p.ifDetour ifDetour
  285. , p.CarRegNo carRegNo
  286. , p.ifLoaded ifLoaded
  287. , p.ifUnLoaded ifUnLoaded
  288. , p.ifStarted ifStarted
  289. , p.ifOrder2ed ifOrder2ed
  290. from OrderBillsPlans p
  291. Left join Empls e on (e.SysID = p.SysID and e.EmplID = p.TransactID)
  292. Left join Empls dr1 on (dr1.SysID = p.SysID and dr1.EmplID = p.DRIVER1ID)
  293. Left join Empls sp on (sp.SysID = p.SysID and sp.EmplID = p.SUPERCARGOID)
  294. Left join Corps c on (c.SysID = p.SysID and c.CorpID = p.CorpID)
  295. Left join Corps l on (l.SysID = p.SysID and l.CorpID = p.LoadFactoryID)
  296. Left join Corps ul on (ul.SysID = p.SysID and ul.CorpID = p.UnLoadFactoryID)
  297. Left join Goods g on (g.SysID = p.SysID and g.GoodsID = p.GoodsID)
  298. INNER JOIN LoadBills b
  299. ON
  300. p.SysID = b.SysID
  301. AND p.EntityID = b.SrcEntityID
  302. AND p.LineNo = b.SrcLineNo
  303. where p.SysID = 1
  304. and p.OrderNo = #{orderNo}
  305. </select>
  306. <select id="getItemsList" resultType="com.ruoyi.system.domain.vo.ItemsVo">
  307. select itemId, cName, itemProp, auditType from Items where SysID=1 and itemProp='F' order by zorder
  308. </select>
  309. <select id="getLoadFeeitemsMapByentityIdKeyItemId" resultType="java.util.Map">
  310. select itemId, atm1, entityId from LoadFeeItems where entityId = #{entityId}
  311. </select>
  312. <select id="getGasStations" resultType="com.ruoyi.system.domain.GasStations">
  313. select gasStationId, cName from GasStations
  314. </select>
  315. <select id="getOrderBillsPlansByOrder" resultType="com.ruoyi.system.domain.vo.OrderBillsPlansVo">
  316. select o.loadetc
  317. , o.loadtoll
  318. , o.oilhomeQty
  319. , o.oilhomeAmt
  320. , o.oilappoint1Qty
  321. , o.oilappoint1Amt
  322. , o.oilappoint2Qty
  323. , o.oilappoint2Amt
  324. , o.oilcash1Qty
  325. , o.oilcash1Amt
  326. , o.oilcardQty
  327. , o.oilcardAmt
  328. , b.gasstation1
  329. , b.gasstation2
  330. , o.entityId
  331. , o.orderNo
  332. , o.carId
  333. , o.lineNo
  334. , o.actId
  335. , b.entityID loadBillsEntityId
  336. , dr1.Empl driver1Name
  337. , dr1.mobile driver1mobile
  338. , b.billStatus
  339. , b.entityId loadBillsEntityId
  340. , b.sysId loadBillsSysId
  341. , o.driverassdesc
  342. , o.ifLoaded ifLoaded
  343. , o.ifUnLoaded ifUnLoaded
  344. , o.ifStarted ifStarted
  345. , o.CarRegNo carRegNo
  346. , o.loadAddr loadAddr
  347. , o.unLoadAddr unLoadAddr
  348. , g.CName goodsCName
  349. , o.loadQty loadQty
  350. , o.loadDate loadDate
  351. , o.unLoadQty unLoadQty
  352. , o.unLoadDate unLoadDate
  353. , o.ifOrder2ed ifOrder2ed
  354. , o.detourEmptyMile detourEmptyMile
  355. , o.detourLoadMile detourLoadMile
  356. , o.detourDesc detourDesc
  357. FROM OrderBillsPlans o
  358. INNER JOIN LoadBills b
  359. ON
  360. o.SysID = b.SysID
  361. AND o.EntityID = b.SrcEntityID
  362. AND o.LineNo = b.SrcLineNo
  363. Left join Empls dr1 on dr1.EmplID = o.DRIVER1ID
  364. Left join Goods g on (g.SysID=b.SysID and g.GoodsID=b.GoodsID)
  365. where o.orderNo = #{orderNo}
  366. and dr1.SysID = 1
  367. </select>
  368. <select id="getLoadFeeItemsByEntityId" resultType="com.ruoyi.system.domain.LoadFeeItems">
  369. select l.itemid, l.amt, i.cName, i.itemProp, i.auditType, l.lineNo, l.entityid, l.remarks
  370. from LoadFeeItems l
  371. inner join Items i on l.ItemID = i.ItemID
  372. where l.sysid = 1
  373. and l.entityId = #{entityId} order by l.lineno
  374. </select>
  375. <select id="getAttachMngsBySysIdEntityId" resultType="java.lang.Long">
  376. select MAX(lineNo) from AttachMngs where sysId = #{loadBillsSysId} and entityId = #{loadBillsEntityId}
  377. </select>
  378. <select id="getAttachMngsAttachtypeIdBySysIdAndEntityIdAndLineNo" resultType="java.lang.Long">
  379. select attachId from AttachMngs where SysId = #{loadBillsSysId} and EntityId = #{loadBillsEntityId} and LineNo = #{lineNo}
  380. </select>
  381. <select id="getAttachMngsAttachIdBySysIdAndEntityIdAndActId" resultType="java.lang.Long">
  382. select attachId from AttachMngs where SysId = #{loadBillsSysId} and EntityId = #{loadBillsEntityId} and ActID = #{actId}
  383. </select>
  384. <select id="getLoadBillsByOrderNo">
  385. select *
  386. FROM OrderBillsPlans o
  387. INNER JOIN LoadBills b
  388. ON
  389. o.SysID = b.SysID
  390. AND o.EntityID = b.SrcEntityID
  391. AND o.LineNo = b.SrcLineNo
  392. </select>
  393. <select id="getIsMileageOrderBillsPlansByOrder" resultType="com.ruoyi.system.domain.WfTaskList">
  394. SELECT
  395. t.SYSID,
  396. p.orderNo
  397. FROM
  398. wf_TaskList t
  399. LEFT JOIN LoadBills b ON
  400. (b.SysID = t.SysID
  401. AND b.EntityID = t.EntityID)
  402. LEFT JOIN OrderBillsPlans p ON
  403. (p.SysID = b.SysID
  404. AND p.EntityID = b.SrcEntityID
  405. AND p.LineNo = b.SrcLineNo)
  406. LEFT JOIN Empls e ON
  407. (e.SysID = b.SysID
  408. AND e.EmplID = b.TransactID)
  409. LEFT JOIN Empls dr1 ON
  410. (dr1.SysID = b.SysID
  411. AND dr1.EmplID = p.DRIVER1ID)
  412. LEFT JOIN Empls sp ON
  413. (sp.SysID = b.SysID
  414. AND sp.EmplID = p.SUPERCARGOID)
  415. LEFT JOIN Corps c ON
  416. (c.SysID = p.SysID
  417. AND c.CorpID = p.CorpID)
  418. LEFT JOIN Corps l ON
  419. (l.SysID = p.SysID
  420. AND l.CorpID = p.LoadFactoryID)
  421. LEFT JOIN Corps ul ON
  422. (ul.SysID = b.SysID
  423. AND ul.CorpID = p.UnLoadFactoryID)
  424. LEFT JOIN Goods g ON
  425. (g.SysID = b.SysID
  426. AND g.GoodsID = b.GoodsID)
  427. WHERE
  428. t.SysID = 1
  429. AND p.orderNo = #{orderNo}
  430. AND t.ActID = 317
  431. AND t.Status = 2
  432. and p.ifLoaded != 'T'
  433. and p.ifUnLoaded != 'T'
  434. </select>
  435. </mapper>