zelong.shao

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

package com.fedex.connect.customer.controller.biz;
import com.fedex.connect.common.dependencies.date.vo.ResponseResultVo;
import com.fedex.connect.customer.data.bo.LongBo;
import org.springframework.web.bind.annotation.RequestBody;
public interface IAttachmentController {
ResponseResultVo findHistory(@RequestBody LongBo bo);
}
......
......@@ -4,6 +4,7 @@ import com.fedex.connect.common.dependencies.date.model.LogShowModel;
import com.fedex.connect.common.dependencies.date.vo.ResponseResultVo;
import com.fedex.connect.common.dependencies.enums.ResponseCode;
import com.fedex.connect.common.dependencies.util.CurrentUserInfo;
import com.fedex.connect.common.model.sys.User;
import com.fedex.connect.customer.controller.AbstractEtController;
import com.fedex.connect.customer.controller.biz.IConsignmentController;
import com.fedex.connect.customer.data.query.ConsignmentQuery;
......@@ -32,9 +33,12 @@ public class ConsignmentControllerImpl extends AbstractEtController implements I
@ApiOperation(value = "运单查询")
public ResponseResultVo findConsignment(@RequestBody ConsignmentQuery consignmentQuery) {
Long userId = null;
String uuid = null;
try {
userId = CurrentUserInfo.getUserId();
//userId = 0L;
User user = CurrentUserInfo.getUser();
userId = user.getId();
uuid = user.getUserUuid();
userId = 0L;
} catch (Exception e) {
logger.error(LogShowModel.showException("Exception", e));
return ResponseResultVo.fail(localeMessageUtil.getMessage(ResponseCode.TOKEN_FORMAT_ERROR.getMsg()));
......@@ -45,6 +49,7 @@ public class ConsignmentControllerImpl extends AbstractEtController implements I
ConsignmentQuery query = ConsignmentQuery.dataProcessing(consignmentQuery);
query.setUserId(userId);
query.setUuid(uuid);
return consignmentService.findConsignments(query);
}
}
......
......@@ -51,6 +51,17 @@ public class ConsignmentQuery extends PageBase {
@JsonIgnore
private Long userId;
@JsonIgnore
private String uuid;
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public String getCreateTimeFrom() {
return createTimeFrom;
}
......
package com.fedex.connect.customer.repository.base;
import com.fedex.connect.customer.repository.dao.AttachmentMapper;
import com.fedex.connect.customer.repository.dao.AttachmentExtMapper;
import com.fedex.connect.customer.repository.dao.ConsignmentExtMapper;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -8,5 +8,5 @@ public class BaseDao {
@Autowired
public ConsignmentExtMapper consignmentExtMapper;
@Autowired
public AttachmentMapper attachmentMapper;
public AttachmentExtMapper attachmentExtMapper;
}
......
......@@ -7,6 +7,6 @@ import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface AttachmentMapper {
public interface AttachmentExtMapper {
List<AttachmentHistoryDto> findHistory(@Param("bizId") Long bizId);
}
......
......@@ -46,39 +46,83 @@
</resultMap>
<select id="findConsignments" resultType="com.fedex.connect.common.model.biz.Consignment">
SELECT *
FROM T_BIZ_CONSIGNMENT
WHERE CREATE_USER_ID = #{userId}
SELECT c.*
FROM T_BIZ_USER_CONSIGNMENT_MAPPING m
JOIN T_BIZ_CONSIGNMENT c ON m.consignment_id = c.id
WHERE m.user_id = #{userId}
<if test="createTimeFrom != null and createTimeFrom != ''">
AND CREATE_TIME &gt;= TO_DATE(#{createTimeFrom}, 'YYYY-MM-DD HH24:MI:SS')
AND c.CREATE_TIME &gt;= TO_DATE(#{createTimeFrom}, 'YYYY-MM-DD HH24:MI:SS')
</if>
<if test="createTimeTo != null and createTimeTo != ''">
AND CREATE_TIME &lt;= TO_DATE(#{createTimeTo}, 'YYYY-MM-DD HH24:MI:SS')
AND c.CREATE_TIME &lt;= TO_DATE(#{createTimeTo}, 'YYYY-MM-DD HH24:MI:SS')
</if>
<if test="consignmentCodeList != null and consignmentCodeList.size() != 0">
AND CONSIGNMENT_CODE IN
AND c.CONSIGNMENT_CODE IN
<foreach collection="consignmentCodeList" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
UNION
SELECT c.*
FROM T_BIZ_CONSIGNMENT c
WHERE c.user_uuid = #{uuid,jdbcType=VARCHAR} <!-- 明确指定 jdbcType -->
<if test="createTimeFrom != null and createTimeFrom != ''">
AND c.CREATE_TIME &gt;= TO_DATE(#{createTimeFrom}, 'YYYY-MM-DD HH24:MI:SS')
</if>
<if test="createTimeTo != null and createTimeTo != ''">
AND c.CREATE_TIME &lt;= TO_DATE(#{createTimeTo}, 'YYYY-MM-DD HH24:MI:SS')
</if>
<if test="consignmentCodeList != null and consignmentCodeList.size() != 0">
AND c.CONSIGNMENT_CODE IN
<foreach collection="consignmentCodeList" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</select>
<select id="findAllCount" resultType="java.lang.Long">
SELECT COUNT(*)
FROM T_BIZ_CONSIGNMENT
WHERE CREATE_USER_ID = #{userId}
FROM (
SELECT c.id AS consignment_id
FROM T_BIZ_USER_CONSIGNMENT_MAPPING m
JOIN T_BIZ_CONSIGNMENT c ON m.consignment_id = c.id
WHERE m.user_id = #{userId}
<if test="createTimeFrom != null and createTimeFrom != ''">
AND CREATE_TIME &gt;= TO_DATE(#{createTimeFrom}, 'YYYY-MM-DD HH24:MI:SS')
AND c.CREATE_TIME &gt;= TO_DATE(#{createTimeFrom}, 'YYYY-MM-DD HH24:MI:SS')
</if>
<if test="createTimeTo != null and createTimeTo != ''">
AND CREATE_TIME &lt;= TO_DATE(#{createTimeTo}, 'YYYY-MM-DD HH24:MI:SS')
AND c.CREATE_TIME &lt;= TO_DATE(#{createTimeTo}, 'YYYY-MM-DD HH24:MI:SS')
</if>
<if test="consignmentCodeList != null and consignmentCodeList.size() != 0">
AND CONSIGNMENT_CODE IN
AND c.CONSIGNMENT_CODE IN
<foreach collection="consignmentCodeList" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
UNION
SELECT c.id AS consignment_id
FROM T_BIZ_CONSIGNMENT c
WHERE c.user_uuid = #{uuid,jdbcType=VARCHAR}
<if test="createTimeFrom != null and createTimeFrom != ''">
AND c.CREATE_TIME &gt;= TO_DATE(#{createTimeFrom}, 'YYYY-MM-DD HH24:MI:SS')
</if>
<if test="createTimeTo != null and createTimeTo != ''">
AND c.CREATE_TIME &lt;= TO_DATE(#{createTimeTo}, 'YYYY-MM-DD HH24:MI:SS')
</if>
<if test="consignmentCodeList != null and consignmentCodeList.size() != 0">
AND c.CONSIGNMENT_CODE IN
<foreach collection="consignmentCodeList" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
) combined_results
</select>
</mapper>
\ No newline at end of file
......
......@@ -8,5 +8,5 @@ import java.util.List;
public interface IConsignmentExtRepository {
List<Consignment> findConsignments(ConsignmentQuery query);
public Long findAllCount(ConsignmentQuery query);
Long findAllCount(ConsignmentQuery query);
}
......
......@@ -8,9 +8,9 @@ import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public class AttachmentRepositoryImpl extends BaseDao implements IAttachmentRepository {
public class AttachmentExtRepositoryImpl extends BaseDao implements IAttachmentRepository {
@Override
public List<AttachmentHistoryDto> findHistory(Long bizId) {
return attachmentMapper.findHistory(bizId);
return attachmentExtMapper.findHistory(bizId);
}
}
......
......@@ -37,7 +37,8 @@ public class ConsignmentServiceImpl extends AbstractEtService implements IConsig
List<Consignment> consignments = consignmentExtRepository.findConsignments(query);
pageResult.setList(consignments);
}
List<Consignment> consignments = consignmentExtRepository.findConsignments(query);
pageResult.setList(consignments);
return ResponseResultVo.succ(pageResult);
}
}
......