jiazx0107@163.com
2023-06-21 d320b9ae40b3dfc1942ea484c8893ba1404c73ec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package com.ld.igds.phone.service.impl;
 
import com.alibaba.fastjson.JSONObject;
import com.ld.igds.constant.RedisConst;
import com.ld.igds.constant.RespCodeEnum;
import com.ld.igds.inout.InoutConstant;
import com.ld.igds.inout.dto.InoutData;
import com.ld.igds.phone.constant.PhoneConstant;
import com.ld.igds.phone.dto.AuthUser;
import com.ld.igds.phone.dto.DtoInoutHandle;
import com.ld.igds.phone.dto.PhoneResponse;
import com.ld.igds.phone.param.ParamInoutHandle;
import com.ld.igds.phone.param.PhoneRequest;
import com.ld.igds.phone.service.PhoneService;
import com.ld.igds.phone.util.PhoneRespUtil;
import com.ld.igds.phone.util.PhoneUtil;
import com.ld.igds.util.RedisUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.List;
 
/**
 * 入库待值仓列表接口实现
 *
 * @author chen
 */
@Service
public class ServiceImpl5204 implements PhoneService {
 
    @Autowired
    private RedisUtil redisUtil;
    @Autowired
    private PhoneUtil phoneUtil;
 
    @Override
    public String getInterfaceId() {
        return PhoneConstant.API_PHONE_5204;
    }
 
    @SuppressWarnings("unchecked")
    @Override
    public PhoneResponse<Object> execute(PhoneRequest<JSONObject> req, AuthUser authUser)
            throws Exception {
 
        //转化为对象
        ParamInoutHandle param = JSONObject.parseObject(req.getData().toString(), ParamInoutHandle.class);
        //获取检索的车牌
        String plateNum = param.getPlateNum();
 
        //获取缓存中当天正在进行的出入库流水
        String key = RedisConst.buildKey(authUser.getCompanyId(),
                InoutConstant.KEY_INOUT_LIST);
        List<InoutData> list = (List<InoutData>) redisUtil.get(key);
        if (list == null) {
            key = RedisConst.buildKey(authUser.getCompanyId(),
                    InoutConstant.KEY_INOUT_COMPLETE_LIST, authUser.getDeptId());
            list = (List<InoutData>) redisUtil.get(key);
        }
 
        if (list == null) {
            return PhoneRespUtil.error(RespCodeEnum.CODE_2000, "暂无查到待值仓的流水单号!");
        }
 
        List<DtoInoutHandle> dtoInoutHandleList = new ArrayList<>();
        DtoInoutHandle dto;
        //遍历查询入库待值仓的单子
        for (InoutData inoutData : list) {
            if(authUser.getDeptId().equals(inoutData.getDeptId())){
                if (inoutData.getType().equals(InoutConstant.TYPE_IN) &&
                        inoutData.getProgress().equals(InoutConstant.PROGRESS_HANDLE)) {
                    if(StringUtils.isNotEmpty(plateNum) && !inoutData.getPlateNum().contains(plateNum)){
                        break;
                    }
                    dto = new DtoInoutHandle();
                    dto.setId(inoutData.getId());
                    dto.setCompanyId(inoutData.getCompanyId());
                    dto.setIntelCard(inoutData.getIntelCard());
                    dto.setPlateNum(inoutData.getPlateNum());
                    dto.setDepotId(inoutData.getDepotId());
                    dto.setDepotName(phoneUtil.getDepotName(authUser.getCompanyId(),
                            inoutData.getDepotId()));
                  //  dto.setCustomerId(inoutData.getCustomerId()); TODO 
                    dto.setCustomerName(inoutData.getCustomerName());
                    dto.setFoodVariety(inoutData.getFoodVariety());
                    dto.setFoodLevel(inoutData.getFoodLevel());
                    dto.setProgress(inoutData.getProgress());
                    dto.setProgressName(phoneUtil.getProgressName(authUser.getCompanyId(),
                            inoutData.getProgress()));
                    dtoInoutHandleList.add(dto);
                }
            }
        }
        if (dtoInoutHandleList.isEmpty()) {
            return PhoneRespUtil.error(RespCodeEnum.CODE_2000, "暂无查到待值仓的流水单号!");
        }
        return PhoneRespUtil.success(dtoInoutHandleList, req);
    }
}