OrderBillsPlansMapper.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  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. <if test="ifDetour != null and ifDetour != ''">
  24. ifDetour = #{ifDetour},
  25. <if test="detourEmptyMile != null and detourEmptyMile != '' or detourEmptyMile == 0">
  26. detourEmptyMile = #{detourEmptyMile},
  27. </if>
  28. <if test="detourLoadMile != null and detourLoadMile != '' or detourLoadMile == 0">
  29. detourLoadMile = #{detourLoadMile},
  30. </if>
  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. order4Date = CURRENT_TIMESTAMP
  88. where sysId = '1'
  89. and OrderNo = #{orderNo}
  90. </update>
  91. <update id="theAuditFailed">
  92. update OrderBillsPlans
  93. set IfStarted = 'B',
  94. order4Date = CURRENT_TIMESTAMP
  95. where sysId = '1'
  96. and OrderNo = #{orderNo}
  97. </update>
  98. <update id="approvedTaskList">
  99. UPDATE wf_TaskList SET status= 2 WHERE SYSID = '1' AND ACTID =#{actId} AND ENTITYID = #{entityId}
  100. </update>
  101. <update id="theAuditFailedTaskList">
  102. UPDATE wf_TaskList SET status= 0 WHERE SYSID = '1' AND ACTID =#{actId} AND ENTITYID = #{entityId}
  103. </update>
  104. <update id="upReceipts">
  105. update OrderBillsPlans set IfOrder2ed = 'S' where sysId = '1' and OrderNo = #{orderNo}
  106. </update>
  107. <update id="addAReviewComment">
  108. update loadbills set audit2Desc = #{audit2Desc} where SrcEntityID = #{entityId} and SrcLineNo = #{lineNo}
  109. </update>
  110. <delete id="deleteLoadFeeItemsByEntityId">
  111. delete from LoadFeeItems where sysid = 1 and entityid = #{entityId}
  112. </delete>
  113. <delete id="deleteTmsAttachMngsByAttachId">
  114. delete from AttachMngs where attachId = #{attachId}
  115. </delete>
  116. <select id="getOrderBillsPlansLsit" parameterType="Map" resultType="com.ruoyi.system.domain.WfTaskList">
  117. Select Distinct p.SysID sysId
  118. , p.EntityID entityId
  119. , p.LineNo lineNo
  120. , p.OrderNo orderNo
  121. ,p.CarID carID
  122. , p.CarRegNo carRegNo
  123. ,p.PlanLoadDate planLoadDate
  124. , p.LoadDate loadDate
  125. , p.LoadAddr loadAddr
  126. , p.EMPTYADDR1 emptyAddr1
  127. , p.EMPTYADDR2 emptyAddr2
  128. ,p.PlanUnLoadDate planUnLoadDate
  129. , p.UnLoadDate unLoadDate
  130. , p.UnLoadAddr unLoadAddr
  131. , p.Remarks remarks
  132. ,t.TaskID taskId
  133. , t.Status status
  134. ,t.AuditStatus auditStatus
  135. , t.ActID wfActId
  136. ,c.SName corpSName
  137. , c.CName corpCName
  138. , g.CName goodsCName
  139. ,l.SName loadFactory
  140. , ul.SName unLoadFactory
  141. ,dr1.Empl driver1Name
  142. ,dr1.mobile driver1mobile
  143. , sp.Empl sUPERCARGOName
  144. ,e.Empl transact
  145. , b.BillDate billDate
  146. , p.rightqty
  147. , b.billStatus
  148. , p.ifLoaded ifLoaded
  149. , p.ifUnLoaded ifUnLoaded
  150. , p.ifStarted ifStarted
  151. , p.ifOrder2ed ifOrder2ed
  152. from wf_TaskList t
  153. Left join LoadBills b on (b.SysID=t.SysID and b.EntityID=t.EntityID)
  154. Left join OrderBillsPlans p on (p.SysID=b.SysID and p.EntityID=b.SrcEntityID and p.LineNo=b.SrcLineNo)
  155. Left join Empls e on (e.SysID=b.SysID and e.EmplID=b.TransactID)
  156. Left join Empls dr1 on (dr1.SysID=b.SysID and dr1.EmplID=p.DRIVER1ID)
  157. Left join Empls sp on (sp.SysID=b.SysID and sp.EmplID=p.SUPERCARGOID)
  158. Left join Corps c on (c.SysID=p.SysID and c.CorpID=p.CorpID)
  159. Left join Corps l on (l.SysID=p.SysID and l.CorpID=p.LoadFactoryID)
  160. Left join Corps ul on (ul.SysID=b.SysID and ul.CorpID=p.UnLoadFactoryID)
  161. Left join Goods g on (g.SysID=b.SysID and g.GoodsID=b.GoodsID)
  162. <where>
  163. t.SysID=1
  164. <if test="type == 'BD'">
  165. and t.ActID=317
  166. <if test="flowType == '未装车'">
  167. and p.ifLoaded = 'F' and p.ifUnLoaded = 'F' and (p.ifOrder2ed = 'F' or p.ifOrder2ed = 'T')
  168. </if>
  169. <if test="flowType == '未卸车'">
  170. and p.ifLoaded = 'T' and p.ifUnLoaded = 'F' and (p.ifOrder2ed = 'F' or p.ifOrder2ed = 'T')
  171. </if>
  172. <if test="flowType == '已卸车'">
  173. and p.ifLoaded = 'T' and p.ifUnLoaded = 'T' and (p.ifOrder2ed = 'F' or p.ifOrder2ed = 'T')
  174. </if>
  175. <if test="flowType == '已提交'">
  176. and p.ifLoaded = 'T' and p.ifUnLoaded = 'T' and p.ifOrder2ed = 'S'
  177. </if>
  178. <if test="flowType == '已审核'">
  179. and p.ifLoaded = 'T' and p.ifUnLoaded = 'T' and p.IfOrder2ed = 'O'
  180. </if>
  181. </if>
  182. <if test="type == 'BX'">
  183. and t.ActID = #{actId, jdbcType=VARCHAR}
  184. <if test="flowType == '未提交'">
  185. and p.ifStarted = 'F'
  186. </if>
  187. <if test="flowType == '已提交'">
  188. and p.ifStarted = 'S'
  189. </if>
  190. <if test="flowType == '已通过'">
  191. and p.ifStarted = 'A'
  192. </if>
  193. <if test="flowType == '已退回'">
  194. and p.ifStarted = 'B'
  195. </if>
  196. </if>
  197. and ((b.CarID=-1) or ((b.CarID &lt;&gt; -1)))
  198. <if test="dataStart != null and dataStart != '' and dataEnd != null and dataEnd != ''">
  199. and b.BillDate >= #{dataStart, jdbcType=VARCHAR} and b.BillDate &lt;= #{dataEnd, jdbcType=VARCHAR}
  200. </if>
  201. <if test="role == 0">
  202. and p.DeptUserID = #{emplId, jdbcType=VARCHAR}
  203. </if>
  204. <if test="role == 1">
  205. and ((p.DRIVER1ID=#{emplId, jdbcType=VARCHAR}) or (p.SUPERCARGOID=#{emplId, jdbcType=VARCHAR}))
  206. </if>
  207. <if test="orderNo != null and orderNo != ''">
  208. and (p.CarRegNo like #{orderNo}
  209. or p.loadAddr like #{orderNo}
  210. or p.unLoadAddr like #{orderNo}
  211. or g.CName like #{orderNo})
  212. </if>
  213. </where>
  214. ORDER BY b.BillDate DESC ROWS #{head} TO #{tail}
  215. </select>
  216. <select id="getOrderBillsPlansByid" resultType="com.ruoyi.system.domain.OrderBillsPlans">
  217. Select g.CName goodsCName
  218. , p.LoadAddr loadAddr
  219. , l.SName loadFactory
  220. , p.LoadAttn loadAttn
  221. , p.LoadAttnTel loadAttnTel
  222. , p.UnLoadAddr unLoadAddr
  223. , ul.SName unLoadFactory
  224. , p.UnLoadAttn unLoadAttn
  225. , p.UNLoadAttnTel unLoadAttnTel
  226. , p.planRemarks
  227. , p.orderNo
  228. , p.loadQty
  229. , p.loadDate
  230. , p.unLoadQty
  231. , p.unLoadDate
  232. , p.emptyaddr1
  233. , p.odometerstart
  234. , p.emptyaddr2
  235. , p.odometerend
  236. , p.loadmile
  237. , p.remarks
  238. , p.driverassdesc
  239. , dr1.Empl driver1Name
  240. , dr1.mobile driver1mobile
  241. , p.sysId
  242. , b.entityId loadBillsEntityId
  243. , b.sysId loadBillsSysId
  244. , b.billStatus
  245. , p.detourEmptyMile detourEmptyMile
  246. , p.detourLoadMile detourLoadMile
  247. , p.detourDesc detourDesc
  248. , p.ifDetour ifDetour
  249. , p.CarRegNo carRegNo
  250. , p.ifLoaded ifLoaded
  251. , p.ifUnLoaded ifUnLoaded
  252. , p.ifStarted ifStarted
  253. , p.ifOrder2ed ifOrder2ed
  254. from OrderBillsPlans p
  255. Left join Empls e on (e.SysID = p.SysID and e.EmplID = p.TransactID)
  256. Left join Empls dr1 on (dr1.SysID = p.SysID and dr1.EmplID = p.DRIVER1ID)
  257. Left join Empls sp on (sp.SysID = p.SysID and sp.EmplID = p.SUPERCARGOID)
  258. Left join Corps c on (c.SysID = p.SysID and c.CorpID = p.CorpID)
  259. Left join Corps l on (l.SysID = p.SysID and l.CorpID = p.LoadFactoryID)
  260. Left join Corps ul on (ul.SysID = p.SysID and ul.CorpID = p.UnLoadFactoryID)
  261. Left join Goods g on (g.SysID = p.SysID and g.GoodsID = p.GoodsID)
  262. INNER JOIN LoadBills b
  263. ON
  264. p.SysID = b.SysID
  265. AND p.EntityID = b.SrcEntityID
  266. AND p.LineNo = b.SrcLineNo
  267. where p.SysID = 1
  268. and p.OrderNo = #{orderNo}
  269. </select>
  270. <select id="getItemsList" resultType="com.ruoyi.system.domain.vo.ItemsVo">
  271. select itemId, cName, itemProp, auditType from Items where SysID=1 and itemProp='F' order by zorder
  272. </select>
  273. <select id="getLoadFeeitemsMapByentityIdKeyItemId" resultType="java.util.Map">
  274. select itemId, atm1, entityId from LoadFeeItems where entityId = #{entityId}
  275. </select>
  276. <select id="getGasStations" resultType="com.ruoyi.system.domain.GasStations">
  277. select gasStationId, cName from GasStations
  278. </select>
  279. <select id="getOrderBillsPlansByOrder" resultType="com.ruoyi.system.domain.vo.OrderBillsPlansVo">
  280. select o.loadetc
  281. , o.loadtoll
  282. , o.oilhomeQty
  283. , o.oilhomeAmt
  284. , o.oilappoint1Qty
  285. , o.oilappoint1Amt
  286. , o.oilappoint2Qty
  287. , o.oilappoint2Amt
  288. , o.oilcash1Qty
  289. , o.oilcash1Amt
  290. , o.oilcardQty
  291. , o.oilcardAmt
  292. , b.gasstation1
  293. , b.gasstation2
  294. , o.entityId
  295. , o.orderNo
  296. , o.carId
  297. , o.lineNo
  298. , o.actId
  299. , b.entityID loadBillsEntityId
  300. , dr1.Empl driver1Name
  301. , dr1.mobile driver1mobile
  302. , b.billStatus
  303. , b.entityId loadBillsEntityId
  304. , b.sysId loadBillsSysId
  305. , o.driverassdesc
  306. , o.ifLoaded ifLoaded
  307. , o.ifUnLoaded ifUnLoaded
  308. , o.ifStarted ifStarted
  309. , o.CarRegNo carRegNo
  310. , o.loadAddr loadAddr
  311. , o.unLoadAddr unLoadAddr
  312. , g.CName goodsCName
  313. , o.loadQty loadQty
  314. , o.loadDate loadDate
  315. , o.unLoadQty unLoadQty
  316. , o.unLoadDate unLoadDate
  317. , o.ifOrder2ed ifOrder2ed
  318. FROM OrderBillsPlans o
  319. INNER JOIN LoadBills b
  320. ON
  321. o.SysID = b.SysID
  322. AND o.EntityID = b.SrcEntityID
  323. AND o.LineNo = b.SrcLineNo
  324. Left join Empls dr1 on dr1.EmplID = o.DRIVER1ID
  325. Left join Goods g on (g.SysID=b.SysID and g.GoodsID=b.GoodsID)
  326. where o.orderNo = #{orderNo}
  327. and dr1.SysID = 1
  328. </select>
  329. <select id="getLoadFeeItemsByEntityId" resultType="com.ruoyi.system.domain.LoadFeeItems">
  330. select l.itemid, l.amt, i.cName, i.itemProp, i.auditType, l.lineNo, l.entityid, l.remarks
  331. from LoadFeeItems l
  332. inner join Items i on l.ItemID = i.ItemID
  333. where l.sysid = 1
  334. and l.entityId = #{entityId} order by l.lineno
  335. </select>
  336. <select id="getAttachMngsBySysIdEntityId" resultType="java.lang.Long">
  337. select MAX(lineNo) from AttachMngs where sysId = #{loadBillsSysId} and entityId = #{loadBillsEntityId}
  338. </select>
  339. <select id="getAttachMngsAttachtypeIdBySysIdAndEntityIdAndLineNo" resultType="java.lang.Long">
  340. select attachId from AttachMngs where SysId = #{loadBillsSysId} and EntityId = #{loadBillsEntityId} and LineNo = #{lineNo}
  341. </select>
  342. <select id="getAttachMngsAttachIdBySysIdAndEntityIdAndActId" resultType="java.lang.Long">
  343. select attachId from AttachMngs where SysId = #{loadBillsSysId} and EntityId = #{loadBillsEntityId} and ActID = #{actId}
  344. </select>
  345. <select id="getLoadBillsByOrderNo">
  346. select *
  347. FROM OrderBillsPlans o
  348. INNER JOIN LoadBills b
  349. ON
  350. o.SysID = b.SysID
  351. AND o.EntityID = b.SrcEntityID
  352. AND o.LineNo = b.SrcLineNo
  353. </select>
  354. <select id="getIsMileageOrderBillsPlansByOrder" resultType="com.ruoyi.system.domain.WfTaskList">
  355. SELECT
  356. t.SYSID,
  357. p.orderNo
  358. FROM
  359. wf_TaskList t
  360. LEFT JOIN LoadBills b ON
  361. (b.SysID = t.SysID
  362. AND b.EntityID = t.EntityID)
  363. LEFT JOIN OrderBillsPlans p ON
  364. (p.SysID = b.SysID
  365. AND p.EntityID = b.SrcEntityID
  366. AND p.LineNo = b.SrcLineNo)
  367. LEFT JOIN Empls e ON
  368. (e.SysID = b.SysID
  369. AND e.EmplID = b.TransactID)
  370. LEFT JOIN Empls dr1 ON
  371. (dr1.SysID = b.SysID
  372. AND dr1.EmplID = p.DRIVER1ID)
  373. LEFT JOIN Empls sp ON
  374. (sp.SysID = b.SysID
  375. AND sp.EmplID = p.SUPERCARGOID)
  376. LEFT JOIN Corps c ON
  377. (c.SysID = p.SysID
  378. AND c.CorpID = p.CorpID)
  379. LEFT JOIN Corps l ON
  380. (l.SysID = p.SysID
  381. AND l.CorpID = p.LoadFactoryID)
  382. LEFT JOIN Corps ul ON
  383. (ul.SysID = b.SysID
  384. AND ul.CorpID = p.UnLoadFactoryID)
  385. LEFT JOIN Goods g ON
  386. (g.SysID = b.SysID
  387. AND g.GoodsID = b.GoodsID)
  388. WHERE
  389. t.SysID = 1
  390. AND p.orderNo = #{orderNo}
  391. AND t.ActID = 317
  392. AND t.Status = 2
  393. and p.ifLoaded != 'T'
  394. and p.ifUnLoaded != 'T'
  395. </select>
  396. </mapper>