Authored by caoyan

质检优化

... ... @@ -21,4 +21,6 @@ public interface ExpressRecordMapper {
int updateWaybillCode(@Param("orderCode") String orderCode, @Param("uid") Integer uid,
@Param("expressType") Integer expressType, @Param("waybillCode") String waybillCode);
List<ExpressRecord> selectByWaybillCodesAndDepotNo(@Param("waybillCodeList") List<String> waybillCodeList, @Param("depotNo") Integer depotNo);
}
... ...
package com.yoho.order.model;
import java.io.Serializable;
/**
* @author caoyan
* @date 2019/7/22
*/
public class SignForPackageRsp implements Serializable {
private static final long serialVersionUID = 2607922995706119816L;
private String sellerWaybillCode;
private Integer orderNum;
public String getSellerWaybillCode() {
return sellerWaybillCode;
}
public void setSellerWaybillCode(String sellerWaybillCode) {
this.sellerWaybillCode = sellerWaybillCode;
}
public Integer getOrderNum() {
return orderNum;
}
public void setOrderNum(Integer orderNum) {
this.orderNum = orderNum;
}
@Override
public String toString() {
return "SignForPackageRsp{" +
"sellerWaybillCode='" + sellerWaybillCode + '\'' +
", orderNum='" + orderNum + '\'' +
'}';
}
}
... ...
... ... @@ -25,8 +25,7 @@
</if>
</select>
<select id="selectCntByCondition" resultType="java.lang.Integer" parameterType="com.yoho.order.model.BuyerOrderReq">
select count(1) from abnormal_package where is_del = 0
<sql id="Query_Sql" >
<if test="buyerOrderReq.depotNo !=null ">
and depot_no = #{buyerOrderReq.depotNo}
</if>
... ... @@ -39,16 +38,17 @@
<if test="buyerOrderReq.endTime !=null">
and create_time &lt;= #{buyerOrderReq.endTime}
</if>
</sql>
<select id="selectCntByCondition" resultType="java.lang.Integer" parameterType="com.yoho.order.model.BuyerOrderReq">
select count(1) from abnormal_package where 1=1
<include refid="Query_Sql" />
</select>
<select id="selectValidSellerWaybillCodeList" resultType="java.lang.String" parameterType="com.yoho.order.model.BuyerOrderReq">
select seller_waybillCode from abnormal_package where is_del=0
<if test="buyerOrderReq.depotNo !=null ">
and depot_no = #{buyerOrderReq.depotNo}
</if>
<if test="buyerOrderReq.sellerWaybillCode!=null and buyerOrderReq.sellerWaybillCode != ''">
and seller_waybillCode = #{buyerOrderReq.sellerWaybillCode}
</if>
select seller_waybillCode from abnormal_package where 1=1
<include refid="Query_Sql" />
order by create_time desc
<if test="buyerOrderReq.start!=null and buyerOrderReq.size != null">
limit #{buyerOrderReq.start},#{buyerOrderReq.size}
</if>
... ...
... ... @@ -54,4 +54,15 @@
where order_code=#{orderCode} and uid=#{uid} and express_type=#{expressType}
</update>
<select id="selectByWaybillCodesAndDepotNo" resultMap="BaseResultMap">
select <include refid="Base_Column_List" />
from express_record where waybill_code in
<foreach collection="waybillCodeList" item="waybillCode" open="(" close=")" separator=",">
#{waybillCode}
</foreach>
<if test="depotNo != null">
and depot_num = #{depotNo}
</if>
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -18,6 +18,7 @@ import com.alibaba.fastjson.JSONObject;
import com.yoho.order.model.BuyerOrderReq;
import com.yoho.order.model.ExpressCompany;
import com.yoho.order.model.QualityCheckResp;
import com.yoho.order.model.SignForPackageRsp;
import com.yoho.ufo.order.service.IBuyerOrderService;
import com.yoho.ufo.service.model.ApiResponse;
import com.yoho.ufo.service.model.PageResponseBO;
... ... @@ -519,7 +520,7 @@ public class BuyerOrderController {
if(null == req.getDepotNo() || null == req.getStatus()) {
return new ApiResponse.ApiResponseBuilder().code(500).message("收货地或状态不能为空").build();
}
PageResponseBO<String> result = buyerOrderService.queryPackage(req.getDepotNo(), req.getSellerWaybillCode(), req.getDate());
PageResponseBO<String> result = buyerOrderService.queryPackage(req);
return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build();
}
... ... @@ -533,6 +534,16 @@ public class BuyerOrderController {
return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build();
}
@RequestMapping(value = "/queryPackageListByStatus")
public ApiResponse queryPackageListByStatus(BuyerOrderReq req) {
LOGGER.info("queryPackageCntByStatus in. param is {}", req);
if(null == req.getDepotNo()) {
return new ApiResponse.ApiResponseBuilder().code(500).message("收货地不能为空").build();
}
PageResponseBO<SignForPackageRsp> result = buyerOrderService.queryPackageListByStatus(req);
return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build();
}
/**
* 记录异常包裹
* @param req
... ...
... ... @@ -110,7 +110,7 @@ public interface IBuyerOrderService {
int getPackageCount(Integer depotNo, Integer date);
PageResponseBO<String> queryPackage(Integer depotNo, String sellerWaybillCode, Integer date);
PageResponseBO<String> queryPackage(BuyerOrderReq req);
// 查询鉴定室列表
//List<IdentifyCenterResp> queryIdentifyCenter();
... ... @@ -142,4 +142,6 @@ public interface IBuyerOrderService {
* @return
*/
public OrderInfoForPackageNum getOrderInfoForPackageNum(String orderCode);
PageResponseBO<SignForPackageRsp> queryPackageListByStatus(BuyerOrderReq req);
}
... ...
... ... @@ -2346,12 +2346,9 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService, ApplicationCon
}
@Override
public PageResponseBO<String> queryPackage(Integer depotNo, String sellerWaybillCode, Integer date) {
public PageResponseBO<String> queryPackage(BuyerOrderReq req) {
BuyerOrderReq req = new BuyerOrderReq();
req.setDepotNo(depotNo);
req.setSellerWaybillCode(sellerWaybillCode);
req.setDate(null == date ? Integer.valueOf(DateUtil.getCurrentDateStr()) : date);
req.setDate(null == req.getDate() ? Integer.valueOf(DateUtil.getCurrentDateStr()) : req.getDate());
int total = signForPackageMapper.selectTotalByCondition(req);
if(total == 0) {
... ... @@ -2369,6 +2366,48 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService, ApplicationCon
}
@Override
public PageResponseBO<SignForPackageRsp> queryPackageListByStatus(BuyerOrderReq req) {
PageResponseBO<SignForPackageRsp> result=new PageResponseBO<>();
if(req.getStatus().intValue() == 0) {//正常包裹
return queryNormalPackageList(req);
}else if(req.getStatus().intValue() == 1) {//异常包裹
return queryAbnormalPackageList(req);
}
return result;
}
private PageResponseBO<SignForPackageRsp> queryNormalPackageList(BuyerOrderReq req){
PageResponseBO<SignForPackageRsp> result=new PageResponseBO<>();
req.setDate(null == req.getDate() ? Integer.valueOf(DateUtil.getCurrentDateStr()) : req.getDate());
int total = signForPackageMapper.selectTotalByCondition(req);
if(total == 0) {
return null;
}
List<SignForPackage> list = signForPackageMapper.selectByCondition(req);
if(CollectionUtils.isEmpty(list)) {
return result;
}
List<String> waybillCodeList = list.stream().map(SignForPackage::getSellerWaybillCode).collect(Collectors.toList());
List<ExpressRecord> expressList = expressRecordMapper.selectByWaybillCodesAndDepotNo(waybillCodeList, req.getDepotNo());
Map<String, List<ExpressRecord>> expressMap = expressList.stream().collect(Collectors.groupingBy(ExpressRecord::getWaybillCode));
List<SignForPackageRsp> rspList = Lists.newArrayList();
for(SignForPackage item : list) {
SignForPackageRsp rsp = new SignForPackageRsp();
rsp.setSellerWaybillCode(item.getSellerWaybillCode());
rsp.setOrderNum(null == expressMap.get(item.getSellerWaybillCode()) ? 0 : expressMap.get(item.getSellerWaybillCode()).size());
rspList.add(rsp);
}
result.setList(rspList);
result.setPage(req.getPage());
result.setSize(req.getSize());
result.setTotal(total);
return result;
}
@Override
public Map<String, Integer> queryPackageCntByStatus(Integer depotNo, String sellerWaybillCode, Integer date) {
//正常签收包裹
BuyerOrderReq req = new BuyerOrderReq();
... ... @@ -2380,7 +2419,14 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService, ApplicationCon
result.put("normalNum", signForPackageMapper.selectTotalByCondition(req));
//异常包裹
String dateStr = null == date ? DateUtil.getCurrentDateStr() : String.valueOf(date);
buildQueryDate(req);
result.put("abnormalNum", abnormalPackageMapper.selectCntByCondition(req));
return result;
}
private void buildQueryDate(BuyerOrderReq req) {
String dateStr = null == req.getDate() ? DateUtil.getCurrentDateStr() : String.valueOf(req.getDate());
String year = dateStr.substring(0, 4);
String month = dateStr.substring(4, 6);
String day = dateStr.substring(6, 8);
... ... @@ -2388,10 +2434,6 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService, ApplicationCon
String endTimeStr = year + "-" + month + "-" + day + " 23:59:59";
req.setStartTime(DateUtil.getTimeSecondsFromStr(startTimeStr, "yyyy-MM-dd HH:mm:ss"));
req.setEndTime(DateUtil.getTimeSecondsFromStr(endTimeStr, "yyyy-MM-dd HH:mm:ss"));
result.put("abnormalNum", abnormalPackageMapper.selectCntByCondition(req));
return result;
}
private RedisKeyBuilder getRedisKey(String orderCode) {
... ... @@ -2932,6 +2974,32 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService, ApplicationCon
return result;
}
private PageResponseBO<SignForPackageRsp> queryAbnormalPackageList(BuyerOrderReq req){
buildQueryDate(req);
int total = abnormalPackageMapper.selectCntByCondition(req);
if(total == 0){
return null;
}
List<String> list = abnormalPackageMapper.selectValidSellerWaybillCodeList(req);
List<ExpressRecord> expressList = expressRecordMapper.selectByWaybillCodesAndDepotNo(list, req.getDepotNo());
Map<String, List<ExpressRecord>> expressMap = expressList.stream().collect(Collectors.groupingBy(ExpressRecord::getWaybillCode));
List<SignForPackageRsp> rspList = Lists.newArrayList();
for(String item : list) {
SignForPackageRsp rsp = new SignForPackageRsp();
rsp.setSellerWaybillCode(item);
rsp.setOrderNum(null == expressMap.get(item) ? 0 : expressMap.get(item).size());
rspList.add(rsp);
}
PageResponseBO<SignForPackageRsp> result=new PageResponseBO<>();
result.setList(rspList);
result.setPage(req.getPage());
result.setSize(req.getSize());
result.setTotal(total);
return result;
}
@Override
public boolean queryIsExistCsCancleOrder(String sellerWaybillCode) {
boolean flag = false;
... ...