|
@@ -19,6 +19,7 @@ import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import jdk.nashorn.internal.runtime.PropertyMap;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.dao.EmptyResultDataAccessException;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.util.StringUtils;
|
|
@@ -38,8 +39,8 @@ public class IndexController {
|
|
|
@Resource(name = "appDeviceService")
|
|
|
AppDeviceService appDeviceService;
|
|
|
|
|
|
-// @Resource(name = "jdbcTemplateRuntime")
|
|
|
-// JdbcTemplate jdbcTemplate;
|
|
|
+ @Resource(name = "jdbcTemplateRuntime")
|
|
|
+ JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
@Resource
|
|
|
AppDeviceLogService appDeviceLogService;
|
|
@@ -191,15 +192,13 @@ public class IndexController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- StringBuffer sql = new StringBuffer();
|
|
|
- sql.append("select * from ");
|
|
|
- res.put("lastOnLineTime", "");
|
|
|
- res.put("lat", 0);
|
|
|
- res.put("long", 0);
|
|
|
res.put("typeTitle", devicePage.getTypeTitle());
|
|
|
res.put("packTitle", devicePage.getPackTitle());
|
|
|
res.put("specTitle", devicePage.getSpecTitle());
|
|
|
res.put("expandTitle", devicePage.getExpandTitle());
|
|
|
+ res.put("lastOnLineTime", "");
|
|
|
+ res.put("lat", 0);
|
|
|
+ res.put("long", 0);
|
|
|
res.put("batStatus", 0);
|
|
|
res.put("soc", 0);
|
|
|
res.put("current", 0);
|
|
@@ -208,6 +207,35 @@ public class IndexController {
|
|
|
res.put("odo", 0);
|
|
|
res.put("accumChargeTime",0);
|
|
|
res.put("cycleCount", 0);
|
|
|
+
|
|
|
+ StringBuffer sql = new StringBuffer();
|
|
|
+ Map<String, Object> bmsData = new HashMap<>();
|
|
|
+ Map<String, Object> gpsData = new HashMap<>();
|
|
|
+ try {
|
|
|
+ bmsData = jdbcTemplate.queryForMap("select devcode, charge_state, soc, soh, current, update_time, max_temp from ff_battery_status where devcode='" + param.getSn() + "'");
|
|
|
+ } catch (EmptyResultDataAccessException e) {
|
|
|
+ bmsData.put("devcode", null);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ gpsData = jdbcTemplate.queryForMap("select devcode, longitude, latitude from ff_location where devcode='" + param.getSn() + "'");
|
|
|
+ } catch (EmptyResultDataAccessException e) {
|
|
|
+ gpsData.put("devcode", null);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(bmsData.get("devcode")))
|
|
|
+ {
|
|
|
+ res.put("lastOnLineTime", DateUtils.toString(ObjectUtil.obj2Date(bmsData.get("update_time")), DateUtils.YMDHMS));
|
|
|
+ res.put("batStatus", bmsData.get("charge_state"));
|
|
|
+ res.put("soc", bmsData.get("soc"));
|
|
|
+ res.put("current", bmsData.get("current"));
|
|
|
+ res.put("temp", bmsData.get("max_temp"));
|
|
|
+ res.put("soh", bmsData.get("soh"));
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(gpsData.get("devcode")))
|
|
|
+ {
|
|
|
+ res.put("lat", gpsData.get("latitude"));
|
|
|
+ res.put("long", gpsData.get("longitude"));
|
|
|
+ }
|
|
|
+
|
|
|
List<Map<String, Object>> result = new ArrayList<>();
|
|
|
result.add(res);
|
|
|
return new ApiPageDTO(null, result);
|