周俊杰
1 year ago
10 changed files with 217 additions and 331 deletions
@ -1,51 +0,0 @@ |
|||
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.queryZDAgvDeviceStatus(); |
|||
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("vehicle"); |
|||
String statusDescription = inst_jo.getString("status"); |
|||
row.put("deviceCode",deviceCode); |
|||
row.put("status","1"); |
|||
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); |
|||
} |
|||
} |
|||
} |
|||
} |
@ -1,166 +0,0 @@ |
|||
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.AcsConfig; |
|||
import org.nl.acs.agv.server.ZheDaAgvService; |
|||
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.task.service.TaskService; |
|||
import org.nl.acs.task.service.dto.TaskDto; |
|||
import org.nl.acs.task.service.impl.TaskServiceImpl; |
|||
import org.nl.modules.system.service.ParamService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
@Slf4j |
|||
@Component |
|||
public class QueryZDAgvTaskStatus { |
|||
@Autowired |
|||
InstructionService instructionService; |
|||
|
|||
@Autowired |
|||
ZheDaAgvService agvService; |
|||
|
|||
@Autowired |
|||
ParamService paramService; |
|||
|
|||
@Autowired |
|||
AcsToWmsZDService acsToWmsZDService; |
|||
|
|||
@Autowired |
|||
TaskService taskService; |
|||
|
|||
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("task_code"); |
|||
Instruction inst = instructionService.findByCodeFromCache(inst_code); |
|||
log.info("查询到的任务号{}",inst); |
|||
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) || "ACTIVE".equals(state)) { |
|||
if (inst != null && StrUtil.equals("0",inst.getInstruction_status())) { |
|||
log.info("更新指令状态执行中---"); |
|||
inst.setInstruction_status("1"); |
|||
instructionService.update(inst); |
|||
log.info("更新指令状态执行中成功---"); |
|||
// 判断是否为WMS下发的任务,如果是反馈任务状态给WMS
|
|||
TaskDto entity = taskService.findByCode(inst.getTask_code()); |
|||
String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue(); |
|||
String Type1=entity.getTask_type(); |
|||
|
|||
if (!StrUtil.startWith(entity.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { |
|||
|
|||
JSONObject jo = new JSONObject(); |
|||
jo.put("taskCode",entity.getTask_code()); |
|||
jo.put("carId","111"); |
|||
jo.put("taskType ",entity.getTask_type()); |
|||
jo.put("feedbackStatus","taking"); |
|||
log.info("请求参数:{}",jo); |
|||
try{ |
|||
HttpResponse result= acsToWmsZDService.taskFeedback(jo); |
|||
log.info("请求ZDwcs成功,反馈取货中 请求结果{}",result.body()); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
// JSONObject response=JSONObject.parseObject(result.body());
|
|||
// int responseCode= response.getInteger("responseCode");
|
|||
// if(responseCode == 0) {
|
|||
// log.info("请求ZDwcs成功,申请取货 请求结果{}",responseCode);
|
|||
// }
|
|||
} else { |
|||
if(StrUtil.equals(Type1,"定点任务")){ |
|||
JSONObject jo = new JSONObject(); |
|||
jo.put("taskCode",entity.getTask_code()); |
|||
jo.put("carId",vehicle); |
|||
jo.put("taskType ",entity.getTask_type()); |
|||
jo.put("feedbackStatus","taking"); |
|||
log.info("请求参数:{}",jo); |
|||
try{ |
|||
HttpResponse result= acsToWmsZDService.taskFeedback(jo); |
|||
log.info("请求ZDwcs成功,反馈取货中 请求结果{}",result.body()); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
// JSONObject response=JSONObject.parseObject(result.body());
|
|||
// int responseCode= response.getInteger("responseCode");
|
|||
// if(responseCode == 0) {
|
|||
// log.info("请求ZDwcs成功,申请取货 请求结果{}",responseCode);
|
|||
// }
|
|||
} |
|||
} |
|||
} else { |
|||
if(ObjectUtil.isEmpty(inst)){ |
|||
log.info("未更新指令状态执行中,inst为空,指令号:"+ inst_code); |
|||
} |
|||
if(!StrUtil.equals("0",inst.getInstruction_status())){ |
|||
log.info("未更新指令状态执行中,inst状态:"+ inst.getInstruction_status()); |
|||
} |
|||
} |
|||
} 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); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} catch (Exception e) { |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
} |
@ -1,33 +0,0 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<included> |
|||
<springProperty scope="context" name="logPath" source="logging.file.path" defaultValue="logs"/> |
|||
<property name="LOG_HOME" value="${logPath}"/> |
|||
<!-- 按照每天生成日志文件 --> |
|||
<appender name="QueryZDAgvTaskStatus" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> |
|||
<!--日志文件输出的文件名--> |
|||
<FileNamePattern>${LOG_HOME}/任务反馈/%d{yyyy-MM-dd}.%i.log</FileNamePattern> |
|||
<!--日志文件保留天数--> |
|||
<maxHistory>15</maxHistory> |
|||
<!--单个日志最大容量 至少10MB才能看得出来--> |
|||
<maxFileSize>200MB</maxFileSize> |
|||
<!--所有日志最多占多大容量--> |
|||
<totalSizeCap>2GB</totalSizeCap> |
|||
</rollingPolicy> |
|||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> |
|||
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符--> |
|||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
|||
<charset>${log.charset}</charset> |
|||
</encoder> |
|||
|
|||
</appender> |
|||
|
|||
<!-- <logger name="org.nl.start.Init" level="info" additivity="false"> |
|||
<appender-ref ref="FILE3"/> |
|||
</logger>--> |
|||
|
|||
<!-- 打印sql --> |
|||
<logger name="org.nl.modules.quartz.task.QueryZDAgvTaskStatus" level="info" additivity="false"> |
|||
<appender-ref ref="QueryZDAgvTaskStatus"/> |
|||
</logger> |
|||
</included> |
@ -0,0 +1,14 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
|
|||
<?import java.lang.*?> |
|||
<?import java.util.*?> |
|||
<?import javafx.scene.*?> |
|||
<?import javafx.scene.control.*?> |
|||
<?import javafx.scene.layout.*?> |
|||
|
|||
<AnchorPane xmlns="http://javafx.com/javafx" |
|||
xmlns:fx="http://javafx.com/fxml" |
|||
fx:controller="$CONTROLLER_NAME$" |
|||
prefHeight="400.0" prefWidth="600.0"> |
|||
|
|||
</AnchorPane> |
Loading…
Reference in new issue