WindturbineGoodnessDetailController.java 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  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.setNfdl(NumberUtil.round(ntb.getRfdl() / 1000, 2).doubleValue());
  106. wtday.setNyfdl(NumberUtil.round(ntb.getLlfdl() / 1000, 2).doubleValue());
  107. wtday.setNpjfs(NumberUtil.round(ntb.getPjfs(), 2).doubleValue());
  108. wtday.setNyxxs(NumberUtil.round(ntb.getYxMin() / 60, 2).doubleValue());
  109. wtday.setNgzxs(NumberUtil.round(ntb.getGzMin() / 60, 2).doubleValue());
  110. wtday.setNjxxs(NumberUtil.round(ntb.getJxMin() / 60, 2).doubleValue());
  111. wtday.setNzdxs(NumberUtil.round(ntb.getTjMin() / 60, 2).doubleValue());
  112. wtday.setNyxfs(NumberUtil.round(ntb.getYxfss(), 2).doubleValue());
  113. }
  114. }
  115. if (null != wtday) {
  116. return R.data(ResultMsg.ok(wtday));
  117. } else {
  118. return R.data(ResultMsg.error());
  119. }
  120. }
  121. /*
  122. * 单台风机当月报警排行
  123. */
  124. @PostMapping("/bjphlist")
  125. @ResponseBody
  126. @ApiOperation(value = "单台风机当月报警排行", notes = "单台风机当月报警排行")
  127. @ApiImplicitParams({
  128. @ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "Integer", paramType = "query"),
  129. @ApiImplicitParam(name = "pageSize", value = "每页数量", required = true, dataType = "Integer", paramType = "query"),
  130. @ApiImplicitParam(name = "wtId", value = "风机编号", required = true, dataType = "string", paramType = "query"),
  131. @ApiImplicitParam(name = "recorddate", value = "日期", required = true, dataType = "string", paramType = "query")})
  132. public R bjphlist(Integer pageNum, Integer pageSize, String wtId, String recorddate) {
  133. List<SawVo> resultList = new ArrayList<>();
  134. if (StringUtils.notEmp(wtId) && StringUtils.notEmp(recorddate)) {
  135. Calendar cal = Calendar.getInstance();
  136. cal.set(Calendar.HOUR_OF_DAY, 0);
  137. cal.set(Calendar.MINUTE, 0);
  138. cal.set(Calendar.SECOND, 0);
  139. cal.setTime(DateUtils.parseDate(recorddate));
  140. Date beginDate = cal.getTime();
  141. cal.add(Calendar.DAY_OF_MONTH, 1);
  142. Date endDate = cal.getTime();
  143. // resultList = alarmsnapService.getWarningRecordsTop(tablepar, wtId, beginDate, endDate);
  144. }
  145. if (null != resultList) {
  146. return R.data(ResultMsg.ok(resultList));
  147. } else {
  148. return R.data(ResultMsg.error());
  149. }
  150. }
  151. /*
  152. * 获取明细页面功率曲线
  153. */
  154. @GetMapping("/glchat")
  155. @ResponseBody
  156. @ApiOperation(value = "获取明细页面功率曲线", notes = "获取明细页面功率曲线")
  157. @ApiImplicitParams({
  158. @ApiImplicitParam(name = "wtId", value = "风机编号", required = true, dataType = "string", paramType = "query"),
  159. @ApiImplicitParam(name = "recorddate", value = "日期", required = true, dataType = "string", paramType = "query")})
  160. public R glchat(String wtId, String recorddate) {
  161. List<DataVo> datavos = new ArrayList<>();
  162. if (StringUtils.notEmp(wtId) && StringUtils.notEmp(recorddate)) {
  163. Date date = DateUtils.parseDate(recorddate);
  164. Map<String, Map<Double, ProBasicModelPowerRd>> modelPowermap = CacheContext.theoreticalPowerMap;
  165. Map<String, ProBasicEquipment> wtmap = CacheContext.wtmap;
  166. Map<Double, ProBasicModelPowerRd> map = null;
  167. Calendar cal = Calendar.getInstance();
  168. cal.setTime(date);
  169. int year = cal.get(Calendar.YEAR);
  170. int month = cal.get(Calendar.MONTH) + 1;
  171. QueryWrapper<ProEconWtCurveFittingMonth> queryWrapper = new QueryWrapper<>();
  172. queryWrapper.eq("windturbine_id", wtId).eq("year", String.valueOf(year)).eq("month", String.valueOf(month));
  173. List<ProEconWtCurveFittingMonth> wcls = proEconWtCurveFittingMonthService.list(queryWrapper);
  174. // .stream().filter(i->
  175. // i.getWindturbineId().equals(wtId)
  176. // && i.getYear().equals(String.valueOf(year)) && i.getMonth().equals(String.valueOf(month))
  177. // ).collect(Collectors.toList());
  178. if (!wcls.isEmpty()) {
  179. if (wtmap.containsKey(wtId)) {
  180. ProBasicEquipment wt = wtmap.get(wtId);
  181. if (modelPowermap.containsKey(wt.getModelId())) {
  182. map = modelPowermap.get(wt.getModelId());
  183. }
  184. }
  185. double temp = 0.0;
  186. for (ProEconWtCurveFittingMonth wc : wcls) {
  187. DataVo vo = new DataVo();
  188. int c = (int) wc.getSpeed().intValue();
  189. if (c == wc.getSpeed()) {
  190. vo.setValue1(wc.getSpeed());// 风速
  191. vo.setValue2(wc.getActualPower());// 实际拟合功率
  192. vo.setValue3(wc.getOptimalPower());// 最优拟合功率
  193. if (null != map && StringUtils.notEmp(wc.getSpeed()) && map.containsKey(wc.getSpeed())) {
  194. ProBasicModelPowerRd mp = map.get(wc.getSpeed());
  195. vo.setValue4(mp.getEnsurePower());// 保证功率曲线
  196. temp = mp.getEnsurePower();
  197. } else {
  198. vo.setValue4(temp);// 保证功率曲线
  199. }
  200. datavos.add(vo);
  201. }
  202. }
  203. }
  204. }
  205. if (null != datavos) {
  206. return R.data(ResultMsg.ok(datavos));
  207. } else {
  208. return R.data(ResultMsg.error());
  209. }
  210. }
  211. /*
  212. * 获取风机风资源
  213. */
  214. @GetMapping("/fjfzy")
  215. @ResponseBody
  216. @ApiOperation(value = "获取风机风资源", notes = "获取风机风资源")
  217. @ApiImplicitParams({
  218. @ApiImplicitParam(name = "wtId", value = "风机编号", required = true, dataType = "string", paramType = "query"),
  219. @ApiImplicitParam(name = "recorddate", value = "日期", required = true, dataType = "string", paramType = "query")})
  220. public R fjfzy(String wtId, String recorddate) {
  221. Map<String, Object> map = new HashMap<String, Object>();
  222. List<ValueVo> vos = new ArrayList<ValueVo>();
  223. if (StringUtils.notEmp(wtId) && StringUtils.notEmp(recorddate)) {
  224. Date date = DateUtils.parseDate(recorddate);
  225. QueryWrapper<ProEconWtwindDayInfo> queryWrapper = new QueryWrapper<>();
  226. queryWrapper.eq("windturbine_id", wtId).eq("record_date", date);
  227. List<ProEconWtwindDayInfo> wtdls = proEconWtwindDayInfoService.list(queryWrapper);
  228. // .stream().filter(i->
  229. // i.getWindturbineId().equals(wtId)
  230. // && i.getRecordDate().compareTo(date) ==0
  231. // ).collect(Collectors.toList());
  232. if (!wtdls.isEmpty()) {
  233. ProEconWtwindDayInfo winfo = wtdls.get(0);
  234. int c = (int) winfo.getCb().intValue();
  235. jfpl = "静风频率为" + c;
  236. for (int i = 0; i < 16; i++) {
  237. ValueVo vo = new ValueVo();
  238. switch (i) {
  239. case 0:
  240. // vo.setName("N("+winfo.getN4()+"/"+winfo.getN()+")");
  241. vo.setName("N");
  242. vo.setData1(winfo.getN2());
  243. break;
  244. case 1:
  245. // vo.setName("NNE("+winfo.getNne4()+"/"+winfo.getNne()+")");
  246. vo.setName("NNE");
  247. vo.setData1(winfo.getNne2());
  248. break;
  249. case 2:
  250. // vo.setName("NE("+winfo.getNe4()+"/"+winfo.getNe()+")");
  251. vo.setName("NE");
  252. vo.setData1(winfo.getNe2());
  253. break;
  254. case 3:
  255. // vo.setName("ENE("+winfo.getEne4()+"/"+winfo.getEne()+")");
  256. vo.setName("ENE");
  257. vo.setData1(winfo.getEne2());
  258. break;
  259. case 4:
  260. // vo.setName("E("+winfo.getE4()+"/"+winfo.getE()+")");
  261. vo.setName("E");
  262. vo.setData1(winfo.getE2());
  263. break;
  264. case 5:
  265. // vo.setName("ESE("+winfo.getEse()+"/"+winfo.getEse()+")");
  266. vo.setName("ESE");
  267. vo.setData1(winfo.getEse2());
  268. break;
  269. case 6:
  270. // vo.setName("SE("+winfo.getSe4()+"/"+winfo.getSe()+")");
  271. vo.setName("SE");
  272. vo.setData1(winfo.getSe2());
  273. break;
  274. case 7:
  275. // vo.setName("SSE("+winfo.getSse4()+"/"+winfo.getSse()+")");
  276. vo.setName("SSE");
  277. vo.setData1(winfo.getSse2());
  278. break;
  279. case 8:
  280. // vo.setName("S("+winfo.getS4()+"/"+winfo.getS()+")");
  281. vo.setName("S");
  282. vo.setData1(winfo.getS2());
  283. break;
  284. case 9:
  285. // vo.setName("SSW("+winfo.getSsw4()+"/"+winfo.getSsw()+")");
  286. vo.setName("SSW");
  287. vo.setData1(winfo.getSsw2());
  288. break;
  289. case 10:
  290. // vo.setName("SW("+winfo.getSw4()+"/"+winfo.getSw()+")");
  291. vo.setName("SW");
  292. vo.setData1(winfo.getSw2());
  293. break;
  294. case 11:
  295. // vo.setName("WSW("+winfo.getWsw4()+"/"+winfo.getWsw()+")");
  296. vo.setName("WSW");
  297. vo.setData1(winfo.getWsw2());
  298. break;
  299. case 12:
  300. // vo.setName("W("+winfo.getW4()+"/"+winfo.getW()+")");
  301. vo.setName("W");
  302. vo.setData1(winfo.getW2());
  303. break;
  304. case 13:
  305. // vo.setName("WNW("+winfo.getWnw4()+"/"+winfo.getWnw()+")");
  306. vo.setName("WNW");
  307. vo.setData1(winfo.getWnw2());
  308. break;
  309. case 14:
  310. // vo.setName("NW("+winfo.getNw4()+"/"+winfo.getNw()+")");
  311. vo.setName("NW");
  312. vo.setData1(winfo.getNw2());
  313. break;
  314. case 15:
  315. // vo.setName("NNW("+winfo.getNnw4()+"/"+winfo.getNnw()+")");
  316. vo.setName("NNW");
  317. vo.setData1(winfo.getNnw2());
  318. break;
  319. default:
  320. break;
  321. }
  322. vos.add(vo);
  323. }
  324. map.put("jfpl", jfpl);
  325. map.put("data", vos);
  326. }
  327. }
  328. if (null != map) {
  329. return R.data(ResultMsg.ok(map));
  330. } else {
  331. return R.data(ResultMsg.error());
  332. }
  333. }
  334. }