Commit 9513c97e authored by wujiang's avatar wujiang

添加日收益接口

parent ad930d78
package com.yeejoin.amos.boot.module.hygf.api.tdenginemapper;
import com.yeejoin.amos.boot.module.hygf.api.entity.TdHygfJpInverterHistory;
import java.util.Map;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.hygf.api.entity.TdHygfJpInverterHistory;
/**
* 户用光伏监盘逆变器历史表 Mapper 接口
......@@ -11,4 +15,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface TdHygfJpInverterHistoryMapper extends BaseMapper<TdHygfJpInverterHistory> {
Map<String, Object> sum(@Param("snCode") String snCode, @Param("thirdStationId") String thirdStationId,
@Param("date") String date);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.hygf.api.tdenginemapper.TdHygfJpInverterHistoryMapper">
<select id="dayList" resultType="com.yeejoin.amos.boot.module.hygf.api.dto.TdHygfJpCollectorHistoryDto">
SELECT * FROM house_pv_data.td_hygf_jp_collector_history
<select id="sum" resultType="Map">
SELECT sum(power_generation) AS power,sum(daily_return) AS dailyReturn,sum(generation_hours) AS hours FROM house_pv_data.td_hygf_jp_inverter_history
<where>
<if test="snCode!=null">
AND `sn_code` = #{snCode}
</if>
<if test="thirdStationId!=null">
<if test="thirdStationId!=null">
AND `third_station_id` = #{thirdStationId}
</if>
<if test="startTime!=null and endTime!=null">
AND time BETWEEN #{startTime} AND #{endTime}
<if test="date!=null">
AND `date` LIKE '%'#{date}'%'
</if>
</where>
</select>
......
package com.yeejoin.amos.boot.module.hygf.biz.controller;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import java.util.List;
import com.yeejoin.amos.boot.module.hygf.biz.service.impl.TdHygfJpInverterHistoryServiceImpl;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
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.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.hygf.api.dto.TdHygfJpInverterHistoryDto;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import com.yeejoin.amos.boot.module.hygf.biz.service.impl.TdHygfJpInverterHistoryServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/**
* 户用光伏监盘逆变器历史表
......@@ -28,88 +39,105 @@ import org.typroject.tyboot.core.foundation.enumeration.UserType;
@RequestMapping(value = "/td-hygf-jp-inverter-history")
public class TdHygfJpInverterHistoryController extends BaseController {
@Autowired
TdHygfJpInverterHistoryServiceImpl tdHygfJpInverterHistoryServiceImpl;
@Autowired
TdHygfJpInverterHistoryServiceImpl tdHygfJpInverterHistoryServiceImpl;
/**
* 新增户用光伏监盘逆变器历史表
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
/**
* 新增户用光伏监盘逆变器历史表
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增户用光伏监盘逆变器历史表", notes = "新增户用光伏监盘逆变器历史表")
public ResponseModel<TdHygfJpInverterHistoryDto> save(@RequestBody TdHygfJpInverterHistoryDto model) {
model = tdHygfJpInverterHistoryServiceImpl.createWithModel(model);
return ResponseHelper.buildResponse(model);
model = tdHygfJpInverterHistoryServiceImpl.createWithModel(model);
return ResponseHelper.buildResponse(model);
}
/**
* 根据sequenceNbr更新
*
* @param sequenceNbr 主键
* @return
*/
* 根据sequenceNbr更新
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PutMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新户用光伏监盘逆变器历史表", notes = "根据sequenceNbr更新户用光伏监盘逆变器历史表")
public ResponseModel<TdHygfJpInverterHistoryDto> updateBySequenceNbrTdHygfJpInverterHistory(@RequestBody TdHygfJpInverterHistoryDto model,@PathVariable(value = "sequenceNbr") Long sequenceNbr) {
return ResponseHelper.buildResponse(tdHygfJpInverterHistoryServiceImpl.updateWithModel(model));
public ResponseModel<TdHygfJpInverterHistoryDto> updateBySequenceNbrTdHygfJpInverterHistory(
@RequestBody TdHygfJpInverterHistoryDto model, @PathVariable(value = "sequenceNbr") Long sequenceNbr) {
return ResponseHelper.buildResponse(tdHygfJpInverterHistoryServiceImpl.updateWithModel(model));
}
/**
* 根据sequenceNbr删除
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@DeleteMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "DELETE", value = "根据sequenceNbr删除户用光伏监盘逆变器历史表", notes = "根据sequenceNbr删除户用光伏监盘逆变器历史表")
public ResponseModel<Boolean> deleteBySequenceNbr(HttpServletRequest request, @PathVariable(value = "sequenceNbr") Long sequenceNbr){
return ResponseHelper.buildResponse(tdHygfJpInverterHistoryServiceImpl.removeById(sequenceNbr));
}
* 根据sequenceNbr删除
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@DeleteMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "DELETE", value = "根据sequenceNbr删除户用光伏监盘逆变器历史表", notes = "根据sequenceNbr删除户用光伏监盘逆变器历史表")
public ResponseModel<Boolean> deleteBySequenceNbr(HttpServletRequest request,
@PathVariable(value = "sequenceNbr") Long sequenceNbr) {
return ResponseHelper.buildResponse(tdHygfJpInverterHistoryServiceImpl.removeById(sequenceNbr));
}
/**
* 根据sequenceNbr查询
*
* @param sequenceNbr 主键
* @return
*/
/**
* 根据sequenceNbr查询
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "GET",value = "根据sequenceNbr查询单个户用光伏监盘逆变器历史表", notes = "根据sequenceNbr查询单个户用光伏监盘逆变器历史表")
@ApiOperation(httpMethod = "GET", value = "根据sequenceNbr查询单个户用光伏监盘逆变器历史表", notes = "根据sequenceNbr查询单个户用光伏监盘逆变器历史表")
public ResponseModel<TdHygfJpInverterHistoryDto> selectOne(@PathVariable Long sequenceNbr) {
return ResponseHelper.buildResponse(tdHygfJpInverterHistoryServiceImpl.queryBySeq(sequenceNbr));
return ResponseHelper.buildResponse(tdHygfJpInverterHistoryServiceImpl.queryBySeq(sequenceNbr));
}
/**
* 列表分页查询
*
* @param current 当前页
* @param current 每页大小
* @return
*/
* 列表分页查询
*
* @param current 当前页
* @param current 每页大小
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/page")
@ApiOperation(httpMethod = "GET",value = "户用光伏监盘逆变器历史表分页查询", notes = "户用光伏监盘逆变器历史表分页查询")
public ResponseModel<Page<TdHygfJpInverterHistoryDto>> queryForPage(@RequestParam(value = "current") int current,@RequestParam
(value = "size") int size) {
Page<TdHygfJpInverterHistoryDto> page = new Page<TdHygfJpInverterHistoryDto>();
page.setCurrent(current);
page.setSize(size);
return ResponseHelper.buildResponse(tdHygfJpInverterHistoryServiceImpl.queryForTdHygfJpInverterHistoryPage(page));
@ApiOperation(httpMethod = "GET", value = "户用光伏监盘逆变器历史表分页查询", notes = "户用光伏监盘逆变器历史表分页查询")
public ResponseModel<Page<TdHygfJpInverterHistoryDto>> queryForPage(@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size) {
Page<TdHygfJpInverterHistoryDto> page = new Page<TdHygfJpInverterHistoryDto>();
page.setCurrent(current);
page.setSize(size);
return ResponseHelper
.buildResponse(tdHygfJpInverterHistoryServiceImpl.queryForTdHygfJpInverterHistoryPage(page));
}
/**
* 列表全部数据查询
*
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET",value = "户用光伏监盘逆变器历史表列表全部数据查询", notes = "户用光伏监盘逆变器历史表列表全部数据查询")
@ApiOperation(httpMethod = "GET", value = "户用光伏监盘逆变器历史表列表全部数据查询", notes = "户用光伏监盘逆变器历史表列表全部数据查询")
@GetMapping(value = "/list")
public ResponseModel<List<TdHygfJpInverterHistoryDto>> selectForList() {
return ResponseHelper.buildResponse(tdHygfJpInverterHistoryServiceImpl.queryForTdHygfJpInverterHistoryList());
return ResponseHelper.buildResponse(tdHygfJpInverterHistoryServiceImpl.queryForTdHygfJpInverterHistoryList());
}
/**
* 列表全部数据查询
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "户用光伏监盘逆变器历史表列表全部数据查询", notes = "户用光伏监盘逆变器历史表列表全部数据查询")
@GetMapping(value = "/statistics")
public ResponseModel<Map<String, Object>> day(@RequestParam(value = "id") Long id,
@RequestParam(value = "type") String type, @RequestParam(value = "date") String date) {
return ResponseHelper.buildResponse(tdHygfJpInverterHistoryServiceImpl.statistics(id,type,date));
}
}
package com.yeejoin.amos.boot.module.hygf.biz.service.impl;
import com.yeejoin.amos.boot.module.hygf.api.entity.TdHygfJpInverterHistory;
import com.yeejoin.amos.boot.module.hygf.api.tdenginemapper.TdHygfJpInverterHistoryMapper;
import com.yeejoin.amos.boot.module.hygf.api.service.ITdHygfJpInverterHistoryService;
import com.yeejoin.amos.boot.module.hygf.api.dto.TdHygfJpInverterHistoryDto;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
import com.yeejoin.amos.boot.module.hygf.api.dto.TdHygfJpInverterHistoryDto;
import com.yeejoin.amos.boot.module.hygf.api.entity.JpCollector;
import com.yeejoin.amos.boot.module.hygf.api.entity.JpInverter;
import com.yeejoin.amos.boot.module.hygf.api.entity.TdHygfJpInverterHistory;
import com.yeejoin.amos.boot.module.hygf.api.service.ITdHygfJpInverterHistoryService;
import com.yeejoin.amos.boot.module.hygf.api.tdenginemapper.TdHygfJpInverterHistoryMapper;
/**
* 户用光伏监盘逆变器历史表服务实现类
......@@ -16,18 +24,48 @@ import java.util.List;
* @date 2023-09-19
*/
@Service
public class TdHygfJpInverterHistoryServiceImpl extends BaseService<TdHygfJpInverterHistoryDto,TdHygfJpInverterHistory,TdHygfJpInverterHistoryMapper> implements ITdHygfJpInverterHistoryService {
/**
* 分页查询
*/
public Page<TdHygfJpInverterHistoryDto> queryForTdHygfJpInverterHistoryPage(Page<TdHygfJpInverterHistoryDto> page) {
return this.queryForPage(page, null, false);
}
/**
* 列表查询 示例
*/
public List<TdHygfJpInverterHistoryDto> queryForTdHygfJpInverterHistoryList() {
return this.queryForList("" , false);
}
public class TdHygfJpInverterHistoryServiceImpl
extends BaseService<TdHygfJpInverterHistoryDto, TdHygfJpInverterHistory, TdHygfJpInverterHistoryMapper>
implements ITdHygfJpInverterHistoryService {
@Autowired
private JpInverterServiceImpl jpInverterServiceImpl;
/**
* 分页查询
*/
public Page<TdHygfJpInverterHistoryDto> queryForTdHygfJpInverterHistoryPage(Page<TdHygfJpInverterHistoryDto> page) {
return this.queryForPage(page, null, false);
}
/**
* 列表查询 示例
*/
public List<TdHygfJpInverterHistoryDto> queryForTdHygfJpInverterHistoryList() {
return this.queryForList("", false);
}
public Map<String, Object> statistics(Long id, String type, String date) {
JpInverter inverter = jpInverterServiceImpl.getById(id);
Double power = null, dailyReturn = null, hours = null;
Map<String, Object> map = new HashMap();
if (inverter != null) {
if ("day".equals(type)) {
map = this.baseMapper.sum(inverter.getSnCode(), inverter.getThirdStationId(), date);
} else if ("month".equals(type)) {
map = this.baseMapper.sum(inverter.getSnCode(), inverter.getThirdStationId(), date);
} else if ("year".equals(type)) {
map = this.baseMapper.sum(inverter.getSnCode(), inverter.getThirdStationId(), date);
} else if ("all".equals(type)) {
map = this.baseMapper.sum(inverter.getSnCode(), inverter.getThirdStationId(), date);
}
}
if (map == null) {
map = new HashMap();
map.put("power", power);
map.put("return", dailyReturn);
map.put("hours", hours);
}
return map;
}
}
\ 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