From e30ffbcb28d5cf24a5cf11d7487b1f9a8d82540e Mon Sep 17 00:00:00 2001
From: tangzy <tangzy123456>
Date: Fri, 10 Dec 2021 17:24:56 +0800
Subject: [PATCH] 1.押运

---
 src/main/java/org/springblade/modules/equipage/controller/fixed.java |   69 ++++++++++++++++++----------------
 1 files changed, 37 insertions(+), 32 deletions(-)

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 74f46ea..4208321 100644
--- a/src/main/java/org/springblade/modules/equipage/controller/fixed.java
+++ b/src/main/java/org/springblade/modules/equipage/controller/fixed.java
@@ -107,7 +107,7 @@
 				status = liveLocationService.save(liveLocation);
 				//数据推送
 				String s1 =
-					"insert into sys_live_location(id,type,worker_id,longitude,latitude,record_time,location) " +
+					"insert into sys_live_location(id,type,worker_id,longitude,latitude,record_time) " +
 						"values(" + "'" + liveLocation.getId() + "'" + "," +
 						"'" + liveLocation.getType() + "'" + "," +
 						"'" + liveLocation.getWorkerId() + "'" + "," +
@@ -138,6 +138,7 @@
 	 */
 	@Scheduled(cron = "0 0 * * * ?")
 	public void Peog() throws Exception {
+		System.out.println("押运人员");
 		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);
@@ -163,36 +164,41 @@
 			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++) {
-				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 += ";";
-				}
+			if (track.equals("[]")){
+				System.out.println("数据为空");
 			}
-			FtpUtil.sqlFileUpload(s1);
+			else {
+				JSONArray jsonArray1 = JSONArray.fromObject(track);
+				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);
+			}
 		}
 	}
 
@@ -247,7 +253,7 @@
 					status = liveLocationService.save(liveLocation);
 					//数据推送
 					String s1 =
-						"insert into sys_live_location(id,type,worker_id,longitude,latitude,record_time,location) " +
+						"insert into sys_live_location(id,type,worker_id,longitude,latitude,record_time) " +
 							"values(" + "'" + liveLocation.getId() + "'" + "," +
 							"'" + liveLocation.getType() + "'" + "," +
 							"'" + liveLocation.getWorkerId() + "'" + "," +
@@ -292,7 +298,6 @@
 	 */
 	@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);

--
Gitblit v1.9.3