package com.gyee.runeconomy.controller.goodness; import cn.hutool.core.util.NumberUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.gyee.common.util.DateUtils; import com.gyee.common.vo.benchmark.ValueVo; import com.gyee.runeconomy.dto.DataVo; import com.gyee.runeconomy.dto.R; import com.gyee.runeconomy.dto.ResultMsg; import com.gyee.runeconomy.dto.SawVo; import com.gyee.runeconomy.init.CacheContext; import com.gyee.runeconomy.model.auto.*; import com.gyee.runeconomy.service.auto.*; import com.gyee.runeconomy.util.StringUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import java.time.LocalDate; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.*; /** * 风机明细信息页面 */ @Controller @RequestMapping("/goodness") @Api(value = "单机信息总览详细信息", tags = "单机信息总览详细信息") public class WindturbineGoodnessDetailController { @Resource private IProEconWindturbineGoodnessService proEconWindturbineGoodnessService; @Resource private IProEconWtwindDayInfoService proEconWtwindDayInfoService; @Resource private IProEconWtAlysisDayService proEconWtAlysisDayService; @Resource private IProEconWtCurveFittingMonthService proEconWtCurveFittingMonthService; private String jfpl; @Resource private ITurbineInfoDayService turbineInfoDayService; /** * 获得明细页面显示信息 * * @param wtId * @param recorddate * @return */ @GetMapping("/wadAjax") @ResponseBody @ApiOperation(value = "查询明细页面显示信息", notes = "查询明细页面显示信息") @ApiImplicitParams({ @ApiImplicitParam(name = "wtId", value = "风机编号", required = true, dataType = "string", paramType = "query"), @ApiImplicitParam(name = "recorddate", value = "日期", required = true, dataType = "string", paramType = "query")}) public R wadAjax(String wtId, String recorddate) { ProEconWtAlysisDay wtday = new ProEconWtAlysisDay(); if (StringUtils.notEmp(wtId) && StringUtils.notEmp(recorddate)) { Date date = DateUtils.parseDate(recorddate); LocalDate localDate = LocalDate.parse(recorddate, DateTimeFormatter.ISO_LOCAL_DATE); LocalDate firstOfMonth = localDate.withDayOfMonth(1); Date firstDayOfMonth = Date.from(firstOfMonth.atStartOfDay(ZoneId.systemDefault()).toInstant()); LocalDate localdate2 = localDate.withDayOfYear(1); Date firstDayOfYear = Date.from(localdate2.atStartOfDay(ZoneId.systemDefault()).toInstant()); QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("record_date", date).eq("windturbine_id", wtId); List wtadls = proEconWtAlysisDayService.list(queryWrapper); // .stream().filter(i->i.getWindturbineId().equals(wtId ) // && i.getRecordDate().compareTo(date)==0 // ).collect(Collectors.toList()); if (!wtadls.isEmpty()) { wtday = wtadls.get(0); QueryWrapper qw = new QueryWrapper<>(); qw.lambda().eq(TurbineInfoDay::getRecordDate, date).eq(TurbineInfoDay::getTurbineId, wtId); List turbineInfoDays = turbineInfoDayService.list(qw); TurbineInfoDay ytb = turbineInfoDayService.getTurbineSingle(wtId, firstDayOfMonth, date); TurbineInfoDay ntb = turbineInfoDayService.getTurbineSingle(wtId, firstDayOfYear, date); TurbineInfoDay tb = turbineInfoDays.get(0); wtday.setRfdl(NumberUtil.round(tb.getRfdl() / 1000, 2).doubleValue()); wtday.setRyfdl(NumberUtil.round(tb.getLlfdl() / 1000, 2).doubleValue()); wtday.setRpjfs(NumberUtil.round(tb.getPjfs(), 2).doubleValue()); wtday.setRyxxs(NumberUtil.round(tb.getYxMin() / 60, 2).doubleValue()); wtday.setRjxxs(NumberUtil.round(tb.getTjMin() / 60, 2).doubleValue()); wtday.setRgzxs(NumberUtil.round(tb.getGzMin() / 60, 2).doubleValue()); wtday.setRdjxs(NumberUtil.round(tb.getDjMin() / 60, 2).doubleValue()); wtday.setRzdxs(NumberUtil.round(tb.getLxMin() / 60, 2).doubleValue()); wtday.setRyxfs(NumberUtil.round(tb.getYxfss(), 2).doubleValue()); wtday.setRssdl(NumberUtil.round((tb.getGzss() + tb.getSlss() + tb.getXdss() + tb.getJhjxss() + tb.getFjhjxss() + tb.getXnss()) / 1000, 2).doubleValue()); wtday.setRtjcs(NumberUtil.round(tb.getTjcs(), 2).doubleValue()); wtday.setRsbklyl(NumberUtil.round(tb.getKlyl(), 2).doubleValue()); wtday.setRpjwd(NumberUtil.round(tb.getHjwd(), 2).doubleValue()); wtday.setYfdl(NumberUtil.round(ytb.getRfdl() / 1000, 2).doubleValue()); wtday.setYyfdl(NumberUtil.round(ytb.getLlfdl() / 1000, 2).doubleValue()); wtday.setYpjfs(NumberUtil.round(ytb.getPjfs(), 2).doubleValue()); wtday.setYyxxs(NumberUtil.round(ytb.getYxMin() / 60, 2).doubleValue()); wtday.setYdjxs(NumberUtil.round(ytb.getTjMin() / 60, 2).doubleValue()); wtday.setYgzxs(NumberUtil.round(ytb.getGzMin() / 60, 2).doubleValue()); wtday.setYjxxs(NumberUtil.round(ytb.getJxMin() / 60, 2).doubleValue()); wtday.setYzdxs(NumberUtil.round(ytb.getLxMin() / 60, 2).doubleValue()); wtday.setYyxfs(NumberUtil.round(ytb.getYxfss(), 2).doubleValue()); wtday.setYtjcs(NumberUtil.round(ytb.getTjcs(), 2).doubleValue()); wtday.setNfdl(NumberUtil.round(ntb.getRfdl() / 1000, 2).doubleValue()); wtday.setNyfdl(NumberUtil.round(ntb.getLlfdl() / 1000, 2).doubleValue()); wtday.setNpjfs(NumberUtil.round(ntb.getPjfs(), 2).doubleValue()); wtday.setNyxxs(NumberUtil.round(ntb.getYxMin() / 60, 2).doubleValue()); wtday.setNgzxs(NumberUtil.round(ntb.getGzMin() / 60, 2).doubleValue()); wtday.setNjxxs(NumberUtil.round(ntb.getJxMin() / 60, 2).doubleValue()); wtday.setNzdxs(NumberUtil.round(ntb.getTjMin() / 60, 2).doubleValue()); wtday.setNyxfs(NumberUtil.round(ntb.getYxfss(), 2).doubleValue()); } } if (null != wtday) { return R.data(ResultMsg.ok(wtday)); } else { return R.data(ResultMsg.error()); } } /* * 单台风机当月报警排行 */ @PostMapping("/bjphlist") @ResponseBody @ApiOperation(value = "单台风机当月报警排行", notes = "单台风机当月报警排行") @ApiImplicitParams({ @ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "Integer", paramType = "query"), @ApiImplicitParam(name = "pageSize", value = "每页数量", required = true, dataType = "Integer", paramType = "query"), @ApiImplicitParam(name = "wtId", value = "风机编号", required = true, dataType = "string", paramType = "query"), @ApiImplicitParam(name = "recorddate", value = "日期", required = true, dataType = "string", paramType = "query")}) public R bjphlist(Integer pageNum, Integer pageSize, String wtId, String recorddate) { List resultList = new ArrayList<>(); if (StringUtils.notEmp(wtId) && StringUtils.notEmp(recorddate)) { Calendar cal = Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.setTime(DateUtils.parseDate(recorddate)); Date beginDate = cal.getTime(); cal.add(Calendar.DAY_OF_MONTH, 1); Date endDate = cal.getTime(); // resultList = alarmsnapService.getWarningRecordsTop(tablepar, wtId, beginDate, endDate); } if (null != resultList) { return R.data(ResultMsg.ok(resultList)); } else { return R.data(ResultMsg.error()); } } /* * 获取明细页面功率曲线 */ @GetMapping("/glchat") @ResponseBody @ApiOperation(value = "获取明细页面功率曲线", notes = "获取明细页面功率曲线") @ApiImplicitParams({ @ApiImplicitParam(name = "wtId", value = "风机编号", required = true, dataType = "string", paramType = "query"), @ApiImplicitParam(name = "recorddate", value = "日期", required = true, dataType = "string", paramType = "query")}) public R glchat(String wtId, String recorddate) { List datavos = new ArrayList<>(); if (StringUtils.notEmp(wtId) && StringUtils.notEmp(recorddate)) { Date date = DateUtils.parseDate(recorddate); Map> modelPowermap = CacheContext.theoreticalPowerMap; Map wtmap = CacheContext.wtmap; Map map = null; Calendar cal = Calendar.getInstance(); cal.setTime(date); int year = cal.get(Calendar.YEAR); int month = cal.get(Calendar.MONTH) + 1; QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("windturbine_id", wtId).eq("year", String.valueOf(year)).eq("month", String.valueOf(month)); List wcls = proEconWtCurveFittingMonthService.list(queryWrapper); // .stream().filter(i-> // i.getWindturbineId().equals(wtId) // && i.getYear().equals(String.valueOf(year)) && i.getMonth().equals(String.valueOf(month)) // ).collect(Collectors.toList()); if (!wcls.isEmpty()) { if (wtmap.containsKey(wtId)) { ProBasicEquipment wt = wtmap.get(wtId); if (modelPowermap.containsKey(wt.getModelId())) { map = modelPowermap.get(wt.getModelId()); } } double temp = 0.0; for (ProEconWtCurveFittingMonth wc : wcls) { DataVo vo = new DataVo(); int c = (int) wc.getSpeed().intValue(); if (c == wc.getSpeed()) { vo.setValue1(wc.getSpeed());// 风速 vo.setValue2(wc.getActualPower());// 实际拟合功率 vo.setValue3(wc.getOptimalPower());// 最优拟合功率 if (null != map && StringUtils.notEmp(wc.getSpeed()) && map.containsKey(wc.getSpeed())) { ProBasicModelPowerRd mp = map.get(wc.getSpeed()); vo.setValue4(mp.getEnsurePower());// 保证功率曲线 temp = mp.getEnsurePower(); } else { vo.setValue4(temp);// 保证功率曲线 } datavos.add(vo); } } } } if (null != datavos) { return R.data(ResultMsg.ok(datavos)); } else { return R.data(ResultMsg.error()); } } /* * 获取风机风资源 */ @GetMapping("/fjfzy") @ResponseBody @ApiOperation(value = "获取风机风资源", notes = "获取风机风资源") @ApiImplicitParams({ @ApiImplicitParam(name = "wtId", value = "风机编号", required = true, dataType = "string", paramType = "query"), @ApiImplicitParam(name = "recorddate", value = "日期", required = true, dataType = "string", paramType = "query")}) public R fjfzy(String wtId, String recorddate) { Map map = new HashMap(); List vos = new ArrayList(); if (StringUtils.notEmp(wtId) && StringUtils.notEmp(recorddate)) { Date date = DateUtils.parseDate(recorddate); QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("windturbine_id", wtId).eq("record_date", date); List wtdls = proEconWtwindDayInfoService.list(queryWrapper); // .stream().filter(i-> // i.getWindturbineId().equals(wtId) // && i.getRecordDate().compareTo(date) ==0 // ).collect(Collectors.toList()); if (!wtdls.isEmpty()) { ProEconWtwindDayInfo winfo = wtdls.get(0); int c = (int) winfo.getCb().intValue(); jfpl = "静风频率为" + c; for (int i = 0; i < 16; i++) { ValueVo vo = new ValueVo(); switch (i) { case 0: // vo.setName("N("+winfo.getN4()+"/"+winfo.getN()+")"); vo.setName("N"); vo.setData1(winfo.getN2()); break; case 1: // vo.setName("NNE("+winfo.getNne4()+"/"+winfo.getNne()+")"); vo.setName("NNE"); vo.setData1(winfo.getNne2()); break; case 2: // vo.setName("NE("+winfo.getNe4()+"/"+winfo.getNe()+")"); vo.setName("NE"); vo.setData1(winfo.getNe2()); break; case 3: // vo.setName("ENE("+winfo.getEne4()+"/"+winfo.getEne()+")"); vo.setName("ENE"); vo.setData1(winfo.getEne2()); break; case 4: // vo.setName("E("+winfo.getE4()+"/"+winfo.getE()+")"); vo.setName("E"); vo.setData1(winfo.getE2()); break; case 5: // vo.setName("ESE("+winfo.getEse()+"/"+winfo.getEse()+")"); vo.setName("ESE"); vo.setData1(winfo.getEse2()); break; case 6: // vo.setName("SE("+winfo.getSe4()+"/"+winfo.getSe()+")"); vo.setName("SE"); vo.setData1(winfo.getSe2()); break; case 7: // vo.setName("SSE("+winfo.getSse4()+"/"+winfo.getSse()+")"); vo.setName("SSE"); vo.setData1(winfo.getSse2()); break; case 8: // vo.setName("S("+winfo.getS4()+"/"+winfo.getS()+")"); vo.setName("S"); vo.setData1(winfo.getS2()); break; case 9: // vo.setName("SSW("+winfo.getSsw4()+"/"+winfo.getSsw()+")"); vo.setName("SSW"); vo.setData1(winfo.getSsw2()); break; case 10: // vo.setName("SW("+winfo.getSw4()+"/"+winfo.getSw()+")"); vo.setName("SW"); vo.setData1(winfo.getSw2()); break; case 11: // vo.setName("WSW("+winfo.getWsw4()+"/"+winfo.getWsw()+")"); vo.setName("WSW"); vo.setData1(winfo.getWsw2()); break; case 12: // vo.setName("W("+winfo.getW4()+"/"+winfo.getW()+")"); vo.setName("W"); vo.setData1(winfo.getW2()); break; case 13: // vo.setName("WNW("+winfo.getWnw4()+"/"+winfo.getWnw()+")"); vo.setName("WNW"); vo.setData1(winfo.getWnw2()); break; case 14: // vo.setName("NW("+winfo.getNw4()+"/"+winfo.getNw()+")"); vo.setName("NW"); vo.setData1(winfo.getNw2()); break; case 15: // vo.setName("NNW("+winfo.getNnw4()+"/"+winfo.getNnw()+")"); vo.setName("NNW"); vo.setData1(winfo.getNnw2()); break; default: break; } vos.add(vo); } map.put("jfpl", jfpl); map.put("data", vos); } } if (null != map) { return R.data(ResultMsg.ok(map)); } else { return R.data(ResultMsg.error()); } } }