|
@@ -0,0 +1,87 @@
|
|
|
+package com.gyee.impala.controller.diagnose.test;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.gyee.impala.common.result.JsonResult;
|
|
|
+import com.gyee.impala.common.result.ResultCode;
|
|
|
+import com.gyee.impala.common.spring.InitialRunner;
|
|
|
+import com.gyee.impala.common.util.DateUtil;
|
|
|
+import com.gyee.impala.model.custom.diagnose.DataInfo;
|
|
|
+import com.gyee.impala.model.custom.diagnose.ExecuteInfo;
|
|
|
+import com.gyee.impala.model.master.Casefaultalg;
|
|
|
+import com.gyee.impala.model.master.diagnose.Diagnosepoint;
|
|
|
+import com.gyee.impala.model.master.diagnose.Diagnosetrainhistory;
|
|
|
+import com.gyee.impala.service.custom.diagnose.DataDiagnoseService;
|
|
|
+import com.gyee.impala.service.master.CasefaultalgService;
|
|
|
+import jdk.nashorn.internal.ir.annotations.Ignore;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.util.Calendar;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 故障数据及正常数据
|
|
|
+ */
|
|
|
+@CrossOrigin
|
|
|
+@RestController
|
|
|
+@RequestMapping("/api/test")
|
|
|
+public class TrainDataController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DataDiagnoseService diagnoseService;
|
|
|
+ @Autowired
|
|
|
+ private CasefaultalgService casefaultalgService;
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping("/traindata")
|
|
|
+ public JSONObject getData(String station, String wtId, String model, String faultTime, String normalTime, int preMinute) throws InterruptedException {
|
|
|
+ Casefaultalg one = casefaultalgService.getOne(station, wtId, model, faultTime, null);
|
|
|
+ if (one == null)
|
|
|
+ return JsonResult.error(4000, "数据不存在");
|
|
|
+
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(DateUtil.parseStrtoDate(faultTime));
|
|
|
+
|
|
|
+ ExecuteInfo executeInfo = new ExecuteInfo();
|
|
|
+ DataInfo dataInfo = new DataInfo();
|
|
|
+ dataInfo.setFaultTime(String.valueOf(calendar.getTime().getTime()));
|
|
|
+ calendar.add(Calendar.MINUTE, (-preMinute));
|
|
|
+ dataInfo.setStartTs(String.valueOf(calendar.getTime().getTime()));
|
|
|
+ calendar.add(Calendar.MINUTE, preMinute);
|
|
|
+ dataInfo.setEndTs(String.valueOf(calendar.getTime().getTime()));
|
|
|
+ dataInfo.setThingId(wtId);
|
|
|
+ dataInfo.setModelId(model);
|
|
|
+ dataInfo.setStationId(station);
|
|
|
+ dataInfo.setTag(one.getFaultcode());
|
|
|
+
|
|
|
+ DataInfo[] dataInfos = new DataInfo[1];
|
|
|
+ dataInfos[0] = dataInfo;
|
|
|
+ executeInfo.setDataInfos(dataInfos);
|
|
|
+
|
|
|
+ List<Diagnosepoint> list = InitialRunner.mapPoint.get(station).get(model);
|
|
|
+ diagnoseService.formatUniformcode(list);
|
|
|
+ String faultFile = diagnoseService.getFormDataAll(executeInfo);
|
|
|
+
|
|
|
+ Thread.sleep(2000);
|
|
|
+
|
|
|
+ ExecuteInfo executeInfo2 = new ExecuteInfo();
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
+ cal.setTime(DateUtil.parseStrtoDate(normalTime));
|
|
|
+ cal.add(Calendar.MINUTE, (-preMinute));
|
|
|
+ dataInfo.setStartTs(String.valueOf(cal.getTime().getTime()));
|
|
|
+ cal.add(Calendar.MINUTE, preMinute);
|
|
|
+ dataInfo.setEndTs(String.valueOf(cal.getTime().getTime()));
|
|
|
+ DataInfo[] info = new DataInfo[1];
|
|
|
+ info[0] = dataInfo;
|
|
|
+ executeInfo2.setDataInfos(info);
|
|
|
+ String normalFile = diagnoseService.getFormDataAll(executeInfo);
|
|
|
+
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("fault", faultFile);
|
|
|
+ map.put("normal", normalFile);
|
|
|
+
|
|
|
+ return JsonResult.successData(ResultCode.SUCCESS, map);
|
|
|
+ }
|
|
|
+}
|