|
@@ -4,6 +4,7 @@ import com.aidex.common.app.domain.vo.LocationVO;
|
|
|
import com.aidex.common.app.domain.vo.SysWharfVO;
|
|
|
import com.aidex.common.app.server.IAppService;
|
|
|
import com.aidex.common.exception.SysException;
|
|
|
+import com.aidex.common.gps.domain.AlarmDatetailsEntity;
|
|
|
import com.aidex.common.gps.domain.FenceEntity;
|
|
|
import com.aidex.common.gps.domain.LocationEntity;
|
|
|
import com.aidex.common.gps.domain.MyGpsEntity;
|
|
@@ -21,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.time.*;
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Comparator;
|
|
|
import java.util.List;
|
|
@@ -107,6 +109,13 @@ public class AppService implements IAppService {
|
|
|
public LocationVO findAllLocationByNext(Boolean direction,String lat, String lon){
|
|
|
if(StringUtils.isEmpty(lat) || StringUtils.isEmpty(lon))
|
|
|
throw new SysException(4441,"请告诉我你在哪");
|
|
|
+
|
|
|
+
|
|
|
+ SysWharf wharf = this.findNearestStation(lat,lon);
|
|
|
+
|
|
|
+ if(!wharf.getStatus().equals("0"))
|
|
|
+ throw new SysException(4442, wharf.getWharfNanme()+" 已经停用!请更换其他站点");
|
|
|
+
|
|
|
|
|
|
List<MyGpsEntity> allMyGps = iGpsService.findMyGps();
|
|
|
|
|
@@ -120,30 +129,40 @@ public class AppService implements IAppService {
|
|
|
|
|
|
Integer inStopTime = Integer.valueOf(ConfigUtils.getConfigByKey("pull.in.time").getConfigValue());
|
|
|
|
|
|
+
|
|
|
+ Integer stopSpeed = Integer.valueOf(ConfigUtils.getConfigByKey("stop.speed").getConfigValue());
|
|
|
+
|
|
|
for (LocationEntity locationEntity : locationEntities) {
|
|
|
- if(Double.valueOf(locationEntity.getDir()) <= 0){
|
|
|
+ locationEntity.setIsLongStop(Boolean.FALSE);
|
|
|
+
|
|
|
+ if(Double.valueOf(locationEntity.getSpeed()) <= Double.valueOf(stopSpeed) && Double.valueOf(locationEntity.getDir()) <= 0){
|
|
|
|
|
|
- LocalDate today = LocalDate.now();
|
|
|
-
|
|
|
- LocalDateTime startOfDay = today.atStartOfDay();
|
|
|
+ LocalDateTime endOfDay = LocalDateTime.now();
|
|
|
|
|
|
- LocalDateTime endOfDay = LocalDateTime.of(today, LocalTime.MAX);
|
|
|
+ LocalDateTime startDay = endOfDay.minusMonths(1);
|
|
|
|
|
|
- long startTimestamp = startOfDay.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
|
|
+ long startTimestamp = startDay.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
|
|
long endTimestamp = endOfDay.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
|
|
- List<FenceEntity> fence = iGpsService.findFenceInByMacId(locationEntity.getMacid(),startTimestamp,endTimestamp);
|
|
|
- if(fence.size() > 0){
|
|
|
-
|
|
|
- FenceEntity fenceEntity = fence.get(0);
|
|
|
- locationEntity.setDir(fenceEntity.getDir());
|
|
|
+ List<AlarmDatetailsEntity> alarms = iGpsService.findAlarmDetails(locationEntity.getMacid(),"4",startTimestamp,endTimestamp);
|
|
|
+ if(alarms.size() > 0){
|
|
|
+
|
|
|
+ AlarmDatetailsEntity alarmDetails = alarms.get(0);
|
|
|
+ locationEntity.setDir(alarmDetails.getDir());
|
|
|
+
|
|
|
+ LocalDateTime longStopTime = LocalDateTime.ofEpochSecond(Long.valueOf(alarmDetails.getAlarmime()) / 1000, 0, java.time.ZoneOffset.UTC);
|
|
|
+
|
|
|
+ Long stopTime = ChronoUnit.MINUTES.between(endOfDay, longStopTime);
|
|
|
+
|
|
|
+ if(stopTime.doubleValue() > Double.valueOf(inStopTime)) {
|
|
|
+ locationEntity.setIsLongStop(Boolean.TRUE);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
List<LocationVO> calcList = new ArrayList<>();
|
|
|
-
|
|
|
- Integer stopSpeed = Integer.valueOf(ConfigUtils.getConfigByKey("stop.speed").getConfigValue());
|
|
|
+
|
|
|
|
|
|
|
|
|
String[] conditions ;
|
|
@@ -179,8 +198,7 @@ public class AppService implements IAppService {
|
|
|
LocationVO res = null;
|
|
|
|
|
|
if(calcList.size() > 0) {
|
|
|
-
|
|
|
- SysWharf wharf = this.findNearestStation(lat,lon);
|
|
|
+
|
|
|
|
|
|
for (LocationVO locationVO : calcList) {
|
|
|
|
|
@@ -212,12 +230,19 @@ public class AppService implements IAppService {
|
|
|
Long endTime = Long.valueOf(res.getServer_time());
|
|
|
|
|
|
Long startTime = endTime - (inStopTime.longValue() * 60 * 1000);
|
|
|
+
|
|
|
+
|
|
|
+ List<AlarmDatetailsEntity> fenceEntities = iGpsService.findAlarmDetails(res.getMacid(),"4",startTime,endTime);
|
|
|
+
|
|
|
|
|
|
- List<FenceEntity> fenceEntities = iGpsService.findFenceIn(res.getMacid(),wharf.getWharfNanme(),startTime,endTime);
|
|
|
-
|
|
|
- List<FenceEntity> fenceShipEntities = iGpsService.findFenceIn(res.getMacid(),wharfShip.getWharfNanme(),startTime,endTime);
|
|
|
+ AlarmDatetailsEntity mySite = fenceEntities.stream().filter(alram -> alram.getDescribe().equals(wharf.getWharfNanme())).findFirst().orElse(null);
|
|
|
+
|
|
|
+ AlarmDatetailsEntity shipSite = fenceEntities.stream().filter(alram -> alram.getDescribe().equals(wharfShip.getWharfNanme())).findFirst().orElse(null);
|
|
|
+
|
|
|
res.setMyWharf(wharf);
|
|
|
|
|
|
+
|
|
|
+
|
|
|
Long distSiteNum = 0L;
|
|
|
if(direction){
|
|
|
Double position = CalcDist.gps2d(Double.valueOf(wharfShip.getLat()),Double.valueOf(wharfShip.getLng()),Double.valueOf(res.getLat()),Double.valueOf(res.getLon()));
|
|
@@ -238,8 +263,16 @@ public class AppService implements IAppService {
|
|
|
res.setDistSiteNum(distSiteNum);
|
|
|
|
|
|
|
|
|
- if (isStopOperation && (fenceEntities.size() > 0 || fenceShipEntities.size() > 0)) {
|
|
|
- res.setStopWharf(wharfShip);
|
|
|
+ if (isStopOperation && (mySite != null || shipSite != null)) {
|
|
|
+ if(res.getIsLongStop())
|
|
|
+ res.setStopWharf(wharfShip);
|
|
|
+ else {
|
|
|
+ if(shipSite == null && mySite != null){
|
|
|
+ res.setStopWharf(wharf);
|
|
|
+ }else {
|
|
|
+ res.setStopWharf(wharfShip);
|
|
|
+ }
|
|
|
+ }
|
|
|
res.setIsArrival(Boolean.TRUE);
|
|
|
|
|
|
if(!wharfShip.getWharfNanme().equals(wharf.getWharfNanme())) {
|