|
@@ -1,43 +1,32 @@
|
|
|
package com.lm.lib.controller;
|
|
|
|
|
|
-import com.fasterxml.jackson.databind.util.JSONPObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.google.gson.Gson;
|
|
|
import com.lm.lib.dto.AlarmMapDto;
|
|
|
+import com.lm.lib.entity.FfLocation;
|
|
|
import com.lm.lib.param.*;
|
|
|
-import com.playcoding.iotp.beans.DataPackage;
|
|
|
-import com.playcoding.iotp.share.Safe;
|
|
|
-import com.playcoding.iotp.store.StoreApi;
|
|
|
-import com.playcoding.iotp.store.bind.StoreBindProxy;
|
|
|
-import com.playcoding.iotp.store.client.StoreClient;
|
|
|
-import com.playcoding.iotp.store.client.StoreIterable;
|
|
|
+import com.lm.lib.service.impl.FfLocationServiceImpl;
|
|
|
+
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
-import io.swagger.models.auth.In;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.http.HttpEntity;
|
|
|
import org.apache.http.client.methods.HttpGet;
|
|
|
import org.apache.http.impl.client.HttpClients;
|
|
|
import org.apache.http.util.EntityUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.dao.EmptyResultDataAccessException;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
-import java.io.PrintWriter;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-import java.util.stream.DoubleStream;
|
|
|
|
|
|
import static java.lang.Math.abs;
|
|
|
|
|
@@ -58,50 +47,65 @@ public class ShowDataController {
|
|
|
|
|
|
@Resource(name = "ossJdbcTemplate")
|
|
|
JdbcTemplate ossJdbcTemplate;
|
|
|
+
|
|
|
+// @Resource
|
|
|
+// FfLocationServiceImpl ffLocationService;
|
|
|
+
|
|
|
+
|
|
|
// @Autowired
|
|
|
// StoreClient storeClient;
|
|
|
// StoreApi service = new StoreBindProxy();
|
|
|
// StoreClient storeClient = new StoreClient(service);
|
|
|
-@ApiOperation(value = "获取gps数据")
|
|
|
-@RequestMapping(value = "/allrealtimeInfo", method = RequestMethod.GET)
|
|
|
-public Map<String, Object> gpsInfo() throws IOException {
|
|
|
- String sql = "select sn from app_device";
|
|
|
- List<Map<String, Object>> snData = ossJdbcTemplate.queryForList(sql);
|
|
|
- List snList = new ArrayList();
|
|
|
- snData.forEach(p->snList.add(p.get("sn")));
|
|
|
-
|
|
|
- Map<String, Object> res = new HashMap<>();
|
|
|
- sql = "select t2.latitude, t2.longitude, t1.charge_state, t1.devcode from ff_battery_status t1 left join ff_location t2 on t1.devcode = t2.devcode";
|
|
|
- List<Map<String, Object>> realtimeData;
|
|
|
- try {
|
|
|
- realtimeData = iotpJdbcTemplate.queryForList(sql);
|
|
|
- } catch (EmptyResultDataAccessException e) {
|
|
|
- realtimeData = null;
|
|
|
- }
|
|
|
- if (!ObjectUtils.isEmpty(realtimeData)) {
|
|
|
- List<Object> data = new ArrayList<>();
|
|
|
- realtimeData.forEach(p->{
|
|
|
- Map<String, Object> thisData = new HashMap<>();
|
|
|
- if (ObjectUtils.isEmpty(p.get("latitude")) ||
|
|
|
- ((abs(Double.parseDouble(p.get("latitude").toString()))) < 0.0001 && (abs(Double.parseDouble(p.get("longitude").toString()))) < 0.0001)) return;
|
|
|
- if (!snList.contains(p.get("devcode"))) return;
|
|
|
- thisData.put("latitude", p.getOrDefault("latitude", null));
|
|
|
- thisData.put("longitude", p.getOrDefault("longitude", null));
|
|
|
- thisData.put("devcode", p.getOrDefault("devcode", null));
|
|
|
- thisData.put("charge_state", p.getOrDefault("charge_state", null));
|
|
|
- data.add(thisData);
|
|
|
- });
|
|
|
- res.put("code", 200);
|
|
|
- res.put("message", "获取成功");
|
|
|
- res.put("data", data);
|
|
|
+
|
|
|
+ @ApiOperation(value = "获取美团sn")
|
|
|
+ @RequestMapping(value = "/getSn", method = RequestMethod.GET)
|
|
|
+ public String getSn() throws IOException {
|
|
|
+ String sql = "select qrcode from py_battery where f_id=141";
|
|
|
+ List<Map<String, Object>> snData = moyuJdbcTemplate.queryForList(sql);
|
|
|
+ List<String> snList = new ArrayList();
|
|
|
+ snData.forEach(p -> snList.add(p.get("qrcode").toString()));
|
|
|
+ String snString = "\'" + String.join("\',\'", snList) + "\'";
|
|
|
+ return snString;
|
|
|
}
|
|
|
- else{
|
|
|
- res.put("code", 500);
|
|
|
- res.put("message", "未获取到数据");
|
|
|
- res.put("data", new ArrayList<>());
|
|
|
+
|
|
|
+ @ApiOperation(value = "获取gps数据")
|
|
|
+ @RequestMapping(value = "/allrealtimeInfo", method = RequestMethod.GET)
|
|
|
+ public Map<String, Object> gpsInfo() throws IOException {
|
|
|
+ String snString = this.getSn();
|
|
|
+ Map<String, Object> res = new HashMap<>();
|
|
|
+ String sql = "select t2.latitude, t2.longitude, t1.charge_state, t1.devcode from ff_battery_status t1 left join ff_location t2 on t1.devcode = t2.devcode where t2.devcode in (%s)";
|
|
|
+ List<Map<String, Object>> realtimeData;
|
|
|
+ List<String> snList = Arrays.asList(snString.replace("'", "").split(","));
|
|
|
+ try {
|
|
|
+ realtimeData = iotpJdbcTemplate.queryForList(String.format(sql, snString));
|
|
|
+ } catch (EmptyResultDataAccessException e) {
|
|
|
+ realtimeData = null;
|
|
|
+ }
|
|
|
+ if (!ObjectUtils.isEmpty(realtimeData)) {
|
|
|
+ List<Object> data = new ArrayList<>();
|
|
|
+ realtimeData.forEach(p -> {
|
|
|
+ Map<String, Object> thisData = new HashMap<>();
|
|
|
+ if (ObjectUtils.isEmpty(p.get("latitude")) ||
|
|
|
+ ((abs(Double.parseDouble(p.get("latitude").toString()))) < 0.0001 && (abs(Double.parseDouble(p.get("longitude").toString()))) < 0.0001))
|
|
|
+ return;
|
|
|
+ if (!snList.contains(p.get("devcode"))) return;
|
|
|
+ thisData.put("latitude", p.getOrDefault("latitude", null));
|
|
|
+ thisData.put("longitude", p.getOrDefault("longitude", null));
|
|
|
+ thisData.put("devcode", p.getOrDefault("devcode", null));
|
|
|
+// thisData.put("charge_state", p.getOrDefault("charge_state", null));
|
|
|
+ data.add(thisData);
|
|
|
+ });
|
|
|
+ res.put("code", 200);
|
|
|
+ res.put("message", "获取成功");
|
|
|
+ res.put("data", data);
|
|
|
+ } else {
|
|
|
+ res.put("code", 500);
|
|
|
+ res.put("message", "未获取到数据");
|
|
|
+ res.put("data", new ArrayList<>());
|
|
|
+ }
|
|
|
+ return res;
|
|
|
}
|
|
|
- return res;
|
|
|
-}
|
|
|
+
|
|
|
@ApiOperation(value = "基本信息")
|
|
|
@RequestMapping(value = "/baseInfo", method = RequestMethod.GET)
|
|
|
public RspBaseInfo baseInfo(@ApiParam(name = "查询参数", value = "sn号", required = false) String sn) throws IOException {
|
|
@@ -226,7 +230,7 @@ public Map<String, Object> gpsInfo() throws IOException {
|
|
|
|
|
|
lastData.put("error_level", lastData.get("error_level") == null ? 0 : lastData.get("error_level"));
|
|
|
Double voltDiff = (600 - (Double.parseDouble(Collections.max(voltages)) - (Double.parseDouble(Collections.min(voltages))))) / 6;
|
|
|
- if (soh.compareTo(100.0) > 0){
|
|
|
+ if (soh.compareTo(100.0) > 0) {
|
|
|
soh = 100.0;
|
|
|
}
|
|
|
score = (soh * soh * 14.0 / 100.0 +
|
|
@@ -323,11 +327,10 @@ public Map<String, Object> gpsInfo() throws IOException {
|
|
|
accumData = null;
|
|
|
}
|
|
|
if (!ObjectUtils.isEmpty(accumData)) {
|
|
|
- if (accumData.get("dsg_phaccum") == null){
|
|
|
+ if (accumData.get("dsg_phaccum") == null) {
|
|
|
rspHealthInfo.setAccumEnergy("-");
|
|
|
- }
|
|
|
- else{
|
|
|
- rspHealthInfo.setAccumEnergy(((Double)(Double.parseDouble(accumData.get("dsg_phaccum").toString())/1000.0)).toString());
|
|
|
+ } else {
|
|
|
+ rspHealthInfo.setAccumEnergy(((Double) (Double.parseDouble(accumData.get("dsg_phaccum").toString()) / 1000.0)).toString());
|
|
|
// 设备信息解析 电压平台和AH数
|
|
|
sql = "select imei from app_device where sn = '" + sn + "'";
|
|
|
Map<String, Object> deviceData;
|
|
@@ -337,26 +340,23 @@ public Map<String, Object> gpsInfo() throws IOException {
|
|
|
deviceData = null;
|
|
|
}
|
|
|
if (!ObjectUtils.isEmpty(deviceData)) {
|
|
|
- Double volt=0.0;
|
|
|
+ Double volt = 0.0;
|
|
|
Double crnt;
|
|
|
- if (deviceData.get("imei").toString().substring(6,7).equals("4")){
|
|
|
+ if (deviceData.get("imei").toString().substring(6, 7).equals("4")) {
|
|
|
volt = 48.0;
|
|
|
- }
|
|
|
- else if (deviceData.get("imei").toString().substring(6,7).equals("6")){
|
|
|
+ } else if (deviceData.get("imei").toString().substring(6, 7).equals("6")) {
|
|
|
volt = 60.0;
|
|
|
- }
|
|
|
- else if (deviceData.get("imei").toString().substring(6,7).equals("7")){
|
|
|
+ } else if (deviceData.get("imei").toString().substring(6, 7).equals("7")) {
|
|
|
volt = 72.0;
|
|
|
}
|
|
|
- crnt = Double.parseDouble(deviceData.get("imei").toString().substring(7,9));
|
|
|
- rspHealthInfo.setAccumCycle(((Double)Math.ceil((Double.parseDouble(rspHealthInfo.getAccumEnergy())/(crnt * volt /1000.0)))).toString());
|
|
|
- }
|
|
|
- else{
|
|
|
+ crnt = Double.parseDouble(deviceData.get("imei").toString().substring(7, 9));
|
|
|
+ rspHealthInfo.setAccumCycle(((Double) Math.ceil((Double.parseDouble(rspHealthInfo.getAccumEnergy()) / (crnt * volt / 1000.0)))).toString());
|
|
|
+ } else {
|
|
|
rspHealthInfo.setAccumCycle("-");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- } else{
|
|
|
+ } else {
|
|
|
rspHealthInfo.setAccumEnergy("-");
|
|
|
rspHealthInfo.setAccumCycle("-");
|
|
|
|
|
@@ -401,7 +401,7 @@ public Map<String, Object> gpsInfo() throws IOException {
|
|
|
return rspAllAlarmInfo;
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "当前电池报警信息")
|
|
|
+ @ApiOperation(value = "低电量报警信息")
|
|
|
@RequestMapping(value = "/alarmInfo", method = RequestMethod.GET)
|
|
|
public RspAlarmInfo alarmInfo(@ApiParam(name = "查询参数", value = "sn号", required = false) String sn) {
|
|
|
RspAlarmInfo rspAlarmInfo = new RspAlarmInfo();
|
|
@@ -428,7 +428,7 @@ public Map<String, Object> gpsInfo() throws IOException {
|
|
|
}
|
|
|
sql = "select t4.*, t5.f_name from (select t.*, t3.s_name from " +
|
|
|
"(select t1.u_id, t1.u_status, t2.username, t2.mobile,t1.s_id, t1.f_id from py_battery t1 left join py_users t2 on t1.u_id=t2.user_id where qrcode = '" + sn + "') t left join py_site t3 on t3.s_id=t.s_id " +
|
|
|
- ")t4 left join py_franchisee t5 on t5.f_id=t4.f_id" ;
|
|
|
+ ")t4 left join py_franchisee t5 on t5.f_id=t4.f_id";
|
|
|
Map<String, Object> userInfo;
|
|
|
try {
|
|
|
userInfo = moyuJdbcTemplate.queryForMap(sql);
|