Browse Source

浙大接口测试

master
周俊杰 1 year ago
parent
commit
0a91f92a3b
  1. 13
      acs/nladmin-system/src/main/java/org/nl/acs/agv/server/ZheDaAgvService.java
  2. 9
      acs/nladmin-system/src/main/java/org/nl/acs/agv/server/dto/AgvDto.java
  3. 376
      acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/ZheDaAgvServiceImpl.java
  4. 6
      acs/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java
  5. 107
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/lubei_conveyor/ItemProtocol.java
  6. 59
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/lubei_conveyor/LubeiConveyorDefination.java
  7. 442
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/lubei_conveyor/LubeiConveyorDeviceDriver.java
  8. 9
      acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsZDController.java
  9. 2
      acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsZDToAcsController.java
  10. 11
      acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsZDService.java
  11. 1
      acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToLiKuServiceImpl.java
  12. 114
      acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsZDServiceImpl.java
  13. 8
      acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java
  14. 17
      acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java
  15. 52
      acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/DeviceStatusUpdate.java
  16. 98
      acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryZDAgvTaskStatus.java
  17. 1
      acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/ToAgvDevice.java
  18. 1
      acs/nladmin-system/src/main/java/org/nl/modules/wql/util/SpringContextHolder.java
  19. 4
      acs/nladmin-ui/src/views/acs/device/config.vue

13
acs/nladmin-system/src/main/java/org/nl/acs/agv/server/ZheDaAgvService.java

@ -19,14 +19,17 @@ public interface ZheDaAgvService {
/**
* 查询AGV状态
* 永裕家居项目:共两楼
*
* @param floor 1二楼AGV系统2一楼AGV系统
* @return
*/
public HttpResponse queryAgvInstStatus(String floor);
HttpResponse queryAgvInstStatus();
/**
* 查询AGV设备状态
* @return
*/
HttpResponse queryZDAgvDeviceStatus();
String process(String jobno, String type, String address, String action, String processingVehicle);
String process(String jobno, String type, String address, String action, String processingVehicle,String feedbackStatus);
public HttpResponse markComplete(String code);

9
acs/nladmin-system/src/main/java/org/nl/acs/agv/server/dto/AgvDto.java

@ -73,5 +73,14 @@ public class AgvDto implements Serializable {
* 当前任务号
*/
private String transportOrder;
/**
* 状态码
*/
private Integer status;
/**
* 状态描述
*/
private String statusDescription;
}

376
acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/ZheDaAgvServiceImpl.java

@ -10,12 +10,16 @@ import lombok.extern.slf4j.Slf4j;
import org.nl.acs.AcsConfig;
import org.nl.acs.agv.AgvUtil;
import org.nl.acs.agv.server.ZheDaAgvService;
import org.nl.acs.agv.server.dto.AgvDto;
import org.nl.acs.device_driver.basedriver.cargo_lift_conveyor.CargoLiftConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.empty_vehicle_stacking_position.EmptyVehicleStackingPositionDeviceDriver;
import org.nl.acs.device_driver.basedriver.hailiang_smart_plc_test.HailiangSmartplcTestDeviceDriver;
import org.nl.acs.device_driver.basedriver.hongxiang_device.HongXiangConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.lubei_conveyor.LubeiConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.paint_conveyor.PaintConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.AcsToWmsZDService;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.log.LokiLog;
@ -25,14 +29,23 @@ import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.opc.DeviceAppServiceImpl;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.config.server.AcsConfigService;
import org.nl.modules.system.service.ParamService;
import org.nl.modules.wql.util.SpringContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
@Slf4j
@Service
@RequiredArgsConstructor
public class ZheDaAgvServiceImpl implements ZheDaAgvService {
@Autowired
AcsConfigService acsConfigService;
Map<String, AgvDto> AGVDeviceStatus = new HashMap();
private final ParamService paramService;
@LokiLog(type = LokiLogType.AGV)
@Override
@ -73,13 +86,7 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
String agvport2 = paramService.findByCode(AcsConfig.AGVPORT2).getValue();
//不同楼层下发不同的agv系统
if (task_type.equals("1")) {
agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + inst.getInstruction_code();
} else {
agvurl = agvurl2 + ":" + agvport2 + "/v1/transportOrders/" + inst.getInstruction_code();
}
log.info("下发agv任务请求:{}", agvurl);
HttpResponse result = HttpRequest.post(agvurl)
@ -96,20 +103,28 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
@LokiLog(type = LokiLogType.AGV)
@Override
//ZDAGV
public HttpResponse queryAgvInstStatus(String type) {
public HttpResponse queryAgvInstStatus() {
if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) {
String agvurl = "";
String agvport = "";
if (type.equals("1")) {
agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
agvurl = agvurl + ":" + agvport + "/v1/vehicles";
HttpResponse result = HttpRequest.get(agvurl)
.timeout(20000)//超时,毫秒
.execute();
System.out.println("查询agv指令数据:" + result.body());
return result;
} else {
return null;
}
if (type.equals("2")) {
agvurl = paramService.findByCode(AcsConfig.AGVURL2).getValue();
agvport = paramService.findByCode(AcsConfig.AGVPORT2).getValue();
}
agvurl = agvurl + ":" + agvport + "/v1/transportOrders";
@Override
public HttpResponse queryZDAgvDeviceStatus() {
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 + "/v1/vehicles";
HttpResponse result = HttpRequest.get(agvurl)
.timeout(20000)//超时,毫秒
.execute();
@ -120,11 +135,13 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
return null;
}
}
@LokiLog(type = LokiLogType.AGV)
@Override
//ZDAGV
public synchronized String process(String jobno, String type, String address, String action, String processingVehicle) {
log.info("查询到AGV请求参数,jobno:{},address:{}", jobno + ",address:" + address + ",type:" + type + ",action:" + action);
public synchronized String process(String jobno, String type, String address, String action, String processingVehicle,String feedbackStatus)
{
{
log.info("查询到AGV请求参数,jobno:{},address:{}", jobno + ",address:" + address + ",type:" + type + ",action:" + action+",feedbackStatus:"+feedbackStatus);
//释放AGV资源,继续后续动作
boolean is_feedback = false;
String str = "";
@ -137,7 +154,8 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
}
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
TaskService taskService = SpringContextHolder.getBean("taskServiceImpl");
AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl");
// AcsToWmsService acsToWmsService=SpringContextHolder.getBean("acsToWmsServiceImpl");
AcsToWmsZDService acsToWmsZDService = SpringContextHolder.getBean("acsToWmsZDServiceImpl");
Instruction inst = instructionService.findByCodeFromCache(jobno);
TaskDto task = taskService.findByCode(inst.getTask_code());
@ -145,248 +163,158 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
Device addressdevice = appService.findDeviceByCode(address);
CargoLiftConveyorDeviceDriver cargoLiftConveyorDeviceDriver;
EmptyVehicleStackingPositionDeviceDriver emptyVehicleStackingPositionDeviceDriver;
HailiangSmartplcTestDeviceDriver hailiangSmartplcTestDeviceDriver;
HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver;
PaintConveyorDeviceDriver paintConveyorDeviceDriver;
LubeiConveyorDeviceDriver lubeiConveyorDeviceDriver;
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
//取货的进入前等待和离开等待
if (action.equals("Load")) {
if ("EntryRequired".equals(type)) {
//共挤线三工位
if (addressdevice.getDeviceDriver() instanceof HailiangSmartplcTestDeviceDriver) {
hailiangSmartplcTestDeviceDriver = (HailiangSmartplcTestDeviceDriver) addressdevice.getDeviceDriver();
if ((hailiangSmartplcTestDeviceDriver.getAction() == 1 || hailiangSmartplcTestDeviceDriver.getAction() == 3) && hailiangSmartplcTestDeviceDriver.getMove() == 1) {
inst.setExecute_status("1");
is_feedback = true;
}
}
//叠盘位
if (addressdevice.getDeviceDriver() instanceof EmptyVehicleStackingPositionDeviceDriver) {
emptyVehicleStackingPositionDeviceDriver = (EmptyVehicleStackingPositionDeviceDriver) addressdevice.getDeviceDriver();
int number = emptyVehicleStackingPositionDeviceDriver.getNumber();
if (number < Integer.valueOf(str)) {
log.info("叠盘位:" + jobno + "当前层高为:" + number + ",不存在第" + str + "的托盘!");
return null;
}
inst.setExecute_status("1");
is_feedback = true;
}
//货梯对接线
if (addressdevice.getDeviceDriver() instanceof CargoLiftConveyorDeviceDriver) {
cargoLiftConveyorDeviceDriver = (CargoLiftConveyorDeviceDriver) addressdevice.getDeviceDriver();
if ((cargoLiftConveyorDeviceDriver.getAction() == 1 || cargoLiftConveyorDeviceDriver.getAction() == 3) && cargoLiftConveyorDeviceDriver.getMove() == 1) {
inst.setExecute_status("1");
//
if (addressdevice.getDeviceDriver() instanceof LubeiConveyorDeviceDriver) {
lubeiConveyorDeviceDriver = (LubeiConveyorDeviceDriver) addressdevice.getDeviceDriver();
if(lubeiConveyorDeviceDriver.getMove()==1 && lubeiConveyorDeviceDriver.getAction()==1){
JSONObject jo = new JSONObject();
jo.put("taskCode",task.getTask_code());
jo.put("carId",processingVehicle);
jo.put("taskType ",type);
jo.put("feedbackStatus",feedbackStatus);
HttpResponse result= acsToWmsZDService.taskFeedback(jo);
JSONObject response=JSONObject.parseObject(result.body());
int responseCode= response.getInteger("responseCode");
if(responseCode == 0) {
is_feedback = true;
log.info("请求ZDwcs成功,申请取货 请求结果{}",responseCode);
}
}
//豪凯自动线对接位
if (addressdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) addressdevice.getDeviceDriver();
if ((hongXiangConveyorDeviceDriver.getAction() == 1 || hongXiangConveyorDeviceDriver.getAction() == 3) && hongXiangConveyorDeviceDriver.getMove() == 1) {
inst.setExecute_status("1");
is_feedback = true;
} else {
log.info("设备{} 请求取货,光电信号:{}",addressdevice,lubeiConveyorDeviceDriver.getMove());
}
}
//油漆线
if (addressdevice.getDeviceDriver() instanceof PaintConveyorDeviceDriver) {
paintConveyorDeviceDriver = (PaintConveyorDeviceDriver) addressdevice.getDeviceDriver();
if ((paintConveyorDeviceDriver.getAction() == 1 || paintConveyorDeviceDriver.getAction() == 3) && paintConveyorDeviceDriver.getMove() == 1) {
inst.setExecute_status("1");
if (addressdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
JSONObject jo = new JSONObject();
jo.put("taskCode",task.getTask_code());
jo.put("carId",processingVehicle);
jo.put("taskType ",type);
jo.put("feedbackStatus",feedbackStatus);
HttpResponse result= acsToWmsZDService.taskFeedback(jo);
JSONObject response=JSONObject.parseObject(result.body());
int responseCode= response.getInteger("responseCode");
if(responseCode == 0) {
is_feedback = true;
log.info("请求ZDwcs成功,申请取货 请求结果{}",responseCode);
}
}
}
if ("PauseOnStation".equals(type)) {
if (addressdevice.getDeviceDriver() instanceof HailiangSmartplcTestDeviceDriver) {
hailiangSmartplcTestDeviceDriver = (HailiangSmartplcTestDeviceDriver) addressdevice.getDeviceDriver();
inst.setExecute_status("2");
hailiangSmartplcTestDeviceDriver.writing(2);
is_feedback = true;
}
if (addressdevice.getDeviceDriver() instanceof EmptyVehicleStackingPositionDeviceDriver) {
emptyVehicleStackingPositionDeviceDriver = (EmptyVehicleStackingPositionDeviceDriver) addressdevice.getDeviceDriver();
inst.setExecute_status("2");
emptyVehicleStackingPositionDeviceDriver.writing(2);
if (addressdevice.getDeviceDriver() instanceof LubeiConveyorDeviceDriver) {
lubeiConveyorDeviceDriver = (LubeiConveyorDeviceDriver) addressdevice.getDeviceDriver();
if(lubeiConveyorDeviceDriver.getMove()==0){
JSONObject jo = new JSONObject();
jo.put("taskCode",task.getTask_code());
jo.put("carId",processingVehicle);
jo.put("taskType ",type);
jo.put("feedbackStatus",feedbackStatus);
HttpResponse result= acsToWmsZDService.taskFeedback(jo);
JSONObject response=JSONObject.parseObject(result.body());
int responseCode= response.getInteger("responseCode");
if(responseCode == 0) {
is_feedback = true;
log.info("请求ZDwcs成功,取货完成 请求结果{}",responseCode);
}
if (addressdevice.getDeviceDriver() instanceof CargoLiftConveyorDeviceDriver) {
cargoLiftConveyorDeviceDriver = (CargoLiftConveyorDeviceDriver) addressdevice.getDeviceDriver();
inst.setExecute_status("2");
cargoLiftConveyorDeviceDriver.writing(2);
is_feedback = true;
} else {
log.info("设备{} 请求离开,光电信号:{}",addressdevice,lubeiConveyorDeviceDriver.getMove());
}
if (addressdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) addressdevice.getDeviceDriver();
inst.setExecute_status("2");
hongXiangConveyorDeviceDriver.writing(2);
is_feedback = true;
}
if (addressdevice.getDeviceDriver() instanceof PaintConveyorDeviceDriver) {
paintConveyorDeviceDriver = (PaintConveyorDeviceDriver) addressdevice.getDeviceDriver();
inst.setExecute_status("2");
paintConveyorDeviceDriver.writing(2);
if (addressdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
JSONObject jo = new JSONObject();
jo.put("taskCode",task.getTask_code());
jo.put("carId",processingVehicle);
jo.put("taskType ",type);
jo.put("feedbackStatus",feedbackStatus);
HttpResponse result= acsToWmsZDService.taskFeedback(jo);
JSONObject response=JSONObject.parseObject(result.body());
int responseCode= response.getInteger("responseCode");
if(responseCode == 0) {
is_feedback = true;
log.info("请求ZDwcs成功,取货完成 请求结果{}",responseCode);
}
}
}
//等待点等待
if (action.equals("Wait")) {
if ("Wait".equals(type)) {
JSONObject jo = new JSONObject();
jo.put("task_code", inst.getInstruction_code());
JSONArray destinations = new JSONArray();
String inst_type = inst.getInstruction_type();
//如果任务类型为1,在点位进行等待,则查询当前叠盘位的数量,取当前数量的层数进行追加任务
// if ("1".equals(inst_type)) {
// emptyVehicleStackingPositionDeviceDriver = (EmptyVehicleStackingPositionDeviceDriver) addressdevice.getDeviceDriver();
// int current_num = emptyVehicleStackingPositionDeviceDriver.getNumber();
// if (current_num > 12) {
// log.info("当前叠盘架:" + jobno + "已放满!");
// return null;
// }
// String start_point_code = inst.getStart_point_code();
// String next_point_code = inst.getNext_point_code();
// start_point_code = start_point_code + "." + (current_num + 1);
// destinations.add(destination(start_point_code, "Load", "1", "1"));
// destinations.add(destination(next_point_code, "Unload", "1", "1"));
//
// }
String resp = acsToWmsService.requestTaskAgain(address,task.getExt_task_id(),inst.getVehicle_code());
JSONObject respjson = JSONObject.parseObject(resp);
if(StrUtil.equals(inst.getInstruction_type(),"3")){
//2楼AGV起点追加任务
String start_device_code = respjson.getString("device_code");
String next_device_code = inst.getNext_device_code();
destinations.add(destination(start_device_code, "load", "1", "1"));
destinations.add(destination(next_device_code, "Unload", "1", "1"));
} else if(StrUtil.equals(inst.getInstruction_type(),"4")){
//2楼AGV终点追加任务
String next_device_code = respjson.getString("device_code");
destinations.add(destination(next_device_code, "Unload", "1", "1"));
}
jo.put("destinations", destinations);
String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
String url = agvurl + ":" + agvport + "/addDestinations";
log.info("下发agv任务请求:{}", url);
HttpResponse result = HttpRequest.post(url)
.body(String.valueOf(jo))//表单内容
.timeout(20000)//超时,毫秒
.execute();
log.info("下发agv任务请求反馈:{}", result);
//对任务进行封口
JSONObject complete = new JSONObject();
complete.put("task_code", inst.getInstruction_code());
String url2 = agvurl + ":" + agvport + "markComplete";
log.info("下发agv任务请求:{}", url2);
HttpResponse result2 = HttpRequest.post(url2)
.body(String.valueOf(complete))//表单内容
.timeout(20000)//超时,毫秒
.execute();
log.info("下发agv任务请求反馈:{}", result2);
}
}
//放货的进入前等待和离开等待
if (action.equals("Unload")) {
if ("EntryRequired".equals(type)) {
if (addressdevice.getDeviceDriver() instanceof HailiangSmartplcTestDeviceDriver) {
hailiangSmartplcTestDeviceDriver = (HailiangSmartplcTestDeviceDriver) addressdevice.getDeviceDriver();
if ((hailiangSmartplcTestDeviceDriver.getAction() == 2 || hailiangSmartplcTestDeviceDriver.getAction() == 3) && hailiangSmartplcTestDeviceDriver.getMove() == 0) {
inst.setExecute_status("3");
is_feedback = true;
}
}
if (addressdevice.getDeviceDriver() instanceof EmptyVehicleStackingPositionDeviceDriver) {
emptyVehicleStackingPositionDeviceDriver = (EmptyVehicleStackingPositionDeviceDriver) addressdevice.getDeviceDriver();
int number = emptyVehicleStackingPositionDeviceDriver.getNumber();
if (number >= Integer.valueOf(str)) {
log.info("叠盘位:" + jobno + "第" + str + "上有货!");
return null;
}
inst.setExecute_status("3");
is_feedback = true;
}
if (addressdevice.getDeviceDriver() instanceof CargoLiftConveyorDeviceDriver) {
cargoLiftConveyorDeviceDriver = (CargoLiftConveyorDeviceDriver) addressdevice.getDeviceDriver();
if ((cargoLiftConveyorDeviceDriver.getAction() == 2 || cargoLiftConveyorDeviceDriver.getAction() == 3) && cargoLiftConveyorDeviceDriver.getMove() == 0) {
inst.setExecute_status("3");
if (addressdevice.getDeviceDriver() instanceof LubeiConveyorDeviceDriver) {
lubeiConveyorDeviceDriver = (LubeiConveyorDeviceDriver) addressdevice.getDeviceDriver();
if(lubeiConveyorDeviceDriver.getMove()==0 && lubeiConveyorDeviceDriver.getAction()==1){
JSONObject jo = new JSONObject();
jo.put("taskCode",task.getTask_code());
jo.put("carId",processingVehicle);
jo.put("taskType ",type);
jo.put("feedbackStatus",feedbackStatus);
HttpResponse result= acsToWmsZDService.taskFeedback(jo);
JSONObject response=JSONObject.parseObject(result.body());
int responseCode= response.getInteger("responseCode");
if(responseCode == 0) {
is_feedback = true;
log.info("请求ZDwcs成功,开始放货 请求结果{}",responseCode);
}
}
if (addressdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) addressdevice.getDeviceDriver();
if ((hongXiangConveyorDeviceDriver.getAction() == 2 || hongXiangConveyorDeviceDriver.getAction() == 3) && hongXiangConveyorDeviceDriver.getMove() == 0) {
inst.setExecute_status("3");
is_feedback = true;
} else {
log.info("设备{} 请求放货,光电信号:{}",addressdevice,lubeiConveyorDeviceDriver.getMove());
}
}
if (addressdevice.getDeviceDriver() instanceof PaintConveyorDeviceDriver) {
paintConveyorDeviceDriver = (PaintConveyorDeviceDriver) addressdevice.getDeviceDriver();
if ((paintConveyorDeviceDriver.getAction() == 2 || paintConveyorDeviceDriver.getAction() == 3) && paintConveyorDeviceDriver.getMove() == 0) {
inst.setExecute_status("3");
if (addressdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
JSONObject jo = new JSONObject();
jo.put("taskCode",task.getTask_code());
jo.put("carId",processingVehicle);
jo.put("taskType ",type);
jo.put("feedbackStatus",feedbackStatus);
HttpResponse result= acsToWmsZDService.taskFeedback(jo);
JSONObject response=JSONObject.parseObject(result.body());
int responseCode= response.getInteger("responseCode");
if(responseCode == 0) {
is_feedback = true;
log.info("请求ZDwcs成功,开始放货 请求结果{}",responseCode);
}
}
}
if ("PauseOnStation".equals(type)) {
if (addressdevice.getDeviceDriver() instanceof HailiangSmartplcTestDeviceDriver) {
hailiangSmartplcTestDeviceDriver = (HailiangSmartplcTestDeviceDriver) addressdevice.getDeviceDriver();
inst.setExecute_status("4");
hailiangSmartplcTestDeviceDriver.writing(3);
if (addressdevice.getDeviceDriver() instanceof LubeiConveyorDeviceDriver) {
lubeiConveyorDeviceDriver = (LubeiConveyorDeviceDriver) addressdevice.getDeviceDriver();
if(lubeiConveyorDeviceDriver.getMove()==1){
JSONObject jo = new JSONObject();
jo.put("taskCode",task.getTask_code());
jo.put("carId",processingVehicle);
jo.put("taskType ",type);
jo.put("feedbackStatus",feedbackStatus);
HttpResponse result= acsToWmsZDService.taskFeedback(jo);
JSONObject response=JSONObject.parseObject(result.body());
int responseCode= response.getInteger("responseCode");
if(responseCode == 0) {
is_feedback = true;
log.info("请求ZDwcs成功,放货完成 请求结果{}",responseCode);
}
if (addressdevice.getDeviceDriver() instanceof EmptyVehicleStackingPositionDeviceDriver) {
emptyVehicleStackingPositionDeviceDriver = (EmptyVehicleStackingPositionDeviceDriver) addressdevice.getDeviceDriver();
inst.setExecute_status("4");
emptyVehicleStackingPositionDeviceDriver.writing(3);
is_feedback = true;
} else {
log.info("设备{} 请求离开,光电信号:{}",addressdevice,lubeiConveyorDeviceDriver.getMove());
}
if (addressdevice.getDeviceDriver() instanceof CargoLiftConveyorDeviceDriver) {
cargoLiftConveyorDeviceDriver = (CargoLiftConveyorDeviceDriver) addressdevice.getDeviceDriver();
inst.setExecute_status("4");
cargoLiftConveyorDeviceDriver.writing(3);
is_feedback = true;
}
if (addressdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) addressdevice.getDeviceDriver();
inst.setExecute_status("4");
hongXiangConveyorDeviceDriver.writing(3);
if (addressdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
JSONObject jo = new JSONObject();
jo.put("taskCode",task.getTask_code());
jo.put("carId",processingVehicle);
jo.put("taskType ",type);
jo.put("feedbackStatus",feedbackStatus);
HttpResponse result= acsToWmsZDService.taskFeedback(jo);
JSONObject response=JSONObject.parseObject(result.body());
int responseCode= response.getInteger("responseCode");
if(responseCode == 0) {
is_feedback = true;
log.info("请求ZDwcs成功,放货完成 请求结果{}",responseCode);
}
if (addressdevice.getDeviceDriver() instanceof PaintConveyorDeviceDriver) {
paintConveyorDeviceDriver = (PaintConveyorDeviceDriver) addressdevice.getDeviceDriver();
inst.setExecute_status("4");
paintConveyorDeviceDriver.writing(3);
is_feedback = true;
}
}
}
JSONObject requestjo = new JSONObject();
com.alibaba.fastjson.JSONObject requestjo = new com.alibaba.fastjson.JSONObject();
if (is_feedback) {
requestjo.put("task_code", jobno);
requestjo.put("operation", action);
@ -398,13 +326,12 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
log.info("反馈AGV请求数据:{}", requestjo);
System.out.println("back agv:" + requestjo);
String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
if (inst.getInstruction_type().equals("4")) {
agvurl = paramService.findByCode(AcsConfig.AGVURL2).getValue();
}
agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + jobno + "/interact";
String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL);
String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT);
agvurl = agvurl + ":" + agvport + "/api/route/transportOrders/" + jobno + "/interact";
HttpResponse result = HttpRequest.post(agvurl)
.body(String.valueOf(requestjo))
@ -414,6 +341,7 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
return requestjo.toString();
}
}
@LokiLog(type = LokiLogType.AGV)
@Override
public HttpResponse markComplete(String code) {

6
acs/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java

@ -21,7 +21,9 @@ public enum DriverTypeEnum {
//
// INSPECT_CONVEYOR_MONITOR(6, "standard_conveyor_monitor", "标准版-输送机-监控点", "conveyor"),
AGV_NDC_ONE(7, "agv_ndc_one", "NDCAGV", "agv");
AGV_NDC_ONE(7, "agv_ndc_one", "NDCAGV", "agv"),
LUBEI_CONVEYOR(18,"lubei_conveyor","输送线","conveyor");
// AGV_NDC_TWO(8, "agv_ndc_two", "NDC2楼AGV", "agv"),
@ -46,6 +48,8 @@ public enum DriverTypeEnum {
// SIEMENS_CONVEYOR_CKK(17, "siemens_conveyor_ckk", "西门子-输送机驱动-出库口", "conveyor");
//驱动索引
private int index;
//驱动编码

107
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/lubei_conveyor/ItemProtocol.java

@ -0,0 +1,107 @@
package org.nl.acs.device_driver.basedriver.lubei_conveyor;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@Data
public class ItemProtocol {
public static String item_heartbeat = "heartbeat";
public static String item_mode = "mode";
public static String item_move = "move";
public static String item_action = "action";
public static String item_error = "error";
public static String item_task = "task";
public static String item_to_command = "to_command";
public static String item_to_target = "to_target";
public static String item_to_task = "to_task";
public static String item_weight = "weight";
private LubeiConveyorDeviceDriver driver;
public ItemProtocol(LubeiConveyorDeviceDriver driver) {
this.driver = driver;
}
public int getHeartbeat() {
return this.getOpcIntegerValue(item_heartbeat);
}
public int getMode() {
return this.getOpcIntegerValue(item_mode);
}
public int getMove() {
return this.getOpcIntegerValue(item_move);
}
public int getaction() {
return this.getOpcIntegerValue(item_action);
}
public int getError() {
return this.getOpcIntegerValue(item_error);
}
public int getTask() {
return this.getOpcIntegerValue(item_task);
}
public int getToCommand() {
return this.getOpcIntegerValue(item_to_command);
}
public int getToTarget() {
return this.getOpcIntegerValue(item_to_target);
}
public int getToTask() {
return this.getOpcIntegerValue(item_to_task);
}
//是否有货
public int hasGoods(int move) {
return move;
}
Boolean isonline;
public int getOpcIntegerValue(String protocol) {
Integer value = this.driver.getIntegeregerValue(protocol);
if (value == null) {
// log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!");
setIsonline(false);
} else {
setIsonline(true);
return value;
}
return 0;
}
public static List<ItemDto> getReadableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_heartbeat, "心跳", "DB600.B0"));
list.add(new ItemDto(item_mode, "工作状态", "DB600.B2", Boolean.valueOf(true)));
list.add(new ItemDto(item_move, "光电开关信号", "DB600.B3"));
list.add(new ItemDto(item_action, "取放开关信号", "DB600.B4"));
list.add(new ItemDto(item_error, "报警信号", "DB600.B5"));
return list;
}
public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_to_command, "作业命令", "DB601.B2", Boolean.valueOf(true)));
return list;
}
@Override
public String toString() {
return "";
}
}

59
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/lubei_conveyor/LubeiConveyorDefination.java

@ -0,0 +1,59 @@
package org.nl.acs.device_driver.basedriver.lubei_conveyor;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceType;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
@Service
public class LubeiConveyorDefination implements OpcDeviceDriverDefination {
@Override
public String getDriverCode() {
return "lubei_conveyor";
}
@Override
public String getDriverName() {
return "输送线";
}
@Override
public String getDriverDescription() {
return "输送线";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
return (new LubeiConveyorDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class<? extends DeviceDriver> getDeviceDriverType() {
return LubeiConveyorDeviceDriver.class;
}
@Override
public List<DeviceType> getFitDeviceTypes() {
List<DeviceType> types = new LinkedList();
types.add(DeviceType.conveyor);
return types;
}
@Override
public List<ItemDto> getReadableItemDtos() {
return ItemProtocol.getReadableItemDtos();
}
@Override
public List<ItemDto> getWriteableItemDtos() {
return ItemProtocol.getWriteableItemDtos();
}
}

442
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/lubei_conveyor/LubeiConveyorDeviceDriver.java

@ -0,0 +1,442 @@
package org.nl.acs.device_driver.basedriver.lubei_conveyor;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.agv.server.AgvService;
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.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver;
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.AcsToWmsZDService;
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.monitor.DeviceStageMonitor;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.opc.DeviceAppServiceImpl;
import org.nl.acs.opc.WcsConfig;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.route.service.dto.RouteLineDto;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.modules.system.service.ParamService;
import org.nl.modules.system.util.CodeUtil;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.util.SpringContextHolder;
import org.openscada.opc.lib.da.Server;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@Data
@RequiredArgsConstructor
public class LubeiConveyorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
// protected org.nl.acs.device_driver.basedriver.lubei_conveyor.ItemProtocol itemProtocol = new org.nl.acs.device_driver.basedriver.lubei_conveyor.ItemProtocol(this);
protected ItemProtocol itemProtocol = new ItemProtocol(this);
@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
AcsToWmsZDService acsToWmsZDService=SpringContextHolder.getBean(AcsToWmsZDService.class);
String container;
String container_type_desc;
String last_container_type_desc;
String last_container;
//放货准备锁
String putReadyLock = null;
//有货标记
protected boolean has_goods_tag = false;
int mode = 0;
int error = 0;
int move = 0;
int task = 0;
int action=0;
int last_mode = 0;
int last_error = 0;
int last_move = 0;
int last_task = 0;
int last_action=0;
Boolean isonline = true;
int hasGoods = 0;
String message = null;
Boolean iserror = false;
boolean hasVehicle = false;
boolean isReady = false;
protected int instruction_num = 0;
protected int instruction_num_truth = 0;
boolean isFold = false;
private String assemble_check_tag;
protected String current_stage_instruction_message;
protected String last_stage_instruction_message;
Integer heartbeat_tag;
private Date instruction_require_time = new Date();
private Date instruction_finished_time = new Date();
private int instruction_require_time_out;
boolean requireSucess = false;
private int instruction_finished_time_out;
int branchProtocol = 0;
//备注
String remark;
//数量
String qty;
//物料
String material;
//批次
String batch;
//当前指令
Instruction inst = null;
//上次指令
Instruction last_inst = null;
//触摸屏手动触发任务
private Boolean is_has_task = false;
//申请搬运任务
private Boolean apply_handling = false;
//申请物料
private Boolean apply_material = false;
//暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
int flag;
String devicecode;
@Override
public Device getDevice() {
return this.device;
}
@Override
public void execute() {
String message = null;
try {
String device_code = this.getDeviceCode();
mode = this.itemProtocol.getMode();
error = this.itemProtocol.getError();
move = this.itemProtocol.getMove();
task = this.itemProtocol.getTask();
hasGoods = this.itemProtocol.getMove();
action =this.itemProtocol.getaction();
if (mode != last_mode) {
this.setRequireSucess(false);
}
if (move != last_move) {
}
if (error != last_error) {
}
if (this.getApply_handling()) {
String link_device_code = this.getDevice().getExtraValue().get("link_device_code").toString();
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
Device link_device = appService.findDeviceByCode(link_device_code);
LubeiConveyorDeviceDriver lubeiConveyorDeviceDriver;
if (link_device.getDeviceDriver() instanceof LubeiConveyorDeviceDriver) {
lubeiConveyorDeviceDriver = (LubeiConveyorDeviceDriver) link_device.getDeviceDriver();
// if(standardInspectSiteDevicedriver.getMode() != 2){
// log.debug("设备未待机");
// return;
// }
// if(standardInspectSiteDevicedriver.getMove() != 0){
// log.debug("设备不满足放货条件");
// return;
// }
//如果目标设备申请叫料 则允许生成任务
if (lubeiConveyorDeviceDriver.getApply_material()) {
TaskDto dto = new TaskDto();
String now = DateUtil.now();
dto.setTask_id(IdUtil.simpleUUID());
dto.setCreate_by(this.getDevice().getDevice_code());
dto.setUpdate_by(this.getDevice().getDevice_code());
dto.setStart_point_code(this.getDevice().getDevice_code());
String taskcode = CodeUtil.getNewCode("TASK_NO");
dto.setTask_code("-" + taskcode);
dto.setTask_status("0");
dto.setPriority("101");
// RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code());
// String next_device_codecode = jo.getNext_device_code();
// if(StrUtil.isEmpty(next_device_codecode)){
// throw new RuntimeException("该设备未找到对应路由");
// }
dto.setNext_point_code(lubeiConveyorDeviceDriver.getDevicecode());
dto.setUpdate_time(now);
dto.setCreate_time(now);
WQLObject wo = WQLObject.getWQLObject("acs_task");
JSONObject json = (JSONObject) JSONObject.toJSON(dto);
wo.insert(json);
lubeiConveyorDeviceDriver.setApply_material(false);
}
}
this.setApply_handling(false);
}
} catch (Exception var17) {
return;
}
if (!this.itemProtocol.getIsonline()) {
this.setIsonline(false);
this.setIserror(true);
message = "信号量同步异常";
//未联机
} else if (mode == 0) {
this.setIsonline(false);
this.setIserror(true);
message = "未联机";
//有报警
} else if (error != 0) {
this.setIsonline(false);
this.setIserror(true);
message = "有报警";
//无报警
} else {
this.setIsonline(true);
this.setIserror(false);
message = "";
Instruction instruction = null;
List toInstructions;
switch (mode) {
case 1:
log.debug("设备运转模式:等待工作");
break;
case 2:
break;
}
switch (flag) {
//取货完成
case 1:
writing(2);
return;
//放货完成
case 2:
writing(3);
return;
}
}
last_mode = mode;
last_error = error;
last_move = move;
last_task = task;
}
public boolean exe_error() {
if (this.error == 0) {
return true;
} else {
log.debug("设备报警");
return false;
}
}
protected void thingToNothing() {
log.debug("从有货到无货 清理数据");
this.set_last_container(container, container_type_desc);
}
public void set_last_container(String barcode, String type_desc) {
this.set_last_container(barcode);
this.set_last_container_type_desc(type_desc);
}
public void set_last_container(String barcode) {
}
public void set_last_container_type_desc(String type) {
}
public boolean exe_business() {
return true;
}
protected void executing(Instruction instruction) {
this.executing(1, instruction, "");
}
public void executing(int command, Instruction instruction, String appendMessage) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + org.nl.acs.device_driver.basedriver.lubei_conveyor.ItemProtocol.item_to_command;
String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + org.nl.acs.device_driver.basedriver.lubei_conveyor.ItemProtocol.item_to_target;
String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + org.nl.acs.device_driver.basedriver.lubei_conveyor.ItemProtocol.item_to_task;
if (appendMessage == null) {
appendMessage = "";
}
if (instruction != null) {
instruction_num = Integer.parseInt(instruction.getInstruction_code());
}
//String opcservcerid = this.getDevice().getOpc_server_id();
//Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_command, 1);
itemMap.put(to_task, instruction_num);
this.control(itemMap);
}
public void executing(Server server, Map<String, Object> itemMap) {
this.control(itemMap);
}
public void writing(int command) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." +ItemProtocol.item_to_command;
//String opcservcerid = this.getDevice().getOpc_server_id();
//Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_command, command);
this.control(itemMap);
}
public void writing(int type, int command) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_command;
String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_target;
String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_task;
//String opcservcerid = this.getDevice().getOpc_server_id();
//Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>();
if (type == 1) {
itemMap.put(to_command, command);
} else if (type == 2) {
itemMap.put(to_target, command);
} else if (type == 3) {
itemMap.put(to_task, command);
}
this.control(itemMap);
}
public boolean instruction_require(String container_code) {
return instruction_require(container_code, WcsConfig.task_container_type_default_desc);
}
/**
* 请求指令
*
* @param container_code
* @param container_type
*/
public synchronized boolean instruction_require(String container_code, String container_type) {
Date date = new Date();
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return false;
} else {
this.instruction_require_time = date;
TaskDto dto = new TaskDto();
String now = DateUtil.now();
dto.setTask_id(IdUtil.simpleUUID());
dto.setCreate_by(this.getDevice().getDevice_code());
dto.setUpdate_by(this.getDevice().getDevice_code());
dto.setStart_point_code(this.getDevice().getDevice_code());
dto.setVehicle_code(container_code);
dto.setVehicle_type(container_type);
String taskcode = CodeUtil.getNewCode("TASK_NO");
dto.setTask_code("-" + taskcode);
dto.setTask_status("0");
dto.setPriority("101");
RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code());
String next_device_codecode = jo.getNext_device_code();
if (StrUtil.isEmpty(next_device_codecode)) {
throw new RuntimeException("该设备未找到对应路由");
}
dto.setNext_point_code(next_device_codecode);
dto.setUpdate_time(now);
dto.setCreate_time(now);
WQLObject wo = WQLObject.getWQLObject("acs_task");
JSONObject json = (JSONObject) JSONObject.toJSON(dto);
wo.insert(json);
requireSucess = false;
return true;
}
}
@Override
public JSONObject getDeviceStatusName() {
JSONObject jo = new JSONObject();
String mode = "";
String action = "";
String move = "";
if (this.getMode() == 0) {
mode = "未联机";
} else if (this.getMode() == 1) {
mode = "单机";
} else if (this.getMode() == 2) {
mode = "联机";
} else if (this.getMode() == 3) {
mode = "运行中";
}
if (this.getMove() == 0) {
move = "无货";
jo.put("hasGoods", false);
} else if (this.getMove() == 1) {
move = "有货";
jo.put("hasGoods", true);
} else if (this.getMove() == 2) {
move = "有托盘有货";
jo.put("hasGoods", true);
}
jo.put("device_name", this.getDevice().getDevice_name());
jo.put("mode", mode);
jo.put("move", move);
jo.put("action", action);
jo.put("isOnline", this.getIsonline());
jo.put("error", this.getError());
jo.put("isError", this.getIserror());
jo.put("task", this.getTask());
return jo;
}
@Override
public void setDeviceStatus(JSONObject data) {
}
}

9
acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsZDController.java

@ -5,6 +5,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.ext.wms.service.AcsToWmsZDService;
import org.nl.modules.logging.annotation.Log;
import org.springframework.context.annotation.Lazy;
import org.springframework.http.HttpStatus;
@ -23,26 +24,26 @@ import java.util.Map;
@Slf4j
@Lazy
public class AcsToWmsZDController {
private final AcsToWmsZDController acsToWmsZDService;
private final AcsToWmsZDService acsToWmsZDService;
@PostMapping("/feedbackTask")
@Log("任务反馈")
@ApiOperation("任务反馈")
public ResponseEntity<Object> taskFeedback(@RequestBody Map whereJson) throws Exception {
public ResponseEntity<Object> taskFeedback(@RequestBody JSONObject whereJson) throws Exception {
return new ResponseEntity<>(acsToWmsZDService.taskFeedback(whereJson), HttpStatus.OK);
}
@PostMapping("/deprecateTask")
@Log("任务取消")
@ApiOperation("任务取消")
public ResponseEntity<Object> taskDeprecate(@RequestBody Map whereJson) throws Exception {
public ResponseEntity<Object> taskDeprecate(@RequestBody JSONObject whereJson) throws Exception {
return new ResponseEntity<>(acsToWmsZDService.taskDeprecate(whereJson), HttpStatus.OK);
}
@PostMapping("/deviceStatusUpdate")
@Log("设备状态上传")
@ApiOperation("设备状态上传")
public ResponseEntity<Object> deviceStatusUpdate(@RequestBody Map whereJson) throws Exception {
public ResponseEntity<Object> deviceStatusUpdate(@RequestBody JSONObject whereJson) throws Exception {
return new ResponseEntity<>(acsToWmsZDService.deviceStatusUpdate(whereJson), HttpStatus.OK);
}
}

2
acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsZDToAcsController.java

@ -1,5 +1,6 @@
package org.nl.acs.ext.wms.rest;
import cn.dev33.satoken.annotation.SaIgnore;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -28,6 +29,7 @@ public class WmsZDToAcsController {
@PostMapping("/createTask")
@Log("任务接收")
@ApiOperation("任务接收")
@SaIgnore
public ResponseEntity<Object> taskCreate(@RequestBody JSONObject whereJson) {
return new ResponseEntity<>(wmsZDToAcsService.taskCreate(whereJson), HttpStatus.OK);
}

11
acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsZDService.java

@ -1,5 +1,6 @@
package org.nl.acs.ext.wms.service;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import java.util.Map;
@ -11,17 +12,17 @@ public interface AcsToWmsZDService {
* 任务反馈
*
*
* @return Map<String, Object>
*
*/
Map<String, Object> taskFeedback(Map whereJson);
HttpResponse taskFeedback(JSONObject whereJson);
/**
* 任务取消
*
*
* @return Map<String, Object>
*
*/
Map<String, Object> taskDeprecate(Map whereJson);
HttpResponse taskDeprecate(JSONObject whereJson);
/**
* 设备状态上传
@ -29,5 +30,5 @@ public interface AcsToWmsZDService {
*
* @return Map<String, Object>
*/
Map<String, Object> deviceStatusUpdate(Map whereJson);
HttpResponse deviceStatusUpdate(JSONObject whereJson);
}

1
acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToLiKuServiceImpl.java

@ -92,7 +92,6 @@ public class AcsToLiKuServiceImpl implements AcsToLiKuService {
String result = AcsUtil.notifyAcs(api, requestParam);
log.info("moveStore-----输出参数{}", result);
return RespUtil.getResp(result, new MoveStoreResponse());
} finally {
MDC.remove(log_file_type);
}

114
acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsZDServiceImpl.java

@ -21,6 +21,7 @@ import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.config.server.AcsConfigService;
import org.nl.modules.logging.service.LogService;
import org.nl.modules.system.service.ParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@ -35,111 +36,90 @@ import java.util.Map;
public class AcsToWmsZDServiceImpl implements AcsToWmsZDService {
private final DeviceAppService deviceAppService;
@Autowired
ParamService paramService;
@Autowired
AcsConfigService acsConfigService;
DeviceService deviceService;
@Autowired
AddressService addressService;
@Autowired
AcsConfigService acsConfigService;
@Autowired
LogService logServer;
@Value("${acsTowms.token}")
public String token;
private String log_file_type="log_file_type";
private String log_type="ACS请求LMS";
@Override
public Map<String, Object> taskFeedback(Map whereJson) {
log.info("taskFeedback-----请求参数{}", whereJson.toString());
String taskCode = MapUtil.getStr(whereJson, "taskCode");
String carId = MapUtil.getStr(whereJson, "carId");
HttpResponse result = null;
AddressDto addressDto = addressService.findByCode("taskFeedback");
String wcsurl = acsConfigService.findConfigFromCache().get(AcsConfig.WCSURL);
public HttpResponse taskFeedback(JSONObject whereJson) {
String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue();
AddressDto addressDto = addressService.findByCode("feedAgvTaskStatus");
String methods_url = addressDto.getMethods_url();
String url = wcsurl + methods_url;
String url = wmsUrl + methods_url;
HttpResponse result = null;
log.info("feedAgvTaskStatus----请求参数{}", whereJson);
try {
result = HttpRequest.post(url)
.header("Authorization", token).body(JSON.toJSONString(whereJson))
.body(String.valueOf(whereJson))
.execute();
logServer.log(taskCode, "taskFeedback", "success", whereJson.toString(), result.body(), String.valueOf(result.getStatus()), url, carId);
JSONObject jo = JSONObject.parseObject(result.body());
return jo;
System.out.println(result);
log.info("feedAgvTaskStatus----返回参数{}", result);
} catch (Exception e) {
int status = 400;
if (!ObjectUtil.isEmpty(result)) {
status = result.getStatus();
}
logServer.log(taskCode, "taskFeedback", "error", whereJson.toString(), e.getMessage(), String.valueOf(status), url, carId);
Map<String, Object> map = new HashMap<>();
map.put("responseCode", 1);
map.put("responseMessage", e.getMessage());
map.put("parameters", new HashMap<>());
return map;
String msg = e.getMessage();
//网络不通
//System.out.println(msg);
}
return result;
}
@Override
public Map<String, Object> taskDeprecate(Map whereJson) {
log.info("taskDeprecate--------------:输入参数" + whereJson.toString());
String taskCode = MapUtil.getStr(whereJson, "task_code");
HttpResponse result = null;
public HttpResponse taskDeprecate(JSONObject whereJson) {
String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue();
AddressDto addressDto = addressService.findByCode("deprecateTask");
String wcsurl = acsConfigService.findConfigFromCache().get(AcsConfig.WCSURL);
String methods_url = addressDto.getMethods_url();
String url = wcsurl + methods_url;
String url = wmsUrl + methods_url;
HttpResponse result = null;
log.info("deprecateTask----请求参数{}", whereJson);
try {
result = HttpRequest.post(url)
.header("Authorization", token)
.body(JSON.toJSONString(whereJson))
.body(String.valueOf(whereJson))
.execute();
logServer.log(taskCode, "taskDeprecate", "success", whereJson.toString(), result.body(), String.valueOf(result.getStatus()), url, "");
JSONObject jo = JSONObject.parseObject(result.body());
return jo;
System.out.println(result);
log.info("deprecateTask----返回参数{}", result);
} catch (Exception e) {
int status = 400;
if (!ObjectUtil.isEmpty(result)) {
status = result.getStatus();
}
logServer.log(taskCode, "taskFeedback", "error", whereJson.toString(), e.getMessage(), String.valueOf(status), url, "");
Map<String, Object> map = new HashMap<>();
map.put("responseCode", 1);
map.put("responseMessage", e.getMessage());
return map;
String msg = e.getMessage();
//网络不通
//System.out.println(msg);
}
return result;
}
@Override
public Map<String, Object> deviceStatusUpdate(Map whereJson) {
Map<String, Object> map = new HashMap<>();
HttpResponse result = null;
public HttpResponse deviceStatusUpdate(JSONObject whereJson) {
String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue();
AddressDto addressDto = addressService.findByCode("deviceStatusUpdate");
String wcsurl = acsConfigService.findConfigFromCache().get(AcsConfig.WCSURL);
String methods_url = addressDto.getMethods_url();
String url = wcsurl + methods_url;
String deviceCode = MapUtil.getStr(whereJson, "deviceCode");
if (StrUtil.isEmpty(deviceCode)) {
map.put("responseCode", 1);
map.put("responseMessage", "请求设备号不能为空!");
map.put("parameters", new HashMap<>());
return map;
}
String url = wmsUrl + methods_url;
HttpResponse result = null;
log.info("deviceStatusUpdate", whereJson);
try {
result = HttpRequest.post(url)
.header("Authorization", token).body(JSON.toJSONString(whereJson))
.body(String.valueOf(whereJson))
.execute();
JSONObject jo = JSONObject.parseObject(result.body());
log.info("checkDeviceStatus-----输出参数{}", jo.toString());
return jo;
System.out.println(result);
log.info("deviceStatusUpdate----返回参数{}", result);
} catch (Exception e) {
int status = 400;
if (!ObjectUtil.isEmpty(result)) {
status = result.getStatus();
}
logServer.log(deviceCode, "deviceStatusUpdate", "error", whereJson.toString(), e.getMessage(), String.valueOf(status), url, "");
map.put("responseCode", 1);
map.put("responseMessage", e.getMessage());
return map;
String msg = e.getMessage();
//网络不通
//System.out.println(msg);
}
return result;
}
}

8
acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java

@ -14,6 +14,7 @@ import org.nl.acs.AcsConfig;
import org.nl.acs.agv.server.MagicAgvService;
import org.nl.acs.agv.server.NDCAgvService;
import org.nl.acs.agv.server.XianGongAgvService;
import org.nl.acs.agv.server.ZheDaAgvService;
import org.nl.acs.auto.initial.ApplicationAutoInitial;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device.service.impl.DeviceServiceImpl;
@ -363,9 +364,16 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
throw new BadRequestException("未查询到相关路由!");
}
if (StrUtil.equals(shortPathsList.get(0).getType(), "1")) {
String agvType = paramService.findByCode(AcsConfig.AGVTYPE).getValue();
if(agvType.equals("2")) {
NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto);
}
if(agvType.equals("4")){
ZheDaAgvService zheDaAgvService=SpringContextHolder.getBean(ZheDaAgvService.class);
zheDaAgvService.sendAgvInstToAgv(dto);
}
}
} catch (Exception e) {
dto.setSend_status("2");
e.printStackTrace();

17
acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java

@ -21,6 +21,7 @@ import org.nl.acs.device.service.StorageCellService;
import org.nl.acs.device.service.dto.DeviceAssignedDto;
import org.nl.acs.device.service.impl.DeviceServiceImpl;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.AcsToWmsZDService;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.instruction.service.dto.InstructionDto;
@ -77,6 +78,8 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
@Autowired
AcsToWmsService acstowmsService;
@Autowired
AcsToWmsZDService acsToWmsZDService;
@Autowired
TaskFeedbackService taskFeedbackService;
@Autowired
ParamService paramService;
@ -953,12 +956,16 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue();
if (!StrUtil.startWith(entity.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) {
JSONObject feed_jo = new JSONObject();
feed_jo.put("task_id", entity.getTask_id());
feed_jo.put("task_code", entity.getTask_code());
feed_jo.put("task_status", entity.getTask_status());
JSONArray ja = new JSONArray();
ja.add(feed_jo);
acstowmsService.feedbackTaskStatusToWms(ja);
// JSONArray ja = new JSONArray();
// ja.add(feed_jo);
// acstowmsService.feedbackTaskStatusToWms(ja);
HttpResponse result=acsToWmsZDService.taskDeprecate(feed_jo);
JSONObject response=JSONObject.parseObject(result.body());
int responseCode= response.getInteger("responseCode");
if(responseCode == 0) {
log.info("请求ZDwcs成功,任务取消 请求结果{}",responseCode);
}
}
List<RouteLineDto> shortPathsList =
routeLineService.getShortPathLines(

52
acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/DeviceStatusUpdate.java

@ -0,0 +1,52 @@
package org.nl.modules.quartz.task;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.agv.server.AgvService;
import org.nl.acs.agv.server.ZheDaAgvService;
import org.nl.acs.agv.server.dto.AgvDto;
import org.nl.acs.ext.wms.service.AcsToWmsZDService;
import org.nl.modules.mnt.websocket.MsgType;
import org.nl.modules.mnt.websocket.SocketMsg;
import org.nl.modules.mnt.websocket.WebSocketServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Map;
/**
* 设备上传 zjj
*/
@Slf4j
@Component
public class DeviceStatusUpdate {
@Autowired
AcsToWmsZDService acsToWmsZDService;
@Autowired
ZheDaAgvService zheDaAgvService;
public void run() throws Exception {
JSONObject row = new JSONObject();
HttpResponse response = zheDaAgvService.queryAgvInstStatus();
JSONArray inst_rows = JSONArray.parseArray(response.body());
for (int i = 0; i < inst_rows.size(); i++) {
JSONObject inst_jo = inst_rows.getJSONObject(i);
String deviceCode = inst_jo.getString("deviceCode");
Integer status = inst_jo.getInteger("status");
String statusDescription = inst_jo.getString("statusDescription");
row.put("deviceCode",deviceCode);
row.put("status",status);
row.put("statusDescription",statusDescription);
JSONObject jo=JSONObject.parseObject(String.valueOf(row));
HttpResponse result=acsToWmsZDService.deviceStatusUpdate(jo);
JSONObject response1=JSONObject.parseObject(result.body());
int responseCode= response1.getInteger("responseCode");
if(responseCode == 0) {
log.info("请求ZDwcs成功,申请取货 请求结果{}", responseCode);
}
}
}
}

98
acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryZDAgvTaskStatus.java

@ -0,0 +1,98 @@
package org.nl.modules.quartz.task;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.agv.server.ZheDaAgvService;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class QueryZDAgvTaskStatus {
@Autowired
InstructionService instructionService;
@Autowired
ZheDaAgvService agvService;
public void run() throws Exception {
try {
HttpResponse response = agvService.queryAgvInstStatus();
//查询AGV指令列表
JSONArray inst_rows = JSONArray.parseArray(response.body());
for (int i = 0; i < inst_rows.size(); i++) {
JSONObject inst_jo = inst_rows.getJSONObject(i);
String inst_code = inst_jo.getString("taskCode");
String feedbackStatus=inst_jo.getString("feedbackStatus");
Instruction inst = instructionService.findByCodeFromCache(inst_code);
if (ObjectUtil.isEmpty(inst)) {
continue;
}
//反馈结果状态
log.info("instcode:" + inst_code + "," + inst_jo.toString());
String state = inst_jo.getString("state");
String vehicle = "";
//正在执行指令agv车号
if (!StrUtil.isEmpty(inst_jo.getString("vehicle"))) {
vehicle = inst_jo.getString("vehicle");
inst.setCarno(vehicle);
}
// RAW:初始状态
// ACTIVE:业务订单已激活
// DISPATCHABLE:业务订单已通过系统验证,等待被调度执行
// BEING_PROCESSED:业务订单正在被执行
// WITHDRAWN:业务订单已被撤销
// FINISHED:业务订单已完成
// FAILED:业务订单已失败
// UNROUTABLE:无法规划该业务订单的执行路线
//执行中
if ("BEING_PROCESSED".equals(state)) {
if (inst != null) {
inst.setInstruction_status("1");
instructionService.update(inst);
}
} else if ("FINISHED".equals(state)) {
if (inst != null) {
inst.setInstruction_status("2");
instructionService.finish(inst);
}
} else if ("WITHDRAWN".equals(state) || "FAILED".equals(state)) {
if (inst != null) {
inst.setInstruction_status("3");
instructionService.update(inst);
instructionService.removeByCodeFromCache(inst_jo.getString("task_code"));
}
}
JSONArray ja = inst_jo.getJSONArray("destinations");
for (int j = 0; j < ja.size(); j++) {
JSONObject jo = ja.getJSONObject(j);
JSONArray pro_rows = jo.getJSONArray("properties");
//Load 取货动作 Unload放货动作 Wait等待
String operation = jo.getString("operation");
String device = jo.getString("locationName");
for (int k = 0; k < pro_rows.size(); k++) {
JSONObject item = pro_rows.getJSONObject(k);
if ("true".equals(item.get("value"))) {
String param = item.get("key").toString();
//EntryRequired是否进入前等待 PauseOnStation是否离开等待 Wait在该点进行等待
agvService.process(inst_code, param, device, operation, vehicle,feedbackStatus);
}
}
}
}
} catch (Exception e) {
}
}
}

1
acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/ToAgvDevice.java

@ -29,7 +29,6 @@ public class ToAgvDevice {
public void run() throws Exception {
JSONObject json = new JSONObject();
Map<String, AgvDto> agv_map = agvService.findAllAgvFromCache();
JSONArray agv_rows = new JSONArray();
JSONObject row = new JSONObject();

1
acs/nladmin-system/src/main/java/org/nl/modules/wql/util/SpringContextHolder.java

@ -125,7 +125,6 @@ public class SpringContextHolder implements ApplicationContextAware, DisposableB
".xml中定义SpringContextHolder或在SpringBoot启动类中注册SpringContextHolder.");
}
}
/**
* 清除SpringContextHolder中的ApplicationContext为Null.
*/

4
acs/nladmin-ui/src/views/acs/device/config.vue

@ -95,6 +95,7 @@ import hongxiang_conveyor from '@/views/acs/device/driver/hongxiang_conveyor'
import plug_pull_device_site from '@/views/acs/device/driver/plug_pull_device_site'
import siemens_conveyor_labeling from '@/views/acs/device/driver/siemens_conveyor_labeling'
import siemens_conveyor_ckk from '@/views/acs/device/driver/siemens_conveyor_ckk'
import lubei_conveyor from '@/views/acs/device/driver/lubei_conveyor'
export default {
name: 'DeviceConfig',
@ -120,7 +121,8 @@ export default {
slit_two_manipulator,
plug_pull_device_site,
siemens_conveyor_labeling,
siemens_conveyor_ckk
siemens_conveyor_ckk,
lubei_conveyor
},
dicts: ['device_type'],
mixins: [crud],

Loading…
Cancel
Save