|
@@ -1,348 +1,371 @@
|
|
|
-package com.tmzn.devicelinkykc.controller;
|
|
|
|
|
-
|
|
|
|
|
-import cn.hutool.http.HttpRequest;
|
|
|
|
|
-import cn.hutool.http.HttpResponse;
|
|
|
|
|
-import com.alibaba.fastjson2.JSONArray;
|
|
|
|
|
-import com.alibaba.fastjson2.JSONObject;
|
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
-import com.tmzn.devicelinkykc.constant.ykc.StatusConstant;
|
|
|
|
|
-import com.tmzn.devicelinkykc.entity.BillingModel;
|
|
|
|
|
-import com.tmzn.devicelinkykc.entity.DeviceStatus;
|
|
|
|
|
-import com.tmzn.devicelinkykc.entity.param.AjaxResult;
|
|
|
|
|
-import com.tmzn.devicelinkykc.entity.param.dto.BillingModelDTO;
|
|
|
|
|
-import com.tmzn.devicelinkykc.frameMsg.DataConversion;
|
|
|
|
|
-import com.tmzn.devicelinkykc.mapstruct.BillingModelMapping;
|
|
|
|
|
-import com.tmzn.devicelinkykc.message.DeviceMsgHandle;
|
|
|
|
|
-import com.tmzn.devicelinkykc.redis.RedisCache;
|
|
|
|
|
-import com.tmzn.devicelinkykc.service.BillingModelService;
|
|
|
|
|
-import com.tmzn.devicelinkykc.service.DeviceControlerService;
|
|
|
|
|
-import com.tmzn.devicelinkykc.service.DeviceStatusService;
|
|
|
|
|
-import com.tmzn.devicelinkykc.transdata.entity.DeviceParam;
|
|
|
|
|
-import com.tmzn.devicelinkykc.msgparser.MessageParseMgr;
|
|
|
|
|
-import com.tmzn.devicelinkykc.util.Encrytion;
|
|
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
-import org.slf4j.Logger;
|
|
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
-import org.springframework.stereotype.Controller;
|
|
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
|
|
-
|
|
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
-import java.math.BigDecimal;
|
|
|
|
|
-import java.util.Arrays;
|
|
|
|
|
-import java.util.HashMap;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
-
|
|
|
|
|
-/**
|
|
|
|
|
- * @author xp
|
|
|
|
|
- * @date 2024/4/13
|
|
|
|
|
- * @explain " "
|
|
|
|
|
- */
|
|
|
|
|
-@Controller
|
|
|
|
|
-@Slf4j(topic = "RealTimeStatusPushFrame")
|
|
|
|
|
-@RequestMapping
|
|
|
|
|
-public class TestController {
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private DeviceControlerService deviceControlerService;
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private BillingModelService billingModelService;
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private BillingModelMapping billingModelMapping;
|
|
|
|
|
- @Value("${billingInterface}")
|
|
|
|
|
- private String url;
|
|
|
|
|
-
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private RedisCache redisCache;
|
|
|
|
|
-
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private MessageParseMgr messageParseMgr;
|
|
|
|
|
-
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private DeviceMsgHandle deviceMsgHandle;
|
|
|
|
|
-
|
|
|
|
|
- @PostMapping("/msg")
|
|
|
|
|
- public String testMsg(@RequestBody String message) {
|
|
|
|
|
- try {
|
|
|
|
|
- deviceMsgHandle.testMsg(message);
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
- }
|
|
|
|
|
- return "ok";
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Autowired
|
|
|
|
|
- DeviceStatusService deviceStatusService;
|
|
|
|
|
-
|
|
|
|
|
- @PostMapping("/parser1")
|
|
|
|
|
- public String parser1(@RequestBody String message ) {
|
|
|
|
|
-
|
|
|
|
|
- try{
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- QueryWrapper<BillingModel> billWapper = new QueryWrapper<>();
|
|
|
|
|
- billWapper.eq("pile_code", "32010600530570");
|
|
|
|
|
- billWapper.eq("device_imei", "863218078065418");
|
|
|
|
|
- BillingModel b = billingModelService.getOne(billWapper);
|
|
|
|
|
- if (b == null) {
|
|
|
|
|
- log.info("{}上报充电中未匹配计费模型", "32010600530570");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- QueryWrapper<DeviceStatus> deviceStatusQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
- deviceStatusQueryWrapper.eq("device_imei", "863343064704539");
|
|
|
|
|
- deviceStatusQueryWrapper.last("limit 1");
|
|
|
|
|
- DeviceStatus statusServiceOne = deviceStatusService.getOne(deviceStatusQueryWrapper);
|
|
|
|
|
- System.out.println(statusServiceOne);
|
|
|
|
|
-
|
|
|
|
|
-// deviceMsgHandle.deviceMsg(message);
|
|
|
|
|
- }catch (Exception e){
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
- System.out.println(e.getMessage());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- System.out.println(111);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- return "ok";
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @PostMapping("/parser2")
|
|
|
|
|
- public String parser2(@RequestBody String message ) {
|
|
|
|
|
-
|
|
|
|
|
- //剩余
|
|
|
|
|
- byte[] soc = new byte[]{0x00};
|
|
|
|
|
- //电池组最高温度
|
|
|
|
|
- byte[] battery_temp = {0x32};
|
|
|
|
|
- //剩余时间
|
|
|
|
|
- byte[] remain_time = {0x00, 0x00};
|
|
|
|
|
- //枪线温度
|
|
|
|
|
- byte[] guns_line_temp = new byte[1];
|
|
|
|
|
- //9.枪线温度
|
|
|
|
|
- guns_line_temp[0] = 0x32;
|
|
|
|
|
-
|
|
|
|
|
- byte gunsStatus = 3;
|
|
|
|
|
- String imei = "868371073352243";
|
|
|
|
|
- byte guns = 1;
|
|
|
|
|
- double voltage = 136;
|
|
|
|
|
-
|
|
|
|
|
- try{
|
|
|
|
|
- //重置电压 直流电压放大10倍
|
|
|
|
|
- if(gunsStatus== StatusConstant.CHARGING){
|
|
|
|
|
- JSONArray dataArray = redisCache.getCacheMapValue("device_last_163",imei+"_"+guns);
|
|
|
|
|
- if(dataArray != null){
|
|
|
|
|
- //获取soc和剩余时间
|
|
|
|
|
- //重置soc
|
|
|
|
|
- soc[0] = (byte) (dataArray.getInteger(21+3) & 0xff);
|
|
|
|
|
-
|
|
|
|
|
- remain_time[0] = dataArray.getByte(22+3);
|
|
|
|
|
- remain_time[1] = dataArray.getByte(23+3);
|
|
|
|
|
-// int remainTIme = (dataArray.getInteger(22+3)) | (dataArray.getInteger(23+3)<<8);
|
|
|
|
|
-// remain_time[1] = (byte) ((remainTIme >> 8) & 0xFF);
|
|
|
|
|
-// remain_time[0] = (byte) (remainTIme & 0xFF);
|
|
|
|
|
-//
|
|
|
|
|
-// System.out.println(remainTIme);
|
|
|
|
|
-// System.out.println(remain_time);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- log.info("充电中-soc:{},remain:{}",soc,remain_time);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- int time = 136;
|
|
|
|
|
- byte[] charnging_Time = new byte[2];
|
|
|
|
|
- charnging_Time[1] = (byte) ((time >> 8) & 0xFF);
|
|
|
|
|
- charnging_Time[0] = (byte) (time & 0xFF);
|
|
|
|
|
- System.out.println(charnging_Time);
|
|
|
|
|
-
|
|
|
|
|
- }catch (Exception e){
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- System.out.println(111);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- return "ok";
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @GetMapping("/test163")
|
|
|
|
|
- public AjaxResult test163(HttpServletRequest request ) {
|
|
|
|
|
- String data = request.getParameter("data");
|
|
|
|
|
- List<Integer> split = Arrays.stream(data.split(","))
|
|
|
|
|
- .map(Integer::parseInt) // 将 String 转换为 Integer
|
|
|
|
|
- .collect(Collectors.toList()); // 收集结果到 List 中
|
|
|
|
|
- List<List<Integer>> packages = Encrytion.parseMorePackage(split);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- System.out.println(111);
|
|
|
|
|
-
|
|
|
|
|
-// JSONArray objects = new JSONArray(split);
|
|
|
|
|
-// JSONObject obj = new JSONObject();
|
|
|
|
|
-// obj.put("data",objects);
|
|
|
|
|
- // JSONObject object = messageParseMgr.parseMessage("75960_103", obj);
|
|
|
|
|
-
|
|
|
|
|
- // System.out.println(object);
|
|
|
|
|
-
|
|
|
|
|
- return null;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- @GetMapping("/parser")
|
|
|
|
|
- public AjaxResult parser(HttpServletRequest request ) {
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- String data = request.getParameter("data");
|
|
|
|
|
-
|
|
|
|
|
- List<Integer> split = Arrays.stream(data.split(","))
|
|
|
|
|
- .map(Integer::parseInt) // 将 String 转换为 Integer
|
|
|
|
|
- .collect(Collectors.toList()); // 收集结果到 List 中
|
|
|
|
|
-
|
|
|
|
|
- List<List<Integer>> packages = Encrytion.parseMorePackage(split);
|
|
|
|
|
-
|
|
|
|
|
- System.out.println(packages);
|
|
|
|
|
-
|
|
|
|
|
- for(int i=0;i<packages.size();i++){
|
|
|
|
|
- JSONObject obj = new JSONObject();
|
|
|
|
|
- obj.put("data",packages.get(i));
|
|
|
|
|
-
|
|
|
|
|
- System.out.println("parser:"+"75960_"+packages.get(i).get(1));
|
|
|
|
|
- JSONObject object = messageParseMgr.parseMessage("75960_"+packages.get(i).get(1),obj);
|
|
|
|
|
- System.out.println(object);
|
|
|
|
|
-
|
|
|
|
|
- if(object!=null){
|
|
|
|
|
- String m = object.toString();
|
|
|
|
|
- System.out.println(m);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- System.out.println(111);
|
|
|
|
|
-
|
|
|
|
|
-// JSONArray objects = new JSONArray(split);
|
|
|
|
|
-// JSONObject obj = new JSONObject();
|
|
|
|
|
-// obj.put("data",objects);
|
|
|
|
|
- // JSONObject object = messageParseMgr.parseMessage("75960_103", obj);
|
|
|
|
|
-
|
|
|
|
|
- // System.out.println(object);
|
|
|
|
|
-
|
|
|
|
|
- return null;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- @GetMapping("/test")
|
|
|
|
|
- public String test(@RequestParam("method") String method, @RequestParam("imei") String imei) {
|
|
|
|
|
-
|
|
|
|
|
- String deviceId = imei;
|
|
|
|
|
- String ccid = imei;
|
|
|
|
|
- if ("start".equals(method)) {
|
|
|
|
|
- deviceControlerService.startCharge(imei, imei, 1,50000);
|
|
|
|
|
- } else if ("stop".equals(method)) {
|
|
|
|
|
- deviceControlerService.stopCharge(imei, imei, 1);
|
|
|
|
|
- } else if ("port".equals(method)) {
|
|
|
|
|
-
|
|
|
|
|
- DeviceParam deviceParam = new DeviceParam();
|
|
|
|
|
- deviceParam.setDeviceId(imei);
|
|
|
|
|
- deviceParam.setCcid(imei);
|
|
|
|
|
- deviceControlerService.sendPortDetailCmd(deviceParam);
|
|
|
|
|
- } else if ("restartDevice".equals(method)) {
|
|
|
|
|
-
|
|
|
|
|
- deviceControlerService.restart(imei, imei);
|
|
|
|
|
- } else if ("rest".equals(method)) {
|
|
|
|
|
- deviceControlerService.reset(imei, imei);
|
|
|
|
|
- }
|
|
|
|
|
- return "ok";
|
|
|
|
|
- }
|
|
|
|
|
- private static final Logger logger = LoggerFactory.getLogger(DeviceMsgHandle.class);
|
|
|
|
|
-
|
|
|
|
|
- @GetMapping("/test2")
|
|
|
|
|
- public String test2(@RequestParam("pileCode") String pileCode) {
|
|
|
|
|
- //调用重启
|
|
|
|
|
-
|
|
|
|
|
- // redisCache.setCacheMapValue(RedisConstant.PILE_GUN_PAY_TIME, pileCode+"_"+1,System.currentTimeMillis());
|
|
|
|
|
-
|
|
|
|
|
-// return "ok";
|
|
|
|
|
-// //标记最后订单时间 5分钟内不上报空闲状态 避免刚下单状态还没更新就被freeTask任务给顶掉了
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- new Thread(() -> {
|
|
|
|
|
- try {
|
|
|
|
|
- Thread.sleep(5000); // 延迟 5 秒
|
|
|
|
|
- DeviceParam dataParam = new DeviceParam();
|
|
|
|
|
- dataParam.setDeviceId("123456");
|
|
|
|
|
- dataParam.setCcid("123456");
|
|
|
|
|
-// deviceControlerService.sendPortDetailCmd(dataParam);
|
|
|
|
|
- logger.info(":主动下发103消息");
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- logger.info(":主动下发103消息异常" + e.getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- }).start();
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-// try{
|
|
|
|
|
-// long ts = redisCache.getCacheMapValue(RedisConstant.PILE_GUN_PAY_TIME, pileCode+"_1");
|
|
|
|
|
-// if(ts!=0){
|
|
|
|
|
-// long ts1 = System.currentTimeMillis();
|
|
|
|
|
-// if((ts1-ts)<300*1000){
|
|
|
|
|
-// return "ok";
|
|
|
|
|
-// }
|
|
|
|
|
-// }
|
|
|
|
|
-// }catch (Exception e){
|
|
|
|
|
-// return "error";
|
|
|
|
|
-// }
|
|
|
|
|
-
|
|
|
|
|
- return "ok";
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- @GetMapping("/test1")
|
|
|
|
|
- public String test1(@RequestParam("pileCode") String pileCode) {
|
|
|
|
|
- //调用重启
|
|
|
|
|
- try{
|
|
|
|
|
- String url = "http://127.0.0.1:8063/api/device/restLogin/"+pileCode;
|
|
|
|
|
- HttpResponse execute = HttpRequest.post(url)
|
|
|
|
|
- .timeout(3000)
|
|
|
|
|
- .execute();
|
|
|
|
|
- String body = execute.body();
|
|
|
|
|
- System.out.println("reset login body:>>>"+body);
|
|
|
|
|
- } catch (Exception ex) {
|
|
|
|
|
- System.out.println("reset error :>>>"+ex.toString());
|
|
|
|
|
- }
|
|
|
|
|
- return "ok";
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @RequestMapping("/testElec")
|
|
|
|
|
- public JSONObject testCompute(@RequestParam("end")Long end,@RequestParam("start")Long star,@RequestParam("imei")String imei,@RequestParam("port")int port) {
|
|
|
|
|
- QueryWrapper<BillingModel> billingModelQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
- BillingModel one = billingModelService.getOne(billingModelQueryWrapper);
|
|
|
|
|
- BillingModelDTO billingModelDTO = billingModelMapping.billingModelToBillingModelDto(one);
|
|
|
|
|
- HashMap<String, Object> map = new HashMap<>();
|
|
|
|
|
- map.put("port",port);
|
|
|
|
|
- map.put("billingModel",billingModelDTO);
|
|
|
|
|
- map.put("startTime",star/1000);
|
|
|
|
|
- map.put("endTime",end/1000);
|
|
|
|
|
- JSONObject jsonObject = new JSONObject(map);
|
|
|
|
|
- String s = jsonObject.toString();
|
|
|
|
|
- HttpResponse execute = HttpRequest.post(url)
|
|
|
|
|
- .form("data",s)
|
|
|
|
|
- .timeout(3000)
|
|
|
|
|
- .execute();
|
|
|
|
|
- int status = execute.getStatus();
|
|
|
|
|
- String body = execute.body();
|
|
|
|
|
- System.out.println("body:>>>"+body);
|
|
|
|
|
- return null;
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
|
|
+package com.tmzn.devicelinkykc.controller;
|
|
|
|
|
+
|
|
|
|
|
+import cn.hutool.http.HttpRequest;
|
|
|
|
|
+import cn.hutool.http.HttpResponse;
|
|
|
|
|
+import com.alibaba.fastjson2.JSONArray;
|
|
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
+import com.tmzn.devicelinkykc.constant.ykc.StatusConstant;
|
|
|
|
|
+import com.tmzn.devicelinkykc.entity.BillingModel;
|
|
|
|
|
+import com.tmzn.devicelinkykc.entity.Device;
|
|
|
|
|
+import com.tmzn.devicelinkykc.entity.DeviceStatus;
|
|
|
|
|
+import com.tmzn.devicelinkykc.entity.param.AjaxResult;
|
|
|
|
|
+import com.tmzn.devicelinkykc.entity.param.dto.BillingModelDTO;
|
|
|
|
|
+import com.tmzn.devicelinkykc.frameMsg.DataConversion;
|
|
|
|
|
+import com.tmzn.devicelinkykc.frameMsg.FrameDataSplicing;
|
|
|
|
|
+import com.tmzn.devicelinkykc.frameMsg.frameType.LoginFrame;
|
|
|
|
|
+import com.tmzn.devicelinkykc.mapstruct.BillingModelMapping;
|
|
|
|
|
+import com.tmzn.devicelinkykc.message.DeviceMsgHandle;
|
|
|
|
|
+import com.tmzn.devicelinkykc.msgEnum.DeviceSendYkc;
|
|
|
|
|
+import com.tmzn.devicelinkykc.redis.RedisCache;
|
|
|
|
|
+import com.tmzn.devicelinkykc.service.BillingModelService;
|
|
|
|
|
+import com.tmzn.devicelinkykc.service.DeviceControlerService;
|
|
|
|
|
+import com.tmzn.devicelinkykc.service.DeviceStatusService;
|
|
|
|
|
+import com.tmzn.devicelinkykc.socket.DeviceConnectionMsg;
|
|
|
|
|
+import com.tmzn.devicelinkykc.transdata.entity.DeviceParam;
|
|
|
|
|
+import com.tmzn.devicelinkykc.msgparser.MessageParseMgr;
|
|
|
|
|
+import com.tmzn.devicelinkykc.util.Encrytion;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
+
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
|
+import java.util.Arrays;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * @author xp
|
|
|
|
|
+ * @date 2024/4/13
|
|
|
|
|
+ * @explain " "
|
|
|
|
|
+ */
|
|
|
|
|
+@Controller
|
|
|
|
|
+@Slf4j(topic = "RealTimeStatusPushFrame")
|
|
|
|
|
+@RequestMapping
|
|
|
|
|
+public class TestController {
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private DeviceControlerService deviceControlerService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private BillingModelService billingModelService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private BillingModelMapping billingModelMapping;
|
|
|
|
|
+ @Value("${billingInterface}")
|
|
|
|
|
+ private String url;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private RedisCache redisCache;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private MessageParseMgr messageParseMgr;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private DeviceMsgHandle deviceMsgHandle;
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/msg")
|
|
|
|
|
+ public String testMsg(@RequestBody String message) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ deviceMsgHandle.testMsg(message);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return "ok";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ DeviceStatusService deviceStatusService;
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/parser1")
|
|
|
|
|
+ public String parser1(@RequestBody String message ) {
|
|
|
|
|
+
|
|
|
|
|
+ try{
|
|
|
|
|
+
|
|
|
|
|
+ String str_key = "6492806831843423";
|
|
|
|
|
+ String code = "";
|
|
|
|
|
+ byte[] res = Encrytion.rsaEncrypt(str_key.getBytes(),"MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKbtY6sYSeN1uv4pafiaTPMHySxmIosW1Jia1mOcaMmWUQrN57uieY++1wkW3LVg4KY7CG/eeQXAwqbbvoax7yMCAwEAAQ==");
|
|
|
|
|
+ System.out.println(res);
|
|
|
|
|
+
|
|
|
|
|
+ byte[] res1 = Encrytion.rsaEncrypt(str_key.getBytes(),"MFwwDQYJKoZIhycNAQEBBQADSWAWSAJBAKbtY6sYSeN1uv4pafiaTPMHySxmlosW1Jia1mOcaMmWUQrN57uieY++1wkW3LVg4KY7CG/eeQxAwabbvoax7yMCAWEAAQ==");
|
|
|
|
|
+ System.out.println(res1);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ QueryWrapper<BillingModel> billWapper = new QueryWrapper<>();
|
|
|
|
|
+ billWapper.eq("pile_code", "32010600530570");
|
|
|
|
|
+ billWapper.eq("device_imei", "863218078065418");
|
|
|
|
|
+ BillingModel b = billingModelService.getOne(billWapper);
|
|
|
|
|
+ if (b == null) {
|
|
|
|
|
+ log.info("{}上报充电中未匹配计费模型", "32010600530570");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ QueryWrapper<DeviceStatus> deviceStatusQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
+ deviceStatusQueryWrapper.eq("device_imei", "863343064704539");
|
|
|
|
|
+ deviceStatusQueryWrapper.last("limit 1");
|
|
|
|
|
+ DeviceStatus statusServiceOne = deviceStatusService.getOne(deviceStatusQueryWrapper);
|
|
|
|
|
+ System.out.println(statusServiceOne);
|
|
|
|
|
+
|
|
|
|
|
+// deviceMsgHandle.deviceMsg(message);
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ System.out.println(e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ System.out.println(111);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ return "ok";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/parser2")
|
|
|
|
|
+ public String parser2(@RequestBody String message ) {
|
|
|
|
|
+
|
|
|
|
|
+ //剩余
|
|
|
|
|
+ byte[] soc = new byte[]{0x00};
|
|
|
|
|
+ //电池组最高温度
|
|
|
|
|
+ byte[] battery_temp = {0x32};
|
|
|
|
|
+ //剩余时间
|
|
|
|
|
+ byte[] remain_time = {0x00, 0x00};
|
|
|
|
|
+ //枪线温度
|
|
|
|
|
+ byte[] guns_line_temp = new byte[1];
|
|
|
|
|
+ //9.枪线温度
|
|
|
|
|
+ guns_line_temp[0] = 0x32;
|
|
|
|
|
+
|
|
|
|
|
+ byte gunsStatus = 3;
|
|
|
|
|
+ String imei = "868371073352243";
|
|
|
|
|
+ byte guns = 1;
|
|
|
|
|
+ double voltage = 136;
|
|
|
|
|
+
|
|
|
|
|
+ try{
|
|
|
|
|
+ //重置电压 直流电压放大10倍
|
|
|
|
|
+ if(gunsStatus== StatusConstant.CHARGING){
|
|
|
|
|
+ JSONArray dataArray = redisCache.getCacheMapValue("device_last_163",imei+"_"+guns);
|
|
|
|
|
+ if(dataArray != null){
|
|
|
|
|
+ //获取soc和剩余时间
|
|
|
|
|
+ //重置soc
|
|
|
|
|
+ soc[0] = (byte) (dataArray.getInteger(21+3) & 0xff);
|
|
|
|
|
+
|
|
|
|
|
+ remain_time[0] = dataArray.getByte(22+3);
|
|
|
|
|
+ remain_time[1] = dataArray.getByte(23+3);
|
|
|
|
|
+// int remainTIme = (dataArray.getInteger(22+3)) | (dataArray.getInteger(23+3)<<8);
|
|
|
|
|
+// remain_time[1] = (byte) ((remainTIme >> 8) & 0xFF);
|
|
|
|
|
+// remain_time[0] = (byte) (remainTIme & 0xFF);
|
|
|
|
|
+//
|
|
|
|
|
+// System.out.println(remainTIme);
|
|
|
|
|
+// System.out.println(remain_time);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ log.info("充电中-soc:{},remain:{}",soc,remain_time);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ int time = 136;
|
|
|
|
|
+ byte[] charnging_Time = new byte[2];
|
|
|
|
|
+ charnging_Time[1] = (byte) ((time >> 8) & 0xFF);
|
|
|
|
|
+ charnging_Time[0] = (byte) (time & 0xFF);
|
|
|
|
|
+ System.out.println(charnging_Time);
|
|
|
|
|
+
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ System.out.println(111);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ return "ok";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/test163")
|
|
|
|
|
+ public AjaxResult test163(HttpServletRequest request ) {
|
|
|
|
|
+ String data = request.getParameter("data");
|
|
|
|
|
+ List<Integer> split = Arrays.stream(data.split(","))
|
|
|
|
|
+ .map(Integer::parseInt) // 将 String 转换为 Integer
|
|
|
|
|
+ .collect(Collectors.toList()); // 收集结果到 List 中
|
|
|
|
|
+ List<List<Integer>> packages = Encrytion.parseMorePackage(split);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ System.out.println(111);
|
|
|
|
|
+
|
|
|
|
|
+// JSONArray objects = new JSONArray(split);
|
|
|
|
|
+// JSONObject obj = new JSONObject();
|
|
|
|
|
+// obj.put("data",objects);
|
|
|
|
|
+ // JSONObject object = messageParseMgr.parseMessage("75960_103", obj);
|
|
|
|
|
+
|
|
|
|
|
+ // System.out.println(object);
|
|
|
|
|
+
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/parser")
|
|
|
|
|
+ public AjaxResult parser(HttpServletRequest request ) {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ String data = request.getParameter("data");
|
|
|
|
|
+
|
|
|
|
|
+ List<Integer> split = Arrays.stream(data.split(","))
|
|
|
|
|
+ .map(Integer::parseInt) // 将 String 转换为 Integer
|
|
|
|
|
+ .collect(Collectors.toList()); // 收集结果到 List 中
|
|
|
|
|
+
|
|
|
|
|
+ List<List<Integer>> packages = Encrytion.parseMorePackage(split);
|
|
|
|
|
+
|
|
|
|
|
+ System.out.println(packages);
|
|
|
|
|
+
|
|
|
|
|
+ for(int i=0;i<packages.size();i++){
|
|
|
|
|
+ JSONObject obj = new JSONObject();
|
|
|
|
|
+ obj.put("data",packages.get(i));
|
|
|
|
|
+
|
|
|
|
|
+ System.out.println("parser:"+"75960_"+packages.get(i).get(1));
|
|
|
|
|
+ JSONObject object = messageParseMgr.parseMessage("75960_"+packages.get(i).get(1),obj);
|
|
|
|
|
+ System.out.println(object);
|
|
|
|
|
+
|
|
|
|
|
+ if(object!=null){
|
|
|
|
|
+ String m = object.toString();
|
|
|
|
|
+ System.out.println(m);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ System.out.println(111);
|
|
|
|
|
+
|
|
|
|
|
+// JSONArray objects = new JSONArray(split);
|
|
|
|
|
+// JSONObject obj = new JSONObject();
|
|
|
|
|
+// obj.put("data",objects);
|
|
|
|
|
+ // JSONObject object = messageParseMgr.parseMessage("75960_103", obj);
|
|
|
|
|
+
|
|
|
|
|
+ // System.out.println(object);
|
|
|
|
|
+
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/test")
|
|
|
|
|
+ public String test(@RequestParam("method") String method, @RequestParam("imei") String imei) {
|
|
|
|
|
+
|
|
|
|
|
+ String deviceId = imei;
|
|
|
|
|
+ String ccid = imei;
|
|
|
|
|
+ if ("start".equals(method)) {
|
|
|
|
|
+ deviceControlerService.startCharge(imei, imei, 1,50000);
|
|
|
|
|
+ } else if ("stop".equals(method)) {
|
|
|
|
|
+ deviceControlerService.stopCharge(imei, imei, 1);
|
|
|
|
|
+ } else if ("port".equals(method)) {
|
|
|
|
|
+
|
|
|
|
|
+ DeviceParam deviceParam = new DeviceParam();
|
|
|
|
|
+ deviceParam.setDeviceId(imei);
|
|
|
|
|
+ deviceParam.setCcid(imei);
|
|
|
|
|
+ deviceControlerService.sendPortDetailCmd(deviceParam);
|
|
|
|
|
+ } else if ("restartDevice".equals(method)) {
|
|
|
|
|
+
|
|
|
|
|
+ deviceControlerService.restart(imei, imei);
|
|
|
|
|
+ } else if ("rest".equals(method)) {
|
|
|
|
|
+ deviceControlerService.reset(imei, imei);
|
|
|
|
|
+ }
|
|
|
|
|
+ return "ok";
|
|
|
|
|
+ }
|
|
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(DeviceMsgHandle.class);
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/test2")
|
|
|
|
|
+ public String test2(@RequestParam("pileCode") String pileCode) {
|
|
|
|
|
+ //调用重启
|
|
|
|
|
+
|
|
|
|
|
+ // redisCache.setCacheMapValue(RedisConstant.PILE_GUN_PAY_TIME, pileCode+"_"+1,System.currentTimeMillis());
|
|
|
|
|
+
|
|
|
|
|
+// return "ok";
|
|
|
|
|
+// //标记最后订单时间 5分钟内不上报空闲状态 避免刚下单状态还没更新就被freeTask任务给顶掉了
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ new Thread(() -> {
|
|
|
|
|
+ try {
|
|
|
|
|
+ Thread.sleep(5000); // 延迟 5 秒
|
|
|
|
|
+ DeviceParam dataParam = new DeviceParam();
|
|
|
|
|
+ dataParam.setDeviceId("123456");
|
|
|
|
|
+ dataParam.setCcid("123456");
|
|
|
|
|
+// deviceControlerService.sendPortDetailCmd(dataParam);
|
|
|
|
|
+ logger.info(":主动下发103消息");
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ logger.info(":主动下发103消息异常" + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }).start();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+// try{
|
|
|
|
|
+// long ts = redisCache.getCacheMapValue(RedisConstant.PILE_GUN_PAY_TIME, pileCode+"_1");
|
|
|
|
|
+// if(ts!=0){
|
|
|
|
|
+// long ts1 = System.currentTimeMillis();
|
|
|
|
|
+// if((ts1-ts)<300*1000){
|
|
|
|
|
+// return "ok";
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+// }catch (Exception e){
|
|
|
|
|
+// return "error";
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+ return "ok";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired LoginFrame loginFrame;
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/test3")
|
|
|
|
|
+ public String test3() throws Exception {
|
|
|
|
|
+ //调用重启
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ loginFrame.test();
|
|
|
|
|
+ return "ok";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/test1")
|
|
|
|
|
+ public String test1(@RequestParam("pileCode") String pileCode) {
|
|
|
|
|
+ //调用重启
|
|
|
|
|
+ try{
|
|
|
|
|
+ String url = "http://127.0.0.1:8063/api/device/restLogin/"+pileCode;
|
|
|
|
|
+ HttpResponse execute = HttpRequest.post(url)
|
|
|
|
|
+ .timeout(3000)
|
|
|
|
|
+ .execute();
|
|
|
|
|
+ String body = execute.body();
|
|
|
|
|
+ System.out.println("reset login body:>>>"+body);
|
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
|
+ System.out.println("reset error :>>>"+ex.toString());
|
|
|
|
|
+ }
|
|
|
|
|
+ return "ok";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @RequestMapping("/testElec")
|
|
|
|
|
+ public JSONObject testCompute(@RequestParam("end")Long end,@RequestParam("start")Long star,@RequestParam("imei")String imei,@RequestParam("port")int port) {
|
|
|
|
|
+ QueryWrapper<BillingModel> billingModelQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
+ BillingModel one = billingModelService.getOne(billingModelQueryWrapper);
|
|
|
|
|
+ BillingModelDTO billingModelDTO = billingModelMapping.billingModelToBillingModelDto(one);
|
|
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
|
|
+ map.put("port",port);
|
|
|
|
|
+ map.put("billingModel",billingModelDTO);
|
|
|
|
|
+ map.put("startTime",star/1000);
|
|
|
|
|
+ map.put("endTime",end/1000);
|
|
|
|
|
+ JSONObject jsonObject = new JSONObject(map);
|
|
|
|
|
+ String s = jsonObject.toString();
|
|
|
|
|
+ HttpResponse execute = HttpRequest.post(url)
|
|
|
|
|
+ .form("data",s)
|
|
|
|
|
+ .timeout(3000)
|
|
|
|
|
+ .execute();
|
|
|
|
|
+ int status = execute.getStatus();
|
|
|
|
|
+ String body = execute.body();
|
|
|
|
|
+ System.out.println("body:>>>"+body);
|
|
|
|
|
+ return null;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+}
|