Authored by caoyan

质检优化

@@ -21,4 +21,6 @@ public interface ExpressRecordMapper { @@ -21,4 +21,6 @@ public interface ExpressRecordMapper {
21 21
22 int updateWaybillCode(@Param("orderCode") String orderCode, @Param("uid") Integer uid, 22 int updateWaybillCode(@Param("orderCode") String orderCode, @Param("uid") Integer uid,
23 @Param("expressType") Integer expressType, @Param("waybillCode") String waybillCode); 23 @Param("expressType") Integer expressType, @Param("waybillCode") String waybillCode);
  24 +
  25 + List<ExpressRecord> selectByWaybillCodesAndDepotNo(@Param("waybillCodeList") List<String> waybillCodeList, @Param("depotNo") Integer depotNo);
24 } 26 }
  1 +package com.yoho.order.model;
  2 +
  3 +import java.io.Serializable;
  4 +
  5 +/**
  6 + * @author caoyan
  7 + * @date 2019/7/22
  8 + */
  9 +public class SignForPackageRsp implements Serializable {
  10 +
  11 + private static final long serialVersionUID = 2607922995706119816L;
  12 +
  13 + private String sellerWaybillCode;
  14 +
  15 + private Integer orderNum;
  16 +
  17 + public String getSellerWaybillCode() {
  18 + return sellerWaybillCode;
  19 + }
  20 +
  21 + public void setSellerWaybillCode(String sellerWaybillCode) {
  22 + this.sellerWaybillCode = sellerWaybillCode;
  23 + }
  24 +
  25 + public Integer getOrderNum() {
  26 + return orderNum;
  27 + }
  28 +
  29 + public void setOrderNum(Integer orderNum) {
  30 + this.orderNum = orderNum;
  31 + }
  32 +
  33 + @Override
  34 + public String toString() {
  35 + return "SignForPackageRsp{" +
  36 + "sellerWaybillCode='" + sellerWaybillCode + '\'' +
  37 + ", orderNum='" + orderNum + '\'' +
  38 + '}';
  39 + }
  40 +}
@@ -25,8 +25,7 @@ @@ -25,8 +25,7 @@
25 </if> 25 </if>
26 </select> 26 </select>
27 27
28 - <select id="selectCntByCondition" resultType="java.lang.Integer" parameterType="com.yoho.order.model.BuyerOrderReq">  
29 - select count(1) from abnormal_package where is_del = 0 28 + <sql id="Query_Sql" >
30 <if test="buyerOrderReq.depotNo !=null "> 29 <if test="buyerOrderReq.depotNo !=null ">
31 and depot_no = #{buyerOrderReq.depotNo} 30 and depot_no = #{buyerOrderReq.depotNo}
32 </if> 31 </if>
@@ -39,16 +38,17 @@ @@ -39,16 +38,17 @@
39 <if test="buyerOrderReq.endTime !=null"> 38 <if test="buyerOrderReq.endTime !=null">
40 and create_time &lt;= #{buyerOrderReq.endTime} 39 and create_time &lt;= #{buyerOrderReq.endTime}
41 </if> 40 </if>
  41 + </sql>
  42 +
  43 + <select id="selectCntByCondition" resultType="java.lang.Integer" parameterType="com.yoho.order.model.BuyerOrderReq">
  44 + select count(1) from abnormal_package where 1=1
  45 + <include refid="Query_Sql" />
42 </select> 46 </select>
43 47
44 <select id="selectValidSellerWaybillCodeList" resultType="java.lang.String" parameterType="com.yoho.order.model.BuyerOrderReq"> 48 <select id="selectValidSellerWaybillCodeList" resultType="java.lang.String" parameterType="com.yoho.order.model.BuyerOrderReq">
45 - select seller_waybillCode from abnormal_package where is_del=0  
46 - <if test="buyerOrderReq.depotNo !=null ">  
47 - and depot_no = #{buyerOrderReq.depotNo}  
48 - </if>  
49 - <if test="buyerOrderReq.sellerWaybillCode!=null and buyerOrderReq.sellerWaybillCode != ''">  
50 - and seller_waybillCode = #{buyerOrderReq.sellerWaybillCode}  
51 - </if> 49 + select seller_waybillCode from abnormal_package where 1=1
  50 + <include refid="Query_Sql" />
  51 + order by create_time desc
52 <if test="buyerOrderReq.start!=null and buyerOrderReq.size != null"> 52 <if test="buyerOrderReq.start!=null and buyerOrderReq.size != null">
53 limit #{buyerOrderReq.start},#{buyerOrderReq.size} 53 limit #{buyerOrderReq.start},#{buyerOrderReq.size}
54 </if> 54 </if>
@@ -54,4 +54,15 @@ @@ -54,4 +54,15 @@
54 where order_code=#{orderCode} and uid=#{uid} and express_type=#{expressType} 54 where order_code=#{orderCode} and uid=#{uid} and express_type=#{expressType}
55 </update> 55 </update>
56 56
  57 + <select id="selectByWaybillCodesAndDepotNo" resultMap="BaseResultMap">
  58 + select <include refid="Base_Column_List" />
  59 + from express_record where waybill_code in
  60 + <foreach collection="waybillCodeList" item="waybillCode" open="(" close=")" separator=",">
  61 + #{waybillCode}
  62 + </foreach>
  63 + <if test="depotNo != null">
  64 + and depot_num = #{depotNo}
  65 + </if>
  66 + </select>
  67 +
57 </mapper> 68 </mapper>
@@ -18,6 +18,7 @@ import com.alibaba.fastjson.JSONObject; @@ -18,6 +18,7 @@ import com.alibaba.fastjson.JSONObject;
18 import com.yoho.order.model.BuyerOrderReq; 18 import com.yoho.order.model.BuyerOrderReq;
19 import com.yoho.order.model.ExpressCompany; 19 import com.yoho.order.model.ExpressCompany;
20 import com.yoho.order.model.QualityCheckResp; 20 import com.yoho.order.model.QualityCheckResp;
  21 +import com.yoho.order.model.SignForPackageRsp;
21 import com.yoho.ufo.order.service.IBuyerOrderService; 22 import com.yoho.ufo.order.service.IBuyerOrderService;
22 import com.yoho.ufo.service.model.ApiResponse; 23 import com.yoho.ufo.service.model.ApiResponse;
23 import com.yoho.ufo.service.model.PageResponseBO; 24 import com.yoho.ufo.service.model.PageResponseBO;
@@ -519,7 +520,7 @@ public class BuyerOrderController { @@ -519,7 +520,7 @@ public class BuyerOrderController {
519 if(null == req.getDepotNo() || null == req.getStatus()) { 520 if(null == req.getDepotNo() || null == req.getStatus()) {
520 return new ApiResponse.ApiResponseBuilder().code(500).message("收货地或状态不能为空").build(); 521 return new ApiResponse.ApiResponseBuilder().code(500).message("收货地或状态不能为空").build();
521 } 522 }
522 - PageResponseBO<String> result = buyerOrderService.queryPackage(req.getDepotNo(), req.getSellerWaybillCode(), req.getDate()); 523 + PageResponseBO<String> result = buyerOrderService.queryPackage(req);
523 return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build(); 524 return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build();
524 } 525 }
525 526
@@ -533,6 +534,16 @@ public class BuyerOrderController { @@ -533,6 +534,16 @@ public class BuyerOrderController {
533 return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build(); 534 return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build();
534 } 535 }
535 536
  537 + @RequestMapping(value = "/queryPackageListByStatus")
  538 + public ApiResponse queryPackageListByStatus(BuyerOrderReq req) {
  539 + LOGGER.info("queryPackageCntByStatus in. param is {}", req);
  540 + if(null == req.getDepotNo()) {
  541 + return new ApiResponse.ApiResponseBuilder().code(500).message("收货地不能为空").build();
  542 + }
  543 + PageResponseBO<SignForPackageRsp> result = buyerOrderService.queryPackageListByStatus(req);
  544 + return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build();
  545 + }
  546 +
536 /** 547 /**
537 * 记录异常包裹 548 * 记录异常包裹
538 * @param req 549 * @param req
@@ -110,7 +110,7 @@ public interface IBuyerOrderService { @@ -110,7 +110,7 @@ public interface IBuyerOrderService {
110 110
111 int getPackageCount(Integer depotNo, Integer date); 111 int getPackageCount(Integer depotNo, Integer date);
112 112
113 - PageResponseBO<String> queryPackage(Integer depotNo, String sellerWaybillCode, Integer date); 113 + PageResponseBO<String> queryPackage(BuyerOrderReq req);
114 114
115 // 查询鉴定室列表 115 // 查询鉴定室列表
116 //List<IdentifyCenterResp> queryIdentifyCenter(); 116 //List<IdentifyCenterResp> queryIdentifyCenter();
@@ -142,4 +142,6 @@ public interface IBuyerOrderService { @@ -142,4 +142,6 @@ public interface IBuyerOrderService {
142 * @return 142 * @return
143 */ 143 */
144 public OrderInfoForPackageNum getOrderInfoForPackageNum(String orderCode); 144 public OrderInfoForPackageNum getOrderInfoForPackageNum(String orderCode);
  145 +
  146 + PageResponseBO<SignForPackageRsp> queryPackageListByStatus(BuyerOrderReq req);
145 } 147 }
@@ -2346,12 +2346,9 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService, ApplicationCon @@ -2346,12 +2346,9 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService, ApplicationCon
2346 } 2346 }
2347 2347
2348 @Override 2348 @Override
2349 - public PageResponseBO<String> queryPackage(Integer depotNo, String sellerWaybillCode, Integer date) { 2349 + public PageResponseBO<String> queryPackage(BuyerOrderReq req) {
2350 2350
2351 - BuyerOrderReq req = new BuyerOrderReq();  
2352 - req.setDepotNo(depotNo);  
2353 - req.setSellerWaybillCode(sellerWaybillCode);  
2354 - req.setDate(null == date ? Integer.valueOf(DateUtil.getCurrentDateStr()) : date); 2351 + req.setDate(null == req.getDate() ? Integer.valueOf(DateUtil.getCurrentDateStr()) : req.getDate());
2355 2352
2356 int total = signForPackageMapper.selectTotalByCondition(req); 2353 int total = signForPackageMapper.selectTotalByCondition(req);
2357 if(total == 0) { 2354 if(total == 0) {
@@ -2369,6 +2366,48 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService, ApplicationCon @@ -2369,6 +2366,48 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService, ApplicationCon
2369 } 2366 }
2370 2367
2371 @Override 2368 @Override
  2369 + public PageResponseBO<SignForPackageRsp> queryPackageListByStatus(BuyerOrderReq req) {
  2370 + PageResponseBO<SignForPackageRsp> result=new PageResponseBO<>();
  2371 + if(req.getStatus().intValue() == 0) {//正常包裹
  2372 + return queryNormalPackageList(req);
  2373 + }else if(req.getStatus().intValue() == 1) {//异常包裹
  2374 + return queryAbnormalPackageList(req);
  2375 + }
  2376 + return result;
  2377 + }
  2378 +
  2379 + private PageResponseBO<SignForPackageRsp> queryNormalPackageList(BuyerOrderReq req){
  2380 + PageResponseBO<SignForPackageRsp> result=new PageResponseBO<>();
  2381 + req.setDate(null == req.getDate() ? Integer.valueOf(DateUtil.getCurrentDateStr()) : req.getDate());
  2382 + int total = signForPackageMapper.selectTotalByCondition(req);
  2383 + if(total == 0) {
  2384 + return null;
  2385 + }
  2386 + List<SignForPackage> list = signForPackageMapper.selectByCondition(req);
  2387 + if(CollectionUtils.isEmpty(list)) {
  2388 + return result;
  2389 + }
  2390 +
  2391 + List<String> waybillCodeList = list.stream().map(SignForPackage::getSellerWaybillCode).collect(Collectors.toList());
  2392 + List<ExpressRecord> expressList = expressRecordMapper.selectByWaybillCodesAndDepotNo(waybillCodeList, req.getDepotNo());
  2393 + Map<String, List<ExpressRecord>> expressMap = expressList.stream().collect(Collectors.groupingBy(ExpressRecord::getWaybillCode));
  2394 +
  2395 + List<SignForPackageRsp> rspList = Lists.newArrayList();
  2396 + for(SignForPackage item : list) {
  2397 + SignForPackageRsp rsp = new SignForPackageRsp();
  2398 + rsp.setSellerWaybillCode(item.getSellerWaybillCode());
  2399 + rsp.setOrderNum(null == expressMap.get(item.getSellerWaybillCode()) ? 0 : expressMap.get(item.getSellerWaybillCode()).size());
  2400 + rspList.add(rsp);
  2401 + }
  2402 +
  2403 + result.setList(rspList);
  2404 + result.setPage(req.getPage());
  2405 + result.setSize(req.getSize());
  2406 + result.setTotal(total);
  2407 + return result;
  2408 + }
  2409 +
  2410 + @Override
2372 public Map<String, Integer> queryPackageCntByStatus(Integer depotNo, String sellerWaybillCode, Integer date) { 2411 public Map<String, Integer> queryPackageCntByStatus(Integer depotNo, String sellerWaybillCode, Integer date) {
2373 //正常签收包裹 2412 //正常签收包裹
2374 BuyerOrderReq req = new BuyerOrderReq(); 2413 BuyerOrderReq req = new BuyerOrderReq();
@@ -2380,7 +2419,14 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService, ApplicationCon @@ -2380,7 +2419,14 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService, ApplicationCon
2380 result.put("normalNum", signForPackageMapper.selectTotalByCondition(req)); 2419 result.put("normalNum", signForPackageMapper.selectTotalByCondition(req));
2381 2420
2382 //异常包裹 2421 //异常包裹
2383 - String dateStr = null == date ? DateUtil.getCurrentDateStr() : String.valueOf(date); 2422 + buildQueryDate(req);
  2423 + result.put("abnormalNum", abnormalPackageMapper.selectCntByCondition(req));
  2424 +
  2425 + return result;
  2426 + }
  2427 +
  2428 + private void buildQueryDate(BuyerOrderReq req) {
  2429 + String dateStr = null == req.getDate() ? DateUtil.getCurrentDateStr() : String.valueOf(req.getDate());
2384 String year = dateStr.substring(0, 4); 2430 String year = dateStr.substring(0, 4);
2385 String month = dateStr.substring(4, 6); 2431 String month = dateStr.substring(4, 6);
2386 String day = dateStr.substring(6, 8); 2432 String day = dateStr.substring(6, 8);
@@ -2388,10 +2434,6 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService, ApplicationCon @@ -2388,10 +2434,6 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService, ApplicationCon
2388 String endTimeStr = year + "-" + month + "-" + day + " 23:59:59"; 2434 String endTimeStr = year + "-" + month + "-" + day + " 23:59:59";
2389 req.setStartTime(DateUtil.getTimeSecondsFromStr(startTimeStr, "yyyy-MM-dd HH:mm:ss")); 2435 req.setStartTime(DateUtil.getTimeSecondsFromStr(startTimeStr, "yyyy-MM-dd HH:mm:ss"));
2390 req.setEndTime(DateUtil.getTimeSecondsFromStr(endTimeStr, "yyyy-MM-dd HH:mm:ss")); 2436 req.setEndTime(DateUtil.getTimeSecondsFromStr(endTimeStr, "yyyy-MM-dd HH:mm:ss"));
2391 -  
2392 - result.put("abnormalNum", abnormalPackageMapper.selectCntByCondition(req));  
2393 -  
2394 - return result;  
2395 } 2437 }
2396 2438
2397 private RedisKeyBuilder getRedisKey(String orderCode) { 2439 private RedisKeyBuilder getRedisKey(String orderCode) {
@@ -2932,6 +2974,32 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService, ApplicationCon @@ -2932,6 +2974,32 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService, ApplicationCon
2932 return result; 2974 return result;
2933 } 2975 }
2934 2976
  2977 + private PageResponseBO<SignForPackageRsp> queryAbnormalPackageList(BuyerOrderReq req){
  2978 + buildQueryDate(req);
  2979 + int total = abnormalPackageMapper.selectCntByCondition(req);
  2980 + if(total == 0){
  2981 + return null;
  2982 + }
  2983 +
  2984 + List<String> list = abnormalPackageMapper.selectValidSellerWaybillCodeList(req);
  2985 + List<ExpressRecord> expressList = expressRecordMapper.selectByWaybillCodesAndDepotNo(list, req.getDepotNo());
  2986 + Map<String, List<ExpressRecord>> expressMap = expressList.stream().collect(Collectors.groupingBy(ExpressRecord::getWaybillCode));
  2987 +
  2988 + List<SignForPackageRsp> rspList = Lists.newArrayList();
  2989 + for(String item : list) {
  2990 + SignForPackageRsp rsp = new SignForPackageRsp();
  2991 + rsp.setSellerWaybillCode(item);
  2992 + rsp.setOrderNum(null == expressMap.get(item) ? 0 : expressMap.get(item).size());
  2993 + rspList.add(rsp);
  2994 + }
  2995 + PageResponseBO<SignForPackageRsp> result=new PageResponseBO<>();
  2996 + result.setList(rspList);
  2997 + result.setPage(req.getPage());
  2998 + result.setSize(req.getSize());
  2999 + result.setTotal(total);
  3000 + return result;
  3001 + }
  3002 +
2935 @Override 3003 @Override
2936 public boolean queryIsExistCsCancleOrder(String sellerWaybillCode) { 3004 public boolean queryIsExistCsCancleOrder(String sellerWaybillCode) {
2937 boolean flag = false; 3005 boolean flag = false;