zelong.shao

customer|查询调整,通过中间表查询

1 package com.fedex.connect.customer.controller.biz; 1 package com.fedex.connect.customer.controller.biz;
2 2
3 +import com.fedex.connect.common.dependencies.date.vo.ResponseResultVo;
4 +import com.fedex.connect.customer.data.bo.LongBo;
5 +import org.springframework.web.bind.annotation.RequestBody;
6 +
3 public interface IAttachmentController { 7 public interface IAttachmentController {
8 + ResponseResultVo findHistory(@RequestBody LongBo bo);
4 } 9 }
......
...@@ -4,6 +4,7 @@ import com.fedex.connect.common.dependencies.date.model.LogShowModel; ...@@ -4,6 +4,7 @@ import com.fedex.connect.common.dependencies.date.model.LogShowModel;
4 import com.fedex.connect.common.dependencies.date.vo.ResponseResultVo; 4 import com.fedex.connect.common.dependencies.date.vo.ResponseResultVo;
5 import com.fedex.connect.common.dependencies.enums.ResponseCode; 5 import com.fedex.connect.common.dependencies.enums.ResponseCode;
6 import com.fedex.connect.common.dependencies.util.CurrentUserInfo; 6 import com.fedex.connect.common.dependencies.util.CurrentUserInfo;
7 +import com.fedex.connect.common.model.sys.User;
7 import com.fedex.connect.customer.controller.AbstractEtController; 8 import com.fedex.connect.customer.controller.AbstractEtController;
8 import com.fedex.connect.customer.controller.biz.IConsignmentController; 9 import com.fedex.connect.customer.controller.biz.IConsignmentController;
9 import com.fedex.connect.customer.data.query.ConsignmentQuery; 10 import com.fedex.connect.customer.data.query.ConsignmentQuery;
...@@ -32,9 +33,12 @@ public class ConsignmentControllerImpl extends AbstractEtController implements I ...@@ -32,9 +33,12 @@ public class ConsignmentControllerImpl extends AbstractEtController implements I
32 @ApiOperation(value = "运单查询") 33 @ApiOperation(value = "运单查询")
33 public ResponseResultVo findConsignment(@RequestBody ConsignmentQuery consignmentQuery) { 34 public ResponseResultVo findConsignment(@RequestBody ConsignmentQuery consignmentQuery) {
34 Long userId = null; 35 Long userId = null;
36 + String uuid = null;
35 try { 37 try {
36 - userId = CurrentUserInfo.getUserId(); 38 + User user = CurrentUserInfo.getUser();
37 - //userId = 0L; 39 + userId = user.getId();
40 + uuid = user.getUserUuid();
41 + userId = 0L;
38 } catch (Exception e) { 42 } catch (Exception e) {
39 logger.error(LogShowModel.showException("Exception", e)); 43 logger.error(LogShowModel.showException("Exception", e));
40 return ResponseResultVo.fail(localeMessageUtil.getMessage(ResponseCode.TOKEN_FORMAT_ERROR.getMsg())); 44 return ResponseResultVo.fail(localeMessageUtil.getMessage(ResponseCode.TOKEN_FORMAT_ERROR.getMsg()));
...@@ -45,6 +49,7 @@ public class ConsignmentControllerImpl extends AbstractEtController implements I ...@@ -45,6 +49,7 @@ public class ConsignmentControllerImpl extends AbstractEtController implements I
45 49
46 ConsignmentQuery query = ConsignmentQuery.dataProcessing(consignmentQuery); 50 ConsignmentQuery query = ConsignmentQuery.dataProcessing(consignmentQuery);
47 query.setUserId(userId); 51 query.setUserId(userId);
52 + query.setUuid(uuid);
48 return consignmentService.findConsignments(query); 53 return consignmentService.findConsignments(query);
49 } 54 }
50 } 55 }
......
...@@ -51,6 +51,17 @@ public class ConsignmentQuery extends PageBase { ...@@ -51,6 +51,17 @@ public class ConsignmentQuery extends PageBase {
51 @JsonIgnore 51 @JsonIgnore
52 private Long userId; 52 private Long userId;
53 53
54 + @JsonIgnore
55 + private String uuid;
56 +
57 + public String getUuid() {
58 + return uuid;
59 + }
60 +
61 + public void setUuid(String uuid) {
62 + this.uuid = uuid;
63 + }
64 +
54 public String getCreateTimeFrom() { 65 public String getCreateTimeFrom() {
55 return createTimeFrom; 66 return createTimeFrom;
56 } 67 }
......
1 package com.fedex.connect.customer.repository.base; 1 package com.fedex.connect.customer.repository.base;
2 2
3 -import com.fedex.connect.customer.repository.dao.AttachmentMapper; 3 +import com.fedex.connect.customer.repository.dao.AttachmentExtMapper;
4 import com.fedex.connect.customer.repository.dao.ConsignmentExtMapper; 4 import com.fedex.connect.customer.repository.dao.ConsignmentExtMapper;
5 import org.springframework.beans.factory.annotation.Autowired; 5 import org.springframework.beans.factory.annotation.Autowired;
6 6
...@@ -8,5 +8,5 @@ public class BaseDao { ...@@ -8,5 +8,5 @@ public class BaseDao {
8 @Autowired 8 @Autowired
9 public ConsignmentExtMapper consignmentExtMapper; 9 public ConsignmentExtMapper consignmentExtMapper;
10 @Autowired 10 @Autowired
11 - public AttachmentMapper attachmentMapper; 11 + public AttachmentExtMapper attachmentExtMapper;
12 } 12 }
......
...@@ -7,6 +7,6 @@ import org.apache.ibatis.annotations.Param; ...@@ -7,6 +7,6 @@ import org.apache.ibatis.annotations.Param;
7 import java.util.List; 7 import java.util.List;
8 8
9 @Mapper 9 @Mapper
10 -public interface AttachmentMapper { 10 +public interface AttachmentExtMapper {
11 List<AttachmentHistoryDto> findHistory(@Param("bizId") Long bizId); 11 List<AttachmentHistoryDto> findHistory(@Param("bizId") Long bizId);
12 } 12 }
......
...@@ -46,39 +46,83 @@ ...@@ -46,39 +46,83 @@
46 </resultMap> 46 </resultMap>
47 47
48 <select id="findConsignments" resultType="com.fedex.connect.common.model.biz.Consignment"> 48 <select id="findConsignments" resultType="com.fedex.connect.common.model.biz.Consignment">
49 - SELECT * 49 + SELECT c.*
50 - FROM T_BIZ_CONSIGNMENT 50 + FROM T_BIZ_USER_CONSIGNMENT_MAPPING m
51 - WHERE CREATE_USER_ID = #{userId} 51 + JOIN T_BIZ_CONSIGNMENT c ON m.consignment_id = c.id
52 + WHERE m.user_id = #{userId}
52 <if test="createTimeFrom != null and createTimeFrom != ''"> 53 <if test="createTimeFrom != null and createTimeFrom != ''">
53 - AND CREATE_TIME &gt;= TO_DATE(#{createTimeFrom}, 'YYYY-MM-DD HH24:MI:SS') 54 + AND c.CREATE_TIME &gt;= TO_DATE(#{createTimeFrom}, 'YYYY-MM-DD HH24:MI:SS')
54 </if> 55 </if>
55 <if test="createTimeTo != null and createTimeTo != ''"> 56 <if test="createTimeTo != null and createTimeTo != ''">
56 - AND CREATE_TIME &lt;= TO_DATE(#{createTimeTo}, 'YYYY-MM-DD HH24:MI:SS') 57 + AND c.CREATE_TIME &lt;= TO_DATE(#{createTimeTo}, 'YYYY-MM-DD HH24:MI:SS')
57 </if> 58 </if>
58 <if test="consignmentCodeList != null and consignmentCodeList.size() != 0"> 59 <if test="consignmentCodeList != null and consignmentCodeList.size() != 0">
59 - AND CONSIGNMENT_CODE IN 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
70 + WHERE c.user_uuid = #{uuid,jdbcType=VARCHAR} <!-- 明确指定 jdbcType -->
71 + <if test="createTimeFrom != null and createTimeFrom != ''">
72 + AND c.CREATE_TIME &gt;= TO_DATE(#{createTimeFrom}, 'YYYY-MM-DD HH24:MI:SS')
73 + </if>
74 + <if test="createTimeTo != null and createTimeTo != ''">
75 + AND c.CREATE_TIME &lt;= TO_DATE(#{createTimeTo}, 'YYYY-MM-DD HH24:MI:SS')
76 + </if>
77 + <if test="consignmentCodeList != null and consignmentCodeList.size() != 0">
78 + AND c.CONSIGNMENT_CODE IN
60 <foreach collection="consignmentCodeList" item="item" separator="," open="(" close=")"> 79 <foreach collection="consignmentCodeList" item="item" separator="," open="(" close=")">
61 #{item} 80 #{item}
62 </foreach> 81 </foreach>
63 </if> 82 </if>
64 </select> 83 </select>
65 84
85 +
66 <select id="findAllCount" resultType="java.lang.Long"> 86 <select id="findAllCount" resultType="java.lang.Long">
67 SELECT COUNT(*) 87 SELECT COUNT(*)
68 - FROM T_BIZ_CONSIGNMENT 88 + FROM (
69 - WHERE CREATE_USER_ID = #{userId} 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}
70 <if test="createTimeFrom != null and createTimeFrom != ''"> 93 <if test="createTimeFrom != null and createTimeFrom != ''">
71 - AND CREATE_TIME &gt;= TO_DATE(#{createTimeFrom}, 'YYYY-MM-DD HH24:MI:SS') 94 + AND c.CREATE_TIME &gt;= TO_DATE(#{createTimeFrom}, 'YYYY-MM-DD HH24:MI:SS')
72 </if> 95 </if>
73 <if test="createTimeTo != null and createTimeTo != ''"> 96 <if test="createTimeTo != null and createTimeTo != ''">
74 - AND CREATE_TIME &lt;= TO_DATE(#{createTimeTo}, 'YYYY-MM-DD HH24:MI:SS') 97 + AND c.CREATE_TIME &lt;= TO_DATE(#{createTimeTo}, 'YYYY-MM-DD HH24:MI:SS')
75 </if> 98 </if>
76 <if test="consignmentCodeList != null and consignmentCodeList.size() != 0"> 99 <if test="consignmentCodeList != null and consignmentCodeList.size() != 0">
77 - AND CONSIGNMENT_CODE IN 100 + AND c.CONSIGNMENT_CODE IN
78 <foreach collection="consignmentCodeList" item="item" separator="," open="(" close=")"> 101 <foreach collection="consignmentCodeList" item="item" separator="," open="(" close=")">
79 #{item} 102 #{item}
80 </foreach> 103 </foreach>
81 </if> 104 </if>
105 +
106 + UNION
107 +
108 + SELECT c.id AS consignment_id
109 + FROM T_BIZ_CONSIGNMENT c
110 + WHERE c.user_uuid = #{uuid,jdbcType=VARCHAR}
111 + <if test="createTimeFrom != null and createTimeFrom != ''">
112 + AND c.CREATE_TIME &gt;= TO_DATE(#{createTimeFrom}, 'YYYY-MM-DD HH24:MI:SS')
113 + </if>
114 + <if test="createTimeTo != null and createTimeTo != ''">
115 + AND c.CREATE_TIME &lt;= TO_DATE(#{createTimeTo}, 'YYYY-MM-DD HH24:MI:SS')
116 + </if>
117 + <if test="consignmentCodeList != null and consignmentCodeList.size() != 0">
118 + AND c.CONSIGNMENT_CODE IN
119 + <foreach collection="consignmentCodeList" item="item" separator="," open="(" close=")">
120 + #{item}
121 + </foreach>
122 + </if>
123 + ) combined_results
82 </select> 124 </select>
83 125
126 +
127 +
84 </mapper> 128 </mapper>
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -8,5 +8,5 @@ import java.util.List; ...@@ -8,5 +8,5 @@ import java.util.List;
8 public interface IConsignmentExtRepository { 8 public interface IConsignmentExtRepository {
9 List<Consignment> findConsignments(ConsignmentQuery query); 9 List<Consignment> findConsignments(ConsignmentQuery query);
10 10
11 - public Long findAllCount(ConsignmentQuery query); 11 + Long findAllCount(ConsignmentQuery query);
12 } 12 }
......
...@@ -8,9 +8,9 @@ import org.springframework.stereotype.Repository; ...@@ -8,9 +8,9 @@ import org.springframework.stereotype.Repository;
8 import java.util.List; 8 import java.util.List;
9 9
10 @Repository 10 @Repository
11 -public class AttachmentRepositoryImpl extends BaseDao implements IAttachmentRepository { 11 +public class AttachmentExtRepositoryImpl extends BaseDao implements IAttachmentRepository {
12 @Override 12 @Override
13 public List<AttachmentHistoryDto> findHistory(Long bizId) { 13 public List<AttachmentHistoryDto> findHistory(Long bizId) {
14 - return attachmentMapper.findHistory(bizId); 14 + return attachmentExtMapper.findHistory(bizId);
15 } 15 }
16 } 16 }
......
...@@ -37,7 +37,8 @@ public class ConsignmentServiceImpl extends AbstractEtService implements IConsig ...@@ -37,7 +37,8 @@ public class ConsignmentServiceImpl extends AbstractEtService implements IConsig
37 List<Consignment> consignments = consignmentExtRepository.findConsignments(query); 37 List<Consignment> consignments = consignmentExtRepository.findConsignments(query);
38 pageResult.setList(consignments); 38 pageResult.setList(consignments);
39 } 39 }
40 - 40 + List<Consignment> consignments = consignmentExtRepository.findConsignments(query);
41 + pageResult.setList(consignments);
41 return ResponseResultVo.succ(pageResult); 42 return ResponseResultVo.succ(pageResult);
42 } 43 }
43 } 44 }
......