فهرست منبع

Merge branch 'master' of http://124.70.43.205:3000/xieshengjie/sis-background

chenminghua 2 سال پیش
والد
کامیت
441473a3b1

+ 18 - 0
gyee-sample-impala/src/main/java/com/gyee/impala/common/spring/InitialRunner.java

@@ -3,8 +3,10 @@ package com.gyee.impala.common.spring;
 
 import com.gyee.impala.model.master.*;
 import com.gyee.impala.model.master.diagnose.Diagnosepoint;
+import com.gyee.impala.model.master.diagnose.Diagnosetrainhistory;
 import com.gyee.impala.service.master.*;
 import com.gyee.impala.service.master.diagnose.DiagnosepointService;
+import com.gyee.impala.service.master.diagnose.DiagnosetrainhistoryService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.CommandLineRunner;
 import org.springframework.core.annotation.Order;
@@ -31,6 +33,8 @@ public class InitialRunner implements CommandLineRunner {
     private EquipmentmodelService modelService;
     @Autowired
     private DiagnosepointService diagnosepointService;
+    @Autowired
+    private DiagnosetrainhistoryService diagnosetrainhistoryService;
 
     /**场站所有信息**/
     public static List<Windpowerstation> wpList = new ArrayList<>();
@@ -58,6 +62,11 @@ public class InitialRunner implements CommandLineRunner {
     /** 故障诊断 训练需要的测点**/
     public static Map<String, Map<String, List<Diagnosepoint>>> mapPoint = new HashMap<>();
 
+    /*** 故障训练历史模型 */
+    public static Map<String, List<Diagnosetrainhistory>> historyModelMap = new HashMap<>();
+    public static List<Diagnosetrainhistory> historyList = new ArrayList<>();
+
+
 
     @Override
     public void run(String... args){
@@ -67,6 +76,7 @@ public class InitialRunner implements CommandLineRunner {
         cacheKnowCategory();
         cacheEquipmentModel();
         cacheDiagnosePoint();
+        cacheHistory();
 
         System.out.println(">>>>>>>>>>>>>>>数据缓存完成<<<<<<<<<<<<<<");
     }
@@ -132,4 +142,12 @@ public class InitialRunner implements CommandLineRunner {
         List<Diagnosepoint> points = diagnosepointService.getDiagnosepointList();
         mapPoint = points.stream().collect(Collectors.groupingBy(Diagnosepoint::getStationen, Collectors.groupingBy(Diagnosepoint::getModel)));
     }
+
+    public void cacheHistory(){
+        historyModelMap.clear();
+        historyList.clear();
+        List<Diagnosetrainhistory> historyList = diagnosetrainhistoryService.getListAll();
+        historyModelMap = historyList.stream().collect(Collectors.groupingBy(Diagnosetrainhistory::getModel));
+
+    }
 }

+ 17 - 2
gyee-sample-impala/src/main/java/com/gyee/impala/service/impl/master/diagnose/DiagnosetrainhistoryServiceImpl.java

@@ -30,6 +30,7 @@ public class DiagnosetrainhistoryServiceImpl extends ServiceImpl<Diagnosetrainhi
     @Autowired
     private InitialRunner initialRunner;
 
+
     @Override
     public List<Diagnosetrainhistory> getAll( AlgorithmType type) {
         ExcludeQueryWrapper<Diagnosetrainhistory> wrapper = new ExcludeQueryWrapper<>();
@@ -46,6 +47,7 @@ public class DiagnosetrainhistoryServiceImpl extends ServiceImpl<Diagnosetrainhi
     public void insertItem(Diagnosetrainhistory obj) {
         try{
             insert(obj);
+            initialRunner.cacheHistory();
         } catch (Exception e) {
             log.error(e.getMessage());
             throw new CustomException(ResultCode.ERROR_DATA);
@@ -65,6 +67,7 @@ public class DiagnosetrainhistoryServiceImpl extends ServiceImpl<Diagnosetrainhi
         wrapper.eq("id",id);
         try {
             baseMapper.delete(wrapper);
+            initialRunner.cacheHistory();
         } catch (CustomException e) {
             log.error(e.getMessage());
             throw new CustomException(ResultCode.ERROR_DATA);
@@ -87,15 +90,21 @@ public class DiagnosetrainhistoryServiceImpl extends ServiceImpl<Diagnosetrainhi
     @Override
     public void editDiagnosetrainhistory(Diagnosetrainhistory history) {
         try {
-            List<Diagnosetrainhistory> historyByModel = getHistoryByModel(history.getId(), history.getModel());
+            List<Diagnosetrainhistory> historyByModel = getHistoryByModel("", history.getModel());
+            if (1 == historyByModel.size() && historyByModel.get(0).getId().equals(history.getId()) && !history.isEnable()) {
+                throw new CustomException(ResultCode.ERROR_DATA);
+            }
             if (null != historyByModel && historyByModel.size() > 0 && history.isEnable()) {
                 for (Diagnosetrainhistory h : historyByModel) {
+                    if (h.getId().equals(history.getId())) {
+                        continue;
+                    }
                     h.setEnable(false);
                     baseMapper.updateById(h);
                 }
             }
             baseMapper.updateById(history);
-            initialRunner.cacheKnowCategory();
+            initialRunner.cacheHistory();
         } catch (Exception e) {
             log.error(e.getMessage());
             throw new CustomException(ResultCode.ERROR_DATA);
@@ -142,6 +151,12 @@ public class DiagnosetrainhistoryServiceImpl extends ServiceImpl<Diagnosetrainhi
         }
     }
 
+    @Override
+    public List<Diagnosetrainhistory> getListAll() {
+        QueryWrapper<Diagnosetrainhistory> wrapper = new QueryWrapper<>();
+        return baseMapper.selectList(wrapper);
+    }
+
 
     /**
      * 由于mybatis-plus存储的中文乱码

+ 10 - 2
gyee-sample-impala/src/main/java/com/gyee/impala/service/master/diagnose/DiagnosetrainhistoryService.java

@@ -32,8 +32,8 @@ public interface DiagnosetrainhistoryService extends IService<Diagnosetrainhisto
     /**
      *
      * 通过mode获取模型
-     * @param id
-     * @param model
+     * @param id  不等于当前id
+     * @param model model名称
      */
     List<Diagnosetrainhistory> getHistoryByModel(String id,String model);
 
@@ -68,5 +68,13 @@ public interface DiagnosetrainhistoryService extends IService<Diagnosetrainhisto
     Diagnosetrainhistory getHistoryByCode(String code);
 
 
+    /**
+     * 查询所有
+     * @return
+     */
+    List<Diagnosetrainhistory> getListAll();
+
+
+
 
 }