rev:代码优化
This commit is contained in:
@@ -12,6 +12,7 @@ import org.nl.acs.log.service.LogServer;
|
|||||||
import org.nl.exception.BadRequestException;
|
import org.nl.exception.BadRequestException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,7 +60,15 @@ public class AgvWaitUtil {
|
|||||||
//取货完成等待
|
//取货完成等待
|
||||||
public JSONObject waitOutGet(String startDeviceCode, Instruction inst) {
|
public JSONObject waitOutGet(String startDeviceCode, Instruction inst) {
|
||||||
log.info("仙工AGV取货完成后请求离开,设备号 - {}", startDeviceCode);
|
log.info("仙工AGV取货完成后请求离开,设备号 - {}", startDeviceCode);
|
||||||
|
if (startDeviceCode.length() == 4) {
|
||||||
|
JSONObject requestWMSParam = new JSONObject();
|
||||||
|
requestWMSParam.put("device_code", startDeviceCode);
|
||||||
|
requestWMSParam.put("device_status", "close");
|
||||||
|
JSONObject wmsResult = acsToWmsService.gccControlDoorSwitch(requestWMSParam);
|
||||||
|
if (HttpStatus.OK.value() == wmsResult.optInt("status")) {
|
||||||
|
JSONObject responseBody = acsToWmsService.gccQueryDoorStatus(startDeviceCode);
|
||||||
|
log.info("当前设备" + startDeviceCode + "门的状态:" + responseBody.get("device_status") + ",门的状态应为关闭状态!");
|
||||||
|
if (ObjectUtil.isNotEmpty(responseBody) && "close".equals(responseBody.get("device_status"))) {
|
||||||
inst.setExecute_status("2");
|
inst.setExecute_status("2");
|
||||||
instructionService.update(inst);
|
instructionService.update(inst);
|
||||||
|
|
||||||
@@ -68,6 +77,22 @@ public class AgvWaitUtil {
|
|||||||
map.put("message", "允许离开!");
|
map.put("message", "允许离开!");
|
||||||
log.info("允许仙工AGV取货完成后请求离开,设备号 - {}", startDeviceCode);
|
log.info("允许仙工AGV取货完成后请求离开,设备号 - {}", startDeviceCode);
|
||||||
return map;
|
return map;
|
||||||
|
} else {
|
||||||
|
throw new BadRequestException("请求失败!");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new BadRequestException("请求失败!");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
inst.setExecute_status("2");
|
||||||
|
instructionService.update(inst);
|
||||||
|
|
||||||
|
JSONObject map = new JSONObject();
|
||||||
|
map.put("status", 200);
|
||||||
|
map.put("message", "允许离开!");
|
||||||
|
log.info("允许仙工AGV取货完成后请求离开,设备号 - {}", startDeviceCode);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//放货前等待
|
//放货前等待
|
||||||
@@ -99,6 +124,27 @@ public class AgvWaitUtil {
|
|||||||
public JSONObject waitOutPut(String endDeviceCode, Instruction inst) {
|
public JSONObject waitOutPut(String endDeviceCode, Instruction inst) {
|
||||||
log.info("仙工AGV放货完成后请求离开,设备号 - {}", endDeviceCode);
|
log.info("仙工AGV放货完成后请求离开,设备号 - {}", endDeviceCode);
|
||||||
|
|
||||||
|
if (endDeviceCode.length() == 4) {
|
||||||
|
JSONObject requestWMSParam = new JSONObject();
|
||||||
|
requestWMSParam.put("device_code", endDeviceCode);
|
||||||
|
requestWMSParam.put("device_status", "close");
|
||||||
|
JSONObject wmsResult = acsToWmsService.gccControlDoorSwitch(requestWMSParam);
|
||||||
|
if (HttpStatus.OK.value() == wmsResult.optInt("status")) {
|
||||||
|
JSONObject responseBody = acsToWmsService.gccQueryDoorStatus(endDeviceCode);
|
||||||
|
log.info("当前设备" + endDeviceCode + "门的状态:" + responseBody.get("device_status") + ",门的状态应为关闭状态!");
|
||||||
|
if (ObjectUtil.isNotEmpty(responseBody) && "close".equals(responseBody.get("device_status"))) {
|
||||||
|
JSONObject map = new JSONObject();
|
||||||
|
map.put("status", 200);
|
||||||
|
map.put("message", "允许离开!");
|
||||||
|
log.info("允许仙工AGV放货完成后请求离开,设备号 - {}", endDeviceCode);
|
||||||
|
return map;
|
||||||
|
} else {
|
||||||
|
throw new BadRequestException("请求失败!");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new BadRequestException("请求失败!");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
JSONObject map = new JSONObject();
|
JSONObject map = new JSONObject();
|
||||||
map.put("status", 200);
|
map.put("status", 200);
|
||||||
map.put("message", "允许离开!");
|
map.put("message", "允许离开!");
|
||||||
@@ -106,3 +152,4 @@ public class AgvWaitUtil {
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -54,14 +54,9 @@ import org.springframework.http.HttpStatus;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.DecimalFormat;
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@@ -287,7 +282,6 @@ public class AgvServiceImpl implements AgvService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private AcsPointAngleDto getAcsPointAngleDto(Instruction dto) {
|
private AcsPointAngleDto getAcsPointAngleDto(Instruction dto) {
|
||||||
List<AcsPointAngleDto> list = acsPointAngleService.queryAll(new HashMap());
|
List<AcsPointAngleDto> list = acsPointAngleService.queryAll(new HashMap());
|
||||||
AcsPointAngleDto acsPointAngleDto = new AcsPointAngleDto();
|
AcsPointAngleDto acsPointAngleDto = new AcsPointAngleDto();
|
||||||
@@ -704,7 +698,7 @@ public class AgvServiceImpl implements AgvService {
|
|||||||
String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL);
|
String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL);
|
||||||
String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT);
|
String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT);
|
||||||
|
|
||||||
agvurl = agvurl + ":" + agvport + "/orders?page=1&size=9999";
|
agvurl = agvurl + ":" + agvport + "/orders?page=1&size=100&orderBy=createTime";
|
||||||
List<Instruction> insts = instructionService.findAllInstFromCache();
|
List<Instruction> insts = instructionService.findAllInstFromCache();
|
||||||
if (!insts.isEmpty()) {
|
if (!insts.isEmpty()) {
|
||||||
JSONObject where = new JSONObject();
|
JSONObject where = new JSONObject();
|
||||||
@@ -2271,6 +2265,16 @@ public class AgvServiceImpl implements AgvService {
|
|||||||
jo5.put("script_args", script_args5);
|
jo5.put("script_args", script_args5);
|
||||||
ja.add(jo5);
|
ja.add(jo5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
com.alibaba.fastjson.JSONObject jo6 = new com.alibaba.fastjson.JSONObject();
|
||||||
|
com.alibaba.fastjson.JSONObject operation_args = new com.alibaba.fastjson.JSONObject();
|
||||||
|
operation_args.put("robot_spin_angle", 0);
|
||||||
|
operation_args.put("spin_direction", 0);
|
||||||
|
jo6.put("blockId", IdUtil.simpleUUID());
|
||||||
|
jo6.put("location", inst.getNext_point_code() + "OUTPUT");
|
||||||
|
jo6.put("operation_args", operation_args);
|
||||||
|
ja.add(jo6);
|
||||||
|
|
||||||
return ja;
|
return ja;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2315,4 +2319,5 @@ public class AgvServiceImpl implements AgvService {
|
|||||||
|
|
||||||
throw new BadRequestException("请求失败,IN OUT 站点错误!");
|
throw new BadRequestException("请求失败,IN OUT 站点错误!");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ import org.openscada.opc.lib.da.Server;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -86,6 +87,8 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
AcsConfigService acsConfigService;
|
AcsConfigService acsConfigService;
|
||||||
|
|
||||||
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
TaskService taskService;
|
TaskService taskService;
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -137,6 +137,7 @@ public class LogServerImpl implements LogServer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void log(String task_code, String method, String type, String requestParam, String responseParam, String status_code, String requesturl, String vehicle_code) {
|
public void log(String task_code, String method, String type, String requestParam, String responseParam, String status_code, String requesturl, String vehicle_code) {
|
||||||
|
try {
|
||||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||||
String now = DateUtil.now();
|
String now = DateUtil.now();
|
||||||
|
|
||||||
@@ -159,5 +160,8 @@ public class LogServerImpl implements LogServer {
|
|||||||
WQLObject wo = WQLObject.getWQLObject("acs_log");
|
WQLObject wo = WQLObject.getWQLObject("acs_log");
|
||||||
JSONObject json = JSONObject.fromObject(logDto);
|
JSONObject json = JSONObject.fromObject(logDto);
|
||||||
wo.insert(json);
|
wo.insert(json);
|
||||||
|
}catch (Exception ex){
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -217,4 +217,9 @@ public class TaskDto implements Serializable {
|
|||||||
* 外部系统标识
|
* 外部系统标识
|
||||||
*/
|
*/
|
||||||
private String ext_task_uuid;
|
private String ext_task_uuid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* agv车号
|
||||||
|
*/
|
||||||
|
private String carno;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -834,8 +834,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void update(TaskDto dto) {
|
public void update(TaskDto dto) {
|
||||||
TaskDto entity = this.findById(dto.getTask_id());
|
TaskDto entity = this.findById(dto.getTask_id());
|
||||||
Instruction instruction = instructionService.findByTaskcode(dto.getTask_code());
|
|
||||||
|
|
||||||
if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
|
if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
|
||||||
|
|
||||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||||
@@ -859,13 +857,13 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
}
|
}
|
||||||
//判断是否为WMS下发的任务,如果是反馈任务状态给WMS
|
//判断是否为WMS下发的任务,如果是反馈任务状态给WMS
|
||||||
String hasWms = acsConfigService.findConfigFromCache().get(AcsConfig.HASWMS);
|
String hasWms = acsConfigService.findConfigFromCache().get(AcsConfig.HASWMS);
|
||||||
if (!StrUtil.startWith(dto.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) {
|
if (!StrUtil.startWith(dto.getTask_code(), "-") && StrUtil.equals(hasWms, "1")&&ObjectUtil.isNotEmpty(dto.getCarno())) {
|
||||||
TaskFeedbackDto feefbackdto = taskFeedbackService.findByCode(entity.getTask_code());
|
TaskFeedbackDto feefbackdto = taskFeedbackService.findByCode(entity.getTask_code());
|
||||||
JSONObject feed_jo = new JSONObject();
|
JSONObject feed_jo = new JSONObject();
|
||||||
feed_jo.put("task_code", dto.getTask_code());
|
feed_jo.put("task_code", dto.getTask_code());
|
||||||
feed_jo.put("ext_task_uuid", entity.getExt_task_uuid());
|
feed_jo.put("ext_task_uuid", entity.getExt_task_uuid());
|
||||||
feed_jo.put("task_status", dto.getTask_status());
|
feed_jo.put("task_status", dto.getTask_status());
|
||||||
feed_jo.put("agv_code",instruction.getCarno());
|
feed_jo.put("agv_code",dto.getCarno());
|
||||||
JSONArray ja = new JSONArray();
|
JSONArray ja = new JSONArray();
|
||||||
ja.add(feed_jo);
|
ja.add(feed_jo);
|
||||||
String message = null;
|
String message = null;
|
||||||
|
|||||||
@@ -57,8 +57,8 @@ public class QueryXZAgvTaskStatus {
|
|||||||
String carno = one.getString("vehicle");
|
String carno = one.getString("vehicle");
|
||||||
if (ObjectUtil.isEmpty(inst.getCarno())) {
|
if (ObjectUtil.isEmpty(inst.getCarno())) {
|
||||||
inst.setCarno(carno);
|
inst.setCarno(carno);
|
||||||
instructionService.update(inst);
|
|
||||||
TaskDto taskDto = taskService.findByCode(inst.getTask_code());
|
TaskDto taskDto = taskService.findByCode(inst.getTask_code());
|
||||||
|
taskDto.setCarno(carno);
|
||||||
taskService.update(taskDto);
|
taskService.update(taskDto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,14 +74,20 @@ public class QueryXZAgvTaskStatus {
|
|||||||
|
|
||||||
//执行中
|
//执行中
|
||||||
if ("RUNNING".equals(state) || "CREATED".equals(state) || "TOBEDISPATCHED".equals(state) || "WAITING".equals(state)) {
|
if ("RUNNING".equals(state) || "CREATED".equals(state) || "TOBEDISPATCHED".equals(state) || "WAITING".equals(state)) {
|
||||||
|
log.info("queryXZAgvTaskStatus--当前inst_code:{},agv_status:{}", inst.getInstruction_code(), state);
|
||||||
if (inst != null) {
|
if (inst != null) {
|
||||||
inst.setInstruction_status("1");
|
inst.setInstruction_status("1");
|
||||||
instructionService.update(inst);
|
instructionService.update(inst);
|
||||||
|
}else {
|
||||||
|
log.info("queryXZAgvTaskStatus--指令为空");
|
||||||
}
|
}
|
||||||
} else if ("FINISHED".equals(state)) {
|
} else if ("FINISHED".equals(state)) {
|
||||||
|
log.info("queryXZAgvTaskStatus--当前inst_code:{},agv_status:{}", inst.getInstruction_code(), state);
|
||||||
if (inst != null) {
|
if (inst != null) {
|
||||||
inst.setInstruction_status("2");
|
inst.setInstruction_status("2");
|
||||||
instructionService.finish(inst);
|
instructionService.finish(inst);
|
||||||
|
}else {
|
||||||
|
log.info("queryXZAgvTaskStatus--指令为空");
|
||||||
}
|
}
|
||||||
} else if ("STOPPED".equals(state) || "FAILED".equals(state) || "Error".equals(state)) {
|
} else if ("STOPPED".equals(state) || "FAILED".equals(state) || "Error".equals(state)) {
|
||||||
if (inst != null) {
|
if (inst != null) {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ spring:
|
|||||||
# url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:gcc_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
# url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:gcc_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||||
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:gcc_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
|
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:gcc_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
|
||||||
username: ${DB_USER:root}
|
username: ${DB_USER:root}
|
||||||
password: ${DB_PWD:root}
|
password: ${DB_PWD:123456}
|
||||||
# password: ${DB_PWD:Root.123456}
|
# password: ${DB_PWD:Root.123456}
|
||||||
# 初始连接数
|
# 初始连接数
|
||||||
initial-size: 5
|
initial-size: 5
|
||||||
|
|||||||
32
hd/nladmin-system/src/main/resources/log/AgvWaitUtil.xml
Normal file
32
hd/nladmin-system/src/main/resources/log/AgvWaitUtil.xml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?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="FILE9" 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>
|
||||||
|
</encoder>
|
||||||
|
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- <logger name="org.nl.start.Init" level="info" additivity="false">
|
||||||
|
<appender-ref ref="FILE3"/>
|
||||||
|
</logger>-->
|
||||||
|
|
||||||
|
<!-- 打印sql -->
|
||||||
|
<logger name="org.nl.acs.agv.service.AgvWaitUtil" level="info" additivity="false">
|
||||||
|
<appender-ref ref="FILE9"/>
|
||||||
|
</logger>
|
||||||
|
</included>
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
window.g = {
|
window.g = {
|
||||||
dev: {
|
dev: {
|
||||||
VUE_APP_BASE_API: '/'
|
VUE_APP_BASE_API: 'http://10.118.33.115:8010'
|
||||||
},
|
},
|
||||||
prod: {
|
prod: {
|
||||||
VUE_APP_BASE_API: 'http://127.0.0.1:8010'
|
VUE_APP_BASE_API: 'http://10.118.33.115:8010'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ module.exports = {
|
|||||||
lintOnSave: process.env.NODE_ENV === 'development',
|
lintOnSave: process.env.NODE_ENV === 'development',
|
||||||
productionSourceMap: false,
|
productionSourceMap: false,
|
||||||
devServer: {
|
devServer: {
|
||||||
|
allowedHosts: ['all'],
|
||||||
|
disableHostCheck: true,
|
||||||
port: port,
|
port: port,
|
||||||
open: true,
|
open: true,
|
||||||
overlay: {
|
overlay: {
|
||||||
|
|||||||
Reference in New Issue
Block a user