From 38f29e38fcc668171dc05c53d40a36b895c86102 Mon Sep 17 00:00:00 2001
From: liusuyi <1951119284@qq.com>
Date: 星期四, 10 十月 2024 13:34:28 +0800
Subject: [PATCH] init
---
ard-work/src/main/java/com/ruoyi/sy/controller/ArdSyCarController.java | 738 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 668 insertions(+), 70 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/sy/controller/ArdSyCarController.java b/ard-work/src/main/java/com/ruoyi/sy/controller/ArdSyCarController.java
index 27d8afc..0b9dd22 100644
--- a/ard-work/src/main/java/com/ruoyi/sy/controller/ArdSyCarController.java
+++ b/ard-work/src/main/java/com/ruoyi/sy/controller/ArdSyCarController.java
@@ -1,27 +1,44 @@
package com.ruoyi.sy.controller;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.text.SimpleDateFormat;
+import java.util.*;
import javax.annotation.PostConstruct;
-import javax.servlet.http.HttpServletRequest;
+import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
-import com.ruoyi.client.ARDCarGPSLogInClient;
-import com.ruoyi.client.ARDCarSYGPSClient;
+import com.alibaba.fastjson2.JSON;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
+import com.ruoyi.sy.domain.ArdTankLock;
+import com.ruoyi.sy.gps31.PushClientImplSerialPort;
+import com.ruoyi.sy.param.ArdSyCarParam;
+import com.ruoyi.sy.service.*;
+import com.ruoyi.sy.service.impl.ArdTankLockServiceImpl;
+import com.ruoyi.sy.vo.ArdSyCarVo;
import com.ruoyi.sy.domain.ArdSyUser;
+import com.ruoyi.sy.gps31.PositionContainer;
+import com.ruoyi.sy.gps31.PushClientImplAlarm;
import com.ruoyi.sy.gps31.PushClientImplPosition;
-import com.ruoyi.sy.service.IArdSyUserService;
-import com.ruoyi.sy.service.SysParaService;
-import com.ruoyi.system.domain.SysConfig;
+import com.ruoyi.common.core.domain.entity.SysConfig;
import com.ruoyi.system.service.ISysConfigService;
-import com.ruoyi.utils.httpclient.SYCarClient;
+import com.ruoyi.system.service.ISysDeptService;
+import com.ruoyi.system.service.ISysUserService;
+import com.ruoyi.system.service.impl.SysConfigServiceImpl;
+import com.ruoyi.utils.forest.SYClient;
+import com.ruoyi.utils.result.Results;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
-import org.bytedeco.javacv.CanvasFrame;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.Response;
+import org.apache.commons.codec.digest.DigestUtils;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -30,16 +47,14 @@
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.sy.domain.ArdSyCar;
-import com.ruoyi.sy.service.IArdSyCarService;
import com.ruoyi.common.utils.poi.ExcelUtil;
-import com.ruoyi.common.core.page.TableDataInfo;
-import org.springframework.web.context.request.RequestContextHolder;
-import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.multipart.MultipartFile;
+
+import static com.ruoyi.utils.websocket.util.WebSocketUtils.ONLINE_USER_SESSIONS;
/**
* 涓変竴杞﹁締Controller
- *
+ *
* @author ard
* @date 2023-06-26
*/
@@ -56,25 +71,50 @@
private Map<Integer,Map<String,String>> logInMap = new HashMap();
- @Autowired
- private SysParaService sysParaService;
@Autowired
private IArdSyUserService iArdSyUserService;
+ @Autowired
+ private ISysUserService sysUserService;
+
+ @Autowired
+ private ISysDeptService sysDeptService;
+
+ @Autowired
+ private IArdTankAbnormalParkAlarmService ardTankAbnormalParkAlarmService;
+
+ @Autowired
+ private IArdTankLockService ardTankLockService;
+
+ @Autowired
+ private IArdTankWallTemporaryService ardTankWallTemporaryService;
+
+ @Resource
+ private SYClient sYClient;
+
private ArdSyCarController ardSyCarController;
+
+ @Value("${syCar.enabled}")
+ private Boolean syCarEnabled;
+
+ @Value("${syCar.userId}")
+ private String userId;
+
+ @Value("${syCar.password}")
+ private String password;
@PostConstruct
public void init(){
ardSyCarController = this;
ardSyCarController.sysConfigService = this.sysConfigService;
ardSyCarController.iArdSyUserService = this.iArdSyUserService;
-
SysConfig config = new SysConfig();
config.setConfigKey("syCarPT");
List<SysConfig> sysConfigResult = sysConfigService.selectConfigList(config);
String syURL = "";
- if(sysConfigResult.size() == 0){
+ //if(sysConfigResult.size() == 0){
+ if(!syCarEnabled){//涓変竴杞﹁締鍔犲叆寮�鍏�
return;
}else{
syURL = sysConfigResult.get(0).getConfigValue();
@@ -82,9 +122,388 @@
String ip = syURL.split(":")[1].replace("//", "");
List<ArdSyUser> ardSyUserList = iArdSyUserService.selectSyUser();
//杞﹁締瀹炴椂浣嶇疆绾跨▼
- PushClientImplPosition pushClientImplPosition = new PushClientImplPosition(ip,ardSyUserList.get(0).getUserId(),ardSyUserList.get(0).getPassword());
+ if(ardSyUserList.size()==0)
+ {
+ return;
+ }
+ //PushClientImplPosition pushClientImplPosition = new PushClientImplPosition(ip,ardSyUserList.get(0).getUserId(),ardSyUserList.get(0).getPassword());
+ PushClientImplPosition pushClientImplPosition = new PushClientImplPosition(ip,userId,password);
Thread pushClientImplPositionThread = new Thread(pushClientImplPosition);
pushClientImplPositionThread.start();
+
+ Date date = new Date();
+ Timer carPositionTimer = new Timer();//瀹氭椂鎺ㄩ�佸疄鏃朵綅缃�
+ TimerTask carPositionTask =new TimerTask(){
+ @Override
+ public void run(){
+ ardSyCarService.sendArdSyCarPosition();
+ }
+ };
+ //carPositionTimer.scheduleAtFixedRate(carPositionTask,date,3*1000);//寮冪敤
+ //杞﹁締瀹炴椂鎶ヨ绾跨▼
+ //PushClientImplAlarm pushClientImplAlarm = new PushClientImplAlarm(ip,ardSyUserList.get(0).getUserId(),ardSyUserList.get(0).getPassword());
+ PushClientImplAlarm pushClientImplAlarm = new PushClientImplAlarm(ip,userId,password);
+ Thread pushClientImplAlarmThread = new Thread(pushClientImplAlarm);
+ pushClientImplAlarmThread.start();
+ //涓插彛绾跨▼
+ PushClientImplSerialPort pushClientImplSerialPort = new PushClientImplSerialPort(ip,userId,password);
+ Thread pushClientImplSerialPortThread = new Thread(pushClientImplSerialPort);
+ pushClientImplSerialPortThread.start();
+
+ //鍒犻櫎缁撴潫鏃堕棿涓簄ull鐨勮褰�
+ int result = ardTankAbnormalParkAlarmService.deleteArdTankAbnormalParkAlarmByEndTime();
+
+ List<ArdSyCar> ardSyCarAndLockList = ardSyCarService.selectArdSyCarAndTankLock();//鏌ヨ鍏ㄩ儴缃愯溅鍙婁笅鎸傜數纾侀攣
+
+ for(ArdSyCar ardSyCar : ardSyCarAndLockList){//鏋勯�犲鍣�
+ Map<String,Map<String,Thread>> carMap = new HashMap();//杞﹁締瀹瑰櫒
+ for(ArdTankLock ardTankLock : ardSyCar.getArdTankLockList()){
+ Map<String,Thread> lockMap = new HashMap();//閿佸鍣�
+ carMap.put(ardTankLock.getLockNum(),lockMap);
+ }
+ PositionContainer.getCarLockProcessThreadMap().put(ardSyCar.getCarId(),carMap);
+ }
+
+ Timer lockStateTimer = new Timer();//瀹氭椂鑾峰彇鍚勪釜閿佺殑鐘舵��
+ TimerTask lockStateTask =new TimerTask(){
+ @Override
+ public void run(){
+ Thread thread = new Thread(){
+ @Override
+ public void run() {
+ SysConfig config = new SysConfig();
+ config.setConfigKey("syCarPT");
+ List<SysConfig> sysConfigResult = sysConfigService.selectConfigList(config);
+ String syURL = "";
+
+ if(sysConfigResult.size() == 0){
+ return;
+ }else{
+ syURL = sysConfigResult.get(0).getConfigValue();
+ }
+ String passwordMd5 = DigestUtils.md5Hex(password);
+ Map<String, Object> LogInResult = sYClient.logIn(syURL, passwordMd5, userId);
+ String sessionId = (String) LogInResult.get("sessionId");
+
+ String finalSyURL = syURL;
+
+ List<ArdTankLock> result = ardTankLockService.getArdTankLockAll();//鏌ヨ鍏ㄩ儴鐢电閿�
+ for(ArdTankLock ardTankLock : result){
+ Thread lockThread = new Thread(finalSyURL){
+ @Override
+ public void run() {
+ String lockNumHead = ardTankLock.getLockNum().substring(0,2);
+ String lockNumTail = ardTankLock.getLockNum().substring(2,4);
+ //璁$畻鏍¢獙
+ String checkNum = Integer.toHexString(Integer.parseInt(lockNumHead, 16) + Integer.parseInt(lockNumTail, 16) + Integer.parseInt("01", 16));
+
+ if(checkNum.length() == 1){
+ checkNum = "0" + checkNum;
+ }else if(checkNum.length() > 2){
+ checkNum = checkNum.substring(checkNum.length() - 2,checkNum.length());
+ }
+
+ String paramsStr = "%7B%22type%22%3A%22ff%22%2C%22dataCnt%22%3A%22" + ardTankLock.getLockNum() + "01" + checkNum + "%22%7D";
+ try{
+ sendCmd(finalSyURL,userId,ardTankLock.getCarId(),199,"DataDownTransfer", paramsStr,sessionId);
+ PositionContainer.getCarLockProcessThreadMap().get(ardTankLock.getCarId()).get(ardTankLock.getLockNum()).remove("lockState");
+ }catch(Exception e){
+ PositionContainer.getCarLockProcessThreadMap().get(ardTankLock.getCarId()).get(ardTankLock.getLockNum()).remove("lockState");
+ }
+ }
+ };
+ //lockThread.start();
+ //灏嗙姸鎬佺嚎绋嬫斁鍏ュ鍣�
+ if(PositionContainer.getCarLockProcessThreadMap().get(ardTankLock.getCarId()).get(ardTankLock.getLockNum()).get("lockState") == null){
+ PositionContainer.getCarLockProcessThreadMap().get(ardTankLock.getCarId()).get(ardTankLock.getLockNum()).put("lockState",lockThread);
+ }
+
+ }
+ }
+ };
+ thread.start();
+ }
+ };
+ //lockStateTimer.scheduleAtFixedRate(lockStateTask,date,3000);
+ lockStateTimer.scheduleAtFixedRate(lockStateTask,date,5000);
+
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ Timer lockCheckTimeTimer = new Timer();//瀹氭椂鏍″噯鏃堕棿
+ TimerTask lockCheckTimeTask = new TimerTask(){
+ @Override
+ public void run() {
+ SysConfig config = new SysConfig();
+ config.setConfigKey("syCarPT");
+ List<SysConfig> sysConfigResult = sysConfigService.selectConfigList(config);
+ String syURL = "";
+
+ if(sysConfigResult.size() == 0){
+ return;
+ }else{
+ syURL = sysConfigResult.get(0).getConfigValue();
+ }
+ String passwordMd5 = DigestUtils.md5Hex(password);
+ Map<String, Object> LogInResult = sYClient.logIn(syURL, passwordMd5, userId);
+ String sessionId = (String) LogInResult.get("sessionId");
+
+ String finalSyURL = syURL;
+
+ List<ArdTankLock> result = ardTankLockService.getArdTankLockAll();//鏌ヨ鍏ㄩ儴鐢电閿�
+ for(ArdTankLock ardTankLock : result){
+ Thread lockThread = new Thread(finalSyURL){
+ @Override
+ public void run() {
+ //鑾峰彇鏃堕棿骞舵媶鍒嗗勾鏈堟棩鏃跺垎绉�
+ String nowTime = sdf.format(new Date());
+ String nowYear = nowTime.substring(2,4);
+ String nowMonth = nowTime.substring(5,7);
+ String nowDay = nowTime.substring(8,10);
+ String nowHour = nowTime.substring(11,13);
+ String nowMinute = nowTime.substring(14,16);
+ String nowSecond = nowTime.substring(17,19);
+
+ String nowYearHex = Integer.toHexString(Integer.parseInt(nowYear));
+ if(nowYearHex.length() == 1){
+ nowYearHex = "0" + nowYearHex;
+ }
+ String nowMonthHex = Integer.toHexString(Integer.parseInt(nowMonth));
+ if(nowMonthHex.length() == 1){
+ nowMonthHex = "0" + nowMonthHex;
+ }
+ String nowDayHex = Integer.toHexString(Integer.parseInt(nowDay));
+ if(nowDayHex.length() == 1){
+ nowDayHex = "0" + nowDayHex;
+ }
+ String nowHourHex = Integer.toHexString(Integer.parseInt(nowHour));
+ if(nowHourHex.length() == 1){
+ nowHourHex = "0" + nowHourHex;
+ }
+ String nowMinuteHex = Integer.toHexString(Integer.parseInt(nowMinute));
+ if(nowMinuteHex.length() == 1){
+ nowMinuteHex = "0" + nowMinuteHex;
+ }
+ String nowSecondHex = Integer.toHexString(Integer.parseInt(nowSecond));
+ if(nowSecondHex.length() == 1){
+ nowSecondHex = "0" + nowSecondHex;
+ }
+ //16杩涘埗鏃堕棿
+ String timeHex = nowYearHex + nowMonthHex + nowDayHex + nowHourHex + nowMinuteHex + nowSecondHex;
+ String lockNumHead = ardTankLock.getLockNum().substring(0,2);
+ String lockNumTail = ardTankLock.getLockNum().substring(2,4);
+ //璁$畻鏍¢獙
+ String checkNum = Integer.toHexString(Integer.parseInt(lockNumHead, 16) + Integer.parseInt(lockNumTail, 16) + Integer.parseInt("08", 16) +
+ Integer.parseInt(nowYearHex, 16) + Integer.parseInt(nowMonthHex, 16) + Integer.parseInt(nowDayHex, 16) +
+ Integer.parseInt(nowHourHex, 16) + Integer.parseInt(nowMinuteHex, 16) + Integer.parseInt(nowSecondHex, 16));
+ if(checkNum.length() == 1){
+ checkNum = "0" + checkNum;
+ }else if(checkNum.length() > 2){
+ checkNum = checkNum.substring(checkNum.length() - 2,checkNum.length());
+ }
+ String paramsStr = "%7B%22type%22%3A%22ff%22%2C%22dataCnt%22%3A%22" + ardTankLock.getLockNum() + "08" + timeHex + checkNum + "%22%7D";
+ try{
+ sendCmd(finalSyURL,userId,ardTankLock.getCarId(),199,"DataDownTransfer", paramsStr,sessionId);
+ PositionContainer.getCarLockProcessThreadMap().get(ardTankLock.getCarId()).get(ardTankLock.getLockNum()).remove("lockTime");
+ }catch(Exception e){
+ PositionContainer.getCarLockProcessThreadMap().get(ardTankLock.getCarId()).get(ardTankLock.getLockNum()).remove("lockTime");
+ }
+ }
+ };
+ //lockThread.start();
+ if(PositionContainer.getCarLockProcessThreadMap().get(ardTankLock.getCarId()).get(ardTankLock.getLockNum()).get("lockTime") == null){
+ PositionContainer.getCarLockProcessThreadMap().get(ardTankLock.getCarId()).get(ardTankLock.getLockNum()).put("lockTime",lockThread);
+ }
+ }
+ }
+ };
+ //lockCheckTimeTimer.scheduleAtFixedRate(lockCheckTimeTask,date,7000);
+ lockCheckTimeTimer.scheduleAtFixedRate(lockCheckTimeTask,date,67000);
+
+ Timer sendTimer = new Timer();//瀹氭椂鍙戦�侀攣鐘舵��
+ TimerTask sendLockStateTask = new TimerTask(){
+ @Override
+ public void run() {
+ for (String key : ONLINE_USER_SESSIONS.keySet()){
+ Thread lockThread = new Thread() {
+ @Override
+ public void run() {
+ ardTankLockService.sendLockState(key,userId,password);
+ }
+ };
+ lockThread.start();
+ }
+ }
+ };
+ sendTimer.scheduleAtFixedRate(sendLockStateTask,date,3000);
+
+ Timer passwordTimer = new Timer();//瀹氭椂鏌ョ湅鐢电閿佸瘑鐮佺姸鎬�
+ TimerTask passwordTask = new TimerTask(){
+ @Override
+ public void run() {
+ ardTankLockService.readPassword(userId,password);
+ }
+ };
+ //passwordTimer.scheduleAtFixedRate(passwordTask,date,11000);
+ passwordTimer.scheduleAtFixedRate(passwordTask,date,13000);
+
+ Timer lockRestartStateTimer = new Timer();//瀹氭椂鍚勪釜閿佺殑澶嶄綅鐘舵��
+ TimerTask lockRestartStateTask = new TimerTask(){
+ @Override
+ public void run(){
+ Thread thread = new Thread(){
+ @Override
+ public void run() {
+ SysConfig config = new SysConfig();
+ config.setConfigKey("syCarPT");
+ List<SysConfig> sysConfigResult = sysConfigService.selectConfigList(config);
+ String syURL = "";
+
+ if(sysConfigResult.size() == 0){
+ return;
+ }else{
+ syURL = sysConfigResult.get(0).getConfigValue();
+ }
+ String passwordMd5 = DigestUtils.md5Hex(password);
+ Map<String, Object> LogInResult = sYClient.logIn(syURL, passwordMd5, userId);
+ String sessionId = (String) LogInResult.get("sessionId");
+
+ String finalSyURL = syURL;
+
+ List<ArdTankLock> result = ardTankLockService.getArdTankLockAllWithState();//鏌ヨ鍏ㄩ儴鐢电閿佸強鏈�缁堢姸鎬�
+ for(ArdTankLock ardTankLock : result){
+ String restartState = ardTankLock.getRestartState();
+ String sRestartState = "";
+ if(ardTankLock.getArdTankLockState() != null){
+ sRestartState = ardTankLock.getArdTankLockState().getRestartState();
+ }
+
+ if(sRestartState.equals("")){
+ continue;
+ }else{
+ sRestartState = sRestartState.substring(0,2);
+ if(!restartState.equals(sRestartState)){
+ Thread lockThread = new Thread(finalSyURL){
+ @Override
+ public void run() {
+ String process = "";
+ if(restartState.equals("寮�閿�")){
+ process = "01";
+ }else if(restartState.equals("鍏抽攣")){
+ process = "02";
+ }else{
+ return;
+ }
+
+ String lockNumHead = ardTankLock.getLockNum().substring(0,2);
+ String lockNumTail = ardTankLock.getLockNum().substring(2,4);
+ //璁$畻鏍¢獙
+ String checkNum = Integer.toHexString(Integer.parseInt(lockNumHead, 16) + Integer.parseInt(lockNumTail, 16) + Integer.parseInt("03", 16) + Integer.parseInt(process, 16));
+
+ if(checkNum.length() == 1){
+ checkNum = "0" + checkNum;
+ }else if(checkNum.length() > 2){
+ checkNum = checkNum.substring(checkNum.length() - 2,checkNum.length());
+ }
+
+ String paramsStr = "%7B%22type%22%3A%22ff%22%2C%22dataCnt%22%3A%22" + ardTankLock.getLockNum() + "03" + process + checkNum + "%22%7D";
+ try{
+ sendCmd(finalSyURL,userId,ardTankLock.getCarId(),199,"DataDownTransfer", paramsStr,sessionId);
+ PositionContainer.getCarLockProcessThreadMap().get(ardTankLock.getCarId()).get(ardTankLock.getLockNum()).remove("lockRestart");
+ }catch (Exception e){
+ PositionContainer.getCarLockProcessThreadMap().get(ardTankLock.getCarId()).get(ardTankLock.getLockNum()).remove("lockRestart");
+ }
+ }
+ };
+ //lockThread.start();
+ if(PositionContainer.getCarLockProcessThreadMap().get(ardTankLock.getCarId()).get(ardTankLock.getLockNum()).get("lockRestart") == null){
+ PositionContainer.getCarLockProcessThreadMap().get(ardTankLock.getCarId()).get(ardTankLock.getLockNum()).put("lockRestart",lockThread);
+ }
+ }
+ }
+ }
+ }
+ };
+ thread.start();
+ }
+ };
+ lockRestartStateTimer.scheduleAtFixedRate(lockRestartStateTask,date,17000);
+
+ Set<String> lockNumSet = new HashSet();//瀛樻斁鍙戦�佽繃鐨勯攣缂栧彿
+
+ Timer mainLockTimer = new Timer();//涓诲畾鏃跺櫒
+ TimerTask mainLockTask = new TimerTask(){
+ @Override
+ public void run() {
+ Long count = ardTankLockService.getArdTankLockCount();
+ if(lockNumSet.size() >= count){//闃叉閿佽鍒犻櫎锛岄噰鐢ㄥぇ浜庣瓑浜�
+ lockNumSet.clear();//鍏ㄩ儴鎵ц杩囷紝娓呯┖瀹瑰櫒
+ }
+ for(String carId : PositionContainer.getCarLockProcessThreadMap().keySet()){
+ Thread thread = new Thread(){
+ @Override
+ public void run() {
+ Map<String, Map<String,Thread>> lockMap = PositionContainer.getCarLockProcessThreadMap().get(carId);
+ for(String lockNum : lockMap.keySet()){
+ if(lockNumSet.contains(lockNum)){//鑻ユ墽琛岃繃锛屾湰娆″拷鐣�
+ continue;
+ }
+ if(lockMap.get(lockNum).get("lockProcess") != null){
+ break;//閿佹搷浣滅骇鍒渶楂�
+ }else{
+ if(lockMap.get(lockNum).get("lockTime") != null){
+ if(lockMap.get(lockNum).get("lockTime").isAlive()){
+ lockNumSet.add(lockNum);
+ break;//閿佹牎鏃舵涔�
+ }else{
+ lockMap.get(lockNum).get("lockTime").start();
+ lockNumSet.add(lockNum);
+ break;//閿佹牎鏃舵涔�
+ }
+ }else{
+ if(lockMap.get(lockNum).get("lockPassword") != null){
+ if(lockMap.get(lockNum).get("lockPassword").isAlive()){
+ lockNumSet.add(lockNum);
+ break;//閿佸瘑鐮佹涔�
+ }else{
+ lockMap.get(lockNum).get("lockPassword").start();
+ lockNumSet.add(lockNum);
+ break;//閿佸瘑鐮佹涔�
+ }
+ }else{
+ if(lockMap.get(lockNum).get("lockRestart") != null) {
+ if(lockMap.get(lockNum).get("lockRestart").isAlive()){
+ lockNumSet.add(lockNum);
+ }else{
+ lockMap.get(lockNum).get("lockRestart").start();
+ lockNumSet.add(lockNum);
+ break;//閿佸浣嶆涔�
+ }
+ }else{
+ if(lockMap.get(lockNum).get("lockState") != null) {
+ if(lockMap.get(lockNum).get("lockState").isAlive()){
+ lockNumSet.add(lockNum);
+ }else{
+ lockMap.get(lockNum).get("lockState").start();
+ lockNumSet.add(lockNum);
+ break;//閿佺姸鎬佹涔�
+ }
+ }else{
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ };
+ thread.start();
+ }
+ }
+ };
+ mainLockTimer.scheduleAtFixedRate(mainLockTask,date,2000);
+
+ //寮傚父閲嶅惎閲嶅缓鏈埌鏈熶复鏃剁數瀛愬洿鏍忕嚎绋�
+ ardTankWallTemporaryService.restartArdTankWallTemporaryThread(userId, password);
}
/**
@@ -92,11 +511,13 @@
*/
@PreAuthorize("@ss.hasPermi('sy:syCar:list')")
@GetMapping("/list")
- public TableDataInfo list(ArdSyCar ardSyCar)
+ @ApiOperation("鏌ヨ涓変竴杞﹁締鍒楄〃")
+ public AjaxResult list(ArdSyCarParam ardSyCarParam)
{
- startPage();
- List<ArdSyCar> list = ardSyCarService.selectArdSyCarList(ardSyCar);
- return getDataTable(list);
+ PageHelper.startPage(ardSyCarParam.getPageNum(),ardSyCarParam.getPageSize());
+ String userId = SecurityUtils.getUserId();
+ Map<String,Object> result = ardSyCarService.getArdSyCarAll(userId);
+ return ardSyCarService.ardSyCarList(ardSyCarParam,result);
}
/**
@@ -153,7 +574,7 @@
*/
@PreAuthorize("@ss.hasPermi('sy:syCar:remove')")
@Log(title = "涓変竴杞﹁締", businessType = BusinessType.DELETE)
- @DeleteMapping("/{ids}")
+ @DeleteMapping("/{ids}")
@ApiOperation("鍒犻櫎涓変竴杞﹁締")
public AjaxResult remove(@PathVariable String[] ids)
{
@@ -178,7 +599,9 @@
return error("涓変竴杞﹁締url娌℃湁褰曞叆");
}else{
syURL = sysConfigResult.get(0).getConfigValue();
- Map<String,Object> result = SYCarClient.logIn(syURL,userId, password);
+ //Map<String,Object> result = SYCarClient.logIn(syURL,userId, password);
+ String passwordMd5 = DigestUtils.md5Hex(password);
+ Map<String,Object> result = sYClient.logIn(syURL,passwordMd5,userId);
return success(result);
}
}
@@ -255,56 +678,231 @@
public Map<String,Object> allListByUser(){
String usersId = SecurityUtils.getUserId();
ArdSyUser ardSyUser = iArdSyUserService.userById(usersId);
- Map<String,Object> result0 = new HashMap();
+ String syURL = sysConfigService.getSYURL();
+ //鏍规嵁userId鏌ヨ閮ㄩ棬Id
+ SysUser sysUser = sysUserService.selectUserById(usersId);
+ //鏍规嵁褰撳墠deptId鎴栬�呭綋鍓嶅強鎵�灞炰笅绾х殑鎵�鏈塪eptId
+ List<Long> deptList = sysDeptService.deptIdBySub(sysUser.getDeptId());
+ return ardSyCarService.allListByUser(ardSyUser,syURL,usersId,deptList);
+ }
+
+ @PreAuthorize("@ss.hasPermi('sy:syCar:carList')")
+ @PostMapping("carList")
+ @ApiOperation("鏍规嵁teamId鑾峰彇杞﹁締鍒楄〃")
+ public Results getCarList(@RequestBody Map<String,String> map){
+ String usersId = SecurityUtils.getUserId();
+ ArdSyUser ardSyUser = iArdSyUserService.userById(usersId);
+ String syURL = sysConfigService.getSYURL();
+ String teamId = map.get("teamId");
//鍒ゆ柇鍏宠仈琛ㄦ槸鍚︽湁鏁版嵁
- if(ardSyUser!=null){
- //31鐢ㄦ埛鍚嶅瘑鐮�
- String username31 = ardSyUser.getUserId();
- String password31 = ardSyUser.getPassword();
- //鏌ヨ鍦板潃
- Map<String, String> result = logInMap.get(Integer.parseInt(usersId));
- String syURL = sysParaService.getSYURL();
- Map<String, Object> result1 = ARDCarGPSLogInClient.loginIn(syURL,username31, password31);
- result = new HashMap();
- result.put("userId", username31);
- result.put("sessionId", (String) result1.get("sessionId"));
- try {
- result0 = ARDCarSYGPSClient.getCarGPSTeamList(syURL,result.get("userId"),result.get("sessionId"));//
- } catch (Exception e) {
- Map<String,Object> map = new HashMap();
- map.put("rspCode", 0);
- map.put("list", new ArrayList());
- return map;
+ if(ardSyUser!=null) {
+ //鏌ヨ鍑�31鐨勮溅杈嗘暟鎹�
+ List<Map<String,String>> list = ardSyCarService.getCarList(ardSyUser,syURL,usersId,teamId);
+ if(list.isEmpty()){
+ return Results.succeed(new ArrayList());
}
- int online = 0;
- for(Map<String,Object> map : (List<Map<String,Object>>) result0.get("list")){
- Map<String,Object> resultMap = (Map<String, Object>) ARDCarSYGPSClient.getCarListByTeamId(syURL,(String)map.get("teamId"),result.get("sessionId"));
- List<Map<String,Object>> carList = (List<Map<String, Object>>) resultMap.get("carList");
- for(Map<String,Object> m : carList){
- if(((String) m.get("stateCn")).contains("鍦ㄧ嚎")){
- online = online + 1;
- }else{
- continue;
- }
- }
- for(Map<String,Object> m : (List<Map<String,Object>>) result0.get("list")){
- if(((String) m.get("teamId")).equals(((String) map.get("teamId")))){
- map.put("count", Integer.parseInt((String) m.get("carNum")));
- }
- }
- map.put("online", online);
- online = 0;
- }
+ //鏍规嵁userId鏌ヨ閮ㄩ棬Id
+ SysUser sysUser = sysUserService.selectUserById(usersId);
+ //鏍规嵁褰撳墠deptId鎴栬�呭綋鍓嶅強鎵�灞炰笅绾х殑鎵�鏈塪eptId
+ List<Long> deptList = sysDeptService.deptIdBySub(sysUser.getDeptId());
+ //鏍规嵁dept闆嗗悎鏌ヨ鍑烘墍鏈夊搴旂殑杞﹁締鍒楄〃骞惰祴鍊�
+ return Results.succeed(ardSyCarService.carIdByDeptList(deptList,list));
}else {
- result0.put("鍒楄〃涓虹┖锛�","鏃犲叧鑱旇处鍙凤紒");
+ return Results.error("鍒楄〃涓虹┖锛佹棤鍏宠仈璐﹀彿锛�");
}
- return result0;
}
@PreAuthorize("@ss.hasPermi('sy:syCar:carListById')")
- @GetMapping("carListById")
+ @PostMapping("/carListById/{id}")
@ApiOperation("鏍规嵁杞﹁締ID鑾峰彇杞﹁締鍒楄〃")
- public List<ArdSyCar> carListById(String id){
+ public Results carListById(@PathVariable String id){
return ardSyCarService.carListById(id);
}
+
+ @PreAuthorize("@ss.hasPermi('sy:syCar:getCarGPSHistory')")
+ @PostMapping("getCarGPSHistory")
+ @ApiOperation("鏍规嵁杞﹁締ID鑾峰彇鍘嗗彶杞ㄨ抗")
+ public Results getCarGPSTrack(@RequestBody Map<String,String> map) {
+ String usersId = SecurityUtils.getUserId();
+ ArdSyUser ardSyUser = iArdSyUserService.userById(usersId);
+ String syURL = sysConfigService.getSYURL();
+ return ardSyCarService.getCarGPSTrack(map,syURL, ardSyUser);
+ }
+
+ @PreAuthorize("@ss.hasPermi('sy:syCar:getArdSyUserByUsersId')")
+ @PostMapping("getArdSyUserByUsersId")
+ @ApiOperation("鑾峰彇涓変竴骞冲彴瀵瑰簲鐢ㄦ埛鍚嶅瘑鐮�")
+ public Results getArdSyUserByUsersId() {
+ String usersId = SecurityUtils.getUserId();
+ ArdSyUser ardSyUser = iArdSyUserService.userById(usersId);
+ Map<String,Object> map = new HashMap<>();
+ if(ardSyUser==null){
+ return Results.succeed();
+ }else {
+ map.put("userId",ardSyUser.getUserId());
+ map.put("password",ardSyUser.getPassword());
+ map.put("passwords",DigestUtils.md5Hex(ardSyUser.getPassword()));
+ }
+ return Results.succeed(map);
+ }
+
+ @PreAuthorize("@ss.hasPermi('sy:syCar:getSDKCarPositionByRight')")
+ @PostMapping("getSDKCarPositionByRight")
+ @ApiOperation("鑾峰彇閮ㄩ棬鏉冮檺涓嬫墍鏈夎溅杈嗕綅缃�")
+ public Results getSDKCarPositionByRight(){
+ String usersId = SecurityUtils.getUserId();
+ //鏍规嵁userId鏌ヨ閮ㄩ棬Id
+ SysUser sysUser = sysUserService.selectUserById(usersId);
+ Map<String, Map<String,Map<String,Object>>> deptPositionMap = PositionContainer.getDeptPositionMap();
+ if(deptPositionMap.isEmpty()){
+ return Results.error("31骞冲彴鏃犺溅杈嗕綅缃繑鍥�");
+ }else {
+// return Results.succeed(deptPositionMap.get(sysUser.getDeptId().toString()).get(map.get("carId")));
+ return Results.succeed(deptPositionMap.get(sysUser.getDeptId().toString()));
+ }
+ }
+
+ @PreAuthorize("@ss.hasPermi('sy:syCar:getCarNearPositionByCarId')")
+ @PostMapping("getCarNearPositionByCarId")
+ @ApiOperation("鑾峰彇鍗曚釜杞﹁締浣嶇疆")
+ public Results getCarNearPositionByCarId(@RequestBody Map<String,String> map){
+ String usersId = SecurityUtils.getUserId();
+ ArdSyUser ardSyUser = iArdSyUserService.userById(usersId);
+ String carId = map.get("carId");
+ String syURL = sysConfigService.getSYURL();
+ return Results.succeed(ardSyCarService.getCarGPSBycarId(usersId,carId,syURL,ardSyUser));
+ }
+
+ @PreAuthorize("@ss.hasPermi('sy:syCar:chaseCarByCarId')")
+ @PostMapping("chaseCarByCarId")
+ @ApiOperation("鏍规嵁杞﹁締涓婚敭杩借釜杞﹁締")
+ public Results chaseCarByCarId(@RequestBody Map<String,String> map){
+ String usersId = SecurityUtils.getUserId();
+ String carId = map.get("carId");
+ String cycle = map.get("cycle");
+ return ardSyCarService.chaseCarByCarId(usersId,carId,cycle);
+ }
+
+ @PreAuthorize("@ss.hasPermi('sy:syCar:getExistTraceByCarIdAndMonth')")
+ @PostMapping("getExistTraceByCarIdAndMonth")
+ @ApiOperation("鏍规嵁杞﹁締涓婚敭鍙婃湀浠芥煡璇㈣建杩瑰瓨鍦�")
+ public Results getExistTraceByCarIdAndMonth(@RequestBody Map<String,String> map){
+ String userId = SecurityUtils.getUserId();
+ String carId = map.get("carId");
+ String time = map.get("time");
+ return ardSyCarService.getExistTraceByCarIdAndMonth(userId,carId,time);
+ }
+
+ @GetMapping("getCarPicture")
+ @ApiOperation("娓呮筏鑾峰彇鐓х墖")
+ public AjaxResult getCarNearPositionByCarId(String carId) throws UnsupportedEncodingException {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
+ Date currentTime = new Date();
+ long tenSeconds = 1000L;
+ Date beforeTenSeconds = new Date(currentTime.getTime() - tenSeconds);
+ String startTime = sdf.format(beforeTenSeconds);
+ String usersId = SecurityUtils.getUserId();
+ ArdSyUser ardSyUser = iArdSyUserService.userById(usersId);
+ String syURL = sysConfigService.getSYURL();
+ String sessionId = ardSyCarService.getSessionId(syURL,ardSyUser);
+ System.out.println("sessionId:"+sessionId);
+ //鑾峰彇鎽勫儚閫氶亾淇℃伅
+ Map<String, Object> result = ardSyCarService.getCarPicture(carId,syURL,sessionId);
+ String vs = "";
+ try {
+ //鎻愬彇閫氶亾淇℃伅
+ Map<String,Object> map = ((List<Map<String,Object>>)result.get("list")).get(0);
+ Map<String, Object> videos = (Map<String, Object>) JSON.parse((String) map.get("videos"));
+ System.out.println("閫氶亾锛�"+videos);
+ vs = (String) videos.get("vs");
+ } catch (Exception e) {
+ return AjaxResult.error("璇ヨ溅杈嗘病鏈夋憚鍍忛�氶亾鏃犵収鐗囨暟鎹紒");
+ }
+ //绛涢�夐�氶亾淇℃伅
+ String[] vsArray = vs.split(",");
+ List<String> channelList = new ArrayList<>();
+ for (int i = 0; i < vsArray.length; i++) {
+ channelList.add(vsArray[i].substring(0,1));
+ }
+ //鎷嶇収
+ Map<String,Object> sendCmdMap = ardSyCarService.sendCmd(ardSyUser.getUserId(),syURL,sessionId,carId,channelList);
+ System.out.println("鎷嶇収锛�"+sendCmdMap);
+ //鑾峰彇鐓х墖
+ Map<String,Object> photoMap = ardSyCarService.getPhoto(syURL,carId,sessionId,startTime);
+ System.out.println("鑾峰彇鐓х墖锛�"+photoMap);
+ return AjaxResult.success(photoMap);
+ }
+
+ @GetMapping("getVideo")
+ @ApiOperation("娓呮筏鑾峰彇瑙嗛")
+ public AjaxResult getVideo(String carId){
+ String usersId = SecurityUtils.getUserId();
+ ArdSyUser ardSyUser = iArdSyUserService.userById(usersId);
+ String syURL = sysConfigService.getSYURL();
+ Map<String,Object> video = ardSyCarService.getVideo(syURL,carId,ardSyUser);
+ return AjaxResult.success(video);
+ }
+
+ @GetMapping("getThreeOne")
+ @ApiOperation("鑾峰彇涓変竴瑙嗛鍦板潃")
+ public AjaxResult getThreeOne() {
+ return AjaxResult.success("鑾峰彇鍦板潃鎴愬姛锛�",sysConfigService.getSYVideo());
+ }
+
+ @PreAuthorize("@ss.hasPermi('sy:syCar:getAlarmHPfmCountDetail')")
+ @PostMapping("getAlarmHPfmCountDetail")
+ @ApiOperation("鏍规嵁杞﹁締鍜屾椂闂存鏌ヨ鎶ヨ鍘嗗彶璁板綍璇︽儏")
+ public AjaxResult getAlarmHPfmCountDetail(@RequestBody Map<String,String> map){
+ String usersId = SecurityUtils.getUserId();
+ ArdSyUser ardSyUser = iArdSyUserService.userById(usersId);
+ String carId = map.get("carId");
+ String startTime = map.get("startTime");
+ String endTime = map.get("endTime");
+ String syURL = sysConfigService.getSYURL();
+ String sessionId = ardSyCarService.getSessionId(syURL,ardSyUser);
+ Map<String, Object> mapDetail = ardSyCarService.getAlarmHPfmCountDetail(sessionId,usersId,carId,startTime,endTime,syURL);
+ return AjaxResult.success(mapDetail);
+ }
+
+ @GetMapping("/getOnlineSYCarPosition")
+ @ApiOperation("鍗曞叺绔煡鐪嬪凡閫氳繃瀹℃壒鐨勫湪绾夸笁涓�杞﹁締浣嶇疆")
+ public AjaxResult getOnlineSYCarPosition() {
+ String soilderId = SecurityUtils.getUserId();
+ try{
+ Map<String,Object> result = ardSyCarService.getOnlineSYCarPosition(soilderId);
+ return AjaxResult.success(result);
+ }catch(Exception e){
+ e.printStackTrace();
+ return AjaxResult.error();
+ }
+ }
+
+ public Map<String,Object> sendCmd(String syURL,String userId,String carId,Integer cmdId,String cmd,String paramsStr,String sessionId){
+ OkHttpClient okHttpClient = new OkHttpClient();
+
+ Request request = new Request.Builder()
+ .url(syURL + "/gps-web/api/send_cmd.jsp?params="+paramsStr+"&userId="+userId+"&carId="+carId+"&cmdId="+cmdId+"&cmd="+cmd+"&sessionId="+sessionId)
+ .build();
+ //System.out.println("url = " + syURL + "/gps-web/api/send_cmd.jsp?params="+paramsStr+"&userId="+userId+"&carId="+carId+"&cmdId="+cmdId+"&cmd="+cmd+"&sessionId="+sessionId);
+ Response response = null;
+ try {
+ response = okHttpClient.newCall(request).execute();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ okhttp3.ResponseBody responseBody = response.body();
+
+ try {
+ String message = responseBody.string();// 鍝嶅簲浣�
+ Map<String,Object> map = (Map<String, Object>) JSON.parse(message);
+ return map;
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return new HashMap();
+ }
+ }
+
}
--
Gitblit v1.9.3