自动化立体仓库 - WMS系统
野心家
2025-03-31 0823adb64bcb21d38ba022888ea8f2a0dc1a8541
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
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.entity.BasCrnp;
import com.zy.asrs.entity.BasDevp;
import com.zy.asrs.entity.WrkMast;
import com.zy.asrs.entity.param.GetShuttleStatusParam;
import com.zy.asrs.service.ApiLogService;
import com.zy.asrs.service.BasCrnpService;
import com.zy.asrs.service.BasDevpService;
import com.zy.asrs.service.impl.BasDevpServiceImpl;
import com.zy.asrs.task.core.ReturnT;
import com.zy.common.utils.HttpHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.util.List;
 
@Component
public class GetEquipmentStatus {
    private static final Logger log = LoggerFactory.getLogger(WorkMastScheduler.class);
    @Value("${wcs.address.URL}")
    private String addrs;
    @Value("${wcs.address.deviceStatus}")
    private String deviceStatus;
    @Autowired
    private BasCrnpService basCrnpService;
    @Autowired
    private ApiLogService apiLogService;
    @Autowired
    private BasDevpService basDevpService;
 
    @Scheduled(cron = "0/3 * * * * ? ")
    private void execute() {
        //获取设备信息
        String response ="";
        try {
            response = new HttpHandler.Builder()
                    // .setHeaders(headParam)
                    .setUri(addrs)
                    .setPath(deviceStatus)
                    .build()
                    .doGet();
            JSONObject jsonObject = JSON.parseObject(response);
            if (jsonObject.get("code").equals(200)) {
                JSONObject data = JSON.parseObject(jsonObject.get("data").toString());
                List<GetShuttleStatusParam> shuttles = JSON.parseArray(data.get("basShuttle").toString(), GetShuttleStatusParam.class);
                for (GetShuttleStatusParam shuttle : shuttles) {
 
 
                    BasCrnp shuttle1 = basCrnpService.selectOne(new EntityWrapper<BasCrnp>().eq("crn_no", shuttle.getShuttleNo()));
                    shuttle1.setCrnSts(shuttle.getStatus());//小车模式
                    shuttle1.setCrnErr(Long.valueOf(shuttle.getErrorCode()));//小车报警
                    shuttle1.setLev1(shuttle.getChargeLine());//小车所在层
                    basCrnpService.updateById(shuttle1);
                }
 
                List<BasDevp> basDevps = JSON.parseArray(data.get("basDevp").toString(), BasDevp.class);
                for (BasDevp basDevp : basDevps) {
                    basDevpService.updateById(basDevp);
                }
            }
        } catch (Exception e) {
            log.error("wms读取wcs小车状态失败");
        }
    }
}