UniversalMapper.xml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  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.UniversalMapper">
  4. <select id="getTiHuoDan" parameterType="string" resultType="java.util.Map">
  5. select OO.ORDER_NUMBER "orderNumber",
  6. RC.CAPACITY_NUMBER "capacityNumber",
  7. RCA.CARRIER_NAME "carrierName",
  8. RCON.CONSIGNEE_COMPANY_NAME "consigneeCompanyName"
  9. from OMSTRUCK_ORDER OO
  10. left join RMS_CAPACITY RC
  11. on RC.CAPACITY_ID = OO.CAPACITY_ID
  12. left join RMS_CARRIER RCA
  13. on RCA.CARRIER_ID = RC.CARRIER_ID
  14. left join AMS_SALE_ORDER ASO
  15. on ASO.SALE_ORDER_ID = OO.ORDER_PLAN_ID
  16. left join RMS_CONSIGNEE RCON
  17. on RCON.CONSIGNEE_ID = ASO.RECEIVE_ID
  18. where OO.ORDER_NUMBER = #{orderNumber}
  19. </select>
  20. <select id="selectHuanPiaoDan">
  21. </select>
  22. <!-- 查询订单子表关联的 -->
  23. <select id="getOOMMes" parameterType="string" resultType="java.util.Map">
  24. select RM.MATERIAL_NAME "materialName",
  25. RPP.PLATFORM_NAME "platformName",
  26. RP.PERSONNEL_NAME "personnelName",
  27. (
  28. select ORDER_MATERIAL_NUMBER
  29. from OMSTRUCK_ORDER_MATERIAL OOM
  30. where OOM.ORDER_ID = OO.ORDER_ID
  31. and TLR.MATERIAL_ID = OOM.MATERIAL_ID
  32. ) "orderMaterialNumber"
  33. from OMSTRUCK_ORDER OO
  34. left join TMSTRUCK_TOTAL_RESULT TTR
  35. on TTR.ORDER_ID = OO.ORDER_ID
  36. left join TMSTRUCK_LOAD_RESULT TLR
  37. on TTR.RESULT_TOTAL_ID = TLR.RESULT_TOTAL_ID
  38. left join RMS_PWAREHOUSE_PLATFORM RPP
  39. on RPP.PLATFORM_ID = TLR.LOADING_ID
  40. left join RMS_MATERIAL RM
  41. on RM.MATERIAL_ID = TLR.MATERIAL_ID
  42. left join RMS_PERSONNEL RP
  43. on RP.PERSONNEL_ID = TLR.LOADER_ID
  44. where ORDER_NUMBER = #{orderNumber}
  45. </select>
  46. <sql id="orderBy">
  47. <if test="orderField != null and orderField != ''">
  48. order by "${orderField}"
  49. <if test="orderType != null and orderType != ''">
  50. ${orderType}
  51. </if>
  52. </if>
  53. </sql>
  54. <!-- 模糊查询所有物资 -->
  55. <select id="queryAPOMaterialByLike" parameterType="java.util.Map" resultType="java.util.Map">
  56. SELECT *
  57. FROM (
  58. SELECT DISTINCT RM.MATERIAL_ID "materialId",
  59. RM.MATERIAL_NAME "materialName",
  60. RM.MATERIAL_CODE "materialCode",
  61. RM.MATERIAL_SPECIFICATION "materialSpecification",
  62. RM.MATERIAL_MODEL "materialModel"
  63. FROM AMS_PURCHASE_ORDER APO
  64. JOIN DIL_BATCH DB
  65. ON DB.BATCH_ID = APO.BATCH_ID
  66. JOIN RMS_MATERIAL RM
  67. ON RM.MATERIAL_ID = DB.MATERIAL_ID
  68. <where>
  69. <if test="index != null">
  70. RM.MATERIAL_NAME LIKE #{index}
  71. </if>
  72. </where>
  73. )
  74. <where>
  75. <if test="materialName != null">
  76. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  77. "materialName" like '%${item}%'
  78. </foreach>
  79. </if>
  80. <if test="materialCode != null">
  81. and
  82. <foreach collection="materialCode" item="item" open="(" separator="or" close=")">
  83. "materialCode" like '%${item}%'
  84. </foreach>
  85. </if>
  86. <if test="materialSpecification != null">
  87. and
  88. <foreach collection="materialSpecification" item="item" open="(" separator="or" close=")">
  89. "materialSpecification" like '%${item}%'
  90. </foreach>
  91. </if>
  92. <if test="materialModel != null">
  93. and
  94. <foreach collection="materialModel" item="item" open="(" separator="or" close=")">
  95. "materialModel" like '%${item}%'
  96. </foreach>
  97. </if>
  98. </where>
  99. <include refid="orderBy"></include>
  100. <if test="orderField == null ">
  101. order by "materialId" desc
  102. </if>
  103. </select>
  104. <!-- 模糊查询发货单位 -->
  105. <select id="querySupplierByLike" parameterType="java.util.Map" resultType="java.util.Map">
  106. SELECT *
  107. FROM (
  108. SELECT RS.SUPPLIER_ID "supplierId",
  109. RS.SUPPLIER_NAME "supplierName",
  110. RS.SUPPLIER_ADDRESS "supplierAddress"
  111. FROM RMS_SUPPLIER RS
  112. <where>
  113. <if test="index != null">
  114. RS.SUPPLIER_NAME LIKE #{index}
  115. </if>
  116. </where>
  117. )
  118. <where>
  119. <if test="supplierName != null">
  120. <foreach collection="supplierName" item="item" open="(" separator="or" close=")">
  121. "supplierName" like '%${item}%'
  122. </foreach>
  123. </if>
  124. <if test="supplierAddress != null">
  125. and
  126. <foreach collection="supplierAddress" item="item" open="(" separator="or" close=")">
  127. "supplierAddress" like '%${item}%'
  128. </foreach>
  129. </if>
  130. </where>
  131. <include refid="orderBy"></include>
  132. <if test="orderField == null ">
  133. order by "supplierId" desc
  134. </if>
  135. </select>
  136. <!-- 获取所有的运力信息 -->
  137. <select id="getAllCapacityByCarrierLike" parameterType="java.util.Map" resultType="java.util.LinkedHashMap">
  138. SELECT *
  139. FROM (
  140. SELECT
  141. RC.CAPACITY_ID "capacityId",
  142. RC.CAPACITY_NUMBER "capacityNumber",
  143. RCA.CARRIER_NAME "carrierName"
  144. FROM RMS_CAPACITY RC
  145. JOIN RMS_CARRIER RCA
  146. ON RCA.CARRIER_ID = RC.CARRIER_ID
  147. WHERE RC.CAPACITY_STATUS = 0 AND RC.CAPACITY_TYPE_ID = 1
  148. <if test="carrierId != null" >
  149. and RC.CARRIER_ID = #{carrierId}
  150. </if>
  151. ) RCRC
  152. <if test="index != null">
  153. where RCRC."capacityNumber" LIKE #{index}
  154. </if>
  155. <if test="index != null">
  156. or RCRC."carrierName" LIKE #{index}
  157. </if>
  158. <!-- <where>-->
  159. <!-- <if test="capacityNumber != null">-->
  160. <!-- <foreach collection="capacityNumber" item="item" open="(" separator="or" close=")">-->
  161. <!-- "capacityNumber" like '%${item}%'-->
  162. <!-- </foreach>-->
  163. <!-- </if>-->
  164. <!-- <if test="carrierName != null">-->
  165. <!-- and-->
  166. <!-- <foreach collection="carrierName" item="item" open="(" separator="or" close=")">-->
  167. <!-- "carrierName" like '%${item}%'-->
  168. <!-- </foreach>-->
  169. <!-- </if>-->
  170. <!-- </where>-->
  171. </select>
  172. <select id="getCarrierIdBySSO" parameterType="java.lang.String" resultType="DECIMAL" >
  173. SELECT
  174. RC.CARRIER_ID AS "carrierId"
  175. FROM RMS_CARRIER RC
  176. WHERE RC.CARRIER_SSO_ID = #{carrierSsoId}
  177. </select>
  178. <!-- 通过订单ID查询物资子表信息 -->
  179. <select id="getMaterialMesByOrderId" parameterType="int" resultType="java.util.Map">
  180. select *
  181. from (
  182. select RM.MATERIAL_NAME "materialName",
  183. RM.MATERIAL_THEORETICAL_WEIGHT "materialTheoreticalWeight",
  184. RM.MATERIAL_SPECIFICATION "materialSpecification",
  185. RM.MATERIAL_MODEL "materialModel",
  186. OOM.ORDER_MATERIAL_NUMBER "orderMaterialNumber"
  187. from OMSTRUCK_ORDER_MATERIAL OOM
  188. left join RMS_MATERIAL RM
  189. ON RM.MATERIAL_ID = OOM.MATERIAL_ID
  190. <where>
  191. <if test="orderId != null" >
  192. OOM.ORDER_ID = #{orderId}
  193. </if>
  194. </where>
  195. )
  196. <where>
  197. <if test="materialName != null">
  198. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  199. "materialName" like '%${item}%'
  200. </foreach>
  201. </if>
  202. <if test="materialTheoreticalWeight != null">
  203. and
  204. <foreach collection="materialTheoreticalWeight" item="item" open="(" separator="or" close=")">
  205. "materialTheoreticalWeight" like '%${item}%'
  206. </foreach>
  207. </if>
  208. <if test="orderMaterialNumber != null">
  209. and
  210. <foreach collection="orderMaterialNumber" item="item" open="(" separator="or" close=")">
  211. "orderMaterialNumber" like '%${item}%'
  212. </foreach>
  213. </if>
  214. </where>
  215. <include refid="orderBy"></include>
  216. <if test="orderField == null ">
  217. order by "materialName" desc
  218. </if>
  219. </select>
  220. <!--查询所有物资-->
  221. <select id="selectAllMaterialName" resultType="java.util.Map" parameterType="java.util.Map">
  222. SELECT * FROM (
  223. select distinct RM.MATERIAL_NAME "materialName",
  224. RM.MATERIAL_SPECIFICATION "materialSpecification",
  225. RM.MATERIAL_MODEL "materialModel",
  226. RM.MATERIAL_CODE "materialCode",
  227. RM.MATERIAL_ID AS "materialId"
  228. from RMS_MATERIAL RM
  229. <where>
  230. <if test="index != null">
  231. RM.MATERIAL_NAME like #{index}
  232. </if>
  233. </where>
  234. )
  235. <where>
  236. <if test="materialName != null">
  237. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  238. "materialName" like '%${item}%'
  239. </foreach>
  240. </if>
  241. <if test="materialSpecification != null">
  242. and
  243. <foreach collection="materialSpecification" item="item" open="(" separator="or" close=")">
  244. "materialSpecification" like '%${item}%'
  245. </foreach>
  246. </if>
  247. <if test="materialModel != null">
  248. and
  249. <foreach collection="materialModel" item="item" open="(" separator="or" close=")">
  250. "materialModel" like '%${item}%'
  251. </foreach>
  252. </if>
  253. <if test="materialCode != null">
  254. and
  255. <foreach collection="materialCode" item="item" open="(" separator="or" close=")">
  256. "materialCode" like '%${item}%'
  257. </foreach>
  258. </if>
  259. </where>
  260. </select>
  261. <!-- 通过物资ID查询该物资的发货单位信息 -->
  262. <select id="getSupplierMesByMaterialId" parameterType="java.util.Map" resultType="java.util.Map">
  263. select *
  264. from (
  265. select distinct RS.SUPPLIER_ID "supplierId",
  266. RS.SUPPLIER_NAME "supplierName",
  267. RS.SUPPLIER_ADDRESS "supplierAddress"
  268. from DIL_BATCH DB
  269. join AMS_PURCHASE_ORDER APO
  270. on apo.BATCH_ID = DB.BATCH_ID
  271. join RMS_SUPPLIER RS
  272. on RS.SUPPLIER_ID = apo.SUPPLIER_UNIT_ID
  273. <where>
  274. <if test="materialId != null">
  275. DB.MATERIAL_ID = #{materialId}
  276. </if>
  277. </where>
  278. )
  279. <where>
  280. <if test="index != null">
  281. "supplierName" like #{index}
  282. </if>
  283. </where>
  284. </select>
  285. <!-- 模糊查询所有的卸货点信息 -->
  286. <select id="getUnloadingMesByLike" parameterType="map" resultType="java.util.Map">
  287. select *
  288. from (
  289. select
  290. RW.WAREHOUSE_ID "warehouseId",
  291. RW.WAREHOUSE_NAME "warehouseName"
  292. from RMS_WAREHOUSE RW
  293. <where>
  294. <if test="type != null">
  295. RW.WAREHOUSE_TYPE_ID = #{type}
  296. </if>
  297. </where>
  298. )
  299. <where>
  300. <if test="index != null">
  301. "warehouseName" like #{index}
  302. </if>
  303. <if test="warehouseName != null">
  304. <foreach collection="warehouseName" item="item" open="(" separator="or" close=")">
  305. "warehouseName" like '%${item}%'
  306. </foreach>
  307. </if>
  308. </where>
  309. <include refid="orderBy"></include>
  310. <if test="orderField == null ">
  311. order by "warehouseName" desc
  312. </if>
  313. </select>
  314. <!-- 模糊查询所有物资 -->
  315. <select id="queryMaterialByLike" parameterType="java.util.Map" resultType="java.util.Map">
  316. SELECT *
  317. FROM (
  318. SELECT RM.MATERIAL_ID "materialId",
  319. RM.MATERIAL_NAME "materialName",
  320. RM.MATERIAL_CODE "materialCode",
  321. RM.MATERIAL_SPECIFICATION "materialSpecification",
  322. RM.MATERIAL_MODEL "materialModel"
  323. FROM RMS_MATERIAL RM
  324. <where>
  325. <if test="startNum != null">
  326. RM.MATERIAL_CODE LIKE #{startNum}
  327. </if>
  328. <if test="startNum == null">
  329. RM.MATERIAL_CODE LIKE '010%' OR RM.MATERIAL_CODE LIKE '080%'
  330. </if>
  331. </where>
  332. )
  333. <where>
  334. <if test="index != null">
  335. "materialName" LIKE #{index}
  336. </if>
  337. <if test="materialName != null">
  338. and
  339. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  340. "materialName" like '%${item}%'
  341. </foreach>
  342. </if>
  343. <if test="materialCode != null">
  344. and
  345. <foreach collection="materialCode" item="item" open="(" separator="or" close=")">
  346. "materialCode" like '%${item}%'
  347. </foreach>
  348. </if>
  349. <if test="materialSpecification != null">
  350. and
  351. <foreach collection="materialSpecification" item="item" open="(" separator="or" close=")">
  352. "materialSpecification" like '%${item}%'
  353. </foreach>
  354. </if>
  355. <if test="materialModel != null">
  356. and
  357. <foreach collection="materialModel" item="item" open="(" separator="or" close=")">
  358. "materialModel" like '%${item}%'
  359. </foreach>
  360. </if>
  361. </where>
  362. <include refid="orderBy"></include>
  363. <if test="orderField == null ">
  364. order by "materialId" desc
  365. </if>
  366. </select>
  367. <!-- 查询所有的批次及其关联的采购订单号 -->
  368. <select id="getBatchAndOrderMes" parameterType="map" resultType="java.util.Map">
  369. select *
  370. from (
  371. select
  372. DB.BATCH_ID "batchId",
  373. DB.RESULT_FOREIGN_SHIP_NAME "resultForeignShipName",
  374. RM.MATERIAL_NAME "materialName",
  375. APO.PURCHASE_ORDER_NO "purchaseOrderNo",
  376. APO.INSERT_TIME "insetTime"
  377. from DIL_BATCH DB
  378. left join AMS_PURCHASE_ORDER APO
  379. on APO.BATCH_ID = DB.BATCH_ID
  380. left join RMS_MATERIAL RM
  381. on RM.MATERIAL_ID = DB.MATERIAL_ID
  382. <where>
  383. <if test="index != null">
  384. "resultForeignShipName" like #{index}
  385. </if>
  386. </where>
  387. )
  388. <where>
  389. <if test="resultForeignShipName != null">
  390. <foreach collection="resultForeignShipName" item="item" open="(" separator="or" close=")">
  391. "resultForeignShipName" like '%${item}%'
  392. </foreach>
  393. </if>
  394. <if test="materialName != null">
  395. and
  396. <foreach collection="materialName" item="item" open="(" separator="or" close=")">
  397. "materialName" like '%${item}%'
  398. </foreach>
  399. </if>
  400. <if test="purchaseOrderNo != null">
  401. and
  402. <foreach collection="purchaseOrderNo" item="item" open="(" separator="or" close=")">
  403. "purchaseOrderNo" like '%${item}%'
  404. </foreach>
  405. </if>
  406. </where>
  407. <include refid="orderBy"></include>
  408. <if test="orderField == null ">
  409. order by "insetTime" desc
  410. </if>
  411. </select>
  412. <!-- 边输边查承运商 -->
  413. <select id="getCarrierMesByLike" parameterType="string" resultType="java.util.Map">
  414. select
  415. RC.CARRIER_ID "carrierId",
  416. RC.CARRIER_NAME "value",
  417. RC.CARRIER_NAME "carrierName"
  418. from RMS_CARRIER RC
  419. where
  420. instr(RC.CARRIER_NAME, #{index}) > 0 and rownum &lt; 10
  421. order by "value"
  422. </select>
  423. <!-- 边输边查发货单位 -->
  424. <select id="getSupplierMesByLike" parameterType="string" resultType="java.util.Map">
  425. select
  426. RS.SUPPLIER_ID "supplierId",
  427. RS.SUPPLIER_NAME "value",
  428. RS.SUPPLIER_NAME "supplierName"
  429. from RMS_SUPPLIER RS
  430. where instr(RS.SUPPLIER_NAME, #{index}) > 0 and rownum &lt; 10
  431. order by "value"
  432. </select>
  433. <!-- 边输边查收货单位 -->
  434. <select id="getConsigneeByLike" parameterType="string" resultType="java.util.Map">
  435. select
  436. RC.CONSIGNEE_ID "consigneeId",
  437. RC.CONSIGNEE_COMPANY_NAME "value",
  438. RC.CONSIGNEE_COMPANY_NAME "consigneeCompanyName"
  439. from RMS_CONSIGNEE RC
  440. where instr(RC.CONSIGNEE_COMPANY_NAME, #{index}) > 0 and rownum &lt; 10
  441. order by "value"
  442. </select>
  443. <select id="getCarrierListByLike" parameterType="java.util.Map" resultType="java.util.Map" >
  444. select
  445. *
  446. from(
  447. select
  448. RC.CARRIER_ID "carrierId",
  449. RC.CARRIER_NAME "carrierName"
  450. from RMS_CARRIER RC
  451. <where>
  452. <if test="index != null">
  453. RC.CARRIER_NAME like #{index}
  454. </if>
  455. </where>
  456. order by RC.CARRIER_NAME
  457. )
  458. </select>
  459. <select id="queryConsigneeByLike" resultType="java.util.Map" parameterType="java.util.Map" >
  460. SELECT * FROM (
  461. SELECT
  462. RCO.CONSIGNEE_COMPANY_NAME AS "consigneeCompanyName",
  463. RCO.CONSIGNEE_CODE AS "consigneeCode",
  464. RCO.CONSIGNEE_ID AS "consigneeId"
  465. FROM RMS_CONSIGNEE RCO
  466. <where>
  467. <if test="index != null">
  468. RCO.CONSIGNEE_COMPANY_NAME like #{index}
  469. </if>
  470. </where>
  471. )
  472. <if test="consigneeCompanyName != null">
  473. <foreach collection="consigneeCompanyName" item="item" open="(" separator="or" close=")">
  474. "consigneeCompanyName" like '%${item}%'
  475. </foreach>
  476. </if>
  477. <if test="consigneeCode != null">
  478. and
  479. <foreach collection="consigneeCode" item="item" open="(" separator="or" close=")">
  480. "consigneeCode" like '%${item}%'
  481. </foreach>
  482. </if>
  483. </select>
  484. <!-- 通过订单ID查询订单下所有物资 -->
  485. <select id="getOrderMaterialMesByOrderId" parameterType="java.math.BigDecimal" resultType="java.util.Map">
  486. select RM.MATERIAL_NAME "materialName",
  487. CONCAT(RM.MATERIAL_SPECIFICATION,RM.MATERIAL_MODEL) "materialModel",
  488. (case
  489. when OOM.ORDER_MATERIAL_WEIGHT is not null
  490. then OOM.ORDER_MATERIAL_WEIGHT
  491. else OOM.ORDER_MATERIAL_NUMBER
  492. end) "weightNum"
  493. from OMSTRUCK_ORDER_MATERIAL OOM
  494. left join RMS_MATERIAL RM
  495. on RM.MATERIAL_ID = OOM.MATERIAL_ID
  496. where OOM.ORDER_ID = #{orderId}
  497. </select>
  498. <!-- 边输边查卸货点 -->
  499. <select id="selectUnloadingPoint" parameterType="string" resultType="java.util.Map">
  500. select Rw.WAREHOUSE_NAME "warehouseName",
  501. RW.WAREHOUSE_ID "warehouseId"
  502. from RMS_WAREHOUSE RW
  503. order by "warehouseName"
  504. </select>
  505. <select id="getAllGatepost" resultType="java.util.Map" >
  506. SELECT
  507. RG.GATEPOST_ID AS "gatepostId",
  508. RG.GATEPOST_NAME AS "gatepostName"
  509. FROM RMS_GATEPOST RG
  510. </select>
  511. <!-- 模糊查询收货单位 -->
  512. <select id="getConsigneeListByLike" parameterType="java.util.Map" resultType="java.util.Map" >
  513. SELECT
  514. RC.CONSIGNEE_COMPANY_NAME AS "consigneeCompanyName"
  515. FROM RMS_CONSIGNEE RC
  516. WHERE
  517. <if test="index != null">
  518. RC.CONSIGNEE_COMPANY_NAME like #{index}
  519. </if>
  520. order by "consigneeCompanyName"
  521. </select>
  522. <select id="queryAllSupplierByLike" resultType="java.util.Map">
  523. select *
  524. from (
  525. select distinct RS.SUPPLIER_ID "supplierId",
  526. RS.SUPPLIER_NAME "supplierName",
  527. RS.SUPPLIER_ADDRESS "supplierAddress"
  528. from RMS_SUPPLIER RS
  529. )
  530. <where>
  531. <if test="index != null">
  532. "supplierName" like #{index}
  533. </if>
  534. </where>
  535. </select>
  536. </mapper>