WindturbineGoodnessDetailController.java 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. package com.gyee.runeconomy.controller.goodness;
  2. import cn.hutool.core.util.NumberUtil;
  3. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  4. import com.gyee.common.util.DateUtils;
  5. import com.gyee.common.vo.benchmark.ValueVo;
  6. import com.gyee.runeconomy.dto.DataVo;
  7. import com.gyee.runeconomy.dto.R;
  8. import com.gyee.runeconomy.dto.ResultMsg;
  9. import com.gyee.runeconomy.dto.SawVo;
  10. import com.gyee.runeconomy.init.CacheContext;
  11. import com.gyee.runeconomy.model.auto.*;
  12. import com.gyee.runeconomy.service.auto.*;
  13. import com.gyee.runeconomy.util.StringUtils;
  14. import io.swagger.annotations.Api;
  15. import io.swagger.annotations.ApiImplicitParam;
  16. import io.swagger.annotations.ApiImplicitParams;
  17. import io.swagger.annotations.ApiOperation;
  18. import org.springframework.stereotype.Controller;
  19. import org.springframework.web.bind.annotation.GetMapping;
  20. import org.springframework.web.bind.annotation.PostMapping;
  21. import org.springframework.web.bind.annotation.RequestMapping;
  22. import org.springframework.web.bind.annotation.ResponseBody;
  23. import javax.annotation.Resource;
  24. import java.time.LocalDate;
  25. import java.time.ZoneId;
  26. import java.time.format.DateTimeFormatter;
  27. import java.util.*;
  28. /**
  29. * 风机明细信息页面
  30. */
  31. @Controller
  32. @RequestMapping("/goodness")
  33. @Api(value = "单机信息总览详细信息", tags = "单机信息总览详细信息")
  34. public class WindturbineGoodnessDetailController {
  35. @Resource
  36. private IProEconWindturbineGoodnessService proEconWindturbineGoodnessService;
  37. @Resource
  38. private IProEconWtwindDayInfoService proEconWtwindDayInfoService;
  39. @Resource
  40. private IProEconWtAlysisDayService proEconWtAlysisDayService;
  41. @Resource
  42. private IProEconWtCurveFittingMonthService proEconWtCurveFittingMonthService;
  43. private String jfpl;
  44. @Resource
  45. private ITurbineInfoDayService turbineInfoDayService;
  46. /**
  47. * 获得明细页面显示信息
  48. *
  49. * @param wtId
  50. * @param recorddate
  51. * @return
  52. */
  53. @GetMapping("/wadAjax")
  54. @ResponseBody
  55. @ApiOperation(value = "查询明细页面显示信息", notes = "查询明细页面显示信息")
  56. @ApiImplicitParams({
  57. @ApiImplicitParam(name = "wtId", value = "风机编号", required = true, dataType = "string", paramType = "query"),
  58. @ApiImplicitParam(name = "recorddate", value = "日期", required = true, dataType = "string", paramType = "query")})
  59. public R wadAjax(String wtId, String recorddate) {
  60. ProEconWtAlysisDay wtday = new ProEconWtAlysisDay();
  61. if (StringUtils.notEmp(wtId) && StringUtils.notEmp(recorddate)) {
  62. Date date = DateUtils.parseDate(recorddate);
  63. LocalDate localDate = LocalDate.parse(recorddate, DateTimeFormatter.ISO_LOCAL_DATE);
  64. LocalDate firstOfMonth = localDate.withDayOfMonth(1);
  65. Date firstDayOfMonth = Date.from(firstOfMonth.atStartOfDay(ZoneId.systemDefault()).toInstant());
  66. LocalDate localdate2 = localDate.withDayOfYear(1);
  67. Date firstDayOfYear = Date.from(localdate2.atStartOfDay(ZoneId.systemDefault()).toInstant());
  68. QueryWrapper<ProEconWtAlysisDay> queryWrapper = new QueryWrapper<>();
  69. queryWrapper.eq("record_date", date).eq("windturbine_id", wtId);
  70. List<ProEconWtAlysisDay> wtadls = proEconWtAlysisDayService.list(queryWrapper);
  71. // .stream().filter(i->i.getWindturbineId().equals(wtId )
  72. // && i.getRecordDate().compareTo(date)==0
  73. // ).collect(Collectors.toList());
  74. if (!wtadls.isEmpty()) {
  75. wtday = wtadls.get(0);
  76. QueryWrapper<TurbineInfoDay> qw = new QueryWrapper<>();
  77. qw.lambda().eq(TurbineInfoDay::getRecordDate, date).eq(TurbineInfoDay::getTurbineId, wtId);
  78. List<TurbineInfoDay> turbineInfoDays = turbineInfoDayService.list(qw);
  79. TurbineInfoDay ytb = turbineInfoDayService.getTurbineSingle(wtId, firstDayOfMonth, date);
  80. TurbineInfoDay ntb = turbineInfoDayService.getTurbineSingle(wtId, firstDayOfYear, date);
  81. TurbineInfoDay tb = turbineInfoDays.get(0);
  82. wtday.setRfdl(NumberUtil.round(tb.getRfdl() / 1000, 2).doubleValue());
  83. wtday.setRyfdl(NumberUtil.round(tb.getLlfdl() / 1000, 2).doubleValue());
  84. wtday.setRpjfs(NumberUtil.round(tb.getPjfs(), 2).doubleValue());
  85. wtday.setRyxxs(NumberUtil.round(tb.getYxMin() / 60, 2).doubleValue());
  86. wtday.setRjxxs(NumberUtil.round(tb.getTjMin() / 60, 2).doubleValue());
  87. wtday.setRgzxs(NumberUtil.round(tb.getGzMin() / 60, 2).doubleValue());
  88. wtday.setRdjxs(NumberUtil.round(tb.getDjMin() / 60, 2).doubleValue());
  89. wtday.setRzdxs(NumberUtil.round(tb.getLxMin() / 60, 2).doubleValue());
  90. wtday.setRyxfs(NumberUtil.round(tb.getYxfss(), 2).doubleValue());
  91. wtday.setRssdl(NumberUtil.round((tb.getGzss() + tb.getSlss() + tb.getXdss() + tb.getJhjxss() + tb.getFjhjxss() + tb.getXnss()) / 1000, 2).doubleValue());
  92. wtday.setRtjcs(NumberUtil.round(tb.getTjcs(), 2).doubleValue());
  93. wtday.setRsbklyl(NumberUtil.round(tb.getKlyl(), 2).doubleValue());
  94. wtday.setRpjwd(NumberUtil.round(tb.getHjwd(), 2).doubleValue());
  95. wtday.setYfdl(NumberUtil.round(ytb.getRfdl() / 1000, 2).doubleValue());
  96. wtday.setYyfdl(NumberUtil.round(ytb.getLlfdl() / 1000, 2).doubleValue());
  97. wtday.setYpjfs(NumberUtil.round(ytb.getPjfs(), 2).doubleValue());
  98. wtday.setYyxxs(NumberUtil.round(ytb.getYxMin() / 60, 2).doubleValue());
  99. wtday.setYdjxs(NumberUtil.round(ytb.getTjMin() / 60, 2).doubleValue());
  100. wtday.setYgzxs(NumberUtil.round(ytb.getGzMin() / 60, 2).doubleValue());
  101. wtday.setYjxxs(NumberUtil.round(ytb.getJxMin() / 60, 2).doubleValue());
  102. wtday.setYzdxs(NumberUtil.round(ytb.getLxMin() / 60, 2).doubleValue());
  103. wtday.setYyxfs(NumberUtil.round(ytb.getYxfss(), 2).doubleValue());
  104. wtday.setYtjcs(NumberUtil.round(ytb.getTjcs(), 2).doubleValue());
  105. wtday.setYsbklyl(NumberUtil.round(ytb.getKlyl(), 2).doubleValue());
  106. wtday.setNfdl(NumberUtil.round(ntb.getRfdl() / 1000, 2).doubleValue());
  107. wtday.setNyfdl(NumberUtil.round(ntb.getLlfdl() / 1000, 2).doubleValue());
  108. wtday.setNpjfs(NumberUtil.round(ntb.getPjfs(), 2).doubleValue());
  109. wtday.setNyxxs(NumberUtil.round(ntb.getYxMin() / 60, 2).doubleValue());
  110. wtday.setNgzxs(NumberUtil.round(ntb.getGzMin() / 60, 2).doubleValue());
  111. wtday.setNjxxs(NumberUtil.round(ntb.getJxMin() / 60, 2).doubleValue());
  112. wtday.setNzdxs(NumberUtil.round(ntb.getTjMin() / 60, 2).doubleValue());
  113. wtday.setNyxfs(NumberUtil.round(ntb.getYxfss(), 2).doubleValue());
  114. }
  115. }
  116. if (null != wtday) {
  117. return R.data(ResultMsg.ok(wtday));
  118. } else {
  119. return R.data(ResultMsg.error());
  120. }
  121. }
  122. /*
  123. * 单台风机当月报警排行
  124. */
  125. @PostMapping("/bjphlist")
  126. @ResponseBody
  127. @ApiOperation(value = "单台风机当月报警排行", notes = "单台风机当月报警排行")
  128. @ApiImplicitParams({
  129. @ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "Integer", paramType = "query"),
  130. @ApiImplicitParam(name = "pageSize", value = "每页数量", required = true, dataType = "Integer", paramType = "query"),
  131. @ApiImplicitParam(name = "wtId", value = "风机编号", required = true, dataType = "string", paramType = "query"),
  132. @ApiImplicitParam(name = "recorddate", value = "日期", required = true, dataType = "string", paramType = "query")})
  133. public R bjphlist(Integer pageNum, Integer pageSize, String wtId, String recorddate) {
  134. List<SawVo> resultList = new ArrayList<>();
  135. if (StringUtils.notEmp(wtId) && StringUtils.notEmp(recorddate)) {
  136. Calendar cal = Calendar.getInstance();
  137. cal.set(Calendar.HOUR_OF_DAY, 0);
  138. cal.set(Calendar.MINUTE, 0);
  139. cal.set(Calendar.SECOND, 0);
  140. cal.setTime(DateUtils.parseDate(recorddate));
  141. Date beginDate = cal.getTime();
  142. cal.add(Calendar.DAY_OF_MONTH, 1);
  143. Date endDate = cal.getTime();
  144. // resultList = alarmsnapService.getWarningRecordsTop(tablepar, wtId, beginDate, endDate);
  145. }
  146. if (null != resultList) {
  147. return R.data(ResultMsg.ok(resultList));
  148. } else {
  149. return R.data(ResultMsg.error());
  150. }
  151. }
  152. /*
  153. * 获取明细页面功率曲线
  154. */
  155. @GetMapping("/glchat")
  156. @ResponseBody
  157. @ApiOperation(value = "获取明细页面功率曲线", notes = "获取明细页面功率曲线")
  158. @ApiImplicitParams({
  159. @ApiImplicitParam(name = "wtId", value = "风机编号", required = true, dataType = "string", paramType = "query"),
  160. @ApiImplicitParam(name = "recorddate", value = "日期", required = true, dataType = "string", paramType = "query")})
  161. public R glchat(String wtId, String recorddate) {
  162. List<DataVo> datavos = new ArrayList<>();
  163. if (StringUtils.notEmp(wtId) && StringUtils.notEmp(recorddate)) {
  164. Date date = DateUtils.parseDate(recorddate);
  165. Map<String, Map<Double, ProBasicModelPowerRd>> modelPowermap = CacheContext.theoreticalPowerMap;
  166. Map<String, ProBasicEquipment> wtmap = CacheContext.wtmap;
  167. Map<Double, ProBasicModelPowerRd> map = null;
  168. Calendar cal = Calendar.getInstance();
  169. cal.setTime(date);
  170. int year = cal.get(Calendar.YEAR);
  171. int month = cal.get(Calendar.MONTH) + 1;
  172. QueryWrapper<ProEconWtCurveFittingMonth> queryWrapper = new QueryWrapper<>();
  173. queryWrapper.eq("windturbine_id", wtId).eq("year", String.valueOf(year)).eq("month", String.valueOf(month));
  174. List<ProEconWtCurveFittingMonth> wcls = proEconWtCurveFittingMonthService.list(queryWrapper);
  175. // .stream().filter(i->
  176. // i.getWindturbineId().equals(wtId)
  177. // && i.getYear().equals(String.valueOf(year)) && i.getMonth().equals(String.valueOf(month))
  178. // ).collect(Collectors.toList());
  179. if (!wcls.isEmpty()) {
  180. if (wtmap.containsKey(wtId)) {
  181. ProBasicEquipment wt = wtmap.get(wtId);
  182. if (modelPowermap.containsKey(wt.getModelId())) {
  183. map = modelPowermap.get(wt.getModelId());
  184. }
  185. }
  186. double temp = 0.0;
  187. for (ProEconWtCurveFittingMonth wc : wcls) {
  188. DataVo vo = new DataVo();
  189. int c = (int) wc.getSpeed().intValue();
  190. if (c == wc.getSpeed()) {
  191. vo.setValue1(wc.getSpeed());// 风速
  192. vo.setValue2(wc.getActualPower());// 实际拟合功率
  193. vo.setValue3(wc.getOptimalPower());// 最优拟合功率
  194. if (null != map && StringUtils.notEmp(wc.getSpeed()) && map.containsKey(wc.getSpeed())) {
  195. ProBasicModelPowerRd mp = map.get(wc.getSpeed());
  196. vo.setValue4(mp.getEnsurePower());// 保证功率曲线
  197. temp = mp.getEnsurePower();
  198. } else {
  199. vo.setValue4(temp);// 保证功率曲线
  200. }
  201. datavos.add(vo);
  202. }
  203. }
  204. }
  205. }
  206. if (null != datavos) {
  207. return R.data(ResultMsg.ok(datavos));
  208. } else {
  209. return R.data(ResultMsg.error());
  210. }
  211. }
  212. /*
  213. * 获取风机风资源
  214. */
  215. @GetMapping("/fjfzy")
  216. @ResponseBody
  217. @ApiOperation(value = "获取风机风资源", notes = "获取风机风资源")
  218. @ApiImplicitParams({
  219. @ApiImplicitParam(name = "wtId", value = "风机编号", required = true, dataType = "string", paramType = "query"),
  220. @ApiImplicitParam(name = "recorddate", value = "日期", required = true, dataType = "string", paramType = "query")})
  221. public R fjfzy(String wtId, String recorddate) {
  222. Map<String, Object> map = new HashMap<String, Object>();
  223. List<ValueVo> vos = new ArrayList<ValueVo>();
  224. if (StringUtils.notEmp(wtId) && StringUtils.notEmp(recorddate)) {
  225. Date date = DateUtils.parseDate(recorddate);
  226. QueryWrapper<ProEconWtwindDayInfo> queryWrapper = new QueryWrapper<>();
  227. queryWrapper.eq("windturbine_id", wtId).eq("record_date", date);
  228. List<ProEconWtwindDayInfo> wtdls = proEconWtwindDayInfoService.list(queryWrapper);
  229. // .stream().filter(i->
  230. // i.getWindturbineId().equals(wtId)
  231. // && i.getRecordDate().compareTo(date) ==0
  232. // ).collect(Collectors.toList());
  233. if (!wtdls.isEmpty()) {
  234. ProEconWtwindDayInfo winfo = wtdls.get(0);
  235. int c = (int) winfo.getCb().intValue();
  236. jfpl = "静风频率为" + c;
  237. for (int i = 0; i < 16; i++) {
  238. ValueVo vo = new ValueVo();
  239. switch (i) {
  240. case 0:
  241. // vo.setName("N("+winfo.getN4()+"/"+winfo.getN()+")");
  242. vo.setName("N");
  243. vo.setData1(winfo.getN2());
  244. break;
  245. case 1:
  246. // vo.setName("NNE("+winfo.getNne4()+"/"+winfo.getNne()+")");
  247. vo.setName("NNE");
  248. vo.setData1(winfo.getNne2());
  249. break;
  250. case 2:
  251. // vo.setName("NE("+winfo.getNe4()+"/"+winfo.getNe()+")");
  252. vo.setName("NE");
  253. vo.setData1(winfo.getNe2());
  254. break;
  255. case 3:
  256. // vo.setName("ENE("+winfo.getEne4()+"/"+winfo.getEne()+")");
  257. vo.setName("ENE");
  258. vo.setData1(winfo.getEne2());
  259. break;
  260. case 4:
  261. // vo.setName("E("+winfo.getE4()+"/"+winfo.getE()+")");
  262. vo.setName("E");
  263. vo.setData1(winfo.getE2());
  264. break;
  265. case 5:
  266. // vo.setName("ESE("+winfo.getEse()+"/"+winfo.getEse()+")");
  267. vo.setName("ESE");
  268. vo.setData1(winfo.getEse2());
  269. break;
  270. case 6:
  271. // vo.setName("SE("+winfo.getSe4()+"/"+winfo.getSe()+")");
  272. vo.setName("SE");
  273. vo.setData1(winfo.getSe2());
  274. break;
  275. case 7:
  276. // vo.setName("SSE("+winfo.getSse4()+"/"+winfo.getSse()+")");
  277. vo.setName("SSE");
  278. vo.setData1(winfo.getSse2());
  279. break;
  280. case 8:
  281. // vo.setName("S("+winfo.getS4()+"/"+winfo.getS()+")");
  282. vo.setName("S");
  283. vo.setData1(winfo.getS2());
  284. break;
  285. case 9:
  286. // vo.setName("SSW("+winfo.getSsw4()+"/"+winfo.getSsw()+")");
  287. vo.setName("SSW");
  288. vo.setData1(winfo.getSsw2());
  289. break;
  290. case 10:
  291. // vo.setName("SW("+winfo.getSw4()+"/"+winfo.getSw()+")");
  292. vo.setName("SW");
  293. vo.setData1(winfo.getSw2());
  294. break;
  295. case 11:
  296. // vo.setName("WSW("+winfo.getWsw4()+"/"+winfo.getWsw()+")");
  297. vo.setName("WSW");
  298. vo.setData1(winfo.getWsw2());
  299. break;
  300. case 12:
  301. // vo.setName("W("+winfo.getW4()+"/"+winfo.getW()+")");
  302. vo.setName("W");
  303. vo.setData1(winfo.getW2());
  304. break;
  305. case 13:
  306. // vo.setName("WNW("+winfo.getWnw4()+"/"+winfo.getWnw()+")");
  307. vo.setName("WNW");
  308. vo.setData1(winfo.getWnw2());
  309. break;
  310. case 14:
  311. // vo.setName("NW("+winfo.getNw4()+"/"+winfo.getNw()+")");
  312. vo.setName("NW");
  313. vo.setData1(winfo.getNw2());
  314. break;
  315. case 15:
  316. // vo.setName("NNW("+winfo.getNnw4()+"/"+winfo.getNnw()+")");
  317. vo.setName("NNW");
  318. vo.setData1(winfo.getNnw2());
  319. break;
  320. default:
  321. break;
  322. }
  323. vos.add(vo);
  324. }
  325. map.put("jfpl", jfpl);
  326. map.put("data", vos);
  327. }
  328. }
  329. if (null != map) {
  330. return R.data(ResultMsg.ok(map));
  331. } else {
  332. return R.data(ResultMsg.error());
  333. }
  334. }
  335. }