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);
|
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||||
standardOrdinarySiteDeviceDriver.setOption(0);
|
standardOrdinarySiteDeviceDriver.setOption(0);
|
||||||
} else if (device.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
|
} else if (device.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
|
||||||
|
//到达取货点 入库
|
||||||
beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) device.getDeviceDriver();
|
beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) device.getDeviceDriver();
|
||||||
if (beltConveyorDeviceDriver.getAction() == 1 && beltConveyorDeviceDriver.getMode() == 2 && beltConveyorDeviceDriver.getError() == 0&& beltConveyorDeviceDriver.getMove() == 1) {
|
if (beltConveyorDeviceDriver.getAction() == 1 && beltConveyorDeviceDriver.getMode() == 2 && beltConveyorDeviceDriver.getError() == 0&& beltConveyorDeviceDriver.getMove() == 1) {
|
||||||
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
|
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
|||||||
if (move == 1 && !requireSucess) {
|
if (move == 1 && !requireSucess) {
|
||||||
boolean b = instruction_require();
|
boolean b = instruction_require();
|
||||||
if (b) {
|
if (b) {
|
||||||
requireSucess = false;
|
log.info(this.device_code + ",任务申请成功!");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String remark = "";
|
String remark = "";
|
||||||
@@ -326,18 +326,10 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
|||||||
synchronized(this) { // 添加同步锁
|
synchronized(this) { // 添加同步锁
|
||||||
if (!requireSucess) { // 双重检查锁定
|
if (!requireSucess) { // 双重检查锁定
|
||||||
try {
|
try {
|
||||||
// 1. 查询设备
|
|
||||||
Device device = deviceAppService.findDeviceByCode(device_code);
|
|
||||||
|
|
||||||
Integer result = updateOutboundTaskNum(-1,true);
|
// 使用统一方法更新出库任务数并同步数据库
|
||||||
|
updateAndSyncOutboundTaskNum(-1, true, true);
|
||||||
// 2. 更新任务数
|
Integer result = this.outbound_task_num;
|
||||||
device.setOutbound_task_num(result);
|
|
||||||
|
|
||||||
// 3. 保存更新(假设需要显式保存)
|
|
||||||
deviceservice.update(new UpdateWrapper<Device>()
|
|
||||||
.set("outbound_task_num",result)
|
|
||||||
.eq("device_code",device.getDevice_code()));
|
|
||||||
|
|
||||||
// 更新task的出库完成数
|
// 更新task的出库完成数
|
||||||
TaskDto taskDto = new TaskDto();
|
TaskDto taskDto = new TaskDto();
|
||||||
@@ -355,7 +347,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
|||||||
map2.put("value", result);
|
map2.put("value", result);
|
||||||
this.writing(list1);
|
this.writing(list1);
|
||||||
|
|
||||||
// 5. 只有成功后才设置标记
|
// 只有成功后才设置标记
|
||||||
requireSucess = true;
|
requireSucess = true;
|
||||||
|
|
||||||
log.info(this.device_code + ",成功更新出库任务数");
|
log.info(this.device_code + ",成功更新出库任务数");
|
||||||
@@ -445,8 +437,10 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
|||||||
} else {
|
} else {
|
||||||
this.instruction_require_time = date;
|
this.instruction_require_time = date;
|
||||||
Device device = deviceAppService.findDeviceByCode(device_code);
|
Device device = deviceAppService.findDeviceByCode(device_code);
|
||||||
|
log.info("device_code"+ device_code);
|
||||||
List<String> list = device.getDeviceDriver().getExtraDeviceCodes("link_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设备
|
//关联的RFID设备
|
||||||
String linkDeviceCode = list.get(0);
|
String linkDeviceCode = list.get(0);
|
||||||
BmVehicleRfid bmVehicleRfid = ibmVehicleRfidService.findByDeviceCode(linkDeviceCode);
|
BmVehicleRfid bmVehicleRfid = ibmVehicleRfidService.findByDeviceCode(linkDeviceCode);
|
||||||
@@ -558,6 +552,32 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
|||||||
}
|
}
|
||||||
return this.outbound_task_num;
|
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
|
@Override
|
||||||
public JSONObject getDeviceStatusName() {
|
public JSONObject getDeviceStatusName() {
|
||||||
|
|||||||
@@ -371,8 +371,10 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
|||||||
}
|
}
|
||||||
if (ObjectUtil.isEmpty(errArr)) {
|
if (ObjectUtil.isEmpty(errArr)) {
|
||||||
response.setStatus(200);
|
response.setStatus(200);
|
||||||
|
response.setCode(200);
|
||||||
response.setMessage("success");
|
response.setMessage("success");
|
||||||
} else {
|
} else {
|
||||||
|
response.setCode(400);
|
||||||
response.setStatus(400);
|
response.setStatus(400);
|
||||||
if (ObjectUtil.isNotEmpty(errArr)) {
|
if (ObjectUtil.isNotEmpty(errArr)) {
|
||||||
response.setMessage(errArr.getJSONObject(0).getString("message"));
|
response.setMessage(errArr.getJSONObject(0).getString("message"));
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.nl.acs.rfid_manage.service.IbmVehicleRfidService;
|
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.BmVehicleRfidParam;
|
||||||
|
import org.nl.acs.rfid_manage.service.dto.UpdateRfidParam;
|
||||||
import org.nl.common.base.TableDataInfo;
|
import org.nl.common.base.TableDataInfo;
|
||||||
import org.nl.common.domain.query.PageQuery;
|
import org.nl.common.domain.query.PageQuery;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
@@ -107,4 +108,16 @@ public class BmVehicleRfidController {
|
|||||||
bmVehicleRfidService.deleteAll(ids);
|
bmVehicleRfidService.deleteAll(ids);
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
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 com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import org.nl.acs.rfid_manage.service.dao.BmVehicleRfid;
|
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.BmVehicleRfidParam;
|
||||||
|
import org.nl.acs.rfid_manage.service.dto.UpdateRfidParam;
|
||||||
import org.nl.common.domain.query.PageQuery;
|
import org.nl.common.domain.query.PageQuery;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -54,6 +55,8 @@ public interface IbmVehicleRfidService extends IService<BmVehicleRfid> {
|
|||||||
|
|
||||||
void connectRfid(BmVehicleRfidParam params);
|
void connectRfid(BmVehicleRfidParam params);
|
||||||
|
|
||||||
|
Boolean updateRfid(UpdateRfidParam params);
|
||||||
|
|
||||||
void writeEpc(String id);
|
void writeEpc(String id);
|
||||||
|
|
||||||
BmVehicleRfid findByDeviceCode(String linkDeviceCode);
|
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.DateTime;
|
||||||
import cn.hutool.core.date.DateUtil;
|
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.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
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.HandlerTagEpcLog;
|
||||||
import com.gg.reader.api.dal.HandlerTcpDisconnected;
|
import com.gg.reader.api.dal.HandlerTcpDisconnected;
|
||||||
import com.gg.reader.api.protocol.gx.*;
|
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.apache.commons.lang3.StringUtils;
|
||||||
import org.nl.acs.rfid_manage.service.IbmVehicleRfidService;
|
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.BmVehicleRfid;
|
||||||
import org.nl.acs.rfid_manage.service.dao.mapper.BmVehicleRfidMapper;
|
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.BmVehicleRfidParam;
|
||||||
import org.nl.acs.rfid_manage.service.dto.EpcRecord;
|
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.acs.utils.StructUtil;
|
||||||
|
import org.nl.common.domain.constant.DictConstantPool;
|
||||||
import org.nl.common.domain.query.PageQuery;
|
import org.nl.common.domain.query.PageQuery;
|
||||||
|
import org.nl.system.service.user.dao.SysUser;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -27,12 +34,14 @@ import javax.annotation.Resource;
|
|||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
@Service("bmVehicleRfidService")
|
@Service("bmVehicleRfidService")
|
||||||
|
@Slf4j
|
||||||
public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, BmVehicleRfid> implements IbmVehicleRfidService {
|
public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, BmVehicleRfid> implements IbmVehicleRfidService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@@ -72,6 +81,7 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
|||||||
client.sendSynMsg(msgBaseInventoryEpc);
|
client.sendSynMsg(msgBaseInventoryEpc);
|
||||||
if (msgBaseInventoryEpc.getRtCode() == 0x00) {
|
if (msgBaseInventoryEpc.getRtCode() == 0x00) {
|
||||||
System.out.println("设备[" + ip + "] 开始扫码任务成功");
|
System.out.println("设备[" + ip + "] 开始扫码任务成功");
|
||||||
|
log.info("设备[" + ip + "] 开始扫码任务成功");
|
||||||
} else {
|
} else {
|
||||||
System.err.println("设备[" + ip + "] 扫码配置失败: " + msgBaseInventoryEpc.getRtMsg());
|
System.err.println("设备[" + ip + "] 扫码配置失败: " + msgBaseInventoryEpc.getRtMsg());
|
||||||
}
|
}
|
||||||
@@ -83,7 +93,7 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
|||||||
// //写EPC,数据默认为 hex 432
|
// //写EPC,数据默认为 hex 432
|
||||||
// msg.setArea(EnumG.WriteArea_Epc);
|
// msg.setArea(EnumG.WriteArea_Epc);
|
||||||
// String sWriteHexData = "888"; // 写入数据 (16进制)
|
// String sWriteHexData = "888"; // 写入数据 (16进制)
|
||||||
// System.out.println("Write hex " + sWriteHexData);
|
// log.info("Write hex " + sWriteHexData);
|
||||||
// int iWordLen = StructUtil.getValueLen(sWriteHexData);
|
// int iWordLen = StructUtil.getValueLen(sWriteHexData);
|
||||||
// // PC值为EPC区域的长度标识(前5个bit标记长度),参考文档说明
|
// // PC值为EPC区域的长度标识(前5个bit标记长度),参考文档说明
|
||||||
// sWriteHexData = StructUtil.getPc(iWordLen) + StructUtil.padLeft(sWriteHexData.toUpperCase(), 4 * iWordLen, '0'); // PC值+数据内容
|
// 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));
|
// // msg.setBwriteData(HexUtils.hexString2Bytes(sWriteHexData));
|
||||||
// client.sendSynMsg(msg);
|
// client.sendSynMsg(msg);
|
||||||
// if (0 == msg.getRtCode()) {
|
// if (0 == msg.getRtCode()) {
|
||||||
// System.out.println("写入:" + sWriteHexData + "成功!");
|
// log.info("写入:" + sWriteHexData + "成功!");
|
||||||
// } else {
|
// } else {
|
||||||
// System.out.println("写入:" + sWriteHexData + "失败!");
|
// log.info("写入:" + sWriteHexData + "失败!");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// 订阅标签事件
|
// 订阅标签事件
|
||||||
@@ -104,16 +114,20 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
|||||||
client.sendSynMsg(msgAppGetBaseVersion);
|
client.sendSynMsg(msgAppGetBaseVersion);
|
||||||
if (0x00 == msgAppGetBaseVersion.getRtCode()) {
|
if (0x00 == msgAppGetBaseVersion.getRtCode()) {
|
||||||
System.out.println("msgAppGetBaseVersion[OK].");
|
System.out.println("msgAppGetBaseVersion[OK].");
|
||||||
|
log.info("msgAppGetBaseVersion[OK].");
|
||||||
} else {
|
} else {
|
||||||
System.out.println(msgAppGetBaseVersion.getRtMsg());
|
System.out.println(msgAppGetBaseVersion.getRtMsg());
|
||||||
|
log.info(msgAppGetBaseVersion.getRtMsg());
|
||||||
}
|
}
|
||||||
//获取设备信息
|
//获取设备信息
|
||||||
MsgAppGetReaderInfo msgAppGetReaderInfo = new MsgAppGetReaderInfo();
|
MsgAppGetReaderInfo msgAppGetReaderInfo = new MsgAppGetReaderInfo();
|
||||||
client.sendSynMsg(msgAppGetReaderInfo);
|
client.sendSynMsg(msgAppGetReaderInfo);
|
||||||
if (0x00 == msgAppGetReaderInfo.getRtCode()) {
|
if (0x00 == msgAppGetReaderInfo.getRtCode()) {
|
||||||
System.out.println("msgAppGetReaderInfo[OK].");
|
System.out.println("msgAppGetReaderInfo[OK].");
|
||||||
|
log.info("msgAppGetReaderInfo[OK].");
|
||||||
} else {
|
} else {
|
||||||
System.out.println(msgAppGetReaderInfo.getRtMsg());
|
System.out.println(msgAppGetReaderInfo.getRtMsg());
|
||||||
|
log.info(msgAppGetReaderInfo.getRtMsg());
|
||||||
}
|
}
|
||||||
BmVehicleRfid updated = new BmVehicleRfid();
|
BmVehicleRfid updated = new BmVehicleRfid();
|
||||||
updated.setId(deviceId);
|
updated.setId(deviceId);
|
||||||
@@ -143,7 +157,7 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
|||||||
// MsgBaseStop stopMsg = new MsgBaseStop();
|
// MsgBaseStop stopMsg = new MsgBaseStop();
|
||||||
// client.sendSynMsg(stopMsg);
|
// client.sendSynMsg(stopMsg);
|
||||||
// if (stopMsg.getRtCode() == 0x00) {
|
// if (stopMsg.getRtCode() == 0x00) {
|
||||||
// System.out.println("设备[" + ip + "] 停止扫码任务成功");
|
// log.info("设备[" + ip + "] 停止扫码任务成功");
|
||||||
// } else {
|
// } else {
|
||||||
// System.err.println("设备[" + ip + "] 停止扫码失败: " + stopMsg.getRtMsg());
|
// System.err.println("设备[" + ip + "] 停止扫码失败: " + stopMsg.getRtMsg());
|
||||||
// }
|
// }
|
||||||
@@ -151,6 +165,7 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
|||||||
// removeClient(deviceId);
|
// removeClient(deviceId);
|
||||||
disconnectAllClients();
|
disconnectAllClients();
|
||||||
System.out.println("设备[" + ip + "] 已断开连接");
|
System.out.println("设备[" + ip + "] 已断开连接");
|
||||||
|
log.info("设备[" + ip + "] 已断开连接");
|
||||||
BmVehicleRfid updated = new BmVehicleRfid();
|
BmVehicleRfid updated = new BmVehicleRfid();
|
||||||
updated.setId(deviceId);
|
updated.setId(deviceId);
|
||||||
updated.setRfid(null);
|
updated.setRfid(null);
|
||||||
@@ -166,11 +181,43 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
|||||||
updated.setStatus(0);
|
updated.setStatus(0);
|
||||||
this.updateById(updated);
|
this.updateById(updated);
|
||||||
System.out.println("设备[" + ip + "] 未连接,无需断开");
|
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
|
@Override
|
||||||
public void writeEpc(String id) {
|
public void writeEpc(String id) {
|
||||||
GClient client = getClient("1");
|
GClient client = getClient("1");
|
||||||
@@ -184,6 +231,7 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
|||||||
msg.setArea(EnumG.WriteArea_Epc);
|
msg.setArea(EnumG.WriteArea_Epc);
|
||||||
String sWriteHexData = "666"; // 写入数据 (16进制)
|
String sWriteHexData = "666"; // 写入数据 (16进制)
|
||||||
System.out.println("Write hex " + sWriteHexData);
|
System.out.println("Write hex " + sWriteHexData);
|
||||||
|
log.info("Write hex " + sWriteHexData);
|
||||||
int iWordLen = StructUtil.getValueLen(sWriteHexData);
|
int iWordLen = StructUtil.getValueLen(sWriteHexData);
|
||||||
// PC值为EPC区域的长度标识(前5个bit标记长度),参考文档说明
|
// PC值为EPC区域的长度标识(前5个bit标记长度),参考文档说明
|
||||||
sWriteHexData = StructUtil.getPc(iWordLen) + StructUtil.padLeft(sWriteHexData.toUpperCase(), 4 * iWordLen, '0'); // PC值+数据内容
|
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);
|
client.sendSynMsg(msg);
|
||||||
if (0 == msg.getRtCode()) {
|
if (0 == msg.getRtCode()) {
|
||||||
System.out.println("写入:" + sWriteHexData + "成功!");
|
System.out.println("写入:" + sWriteHexData + "成功!");
|
||||||
|
log.info("写入:" + sWriteHexData + "成功!");
|
||||||
} else {
|
} else {
|
||||||
System.out.println("写入:" + sWriteHexData + "失败!");
|
System.out.println("写入:" + sWriteHexData + "失败!");
|
||||||
|
log.info("写入:" + sWriteHexData + "失败!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -215,8 +265,10 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
|||||||
client.sendSynMsg(msgBaseStop);
|
client.sendSynMsg(msgBaseStop);
|
||||||
if (0 == msgBaseStop.getRtCode()) {
|
if (0 == msgBaseStop.getRtCode()) {
|
||||||
System.out.println("停止成功!");
|
System.out.println("停止成功!");
|
||||||
|
log.info("停止成功!");
|
||||||
} else {
|
} else {
|
||||||
System.out.println("停止失败!");
|
System.out.println("停止失败!");
|
||||||
|
log.info("停止失败!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -242,8 +294,10 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
|||||||
for (BmVehicleRfid r : clientList) {
|
for (BmVehicleRfid r : clientList) {
|
||||||
String ip = r.getIp() + ":" + r.getPort();
|
String ip = r.getIp() + ":" + r.getPort();
|
||||||
System.out.println("设备[" + ip + "] 连接异常,开始重连...");
|
System.out.println("设备[" + ip + "] 连接异常,开始重连...");
|
||||||
|
log.info("设备[" + ip + "] 连接异常,开始重连...");
|
||||||
if (tryReconnect(r.getId(), ip)) {
|
if (tryReconnect(r.getId(), ip)) {
|
||||||
System.out.println("设备[" + ip + "] 重连成功");
|
System.out.println("设备[" + ip + "] 重连成功");
|
||||||
|
log.info("设备[" + ip + "] 重连成功");
|
||||||
} else {
|
} else {
|
||||||
System.err.println("设备[" + ip + "] 重连失败");
|
System.err.println("设备[" + ip + "] 重连失败");
|
||||||
}
|
}
|
||||||
@@ -255,6 +309,7 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
|||||||
final int WAIT_MS = 500;
|
final int WAIT_MS = 500;
|
||||||
for (int i = 1; i <= MAX_RETRY; i++) {
|
for (int i = 1; i <= MAX_RETRY; i++) {
|
||||||
System.out.println("设备[" + ip + "] 第" + i + "次重连尝试...");
|
System.out.println("设备[" + ip + "] 第" + i + "次重连尝试...");
|
||||||
|
log.info("设备[" + ip + "] 第" + i + "次重连尝试...");
|
||||||
GClient oldClient = clientMap.remove(deviceId);
|
GClient oldClient = clientMap.remove(deviceId);
|
||||||
if (oldClient != null) {
|
if (oldClient != null) {
|
||||||
try {
|
try {
|
||||||
@@ -269,6 +324,7 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
|||||||
newClient.setSendHeartBeat(true);
|
newClient.setSendHeartBeat(true);
|
||||||
if (checkConnection(newClient)) {
|
if (checkConnection(newClient)) {
|
||||||
System.out.println("设备[" + ip + "] 重连成功");
|
System.out.println("设备[" + ip + "] 重连成功");
|
||||||
|
log.info("设备[" + ip + "] 重连成功");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
@@ -312,7 +368,7 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
|||||||
// MsgBaseStop stopMsg = new MsgBaseStop();
|
// MsgBaseStop stopMsg = new MsgBaseStop();
|
||||||
// client.sendSynMsg(stopMsg);
|
// client.sendSynMsg(stopMsg);
|
||||||
// if (stopMsg.getRtCode() == 0x00) {
|
// if (stopMsg.getRtCode() == 0x00) {
|
||||||
// System.out.println("停止扫码任务成功: " + deviceId);
|
// log.info("停止扫码任务成功: " + deviceId);
|
||||||
// } else {
|
// } else {
|
||||||
// System.err.println("停止扫码失败: " + stopMsg.getRtMsg());
|
// System.err.println("停止扫码失败: " + stopMsg.getRtMsg());
|
||||||
// }
|
// }
|
||||||
@@ -320,7 +376,7 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
|||||||
// System.err.println("停止扫码任务异常: " + e.getMessage());
|
// System.err.println("停止扫码任务异常: " + e.getMessage());
|
||||||
// } finally {
|
// } finally {
|
||||||
// client.close();
|
// client.close();
|
||||||
// System.out.println("已断开设备连接: " + deviceId);
|
// log.info("已断开设备连接: " + deviceId);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -345,6 +401,7 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
|||||||
@Override
|
@Override
|
||||||
public void log(String s) {
|
public void log(String s) {
|
||||||
System.out.println("command log output5:onDisconnected:" + "connect" + s + "close..........");
|
System.out.println("command log output5:onDisconnected:" + "connect" + s + "close..........");
|
||||||
|
log.info("command log output5:onDisconnected:" + "connect" + s + "close..........");
|
||||||
client.close();//释放当前连接资源
|
client.close();//释放当前连接资源
|
||||||
BmVehicleRfid updated = new BmVehicleRfid();
|
BmVehicleRfid updated = new BmVehicleRfid();
|
||||||
updated.setId(id);
|
updated.setId(id);
|
||||||
@@ -373,6 +430,7 @@ public class BmVehicleRfidServiceImpl extends ServiceImpl<BmVehicleRfidMapper, B
|
|||||||
|
|
||||||
if (isSame) {
|
if (isSame) {
|
||||||
System.out.println(epc + "与上次标签值相同,不上报,跳过....");
|
System.out.println(epc + "与上次标签值相同,不上报,跳过....");
|
||||||
|
log.info(epc + "与上次标签值相同,不上报,跳过....");
|
||||||
return; // EPC 相同且未过期,跳过
|
return; // EPC 相同且未过期,跳过
|
||||||
}
|
}
|
||||||
epcCache.computeIfAbsent(deviceId, k -> new ConcurrentHashMap<>())
|
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 + "成功!");
|
updated.setLog(DateUtil.now() + ":设备:" + currentDevice.getDevice_code() + "读取RFID值:" + epc + "成功!");
|
||||||
this.updateById(updated);
|
this.updateById(updated);
|
||||||
System.out.println("读取RFID值:" + epc + "成功!");
|
System.out.println("读取RFID值:" + epc + "成功!");
|
||||||
|
log.info("读取RFID值:" + epc + "成功!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -197,20 +197,32 @@ public class AutoCreateInst {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
instructionService.create(instdto);
|
instructionService.create(instdto);
|
||||||
|
if (nextdevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
|
||||||
// beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) nextdevice.getDeviceDriver();
|
BeltConveyorDeviceDriver beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) nextdevice.getDeviceDriver();
|
||||||
// //满足出库,查询当前出库任务,+1后返回给
|
//满足出库,查询当前出库任务,+1后返回给
|
||||||
// if (beltConveyorDeviceDriver.getType() == 2) {
|
if (beltConveyorDeviceDriver.getAction() == 2 && beltConveyorDeviceDriver.getMode() == 2
|
||||||
// synchronized (this) {
|
&& beltConveyorDeviceDriver.getError() == 0 && beltConveyorDeviceDriver.getMove() == 0) {
|
||||||
// if (beltConveyorDeviceDriver.getType() == 2) {
|
// 使用同步块确保操作原子性
|
||||||
// //因为已经创建成功,因此这个时候可以+1了
|
synchronized (beltConveyorDeviceDriver) {
|
||||||
// int count = instructionService.queryInstructionCount(next_device_code);
|
try {
|
||||||
// beltConveyorDeviceDriver.updateOutboundTaskNum(count,false);
|
// 因为已经创建成功
|
||||||
// beltConveyorDeviceDriver.writing("to_taskNum", count + "");
|
int count = instructionService.queryInstructionCount(next_device_code);
|
||||||
// nextdevice.setOutbound_task_num(count);
|
// 使用统一更新方法,不同步数据库(由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) {
|
} catch (Exception e) {
|
||||||
acsTask.setRemark(e.getMessage());
|
acsTask.setRemark(e.getMessage());
|
||||||
taskserver.updateByCodeFromCache(acsTask);
|
taskserver.updateByCodeFromCache(acsTask);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ spring:
|
|||||||
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
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: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: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}
|
username: ${DB_USER:root}
|
||||||
# password: ${DB_PWD:Root.123456}
|
# password: ${DB_PWD:Root.123456}
|
||||||
|
|||||||
Reference in New Issue
Block a user