czt
2025-11-29 46adcbf7494340a495539708210bb39110bdc33b
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
package com.fzzy.sys.manager.inout;
 
import com.fzzy.igds.constant.Constant;
import com.fzzy.igds.domain.InoutConf;
import com.fzzy.igds.domain.InoutSysConf;
import com.fzzy.igds.service.InoutConfService;
import com.fzzy.igds.utils.SystemUtil;
import com.ruoyi.common.core.redis.RedisCache;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
 
/**
 * @Description 出入库业务处理
 * @Author CZT
 * @Date 2025/11/29 11:02
 */
@Slf4j
@Component
public class InoutManager {
 
    @Resource
    private RedisCache redisCache;
    @Resource
    private InoutConfService inoutConfService;
 
    /**
     * 根据用户请求信息,根据当前客户电脑IP,获取出入库称重上次选择的地磅
     *
     * @param httpRequest
     * @return
     */
    public String getInoutWeightByClient(HttpServletRequest httpRequest) {
        String userIp = SystemUtil.getIP(httpRequest);
        log.debug("----------------根据用户IP获取选择-地磅----{}", userIp);
 
        String key = "INOUT:WEIGHT:" + userIp;
        String sort = (String) redisCache.getCacheObject(key);
        if (com.ruoyi.common.utils.StringUtils.isEmpty(sort)) sort = "1";
        return sort;
    }
 
    /**
     * 获取出入库的整个流程信息
     *
     * @param companyId
     * @param deptId
     * @param inoutType
     * @return
     */
    public String getInoutProgressConf(String companyId, String deptId, String inoutType) {
        // 从缓存中获取出入库系统配置信息
        InoutSysConf inoutSysConf = inoutConfService.getCacheInoutSysConf(companyId, deptId);
        String progressConf = null;
        if (inoutSysConf != null) {
            if (Constant.TYPE_IN.equals(inoutType)) {
                progressConf = inoutSysConf.getProgressIn();
            }
            if (Constant.TYPE_OUT.equals(inoutType)) {
                progressConf = inoutSysConf.getProgressOut();
            }
        }
        return progressConf;
    }
 
    /**
     * 获取出入库设备配置信息
     *
     * @param companyId
     * @param deptId
     * @return
     */
    public List<InoutConf> getListInoutConf(String companyId, String deptId) {
        return inoutConfService.getCacheInoutConf(companyId, deptId);
    }
 
    /**
     * 根据配置获取出入库的配置参数
     *
     * @param listInoutConf 配置列表
     * @param sort          方案序号
     * @param type          设备类型
     * @param inoutProgress 出入库流程
     * @return 车牌设备配置,没有则返回NULL
     */
    public InoutConf getInoutConf(List<InoutConf> listInoutConf, String sort, String type, String inoutProgress, int inOrder) {
        if (null == listInoutConf) {
            return new InoutConf(sort);
        }
        if (StringUtils.isEmpty(sort)) sort = "1";
 
        InoutConf result = null;
        for (InoutConf conf : listInoutConf) {
            if (sort.equals(conf.getSort()) && type.equals(conf.getType()) && inoutProgress.equals(conf.getInoutProgress())) {
                if (conf.getInOrder() == inOrder) {
                    result = conf;
                    break;
                }
            }
        }
 
        if (null == result) return new InoutConf(sort);
 
        return result;
    }
 
    public List<InoutConf> getInoutConf(List<InoutConf> listInoutConf, String type) {
        List<InoutConf> result = new ArrayList<>();
        if (null == listInoutConf) return result;
        for (InoutConf conf : listInoutConf) {
            if (type.equals(conf.getType())) {
                result.add(conf);
            }
        }
        return result;
    }
 
    public InoutConf getInoutConf(List<InoutConf> listInoutConf, String sort, String type) {
        if (null == listInoutConf) return new InoutConf(sort);
        if (StringUtils.isEmpty(sort)) sort = "1";
 
        for (InoutConf conf : listInoutConf) {
            if (sort.equals(conf.getSort()) && type.equals(conf.getType())) {
                return conf;
            }
        }
        return new InoutConf(sort);
    }
 
    /**
     * 获取地磅重量编辑标签
     *
     * @param companyId
     * @param deptId
     * @return
     */
    public String getWeightEditTag(String companyId, String deptId) {
        // 从缓存中获取出入库系统配置信息
        InoutSysConf inoutSysConf = inoutConfService.getCacheInoutSysConf(companyId, deptId);
        String weightEditTag = Constant.YN_N;
        if (inoutSysConf != null) {
            weightEditTag = inoutSysConf.getWeightEditTag();
        }
        if (null == weightEditTag) weightEditTag = Constant.YN_N;
 
        return weightEditTag;
    }
}