|
@@ -21,6 +21,7 @@ import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.Date;
|
|
|
|
|
|
import java.util.List;
|
|
@@ -168,14 +169,14 @@ public class MqttMsgService {
|
|
|
for(Map target : targets) {
|
|
|
Integer tid = (Integer) target.get("tid");
|
|
|
Integer cls = (Integer) target.get("cls");
|
|
|
- double x = (double) target.get("x");
|
|
|
- double y = (double) target.get("y");
|
|
|
+ BigDecimal x = (BigDecimal) target.get("x");
|
|
|
+ BigDecimal y = (BigDecimal) target.get("y");
|
|
|
if (cls == 1) { //是人
|
|
|
//先查是否存在
|
|
|
String content = (String)redisUtil.hget(RedisKeyConstant.PEOPLEEVENT_ACTIVE_INFO,careDevice.getDevCode()+ "_" + tid);
|
|
|
if (content != null) {//之前有存储redis
|
|
|
//计算当前的和存储的之间距离和时长
|
|
|
- double distance = getDistance(Double.parseDouble(content.split("_")[1]),x,Double.parseDouble(content.split("_")[2]),y);
|
|
|
+ double distance = getDistance(new BigDecimal(content.split("_")[1]),x,new BigDecimal(content.split("_")[2]),y);
|
|
|
long duration = (date.getTime() - Long.parseLong(content.split("_")[0]));
|
|
|
|
|
|
//存储行走距离明细表
|
|
@@ -217,8 +218,8 @@ public class MqttMsgService {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private double getDistance(double x1, double y1,double x2, double y2) {
|
|
|
- double distance = Math.sqrt(Math.abs((x1 - x2)*(x1 - x2))+Math.abs((y1 - y2)*(y1 - y2)));
|
|
|
+ private double getDistance(BigDecimal x1, BigDecimal y1,BigDecimal x2, BigDecimal y2) {
|
|
|
+ double distance = Math.sqrt(Math.abs((x1.doubleValue() - x2.doubleValue())*(x1.doubleValue() - x2.doubleValue()))+Math.abs((y1.doubleValue() - y2.doubleValue())*(y1.doubleValue() - y2.doubleValue())));
|
|
|
return distance;
|
|
|
}
|
|
|
private void handleOptInOut(Map msg,CareDevice careDevice,Date date){
|