zelong.shao

customer|查询调整

1 <?xml version="1.0" encoding="UTF-8"?> 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"> 2 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 <mapper namespace="com.fedex.connect.customer.repository.dao.ConsignmentExtMapper"> 3 <mapper namespace="com.fedex.connect.customer.repository.dao.ConsignmentExtMapper">
4 - <resultMap id="BaseResultMap" type="com.fedex.connect.common.model.biz.Consignment">
5 - <id column="ID" jdbcType="NUMERIC" property="id" />
6 - <result column="CONSIGNMENT_CODE" jdbcType="VARCHAR" property="consignmentCode" />
7 - <result column="SHIP_DATE" jdbcType="TIMESTAMP" property="shipDate" />
8 - <result column="SHIPPER_COUNTRY" jdbcType="VARCHAR" property="shipperCountry" />
9 - <result column="RECIPIENT_COUNTRY" jdbcType="VARCHAR" property="recipientCountry" />
10 - <result column="DEST_IATA_CODE" jdbcType="VARCHAR" property="destIataCode" />
11 - <result column="COUNT_ORIGIN" jdbcType="VARCHAR" property="countOrigin" />
12 - <result column="DESTINATION_COUNTRY" jdbcType="VARCHAR" property="destinationCountry" />
13 - <result column="CUSTOMS_CURRENCY" jdbcType="VARCHAR" property="customsCurrency" />
14 - <result column="CUSTOMS_VALUE" jdbcType="NUMERIC" property="customsValue" />
15 - <result column="WEIGHT" jdbcType="NUMERIC" property="weight" />
16 - <result column="WEIGHTUNIT" jdbcType="NUMERIC" property="weightunit" />
17 - <result column="SCANDATE" jdbcType="TIMESTAMP" property="scandate" />
18 - <result column="SHIPPER_CONTACT_NAME" jdbcType="VARCHAR" property="shipperContactName" />
19 - <result column="SHIPPER_PHONE" jdbcType="VARCHAR" property="shipperPhone" />
20 - <result column="SHIPPER_ACCOUNT" jdbcType="VARCHAR" property="shipperAccount" />
21 - <result column="SHIPPER_COMPANY" jdbcType="VARCHAR" property="shipperCompany" />
22 - <result column="SHIPPER_ADDR_LINE1" jdbcType="VARCHAR" property="shipperAddrLine1" />
23 - <result column="SHIPPER_ADDR_LINE2" jdbcType="VARCHAR" property="shipperAddrLine2" />
24 - <result column="SHIPPER_CITY" jdbcType="VARCHAR" property="shipperCity" />
25 - <result column="SHIPPER_EMAIL" jdbcType="VARCHAR" property="shipperEmail" />
26 - <result column="RECIPIENT_CONTACT_NAME" jdbcType="VARCHAR" property="recipientContactName" />
27 - <result column="RECIPIENT_PHONE" jdbcType="VARCHAR" property="recipientPhone" />
28 - <result column="RECIPIENT_COMPANY" jdbcType="VARCHAR" property="recipientCompany" />
29 - <result column="RECIPIENT_ADDR_LINE1" jdbcType="VARCHAR" property="recipientAddrLine1" />
30 - <result column="RECIPIENT_ADDR_LINE2" jdbcType="VARCHAR" property="recipientAddrLine2" />
31 - <result column="RECIPIENT_ADDR_LINE3" jdbcType="VARCHAR" property="recipientAddrLine3" />
32 - <result column="RECIPIENT_CITY" jdbcType="VARCHAR" property="recipientCity" />
33 - <result column="FIRST_COMMIT_TIME" jdbcType="TIMESTAMP" property="firstCommitTime" />
34 - <result column="FIRST_SUBMITTER_ID" jdbcType="NUMERIC" property="firstSubmitterId" />
35 - <result column="FIRST_SUBMITTER" jdbcType="VARCHAR" property="firstSubmitter" />
36 - <result column="COMMIT_TIME" jdbcType="TIMESTAMP" property="commitTime" />
37 - <result column="SUBMITTER_ID" jdbcType="NUMERIC" property="submitterId" />
38 - <result column="SUBMITTER" jdbcType="VARCHAR" property="submitter" />
39 - <result column="CREATE_TIME" jdbcType="TIMESTAMP" property="createTime" />
40 - <result column="CREATE_USER_ID" jdbcType="NUMERIC" property="createUserId" />
41 - <result column="CREATE_USER_NAME" jdbcType="VARCHAR" property="createUserName" />
42 - <result column="MODIFY_TIME" jdbcType="TIMESTAMP" property="modifyTime" />
43 - <result column="MODIFY_USER_ID" jdbcType="NUMERIC" property="modifyUserId" />
44 - <result column="MODIFY_USER_NAME" jdbcType="VARCHAR" property="modifyUserName" />
45 - <result column="CE_INFO_ID" jdbcType="NUMERIC" property="ceInfoId" />
46 - </resultMap>
47 4
48 <select id="findConsignments" resultType="com.fedex.connect.common.model.biz.Consignment"> 5 <select id="findConsignments" resultType="com.fedex.connect.common.model.biz.Consignment">
49 - SELECT c.* 6 + SELECT DISTINCT c.*
50 - FROM T_BIZ_USER_CONSIGNMENT_MAPPING m
51 - JOIN T_BIZ_CONSIGNMENT c ON m.consignment_id = c.id
52 - WHERE m.user_id = #{userId}
53 - <if test="createTimeFrom != null and createTimeFrom != ''">
54 - AND c.CREATE_TIME &gt;= TO_DATE(#{createTimeFrom}, 'YYYY-MM-DD HH24:MI:SS')
55 - </if>
56 - <if test="createTimeTo != null and createTimeTo != ''">
57 - AND c.CREATE_TIME &lt;= TO_DATE(#{createTimeTo}, 'YYYY-MM-DD HH24:MI:SS')
58 - </if>
59 - <if test="consignmentCodeList != null and consignmentCodeList.size() != 0">
60 - AND c.CONSIGNMENT_CODE IN
61 - <foreach collection="consignmentCodeList" item="item" separator="," open="(" close=")">
62 - #{item}
63 - </foreach>
64 - </if>
65 -
66 - UNION
67 -
68 - SELECT c.*
69 FROM T_BIZ_CONSIGNMENT c 7 FROM T_BIZ_CONSIGNMENT c
70 - WHERE c.user_uuid = #{uuid,jdbcType=VARCHAR} <!-- 明确指定 jdbcType --> 8 + LEFT JOIN T_BIZ_USER_CONSIGNMENT_MAPPING m ON c.id = m.consignment_id
9 + WHERE
10 + (
11 + (m.user_id = #{userId} AND m.consignment_id IS NOT NULL)
12 + OR c.user_uuid = #{uuid,jdbcType=VARCHAR}
13 + )
71 <if test="createTimeFrom != null and createTimeFrom != ''"> 14 <if test="createTimeFrom != null and createTimeFrom != ''">
72 AND c.CREATE_TIME &gt;= TO_DATE(#{createTimeFrom}, 'YYYY-MM-DD HH24:MI:SS') 15 AND c.CREATE_TIME &gt;= TO_DATE(#{createTimeFrom}, 'YYYY-MM-DD HH24:MI:SS')
73 </if> 16 </if>
...@@ -84,30 +27,14 @@ ...@@ -84,30 +27,14 @@
84 27
85 28
86 <select id="findAllCount" resultType="java.lang.Long"> 29 <select id="findAllCount" resultType="java.lang.Long">
87 - SELECT COUNT(*) 30 + SELECT COUNT(DISTINCT c.id)
88 - FROM (
89 - SELECT c.id AS consignment_id
90 - FROM T_BIZ_USER_CONSIGNMENT_MAPPING m
91 - JOIN T_BIZ_CONSIGNMENT c ON m.consignment_id = c.id
92 - WHERE m.user_id = #{userId}
93 - <if test="createTimeFrom != null and createTimeFrom != ''">
94 - AND c.CREATE_TIME &gt;= TO_DATE(#{createTimeFrom}, 'YYYY-MM-DD HH24:MI:SS')
95 - </if>
96 - <if test="createTimeTo != null and createTimeTo != ''">
97 - AND c.CREATE_TIME &lt;= TO_DATE(#{createTimeTo}, 'YYYY-MM-DD HH24:MI:SS')
98 - </if>
99 - <if test="consignmentCodeList != null and consignmentCodeList.size() != 0">
100 - AND c.CONSIGNMENT_CODE IN
101 - <foreach collection="consignmentCodeList" item="item" separator="," open="(" close=")">
102 - #{item}
103 - </foreach>
104 - </if>
105 -
106 - UNION
107 -
108 - SELECT c.id AS consignment_id
109 FROM T_BIZ_CONSIGNMENT c 31 FROM T_BIZ_CONSIGNMENT c
110 - WHERE c.user_uuid = #{uuid,jdbcType=VARCHAR} 32 + LEFT JOIN T_BIZ_USER_CONSIGNMENT_MAPPING m ON c.id = m.consignment_id
33 + WHERE
34 + (
35 + (m.user_id = #{userId} AND m.consignment_id IS NOT NULL)
36 + OR c.user_uuid = #{uuid,jdbcType=VARCHAR}
37 + )
111 <if test="createTimeFrom != null and createTimeFrom != ''"> 38 <if test="createTimeFrom != null and createTimeFrom != ''">
112 AND c.CREATE_TIME &gt;= TO_DATE(#{createTimeFrom}, 'YYYY-MM-DD HH24:MI:SS') 39 AND c.CREATE_TIME &gt;= TO_DATE(#{createTimeFrom}, 'YYYY-MM-DD HH24:MI:SS')
113 </if> 40 </if>
...@@ -120,7 +47,6 @@ ...@@ -120,7 +47,6 @@
120 #{item} 47 #{item}
121 </foreach> 48 </foreach>
122 </if> 49 </if>
123 - ) combined_results
124 </select> 50 </select>
125 51
126 52
......
...@@ -52,8 +52,6 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS ...@@ -52,8 +52,6 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS
52 List<Consignment> consignments = consignmentExtRepository.findConsignments(query); 52 List<Consignment> consignments = consignmentExtRepository.findConsignments(query);
53 pageResult.setList(consignments); 53 pageResult.setList(consignments);
54 } 54 }
55 - List<Consignment> consignments = consignmentExtRepository.findConsignments(query);
56 - pageResult.setList(consignments);
57 return ResponseVo.succ(pageResult); 55 return ResponseVo.succ(pageResult);
58 } 56 }
59 57
......