add: 添加仙工AGV,流量限制界面;实现流量限制国际化
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
package org.nl.acs.agv;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.one_manipulator.box_storage_manipulator.BoxStorageManipulatorDeviceDriver;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.instruction.domain.Instruction;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author zhangjiangwei
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class AgvWaitUtil {
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
AcsToWmsService acsToWmsService;
|
||||
|
||||
@Autowired
|
||||
InstructionService instructionService;
|
||||
|
||||
@Autowired
|
||||
private DeviceAppService deviceAppService;
|
||||
|
||||
//取货前等待
|
||||
public JSONObject waitInGet(String startDeviceCode, Instruction inst) {
|
||||
log.info("仙工AGV请求取货,设备号 - {}", startDeviceCode);
|
||||
|
||||
/*JSONObject responseBody = acsToWmsService.queryStationState(inst);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(responseBody) && "200".equals(responseBody.getString("status"))) {
|
||||
JSONArray data = JSON.parseArray(responseBody.getString("data"));
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
JSONObject datum = data.getJSONObject(i);
|
||||
if (startDeviceCode.equals(datum.getString("Station_Code")) && !datum.getBooleanValue("IsHasGoods")) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new BadRequestException("请求失败!");*/
|
||||
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("status", 200);
|
||||
map.put("message", "允许取货!");
|
||||
log.info("允许仙工AGV取货,设备号 - {}", startDeviceCode);
|
||||
return map;
|
||||
}
|
||||
|
||||
//取货完成等待
|
||||
public JSONObject waitOutGet(String startDeviceCode, Instruction inst) {
|
||||
log.info("仙工AGV取货完成后请求离开,设备号 - {}", startDeviceCode);
|
||||
|
||||
inst.setExecute_status("2");
|
||||
instructionService.update(inst);
|
||||
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("status", 200);
|
||||
map.put("message", "允许离开!");
|
||||
log.info("允许仙工AGV取货完成后请求离开,设备号 - {}", startDeviceCode);
|
||||
return map;
|
||||
}
|
||||
|
||||
//放货前等待
|
||||
public JSONObject waitInPut(String endDeviceCode, Instruction inst) {
|
||||
log.info("仙工AGV请求放货,设备号 - {}", endDeviceCode);
|
||||
|
||||
Device doordevice = deviceAppService.findDeviceByCode(endDeviceCode);
|
||||
BoxStorageManipulatorDeviceDriver boxStorageManipulatorDeviceDriver;
|
||||
if(doordevice.getDeviceDriver() instanceof BoxStorageManipulatorDeviceDriver){
|
||||
boxStorageManipulatorDeviceDriver = (BoxStorageManipulatorDeviceDriver) doordevice.getDeviceDriver();
|
||||
if(boxStorageManipulatorDeviceDriver.getMode() != 2 && boxStorageManipulatorDeviceDriver.getMove() != 0){
|
||||
throw new BadRequestException("请求失败!");
|
||||
}
|
||||
}
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("status", 200);
|
||||
map.put("message", "允许放货!");
|
||||
log.info("允许仙工AGV放货,设备号 - {}", endDeviceCode);
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
//放货完成等待
|
||||
public JSONObject waitOutPut(String endDeviceCode, Instruction inst) {
|
||||
log.info("仙工AGV放货完成后请求离开,设备号 - {}", endDeviceCode);
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("status", 200);
|
||||
map.put("message", "允许离开!");
|
||||
log.info("允许仙工AGV放货完成后请求离开,设备号 - {}", endDeviceCode);
|
||||
return map;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package org.nl.acs.agv;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.AcsConfig;
|
||||
import org.nl.acs.instruction.domain.Instruction;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 定时查询AGV状态
|
||||
*/
|
||||
@Slf4j
|
||||
@Component("queryAGVStatus")
|
||||
public class QueryAGVStatus {
|
||||
|
||||
public void run() {
|
||||
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
|
||||
ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class);
|
||||
List<Instruction> allInstFromCache = instructionService.findAllInstFromCache();
|
||||
if(CollUtil.isEmpty(allInstFromCache) || allInstFromCache.size() < 1){
|
||||
return;
|
||||
}
|
||||
for (Instruction instruction : allInstFromCache) {
|
||||
if ("4".equals(instruction.getInstruction_type())) {
|
||||
String agvurl =paramService.findByCode(AcsConfig.AGVURL).getValue();
|
||||
String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
|
||||
JSONObject param = new JSONObject();
|
||||
agvurl = agvurl + ":" + agvport + "/" + instruction.getInstruction_code();
|
||||
log.info("根据运单号查询运单状态的请求:{}", agvurl);
|
||||
HttpResponse result = HttpRequest.get(agvurl)
|
||||
.timeout(20000)//超时,毫秒
|
||||
.execute();
|
||||
log.info("根据运单号查询运单状态的请求反馈:{}", result);
|
||||
String body = result.body();
|
||||
JSONObject json = JSONObject.parseObject(body);
|
||||
if(result.getStatus() == 200 && json.getString("id").equals(instruction.getInstruction_code())){
|
||||
// 已创建=CREATED,
|
||||
// 待分配=TOBEDISPATCHED,
|
||||
// 正在执行=RUNNING,
|
||||
// 完成=FINISHED,
|
||||
// 失败=FAILED(主动失败),
|
||||
// 终止=STOPPED(被人为终止),
|
||||
// 无法执行=Error(参数错误),
|
||||
// 等待=WAITING
|
||||
//执行中
|
||||
String state = json.getString("state");
|
||||
if ("RUNNING".equals(state) || "CREATED".equals(state) || "TOBEDISPATCHED".equals(state) || "WAITING".equals(state)) {
|
||||
instruction.setInstruction_status("1");
|
||||
instructionService.update(instruction);
|
||||
} else if ("FINISHED".equals(state)) {
|
||||
instruction.setInstruction_status("2");
|
||||
try {
|
||||
instructionService.finish(instruction);
|
||||
} catch (Exception e) {
|
||||
log.error("执行完成,但无法更新状态,可能由于参数错误导致的异常");
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if ("STOPPED".equals(state) || "FAILED".equals(state) || "Error".equals(state)) {
|
||||
instruction.setInstruction_status("1");
|
||||
instructionService.update(instruction);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,30 @@
|
||||
package org.nl.acs.agv.rest;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.acs.agv.server.XianGongAgvService;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Configurable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
/**
|
||||
* @author 20220102CG\noblelift
|
||||
*/
|
||||
|
||||
@Controller
|
||||
public class XianGongAgvController {
|
||||
|
||||
@Autowired
|
||||
private XianGongAgvService xianGongAgentService;
|
||||
|
||||
@PostMapping("/waitPointRequest")
|
||||
@Log("仙工AGV请求取放货")
|
||||
public ResponseEntity<JSONObject> xgAGVWaitPointRequest(@RequestBody JSONObject requestParam) {
|
||||
return new ResponseEntity<>(xianGongAgentService.xgAGVWaitPointRequest(requestParam), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -102,4 +102,21 @@ public interface XianGongAgvService {
|
||||
*/
|
||||
public JSONObject createOrederData(Instruction inst, String type);
|
||||
|
||||
/**
|
||||
* 请求取货放货
|
||||
* @param requestParam
|
||||
* @return
|
||||
*/
|
||||
JSONObject xgAGVWaitPointRequest(JSONObject requestParam);
|
||||
|
||||
/**
|
||||
* 运单号查询运单状态
|
||||
*/
|
||||
public HttpResponse selectOrderByInstCode(String instCode);
|
||||
|
||||
|
||||
/**
|
||||
* 查询场景中指定机器人信息
|
||||
*/
|
||||
HttpResponse getRobotInfo(String robotCode);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.AcsConfig;
|
||||
import org.nl.acs.agv.AgvUtil;
|
||||
import org.nl.acs.agv.AgvWaitUtil;
|
||||
import org.nl.acs.agv.server.XianGongAgvService;
|
||||
import org.nl.acs.agv.server.dto.AgvDto;
|
||||
import org.nl.acs.angle.domain.AcsPointAngle;
|
||||
@@ -19,6 +20,7 @@ import org.nl.acs.common.base.CommonFinalParam;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.instruction.domain.Instruction;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.log.LokiLog;
|
||||
import org.nl.acs.log.LokiLogType;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
@@ -50,6 +52,11 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
|
||||
@Autowired
|
||||
private IAcsPointAngleService acsPointAngleService;
|
||||
|
||||
@Autowired
|
||||
private InstructionService instructionService;
|
||||
|
||||
@Autowired
|
||||
private AgvWaitUtil agvWaitUtil;
|
||||
|
||||
Map<String, AgvDto> AGVDeviceStatus = new HashMap();
|
||||
|
||||
@@ -286,23 +293,47 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
|
||||
}
|
||||
}
|
||||
|
||||
public com.alibaba.fastjson.JSONArray createBlocksData(Instruction inst) {
|
||||
/**
|
||||
* 下发运单
|
||||
* @param inst
|
||||
* @return
|
||||
*/
|
||||
public JSONArray createBlocksData(Instruction inst) {
|
||||
JSONArray ja = new JSONArray();
|
||||
Device startDevice = deviceAppService.findDeviceByCode(inst.getStart_device_code());
|
||||
sendStartDeviceOrder(ja,inst.getStart_device_code(), inst.getStart_point_code(),inst.getInstruction_code());
|
||||
sendEndDeviceOrder(ja,inst.getStart_device_code(),inst.getInstruction_code(),inst.getNext_point_code(),inst.getNext_device_code());
|
||||
if(StrUtil.isNotEmpty(inst.getStart_device_code2())){
|
||||
sendStartDeviceOrder(ja,inst.getStart_device_code2(), inst.getStart_point_code2(),inst.getInstruction_code());
|
||||
}
|
||||
if(StrUtil.isNotEmpty(inst.getNext_device_code2())){
|
||||
sendEndDeviceOrder(ja,inst.getNext_device_code2(),inst.getInstruction_code(),inst.getNext_point_code2(),inst.getNext_device_code2());
|
||||
}
|
||||
return ja;
|
||||
}
|
||||
|
||||
/**
|
||||
* 下发取货
|
||||
* @param device_code
|
||||
* @param instCode
|
||||
*/
|
||||
public void sendStartDeviceOrder(JSONArray ja,String pointCode, String device_code,String instCode){
|
||||
|
||||
Device startDevice = deviceAppService.findDeviceByCode(device_code);
|
||||
//忽略取货校验
|
||||
if ("true".equals(startDevice.getExtraValue().get("ignore_pickup_check"))) {
|
||||
//取货前等待
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("blockId", IdUtil.simpleUUID());
|
||||
jo.put("location", inst.getStart_point_code() + "INGET");
|
||||
jo.put("location", pointCode + "INGET");
|
||||
jo.put("operation", "script");
|
||||
jo.put("id", inst.getStart_point_code() + "INGET");
|
||||
jo.put("id", pointCode + "INGET");
|
||||
jo.put("script_name", "userpy/interact.py");
|
||||
JSONObject script_args = new JSONObject();
|
||||
script_args.put("addr", addr);
|
||||
JSONObject data = new JSONObject();
|
||||
JSONObject reach = new JSONObject();
|
||||
reach.put("task_code", inst.getInstruction_code());
|
||||
reach.put("address", inst.getStart_point_code() + "INGET");
|
||||
reach.put("task_code", instCode);
|
||||
reach.put("address", pointCode + "INGET");
|
||||
data.put("reach", reach);
|
||||
script_args.put("data", data);
|
||||
script_args.put("protocol", "HTTP");
|
||||
@@ -312,44 +343,52 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
|
||||
|
||||
JSONObject jo1 = new JSONObject();
|
||||
jo1.put("blockId", IdUtil.simpleUUID());
|
||||
jo1.put("location", inst.getStart_point_code());
|
||||
jo1.put("location", pointCode);
|
||||
jo1.put("operation", "JackLoad");
|
||||
ja.add(jo1);
|
||||
|
||||
//取货完成等待
|
||||
JSONObject jo2 = new JSONObject();
|
||||
jo2.put("blockId", IdUtil.simpleUUID());
|
||||
jo2.put("location", inst.getStart_point_code() + "OUTGET");
|
||||
jo2.put("location", pointCode + "OUTGET");
|
||||
jo2.put("operation", "script");
|
||||
jo2.put("id", inst.getStart_point_code() + "OUTGET");
|
||||
jo2.put("id", pointCode + "OUTGET");
|
||||
jo2.put("script_name", "userpy/interact.py");
|
||||
JSONObject script_args2 = new JSONObject();
|
||||
script_args2.put("addr", addr);
|
||||
JSONObject data2 = new JSONObject();
|
||||
JSONObject reach2 = new JSONObject();
|
||||
reach2.put("task_code", inst.getInstruction_code());
|
||||
reach2.put("address", inst.getStart_point_code() + "OUTGET");
|
||||
reach2.put("task_code", instCode);
|
||||
reach2.put("address", pointCode + "OUTGET");
|
||||
data2.put("reach", reach2);
|
||||
script_args2.put("data", data2);
|
||||
script_args2.put("protocol", "HTTP");
|
||||
jo2.put("script_args", script_args2);
|
||||
ja.add(jo2);
|
||||
}
|
||||
|
||||
Device nextDevice = deviceAppService.findDeviceByCode(inst.getNext_device_code());
|
||||
/**
|
||||
* 下发放货
|
||||
* @param device_code
|
||||
* @param instCode
|
||||
*/
|
||||
public void sendEndDeviceOrder(JSONArray ja,String device_code,String instCode,String pointCode,String nextDeviceCode){
|
||||
Device nextDevice = deviceAppService.findDeviceByCode(nextDeviceCode);
|
||||
//忽略放货校验
|
||||
if ("true".equals(nextDevice.getExtraValue().get("ignore_release_check"))) {
|
||||
//放货前等待
|
||||
JSONObject jo3 = new JSONObject();
|
||||
jo3.put("blockId", IdUtil.simpleUUID());
|
||||
jo3.put("location", inst.getNext_point_code() + "INPUT");
|
||||
jo3.put("location", pointCode + "INPUT");
|
||||
jo3.put("operation", "script");
|
||||
jo3.put("id", inst.getNext_point_code() + "INPUT");
|
||||
jo3.put("id", pointCode + "INPUT");
|
||||
jo3.put("script_name", "userpy/interact.py");
|
||||
JSONObject script_args3 = new JSONObject();
|
||||
script_args3.put("addr", addr);
|
||||
JSONObject data3 = new JSONObject();
|
||||
JSONObject reach3 = new JSONObject();
|
||||
reach3.put("task_code", inst.getInstruction_code());
|
||||
reach3.put("address", inst.getNext_point_code() + "INPUT");
|
||||
reach3.put("task_code", instCode);
|
||||
reach3.put("address", pointCode + "INPUT");
|
||||
data3.put("reach", reach3);
|
||||
script_args3.put("data", data3);
|
||||
script_args3.put("protocol", "HTTP");
|
||||
@@ -359,7 +398,7 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
|
||||
|
||||
//放货前下发旋转角度
|
||||
JSONObject json1 = new JSONObject();
|
||||
AcsPointAngle acsPointAngleDto = acsPointAngleService.findByCode(inst.getStart_device_code(),inst.getNext_device_code());
|
||||
AcsPointAngle acsPointAngleDto = acsPointAngleService.findByCode(device_code,nextDeviceCode);
|
||||
if (ObjectUtil.isNotEmpty(acsPointAngleDto)){
|
||||
log.info("acsPointAngleDto----參數,{}", acsPointAngleDto.toString());
|
||||
com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
|
||||
@@ -367,38 +406,37 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
|
||||
operation_args.put("increase_spin_angle",next_point_angle);//弧度值,如3.14
|
||||
operation_args.put("skill_name","GoByOdometer");
|
||||
json1.put("blockId", IdUtil.simpleUUID());
|
||||
json1.put("location", inst.getNext_point_code() + "INPUT");
|
||||
json1.put("location", pointCode + "INPUT");
|
||||
json1.put("operation_args",operation_args);
|
||||
ja.add(json1);
|
||||
}
|
||||
|
||||
com.alibaba.fastjson.JSONObject jo4 = new com.alibaba.fastjson.JSONObject();
|
||||
jo4.put("blockId", IdUtil.simpleUUID());
|
||||
jo4.put("location", inst.getNext_point_code());
|
||||
jo4.put("location", pointCode);
|
||||
jo4.put("operation", "JackUnload");
|
||||
ja.add(jo4);
|
||||
|
||||
//忽略放货校验
|
||||
if ("true".equals(nextDevice.getExtraValue().get("ignore_release_check"))) {
|
||||
//放货完成等待
|
||||
com.alibaba.fastjson.JSONObject jo5 = new com.alibaba.fastjson.JSONObject();
|
||||
jo5.put("blockId", IdUtil.simpleUUID());
|
||||
jo5.put("location", inst.getNext_point_code() + "OUTPUT");
|
||||
jo5.put("location", pointCode + "OUTPUT");
|
||||
jo5.put("operation", "script");
|
||||
jo5.put("id", inst.getNext_point_code() + "OUTPUT");
|
||||
jo5.put("id", pointCode + "OUTPUT");
|
||||
jo5.put("script_name", "userpy/interact.py");
|
||||
com.alibaba.fastjson.JSONObject script_args5 = new com.alibaba.fastjson.JSONObject();
|
||||
script_args5.put("addr", addr);
|
||||
com.alibaba.fastjson.JSONObject data5 = new com.alibaba.fastjson.JSONObject();
|
||||
com.alibaba.fastjson.JSONObject reach5 = new com.alibaba.fastjson.JSONObject();
|
||||
reach5.put("task_code", inst.getInstruction_code());
|
||||
reach5.put("address", inst.getNext_point_code() + "OUTPUT");
|
||||
reach5.put("task_code", instCode);
|
||||
reach5.put("address", pointCode + "OUTPUT");
|
||||
data5.put("reach", reach5);
|
||||
script_args5.put("data", data5);
|
||||
script_args5.put("protocol", "HTTP");
|
||||
jo5.put("script_args", script_args5);
|
||||
ja.add(jo5);
|
||||
}
|
||||
return ja;
|
||||
}
|
||||
|
||||
@LokiLog(type = LokiLogType.AGV)
|
||||
@@ -632,4 +670,87 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
|
||||
return AGVDeviceStatus;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public JSONObject xgAGVWaitPointRequest(JSONObject requestParam) {
|
||||
log.info("仙工AGV请求取放货,请求参数 - {}", requestParam);
|
||||
String inst_code = requestParam.getString("task_code");
|
||||
Instruction instructionDto = instructionService.findByCodeFromCache(inst_code);
|
||||
if (ObjectUtil.isEmpty(instructionDto)) {
|
||||
throw new BadRequestException("请求失败,未找到指令!");
|
||||
}
|
||||
String address = requestParam.getString("address");
|
||||
if (StrUtil.isBlank(address)) {
|
||||
throw new BadRequestException("请求失败,地址为空!");
|
||||
}
|
||||
|
||||
|
||||
if (address.contains("IN")) {
|
||||
String deviceCodeNow = address.substring(0, address.length() - 5);
|
||||
if (ObjectUtil.isEmpty(deviceAppService.findDeviceByCode(deviceCodeNow))) {
|
||||
throw new BadRequestException("设备号 " + deviceCodeNow + " 不存在!");
|
||||
}
|
||||
|
||||
if (address.contains("GET")) {
|
||||
return agvWaitUtil.waitInGet(deviceCodeNow, instructionDto);
|
||||
} else if (address.contains("PUT")) {
|
||||
return agvWaitUtil.waitInPut(deviceCodeNow, instructionDto);
|
||||
}
|
||||
}
|
||||
if (address.contains("OUT")) {
|
||||
String deviceCodeNow = address.substring(0, address.length() - 6);
|
||||
if (ObjectUtil.isEmpty(deviceAppService.findDeviceByCode(deviceCodeNow))) {
|
||||
throw new BadRequestException("设备号 " + deviceCodeNow + " 不存在!");
|
||||
}
|
||||
|
||||
if (address.contains("GET")) {
|
||||
return agvWaitUtil.waitOutGet(deviceCodeNow, instructionDto);
|
||||
} else if (address.contains("PUT")) {
|
||||
return agvWaitUtil.waitOutPut(deviceCodeNow, instructionDto);
|
||||
}
|
||||
}
|
||||
|
||||
throw new BadRequestException("请求失败,IN OUT 站点错误!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResponse selectOrderByInstCode(String instCode) {
|
||||
if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) {
|
||||
String agvurl =paramService.findByCode(AcsConfig.AGVURL).getValue();
|
||||
String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
|
||||
|
||||
com.alibaba.fastjson.JSONObject param = new com.alibaba.fastjson.JSONObject();
|
||||
param.put("id", instCode);
|
||||
param.put("disableVehicle", false);
|
||||
agvurl = agvurl + ":" + agvport + "/" + instCode;
|
||||
log.info("根据运单号查询运单状态的请求:{}", agvurl);
|
||||
HttpResponse result = HttpRequest.post(agvurl)
|
||||
.body(param.toJSONString())
|
||||
.timeout(20000)//超时,毫秒
|
||||
.execute();
|
||||
log.info("根据运单号查询运单状态的请求反馈:{}", result);
|
||||
return result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResponse getRobotInfo(String robotCode) {
|
||||
if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) {
|
||||
String agvurl =paramService.findByCode(AcsConfig.AGVURL).getValue();
|
||||
String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
|
||||
|
||||
agvurl = agvurl + ":" + agvport + "/"+ " robotsStatus?vehicles=" + robotCode;
|
||||
log.info("根据指定机器人查询状态的请求:{}", agvurl);
|
||||
HttpResponse result = HttpRequest.get(agvurl)
|
||||
.timeout(20000)//超时,毫秒
|
||||
.execute();
|
||||
log.info("根据指定机器人查询状态的请求反馈:{}", result);
|
||||
return result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,9 +16,7 @@ public class CommonFinalParam {
|
||||
*/
|
||||
private final String BARRE = "-";
|
||||
private final String POINT = ".";
|
||||
/**
|
||||
* 开门
|
||||
*/
|
||||
|
||||
public static final String ONE = "1";
|
||||
|
||||
public static final String TWO = "2";
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapp
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.map.ListOrderedMap;
|
||||
import org.apache.commons.lang.LocaleUtils;
|
||||
import org.nl.acs.auto.initial.ApplicationAutoInitial;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
@@ -653,8 +654,8 @@ public class DeviceServiceImpl extends CommonServiceImpl<DeviceMapper, Device> i
|
||||
// String device_code = jo.getString("device_code");
|
||||
// String device_name = jo.getString("device_name");
|
||||
// Device device = appService.findDeviceByCode(device_code);
|
||||
// if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||
// standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
|
||||
// if (device.getDeviceDriver() instanceof XgAgvCarDeviceDriver) {
|
||||
// standardOrdinarySiteDeviceDriver = (XgAgvCarDeviceDriver) device.getDeviceDriver();
|
||||
// int branchProtocol = standardOrdinarySiteDeviceDriver.getBranchProtocol();
|
||||
// devicejo.put("device_code",device_code);
|
||||
// devicejo.put("branchProtocol",branchProtocol);
|
||||
@@ -1893,6 +1894,9 @@ public class DeviceServiceImpl extends CommonServiceImpl<DeviceMapper, Device> i
|
||||
String is_config = list.get(3).toString();
|
||||
String is_route = list.get(4).toString();
|
||||
String region = list.get(5).toString();
|
||||
String in_device_name = list.get(6).toString();
|
||||
String en_device_name = list.get(7).toString();
|
||||
String zh_device_name = list.get(8).toString();
|
||||
if (StrUtil.isEmpty(device_code)) {
|
||||
throw new BadRequestException(LangProcess.msg("error_checkNull", "device_code"));
|
||||
}
|
||||
@@ -1912,6 +1916,16 @@ public class DeviceServiceImpl extends CommonServiceImpl<DeviceMapper, Device> i
|
||||
if (ObjectUtil.isNotEmpty(dto)) {
|
||||
continue;
|
||||
}
|
||||
if(StrUtil.isEmpty(zh_device_name)){
|
||||
//throw new BadRequestException(LangProcess.msg("zh_device_name_isNotNull"));
|
||||
zh_device_name = StrUtil.isNotEmpty(device_name) ? device_name : device_code;
|
||||
}
|
||||
if(StrUtil.isEmpty(en_device_name)){
|
||||
en_device_name = StrUtil.isNotEmpty(device_name) ? device_name : device_code;
|
||||
}
|
||||
if (StrUtil.isEmpty(in_device_name)){
|
||||
in_device_name = StrUtil.isNotEmpty(device_name) ? device_name : device_code;
|
||||
}
|
||||
//按照列获取
|
||||
param.put("device_id", IdUtil.getSnowflake(1, 1).nextId());
|
||||
param.put("device_code", device_code);
|
||||
@@ -1924,8 +1938,10 @@ public class DeviceServiceImpl extends CommonServiceImpl<DeviceMapper, Device> i
|
||||
param.put("update_by", nickName);
|
||||
param.put("update_time", now);
|
||||
param.put("region", region);
|
||||
param.put("in_device_name", in_device_name);
|
||||
param.put("en_device_name", en_device_name);
|
||||
param.put("zh_device_name", zh_device_name);
|
||||
|
||||
// wo.insert(param);
|
||||
Device entity = ConvertUtil.convert(param, Device.class);
|
||||
deviceMapper.insert(entity);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package org.nl.acs.device_driver.agv.xg_agv_car;
|
||||
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.device.enums.DeviceType;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.DeviceDriverDefination;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 仙工AGV
|
||||
*/
|
||||
@Service
|
||||
public class XgAgvCarDefination implements DeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "xg_agv_car";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverName() {
|
||||
return "仙工AGV车";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverDescription() {
|
||||
return "仙工AGV车";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new XgAgvCarDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||
return XgAgvCarDeviceDriver.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceType> getFitDeviceTypes() {
|
||||
List<DeviceType> types = new LinkedList();
|
||||
types.add(DeviceType.agv);
|
||||
return types;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
package org.nl.acs.device_driver.agv.xg_agv_car;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.agv.server.NDCAgvService;
|
||||
import org.nl.acs.agv.server.XianGongAgvService;
|
||||
import org.nl.acs.common.base.CommonFinalParam;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.RouteableDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.AbstractDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
|
||||
import org.nl.acs.instruction.domain.Instruction;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.monitor.DeviceStageMonitor;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* 普通站点仙工AGV
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class XgAgvCarDeviceDriver extends AbstractDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
|
||||
@Autowired
|
||||
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
|
||||
@Autowired
|
||||
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
|
||||
@Autowired
|
||||
DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl");
|
||||
@Autowired
|
||||
RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl");
|
||||
@Autowired
|
||||
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
|
||||
@Autowired
|
||||
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
|
||||
@Autowired
|
||||
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
|
||||
@Autowired
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
|
||||
@Autowired
|
||||
NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvService.class);
|
||||
@Autowired
|
||||
private XianGongAgvService xianGongAgvService;
|
||||
|
||||
Integer hasGoods = 0;
|
||||
int error = 0;
|
||||
Boolean iserror = false;
|
||||
Boolean islock = false;
|
||||
|
||||
int branchProtocol = 0;
|
||||
int last_branchProtocol = 0;
|
||||
/**
|
||||
* 是否需要输入物料
|
||||
*/
|
||||
String input_material = "0";
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
String remark = "";
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
String qty = "";
|
||||
/**
|
||||
* 批次
|
||||
*/
|
||||
String batch = "";
|
||||
/**
|
||||
* 物料
|
||||
*/
|
||||
String material = "";
|
||||
/**
|
||||
* 目标点位
|
||||
*/
|
||||
String purpose = "";
|
||||
/**
|
||||
* 当前指令
|
||||
*/
|
||||
Instruction inst = null;
|
||||
/**
|
||||
* 上次指令
|
||||
*/
|
||||
Instruction last_inst = null;
|
||||
|
||||
boolean requireSucess = false;
|
||||
|
||||
/**
|
||||
* 触摸屏手动触发任务
|
||||
*/
|
||||
private Boolean is_has_task = false;
|
||||
|
||||
/**
|
||||
* 申请搬运任务
|
||||
*/
|
||||
private Boolean apply_handling = false;
|
||||
/**
|
||||
* 申请物料
|
||||
*/
|
||||
private Boolean apply_material = false;
|
||||
|
||||
/**
|
||||
* 1取货完成 2放货完成 3进入区域 4离开区域
|
||||
*/
|
||||
private int flag;
|
||||
|
||||
/**
|
||||
* 人工确认信号 默认0 agv到达后请求置1 等人工确认后变为2 反馈agv后继续为0
|
||||
*/
|
||||
private int manua_confirm = 0;
|
||||
|
||||
String device_code = null;
|
||||
String container;
|
||||
String container_type_desc;
|
||||
String last_container_type_desc;
|
||||
String last_container;
|
||||
private Date instruction_require_time = new Date();
|
||||
private Date instruction_finished_time = new Date();
|
||||
|
||||
private int instruction_require_time_out;
|
||||
|
||||
String message;
|
||||
|
||||
// 1 上位系统允许进入 2 上位系统允许离开
|
||||
int status = 0;
|
||||
|
||||
int agvphase = 0;
|
||||
int index = 0;
|
||||
|
||||
int mode = 2;
|
||||
|
||||
int move;
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取机器人信息
|
||||
*/
|
||||
private void getAgvStatus() {
|
||||
HttpResponse robotInfo = xianGongAgvService.getRobotInfo(this.getDevice().getDevice_name());
|
||||
if(robotInfo.getStatus() == 200){
|
||||
JSONObject jsonObject = JSONObject.parseObject(robotInfo.body());
|
||||
|
||||
}else{
|
||||
log.info("请求{}机器人状态失败", this.getDevice().getDevice_name());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
|
||||
carrier_direction = this.itemProtocol.getCarrier_direction();
|
||||
qty = this.itemProtocol.getQty();
|
||||
weight = this.itemProtocol.getWeight();
|
||||
barcode = this.itemProtocol.getBarcode();
|
||||
// barcode = this.itemProtocol.getBarcode();
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -150,40 +150,40 @@ public class ItemProtocol {
|
||||
|
||||
public static List<ItemDto> getReadableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_heartbeat, "心跳", "251"));
|
||||
list.add(new ItemDto(item_mode, "工作模式", "7990"));
|
||||
list.add(new ItemDto(item_move, "光电信号", "550"));
|
||||
list.add(new ItemDto(item_door, "门状态", "450"));
|
||||
list.add(new ItemDto(item_temperature, "工位温度", "7991"));
|
||||
list.add(new ItemDto(item_countdown_house, "恒温倒计时(时)", "80500"));
|
||||
list.add(new ItemDto(item_countdown_min, "恒温倒计时(分)", "80502"));
|
||||
list.add(new ItemDto(item_countdown_sec, "恒温倒计时(秒)", "80504"));
|
||||
list.add(new ItemDto(item_finish, "烘干完成", "8025"));
|
||||
list.add(new ItemDto(item_action, "取放信号", "450"));
|
||||
list.add(new ItemDto(item_task, "任务号", "220"));
|
||||
list.add(new ItemDto(item_error, "故障", "8055"));
|
||||
list.add(new ItemDto(item_error1, "故障1", "216"));
|
||||
list.add(new ItemDto(item_material, "物料", "223"));
|
||||
list.add(new ItemDto(item_consumption, "电能耗", "8092"));
|
||||
list.add(new ItemDto(item_voltageA, "A相电压", "8080"));
|
||||
list.add(new ItemDto(item_voltageB, "B相电压", "8082"));
|
||||
list.add(new ItemDto(item_voltageC, "C相电压", "8084"));
|
||||
list.add(new ItemDto(item_currentA, "A相电流", "8086"));
|
||||
list.add(new ItemDto(item_currentB, "B相电流", "8088"));
|
||||
list.add(new ItemDto(item_currentC, "C相电流", "8090"));
|
||||
list.add(new ItemDto(item_heartbeat, "心跳", "DB118.B251"));
|
||||
list.add(new ItemDto(item_mode, "工作模式", "DB118.B7990"));
|
||||
list.add(new ItemDto(item_move, "光电信号", "DB118.B550"));
|
||||
list.add(new ItemDto(item_door, "门状态", "DB118.B450"));
|
||||
list.add(new ItemDto(item_temperature, "工位温度", "DB118.B7991"));
|
||||
list.add(new ItemDto(item_countdown_house, "恒温倒计时(时)", "DB118.B80500"));
|
||||
list.add(new ItemDto(item_countdown_min, "恒温倒计时(分)", "DB118.B80502"));
|
||||
list.add(new ItemDto(item_countdown_sec, "恒温倒计时(秒)", "DB118.B80504"));
|
||||
list.add(new ItemDto(item_finish, "烘干完成", "DB118.B8025"));
|
||||
list.add(new ItemDto(item_action, "取放信号", "DB118.B450"));
|
||||
list.add(new ItemDto(item_task, "任务号", "DB118.B220"));
|
||||
list.add(new ItemDto(item_error, "故障", "DB118.B8055"));
|
||||
list.add(new ItemDto(item_error1, "故障1", "DB118.B216"));
|
||||
list.add(new ItemDto(item_material, "物料", "DB118.B223"));
|
||||
list.add(new ItemDto(item_consumption, "电能耗", "DB118.B8092"));
|
||||
list.add(new ItemDto(item_voltageA, "A相电压", "DB118.B8080"));
|
||||
list.add(new ItemDto(item_voltageB, "B相电压", "DB118.B8082"));
|
||||
list.add(new ItemDto(item_voltageC, "C相电压", "DB118.B8084"));
|
||||
list.add(new ItemDto(item_currentA, "A相电流", "DB118.B8086"));
|
||||
list.add(new ItemDto(item_currentB, "B相电流", "DB118.B8088"));
|
||||
list.add(new ItemDto(item_currentC, "C相电流", "DB118.B8090"));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_to_command, "下发命令", "40226"));
|
||||
list.add(new ItemDto(item_to_open_door, "开门", "00111"));
|
||||
list.add(new ItemDto(item_to_close_door, "关门", "00112"));
|
||||
list.add(new ItemDto(item_to_temperature, "生产温度", "48100"));
|
||||
list.add(new ItemDto(item_to_material, "生产物料", "40229"));
|
||||
list.add(new ItemDto(item_to_time_house, "生产时间(时)", "48771"));
|
||||
list.add(new ItemDto(item_to_time_min, "生产时间(分)", "48770"));
|
||||
list.add(new ItemDto(item_to_task, "任务号", "40232"));
|
||||
list.add(new ItemDto(item_to_command, "下发命令", "DB118.B40226"));
|
||||
list.add(new ItemDto(item_to_open_door, "开门", "DB118.B00111"));
|
||||
list.add(new ItemDto(item_to_close_door, "关门", "DB118.B00112"));
|
||||
list.add(new ItemDto(item_to_temperature, "生产温度", "DB118.B48100"));
|
||||
list.add(new ItemDto(item_to_material, "生产物料", "DB118.B40229"));
|
||||
list.add(new ItemDto(item_to_time_house, "生产时间(时)", "DB118.B48771"));
|
||||
list.add(new ItemDto(item_to_time_min, "生产时间(分)", "DB118.B48770"));
|
||||
list.add(new ItemDto(item_to_task, "任务号", "DB118.B40232"));
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,8 @@ public class ItemProtocol {
|
||||
|
||||
public String getOpcStringValue(String protocol) {
|
||||
String value = this.driver.getStringValue(protocol);
|
||||
if (StrUtil.isEmpty(value)) {
|
||||
if (StrUtil.isBlank(value)) {
|
||||
//throw new BusinessException("{} : {}", new Object[]{protocol, DeviceErrorProtocol.getMessage(10000)});
|
||||
|
||||
} else {
|
||||
return value;
|
||||
@@ -128,9 +129,6 @@ public class ItemProtocol {
|
||||
if (value == null) {
|
||||
// log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!");
|
||||
setIsonline(false);
|
||||
} else {
|
||||
setIsonline(true);
|
||||
return value;
|
||||
}
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package org.nl.acs.device_driver.two_conveyor.oven_manipulator;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -23,7 +25,10 @@ import org.nl.acs.history.ErrorUtil;
|
||||
import org.nl.acs.history.service.DeviceErrorLogService;
|
||||
import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl;
|
||||
import org.nl.acs.instruction.domain.Instruction;
|
||||
import org.nl.acs.instruction.domain.InstructionMybatis;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.limit_regional.server.LimitRegionalService;
|
||||
import org.nl.acs.limit_regional.server.dto.LimitRegionalDto;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.monitor.DeviceStageMonitor;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
@@ -61,6 +66,8 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||
@Autowired
|
||||
DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class);
|
||||
@Autowired
|
||||
private LimitRegionalService limitRegionalService=SpringContextHolder.getBean(LimitRegionalService.class);
|
||||
|
||||
//工作模式
|
||||
int mode = 0;
|
||||
@@ -156,8 +163,8 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
error = this.itemProtocol.getError();
|
||||
task = this.itemProtocol.getTask();
|
||||
heartbeat = this.itemProtocol.getHeartbeat();
|
||||
to_command = this.itemProtocol.getTo_command();
|
||||
to_target = this.itemProtocol.getTo_target();
|
||||
to_command = this.itemProtocol.getTo_command();
|
||||
to_task = this.itemProtocol.getTo_task();
|
||||
to_onset = this.itemProtocol.getTo_onset();
|
||||
x_position = this.itemProtocol.getX_position();
|
||||
@@ -339,7 +346,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
String next_device_code = instruction.getNext_device_code();
|
||||
Device nextdevice = deviceAppService.findDeviceByCode(next_device_code);
|
||||
Device startdevice = deviceAppService.findDeviceByCode(start_device_code);
|
||||
// PhotoelectricInspectionSiteDeviceDriver photoelectricInspectionSiteDeviceDriver;
|
||||
//PhotoelectricInspectionSiteDeviceDriver photoelectricInspectionSiteDeviceDriver;
|
||||
HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver;
|
||||
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
|
||||
// if (startdevice.getDeviceDriver() instanceof PhotoelectricInspectionSiteDeviceDriver) {
|
||||
@@ -401,10 +408,14 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:"
|
||||
+ instruction.getInstruction_code() + ",指令起点:" + instruction.getStart_device_code()
|
||||
+ ",指令终点:" + instruction.getNext_device_code());
|
||||
this.writing("to_onset", start_addr);
|
||||
this.writing("to_target", next_addr);
|
||||
this.writing("to_task", instruction.getInstruction_code());
|
||||
this.writing("to_command", "1");
|
||||
List list = new ArrayList<>();
|
||||
Map map = new HashMap();
|
||||
map.put("to_onset", start_addr);
|
||||
map.put("to_target", next_addr);
|
||||
map.put("to_task", instruction.getInstruction_code());
|
||||
map.put("to_command", "1");
|
||||
list.add(map);
|
||||
this.writing(list);
|
||||
if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
|
||||
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startdevice.getDeviceDriver();
|
||||
hongXiangConveyorDeviceDriver.writing("to_open_door", "1");
|
||||
@@ -520,7 +531,6 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
if (isCloseDoor) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
instructionService.create(instdto);
|
||||
} catch (Exception e) {
|
||||
@@ -550,10 +560,24 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:"
|
||||
+ instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code()
|
||||
+ ",指令终点:" + instdto.getNext_device_code());
|
||||
this.writing("to_onset", start_addr);
|
||||
this.writing("to_target", next_addr);
|
||||
this.writing("to_task", instdto.getInstruction_code());
|
||||
this.writing("to_command", "1");
|
||||
List list = new ArrayList<>();
|
||||
Map map = new HashMap();
|
||||
map.put("code", "to_onset");
|
||||
map.put("value",StrUtil.isNotBlank(start_addr)? start_addr : "0");
|
||||
Map map1 = new HashMap();
|
||||
map1.put("code", "to_target");
|
||||
map1.put("value",StrUtil.isNotBlank(next_addr)? next_addr : "0");
|
||||
Map map2 = new HashMap();
|
||||
map2.put("code", "to_task");
|
||||
map2.put("value",instdto.getInstruction_code());
|
||||
Map map3 = new HashMap();
|
||||
map3.put("code", "to_command");
|
||||
map3.put("value","1");
|
||||
list.add(map);
|
||||
list.add(map1);
|
||||
list.add(map2);
|
||||
list.add(map3);
|
||||
this.writing(list);
|
||||
//HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver;
|
||||
if (nextDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
|
||||
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextDevice.getDeviceDriver();
|
||||
@@ -579,7 +603,6 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
//判断取货位或放货位为烘箱设备时关联的同一列烘箱设备是否有开门
|
||||
public boolean judgeCloseDoor(String start_device_code, String next_device_code) {
|
||||
Boolean isClose = false;
|
||||
|
||||
try {
|
||||
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
|
||||
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
|
||||
@@ -1006,6 +1029,31 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + value);
|
||||
}
|
||||
|
||||
public void writing(List list) {
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Object ob = list.get(i);
|
||||
JSONObject json = (JSONObject) JSONObject.toJSON(ob);
|
||||
if (!StrUtil.isEmpty(json.getString("value"))) {
|
||||
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + json.getString("code");
|
||||
itemMap.put(to_param, json.getString("value"));
|
||||
}
|
||||
}
|
||||
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap);
|
||||
try {
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
this.checkcontrol(itemMap);
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject feedLmsRealFailedInfo() {
|
||||
JSONObject jo = new JSONObject();
|
||||
|
||||
@@ -5,9 +5,13 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.acs.ext.wms.data.*;
|
||||
import org.nl.acs.ext.wms.data.one.*;
|
||||
<<<<<<< Updated upstream
|
||||
import org.nl.acs.ext.wms.data.one.ApplyLabelingAndBindingRequest;
|
||||
import org.nl.acs.ext.wms.data.one.ApplyLabelingAndBindingResponse;
|
||||
import org.nl.acs.ext.wms.data.one.BaseRequest;
|
||||
=======
|
||||
import org.nl.acs.instruction.domain.Instruction;
|
||||
>>>>>>> Stashed changes
|
||||
|
||||
public interface AcsToWmsService {
|
||||
|
||||
@@ -129,6 +133,7 @@ public interface AcsToWmsService {
|
||||
*/
|
||||
BlankingButtonResponse applyBlankButtonTask(BlankingButtonRequest param);
|
||||
|
||||
<<<<<<< Updated upstream
|
||||
/**
|
||||
* 向lms申请反馈
|
||||
* @param param
|
||||
@@ -142,4 +147,14 @@ public interface AcsToWmsService {
|
||||
* @return
|
||||
*/
|
||||
ApplyPlugPullSitResponse applyPlugPullSiteRequest(ApplyPlugPullSiteRequest param);
|
||||
=======
|
||||
|
||||
/**
|
||||
* 查询站点有无货状态
|
||||
* @param inst
|
||||
* @return
|
||||
*/
|
||||
JSONObject queryStationState(Instruction inst);
|
||||
|
||||
>>>>>>> Stashed changes
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.nl.acs.ext.wms.data.one.ApplyLabelingAndBindingRequest;
|
||||
import org.nl.acs.ext.wms.data.one.ApplyLabelingAndBindingResponse;
|
||||
import org.nl.acs.ext.wms.data.one.BaseRequest;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.instruction.domain.Instruction;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
@@ -226,7 +227,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
|
||||
@Override
|
||||
public ApplyManipulatorActionResponse applyManipulatorActionRequest(ApplyManipulatorActionRequest param) {
|
||||
log.info("向LMS申请反馈,请求参数{}",param);
|
||||
log.info("向LMS申请反馈,请求参数{}", param);
|
||||
try {
|
||||
MDC.put(log_file_type, log_type);
|
||||
ApplyManipulatorActionResponse applyManipulatorActionResponse = new ApplyManipulatorActionResponse();
|
||||
@@ -254,6 +255,33 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
return applyManipulatorActionResponse;
|
||||
} finally {
|
||||
MDC.remove(log_file_type);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public JSONObject queryStationState(Instruction inst) {
|
||||
try {
|
||||
String wmsurl = paramService.findByCode(AcsConfig.WMSURL).getValue();
|
||||
AddressDto addressDto = addressService.findByCode("gccQueryStationState");
|
||||
String uri = wmsurl + addressDto.getMethods_url() + "?StartStationCode=" + inst.getStart_point_code() + "&EndStationCode=" + inst.getNext_point_code();
|
||||
|
||||
log.info("gccQueryStationState - 请求路径{}", uri);
|
||||
String responseBody = HttpRequest
|
||||
.get(uri)
|
||||
.execute()
|
||||
.body();
|
||||
log.info("gccQueryStationState - 响应参数{}", responseBody);
|
||||
|
||||
return JSONObject.parseObject(responseBody);
|
||||
} catch (Exception e) {
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("status", HttpStatus.BAD_REQUEST.value());
|
||||
result.put("message", e.getMessage());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package org.nl.acs.instruction.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.stream.CollectorUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@@ -13,6 +16,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
@@ -38,6 +42,8 @@ import org.nl.acs.instruction.domain.InstructionMybatis;
|
||||
import org.nl.acs.instruction.enums.InstructionStatusEnum;
|
||||
import org.nl.acs.instruction.service.dto.InstructionDto;
|
||||
import org.nl.acs.instruction.service.dto.InstructionQueryParam;
|
||||
import org.nl.acs.limit_regional.server.LimitRegionalService;
|
||||
import org.nl.acs.limit_regional.server.dto.LimitRegionalDto;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.opc.DeviceAppServiceImpl;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
@@ -104,6 +110,8 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
private AcsToLiKuService acsToLiKuService;
|
||||
@Autowired
|
||||
private XianGongAgvService xiangGongAgvService;
|
||||
@Autowired
|
||||
private LimitRegionalService limitRegionalService;
|
||||
|
||||
private List<Instruction> instructions = new CopyOnWriteArrayList();
|
||||
|
||||
@@ -445,6 +453,9 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
dto.setSend_status("1");
|
||||
}
|
||||
}
|
||||
Device nextdevice = appService.findDeviceByCode(dto.getNext_device_code());
|
||||
String startRegion = startdevice.getRegion();
|
||||
String nextRegion = nextdevice.getRegion();
|
||||
} catch (Exception e) {
|
||||
dto.setSend_status("2");
|
||||
e.printStackTrace();
|
||||
@@ -832,9 +843,9 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
return;
|
||||
}
|
||||
// 如果是无光电的设备 放货任务完成需要变更有货状态
|
||||
// StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
|
||||
// if(device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||
// standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver)
|
||||
// XgAgvCarDeviceDriver standardOrdinarySiteDeviceDriver;
|
||||
// if(device.getDeviceDriver() instanceof XgAgvCarDeviceDriver) {
|
||||
// standardOrdinarySiteDeviceDriver = (XgAgvCarDeviceDriver)
|
||||
// device.getDeviceDriver();
|
||||
// standardOrdinarySiteDeviceDriver.setMove(2);
|
||||
// }
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
package org.nl.acs.limit_regional.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.*;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("acs_regional_flow_control")
|
||||
public class LimitRegional {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 起始区域
|
||||
*/
|
||||
private String start_regional;
|
||||
|
||||
/**
|
||||
* 目标区域
|
||||
*/
|
||||
private String next_regional;
|
||||
|
||||
/**
|
||||
* 起始区域排除设备
|
||||
*/
|
||||
private String start_exclude_device;
|
||||
@TableField(exist = false)
|
||||
private List<String> startExcludeDevice;
|
||||
|
||||
/**
|
||||
* 目标区域排除设备
|
||||
*/
|
||||
private String next_exclude_device;
|
||||
@TableField(exist = false)
|
||||
private List<String> nextExcludeDevice;
|
||||
|
||||
/**
|
||||
* 最大数量
|
||||
*/
|
||||
private String max_num;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private String is_active;
|
||||
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
@NotBlank
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private String create_by;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@NotBlank
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private String create_time;
|
||||
|
||||
/**
|
||||
* 修改者
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private String update_by;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@NotBlank
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private String update_time;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package org.nl.acs.limit_regional.rest;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.acs.limit_regional.server.LimitRegionalService;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/acsRegional")
|
||||
public class LimitRegionalController {
|
||||
|
||||
@Autowired
|
||||
private LimitRegionalService limitRegionalService;
|
||||
|
||||
@GetMapping
|
||||
@Log("分页查询流量限制")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) {
|
||||
return new ResponseEntity<>(limitRegionalService.queryByPage(whereJson, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("synchronous")
|
||||
@Log("同步流量限制")
|
||||
public ResponseEntity<Object> queryAll() {
|
||||
limitRegionalService.queryAll();
|
||||
return new ResponseEntity<>( HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增流量限制")
|
||||
public ResponseEntity<Object> add(@RequestBody JSONObject json) {
|
||||
return new ResponseEntity<>(limitRegionalService.add(json), HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@PutMapping
|
||||
@Log("修改流量限制")
|
||||
public ResponseEntity<Object> update(@RequestBody JSONObject json) {
|
||||
limitRegionalService.update(json);
|
||||
return new ResponseEntity<>( HttpStatus.OK);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Log("删除流量限制")
|
||||
public ResponseEntity<Object> del(@RequestBody String[] ids) {
|
||||
limitRegionalService.del(ids);
|
||||
return new ResponseEntity<>( HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("updateActive")
|
||||
@Log("修改流量限制状态")
|
||||
public ResponseEntity<Object> updateStatusById(@RequestParam Map whereJson) {
|
||||
limitRegionalService.updateStatusById(whereJson);
|
||||
return new ResponseEntity<>( HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package org.nl.acs.limit_regional.server;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.nl.acs.common.base.CommonService;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.limit_regional.domain.LimitRegional;
|
||||
import org.nl.acs.limit_regional.server.dto.LimitRegionalDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public interface LimitRegionalService extends CommonService<LimitRegional> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param whereJson
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> queryByPage(Map whereJson, Pageable page);
|
||||
|
||||
/**
|
||||
* 查询全部流量限制
|
||||
* @param whereJson
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
void queryAll();
|
||||
|
||||
/**
|
||||
* 新增流量限制
|
||||
* @param json
|
||||
* @return
|
||||
*/
|
||||
List<LimitRegional> add(JSONObject json);
|
||||
|
||||
|
||||
/**
|
||||
* 删除流量限制
|
||||
* @param json
|
||||
*/
|
||||
void del(String[] ids);
|
||||
|
||||
/**
|
||||
* 修改流量限制
|
||||
* @param json
|
||||
*/
|
||||
void update(JSONObject json);
|
||||
|
||||
/**
|
||||
* 修改流量限制状态
|
||||
* @param whereJson
|
||||
*/
|
||||
void updateStatusById(Map whereJson);
|
||||
|
||||
/**
|
||||
* 根绝起点目标区域查询流量限制
|
||||
* @param startdevice
|
||||
* @param nextRegion
|
||||
*/
|
||||
LimitRegionalDto selectByReging(String startdevice, String nextRegion);
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package org.nl.acs.limit_regional.server.dto;
|
||||
|
||||
import lombok.*;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class LimitRegionalDto implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 起始区域
|
||||
*/
|
||||
private String start_regional;
|
||||
|
||||
/**
|
||||
* 目标区域
|
||||
*/
|
||||
private String next_regional;
|
||||
|
||||
/**
|
||||
* 起始区域排除设备
|
||||
*/
|
||||
private String start_exclude_device;
|
||||
private List<String> startExcludeDevice;
|
||||
|
||||
/**
|
||||
* 目标区域排除设备
|
||||
*/
|
||||
private String next_exclude_device;
|
||||
private List<String> nextExcludeDevice;
|
||||
|
||||
/**
|
||||
* 最大数量
|
||||
*/
|
||||
private String max_num;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private String is_active;
|
||||
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
private String create_by;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String create_time;
|
||||
|
||||
/**
|
||||
* 修改者
|
||||
*/
|
||||
private String update_by;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private String update_time;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
package org.nl.acs.limit_regional.server.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.common.base.PageInfo;
|
||||
import org.nl.acs.common.base.QueryHelpMybatisPlus;
|
||||
import org.nl.acs.common.base.impl.CommonServiceImpl;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.limit_regional.domain.LimitRegional;
|
||||
import org.nl.acs.limit_regional.server.LimitRegionalService;
|
||||
import org.nl.acs.limit_regional.server.dto.LimitRegionalDto;
|
||||
import org.nl.acs.limit_regional.server.mapper.LimitRegionalMapper;
|
||||
import org.nl.acs.utils.ConvertUtil;
|
||||
import org.nl.acs.utils.PageUtil;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
@Slf4j
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||
public class LimitRegionalServiceImpl extends CommonServiceImpl<LimitRegionalMapper, LimitRegional> implements LimitRegionalService {
|
||||
|
||||
@Autowired
|
||||
private LimitRegionalMapper limitRegionalMapper;
|
||||
|
||||
private List<LimitRegional> dataList;
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryByPage(Map whereJson, Pageable page) {
|
||||
for (LimitRegional dto : dataList) {
|
||||
String next_exclude_device = dto.getNext_exclude_device();
|
||||
String elementStr = next_exclude_device.replaceAll("[\\[\\] ]", "");
|
||||
String[] elements = elementStr.split(",");
|
||||
List<String> list = new ArrayList<>();
|
||||
list.addAll(Arrays.asList(elements));
|
||||
String start_exclude_device = dto.getStart_exclude_device();
|
||||
String elementStr1 = start_exclude_device.replaceAll("[\\[\\] ]", "");
|
||||
String[] elements1 = elementStr1.split(",");
|
||||
List<String> list1 = new ArrayList<>();
|
||||
list1.addAll(Arrays.asList(elements1));
|
||||
dto.setNextExcludeDevice(list);
|
||||
dto.setStartExcludeDevice(list1);
|
||||
}
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("content",dataList);
|
||||
jsonObject.put("totalElements",dataList.size());
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@PostConstruct
|
||||
public void queryAll() {
|
||||
dataList = limitRegionalMapper.selectList(null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<LimitRegional> add(JSONObject json) {
|
||||
LimitRegional limitRegional = new LimitRegional();
|
||||
limitRegional.setId(RandomUtil.randomString(8));
|
||||
limitRegional.setStart_regional(json.getString("start_regional"));
|
||||
limitRegional.setNext_regional(json.getString("next_regional"));
|
||||
limitRegional.setStart_exclude_device(json.getString("startExcludeDevice"));
|
||||
limitRegional.setNext_exclude_device(json.getString("nextExcludeDevice"));
|
||||
String max_num = json.getString("max_num");
|
||||
String regex = "\\d+";
|
||||
boolean isNumeric = max_num.matches(regex);
|
||||
if(!isNumeric){
|
||||
throw new RuntimeException("最大数请输入纯数字");
|
||||
}
|
||||
limitRegional.setMax_num(max_num);
|
||||
limitRegional.setCreate_by("auto");
|
||||
limitRegional.setCreate_time(DateUtil.now());
|
||||
limitRegionalMapper.insert(limitRegional);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void del(String[] ids) {
|
||||
if(CollUtil.isEmpty(Arrays.asList(ids)) || ids.length < 1){
|
||||
return;
|
||||
}
|
||||
for (String id : ids) {
|
||||
limitRegionalMapper.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void update(JSONObject json) {
|
||||
LimitRegional limitRegional = new LimitRegional();
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
limitRegional.setId(json.getString("id"));
|
||||
limitRegional.setStart_regional(json.getString("start_regional"));
|
||||
limitRegional.setNext_regional(json.getString("next_regional"));
|
||||
limitRegional.setStart_exclude_device(json.getString("startExcludeDevice"));
|
||||
limitRegional.setNext_exclude_device(json.getString("nextExcludeDevice"));
|
||||
limitRegional.setMax_num(json.getString("max_num"));
|
||||
limitRegional.setUpdate_by(currentUsername);
|
||||
limitRegional.setUpdate_time(DateUtil.now());
|
||||
limitRegionalMapper.updateById(limitRegional);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStatusById(Map whereJson) {
|
||||
String id = whereJson.get("id").toString();
|
||||
if(StrUtil.isEmpty(id)){
|
||||
return;
|
||||
}
|
||||
LimitRegional limitRegional = new LimitRegional();
|
||||
limitRegional.setId(id);
|
||||
limitRegional.setIs_active(whereJson.get("is_active").toString());
|
||||
limitRegional.setUpdate_by(SecurityUtils.getCurrentUsername());
|
||||
limitRegional.setUpdate_time(DateUtil.now());
|
||||
limitRegionalMapper.updateById(limitRegional);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LimitRegionalDto selectByReging(String startRegion, String nextRegion) {
|
||||
for (LimitRegional limitRegional : dataList) {
|
||||
if (startRegion.equals(limitRegional.getStart_regional()) && nextRegion.equals(limitRegional.getNext_regional())){
|
||||
return ConvertUtil.convert(limitRegional, LimitRegionalDto.class);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.nl.acs.limit_regional.server.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.nl.acs.common.base.CommonMapper;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.limit_regional.domain.LimitRegional;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface LimitRegionalMapper extends CommonMapper<LimitRegional> {
|
||||
|
||||
}
|
||||
@@ -235,7 +235,6 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
|
||||
if (log.isWarnEnabled()) {
|
||||
log.warn("{} 所有内容都为空, all_null:{} ,暂定{}s", tag, all_null, 5000 + random);
|
||||
}
|
||||
|
||||
ThreadUtl.sleep((long) (5000 + random));
|
||||
} else if (this.all_null < 6) {
|
||||
if (log.isWarnEnabled()) {
|
||||
|
||||
@@ -13,7 +13,7 @@ public class OpcServerManageDto {
|
||||
private String password;
|
||||
private String prog_id;
|
||||
private String cls_id;
|
||||
private String domain;
|
||||
private String domain = "";
|
||||
|
||||
public String getOpc_code() {
|
||||
return this.opc_code;
|
||||
|
||||
@@ -17,6 +17,7 @@ package org.nl.config.thread;
|
||||
|
||||
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
@@ -29,6 +30,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
public class ThreadPoolExecutorUtil {
|
||||
|
||||
|
||||
public static ThreadPoolExecutor getPoll(){
|
||||
AsyncTaskProperties properties = SpringContextHolder.getBean(AsyncTaskProperties.class);
|
||||
return new ThreadPoolExecutor(
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.util.List;
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@Order(100)
|
||||
@ConditionalOnProperty(value = "spring.profiles.active",havingValue = "prod")
|
||||
@ConditionalOnProperty(value = "spring.profiles.active",havingValue = "dev")
|
||||
public class JobRunner implements ApplicationRunner {
|
||||
private static final Logger log = LoggerFactory.getLogger(JobRunner.class);
|
||||
private final ISysQuartzJobService quartzJobService;
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
package org.nl.system.service.quartz.task;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.nl.acs.common.base.CommonFinalParam;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.instruction.domain.InstructionMybatis;
|
||||
import org.nl.acs.instruction.enums.InstructionStatusEnum;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.instruction.domain.Instruction;
|
||||
import org.nl.acs.limit_regional.server.LimitRegionalService;
|
||||
import org.nl.acs.limit_regional.server.dto.LimitRegionalDto;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.opc.DeviceAppServiceImpl;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
@@ -38,6 +45,7 @@ public class AutoCreateInst {
|
||||
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
|
||||
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
|
||||
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||
LimitRegionalService limitRegionalService = SpringContextHolder.getBean(LimitRegionalService.class);
|
||||
List<TaskDto> list = taskserver.queryAllByStatus("0");
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
TaskDto acsTask = list.get(i);
|
||||
@@ -173,6 +181,81 @@ public class AutoCreateInst {
|
||||
} else {
|
||||
instdto.setAgv_inst_type("4");
|
||||
}
|
||||
Device startdevice = appService.findDeviceByCode(start_device_code);
|
||||
Device nextdevice = appService.findDeviceByCode(next_device_code);
|
||||
String startRegion = startdevice.getRegion();
|
||||
String nextRegion = nextdevice.getRegion();
|
||||
int count = 0;
|
||||
boolean startRegionalExit = true;
|
||||
boolean nextRegionalExit = true;
|
||||
//控制指令生成
|
||||
LimitRegionalDto limitRegionalDtos = limitRegionalService.selectByReging(startRegion, nextRegion);
|
||||
if (ObjectUtil.isNotEmpty(limitRegionalDtos)) {
|
||||
String next_exclude_device = limitRegionalDtos.getNext_exclude_device();
|
||||
if (StrUtil.isNotEmpty(next_exclude_device)) {
|
||||
String content = next_exclude_device.substring(1, next_exclude_device.length() - 1);
|
||||
boolean contains = content.contains(",");
|
||||
String[] array = contains ? content.split(",") : new String[]{content};
|
||||
List<String> list1 = Arrays.asList(array);
|
||||
for (String s : list1) {
|
||||
if (s.equals(next_device_code)) {
|
||||
nextRegionalExit = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
String start_exclude_device = limitRegionalDtos.getStart_exclude_device();
|
||||
if (StrUtil.isNotEmpty(start_exclude_device)) {
|
||||
String content = start_exclude_device.substring(1, start_exclude_device.length() - 1);
|
||||
boolean contains = content.contains(",");
|
||||
String[] array = contains ? content.split(",") : new String[]{content};
|
||||
List<String> list1 = Arrays.asList(array);
|
||||
for (String s : list1) {
|
||||
if (s.equals(start_device_code)) {
|
||||
startRegionalExit = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(limitRegionalDtos) && (startRegionalExit || nextRegionalExit)) {
|
||||
List<InstructionMybatis> instructionMybatis = instructionService.list(Wrappers.lambdaQuery(InstructionMybatis.class).le(InstructionMybatis::getInstruction_status, 1));
|
||||
for (InstructionMybatis instructionMybati : instructionMybatis) {
|
||||
Device startDevice = appService.findDeviceByCode(instructionMybati.getStart_device_code());
|
||||
Device nextDevice = appService.findDeviceByCode(instructionMybati.getNext_device_code());
|
||||
if ((StrUtil.isNotEmpty(startDevice.getRegion()) ? startDevice.getRegion() : "0").equals(startRegion) && (StrUtil.isNotEmpty(nextDevice.getRegion()) ? nextDevice.getRegion() : "0").equals(nextRegion)) {
|
||||
String start_exclude_device = limitRegionalDtos.getStart_exclude_device();
|
||||
if (StrUtil.isNotEmpty(start_exclude_device)) {
|
||||
String content = start_exclude_device.substring(1, start_exclude_device.length() - 1);
|
||||
boolean contains = content.contains(",");
|
||||
String[] array = contains ? content.split(",") : new String[]{content};
|
||||
List<String> list1 = Arrays.asList(array);
|
||||
for (String s : list1) {
|
||||
if (s.equals(instructionMybati.getStart_device_code())) {
|
||||
startRegionalExit = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
String next_exclude_device = limitRegionalDtos.getNext_exclude_device();
|
||||
if (StrUtil.isNotEmpty(next_exclude_device)) {
|
||||
String content = next_exclude_device.substring(1, next_exclude_device.length() - 1);
|
||||
boolean contains = content.contains(",");
|
||||
String[] array = contains ? content.split(",") : new String[]{content};
|
||||
List<String> list2 = Arrays.asList(array);
|
||||
for (String s : list2) {
|
||||
if (s.equals(instructionMybati.getNext_device_code())) {
|
||||
nextRegionalExit = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (startRegionalExit || nextRegionalExit) {
|
||||
++count;
|
||||
}
|
||||
if (count >= Integer.parseInt(limitRegionalDtos.getMax_num())) {
|
||||
log.info("同区域指令数量过多,等待指令完成再此创建");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
instructionService.create(instdto);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -38,9 +38,11 @@ public class ExecutionJob extends TLogQuartzJobBean {
|
||||
/**
|
||||
* 该处仅供参考
|
||||
*/
|
||||
@Autowired
|
||||
/* @Autowired
|
||||
@Qualifier("threadPoolExecutor")
|
||||
private ThreadPoolExecutor EXECUTOR;
|
||||
private ThreadPoolExecutor EXECUTOR;*/
|
||||
|
||||
private final static ThreadPoolExecutor EXECUTOR = ThreadPoolExecutorUtil.getPoll();
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user