opt:富佳优化
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
acs2/.idea/
|
||||
acs2/nladmin-ui/dist.zip
|
||||
@@ -232,6 +232,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
standardOrdinarySiteDeviceDriver.setOption(0);
|
||||
} else if (device.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
|
||||
//到达取货点 入库
|
||||
beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) device.getDeviceDriver();
|
||||
if (beltConveyorDeviceDriver.getAction() == 1 && beltConveyorDeviceDriver.getMode() == 2 && beltConveyorDeviceDriver.getError() == 0&& beltConveyorDeviceDriver.getMove() == 1) {
|
||||
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
|
||||
@@ -297,7 +297,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
if (move == 1 && !requireSucess) {
|
||||
boolean b = instruction_require();
|
||||
if (b) {
|
||||
requireSucess = false;
|
||||
log.info(this.device_code + ",任务申请成功!");
|
||||
}
|
||||
} else {
|
||||
String remark = "";
|
||||
@@ -326,18 +326,10 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
synchronized(this) { // 添加同步锁
|
||||
if (!requireSucess) { // 双重检查锁定
|
||||
try {
|
||||
// 1. 查询设备
|
||||
Device device = deviceAppService.findDeviceByCode(device_code);
|
||||
|
||||
Integer result = updateOutboundTaskNum(-1,true);
|
||||
|
||||
// 2. 更新任务数
|
||||
device.setOutbound_task_num(result);
|
||||
|
||||
// 3. 保存更新(假设需要显式保存)
|
||||
deviceservice.update(new UpdateWrapper<Device>()
|
||||
.set("outbound_task_num",result)
|
||||
.eq("device_code",device.getDevice_code()));
|
||||
// 使用统一方法更新出库任务数并同步数据库
|
||||
updateAndSyncOutboundTaskNum(-1, true, true);
|
||||
Integer result = this.outbound_task_num;
|
||||
|
||||
// 更新task的出库完成数
|
||||
TaskDto taskDto = new TaskDto();
|
||||
@@ -355,7 +347,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
map2.put("value", result);
|
||||
this.writing(list1);
|
||||
|
||||
// 5. 只有成功后才设置标记
|
||||
// 只有成功后才设置标记
|
||||
requireSucess = true;
|
||||
|
||||
log.info(this.device_code + ",成功更新出库任务数");
|
||||
@@ -445,8 +437,10 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
} else {
|
||||
this.instruction_require_time = date;
|
||||
Device device = deviceAppService.findDeviceByCode(device_code);
|
||||
log.info("device_code"+ device_code);
|
||||
List<String> list = device.getDeviceDriver().getExtraDeviceCodes("link_device_code");
|
||||
if (CollUtil.isNotEmpty(getDeviceCodeList)) {
|
||||
log.info("link_device_code_list"+ JSONObject.toJSONString(list));
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
//关联的RFID设备
|
||||
String linkDeviceCode = list.get(0);
|
||||
BmVehicleRfid bmVehicleRfid = ibmVehicleRfidService.findByDeviceCode(linkDeviceCode);
|
||||
@@ -558,6 +552,32 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
}
|
||||
return this.outbound_task_num;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一更新出库任务数的方法,确保数据一致性
|
||||
* @param num 任务数
|
||||
* @param addFlag 是否累加
|
||||
* @param syncDb 是否同步数据库
|
||||
* @throws Exception 异常信息
|
||||
*/
|
||||
public synchronized void updateAndSyncOutboundTaskNum(Integer num, Boolean addFlag, boolean syncDb) throws Exception {
|
||||
try {
|
||||
Integer result = updateOutboundTaskNum(num, addFlag);
|
||||
// 更新device对象
|
||||
if (this.device != null) {
|
||||
this.device.setOutbound_task_num(result);
|
||||
}
|
||||
// 如需同步数据库
|
||||
if (syncDb) {
|
||||
deviceservice.update(new UpdateWrapper<Device>()
|
||||
.set("outbound_task_num", result)
|
||||
.eq("device_code", device_code));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("更新出库任务数失败: {}", e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() {
|
||||
|
||||
@@ -371,8 +371,10 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
}
|
||||
if (ObjectUtil.isEmpty(errArr)) {
|
||||
response.setStatus(200);
|
||||
response.setCode(200);
|
||||
response.setMessage("success");
|
||||
} else {
|
||||
response.setCode(400);
|
||||
response.setStatus(400);
|
||||
if (ObjectUtil.isNotEmpty(errArr)) {
|
||||
response.setMessage(errArr.getJSONObject(0).getString("message"));
|
||||
|
||||
@@ -5,6 +5,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.rfid_manage.service.IbmVehicleRfidService;
|
||||
import org.nl.acs.rfid_manage.service.dto.BmVehicleRfidParam;
|
||||
import org.nl.acs.rfid_manage.service.dto.UpdateRfidParam;
|
||||
import org.nl.common.base.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -107,4 +108,16 @@ public class BmVehicleRfidController {
|
||||
bmVehicleRfidService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 条件查询
|
||||
*
|
||||
* @param params 查询条件
|
||||
*/
|
||||
@PostMapping("/updateRfid")
|
||||
//@SaCheckPermission("@el.check(BmVehicleRfid:list")
|
||||
public ResponseEntity<Object> updateRfid(@RequestBody UpdateRfidParam params) {
|
||||
return new ResponseEntity<>(bmVehicleRfidService.updateRfid(params), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.acs.rfid_manage.service.dao.BmVehicleRfid;
|
||||
import org.nl.acs.rfid_manage.service.dto.BmVehicleRfidParam;
|
||||
import org.nl.acs.rfid_manage.service.dto.UpdateRfidParam;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
|
||||
import java.util.List;
|
||||
@@ -54,6 +55,8 @@ public interface IbmVehicleRfidService extends IService<BmVehicleRfid> {
|
||||
|
||||
void connectRfid(BmVehicleRfidParam params);
|
||||
|
||||
Boolean updateRfid(UpdateRfidParam params);
|
||||
|
||||
void writeEpc(String id);
|
||||
|
||||
BmVehicleRfid findByDeviceCode(String linkDeviceCode);
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.nl.acs.rfid_manage.service.dto;
|
||||
|
||||
import lombok.*;
|
||||
import org.nl.acs.rfid_manage.service.dao.BmVehicleRfid;
|
||||
import org.nl.common.domain.query.BaseQuery;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class UpdateRfidEventDataParam extends BaseQuery<BmVehicleRfid> {
|
||||
/**
|
||||
* reader_name
|
||||
*/
|
||||
private String ep;
|
||||
/**
|
||||
* event_type
|
||||
*/
|
||||
private String bd;
|
||||
/**
|
||||
* reader_name
|
||||
*/
|
||||
private Integer at;
|
||||
/**
|
||||
* event_type
|
||||
*/
|
||||
private Integer rc;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.nl.acs.rfid_manage.service.dto;
|
||||
|
||||
import lombok.*;
|
||||
import org.nl.acs.rfid_manage.service.dao.BmVehicleRfid;
|
||||
import org.nl.common.domain.query.BaseQuery;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class UpdateRfidParam extends BaseQuery<BmVehicleRfid> {
|
||||
/**
|
||||
* reader_name
|
||||
*/
|
||||
private String reader_name;
|
||||
/**
|
||||
* event_type
|
||||
*/
|
||||
private String event_type;
|
||||
|
||||
private Object event_data;
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package org.nl.acs.rfid_manage.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
@@ -12,14 +13,20 @@ import com.gg.reader.api.dal.GClient;
|
||||
import com.gg.reader.api.dal.HandlerTagEpcLog;
|
||||
import com.gg.reader.api.dal.HandlerTcpDisconnected;
|
||||
import com.gg.reader.api.protocol.gx.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.acs.rfid_manage.service.IbmVehicleRfidService;
|
||||
import org.nl.acs.rfid_manage.service.dao.BmVehicleRfid;
|
||||
import org.nl.acs.rfid_manage.service.dao.mapper.BmVehicleRfidMapper;
|
||||
import org.nl.acs.rfid_manage.service.dto.BmVehicleRfidParam;
|
||||
import org.nl.acs.rfid_manage.service.dto.EpcRecord;
|
||||
import org.nl.acs.rfid_manage.service.dto.UpdateRfidEventDataParam;
|
||||
import org.nl.acs.rfid_manage.service.dto.UpdateRfidParam;
|
||||
import org.nl.acs.utils.StructUtil;
|
||||
import org.nl.common.domain.constant.DictConstantPool;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.system.service.user.dao.SysUser;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -27,12 +34,14 @@ import javax.annotation.Resource;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Service("bmVehicleRfidService")
|
||||
@Slf4j
|
||||
public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, BmVehicleRfid> implements IbmVehicleRfidService {
|
||||
|
||||
@Resource
|
||||
@@ -72,6 +81,7 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
||||
client.sendSynMsg(msgBaseInventoryEpc);
|
||||
if (msgBaseInventoryEpc.getRtCode() == 0x00) {
|
||||
System.out.println("设备[" + ip + "] 开始扫码任务成功");
|
||||
log.info("设备[" + ip + "] 开始扫码任务成功");
|
||||
} else {
|
||||
System.err.println("设备[" + ip + "] 扫码配置失败: " + msgBaseInventoryEpc.getRtMsg());
|
||||
}
|
||||
@@ -83,7 +93,7 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
||||
// //写EPC,数据默认为 hex 432
|
||||
// msg.setArea(EnumG.WriteArea_Epc);
|
||||
// String sWriteHexData = "888"; // 写入数据 (16进制)
|
||||
// System.out.println("Write hex " + sWriteHexData);
|
||||
// log.info("Write hex " + sWriteHexData);
|
||||
// int iWordLen = StructUtil.getValueLen(sWriteHexData);
|
||||
// // PC值为EPC区域的长度标识(前5个bit标记长度),参考文档说明
|
||||
// sWriteHexData = StructUtil.getPc(iWordLen) + StructUtil.padLeft(sWriteHexData.toUpperCase(), 4 * iWordLen, '0'); // PC值+数据内容
|
||||
@@ -92,9 +102,9 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
||||
// // msg.setBwriteData(HexUtils.hexString2Bytes(sWriteHexData));
|
||||
// client.sendSynMsg(msg);
|
||||
// if (0 == msg.getRtCode()) {
|
||||
// System.out.println("写入:" + sWriteHexData + "成功!");
|
||||
// log.info("写入:" + sWriteHexData + "成功!");
|
||||
// } else {
|
||||
// System.out.println("写入:" + sWriteHexData + "失败!");
|
||||
// log.info("写入:" + sWriteHexData + "失败!");
|
||||
// }
|
||||
|
||||
// 订阅标签事件
|
||||
@@ -104,16 +114,20 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
||||
client.sendSynMsg(msgAppGetBaseVersion);
|
||||
if (0x00 == msgAppGetBaseVersion.getRtCode()) {
|
||||
System.out.println("msgAppGetBaseVersion[OK].");
|
||||
log.info("msgAppGetBaseVersion[OK].");
|
||||
} else {
|
||||
System.out.println(msgAppGetBaseVersion.getRtMsg());
|
||||
log.info(msgAppGetBaseVersion.getRtMsg());
|
||||
}
|
||||
//获取设备信息
|
||||
MsgAppGetReaderInfo msgAppGetReaderInfo = new MsgAppGetReaderInfo();
|
||||
client.sendSynMsg(msgAppGetReaderInfo);
|
||||
if (0x00 == msgAppGetReaderInfo.getRtCode()) {
|
||||
System.out.println("msgAppGetReaderInfo[OK].");
|
||||
log.info("msgAppGetReaderInfo[OK].");
|
||||
} else {
|
||||
System.out.println(msgAppGetReaderInfo.getRtMsg());
|
||||
log.info(msgAppGetReaderInfo.getRtMsg());
|
||||
}
|
||||
BmVehicleRfid updated = new BmVehicleRfid();
|
||||
updated.setId(deviceId);
|
||||
@@ -143,7 +157,7 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
||||
// MsgBaseStop stopMsg = new MsgBaseStop();
|
||||
// client.sendSynMsg(stopMsg);
|
||||
// if (stopMsg.getRtCode() == 0x00) {
|
||||
// System.out.println("设备[" + ip + "] 停止扫码任务成功");
|
||||
// log.info("设备[" + ip + "] 停止扫码任务成功");
|
||||
// } else {
|
||||
// System.err.println("设备[" + ip + "] 停止扫码失败: " + stopMsg.getRtMsg());
|
||||
// }
|
||||
@@ -151,6 +165,7 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
||||
// removeClient(deviceId);
|
||||
disconnectAllClients();
|
||||
System.out.println("设备[" + ip + "] 已断开连接");
|
||||
log.info("设备[" + ip + "] 已断开连接");
|
||||
BmVehicleRfid updated = new BmVehicleRfid();
|
||||
updated.setId(deviceId);
|
||||
updated.setRfid(null);
|
||||
@@ -166,11 +181,43 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
||||
updated.setStatus(0);
|
||||
this.updateById(updated);
|
||||
System.out.println("设备[" + ip + "] 未连接,无需断开");
|
||||
log.info("设备[" + ip + "] 未连接,无需断开");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateRfid(UpdateRfidParam params) {
|
||||
log.info("接收到的报文=【{}】", JSON.toJSONString(params));
|
||||
if ("tag_read".equals(params.getEvent_type())) {
|
||||
// 将Object类型转换为List<UpdateRfidEventDataParam>
|
||||
Object eventDataObj = params.getEvent_data();
|
||||
List<UpdateRfidEventDataParam> updateRfidEventDataParamList = new ArrayList<>();
|
||||
|
||||
if (eventDataObj != null) {
|
||||
try {
|
||||
// 使用JSON转换将Object转为List
|
||||
String jsonStr = JSON.toJSONString(eventDataObj);
|
||||
updateRfidEventDataParamList = JSON.parseArray(jsonStr, UpdateRfidEventDataParam.class);
|
||||
} catch (Exception e) {
|
||||
log.error("类型转换失败: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(updateRfidEventDataParamList)) {
|
||||
UpdateRfidEventDataParam updateRfidEventDataParam = updateRfidEventDataParamList.get(0);
|
||||
if (updateRfidEventDataParam != null && StringUtils.isNotBlank(updateRfidEventDataParam.getEp()) && StringUtils.isNotBlank(params.getReader_name())) {
|
||||
update(new UpdateWrapper<BmVehicleRfid>().set("rfid", updateRfidEventDataParam.getEp()).eq("device_code", params.getReader_name()));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(!"heart_beat".equals(params.getEvent_type())) {
|
||||
update(new UpdateWrapper<BmVehicleRfid>().set("rfid", null).eq("device_code", params.getReader_name()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEpc(String id) {
|
||||
GClient client = getClient("1");
|
||||
@@ -184,6 +231,7 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
||||
msg.setArea(EnumG.WriteArea_Epc);
|
||||
String sWriteHexData = "666"; // 写入数据 (16进制)
|
||||
System.out.println("Write hex " + sWriteHexData);
|
||||
log.info("Write hex " + sWriteHexData);
|
||||
int iWordLen = StructUtil.getValueLen(sWriteHexData);
|
||||
// PC值为EPC区域的长度标识(前5个bit标记长度),参考文档说明
|
||||
sWriteHexData = StructUtil.getPc(iWordLen) + StructUtil.padLeft(sWriteHexData.toUpperCase(), 4 * iWordLen, '0'); // PC值+数据内容
|
||||
@@ -193,8 +241,10 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
||||
client.sendSynMsg(msg);
|
||||
if (0 == msg.getRtCode()) {
|
||||
System.out.println("写入:" + sWriteHexData + "成功!");
|
||||
log.info("写入:" + sWriteHexData + "成功!");
|
||||
} else {
|
||||
System.out.println("写入:" + sWriteHexData + "失败!");
|
||||
log.info("写入:" + sWriteHexData + "失败!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -215,8 +265,10 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
||||
client.sendSynMsg(msgBaseStop);
|
||||
if (0 == msgBaseStop.getRtCode()) {
|
||||
System.out.println("停止成功!");
|
||||
log.info("停止成功!");
|
||||
} else {
|
||||
System.out.println("停止失败!");
|
||||
log.info("停止失败!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -242,8 +294,10 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
||||
for (BmVehicleRfid r : clientList) {
|
||||
String ip = r.getIp() + ":" + r.getPort();
|
||||
System.out.println("设备[" + ip + "] 连接异常,开始重连...");
|
||||
log.info("设备[" + ip + "] 连接异常,开始重连...");
|
||||
if (tryReconnect(r.getId(), ip)) {
|
||||
System.out.println("设备[" + ip + "] 重连成功");
|
||||
log.info("设备[" + ip + "] 重连成功");
|
||||
} else {
|
||||
System.err.println("设备[" + ip + "] 重连失败");
|
||||
}
|
||||
@@ -255,6 +309,7 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
||||
final int WAIT_MS = 500;
|
||||
for (int i = 1; i <= MAX_RETRY; i++) {
|
||||
System.out.println("设备[" + ip + "] 第" + i + "次重连尝试...");
|
||||
log.info("设备[" + ip + "] 第" + i + "次重连尝试...");
|
||||
GClient oldClient = clientMap.remove(deviceId);
|
||||
if (oldClient != null) {
|
||||
try {
|
||||
@@ -269,6 +324,7 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
||||
newClient.setSendHeartBeat(true);
|
||||
if (checkConnection(newClient)) {
|
||||
System.out.println("设备[" + ip + "] 重连成功");
|
||||
log.info("设备[" + ip + "] 重连成功");
|
||||
return true;
|
||||
} else {
|
||||
try {
|
||||
@@ -312,7 +368,7 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
||||
// MsgBaseStop stopMsg = new MsgBaseStop();
|
||||
// client.sendSynMsg(stopMsg);
|
||||
// if (stopMsg.getRtCode() == 0x00) {
|
||||
// System.out.println("停止扫码任务成功: " + deviceId);
|
||||
// log.info("停止扫码任务成功: " + deviceId);
|
||||
// } else {
|
||||
// System.err.println("停止扫码失败: " + stopMsg.getRtMsg());
|
||||
// }
|
||||
@@ -320,7 +376,7 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
||||
// System.err.println("停止扫码任务异常: " + e.getMessage());
|
||||
// } finally {
|
||||
// client.close();
|
||||
// System.out.println("已断开设备连接: " + deviceId);
|
||||
// log.info("已断开设备连接: " + deviceId);
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -345,6 +401,7 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
||||
@Override
|
||||
public void log(String s) {
|
||||
System.out.println("command log output5:onDisconnected:" + "connect" + s + "close..........");
|
||||
log.info("command log output5:onDisconnected:" + "connect" + s + "close..........");
|
||||
client.close();//释放当前连接资源
|
||||
BmVehicleRfid updated = new BmVehicleRfid();
|
||||
updated.setId(id);
|
||||
@@ -373,6 +430,7 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
||||
|
||||
if (isSame) {
|
||||
System.out.println(epc + "与上次标签值相同,不上报,跳过....");
|
||||
log.info(epc + "与上次标签值相同,不上报,跳过....");
|
||||
return; // EPC 相同且未过期,跳过
|
||||
}
|
||||
epcCache.computeIfAbsent(deviceId, k -> new ConcurrentHashMap<>())
|
||||
@@ -385,6 +443,7 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
||||
updated.setLog(DateUtil.now() + ":设备:" + currentDevice.getDevice_code() + "读取RFID值:" + epc + "成功!");
|
||||
this.updateById(updated);
|
||||
System.out.println("读取RFID值:" + epc + "成功!");
|
||||
log.info("读取RFID值:" + epc + "成功!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -197,20 +197,32 @@ public class AutoCreateInst {
|
||||
|
||||
try {
|
||||
instructionService.create(instdto);
|
||||
|
||||
// beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) nextdevice.getDeviceDriver();
|
||||
// //满足出库,查询当前出库任务,+1后返回给
|
||||
// if (beltConveyorDeviceDriver.getType() == 2) {
|
||||
// synchronized (this) {
|
||||
// if (beltConveyorDeviceDriver.getType() == 2) {
|
||||
// //因为已经创建成功,因此这个时候可以+1了
|
||||
// int count = instructionService.queryInstructionCount(next_device_code);
|
||||
// beltConveyorDeviceDriver.updateOutboundTaskNum(count,false);
|
||||
// beltConveyorDeviceDriver.writing("to_taskNum", count + "");
|
||||
// nextdevice.setOutbound_task_num(count);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
if (nextdevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
|
||||
BeltConveyorDeviceDriver beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) nextdevice.getDeviceDriver();
|
||||
//满足出库,查询当前出库任务,+1后返回给
|
||||
if (beltConveyorDeviceDriver.getAction() == 2 && beltConveyorDeviceDriver.getMode() == 2
|
||||
&& beltConveyorDeviceDriver.getError() == 0 && beltConveyorDeviceDriver.getMove() == 0) {
|
||||
// 使用同步块确保操作原子性
|
||||
synchronized (beltConveyorDeviceDriver) {
|
||||
try {
|
||||
// 因为已经创建成功
|
||||
int count = instructionService.queryInstructionCount(next_device_code);
|
||||
// 使用统一更新方法,不同步数据库(由BeltConveyorDeviceDriver内部处理)
|
||||
beltConveyorDeviceDriver.updateAndSyncOutboundTaskNum(count, false, false);
|
||||
beltConveyorDeviceDriver.writing("to_taskNum", count + "");
|
||||
// 确保nextdevice也被更新
|
||||
nextdevice.setOutbound_task_num(count);
|
||||
} catch (Exception e) {
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code("更新出库任务数失败")
|
||||
.content("设备: " + nextdevice.getDevice_code() + ", 错误: " + e.getMessage())
|
||||
.build();
|
||||
logDto.setLog_level(4);
|
||||
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
acsTask.setRemark(e.getMessage());
|
||||
taskserver.updateByCodeFromCache(acsTask);
|
||||
|
||||
@@ -10,7 +10,7 @@ spring:
|
||||
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
||||
# url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:stand_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||
# url: jdbc:log4jdbc:mysql://${DB_HOST:47.111.78.178}:${DB_PORT:3306}/${DB_NAME:lzhl_two_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:ynfj_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:fujia_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
|
||||
|
||||
username: ${DB_USER:root}
|
||||
# password: ${DB_PWD:Root.123456}
|
||||
|
||||
Reference in New Issue
Block a user