jiazx0107@163.com
2023-06-05 7f5ecaf7dbd07e218fbda575e45d8264a560a1e6
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
package com.ld.igds.inout.manager;
 
import com.ld.igds.constant.Constant;
import com.ld.igds.inout.InoutConstant;
import com.ld.igds.inout.dto.InoutData;
import com.ld.igds.inout.service.InoutService;
import com.ld.igds.io.dto.WeightDto;
import com.ld.igds.m.service.InoutCommonService;
import com.ld.igds.models.DicTrigger;
import com.ld.igds.models.InoutConf;
import com.ld.igds.models.InoutSysConf;
import com.ld.igds.sys.service.DicTriggerService;
import com.ld.igds.util.ContextUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
 
/**
 * @Desc: 出入库公共业务管理模块
 * @author: andy.jia
 * @update-time: 2022/11/26 13:20
 */
@Component
public class InoutCommonManager {
 
    @Resource
    private InoutCommonService inoutCommonService;
    @Resource
    private DicTriggerService dicTriggerService;
    @Resource
    private InoutService inoutService;
 
    /**
     * 获取出入库的整个流程信息
     *
     * @param companyId
     * @param deptId
     * @param inoutType
     * @return
     */
    public String getInoutProgressConf(String companyId, String deptId, String inoutType) {
        // 从缓存中获取出入库系统配置信息
        InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(companyId, deptId);
        String progressConf = null;
        if (inoutSysConf != null) {
            if (InoutConstant.TYPE_IN.equals(inoutType)) {
                progressConf = inoutSysConf.getProgressIn();
            }
            if (InoutConstant.TYPE_OUT.equals(inoutType)) {
                progressConf = inoutSysConf.getProgressOut();
            }
        }
        return progressConf;
    }
 
    /**
     * 获取出入库设备配置信息
     *
     * @param companyId
     * @param deptId
     * @return
     */
    public List<InoutConf> getListInoutConf(String companyId, String deptId) {
        return inoutCommonService.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";
 
        InoutConf result = null;
        for (InoutConf conf : listInoutConf) {
            if (sort.equals(conf.getSort()) && type.equals(conf.getType())) {
                return conf;
            }
        }
 
        if (null == result) return new InoutConf(sort);
 
        return result;
    }
 
 
    /**
     * 根据类型获取字典表下拉框
     *
     * @param parentCode
     * @param companyId
     * @return
     */
    public List<DicTrigger> getDicTrigger(String parentCode, String companyId) {
        return dicTriggerService.getCacheDicByParent(companyId, parentCode);
    }
 
    /**
     * 获取地磅重量编辑标签
     *
     * @param companyId
     * @param deptId
     * @return
     */
    public String getWeightEditTag(String companyId, String deptId) {
        // 从缓存中获取出入库系统配置信息
        InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(companyId, deptId);
        String weightEditTag = Constant.YN_N;
        if (inoutSysConf != null) {
            weightEditTag = inoutSysConf.getWeightEditTag();
        }
        if (null == weightEditTag) weightEditTag = Constant.YN_N;
 
        return weightEditTag;
    }
 
 
    /**
     * 出入库大屏初始化通知后端
     *
     * @param deptId
     */
    public void initInoutScreen(String companyId, String deptId) {
        if (StringUtils.isEmpty(companyId)) return;
        if (StringUtils.isEmpty(deptId)) return;
        inoutService.notifyToScreen(companyId, deptId, null);
    }
 
    public List<InoutData> getListInoutCache(String deptId) {
        return inoutService.getListInoutCache(deptId);
 
    }
 
    public List<InoutData> getCompleteListInoutCache(String deptId) {
        return inoutService.getCompleteListInoutCache(deptId);
    }
}