From b14531e3b850fe6d2fa916ba7b88b3e2bd2ff30a Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期三, 11 九月 2024 16:47:48 +0800
Subject: [PATCH] OSD加标签

---
 ycl-server/src/main/java/com/ycl/platform/service/impl/YwPointServiceImpl.java |  122 +++++++++++++++++++---------------------
 1 files changed, 58 insertions(+), 64 deletions(-)

diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/YwPointServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/YwPointServiceImpl.java
index d5c04a7..f2476f6 100644
--- a/ycl-server/src/main/java/com/ycl/platform/service/impl/YwPointServiceImpl.java
+++ b/ycl-server/src/main/java/com/ycl/platform/service/impl/YwPointServiceImpl.java
@@ -6,13 +6,18 @@
 import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ycl.dataListener.CurrencyDataListener;
+import com.ycl.platform.domain.entity.ReportAuditingRecord;
 import com.ycl.platform.domain.entity.YwPeople;
 import com.ycl.platform.domain.entity.YwPoint;
 import com.ycl.platform.domain.excel.PointExport;
 import com.ycl.platform.domain.form.BatchEditPointForm;
 import com.ycl.platform.domain.form.YwPointForm;
 import com.ycl.platform.domain.query.YwPointQuery;
+import com.ycl.platform.domain.result.BaseResult;
+import com.ycl.platform.domain.vo.CheckTagVO;
+import com.ycl.platform.domain.vo.ReportAuditingRecordVO;
 import com.ycl.platform.domain.vo.YwPointVO;
+import com.ycl.platform.mapper.TMonitorMapper;
 import com.ycl.platform.mapper.YwPeopleMapper;
 import com.ycl.platform.mapper.YwPointMapper;
 import com.ycl.platform.service.YwPointService;
@@ -30,6 +35,7 @@
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.Assert;
 import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.IOException;
@@ -49,16 +55,8 @@
 public class YwPointServiceImpl extends ServiceImpl<YwPointMapper, YwPoint> implements YwPointService {
 
     private final SysDeptMapper sysDeptMapper;
-    private final YwUnitService unitService;
-    private final YwPeopleMapper ywPeopleMapper;
+    private final TMonitorMapper monitorMapper;
 
-    private static final ExecutorService executorService = new ThreadPoolExecutor(8,
-            24,
-            5000,
-            TimeUnit.SECONDS,
-            new ArrayBlockingQueue<>(10),
-            new ThreadPoolExecutor.CallerRunsPolicy()
-    );
 
     /**
      * 娣诲姞
@@ -200,20 +198,8 @@
 
     @Override
     public Result select(String keyword) {
-        Long userId = SecurityUtils.getUserId();
-        // 鑾峰彇褰撳墠杩愮淮浜哄憳鐨勮繍缁村崟浣�
-        YwPeople people = new LambdaQueryChainWrapper<>(ywPeopleMapper)
-                .eq(YwPeople::getUserId, userId)
-                .one();
-        Integer unitId = null;
-        if (Objects.nonNull(people)) {
-            unitId = people.getBelongUnit();
-        }
-
-        List<YwPoint> list = new LambdaQueryChainWrapper<>(baseMapper)
-                .eq(YwPoint::getUnitId, unitId)
-                .like(YwPoint::getPointName, keyword)
-                .list();
+        Integer unitId = SecurityUtils.getUnitId();
+        List<YwPoint> list = baseMapper.select(keyword, unitId);
         List data = list.stream().map(item -> {
             Map map = new HashMap<String, Object>();
             map.put("id", item.getSerialNumber());
@@ -248,10 +234,10 @@
     }
 
     @Override
-    public Result importData(MultipartFile file, Integer unitId, Date startTime, Date endTime) throws IOException {
+    public Result importData(MultipartFile file, Integer unitId, Date startTime, Date endTime, Boolean needUpdateUnit) throws IOException {
         Consumer<List<PointExport>> consumer = (dataList) -> {
             try {
-                this.updatePoint(dataList, unitId, startTime, endTime);
+                this.updatePoint(dataList, unitId, startTime, endTime, needUpdateUnit);
             } catch (ExecutionException e) {
                 e.printStackTrace();
             } catch (InterruptedException e) {
@@ -262,6 +248,11 @@
         return Result.ok();
     }
 
+    @Override
+    public ReportAuditingRecordVO getReportResult(String serialNumber, String reportType) {
+        return baseMapper.getReportResult(serialNumber, reportType);
+    }
+
     /**
      * 淇敼鐐逛綅鐨勮繍缁村崟浣�
      *
@@ -269,7 +260,7 @@
      * @param unitId
      */
     @Transactional(rollbackFor = Exception.class)
-    public void updatePoint(List<PointExport> dataList, Integer unitId, Date startTime, Date endTime) throws ExecutionException, InterruptedException {
+    public void updatePoint(List<PointExport> dataList, Integer unitId, Date startTime, Date endTime, Boolean needUpdateUnit) throws ExecutionException, InterruptedException {
         if (CollectionUtils.isEmpty(dataList)) {
             throw new RuntimeException("瀵煎叆鏁版嵁涓嶈兘涓虹┖");
         }
@@ -277,62 +268,65 @@
             YwPoint point = new YwPoint();
             point.setImportantCommandImageTag("鏄�".equals(item.getImportantCommandImageTagString()));
             point.setProvinceTag("鏄�".equals(item.getProvinceTagString()));
-            if (Objects.nonNull(unitId)) {
-                point.setUnitId(Long.valueOf(unitId));
+            point.setDeptTag("鏄�".equals(item.getDeptTag()));
+            if (needUpdateUnit) {
+                if (Objects.nonNull(unitId)) {
+                    point.setUnitId(Long.valueOf(unitId));
+                }
+                point.setStartTime(startTime);
+                point.setEndTime(endTime);
+            } else {
+                point.setUnitId(null);
+                point.setStartTime(null);
+                point.setEndTime(null);
             }
-            point.setStartTime(startTime);
-            point.setEndTime(endTime);
+
             point.setPointName(item.getPointName());
             point.setSerialNumber(item.getSerialNumber());
             return point;
         }).collect(Collectors.toList());
         this.waitAllFinishAndGetResult(pointList);
-//        for (PointExport pointExport : dataList) {
-//            YwPoint point = new YwPoint();
-//            point.setImportantCommandImageTag("鏄�".equals(pointExport.getImportantCommandImageTagString()));
-//            point.setProvinceTag("鏄�".equals(pointExport.getProvinceTagString()));
-//            point.setUnitId(Long.valueOf(unitId));
-//            point.setStartTime(startTime);
-//            point.setEndTime(endTime);
-//            point.setPointName(pointExport.getPointName());
-//            point.setSerialNumber(pointExport.getSerialNumber());
-//            this.baseMapper.updatePoint(point);
-//        }
     }
 
     public void waitAllFinishAndGetResult(List<YwPoint> dataList) throws InterruptedException, ExecutionException {
-        List<FutureTask<Boolean>> resultList = new ArrayList<>(512);
-        List<Boolean> data = new ArrayList<>(512);
         int start = 0;
         Date startTime = new Date();
         while (true) {
-            if (dataList.size() < start + 50) {
+            if (dataList.size() < start + 800) {
                 List<YwPoint> list = dataList.subList(start, dataList.size() - 1);
-                Callable<Boolean> callable = new PointImportCallable(list, this.baseMapper);
-                FutureTask<Boolean> futureTask = new FutureTask(callable);
-                Thread thread = new Thread(futureTask);
-                thread.start();
-                // 涓嶈兘鐩存帴璋冪敤Future鐨刧et鏂规硶锛屽惁鍒欏氨鍙樻垚涓茶鎵ц浜嗭紝澶卞幓澶氱嚎绋嬫剰涔�
-                resultList.add(futureTask);
+                this.baseMapper.updatePoint(list);
                 break;
             } else {
-                List<YwPoint> list = dataList.subList(start, start + 50);
-                Callable<Boolean> callable = new PointImportCallable(list, this.baseMapper);
-                FutureTask<Boolean> futureTask = new FutureTask(callable);
-                Thread thread = new Thread(futureTask);
-                thread.start();
-                // 涓嶈兘鐩存帴璋冪敤Future鐨刧et鏂规硶锛屽惁鍒欏氨鍙樻垚涓茶鎵ц浜嗭紝澶卞幓澶氱嚎绋嬫剰涔�
-                resultList.add(futureTask);
-                start += 50;
+                List<YwPoint> list = dataList.subList(start, start + 800);
+                this.baseMapper.updatePoint(list);
+                start += 800;
             }
         }
-        for (FutureTask<Boolean> futureTask : resultList) {
-            data.add(futureTask.get());
-        }
         Date endTime = new Date();
-        log.error("鎬诲叡鑰楁椂锛�" + (endTime.getTime() - startTime.getTime()) / 1000);
-        if (data.stream().allMatch(item -> item == Boolean.TRUE)) {
-            System.out.println("鎵ц鎴愬姛");
+        log.error("鎬诲叡鑰楁椂锛�" + (endTime.getTime() - startTime.getTime()));
+    }
+
+    @Override
+    public <T extends BaseResult> void setDeviceTagByGB(List<T> dataList) {
+        List<String> gbList = dataList.stream().map(BaseResult::getNo).collect(Collectors.toList());
+        List<CheckTagVO> pointList = baseMapper.getTagsByGB(gbList);
+        Map<String, CheckTagVO> pointMap = pointList.stream().collect(Collectors.toMap(CheckTagVO::getNo, item -> item));
+        for (BaseResult data : dataList) {
+            CheckTagVO tag = pointMap.get(data.getNo());
+            if (Objects.nonNull(tag)) {
+                BeanUtils.copyProperties(tag, data);
+            }
+        }
+    }
+
+    @Override
+    public <T extends BaseResult> void setNew(List<T> dataList) {
+        List<String> gbList = dataList.stream().map(BaseResult::getNo).collect(Collectors.toList());
+        Map<String, BaseResult> pointMap = dataList.stream().collect(Collectors.toMap(BaseResult::getNo, item -> item));
+        List<String> dbGBList = monitorMapper.getGBbyGB(gbList);
+        for (String s : gbList) {
+            BaseResult baseResult = pointMap.get(s);
+            baseResult.setNewDevice(!dbGBList.contains(s));
         }
     }
 

--
Gitblit v1.8.0