自动化立体仓库 - WMS系统
zhang
2025-05-23 2e0d98030100f7c201c50a94073f33c22082f24c
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
package com.zy.nc.task.handler;
 
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.core.common.Cools;
import com.zy.asrs.entity.Tag;
import com.zy.asrs.entity.param.MatSyncParam;
import com.zy.asrs.service.OpenService;
import com.zy.asrs.service.TagService;
import com.zy.asrs.task.AbstractHandler;
import com.zy.asrs.task.core.ReturnT;
import com.zy.common.utils.NodeUtils;
import com.zy.nc.entity.*;
import com.zy.nc.service.*;
import com.zy.system.entity.User;
import com.zy.system.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
@Service
@Slf4j
public class BaseDataHandler extends AbstractHandler<String> {
 
    @Autowired
    private NccBdCustomerWmsService nccBdCustomerWmsService;
 
    @Autowired
    private NccCgCgdhdWmsService nccCgCgdhdWmsService;
 
    @Autowired
    private NccCkPddWmsService nccCkPddWmsService;
 
 
    @Autowired
    private NccJcBmWmsService nccJcBmWmsService;
 
    @Autowired
    private NccJcCkhwService nccJcCkhwService;
 
    @Autowired
    private NccJcCkWmsService nccJcCkWmsService;
 
    @Autowired
    private NccJcQilibcBarcodeflowWmsService nccJcQilibcBarcodeflowWmsService;
 
    @Autowired
    private NccJcRyWmsService nccJcRyWmsService;
 
    @Autowired
    private NccJcWlflWmsService nccJcWlflWmsService;
 
    @Autowired
    private NccOrgCorpWmsService nccOrgCorpWmsService;
 
 
    @Autowired
    private VGetBdMaterialService vGetBdMaterialService;
 
    @Autowired
    private OpenService openService;
 
    @Autowired
    private TagService tagService;
 
    @Autowired
    private UserService userService;
 
    @Value("${NYNC.pageSize}")
    private Integer pageSize;
 
    /**
     * @return
     */
    public ReturnT<String> start1() {
        Page<NccBdCustomerWms> page = new Page<>(1, pageSize);
        Page<NccBdCustomerWms> wmsFlag = nccBdCustomerWmsService.selectPage(page, new EntityWrapper<NccBdCustomerWms>().ne("wms_flag", 1));
        for (NccBdCustomerWms nccBdCustomerWms : wmsFlag.getRecords()) {
            //TODO
            log.info("NccBdCustomerWms数据:{}", JSONObject.toJSON(nccBdCustomerWms));
        }
        return SUCCESS;
    }
 
    /**
     * @return
     */
    public ReturnT<String> start2() {
        Page<NccCgCgdhdWms> page = new Page<>(1, pageSize);
        Page<NccCgCgdhdWms> wmsFlag = nccCgCgdhdWmsService.selectPage(page, new EntityWrapper<NccCgCgdhdWms>().ne("wms_flag", 1));
        for (NccCgCgdhdWms nccCgCgdhdWms : wmsFlag.getRecords()) {
            log.info("NccCgCgdhdWms数据:{}", JSONObject.toJSON(nccCgCgdhdWms));
        }
        return SUCCESS;
    }
 
    public ReturnT<String> start3() {
        Page<NccCkPddWms> page = new Page<>(1, pageSize);
        Page<NccCkPddWms> wmsFlag = nccCkPddWmsService.selectPage(page, new EntityWrapper<NccCkPddWms>().ne("wms_flag", 1));
        for (NccCkPddWms nccCkPddWms : wmsFlag.getRecords()) {
            log.info("NccCkPddWms数据:{}", JSONObject.toJSON(nccCkPddWms));
        }
        return SUCCESS;
    }
 
    public ReturnT<String> start4() {
        Page<NccJcBmWms> page = new Page<>(1, pageSize);
        Page<NccJcBmWms> wmsFlag = nccJcBmWmsService.selectPage(page, new EntityWrapper<NccJcBmWms>().ne("wms_flag", 1));
        for (NccJcBmWms nccCkPddWms : wmsFlag.getRecords()) {
            log.info("NccJcBmWms数据:{}", JSONObject.toJSON(nccCkPddWms));
        }
        return SUCCESS;
    }
 
 
    public ReturnT<String> start5() {
        Page<NccJcCkhw> page = new Page<>(1, pageSize);
        Page<NccJcCkhw> wmsFlag = nccJcCkhwService.selectPage(page, new EntityWrapper<NccJcCkhw>().ne("wms_flag", 1));
        for (NccJcCkhw nccJcCkhw : wmsFlag.getRecords()) {
            log.info("NccJcCkhw数据:{}", JSONObject.toJSON(nccJcCkhw));
        }
        return SUCCESS;
    }
 
    public ReturnT<String> start6() {
        Page<NccJcCkWms> page = new Page<>(1, pageSize);
        Page<NccJcCkWms> wmsFlag = nccJcCkWmsService.selectPage(page, new EntityWrapper<NccJcCkWms>().ne("wms_flag", 1));
        for (NccJcCkWms nccJcCkWms : wmsFlag.getRecords()) {
            log.info("NccJcCkWms数据:{}", JSONObject.toJSON(nccJcCkWms));
        }
        return SUCCESS;
    }
 
    public ReturnT<String> start7() {
        Page<NccJcQilibcBarcodeflowWms> page = new Page<>(1, pageSize);
        Page<NccJcQilibcBarcodeflowWms> wmsFlag = nccJcQilibcBarcodeflowWmsService.selectPage(page, new EntityWrapper<NccJcQilibcBarcodeflowWms>().ne("wms_flag", 1));
        for (NccJcQilibcBarcodeflowWms nccJcQilibcBarcodeflowWms : wmsFlag.getRecords()) {
            log.info("NccJcQilibcBarcodeflowWms数据:{}", JSONObject.toJSON(nccJcQilibcBarcodeflowWms));
        }
        return SUCCESS;
    }
 
    public ReturnT<String> start8() {
        Page<NccJcRyWms> page = new Page<>(1, pageSize);
        Page<NccJcRyWms> wmsFlag = nccJcRyWmsService.selectPage(page, new EntityWrapper<NccJcRyWms>().ne("wms_flag", 1).eq("sszzmc", "浙江福莱新材料股份有限公司烟台分公司"));
        for (NccJcRyWms nccJcRyWms : wmsFlag.getRecords()) {
            User user = userService.selectOne(new EntityWrapper<User>().eq("username", nccJcRyWms.getRybm()));
            if (user == null) {
                user = new User();
                user.setUsername(nccJcRyWms.getRybm());
                user.setNickname(nccJcRyWms.getRymc());
                user.setRoleId(12L);
                user.setStatus(1);
                user.setCreateTime(new Date());
                userService.insert(user);
            }else {
                user.setUsername(nccJcRyWms.getRybm());
                user.setNickname(nccJcRyWms.getRymc());
                user.setRoleId(12L);
                user.setStatus(1);
                userService.updateById(user);
            }
            nccJcRyWms.setWmsFlag(1);
            nccJcRyWmsService.updateById(nccJcRyWms);
            log.info("NccJcRyWms数据:{}", JSONObject.toJSON(nccJcRyWms));
        }
 
        return SUCCESS;
    }
 
    public ReturnT<String> start9() {
        Page<NccJcWlflWms> page = new Page<>(1, pageSize);
        Page<NccJcWlflWms> wmsFlag = nccJcWlflWmsService.selectPage(page, new EntityWrapper<NccJcWlflWms>().ne("wms_flag", 1));
        Tag top = tagService.getTop();
        for (NccJcWlflWms nccJcWlflWms : wmsFlag.getRecords()) {
            if (!Cools.isEmpty(nccJcWlflWms.getSjflbm())) {
                Tag priTag = tagService.selectOne(new EntityWrapper<Tag>().eq("uuid", nccJcWlflWms.getSjflbm()));
                if (priTag == null) {
                    continue;
                } else {
                    Tag tag = new Tag();
                    tag.setUuid(nccJcWlflWms.getCode());
                    tag.setName(nccJcWlflWms.getName());
                    tag.setParentId(priTag.getId());
                    tag.setParentName(priTag.getName());
                    tag.setType(0);
                    tag.setLevel(priTag.getLevel() + 1);
                    tag.setStatus(1);
                    tag.setCreateTime(new Date());
                    tag.setPath(priTag.getPath());
                    NodeUtils nodeUtils = new NodeUtils();
                    nodeUtils.executePath(priTag.getId());
                    tag.setPath(nodeUtils.path.toString());
                    tag.setPathName(nodeUtils.pathName.toString());
                    tagService.insert(tag);
                    nccJcWlflWms.setWmsFlag(1);
                    nccJcWlflWmsService.updateById(nccJcWlflWms);
                }
            } else {
                Tag tag = new Tag();
                tag.setUuid(nccJcWlflWms.getCode());
                tag.setName(nccJcWlflWms.getName());
                tag.setStatus(1);
                tag.setCreateTime(new Date());
                tag.setType(0);
                tag.setLevel(2);
                tag.setParentId(top.getId());
                tag.setParentName(top.getName());
                tag.setPath(top.getPath());
                NodeUtils nodeUtils = new NodeUtils();
                nodeUtils.executePath(top.getId());
                tag.setPath(nodeUtils.path.toString());
                tag.setPathName(nodeUtils.pathName.toString());
                tagService.insert(tag);
                nccJcWlflWms.setWmsFlag(1);
                nccJcWlflWmsService.updateById(nccJcWlflWms);
            }
            log.info("NccJcWlflWms数据:{}", JSONObject.toJSON(nccJcWlflWms));
        }
        return SUCCESS;
    }
 
    public ReturnT<String> start10() {
        Page<NccOrgCorpWms> page = new Page<>(1, pageSize);
        Page<NccOrgCorpWms> wmsFlag = nccOrgCorpWmsService.selectPage(page, new EntityWrapper<NccOrgCorpWms>().ne("wms_flag", 1));
        for (NccOrgCorpWms nccOrgCorpWms : wmsFlag.getRecords()) {
 
            log.info("NccOrgCorpWms数据:{}", JSONObject.toJSON(nccOrgCorpWms));
        }
        return SUCCESS;
    }
 
 
    public ReturnT<String> start13() {
        Page<VGetBdMaterial> page = new Page<>(1, pageSize);
        Page<VGetBdMaterial> wmsFlag = vGetBdMaterialService.selectPage(page, new EntityWrapper<VGetBdMaterial>().ne("wms_flag", 1));
        MatSyncParam param = new MatSyncParam();
        List<MatSyncParam.MatParam> matDetails = new ArrayList<>();
        MatSyncParam.MatParam matParam;
        for (VGetBdMaterial vGetBdMaterial : wmsFlag.getRecords()) {
            Tag priTag = tagService.selectOne(new EntityWrapper<Tag>().eq("uuid", vGetBdMaterial.get存货分类编码()));
            if (priTag == null) {
                continue;
            }
            matParam = new MatSyncParam.MatParam();
            matParam.setMatnr(vGetBdMaterial.get物料编码());
            matParam.setMaktx(vGetBdMaterial.get物料名称());
            matParam.setSpecs(vGetBdMaterial.get规格());
            matParam.setModel(vGetBdMaterial.get型号());
            matParam.setUnit(vGetBdMaterial.get主单位());
            matParam.setMemo(vGetBdMaterial.get备注());
            matParam.setGroupCode(vGetBdMaterial.get存货分类编码());
            matParam.setGroupName(vGetBdMaterial.get存货分类名称());
            matDetails.add(matParam);
        }
        if (!matDetails.isEmpty()) {
            param.setMatDetails(matDetails);
            openService.syncMat(param);
            for (VGetBdMaterial vGetBdMaterial : wmsFlag.getRecords()) {
                vGetBdMaterial.setWmsFlag(1);
            }
            vGetBdMaterialService.updateBatchById(wmsFlag.getRecords());
        }
        return SUCCESS;
    }
 
}