OffSiteTransportationMapper.xml 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.steerinfo.dil.mapper.OffSiteTransportationMapper">
  4. <insert id="insertOrderMileage" >
  5. update TMSTRUCK_RECEIPT_RESULT set ORDER_MILEAGE = #{orderMileage} where RESULT_TOTAL_ID = #{truckTotalId}
  6. </insert>
  7. <insert id="insertReceive">
  8. insert into TMSTRUCK_RECEIVE_RESULT(RESULT_RECEIVE_ID ,result_total_id ,insert_username ,insert_time ,status) values('${RESULTID}','${RESULTTOTALID}','${INSERUSERNAME}', #{INSERTTIME,jdbcType=TIMESTAMP},'${STATUS}')
  9. </insert>
  10. <insert id="addTransportationAlarm">
  11. </insert>
  12. <update id="insertOrderTripId" parameterType="java.util.Map">
  13. update OMSTRUCK_ORDER set TRIP_ID = #{rid} where ORDER_NUMBER = #{orderNumber}
  14. </update>
  15. <update id="orderClose">
  16. update OMSTRUCK_ORDER set ORDER_STATUS = '2' where ORDER_NUMBER = #{orderNumber}
  17. </update>
  18. <select id="getInTransitTransportation" resultType="java.util.Map">
  19. select
  20. *
  21. from (
  22. select distinct
  23. OO.ORDER_STATUS "orderStatus",
  24. OO.ORDER_NUMBER "orderNumber", --运单订单号
  25. RC.CAPACITY_NUMBER "capacityNumber",--车牌号
  26. TWR.RESULT_GROSS_WEIGHT_TIME "resultGrossWeightTime",--计毛时间
  27. TWR.RESULT_NET_WEIGHT "resultNetWeight",--净重
  28. TLFR.RESULT_OUT_GATE_TIME "resultOutGateTime",--出厂时间
  29. RGOUT.GATEPOST_NAME "outGatepostName",--出厂门禁
  30. RCR.CARRIER_NAME "carrierName" , --承运商名称
  31. CONCAT( CONCAT( CONCAT(RRA.ADDRESS_PROVINCE,RRA.ADDRESS_DISTRICT),RRA.Address_Town),RRP.ADDRESS_DELIVERY_ADDRESS) "deliveryAddress", --详细收货地址
  32. RM.MATERIAL_NAME "materialName" , --"物质名称"
  33. RM.MATERIAL_SPECIFICATION "materialSpecification", -- "物质规格"
  34. RM.MATERIAL_MODEL "materialModel", --"物质型号"
  35. RCON.CONSIGNEE_COMPANY_NAME "receiveName"--客户名称
  36. from OMSTRUCK_ORDER OO --运输订单
  37. left join AMS_SALE_ORDER_MATERIAL ASOM --销售订单物质表
  38. on ASOM.SALE_ORDER_MATERIAL_ID = OO.ORDER_PLAN_ID
  39. left join AMS_SALE_ORDER ASO --销售订单
  40. on ASO.SALE_ORDER_ID = ASOM.SALE_ORDER_ID
  41. left join RMS_CONSIGNEE RCON --收货客户
  42. on RCON.CONSIGNEE_ID = ASO.RECEIVE_ID
  43. left join TMSTRUCK_TOTAL_RESULT TTR --运输总实绩
  44. on TTR.ORDER_ID = OO.ORDER_ID
  45. left join TMSTRUCK_LOAD_RESULT TLR --汽车运输实绩表
  46. on TLR.RESULT_TOTAL_ID = TTR.RESULT_TOTAL_ID
  47. left join RMS_WAREHOUSE RW --装卸货仓库
  48. on RW.WAREHOUSE_ID = TLR.LOADING_ID
  49. left join TMSTRUCK_LEAVE_FACTORY_RESULT TLFR --离厂实绩
  50. on TLFR.RESULT_TOTAL_ID = TTR.RESULT_TOTAL_ID
  51. left join RMS_GATEPOST RGOUT --门岗
  52. on RGOUT.GATEPOST_ID = TLFR.GATEPOST_ID
  53. left join RMS_CAPACITY RC --运力
  54. on RC.CAPACITY_ID = OO.CAPACITY_ID
  55. left join AMS_DISPATCH_SALE_ORDER ADSO
  56. on ASOM.SALE_ORDER_MATERIAL_ID=ADSO.SALE_ORDER_MATERIAL_ID
  57. left join RMS_CARRIER RCR --承运单位
  58. on ADSO.CARRIER_ID=RCR.CARRIER_ID
  59. left join RMS_RECEIVE_PLACE RRP --收货地址
  60. on ASOM.SALE_SHIPPING_ADDRESS_ID=RRP.PLACE_ID
  61. left join RMS_RECEIVE_ADDRESS RRA
  62. on RRP.ADDRESS_ID=RRA.ADDRESS_ID
  63. left join AMS_SALE_TRUCKNO_MATERIAL ASTM
  64. on ASOM.SALE_ORDER_MATERIAL_ID=ASTM.SALE_ORDER_MATERIAL_ID
  65. left join AMS_SALE_MATERIAL ASM1
  66. on ASTM.MATERIAL_ID =ASM1.SALE_MATERIAL_ID
  67. left join TMSTRUCK_WEIGHT_RESULT TWR --运输实绩计重
  68. on TWR.RESULT_TOTAL_ID = TTR.RESULT_TOTAL_ID and ASM1.MATERIAL_ID =TWR.MATERIAL_ID
  69. left join RMS_MATERIAL RM
  70. on ASM1.MATERIAL_ID=RM.MATERIAL_ID
  71. where OO.ORDER_TYPE in (1) and TLFR.RESULT_OUT_GATE_TIME IS NOT NULL
  72. )
  73. <where>
  74. <if test="orderStatus !=null">
  75. and "orderStatus" ='${orderStatus}'
  76. </if>
  77. <if test="orderNumbers !=null and orderNumbers !=''">
  78. and "orderNumber" like '%${orderNumbers}%'
  79. </if>
  80. <if test="capacityNumbers !=null and capacityNumbers !=''">
  81. and "capacityNumber" like '%${capacityNumbers}%'
  82. </if>
  83. <if test="resultGrossWeightTimes !=null and resultGrossWeightTimes !=''">
  84. and "resultGrossWeightTime" like '%${resultGrossWeightTimes}%'
  85. </if>
  86. <if test="resultGrossWeightTimes !=null and resultGrossWeightTimes !=''">
  87. and "resultGrossWeightTime" like '%${resultGrossWeightTimes}%'
  88. </if>
  89. <if test="resultOutGateTimes !=null and resultOutGateTimes !=''">
  90. and "resultOutGateTime" like '%${resultOutGateTimes}%'
  91. </if>
  92. <if test="resultNetWeights !=null and resultNetWeights !=''">
  93. and "resultNetWeight" like '%${resultNetWeights}%'
  94. </if>
  95. <if test="resultOutGateTimes !=null and resultOutGateTimes !=''">
  96. and "resultOutGateTime" like '%${resultOutGateTimes}%'
  97. </if>
  98. <if test="outGatepostNames !=null and outGatepostNames !=''">
  99. and "outGatepostName" like '%${outGatepostNames}%'
  100. </if>
  101. <if test="carrierNames !=null and carrierNames !=''">
  102. and "carrierName" like '%${carrierNames}%'
  103. </if>
  104. <if test="deliveryAddresss !=null and deliveryAddresss !=''">
  105. and "deliveryAddress" like '%${deliveryAddresss}%'
  106. </if>
  107. <if test="materialNames !=null and materialNames !=''">
  108. and "materialName" like '%${materialNames}%'
  109. </if>
  110. <if test="materialSpecifications !=null and materialSpecifications !=''">
  111. and "materialSpecification" like '%${materialSpecifications}%'
  112. </if>
  113. <if test="materialModels !=null and materialModels !=''">
  114. and "materialModel" like '%${materialModels}%'
  115. </if>
  116. <if test="receiveNames !=null and receiveNames!=''">
  117. and "receiveName" like '%${receiveNames}%'
  118. </if>
  119. <if test="startTime != null">
  120. and "resultOutGateTime" &gt;= to_date('${startTime}','yyyy-mm-dd')
  121. </if>
  122. <if test="endTime != null">
  123. and "resultOutGateTime" &lt;= to_date('${endTime}','yyyy-mm-dd')
  124. </if>
  125. <if test="orderNumber !=null">
  126. and "orderNumber" in
  127. <foreach collection="orderNumber" separator="," open="(" close=")" item="item" >
  128. #{item}
  129. </foreach>
  130. </if>
  131. <if test="capacityNumber !=null">
  132. and "capacityNumber" in
  133. <foreach collection="capacityNumber" separator="," open="(" close=")" item="item" >
  134. #{item}
  135. </foreach>
  136. </if>
  137. <if test="resultGrossWeightTime !=null">
  138. and "resultGrossWeightTime" in
  139. <foreach collection="resultGrossWeightTime" separator="," open="(" close=")" item="item" >
  140. #{item}
  141. </foreach>
  142. </if>
  143. <if test="resultNetWeight !=null">
  144. and "resultNetWeight" in
  145. <foreach collection="resultNetWeight" separator="," open="(" close=")" item="item" >
  146. #{item}
  147. </foreach>
  148. </if>
  149. <if test="resultOutGateTime !=null">
  150. and "resultOutGateTime" in
  151. <foreach collection="resultOutGateTime" separator="," open="(" close=")" item="item" >
  152. #{item}
  153. </foreach>
  154. </if>
  155. <if test="outGatepostName !=null">
  156. and "outGatepostName" in
  157. <foreach collection="outGatepostName" separator="," open="(" close=")" item="item" >
  158. #{item}
  159. </foreach>
  160. </if>
  161. <if test="carrierName !=null">
  162. and "carrierName" in
  163. <foreach collection="carrierName" separator="," open="(" close=")" item="item" >
  164. #{item}
  165. </foreach>
  166. </if>
  167. <if test="deliveryAddress !=null">
  168. and "deliveryAddress" in
  169. <foreach collection="deliveryAddress" separator="," open="(" close=")" item="item" >
  170. #{item}
  171. </foreach>
  172. </if>
  173. <if test="materialSpecification !=null">
  174. and "materialSpecification" in
  175. <foreach collection="materialSpecification" separator="," open="(" close=")" item="item" >
  176. #{item}
  177. </foreach>
  178. </if>
  179. <if test="materialModel !=null">
  180. and "materialModel" in
  181. <foreach collection="materialModel" separator="," open="(" close=")" item="item" >
  182. #{item}
  183. </foreach>
  184. </if>
  185. <if test="receiveName !=null">
  186. and "receiveName" in
  187. <foreach collection="receiveName" separator="," open="(" close=")" item="item" >
  188. #{item}
  189. </foreach>
  190. </if>
  191. </where>
  192. <include refid="orderBy"></include>
  193. </select>
  194. <select id="getTruckFactoryResult" resultType="java.util.Map">
  195. SELECT * from(
  196. SELECT
  197. -- 出厂时间
  198. to_char(TLFR.RESULT_OUT_GATE_TIME,'yyyy-mm-dd hh24:mi:ss') "resultOutGateTime",
  199. --出厂抓拍图片
  200. TLFR.RESULT_TRUCK_SNAPSHOT_PICTURE "resultTruckSnapshotPicture",
  201. --出厂方式
  202. TLFR.RESULT_OUT_MODE "resultOutMode",
  203. --门岗名称
  204. RG.GATEPOST_NAME "gatepostName",
  205. -- 运输订单号
  206. OO.ORDER_NUMBER "orderNumber",
  207. -- 车牌号
  208. RC.CAPACITY_NUMBER "capacityNumber",
  209. -- 运输订单id
  210. OO.ORDER_ID "orderId",
  211. -- 订单类型
  212. OO.ORDER_TYPE "orderType",
  213. -- 销售订单号
  214. ASO.SALE_NUMBER "saleNum",
  215. -- 收货地址
  216. RRA.ADDRESS_DELIVERY_ADDRESS "receiveAddress",
  217. -- 收货单位
  218. RS.SUPPLIER_NAME "supplierName" ,
  219. -- 发货单位
  220. RS2.SHIPPER_NAME "shipperName"
  221. FROM
  222. -- 出厂实绩
  223. TMSTRUCK_LEAVE_FACTORY_RESULT TLFR
  224. -- 总实绩
  225. LEFT JOIN TMSTRUCK_TOTAL_RESULT TTR ON TLFR.RESULT_TOTAL_ID = TTR.RESULT_TOTAL_ID
  226. -- 运输订单
  227. LEFT JOIN OMSTRUCK_ORDER OO ON TTR.ORDER_ID = OO.ORDER_ID
  228. -- 销售订单信息
  229. LEFT JOIN AMS_SALE_ORDER ASO ON OO.ORDER_PLAN_ID = ASO.SALE_ORDER_ID
  230. -- 托运人
  231. LEFT JOIN RMS_SUPPLIER RS ON ASO.SHIPPER_ID = RS.SUPPLIER_ID
  232. -- 门岗
  233. LEFT JOIN RMS_GATEPOST RG ON TLFR.GATEPOST_ID = RG.GATEPOST_ID
  234. -- 运力信息
  235. LEFT JOIN RMS_CAPACITY RC ON OO.CAPACITY_ID = RC.CAPACITY_ID
  236. -- 销售订单中间表
  237. LEFT JOIN AMS_SALE_ORDER_MATERIAL ASOM ON ASOM.SALE_ORDER_MATERIAL_ID =OO.ORDER_PLAN_ID
  238. -- 收货地址
  239. LEFT JOIN RMS_RECEIVE_ADDRESS RRA ON ASOM.SALE_SHIPPING_ADDRESS_ID =RRA.ADDRESS_ID
  240. -- 收货单位
  241. LEFT JOIN RMS_SHIPPER RS2 ON ASO.SHIPPER_ID = RS2.SHIPPER_ID
  242. WHERE
  243. -- 判断出厂实绩的出厂时间不为空
  244. TLFR.RESULT_OUT_GATE_TIME IS NOT NULL
  245. -- 并且订单类型等于1(销售订单),2(焦炭发运计划),3(水渣发运计划)
  246. AND OO.ORDER_TYPE =1 AND OO.ORDER_NUMBER=#{orderNumber}
  247. )
  248. </select>
  249. <select id="getOrderStatu" resultType="java.lang.Integer">
  250. select o_order.ORDER_STATUS from OMSTRUCK_ORDER o_order
  251. where o_order.ORDER_NUMBER = #{orderNumber}
  252. </select>
  253. <select id="getStartAndEndCapacityNumber" resultType="java.util.Map">
  254. SELECT
  255. -- 出厂时间
  256. to_char(TLFR.RESULT_OUT_GATE_TIME,'yyyy-mm-dd hh24:mi:ss') "resultOutGateTime",
  257. -- 车牌号
  258. RC.CAPACITY_NUMBER "capacityNumber",
  259. -- 收货地址
  260. CONCAT( CONCAT(RRA.ADDRESS_PROVINCE,RRA.ADDRESS_DISTRICT),RRA.Address_Town) "addressDeliveryAddress"
  261. FROM
  262. -- 出厂实绩
  263. TMSTRUCK_LEAVE_FACTORY_RESULT TLFR
  264. -- 总实绩
  265. LEFT JOIN TMSTRUCK_TOTAL_RESULT TTR ON TLFR.RESULT_TOTAL_ID = TTR.RESULT_TOTAL_ID
  266. -- 运输订单
  267. LEFT JOIN OMSTRUCK_ORDER OO ON TTR.ORDER_ID = OO.ORDER_ID
  268. -- 运力信息
  269. LEFT JOIN RMS_CAPACITY RC ON OO.CAPACITY_ID = RC.CAPACITY_ID
  270. -- 销售订单中间表
  271. LEFT JOIN AMS_SALE_ORDER_MATERIAL ASOM ON ASOM.SALE_ORDER_MATERIAL_ID =OO.ORDER_PLAN_ID
  272. --收货地址
  273. left join RMS_RECEIVE_PLACE RRP on ASOM.SALE_SHIPPING_ADDRESS_ID=RRP.PLACE_ID
  274. left join RMS_RECEIVE_ADDRESS RRA on RRP.ADDRESS_ID=RRA.ADDRESS_ID
  275. WHERE
  276. -- 判断出厂实绩的出厂时间不为空
  277. TLFR.RESULT_OUT_GATE_TIME IS NOT NULL
  278. -- 并且订单类型等于1(销售订单),2(焦炭发运计划),3(水渣发运计划)
  279. AND OO.ORDER_TYPE =1 AND OO.ORDER_NUMBER=#{orderNumber}
  280. </select>
  281. <select id="getReceiptData" resultType="java.util.Map">
  282. select result_id resultId,result_total_id resultTotalId,insert_username inserUserName,insert_time insertTime,status status from TMSTRUCK_RECEIPT_RESULT
  283. </select>
  284. <select id="selectWarnSwitch" resultType="Map">
  285. select WARN_SWITCH "switch",WARN_TYPE "type" from TMSTRUCK_IN_TRANSIT_WARN where WARN_ID = 1
  286. </select>
  287. <select id="selectIsReceiving" resultType="java.math.BigDecimal">
  288. select RESULT_TOTAL_ID "totalId"
  289. from TMSTRUCK_TOTAL_RESULT t_total
  290. left join OMSTRUCK_ORDER o_order
  291. on t_total.ORDER_ID=o_order.ORDER_ID
  292. where o_order.TRIP_ID = #{tripId} and o_order.ORDER_STATUS = 1
  293. </select>
  294. <select id="getHaveAbnormalTruckOrderInfo" resultType="java.util.Map">
  295. select
  296. *
  297. from (
  298. select distinct
  299. OO.ORDER_STATUS "orderStatus",
  300. OO.ORDER_NUMBER "orderNumber", --运单订单号
  301. RC.CAPACITY_NUMBER "capacityNumber",--车牌号
  302. TWR.RESULT_GROSS_WEIGHT_TIME "resultGrossWeightTime",--计毛时间
  303. TWR.RESULT_NET_WEIGHT "resultNetWeight",--净重
  304. TLFR.RESULT_OUT_GATE_TIME "resultOutGateTime",--出厂时间
  305. RGOUT.GATEPOST_NAME "outGatepostName",--出厂门禁
  306. RCR.CARRIER_NAME "carrierName" , --承运商名称
  307. CONCAT( CONCAT( CONCAT(RRA.ADDRESS_PROVINCE,RRA.ADDRESS_DISTRICT),RRA.Address_Town),RRP.ADDRESS_DELIVERY_ADDRESS) "deliveryAddress", --详细收货地址
  308. RM.MATERIAL_NAME "materialName" , --"物质名称"
  309. RM.MATERIAL_SPECIFICATION "materialSpecification", -- "物质规格"
  310. RM.MATERIAL_MODEL "materialModel", --"物质型号"
  311. RCON.CONSIGNEE_COMPANY_NAME "receiveName"--客户名称
  312. from OMSTRUCK_ORDER OO --运输订单
  313. left join AMS_SALE_ORDER_MATERIAL ASOM --销售订单物质表
  314. on ASOM.SALE_ORDER_MATERIAL_ID = OO.ORDER_PLAN_ID
  315. left join AMS_SALE_ORDER ASO --销售订单
  316. on ASO.SALE_ORDER_ID = ASOM.SALE_ORDER_ID
  317. left join RMS_CONSIGNEE RCON --收货客户
  318. on RCON.CONSIGNEE_ID = ASO.RECEIVE_ID
  319. left join TMSTRUCK_TOTAL_RESULT TTR --运输总实绩
  320. on TTR.ORDER_ID = OO.ORDER_ID
  321. left join TMSTRUCK_LOAD_RESULT TLR --汽车运输实绩表
  322. on TLR.RESULT_TOTAL_ID = TTR.RESULT_TOTAL_ID
  323. left join RMS_WAREHOUSE RW --装卸货仓库
  324. on RW.WAREHOUSE_ID = TLR.LOADING_ID
  325. left join TMSTRUCK_LEAVE_FACTORY_RESULT TLFR --离厂实绩
  326. on TLFR.RESULT_TOTAL_ID = TTR.RESULT_TOTAL_ID
  327. left join RMS_GATEPOST RGOUT --门岗
  328. on RGOUT.GATEPOST_ID = TLFR.GATEPOST_ID
  329. left join RMS_CAPACITY RC --运力
  330. on RC.CAPACITY_ID = OO.CAPACITY_ID
  331. left join AMS_DISPATCH_SALE_ORDER ADSO
  332. on ASOM.SALE_ORDER_MATERIAL_ID=ADSO.SALE_ORDER_MATERIAL_ID
  333. left join RMS_CARRIER RCR --承运单位
  334. on ADSO.CARRIER_ID=RCR.CARRIER_ID
  335. left join RMS_RECEIVE_PLACE RRP --收货地址
  336. on ASOM.SALE_SHIPPING_ADDRESS_ID=RRP.PLACE_ID
  337. left join RMS_RECEIVE_ADDRESS RRA
  338. on RRP.ADDRESS_ID=RRA.ADDRESS_ID
  339. left join AMS_SALE_TRUCKNO_MATERIAL ASTM
  340. on ASOM.SALE_ORDER_MATERIAL_ID=ASTM.SALE_ORDER_MATERIAL_ID
  341. left join AMS_SALE_MATERIAL ASM1
  342. on ASTM.MATERIAL_ID =ASM1.SALE_MATERIAL_ID
  343. left join TMSTRUCK_WEIGHT_RESULT TWR --运输实绩计重
  344. on TWR.RESULT_TOTAL_ID = TTR.RESULT_TOTAL_ID and ASM1.MATERIAL_ID =TWR.MATERIAL_ID
  345. left join RMS_MATERIAL RM
  346. on ASM1.MATERIAL_ID=RM.MATERIAL_ID
  347. left join(
  348. select max(RESULT_TOTAL_ID) coun,RESULT_TOTAL_ID RESULT_TOTAL_ID from TMSTRUCK_ABNORMAL_RESULT
  349. <if test="abnormalType!=null">
  350. where
  351. ABNORMAL_TYPE=#{abnormalType}
  352. </if>
  353. group by RESULT_TOTAL_ID
  354. ) TAR
  355. on TTR.RESULT_TOTAL_ID=TAR.RESULT_TOTAL_ID
  356. where TAR.coun is not null and OO.ORDER_TYPE in (1) and TLFR.RESULT_OUT_GATE_TIME IS NOT NULL
  357. )
  358. <where>
  359. <if test="orderStatus !=null">
  360. and "orderStatus" ='${orderStatus}'
  361. </if>
  362. <if test="orderNumbers !=null and orderNumbers !=''">
  363. and "orderNumber" like '%${orderNumbers}%'
  364. </if>
  365. <if test="capacityNumbers !=null and capacityNumbers !=''">
  366. and "capacityNumber" like '%${capacityNumbers}%'
  367. </if>
  368. <if test="resultGrossWeightTimes !=null and resultGrossWeightTimes !=''">
  369. and "resultGrossWeightTime" like '%${resultGrossWeightTimes}%'
  370. </if>
  371. <if test="resultGrossWeightTimes !=null and resultGrossWeightTimes !=''">
  372. and "resultGrossWeightTime" like '%${resultGrossWeightTimes}%'
  373. </if>
  374. <if test="resultOutGateTimes !=null and resultOutGateTimes !=''">
  375. and "resultOutGateTime" like '%${resultOutGateTimes}%'
  376. </if>
  377. <if test="resultNetWeights !=null and resultNetWeights !=''">
  378. and "resultNetWeight" like '%${resultNetWeights}%'
  379. </if>
  380. <if test="resultOutGateTimes !=null and resultOutGateTimes !=''">
  381. and "resultOutGateTime" like '%${resultOutGateTimes}%'
  382. </if>
  383. <if test="outGatepostNames !=null and outGatepostNames !=''">
  384. and "outGatepostName" like '%${outGatepostNames}%'
  385. </if>
  386. <if test="carrierNames !=null and carrierNames !=''">
  387. and "carrierName" like '%${carrierNames}%'
  388. </if>
  389. <if test="deliveryAddresss !=null and deliveryAddresss !=''">
  390. and "deliveryAddress" like '%${deliveryAddresss}%'
  391. </if>
  392. <if test="materialNames !=null and materialNames !=''">
  393. and "materialName" like '%${materialNames}%'
  394. </if>
  395. <if test="materialSpecifications !=null and materialSpecifications !=''">
  396. and "materialSpecification" like '%${materialSpecifications}%'
  397. </if>
  398. <if test="materialModels !=null and materialModels !=''">
  399. and "materialModel" like '%${materialModels}%'
  400. </if>
  401. <if test="receiveNames !=null and receiveNames!=''">
  402. and "receiveName" like '%${receiveNames}%'
  403. </if>
  404. <if test="startTime != null">
  405. and "resultOutGateTime" &gt;= to_date('${startTime}','yyyy-mm-dd')
  406. </if>
  407. <if test="endTime != null">
  408. and "resultOutGateTime" &lt;= to_date('${endTime}','yyyy-mm-dd')
  409. </if>
  410. <if test="orderNumber !=null">
  411. and "orderNumber" in
  412. <foreach collection="orderNumber" separator="," open="(" close=")" item="item" >
  413. #{item}
  414. </foreach>
  415. </if>
  416. <if test="capacityNumber !=null">
  417. and "capacityNumber" in
  418. <foreach collection="capacityNumber" separator="," open="(" close=")" item="item" >
  419. #{item}
  420. </foreach>
  421. </if>
  422. <if test="resultGrossWeightTime !=null">
  423. and "resultGrossWeightTime" in
  424. <foreach collection="resultGrossWeightTime" separator="," open="(" close=")" item="item" >
  425. #{item}
  426. </foreach>
  427. </if>
  428. <if test="resultNetWeight !=null">
  429. and "resultNetWeight" in
  430. <foreach collection="resultNetWeight" separator="," open="(" close=")" item="item" >
  431. #{item}
  432. </foreach>
  433. </if>
  434. <if test="resultOutGateTime !=null">
  435. and "resultOutGateTime" in
  436. <foreach collection="resultOutGateTime" separator="," open="(" close=")" item="item" >
  437. #{item}
  438. </foreach>
  439. </if>
  440. <if test="outGatepostName !=null">
  441. and "outGatepostName" in
  442. <foreach collection="outGatepostName" separator="," open="(" close=")" item="item" >
  443. #{item}
  444. </foreach>
  445. </if>
  446. <if test="carrierName !=null">
  447. and "carrierName" in
  448. <foreach collection="carrierName" separator="," open="(" close=")" item="item" >
  449. #{item}
  450. </foreach>
  451. </if>
  452. <if test="deliveryAddress !=null">
  453. and "deliveryAddress" in
  454. <foreach collection="deliveryAddress" separator="," open="(" close=")" item="item" >
  455. #{item}
  456. </foreach>
  457. </if>
  458. <if test="materialSpecification !=null">
  459. and "materialSpecification" in
  460. <foreach collection="materialSpecification" separator="," open="(" close=")" item="item" >
  461. #{item}
  462. </foreach>
  463. </if>
  464. <if test="materialModel !=null">
  465. and "materialModel" in
  466. <foreach collection="materialModel" separator="," open="(" close=")" item="item" >
  467. #{item}
  468. </foreach>
  469. </if>
  470. <if test="receiveName !=null">
  471. and "receiveName" in
  472. <foreach collection="receiveName" separator="," open="(" close=")" item="item" >
  473. #{item}
  474. </foreach>
  475. </if>
  476. </where>
  477. <include refid="orderBy"></include>
  478. </select>
  479. <select id="getTransportAbnormalInfo" parameterType="java.util.Map" resultType="java.util.LinkedHashMap">
  480. select * from(
  481. select r_capacity.CAPACITY_NUMBER "capacityNumber",
  482. o_torder.ORDER_NUMBER "orderNumber",
  483. a_s_order.SALE_NUMBER "saleNumber",
  484. case t_abnormal.ABNORMAL_TYPE
  485. when '1' then '偏离'
  486. when '2' then '停车'
  487. when '3' then '离线'
  488. else '其他' end "abnormalType",
  489. t_abnormal.ABNORMAL_TIME "abnormalTime",
  490. t_abnormal.ABNORMAL_ADDRESS "abnormalAddress",
  491. t_abnormal.ABNORMAL_DURATION "abnormalDuration"
  492. from TMSTRUCK_ABNORMAL_RESULT t_abnormal
  493. left join TMSTRUCK_TOTAL_RESULT t_total
  494. on t_abnormal.RESULT_TOTAL_ID=t_total.RESULT_TOTAL_ID
  495. left join OMSTRUCK_ORDER o_torder
  496. on t_total.ORDER_ID=o_torder.ORDER_ID
  497. left join RMS_CAPACITY r_capacity
  498. on o_torder.CAPACITY_ID=r_capacity.CAPACITY_ID
  499. left join AMS_SALE_ORDER_MATERIAL sale_material
  500. on o_torder.ORDER_PLAN_ID=sale_material.SALE_ORDER_MATERIAL_ID
  501. left join AMS_SALE_ORDER a_s_order
  502. on sale_material.SALE_ORDER_ID=a_s_order.SALE_ORDER_ID
  503. where o_torder.ORDER_NUMBER=#{orderNumbers}
  504. order by t_abnormal.ABNORMAL_TIME desc)
  505. <where>
  506. <if test="capacityNumber != null">
  507. and
  508. <foreach collection="capacityNumber" item="item" open="(" separator="or" close=")">
  509. "capacityNumber" like '%${item}%'
  510. </foreach>
  511. </if>
  512. <if test="orderNumber != null">
  513. and
  514. <foreach collection="orderNumber" item="item" open="(" separator="or" close=")">
  515. "orderNumber" like '%${item}%'
  516. </foreach>
  517. </if>
  518. <if test="saleNumber != null">
  519. and
  520. <foreach collection="saleNumber" item="item" open="(" separator="or" close=")">
  521. "saleNumber" like '%${item}%'
  522. </foreach>
  523. </if>
  524. <if test="abnormalCondition != null">
  525. and
  526. <foreach collection="abnormalCondition" item="item" open="(" separator="or" close=")">
  527. "abnormalCondition" like '%${item}%'
  528. </foreach>
  529. </if>
  530. <if test="abnormalTime != null">
  531. and
  532. <foreach collection="abnormalTime" item="item" open="(" separator="or" close=")">
  533. "abnormalTime" like '%${item}%'
  534. </foreach>
  535. </if>
  536. <if test="abnormalAddress != null">
  537. and
  538. <foreach collection="abnormalAddress" item="item" open="(" separator="or" close=")">
  539. "abnormalAddress" like '%${item}%'
  540. </foreach>
  541. </if>
  542. <if test="abnormalDuration != null">
  543. and
  544. <foreach collection="abnormalDuration" item="item" open="(" separator="or" close=")">
  545. "abnormalDuration" like '%${item}%'
  546. </foreach>
  547. </if>
  548. <include refid="orderBy"></include>
  549. </where>
  550. </select>
  551. <select id="transportationPerformance" resultType="java.util.Map">
  552. select
  553. *
  554. from (
  555. select distinct
  556. OO.ORDER_STATUS "orderStatus",
  557. OO.ORDER_NUMBER "orderNumber", --运单订单号
  558. RC.CAPACITY_NUMBER "capacityNumber",--车牌号
  559. TWR.RESULT_GROSS_WEIGHT_TIME "resultGrossWeightTime",--计毛时间
  560. TWR.RESULT_NET_WEIGHT "resultNetWeight",--净重
  561. RGOUT.GATEPOST_NAME "outGatepostName",--出厂门禁
  562. RCR.CARRIER_NAME "carrierName" , --承运商名称
  563. CONCAT( CONCAT( CONCAT(RRA.ADDRESS_PROVINCE,RRA.ADDRESS_DISTRICT),RRA.Address_Town),RRP.ADDRESS_DELIVERY_ADDRESS) "deliveryAddress", --详细收货地址
  564. RM.MATERIAL_NAME "materialName" , --"物质名称"
  565. RM.MATERIAL_SPECIFICATION "materialSpecification", -- "物质规格"
  566. RM.MATERIAL_MODEL "materialModel", --"物质型号"
  567. RCON.CONSIGNEE_COMPANY_NAME "receiveName" ,--客户名称
  568. TAR.RESULT_ARRIVAL_ADDRESS "resultReceiveAddress",--签收收货点的地址
  569. TRR.ORDER_MILEAGE "orderMileage", --运输距离
  570. TAR.RESULT_ARRIVAL_ADDRESS "resultArrivalAddress",--抵达收货点的地址
  571. TLFR.RESULT_OUT_GATE_TIME "resultOutGateTime",--出厂时间
  572. TAR.INSERT_TIME "arrivalTime",--抵达作业时间
  573. TRR.INSERT_TIME "recepitTime",--签收作业时间
  574. to_char(to_timestamp(to_char(TRR.INSERT_TIME,'yyyy-MM-dd HH24:mi:ss'),'yyyy-mm-dd hh24:mi:ss')-to_timestamp(to_char(TAR.INSERT_TIME,'yyyy-MM-dd HH24:mi:ss'),'yyyy-mm-dd hh24:mi:ss')) "unloadingWaitingTime",
  575. to_char(to_timestamp(to_char(TAR.INSERT_TIME,'yyyy-MM-dd HH24:mi:ss'),'yyyy-mm-dd hh24:mi:ss')-to_timestamp(to_char(TLFR.RESULT_OUT_GATE_TIME,'yyyy-MM-dd HH24:mi:ss'),'yyyy-mm-dd hh24:mi:ss')) "transportationTime"
  576. from OMSTRUCK_ORDER OO --运输订单
  577. left join AMS_SALE_ORDER_MATERIAL ASOM --销售订单物质表
  578. on ASOM.SALE_ORDER_MATERIAL_ID = OO.ORDER_PLAN_ID
  579. left join AMS_SALE_ORDER ASO --销售订单
  580. on ASO.SALE_ORDER_ID = ASOM.SALE_ORDER_ID
  581. left join RMS_CONSIGNEE RCON --收货客户
  582. on RCON.CONSIGNEE_ID = ASO.RECEIVE_ID
  583. left join TMSTRUCK_TOTAL_RESULT TTR --运输总实绩
  584. on TTR.ORDER_ID = OO.ORDER_ID
  585. left join TMSTRUCK_LOAD_RESULT TLR --汽车运输实绩表
  586. on TLR.RESULT_TOTAL_ID = TTR.RESULT_TOTAL_ID
  587. left join RMS_WAREHOUSE RW --装卸货仓库
  588. on RW.WAREHOUSE_ID = TLR.LOADING_ID
  589. left join TMSTRUCK_LEAVE_FACTORY_RESULT TLFR --离厂实绩
  590. on TLFR.RESULT_TOTAL_ID = TTR.RESULT_TOTAL_ID
  591. left join RMS_GATEPOST RGOUT --门岗
  592. on RGOUT.GATEPOST_ID = TLFR.GATEPOST_ID
  593. left join RMS_CAPACITY RC --运力
  594. on RC.CAPACITY_ID = OO.CAPACITY_ID
  595. left join AMS_DISPATCH_SALE_ORDER ADSO
  596. on ASOM.SALE_ORDER_MATERIAL_ID=ADSO.SALE_ORDER_MATERIAL_ID
  597. left join RMS_CARRIER RCR --承运单位
  598. on ADSO.CARRIER_ID=RCR.CARRIER_ID
  599. left join RMS_RECEIVE_PLACE RRP --收货地址
  600. on ASOM.SALE_SHIPPING_ADDRESS_ID=RRP.PLACE_ID
  601. left join RMS_RECEIVE_ADDRESS RRA
  602. on RRP.ADDRESS_ID=RRA.ADDRESS_ID
  603. left join AMS_SALE_TRUCKNO_MATERIAL ASTM
  604. on ASOM.SALE_ORDER_MATERIAL_ID=ASTM.SALE_ORDER_MATERIAL_ID
  605. left join AMS_SALE_MATERIAL ASM1
  606. on ASTM.MATERIAL_ID =ASM1.SALE_MATERIAL_ID
  607. left join TMSTRUCK_WEIGHT_RESULT TWR --运输实绩计重
  608. on TWR.RESULT_TOTAL_ID = TTR.RESULT_TOTAL_ID and ASM1.MATERIAL_ID =TWR.MATERIAL_ID
  609. left join RMS_MATERIAL RM
  610. on ASM1.MATERIAL_ID=RM.MATERIAL_ID
  611. left join TMSTRUCK_RECEIPT_RESULT TRR
  612. on TRR.RESULT_TOTAL_ID=TTR.RESULT_TOTAL_ID
  613. left join TMSTRUCK_ARRIVAL_RESULT TAR
  614. on TAR.RESULT_TOTAL_ID = TTR.RESULT_TOTAL_ID
  615. where OO.ORDER_TYPE in (1) and TLFR.RESULT_OUT_GATE_TIME IS NOT NULL
  616. )
  617. <where>
  618. <if test="orderStatus !=null">
  619. and "orderStatus" ='${orderStatus}'
  620. </if>
  621. <if test="orderNumbers !=null and orderNumbers !=''">
  622. and "orderNumber" like '%${orderNumbers}%'
  623. </if>
  624. <if test="capacityNumbers !=null and capacityNumbers !=''">
  625. and "capacityNumber" like '%${capacityNumbers}%'
  626. </if>
  627. <if test="resultGrossWeightTimes !=null and resultGrossWeightTimes !=''">
  628. and "resultGrossWeightTime" like '%${resultGrossWeightTimes}%'
  629. </if>
  630. <if test="resultGrossWeightTimes !=null and resultGrossWeightTimes !=''">
  631. and "resultGrossWeightTime" like '%${resultGrossWeightTimes}%'
  632. </if>
  633. <if test="resultOutGateTimes !=null and resultOutGateTimes !=''">
  634. and "resultOutGateTime" like '%${resultOutGateTimes}%'
  635. </if>
  636. <if test="resultNetWeights !=null and resultNetWeights !=''">
  637. and "resultNetWeight" like '%${resultNetWeights}%'
  638. </if>
  639. <if test="resultOutGateTimes !=null and resultOutGateTimes !=''">
  640. and "resultOutGateTime" like '%${resultOutGateTimes}%'
  641. </if>
  642. <if test="outGatepostNames !=null and outGatepostNames !=''">
  643. and "outGatepostName" like '%${outGatepostNames}%'
  644. </if>
  645. <if test="carrierNames !=null and carrierNames !=''">
  646. and "carrierName" like '%${carrierNames}%'
  647. </if>
  648. <if test="deliveryAddresss !=null and deliveryAddresss !=''">
  649. and "deliveryAddress" like '%${deliveryAddresss}%'
  650. </if>
  651. <if test="materialNames !=null and materialNames !=''">
  652. and "materialName" like '%${materialNames}%'
  653. </if>
  654. <if test="materialSpecifications !=null and materialSpecifications !=''">
  655. and "materialSpecification" like '%${materialSpecifications}%'
  656. </if>
  657. <if test="materialModels !=null and materialModels !=''">
  658. and "materialModel" like '%${materialModels}%'
  659. </if>
  660. <if test="receiveNames !=null and receiveNames!=''">
  661. and "receiveName" like '%${receiveNames}%'
  662. </if>
  663. <if test="startTime != null">
  664. and "resultOutGateTime" &gt;= to_date('${startTime}','yyyy-mm-dd')
  665. </if>
  666. <if test="endTime != null">
  667. and "resultOutGateTime" &lt;= to_date('${endTime}','yyyy-mm-dd')
  668. </if>
  669. <if test="orderNumber !=null">
  670. and "orderNumber" in
  671. <foreach collection="orderNumber" separator="," open="(" close=")" item="item" >
  672. #{item}
  673. </foreach>
  674. </if>
  675. <if test="capacityNumber !=null">
  676. and "capacityNumber" in
  677. <foreach collection="capacityNumber" separator="," open="(" close=")" item="item" >
  678. #{item}
  679. </foreach>
  680. </if>
  681. <if test="resultGrossWeightTime !=null">
  682. and "resultGrossWeightTime" in
  683. <foreach collection="resultGrossWeightTime" separator="," open="(" close=")" item="item" >
  684. #{item}
  685. </foreach>
  686. </if>
  687. <if test="resultNetWeight !=null">
  688. and "resultNetWeight" in
  689. <foreach collection="resultNetWeight" separator="," open="(" close=")" item="item" >
  690. #{item}
  691. </foreach>
  692. </if>
  693. <if test="resultOutGateTime !=null">
  694. and "resultOutGateTime" in
  695. <foreach collection="resultOutGateTime" separator="," open="(" close=")" item="item" >
  696. #{item}
  697. </foreach>
  698. </if>
  699. <if test="outGatepostName !=null">
  700. and "outGatepostName" in
  701. <foreach collection="outGatepostName" separator="," open="(" close=")" item="item" >
  702. #{item}
  703. </foreach>
  704. </if>
  705. <if test="carrierName !=null">
  706. and "carrierName" in
  707. <foreach collection="carrierName" separator="," open="(" close=")" item="item" >
  708. #{item}
  709. </foreach>
  710. </if>
  711. <if test="deliveryAddress !=null">
  712. and "deliveryAddress" in
  713. <foreach collection="deliveryAddress" separator="," open="(" close=")" item="item" >
  714. #{item}
  715. </foreach>
  716. </if>
  717. <if test="materialSpecification !=null">
  718. and "materialSpecification" in
  719. <foreach collection="materialSpecification" separator="," open="(" close=")" item="item" >
  720. #{item}
  721. </foreach>
  722. </if>
  723. <if test="materialModel !=null">
  724. and "materialModel" in
  725. <foreach collection="materialModel" separator="," open="(" close=")" item="item" >
  726. #{item}
  727. </foreach>
  728. </if>
  729. <if test="receiveName !=null">
  730. and "receiveName" in
  731. <foreach collection="receiveName" separator="," open="(" close=")" item="item" >
  732. #{item}
  733. </foreach>
  734. </if>
  735. <if test="orderMileage !=null">
  736. and "orderMileage" in
  737. <foreach collection="orderMileage" separator="," open="(" close=")" item="item" >
  738. #{item}
  739. </foreach>
  740. </if>
  741. </where>
  742. <include refid="orderBy"></include>
  743. </select>
  744. <select id="selectIsSelfMention" resultType="java.lang.Integer">
  745. select count(*) from RMS_CAPACITY RC
  746. left join OMSTRUCK_ORDER OO
  747. on RC.CAPACITY_ID=OO.CAPACITY_ID
  748. left join AMS_SALE_ORDER_MATERIAL ASOM
  749. on OO.ORDER_PLAN_ID = ASOM.SALE_ORDER_MATERIAL_ID
  750. left join AMS_SALE_ORDER ASO
  751. on ASOM.SALE_ORDER_ID = ASO.SALE_ORDER_ID
  752. where OO.ORDER_TYPE in (1) and ASO.Sale_Order_Isself_Mention='是' and RC.CAPACITY_NUMBER = #{capcityNumber}
  753. </select>
  754. <select id="isSelfMentionByOrderNumber" resultType="java.lang.Integer">
  755. select count(*) from OMSTRUCK_ORDER OO
  756. left join AMS_SALE_ORDER_MATERIAL ASOM
  757. on OO.ORDER_PLAN_ID = ASOM.SALE_ORDER_MATERIAL_ID
  758. left join AMS_SALE_ORDER ASO
  759. on ASOM.SALE_ORDER_ID = ASO.SALE_ORDER_ID
  760. where OO.ORDER_TYPE in (1) and ASO.Sale_Order_Isself_Mention='是' and OO.ORDER_NUMBER =#{orderNumber}
  761. </select>
  762. <sql id="orderBy">
  763. <if test="orderField != null and orderField != ''">
  764. order by "${orderField}"
  765. <if test="orderType != null and orderType != ''">
  766. ${orderType}
  767. </if>
  768. </if>
  769. </sql>
  770. </mapper>