123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387 |
- 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<ProEconWtAlysisDay> queryWrapper = new QueryWrapper<>();
- queryWrapper.eq("record_date", date).eq("windturbine_id", wtId);
- List<ProEconWtAlysisDay> 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<TurbineInfoDay> qw = new QueryWrapper<>();
- qw.lambda().eq(TurbineInfoDay::getRecordDate, date).eq(TurbineInfoDay::getTurbineId, wtId);
- List<TurbineInfoDay> 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<SawVo> 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<DataVo> datavos = new ArrayList<>();
- if (StringUtils.notEmp(wtId) && StringUtils.notEmp(recorddate)) {
- Date date = DateUtils.parseDate(recorddate);
- Map<String, Map<Double, ProBasicModelPowerRd>> modelPowermap = CacheContext.theoreticalPowerMap;
- Map<String, ProBasicEquipment> wtmap = CacheContext.wtmap;
- Map<Double, ProBasicModelPowerRd> map = null;
- Calendar cal = Calendar.getInstance();
- cal.setTime(date);
- int year = cal.get(Calendar.YEAR);
- int month = cal.get(Calendar.MONTH) + 1;
- QueryWrapper<ProEconWtCurveFittingMonth> queryWrapper = new QueryWrapper<>();
- queryWrapper.eq("windturbine_id", wtId).eq("year", String.valueOf(year)).eq("month", String.valueOf(month));
- List<ProEconWtCurveFittingMonth> 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<String, Object> map = new HashMap<String, Object>();
- List<ValueVo> vos = new ArrayList<ValueVo>();
- if (StringUtils.notEmp(wtId) && StringUtils.notEmp(recorddate)) {
- Date date = DateUtils.parseDate(recorddate);
- QueryWrapper<ProEconWtwindDayInfo> queryWrapper = new QueryWrapper<>();
- queryWrapper.eq("windturbine_id", wtId).eq("record_date", date);
- List<ProEconWtwindDayInfo> 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());
- }
- }
- }
|