|
@@ -0,0 +1,91 @@
|
|
|
|
+package com.gyee.impala.controller.diagnose;
|
|
|
|
+
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.gyee.impala.common.feign.RemoteServiceBuilder;
|
|
|
|
+import com.gyee.impala.common.result.JsonResult;
|
|
|
|
+import com.gyee.impala.common.result.ResultCode;
|
|
|
|
+import com.gyee.impala.model.custom.diagnose.FaultInfo;
|
|
|
|
+import com.gyee.impala.model.master.Casefaultalg;
|
|
|
|
+import com.gyee.impala.service.custom.diagnose.AutoCmdService;
|
|
|
|
+import com.gyee.impala.service.master.CasefaultalgService;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Optional;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
|
|
+@CrossOrigin
|
|
|
|
+@RestController
|
|
|
|
+@RequestMapping("/api/diagnosefault")
|
|
|
|
+public class DiagnoseFaultController {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private AutoCmdService autoCmdService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private CasefaultalgService casefaultalgService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private RemoteServiceBuilder remoteServiceBuilder;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @GetMapping("/offline")
|
|
|
|
+ public JSONObject offline(@RequestParam(value = "station", required = false) String station,
|
|
|
|
+ @RequestParam(value = "id", required = false) String[] id,
|
|
|
|
+ @RequestParam(value = "faultid", required = false) Long[] faultid,
|
|
|
|
+ @RequestParam(value = "model", required = false) String[] model,
|
|
|
|
+ @RequestParam(value = "faultcode", required = false) String[] faultcode,
|
|
|
|
+ @RequestParam(value = "st", required = false) String st,
|
|
|
|
+ @RequestParam(value = "et", required = false) String et,
|
|
|
|
+ @RequestParam(value = "algcode", required = false) String algcode,
|
|
|
|
+ @RequestParam(value = "confirm", required = false) Optional<Boolean> confirm){
|
|
|
|
+ boolean conf = confirm.isPresent() ? confirm.get() : false;
|
|
|
|
+ if (conf){
|
|
|
|
+ List<Casefaultalg> list = casefaultalgService.getAll(station, id, faultid, model, faultcode, st, et, algcode, false);
|
|
|
|
+ return JsonResult.successData(ResultCode.SUCCESS, list);
|
|
|
|
+ }else{
|
|
|
|
+ List<Casefaultalg> array = new ArrayList<>();
|
|
|
|
+ List<Casefaultalg> list = casefaultalgService.getAll(station, id, faultid, model, faultcode, st, et, algcode, false);
|
|
|
|
+ List<FaultInfo> faults = remoteServiceBuilder.sharding().getFaultRecent(et);
|
|
|
|
+ List<FaultInfo> collect = faults.stream().filter(f -> f.getCategory1().equals("FJ") && f.getCategory2().equals("GZ")).collect(Collectors.toList());
|
|
|
|
+ for (int i = 0; i < collect.size(); i++){
|
|
|
|
+ FaultInfo info = collect.get(i);
|
|
|
|
+ if (list == null || list.size() == 0){
|
|
|
|
+ array.add(format(info));
|
|
|
|
+ }else{
|
|
|
|
+ List<Casefaultalg> ls = list.stream().filter(a -> a.getFaultid().equals(info.getId())).collect(Collectors.toList());
|
|
|
|
+ if (ls.size() == 0)
|
|
|
|
+ array.add(format(info));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return JsonResult.successData(ResultCode.SUCCESS, array);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @PostMapping("/offlinediagnose")
|
|
|
|
+ public JSONObject offlineDiagnose(@RequestBody List<Casefaultalg> faults){
|
|
|
|
+ faults.stream().forEach(obj -> {
|
|
|
|
+ FaultInfo info = new FaultInfo();
|
|
|
|
+ info.setStationId(obj.getStationen());
|
|
|
|
+ info.setModelId(obj.getModel());
|
|
|
|
+ info.setId(Long.valueOf(obj.getFaultid()));
|
|
|
|
+ autoCmdService.exec(info);
|
|
|
|
+ });
|
|
|
|
+ return JsonResult.success(ResultCode.SUCCESS);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private Casefaultalg format(FaultInfo info){
|
|
|
|
+ Casefaultalg fault = new Casefaultalg();
|
|
|
|
+ fault.setStationcn(info.getStationName());
|
|
|
|
+ fault.setStationen(info.getStationId());
|
|
|
|
+ fault.setTag(0);
|
|
|
|
+ fault.setFaultid(info.getId());
|
|
|
|
+ fault.setWindturbineid(info.getWindturbineId());
|
|
|
|
+ fault.setDiagnosetype(info.getAlertText());
|
|
|
|
+ fault.setStarttime(info.getFaultTime());
|
|
|
|
+ fault.setModel(info.getModelId());
|
|
|
|
+ fault.setCategory("0");
|
|
|
|
+ return fault;
|
|
|
|
+ }
|
|
|
|
+}
|