|
@@ -1,10 +1,23 @@
|
|
package com.gyee.impala.schdule;
|
|
package com.gyee.impala.schdule;
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.gyee.impala.common.spring.InitialRunner;
|
|
|
|
+import com.gyee.impala.model.gdoa.EqQxjcljl;
|
|
|
|
+import com.gyee.impala.model.master.Casefaultrepair;
|
|
|
|
+import com.gyee.impala.model.master.ICasefaultrepairService;
|
|
|
|
+import com.gyee.impala.model.master.Knowcategory;
|
|
|
|
+import com.gyee.impala.model.master.Windturbine;
|
|
|
|
+import com.gyee.impala.service.gdoa.IEqQxjcljlService;
|
|
import com.gyee.impala.service.master.KnowinspectService;
|
|
import com.gyee.impala.service.master.KnowinspectService;
|
|
|
|
+import org.apache.kudu.client.KuduException;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 来自国电oa的设备检修数据同步至kudu样本库
|
|
* 来自国电oa的设备检修数据同步至kudu样本库
|
|
@@ -14,6 +27,12 @@ public class TaskEQInspect {
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private KnowinspectService knowinspectService;
|
|
private KnowinspectService knowinspectService;
|
|
|
|
+ @Resource
|
|
|
|
+ private IEqQxjcljlService iEqQxjcljlService;
|
|
|
|
+ @Resource
|
|
|
|
+ private ICasefaultrepairService casefaultrepairService;
|
|
|
|
+ //故障类型
|
|
|
|
+ private Map<String,String> gzlx;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 每周六一点执行一次
|
|
* 每周六一点执行一次
|
|
@@ -23,4 +42,65 @@ public class TaskEQInspect {
|
|
String time = knowinspectService.selectMaxTime();
|
|
String time = knowinspectService.selectMaxTime();
|
|
knowinspectService.insertBatch(time);
|
|
knowinspectService.insertBatch(time);
|
|
}
|
|
}
|
|
|
|
+ /**
|
|
|
|
+ * 每周六一点半执行一次
|
|
|
|
+ */
|
|
|
|
+ @Scheduled(cron = "0 30 1 ? * 6")
|
|
|
|
+ public void caseFaultRepair(){
|
|
|
|
+ QueryWrapper<EqQxjcljl> wrapper = new QueryWrapper<>();
|
|
|
|
+ wrapper.notLike("USE_DEPT", "光伏");
|
|
|
|
+ List<EqQxjcljl> list = iEqQxjcljlService.list(wrapper);
|
|
|
|
+ List<Casefaultrepair> casefaultrepairs = new ArrayList<>();
|
|
|
|
+ for (EqQxjcljl eqxjcljl : list) {
|
|
|
|
+ Casefaultrepair cfr = new Casefaultrepair();
|
|
|
|
+ String stid = InitialRunner.stationenMap.get(eqxjcljl.getUseDept());
|
|
|
|
+ cfr.setStationid(stid);
|
|
|
|
+ cfr.setStationname(eqxjcljl.getUseDept());
|
|
|
|
+ String wtId = getWtId(stid, eqxjcljl.getEquipmentName());
|
|
|
|
+ cfr.setWindturbineid(wtId);
|
|
|
|
+ Windturbine windturbine = InitialRunner.wtMap.get(wtId);
|
|
|
|
+ if(windturbine==null||windturbine.getName()==null) continue;
|
|
|
|
+ cfr.setWindturbinename(windturbine.getName());
|
|
|
|
+ cfr.setModelid(windturbine.getModel());
|
|
|
|
+ String ftc = getFaultType(eqxjcljl.getQxname());
|
|
|
|
+ cfr.setFaulttypecode(ftc);
|
|
|
|
+ cfr.setFaulttypename(InitialRunner.faultTypeMap.get(ftc));
|
|
|
|
+ cfr.setStarttime(eqxjcljl.getFinddate());
|
|
|
|
+ cfr.setEndtime(eqxjcljl.getEnddate());
|
|
|
|
+ cfr.setFaultreason(eqxjcljl.getCause());
|
|
|
|
+ cfr.setTreatprocesses(eqxjcljl.getClgc());
|
|
|
|
+ cfr.setSparepartsreplacement(eqxjcljl.getBjghqk());
|
|
|
|
+ casefaultrepairs.add(cfr);
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ casefaultrepairService.insertBatch(casefaultrepairs);
|
|
|
|
+ } catch (KuduException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private String getFaultType(String qxname) {
|
|
|
|
+ if(gzlx==null ||gzlx.size()==0){
|
|
|
|
+ gzlx = new HashMap<>();
|
|
|
|
+ for (Knowcategory knowcategory : InitialRunner.faultTypeList) {
|
|
|
|
+ gzlx.put(knowcategory.getName().replace("系统故障","")
|
|
|
|
+ .replace("类故障","")
|
|
|
|
+ .replace("故障",""), knowcategory.getCode());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ for (String s : gzlx.keySet()) {
|
|
|
|
+ if(qxname.contains(s)){
|
|
|
|
+ return gzlx.get(s);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return "QT";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private String getWtId(String stid, String equipmentName) {
|
|
|
|
+ if(stid==null||equipmentName==null) return null;
|
|
|
|
+ String fj = equipmentName.replace("#", "").replace("风机", "");
|
|
|
|
+ fj = fj.length() > 1 ? fj : "0" + fj;
|
|
|
|
+ return stid.charAt(0)+"G01_"+fj;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|