自动化立体仓库 - WCS系统
野心家
2025-03-13 7112338864ef558d54db0329d75b903322787f6c
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
package com.zy.asrs.task;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
import com.zy.asrs.controller.CrnController;
import com.zy.asrs.controller.SiteController;
import com.zy.asrs.entity.TaskWrk;
import com.zy.asrs.mapper.BasCrnErrorMapper;
import com.zy.asrs.mapper.StaDescMapper;
import com.zy.asrs.mapper.TaskWrkMapper;
import com.zy.asrs.mapper.WrkMastMapper;
import com.zy.asrs.service.*;
import com.zy.asrs.service.impl.OpenServiceImpl;
import com.zy.common.service.CommonService;
import com.zy.common.utils.HttpHandler;
import com.zy.core.properties.SlaveProperties;
import com.zy.system.service.ConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
 
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
 
@Slf4j
@Component
public class autoReportStartHandler {
 
    @Autowired
    private SlaveProperties slaveProperties;
    @Autowired
    private WrkMastMapper wrkMastMapper;
    @Autowired
    private LocMastService locMastService;
    @Autowired
    private BasCrnpService basCrnpService;
    @Autowired
    private BasDevpService basDevpService;
    @Autowired
    private BasErrLogService basErrLogService;
    @Autowired
    private BasCrnErrorMapper basCrnErrorMapper;
    @Autowired
    private TaskWrkMapper taskWrkMapper;
    @Autowired
    private TaskWrkService taskWrkService;
    @Autowired
    private ConfigService configService;
    @Autowired
    private StaDescMapper staDescMapper;
    @Autowired
    private CommandInfoService commandInfoService;
 
    @Autowired
    private OpenServiceImpl openServiceImpl;
    @Autowired
    private StaDescService staDescService;
 
    @Autowired
    private ApiLogService apiLogService;
    @Autowired
    private CommonService commonService;
 
    @Value("${wms.url}")
    private String wmsUrl;
    @Value("${wms.inboundTaskApplyPath}")
    private String inboundTaskApplyPath;
    @Value("${wms.TaskExecCallback}")
    private String TaskExecCallback;
    @Value("${wms.taskStatusFeedbackPath}")
    private String taskStatusFeedbackPath;
    @Autowired
    private CrnController crnController;
    @Autowired
    private SiteController siteController;
 
    /**
     * 自动上报开始
     * @throws IOException
     */
    @Scheduled(cron = "0/3 * * * * ? ")
    public synchronized void execute() throws IOException {
        List<TaskWrk> taskWrks=taskWrkService.selectList(new EntityWrapper<TaskWrk>().eq("status",1).in("wrk_sts",12,13,2,3,4));
        if(taskWrks.size()>0){
            for(TaskWrk taskWrk:taskWrks){
                if(Cools.isEmpty(taskWrk.getMarkStart())||taskWrk.getMarkStart()==0){
                    HashMap<String, Object> hashMap = new HashMap<>();
                    hashMap.put("TaskNo",taskWrk.getTaskNo());
                    String response = "";
                    Boolean bool = false;
                    try {
                        //开始上报,出库任务开始时,WCS回调WMS
                        response = new HttpHandler.Builder()
                                .setUri(wmsUrl)
                                .setPath(taskStatusFeedbackPath)
                                .setJson(JSON.toJSONString(hashMap))
                                .build()
                                .doPost();
                        JSONObject jsonObject = JSON.parseObject(response);
 
                        if(jsonObject.get("ReturnStatus").equals(0)){
                            bool = true;
                            taskWrk.setMarkStart(1);
                            taskWrk.setStatus(2);
                            taskWrkMapper.updateById(taskWrk);
                        }
 
                    } catch (Exception e) {
                    }finally {
                        apiLogService.save("wcs开始任务上报wms"
                                , wmsUrl + TaskExecCallback
                                , null
                                , "127.0.0.1"
                                , JSON.toJSONString(hashMap)
                                , response
                                , bool
                        );
                    }
                }
            }
        }
 
    }
 
}