WindturbineGoodnessDetailController.java 18 KB

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