Authored by caoyan

寄存

... ... @@ -46,4 +46,18 @@ public interface StorageDepositMapper {
* @return
*/
int updateStatus(@Param("id")Integer id, @Param("status")Integer status, @Param("orderStatus")int orderStatus);
int selectShelfCodeCnt(@Param("depotNo") Integer depotNo, @Param("status") Integer status);
List<String> selectShelfCodeList(@Param("storageDepositReq") StorageDepositReq req);
List<StorageDeposit> selectByShelfCodeList(@Param("list") List<String> shelfCodeList);
int batchBindShelfCode(@Param("shelfCode") String shelfCode, @Param("list") List<String> depositCodeList);
List<StorageDeposit> selectByDepositCodeList(@Param("list") List<String> depositCodeList);
int batchUpdateStatusByDepositCodeList(@Param("status") Integer status, @Param("list") List<String> depositCodeList);
StorageDeposit selectByOrderCode(@Param("orderCode") String orderCode);
}
\ No newline at end of file
... ...
... ... @@ -25,6 +25,6 @@ public class StorageDepositPickRsp extends PageRequestBO{
private String shelfCode;
private List<StorageDepositPickRsp> list;
private List<StorageDepositRsp> list;
}
... ...
... ... @@ -33,4 +33,8 @@ public class StorageDepositReq extends PageRequestBO{
private Integer status;
private String shelfCode;
private String depositCodeStr;
}
... ...
... ... @@ -37,10 +37,16 @@
#{skup}, #{status}, #{orderStatus}, #{updateTime}, #{createTime}, #{depositStartTime}, #{depositEndTime}, #{editPid}, #{outType})
</insert>
<select id="bindShelfCode" resultType="java.lang.Integer">
<update id="batchBindShelfCode">
update storage_deposit set shelf_code=#{shelfCode}
where deposit_code=#{depositCode}
</select>
where 1=1
<if test="list != null and list.size()>0">
and deposit_code in
<foreach collection="list" item="depositCode" open="(" close=")" separator=",">
#{depositCode}
</foreach>
</if>
</update>
<select id="selectCountByStatusAndDepotNo" resultType="java.lang.Integer">
select count(1)
... ... @@ -104,4 +110,73 @@
<update id="updateStatus">
UPDATE storage_deposit a SET status = #{status} WHERE id = #{id} AND order_status = #{orderStatus}
</update>
<select id="selectShelfCodeCnt" resultType="java.lang.Integer">
select count(1)
from storage_deposit a
<if test="depotNo != null">
LEFT JOIN seller_order_goods b
ON(b.id=a.skup)
</if>
where 1=1
<if test="status != null">
and a.status = #{status}
</if>
<if test="depotNo != null">
and b.depot_no=#{depotNo}
</if>
</select>
<select id="selectShelfCodeList" resultType="java.lang.String" parameterType="com.yoho.order.model.StorageDepositReq">
select distinct a.shelf_code
from storage_deposit a
<if test="storageDepositReq.depotNo != null">
LEFT JOIN seller_order_goods b
ON(b.id=a.skup)
</if>
where 1=1
<include refid="Query_Order_Sql" />
<if test="storageDepositReq.start!=null and storageDepositReq.size != null">
limit #{storageDepositReq.start},#{storageDepositReq.size}
</if>
</select>
<select id="selectByShelfCodeList" resultMap="BaseResultMap">
select <include refid="Base_Column_List"></include>
from storage_deposit
where 1=1
<if test="list != null and list.size()>0">
and shelf_code in
<foreach collection="list" item="shelfCode" open="(" close=")" separator=",">
#{shelfCode}
</foreach>
</if>
</select>
<select id="selectByDepositCodeList" resultMap="BaseResultMap">
select <include refid="Base_Column_List"></include>
from storage_deposit
where 1=1
<if test="list != null and list.size()>0">
and deposit_code in
<foreach collection="list" item="depositCode" open="(" close=")" separator=",">
#{depositCode}
</foreach>
</if>
</select>
<update id="batchUpdateStatusByDepositCodeList">
update storage_deposit
set status=#{status}
where deposit_code in
<foreach collection="list" item="depositCode" open="(" close=")" separator=",">
#{depositCode}
</foreach>
</update>
<select id="selectByOrderCode" resultMap="BaseResultMap">
select <include refid="Base_Column_List"></include>
from storage_deposit
where order_code=#{orderCode} limit 1
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -2,13 +2,14 @@ package com.yoho.ufo.order.controller;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yoho.order.model.StorageDepositPickRsp;
import com.yoho.order.model.StorageDepositReq;
import com.yoho.order.model.StorageDepositRsp;
import com.yoho.ufo.order.service.IStorageDepositService;
... ... @@ -41,14 +42,43 @@ public class StorageDepositController {
return new ApiResponse.ApiResponseBuilder().code(200).data(result).message("查询成功").build();
}
@RequestMapping(value = "/batchBindShelfCode")
public ApiResponse batchBindShelfCode(StorageDepositReq req) {
LOGGER.info("batchBindShelfCode in. param is {}", req);
if(StringUtils.isEmpty(req.getShelfCode()) || StringUtils.isEmpty(req.getDepositCodeStr())) {
return new ApiResponse.ApiResponseBuilder().data("").code(400).message("参数shelfCode或depositCodeStr不能为空").build();
}
int result = storageDepositService.batchBindShelfCode(req.getShelfCode(), req.getDepositCodeStr());
if(result > 0) {
return new ApiResponse.ApiResponseBuilder().code(200).data(result).message("绑定成功").build();
}else {
return new ApiResponse.ApiResponseBuilder().code(500).data(result).message("绑定失败").build();
}
}
@RequestMapping(value = "/queryDepositPickList")
public ApiResponse queryDepositPickList(StorageDepositReq req) {
LOGGER.info("queryDepositPickList in. param is {}", req);
if(null == req.getStatus()) {
return new ApiResponse.ApiResponseBuilder().data("").code(400).message("参数status不能为空").build();
}
PageResponseBO<StorageDepositRsp> result = storageDepositService.queryDepositListByStatus(req);
PageResponseBO<StorageDepositPickRsp> result = storageDepositService.queryDepositPickListByStatus(req);
return new ApiResponse.ApiResponseBuilder().code(200).data(result).message("查询成功").build();
}
@RequestMapping(value = "/finishPick")
public ApiResponse finishPick(StorageDepositReq req) {
LOGGER.info("finishPick in. param is {}", req);
if(StringUtils.isEmpty(req.getShelfCode()) || StringUtils.isEmpty(req.getDepositCodeStr())) {
return new ApiResponse.ApiResponseBuilder().data("").code(400).message("参数shelfCode或depositCodeStr不能为空").build();
}
int result = storageDepositService.finishPick(req.getShelfCode(), req.getDepositCodeStr());
if(result > 0) {
return new ApiResponse.ApiResponseBuilder().code(200).data(result).message("拣货成功").build();
}else {
return new ApiResponse.ApiResponseBuilder().code(500).data(result).message("拣货失败").build();
}
}
}
... ...
... ... @@ -4,6 +4,7 @@ import java.util.List;
import java.util.Map;
import com.yoho.order.model.StorageDeposit;
import com.yoho.order.model.StorageDepositPickRsp;
import com.yoho.order.model.StorageDepositReq;
import org.apache.ibatis.annotations.Param;
import com.yoho.order.model.StorageDepositRsp;
... ... @@ -23,4 +24,10 @@ public interface IStorageDepositService {
PageResponseBO<StorageDepositRsp> queryDepositListByStatus(StorageDepositReq req);
PageResponseBO<StorageDepositPickRsp> queryDepositPickListByStatus(StorageDepositReq req);
int batchBindShelfCode(String shelfCode, String depositCodeStr);
int finishPick(String shelfCode, String depositCodeStr);
}
... ...
... ... @@ -2067,6 +2067,8 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService, ApplicationCon
queryAberrationNum(resp, buyerOrder.getSellerUid()); // 查询违规记录数
queryProductLimitInfo(resp, sellerGoods.getProductId(), buyerOrder.getSellerUid()); // 独家标识
queryStorageDeposit(resp, buyerOrder.getOrderCode()); //查询寄存信息
resp.setAttributesStr(OrderConfigConstant.getOrderAttributeStr(buyerOrder.getAttributes(), sellerGoods.getRegion()));
... ... @@ -3209,6 +3211,26 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService, ApplicationCon
}
}
}
private void queryStorageDeposit(QcOrderDetailResp resp, String orderCode) { // 查询寄存信息
StorageDeposit deposit = storageDepositMapper.selectByOrderCode(orderCode);
if(null == deposit) {
return;
}
resp.setDepositCode(deposit.getDepositCode());
resp.setShelfCode(deposit.getShelfCode());
if(null != deposit.getOutType()) {
String outTypeStr = "";
if(deposit.getOutType().intValue() == 1) {
outTypeStr = "召回";
}else if(deposit.getOutType().intValue() == 2) {
outTypeStr = "闪购";
}
resp.setStatusStr(resp.getStatusStr() + "(" + outTypeStr + "出库)");
}
}
/**
... ...
package com.yoho.ufo.order.service.impl;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import com.yoho.ufo.util.DateUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.elasticsearch.common.collect.Maps;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.google.common.collect.Lists;
import com.yoho.error.exception.ServiceException;
import com.yoho.order.dal.StorageDepositMapper;
import com.yoho.order.model.StorageDeposit;
import com.yoho.order.model.StorageDepositPickRsp;
import com.yoho.order.model.StorageDepositReq;
import com.yoho.order.model.StorageDepositRsp;
import com.yoho.ufo.order.service.IStorageDepositService;
import com.yoho.ufo.service.model.PageResponseBO;
import com.yoho.ufo.util.DateUtil;
import com.yohobuy.ufo.model.order.constants.StorageDepositStatusEnum;
@Service
public class StorageDepositServiceImpl implements IStorageDepositService{
... ... @@ -82,6 +87,138 @@ public class StorageDepositServiceImpl implements IStorageDepositService{
return result;
}
@Override
public PageResponseBO<StorageDepositPickRsp> queryDepositPickListByStatus(StorageDepositReq req){
req.setDepotNo(null == req.getDepotNo() ? DEPOT_NO_NANJING : req.getDepotNo());
if(StringUtils.isNotEmpty(req.getQueryStr())) {
return queryDepositPickListByQueryStr(req.getQueryStr(), req.getStatus(), req.getDepotNo());
}
int total = storageDepositMapper.selectShelfCodeCnt(req.getDepotNo(), req.getStatus());
if(total == 0) {
return null;
}
List<String> shelfCodeList = storageDepositMapper.selectShelfCodeList(req);
List<StorageDeposit> depositList = storageDepositMapper.selectByShelfCodeList(shelfCodeList);
Map<String, List<StorageDeposit>> depositMap = depositList.stream().collect(Collectors.groupingBy(StorageDeposit::getShelfCode));
List<StorageDepositPickRsp> rspList = buildStorageDepositPickRsp(depositMap);
PageResponseBO<StorageDepositPickRsp> result=new PageResponseBO<>();
result.setPage(req.getPage());
result.setList(rspList);
result.setSize(req.getSize());
result.setTotal(total);
return result;
}
@Override
public int batchBindShelfCode(String shelfCode, String depositCodeStr) {
String[] depositCodeArr = depositCodeStr.split(",");
List<String> depositCodeList = Arrays.asList(depositCodeArr);
//1、校验商品是不是属于当前货位
//2、校验商品状态是不是待寄存
List<StorageDeposit> depositList = storageDepositMapper.selectByDepositCodeList(depositCodeList);
for(StorageDeposit item : depositList) {
if(StringUtils.isNotEmpty(item.getShelfCode()) && item.getShelfCode().equals(shelfCode)) {
throw new ServiceException(400, "寄存码:"+item.getDepositCode()+"已属于当前货位");
}
if(!item.getStatus().equals(StorageDepositStatusEnum.WAITING_IN.getCode())) {
throw new ServiceException(400, "寄存码:"+item.getDepositCode()+"不是待寄存状态");
}
}
//保存绑定
int num = storageDepositMapper.batchBindShelfCode(shelfCode, depositCodeList);
if(num > 0) {
//更改状态为已入库
num = storageDepositMapper.batchUpdateStatusByDepositCodeList(StorageDepositStatusEnum.HAS_IN.getCode(), depositCodeList);
}
return num;
}
@Override
public int finishPick(String shelfCode, String depositCodeStr) {
String[] depositCodeArr = depositCodeStr.split(",");
List<String> depositCodeList = Arrays.asList(depositCodeArr);
//1、校验商品是不是属于当前货位
//2、校验商品状态是不是待拣货
List<StorageDeposit> depositList = storageDepositMapper.selectByDepositCodeList(depositCodeList);
for(StorageDeposit item : depositList) {
if(StringUtils.isNotEmpty(item.getShelfCode()) && !item.getShelfCode().equals(shelfCode)) {
throw new ServiceException(400, "寄存码:"+item.getDepositCode()+"不属于当前货位");
}
if(!item.getStatus().equals(StorageDepositStatusEnum.WAITING_QUERY.getCode())) {
throw new ServiceException(400, "寄存码:"+item.getDepositCode()+"不是待拣货状态");
}
}
//更改状态为已入库
return storageDepositMapper.batchUpdateStatusByDepositCodeList(StorageDepositStatusEnum.WAITING_OUT.getCode(), depositCodeList);
}
private PageResponseBO<StorageDepositPickRsp> queryDepositPickListByQueryStr(String queryStr, Integer status, Integer depotNo){
//先按订单号来查
StorageDepositReq req = new StorageDepositReq();
req.setOrderCode(queryStr);
req.setDepotNo(depotNo);
req.setStatus(status);
req.setSize(100);
List<StorageDeposit> depositList = storageDepositMapper.selectByCondition(req);
if(CollectionUtils.isEmpty(depositList)){//再按寄存码来查
depositList = Lists.newArrayList();
req = new StorageDepositReq();
req.setDepositCode(queryStr);
req.setDepotNo(depotNo);
req.setStatus(status);
req.setSize(100);
List<StorageDeposit> list = storageDepositMapper.selectByCondition(req);
if(CollectionUtils.isNotEmpty(list)){
depositList.addAll(list);
}
}
if(CollectionUtils.isEmpty(depositList)) {
return null;
}
StorageDepositPickRsp rsp = new StorageDepositPickRsp();
rsp.setShelfCode(depositList.get(0).getShelfCode());
StorageDepositRsp depositRsp = new StorageDepositRsp();
depositRsp.setDepositCode(depositList.get(0).getDepositCode());
depositRsp.setOrderCode(depositList.get(0).getOrderCode());
rsp.setList(Lists.newArrayList(depositRsp));
PageResponseBO<StorageDepositPickRsp> result=new PageResponseBO<>();
result.setPage(1);
result.setList(Lists.newArrayList(rsp));
result.setSize(depositList.size());
result.setTotal(depositList.size());
return result;
}
private List<StorageDepositPickRsp> buildStorageDepositPickRsp(Map<String, List<StorageDeposit>> depositMap){
List<StorageDepositPickRsp> rspList = Lists.newArrayList();
for(Entry<String, List<StorageDeposit>> entry : depositMap.entrySet()) {
StorageDepositPickRsp rsp = new StorageDepositPickRsp();
rsp.setShelfCode(entry.getKey());
List<StorageDepositRsp> list = Lists.newArrayList();
for(StorageDeposit item : entry.getValue()) {
StorageDepositRsp depositRsp = new StorageDepositRsp();
depositRsp.setDepositCode(item.getDepositCode());
depositRsp.setOrderCode(item.getOrderCode());
list.add(depositRsp);
}
rsp.setList(list);
rspList.add(rsp);
}
return rspList;
}
private PageResponseBO<StorageDepositRsp> queryDepositListByQueryStrAndStatus(String queryStr, Integer status, Integer depotNo){
//先按订单号来查
StorageDepositReq req = new StorageDepositReq();
... ...