From aa86cb57b09c5300db3c33d75d91d8b51a4b636f Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期五, 16 六月 2023 09:27:45 +0800
Subject: [PATCH] 1

---
 src/main/java/com/yssh/service/impl/SuYuanServiceImpl.java |   82 +++++++++++++++++++++++++----------------
 1 files changed, 50 insertions(+), 32 deletions(-)

diff --git a/src/main/java/com/yssh/service/impl/SuYuanServiceImpl.java b/src/main/java/com/yssh/service/impl/SuYuanServiceImpl.java
index 8e57d66..37e65d5 100644
--- a/src/main/java/com/yssh/service/impl/SuYuanServiceImpl.java
+++ b/src/main/java/com/yssh/service/impl/SuYuanServiceImpl.java
@@ -1,20 +1,15 @@
 package com.yssh.service.impl;
 
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import com.yssh.dao.QxshMapper;
+import com.yssh.entity.*;
+import com.yssh.utils.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 
@@ -22,28 +17,15 @@
 import com.yssh.dao.DictRecordMapper;
 import com.yssh.dao.FeedbackMapper;
 import com.yssh.dao.SuYuanMapper;
-import com.yssh.entity.DictRecord;
-import com.yssh.entity.DistanceSuYuan;
-import com.yssh.entity.FeedbackDetail;
-import com.yssh.entity.MonitorPointPosition;
-import com.yssh.entity.SuYuan;
-import com.yssh.entity.SuYuan2d;
-import com.yssh.entity.SuYuan3d;
-import com.yssh.entity.SuYuanMonitorData;
 import com.yssh.service.IAsyncService;
 import com.yssh.service.ICommonService;
 import com.yssh.service.ISuYuanService;
-import com.yssh.utils.CalculateUtils;
-import com.yssh.utils.DateUtils;
-import com.yssh.utils.StringUtils;
-import com.yssh.utils.TableStrategy;
 
 import javax.annotation.Resource;
 
 @Service
 public class SuYuanServiceImpl implements ISuYuanService {
-
-	protected final Log logger = LogFactory.getLog(this.getClass());
+	protected final Logger logger = LoggerFactory.getLogger(this.getClass());
 
 	@Resource
 	private SuYuanMapper suYuanMapper;
@@ -60,12 +42,15 @@
 	@Resource
 	private FeedbackMapper feedbackMapper;
 
+	@Resource
+	private QxshMapper qxshMapper;
+
 	private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHH");
 
 	//@Transactional
-	@Override
+	//@Override
 	@Async("threadPoolTaskExecutor")
-	public void insertSuYuanDatas(List<SuYuan> lists, String time) throws Exception {
+	public void insertSuYuanDatasAsync(List<SuYuan> lists, String time) throws Exception {
 		//鎻掑叆鏁版嵁
 		List<List<SuYuan>> list = Lists.partition(lists, IAsyncService.BATCH_INSERT_NUMBER);
 		CountDownLatch countDownLatch = new CountDownLatch(list.size());
@@ -74,6 +59,16 @@
 		}
 		countDownLatch.await();
 		logger.info(lists.size() + "鏉℃暟鎹叆搴撳畬鎴�-----");
+	}
+
+	@Override
+	public void insertSuYuanDatas(List<SuYuan> lists, String time) {
+		List<List<SuYuan>> subLists = Lists.partition(lists, IAsyncService.BATCH_INSERT_NUMBER);
+		for (List<SuYuan> sub : subLists) {
+			suYuanMapper.batchInsert(TableStrategy.getTableStrategy(time), sub);
+		}
+
+		logger.info("------ " + time + ".csv锛�" + lists.size() + " 鏉℃暟鎹凡鍏ュ簱 ------");
 	}
 
 	@Override
@@ -251,21 +246,44 @@
 		if (StringUtils.isNull(checkPoint)) {
 			return null;
 		}
-		List<DictRecord> recordList = dictRecordMapper.selectDictRecordList(new DictRecord());
+
+		/*List<DictRecord> recordList = dictRecordMapper.selectDictRecordList(new DictRecord());
+
 		List<String> tableNames = new ArrayList<String>();
-		recordList.stream().forEach(s -> {
-			tableNames.add(s.getTableName());
-		});
-		return suYuanMapper.getMonitorData(tableNames, checkPoint.getX() + "_" + checkPoint.getY() + "_" + checkPoint.getZ());
+		for (DictRecord dr : recordList) {
+			if (suYuanMapper.isTableExists(dr.getTableName()) > 0) {
+				tableNames.add(dr.getTableName());
+			}
+		}
+
+		return suYuanMapper.getMonitorData(tableNames, checkPoint.getX() + "_" + checkPoint.getY() + "_" + checkPoint.getZ());*/
+
+		Calendar calendar = Calendar.getInstance();
+		calendar.set(Calendar.HOUR_OF_DAY, 23);
+		String end = dateFormat.format(calendar.getTime());
+
+		calendar.set(Calendar.HOUR_OF_DAY, 0);
+		calendar.add(Calendar.DATE, -7);
+		String start = dateFormat.format(calendar.getTime());
+
+		return suYuanMapper.getNewMonitorData(checkPoint.getName(), start, end);
 	}
 
 	@Override
 	public int updateVocsName(Date date, String id, String vocsName) {
-		String table = "su_yuan_" + dateFormat.format(new Date());
+		String table = "su_yuan_" + dateFormat.format(date); // new Date()
 		if (isTableExists(table) == 0) {
 			return 0;
 		}
 
-		return suYuanMapper.updateVocsName(table, id, vocsName);
+		//return suYuanMapper.updateVocsName(table, id, vocsName);
+		return 1;
+	}
+
+	@Override
+	public List<Qxsh> queryQxsh(Date date) {
+		String time = dateFormat.format(date);
+
+		return qxshMapper.selectByTime(time);
 	}
 }

--
Gitblit v1.9.3