add:增加NDC调度系统交互流程
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
package org.nl.acs;
|
||||
|
||||
|
||||
public interface AcsConfig {
|
||||
//指令下发agv
|
||||
String FORKAGV = "forkagv";
|
||||
//单工指令下发agv
|
||||
String ONEFORKAGV = "oneforkagv";
|
||||
//同一站点运行最大任务数
|
||||
String ONEPOINTMAXTASK = "onePointMaxTask";
|
||||
//同一任务创建最大指令数
|
||||
String MAXINSTNUMBER = "maxInstNumber";
|
||||
//创建任务检查
|
||||
String CREATETASKCHECK = "createTaskCheck";
|
||||
//撤销任务检查
|
||||
String CANCELTASKCHECK = "cancelTaskCheck";
|
||||
//agv系统接口地址
|
||||
String AGVURL = "agvurl";
|
||||
//AGV系统端口
|
||||
String AGVPORT = "agvport";
|
||||
//rgv系统接口地址
|
||||
String RGVURL = "rgvurl";
|
||||
//RGV系统端口
|
||||
String RGVPORT = "rgvport";
|
||||
//指定AGV系统
|
||||
String AGVTYPE = "agvType";
|
||||
//WMS系统接口地址
|
||||
String WMSURL = "wmsurl";
|
||||
//WCS系统接口地址
|
||||
String WCSURL = "wcsurl";
|
||||
|
||||
String HASOTHERSYSTEM = "hasOtherSystem";
|
||||
|
||||
String ERPURL = "erpurl";
|
||||
//是否存在wms系统
|
||||
String HASWMS = "hasWms";
|
||||
|
||||
//
|
||||
String MESURL= "mesurl";
|
||||
//lucene日志索引目录
|
||||
String LUCENEURL = "luceneUrl";
|
||||
//路由选择
|
||||
String ROUTE = "route";
|
||||
//忽略取放货校验
|
||||
String IGNOREHASGOODS = "ignoreHasGoods";
|
||||
//项目类型
|
||||
String BUSINESSTYPE = "businessType";
|
||||
//海亮贴标设备ip
|
||||
String LETTERINGURL = "letteringUrl";
|
||||
//海亮贴标设备
|
||||
String LETTERINGPORT = "letteringPort";
|
||||
//NDC断线重连reconnection
|
||||
String NDC_RECONNECTION = "NDC_reconnection";
|
||||
//自动清理日志保留时间
|
||||
String AutoCleanDays = "AutoCleanDays";
|
||||
//最大任务下发时间
|
||||
String MAXSENDTASKTIME = "maxSendTaskTime";
|
||||
//指令下发立库
|
||||
String INSTSENDLK = "instSendLk";
|
||||
/**
|
||||
* 日志级别
|
||||
*/
|
||||
String LOGLEVEL = "log_level";
|
||||
|
||||
String ELECTRIC ="electric";
|
||||
|
||||
String HAS_HK = "has_hk";
|
||||
|
||||
String HK_URL = "hk_url";
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package org.nl.acs.agv.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author wangsong
|
||||
*/
|
||||
@Data
|
||||
public class AgvDto implements Serializable {
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 机器人当前的自身状态
|
||||
* <p>
|
||||
* UNKNOWN:未知状态
|
||||
* UNAVAILABLE:通信超时或者已断开连接
|
||||
* ERROR:错误状态
|
||||
* IDLE:空闲状态
|
||||
* EXECUTING:正在执行运单
|
||||
* CHARGING:正在充电
|
||||
*/
|
||||
private String state;
|
||||
|
||||
/**
|
||||
* 机器人的剩余电量值(单位:整数百分比)
|
||||
*/
|
||||
private String energyLevel;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String energyLevelGood;
|
||||
|
||||
/**
|
||||
* 机器人在 SRD 系统中的在线状态
|
||||
* <p>
|
||||
* TO_BE_IGNORED:机器人处于离线状态,SRD 不会标识出机器人位置。
|
||||
* TO_BE_NOTICED:机器人处于离线状态,SRD 标识出机器人的位置。
|
||||
* TO_BE_RESPECTED:机器人处于在线状态,但不能接受新的运单。
|
||||
* TO_BE_UTILIZED:机器人处于在线状态,可以接受并执行新的运单。
|
||||
*/
|
||||
private String integrationLevel;
|
||||
|
||||
/**
|
||||
* 机器人当前的运单执行状态
|
||||
* <p>
|
||||
* UNAVAILABLE:无法执行任何运单和任务
|
||||
* IDLE:空闲状态
|
||||
* AWAITING_ORDER:机器人在等待运单中新的子任务
|
||||
* PROCESSING_ORDER:机器人正在执行运单
|
||||
*/
|
||||
private String procState;
|
||||
|
||||
/**
|
||||
* 角度
|
||||
*/
|
||||
private String positionAngle;
|
||||
|
||||
/**
|
||||
* X坐标
|
||||
*/
|
||||
private String positionX;
|
||||
|
||||
/**
|
||||
* Y坐标
|
||||
*/
|
||||
private String positionY;
|
||||
|
||||
/**
|
||||
* 当前任务号
|
||||
*/
|
||||
private String transportOrder;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,311 @@
|
||||
package org.nl.acs.agv.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.AcsConfig;
|
||||
import org.nl.acs.agv.dto.AgvDto;
|
||||
import org.nl.acs.agv.service.NDCAgvService;
|
||||
import org.nl.acs.autoThread.autoRun.impl.ndcAuto.OneNDCSocketConnectionAutoRun;
|
||||
import org.nl.acs.device.device.service.DeviceAppService;
|
||||
import org.nl.acs.device.device.service.DeviceService;
|
||||
import org.nl.acs.device.device.service.impl.DeviceAppServiceImpl;
|
||||
import org.nl.acs.device.device.service.impl.DeviceServiceImpl;
|
||||
import org.nl.acs.log.LokiLog;
|
||||
import org.nl.acs.log.LokiLogType;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.task.instruction.domain.Instruction;
|
||||
import org.nl.common.db.CommonFinalParam;
|
||||
import org.nl.common.utils.CodeUtil;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.extInterface.wms.service.AcsToWmsService;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author 20220102CG\noblelift
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Lazy
|
||||
public class NDCAgvServiceImpl implements NDCAgvService {
|
||||
|
||||
private final DeviceAppService deviceAppService;
|
||||
private final ISysParamService paramService;
|
||||
private final AcsToWmsService acsToWmsService;
|
||||
|
||||
private final DeviceExecuteLogService logServer;
|
||||
|
||||
Map<String, AgvDto> AGVDeviceStatus = new HashMap();
|
||||
|
||||
@LokiLog(type = LokiLogType.AGV)
|
||||
@Override
|
||||
public void deleteAgvInstToNDC(Instruction inst) throws Exception {
|
||||
if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
|
||||
int index = Integer.parseInt(inst.getAgv_jobno());
|
||||
|
||||
byte indexhigh = (byte) IntToHexHigh(index);
|
||||
byte indexlow = (byte) IntToHexLow(index);
|
||||
|
||||
String str = "十进制下发:";
|
||||
String str1 = "十六进制下发:";
|
||||
str += "index:" + index;
|
||||
str1 += "ikey:" + hexToString(indexhigh & 0xFF) + hexToString(indexlow & 0xFF);
|
||||
System.out.println(str);
|
||||
System.out.println(str1);
|
||||
|
||||
byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD,
|
||||
(byte) 0X00, (byte) 0X08,
|
||||
(byte) 0X00, (byte) 0X06,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) 0X00, (byte) 0X6E,
|
||||
(byte) 0X00, (byte) 0X02,
|
||||
(byte) indexhigh, (byte) indexlow,
|
||||
};
|
||||
log.info("下发删除AGV指令--{}", Bytes2HexString(b));
|
||||
OneNDCSocketConnectionAutoRun.write(b);
|
||||
log.info("删除AGV指令成功--{}", Bytes2HexString(b));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@LokiLog(type = LokiLogType.AGV)
|
||||
@Override
|
||||
public void sendAgvInstToNDC(String agv_system_type, Instruction inst) {
|
||||
if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
|
||||
String instcode = inst.getInstruction_code();
|
||||
int type = Integer.parseInt(inst.getInstruction_type());
|
||||
int priority = Integer.parseInt(inst.getPriority()) + 128;
|
||||
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
|
||||
int startAddress = deviceService.queryAddressBydeviceCode(inst.getStart_point_code());
|
||||
int nextAddress = deviceService.queryAddressBydeviceCode(inst.getNext_point_code());
|
||||
byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode));
|
||||
byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode));
|
||||
byte typehigh = (byte) IntToHexHigh(type);
|
||||
byte typelow = (byte) IntToHexLow(type);
|
||||
byte qhdhigh = (byte) IntToHexHigh(startAddress);
|
||||
byte qhdlow = (byte) IntToHexLow(startAddress);
|
||||
byte fhdhigh = (byte) IntToHexHigh(nextAddress);
|
||||
byte fhdlow = (byte) IntToHexLow(nextAddress);
|
||||
byte prioritylow = (byte) IntToHexLow(priority);
|
||||
String str = "十进制下发:";
|
||||
String str1 = "十六进制下发:";
|
||||
str += "ikey:" + (Integer.parseInt(instcode));
|
||||
str1 += "ikey:" + hexToString(ikeyhigh & 0xFF) + hexToString(ikeylow & 0xFF);
|
||||
str += "/type:" + (type);
|
||||
str1 += "/type:" + hexToString(typehigh & 0xFF) + hexToString(typelow & 0xFF);
|
||||
str += "/qhd:" + (startAddress);
|
||||
str1 += "/qhd:" + hexToString(qhdhigh & 0xFF) + hexToString(qhdlow & 0xFF);
|
||||
str += "/fhd:" + (nextAddress);
|
||||
str1 += "/fhd:" + hexToString(fhdhigh & 0xFF) + hexToString(fhdlow & 0xFF);
|
||||
str += "/priority:" + (priority);
|
||||
str1 += "/priority:" + hexToString(prioritylow & 0xFF);
|
||||
System.out.println(str);
|
||||
System.out.println(str1);
|
||||
byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD,
|
||||
(byte) 0X00, (byte) 0X08,
|
||||
(byte) 0X00, (byte) 0X12,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) 0X00, (byte) 0X71,
|
||||
(byte) 0X00, (byte) 0X0E,
|
||||
(byte) 0X01, prioritylow,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) ikeyhigh, (byte) ikeylow,
|
||||
(byte) ikeyhigh, (byte) ikeylow,
|
||||
(byte) typehigh, (byte) typelow,
|
||||
(byte) qhdhigh, (byte) qhdlow,
|
||||
(byte) fhdhigh, (byte) fhdlow
|
||||
};
|
||||
log.info("下发AGV作业指令--{}", str1);
|
||||
log.info("下发AGV作业任务--{}", inst.getInstruction_code()+"-----"+Bytes2HexString(b));
|
||||
OneNDCSocketConnectionAutoRun.write(b);
|
||||
System.out.println("下发agv指令数据:" + Bytes2HexString(b));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] sendAgvOneModeInst(int phase, int index, int result, int startPoint, int nextPoint, int startHigh, int nextHigh) {
|
||||
if (phase < 0 || index < 0) {
|
||||
return null;
|
||||
}
|
||||
byte indexhigh = (byte) IntToHexHigh(index);
|
||||
byte indexlow = (byte) IntToHexLow(index);
|
||||
byte phasehigh = (byte) IntToHexHigh(phase);
|
||||
byte phaselow = (byte) IntToHexLow(phase);
|
||||
byte resulthigh = (byte) IntToHexHigh(result);
|
||||
byte resultlow = (byte) IntToHexLow(result);
|
||||
|
||||
byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD,
|
||||
(byte) 0X00, (byte) 0X08,
|
||||
(byte) 0X00, (byte) 0X0A,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) 0X00, (byte) 0X6D,
|
||||
(byte) 0X00, (byte) 0X06,
|
||||
(byte) indexhigh, (byte) indexlow,
|
||||
(byte) 0X01, (byte) 0X12,
|
||||
(byte) phasehigh, (byte) phaselow
|
||||
};
|
||||
|
||||
|
||||
log.info("反馈agv动作数据--index:" + hexToString(indexhigh & 0xFF) + hexToString(indexlow & 0xFF) + ",phase:" + hexToString(phasehigh & 0xFF) + hexToString(phaselow & 0xFF));
|
||||
|
||||
System.out.println("反馈agv动作数据:" + Bytes2HexString(b));
|
||||
return b;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] sendAgvTwoModeInst(int phase, int index, int result) {
|
||||
return new byte[0];
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public byte[] sendAgvOneModeInst(int phase, int index, int result) {
|
||||
if (phase < 0 || index < 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
byte indexhigh = (byte) IntToHexHigh(index);
|
||||
byte indexlow = (byte) IntToHexLow(index);
|
||||
byte phasehigh = (byte) IntToHexHigh(phase);
|
||||
byte phaselow = (byte) IntToHexLow(phase);
|
||||
byte resulthigh = (byte) IntToHexHigh(result);
|
||||
byte resultlow = (byte) IntToHexLow(result);
|
||||
|
||||
byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD,
|
||||
(byte) 0X00, (byte) 0X08,
|
||||
(byte) 0X00, (byte) 0X0A,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) 0X00, (byte) 0X6D,
|
||||
(byte) 0X00, (byte) 0X06,
|
||||
(byte) indexhigh, (byte) indexlow,
|
||||
(byte) 0X01, (byte) 0X12,
|
||||
(byte) phasehigh, (byte) phaselow
|
||||
};
|
||||
|
||||
log.info("反馈agv动作数据--index:" + hexToString(indexhigh & 0xFF) + hexToString(indexlow & 0xFF) + ",phase:" + hexToString(phasehigh & 0xFF) + hexToString(phaselow & 0xFF));
|
||||
|
||||
System.out.println("反馈agv动作数据:" + Bytes2HexString(b));
|
||||
return b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] sendAgvOneModeInstDis(int phase, int index, String disPoint) {
|
||||
if (phase < 0 || index < 0) {
|
||||
return null;
|
||||
}
|
||||
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
|
||||
int disPointAddress = deviceService.queryAddressBydeviceCode(disPoint);
|
||||
|
||||
byte indexhigh = (byte) IntToHexHigh(index);
|
||||
byte indexlow = (byte) IntToHexLow(index);
|
||||
byte phasehigh = (byte) IntToHexHigh(phase);
|
||||
byte phaselow = (byte) IntToHexLow(phase);
|
||||
byte fhdhigh = (byte) IntToHexHigh(disPointAddress);
|
||||
byte fhdlow = (byte) IntToHexLow(disPointAddress);
|
||||
|
||||
byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD,
|
||||
(byte) 0X00, (byte) 0X08,
|
||||
(byte) 0X00, (byte) 0X0C,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) 0X00, (byte) 0X6D,
|
||||
(byte) 0X00, (byte) 0X08,
|
||||
(byte) indexhigh, (byte) indexlow,
|
||||
(byte) 0X01, (byte) 0X12,
|
||||
(byte) phasehigh, (byte) phaselow,
|
||||
(byte) fhdhigh, (byte) fhdlow
|
||||
};
|
||||
|
||||
log.info("反馈agv动作数据--index:" + hexToString(indexhigh & 0xFF) + hexToString(indexlow & 0xFF) + ",phase:" + hexToString(phasehigh & 0xFF) + hexToString(phaselow & 0xFF) + ",disPoint:" + hexToString(fhdhigh & 0xFF) + hexToString(fhdlow & 0xFF));
|
||||
|
||||
System.out.println("反馈agv动作数据:" + Bytes2HexString(b));
|
||||
return b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createChargingTaskToNDC(String carno) {
|
||||
byte carhigh = (byte) IntToHexHigh(Integer.parseInt(carno));
|
||||
byte carlow = (byte) IntToHexLow(Integer.parseInt(carno));
|
||||
|
||||
String instcode = CodeUtil.getNewCode("INSTRUCT_NO");
|
||||
byte instcodehigh = (byte) IntToHexHigh(Integer.parseInt(instcode));
|
||||
byte instcodelow = (byte) IntToHexLow(Integer.parseInt(instcode));
|
||||
|
||||
String str = "十进制下发:";
|
||||
String str1 = "十六进制下发:";
|
||||
str += "carno:" + (Integer.parseInt(carno));
|
||||
str1 += "carno:" + hexToString(carhigh & 0xFF) + hexToString(carlow & 0xFF);
|
||||
|
||||
str += "/instcode:" + (instcode);
|
||||
str1 += "/instcode:" + hexToString(instcodehigh & 0xFF) + hexToString(instcodelow & 0xFF);
|
||||
|
||||
System.out.println(str);
|
||||
System.out.println(str1);
|
||||
|
||||
byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD,
|
||||
(byte) 0X00, (byte) 0X08,
|
||||
(byte) 0X00, (byte) 0X0C,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) 0X00, (byte) 0X71,
|
||||
(byte) 0X00, (byte) 0X08,
|
||||
(byte) 0X64, (byte) 0X80,
|
||||
(byte) 0X00, (byte) 0X01,
|
||||
(byte) instcodehigh, (byte) instcodelow,
|
||||
(byte) carhigh, (byte) carlow
|
||||
};
|
||||
log.info("下发AGV充电任务--{}", str1);
|
||||
|
||||
try {
|
||||
OneNDCSocketConnectionAutoRun.write(b);
|
||||
} catch (Exception e) {
|
||||
e.getMessage();
|
||||
return false;
|
||||
}
|
||||
System.out.println("下发agv充电任务数据:" + Bytes2HexString(b));
|
||||
return true;
|
||||
}
|
||||
|
||||
String hexToString(int i) {
|
||||
return (i < 16 ? "0" + Integer.toHexString(i) : Integer.toHexString(i)).toUpperCase();
|
||||
}
|
||||
|
||||
|
||||
public static int IntToHexHigh(int b) {
|
||||
int big = (b & 0xFF00) >> 8;
|
||||
return big;
|
||||
}
|
||||
|
||||
public static int IntToHexLow(int b) {
|
||||
int little = b & 0xFF;
|
||||
return little;
|
||||
}
|
||||
|
||||
|
||||
public static String Bytes2HexString(byte[] b) {
|
||||
String ret = "";
|
||||
for (int i = 0; i < b.length; i++) {
|
||||
String hex = Integer.toHexString(b[i] & 0xFF);
|
||||
if (hex.length() == 1) {
|
||||
hex = '0' + hex;
|
||||
}
|
||||
ret += hex.toUpperCase();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@LokiLog(type = LokiLogType.AGV)
|
||||
@Override
|
||||
public Map<String, AgvDto> findAllAgvFromCache() {
|
||||
return AGVDeviceStatus;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package org.nl.acs.agv.service;
|
||||
|
||||
|
||||
import org.nl.acs.agv.dto.AgvDto;
|
||||
import org.nl.acs.task.instruction.domain.Instruction;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Description:
|
||||
* @Date: 2022-08-15
|
||||
*/
|
||||
public interface NDCAgvService {
|
||||
/**
|
||||
* 全部agv
|
||||
* @return
|
||||
*/
|
||||
Map<String, AgvDto> findAllAgvFromCache();
|
||||
|
||||
/**
|
||||
* 删除NDC任务
|
||||
*
|
||||
* @param inst
|
||||
* @throws Exception
|
||||
*/
|
||||
public void deleteAgvInstToNDC(Instruction inst) throws Exception;
|
||||
|
||||
/**
|
||||
* 下发任务
|
||||
* @param agv_system_type
|
||||
* @param inst
|
||||
* @throws Exception
|
||||
*/
|
||||
public void sendAgvInstToNDC(String agv_system_type, Instruction inst) throws Exception;
|
||||
|
||||
/**
|
||||
* 一号agv指令
|
||||
* @param phase
|
||||
* @param index
|
||||
* @param result
|
||||
* @param startPoint
|
||||
* @param nextPoint
|
||||
* @param startHigh
|
||||
* @param nextHigh
|
||||
* @return
|
||||
*/
|
||||
public byte[] sendAgvOneModeInst(int phase, int index, int result, int startPoint, int nextPoint, int startHigh, int nextHigh);
|
||||
|
||||
/**
|
||||
* 下发二号agv指令
|
||||
* @param phase
|
||||
* @param index
|
||||
* @param result
|
||||
* @return
|
||||
*/
|
||||
public byte[] sendAgvTwoModeInst(int phase, int index, int result);
|
||||
|
||||
/**
|
||||
* 下发一号agv指令
|
||||
* @param phase
|
||||
* @param index
|
||||
* @param result
|
||||
* @return
|
||||
*/
|
||||
public byte[] sendAgvOneModeInst(int phase, int index, int result);
|
||||
|
||||
/**
|
||||
* 下发一号agv指令(二次分配)
|
||||
* @param phase
|
||||
* @param index
|
||||
* @param disPoint 新点位
|
||||
* @return
|
||||
*/
|
||||
public byte[] sendAgvOneModeInstDis(int phase, int index, String disPoint);
|
||||
|
||||
/**
|
||||
* 下发充电任务
|
||||
*
|
||||
* @param carno
|
||||
* @return
|
||||
*/
|
||||
public boolean createChargingTaskToNDC(String carno);
|
||||
}
|
||||
@@ -0,0 +1,341 @@
|
||||
package org.nl.acs.autoThread.autoRun.impl.ndcAuto;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.AcsConfig;
|
||||
import org.nl.acs.agv.service.NDCAgvService;
|
||||
import org.nl.acs.autoThread.autoRun.AbstractAutoRunnable;
|
||||
import org.nl.acs.autoThread.service.AutoRunService;
|
||||
import org.nl.acs.device.device.service.DeviceAppService;
|
||||
import org.nl.acs.device.device.service.DeviceService;
|
||||
import org.nl.acs.device.device.service.entity.Device;
|
||||
import org.nl.acs.device.deviceDriver.service.defination.agvDefination.ndc.AgvNdcOneDeviceDriver;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.task.instruction.domain.Instruction;
|
||||
import org.nl.acs.task.instruction.enums.InstructionStatusEnum;
|
||||
import org.nl.acs.task.instruction.service.InstructionService;
|
||||
import org.nl.acs.task.instruction.service.impl.InstructionServiceImpl;
|
||||
import org.nl.common.db.CommonFinalParam;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.config.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.extInterface.wms.service.AcsToWmsService;
|
||||
import org.nl.extInterface.wms.service.impl.AcsToWmsServiceImpl;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
import org.nl.system.service.param.impl.SysParamServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static org.nl.acs.agv.impl.NDCAgvServiceImpl.Bytes2HexString;
|
||||
|
||||
|
||||
/**
|
||||
* Demo class
|
||||
*
|
||||
* @author zhoujj
|
||||
* @date 2023/12/06
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
|
||||
Socket s;
|
||||
String ip = "192.168.46.225";
|
||||
int port = 1234;
|
||||
static DataOutputStream dos;
|
||||
static DataInputStream dis;
|
||||
private int recordTimeOut = 10000;
|
||||
private Date recordTime;
|
||||
String[] ERROR = new String[]{
|
||||
"货叉尖部传感器触发", "S300传感器触发", "载货状态改变", "急停按钮触发", "触边开关出发", "需要复位",
|
||||
"停在充电位", "取货失败", "放货失败", "轮子打滑", "没有动作码不能进入站点", "取货时有货", "丢失定位",
|
||||
"抬叉停止"};
|
||||
boolean bConnected = true;
|
||||
|
||||
boolean isReConnect = false;
|
||||
|
||||
@Autowired
|
||||
ISysParamService paramService;
|
||||
@Autowired
|
||||
AutoRunService autoRunService;
|
||||
@Autowired
|
||||
LuceneExecuteLogService luceneExecuteLogService;
|
||||
|
||||
|
||||
public OneNDCSocketConnectionAutoRun() {
|
||||
this.recordTime = new Date((new Date()).getTime() - (long) this.recordTimeOut);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCode() {
|
||||
return OneNDCSocketConnectionAutoRun.class.getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "NDC在线连接";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void autoRun() throws IOException {
|
||||
System.out.println("NDCAgv链接开始");
|
||||
ISysParamService ISysParamService = SpringContextHolder.getBean(SysParamServiceImpl.class);
|
||||
InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class);
|
||||
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
|
||||
NDCAgvService NDCAgvService = SpringContextHolder.getBean(NDCAgvService.class);
|
||||
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
|
||||
DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class);
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
|
||||
ip = paramService.findByCode(AcsConfig.AGVURL).getValue();
|
||||
port = Integer.parseInt(paramService.findByCode(AcsConfig.AGVPORT).getValue());
|
||||
|
||||
|
||||
try {
|
||||
byte[] b = new byte[1024];
|
||||
s = new Socket(ip, port);
|
||||
dos = new DataOutputStream(s.getOutputStream());
|
||||
dis = new DataInputStream(s.getInputStream());
|
||||
System.out.println("NDCAgv链接成功");
|
||||
log.info("NDCAgv链接成功");
|
||||
while (bConnected) {
|
||||
int count = dis.read(b);
|
||||
|
||||
if (count == -1) {
|
||||
break;
|
||||
}
|
||||
|
||||
int[] arr = new int[count];
|
||||
StringBuffer bs = new StringBuffer();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
int temp = b[i];
|
||||
if (temp < 0) {
|
||||
temp += 256;
|
||||
}
|
||||
arr[i] = temp;
|
||||
StringBuffer bs1 = new StringBuffer("0");
|
||||
bs.append(temp < 16 ? bs1.append(Integer.toHexString(temp)) : Integer.toHexString(temp));
|
||||
}
|
||||
|
||||
boolean flag = false;
|
||||
if (arr[8] * 256 + arr[9] == 0x73) {
|
||||
byte[] data = null;
|
||||
System.out.println("接收agv上报信息:" + bs);
|
||||
//执行阶段
|
||||
int phase = arr[16] * 256 + arr[17];
|
||||
// agv任务号
|
||||
int index = arr[12] * 256 + arr[13];
|
||||
/**
|
||||
* 任务号
|
||||
*/
|
||||
int ikey = arr[26] * 256 + arr[27];
|
||||
//站点号
|
||||
int agvaddr = arr[18] * 256 + arr[19];
|
||||
//车号
|
||||
int carno = arr[20];
|
||||
Instruction link_inst = null;
|
||||
Instruction inst = null;
|
||||
List<Instruction> insts = null;
|
||||
boolean link_flag = false;
|
||||
Device agv_device = null;
|
||||
String old_device_code = null;
|
||||
if (carno != 0) {
|
||||
agv_device = deviceAppService.findDeviceByCode(String.valueOf(carno));
|
||||
}
|
||||
if (ikey != 0) {
|
||||
inst = instructionService.findByCodeFromCache(String.valueOf(ikey));
|
||||
if (ObjectUtil.isEmpty(inst)) {
|
||||
inst = instructionService.findByCode(String.valueOf(ikey));
|
||||
}
|
||||
}
|
||||
if (!ObjectUtil.isEmpty(link_inst)) {
|
||||
link_flag = true;
|
||||
}
|
||||
log.info("接收agv上报信息:" + bs);
|
||||
log.info("接收agv上报信息:" + "phase--" + phase + " index--" + index + " ikey--" + ikey + " agvaddr--" + agvaddr + " Car--" + carno);
|
||||
Device device = null;
|
||||
String device_code = null;
|
||||
|
||||
|
||||
//
|
||||
AgvNdcOneDeviceDriver agvNdcOneDeviceDriver;
|
||||
|
||||
//开始任务/上报订单号
|
||||
if (phase == 0x01) {
|
||||
if (!ObjectUtil.isEmpty(inst)) {
|
||||
inst.setInstruction_status(InstructionStatusEnum.BUSY.getIndex());
|
||||
inst.setAgv_jobno(String.valueOf(index));
|
||||
inst.setSend_status(CommonFinalParam.ONE);
|
||||
instructionService.update(inst);
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
//任务完毕
|
||||
//(无车id及状态)
|
||||
else if (phase == 0x0A) {
|
||||
if (!ObjectUtil.isEmpty(inst)) {
|
||||
instructionService.finish(inst.getInstruction_id());
|
||||
} else {
|
||||
log.warn("指令号:{},未反馈wms任务完成,因为agv上报指令号查询指令为空!");
|
||||
}
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||
log.info("指令号:{},已反馈agv任务完成!");
|
||||
}
|
||||
//请求删除任务
|
||||
//(需要WCS反馈)
|
||||
else if (phase == 0x30) {
|
||||
data = NDCAgvService.sendAgvOneModeInst(0x8F, index, 0, 0, 0, 0, 0);
|
||||
}
|
||||
//任务删除确认
|
||||
//(需要WCS反馈)
|
||||
else if (phase == 0xFF) {
|
||||
|
||||
if (!ObjectUtil.isEmpty(inst)) {
|
||||
if (!ObjectUtil.isEmpty(inst)) {
|
||||
instructionService.cancelNOSendAgv(inst.getInstruction_id());
|
||||
}
|
||||
}
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||
|
||||
} else if (phase == 0x50) {//进入区域
|
||||
if (agvaddr != 0) {
|
||||
old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
|
||||
if (StrUtil.contains(old_device_code, "-")) {
|
||||
String[] point = old_device_code.split("-");
|
||||
device_code = point[0];
|
||||
} else if (StrUtil.contains(old_device_code, ".")) {
|
||||
String[] point = old_device_code.split("\\.");
|
||||
device_code = point[0];
|
||||
} else {
|
||||
device_code = old_device_code;
|
||||
}
|
||||
}
|
||||
device = deviceAppService.findDeviceByCode(device_code);
|
||||
if (ObjectUtil.isEmpty(device_code)) {
|
||||
log.info(agvaddr + "对应设备号为空!");
|
||||
return;
|
||||
}
|
||||
} else if (phase == 0x51) {//离开区域
|
||||
|
||||
if (agvaddr != 0) {
|
||||
old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
|
||||
if (StrUtil.contains(old_device_code, "-")) {
|
||||
String[] point = old_device_code.split("-");
|
||||
device_code = point[0];
|
||||
} else if (StrUtil.contains(old_device_code, ".")) {
|
||||
String[] point = old_device_code.split("\\.");
|
||||
device_code = point[0];
|
||||
} else {
|
||||
device_code = old_device_code;
|
||||
}
|
||||
}
|
||||
device = deviceAppService.findDeviceByCode(device_code);
|
||||
if (ObjectUtil.isEmpty(device_code)) {
|
||||
log.info(agvaddr + "对应设备号为空!");
|
||||
return;
|
||||
}
|
||||
} else if (phase == 0x4D) {
|
||||
/*if (agvaddr != 0) {
|
||||
old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
|
||||
if (StrUtil.contains(old_device_code, "-")) {
|
||||
String[] point = old_device_code.split("-");
|
||||
device_code = point[0];
|
||||
} else if (StrUtil.contains(old_device_code, ".")) {
|
||||
String[] point = old_device_code.split("\\.");
|
||||
device_code = point[0];
|
||||
} else {
|
||||
device_code = old_device_code;
|
||||
}
|
||||
}
|
||||
device = deviceAppService.findDeviceByCode(device_code);
|
||||
if (ObjectUtil.isEmpty(device_code)) {
|
||||
log.info(agvaddr + "对应设备号为空!");
|
||||
return;
|
||||
}*/
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
} else {
|
||||
//上报异常信息
|
||||
//(不需要WCS反馈)
|
||||
if (phase == 0x67) {
|
||||
device = deviceAppService.findDeviceByCode(Integer.toString(arr[27]));
|
||||
} else {
|
||||
device = deviceAppService.findDeviceByCode(Integer.toString(arr[20]));
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(device)) {
|
||||
if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) {
|
||||
agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) device.getDeviceDriver();
|
||||
try {
|
||||
agvNdcOneDeviceDriver.processSocket(arr);
|
||||
} catch (Exception e) {
|
||||
log.error("处理phase:{},发生异常。异常信息:{}", phase, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (!ObjectUtil.isEmpty(data)) {
|
||||
write(data);
|
||||
}
|
||||
|
||||
} else {
|
||||
System.out.println("agv上报不是0073类型动作,不处理");
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
System.out.println("Agv链接异常");
|
||||
log.info("Agv链接异常");
|
||||
log.error("agv连接出现异常:{}", e);
|
||||
if (ObjectUtil.isNotEmpty(s)) {
|
||||
s.close();
|
||||
}
|
||||
System.out.println(e.getMessage());
|
||||
e.printStackTrace();
|
||||
|
||||
} finally {
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
super.after();
|
||||
try {
|
||||
s.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void write(byte[] b) {
|
||||
try {
|
||||
log.info("下发agv数据:" + Bytes2HexString(b));
|
||||
System.out.println("下发agv数据:" + Bytes2HexString(b));
|
||||
dos.write(b);
|
||||
dos.flush();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
try {
|
||||
Thread.sleep(5000L);
|
||||
log.info("再次下发agv数据:" + Bytes2HexString(b));
|
||||
System.out.println("再次下发agv数据:" + Bytes2HexString(b));
|
||||
dos.write(b);
|
||||
dos.flush();
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -701,97 +701,6 @@ public class DeviceServiceImpl extends CommonServiceImpl<DeviceMapper, Device> i
|
||||
|
||||
@Override
|
||||
public void changeDeviceStatus(JSONObject form) {
|
||||
String device_code = form.getString("device_code");
|
||||
if (StrUtil.contains(device_code, "-") && StrUtil.count(device_code, "-") == 2) {
|
||||
String[] point = device_code.split("-");
|
||||
device_code = point[0];
|
||||
}
|
||||
//需要数量
|
||||
String hasGoodStatus = form.getString("hasGoodStatus");
|
||||
if (StrUtil.isEmpty(hasGoodStatus)) {
|
||||
hasGoodStatus = "0";
|
||||
}
|
||||
String batch = form.getString("batch");
|
||||
String material_type = form.getString("material_type");
|
||||
String quantity = form.getString("quantity");
|
||||
String remark = form.getString("remark");
|
||||
String vehicle_code = form.getString("vehicle_code");
|
||||
String islock = form.getString("islock");
|
||||
String requireSucess = form.getString("requireSucess");
|
||||
String requireActionSucess = form.getString("requireActionSucess");
|
||||
String fullrequireSucess = form.getString("fullrequireSucess");
|
||||
if (device_code.indexOf(".") != -1) {
|
||||
device_code = device_code.substring(0, device_code.indexOf("."));
|
||||
}
|
||||
Device device = deviceAppService.findDeviceByCode(device_code);
|
||||
if (ObjectUtil.isEmpty(device)) {
|
||||
throw new BadRequestException(LangProcess.msg("error_isNull", device_code));
|
||||
}
|
||||
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
|
||||
//检测站点
|
||||
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
|
||||
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
|
||||
if (!StrUtil.isEmpty(hasGoodStatus)) {
|
||||
device.setHas_goods(Integer.parseInt(hasGoodStatus));
|
||||
}
|
||||
if (StrUtil.isNotEmpty(material_type)) {
|
||||
standardOrdinarySiteDeviceDriver.setMaterial(material_type);
|
||||
device.setMaterial_type(material_type);
|
||||
} else {
|
||||
standardOrdinarySiteDeviceDriver.setMaterial("");
|
||||
device.setMaterial_type("");
|
||||
}
|
||||
if (StrUtil.isNotEmpty(quantity)) {
|
||||
standardOrdinarySiteDeviceDriver.setQty(quantity);
|
||||
device.setQuantity(quantity);
|
||||
} else {
|
||||
standardOrdinarySiteDeviceDriver.setQty("");
|
||||
device.setQuantity("");
|
||||
}
|
||||
if (StrUtil.isNotEmpty(remark)) {
|
||||
standardOrdinarySiteDeviceDriver.setRemark(remark);
|
||||
device.setRemark(remark);
|
||||
} else {
|
||||
standardOrdinarySiteDeviceDriver.setRemark("");
|
||||
device.setRemark("");
|
||||
}
|
||||
if (StrUtil.isNotEmpty(batch)) {
|
||||
standardOrdinarySiteDeviceDriver.setBatch(batch);
|
||||
device.setBatch(batch);
|
||||
} else {
|
||||
standardOrdinarySiteDeviceDriver.setBatch("");
|
||||
device.setBatch("");
|
||||
}
|
||||
//// WQLObject runpointwo = WQLObject.getWQLObject("acs_device_runpoint");
|
||||
//// JSONObject json = runpointwo.query("device_code ='" + device_code + "'").uniqueResult(0);
|
||||
//// DeviceRunpoint deviceRunpoint = new LambdaQueryChainWrapper<>(deviceRunpointMapper)
|
||||
//// .eq(DeviceRunpoint::getDevice_code, device_code)
|
||||
//// .one();
|
||||
// if (!ObjectUtil.isEmpty(deviceRunpoint)) {
|
||||
//// DeviceRunpointDto obj = json.toJavaObject(DeviceRunpointDto.class);
|
||||
//// deviceRunpoint.setHasgoods(hasGoodStatus);
|
||||
//// deviceRunpoint.setMaterial_type(material_type);
|
||||
//// deviceRunpoint.setBatch(batch);
|
||||
// device.setHas_goods(Integer.parseInt(hasGoodStatus));
|
||||
// device.setMaterial_type(material_type);
|
||||
// device.setRemark(remark);
|
||||
// device.setQuantity(quantity);
|
||||
// device.setBatch(batch);
|
||||
// device.setIslock(islock);
|
||||
//// JSONObject updatejson = (JSONObject) JSONObject.toJSON(obj);
|
||||
//// runpointwo.update(updatejson, "device_code = '" + device_code + "'");
|
||||
// LambdaQueryWrapper<DeviceRunpoint> wrapper = new LambdaQueryWrapper<>();
|
||||
// wrapper.eq(DeviceRunpoint::getDevice_code, device_code);
|
||||
// deviceRunpointMapper.delete(wrapper);
|
||||
// }
|
||||
} else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
|
||||
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
|
||||
standardInspectSiteDeviceDriver.setMaterial(material_type);
|
||||
standardInspectSiteDeviceDriver.setBatch(batch);
|
||||
device.setMaterial_type(material_type);
|
||||
device.setBatch(batch);
|
||||
}
|
||||
}
|
||||
|
||||
public String formatNum(int x) {
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package org.nl.acs.device.deviceDriver.service.defination.agvDefination.ndc;
|
||||
|
||||
import org.nl.acs.device.device.service.entity.Device;
|
||||
import org.nl.acs.device.device.service.enums.DeviceType;
|
||||
import org.nl.acs.device.deviceDriver.service.defination.DeviceDriverDefination;
|
||||
import org.nl.acs.device.deviceDriver.service.driver.DeviceDriver;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* NDC单工位AGV
|
||||
*/
|
||||
@Service
|
||||
public class AgvNdcOneDefination implements DeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "agv_ndc_one";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverName() {
|
||||
return "NDC1楼AGV";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverDescription() {
|
||||
return "NDC1楼AGV";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new AgvNdcOneDeviceDriver()).init(device, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||
return AgvNdcOneDeviceDriver.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceType> getFitDeviceTypes() {
|
||||
List<DeviceType> types = new LinkedList();
|
||||
types.add(DeviceType.agv);
|
||||
return types;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,412 @@
|
||||
package org.nl.acs.device.deviceDriver.service.defination.agvDefination.ndc;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
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.service.NDCAgvService;
|
||||
import org.nl.acs.autoThread.autoRun.impl.ndcAuto.OneNDCSocketConnectionAutoRun;
|
||||
import org.nl.acs.device.device.service.DeviceAppService;
|
||||
import org.nl.acs.device.device.service.DeviceService;
|
||||
import org.nl.acs.device.device.service.entity.Device;
|
||||
import org.nl.acs.device.deviceDriver.service.defination.ordinaryDefination.AbstractStandardDeviceDriver;
|
||||
import org.nl.acs.device.deviceDriver.service.defination.ordinaryDefination.standardOrdinarySite.StandardOrdinarySiteDeviceDriver;
|
||||
import org.nl.acs.log.LokiLog;
|
||||
import org.nl.acs.log.LokiLogType;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.task.instruction.domain.Instruction;
|
||||
import org.nl.acs.task.instruction.service.InstructionService;
|
||||
import org.nl.acs.task.instruction.service.impl.InstructionServiceImpl;
|
||||
import org.nl.acs.task.task.service.TaskService;
|
||||
import org.nl.acs.task.task.service.dto.TaskDto;
|
||||
import org.nl.acs.task.task.service.impl.TaskServiceImpl;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.config.lucene.service.LuceneExecuteLogService;
|
||||
import org.nl.config.thread.ThreadPoolExecutorUtil;
|
||||
import org.nl.extInterface.wms.service.AcsToWmsService;
|
||||
import org.nl.extInterface.wms.service.enums.WmsFeedbackStatusEnum;
|
||||
import org.nl.extInterface.wms.service.impl.AcsToWmsServiceImpl;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
import org.nl.system.service.param.impl.SysParamServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
/**
|
||||
* NDC单工位AGV
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class AgvNdcOneDeviceDriver extends AbstractStandardDeviceDriver {
|
||||
LuceneExecuteLogService lucene = SpringContextHolder.getBean("luceneExecuteLogServiceImpl");
|
||||
ISysParamService paramService = SpringContextHolder.getBean(SysParamServiceImpl.class);
|
||||
InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class);
|
||||
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
|
||||
TaskService taskService = SpringContextHolder.getBean(TaskServiceImpl.class);
|
||||
NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
|
||||
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
|
||||
DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class);
|
||||
@Autowired
|
||||
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl");
|
||||
@Autowired
|
||||
TaskService taskserver = SpringContextHolder.getBean(TaskService.class);
|
||||
private final static ThreadPoolExecutor EXECUTOR = (ThreadPoolExecutor) ThreadPoolExecutorUtil.getPoll();
|
||||
int agvaddr = 0;
|
||||
int agvaddr_copy = 0;
|
||||
int weight = 0;
|
||||
String device_code = "";
|
||||
int phase = 0;
|
||||
boolean flag = false;
|
||||
int x = 0; //x坐标
|
||||
int y = 0; //y坐标
|
||||
int angle = 0; //角度
|
||||
int electric_qty = 0; //电量
|
||||
int status = 0; //agv状态
|
||||
int agv_status = 0; //车辆动作状态
|
||||
int is_have = 0; //是否有货
|
||||
int error = 0; //车辆故障
|
||||
|
||||
String transportOrder = "";
|
||||
boolean isCharge = false;
|
||||
String message = null;
|
||||
String agv_message = "";
|
||||
|
||||
@LokiLog(type = LokiLogType.ACS_TO_LMS)
|
||||
public synchronized void processSocket(int[] arr) throws Exception {
|
||||
device_code = this.getDeviceCode();
|
||||
byte[] data = null;
|
||||
phase = arr[16] * 256 + arr[17];
|
||||
// agv任务号
|
||||
int index = arr[12] * 256 + arr[13];
|
||||
//任务单号和其他状态信息
|
||||
int ikey = arr[26] * 256 + arr[27];
|
||||
//站点号
|
||||
agvaddr = arr[18] * 256 + arr[19];
|
||||
//车号
|
||||
int carno = arr[20];
|
||||
Instruction link_inst = null;
|
||||
List<Instruction> insts = null;
|
||||
Instruction inst = null;
|
||||
boolean link_flag = false;
|
||||
Device agv_device = null;
|
||||
if (carno != 0) {
|
||||
agv_device = deviceAppService.findDeviceByCode(String.valueOf(carno));
|
||||
}
|
||||
if (ikey != 0) {
|
||||
inst = instructionService.findByCodeFromCache(String.valueOf(ikey));
|
||||
if (ObjectUtil.isEmpty(inst)) {
|
||||
inst = instructionService.findByCode(String.valueOf(ikey));
|
||||
}
|
||||
}
|
||||
if (!ObjectUtil.isEmpty(link_inst)) {
|
||||
link_flag = true;
|
||||
}
|
||||
if (error != 0) {
|
||||
//todo 反馈立库AGV故障信息
|
||||
}
|
||||
Device device = null;
|
||||
String old_device_code = null;
|
||||
String emptyNum = null;
|
||||
String device_code = null;
|
||||
|
||||
if (phase == 0x67) {
|
||||
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||
}
|
||||
TaskDto task = new TaskDto();
|
||||
|
||||
if (ObjectUtil.isNotEmpty(inst)) {
|
||||
task = taskService.findById(inst.getTask_id());
|
||||
}
|
||||
//分配 车id
|
||||
//(不需要WCS反馈)
|
||||
if (phase == 0x02) {
|
||||
inst.setCarno(String.valueOf(carno));
|
||||
instructionService.update(inst);
|
||||
transportOrder = inst.getTask_code();
|
||||
//车辆分配任务时 状态为1 执行中
|
||||
task.setTask_status("1");
|
||||
task.setCarno(String.valueOf(carno));
|
||||
taskserver.update(task);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + "反馈:" + data);
|
||||
//车辆状态归零
|
||||
agv_status = 0;
|
||||
|
||||
// 二次分配处理
|
||||
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
// 判断是否需要二次分配
|
||||
if ("".equals(inst.getStart_device_code())) {
|
||||
// 向WMS申请新点位
|
||||
JSONObject response = acsToWmsService.taskRedirection(task.getTask_code(), inst.getStart_device_code());
|
||||
if (response != null && response.getInteger("responseCode") == 0
|
||||
&& ObjectUtil.isNotEmpty(response.getString("locationNew"))) {
|
||||
// 返回NDC更换新位置
|
||||
data = ndcAgvService.sendAgvOneModeInstDis(phase, index, response.getString("locationNew"));
|
||||
}
|
||||
}
|
||||
//(需要WCS反馈)
|
||||
} else if (phase == 0x03) {
|
||||
// 请求取货
|
||||
if (agvaddr == 0) {
|
||||
agvaddr = agvaddr_copy;
|
||||
}
|
||||
if (agvaddr < 1) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase);
|
||||
return;
|
||||
}
|
||||
device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
|
||||
if (agvaddr != 0) {
|
||||
old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
|
||||
if (StrUtil.contains(old_device_code, "-")) {
|
||||
String[] point = old_device_code.split("-");
|
||||
device_code = point[0];
|
||||
} else if (StrUtil.contains(old_device_code, ".")) {
|
||||
String[] point = old_device_code.split("\\.");
|
||||
device_code = point[0];
|
||||
emptyNum = point[1];
|
||||
} else {
|
||||
device_code = old_device_code;
|
||||
}
|
||||
}
|
||||
|
||||
device = deviceAppService.findDeviceByCode(device_code);
|
||||
if (ObjectUtil.isEmpty(device_code)) {
|
||||
log.info(agvaddr + "对应设备号为空!");
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", agvaddr + "对应设备号为空");
|
||||
return;
|
||||
}
|
||||
//校验agv上报站点编号与指令起始点相同
|
||||
if (ObjectUtil.isEmpty(inst)) {
|
||||
log.info("未找到编号{}对应的指令", ikey);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "未找到关联编号对应的指令" + ikey);
|
||||
return;
|
||||
}
|
||||
// "========================================================================请求取货================================================================================="
|
||||
agv_status = 1;
|
||||
//到达普通站点
|
||||
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||
// 请求wms是否可以取货
|
||||
if (acsToWmsService.feedbackTask(inst, WmsFeedbackStatusEnum.APPLY_TAKE.getValue())) {
|
||||
log.info("到达{}取货点开始取货", device_code + "指令号:" + ikey);
|
||||
inst.setExecute_status("1");
|
||||
instructionService.update(inst);
|
||||
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
|
||||
} else if (phase == 0x04) {
|
||||
data = getData(data, index, inst, task);
|
||||
//取货完毕
|
||||
//(需要WCS反馈)
|
||||
} else if (phase == 0x05) {
|
||||
// 取货完成
|
||||
if (agvaddr == 0) {
|
||||
agvaddr = agvaddr_copy;
|
||||
}
|
||||
if (agvaddr < 1) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase);
|
||||
return;
|
||||
}
|
||||
if (agvaddr != 0) {
|
||||
old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
|
||||
if (StrUtil.contains(old_device_code, "-")) {
|
||||
String[] point = old_device_code.split("-");
|
||||
device_code = point[0];
|
||||
} else if (StrUtil.contains(old_device_code, ".")) {
|
||||
String[] point = old_device_code.split("\\.");
|
||||
device_code = point[0];
|
||||
emptyNum = point[1];
|
||||
} else {
|
||||
device_code = old_device_code;
|
||||
}
|
||||
}
|
||||
device = deviceAppService.findDeviceByCode(device_code);
|
||||
if (ObjectUtil.isEmpty(device_code)) {
|
||||
log.info(agvaddr + "对应设备号为空!");
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "对应设备号为空" + device_code);
|
||||
return;
|
||||
}
|
||||
//校验agv上报站点编号与指令起始点相同
|
||||
if (ObjectUtil.isEmpty(inst)) {
|
||||
log.info("未找到关联编号{}对应的指令", ikey);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "未找到关联编号对应的指令" + ikey);
|
||||
return;
|
||||
}
|
||||
// "========================================================================取货完成================================================================================="
|
||||
//反馈车辆动作
|
||||
agv_status = 2;
|
||||
//到达普通站点取货完成
|
||||
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||
// 通知wms取货完成
|
||||
if (acsToWmsService.feedbackTask(inst, WmsFeedbackStatusEnum.TAKE_FINISH.getValue())) {
|
||||
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
log.info("agv进入" + device_code + "取货完成" + "指令号:" + ikey);
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
} else if (phase == 0x06) {
|
||||
//到达放货点
|
||||
// 二次分配处理
|
||||
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
// 判断是否需要二次分配
|
||||
if ("".equals(inst.getStart_device_code())) {
|
||||
// 向WMS申请新点位
|
||||
JSONObject response = acsToWmsService.taskRedirection(task.getTask_code(), inst.getStart_device_code());
|
||||
if (response != null && response.getInteger("responseCode") == 0
|
||||
&& ObjectUtil.isNotEmpty(response.getString("locationNew"))) {
|
||||
// 返回NDC更换新位置
|
||||
data = ndcAgvService.sendAgvOneModeInstDis(phase, index, response.getString("locationNew"));
|
||||
}
|
||||
}
|
||||
} else if (phase == 0x07) {
|
||||
// 请求放货
|
||||
if (agvaddr == 0) {
|
||||
agvaddr = agvaddr_copy;
|
||||
}
|
||||
if (agvaddr < 1) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase);
|
||||
return;
|
||||
}
|
||||
if (agvaddr != 0) {
|
||||
old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
|
||||
if (StrUtil.contains(old_device_code, "-")) {
|
||||
String[] point = old_device_code.split("-");
|
||||
device_code = point[0];
|
||||
} else if (StrUtil.contains(old_device_code, ".")) {
|
||||
String[] point = old_device_code.split("\\.");
|
||||
device_code = point[0];
|
||||
emptyNum = point[1];
|
||||
} else {
|
||||
device_code = old_device_code;
|
||||
}
|
||||
}
|
||||
device = deviceAppService.findDeviceByCode(device_code);
|
||||
if (ObjectUtil.isEmpty(device_code) && !device_code.equals("0")) {
|
||||
log.info(agvaddr + "对应设备号为空!");
|
||||
return;
|
||||
}
|
||||
//校验agv上报站点编号与指令起始点相同
|
||||
if (ObjectUtil.isEmpty(inst)) {
|
||||
log.info("未找到关联编号{}对应的指令", ikey);
|
||||
return;
|
||||
}
|
||||
// "========================================================================请求放货================================================================================="
|
||||
agv_status = 3;
|
||||
//普通站点
|
||||
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||
if (acsToWmsService.feedbackTask(inst, WmsFeedbackStatusEnum.APPLY_PUT.getValue())) {
|
||||
log.info("到达{}放货点", device_code + "指令号:" + ikey);
|
||||
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
|
||||
//放货完毕
|
||||
//(需要WCS反馈)
|
||||
} else if (phase == 0x09) {
|
||||
// 放货完成
|
||||
if (agvaddr == 0) {
|
||||
agvaddr = agvaddr_copy;
|
||||
}
|
||||
if (agvaddr < 1) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase);
|
||||
return;
|
||||
}
|
||||
if (agvaddr != 0) {
|
||||
old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
|
||||
if (StrUtil.contains(old_device_code, "-")) {
|
||||
String[] point = old_device_code.split("-");
|
||||
device_code = point[0];
|
||||
} else if (StrUtil.contains(old_device_code, ".")) {
|
||||
String[] point = old_device_code.split("\\.");
|
||||
device_code = point[0];
|
||||
emptyNum = point[1];
|
||||
} else {
|
||||
device_code = old_device_code;
|
||||
}
|
||||
}
|
||||
device = deviceAppService.findDeviceByCode(device_code);
|
||||
if (ObjectUtil.isEmpty(device_code)) {
|
||||
log.info(agvaddr + "对应设备号为空!");
|
||||
return;
|
||||
}
|
||||
|
||||
//校验agv上报站点编号与指令起始点相同
|
||||
if (ObjectUtil.isEmpty(inst)) {
|
||||
log.info("未找到编号{}对应的指令", ikey);
|
||||
return;
|
||||
}
|
||||
transportOrder = "";
|
||||
// "========================================================================放货完成================================================================================="
|
||||
agv_status = 4;
|
||||
//agv普通站点放货完成
|
||||
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||
if (acsToWmsService.feedbackTask(inst, WmsFeedbackStatusEnum.PUT_FINISH.getValue())) {
|
||||
log.info("{}放货完成", device_code + "指令号:" + ikey);
|
||||
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
//到达位置点
|
||||
//(需要WCS反馈)
|
||||
else if (phase == 0x64) {//param,agv货位id待定
|
||||
//1、根据货位id找到对应三工位设备,赋给agv属性地址对应的满料位设备
|
||||
agvaddr = arr[18] * 256 + arr[19];
|
||||
agvaddr_copy = agvaddr;
|
||||
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||
} else if (phase == 0x50) {//进入交通灯区域
|
||||
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||
} else if (phase == 0x51) {//离开交通灯区域
|
||||
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||
} else if (phase == 0x70) {
|
||||
//x坐标
|
||||
x = ikey;
|
||||
} else if (phase == 0x71) {
|
||||
//y坐标
|
||||
y = ikey;
|
||||
} else if (phase == 0x72) {
|
||||
//车辆角度
|
||||
angle = ikey;
|
||||
} else if (phase == 0x73) {
|
||||
//agv电量
|
||||
electric_qty = ikey;
|
||||
} else if (phase == 0x74) {
|
||||
status = ikey;
|
||||
} else if (phase == 0x75) {
|
||||
is_have = ikey;
|
||||
}
|
||||
if (!ObjectUtil.isEmpty(data)) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||
OneNDCSocketConnectionAutoRun.write(data);
|
||||
}
|
||||
}
|
||||
|
||||
byte[] getData(byte[] data, int index, Instruction inst, TaskDto task) {
|
||||
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws Exception {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -153,7 +153,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver {
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
try {
|
||||
/* try {
|
||||
Thread.sleep(2000);
|
||||
this.devicecode = this.getDevice().getDevice_code();
|
||||
if (this.reqTakeRequireSuccess && ObjectUtil.isNotEmpty(this.reqTakeInstCode)) {
|
||||
@@ -283,7 +283,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver {
|
||||
} catch (Exception e) {
|
||||
System.out.println("--交互异常---");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public class StandardOrdinarySiteDefination implements DeviceDriverDefination {
|
||||
@Override
|
||||
public List<DeviceType> getFitDeviceTypes() {
|
||||
List<DeviceType> types = new LinkedList();
|
||||
types.add(DeviceType.conveyor);
|
||||
types.add(DeviceType.station);
|
||||
return types;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,19 @@
|
||||
package org.nl.acs.device.deviceDriver.service.defination.ordinaryDefination.standardOrdinarySite;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.nl.acs.device.deviceDriver.service.defination.ordinaryDefination.AbstractStandardDeviceDriver;
|
||||
import org.nl.acs.device.storageMgt.service.dto.StorageCellDto;
|
||||
import org.nl.acs.device.storageMgt.service.impl.StorageCellServiceImpl;
|
||||
import org.nl.acs.device.device.service.DeviceAppService;
|
||||
import org.nl.acs.device.deviceDriver.service.defination.ordinaryDefination.AbstractStandardDeviceDriver;
|
||||
import org.nl.acs.task.TaskConfig;
|
||||
import org.nl.acs.task.instruction.domain.Instruction;
|
||||
import org.nl.acs.task.instruction.service.InstructionService;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
import org.nl.extInterface.agvKit.service.AcsToKitService;
|
||||
import org.nl.extInterface.wms.service.AcsToWmsService;
|
||||
import org.nl.extInterface.wms.service.enums.WmsFeedbackStatusEnum;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -74,7 +68,7 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractStandardDeviceDriv
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
try {
|
||||
/* try {
|
||||
Thread.sleep(2000);
|
||||
if (this.reqTakeRequireSuccess && ObjectUtil.isNotEmpty(this.reqTakeInstCode)) {
|
||||
// 驱动按周期执行,当前直接 return 就会停留在等待态,下一轮继续请求 WMS 许可。
|
||||
@@ -198,7 +192,7 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractStandardDeviceDriv
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
log.info("设备执行失败" + ex.getMessage());
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -214,7 +208,7 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractStandardDeviceDriv
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDeviceInnerParam(Map<String,String> innerParamss) {
|
||||
public void setDeviceInnerParam(Map<String, String> innerParamss) {
|
||||
synchronized (lock) {
|
||||
// 不允许设置和上次处理相同的taskId
|
||||
final String taskId = innerParamss.get("taskId");
|
||||
@@ -234,7 +228,7 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractStandardDeviceDriv
|
||||
synchronized (lock) {
|
||||
// 设置新任务
|
||||
// 处理完成,更新状态
|
||||
if (Integer.valueOf(4).equals(agvphase)){
|
||||
if (Integer.valueOf(4).equals(agvphase)) {
|
||||
this.lastTakeInstCode = reqTakeInstCode;
|
||||
}
|
||||
this.reqTakeRequireSuccess = false;
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.nl.acs.log;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author: lyd
|
||||
* @description: 自定义日志注解, 用作LOKI日志分类
|
||||
* @Date: 2022/10/10
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.METHOD})
|
||||
@Documented
|
||||
public @interface LokiLog {
|
||||
LokiLogType type() default LokiLogType.DEFAULT;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.nl.acs.log;
|
||||
|
||||
/**
|
||||
* @author: lyd
|
||||
* @description:
|
||||
* @Date: 2022/10/11
|
||||
*/
|
||||
public enum LokiLogType {
|
||||
// 默认
|
||||
DEFAULT("默认"),
|
||||
// AGV接口日志
|
||||
AGV("AGV接口日志"),
|
||||
// ACS请求LMS
|
||||
ACS_TO_LMS("ACS请求LMS"),
|
||||
// ACS请求立库
|
||||
ACS_TO_LK("ACS请求立库");
|
||||
|
||||
private String desc;
|
||||
|
||||
LokiLogType(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapp
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.nl.ApplicationAutoInitial;
|
||||
import org.nl.acs.agv.service.NDCAgvService;
|
||||
import org.nl.acs.task.instruction.domain.Instruction;
|
||||
import org.nl.acs.task.instruction.domain.InstructionMybatis;
|
||||
import org.nl.acs.task.instruction.enums.InstructionStatusEnum;
|
||||
@@ -53,6 +54,7 @@ import org.nl.common.utils.FileUtil;
|
||||
import org.nl.common.utils.PageUtil;
|
||||
import org.nl.acs.task.instruction.service.InstructionService;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.config.MapOf;
|
||||
import org.nl.config.language.LangProcess;
|
||||
import org.nl.config.lucene.enums.LogLevelEnum;
|
||||
import org.nl.config.lucene.service.LuceneExecuteLogService;
|
||||
@@ -364,20 +366,8 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
dto = foramte(dto);
|
||||
String task_code = dto.getTask_code();
|
||||
TaskDto task = taskService.findByCodeFromCache(task_code);
|
||||
if (task == null) {
|
||||
throw new BadRequestException("任务号为:" + task_code + "的任务不存在!");
|
||||
}
|
||||
|
||||
String start_device_code = dto.getStart_device_code();
|
||||
if (StrUtil.isNotEmpty(dto.getTask_code())) {
|
||||
List<InstructionMybatis> instructionMybatis = instructionMapper.selectList(Wrappers.lambdaQuery(InstructionMybatis.class)
|
||||
.eq(InstructionMybatis::getTask_code, dto.getTask_code()));
|
||||
if (CollUtil.isNotEmpty(instructionMybatis) && instructionMybatis.stream().anyMatch(inst -> inst.getStart_device_code()
|
||||
.equals(start_device_code))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
String currentUsername = SecurityUtils.getCurrentNickName();
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
String now = DateUtil.now();
|
||||
if (StrUtil.isEmpty(dto.getRoute_plan_code())) {
|
||||
dto.setRoute_plan_code(task.getRoute_plan_code());
|
||||
@@ -394,13 +384,10 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
if (StrUtil.isEmpty(dto.getIs_send())) {
|
||||
dto.setIs_send(task.getIs_send());
|
||||
}
|
||||
// if (StrUtil.isEmpty(dto.getLink_num())) {
|
||||
// dto.setIs_send(task.getLink_num());
|
||||
// }
|
||||
if (StrUtil.isEmpty(dto.getVehicle_code2())) {
|
||||
dto.setVehicle_code2(task.getVehicle_code2());
|
||||
if (StrUtil.isEmpty(dto.getLink_num())) {
|
||||
dto.setIs_send(task.getLink_num());
|
||||
}
|
||||
|
||||
dto.setInstruction_type(task.getTask_type());
|
||||
// 起点设备与终点设备相同则为初始指令
|
||||
if (StrUtil.equals(task.getStart_device_code(), dto.getStart_device_code())) {
|
||||
if (!StrUtil.equals(dto.getCompound_inst(), "0")
|
||||
@@ -409,8 +396,9 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
dto.setCompound_inst_data(task.getCompound_task_data());
|
||||
}
|
||||
}
|
||||
dto.setCreate_by(ObjectUtil.isNotEmpty(currentUsername) ? currentUsername : dto.getStart_device_code() + ":自动创建");
|
||||
dto.setUpdate_by(ObjectUtil.isNotEmpty(currentUsername) ? currentUsername : dto.getStart_device_code() + ":自动创建");
|
||||
|
||||
dto.setCreate_by(ObjectUtil.isNotEmpty(currentUsername) ? currentUsername : "admin");
|
||||
dto.setUpdate_by(ObjectUtil.isNotEmpty(currentUsername) ? currentUsername : "admin");
|
||||
dto.setUpdate_time(now);
|
||||
dto.setCreate_time(now);
|
||||
dto.setStart_parent_code(task.getStart_parent_code());
|
||||
@@ -425,59 +413,34 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
|
||||
|
||||
try {
|
||||
/*String start_device_code = dto.getStart_device_code();*/
|
||||
String start_device_code = dto.getStart_device_code();
|
||||
String next_device_code = dto.getNext_device_code();
|
||||
String route_plan_code = task.getRoute_plan_code();
|
||||
List<RouteLineDto> shortPathsList =
|
||||
routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
|
||||
if (ObjectUtils.isEmpty(shortPathsList)) {
|
||||
throw new Exception(dto.getStart_device_code() + "->" + dto.getNext_device_code() + "路由不通");
|
||||
}
|
||||
if (StrUtil.equals(shortPathsList.get(0).getType(), CommonFinalParam.ONE)) {
|
||||
throw new BadRequestException(dto.getStart_device_code() + "->" + dto.getNext_device_code() + "路由类型不是agv类型");
|
||||
}
|
||||
if (shortPathsList.size() > 0 && StrUtil.equals(shortPathsList.get(0).getType(), CommonFinalParam.ONE) && dto.getAgv_system_type().equals(AgvSystemTypeEnum.Two_NDC_System_Type.getIndex()))
|
||||
{
|
||||
// 0为输送、立库任务 1 1楼叉车系统 2 2楼1区域AGV系统 3 2楼2区域AGV系统
|
||||
if (!StrUtil.equals(task.getAgv_system_type(), "0")
|
||||
&& ObjectUtil.isNotEmpty(task.getAgv_system_type())) {
|
||||
if (StrUtil.isBlank(dto.getAgv_inst_type())) {
|
||||
String agv_system_type = task.getAgv_system_type();
|
||||
String task_type = task.getTask_type();
|
||||
if (!StrUtil.equals(agv_system_type, "1")) {
|
||||
dto.setAgv_inst_type("2");
|
||||
|
||||
}
|
||||
dto.setAgv_system_type(task.getAgv_system_type());
|
||||
}
|
||||
try {
|
||||
if (StrUtil.isEmpty(dto.getAgv_inst_type()) || StrUtil.isEmpty(dto.getAgv_system_type())) {
|
||||
log.info("sendAgvInstToNDC 指令校验:" + dto.getInstruction_code() + ",inst_type:" + dto.getInstruction_type()
|
||||
+ ",inst_system_type:" + dto.getAgv_system_type());
|
||||
}
|
||||
HttpResponse httpResponse = acsToKitService.genAgvSchedulingTask(dto, 3);
|
||||
log.warn("下发AGV指令数据," + "指令号:" + dto.getInstruction_code() + ",AGV系统类型:" + dto.getAgv_system_type()
|
||||
+ ",AGV指令类型:" + dto.getInstruction_type());
|
||||
|
||||
} catch (Exception e) {
|
||||
dto.setSend_status("2");
|
||||
dto.setRemark(e.getMessage());
|
||||
e.printStackTrace();
|
||||
log.warn("下发AGV指令异常:" + e);
|
||||
LuceneLogDto logDto1 = LuceneLogDto.builder()
|
||||
.deviceCode(start_device_code)
|
||||
.content("下发AGV指令异常")
|
||||
.build();
|
||||
logDto1.setLogLevel((LogLevelEnum.ERROR));
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto1);
|
||||
}
|
||||
RouteLineDto route = null;
|
||||
for (int i = 0; i < shortPathsList.size(); i++) {
|
||||
RouteLineDto routeLineDto = shortPathsList.get(i);
|
||||
String route_device = routeLineDto.getDevice_code();
|
||||
String route_next_device = routeLineDto.getNext_device_code();
|
||||
if (route_device.equals(dto.getStart_device_code())
|
||||
&& route_next_device.equals(dto.getNext_device_code())) {
|
||||
route = routeLineDto;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ObjectUtil.isEmpty(route)) {
|
||||
throw new BadRequestException(LangProcess.msg("error_isNull", "route"));
|
||||
}
|
||||
// 下发ndc系统
|
||||
if (dto.getAgv_system_type().equals(AgvSystemTypeEnum.One_NDC_System_Type.getIndex())) {
|
||||
NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
|
||||
ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
dto.setSend_status("2");
|
||||
log.error(e.getMessage());
|
||||
throw e;
|
||||
e.printStackTrace();
|
||||
log.error("");
|
||||
}
|
||||
InstructionMybatis entity = ConvertUtil.convert(dto, InstructionMybatis.class);
|
||||
instructionMapper.insert(entity);
|
||||
@@ -819,15 +782,15 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
jo1.put("barrels_status", startdevice.getBarrels_status());
|
||||
deviceService.changeDeviceStatus(jo1);
|
||||
// 如果是无光电的设备 指令完成变更起点、终点状态
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("device_code", entity.getStart_device_code());
|
||||
jo.put("hasGoodStatus", "0");
|
||||
jo.put("material_type", "");
|
||||
jo.put("quantity", "");
|
||||
jo.put("remark", "");
|
||||
jo.put("batch", "");
|
||||
jo.put("islock", "0");
|
||||
deviceService.changeDeviceStatus(jo);
|
||||
// JSONObject jo = new JSONObject();
|
||||
// jo.put("device_code", entity.getStart_device_code());
|
||||
// jo.put("hasGoodStatus", "0");
|
||||
// jo.put("material_type", "");
|
||||
// jo.put("quantity", "");
|
||||
// jo.put("remark", "");
|
||||
// jo.put("batch", "");
|
||||
// jo.put("islock", "0");
|
||||
// deviceService.changeDeviceStatus(jo);
|
||||
|
||||
|
||||
InstructionMybatis ins = ConvertUtil.convert(entity, InstructionMybatis.class);
|
||||
@@ -839,42 +802,16 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
.one();
|
||||
// =0 则不用再次请求
|
||||
if (StrUtil.equals(task.getRequest_again(), "0")) {
|
||||
if (StrUtil.equals(task.getTask_type(), "8")) {
|
||||
//中转为空
|
||||
if (StrUtil.isEmpty(task.getPut_device_code())) {
|
||||
if (StrUtil.equals(task.getNext_device_code(), instnextdevice)) {
|
||||
TaskIdAndStatusDTO taskIdAndStatusDTO = new TaskIdAndStatusDTO();
|
||||
taskIdAndStatusDTO.setTask_id(task.getTask_id());
|
||||
taskIdAndStatusDTO.setTask_status(TaskStatusEnum.FINISHED.getIndex());
|
||||
taskService.finish(taskIdAndStatusDTO);
|
||||
} else {
|
||||
finishAndCreateNextInst(ConvertUtil.convert(entity, Instruction.class));
|
||||
}
|
||||
} else {
|
||||
if (StrUtil.equals(task.getNext_device_code(), instnextdevice)) {
|
||||
finishAndCreateHXInst(ConvertUtil.convert(entity, Instruction.class));
|
||||
} else if (StrUtil.equals(task.getPut_device_code(), instnextdevice)) {
|
||||
TaskIdAndStatusDTO taskIdAndStatusDTO = new TaskIdAndStatusDTO();
|
||||
taskIdAndStatusDTO.setTask_id(task.getTask_id());
|
||||
taskIdAndStatusDTO.setTask_status(TaskStatusEnum.FINISHED.getIndex());
|
||||
taskService.finish(taskIdAndStatusDTO);
|
||||
}
|
||||
}
|
||||
|
||||
if (StrUtil.equals(task.getNext_device_code(), instnextdevice)) {
|
||||
TaskIdAndStatusDTO taskIdAndStatusDTO = new TaskIdAndStatusDTO();
|
||||
taskIdAndStatusDTO.setTask_id(task.getTask_id());
|
||||
taskIdAndStatusDTO.setTask_status(TaskStatusEnum.FINISHED.getIndex());
|
||||
taskService.finish(taskIdAndStatusDTO);
|
||||
} else {
|
||||
if (StrUtil.equals(task.getNext_device_code(), instnextdevice)) {
|
||||
TaskIdAndStatusDTO taskIdAndStatusDTO = new TaskIdAndStatusDTO();
|
||||
taskIdAndStatusDTO.setTask_id(task.getTask_id());
|
||||
taskIdAndStatusDTO.setTask_status(TaskStatusEnum.FINISHED.getIndex());
|
||||
taskService.finish(taskIdAndStatusDTO);
|
||||
} else {
|
||||
finishAndCreateNextInst(ConvertUtil.convert(entity, Instruction.class));
|
||||
}
|
||||
finishAndCreateNextInst((Instruction) entity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// this.reload();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,10 +10,19 @@ public interface AcsToWmsService {
|
||||
*/
|
||||
boolean feedbackTask(TaskDto taskDto, String card, String feedbackStatus);
|
||||
|
||||
/**
|
||||
* ACS反馈WMS任务状态
|
||||
*/
|
||||
boolean feedbackTask(Instruction instruction, String feedbackStatus);
|
||||
|
||||
/**
|
||||
* ACS反馈WMS任务删除
|
||||
*/
|
||||
boolean deprecateTask(TaskDto taskDto, String reason);
|
||||
|
||||
/**
|
||||
* ACS向WMS申请二次分配
|
||||
*/
|
||||
JSONObject taskRedirection(String taskCode, String currLocation);
|
||||
|
||||
boolean deviceStatusUpdate(String deviceCode, Integer status, String statusDescription);
|
||||
|
||||
@@ -5,15 +5,48 @@ import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CreateTaskRequest {
|
||||
/*
|
||||
* 库编号
|
||||
*/
|
||||
private String houseCode;
|
||||
/*
|
||||
* 系统编码
|
||||
*/
|
||||
private String systemCode;
|
||||
/*
|
||||
* 扩展项
|
||||
*/
|
||||
private JSONObject parameters;
|
||||
/*
|
||||
* 任务号
|
||||
*/
|
||||
private String taskCode;
|
||||
/*
|
||||
* 任务类型
|
||||
*/
|
||||
private String taskType;
|
||||
/*
|
||||
* 任务下发时间
|
||||
*/
|
||||
private String taskCreateDateTime;
|
||||
/*
|
||||
* 容器编号
|
||||
*/
|
||||
private String containerCode;
|
||||
/*
|
||||
* 容器类型
|
||||
*/
|
||||
private String containerType;
|
||||
/*
|
||||
* 任务起点
|
||||
*/
|
||||
private String locationFrom;
|
||||
/*
|
||||
* 任务终点
|
||||
*/
|
||||
private String locationTo;
|
||||
/*
|
||||
* 优先级
|
||||
*/
|
||||
private Integer priority;
|
||||
}
|
||||
|
||||
@@ -19,9 +19,13 @@ import org.springframework.stereotype.Service;
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
// 反馈任务状态
|
||||
private static final String FEEDBACK_TASK_PATH = "/restful/api/v3/system_car/feedbackTask";
|
||||
// 删除任务
|
||||
private static final String DEPRECATE_TASK_PATH = "/restful/api/v3/system_car/deprecateTask";
|
||||
// 申请二次分配
|
||||
private static final String TASK_REDIRECTION_PATH = "/restful/api/v3/system_car/taskRedirection";
|
||||
// 反馈设备状态 -- 弃用
|
||||
private static final String DEVICE_STATUS_PATH = "/restful/api/v3/system_car/deviceStatusUpdate";
|
||||
|
||||
private final ISysParamService paramService;
|
||||
@@ -37,7 +41,9 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
body.put("card", StrUtil.blankToDefault(card, ""));
|
||||
body.put("taskType", StrUtil.blankToDefault(taskDto.getTask_type(), ""));
|
||||
body.put("feedbackStatus", feedbackStatus);
|
||||
log.info("feedbackTask接口反馈WMS任务状态输入参数:{}", body);
|
||||
JSONObject response = postJson(buildUrl(FEEDBACK_TASK_PATH), body);
|
||||
log.info("feedbackTask接口反馈WMS任务状态输出参数:{}", response);
|
||||
return isSuccess(response);
|
||||
}
|
||||
|
||||
@@ -51,7 +57,9 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
body.put("card", StrUtil.blankToDefault(instruction.getCarno(), ""));
|
||||
body.put("taskType", StrUtil.blankToDefault(instruction.getInstruction_type(), ""));
|
||||
body.put("feedbackStatus", feedbackStatus);
|
||||
log.info("feedbackTask接口反馈WMS任务状态输入参数:{}", body);
|
||||
JSONObject response = postJson(buildUrl(FEEDBACK_TASK_PATH), body);
|
||||
log.info("feedbackTask接口反馈WMS任务状态输出参数:{}", response);
|
||||
return isSuccess(response);
|
||||
}
|
||||
|
||||
@@ -63,7 +71,9 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
JSONObject body = baseBody();
|
||||
body.put("taskCode", getExternalTaskCode(taskDto));
|
||||
body.put("reason", StrUtil.blankToDefault(reason, ""));
|
||||
log.info("deprecateTask接口ACS删除任务反馈WMS输入参数:{}", body);
|
||||
JSONObject response = postJson(buildUrl(DEPRECATE_TASK_PATH), body);
|
||||
log.info("deprecateTask接口ACS删除任务反馈WMS输出参数:{}", response);
|
||||
return isSuccess(response);
|
||||
}
|
||||
|
||||
@@ -72,7 +82,10 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
JSONObject body = baseBody();
|
||||
body.put("taskCode", taskCode);
|
||||
body.put("currLocation", currLocation);
|
||||
return postJson(buildUrl(TASK_REDIRECTION_PATH), body);
|
||||
log.info("taskRedirection接口ACS二次分配申请WMS输入参数:{}", body);
|
||||
JSONObject json = postJson(buildUrl(TASK_REDIRECTION_PATH), body);
|
||||
log.info("taskRedirection接口ACS二次分配申请WMS输出参数:{}", json);
|
||||
return json;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,6 +18,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
|
||||
@Override
|
||||
public JSONObject createTask(CreateTaskRequest request) {
|
||||
log.info("createTask接口WMS下发搬运任务-----输入参数{}", request);
|
||||
JSONObject response = new JSONObject();
|
||||
try {
|
||||
// 将 WMS 协议报文转换成现有 ACS 任务 DTO,复用已有建单和调度链路。
|
||||
@@ -37,6 +38,8 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
dto.setCompound_task("0");
|
||||
dto.setCreate_type("WMS");
|
||||
dto.setFinish_type("WMS");
|
||||
// 调度系统类型:默认1
|
||||
dto.setAgv_system_type("1");
|
||||
// 当前任务模型没有完整承载 WMS 扩展字段的结构化列,先放入 remark 保留。
|
||||
JSONObject extInfo = new JSONObject();
|
||||
extInfo.put("houseCode", request.getHouseCode());
|
||||
@@ -52,6 +55,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
response.put("responseCode", 1);
|
||||
response.put("responseMessage", ex.getMessage());
|
||||
}
|
||||
log.info("createTask接口WMS下发搬运任务-----输出参数{}", response);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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="AcsToWms" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<!--日志文件输出的文件名-->
|
||||
<FileNamePattern>${LOG_HOME}/ACS请求WMS/%d{yyyy-MM-dd}.%i.log</FileNamePattern>
|
||||
<!--日志文件保留天数-->
|
||||
<maxHistory>15</maxHistory>
|
||||
<!--单个日志最大容量 至少10MB才能看得出来-->
|
||||
<maxFileSize>100MB</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>
|
||||
<appender name="asyncFileAppender" class="ch.qos.logback.classic.AsyncAppender">
|
||||
<appender-ref ref="AcsToWms" />
|
||||
<!-- 设置队列大小,根据您的需求调整 -->
|
||||
<queueSize>512</queueSize>
|
||||
</appender>
|
||||
<logger name="org.nl.extInterface.wms.service.impl.AcsToWmsServiceImpl" level="info" additivity="true">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
</logger>
|
||||
</included>
|
||||
@@ -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="AgvNdcOneDeviceDriver" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<!--日志文件输出的文件名-->
|
||||
<FileNamePattern>${LOG_HOME}/AGV驱动与NDC交互/%d{yyyy-MM-dd}.%i.log</FileNamePattern>
|
||||
<!--日志文件保留天数-->
|
||||
<maxHistory>15</maxHistory>
|
||||
<!--单个日志最大容量 至少10MB才能看得出来-->
|
||||
<maxFileSize>100MB</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>
|
||||
<appender name="asyncFileAppender" class="ch.qos.logback.classic.AsyncAppender">
|
||||
<appender-ref ref="AgvNdcOneDeviceDriver" />
|
||||
<!-- 设置队列大小,根据您的需求调整 -->
|
||||
<queueSize>512</queueSize>
|
||||
</appender>
|
||||
<logger name="org.nl.acs.device.deviceDriver.service.defination.agvDefination.ndc.AgvNdcOneDeviceDriver" level="info" additivity="true">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
</logger>
|
||||
</included>
|
||||
@@ -0,0 +1,33 @@
|
||||
<?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="NDCAgvServiceImpl" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<!--日志文件输出的文件名-->
|
||||
<FileNamePattern>${LOG_HOME}/下发NDC/%d{yyyy-MM-dd}.%i.log</FileNamePattern>
|
||||
<!--日志文件保留天数-->
|
||||
<maxHistory>15</maxHistory>
|
||||
<!--单个日志最大容量 至少10MB才能看得出来-->
|
||||
<maxFileSize>100MB</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>
|
||||
|
||||
<appender name="asyncFileAppender" class="ch.qos.logback.classic.AsyncAppender">
|
||||
<appender-ref ref="NDCAgvServiceImpl" />
|
||||
<!-- 设置队列大小,根据您的需求调整 -->
|
||||
<queueSize>512</queueSize>
|
||||
</appender>
|
||||
<logger name="org.nl.acs.agv.impl.NDCAgvServiceImpl" level="info" additivity="true">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
</logger>
|
||||
</included>
|
||||
@@ -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="NDCSocketConnectionAutoRun" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<!--日志文件输出的文件名-->
|
||||
<FileNamePattern>${LOG_HOME}/NDC交互日志/%d{yyyy-MM-dd}.%i.log</FileNamePattern>
|
||||
<!--日志文件保留天数-->
|
||||
<maxHistory>15</maxHistory>
|
||||
<!--单个日志最大容量 至少10MB才能看得出来-->
|
||||
<maxFileSize>100MB</maxFileSize>a
|
||||
<!--所有日志最多占多大容量-->
|
||||
<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>
|
||||
<appender name="asyncFileAppender" class="ch.qos.logback.classic.AsyncAppender">
|
||||
<appender-ref ref="NDCSocketConnectionAutoRun" />
|
||||
<!-- 设置队列大小,根据您的需求调整 -->
|
||||
<queueSize>512</queueSize>
|
||||
</appender>
|
||||
<logger name="org.nl.acs.autoThread.autoRun.impl.ndcAuto.OneNDCSocketConnectionAutoRun" level="info" additivity="true">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
</logger>
|
||||
</included>
|
||||
@@ -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="WmsToAcs" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<!--日志文件输出的文件名-->
|
||||
<FileNamePattern>${LOG_HOME}/WMS请求ACS/%d{yyyy-MM-dd}.%i.log</FileNamePattern>
|
||||
<!--日志文件保留天数-->
|
||||
<maxHistory>15</maxHistory>
|
||||
<!--单个日志最大容量 至少10MB才能看得出来-->
|
||||
<maxFileSize>100MB</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>
|
||||
<appender name="asyncFileAppender" class="ch.qos.logback.classic.AsyncAppender">
|
||||
<appender-ref ref="WmsToAcs" />
|
||||
<!-- 设置队列大小,根据您的需求调整 -->
|
||||
<queueSize>512</queueSize>
|
||||
</appender>
|
||||
<logger name="org.nl.extInterface.wms.service.impl.WmsToAcsServiceImpl" level="info" additivity="true">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
</logger>
|
||||
</included>
|
||||
@@ -12,39 +12,55 @@ https://juejin.cn/post/6844903775631572999
|
||||
<contextName>nlAdmin</contextName>
|
||||
<property name="log.charset" value="utf-8"/>
|
||||
<property name="log.pattern"
|
||||
value="%black(%contextName-) %red(%d{yyyy-MM-dd HH:mm:ss.SSS}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}) - %cyan(%msg%n)"/>
|
||||
<springProperty scope="context" name="logPath" source="logging.file.path" defaultValue="logs"/>
|
||||
<property name="SYSTEM_NAME" value="${systemName}"/>
|
||||
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
|
||||
value="%cyan(%contextName-) %red(%d{yyyy-MM-dd HH:mm:ss.SSS}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}) - %blue(%msg%n)"/>
|
||||
<property name="LOG_HOME" value="${logPath}"/>
|
||||
<!--引入默认的一些设置-->
|
||||
<include resource="log/OpcLog.xml"/>
|
||||
<include resource="log/AcsToWms.xml"/>
|
||||
<include resource="log/WmsToAcs.xml"/>
|
||||
<include resource="log/AgvNdcOneDeviceDriver.xml"/>
|
||||
<include resource="log/NDCAgvServiceImpl.xml"/>
|
||||
<include resource="log/NDCSocketConnectionAutoRun.xml"/>
|
||||
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<!--withJansi 参数改为true-->
|
||||
<withJansi>true</withJansi>
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<encoder class="com.yomahub.tlog.core.enhance.logback.AspectLogbackEncoder">
|
||||
<pattern>${log.pattern}</pattern>
|
||||
<!--<charset>${log.charset}</charset>-->
|
||||
<!-- <charset>${log.charset}</charset>-->
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
|
||||
<property name="LOG_HOME" value="${logPath}"/>
|
||||
<!-- 按照每天生成日志文件 -->
|
||||
<appender name="FILE" 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>
|
||||
<maxHistory>30</maxHistory>
|
||||
<!--单个日志最大容量 至少10MB才能看得出来-->
|
||||
<maxFileSize>200MB</maxFileSize>
|
||||
<maxFileSize>120MB</maxFileSize>
|
||||
<!--所有日志最多占多大容量-->
|
||||
<totalSizeCap>20GB</totalSizeCap>
|
||||
</rollingPolicy>
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
|
||||
<!--格式化输出:%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>
|
||||
<appender name="luceneAppender" class="org.nl.config.lucene.config.LuceneAppender" >
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>DEBUG</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
<appender name="asyncLuceneAppender" class="ch.qos.logback.classic.AsyncAppender">
|
||||
<appender-ref ref="luceneAppender" />
|
||||
<!-- 设置队列大小 -->
|
||||
<queueSize>512</queueSize>
|
||||
</appender>
|
||||
|
||||
<!--异步到文件-->
|
||||
@@ -53,21 +69,14 @@ https://juejin.cn/post/6844903775631572999
|
||||
<queueSize>500</queueSize>
|
||||
<appender-ref ref="FILE"/>
|
||||
</appender>
|
||||
<appender name="luceneAppender" class="org.nl.config.lucene.config.LuceneAppender"/>
|
||||
<appender name="asyncLuceneAppender" class="org.nl.config.lucene.config.AsyncLuceneAppender">
|
||||
<appender-ref ref="luceneAppender"/>
|
||||
<!-- 设置队列大小,根据您的需求调整 -->
|
||||
<queueSize>512</queueSize>
|
||||
</appender>
|
||||
|
||||
<!--开发环境:打印控制台-->
|
||||
<springProfile name="dev">
|
||||
<root level="info">
|
||||
<!-- <appender-ref ref="asyncLuceneAppender"/>-->
|
||||
<!-- <appender-ref ref="asyncFileAppender"/>-->
|
||||
<appender-ref ref="asyncLuceneAppender"/>
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</root>
|
||||
<!-- <logger name="jdbc" level="ERROR" additivity="true">
|
||||
<logger name="jdbc" level="ERROR" additivity="true">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
</logger>
|
||||
<logger name="org.springframework" level="ERROR" additivity="true">
|
||||
@@ -90,18 +99,10 @@ https://juejin.cn/post/6844903775631572999
|
||||
</logger>
|
||||
<logger name="org.jinterop" level="ERROR" additivity="true">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
</logger>-->
|
||||
</springProfile>
|
||||
|
||||
<!--测试环境:打印控制台-->
|
||||
<springProfile name="test">
|
||||
<!-- 打印sql -->
|
||||
<logger name="org.nl.start.Init" level="info" additivity="false">
|
||||
<appender-ref ref="FILE"/>
|
||||
</logger>
|
||||
<root level="info">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</root>
|
||||
<logger name="org.openscada" level="ERROR" additivity="true">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
</logger>
|
||||
</springProfile>
|
||||
|
||||
<!--生产环境:打印控制台和输出到文件-->
|
||||
@@ -109,14 +110,11 @@ https://juejin.cn/post/6844903775631572999
|
||||
<root level="info">
|
||||
<appender-ref ref="asyncLuceneAppender"/>
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
<!-- <appender-ref ref="CONSOLE"/>-->
|
||||
</root>
|
||||
<logger name="jdbc" level="ERROR" additivity="true">
|
||||
<appender-ref ref="asyncLuceneAppender"/>
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
</logger>
|
||||
<logger name="org.springframework" level="ERROR" additivity="true">
|
||||
<appender-ref ref="asyncLuceneAppender"/>
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
</logger>
|
||||
<logger name="org.hibernate" level="ERROR" additivity="true">
|
||||
@@ -131,6 +129,9 @@ https://juejin.cn/post/6844903775631572999
|
||||
<logger name="org.redisson" level="ERROR" additivity="true">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
</logger>
|
||||
<logger name="org.nl.modules.wql" level="ERROR" additivity="true">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
</logger>
|
||||
<logger name="org.springframework.data" level="ERROR" additivity="true">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
</logger>
|
||||
@@ -138,4 +139,27 @@ https://juejin.cn/post/6844903775631572999
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
</logger>
|
||||
</springProfile>
|
||||
|
||||
|
||||
<!--测试环境:打印控制台-->
|
||||
<springProfile name="test">
|
||||
<root level="INFO">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
</root>
|
||||
<logger name="jdbc.audit" level="ERROR" additivity="false">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
<logger name="jdbc.resultset" level="ERROR" additivity="false">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
<logger name="springfox.documentation" level="ERROR" additivity="false">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
<logger name="jdbc.resultsettable" level="ERROR" additivity="false">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
<logger name="jdbc.sqlonly" level="ERROR" additivity="false">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
</springProfile>
|
||||
</configuration>
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
<template>
|
||||
<!--agv单工位-->
|
||||
<div>
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span">指令相关:</span>
|
||||
</div>
|
||||
<el-form ref="form" :inline="true" :model="form" size="small" label-width="95px">
|
||||
<el-row>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="ip地址" prop="ip_address">
|
||||
<el-input
|
||||
v-model="form.ip_address"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</el-card>
|
||||
<el-card class="box-card" shadow="never">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="role-span" />
|
||||
<el-button
|
||||
:loading="false"
|
||||
icon="el-icon-check"
|
||||
size="mini"
|
||||
style="float: right; padding: 6px 9px"
|
||||
type="primary"
|
||||
@click="doSubmit"
|
||||
>保存
|
||||
</el-button>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
queryDriverConfig,
|
||||
updateConfig
|
||||
} from '@/api/acs/device/driverConfig'
|
||||
import crud from '@/mixins/crud'
|
||||
|
||||
export default {
|
||||
name: 'StandardConveyorControl',
|
||||
mixins: [crud],
|
||||
props: {
|
||||
parentForm: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
form: {
|
||||
ip_address: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.$nextTick(() => {
|
||||
// 从父表单获取设备编码
|
||||
this.device_id = this.$props.parentForm.device_id
|
||||
this.device_code = this.$props.parentForm.device_code
|
||||
queryDriverConfig(this.device_id, this.$props.parentForm.driver_code).then(data => {
|
||||
// 给表单赋值,并且属性不能为空
|
||||
if (data.form) {
|
||||
const arr = Object.keys(data.form)
|
||||
// 不为空
|
||||
if (arr.length > 0) {
|
||||
this.form = data.form
|
||||
}
|
||||
}
|
||||
this.sliceItem()
|
||||
})
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
doSubmit() {
|
||||
this.$refs['form'].validate((valid) => {
|
||||
if (valid) {
|
||||
this.configLoading = true
|
||||
// 根据驱动类型判断是否为路由设备
|
||||
const parentForm = this.parentForm
|
||||
parentForm.is_route = true
|
||||
updateConfig(parentForm, this.form, this.data1, this.data2).then(res => {
|
||||
this.notify('保存成功', 'success')
|
||||
this.configLoading = false
|
||||
}).catch(err => {
|
||||
this.configLoading = false
|
||||
console.log(err.response.data.message)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user