SingleAnalysisController.java 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. package com.gyee.runeconomy.controller;
  2. import com.gyee.runeconomy.dto.R;
  3. import com.gyee.runeconomy.dto.ResultMsg;
  4. import com.gyee.runeconomy.model.vo.SingleAnalysisVo;
  5. import com.gyee.runeconomy.service.singleanalysis.SingleAnalysisService;
  6. import com.gyee.runeconomy.util.DateUtils;
  7. import com.gyee.runeconomy.util.StringUtils;
  8. import io.swagger.annotations.Api;
  9. import io.swagger.annotations.ApiImplicitParam;
  10. import io.swagger.annotations.ApiImplicitParams;
  11. import io.swagger.annotations.ApiOperation;
  12. import org.springframework.stereotype.Controller;
  13. import org.springframework.web.bind.annotation.GetMapping;
  14. import org.springframework.web.bind.annotation.PostMapping;
  15. import org.springframework.web.bind.annotation.RequestMapping;
  16. import org.springframework.web.bind.annotation.ResponseBody;
  17. import javax.annotation.Resource;
  18. import java.util.*;
  19. @Controller
  20. @RequestMapping("/singleanalysis")
  21. @Api(value = "单机性能分析" ,tags="单机性能分析")
  22. public class SingleAnalysisController {
  23. @Resource
  24. private SingleAnalysisService singleAnalysisService;
  25. @PostMapping("/singleanalysisMain")
  26. @ResponseBody
  27. @ApiOperation(value = "查询单机性能分析首页", notes = "查询单机性能分析首页")
  28. @ApiImplicitParams({
  29. @ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "Integer", paramType = "query"),
  30. @ApiImplicitParam(name = "pageSize", value = "每页数量", required = true, dataType = "Integer", paramType = "query"),
  31. @ApiImplicitParam(name = "cmId", value = "公司编号", required = true, dataType = "string", paramType = "query"),
  32. @ApiImplicitParam(name = "type", value = "光伏(-2)/风场(-1)", required = true, dataType = "string", paramType = "query"),
  33. @ApiImplicitParam(name = "wpId", value = "风场编号", required = false, dataType = "string", paramType = "query"),
  34. @ApiImplicitParam(name = "year", value = "年份", required = true, dataType = "string", paramType = "query"),
  35. @ApiImplicitParam(name = "month", value = "月份", required = true, dataType = "string", paramType = "query")})
  36. public R singleanalysisMain(Integer pageNum, Integer pageSize,String cmId,String type, String wpId, String year, String month) throws Exception {
  37. List<SingleAnalysisVo> vos =new ArrayList<>();
  38. if (StringUtils.notEmp(wpId) && StringUtils.notEmp(year) && StringUtils.notEmp(month)) {
  39. Calendar cal = Calendar.getInstance();
  40. int newyear=cal.get(Calendar.YEAR);
  41. int newmonth=cal.get(Calendar.MONTH)+1;
  42. Date recordDate=null;
  43. if(Integer.valueOf(year)==newyear && Integer.valueOf(month) == newmonth)
  44. {
  45. cal.add(Calendar.DAY_OF_MONTH,-1);
  46. recordDate= DateUtils.truncate(cal.getTime());
  47. }else
  48. {
  49. cal.set(Calendar.YEAR,Integer.valueOf(year));
  50. cal.set(Calendar.MONTH,Integer.valueOf(month)-1);
  51. cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
  52. recordDate= DateUtils.truncate(cal.getTime());
  53. }
  54. vos =singleAnalysisService.SingleAnalysisList(pageNum, pageSize,cmId,type, wpId,recordDate);
  55. }
  56. return R.data(ResultMsg.ok(vos));
  57. }
  58. /**
  59. * 单机信息总览子页面
  60. * @param wtId
  61. * @param year
  62. * @param month
  63. * @return
  64. * @throws Exception
  65. */
  66. @GetMapping("/singleanalysisSub")
  67. @ResponseBody
  68. @ApiOperation(value = "查询单机性能分析子页面", notes = "查询单机性能分析子页面")
  69. @ApiImplicitParams({
  70. @ApiImplicitParam(name = "wtId", value = "风机编号", required = true, dataType = "string", paramType = "query"),
  71. @ApiImplicitParam(name = "year", value = "年份", required = true, dataType = "string", paramType = "query"),
  72. @ApiImplicitParam(name = "month", value = "月份", required = true, dataType = "string", paramType = "query")})
  73. public R singleanalysisSub(String wtId, String year, String month) throws Exception {
  74. Map<String,Object> map=new HashMap<>();
  75. if (StringUtils.notEmp(wtId) && StringUtils.notEmp(year) && StringUtils.notEmp(month)) {
  76. Calendar cal = Calendar.getInstance();
  77. int newyear=cal.get(Calendar.YEAR);
  78. int newmonth=cal.get(Calendar.MONTH)+1;
  79. Date recordDate=null;
  80. if(Integer.valueOf(year)==newyear && Integer.valueOf(month) == newmonth)
  81. {
  82. cal.add(Calendar.DAY_OF_MONTH,-1);
  83. recordDate= DateUtils.truncate(cal.getTime());
  84. }else
  85. {
  86. cal.set(Calendar.YEAR,Integer.valueOf(year));
  87. cal.set(Calendar.MONTH,Integer.valueOf(month)-1);
  88. cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
  89. recordDate= DateUtils.truncate(cal.getTime());
  90. }
  91. SingleAnalysisVo byzb =singleAnalysisService.SingleAnalysisListByWtId(wtId,recordDate);
  92. cal.add(Calendar.YEAR,-1);
  93. Date lastYear=DateUtils.truncate(cal.getTime());
  94. SingleAnalysisVo tqzb =singleAnalysisService.SingleAnalysisListByWtId(wtId,lastYear);
  95. SingleAnalysisVo tbzb =singleAnalysisService.SingleAnalysisListByWtId(byzb,tqzb);
  96. cal.setTime(recordDate);
  97. cal.add(Calendar.MONTH,-1);
  98. Date lastMonth=DateUtils.truncate(cal.getTime());
  99. SingleAnalysisVo hqzb =singleAnalysisService.SingleAnalysisListByWtId(wtId,lastMonth);
  100. SingleAnalysisVo hbzb =singleAnalysisService.SingleAnalysisListByWtId(byzb,hqzb);
  101. map.put("byzb",byzb);//本月指标
  102. map.put("tqzb",tqzb);//全年同期
  103. map.put("tbzb",tbzb);//同比指标
  104. map.put("hqzb",hqzb);//上月同期
  105. map.put("hbzb",hbzb);//环比指标
  106. }
  107. // if (null!=map) {
  108. // return AjaxResult.successData(ResultCode.SUCCESS, map);
  109. // } else {
  110. // return AjaxResult.successData(ResultCode.SUCCESS, map);
  111. // }
  112. return R.data(ResultMsg.ok(map));
  113. }
  114. /**
  115. * 单机信息总览图表接口(3个)
  116. * @param wtId
  117. * @param year
  118. * @param month
  119. * @return
  120. * @throws Exception
  121. */
  122. @GetMapping("/singleanalysisChart")
  123. @ResponseBody
  124. @ApiOperation(value = "单机信息总览图表接口(3个) 发电量和风速、五项损失、静风频率和待机时间", notes = "单机信息总览图表接口(3个) 发电量和风速、五项损失、静风频率和待机时间")
  125. @ApiImplicitParams({
  126. @ApiImplicitParam(name = "wtId", value = "风机编号", required = true, dataType = "string", paramType = "query"),
  127. @ApiImplicitParam(name = "year", value = "年份", required = true, dataType = "string", paramType = "query"),
  128. @ApiImplicitParam(name = "month", value = "月份", required = true, dataType = "string", paramType = "query")})
  129. public R singleanalysisChart(String wtId, String year, String month) throws Exception {
  130. Map<String,List<SingleAnalysisVo>> map =new HashMap<>();
  131. if (StringUtils.notEmp(wtId) && StringUtils.notEmp(year) && StringUtils.notEmp(month)) {
  132. Calendar cal = Calendar.getInstance();
  133. cal.set(Calendar.HOUR_OF_DAY, 0);
  134. cal.set(Calendar.MINUTE, 0);
  135. cal.set(Calendar.SECOND, 0);
  136. cal.set(Calendar.MILLISECOND,0);
  137. cal.set(Calendar.YEAR, Integer.valueOf(year));
  138. cal.set(Calendar.MONTH, Integer.valueOf(month) - 1);
  139. cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH));
  140. Date beginDate = cal.getTime();
  141. cal.add(Calendar.MONTH, 1);
  142. Date endDate = cal.getTime();
  143. map =singleAnalysisService.SingleAnalysisListByWtIdDetiml(wtId,beginDate,endDate);
  144. }
  145. // map.put("ff",fdlfsls);//发电量和风速
  146. // map.put("ws",wsls);//五项损失,绑定五个
  147. // map.put("jd",jfpldjsjls);//静风频率和待机时间
  148. // if (null!=map) {
  149. // return AjaxResult.successData(ResultCode.SUCCESS, map);
  150. // } else {
  151. // return AjaxResult.successData(ResultCode.SUCCESS, map);
  152. // }
  153. return R.data(ResultMsg.ok(map));
  154. }
  155. }