燕山石化溯源三维电子沙盘-【后端】-服务
1
13693261870
2023-07-05 2b8df9f5452218cad1f012a008acea724de81fff
src/main/java/com/yssh/service/impl/SuYuanServiceImpl.java
@@ -1,27 +1,18 @@
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 com.yssh.dao.QxshMapper;
import com.yssh.dao.*;
import com.yssh.entity.*;
import com.yssh.utils.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import com.google.common.collect.Lists;
import com.yssh.dao.DictRecordMapper;
import com.yssh.dao.FeedbackMapper;
import com.yssh.dao.SuYuanMapper;
import com.yssh.service.IAsyncService;
import com.yssh.service.ICommonService;
import com.yssh.service.ISuYuanService;
@@ -30,8 +21,7 @@
@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;
@@ -51,12 +41,13 @@
   @Resource
   private QxshMapper qxshMapper;
   private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHH");
   @Resource
   private LocationMapper locationMapper;
   //@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());
@@ -65,6 +56,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
@@ -243,7 +244,7 @@
         return null;
      }
      List<DictRecord> recordList = dictRecordMapper.selectDictRecordList(new DictRecord());
      /*List<DictRecord> recordList = dictRecordMapper.selectDictRecordList(new DictRecord());
      List<String> tableNames = new ArrayList<String>();
      for (DictRecord dr : recordList) {
@@ -252,12 +253,22 @@
         }
      }
      return suYuanMapper.getMonitorData(tableNames, checkPoint.getX() + "_" + checkPoint.getY() + "_" + checkPoint.getZ());
      return suYuanMapper.getMonitorData(tableNames, checkPoint.getX() + "_" + checkPoint.getY() + "_" + checkPoint.getZ());*/
      Calendar calendar = Calendar.getInstance();
      calendar.set(Calendar.HOUR_OF_DAY, 23);
      String end = DateUtils.getYyyyMmDdHh(calendar.getTime()); //dateFormat.format(calendar.getTime());
      calendar.set(Calendar.HOUR_OF_DAY, 0);
      calendar.add(Calendar.DATE, -7);
      String start = DateUtils.getYyyyMmDdHh(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(date); // new Date()
      String table = "su_yuan_" + DateUtils.getYyyyMmDdHh(date); // new Date()
      if (isTableExists(table) == 0) {
         return 0;
      }
@@ -268,8 +279,37 @@
   @Override
   public List<Qxsh> queryQxsh(Date date) {
      String time = dateFormat.format(date);
      String time = DateUtils.getYyyyMmDdHh(date);
      return qxshMapper.selectByTime(time);
   }
   @Override
   public List<List<Coordinate>> selectRects(Double[] x, Double[] y) {
      List<List<Coordinate>> list = new ArrayList<>();
      for (int i = 0; i < x.length; i++) {
         list.add(CalculateUtils.calcRect(x[i], y[i]));
      }
      return list;
   }
   @Override
   public SuYuan700 selectSuYuan700ById(String id, Date date) {
      id = id.substring(0, id.lastIndexOf("_") + 1) + "0";
      String time = DateUtils.getYyyyMmDdHhMmSs(date).substring(0, 13) + ":00:00";
      return suYuanMapper.selectSuYuan700ById(id, time);
   }
   @Override
   public String selectAddrByXY(double x, double y) {
      List<Location> locations = locationMapper.selectByXY(x, y);
      if (null != locations && locations.size() > 0) {
         return locations.get(0).getName();
      }
      return null;
   }
}