|
@@ -4,17 +4,18 @@ import com.alibaba.excel.EasyExcel;
|
|
|
import com.alibaba.excel.ExcelReader;
|
|
import com.alibaba.excel.ExcelReader;
|
|
|
import com.alibaba.excel.read.metadata.ReadSheet;
|
|
import com.alibaba.excel.read.metadata.ReadSheet;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.sckw.core.common.enums.enums.DictTypeEnum;
|
|
import com.sckw.core.common.enums.enums.DictTypeEnum;
|
|
|
import com.sckw.core.common.enums.enums.FileEnum;
|
|
import com.sckw.core.common.enums.enums.FileEnum;
|
|
|
import com.sckw.core.exception.SystemException;
|
|
import com.sckw.core.exception.SystemException;
|
|
|
import com.sckw.core.model.constant.Global;
|
|
import com.sckw.core.model.constant.Global;
|
|
|
|
|
+import com.sckw.core.model.enums.SystemTypeEnum;
|
|
|
import com.sckw.core.model.file.FileInfo;
|
|
import com.sckw.core.model.file.FileInfo;
|
|
|
-import com.sckw.core.utils.BeanUtils;
|
|
|
|
|
-import com.sckw.core.utils.CollectionUtils;
|
|
|
|
|
-import com.sckw.core.utils.FileUtils;
|
|
|
|
|
-import com.sckw.core.utils.StringUtils;
|
|
|
|
|
|
|
+import com.sckw.core.utils.*;
|
|
|
import com.sckw.core.web.constant.HttpStatus;
|
|
import com.sckw.core.web.constant.HttpStatus;
|
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
|
|
|
+import com.sckw.core.web.request.HttpClientUtil;
|
|
|
import com.sckw.core.web.response.HttpResult;
|
|
import com.sckw.core.web.response.HttpResult;
|
|
|
import com.sckw.excel.easyexcel.ExcelImportListener;
|
|
import com.sckw.excel.easyexcel.ExcelImportListener;
|
|
|
import com.sckw.excel.utils.ExcelUtil;
|
|
import com.sckw.excel.utils.ExcelUtil;
|
|
@@ -28,15 +29,13 @@ import com.sckw.system.api.model.dto.res.SysDictResDto;
|
|
|
import com.sckw.system.api.model.dto.res.UserCacheResDto;
|
|
import com.sckw.system.api.model.dto.res.UserCacheResDto;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
import java.io.InputStream;
|
|
import java.io.InputStream;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
-import java.util.HashMap;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -587,6 +586,50 @@ public class KwfTruckService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param params {truckNo 車牌號}
|
|
|
|
|
+ * @desc 车辆查询(业务关联+归属车辆)
|
|
|
|
|
+ * @author zk
|
|
|
|
|
+ * @date 2023/9/5
|
|
|
|
|
+ **/
|
|
|
|
|
+ public List<KwfTruckMonitorVo> findTruck(Map<String, Object> params){
|
|
|
|
|
+ /**车辆查询**/
|
|
|
|
|
+ List<KwfTruckMonitorVo> trucks = new ArrayList<>();
|
|
|
|
|
+ if (LoginUserHolder.getSystemType() == SystemTypeEnum.COMPANY.getCode()) {
|
|
|
|
|
+ trucks = truckDao.findTruckByEnt(LoginUserHolder.getEntId());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (LoginUserHolder.getSystemType() == SystemTypeEnum.MANAGE.getCode()) {
|
|
|
|
|
+ trucks = truckDao.findTruckByAll();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (trucks == null || trucks.size() == 0) {
|
|
|
|
|
+ return trucks;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**数据配置**/
|
|
|
|
|
+ List<Long> entIds = new ArrayList<>();
|
|
|
|
|
+ List<String> truckNos = new ArrayList<>();
|
|
|
|
|
+ for (KwfTruckMonitorVo truck:trucks) {
|
|
|
|
|
+ entIds.add(truck.getEntId());
|
|
|
|
|
+ truckNos.add(truck.getTruckNo());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //企业数据集
|
|
|
|
|
+ entIds = entIds.stream().distinct().collect(Collectors.toList());
|
|
|
|
|
+ Map<Long, EntCacheResDto> ents = remoteSystemService.queryEntCacheMapByIds(entIds);
|
|
|
|
|
+ //车辆定位数据集
|
|
|
|
|
+ Map<String, KwfTruckGpsVo> truckGpsMap = findTruckLocateHandle(truckNos);
|
|
|
|
|
+
|
|
|
|
|
+ /**数据组装**/
|
|
|
|
|
+ for (KwfTruckMonitorVo truck:trucks) {
|
|
|
|
|
+ EntCacheResDto ent = ents == null ? null : ents.get(truck.getEntId());
|
|
|
|
|
+ KwfTruckGpsVo truckGps = truckGpsMap != null ? truckGpsMap.get(truck.getTruckNo()) : null;
|
|
|
|
|
+ truck.setFirmName(ent != null ? ent.getFirmName() : null);
|
|
|
|
|
+ truck.setRunStatus(truckGps != null ? truckGps.getRunStatus() : null);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return trucks;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @param params 参数
|
|
* @param params 参数
|
|
|
* @desc 校验车辆是否有证书
|
|
* @desc 校验车辆是否有证书
|
|
@@ -690,4 +733,113 @@ public class KwfTruckService {
|
|
|
}
|
|
}
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param truckNos 车牌号
|
|
|
|
|
+ * @desc 查询车辆定位数据
|
|
|
|
|
+ * @author zk
|
|
|
|
|
+ * @date 2023/9/5
|
|
|
|
|
+ **/
|
|
|
|
|
+ public Map<String, KwfTruckGpsVo> findTruckLocateHandle(List<String> truckNos){
|
|
|
|
|
+ /**车牌号超过100则分批次请求数据**/
|
|
|
|
|
+ int maxLimit = 100;
|
|
|
|
|
+ List<List<String>> truckNoList = new ArrayList<List<String>>();
|
|
|
|
|
+ List<String> findTruckSon = null;
|
|
|
|
|
+ for (int i = 0; i < truckNos.size(); i++) {
|
|
|
|
|
+ if (i % maxLimit == 0) {
|
|
|
|
|
+ findTruckSon = new ArrayList<String>();
|
|
|
|
|
+ truckNoList.add(findTruckSon);
|
|
|
|
|
+ }
|
|
|
|
|
+ findTruckSon.add(truckNos.get(i));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**获取数据**/
|
|
|
|
|
+ Map<String, KwfTruckGpsVo> truckGpsMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
|
|
|
|
|
+ for (List<String> turckNo:truckNoList) {
|
|
|
|
|
+ Map<String, KwfTruckGpsVo> truckGps = findTruckLocate(turckNo);
|
|
|
|
|
+ truckGpsMap.putAll(truckGps);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return truckGpsMap;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Value("${external.openapi.queryLocate}")
|
|
|
|
|
+ private String queryLocate;
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param truckNos 车牌号
|
|
|
|
|
+ * @desc 查询车辆定位数据
|
|
|
|
|
+ * @author zk
|
|
|
|
|
+ * @date 2023/9/5
|
|
|
|
|
+ **/
|
|
|
|
|
+ public Map<String, KwfTruckGpsVo> findTruckLocate(List<String> truckNos){
|
|
|
|
|
+ Map<String, KwfTruckGpsVo> truckGpsMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
|
|
|
|
|
+ if (truckNos == null || truckNos.size() == 0) {
|
|
|
|
|
+ return truckGpsMap;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ Map<String, Object> params = new HashMap<>(Global.NUMERICAL_SIXTEEN) {{
|
|
|
|
|
+ put("vehicleNoList", truckNos);
|
|
|
|
|
+ }};
|
|
|
|
|
+ String httpResult = HttpClientUtil.post(queryLocate, JSON.toJSONString(params));
|
|
|
|
|
+ if (StringUtils.isNotBlank(httpResult)) {
|
|
|
|
|
+ JSONObject result = JSONObject.parseObject(httpResult);
|
|
|
|
|
+ if (result.getInteger("code") != null && result.getInteger("code") != 200) {
|
|
|
|
|
+ return truckGpsMap;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ System.out.println(result);
|
|
|
|
|
+ }
|
|
|
|
|
+ JSONArray trucks = result.getJSONArray("data");
|
|
|
|
|
+ for (int i=0; trucks != null && i < trucks.size(); i++) {
|
|
|
|
|
+ JSONObject truck = trucks.getJSONObject(i);
|
|
|
|
|
+ JSONObject locateInfo = truck.getJSONObject("locateInfo");
|
|
|
|
|
+ KwfTruckGpsVo truckGps = new KwfTruckGpsVo();
|
|
|
|
|
+ truckGps.setTruckNo(truck.getString("vehicleNo"));
|
|
|
|
|
+ truckGps.setLat(locateInfo.getString("lng"));
|
|
|
|
|
+ truckGps.setLng(locateInfo.getString("vehicleNo"));
|
|
|
|
|
+ truckGps.setSpeed(locateInfo.getDouble("speed"));
|
|
|
|
|
+ truckGps.setGpsTime(locateInfo.getString("createTime"));
|
|
|
|
|
+ truckGps.setRunStatus(runStatus(truckGps.getGpsTime(), truckGps.getSpeed()));
|
|
|
|
|
+ truckGpsMap.put(truckGps.getTruckNo(), truckGps);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return truckGpsMap;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param gpsTimeStr 地位时间
|
|
|
|
|
+ * @param speed 速度
|
|
|
|
|
+ * @desc 校验当前车辆运行状态
|
|
|
|
|
+ * @author zk
|
|
|
|
|
+ * @date 2023/9/5
|
|
|
|
|
+ **/
|
|
|
|
|
+ public int runStatus(String gpsTimeStr, Double speed){
|
|
|
|
|
+ if (StringUtils.isBlank(gpsTimeStr)) {
|
|
|
|
|
+ return Global.NUMERICAL_TWO;
|
|
|
|
|
+ }
|
|
|
|
|
+ Date gpsTime = DateUtils.formatDate(gpsTimeStr);
|
|
|
|
|
+ if (gpsTime == null) {
|
|
|
|
|
+ return Global.NUMERICAL_TWO;
|
|
|
|
|
+ }
|
|
|
|
|
+ Date newTime = DateUtils.addDateMinutes(gpsTime, 15);
|
|
|
|
|
+ int compareTo = DateUtils.compareTo(newTime, new Date());
|
|
|
|
|
+ //-1 date1小于date2、0 date1等于date2、1 date1大于date2
|
|
|
|
|
+ //运行状态(0行驶、1停止、2离线)
|
|
|
|
|
+ return compareTo < 0 ? 2 : (speed == null || speed == 0) ? 1 : 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static void main(String[] args) {
|
|
|
|
|
+ String url = "http://10.10.10.224:27802/openapi/vehicleLocate/queryLocateByDesignatedTime";
|
|
|
|
|
+ Map<String, Object> params = new HashMap<>(Global.NUMERICAL_SIXTEEN){{put("vehicleNo", "川L01819D");}};
|
|
|
|
|
+ String result = HttpClientUtil.post(url, JSON.toJSONString(params));
|
|
|
|
|
+ System.out.println(result);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|