From a0a32e1315605772dcd8d311bac92c016f4ab3ff Mon Sep 17 00:00:00 2001
From: tangzy <tangzy123456>
Date: Wed, 08 Dec 2021 10:39:05 +0800
Subject: [PATCH] 1.押运
---
src/main/java/org/springblade/common/config/BladeConfiguration.java | 2
src/main/java/org/springblade/modules/location/controller/LocusController.java | 193 ++++++++++++++++++++-----------------
src/main/java/org/springblade/modules/equipage/controller/fixed.java | 62 ++++++------
3 files changed, 137 insertions(+), 120 deletions(-)
diff --git a/src/main/java/org/springblade/common/config/BladeConfiguration.java b/src/main/java/org/springblade/common/config/BladeConfiguration.java
index 454aa51..0be1470 100644
--- a/src/main/java/org/springblade/common/config/BladeConfiguration.java
+++ b/src/main/java/org/springblade/common/config/BladeConfiguration.java
@@ -39,6 +39,7 @@
SecureRegistry secureRegistry = new SecureRegistry();
secureRegistry.setEnabled(true);
secureRegistry.excludePathPatterns("/blade-auth/**");
+ secureRegistry.excludePathPatterns("/blade-user/**");
secureRegistry.excludePathPatterns("/blade-system/menu/routes");
secureRegistry.excludePathPatterns("/blade-system/menu/auth-routes");
secureRegistry.excludePathPatterns("/blade-system/menu/top-menu");
@@ -84,6 +85,7 @@
secureRegistry.excludePathPatterns("/zc/**");
secureRegistry.excludePathPatterns("/licet/**");
secureRegistry.excludePathPatterns("/licetuser/**");
+ secureRegistry.excludePathPatterns("/locus/**");
return secureRegistry;
}
diff --git a/src/main/java/org/springblade/modules/equipage/controller/fixed.java b/src/main/java/org/springblade/modules/equipage/controller/fixed.java
index 3265431..74f46ea 100644
--- a/src/main/java/org/springblade/modules/equipage/controller/fixed.java
+++ b/src/main/java/org/springblade/modules/equipage/controller/fixed.java
@@ -44,9 +44,9 @@
* @return
* @throws Exception
*/
- //@Scheduled(cron = "0 */1 * * * ?")
+ @Scheduled(cron = "0 */5 * * * ?")
public void Peo() throws Exception {
- String url = "http://223.82.109.183:2080/Escort/getgis.php";
+ String url = "http://47.104.104.46/api/client/getgis.php";
//查询有押运人员的数据
List<Map<String, Object>> list = userService.selectEquipent();
for (int i = 0; i < list.size(); i++) {
@@ -113,8 +113,7 @@
"'" + liveLocation.getWorkerId() + "'" + "," +
"'" + liveLocation.getLongitude() + "'" + "," +
"'" + liveLocation.getLatitude() + "'" + "," +
- "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(liveLocation.getRecordTime()) + "'" + "," +
- "'" + liveLocation.getLocation() + "'" + ")";
+ "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(liveLocation.getRecordTime()) + "'" + ")";
FtpUtil.sqlFileUpload(s1);
} else {
status = liveLocationService.updateById(liveLocationInfo);
@@ -125,7 +124,6 @@
",longitude = " + "'" + liveLocationInfo.getLongitude() + "'" +
",latitude = " + "'" + liveLocationInfo.getLatitude() + "'" +
",record_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(liveLocationInfo.getRecordTime()) + "'" +
- ",location = " + "'" + liveLocationInfo.getLocation() + "'" +
" " + "where id = " + "'" + liveLocationInfo.getId() + "'";
FtpUtil.sqlFileUpload(s1);
}
@@ -138,12 +136,12 @@
* @return
* @throws Exception
*/
- //@Scheduled(cron = "0 */1 * * * ?")
+ @Scheduled(cron = "0 0 * * * ?")
public void Peog() throws Exception {
String url = "http://47.104.104.46/api/client/getgistrack.php";
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, calendar.get(Calendar.HOUR_OF_DAY) - 1);
- SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:00:00");
//查询有押运人员的数据
List<Map<String, Object>> list = userService.selectEquipent();
for (int i = 0; i < list.size(); i++) {
@@ -156,13 +154,14 @@
String equipmentCode = list.get(i).get("code").toString();
//设备imei号
params.put("number", 7730);
- params.put("acc", 7731);
+ params.put("acc", equipmentCode);
params.put("startTime", df.format(calendar.getTime()));
params.put("endTime", df.format(new Date()));
String res = null;
res = HttpReqUtil.getInstance().doPost(url, params, null);
- String a="["+res+"]";
+ String a = "[" + res + "]";
JSONArray jsonArray = JSONArray.fromObject(a);
+ String s1 = "";
String track = jsonArray.getJSONObject(0).get("track").toString();
JSONArray jsonArray1 = JSONArray.fromObject(track);
for (int j = 0; j < jsonArray1.size(); j++) {
@@ -181,16 +180,19 @@
locus.setLongitude(gis_jd);
locus.setLatitude(gis_wd);
locusService.save(locus);
-// //数据推送
-// String s1 = "insert into sys_locus(id,type,worker_id,longitude,latitude,record_time) " +
-// "values(" + "'" + locus.getId() + "'" + "," +
-// "'" + locus.getType() + "'" + "," +
-// "'" + locus.getWorkerId() + "'" + "," +
-// "'" + locus.getLongitude() + "'" + "," +
-// "'" + locus.getLatitude() + "'" + "," +
-// "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(locus.getRecordTime()) + "'" + ")";
-// FtpUtil.sqlFileUpload(s1);
+ //数据推送
+ s1 += "insert into sys_locus(id,type,worker_id,longitude,latitude,record_time) values" +
+ " (" + "'" + locus.getId() + "'" + "," +
+ "'" + locus.getType() + "'" + "," +
+ "'" + locus.getWorkerId() + "'" + "," +
+ "'" + locus.getLongitude() + "'" + "," +
+ "'" + locus.getLatitude() + "'" + "," +
+ "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(locus.getRecordTime()) + "'" + ")";
+ if (j != jsonArray1.size() - 1) {
+ s1 += ";";
+ }
}
+ FtpUtil.sqlFileUpload(s1);
}
}
@@ -198,7 +200,7 @@
/**
* 车辆实时位置
*/
- //@Scheduled(cron = "0 */1 * * * ?")
+ @Scheduled(cron = "0 */5 * * * ?")
public void locationcar() {
String url = "http://dvopenapi.aimap.net.cn/openapi/device/location";
String res = null;
@@ -251,20 +253,18 @@
"'" + liveLocation.getWorkerId() + "'" + "," +
"'" + liveLocation.getLongitude() + "'" + "," +
"'" + liveLocation.getLatitude() + "'" + "," +
- "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(liveLocation.getRecordTime()) + "'" + "," +
- "'" + liveLocation.getLocation() + "'" + ")";
+ "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(liveLocation.getRecordTime()) + "'" + ")";
FtpUtil.sqlFileUpload(s1);
} else {
status = liveLocationService.updateById(liveLocationInfo);
//内网同步
String s1 =
- "update sys_live_location set type = " + "'" + liveLocation.getType() + "'" +
- ",worker_id = " + "'" + liveLocation.getWorkerId() + "'" +
- ",longitude = " + "'" + liveLocation.getLongitude() + "'" +
- ",latitude = " + "'" + liveLocation.getLatitude() + "'" +
- ",record_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(liveLocation.getRecordTime()) + "'" +
- ",location = " + "'" + liveLocation.getLocation() + "'" +
- " " + "where id = " + "'" + liveLocation.getId() + "'";
+ "update sys_live_location set type = " + "'" + liveLocationInfo.getType() + "'" +
+ ",worker_id = " + "'" + liveLocationInfo.getWorkerId() + "'" +
+ ",longitude = " + "'" + liveLocationInfo.getLongitude() + "'" +
+ ",latitude = " + "'" + liveLocationInfo.getLatitude() + "'" +
+ ",record_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(liveLocationInfo.getRecordTime()) + "'" +
+ " " + "where id = " + "'" + liveLocationInfo.getId() + "'";
FtpUtil.sqlFileUpload(s1);
}
} catch (Exception e) {
@@ -290,8 +290,9 @@
/**
* 查询车辆轨迹
*/
- //@Scheduled(cron = "0 */1 * * * ?")
+ @Scheduled(cron = "0 0 * * * ?")
public void locationhistoryTrack() {
+ System.out.println("车辆轨迹");
Calendar calendar = Calendar.getInstance();
/* HOUR_OF_DAY 指示一天中的小时 */
calendar.set(Calendar.HOUR_OF_DAY, calendar.get(Calendar.HOUR_OF_DAY) - 1);
@@ -305,7 +306,7 @@
params.put("beginTime", df.format(calendar.getTime()));
params.put("endTime", df.format(new Date()));
params.put("rectify", 0);
- params.put("callbackUrl", "http://2h3f861221.wicp.vip/locus/SaveUrl");
+ params.put("callbackUrl", "http://223.82.109.183:2080/api/locus/SaveUrl");
params.put("callbackId", maps.get(i).get("carnumber").toString());
params.put("appId", "PO00000761");
params.put("timestamp", System.currentTimeMillis());
@@ -325,6 +326,5 @@
}
}
-
}
diff --git a/src/main/java/org/springblade/modules/location/controller/LocusController.java b/src/main/java/org/springblade/modules/location/controller/LocusController.java
index 42b9194..9077d20 100644
--- a/src/main/java/org/springblade/modules/location/controller/LocusController.java
+++ b/src/main/java/org/springblade/modules/location/controller/LocusController.java
@@ -37,6 +37,8 @@
import java.util.*;
import java.util.List;
+import static org.springblade.common.config.FtpConfig.localPath;
+
/**
* @author zhongrj
* @time 2021-07-06
@@ -161,18 +163,18 @@
@ApiOperation(value = "详情", notes = "传入car")
public void SaveUrl(String callbackId, String fileUrl) throws Exception {
DowloadZipUtil dowloadZipUtil = new DowloadZipUtil();
- File file = dowloadZipUtil.downloadFile(fileUrl, "D:\\caiji");
+ File file = dowloadZipUtil.downloadFile(fileUrl, "/usr/local/nginx/dist/enterprises/car");
//文件名
String name = file.getName();
String substring = name.substring(0, name.length() - 4);
//解压数据
FileZip fileZip = new FileZip();
- fileZip.ZipUncompress("D:\\caiji\\" + substring + ".zip", "D:\\caiji");
+ fileZip.ZipUncompress("/usr/local/nginx/dist/enterprises/car/" + substring + ".zip", "/usr/local/nginx/dist/enterprises/car");
try {
// 用来保存数据
ArrayList<String[]> csvFileList = new ArrayList<String[]>();
// 定义一个CSV路径
- String csvFilePath = "D:\\caiji\\" + substring + ".csv";
+ String csvFilePath = "/usr/local/nginx/dist/enterprises/car/" + substring + ".csv";
// 创建CSV读对象 例如:CsvReader(文件路径,分隔符,编码格式);
CsvReader reader = new CsvReader(csvFilePath, ',', Charset.forName("UTF-8"));
// 跳过表头 如果需要表头的话,这句可以忽略
@@ -184,33 +186,37 @@
reader.close();
Locus locus = new Locus();
String s1 = "";
- //遍历读取的CSV文件
- for (int row = 0; row < csvFileList.size(); row++) {
- // 取得第row行第0列的数据
- String cell = csvFileList.get(row)[0];
- String cell1 = csvFileList.get(row)[1];
- String cell2 = csvFileList.get(row)[2];
- Date date = timeStamp2Date(cell2);
- locus.setType(2);
- locus.setLongitude(cell);
- locus.setLatitude(cell1);
- locus.setRecordTime(date);
- locus.setWorkerId(callbackId);
- locusService.save(locus);
- //数据推送
- s1 +=
- "insert into sys_locus(id,type,worker_id,longitude,latitude,record_time) " +
- "values(" + "'" + locus.getId() + "'" + "," +
- "'" + locus.getType() + "'" + "," +
- "'" + locus.getWorkerId() + "'" + "," +
- "'" + locus.getLongitude() + "'" + "," +
- "'" + locus.getLatitude() + "'" + "," +
- "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(locus.getRecordTime()) + "'" + ")";
- if (row != csvFileList.size() - 1) {
- s1 += ";";
+ if(csvFileList.size()!=0){
+ //遍历读取的CSV文件
+ for (int row = 0; row < csvFileList.size(); row++) {
+ // 取得第row行第0列的数据
+ String cell = csvFileList.get(row)[0];
+ String cell1 = csvFileList.get(row)[1];
+ String cell2 = csvFileList.get(row)[2];
+ Date date = timeStamp2Date(cell2);
+ locus.setType(2);
+ locus.setLongitude(cell);
+ locus.setLatitude(cell1);
+ locus.setRecordTime(date);
+ locus.setWorkerId(callbackId);
+ locusService.save(locus);
+ //数据推送
+ s1 +=
+ "insert into sys_locus(id,type,worker_id,longitude,latitude,record_time) " +
+ "values(" + "'" + locus.getId() + "'" + "," +
+ "'" + locus.getType() + "'" + "," +
+ "'" + locus.getWorkerId() + "'" + "," +
+ "'" + locus.getLongitude() + "'" + "," +
+ "'" + locus.getLatitude() + "'" + "," +
+ "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(locus.getRecordTime()) + "'" + ")";
+ if (row != csvFileList.size() - 1) {
+ s1 += ";";
+ }
}
+ FtpUtil.sqlFileUpload(s1);
+ deletescsv(substring);
}
- FtpUtil.sqlFileUpload(s1);
+ deletescsv(substring);
} catch (IOException e) {
e.printStackTrace();
}
@@ -230,68 +236,77 @@
}
- @PostMapping("/ss")
- public void Peog() throws Exception {
- String url = "http://47.104.104.46/api/client/getgistrack.php";
- Calendar calendar = Calendar.getInstance();
- calendar.set(Calendar.HOUR_OF_DAY, calendar.get(Calendar.HOUR_OF_DAY) - 1);
- SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:00:00");
- //查询有押运人员的数据
- List<Map<String, Object>> list = userService.selectEquipent();
- for (int i = 0; i < list.size(); i++) {
- //实时位置实体类
- Locus locus = new Locus();
- locus.setType(1);
- String id = list.get(i).get("id").toString();
- locus.setWorkerId(id);
- Map<String, Object> params = new HashMap<>();
- String equipmentCode = list.get(i).get("code").toString();
- //设备imei号
- params.put("number", 7730);
- params.put("acc", equipmentCode);
- params.put("startTime", "2021-06-01");
- params.put("endTime", "2021-08-01");
- String res = null;
- res = HttpReqUtil.getInstance().doPost(url, params, null);
- String a = "[" + res + "]";
- JSONArray jsonArray = JSONArray.fromObject(a);
- String track = jsonArray.getJSONObject(0).get("track").toString();
- JSONArray jsonArray1 = JSONArray.fromObject(track);
- String s1 = "";
- String sql="insert into sys_locus(id,type,worker_id,longitude,latitude,record_time) values ";
- for (int j = 0; j < jsonArray1.size(); j++) {
- String gis_jd = jsonArray1.getJSONObject(j).get("gis_jd").toString();
- String gis_wd = jsonArray1.getJSONObject(j).get("gis_wd").toString();
- String date = jsonArray1.getJSONObject(j).get("date").toString();
- SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- try {
- //使用SimpleDateFormat的parse()方法生成Date
- Date dates = sf.parse(date);
- locus.setRecordTime(dates);
- //打印Date
- } catch (ParseException e) {
- e.printStackTrace();
- }
- locus.setLongitude(gis_jd);
- locus.setLatitude(gis_wd);
- locusService.save(locus);
- //数据推送
- s1 += "(" + "'" + locus.getId() + "'" + "," +
- "'" + locus.getType() + "'" + "," +
- "'" + locus.getWorkerId() + "'" + "," +
- "'" + locus.getLongitude() + "'" + "," +
- "'" + locus.getLatitude() + "'" + "," +
- "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(locus.getRecordTime()) + "'" + ")";
- if (j != jsonArray1.size() - 1) {
- s1 += ",";
- }
- else {
- s1+=";";
- }
- }
- String c = "a" +sql+ s1;
- FtpUtil.sqlFileUpload(c);
+// @PostMapping("/ss")
+// public void Peog() throws Exception {
+// String url = "http://47.104.104.46/api/client/getgistrack.php";
+// Calendar calendar = Calendar.getInstance();
+// calendar.set(Calendar.HOUR_OF_DAY, calendar.get(Calendar.HOUR_OF_DAY) - 1);
+// SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:00:00");
+// //查询有押运人员的数据
+// List<Map<String, Object>> list = userService.selectEquipent();
+// for (int i = 0; i < list.size(); i++) {
+// //实时位置实体类
+// Locus locus = new Locus();
+// locus.setType(1);
+// String id = list.get(i).get("id").toString();
+// locus.setWorkerId(id);
+// Map<String, Object> params = new HashMap<>();
+// String equipmentCode = list.get(i).get("code").toString();
+// //设备imei号
+// params.put("number", 7730);
+// params.put("acc", equipmentCode);
+// params.put("startTime", "2021-12-01");
+// params.put("endTime", "2021-12-02");
+// String res = null;
+// res = HttpReqUtil.getInstance().doPost(url, params, null);
+// String a = "[" + res + "]";
+// JSONArray jsonArray = JSONArray.fromObject(a);
+// String track = jsonArray.getJSONObject(0).get("track").toString();
+// JSONArray jsonArray1 = JSONArray.fromObject(track);
+// String s1 = "";
+// for (int j = 0; j < jsonArray1.size(); j++) {
+// String gis_jd = jsonArray1.getJSONObject(j).get("gis_jd").toString();
+// String gis_wd = jsonArray1.getJSONObject(j).get("gis_wd").toString();
+// String date = jsonArray1.getJSONObject(j).get("date").toString();
+// SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+// try {
+// //使用SimpleDateFormat的parse()方法生成Date
+// Date dates = sf.parse(date);
+// locus.setRecordTime(dates);
+// //打印Date
+// } catch (ParseException e) {
+// e.printStackTrace();
+// }
+// locus.setLongitude(gis_jd);
+// locus.setLatitude(gis_wd);
+// locusService.save(locus);
+// //数据推送
+// s1 += "insert into sys_locus(id,type,worker_id,longitude,latitude,record_time) values" +
+// " (" + "'" + locus.getId() + "'" + "," +
+// "'" + locus.getType() + "'" + "," +
+// "'" + locus.getWorkerId() + "'" + "," +
+// "'" + locus.getLongitude() + "'" + "," +
+// "'" + locus.getLatitude() + "'" + "," +
+// "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(locus.getRecordTime()) + "'" + ")";
+// if (j != jsonArray1.size() - 1) {
+// s1 += ";";
+// }
+// }
+// FtpUtil.sqlFileUpload(s1);
+// }
+// }
+
+
+ /**
+ * 删除本地csv文件
+ * @param fileName
+ */
+ public static void deletescsv(String fileName){
+ File file = new File("D:\\caiji\\"+fileName+".csv");
+ if (file.isFile() && file.exists()) {
+ file.delete();
}
}
+
}
--
Gitblit v1.9.3