Browse Source

迦南fix

master
psh 1 year ago
parent
commit
65742a4bb6
  1. 72
      acs/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java
  2. 78
      acs/hd/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java
  3. 2
      acs/hd/nladmin-system/src/main/resources/config/application.yml
  4. 30
      acs/hd/nladmin-system/src/main/resources/log/WmsToAcs.xml
  5. 44
      acs/hd/nladmin-system/src/main/resources/logback-spring.xml
  6. 18
      lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/tasks/SendMaterialTask.java
  7. 2
      lms/hd/nladmin-system/src/main/resources/config/application-dev.yml
  8. 4
      lms/hd/nladmin-system/src/main/resources/config/application-prod.yml
  9. 2
      lms/hd/nladmin-system/src/main/resources/config/application.yml

72
acs/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java

@ -22,6 +22,7 @@ import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.opc.DeviceAppServiceImpl;
import org.nl.acs.opc.DeviceType;
import org.nl.exception.BadRequestException;
import org.nl.start.auto.run.NDCSocketConnectionAutoRun;
import org.nl.utils.SpringContextHolder;
import org.slf4j.MDC;
import org.springframework.stereotype.Service;
@ -51,7 +52,7 @@ public class NDCAgvServiceImpl implements NDCAgvService {
try {
MDC.put(log_file_type, log_type);
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) {
int index = Integer.parseInt(inst.getAgv_jobno());
int index = ObjectUtil.isEmpty(inst.getAgv_jobno())?0:Integer.parseInt(inst.getAgv_jobno());
byte indexhigh = (byte) IntToHexHigh(index);
byte indexlow = (byte) IntToHexLow(index);
@ -181,7 +182,7 @@ public class NDCAgvServiceImpl implements NDCAgvService {
};
log.info("下发AGV作业指令--{}", str1);
// NDCSocketConnectionAutoRun.write(b);
NDCSocketConnectionAutoRun.write(b);
System.out.println("下发agv指令数据:" + Bytes2HexString(b));
}
} finally {
@ -230,73 +231,15 @@ public class NDCAgvServiceImpl implements NDCAgvService {
return new byte[0];
}
@Override
public byte[] sendAgvOneModeInst(int phase, int index, int result) {
try {
MDC.put(log_file_type, log_type);
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);
int type = Integer.parseInt(acsConfigService.findConfigFromCache().get(AcsConfig.BUSINESSTYPE));
byte[] b = new byte[]{};
switch (type) {
case 0:
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
};
break;
case 1:
b = new byte[]{(byte) 0X87, (byte) 0XCD,
(byte) 0X00, (byte) 0X08,
(byte) 0X00, (byte) 0X0D,
(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) resulthigh, (byte) resultlow
};
break;
case 2:
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
};
break;
case 5:
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
};
break;
case 7:
b = new byte[]{(byte) 0X87, (byte) 0XCD,
byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD,
(byte) 0X00, (byte) 0X08,
(byte) 0X00, (byte) 0X0A,
(byte) 0X00, (byte) 0X01,
@ -306,15 +249,12 @@ public class NDCAgvServiceImpl implements NDCAgvService {
(byte) 0X01, (byte) 0X12,
(byte) phasehigh, (byte) phaselow
};
break;
}
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;
} finally {
MDC.remove(log_file_type);
}
}

78
acs/hd/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java

@ -162,14 +162,13 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
try {
if (phase == 0x01) {
data = AgvService.sendAgvOneModeInst(phase, index);
if (!ObjectUtil.isEmpty(inst)) {
inst.setInstruction_status("1");
inst.setAgv_jobno(String.valueOf(index));
inst.setSend_status("1");
instructionService.update(inst);
data = AgvService.sendAgvOneModeInst(phase, index, 0);
}
data = AgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
}
//分配 车id
@ -221,22 +220,34 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
//检测站点smart200
if (device.getDeviceDriver() instanceof StandardInspectSiteSmartDeviceDriver) {
standardInspectSiteSmartDeviceDriver = (StandardInspectSiteSmartDeviceDriver) device.getDeviceDriver();
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.IGNOREHASGOODS), "1")) {
inst.setExecute_status("1");
instructionService.update(inst);
data = AgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
} else {
if (device.getHas_goods() != 0) {
inst.setExecute_status("1");
}
}
// 取货完成请求离开
else if (phase == 0x05) {
if (ObjectUtil.isEmpty(inst)) {
logServer.deviceExecuteLog("未找到指令号对应的指令:", "", "", String.valueOf(ikey));
break;
}
if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
standardInspectSiteDeviceDriver.writing(3);
if (standardInspectSiteDeviceDriver.getMode() != 0
&& standardInspectSiteDeviceDriver.getMove() == 0) {
inst.setExecute_status("5");
instructionService.update(inst);
data = AgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
} else {
logServer.deviceExecuteLog(device_code, "", "", "AGV请求取货设备{}无货,无法反馈");
logServer.deviceExecuteLog(device_code, "", "", "AGV取货完成请求离开设备{}有货,无法反馈");
}
}
//检测站点smart200
if (device.getDeviceDriver() instanceof StandardInspectSiteSmartDeviceDriver) {
standardInspectSiteSmartDeviceDriver = (StandardInspectSiteSmartDeviceDriver) device.getDeviceDriver();
//如果是混料区则上送LMS当前点位的字段,同步到st_ivt_structivt仓位库存表
JSONObject jsonObject = new JSONObject();
jsonObject.put("device_code", device_code);
@ -245,10 +256,9 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
jsonObject.put("batch_code", standardInspectSiteSmartDeviceDriver.getBatch_code());
jsonObject.put("product_specifications", standardInspectSiteSmartDeviceDriver.getProduct_specifications());
jsonObject.put("time", standardInspectSiteSmartDeviceDriver.getTime());
jsonObject.put("type","9");
jsonObject.put("type", "9");
acsToWmsService.lnshApplyTaskToWms(jsonObject);
}
// 检验取放货条件
JSONObject agv_check = device_extra_table
.query("is_delete = '0' AND extra_code = 'agv_check' AND device_code = '" + device.getDevice_code() + "'")
@ -268,26 +278,6 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
logServer.deviceExecuteLog(device_code, "", "", "AGV请求取货设备{}未放盖确认,无法反馈");
}
}
}
// 取货完成请求离开
else if (phase == 0x05) {
if (ObjectUtil.isEmpty(inst)) {
logServer.deviceExecuteLog("未找到指令号对应的指令:", "", "", String.valueOf(ikey));
break;
}
if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
standardInspectSiteDeviceDriver.writing(3);
if (standardInspectSiteDeviceDriver.getMode() != 0
&& standardInspectSiteDeviceDriver.getMove() == 0) {
inst.setExecute_status("5");
instructionService.update(inst);
data = AgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
} else {
logServer.deviceExecuteLog(device_code, "", "", "AGV取货完成请求离开设备{}有货,无法反馈");
}
}
// if(!inst.getTask_code().startsWith("-")) {
// //反馈wms系统动作完成
@ -360,6 +350,10 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
} else {
logServer.deviceExecuteLog(device_code, "", "", "AGV放货完成请求离开设备{}无货,无法反馈");
}
} else {
inst.setExecute_status("6");
instructionService.update(inst);
data = AgvService.sendAgvOneModeInst(phase, index, 0);
}
// if(!inst.getTask_code().startsWith("-")){
@ -388,13 +382,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
}
//请求删除任务
else if (phase == 0x30) {
flag = true;
if (!ObjectUtil.isEmpty(inst)) {
data = AgvService.sendAgvOneModeInst(0x8F, index, 0);
} else {
log.info("未找到对应的指令无法删除");
break;
}
}
//任务删除确认
//(需要WCS反馈)
@ -511,31 +499,27 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
if (!ObjectUtil.isEmpty(data)) {
write(data);
}
} catch(Exception e){
} catch (Exception e) {
System.out.println(e);
log.info(e.toString());
log.info(e.getMessage());
e.printStackTrace();
}
} else{
} else {
System.out.println("agv上报不是0073类型动作,不处理");
}
}
} catch(
Exception e)
} catch (
Exception e) {
{
} finally
{
} finally {
}
}
}
@Override

2
acs/hd/nladmin-system/src/main/resources/config/application.yml

@ -2,7 +2,7 @@ spring:
freemarker:
check-template-location: false
profiles:
active: dev
active: prod
jackson:
time-zone: GMT+8
data:

30
acs/hd/nladmin-system/src/main/resources/log/WmsToAcs.xml

@ -1,30 +0,0 @@
<!--<?xml version="1.0" encoding="UTF-8"?>-->
<!--<included>-->
<!-- <springProperty scope="context" name="logPath" source="logging.file.path" defaultValue="logs"/>-->
<!-- <springProperty scope="context" name="lokiUrl" source="loki.url"/>-->
<!-- <property name="LOKI_URL" value="${lokiUrl}"/>-->
<!-- <property name="log.pattern"-->
<!-- value="%black(%contextName-) %red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}) - %gray(%msg%n)"/>-->
<!-- &lt;!&ndash;添加loki&ndash;&gt;-->
<!-- <appender name="lokiAppender" class="com.github.loki4j.logback.Loki4jAppender">-->
<!-- <batchTimeoutMs>1000</batchTimeoutMs>-->
<!-- <http class="com.github.loki4j.logback.ApacheHttpSender">-->
<!-- <url>${LOKI_URL}</url>-->
<!-- </http>-->
<!-- <format>-->
<!-- <label>-->
<!-- <pattern>logType=wms_to_acs</pattern>-->
<!-- </label>-->
<!-- <message>-->
<!-- <pattern>${log.pattern}</pattern>-->
<!-- </message>-->
<!-- <sortByTime>true</sortByTime>-->
<!-- </format>-->
<!-- </appender>-->
<!-- &lt;!&ndash; 打印sql &ndash;&gt;-->
<!-- <logger name="org.nl.acs.ext.wms.service.impl.WmsToAcsServiceImpl" level="info" additivity="false">-->
<!-- <appender-ref ref="lokiAppender" />-->
<!-- </logger>-->
<!--</included>-->

44
acs/hd/nladmin-system/src/main/resources/logback-spring.xml

@ -12,7 +12,7 @@ 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}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}) - %gray(%msg%n)"/>
value="%black(%contextName-) %red(%d{yyyy-MM-dd HH:mm:ss.SSS}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}) - %gray(%msg%n)"/>
<springProperty scope="context" name="logPath" source="logging.file.path" defaultValue="logs"/>
<springProperty scope="context" name="lokiUrl" source="loki.url"/>
<springProperty scope="context" name="systemName" source="loki.systemName"/>
@ -29,8 +29,18 @@ https://juejin.cn/post/6844903775631572999
<include resource="log/AcsToWms.xml"/>
<include resource="log/WmsToAcs.xml"/>
<include resource="log/QueryXZAgvTaskStatus.xml"/>
<include resource="log/NDCSocketConnectionAutoRun.xml"/>-->
<!-- <include resource="log/QueryMagicAgvDeviceStatus.xml"/>-->
-->
<!-- <include resource="log/QueryMagicAgvDeviceStatus.xml"/>-->
<!--FILE 10开始+1-->
<include resource="log/OneNDCSocketConnectionAutoRun.xml"/>
<include resource="log/AgvNdcOneDeviceDriver.xml"/>
<include resource="log/AcsToLk.xml"/>
<include resource="log/LkToAcs.xml"/>
<include resource="log/AcsToWms.xml"/>
<include resource="log/WmsToAcs.xml"/>
<include resource="log/OpcUtil.xml"/>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
@ -39,6 +49,7 @@ https://juejin.cn/post/6844903775631572999
</encoder>
</appender>
<!-- 按照每天生成日志文件 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
@ -81,15 +92,37 @@ https://juejin.cn/post/6844903775631572999
</format>
</appender>
<appender name="ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>error</level>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/ERROR/%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
<!--单个日志最大容量 至少10MB才能看得出来-->
<maxFileSize>200MB</maxFileSize>
<!--所有日志最多占多大容量-->
<totalSizeCap>20GB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
<charset>${log.charset}</charset>
</encoder>
</appender>
<!--开发环境:打印控制台-->
<springProfile name="dev">
<root level="info">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="lokiAppender" />
<appender-ref ref="asyncFileAppender"/>
</root>
<!--logmanage -->
<logger name="org.nl.acs.log.service.impl.DeviceExecuteLogServiceImpl" level="info" additivity="false">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="lokiAppender" />
</logger>
<logger name="jdbc.resultsettable" level="ERROR" additivity="false">
@ -130,15 +163,16 @@ https://juejin.cn/post/6844903775631572999
</logger>
<root level="info">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="lokiAppender" />
</root>
</springProfile>
<!--生产环境:打印控制台和输出到文件-->
<springProfile name="prod">
<root level="info">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="ERROR"/>
<appender-ref ref="lokiAppender" />
<appender-ref ref="asyncFileAppender"/>
</root>
<!--logmanage -->
<logger name="org.nl.acs.log.service.impl.DeviceExecuteLogServiceImpl" level="info" additivity="false">

18
lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/tasks/SendMaterialTask.java

@ -235,17 +235,17 @@ public class SendMaterialTask extends AbstractAcsTask {
PointService pointService = SpringContextHolder.getBean(PointService.class);
// 起点是空位不能搬
// // 起点是空位不能搬
PointDto startPoint = pointService.findByCode(start_point_code);
if (StrUtil.equals(startPoint.getPoint_status(), "00")) {
throw new BadRequestException("起点是空位");
}
// 终点不是空位不能搬
// if (StrUtil.equals(startPoint.getPoint_status(), "00")) {
// throw new BadRequestException("起点是空位");
// }
//
// // 终点不是空位不能搬
PointDto nextPoint = pointService.findByCode(next_point_code);
if (!StrUtil.equals(nextPoint.getPoint_status(), "00")) {
throw new BadRequestException("终点不是空位");
}
// if (!StrUtil.equals(nextPoint.getPoint_status(), "00")) {
// throw new BadRequestException("终点不是空位");
// }
// 判断起点有没有未完成的指令
JSONObject startPointTask = taskTable

2
lms/hd/nladmin-system/src/main/resources/config/application-dev.yml

@ -68,7 +68,7 @@ spring:
multi-statement-alagvslow: true
redis:
#数据库索引
database: ${REDIS_DB:1}
database: ${REDIS_DB:3}
host: ${REDIS_HOST:127.0.0.1}
port: ${REDIS_PORT:6379}
password: ${REDIS_PWD:}

4
lms/hd/nladmin-system/src/main/resources/config/application-prod.yml

@ -157,4 +157,6 @@ jetcache:
maxTotal: 1000
uri:
- redis://localhost:6379
loki:
url: http://localhost:3100/loki/api/v1
systemName: lms

2
lms/hd/nladmin-system/src/main/resources/config/application.yml

@ -2,7 +2,7 @@ spring:
freemarker:
check-template-location: false
profiles:
active: dev
active: prod
jackson:
time-zone: GMT+8
data:

Loading…
Cancel
Save