|
|
|
@ -28,7 +28,9 @@ import java.util.List;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class HardService {
|
|
|
|
|
private final Logger logger = LoggerFactory.getLogger("HardService.class");//Logger.getLogger("HardService.class");
|
|
|
|
|
private final Logger logger = LoggerFactory.getLogger("HardService.class");// Logger.getLogger("HardService.class");
|
|
|
|
|
public MqttClient recvClient;
|
|
|
|
|
public MqttClient deviceClient;
|
|
|
|
|
@Autowired
|
|
|
|
|
private IntegratedMachineConfigDao integratedMachineConfigDao;
|
|
|
|
|
@Autowired
|
|
|
|
@ -41,10 +43,10 @@ public class HardService {
|
|
|
|
|
private DisplayConfigDao displayConfigDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private MessageConfigDao messageConfigDao;
|
|
|
|
|
public MqttClient recvClient;
|
|
|
|
|
public MqttClient deviceClient;
|
|
|
|
|
|
|
|
|
|
public void plateRecognize(RecognizeAlarmInfoPlate req) {
|
|
|
|
|
logger.info("车牌识别结果:{}", JSONObject.toJSONString(req));
|
|
|
|
|
|
|
|
|
|
ReturnCode result;
|
|
|
|
|
ReportCarPassRes ret;
|
|
|
|
|
String strRet = "";
|
|
|
|
@ -53,43 +55,59 @@ public class HardService {
|
|
|
|
|
String carNo = req.getAlarmInfoPlate().getResult().getPlateResult().getLicense();
|
|
|
|
|
String devNo = req.getAlarmInfoPlate().getSerialno();
|
|
|
|
|
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"收到车牌识别推送");
|
|
|
|
|
if (carNo == null || carNo.isEmpty() || carNo.contains("无")) {
|
|
|
|
|
logger.error("车牌识别失败, 车牌为空");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "收到车牌识别推送");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IntegratedMachineConfig integratedCond = new IntegratedMachineConfig();
|
|
|
|
|
integratedCond.setDevNo(devNo);
|
|
|
|
|
//获取一体机配置
|
|
|
|
|
// 获取一体机配置
|
|
|
|
|
IntegratedMachineConfig integratedCfg = integratedMachineConfigDao.selectByCond(integratedCond);
|
|
|
|
|
|
|
|
|
|
laneName = integratedCfg.getLaneName();
|
|
|
|
|
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"车牌识别详细信息");
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "车牌识别详细信息");
|
|
|
|
|
|
|
|
|
|
//保持车头照
|
|
|
|
|
String dirName = createLocalImgDir(carNo,devNo,laneName);
|
|
|
|
|
// 保持车头照
|
|
|
|
|
String dirName = createLocalImgDir(carNo, devNo, laneName);
|
|
|
|
|
String PhotoFrontFileName = RandomUtil.getRandomUuid() + ".jpg";
|
|
|
|
|
String PhotoFrontFilePath = saveFrontImage(req.getAlarmInfoPlate().getResult().getPlateResult().getImageFile(),carNo,dirName,devNo,laneName,PhotoFrontFileName);
|
|
|
|
|
String PhotoFrontFilePath = saveFrontImage(req.getAlarmInfoPlate().getResult().getPlateResult().getImageFile(), carNo, dirName, devNo, laneName, PhotoFrontFileName);
|
|
|
|
|
logger.info("播放语音: {}", integratedCfg.getIpVoiceId());
|
|
|
|
|
try {
|
|
|
|
|
if (integratedCfg != null) {
|
|
|
|
|
if (integratedCfg.getIsFront() == 1) {
|
|
|
|
|
// 获取音柱配置
|
|
|
|
|
IpVoiceboxConfigEx ipVoiceboxConfig = ipVoiceboxConfigDao.selectByPrimaryKey(integratedCfg.getIpVoiceId());
|
|
|
|
|
if (ipVoiceboxConfig != null) {
|
|
|
|
|
MessageConfig messageConfig = messageConfigDao.selectByPrimaryKey(3L);
|
|
|
|
|
|
|
|
|
|
if(integratedCfg != null) {
|
|
|
|
|
if (integratedCfg.getIsFront() == 1) {
|
|
|
|
|
//获取音柱配置
|
|
|
|
|
IpVoiceboxConfigEx ipVoiceboxConfig = ipVoiceboxConfigDao.selectByPrimaryKey(integratedCfg.getIpVoiceId());
|
|
|
|
|
if (ipVoiceboxConfig != null) {
|
|
|
|
|
MessageConfig messageConfig = messageConfigDao.selectByPrimaryKey(3L);
|
|
|
|
|
|
|
|
|
|
PlayVoiceReq playVoice = new PlayVoiceReq();
|
|
|
|
|
playVoice.setCarNo(carNo);
|
|
|
|
|
playVoice.setDeviceNo(ipVoiceboxConfig.getDevNo());
|
|
|
|
|
playVoice.setText(messageConfig.getContent());
|
|
|
|
|
playVoice(playVoice);
|
|
|
|
|
PlayVoiceReq playVoice = new PlayVoiceReq();
|
|
|
|
|
playVoice.setCarNo(carNo);
|
|
|
|
|
playVoice.setDeviceNo(ipVoiceboxConfig.getDevNo());
|
|
|
|
|
playVoice.setText(messageConfig.getContent());
|
|
|
|
|
playVoice(playVoice);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "not find integrated");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"not find integrated");
|
|
|
|
|
return;
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("播放语音失败", e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String PhotoBodyUrl = UploadToAliUtil.uploadFile(dirName, new File(PhotoFrontFilePath), PhotoFrontFileName,
|
|
|
|
|
ConstUtil.OSS_ENDPOINT, ConstUtil.OSS_BUCKET, ConstUtil.OSS_SECRET_ID, ConstUtil.OSS_SECRET_KEY);
|
|
|
|
|
String PhotoBodyUrl = null;
|
|
|
|
|
try {
|
|
|
|
|
PhotoBodyUrl = UploadToAliUtil.uploadFile(dirName, new File(PhotoFrontFilePath), PhotoFrontFileName,
|
|
|
|
|
ConstUtil.OSS_ENDPOINT, ConstUtil.OSS_BUCKET, ConstUtil.OSS_SECRET_ID, ConstUtil.OSS_SECRET_KEY);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("图片上传失败", e);
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ReportUnifyReq reportUnifyReq = new ReportUnifyReq();
|
|
|
|
@ -98,7 +116,7 @@ public class HardService {
|
|
|
|
|
reportUnifyReq.setCarDiscernCode(devNo);
|
|
|
|
|
reportUnifyReq.setPhotoFront(PhotoBodyUrl);
|
|
|
|
|
|
|
|
|
|
printDate(carNo,devNo,laneName,optName + "上报",reportUnifyReq);
|
|
|
|
|
printDate(carNo, devNo, laneName, optName + "上报", reportUnifyReq);
|
|
|
|
|
String jsonObj;
|
|
|
|
|
jsonObj = JSONObject.toJSONString(reportUnifyReq);
|
|
|
|
|
strRet = HttpClientUtil.postJson(ConstUtil.REPORT_SERVER + ConstUtil.REPORT_PASS_SERVER_URL, jsonObj);
|
|
|
|
@ -111,61 +129,61 @@ public class HardService {
|
|
|
|
|
// " \"scene\":\"CPR\"" +
|
|
|
|
|
// " }\n" +
|
|
|
|
|
// "}";
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"上报返回:" + strRet);
|
|
|
|
|
result = JSONObject.parseObject(strRet,ReturnCode.class);
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "上报返回:" + strRet);
|
|
|
|
|
result = JSONObject.parseObject(strRet, ReturnCode.class);
|
|
|
|
|
|
|
|
|
|
//printDate(carNo,devNo,laneName,optName,"上报解析:" + result);
|
|
|
|
|
// printDate(carNo,devNo,laneName,optName,"上报解析:" + result);
|
|
|
|
|
|
|
|
|
|
ConstUtil.DOOR_STATUS.put(devNo,0);
|
|
|
|
|
ConstUtil.DOOR_STATUS.put(devNo, 0);
|
|
|
|
|
|
|
|
|
|
if(result != null && result.getData() != null) {
|
|
|
|
|
if (result != null && result.getData() != null) {
|
|
|
|
|
ret = JSONObject.parseObject(result.getData(), ReportCarPassRes.class);
|
|
|
|
|
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"type:" + ret.getType().intValue() + "");
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "type:" + ret.getType().intValue() + "");
|
|
|
|
|
|
|
|
|
|
if (ret.getScene().compareTo("OPEN") == 0) {
|
|
|
|
|
System.out.println("open enter door");
|
|
|
|
|
} else {
|
|
|
|
|
if (ret.getType().intValue() == 0) {
|
|
|
|
|
//无效数据
|
|
|
|
|
// 无效数据
|
|
|
|
|
} else if (ret.getType().intValue() == 1) {
|
|
|
|
|
//进场,需要获取进场磅重
|
|
|
|
|
// 进场,需要获取进场磅重
|
|
|
|
|
int nLane = integratedCfg.getNType();
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"车道编号:" + nLane + "");
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "车道编号:" + nLane + "");
|
|
|
|
|
if (nLane == 0) {
|
|
|
|
|
//出场
|
|
|
|
|
// 出场
|
|
|
|
|
} else {
|
|
|
|
|
if(integratedCfg.getIsDoorStatus() == 1) {
|
|
|
|
|
if (checkDoorStatus(devNo,carNo,laneName) == false) {
|
|
|
|
|
if (integratedCfg.getIsDoorStatus() == 1) {
|
|
|
|
|
if (checkDoorStatus(devNo, carNo, laneName) == false) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
collectAndUploadData(req, ret.getOrderNo(),dirName,PhotoFrontFilePath);
|
|
|
|
|
//closeDoor(30000,carNo,devNo,laneName);
|
|
|
|
|
collectAndUploadData(req, ret.getOrderNo(), dirName, PhotoFrontFilePath);
|
|
|
|
|
// closeDoor(30000,carNo,devNo,laneName);
|
|
|
|
|
}
|
|
|
|
|
} else if (ret.getType().intValue() == 2) {
|
|
|
|
|
//出场,需要获取出场磅重
|
|
|
|
|
// 出场,需要获取出场磅重
|
|
|
|
|
int nLane = integratedCfg.getNType();
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"车道编号:" + nLane + "");
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "车道编号:" + nLane + "");
|
|
|
|
|
if (nLane == 0) {
|
|
|
|
|
//出场
|
|
|
|
|
if(integratedCfg.getIsDoorStatus() == 1) {
|
|
|
|
|
if (checkDoorStatus(devNo,carNo,laneName) == false) {
|
|
|
|
|
// 出场
|
|
|
|
|
if (integratedCfg.getIsDoorStatus() == 1) {
|
|
|
|
|
if (checkDoorStatus(devNo, carNo, laneName) == false) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
closeDoor(0,carNo,devNo,laneName);
|
|
|
|
|
collectAndUploadData(req, ret.getOrderNo(),dirName,PhotoFrontFilePath);
|
|
|
|
|
closeDoor(0, carNo, devNo, laneName);
|
|
|
|
|
collectAndUploadData(req, ret.getOrderNo(), dirName, PhotoFrontFilePath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"服务器无法访问或返回错误");
|
|
|
|
|
} else {
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "服务器无法访问或返回错误");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void collectAndUploadData(RecognizeAlarmInfoPlate req,String orderNo,String dirName,String PhotoFrontFilePath){
|
|
|
|
|
public void collectAndUploadData(RecognizeAlarmInfoPlate req, String orderNo, String dirName, String PhotoFrontFilePath) {
|
|
|
|
|
ReturnCode ret;
|
|
|
|
|
boolean bRet;
|
|
|
|
|
String PhotoBodyUrl = "";
|
|
|
|
@ -180,19 +198,19 @@ public class HardService {
|
|
|
|
|
MessageConfig messageConfig;
|
|
|
|
|
|
|
|
|
|
integratedCond.setDevNo(devNo);
|
|
|
|
|
//获取一体机配置
|
|
|
|
|
// 获取一体机配置
|
|
|
|
|
IntegratedMachineConfigEx integratedCfg = integratedMachineConfigDao.selectByCond(integratedCond);
|
|
|
|
|
//获取地磅配置
|
|
|
|
|
// 获取地磅配置
|
|
|
|
|
WagonBalanceConfig wagonCfg = wagonBalanceConfigDao.selectByPrimaryKey(integratedCfg.getWagonBalanceId());
|
|
|
|
|
//获取网络摄像头1配置
|
|
|
|
|
// 获取网络摄像头1配置
|
|
|
|
|
HkCameraConfigEx hkCameraConfig = hkCameraConfigDao.selectByPrimaryKey(integratedCfg.getHkCameraId());
|
|
|
|
|
//获取网络音柱配置
|
|
|
|
|
// 获取网络音柱配置
|
|
|
|
|
IpVoiceboxConfig ipVoiceboxConfig = ipVoiceboxConfigDao.selectByPrimaryKey(integratedCfg.getIpVoiceId());
|
|
|
|
|
|
|
|
|
|
laneName = integratedCfg.getLaneName();
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"collectAndUploadData");
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "collectAndUploadData");
|
|
|
|
|
|
|
|
|
|
//显示车牌
|
|
|
|
|
// 显示车牌
|
|
|
|
|
DisplayInfoReq displayInfoReq = new DisplayInfoReq();
|
|
|
|
|
|
|
|
|
|
displayInfoReq.setCarPlate(carNo);
|
|
|
|
@ -205,7 +223,7 @@ public class HardService {
|
|
|
|
|
int weightLoop = 3;
|
|
|
|
|
if (wagonCfg != null) {
|
|
|
|
|
while (weightLoop > 0) {
|
|
|
|
|
//播放等待语音
|
|
|
|
|
// 播放等待语音
|
|
|
|
|
if (ipVoiceboxConfig != null) {
|
|
|
|
|
messageConfig = messageConfigDao.selectByPrimaryKey(2L);
|
|
|
|
|
PlayVoiceReq playVoice = new PlayVoiceReq();
|
|
|
|
@ -216,19 +234,19 @@ public class HardService {
|
|
|
|
|
playVoice(playVoice);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//printDate(carNo,devNo,laneName,"称重","读地磅开始");
|
|
|
|
|
// printDate(carNo,devNo,laneName,"称重","读地磅开始");
|
|
|
|
|
|
|
|
|
|
//读取地磅数据
|
|
|
|
|
// 读取地磅数据
|
|
|
|
|
weight = getWeightInfo(wagonCfg.getPortName(), wagonCfg.getBaudRate(), wagonCfg.getDataBits().byteValue()
|
|
|
|
|
, wagonCfg.getParity().byteValue(), wagonCfg.getStopBits().byteValue()
|
|
|
|
|
, carNo, devNo, "称重");
|
|
|
|
|
|
|
|
|
|
int nWeight = (int) weight;
|
|
|
|
|
printDate(carNo, devNo, laneName, "称重", "磅重数据:" + weight);
|
|
|
|
|
//nWeight = 10000;
|
|
|
|
|
//printDate(carNo,devNo,laneName,"称重","读地磅结束");
|
|
|
|
|
// nWeight = 10000;
|
|
|
|
|
// printDate(carNo,devNo,laneName,"称重","读地磅结束");
|
|
|
|
|
if (nWeight <= 200) {
|
|
|
|
|
//播放重新称重提示
|
|
|
|
|
// 播放重新称重提示
|
|
|
|
|
if (ipVoiceboxConfig != null) {
|
|
|
|
|
messageConfig = messageConfigDao.selectByPrimaryKey(4L);
|
|
|
|
|
PlayVoiceReq playVoice = new PlayVoiceReq();
|
|
|
|
@ -239,47 +257,47 @@ public class HardService {
|
|
|
|
|
playVoice(playVoice);
|
|
|
|
|
}
|
|
|
|
|
weightLoop--;
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//显示磅重
|
|
|
|
|
// 显示磅重
|
|
|
|
|
displayInfoReq.setCarPlate(carNo);
|
|
|
|
|
displayInfoReq.setWeight("磅重:" + (weight / 1000));
|
|
|
|
|
displayInfoReq.setAmount("");
|
|
|
|
|
displayInfoReq.setDeviceNo(devNo);
|
|
|
|
|
displayInfo(displayInfoReq);
|
|
|
|
|
|
|
|
|
|
//抓拍车斗图片并上传
|
|
|
|
|
// 抓拍车斗图片并上传
|
|
|
|
|
String PhotoBodyFileName = RandomUtil.getRandomUuid() + ".jpg";
|
|
|
|
|
String PhotoBodyFilePath = "/" +dirName + "/" + PhotoBodyFileName;
|
|
|
|
|
String PhotoBodyFilePath = "/" + dirName + "/" + PhotoBodyFileName;
|
|
|
|
|
String PhotoFrontUrl = "";
|
|
|
|
|
|
|
|
|
|
if(hkCameraConfig != null) {
|
|
|
|
|
printDate(carNo,devNo,laneName,"高位","获取高位摄像头开始");
|
|
|
|
|
bRet = captureImage(hkCameraConfig, ConstUtil.LOCAL_PATH + PhotoBodyFilePath,carNo,devNo,laneName);
|
|
|
|
|
if (hkCameraConfig != null) {
|
|
|
|
|
printDate(carNo, devNo, laneName, "高位", "获取高位摄像头开始");
|
|
|
|
|
bRet = captureImage(hkCameraConfig, ConstUtil.LOCAL_PATH + PhotoBodyFilePath, carNo, devNo, laneName);
|
|
|
|
|
if (bRet == true) {
|
|
|
|
|
printDate(carNo,devNo,laneName,"高位","上传车斗照");
|
|
|
|
|
printDate(carNo, devNo, laneName, "高位", "上传车斗照");
|
|
|
|
|
PhotoBodyUrl = "/file" + PhotoBodyFilePath;
|
|
|
|
|
PhotoBodyUrl = UploadToAliUtil.uploadFile(dirName, new File(ConstUtil.LOCAL_PATH + PhotoBodyFilePath), PhotoBodyFileName,
|
|
|
|
|
ConstUtil.OSS_ENDPOINT, ConstUtil.OSS_BUCKET, ConstUtil.OSS_SECRET_ID, ConstUtil.OSS_SECRET_KEY);
|
|
|
|
|
} else {
|
|
|
|
|
PhotoBodyFilePath = "";
|
|
|
|
|
printDate(carNo,devNo,laneName,"高位","高位摄像头拍摄失败");
|
|
|
|
|
printDate(carNo, devNo, laneName, "高位", "高位摄像头拍摄失败");
|
|
|
|
|
}
|
|
|
|
|
printDate(carNo,devNo,laneName,"高位","获取高位摄像头结束");
|
|
|
|
|
printDate(carNo, devNo, laneName, "高位", "获取高位摄像头结束");
|
|
|
|
|
}
|
|
|
|
|
printDate(carNo,devNo,laneName,"高位","上传车头照");
|
|
|
|
|
//上传车头照
|
|
|
|
|
printDate(carNo, devNo, laneName, "高位", "上传车头照");
|
|
|
|
|
// 上传车头照
|
|
|
|
|
File file = new File(PhotoFrontFilePath);
|
|
|
|
|
String PhotoFrontFileName = file.getName();
|
|
|
|
|
PhotoFrontUrl = UploadToAliUtil.uploadFile(dirName, new File(PhotoFrontFilePath), PhotoFrontFileName,
|
|
|
|
|
ConstUtil.OSS_ENDPOINT, ConstUtil.OSS_BUCKET, ConstUtil.OSS_SECRET_ID, ConstUtil.OSS_SECRET_KEY);
|
|
|
|
|
|
|
|
|
|
//ConstUtil.DOOR_STATUS.put(devNo,0);
|
|
|
|
|
//上传数据
|
|
|
|
|
// ConstUtil.DOOR_STATUS.put(devNo,0);
|
|
|
|
|
// 上传数据
|
|
|
|
|
// printDate(carNo,devNo,laneName,optName,"上传数据开始");
|
|
|
|
|
// //获取另一台识别设备的设备号
|
|
|
|
|
// IntegratedMachineConfig listCond = new IntegratedMachineConfig();
|
|
|
|
@ -311,50 +329,50 @@ public class HardService {
|
|
|
|
|
|
|
|
|
|
jsonObj = JSONObject.toJSONString(reportUnifyReq);
|
|
|
|
|
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"上传数据开始:" + reportUnifyReq);
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "上传数据开始:" + reportUnifyReq);
|
|
|
|
|
|
|
|
|
|
strRet = HttpClientUtil.postJson(ConstUtil.REPORT_SERVER + ConstUtil.REPORT_SERVER_URL, jsonObj);
|
|
|
|
|
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"上传数据返回:" + strRet);
|
|
|
|
|
//ret = JSONObject.parseObject(strRet, ReturnCode.class);
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "上传数据返回:" + strRet);
|
|
|
|
|
// ret = JSONObject.parseObject(strRet, ReturnCode.class);
|
|
|
|
|
|
|
|
|
|
req.getAlarmInfoPlate().getResult().getPlateResult().setImageFile("");
|
|
|
|
|
jsonObj = JSONObject.toJSONString(req);
|
|
|
|
|
printDate(carNo,devNo,laneName,"车牌识别","车牌识别数据:" + req);
|
|
|
|
|
printDate(carNo, devNo, laneName, "车牌识别", "车牌识别数据:" + req);
|
|
|
|
|
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"上传数据结束");
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "上传数据结束");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getDoorStatus(String devNo,String carNo){
|
|
|
|
|
public int getDoorStatus(String devNo, String carNo) {
|
|
|
|
|
String laneName = "";
|
|
|
|
|
String optName = "获取道闸状态";
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"获取道闸状态开始");
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "获取道闸状态开始");
|
|
|
|
|
String strStatus = "";
|
|
|
|
|
DoorStatus doorStatus;
|
|
|
|
|
int nRet = 0;
|
|
|
|
|
int nRet = 0;
|
|
|
|
|
IntegratedMachineConfig integratedCond = new IntegratedMachineConfig();
|
|
|
|
|
|
|
|
|
|
integratedCond.setDevNo(devNo);
|
|
|
|
|
//获取一体机配置
|
|
|
|
|
// 获取一体机配置
|
|
|
|
|
IntegratedMachineConfig integratedCfg = integratedMachineConfigDao.selectByCond(integratedCond);
|
|
|
|
|
|
|
|
|
|
laneName = integratedCfg.getLaneName();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
String cmd = ConstUtil.CMD_PATH + " getDoorStatus" + integratedCfg.getVerNo() + " " + integratedCfg.getIpAddr() +" " + integratedCfg.getTcpPort() +" " + integratedCfg.getRs485Port();
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,cmd);
|
|
|
|
|
String cmd = ConstUtil.CMD_PATH + " getDoorStatus" + integratedCfg.getVerNo() + " " + integratedCfg.getIpAddr() + " " + integratedCfg.getTcpPort() + " " + integratedCfg.getRs485Port();
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, cmd);
|
|
|
|
|
CmdUtil cmdUtil = new CmdUtil();
|
|
|
|
|
List<String> listRet = cmdUtil.exec(cmd);
|
|
|
|
|
String line;
|
|
|
|
|
for (int i = 0;i < listRet.size();i++){
|
|
|
|
|
for (int i = 0; i < listRet.size(); i++) {
|
|
|
|
|
line = listRet.get(i);
|
|
|
|
|
int pos = line.indexOf("getDoorStatus_success:");
|
|
|
|
|
if(pos >= 0){
|
|
|
|
|
if (pos >= 0) {
|
|
|
|
|
strStatus = line.substring(22);
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,strStatus);
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, strStatus);
|
|
|
|
|
doorStatus = JSONObject.parseObject(strStatus, DoorStatus.class);
|
|
|
|
|
//信号为0的时候说明闸是关着的;信号是1的时候,说明闸开了
|
|
|
|
|
if(doorStatus.getValue().compareTo("0") == 0){
|
|
|
|
|
// 信号为0的时候说明闸是关着的;信号是1的时候,说明闸开了
|
|
|
|
|
if (doorStatus.getValue().compareTo("0") == 0) {
|
|
|
|
|
nRet = 1;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
@ -363,12 +381,12 @@ public class HardService {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"status is " + nRet);
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"获取道闸状态结束");
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "status is " + nRet);
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "获取道闸状态结束");
|
|
|
|
|
return nRet;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public double getWeightInfo(String pPort,int BaudRate,byte ByteSize,byte Parity,byte StopBits,String carNo,String devNo,String laneName){
|
|
|
|
|
public double getWeightInfo(String pPort, int BaudRate, byte ByteSize, byte Parity, byte StopBits, String carNo, String devNo, String laneName) {
|
|
|
|
|
String weight = "0.0";
|
|
|
|
|
double dWeight = 0.0;
|
|
|
|
|
String optName = "称重";
|
|
|
|
@ -378,12 +396,12 @@ public class HardService {
|
|
|
|
|
CmdUtil cmdUtil = new CmdUtil();
|
|
|
|
|
List<String> listRet = cmdUtil.exec(cmd);
|
|
|
|
|
String line;
|
|
|
|
|
for (int i = 0;i < listRet.size();i++) {
|
|
|
|
|
for (int i = 0; i < listRet.size(); i++) {
|
|
|
|
|
line = listRet.get(i);
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,line);
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, line);
|
|
|
|
|
int pos = line.indexOf("weight:");
|
|
|
|
|
if(pos >= 0){
|
|
|
|
|
weight = line.substring(7,line.length() - 1);
|
|
|
|
|
if (pos >= 0) {
|
|
|
|
|
weight = line.substring(7, line.length() - 1);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -395,7 +413,7 @@ public class HardService {
|
|
|
|
|
return dWeight;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean captureImage(HkCameraConfigEx config,String fileName,String carNo,String devNo,String laneName){
|
|
|
|
|
public boolean captureImage(HkCameraConfigEx config, String fileName, String carNo, String devNo, String laneName) {
|
|
|
|
|
boolean bRet = false;
|
|
|
|
|
String optName = "高位";
|
|
|
|
|
|
|
|
|
@ -405,9 +423,9 @@ public class HardService {
|
|
|
|
|
CmdUtil cmdUtil = new CmdUtil();
|
|
|
|
|
List<String> listRet = cmdUtil.exec(cmd);
|
|
|
|
|
String line;
|
|
|
|
|
for (int i = 0;i < listRet.size();i++) {
|
|
|
|
|
for (int i = 0; i < listRet.size(); i++) {
|
|
|
|
|
line = listRet.get(i);
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,line);
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, line);
|
|
|
|
|
int pos = line.indexOf("captureImage:success");
|
|
|
|
|
if (pos >= 0) {
|
|
|
|
|
bRet = true;
|
|
|
|
@ -422,6 +440,8 @@ public class HardService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int playVoice(PlayVoiceReq req) {
|
|
|
|
|
logger.info("播放语音请求:{}", JSONObject.toJSONString(req));
|
|
|
|
|
|
|
|
|
|
String carNo = req.getCarNo();
|
|
|
|
|
String devNo = req.getDeviceNo();
|
|
|
|
|
String laneName = "";
|
|
|
|
@ -431,10 +451,10 @@ public class HardService {
|
|
|
|
|
|
|
|
|
|
cond.setDevNo(req.getDeviceNo());
|
|
|
|
|
IpVoiceboxConfigEx cfg = ipVoiceboxConfigDao.selectByCond(cond);
|
|
|
|
|
if(cfg != null) {
|
|
|
|
|
if (cfg != null) {
|
|
|
|
|
try {
|
|
|
|
|
laneName = cfg.getLaneName();
|
|
|
|
|
//printDate(carNo, devNo, laneName, optName, "播放语音开始");
|
|
|
|
|
// printDate(carNo, devNo, laneName, optName, "播放语音开始");
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, req);
|
|
|
|
|
String strChinese = StringToChineseUtil.convert(req.getText());
|
|
|
|
|
String baseStr = Base64.encodeBase64String(strChinese.getBytes("UTF-8"));
|
|
|
|
@ -459,15 +479,15 @@ public class HardService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String prefix = "voice dev return ";
|
|
|
|
|
ThreadPlayVoice thread = new ThreadPlayVoice(this,cmd, prefix, jsonReq, optName, carNo, devNo, laneName);
|
|
|
|
|
ThreadPlayVoice thread = new ThreadPlayVoice(this, cmd, prefix, jsonReq, optName, carNo, devNo, laneName);
|
|
|
|
|
thread.start();
|
|
|
|
|
|
|
|
|
|
//printDate(carNo, devNo, laneName, optName, "播放语音结束");
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
// printDate(carNo, devNo, laneName, optName, "播放语音结束");
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.info("语音播放异常", e);
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"device not fount");
|
|
|
|
|
} else {
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "device not fount");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
@ -482,80 +502,121 @@ public class HardService {
|
|
|
|
|
IntegratedMachineConfig integratedCond = new IntegratedMachineConfig();
|
|
|
|
|
|
|
|
|
|
integratedCond.setDevNo(req.getDeviceNo());
|
|
|
|
|
//获取一体机配置
|
|
|
|
|
// 获取一体机配置
|
|
|
|
|
IntegratedMachineConfig integratedCfg = integratedMachineConfigDao.selectByCond(integratedCond);
|
|
|
|
|
|
|
|
|
|
laneName = integratedCfg.getLaneName();
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"开闸开始");
|
|
|
|
|
if(integratedCfg != null) {
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "开闸开始");
|
|
|
|
|
if (integratedCfg != null) {
|
|
|
|
|
String cmd = ConstUtil.CMD_PATH + " openDoor" + integratedCfg.getVerNo() + " " + integratedCfg.getIpAddr();
|
|
|
|
|
if(integratedCfg.getTcpPort().intValue() >= 0){
|
|
|
|
|
if (integratedCfg.getTcpPort().intValue() >= 0) {
|
|
|
|
|
cmd += " " + integratedCfg.getTcpPort();
|
|
|
|
|
}
|
|
|
|
|
if(integratedCfg.getHttpPort().intValue() >= 0){
|
|
|
|
|
if (integratedCfg.getHttpPort().intValue() >= 0) {
|
|
|
|
|
cmd += " " + integratedCfg.getHttpPort();
|
|
|
|
|
}
|
|
|
|
|
if(integratedCfg.getIoPort().intValue() >= 0){
|
|
|
|
|
if (integratedCfg.getIoPort().intValue() >= 0) {
|
|
|
|
|
cmd += " " + integratedCfg.getIoPort();
|
|
|
|
|
}
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,cmd);
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, cmd);
|
|
|
|
|
String prefix = "dev return ";
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
ThreadOpenDoor thread = new ThreadOpenDoor(this,cmd, prefix, jsonReq, optName, carNo, devNo, laneName);
|
|
|
|
|
ThreadOpenDoor thread = new ThreadOpenDoor(this, cmd, prefix, jsonReq, optName, carNo, devNo, laneName);
|
|
|
|
|
thread.start();
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"开闸结束");
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "开闸结束");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int mqttOpenDoor(DoorReq req){
|
|
|
|
|
String[] TOPIC_ARRAY = {
|
|
|
|
|
ConstUtil.MQTT_DEVICE_TOPIC + "user/get"};
|
|
|
|
|
public int mqttOpenDoor(DoorReq req) {
|
|
|
|
|
logger.info("开门请求: {}", JSONObject.toJSONString(req));
|
|
|
|
|
|
|
|
|
|
// String[] TOPIC_ARRAY = {"/message/down/gpio_out"};
|
|
|
|
|
String carNo = req.getCarNo();
|
|
|
|
|
String devNo = req.getDeviceNo();
|
|
|
|
|
String deviceNo = req.getDeviceNo();
|
|
|
|
|
String devNo = deviceNo;
|
|
|
|
|
String laneName = "";
|
|
|
|
|
String optName = "开闸";
|
|
|
|
|
IntegratedMachineConfig integratedCond = new IntegratedMachineConfig();
|
|
|
|
|
|
|
|
|
|
integratedCond.setDevNo(req.getDeviceNo());
|
|
|
|
|
//获取一体机配置
|
|
|
|
|
integratedCond.setDevNo(deviceNo);
|
|
|
|
|
// 获取一体机配置
|
|
|
|
|
IntegratedMachineConfig integratedCfg = integratedMachineConfigDao.selectByCond(integratedCond);
|
|
|
|
|
|
|
|
|
|
int i = integratedCfg.getIoPort().intValue();
|
|
|
|
|
laneName = integratedCfg.getLaneName();
|
|
|
|
|
String msgId = System.currentTimeMillis() + RandomUtil.getRandomStr(7);
|
|
|
|
|
|
|
|
|
|
RecognizePlateResultAckQy ack = new RecognizePlateResultAckQy();
|
|
|
|
|
/* RecognizePlateResultAckQy ack = new RecognizePlateResultAckQy();
|
|
|
|
|
ack.setCmd("iooutput");
|
|
|
|
|
ack.setMsg_id(msgId);
|
|
|
|
|
ack.setIonum(1);
|
|
|
|
|
ack.setAction("on");
|
|
|
|
|
ack.setUtc_ts(1);
|
|
|
|
|
ack.setUtc_ts(1); */
|
|
|
|
|
|
|
|
|
|
long time = new Date().getTime();
|
|
|
|
|
DorMsg dorMsg = new DorMsg()
|
|
|
|
|
.setId("open" + time)
|
|
|
|
|
.setSn(deviceNo)
|
|
|
|
|
.setTimestamp(time)
|
|
|
|
|
.setPayload(new DorMsg.Payload()
|
|
|
|
|
.setBody(new DorMsg.Payload.Body()
|
|
|
|
|
.setIo(i)
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
MqttMessage ackMsg = new MqttMessage();
|
|
|
|
|
String strPayload = JSONObject.toJSONString(ack);
|
|
|
|
|
String strPayload = JSONObject.toJSONString(dorMsg);
|
|
|
|
|
|
|
|
|
|
ackMsg.setPayload(strPayload.getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
try {
|
|
|
|
|
String topic = ConstUtil.MQTT_DEVICE_TYPE + req.getDeviceNo() + TOPIC_ARRAY[0];
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"开闸主题:" + topic);
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"开闸消息:" + strPayload);
|
|
|
|
|
deviceClient.publish( topic, ackMsg);
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
String topic = "device/" + deviceNo + "/message/down/gpio_out";
|
|
|
|
|
logger.info("主题: {},开门数据: {}", topic, strPayload);
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "开闸主题:" + topic);
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "开闸消息:" + strPayload);
|
|
|
|
|
deviceClient.publish(topic, ackMsg);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("开门失败", e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"开闸结束");
|
|
|
|
|
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "开闸结束");
|
|
|
|
|
/* if (deviceNo.equals("e6141562-e3ca0602")) {
|
|
|
|
|
rollerDoor();
|
|
|
|
|
} */
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int mqttCloseDoor(DoorReq req){
|
|
|
|
|
void rollerDoor() {
|
|
|
|
|
logger.info("开卷闸门");
|
|
|
|
|
long time = new Date().getTime();
|
|
|
|
|
String sn = "5417bd21-ca9f6a6b";
|
|
|
|
|
DorMsg dorMsg = new DorMsg()
|
|
|
|
|
.setId("open" + time)
|
|
|
|
|
.setSn(sn)
|
|
|
|
|
.setTimestamp(time)
|
|
|
|
|
.setPayload(new DorMsg.Payload()
|
|
|
|
|
.setBody(new DorMsg.Payload.Body()
|
|
|
|
|
.setIo(1)
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
MqttMessage ackMsg = new MqttMessage();
|
|
|
|
|
String strPayload = JSONObject.toJSONString(dorMsg);
|
|
|
|
|
|
|
|
|
|
ackMsg.setPayload(strPayload.getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
try {
|
|
|
|
|
String topic = "device/" + sn + "/message/down/gpio_out";
|
|
|
|
|
logger.info("主题: {},开门数据: {}", topic, strPayload);
|
|
|
|
|
deviceClient.publish(topic, ackMsg);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("开门失败", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int mqttCloseDoor(DoorReq req) {
|
|
|
|
|
String[] TOPIC_ARRAY = {
|
|
|
|
|
ConstUtil.MQTT_DEVICE_TOPIC + "user/get"};
|
|
|
|
|
String carNo = req.getCarNo();
|
|
|
|
@ -565,7 +626,7 @@ public class HardService {
|
|
|
|
|
IntegratedMachineConfig integratedCond = new IntegratedMachineConfig();
|
|
|
|
|
|
|
|
|
|
integratedCond.setDevNo(req.getDeviceNo());
|
|
|
|
|
//获取一体机配置
|
|
|
|
|
// 获取一体机配置
|
|
|
|
|
IntegratedMachineConfig integratedCfg = integratedMachineConfigDao.selectByCond(integratedCond);
|
|
|
|
|
|
|
|
|
|
laneName = integratedCfg.getLaneName();
|
|
|
|
@ -583,15 +644,15 @@ public class HardService {
|
|
|
|
|
|
|
|
|
|
ackMsg.setPayload(strPayload.getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
try {
|
|
|
|
|
String topic = ConstUtil.MQTT_DEVICE_TYPE + req.getDeviceNo() + TOPIC_ARRAY[0];
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"开闸主题:" + topic);
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"开闸消息:" + strPayload);
|
|
|
|
|
deviceClient.publish( topic, ackMsg);
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
String topic = ConstUtil.MQTT_DEVICE_TYPE + req.getDeviceNo() + TOPIC_ARRAY[0];
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "开闸主题:" + topic);
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "开闸消息:" + strPayload);
|
|
|
|
|
deviceClient.publish(topic, ackMsg);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"开闸结束");
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "开闸结束");
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
@ -604,22 +665,22 @@ public class HardService {
|
|
|
|
|
IntegratedMachineConfig integratedCond = new IntegratedMachineConfig();
|
|
|
|
|
|
|
|
|
|
integratedCond.setDevNo(req.getDeviceNo());
|
|
|
|
|
//获取一体机配置
|
|
|
|
|
// 获取一体机配置
|
|
|
|
|
IntegratedMachineConfig integratedCfg = integratedMachineConfigDao.selectByCond(integratedCond);
|
|
|
|
|
|
|
|
|
|
laneName = integratedCfg.getLaneName();
|
|
|
|
|
|
|
|
|
|
if(integratedCfg != null) {
|
|
|
|
|
if (integratedCfg != null) {
|
|
|
|
|
String cmd = ConstUtil.CMD_PATH + " manualTrigger " + integratedCfg.getIpAddr() + " " + integratedCfg.getTcpPort();
|
|
|
|
|
CmdUtil cmdUtil = new CmdUtil();
|
|
|
|
|
List<String> listRet = cmdUtil.exec(cmd);
|
|
|
|
|
String line;
|
|
|
|
|
for (int i = 0;i < listRet.size();i++) {
|
|
|
|
|
for (int i = 0; i < listRet.size(); i++) {
|
|
|
|
|
line = listRet.get(i);
|
|
|
|
|
int pos = line.indexOf("dev return ");
|
|
|
|
|
if(pos >= 0){
|
|
|
|
|
if (pos >= 0) {
|
|
|
|
|
String devRet = line.substring(11);
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,devRet);
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, devRet);
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
@ -639,14 +700,14 @@ public class HardService {
|
|
|
|
|
DisplayConfig displayCond = new DisplayConfig();
|
|
|
|
|
|
|
|
|
|
displayCond.setDevNo(devNo);
|
|
|
|
|
//获取一体机配置
|
|
|
|
|
// 获取一体机配置
|
|
|
|
|
DisplayConfig displayCfg = displayConfigDao.selectByCond(displayCond);
|
|
|
|
|
|
|
|
|
|
if(displayCfg != null) {
|
|
|
|
|
if (displayCfg != null) {
|
|
|
|
|
try {
|
|
|
|
|
laneName = displayCfg.getLaneName();
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, req);
|
|
|
|
|
//printDate(carNo, devNo, laneName, optName, "显示文字开始");
|
|
|
|
|
// printDate(carNo, devNo, laneName, optName, "显示文字开始");
|
|
|
|
|
String cmd = ConstUtil.CMD_PATH + " displayInfo" + displayCfg.getVerNo() + " " + displayCfg.getIpAddr();
|
|
|
|
|
String clearCmd = ConstUtil.CMD_PATH + " displayInfo" + displayCfg.getVerNo() + " " + displayCfg.getIpAddr();
|
|
|
|
|
if (displayCfg.getTcpPort().intValue() >= 0) {
|
|
|
|
@ -655,41 +716,43 @@ public class HardService {
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isBlank(req.getCarPlate()) == true) {
|
|
|
|
|
cmd += " " + "IA==";
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
cmd += " " + Base64.encodeBase64String(req.getCarPlate().getBytes("UTF-8"));
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isBlank(req.getWeight()) == true) {
|
|
|
|
|
cmd += " " + "IA==";
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
cmd += " " + Base64.encodeBase64String(req.getWeight().getBytes("UTF-8"));
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isBlank(req.getAmount()) == true) {
|
|
|
|
|
cmd += " " + "IA==";
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
cmd += " " + Base64.encodeBase64String(req.getAmount().getBytes("UTF-8"));
|
|
|
|
|
}
|
|
|
|
|
clearCmd += " IA==";
|
|
|
|
|
clearCmd += " " + Base64.encodeBase64String(ConstUtil.DEFAULT_ADVERT_1.getBytes("UTF-8"));
|
|
|
|
|
clearCmd += " " + Base64.encodeBase64String(ConstUtil.DEFAULT_ADVERT_2.getBytes("UTF-8"));;
|
|
|
|
|
clearCmd += " " + Base64.encodeBase64String(ConstUtil.DEFAULT_ADVERT_2.getBytes("UTF-8"));
|
|
|
|
|
;
|
|
|
|
|
if (displayCfg.getRs485Port().intValue() >= 0) {
|
|
|
|
|
cmd += " " + displayCfg.getRs485Port();
|
|
|
|
|
clearCmd += " " + displayCfg.getRs485Port();
|
|
|
|
|
}
|
|
|
|
|
String prefix = "display dev return ";
|
|
|
|
|
|
|
|
|
|
ThreadDisplayInfo thread = new ThreadDisplayInfo(this,cmd, prefix, jsonReq, "显示", carNo, devNo, laneName);
|
|
|
|
|
ThreadDisplayInfo thread = new ThreadDisplayInfo(this, cmd, prefix, jsonReq, "显示", carNo, devNo, laneName);
|
|
|
|
|
thread.start();
|
|
|
|
|
ThreadClearDisplay clearThread = new ThreadClearDisplay(this,clearCmd, carNo, devNo, laneName);
|
|
|
|
|
ThreadClearDisplay clearThread = new ThreadClearDisplay(this, clearCmd, carNo, devNo, laneName);
|
|
|
|
|
clearThread.start();
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"device not find");
|
|
|
|
|
} else {
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "device not find");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int mqttDisplayInfo(DisplayInfoReq req) {
|
|
|
|
|
String[] TOPIC_ARRAY = {
|
|
|
|
|
ConstUtil.MQTT_DEVICE_TOPIC + "user/get"};
|
|
|
|
@ -700,7 +763,7 @@ public class HardService {
|
|
|
|
|
IntegratedMachineConfig integratedCond = new IntegratedMachineConfig();
|
|
|
|
|
|
|
|
|
|
integratedCond.setDevNo(req.getDeviceNo());
|
|
|
|
|
//获取一体机配置
|
|
|
|
|
// 获取一体机配置
|
|
|
|
|
IntegratedMachineConfig integratedCfg = integratedMachineConfigDao.selectByCond(integratedCond);
|
|
|
|
|
|
|
|
|
|
laneName = integratedCfg.getLaneName();
|
|
|
|
@ -736,24 +799,24 @@ public class HardService {
|
|
|
|
|
|
|
|
|
|
ackMsg.setPayload(strPayload.getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
try {
|
|
|
|
|
String topic = ConstUtil.MQTT_DEVICE_TYPE + req.getDeviceNo() + TOPIC_ARRAY[0];
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"开闸主题:" + topic);
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"开闸消息:" + strPayload);
|
|
|
|
|
String topic = ConstUtil.MQTT_DEVICE_TYPE + req.getDeviceNo() + TOPIC_ARRAY[0];
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "开闸主题:" + topic);
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "开闸消息:" + strPayload);
|
|
|
|
|
deviceClient.publish(topic, ackMsg);
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"开闸结束");
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "开闸结束");
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void clearDisplay(){
|
|
|
|
|
public void clearDisplay() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int manualPlateRecognize(RecognizeAlarmInfoPlate req,String orderNo) {
|
|
|
|
|
public int manualPlateRecognize(RecognizeAlarmInfoPlate req, String orderNo) {
|
|
|
|
|
String jsonObj = JSONObject.toJSONString(req);
|
|
|
|
|
String devNo = req.getAlarmInfoPlate().getSerialno();
|
|
|
|
|
String carNo = req.getAlarmInfoPlate().getResult().getPlateResult().getLicense();
|
|
|
|
@ -763,28 +826,28 @@ public class HardService {
|
|
|
|
|
IntegratedMachineConfig integratedCond = new IntegratedMachineConfig();
|
|
|
|
|
|
|
|
|
|
integratedCond.setDevNo(devNo);
|
|
|
|
|
//获取一体机配置
|
|
|
|
|
// 获取一体机配置
|
|
|
|
|
IntegratedMachineConfig integratedCfg = integratedMachineConfigDao.selectByCond(integratedCond);
|
|
|
|
|
|
|
|
|
|
laneName = integratedCfg.getLaneName();
|
|
|
|
|
|
|
|
|
|
String dirName = createLocalImgDir(carNo,carNo,laneName);
|
|
|
|
|
String dirName = createLocalImgDir(carNo, carNo, laneName);
|
|
|
|
|
String PhotoFrontFileName = RandomUtil.getRandomUuid() + ".jpg";
|
|
|
|
|
String PhotoFrontFilePath = ConstUtil.LOCAL_PATH + "/" + dirName + "/" + PhotoFrontFileName;
|
|
|
|
|
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"手动获取数据");
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,req);
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "手动获取数据");
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, req);
|
|
|
|
|
|
|
|
|
|
if(integratedCfg != null) {
|
|
|
|
|
if (integratedCfg != null) {
|
|
|
|
|
boolean bRet = false;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
String cmd = ConstUtil.CMD_PATH + " manualPlateRecognize " + integratedCfg.getIpAddr() + " " + integratedCfg.getTcpPort() + " " + PhotoFrontFilePath;
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,cmd);
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, cmd);
|
|
|
|
|
CmdUtil cmdUtil = new CmdUtil();
|
|
|
|
|
List<String> listRet = cmdUtil.exec(cmd);
|
|
|
|
|
String line;
|
|
|
|
|
for (int i = 0;i < listRet.size();i++) {
|
|
|
|
|
for (int i = 0; i < listRet.size(); i++) {
|
|
|
|
|
line = listRet.get(i);
|
|
|
|
|
int pos = line.indexOf("captureImage:success");
|
|
|
|
|
if (pos >= 0) {
|
|
|
|
@ -796,11 +859,11 @@ public class HardService {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(bRet == false){
|
|
|
|
|
if (bRet == false) {
|
|
|
|
|
PhotoFrontFilePath = "";
|
|
|
|
|
}
|
|
|
|
|
//req.getAlarmInfoPlate().getResult().getPlateResult().setImageFile(imageData);
|
|
|
|
|
ThreadManualPlateRecognize thread = new ThreadManualPlateRecognize(this, req, orderNo,dirName,PhotoFrontFilePath);
|
|
|
|
|
// req.getAlarmInfoPlate().getResult().getPlateResult().setImageFile(imageData);
|
|
|
|
|
ThreadManualPlateRecognize thread = new ThreadManualPlateRecognize(this, req, orderNo, dirName, PhotoFrontFilePath);
|
|
|
|
|
thread.start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -815,33 +878,33 @@ public class HardService {
|
|
|
|
|
IntegratedMachineConfig integratedCond = new IntegratedMachineConfig();
|
|
|
|
|
|
|
|
|
|
integratedCond.setDevNo(req.getDeviceNo());
|
|
|
|
|
//获取一体机配置
|
|
|
|
|
// 获取一体机配置
|
|
|
|
|
List<IntegratedMachineConfigEx> list = integratedMachineConfigDao.selectListByCond(integratedCond);
|
|
|
|
|
|
|
|
|
|
for (int i = 0;i < list.size();i++){
|
|
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
|
|
IntegratedMachineConfigEx integratedCfg = list.get(i);
|
|
|
|
|
|
|
|
|
|
String cmd = ConstUtil.CMD_PATH + " resetDevTime" + integratedCfg.getVerNo() + " " + integratedCfg.getIpAddr() + " " + integratedCfg.getTcpPort() + " " + integratedCfg.getRs485Port();
|
|
|
|
|
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,cmd);
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, cmd);
|
|
|
|
|
CmdUtil cmdUtil = new CmdUtil();
|
|
|
|
|
List<String> listRet = cmdUtil.exec(cmd);
|
|
|
|
|
String line;
|
|
|
|
|
for (int j = 0;j < listRet.size();j++) {
|
|
|
|
|
for (int j = 0; j < listRet.size(); j++) {
|
|
|
|
|
line = listRet.get(j);
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,line);
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, line);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean checkDoorStatus(String devNo,String carNo,String laneName){
|
|
|
|
|
public boolean checkDoorStatus(String devNo, String carNo, String laneName) {
|
|
|
|
|
String optName = "获取道闸状态";
|
|
|
|
|
Integer status = ConstUtil.DOOR_STATUS.get(devNo);
|
|
|
|
|
int i = 0;
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"checkDoorStatus:" + status);
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "checkDoorStatus:" + status);
|
|
|
|
|
|
|
|
|
|
//20秒内是否已下发开闸指令,如果已下发,状态为IS_SEND_OPEN_DOOR,否则20秒内检测40次
|
|
|
|
|
while (status.compareTo(ConstUtil.IS_NOT_SEND_OPEN_DOOR) == 0 && i < 40){
|
|
|
|
|
// 20秒内是否已下发开闸指令,如果已下发,状态为IS_SEND_OPEN_DOOR,否则20秒内检测40次
|
|
|
|
|
while (status.compareTo(ConstUtil.IS_NOT_SEND_OPEN_DOOR) == 0 && i < 40) {
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(500);
|
|
|
|
|
status = ConstUtil.DOOR_STATUS.get(devNo);
|
|
|
|
@ -851,15 +914,15 @@ public class HardService {
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"status:" + status);
|
|
|
|
|
//已下发开闸指令,开始获取落闸信号
|
|
|
|
|
if(status.compareTo(ConstUtil.IS_SEND_OPEN_DOOR) == 0) {
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "status:" + status);
|
|
|
|
|
// 已下发开闸指令,开始获取落闸信号
|
|
|
|
|
if (status.compareTo(ConstUtil.IS_SEND_OPEN_DOOR) == 0) {
|
|
|
|
|
int nTotalTime = 0;
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"已开闸");
|
|
|
|
|
//50秒内取100次道闸状态,确认道闸是否为落闸
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "已开闸");
|
|
|
|
|
// 50秒内取100次道闸状态,确认道闸是否为落闸
|
|
|
|
|
while (nTotalTime < 100) {
|
|
|
|
|
try {
|
|
|
|
|
int doorStatus = getDoorStatus(devNo,carNo);
|
|
|
|
|
int doorStatus = getDoorStatus(devNo, carNo);
|
|
|
|
|
if (doorStatus == ConstUtil.DOOR_STATUS_CLOSEED) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
@ -874,45 +937,45 @@ public class HardService {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void closeDoor(int times,String carNo,String devNo,String laneName){
|
|
|
|
|
//关卷帘门,苏州弘盛发专用
|
|
|
|
|
ThreadCloseDoor thread = new ThreadCloseDoor(this,carNo,devNo,laneName,times);
|
|
|
|
|
public void closeDoor(int times, String carNo, String devNo, String laneName) {
|
|
|
|
|
// 关卷帘门,苏州弘盛发专用
|
|
|
|
|
ThreadCloseDoor thread = new ThreadCloseDoor(this, carNo, devNo, laneName, times);
|
|
|
|
|
thread.start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String createLocalImgDir(String carNo,String devNo,String laneName){
|
|
|
|
|
public String createLocalImgDir(String carNo, String devNo, String laneName) {
|
|
|
|
|
String optName = "创建图片目录";
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
SimpleDateFormat dateFormat= new SimpleDateFormat("yyyyMMdd");
|
|
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
|
String dirName = dateFormat.format(date);
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,dirName);
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, dirName);
|
|
|
|
|
|
|
|
|
|
File file = new File(ConstUtil.LOCAL_PATH + dirName);
|
|
|
|
|
|
|
|
|
|
if (!file.exists()) {
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"目录不存在");
|
|
|
|
|
//创建上级目录
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "目录不存在");
|
|
|
|
|
// 创建上级目录
|
|
|
|
|
file.mkdirs();
|
|
|
|
|
}
|
|
|
|
|
return dirName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String saveFrontImage(String imageData,String carNo,String dirName,String devNo,String laneName,String PhotoFrontFileName){
|
|
|
|
|
public String saveFrontImage(String imageData, String carNo, String dirName, String devNo, String laneName, String PhotoFrontFileName) {
|
|
|
|
|
String optName = "保存图片";
|
|
|
|
|
String PhotoFrontFilePath = ConstUtil.LOCAL_PATH + "/" + dirName + "/" + PhotoFrontFileName;
|
|
|
|
|
|
|
|
|
|
//保存车牌图片并上传
|
|
|
|
|
// 保存车牌图片并上传
|
|
|
|
|
boolean bRet = ImageUtil.generateImage(imageData, PhotoFrontFilePath);
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"保存车牌图片完成:" + PhotoFrontFilePath);
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "保存车牌图片完成:" + PhotoFrontFilePath);
|
|
|
|
|
if (bRet == false) {
|
|
|
|
|
PhotoFrontFilePath = "";
|
|
|
|
|
printDate(carNo,devNo,laneName,optName,"一体机拍摄失败:" + carNo);
|
|
|
|
|
printDate(carNo, devNo, laneName, optName, "一体机拍摄失败:" + carNo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return PhotoFrontFilePath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void printDate(String carNo,String devNo,String laneName,String optName,Object content){
|
|
|
|
|
public void printDate(String carNo, String devNo, String laneName, String optName, Object content) {
|
|
|
|
|
logger.info(optName + ":" + carNo + ":" + devNo + ":" + laneName + ":" + content);
|
|
|
|
|
|
|
|
|
|
LogEntity logEntity = new LogEntity();
|
|
|
|
|