Commit 543beff0 authored by caotao's avatar caotao

1.户用光伏数据日报表接口开发。

parent a1299823
......@@ -12,6 +12,12 @@ public class TdHYGFInverterDayGenerate implements Serializable {
* 创建时间
*/
private Long createdTime;
/**
* 创建时间
*/
private String createdTimeStr;
/**
* 第三方场站id
*/
......
package com.yeejoin.amos.boot.module.hygf.biz.controller;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.yeejoin.amos.boot.module.hygf.api.entity.TdHYGFInverterDayGenerate;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -9,6 +10,7 @@ import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import org.springframework.core.io.Resource;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
......@@ -21,7 +23,9 @@ import com.yeejoin.amos.boot.module.hygf.biz.service.impl.JpInverterServiceImpl;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
......@@ -57,7 +61,6 @@ public class JpInverterController extends BaseController {
private Resource paramsTree;
/**
* 新增户用光伏监盘逆变器表
*
......@@ -110,11 +113,11 @@ public class JpInverterController extends BaseController {
@GetMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "GET", value = "根据sequenceNbr查询单个户用光伏监盘逆变器表", notes = "根据sequenceNbr查询单个户用光伏监盘逆变器表")
public ResponseModel<JpInverterDto> selectOne(@PathVariable Long sequenceNbr) {
JpInverterDto jpInverter= jpInverterServiceImpl.queryBySeq(sequenceNbr);
jpInverter.setDayPowerGeneration(jpInverter.getDayPowerGeneration()!=null?jpInverter.getDayPowerGeneration()/1000:0);
jpInverter.setMonthPowerGeneration(jpInverter.getMonthPowerGeneration()!=null?jpInverter.getMonthPowerGeneration()/1000:0);
jpInverter.setYearPowerGeneration(jpInverter.getYearPowerGeneration()!=null?jpInverter.getYearPowerGeneration()/1000:0);
jpInverter.setTotalPowerGeneration(jpInverter.getTotalPowerGeneration()!=null?jpInverter.getTotalPowerGeneration()/1000:0);
JpInverterDto jpInverter = jpInverterServiceImpl.queryBySeq(sequenceNbr);
jpInverter.setDayPowerGeneration(jpInverter.getDayPowerGeneration() != null ? jpInverter.getDayPowerGeneration() / 1000 : 0);
jpInverter.setMonthPowerGeneration(jpInverter.getMonthPowerGeneration() != null ? jpInverter.getMonthPowerGeneration() / 1000 : 0);
jpInverter.setYearPowerGeneration(jpInverter.getYearPowerGeneration() != null ? jpInverter.getYearPowerGeneration() / 1000 : 0);
jpInverter.setTotalPowerGeneration(jpInverter.getTotalPowerGeneration() != null ? jpInverter.getTotalPowerGeneration() / 1000 : 0);
return ResponseHelper.buildResponse(jpInverter);
}
......@@ -131,13 +134,13 @@ public class JpInverterController extends BaseController {
public ResponseModel<Page<JpInverterDto>> queryForPage(@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size, JpInverterDto jpInverterDto) {
List<JpPersonStation> pPersonStation =null;
if(jpInverterDto.getName()!=null&&!"".equals(jpInverterDto.getName())){
LambdaQueryWrapper<JpPersonStation> qug1=new LambdaQueryWrapper<>();
qug1.like(JpPersonStation::getStationName,jpInverterDto.getName());
pPersonStation=pPersonStationMapper.selectList(qug1);
List<JpPersonStation> pPersonStation = null;
if (jpInverterDto.getName() != null && !"".equals(jpInverterDto.getName())) {
LambdaQueryWrapper<JpPersonStation> qug1 = new LambdaQueryWrapper<>();
qug1.like(JpPersonStation::getStationName, jpInverterDto.getName());
pPersonStation = pPersonStationMapper.selectList(qug1);
}else{
} else {
LambdaQueryWrapper<JpPersonStation> qug = new LambdaQueryWrapper<>();
qug.eq(JpPersonStation::getPersonId, getUserInfo().getUserId());
pPersonStation = pPersonStationMapper.selectList(qug);
......@@ -177,13 +180,12 @@ public class JpInverterController extends BaseController {
page.setCurrent(current);
page.setSize(size);
page.setTotal(jpInverterServiceImpl.selectPageDataTota(jpInverterDto));
page.setRecords(jpInverterServiceImpl.selectPageData(jpInverterDto,(current-1)*size,size));
page.setRecords(jpInverterServiceImpl.selectPageData(jpInverterDto, (current - 1) * size, size));
return ResponseHelper.buildResponse(page);
}
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/selectParamTree")
@ApiOperation(httpMethod = "GET", value = "逆变器图标 选择参数树", notes = "逆变器图标 选择参数树")
public ResponseModel<List<Map>> selectParamTree() {
......@@ -198,19 +200,24 @@ public class JpInverterController extends BaseController {
return ResponseHelper.buildResponse(list);
}
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/jpInverterTrend")
@ApiOperation(httpMethod = "GET", value = "逆变器图标 折线图", notes = "逆变器图标 折线图")
public void jpInverterTrend (List<String> treeParams,String type,String time ,String snCode,String thirdStationId ){
public void jpInverterTrend(List<String> treeParams, String type, String time, String snCode, String thirdStationId) {
if (CollectionUtils.isNotEmpty(treeParams)){
if (CollectionUtils.isNotEmpty(treeParams)) {
jpInverterServiceImpl.selectDayTrend(treeParams,time,snCode,thirdStationId);
jpInverterServiceImpl.selectDayTrend(treeParams, time, snCode, thirdStationId);
}
// jpInverterServiceImpl.
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/jpInverterDayReport")
@ApiOperation(httpMethod = "GET", value = "逆变器日报表", notes = "逆变器日报表")
public ResponseModel<Page<TdHYGFInverterDayGenerate>> jpInverterDayReport(@RequestParam(value = "current") int current, @RequestParam(value = "size") int size, String time, @RequestParam(required = false) List<String> snCodes) {
return ResponseHelper.buildResponse(jpInverterServiceImpl.jpInverterDayReport(current,size,time,snCodes));
}
}
package com.yeejoin.amos.boot.module.hygf.biz.service.impl;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.module.hygf.api.config.UserLimits;
import com.yeejoin.amos.boot.module.hygf.api.entity.TdHYGFInverterDayGenerate;
import com.yeejoin.amos.boot.module.hygf.api.tdenginemapper.TdHYGFInverterDayGenerateMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
......@@ -25,7 +34,8 @@ import com.yeejoin.amos.boot.module.hygf.api.service.IJpInverterService;
@Service
public class JpInverterServiceImpl extends BaseService<JpInverterDto, JpInverter, JpInverterMapper>
implements IJpInverterService {
@Autowired
TdHYGFInverterDayGenerateMapper tdHYGFInverterDayGenerateMapper;
/**
......@@ -37,7 +47,7 @@ public class JpInverterServiceImpl extends BaseService<JpInverterDto, JpInverter
if (jpInverterDto.getState() != null) {
wrapper.eq(JpInverter::getState, jpInverterDto.getState());
}
if(StringUtils.isNotEmpty(jpInverterDto.getSnCode())) {
if (StringUtils.isNotEmpty(jpInverterDto.getSnCode())) {
wrapper.like(JpInverter::getSnCode, jpInverterDto.getSnCode());
}
if (!jpInverterDto.getStationIds().isEmpty()) {
......@@ -66,7 +76,7 @@ public class JpInverterServiceImpl extends BaseService<JpInverterDto, JpInverter
@UserLimits
public List<JpInverterDto> selectPageData(JpInverterDto jpInverterDto, int current, int size) {
return this.getBaseMapper().selectPageData(jpInverterDto,current,size);
return this.getBaseMapper().selectPageData(jpInverterDto, current, size);
}
@UserLimits
......@@ -77,7 +87,30 @@ public class JpInverterServiceImpl extends BaseService<JpInverterDto, JpInverter
public void selectDayTrend(List<String> treeParams, String time, String snCode, String thirdStationId) {
}
public Page<TdHYGFInverterDayGenerate> jpInverterDayReport(int current, int size, String time, List<String> sncodes) {
Page<TdHYGFInverterDayGenerate> tdHYGFInverterDayGeneratePage = new Page<>();
Date date = DateUtil.parse(time, "yyyy-MM-dd");
String startTime = DateUtil.format(date, "yyyy-MM-dd") + "00:00:00";
String endTime = DateUtil.format(date, "yyyy-MM-dd") + "23:59:59";
QueryWrapper queryWrapper = new QueryWrapper<TdHYGFInverterDayGenerate>()
.ge("created_time", startTime)
.le("created_time", endTime);
if (CollectionUtil.isNotEmpty(sncodes)) {
queryWrapper.in("sn_code", sncodes);
}
queryWrapper.orderByDesc("created_time");
List<TdHYGFInverterDayGenerate> tdHYGFInverterDayGenerates = tdHYGFInverterDayGenerateMapper.selectList(queryWrapper);
tdHYGFInverterDayGeneratePage.setTotal(tdHYGFInverterDayGenerates.size());
tdHYGFInverterDayGeneratePage.setSize(size);
tdHYGFInverterDayGeneratePage.setCurrent(current);
tdHYGFInverterDayGenerates=tdHYGFInverterDayGenerates.subList((current-1)*size,current*size>tdHYGFInverterDayGenerates.size()?tdHYGFInverterDayGenerates.size():current*size);
tdHYGFInverterDayGenerates.forEach(tdHYGFInverterDayGenerate -> {
Date date1=new Date(tdHYGFInverterDayGenerate.getCreatedTime());
tdHYGFInverterDayGenerate.setCreatedTimeStr(DateUtil.format(date1, DatePattern.NORM_DATETIME_PATTERN));
});
tdHYGFInverterDayGeneratePage.setRecords(tdHYGFInverterDayGenerates);
return tdHYGFInverterDayGeneratePage;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment