rev:更新

This commit is contained in:
2026-07-19 10:29:03 +08:00
parent aa1dda4fa2
commit 824400397b
21 changed files with 414 additions and 387 deletions

View File

@@ -76,14 +76,14 @@ public class AppRun {
@GetMapping("/kaishichongdian/{no}") @GetMapping("/kaishichongdian/{no}")
@SaIgnore @SaIgnore
public String kaishichongdian(@PathVariable Integer no) { public String kaishichongdian(@PathVariable Integer no) {
BMSSocketConnectionAutoRun.writeStartCharge(no); BMSSocketConnectionAutoRun.writeStartChargeAndArmExtend(no);
return "Backend service started successfully"; return "Backend service started successfully";
} }
@GetMapping("/tingzhichongdian/{no}") @GetMapping("/tingzhichongdian/{no}")
@SaIgnore @SaIgnore
public String tingzhichongdian(@PathVariable Integer no) { public String tingzhichongdian(@PathVariable Integer no) {
BMSSocketConnectionAutoRun.writeStopCharge(no); BMSSocketConnectionAutoRun.writeStopChargeAndArmRetract(no);
return "Backend service started successfully"; return "Backend service started successfully";
} }
@@ -115,4 +115,3 @@ public class AppRun {
return String.valueOf(armExtended); return String.valueOf(armExtended);
} }
} }

View File

@@ -26,6 +26,7 @@ import org.nl.system.service.param.dao.Param;
import org.nl.system.service.param.impl.SysParamServiceImpl; import org.nl.system.service.param.impl.SysParamServiceImpl;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.net.InetSocketAddress;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
@@ -35,7 +36,6 @@ import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.zip.CRC32;
@Slf4j @Slf4j
@Component @Component
@@ -71,8 +71,10 @@ public class BMSSocketConnectionAutoRun extends AbstractAutoRunnable {
private static final long RECONNECT_DELAY_MS = 3000L; private static final long RECONNECT_DELAY_MS = 3000L;
private static final long CONFIG_REFRESH_MS = 5000L; private static final long CONFIG_REFRESH_MS = 5000L;
private static final long STATUS_EXPIRE_MS = 3000L; private static final long STATUS_EXPIRE_MS = 3000L;
private static final long COMMAND_RESPONSE_WINDOW_MS = 5000L;
private static final int CIRCUIT_FAILURE_THRESHOLD = 5; private static final int CIRCUIT_FAILURE_THRESHOLD = 5;
private static final long CIRCUIT_OPEN_MS = 30000L; private static final long CIRCUIT_OPEN_MS = 30000L;
private static final int LOCAL_PORT_BASE = 10000;
private static final Map<Integer, StationClient> CLIENTS = new ConcurrentHashMap<>(); private static final Map<Integer, StationClient> CLIENTS = new ConcurrentHashMap<>();
private static final AtomicBoolean stopRequested = new AtomicBoolean(false); private static final AtomicBoolean stopRequested = new AtomicBoolean(false);
@@ -137,10 +139,18 @@ public class BMSSocketConnectionAutoRun extends AbstractAutoRunnable {
write(buildFixedFrame(CHARGE_CMD_START, ARM_CMD_NONE, stationNo), stationNo); write(buildFixedFrame(CHARGE_CMD_START, ARM_CMD_NONE, stationNo), stationNo);
} }
public static void writeStartChargeAndArmExtend(int stationNo) {
write(buildFixedFrame(CHARGE_CMD_START, ARM_CMD_EXTEND, stationNo), stationNo);
}
public static void writeStopCharge(int stationNo) { public static void writeStopCharge(int stationNo) {
write(buildFixedFrame(CHARGE_CMD_STOP, ARM_CMD_NONE, stationNo), stationNo); write(buildFixedFrame(CHARGE_CMD_STOP, ARM_CMD_NONE, stationNo), stationNo);
} }
public static void writeStopChargeAndArmRetract(int stationNo) {
write(buildFixedFrame(CHARGE_CMD_STOP, ARM_CMD_RETRACT, stationNo), stationNo);
}
public static void writeChargeComplete(int stationNo) { public static void writeChargeComplete(int stationNo) {
writeStopCharge(stationNo); writeStopCharge(stationNo);
} }
@@ -189,6 +199,41 @@ public class BMSSocketConnectionAutoRun extends AbstractAutoRunnable {
return waitUntil(stationNo, timeoutMs, WaitTarget.CHARGE_STOPPED); return waitUntil(stationNo, timeoutMs, WaitTarget.CHARGE_STOPPED);
} }
private static String armStateToText(int armState) {
switch (armState) {
case ARM_STATE_RETRACTED:
return "退回到位";
case ARM_STATE_EXTENDED:
return "伸出到位";
case ARM_STATE_UNKNOWN:
default:
return "未知";
}
}
private static String chargerStateToText(int chargerState) {
switch (chargerState) {
case CHARGER_STATE_CHARGING:
return "充电中";
case CHARGER_STATE_STOPPED:
return "停止充电/充满";
case CHARGER_STATE_INVALID:
default:
return "未知";
}
}
private static String describeWord7(int word7) {
switch (word7) {
case 0x0000:
return "无附加状态";
case 0x0006:
return "保留位返回0x0006";
default:
return "保留位状态未知";
}
}
public static byte[] buildFixedFrame(int chargeCmd, int armCmd, int stationNo) { public static byte[] buildFixedFrame(int chargeCmd, int armCmd, int stationNo) {
if (stationNo < 0 || stationNo > 0xFFFF) { if (stationNo < 0 || stationNo > 0xFFFF) {
throw new IllegalArgumentException("stationNo must be in [0, 65535]"); throw new IllegalArgumentException("stationNo must be in [0, 65535]");
@@ -203,7 +248,7 @@ public class BMSSocketConnectionAutoRun extends AbstractAutoRunnable {
offset += 2; offset += 2;
writeUInt16BE(frame, offset, stationNo); writeUInt16BE(frame, offset, stationNo);
offset += 2; offset += 2;
writeUInt32BE(frame, offset, calculateCrc32(frame, FRAME_HEAD.length, 6)); writeUInt32BE(frame, offset, 0L);
offset += 4; offset += 4;
System.arraycopy(FRAME_TAIL, 0, frame, offset, FRAME_TAIL.length); System.arraycopy(FRAME_TAIL, 0, frame, offset, FRAME_TAIL.length);
@@ -307,6 +352,10 @@ public class BMSSocketConnectionAutoRun extends AbstractAutoRunnable {
log.warn("BMS站点配置无效stationNo异常: {}", item); log.warn("BMS站点配置无效stationNo异常: {}", item);
continue; continue;
} }
if (LOCAL_PORT_BASE + stationNo > 65535) {
log.warn("BMS站点{}配置无效,本地端口{}超出范围", stationNo, LOCAL_PORT_BASE + stationNo);
continue;
}
if (StrUtil.isBlank(ip)) { if (StrUtil.isBlank(ip)) {
log.warn("BMS站点{}配置无效ip为空", stationNo); log.warn("BMS站点{}配置无效ip为空", stationNo);
continue; continue;
@@ -385,10 +434,12 @@ public class BMSSocketConnectionAutoRun extends AbstractAutoRunnable {
| (long) (source[offset + 3] & 0xFF); | (long) (source[offset + 3] & 0xFF);
} }
private static long calculateCrc32(byte[] source, int offset, int len) { private static long calculateWordChecksum(byte[] source, int offset, int wordCount) {
CRC32 crc32 = new CRC32(); long checksum = 0L;
crc32.update(source, offset, len); for (int i = 0; i < wordCount; i++) {
return crc32.getValue(); checksum += readUInt16BE(source, offset + i * 2);
}
return checksum & 0xFFFFFFFFL;
} }
private static boolean validateChecksum(byte[] frame) { private static boolean validateChecksum(byte[] frame) {
@@ -397,12 +448,12 @@ public class BMSSocketConnectionAutoRun extends AbstractAutoRunnable {
} }
if (frame.length == FRAME_LEN) { if (frame.length == FRAME_LEN) {
long expected = readUInt32BE(frame, FRAME_HEAD.length + 6); long expected = readUInt32BE(frame, FRAME_HEAD.length + 6);
long actual = calculateCrc32(frame, FRAME_HEAD.length, 6); long actual = calculateWordChecksum(frame, FRAME_HEAD.length, 3);
return expected == actual; return expected == actual;
} }
if (frame.length == REPORT_FRAME_LEN) { if (frame.length == REPORT_FRAME_LEN) {
long expected = readUInt32BE(frame, FRAME_HEAD.length + 14); long expected = readUInt32BE(frame, FRAME_HEAD.length + 14);
long actual = calculateCrc32(frame, FRAME_HEAD.length, 14); long actual = calculateWordChecksum(frame, FRAME_HEAD.length, 7);
return expected == actual; return expected == actual;
} }
return false; return false;
@@ -473,6 +524,8 @@ public class BMSSocketConnectionAutoRun extends AbstractAutoRunnable {
private volatile String lastConnectError = ""; private volatile String lastConnectError = "";
private volatile long lastConnectSuccessTimeMs = 0L; private volatile long lastConnectSuccessTimeMs = 0L;
private volatile long lastConnectAttemptTimeMs = 0L; private volatile long lastConnectAttemptTimeMs = 0L;
private volatile String pendingCommandHex;
private volatile long pendingCommandTimeMs = 0L;
private StationClient(StationConfig config) { private StationClient(StationConfig config) {
this.config = config; this.config = config;
@@ -525,6 +578,7 @@ public class BMSSocketConnectionAutoRun extends AbstractAutoRunnable {
.channel(NioSocketChannel.class) .channel(NioSocketChannel.class)
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000) .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000)
.option(ChannelOption.SO_KEEPALIVE, true) .option(ChannelOption.SO_KEEPALIVE, true)
.option(ChannelOption.SO_REUSEADDR, true)
.option(ChannelOption.TCP_NODELAY, true) .option(ChannelOption.TCP_NODELAY, true)
.handler(new ChannelInitializer<SocketChannel>() { .handler(new ChannelInitializer<SocketChannel>() {
@Override @Override
@@ -535,7 +589,9 @@ public class BMSSocketConnectionAutoRun extends AbstractAutoRunnable {
}); });
StationConfig currentConfig = this.config; StationConfig currentConfig = this.config;
ChannelFuture future = bootstrap.connect(currentConfig.ip, currentConfig.port); int localPort = getLocalPort(currentConfig.stationNo);
ChannelFuture future = bootstrap.connect(new InetSocketAddress(currentConfig.ip, currentConfig.port),
new InetSocketAddress(localPort));
future.addListener((ChannelFutureListener) f -> { future.addListener((ChannelFutureListener) f -> {
reconnectScheduled.set(false); reconnectScheduled.set(false);
if (closed.get() || stopRequested.get()) { if (closed.get() || stopRequested.get()) {
@@ -548,7 +604,8 @@ public class BMSSocketConnectionAutoRun extends AbstractAutoRunnable {
if (f.isSuccess()) { if (f.isSuccess()) {
channel = f.channel(); channel = f.channel();
onConnectSuccess(); onConnectSuccess();
log.info("BMS站点{}连接成功 {}:{}", currentConfig.stationNo, currentConfig.ip, currentConfig.port); log.info("BMS站点{}连接成功 localPort={}, remote={}:{}",
currentConfig.stationNo, localPort, currentConfig.ip, currentConfig.port);
} else { } else {
onConnectFailure(f.cause()); onConnectFailure(f.cause());
} }
@@ -602,21 +659,31 @@ public class BMSSocketConnectionAutoRun extends AbstractAutoRunnable {
ensureConnected(); ensureConnected();
return; return;
} }
log.info("下发BMS站点{}数据(HEX): {}", config.stationNo, bytesToHex(data)); String commandHex = bytesToHex(data);
log.info("下发BMS站点{}数据(HEX): {}", config.stationNo, commandHex);
current.writeAndFlush(current.alloc().buffer(data.length).writeBytes(data)).addListener((ChannelFutureListener) future -> { current.writeAndFlush(current.alloc().buffer(data.length).writeBytes(data)).addListener((ChannelFutureListener) future -> {
if (!future.isSuccess()) { if (!future.isSuccess()) {
log.error("下发BMS站点{}数据失败: {}", config.stationNo, bytesToHex(data), future.cause()); log.error("下发BMS站点{}数据失败: {}", config.stationNo, commandHex, future.cause());
Channel failedChannel = future.channel(); Channel failedChannel = future.channel();
if (failedChannel != null && failedChannel.isOpen()) { if (failedChannel != null && failedChannel.isOpen()) {
failedChannel.close(); failedChannel.close();
} }
} else {
pendingCommandHex = commandHex;
pendingCommandTimeMs = System.currentTimeMillis();
} }
}); });
} }
private void updateStatus(byte[] frame) { private void updateStatus(byte[] frame) {
if (!validateChecksum(frame)) { if (!validateChecksum(frame)) {
log.warn("BMS站点{}收到CRC校验失败报文忽略: {}", config.stationNo, bytesToHex(frame)); long expected = frame.length == REPORT_FRAME_LEN ? readUInt32BE(frame, FRAME_HEAD.length + 14) : -1L;
long actual = frame.length == REPORT_FRAME_LEN ? calculateWordChecksum(frame, FRAME_HEAD.length, 7) : -1L;
log.warn("BMS站点{}收到校验失败报文expected=0x{}, actual=0x{}, 忽略: {}",
config.stationNo,
Long.toHexString(expected),
Long.toHexString(actual),
bytesToHex(frame));
return; return;
} }
int dataOffset = FRAME_HEAD.length; int dataOffset = FRAME_HEAD.length;
@@ -625,6 +692,9 @@ public class BMSSocketConnectionAutoRun extends AbstractAutoRunnable {
int armState = readUInt16BE(frame, dataOffset + 4); int armState = readUInt16BE(frame, dataOffset + 4);
int chargerState = readUInt16BE(frame, dataOffset + 6); int chargerState = readUInt16BE(frame, dataOffset + 6);
int reportStationNo = readUInt16BE(frame, dataOffset + 8); int reportStationNo = readUInt16BE(frame, dataOffset + 8);
int reservedWord6 = readUInt16BE(frame, dataOffset + 10);
int reservedWord7 = readUInt16BE(frame, dataOffset + 12);
long checksum = readUInt32BE(frame, dataOffset + 14);
if (reportStationNo != config.stationNo) { if (reportStationNo != config.stationNo) {
log.warn("BMS站点{}收到站点{}上报,忽略异常报文: {}", config.stationNo, reportStationNo, bytesToHex(frame)); log.warn("BMS站点{}收到站点{}上报,忽略异常报文: {}", config.stationNo, reportStationNo, bytesToHex(frame));
return; return;
@@ -636,12 +706,31 @@ public class BMSSocketConnectionAutoRun extends AbstractAutoRunnable {
status.outputCurrentRaw = outputCurrent; status.outputCurrentRaw = outputCurrent;
status.armState = armState; status.armState = armState;
status.chargerState = chargerState; status.chargerState = chargerState;
status.reservedWord6 = reservedWord6;
status.reservedWord7 = reservedWord7;
status.checksum = checksum;
status.lastUpdateTimeMs = System.currentTimeMillis(); status.lastUpdateTimeMs = System.currentTimeMillis();
status.rawFrameHex = bytesToHex(frame); status.rawFrameHex = bytesToHex(frame);
latestStatus = status; latestStatus = status;
log.info("BMS状态更新 stationNo={}, armState={}, chargerState={}, voltageRaw={}, currentRaw={}", String commandHex = pendingCommandHex;
reportStationNo, armState, chargerState, outputVoltage, outputCurrent); if (commandHex != null && status.lastUpdateTimeMs - pendingCommandTimeMs <= COMMAND_RESPONSE_WINDOW_MS) {
log.info("BMS站点{}下发后收到回包: commandHex={}, replyHex={}",
config.stationNo, commandHex, status.rawFrameHex);
pendingCommandHex = null;
pendingCommandTimeMs = 0L;
}
log.info("BMS站点{}状态更新: 机械臂={}, 充电状态={}, 输出电压原始值={}, 输出电流原始值={}, 保留字6=0x{}, 保留字7=0x{}({}), 校验值=0x{}",
reportStationNo,
armStateToText(armState),
chargerStateToText(chargerState),
outputVoltage,
outputCurrent,
Integer.toHexString(reservedWord6),
Integer.toHexString(reservedWord7),
describeWord7(reservedWord7),
Long.toHexString(checksum));
} }
private BmsStationStatus snapshotStatus() { private BmsStationStatus snapshotStatus() {
@@ -652,6 +741,9 @@ public class BMSSocketConnectionAutoRun extends AbstractAutoRunnable {
copy.outputCurrentRaw = source.outputCurrentRaw; copy.outputCurrentRaw = source.outputCurrentRaw;
copy.armState = source.armState; copy.armState = source.armState;
copy.chargerState = source.chargerState; copy.chargerState = source.chargerState;
copy.reservedWord6 = source.reservedWord6;
copy.reservedWord7 = source.reservedWord7;
copy.checksum = source.checksum;
copy.lastUpdateTimeMs = source.lastUpdateTimeMs; copy.lastUpdateTimeMs = source.lastUpdateTimeMs;
copy.rawFrameHex = source.rawFrameHex; copy.rawFrameHex = source.rawFrameHex;
if (copy.lastUpdateTimeMs <= 0 || System.currentTimeMillis() - copy.lastUpdateTimeMs > STATUS_EXPIRE_MS) { if (copy.lastUpdateTimeMs <= 0 || System.currentTimeMillis() - copy.lastUpdateTimeMs > STATUS_EXPIRE_MS) {
@@ -699,6 +791,10 @@ public class BMSSocketConnectionAutoRun extends AbstractAutoRunnable {
return latestStatus.lastUpdateTimeMs; return latestStatus.lastUpdateTimeMs;
} }
private int getLocalPort(int stationNo) {
return LOCAL_PORT_BASE + stationNo;
}
private boolean allowConnectAttempt() { private boolean allowConnectAttempt() {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
if (circuitState == CircuitState.OPEN) { if (circuitState == CircuitState.OPEN) {
@@ -839,6 +935,9 @@ public class BMSSocketConnectionAutoRun extends AbstractAutoRunnable {
public int outputCurrentRaw; public int outputCurrentRaw;
public int armState = ARM_STATE_UNKNOWN; public int armState = ARM_STATE_UNKNOWN;
public int chargerState = CHARGER_STATE_INVALID; public int chargerState = CHARGER_STATE_INVALID;
public int reservedWord6;
public int reservedWord7;
public long checksum;
public long lastUpdateTimeMs; public long lastUpdateTimeMs;
public String rawFrameHex; public String rawFrameHex;
} }

View File

@@ -37,6 +37,8 @@ import static org.nl.acs.agv.server.impl.NDCAgvServiceImpl.Bytes2HexString;
@Slf4j @Slf4j
@Component @Component
public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
private static final long BMS_COMMAND_WAIT_TIMEOUT_MS = 5000L;
static volatile Socket socket; static volatile Socket socket;
String ip = "192.168.46.225"; String ip = "192.168.46.225";
@@ -149,13 +151,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
AgvNdcTwoDeviceDriver agvNdcTwoDeviceDriver; AgvNdcTwoDeviceDriver agvNdcTwoDeviceDriver;
//开始任务 //开始任务
if (phase == 0x01) { if (phase == 0x01) {
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x01").request_direction("AGV->ACS").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).content("phase=0x01ikey=" + ikey + "index=" + index).build());
.request_url("socket://ndc/phase/0x01")
.request_direction("AGV->ACS")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.content("phase=0x01ikey=" + ikey + "index=" + index)
.build());
if (!ObjectUtil.isEmpty(inst)) { if (!ObjectUtil.isEmpty(inst)) {
inst.setInstruction_status("1"); inst.setInstruction_status("1");
@@ -163,26 +159,13 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
inst.setSend_status("1"); inst.setSend_status("1");
instructionService.update(inst); instructionService.update(inst);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x01").request_direction("ACS->AGV").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).response_param(ObjectUtil.isEmpty(data) ? "" : Bytes2HexString(data)).content("已反馈AGVphase=0x01ikey=" + ikey + "index=" + index).build());
.request_url("socket://ndc/phase/0x01")
.request_direction("ACS->AGV")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.response_param(ObjectUtil.isEmpty(data) ? "" : Bytes2HexString(data))
.content("已反馈AGVphase=0x01ikey=" + ikey + "index=" + index)
.build());
} }
} }
//任务完毕 //任务完毕
//无车id及状态 //无车id及状态
else if (phase == 0x14) { else if (phase == 0x14) {
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x14").request_direction("AGV->ACS").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).content("phase=0x14ikey=" + ikey + "index=" + index).build());
.request_url("socket://ndc/phase/0x14")
.request_direction("AGV->ACS")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.content("phase=0x14ikey=" + ikey + "index=" + index)
.build());
if (ObjectUtil.isEmpty(inst)) { if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令号{}对应的指令", ikey); log.info("未找到指令号{}对应的指令", ikey);
} else { } else {
@@ -202,96 +185,37 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
} }
} }
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x14").request_direction("ACS->AGV").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).response_param(ObjectUtil.isEmpty(data) ? "" : Bytes2HexString(data)).content("已反馈AGVphase=0x14ikey=" + ikey + "index=" + index).build());
.request_url("socket://ndc/phase/0x14")
.request_direction("ACS->AGV")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.response_param(ObjectUtil.isEmpty(data) ? "" : Bytes2HexString(data))
.content("已反馈AGVphase=0x14ikey=" + ikey + "index=" + index)
.build());
} }
//请求删除任务 //请求删除任务
//(需要WCS反馈) //(需要WCS反馈)
else if (phase == 0x30) { else if (phase == 0x30) {
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x30").request_direction("AGV->ACS").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).content("phase=0x30ikey=" + ikey + "index=" + index).build());
.request_url("socket://ndc/phase/0x30")
.request_direction("AGV->ACS")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.content("phase=0x30ikey=" + ikey + "index=" + index)
.build());
data = ndcAgvService.sendAgvTwoModeInst(0x8F, index, 0); data = ndcAgvService.sendAgvTwoModeInst(0x8F, index, 0);
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x30").request_direction("ACS->AGV").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).response_param(ObjectUtil.isEmpty(data) ? "" : Bytes2HexString(data)).content("已反馈AGVphase=0x30ikey=" + ikey + "index=" + index).build());
.request_url("socket://ndc/phase/0x30")
.request_direction("ACS->AGV")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.response_param(ObjectUtil.isEmpty(data) ? "" : Bytes2HexString(data))
.content("已反馈AGVphase=0x30ikey=" + ikey + "index=" + index)
.build());
} }
//任务删除确认 //任务删除确认
//(需要WCS反馈) //(需要WCS反馈)
else if (phase == 0xFF) { else if (phase == 0xFF) {
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0xFF").request_direction("AGV->ACS").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).content("phase=0xFFikey=" + ikey + "index=" + index).build());
.request_url("socket://ndc/phase/0xFF")
.request_direction("AGV->ACS")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.content("phase=0xFFikey=" + ikey + "index=" + index)
.build());
if (ObjectUtil.isEmpty(inst)) { if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令号{}对应的指令", ikey); log.info("未找到指令号{}对应的指令", ikey);
} else { } else {
instructionService.cancelNOSendAgv(inst.getInstruction_id()); instructionService.cancelNOSendAgv(inst.getInstruction_id());
} }
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0xFF").request_direction("ACS->AGV").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).response_param(ObjectUtil.isEmpty(data) ? "" : Bytes2HexString(data)).content("已反馈AGVphase=0xFFikey=" + ikey + "index=" + index).build());
.request_url("socket://ndc/phase/0xFF")
.request_direction("ACS->AGV")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.response_param(ObjectUtil.isEmpty(data) ? "" : Bytes2HexString(data))
.content("已反馈AGVphase=0xFFikey=" + ikey + "index=" + index)
.build());
} }
//任务删除结束 //任务删除结束
else if (phase == 0x0F) { else if (phase == 0x0F) {
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x0F").request_direction("AGV->ACS").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).content("phase=0x0Fikey=" + ikey + "index=" + index).build());
.request_url("socket://ndc/phase/0x0F")
.request_direction("AGV->ACS")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.content("phase=0x0Fikey=" + ikey + "index=" + index)
.build());
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x0F").request_direction("ACS->AGV").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).response_param(ObjectUtil.isEmpty(data) ? "" : Bytes2HexString(data)).content("已反馈AGVphase=0x0Fikey=" + ikey + "index=" + index).build());
.request_url("socket://ndc/phase/0x0F")
.request_direction("ACS->AGV")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.response_param(ObjectUtil.isEmpty(data) ? "" : Bytes2HexString(data))
.content("已反馈AGVphase=0x0Fikey=" + ikey + "index=" + index)
.build());
} // 开门 } // 开门
else if (phase == 0x50) { else if (phase == 0x50) {
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x50").request_direction("AGV->ACS").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).content("phase=0x50ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code).build());
.request_url("socket://ndc/phase/0x50")
.request_direction("AGV->ACS")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.content("phase=0x50ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code)
.build());
if (ObjectUtil.isEmpty(device_code)) { if (ObjectUtil.isEmpty(device_code)) {
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x50").request_direction("ACS->AGV").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).response_param("原因: agvaddr=" + agvaddr + " 对应设备号为空").content("未反馈AGVphase=0x50ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code).build());
.request_url("socket://ndc/phase/0x50")
.request_direction("ACS->AGV")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.response_param("原因: agvaddr=" + agvaddr + " 对应设备号为空")
.content("未反馈AGVphase=0x50ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code)
.build());
log.info(agvaddr + "对应设备号为空!"); log.info(agvaddr + "对应设备号为空!");
return; return;
} }
@@ -300,14 +224,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
try { try {
elevatorDoorDeviceDriver.writing("call", "1"); elevatorDoorDeviceDriver.writing("call", "1");
} catch (Exception e) { } catch (Exception e) {
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x50").request_direction("ACS->AGV").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).response_param("原因: 下发开门信号异常: " + e.getMessage()).content("未反馈AGVphase=0x50ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code).build());
.request_url("socket://ndc/phase/0x50")
.request_direction("ACS->AGV")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.response_param("原因: 下发开门信号异常: " + e.getMessage())
.content("未反馈AGVphase=0x50ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code)
.build());
log.info("下发电气信号失败:" + e.getMessage()); log.info("下发电气信号失败:" + e.getMessage());
log.error("下发呼叫电梯信号失败", e); log.error("下发呼叫电梯信号失败", e);
} }
@@ -315,79 +232,31 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
if (elevatorDoorDeviceDriver.getOpen() == 1 && elevatorDoorDeviceDriver.getCall() == 1 && elevatorDoorDeviceDriver.getFire_open() == 1) { if (elevatorDoorDeviceDriver.getOpen() == 1 && elevatorDoorDeviceDriver.getCall() == 1 && elevatorDoorDeviceDriver.getFire_open() == 1) {
log.info("下发开门信号值为:{},读取开门信号值为:{}", elevatorDoorDeviceDriver.getCall(), elevatorDoorDeviceDriver.getOpen()); log.info("下发开门信号值为:{},读取开门信号值为:{}", elevatorDoorDeviceDriver.getCall(), elevatorDoorDeviceDriver.getOpen());
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x50").request_direction("ACS->AGV").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).response_param(ObjectUtil.isEmpty(data) ? "" : Bytes2HexString(data)).content("已反馈AGVphase=0x50ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code).build());
.request_url("socket://ndc/phase/0x50")
.request_direction("ACS->AGV")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.response_param(ObjectUtil.isEmpty(data) ? "" : Bytes2HexString(data))
.content("已反馈AGVphase=0x50ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code)
.build());
} else { } else {
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x50").request_direction("ACS->AGV").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).response_param("原因: 未满足反馈条件, call=" + elevatorDoorDeviceDriver.getCall() + ", open=" + elevatorDoorDeviceDriver.getOpen() + ", fire_open=" + elevatorDoorDeviceDriver.getFire_open()).content("未反馈AGVphase=0x50ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code).build());
.request_url("socket://ndc/phase/0x50")
.request_direction("ACS->AGV")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.response_param("原因: 未满足反馈条件, call=" + elevatorDoorDeviceDriver.getCall() + ", open=" + elevatorDoorDeviceDriver.getOpen() + ", fire_open=" + elevatorDoorDeviceDriver.getFire_open())
.content("未反馈AGVphase=0x50ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code)
.build());
log.info("未下发NDC信号原因: 下发开门信号值为:{},读取开门信号值为:{},读取防火门状态:{}", elevatorDoorDeviceDriver.getCall(), elevatorDoorDeviceDriver.getOpen(), elevatorDoorDeviceDriver.getFire_open()); log.info("未下发NDC信号原因: 下发开门信号值为:{},读取开门信号值为:{},读取防火门状态:{}", elevatorDoorDeviceDriver.getCall(), elevatorDoorDeviceDriver.getOpen(), elevatorDoorDeviceDriver.getFire_open());
} }
} else { } else {
if (elevatorDoorDeviceDriver.getOpen() == 1 && elevatorDoorDeviceDriver.getCall() == 1) { if (elevatorDoorDeviceDriver.getOpen() == 1 && elevatorDoorDeviceDriver.getCall() == 1) {
log.info("下发开门信号值为:{},读取开门信号值为:{}", elevatorDoorDeviceDriver.getCall(), elevatorDoorDeviceDriver.getOpen()); log.info("下发开门信号值为:{},读取开门信号值为:{}", elevatorDoorDeviceDriver.getCall(), elevatorDoorDeviceDriver.getOpen());
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x50").request_direction("ACS->AGV").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).response_param(ObjectUtil.isEmpty(data) ? "" : Bytes2HexString(data)).content("已反馈AGVphase=0x50ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code).build());
.request_url("socket://ndc/phase/0x50")
.request_direction("ACS->AGV")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.response_param(ObjectUtil.isEmpty(data) ? "" : Bytes2HexString(data))
.content("已反馈AGVphase=0x50ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code)
.build());
} else { } else {
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x50").request_direction("ACS->AGV").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).response_param("原因: 未满足反馈条件, call=" + elevatorDoorDeviceDriver.getCall() + ", open=" + elevatorDoorDeviceDriver.getOpen()).content("未反馈AGVphase=0x50ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code).build());
.request_url("socket://ndc/phase/0x50")
.request_direction("ACS->AGV")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.response_param("原因: 未满足反馈条件, call=" + elevatorDoorDeviceDriver.getCall() + ", open=" + elevatorDoorDeviceDriver.getOpen())
.content("未反馈AGVphase=0x50ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code)
.build());
log.info("未下发NDC信号原因: 下发开门信号值为:{},读取开门信号值为:{}", elevatorDoorDeviceDriver.getCall(), elevatorDoorDeviceDriver.getOpen()); log.info("未下发NDC信号原因: 下发开门信号值为:{},读取开门信号值为:{}", elevatorDoorDeviceDriver.getCall(), elevatorDoorDeviceDriver.getOpen());
} }
} }
} else { } else {
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x50").request_direction("ACS->AGV").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).response_param("原因: device_code=" + device_code + " 不是电梯门设备").content("未反馈AGVphase=0x50ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code).build());
.request_url("socket://ndc/phase/0x50")
.request_direction("ACS->AGV")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.response_param("原因: device_code=" + device_code + " 不是电梯门设备")
.content("未反馈AGVphase=0x50ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code)
.build());
log.info(agvaddr + "对应设备号为空!"); log.info(agvaddr + "对应设备号为空!");
} }
} }
// 关门 // 关门
else if (phase == 0x51) { else if (phase == 0x51) {
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x51").request_direction("AGV->ACS").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).content("phase=0x51ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code).build());
.request_url("socket://ndc/phase/0x51")
.request_direction("AGV->ACS")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.content("phase=0x51ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code)
.build());
if (ObjectUtil.isEmpty(device_code)) { if (ObjectUtil.isEmpty(device_code)) {
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x51").request_direction("ACS->AGV").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).response_param("原因: agvaddr=" + agvaddr + " 对应设备号为空").content("未反馈AGVphase=0x51ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code).build());
.request_url("socket://ndc/phase/0x51")
.request_direction("ACS->AGV")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.response_param("原因: agvaddr=" + agvaddr + " 对应设备号为空")
.content("未反馈AGVphase=0x51ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code)
.build());
log.info(agvaddr + "对应设备号为空!"); log.info(agvaddr + "对应设备号为空!");
return; return;
} }
@@ -396,48 +265,20 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
try { try {
elevatorDoorDeviceDriver.writing("call", "0"); elevatorDoorDeviceDriver.writing("call", "0");
} catch (Exception e) { } catch (Exception e) {
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x51").request_direction("ACS->AGV").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).response_param("原因: 下发关门信号异常: " + e.getMessage()).content("未反馈AGVphase=0x51ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code).build());
.request_url("socket://ndc/phase/0x51")
.request_direction("ACS->AGV")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.response_param("原因: 下发关门信号异常: " + e.getMessage())
.content("未反馈AGVphase=0x51ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code)
.build());
log.info("下发电气信号失败:" + e.getMessage()); log.info("下发电气信号失败:" + e.getMessage());
log.error("下发关门信号失败", e); log.error("下发关门信号失败", e);
} }
if (elevatorDoorDeviceDriver.getOpen() == 0 && elevatorDoorDeviceDriver.getCall() == 0) { if (elevatorDoorDeviceDriver.getOpen() == 0 && elevatorDoorDeviceDriver.getCall() == 0) {
log.info("读取关门信号值为:{}", elevatorDoorDeviceDriver.getOpen()); log.info("读取关门信号值为:{}", elevatorDoorDeviceDriver.getOpen());
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x51").request_direction("ACS->AGV").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).response_param(ObjectUtil.isEmpty(data) ? "" : Bytes2HexString(data)).content("已反馈AGVphase=0x51ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code).build());
.request_url("socket://ndc/phase/0x51")
.request_direction("ACS->AGV")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.response_param(ObjectUtil.isEmpty(data) ? "" : Bytes2HexString(data))
.content("已反馈AGVphase=0x51ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code)
.build());
} else { } else {
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x51").request_direction("ACS->AGV").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).response_param("原因: 未满足反馈条件, call=" + elevatorDoorDeviceDriver.getCall() + ", open=" + elevatorDoorDeviceDriver.getOpen()).content("未反馈AGVphase=0x51ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code).build());
.request_url("socket://ndc/phase/0x51")
.request_direction("ACS->AGV")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.response_param("原因: 未满足反馈条件, call=" + elevatorDoorDeviceDriver.getCall() + ", open=" + elevatorDoorDeviceDriver.getOpen())
.content("未反馈AGVphase=0x51ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code)
.build());
log.info("未下发NDC信号原因: 读取自动门信号值为:{}", elevatorDoorDeviceDriver.getOpen()); log.info("未下发NDC信号原因: 读取自动门信号值为:{}", elevatorDoorDeviceDriver.getOpen());
} }
} else { } else {
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x51").request_direction("ACS->AGV").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).response_param("原因: device_code=" + device_code + " 不是电梯门设备").content("未反馈AGVphase=0x51ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code).build());
.request_url("socket://ndc/phase/0x51")
.request_direction("ACS->AGV")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.response_param("原因: device_code=" + device_code + " 不是电梯门设备")
.content("未反馈AGVphase=0x51ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code)
.build());
log.info(device_code + "对应设备号为空!"); log.info(device_code + "对应设备号为空!");
} }
} //请求充电,需要充电桩伸出到位 } //请求充电,需要充电桩伸出到位
@@ -446,83 +287,29 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
//carno是车号 //carno是车号
//ADDR_STATION 是AGV站点号对应的充电桩桩号 //ADDR_STATION 是AGV站点号对应的充电桩桩号
Integer stationNo = ADDR_STATION.get(ikey); Integer stationNo = ADDR_STATION.get(ikey);
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x64").request_direction("AGV->ACS").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).content("phase=0x64ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code + "stationNo=" + stationNo).build());
.request_url("socket://ndc/phase/0x64")
.request_direction("AGV->ACS")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.content("phase=0x64ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code + "stationNo=" + stationNo)
.build());
if (ObjectUtil.isEmpty(stationNo)) { if (ObjectUtil.isEmpty(stationNo)) {
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x64").request_direction("ACS->AGV").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).response_param("原因: ikey=" + ikey + " 未映射到充电桩stationNo").content("未反馈AGVphase=0x64ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code + "stationNo=" + stationNo).build());
.request_url("socket://ndc/phase/0x64") continue;
.request_direction("ACS->AGV") }
.method("NDCSocketConnectionAutoRun.autoRun") try {
.request_param(bs.toString().toUpperCase()) BMSSocketConnectionAutoRun.writeStartChargeAndArmExtend(stationNo);
.response_param("原因: ikey=" + ikey + " 未映射到充电桩stationNo") } catch (Exception e) {
.content("未反馈AGVphase=0x64ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code + "stationNo=" + stationNo) luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x64").request_direction("ACS->AGV").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).response_param("原因: 下发组合命令(开始充电+伸臂)异常: " + e.getMessage()).content("未反馈AGVphase=0x64ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code + "stationNo=" + stationNo).build());
.build());
continue; continue;
} }
boolean armExtended = false; boolean armExtended = false;
try { try {
armExtended = BMSSocketConnectionAutoRun.isArmExtended(stationNo); armExtended = BMSSocketConnectionAutoRun.waitArmExtended(stationNo, BMS_COMMAND_WAIT_TIMEOUT_MS);
} catch (Exception e) { } catch (Exception e) {
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x64").request_direction("ACS->AGV").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).response_param("原因: 等待充电桩伸出到位异常: " + e.getMessage()).content("未反馈AGVphase=0x64ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code + "stationNo=" + stationNo).build());
.request_url("socket://ndc/phase/0x64")
.request_direction("ACS->AGV")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.response_param("原因: 查询充电臂状态异常: " + e.getMessage())
.content("未反馈AGVphase=0x64ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code + "stationNo=" + stationNo)
.build());
continue; continue;
} }
if (armExtended) { if (armExtended) {
try {
BMSSocketConnectionAutoRun.writeStartCharge(stationNo);
}catch (Exception e){
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder()
.request_url("socket://ndc/phase/0x64")
.request_direction("ACS->AGV")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.response_param("原因: 下发开始充电异常: " + e.getMessage())
.content("未反馈AGVphase=0x64ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code + "stationNo=" + stationNo)
.build());
continue;
}
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x64").request_direction("ACS->AGV").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).response_param(ObjectUtil.isEmpty(data) ? "" : Bytes2HexString(data)).content("已反馈AGVphase=0x64ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code + "stationNo=" + stationNo).build());
.request_url("socket://ndc/phase/0x64")
.request_direction("ACS->AGV")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.response_param(ObjectUtil.isEmpty(data) ? "" : Bytes2HexString(data))
.content("已反馈AGVphase=0x64ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code + "stationNo=" + stationNo)
.build());
} else { } else {
try { luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x64").request_direction("ACS->AGV").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).response_param("原因: 已下发组合命令(开始充电+伸臂)但充电桩未伸出到位不给NDC反馈").content("未反馈AGVphase=0x64ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code + "stationNo=" + stationNo).build());
BMSSocketConnectionAutoRun.writeArmExtend(stationNo);
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder()
.request_url("socket://ndc/phase/0x64")
.request_direction("ACS->AGV")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.response_param("原因: 充电臂未伸出,已下发伸臂命令")
.content("未反馈AGVphase=0x64ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code + "stationNo=" + stationNo)
.build());
} catch (Exception e) {
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder()
.request_url("socket://ndc/phase/0x64")
.request_direction("ACS->AGV")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.response_param("原因: 下发伸臂命令异常: " + e.getMessage())
.content("未反馈AGVphase=0x64ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code + "stationNo=" + stationNo)
.build());
continue;
}
} }
} }
//请求离开,需要充电桩缩回到位 //请求离开,需要充电桩缩回到位
@@ -531,61 +318,32 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
//carno是车号 //carno是车号
//ADDR_STATION 是AGV站点号对应的充电桩桩号 //ADDR_STATION 是AGV站点号对应的充电桩桩号
Integer stationNo = ADDR_STATION.get(ikey); Integer stationNo = ADDR_STATION.get(ikey);
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x66").request_direction("AGV->ACS").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).content("phase=0x66ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code + "stationNo=" + stationNo).build());
.request_url("socket://ndc/phase/0x66")
.request_direction("AGV->ACS")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.content("phase=0x66ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code + "stationNo=" + stationNo)
.build());
if (ObjectUtil.isEmpty(stationNo)) { if (ObjectUtil.isEmpty(stationNo)) {
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x66").request_direction("ACS->AGV").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).response_param("原因: ikey=" + ikey + " 未映射到充电桩stationNo").content("未反馈AGVphase=0x66ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code + "stationNo=" + stationNo).build());
.request_url("socket://ndc/phase/0x66")
.request_direction("ACS->AGV")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.response_param("原因: ikey=" + ikey + " 未映射到充电桩stationNo")
.content("未反馈AGVphase=0x66ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code + "stationNo=" + stationNo)
.build());
continue; continue;
} }
boolean armRetracted = BMSSocketConnectionAutoRun.isArmRetracted(stationNo); try {
if (armRetracted) { BMSSocketConnectionAutoRun.writeStopChargeAndArmRetract(stationNo);
try { } catch (Exception e) {
BMSSocketConnectionAutoRun.writeStopCharge(stationNo); luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x66").request_direction("ACS->AGV").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).response_param("原因: 下发组合命令(停止充电+退回伸臂)异常," + e.getMessage()).content("未反馈AGVphase=0x66ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code + "stationNo=" + stationNo).build());
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); continue;
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder()
.request_url("socket://ndc/phase/0x66")
.request_direction("ACS->AGV")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.response_param(ObjectUtil.isEmpty(data) ? "" : Bytes2HexString(data))
.content("已反馈AGVphase=0x66ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code + "stationNo=" + stationNo)
.build());
} catch (Exception e) {
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder()
.request_url("socket://ndc/phase/0x66")
.request_direction("ACS->AGV")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.response_param("原因: 停止充电或反馈异常: " + e.getMessage())
.content("未反馈AGVphase=0x66ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code + "stationNo=" + stationNo)
.build());
}
} else {
BMSSocketConnectionAutoRun.writeStopCharge(stationNo);
BMSSocketConnectionAutoRun.writeArmRetract(stationNo);
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder()
.request_url("socket://ndc/phase/0x66")
.request_direction("ACS->AGV")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.response_param("原因: 充电臂未缩回到位,下发退回")
.content("未反馈AGVphase=0x66ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code + "stationNo=" + stationNo)
.build());
} }
} //退回到位
else { boolean armRetracted = false;
try {
armRetracted = BMSSocketConnectionAutoRun.waitArmRetracted(stationNo, BMS_COMMAND_WAIT_TIMEOUT_MS);
} catch (Exception e) {
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x66").request_direction("ACS->AGV").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).response_param("原因: 等待停止充电/退回到位异常: " + e.getMessage()).content("未反馈AGVphase=0x66ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code + "stationNo=" + stationNo).build());
continue;
}
if (armRetracted) {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x66").request_direction("ACS->AGV").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).response_param(ObjectUtil.isEmpty(data) ? "" : Bytes2HexString(data)).content("已反馈AGVphase=0x66ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code + "stationNo=" + stationNo).build());
} else {
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x66").request_direction("ACS->AGV").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).response_param("原因: 已下发组合命令(停止充电+退回伸臂)但充电桩未同时满足停止充电和退回到位不给NDC反馈").content("未反馈AGVphase=0x66ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code + "stationNo=" + stationNo).build());
}
} else {
if (phase == 0x70 || phase == 0x71 || phase == 0x72 || phase == 0x73 || phase == 0x74) { if (phase == 0x70 || phase == 0x71 || phase == 0x72 || phase == 0x73 || phase == 0x74) {
device = deviceAppService.findDeviceByCode(Integer.toString(arr[18] * 256 + arr[19])); device = deviceAppService.findDeviceByCode(Integer.toString(arr[18] * 256 + arr[19]));
} else { } else {
@@ -598,14 +356,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
agvNdcTwoDeviceDriver.processSocket(arr); agvNdcTwoDeviceDriver.processSocket(arr);
} }
} else { } else {
luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.interfaceExecuteLog(LuceneLogDto.builder().request_url("socket://ndc/phase/0x" + Integer.toHexString(phase).toUpperCase()).request_direction("ACS->AGV").method("NDCSocketConnectionAutoRun.autoRun").request_param(bs.toString().toUpperCase()).response_param("原因: 当前phase=" + phase + " 未找到对应设备").content("未反馈AGVphase=0x" + Integer.toHexString(phase).toUpperCase() + "ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code).build());
.request_url("socket://ndc/phase/0x" + Integer.toHexString(phase).toUpperCase())
.request_direction("ACS->AGV")
.method("NDCSocketConnectionAutoRun.autoRun")
.request_param(bs.toString().toUpperCase())
.response_param("原因: 当前phase=" + phase + " 未找到对应设备")
.content("未反馈AGVphase=0x" + Integer.toHexString(phase).toUpperCase() + "ikey=" + ikey + "index=" + index + "agvaddr=" + agvaddr + "device_code=" + device_code)
.build());
log.info("当前phase" + phase + "未找到对应设备"); log.info("当前phase" + phase + "未找到对应设备");
} }
} catch (Exception e) { } catch (Exception e) {

View File

@@ -83,6 +83,17 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
String error_type = "agv_error_type"; String error_type = "agv_error_type";
/**
* 屏蔽拆封盖机需要用到
* 四点任务从拆包机对接位->料筒库缓存位空位;从料筒库缓存位空桶位->拆包机对接位;
* 在拆包机对接位取货完成后,需要人工确认盖盖子
* 在拆包机对接位放货前,需要人工拆盖子
* 拆盖标记 open_flag 封盖标记close_flag
*/
private boolean open_flag = false;
private boolean close_flag = false;
private Integer lastPhase = 0; private Integer lastPhase = 0;
/** /**

View File

@@ -53,6 +53,7 @@ public class WmsToAcsController {
@PostMapping("/areaControl") @PostMapping("/areaControl")
@Log(value = "区域控制") @Log(value = "区域控制")
@SaIgnore
public ResponseEntity<Object> areaControl(@RequestBody JSONObject whereJson) { public ResponseEntity<Object> areaControl(@RequestBody JSONObject whereJson) {
return new ResponseEntity<>(wmstoacsService.areaControl(whereJson), HttpStatus.OK); return new ResponseEntity<>(wmstoacsService.areaControl(whereJson), HttpStatus.OK);
} }

View File

@@ -455,15 +455,21 @@ public class PdaIosOutServiceImpl implements PdaIosOutService {
throw new BadRequestException("该点位存在正在执行的任务,请核对!"); throw new BadRequestException("该点位存在正在执行的任务,请核对!");
} }
iSchBasePointService.update(new LambdaUpdateWrapper<SchBasePoint>() if ("1".equals(whereJson.getString("point_status"))) {
.set(SchBasePoint::getPoint_status, whereJson.getString("point_status")) iSchBasePointService.update(new LambdaUpdateWrapper<SchBasePoint>()
.set("1".equals(whereJson.getString("point_status")), SchBasePoint::getVehicle_code, null) .set(SchBasePoint::getPoint_status, whereJson.getString("point_status"))
.set("1".equals(whereJson.getString("point_status")), SchBasePoint::getVehicle_type, "") .set(SchBasePoint::getVehicle_code, "")
.set("1".equals(whereJson.getString("point_status")), SchBasePoint::getVehicle_qty, 0) .set(SchBasePoint::getVehicle_type, "")
.set("2".equals(whereJson.getString("point_status")),SchBasePoint::getVehicle_code, vehicle_code) .set(SchBasePoint::getVehicle_qty, 0)
.set("2".equals(whereJson.getString("point_status")),SchBasePoint::getVehicle_type, vehicleInfo.getStoragevehicle_type()) .eq(SchBasePoint::getPoint_code, whereJson.getString("point_code")));
.set("2".equals(whereJson.getString("point_status")),SchBasePoint::getVehicle_qty, 1) } else {
.eq(SchBasePoint::getPoint_code, whereJson.getString("point_code"))); iSchBasePointService.update(new LambdaUpdateWrapper<SchBasePoint>()
.set(SchBasePoint::getPoint_status, whereJson.getString("point_status"))
.set(SchBasePoint::getVehicle_code, vehicle_code)
.set(SchBasePoint::getVehicle_type, vehicleInfo.getStoragevehicle_type())
.set(SchBasePoint::getVehicle_qty, 1)
.eq(SchBasePoint::getPoint_code, whereJson.getString("point_code")));
}
//查询点位上的载具 //查询点位上的载具
List<SchBasePoint> schBasePointList = iSchBasePointService.list(new LambdaQueryWrapper<SchBasePoint>() List<SchBasePoint> schBasePointList = iSchBasePointService.list(new LambdaQueryWrapper<SchBasePoint>()

View File

@@ -2,6 +2,7 @@ package org.nl.wms.sch_manage.service.util;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpStatus; import cn.hutool.http.HttpStatus;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
@@ -15,6 +16,9 @@ import org.nl.wms.ext_manage.service.util.AcsResponse;
import org.nl.wms.sch_manage.enums.TaskStatus; import org.nl.wms.sch_manage.enums.TaskStatus;
import org.nl.wms.sch_manage.service.ISchBaseTaskService; import org.nl.wms.sch_manage.service.ISchBaseTaskService;
import org.nl.wms.sch_manage.service.dao.SchBaseTask; import org.nl.wms.sch_manage.service.dao.SchBaseTask;
import org.nl.wms.system_manage.enums.SysParamConstant;
import org.nl.wms.system_manage.service.param.ISysParamService;
import org.nl.wms.system_manage.service.param.dao.Param;
import org.nl.wms.warehouse_manage.enums.IOSConstant; import org.nl.wms.warehouse_manage.enums.IOSConstant;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -48,6 +52,8 @@ public abstract class AbstractTask {
private WmsToAcsService wmsToAcsService; private WmsToAcsService wmsToAcsService;
@Autowired @Autowired
private TaskFactory taskFactory; private TaskFactory taskFactory;
@Autowired
private ISysParamService sysParamService;
/** /**
* 任务创建 * 任务创建
@@ -73,6 +79,27 @@ public abstract class AbstractTask {
acsTaskDto.setTask_group_seq(taskDao.getTask_group_seq()); acsTaskDto.setTask_group_seq(taskDao.getTask_group_seq());
} }
/**
* AGV扫码关闭时兼容旧ACS任务类型
* 2 -> 13 -> 4开启扫码时保持原值。
*/
protected String normalizeAgvSystemType(String agvSystemType) {
if (StrUtil.isBlank(agvSystemType)) {
return agvSystemType;
}
Param param = sysParamService.findByCode(SysParamConstant.IS_OPEN_AGV_SCANNER);
if (param == null || !StrUtil.equals(param.getValue(), "0")) {
return agvSystemType;
}
if (StrUtil.equals(agvSystemType, "2")) {
return "1";
}
if (StrUtil.equals(agvSystemType, "3")) {
return "4";
}
return agvSystemType;
}
/** /**
* 定时任务 * 定时任务
*/ */

View File

@@ -110,10 +110,10 @@ public class JbDownAgvTask extends AbstractTask {
acsTaskDto.setStart_device_code2(taskDao.getPoint_code3()); acsTaskDto.setStart_device_code2(taskDao.getPoint_code3());
acsTaskDto.setNext_device_code2(taskDao.getPoint_code4()); acsTaskDto.setNext_device_code2(taskDao.getPoint_code4());
// 解包出桶四点任务 -> ACS 类型 3 // 解包出桶四点任务 -> ACS 类型 3
acsTaskDto.setAgv_system_type("3"); acsTaskDto.setAgv_system_type(normalizeAgvSystemType("3"));
} else { } else {
// 解包出桶两点任务 -> ACS 类型 2 // 解包出桶两点任务 -> ACS 类型 2
acsTaskDto.setAgv_system_type("2"); acsTaskDto.setAgv_system_type(normalizeAgvSystemType("2"));
} }
acsTaskDto.setTask_group_id(taskDao.getTask_group_id()); acsTaskDto.setTask_group_id(taskDao.getTask_group_id());
acsTaskDto.setTask_group_seq(taskDao.getTask_group_seq()); acsTaskDto.setTask_group_seq(taskDao.getTask_group_seq());

View File

@@ -100,7 +100,7 @@ public class JbDownCloseUnsealingAgvTask extends AbstractTask {
acsTaskDto.setNext_device_code(taskDao.getPoint_code2()); acsTaskDto.setNext_device_code(taskDao.getPoint_code2());
acsTaskDto.setStart_device_code2(taskDao.getPoint_code3()); acsTaskDto.setStart_device_code2(taskDao.getPoint_code3());
acsTaskDto.setNext_device_code2(taskDao.getPoint_code4()); acsTaskDto.setNext_device_code2(taskDao.getPoint_code4());
acsTaskDto.setAgv_system_type("3"); acsTaskDto.setAgv_system_type(normalizeAgvSystemType("3"));
acsTaskDto.setPriority(taskDao.getPriority()); acsTaskDto.setPriority(taskDao.getPriority());
acsTaskDto.setTask_type(taskconfig.getTask_type()); acsTaskDto.setTask_type(taskconfig.getTask_type());
acsTaskDto.setTruss_type(object.getString("truss_type")); acsTaskDto.setTruss_type(object.getString("truss_type"));

View File

@@ -131,7 +131,7 @@ public class SeparateMaterialTask extends AbstractTask {
acsTaskDto.setStart_device_code2(taskDao.getPoint_code3()); acsTaskDto.setStart_device_code2(taskDao.getPoint_code3());
acsTaskDto.setNext_device_code2(taskDao.getPoint_code4()); acsTaskDto.setNext_device_code2(taskDao.getPoint_code4());
acsTaskDto.setPriority(taskDao.getPriority()); acsTaskDto.setPriority(taskDao.getPriority());
acsTaskDto.setAgv_system_type("2"); acsTaskDto.setAgv_system_type(normalizeAgvSystemType("2"));
acsTaskDto.setTask_type("2"); acsTaskDto.setTask_type("2");
fillCommonAcsTaskFields(taskDao, acsTaskDto); fillCommonAcsTaskFields(taskDao, acsTaskDto);
return acsTaskDto; return acsTaskDto;

View File

@@ -22,6 +22,11 @@ public class SysParamConstant {
*/ */
public final static String ACS_URL = "acs_url"; public final static String ACS_URL = "acs_url";
/**
* 是否开启AGV扫码识别
*/
public final static String IS_OPEN_AGV_SCANNER = "is_open_agv_scanner";
/** /**
* ERP系统IP * ERP系统IP
*/ */

View File

@@ -25,7 +25,7 @@ public enum IOSEnum {
IO_TYPE(MapOf.of("入库", "0", "出库", "1")), IO_TYPE(MapOf.of("入库", "0", "出库", "1")),
//单据状态 //单据状态
BILL_STATUS(MapOf.of("生成", "10", "分配中", "20", "分配完", "30", "完成", "99")), BILL_STATUS(MapOf.of("生成", "10", "审核", "15", "分配中", "20", "分配完", "30", "完成", "99")),
// 入库业务类型 // 入库业务类型
BILL_TYPE(MapOf.of("生产入库", "0001", "手工入库", "0009", "解包入库", "0011", "解包直接入库", "0016", "手工出库", "1009", "解包出库", "1012")), BILL_TYPE(MapOf.of("生产入库", "0001", "手工入库", "0009", "解包入库", "0011", "解包直接入库", "0016", "手工出库", "1009", "解包出库", "1012")),

View File

@@ -80,6 +80,13 @@ public class OutBillController {
return new ResponseEntity<>(iOutBillService.getOutBillDis(whereJson), HttpStatus.OK); return new ResponseEntity<>(iOutBillService.getOutBillDis(whereJson), HttpStatus.OK);
} }
@PostMapping("/audit")
@Log("出库单审核")
public ResponseEntity<Object> audit(@RequestBody JSONObject whereJson) {
iOutBillService.audit(whereJson);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@PostMapping("/allDiv") @PostMapping("/allDiv")
@Log("出库单全部分配") @Log("出库单全部分配")
public ResponseEntity<Object> allDiv(@RequestBody JSONObject whereJson) { public ResponseEntity<Object> allDiv(@RequestBody JSONObject whereJson) {

View File

@@ -82,6 +82,13 @@ public interface IOutBillService extends IService<IOStorInv> {
*/ */
List<IOStorInvDisDto> getOutBillDis(Map whereJson); List<IOStorInvDisDto> getOutBillDis(Map whereJson);
/**
* 出库单审核
*
* @param whereJson /
*/
void audit(JSONObject whereJson);
/** /**
* 全部分配,对同一出库单明细进行分配 * 全部分配,对同一出库单明细进行分配
* *

View File

@@ -90,7 +90,7 @@ public class IOStorInv implements Serializable {
private Integer detail_count; private Integer detail_count;
/** /**
* 单据状态 10生成 20分配中 30分配完 99完成 * 单据状态 10生成 15审核 20分配中 30分配完 99完成
*/ */
private String bill_status; private String bill_status;
@@ -139,6 +139,21 @@ public class IOStorInv implements Serializable {
*/ */
private String dis_optid; private String dis_optid;
/**
* 审核人
*/
private String audit_optid;
/**
* 审核人姓名
*/
private String audit_optname;
/**
* 审核时间
*/
private String audit_time;
/** /**
* 分配人姓名 * 分配人姓名
*/ */

View File

@@ -72,6 +72,11 @@ import java.util.stream.Collectors;
@Service @Service
public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> implements IOutBillService { public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> implements IOutBillService {
private static final String OUT_BILL_STATUS_CREATED = "生成";
private static final String OUT_BILL_STATUS_AUDITED = "审核";
private static final String OUT_BILL_STATUS_ASSIGNING = "分配中";
private static final String OUT_BILL_STATUS_ASSIGNED = "分配完";
@Resource @Resource
private IOStorInvMapper ioStorInvMapper; private IOStorInvMapper ioStorInvMapper;
@@ -125,6 +130,24 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
@Resource @Resource
private IInBillService inBillService; private IInBillService inBillService;
private IOStorInv getOutBillOrThrow(String iostorinvId) {
IOStorInv ioStorInv = ioStorInvMapper.selectById(iostorinvId);
if (ObjectUtil.isEmpty(ioStorInv)) {
throw new BadRequestException("查不到出库单信息");
}
return ioStorInv;
}
private void ensureOutBillStatus(IOStorInv ioStorInv, String... allowedStatuses) {
String currentStatus = ioStorInv.getBill_status();
for (String allowedStatus : allowedStatuses) {
if (IOSEnum.BILL_STATUS.code(allowedStatus).equals(currentStatus)) {
return;
}
}
throw new BadRequestException("当前出库单状态不允许执行该操作");
}
@Override @Override
public IPage<IOStorInv> pageQuery(Map whereJson, PageQuery page, String[] stor_id, String[] bill_status, String[] bill_type) { public IPage<IOStorInv> pageQuery(Map whereJson, PageQuery page, String[] stor_id, String[] bill_status, String[] bill_type) {
@@ -366,6 +389,35 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
return ioStorInvDisMapper.queryOutBillDisDtl(whereJson); return ioStorInvDisMapper.queryOutBillDisDtl(whereJson);
} }
@Override
@Transactional(rollbackFor = Exception.class)
public void audit(JSONObject whereJson) {
String iostorinvId = whereJson.getString("iostorinv_id");
IOStorInv ioStorInv = getOutBillOrThrow(iostorinvId);
ensureOutBillStatus(ioStorInv, OUT_BILL_STATUS_CREATED);
String currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
String now = DateUtil.now();
IOStorInv updateMst = new IOStorInv();
updateMst.setIostorinv_id(iostorinvId);
updateMst.setBill_status(IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_AUDITED));
updateMst.setAudit_optid(currentUserId);
updateMst.setAudit_optname(nickName);
updateMst.setAudit_time(now);
updateMst.setUpdate_optid(currentUserId);
updateMst.setUpdate_optname(nickName);
updateMst.setUpdate_time(now);
ioStorInvMapper.updateById(updateMst);
ioStorInvDtlMapper.update(new IOStorInvDtl(),
new LambdaUpdateWrapper<IOStorInvDtl>()
.set(IOStorInvDtl::getBill_status, IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_AUDITED))
.eq(IOStorInvDtl::getIostorinv_id, iostorinvId)
.eq(IOStorInvDtl::getBill_status, IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_CREATED)));
}
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void allDiv(JSONObject whereJson) { public void allDiv(JSONObject whereJson) {
@@ -377,14 +429,12 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
String iostorinv_id = whereJson.getString("iostorinv_id"); String iostorinv_id = whereJson.getString("iostorinv_id");
//查询主表信息 //查询主表信息
IOStorInv ioStorInv = ioStorInvMapper.selectById(iostorinv_id); IOStorInv ioStorInv = getOutBillOrThrow(iostorinv_id);
if (ObjectUtil.isEmpty(ioStorInv)) { ensureOutBillStatus(ioStorInv, OUT_BILL_STATUS_AUDITED, OUT_BILL_STATUS_ASSIGNING, OUT_BILL_STATUS_ASSIGNED);
throw new BadRequestException("查不到出库单信息");
}
//查询生成和未分配完的明细 //查询生成和未分配完的明细
JSONObject queryDtl = new JSONObject(); JSONObject queryDtl = new JSONObject();
queryDtl.put("bill_status", IOSEnum.BILL_STATUS.code("分配完")); queryDtl.put("bill_status", IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_ASSIGNED));
queryDtl.put("unassign_flag", BaseDataEnum.IS_YES_NOT.code("")); queryDtl.put("unassign_flag", BaseDataEnum.IS_YES_NOT.code(""));
queryDtl.put("iostorinv_id", iostorinv_id); queryDtl.put("iostorinv_id", iostorinv_id);
List<IOStorInvDtlDto> dtls = ioStorInvMapper.getIODtl(queryDtl); List<IOStorInvDtlDto> dtls = ioStorInvMapper.getIODtl(queryDtl);
@@ -459,7 +509,7 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
} }
//更新详情 //更新详情
dtl.setBill_status(IOSEnum.BILL_STATUS.code("分配完")); dtl.setBill_status(IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_ASSIGNED));
dtl.setUnassign_qty(unassign_qty); dtl.setUnassign_qty(unassign_qty);
dtl.setAssign_qty(dtl.getAssign_qty().add(allocation_canuse_qty)); dtl.setAssign_qty(dtl.getAssign_qty().add(allocation_canuse_qty));
ioStorInvDtlMapper.updateById(dtl); ioStorInvDtlMapper.updateById(dtl);
@@ -469,7 +519,7 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
//根据单据标识判断明细是否都已经分配完成 //根据单据标识判断明细是否都已经分配完成
int disCount = ioStorInvDtlMapper.selectCount(new LambdaQueryWrapper<>(IOStorInvDtl.class) int disCount = ioStorInvDtlMapper.selectCount(new LambdaQueryWrapper<>(IOStorInvDtl.class)
.eq(IOStorInvDtl::getIostorinv_id,iostorinv_id) .eq(IOStorInvDtl::getIostorinv_id,iostorinv_id)
.lt(IOStorInvDtl::getBill_status,IOSEnum.BILL_STATUS.code("分配完")) .lt(IOStorInvDtl::getBill_status,IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_ASSIGNED))
); );
// 根据分配货位情况 更新主表单据状态 // 根据分配货位情况 更新主表单据状态
IOStorInv ios = new IOStorInv(); IOStorInv ios = new IOStorInv();
@@ -477,7 +527,7 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
ios.setUpdate_optid(currentUserId); ios.setUpdate_optid(currentUserId);
ios.setUpdate_optname(nickName); ios.setUpdate_optname(nickName);
ios.setUpdate_time(now); ios.setUpdate_time(now);
ios.setBill_status(disCount>0 ? IOSEnum.BILL_STATUS.code("分配中") : IOSEnum.BILL_STATUS.code("分配完")); ios.setBill_status(disCount>0 ? IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_ASSIGNING) : IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_ASSIGNED));
ioStorInvMapper.updateById(ios); ioStorInvMapper.updateById(ios);
} }
@@ -490,6 +540,8 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
String now = DateUtil.now(); String now = DateUtil.now();
String iostorinv_id = whereJson.getString("iostorinv_id"); String iostorinv_id = whereJson.getString("iostorinv_id");
IOStorInv ioStorInv = getOutBillOrThrow(iostorinv_id);
ensureOutBillStatus(ioStorInv, OUT_BILL_STATUS_AUDITED, OUT_BILL_STATUS_ASSIGNING, OUT_BILL_STATUS_ASSIGNED);
List<IOStorInvDis> ioStorInvDisList = ioStorInvDisMapper.selectList(new LambdaQueryWrapper<>(IOStorInvDis.class) List<IOStorInvDis> ioStorInvDisList = ioStorInvDisMapper.selectList(new LambdaQueryWrapper<>(IOStorInvDis.class)
.le(IOStorInvDis::getWork_status,IOSEnum.INBILL_DIS_STATUS.code("未生成")) .le(IOStorInvDis::getWork_status,IOSEnum.INBILL_DIS_STATUS.code("未生成"))
@@ -538,7 +590,7 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
IOStorInvDtl ioStorInvDtl = ioStorInvDtlMapper.selectById(dtlId); IOStorInvDtl ioStorInvDtl = ioStorInvDtlMapper.selectById(dtlId);
ioStorInvDtl.setAssign_qty(BigDecimal.ZERO); ioStorInvDtl.setAssign_qty(BigDecimal.ZERO);
ioStorInvDtl.setUnassign_qty(ioStorInvDtl.getPlan_qty()); ioStorInvDtl.setUnassign_qty(ioStorInvDtl.getPlan_qty());
ioStorInvDtl.setBill_status(IOSEnum.BILL_STATUS.code("生成")); ioStorInvDtl.setBill_status(IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_AUDITED));
ioStorInvDtlMapper.updateById(ioStorInvDtl); ioStorInvDtlMapper.updateById(ioStorInvDtl);
} }
@@ -549,7 +601,7 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
ios.setUpdate_optid(currentUserId); ios.setUpdate_optid(currentUserId);
ios.setUpdate_optname(nickName); ios.setUpdate_optname(nickName);
ios.setUpdate_time(now); ios.setUpdate_time(now);
ios.setBill_status(IOSEnum.BILL_STATUS.code("生成")); ios.setBill_status(IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_AUDITED));
ioStorInvMapper.updateById(ios); ioStorInvMapper.updateById(ios);
} }
@@ -563,14 +615,12 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
String sectCode = whereJson.getString("sect_code"); String sectCode = whereJson.getString("sect_code");
String iostorinv_id = whereJson.getString("iostorinv_id"); String iostorinv_id = whereJson.getString("iostorinv_id");
//查询主表信息 //查询主表信息
IOStorInv ioStorInv = ioStorInvMapper.selectById(iostorinv_id); IOStorInv ioStorInv = getOutBillOrThrow(iostorinv_id);
if (ObjectUtil.isEmpty(ioStorInv)) { ensureOutBillStatus(ioStorInv, OUT_BILL_STATUS_AUDITED, OUT_BILL_STATUS_ASSIGNING, OUT_BILL_STATUS_ASSIGNED);
throw new BadRequestException("查不到出库单信息");
}
//查询生成和未分配完的明细 //查询生成和未分配完的明细
JSONObject queryDtl = new JSONObject(); JSONObject queryDtl = new JSONObject();
queryDtl.put("bill_status", IOSEnum.BILL_STATUS.code("分配完")); queryDtl.put("bill_status", IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_ASSIGNED));
queryDtl.put("unassign_flag", BaseDataEnum.IS_YES_NOT.code("")); queryDtl.put("unassign_flag", BaseDataEnum.IS_YES_NOT.code(""));
queryDtl.put("iostorinv_id", iostorinv_id); queryDtl.put("iostorinv_id", iostorinv_id);
queryDtl.put("iostorinvdtl_id", whereJson.getString("iostorinvdtl_id")); queryDtl.put("iostorinvdtl_id", whereJson.getString("iostorinvdtl_id"));
@@ -642,7 +692,7 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
} }
} }
//更新详情 //更新详情
dtl.setBill_status(IOSEnum.BILL_STATUS.code("分配完")); dtl.setBill_status(IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_ASSIGNED));
dtl.setUnassign_qty(unassign_qty); dtl.setUnassign_qty(unassign_qty);
dtl.setAssign_qty(dtl.getAssign_qty().add(allocation_canuse_qty)); dtl.setAssign_qty(dtl.getAssign_qty().add(allocation_canuse_qty));
ioStorInvDtlMapper.updateById(dtl); ioStorInvDtlMapper.updateById(dtl);
@@ -651,7 +701,7 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
//根据单据标识判断明细是否都已经分配完成 //根据单据标识判断明细是否都已经分配完成
int disCount = ioStorInvDtlMapper.selectCount(new LambdaQueryWrapper<>(IOStorInvDtl.class) int disCount = ioStorInvDtlMapper.selectCount(new LambdaQueryWrapper<>(IOStorInvDtl.class)
.eq(IOStorInvDtl::getIostorinv_id,iostorinv_id) .eq(IOStorInvDtl::getIostorinv_id,iostorinv_id)
.lt(IOStorInvDtl::getBill_status,IOSEnum.BILL_STATUS.code("分配完")) .lt(IOStorInvDtl::getBill_status,IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_ASSIGNED))
); );
// 根据分配货位情况 更新主表单据状态 // 根据分配货位情况 更新主表单据状态
IOStorInv ios = new IOStorInv(); IOStorInv ios = new IOStorInv();
@@ -659,7 +709,7 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
ios.setUpdate_optid(currentUserId); ios.setUpdate_optid(currentUserId);
ios.setUpdate_optname(nickName); ios.setUpdate_optname(nickName);
ios.setUpdate_time(now); ios.setUpdate_time(now);
ios.setBill_status(disCount>0 ? IOSEnum.BILL_STATUS.code("分配中") : IOSEnum.BILL_STATUS.code("分配完")); ios.setBill_status(disCount>0 ? IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_ASSIGNING) : IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_ASSIGNED));
ioStorInvMapper.updateById(ios); ioStorInvMapper.updateById(ios);
} }
@@ -670,6 +720,8 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
String now = DateUtil.now(); String now = DateUtil.now();
String iostorinv_id = whereJson.getString("iostorinv_id"); String iostorinv_id = whereJson.getString("iostorinv_id");
IOStorInv ioStorInv = getOutBillOrThrow(iostorinv_id);
ensureOutBillStatus(ioStorInv, OUT_BILL_STATUS_AUDITED, OUT_BILL_STATUS_ASSIGNING, OUT_BILL_STATUS_ASSIGNED);
List<IOStorInvDis> ioStorInvDisList = ioStorInvDisMapper.selectList(new LambdaQueryWrapper<>(IOStorInvDis.class) List<IOStorInvDis> ioStorInvDisList = ioStorInvDisMapper.selectList(new LambdaQueryWrapper<>(IOStorInvDis.class)
.le(IOStorInvDis::getWork_status,IOSEnum.INBILL_DIS_STATUS.code("未生成")) .le(IOStorInvDis::getWork_status,IOSEnum.INBILL_DIS_STATUS.code("未生成"))
@@ -719,7 +771,7 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
IOStorInvDtl ioStorInvDtl = ioStorInvDtlMapper.selectById(dtlId); IOStorInvDtl ioStorInvDtl = ioStorInvDtlMapper.selectById(dtlId);
ioStorInvDtl.setAssign_qty(BigDecimal.ZERO); ioStorInvDtl.setAssign_qty(BigDecimal.ZERO);
ioStorInvDtl.setUnassign_qty(ioStorInvDtl.getPlan_qty()); ioStorInvDtl.setUnassign_qty(ioStorInvDtl.getPlan_qty());
ioStorInvDtl.setBill_status(IOSEnum.BILL_STATUS.code("生成")); ioStorInvDtl.setBill_status(IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_AUDITED));
ioStorInvDtlMapper.updateById(ioStorInvDtl); ioStorInvDtlMapper.updateById(ioStorInvDtl);
} }
@@ -728,8 +780,8 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
//根据单据标识判断明细是否都已经分配完成 //根据单据标识判断明细是否都已经分配完成
int disCount = ioStorInvDtlMapper.selectCount(new LambdaQueryWrapper<>(IOStorInvDtl.class) int disCount = ioStorInvDtlMapper.selectCount(new LambdaQueryWrapper<>(IOStorInvDtl.class)
.eq(IOStorInvDtl::getIostorinv_id,iostorinv_id) .eq(IOStorInvDtl::getIostorinv_id,iostorinv_id)
.le(IOStorInvDtl::getBill_status,IOSEnum.BILL_STATUS.code("分配完")) .le(IOStorInvDtl::getBill_status,IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_ASSIGNED))
.gt(IOStorInvDtl::getBill_status,IOSEnum.BILL_STATUS.code("生成")) .gt(IOStorInvDtl::getBill_status,IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_AUDITED))
); );
// 根据分配货位情况 更新主表单据状态 // 根据分配货位情况 更新主表单据状态
@@ -738,7 +790,7 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
ios.setUpdate_optid(currentUserId); ios.setUpdate_optid(currentUserId);
ios.setUpdate_optname(nickName); ios.setUpdate_optname(nickName);
ios.setUpdate_time(now); ios.setUpdate_time(now);
ios.setBill_status(disCount>0 ? IOSEnum.BILL_STATUS.code("分配中") : IOSEnum.BILL_STATUS.code("生成")); ios.setBill_status(disCount>0 ? IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_ASSIGNING) : IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_AUDITED));
ioStorInvMapper.updateById(ios); ioStorInvMapper.updateById(ios);
} }
@@ -761,14 +813,12 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
String iostorinv_id = row.getString("iostorinv_id"); String iostorinv_id = row.getString("iostorinv_id");
//查询主表信息 //查询主表信息
IOStorInv ioStorInv = ioStorInvMapper.selectById(iostorinv_id); IOStorInv ioStorInv = getOutBillOrThrow(iostorinv_id);
if (ObjectUtil.isEmpty(ioStorInv)) { ensureOutBillStatus(ioStorInv, OUT_BILL_STATUS_AUDITED, OUT_BILL_STATUS_ASSIGNING, OUT_BILL_STATUS_ASSIGNED);
throw new BadRequestException("当前订单无可分配出库明细");
}
//查询生成和未分配完的明细 //查询生成和未分配完的明细
JSONObject queryDtl = new JSONObject(); JSONObject queryDtl = new JSONObject();
queryDtl.put("bill_status", IOSEnum.BILL_STATUS.code("分配完")); queryDtl.put("bill_status", IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_ASSIGNED));
queryDtl.put("unassign_flag", BaseDataEnum.IS_YES_NOT.code("")); queryDtl.put("unassign_flag", BaseDataEnum.IS_YES_NOT.code(""));
queryDtl.put("iostorinv_id", iostorinv_id); queryDtl.put("iostorinv_id", iostorinv_id);
queryDtl.put("iostorinvdtl_id", row.getString("iostorinvdtl_id")); queryDtl.put("iostorinvdtl_id", row.getString("iostorinvdtl_id"));
@@ -853,7 +903,7 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
} }
//更新详情 //更新详情
dtl.setBill_status(unassign_qty==0 ? IOSEnum.BILL_STATUS.code("分配完"): IOSEnum.BILL_STATUS.code("分配中")); dtl.setBill_status(unassign_qty==0 ? IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_ASSIGNED): IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_ASSIGNING));
double assign_qty = allocation_canuse_qty + dtl.getAssign_qty().doubleValue(); double assign_qty = allocation_canuse_qty + dtl.getAssign_qty().doubleValue();
dtl.setUnassign_qty(BigDecimal.valueOf(unassign_qty)); dtl.setUnassign_qty(BigDecimal.valueOf(unassign_qty));
dtl.setAssign_qty(BigDecimal.valueOf(assign_qty)); dtl.setAssign_qty(BigDecimal.valueOf(assign_qty));
@@ -864,7 +914,7 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
//根据单据标识判断明细是否都已经分配完成 //根据单据标识判断明细是否都已经分配完成
int disCount = ioStorInvDtlMapper.selectCount(new LambdaQueryWrapper<>(IOStorInvDtl.class) int disCount = ioStorInvDtlMapper.selectCount(new LambdaQueryWrapper<>(IOStorInvDtl.class)
.eq(IOStorInvDtl::getIostorinv_id,iostorinv_id) .eq(IOStorInvDtl::getIostorinv_id,iostorinv_id)
.lt(IOStorInvDtl::getBill_status,IOSEnum.BILL_STATUS.code("分配完")) .lt(IOStorInvDtl::getBill_status,IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_ASSIGNED))
); );
// 根据分配货位情况 更新主表单据状态 // 根据分配货位情况 更新主表单据状态
@@ -873,7 +923,7 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
ios.setUpdate_optid(currentUserId); ios.setUpdate_optid(currentUserId);
ios.setUpdate_optname(nickName); ios.setUpdate_optname(nickName);
ios.setUpdate_time(now); ios.setUpdate_time(now);
ios.setBill_status(disCount>0 ? IOSEnum.BILL_STATUS.code("分配中") : IOSEnum.BILL_STATUS.code("分配完")); ios.setBill_status(disCount>0 ? IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_ASSIGNING) : IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_ASSIGNED));
ioStorInvMapper.updateById(ios); ioStorInvMapper.updateById(ios);
} }
@@ -885,6 +935,8 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
String now = DateUtil.now(); String now = DateUtil.now();
String iostorinv_id = whereJson.getString("iostorinv_id"); String iostorinv_id = whereJson.getString("iostorinv_id");
IOStorInv ioStorInv = getOutBillOrThrow(iostorinv_id);
ensureOutBillStatus(ioStorInv, OUT_BILL_STATUS_AUDITED, OUT_BILL_STATUS_ASSIGNING, OUT_BILL_STATUS_ASSIGNED);
List<IOStorInvDis> ioStorInvDisList = ioStorInvDisMapper.selectList(new LambdaQueryWrapper<>(IOStorInvDis.class) List<IOStorInvDis> ioStorInvDisList = ioStorInvDisMapper.selectList(new LambdaQueryWrapper<>(IOStorInvDis.class)
.le(IOStorInvDis::getWork_status,IOSEnum.INBILL_DIS_STATUS.code("未生成")) .le(IOStorInvDis::getWork_status,IOSEnum.INBILL_DIS_STATUS.code("未生成"))
@@ -928,11 +980,11 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
ioStorInvDtl.setAssign_qty(BigDecimal.valueOf(assign_qty)); ioStorInvDtl.setAssign_qty(BigDecimal.valueOf(assign_qty));
ioStorInvDtl.setUnassign_qty(BigDecimal.valueOf(unassign_qty)); ioStorInvDtl.setUnassign_qty(BigDecimal.valueOf(unassign_qty));
if (assign_qty == 0){ if (assign_qty == 0){
ioStorInvDtl.setBill_status(IOSEnum.BILL_STATUS.code("生成")); ioStorInvDtl.setBill_status(IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_AUDITED));
}else if (unassign_qty == 0){ }else if (unassign_qty == 0){
ioStorInvDtl.setBill_status(IOSEnum.BILL_STATUS.code("分配完")); ioStorInvDtl.setBill_status(IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_ASSIGNED));
}else { }else {
ioStorInvDtl.setBill_status(IOSEnum.BILL_STATUS.code("分配中")); ioStorInvDtl.setBill_status(IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_ASSIGNING));
} }
ioStorInvDtlMapper.updateById(ioStorInvDtl); ioStorInvDtlMapper.updateById(ioStorInvDtl);
@@ -945,8 +997,8 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
//根据单据标识判断明细是否都已经分配完成 //根据单据标识判断明细是否都已经分配完成
int disCount = ioStorInvDtlMapper.selectCount(new LambdaQueryWrapper<>(IOStorInvDtl.class) int disCount = ioStorInvDtlMapper.selectCount(new LambdaQueryWrapper<>(IOStorInvDtl.class)
.eq(IOStorInvDtl::getIostorinv_id,iostorinv_id) .eq(IOStorInvDtl::getIostorinv_id,iostorinv_id)
.le(IOStorInvDtl::getBill_status,IOSEnum.BILL_STATUS.code("分配完")) .le(IOStorInvDtl::getBill_status,IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_ASSIGNED))
.gt(IOStorInvDtl::getBill_status,IOSEnum.BILL_STATUS.code("生成")) .gt(IOStorInvDtl::getBill_status,IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_AUDITED))
); );
// 根据分配货位情况 更新主表单据状态 // 根据分配货位情况 更新主表单据状态
@@ -955,7 +1007,7 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i
ios.setUpdate_optid(currentUserId); ios.setUpdate_optid(currentUserId);
ios.setUpdate_optname(nickName); ios.setUpdate_optname(nickName);
ios.setUpdate_time(now); ios.setUpdate_time(now);
ios.setBill_status(disCount>0 ? IOSEnum.BILL_STATUS.code("分配中") : IOSEnum.BILL_STATUS.code("生成")); ios.setBill_status(disCount>0 ? IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_ASSIGNING) : IOSEnum.BILL_STATUS.code(OUT_BILL_STATUS_AUDITED));
ioStorInvMapper.updateById(ios); ioStorInvMapper.updateById(ios);
} }

View File

@@ -0,0 +1,4 @@
ALTER TABLE `pdm_bd_workorder`
ADD COLUMN `audit_id` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '审核人' AFTER `workshop_code`,
ADD COLUMN `audit_name` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '审核人姓名' AFTER `audit_id`,
ADD COLUMN `audit_time` varchar(25) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '审核时间' AFTER `audit_name`;

View File

@@ -0,0 +1,4 @@
ALTER TABLE `st_ivt_iostorinv`
ADD COLUMN `audit_optid` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '审核人' AFTER `update_time`,
ADD COLUMN `audit_optname` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '审核人姓名' AFTER `audit_optid`,
ADD COLUMN `audit_time` varchar(25) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NULL DEFAULT NULL COMMENT '审核时间' AFTER `audit_optname`;

View File

@@ -382,18 +382,22 @@ export default {
this.form2.unassign_qty = current.unassign_qty this.form2.unassign_qty = current.unassign_qty
this.form2.assign_qty = current.assign_qty this.form2.assign_qty = current.assign_qty
this.tabledis = [] this.tabledis = []
if (current.bill_status === '10') { if (current.bill_status === '15') {
this.button1 = false this.button1 = false
this.button2 = true this.button2 = true
this.button3 = false this.button3 = false
} else if (current.bill_status === '30') { } else if (current.bill_status === '20') {
this.button1 = false this.button1 = false
this.button2 = false this.button2 = false
this.button3 = false this.button3 = false
} else if (current.bill_status === '40') { } else if (current.bill_status === '30') {
this.button1 = true this.button1 = true
this.button2 = false this.button2 = false
this.button3 = true this.button3 = true
} else {
this.button1 = true
this.button2 = true
this.button3 = true
} }
this.queryTableDdis(current.iostorinvdtl_id) this.queryTableDdis(current.iostorinvdtl_id)
} else { } else {

View File

@@ -38,6 +38,13 @@ export function getOutBillDis(params) {
params params
}) })
} }
export function audit(data) {
return request({
url: '/api/checkoutbill/audit',
method: 'post',
data
})
}
export function allDiv(data) { export function allDiv(data) {
return request({ return request({
url: '/api/checkoutbill/allDiv', url: '/api/checkoutbill/allDiv',
@@ -116,4 +123,4 @@ export function outReturn(data) {
}) })
} }
export default { add, edit, del, allDiv, allCancel, getOutBillDtl, getOutBillDis, autoCancel, getStructIvt, manualDiv, confirm, allDivOne, getOutBillTask, oneCancel, allSetPoint, outReturn } export default { add, edit, del, audit, allDiv, allCancel, getOutBillDtl, getOutBillDis, autoCancel, getStructIvt, manualDiv, confirm, allDivOne, getOutBillTask, oneCancel, allSetPoint, outReturn }

View File

@@ -118,6 +118,18 @@
</div> </div>
<!--如果想在工具栏加入更多按钮可以使用插槽方式 slot = 'left' or 'right'--> <!--如果想在工具栏加入更多按钮可以使用插槽方式 slot = 'left' or 'right'-->
<crudOperation :permission="permission"> <crudOperation :permission="permission">
<el-button
slot="right"
class="filter-item"
type="warning"
icon="el-icon-check"
size="mini"
:loading="loadingAudit"
:disabled="audit_flag"
@click="audit"
>
审核
</el-button>
<el-button <el-button
slot="right" slot="right"
class="filter-item" class="filter-item"
@@ -134,7 +146,7 @@
v-permission="permission.confirm" v-permission="permission.confirm"
class="filter-item" class="filter-item"
:loading="loadingConfirm" :loading="loadingConfirm"
type="warning" type="danger"
:disabled="confirm_flag" :disabled="confirm_flag"
icon="el-icon-check" icon="el-icon-check"
size="mini" size="mini"
@@ -191,6 +203,8 @@
<el-table-column show-overflow-tooltip label="备注" align="center" prop="remark" width="100" /> <el-table-column show-overflow-tooltip label="备注" align="center" prop="remark" width="100" />
<el-table-column show-overflow-tooltip label="制单人" align="center" prop="input_optname" /> <el-table-column show-overflow-tooltip label="制单人" align="center" prop="input_optname" />
<el-table-column show-overflow-tooltip label="制单时间" align="center" prop="input_time" width="140" /> <el-table-column show-overflow-tooltip label="制单时间" align="center" prop="input_time" width="140" />
<el-table-column show-overflow-tooltip label="审核人" align="center" prop="audit_optname" />
<el-table-column show-overflow-tooltip label="审核时间" align="center" prop="audit_time" width="140" />
<el-table-column show-overflow-tooltip label="修改人" align="center" prop="update_optname" /> <el-table-column show-overflow-tooltip label="修改人" align="center" prop="update_optname" />
<el-table-column show-overflow-tooltip label="修改时间" align="center" prop="update_time" width="140" /> <el-table-column show-overflow-tooltip label="修改时间" align="center" prop="update_time" width="140" />
<el-table-column show-overflow-tooltip label="分配人" align="center" prop="dis_optname" /> <el-table-column show-overflow-tooltip label="分配人" align="center" prop="dis_optname" />
@@ -249,7 +263,9 @@ export default {
confirm: ['admin', 'checkoutbill:confirm'] confirm: ['admin', 'checkoutbill:confirm']
}, },
loadingConfirm: false, loadingConfirm: false,
loadingAudit: false,
divShow: false, divShow: false,
audit_flag: true,
dis_flag: true, dis_flag: true,
confirm_flag: true, confirm_flag: true,
business_confirm_flag: true, business_confirm_flag: true,
@@ -334,12 +350,13 @@ export default {
buttonChange(current) { buttonChange(current) {
if (current !== null) { if (current !== null) {
this.currentRow = current this.currentRow = current
if (current.bill_status === '10' || current.bill_status === '20' || current.bill_status === '30' || current.bill_status === '40') { this.audit_flag = current.bill_status !== '10'
if (current.bill_status === '15' || current.bill_status === '20' || current.bill_status === '30') {
this.dis_flag = false this.dis_flag = false
} else { } else {
this.dis_flag = true this.dis_flag = true
} }
if (current.bill_status === '50' || current.bill_status === '40' || current.bill_status === '30') { if (current.bill_status === '30') {
this.confirm_flag = false this.confirm_flag = false
} else { } else {
this.confirm_flag = true this.confirm_flag = true
@@ -349,7 +366,7 @@ export default {
} else { } else {
this.business_confirm_flag = true this.business_confirm_flag = true
} }
if (current.bill_status === '40' || current.bill_status === '30') { if (current.bill_status === '30') {
this.outReturn_flag = false this.outReturn_flag = false
} else { } else {
this.outReturn_flag = true this.outReturn_flag = true
@@ -370,6 +387,7 @@ export default {
}, },
handleCurrentChange(current) { handleCurrentChange(current) {
if (current === null) { if (current === null) {
this.audit_flag = true
this.dis_flag = true this.dis_flag = true
this.confirm_flag = true this.confirm_flag = true
this.outReturn_flag = true this.outReturn_flag = true
@@ -387,6 +405,16 @@ export default {
this.mstrow = this.currentRow this.mstrow = this.currentRow
}) })
}, },
audit() {
this.loadingAudit = true
checkoutbill.audit({ 'iostorinv_id': this.currentRow.iostorinv_id }).then(() => {
this.querytable()
this.crud.notify('审核成功!', CRUD.NOTIFICATION_TYPE.SUCCESS)
this.loadingAudit = false
}).catch(() => {
this.loadingAudit = false
})
},
confirm() { confirm() {
this.loadingConfirm = true this.loadingConfirm = true
checkoutbill.confirm({ 'iostorinv_id': this.currentRow.iostorinv_id }).then(res => { checkoutbill.confirm({ 'iostorinv_id': this.currentRow.iostorinv_id }).then(res => {