Commit 32b4d8cc authored by tangwei's avatar tangwei

增加权重接口

parent 14bbcbe3
...@@ -5,21 +5,22 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; ...@@ -5,21 +5,22 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBiz3yudDto;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanWeight; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanWeight;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvWeight;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanWeightMapper; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanWeightMapper;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.text.DecimalFormat;
import java.util.List; import java.util.List;
/** /**
...@@ -112,4 +113,60 @@ public class IdxBizFanWeightController extends BaseController { ...@@ -112,4 +113,60 @@ public class IdxBizFanWeightController extends BaseController {
List<IdxBizFanWeight> list = idxBizFanWeightMapper.selectList(qu); List<IdxBizFanWeight> list = idxBizFanWeightMapper.selectList(qu);
return ResponseHelper.buildResponse(list); return ResponseHelper.buildResponse(list);
} }
@Transactional
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/update")
@ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新", notes = "根据sequenceNbr更新")
public ResponseModel<IdxBizFanWeight> update(@RequestBody List<IdxBizFanWeight> list) {
//获取所属,同类指标
if(list!=null&&list.size()>0){
IdxBizFanWeight reviewDto= list.get(0);
LambdaQueryWrapper<IdxBizFanWeight> qu=new LambdaQueryWrapper<>();
qu.eq(!StringUtils.isEmpty(reviewDto.getType()),IdxBizFanWeight::getType,reviewDto.getType());
qu.eq(!StringUtils.isEmpty(reviewDto.getArae()),IdxBizFanWeight::getArae,reviewDto.getArae());
qu.eq(!StringUtils.isEmpty(reviewDto.getStation()), IdxBizFanWeight::getStation,reviewDto.getStation());
qu.eq(!StringUtils.isEmpty(reviewDto.getSubarray()),IdxBizFanWeight::getSubarray,reviewDto.getSubarray());
qu.eq(!StringUtils.isEmpty(reviewDto.getEquipmentName()),IdxBizFanWeight::getEquipmentName,reviewDto.getEquipmentName());
qu.eq(!StringUtils.isEmpty(reviewDto.getPointName()),IdxBizFanWeight::getPointName,reviewDto.getPointName());
List<IdxBizFanWeight> listdata = idxBizFanWeightMapper.selectList(qu);
Float value= list.stream().map(e->e.getValue()).reduce(Float::sum).get();
//设置权重值,
int num= listdata.size()-list.size();
//剩余权重值
float formattedNum = Float.parseFloat(new DecimalFormat("0.0000").format((1-value)/num));
for (IdxBizFanWeight listdatum : listdata) {
for (IdxBizFanWeight idxBizPvWeight : list) {
if(idxBizPvWeight.getSequenceNbr().equals(listdatum.getSequenceNbr())){
listdatum.setValue(idxBizPvWeight.getValue());
break;
}else{
listdatum.setValue(formattedNum);
break;
}
}
idxBizFanWeightMapper.updateById(listdatum);
}
}
return ResponseHelper.buildResponse(null);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping (value = "/list")
@ApiOperation(httpMethod = "get", value = "根据sequenceNbr更新", notes = "根据sequenceNbr更新")
public ResponseModel<List<IdxBizFanWeight>> list(@RequestBody List<String> list) {
LambdaQueryWrapper<IdxBizFanWeight> qu=new LambdaQueryWrapper<>();
qu.in(!list.isEmpty(),IdxBizFanWeight::getSequenceNbr,list);
List<IdxBizFanWeight> listdata = idxBizFanWeightMapper.selectList(qu);
return ResponseHelper.buildResponse(listdata);
}
} }
...@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBiz3yudDto;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanWeight; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanWeight;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvWeight; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvWeight;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvWeightMapper; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvWeightMapper;
...@@ -14,15 +15,14 @@ import io.swagger.annotations.Api; ...@@ -14,15 +15,14 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.text.DecimalFormat;
import java.util.List; import java.util.List;
/** /**
...@@ -128,7 +128,53 @@ public class IdxBizPvWeightController extends BaseController { ...@@ -128,7 +128,53 @@ public class IdxBizPvWeightController extends BaseController {
return ResponseHelper.buildResponse(list); return ResponseHelper.buildResponse(list);
} }
@Transactional
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping (value = "/update")
@ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新", notes = "根据sequenceNbr更新")
public ResponseModel<IdxBizPvWeight> update(@RequestBody List<IdxBizPvWeight> list) {
//获取所属,同类指标
if(list!=null&&list.size()>0){
IdxBizPvWeight reviewDto= list.get(0);
LambdaQueryWrapper<IdxBizPvWeight> qu=new LambdaQueryWrapper<>();
qu.eq(!StringUtils.isEmpty(reviewDto.getType()),IdxBizPvWeight::getType,reviewDto.getType());
qu.eq(!StringUtils.isEmpty(reviewDto.getArae()),IdxBizPvWeight::getArae,reviewDto.getArae());
qu.eq(!StringUtils.isEmpty(reviewDto.getStation()),IdxBizPvWeight::getStation,reviewDto.getStation());
qu.eq(!StringUtils.isEmpty(reviewDto.getSubarray()),IdxBizPvWeight::getSubarray,reviewDto.getSubarray());
qu.eq(!StringUtils.isEmpty(reviewDto.getEquipmentName()),IdxBizPvWeight::getEquipmentName,reviewDto.getEquipmentName());
qu.eq(!StringUtils.isEmpty(reviewDto.getPointName()),IdxBizPvWeight::getPointName,reviewDto.getPointName());
List<IdxBizPvWeight> listdata = idxBizPvWeightMapper.selectList(qu);
Float value= list.stream().map(e->e.getValue()).reduce(Float::sum).get();
//设置权重值,
int num= listdata.size()-list.size();
//剩余权重值
float formattedNum = Float.parseFloat(new DecimalFormat("0.0000").format((1-value)/num));
for (IdxBizPvWeight listdatum : listdata) {
for (IdxBizPvWeight idxBizPvWeight : list) {
if(idxBizPvWeight.getSequenceNbr().equals(listdatum.getSequenceNbr())){
listdatum.setValue(idxBizPvWeight.getValue());
break;
}else{
listdatum.setValue(formattedNum);
break;
}
}
idxBizPvWeightMapper.updateById(listdatum);
}
}
return ResponseHelper.buildResponse(null);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping (value = "/list")
@ApiOperation(httpMethod = "get", value = "根据sequenceNbr更新", notes = "根据sequenceNbr更新")
public ResponseModel<List<IdxBizPvWeight>> list(@RequestBody List<String> list) {
LambdaQueryWrapper<IdxBizPvWeight> qu=new LambdaQueryWrapper<>();
qu.in(!list.isEmpty(),IdxBizPvWeight::getSequenceNbr,list);
List<IdxBizPvWeight> listdata = idxBizPvWeightMapper.selectList(qu);
return ResponseHelper.buildResponse(listdata);
}
} }
package com.yeejoin.amos.boot.module.jxiop.biz.controller; package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
...@@ -293,4 +294,46 @@ public class MonitoringMapController extends BaseController { ...@@ -293,4 +294,46 @@ public class MonitoringMapController extends BaseController {
} }
return stationBasicListAll; return stationBasicListAll;
} }
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(value = "大屏首页- 全国发电量趋势完成率")
@GetMapping("/getSeriesDataqg")
public ResponseModel<SeriesData> getSeriesDataqg() {
SeriesData map= largeScreenImpl.getSeriesDataqg();
return ResponseHelper.buildResponse(map);
}
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(value = "大屏首页- 区域发电量趋势完成率")
@GetMapping("/getSeriesDataqy")
public ResponseModel<SeriesData> getSeriesDataqy(String areaCode) {
LambdaQueryWrapper<StationBasic> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(areaCode!=null,StationBasic::getAreaCode,areaCode);
List<StationBasic> stationBasics = stationBasicMapper.selectList(wrapper);
List<String> ids = stationBasics.stream().map(StationBasic::getFanGatewayId).collect(Collectors.toList());
SeriesData map= largeScreenImpl.getSeriesDataqy( new Date(),ids, areaCode);
return ResponseHelper.buildResponse(map);
}
} }
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
}, },
{ {
"url": "upload/jxiop/amos_studio/22639FDFF29B20B681DF55F1252876B3.png", "url": "upload/jxiop/amos_studio/22639FDFF29B20B681DF55F1252876B3.png",
"title1": "总辐射日累计(Mb/㎡)", "title1": "总辐射日累计(MJ/㎡)",
"title": "总辐射累计" "title": "总辐射累计"
}, },
{ {
......
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