|
|
@@ -1,134 +0,0 @@
|
|
|
-//package com.tmzn.devicelinkykc.taskQueue;
|
|
|
-//
|
|
|
-//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-//import com.tmzn.devicelinkykc.constant.RedisConstant;
|
|
|
-//import com.tmzn.devicelinkykc.entity.Device;
|
|
|
-//import com.tmzn.devicelinkykc.entity.param.TransCheck;
|
|
|
-//import com.tmzn.devicelinkykc.frameMsg.DataConversion;
|
|
|
-//import com.tmzn.devicelinkykc.frameMsg.FrameDataSplicing;
|
|
|
-//import com.tmzn.devicelinkykc.msgEnum.DeviceSendYkc;
|
|
|
-//import com.tmzn.devicelinkykc.redis.RedisCache;
|
|
|
-//import com.tmzn.devicelinkykc.service.DeviceService;
|
|
|
-//import com.tmzn.devicelinkykc.service.DeviceStatusService;
|
|
|
-//import com.tmzn.devicelinkykc.socket.DeviceConnectionMsg;
|
|
|
-//import com.tmzn.devicelinkykc.socket.SocketHandle;
|
|
|
-//import com.tmzn.devicelinkykc.taskQueue.queue.MsgHeartQueue;
|
|
|
-//import com.tmzn.devicelinkykc.util.Encrytion;
|
|
|
-//import lombok.extern.slf4j.Slf4j;
|
|
|
-//import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-//import org.springframework.stereotype.Component;
|
|
|
-//
|
|
|
-//import java.io.IOException;
|
|
|
-//import java.util.List;
|
|
|
-//import java.util.Map;
|
|
|
-//import java.util.Optional;
|
|
|
-//import java.util.Set;
|
|
|
-//import java.util.concurrent.ScheduledExecutorService;
|
|
|
-//import java.util.concurrent.ScheduledThreadPoolExecutor;
|
|
|
-//import java.util.concurrent.TimeUnit;
|
|
|
-//
|
|
|
-///**
|
|
|
-// * @author xp
|
|
|
-// * @date 2024/7/23
|
|
|
-// * @explain " "
|
|
|
-// */
|
|
|
-//@Component
|
|
|
-//@Slf4j
|
|
|
-//public class TransCheckTask {
|
|
|
-// @Autowired
|
|
|
-// private SocketHandle socketHandle;
|
|
|
-// @Autowired
|
|
|
-// private RedisCache redisCache;
|
|
|
-// @Autowired
|
|
|
-// private DeviceService deviceService;
|
|
|
-// @Autowired
|
|
|
-// private MsgHeartQueue msgHeartQueue;
|
|
|
-//
|
|
|
-// //30s没收到订单回复再次上送,上送三次就结束将订单改为
|
|
|
-// public void start(){
|
|
|
-// ScheduledExecutorService scheduler = new ScheduledThreadPoolExecutor(1);
|
|
|
-// Runnable task = new Runnable() {
|
|
|
-// @Override
|
|
|
-// public void run() {
|
|
|
-// try {
|
|
|
-// log.info("check Trans>>>>>>>>>>>>>>>>>>>");
|
|
|
-// Map<String, DeviceConnectionMsg> deviceConnectionMsgMap = socketHandle.getDeviceConnectionMsgMap();
|
|
|
-// Set<String> imeis = redisCache.getCacheObject(RedisConstant.DEVICE_INFO);
|
|
|
-// imeis.stream().forEach(s -> {
|
|
|
-// QueryWrapper<Device> deviceQueryWrapper = new QueryWrapper<>();
|
|
|
-// QueryWrapper<Device> device_imei = deviceQueryWrapper.eq("device_imei", s);
|
|
|
-// Device one = deviceService.getOne(device_imei);
|
|
|
-// if (one != null) {
|
|
|
-// if (deviceConnectionMsgMap.containsKey(one.getPileCode())) {
|
|
|
-// //在线且链接,
|
|
|
-// TransCheck transCheck = redisCache.getCacheObject(RedisConstant.NO_RESPONSE_WAS_RECEIVED + one.getPileCode());
|
|
|
-//
|
|
|
-// if (transCheck.getCheck_time() == 0) {
|
|
|
-// if ((System.currentTimeMillis() - transCheck.getTime()) > 30 * 1000) {
|
|
|
-// log.info(one.getPileCode() + "Transchek>>>>>>>checkTime:" + transCheck.getCheck_time());
|
|
|
-// upTrans(deviceConnectionMsgMap.get(one.getPileCode()), transCheck.getTrans());
|
|
|
-// transCheck.setCheck_time(1);
|
|
|
-// redisCache.setCacheObject(RedisConstant.NO_RESPONSE_WAS_RECEIVED+one.getPileCode(),transCheck);
|
|
|
-// }
|
|
|
-// } else if (transCheck.getCheck_time() == 1) {
|
|
|
-// if ((System.currentTimeMillis() - transCheck.getTime()) > 60 * 1000) {
|
|
|
-// log.info(one.getPileCode() + "Transchek>>>>>>>checkTime:" + transCheck.getCheck_time());
|
|
|
-// upTrans(deviceConnectionMsgMap.get(one.getPileCode()), transCheck.getTrans());
|
|
|
-// transCheck.setCheck_time(2);
|
|
|
-// redisCache.setCacheObject(RedisConstant.NO_RESPONSE_WAS_RECEIVED+one.getPileCode(),transCheck);
|
|
|
-// }
|
|
|
-// } else if (transCheck.getCheck_time() == 2) {
|
|
|
-// if ((System.currentTimeMillis() - transCheck.getTime()) > 90 * 1000) {
|
|
|
-// log.info(one.getPileCode() + "Transchek>>>>>>>checkTime:" + transCheck.getCheck_time());
|
|
|
-// upTrans(deviceConnectionMsgMap.get(one.getPileCode()), transCheck.getTrans());
|
|
|
-// transCheck.setCheck_time(3);
|
|
|
-// redisCache.setCacheObject(RedisConstant.NO_RESPONSE_WAS_RECEIVED+one.getPileCode(),transCheck);
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// redisCache.deleteObject(RedisConstant.NO_RESPONSE_WAS_RECEIVED + one.getPileCode());
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// });
|
|
|
-// }catch (Exception e){
|
|
|
-//
|
|
|
-// }
|
|
|
-// }
|
|
|
-// };
|
|
|
-// scheduler.scheduleAtFixedRate(task,1,5*1000, TimeUnit.MILLISECONDS);
|
|
|
-//
|
|
|
-// }
|
|
|
-// private void upTrans(DeviceConnectionMsg deviceConnectionMsg,byte[] bytes){
|
|
|
-// if(deviceConnectionMsg.getIs18()){
|
|
|
-// try {
|
|
|
-//
|
|
|
-// String key = redisCache.getCacheObject(RedisConstant.KEYS+deviceConnectionMsg.getDeviceId());
|
|
|
-// byte[] rsaEncrypt = Encrytion.aesEncrypt(bytes, key.getBytes());
|
|
|
-// byte[] msg = FrameDataSplicing.spliceing(deviceConnectionMsg.getMessageCount(), DeviceSendYkc.TRANSACTION_RECORDS_REQUEST.getFrameType(), DeviceSendYkc.TRANSACTION_RECORDS_REQUEST.getEncryptFlag(), rsaEncrypt, rsaEncrypt.length, deviceConnectionMsg.getIs18());
|
|
|
-// deviceConnectionMsg.getOutputStream().write(msg);
|
|
|
-// deviceConnectionMsg.getOutputStream().flush();
|
|
|
-// log.info(deviceConnectionMsg.getDeviceId() + "Trans_chek,rsaEncrypt:"+DataConversion.bytesToHexString(rsaEncrypt));
|
|
|
-// } catch (IOException e) {
|
|
|
-// log.info("TransCheck:>>pileCode:" + deviceConnectionMsg.getDeviceId() + " ,TransactionFlow push frame Exception");
|
|
|
-// e.printStackTrace();
|
|
|
-// } catch (Exception e) {
|
|
|
-// e.printStackTrace();
|
|
|
-// }
|
|
|
-// deviceConnectionMsg.incrementMessageCount();
|
|
|
-// return;
|
|
|
-// }
|
|
|
-// try {
|
|
|
-// byte[] msg = FrameDataSplicing.spliceing(deviceConnectionMsg.getMessageCount(), DeviceSendYkc.TRANSACTION_RECORDS_REQUEST.getFrameType(), DeviceSendYkc.TRANSACTION_RECORDS_REQUEST.getEncryptFlag(), bytes, bytes.length, deviceConnectionMsg.getIs18());
|
|
|
-// deviceConnectionMsg.getOutputStream().write(msg);
|
|
|
-// deviceConnectionMsg.getOutputStream().flush();
|
|
|
-// log.info(deviceConnectionMsg.getDeviceId() + "Trans_chek:"+DataConversion.bytesToHexString(bytes));
|
|
|
-// } catch (IOException e) {
|
|
|
-// log.info("TransCheck:>>pileCode:" + deviceConnectionMsg.getDeviceId() + " ,TransactionFlow push frame Exception");
|
|
|
-// e.printStackTrace();
|
|
|
-// } catch (Exception e) {
|
|
|
-// e.printStackTrace();
|
|
|
-// }
|
|
|
-// deviceConnectionMsg.incrementMessageCount();
|
|
|
-//
|
|
|
-// }
|
|
|
-//}
|