OrderBillsPlansMapper.xml 19 KB

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