燕山石化溯源三维电子沙盘-【后端】-服务
1
13693261870
2023-04-26 d254c34b538e190fd5a9355d757f64bd495bdda9
src/main/java/com/yssh/service/impl/SuYuanServiceImpl.java
@@ -1,5 +1,6 @@
package com.yssh.service.impl;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
@@ -39,38 +40,40 @@
public class SuYuanServiceImpl implements ISuYuanService {
   protected final Logger logger = LoggerFactory.getLogger(this.getClass());
   @Autowired
   private SuYuanMapper suYuanMapper;
   @Autowired
   private  IAsyncService asyncService;
   private IAsyncService asyncService;
   @Autowired
   private DictRecordMapper dictRecordMapper;
   @Autowired
   private ICommonService commonService;
   @Autowired
   private FeedbackMapper feedbackMapper;
   private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHH");
   //@Transactional
   @Override
   @Async("threadPoolTaskExecutor")
   public void insertSuYuanDatas(List<SuYuan> lists, String time) throws Exception{
   public void insertSuYuanDatas(List<SuYuan> lists, String time) throws Exception {
      //插入数据
      List<List<SuYuan>> list = Lists.partition(lists, IAsyncService.BATCH_INSERT_NUMBER);
      CountDownLatch countDownLatch = new CountDownLatch(list.size());
      for (List<SuYuan> corpReserveList : list) {
         asyncService.executeAsync(TableStrategy.getTableStrategy(time), corpReserveList, suYuanMapper, countDownLatch);
      }
      countDownLatch.await();
      countDownLatch.await();
      logger.info(lists.size() + "条数据入库完成-----");
   }
   @Override
   public Integer isTableExists(String tableName){
   public Integer isTableExists(String tableName) {
      return suYuanMapper.isTableExists(tableName);
   }
@@ -122,11 +125,15 @@
      }
      List<DistanceSuYuan> list = suYuanMapper.getDistanceSuYuan(dictRecord.getTableName(), ids3d);
      AtomicInteger i = new AtomicInteger(0);
      list.stream().forEach(s->{s.setName(checkPoint.getName());i.getAndIncrement();s.setVocsName(checkPoint.getName()+ "-" + i.longValue());});
      list.stream().forEach(s -> {
         s.setName(checkPoint.getName());
         i.getAndIncrement();
         s.setVocsName(checkPoint.getName() + "-" + i.longValue());
      });
      if (StringUtils.isNotEmpty(list)) {
         Collections.sort(list);
         DistanceSuYuan max = list.get(0);
         FeedbackDetail feedbackDetail = new FeedbackDetail(null, dictRecord.getTableName(),
         FeedbackDetail feedbackDetail = new FeedbackDetail(null, dictRecord.getTableName(),
               max.getName(), max.getId(), max.getVocsName(), max.getVocsValue(), null, null, null, DateUtils.getNowDate());
         feedbackMapper.insert(feedbackDetail);
         result.put("feedbackId", feedbackDetail.getId());
@@ -151,11 +158,15 @@
      }
      List<DistanceSuYuan> list = suYuanMapper.getDistanceSuYuan(dictRecord.getTableName(), ids3d);
      AtomicInteger i = new AtomicInteger(0);
      list.stream().forEach(s->{s.setName(checkPoint.getName());i.getAndIncrement();s.setVocsName(checkPoint.getName()+ "-" + i.longValue());});
      list.stream().forEach(s -> {
         s.setName(checkPoint.getName());
         i.getAndIncrement();
         s.setVocsName(checkPoint.getName() + "-" + i.longValue());
      });
      if (StringUtils.isNotEmpty(list)) {
         Collections.sort(list);
         DistanceSuYuan max = list.get(0);
         FeedbackDetail feedbackDetail = new FeedbackDetail(null, dictRecord.getTableName(),
         FeedbackDetail feedbackDetail = new FeedbackDetail(null, dictRecord.getTableName(),
               max.getName(), max.getId(), max.getVocsName(), max.getVocsValue(), null, null, null, DateUtils.getNowDate());
         feedbackMapper.insert(feedbackDetail);
         result.put("feedbackId", feedbackDetail.getId());
@@ -163,7 +174,7 @@
      result.put("data", list);
      return result;
   }
   @Override
   public Map<String, Object> selectSuYuan300(String name, Date date) {
      Map<String, Object> result = new HashMap<String, Object>();
@@ -180,11 +191,15 @@
      }
      List<DistanceSuYuan> list = suYuanMapper.getDistanceSuYuan(dictRecord.getTableName(), ids3d);
      AtomicInteger i = new AtomicInteger(0);
      list.stream().forEach(s->{s.setName(checkPoint.getName());i.getAndIncrement();s.setVocsName(checkPoint.getName()+ "-" + i.longValue());});
      list.stream().forEach(s -> {
         s.setName(checkPoint.getName());
         i.getAndIncrement();
         s.setVocsName(checkPoint.getName() + "-" + i.longValue());
      });
      if (StringUtils.isNotEmpty(list)) {
         Collections.sort(list);
         DistanceSuYuan max = list.get(0);
         FeedbackDetail feedbackDetail = new FeedbackDetail(null, dictRecord.getTableName(),
         FeedbackDetail feedbackDetail = new FeedbackDetail(null, dictRecord.getTableName(),
               max.getName(), max.getId(), max.getVocsName(), max.getVocsValue(), null, null, null, DateUtils.getNowDate());
         feedbackMapper.insert(feedbackDetail);
         result.put("feedbackId", feedbackDetail.getId());
@@ -192,7 +207,7 @@
      result.put("data", list);
      return result;
   }
   @Override
   public Map<String, Object> selectSuYuan500(String name, Date date) {
      Map<String, Object> result = new HashMap<String, Object>();
@@ -209,11 +224,15 @@
      }
      List<DistanceSuYuan> list = suYuanMapper.getDistanceSuYuan(dictRecord.getTableName(), ids3d);
      AtomicInteger i = new AtomicInteger(0);
      list.stream().forEach(s->{s.setName(checkPoint.getName());i.getAndIncrement();s.setVocsName(checkPoint.getName()+ "-" + i.longValue());});
      list.stream().forEach(s -> {
         s.setName(checkPoint.getName());
         i.getAndIncrement();
         s.setVocsName(checkPoint.getName() + "-" + i.longValue());
      });
      if (StringUtils.isNotEmpty(list)) {
         Collections.sort(list);
         DistanceSuYuan max = list.get(0);
         FeedbackDetail feedbackDetail = new FeedbackDetail(null, dictRecord.getTableName(),
         FeedbackDetail feedbackDetail = new FeedbackDetail(null, dictRecord.getTableName(),
               max.getName(), max.getId(), max.getVocsName(), max.getVocsValue(), null, null, null, DateUtils.getNowDate());
         feedbackMapper.insert(feedbackDetail);
         result.put("feedbackId", feedbackDetail.getId());
@@ -230,8 +249,19 @@
      }
      List<DictRecord> recordList = dictRecordMapper.selectDictRecordList(new DictRecord());
      List<String> tableNames = new ArrayList<String>();
      recordList.stream().forEach(s -> {tableNames.add(s.getTableName());});
      recordList.stream().forEach(s -> {
         tableNames.add(s.getTableName());
      });
      return suYuanMapper.getMonitorData(tableNames, checkPoint.getX() + "_" + checkPoint.getY() + "_" + checkPoint.getZ());
   }
   @Override
   public int updateVocsName(Date date, String id, String vocsName) {
      String table = "su_yuan_" + dateFormat.format(new Date());
      if (isTableExists(table) == 0) {
         return 0;
      }
      return suYuanMapper.updateVocsName(table, id, vocsName);
   }
}