package com.zy.asrs.controller;
|
|
import com.core.common.R;
|
import com.zy.asrs.domain.param.AskStaParam;
|
import com.zy.asrs.domain.param.TaskReportParam;
|
import com.zy.asrs.service.LocMastService;
|
import com.zy.asrs.service.impl.CtuMainServiceImpl;
|
import com.zy.common.web.BaseController;
|
import com.zy.core.cache.SlaveConnection;
|
import com.zy.core.enums.SlaveType;
|
import com.zy.core.model.protocol.StaProtocol;
|
import com.zy.core.thread.SiemensDevpThread;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import java.util.ArrayList;
|
|
/**
|
* Created by vincent on 2022/4/8
|
*/
|
@Slf4j
|
@RestController
|
@RequestMapping("open/asrs")
|
public class OpenController extends BaseController {
|
|
|
@Autowired
|
private LocMastService locMastService;
|
|
|
@Autowired
|
private CtuMainServiceImpl ctuMainService;
|
|
|
@Value("${ctu.url}")
|
private String ctuUrl;
|
|
@Value("${ctu.locSync}")
|
private String locSync;
|
|
private static final boolean auth = true;
|
|
public static final ArrayList<String> APP_KEY_LIST = new ArrayList<String>() {{
|
add("ea1f0459efc02a79f046f982767939ae");
|
}};
|
|
|
private String getLocSts(Long sts) {
|
//15 IDLE 空闲
|
//16 STOCK 在库
|
//17 PAKIN 入库预约
|
//18 PAKOUT 出库预约
|
//19 DISABLED 禁用
|
switch (sts.intValue()) {
|
case 15:
|
return "O";
|
case 16:
|
return "F";
|
case 17:
|
return "S";
|
case 18:
|
return "R";
|
case 19:
|
return "X";
|
default:
|
return "W";
|
}
|
}
|
|
/**
|
* 任务状态上报接收
|
*/
|
@RequestMapping("/task/sync/v1")
|
public R taskSync(@RequestBody TaskReportParam param) {
|
if (param == null || param.getSeqNum() == null || param.getQrCode() == null) {
|
return R.error("参数为空");
|
}
|
if (param.getQrCode().equals("00001547") && param.getTaskSts() == 10) {
|
log.info("1001任务状态上报接收:{}", param);
|
ctuMainService.setFlag1001(true);
|
} else if (param.getQrCode().equals("00001612") && param.getTaskSts() == 5) {
|
log.info("1007任务状态上报接收:{}", param);
|
ctuMainService.setFlag1007(true);
|
}
|
return R.ok();
|
}
|
|
/**
|
* 任务状态上报接收
|
*/
|
@RequestMapping("/sta/ask/v1")
|
public R taskSync(@RequestBody AskStaParam param) {
|
if (param == null || param.getAskSta() == null || param.getAskType() == null) {
|
return R.error("参数为空");
|
}
|
SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, 1);
|
StaProtocol staProtocol = devpThread.getStation().get(param.getAskSta());
|
if (staProtocol != null) {
|
if (param.getAskType() == 1) {
|
if (staProtocol.isLoading() && staProtocol.isAutoing() && staProtocol.isOutEnable()) {
|
return R.ok();
|
}
|
} else if (param.getAskType() == 2) {
|
if (!staProtocol.isLoading() && staProtocol.isAutoing() && staProtocol.isInEnable()) {
|
return R.ok();
|
}
|
}
|
}
|
return R.error("状态不对");
|
}
|
|
|
}
|