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小车状态失败");
|
}
|
}
|
}
|