BenchmarkingController.java 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. package com.gyee.runeconomy.controller.bmk;/*
  2. @author 谢生杰
  3. @date 2022/11/23-13:16
  4. */
  5. import com.gyee.common.model.StringUtils;
  6. import com.gyee.common.util.DateUtils;
  7. import com.gyee.common.util.SortUtils;
  8. import com.gyee.common.vo.benchmark.FjjxbVo;
  9. import com.gyee.common.vo.benchmark.FjjxbmxVo;
  10. import com.gyee.common.vo.benchmark.WxsslVo;
  11. import com.gyee.runeconomy.dto.R;
  12. import com.gyee.runeconomy.dto.ResultMsg;
  13. import com.gyee.runeconomy.model.auto.*;
  14. import com.gyee.runeconomy.service.bmk.BenchmarkingService;
  15. import io.swagger.annotations.Api;
  16. import io.swagger.annotations.ApiOperation;
  17. import org.springframework.web.bind.annotation.*;
  18. import javax.annotation.Resource;
  19. import java.util.ArrayList;
  20. import java.util.Date;
  21. import java.util.List;
  22. import java.util.Map;
  23. import java.util.stream.Collectors;
  24. @RestController
  25. @RequestMapping("//benchmarking")
  26. @Api(value = "对标管理", tags = "对标管理")
  27. public class BenchmarkingController {
  28. @Resource
  29. private BenchmarkingService benchmarkingService;
  30. @GetMapping(value = "/companys")
  31. @ApiOperation(value = "公司列表", notes = "公司列表")
  32. public R companys() {
  33. List<ProBasicCompany> resultList = benchmarkingService.companys();
  34. if (StringUtils.isNotNull(resultList)) {
  35. return R.data(ResultMsg.ok(resultList));
  36. } else {
  37. return R.error(ResultMsg.error());
  38. }
  39. }
  40. @GetMapping(value = "/companysByRg")
  41. @ApiOperation(value = "根据区域查询公司列表", notes = "根据区域查询公司列表")
  42. public R companysByRg(@RequestParam(value = "regionid", required = true) String regionid) {
  43. List<ProBasicCompany> resultList = benchmarkingService.companys().stream().filter(i -> i.getRegionId().equals(regionid)).collect(Collectors.toList());
  44. if (StringUtils.isNotNull(resultList)) {
  45. return R.data(ResultMsg.ok(resultList));
  46. } else {
  47. return R.error(ResultMsg.error());
  48. }
  49. }
  50. @GetMapping(value = "/wpByCplist")
  51. @ApiOperation(value = "场站列表", notes = "场站列表")
  52. public R wpByCplist(@RequestParam(value = "companyids") String companyids,
  53. @RequestParam(value = "type", required = false) String type) {
  54. List<ProBasicPowerstation> resultList = benchmarkingService.wpByCplist(companyids, type);
  55. if (StringUtils.isNotNull(resultList)) {
  56. return R.data(ResultMsg.ok(resultList));
  57. } else {
  58. return R.error(ResultMsg.error());
  59. }
  60. }
  61. @GetMapping(value = "/subByCplist")
  62. @ApiOperation(value = "升压站列表", notes = "升压站列表")
  63. public R subByCplist(@RequestParam(value = "companyids", required = true) String companyids,
  64. @RequestParam(value = "type", required = false) String type) {
  65. List<ProBasicSubStation> resultList = benchmarkingService.subByCplist(companyids, type);
  66. if (StringUtils.isNotNull(resultList)) {
  67. return R.data(ResultMsg.ok(resultList));
  68. } else {
  69. return R.error(ResultMsg.error());
  70. }
  71. }
  72. @GetMapping(value = "/wtByWplist")
  73. @ApiOperation(value = "设备列表", notes = "设备列表")
  74. public R wtByWplist(@RequestParam(value = "wpId", required = true) String wpId) {
  75. List<ProBasicEquipment> resultList = benchmarkingService.wtByWplist(wpId);
  76. if (StringUtils.isNotNull(resultList)) {
  77. return R.data(ResultMsg.ok(resultList));
  78. } else {
  79. return R.error(ResultMsg.error());
  80. }
  81. }
  82. @GetMapping(value = "/pjByWplist")
  83. @ApiOperation(value = "项目列表", notes = "项目列表")
  84. public R pjByWplist(@RequestParam(value = "wpids", required = true) String wpids) {
  85. List<ProBasicProject> resultList = benchmarkingService.pjByWplist(wpids);
  86. if (StringUtils.isNotNull(resultList)) {
  87. return R.data(ResultMsg.ok(resultList));
  88. } else {
  89. return R.error(ResultMsg.error());
  90. }
  91. }
  92. @GetMapping(value = "/lnByPjlist")
  93. @ApiOperation(value = "线路列表", notes = "线路列表")
  94. public R lnByPjlist(@RequestParam(value = "pjids", required = true) String pjids) {
  95. List<ProBasicLine> resultList = benchmarkingService.lnByPjlist(pjids);
  96. if (StringUtils.isNotNull(resultList)) {
  97. return R.data(ResultMsg.ok(resultList));
  98. } else {
  99. return R.error(ResultMsg.error());
  100. }
  101. }
  102. @GetMapping(value = "/performance")
  103. @ApiOperation(value = "风机绩效榜", notes = "风机绩效榜")
  104. public R performance(@RequestParam(value = "companyid", required = true) String companyid,
  105. @RequestParam(value = "getype", required = true) String getype,
  106. @RequestParam(value = "sttype", required = true) String sttype,
  107. @RequestParam(value = "beginDate", required = true) String beginDate,
  108. @RequestParam(value = "endDate", required = true) String endDate,
  109. @RequestParam(value = "wpids", required = true) String wpids,
  110. @RequestParam(value = "projectids", required = true) String projectids,
  111. @RequestParam(value = "lineids", required = true) String lineids,
  112. @RequestParam(value = "target", required = false) String target,
  113. @RequestParam(value = "sort", required = false) String sort) {
  114. List<FjjxbVo> resultList = benchmarkingService.performance(companyid, getype, sttype, beginDate, endDate, wpids, projectids, lineids, target, sort);
  115. if (StringUtils.isNotNull(resultList)) {
  116. return R.data(ResultMsg.ok(resultList));
  117. } else {
  118. return R.error(ResultMsg.error());
  119. }
  120. }
  121. @GetMapping(value = "/performanceMX")
  122. @ApiOperation(value = "风机绩效榜明细", notes = "风机绩效榜明细")
  123. public R performanceMX(@RequestParam(value = "companyid", required = true) String companyid,
  124. @RequestParam(value = "getype", required = true) String getype,
  125. @RequestParam(value = "sttype", required = true) String sttype,
  126. @RequestParam(value = "beginDate", required = true) String beginDate,
  127. @RequestParam(value = "endDate", required = true) String endDate,
  128. @RequestParam(value = "wpids", required = true) String wpids,
  129. @RequestParam(value = "projectids", required = true) String projectids,
  130. @RequestParam(value = "lineids", required = true) String lineids,
  131. @RequestParam(value = "target", required = true) String target,
  132. @RequestParam(value = "sort", required = true) String sort) {
  133. List<FjjxbmxVo> resultList = benchmarkingService.performanceMX(companyid, getype, sttype, beginDate, endDate, wpids, projectids, lineids, target, sort);
  134. if (StringUtils.isNotNull(resultList)) {
  135. return R.data(ResultMsg.ok(resultList));
  136. } else {
  137. return R.error(ResultMsg.error());
  138. }
  139. }
  140. @GetMapping("/wxssl")
  141. @ResponseBody
  142. @ApiOperation(value = "五项损失率", notes = "五项损失率")
  143. public R wxssl(@RequestParam(value = "companys", required = true) String companys,
  144. @RequestParam(value = "type", required = true) String type,
  145. @RequestParam(value = "wpids", required = true) String wpids,
  146. @RequestParam(value = "projectids", required = true) String projectids,
  147. @RequestParam(value = "lineids", required = true) String lineids,
  148. @RequestParam(value = "beginDate", required = true) String beginDate,
  149. @RequestParam(value = "endDate", required = true) String endDate,
  150. @RequestParam(value = "target", required = true) String target,
  151. @RequestParam(value = "sort", required = true) String sort
  152. ) {
  153. List<WxsslVo> resultList = benchmarkingService.wxssl(companys, type, wpids, projectids, lineids, beginDate, endDate, target, sort);
  154. if (StringUtils.isNotNull(resultList)) {
  155. return R.data(ResultMsg.ok(resultList));
  156. } else {
  157. return R.error(ResultMsg.error());
  158. }
  159. }
  160. @GetMapping("/cndb")
  161. @ResponseBody
  162. @ApiOperation(value = "场内对标", notes = "场内对标")
  163. public R cndb(@RequestParam(value = "companys", required = true) String companys,
  164. @RequestParam(value = "type", required = true) String type,
  165. @RequestParam(value = "wpid", required = true) String wpid,
  166. @RequestParam(value = "beginDate", required = true) String beginDate,
  167. @RequestParam(value = "endDate", required = true) String endDate,
  168. @RequestParam(value = "target", required = true) String target,
  169. @RequestParam(value = "sort", required = true) String sort,
  170. @RequestParam(value = "pageNum", required = true) int pageNum,
  171. @RequestParam(value = "pageSize", required = true) int pageSize
  172. ) {
  173. Map<String, Object> resultList = benchmarkingService.cndb(companys, type, wpid, beginDate, endDate, target, sort, pageNum, pageSize);
  174. if (StringUtils.isNotNull(resultList)) {
  175. return R.data(ResultMsg.ok(resultList));
  176. } else {
  177. return R.error(ResultMsg.error());
  178. }
  179. }
  180. @GetMapping("/cndbthb")
  181. @ResponseBody
  182. @ApiOperation(value = "场内对标同环比", notes = "场内对标同环比")
  183. public R cndbthb(@RequestParam(value = "companys", required = true) String companys,
  184. @RequestParam(value = "type", required = true) String type,
  185. @RequestParam(value = "wpid", required = true) String wpid,
  186. @RequestParam(value = "pageNum", required = true) int pageNum,
  187. @RequestParam(value = "pageSize", required = true) int pageSize
  188. ) throws Exception {
  189. List<WxsslVo> resultList = new ArrayList<>();
  190. //获取当前时间
  191. String endDate = DateUtils.toDate1(new Date());
  192. Date date = DateUtils.parseDate(endDate);
  193. String beginDate = DateUtils.toDate1(DateUtils.getFirstAndLastDayOfMonth(date));
  194. // Map<String, Object> dateList = benchmarkingService.cndbthb(companys,type,wpid,beginDate,endDate,page,pageSize);
  195. // if(dateList != null && dateList.size()>0){
  196. // dateList.get(0).setName("当月");
  197. // resultList.add((dateList != null && dateList.size()>0)?dateList.get(0): null);
  198. // }
  199. Map<String, Object> dateList = benchmarkingService.cndbthb(companys, type, wpid, beginDate, endDate, pageNum, pageSize);
  200. if (dateList != null && dateList.containsKey("resultList")) {
  201. List<WxsslVo> currentMonthList = (List<WxsslVo>) dateList.get("resultList");
  202. if (currentMonthList.size() > 0) {
  203. WxsslVo firstItem = currentMonthList.get(0);
  204. firstItem.setName("当月");
  205. resultList.add(firstItem);
  206. }
  207. }
  208. String previousMonthEndDate = DateUtils.toDate1(DateUtils.getYestmonthLastday(date));
  209. String previousMonthBeginDate = DateUtils.toDate1(DateUtils.getFirstAndLastDayOfMonth(DateUtils.parseDate(previousMonthEndDate)));
  210. Map<String, Object> previousMonthList = benchmarkingService.cndbthb(companys, type, wpid, previousMonthBeginDate, previousMonthEndDate, pageNum, pageSize);
  211. if (previousMonthList != null && previousMonthList.containsKey("resultList")) {
  212. List<WxsslVo> previousMonthData = (List<WxsslVo>) previousMonthList.get("resultList");
  213. if (previousMonthData.size() > 0) {
  214. WxsslVo firstItem = previousMonthData.get(0);
  215. firstItem.setName("环比");
  216. resultList.add(firstItem);
  217. }
  218. }
  219. Date previousYearDate = DateUtils.subOneYear(date);
  220. String previousYearBeginDate = DateUtils.toDate1(DateUtils.getMonthFirstZero(DateUtils.toDate1(previousYearDate)));
  221. String previousYearEndDate = DateUtils.toDate1(DateUtils.getMonthLast(previousYearDate));
  222. Map<String, Object> previousYearList = benchmarkingService.cndbthb(companys, type, wpid, previousYearBeginDate, previousYearEndDate, pageNum, pageSize);
  223. if (previousYearList != null && previousYearList.containsKey("resultList")) {
  224. List<WxsslVo> previousYearData = (List<WxsslVo>) previousYearList.get("resultList");
  225. if (previousYearData.size() > 0) {
  226. WxsslVo firstItem = previousYearData.get(0);
  227. firstItem.setName("同比");
  228. resultList.add(firstItem);
  229. }
  230. }
  231. SortUtils.sort(resultList, "llfdl", SortUtils.DESC);
  232. for (int i = 0; i < resultList.size(); i++) {
  233. resultList.get(i).setZhpm(i + 1);
  234. }
  235. SortUtils.sort(resultList, "fdl", SortUtils.DESC);
  236. for (int i = 0; i < resultList.size(); i++) {
  237. resultList.get(i).setFdlpm(i + 1);
  238. }
  239. SortUtils.sort(resultList, "fnlyl", SortUtils.DESC);
  240. for (int i = 0; i < resultList.size(); i++) {
  241. resultList.get(i).setFnlylpm(i + 1);
  242. }
  243. SortUtils.sort(resultList, "gzssdl", SortUtils.ASC);
  244. for (int i = 0; i < resultList.size(); i++) {
  245. resultList.get(i).setGzssdlpm(i + 1);
  246. }
  247. SortUtils.sort(resultList, "gzssl", SortUtils.ASC);
  248. for (int i = 0; i < resultList.size(); i++) {
  249. resultList.get(i).setGzsslpm(i + 1);
  250. }
  251. SortUtils.sort(resultList, "jxssdl", SortUtils.ASC);
  252. for (int i = 0; i < resultList.size(); i++) {
  253. resultList.get(i).setJxssdlpm(i + 1);
  254. }
  255. SortUtils.sort(resultList, "jxssl", SortUtils.ASC);
  256. for (int i = 0; i < resultList.size(); i++) {
  257. resultList.get(i).setJxsslpm(i + 1);
  258. }
  259. SortUtils.sort(resultList, "xdssdl", SortUtils.ASC);
  260. for (int i = 0; i < resultList.size(); i++) {
  261. resultList.get(i).setXdssdlpm(i + 1);
  262. }
  263. SortUtils.sort(resultList, "qfl", SortUtils.ASC);
  264. for (int i = 0; i < resultList.size(); i++) {
  265. resultList.get(i).setQflpm(i + 1);
  266. }
  267. SortUtils.sort(resultList, "xnssdl", SortUtils.ASC);
  268. for (int i = 0; i < resultList.size(); i++) {
  269. resultList.get(i).setXnssdlpm(i + 1);
  270. }
  271. SortUtils.sort(resultList, "xnssl", SortUtils.ASC);
  272. for (int i = 0; i < resultList.size(); i++) {
  273. resultList.get(i).setXnsslpm(i + 1);
  274. }
  275. SortUtils.sort(resultList, "slssdl", SortUtils.ASC);
  276. for (int i = 0; i < resultList.size(); i++) {
  277. resultList.get(i).setSlssdlpm(i + 1);
  278. }
  279. SortUtils.sort(resultList, "slssl", SortUtils.ASC);
  280. for (int i = 0; i < resultList.size(); i++) {
  281. resultList.get(i).setSlsslpm(i + 1);
  282. }
  283. if (StringUtils.isNotNull(resultList)) {
  284. return R.data(ResultMsg.ok(resultList));
  285. } else {
  286. return R.error(ResultMsg.error());
  287. }
  288. }
  289. @GetMapping("/cjdb")
  290. @ResponseBody
  291. @ApiOperation(value = "场际对标", notes = "场际对标")
  292. public R cjdb(@RequestParam(value = "companys", required = true) String companys,
  293. @RequestParam(value = "type", required = true) String type,
  294. @RequestParam(value = "wpids", required = true) String wpids,
  295. @RequestParam(value = "beginDate", required = true) String beginDate,
  296. @RequestParam(value = "endDate", required = true) String endDate,
  297. @RequestParam(value = "target", required = true) String target,
  298. @RequestParam(value = "sort", required = true) String sort,
  299. @RequestParam(value = "pageNum", required = true) int pageNum,
  300. @RequestParam(value = "pageSize", required = true) int pageSize
  301. ) {
  302. Map<String, Object> resultList = benchmarkingService.cjdb(companys, type, wpids, beginDate, endDate, target, sort, pageNum, pageSize);
  303. if (StringUtils.isNotNull(resultList)) {
  304. return R.data(ResultMsg.ok(resultList));
  305. } else {
  306. return R.error(ResultMsg.error());
  307. }
  308. }
  309. @GetMapping("/xmdb")
  310. @ResponseBody
  311. @ApiOperation(value = "项目对标", notes = "项目对标")
  312. public R xmdb(@RequestParam(value = "companys", required = true) String companys,
  313. @RequestParam(value = "type", required = true) String type,
  314. @RequestParam(value = "wpids", required = true) String wpids,
  315. @RequestParam(value = "projectids", required = true) String projectids,
  316. @RequestParam(value = "beginDate", required = true) String beginDate,
  317. @RequestParam(value = "endDate", required = true) String endDate,
  318. @RequestParam(value = "target", required = true) String target,
  319. @RequestParam(value = "sort", required = true) String sort,
  320. @RequestParam(value = "pageNum", required = true) int pageNum,
  321. @RequestParam(value = "pageSize", required = true) int pageSize
  322. ) {
  323. Map<String, Object> resultList = benchmarkingService.xmdb(companys, type, wpids, projectids, beginDate, endDate, target, sort, pageNum, pageSize);
  324. if (StringUtils.isNotNull(resultList)) {
  325. return R.data(ResultMsg.ok(resultList));
  326. } else {
  327. return R.error(ResultMsg.error());
  328. }
  329. }
  330. @GetMapping("/xldb")
  331. @ResponseBody
  332. @ApiOperation(value = "线路对标", notes = "线路对标")
  333. public R xldb(@RequestParam(value = "companys", required = true) String companys,
  334. @RequestParam(value = "type", required = true) String type,
  335. @RequestParam(value = "wpids", required = true) String wpids,
  336. @RequestParam(value = "projectids", required = true) String projectids,
  337. @RequestParam(value = "lineids", required = true) String lineids,
  338. @RequestParam(value = "beginDate", required = true) String beginDate,
  339. @RequestParam(value = "endDate", required = true) String endDate,
  340. @RequestParam(value = "target", required = true) String target,
  341. @RequestParam(value = "sort", required = true) String sort,
  342. @RequestParam(value = "pageNum", required = true) int pageNum,
  343. @RequestParam(value = "pageSize", required = true) int pageSize
  344. ) {
  345. Map<String, Object> resultList = benchmarkingService.xldb(companys, type, wpids, projectids, lineids, beginDate, endDate, target, sort, pageNum, pageSize);
  346. if (StringUtils.isNotNull(resultList)) {
  347. return R.data(ResultMsg.ok(resultList));
  348. } else {
  349. return R.error(ResultMsg.error());
  350. }
  351. }
  352. /**
  353. * 对标页面详情
  354. *
  355. * @param beginDate
  356. * @param endDate
  357. * @return
  358. */
  359. @GetMapping("/details")
  360. @ResponseBody
  361. @ApiOperation(value = "对标详情", notes = "对标详情")
  362. public R details(@RequestParam(value = "id", required = true) String id,
  363. @RequestParam(value = "beginDate", required = true) String beginDate,
  364. @RequestParam(value = "endDate", required = true) String endDate,
  365. @RequestParam(value = "target", required = true) String target,
  366. @RequestParam(value = "sort", required = true) String sort,
  367. @RequestParam(value = "pageNum", required = true) int pageNum,
  368. @RequestParam(value = "pageSize", required = true) int pageSize
  369. ) {
  370. Map<String, Object> resultList = benchmarkingService.details(id, beginDate, endDate, target, sort, pageNum, pageSize);
  371. if (StringUtils.isNotNull(resultList)) {
  372. return R.data(ResultMsg.ok(resultList));
  373. } else {
  374. return R.error(ResultMsg.error());
  375. }
  376. }
  377. }