Commit 12547a60 authored by chenzhao's avatar chenzhao

Merge branch 'developer' of http://39.98.45.134:8090/moa/amos-boot-biz into developer

parents 34675325 d918cd61
package com.yeejoin.amos.boot.module.jxiop.biz.controller; package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
...@@ -13,10 +14,7 @@ import com.yeejoin.amos.boot.module.jxiop.api.feign.RiskWarningFeign; ...@@ -13,10 +14,7 @@ import com.yeejoin.amos.boot.module.jxiop.api.feign.RiskWarningFeign;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper; import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.FullViewRecallDataDTO; import com.yeejoin.amos.boot.module.jxiop.biz.dto.FullViewRecallDataDTO;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.FullViewRecallInfoDTO; import com.yeejoin.amos.boot.module.jxiop.biz.dto.FullViewRecallInfoDTO;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanHealthLevel; import com.yeejoin.amos.boot.module.jxiop.biz.entity.*;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanWarningRecord;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizPvHealthLevel;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IndicatorData;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanHealthIndexMapper; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanHealthIndexMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanHealthLevelMapper; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanHealthLevelMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanWarningRecordMapper; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizFanWarningRecordMapper;
...@@ -31,10 +29,7 @@ import io.swagger.annotations.ApiOperation; ...@@ -31,10 +29,7 @@ import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
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;
......
...@@ -25,6 +25,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper; ...@@ -25,6 +25,7 @@ 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 javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -261,4 +262,73 @@ public class IdxBizFanWarningRecordController extends BaseController { ...@@ -261,4 +262,73 @@ public class IdxBizFanWarningRecordController extends BaseController {
} }
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/stringToMap")
@ApiOperation(httpMethod = "get", value = "字符串转为对象格式", notes = "字符串转为对象格式")
public ResponseModel<Map<String, Object>> list(@RequestParam("analysisPointIds") String ids) {
Map<String, Object> data = new HashMap<>();
data.put("analysisPointIds", ids);
return ResponseHelper.buildResponse(data);
}
/**
* 根据pointId修改信息
*
* @param analysisInfo 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/updateByPointInfoBatchPv")
@ApiOperation(httpMethod = "POST", value = "根据pointId修改信息", notes = "根据pointId修改信息")
public ResponseModel<Boolean> updateByPointInfoBatchPv(@RequestBody JSONObject analysisInfo) {
LambdaQueryWrapper<IdxBizPvWarningRuleSet> query = new LambdaQueryWrapper<>();
List<String> analysisPointIds = Arrays.asList(analysisInfo.get("analysisPointIds").toString().split(","));
query.in(IdxBizPvWarningRuleSet::getAnalysisPointId, analysisPointIds);
List<IdxBizPvWarningRuleSet> idxBizFanWarningRecordList = idxBizPvWarningRuleSetService.getBaseMapper().selectList(query);
for (IdxBizPvWarningRuleSet idxBizPvWarningRuleSet : idxBizFanWarningRecordList) {
BeanUtil.copyProperties(analysisInfo, idxBizPvWarningRuleSet, "analysisPointIds");
if (idxBizPvWarningRuleSet.getWarningName().equals("警告")) {
//警告周期
idxBizPvWarningRuleSet.setWarningIf(analysisInfo.get("jgWarningIf").toString());
idxBizPvWarningRuleSet.setWarningCycle(analysisInfo.get("jgWarningCycle").toString());
} else if (idxBizPvWarningRuleSet.getWarningName().equals("危险")) {
//警告周期
idxBizPvWarningRuleSet.setWarningIf(analysisInfo.get("wxWarningIf").toString());
idxBizPvWarningRuleSet.setWarningCycle(analysisInfo.get("wxWarningCycle").toString());
}
}
boolean b = idxBizPvWarningRuleSetService.updateBatchById(idxBizFanWarningRecordList);
return ResponseHelper.buildResponse(b);
}
/**
* 根据pointId修改信息
*
* @param analysisInfo 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/updateByPointInfoBatchFan")
@ApiOperation(httpMethod = "POST", value = "根据pointId修改信息", notes = "根据pointId修改信息")
public ResponseModel<Boolean> updateByPointInfoBatchFan(@RequestBody JSONObject analysisInfo) {
LambdaQueryWrapper<IdxBizFanWarningRuleSet> query = new LambdaQueryWrapper<>();
List<String> analysisPointIds = Arrays.asList(analysisInfo.get("analysisPointIds").toString().split(","));
query.in(IdxBizFanWarningRuleSet::getAnalysisPointId, analysisPointIds);
List<IdxBizFanWarningRuleSet> idxBizFanWarningRecordList = idxBizFanWarningRuleSetService.getBaseMapper().selectList(query);
for (IdxBizFanWarningRuleSet idxBizFanWarningRuleSet : idxBizFanWarningRecordList) {
BeanUtil.copyProperties(analysisInfo, idxBizFanWarningRuleSet, "analysisPointIds");
if (idxBizFanWarningRuleSet.getWarningName().equals("警告")) {
//警告周期
idxBizFanWarningRuleSet.setWarningIf(analysisInfo.get("jgWarningIf").toString());
idxBizFanWarningRuleSet.setWarningCycle(analysisInfo.get("jgWarningCycle").toString());
} else if (idxBizFanWarningRuleSet.getWarningName().equals("危险")) {
//警告周期
idxBizFanWarningRuleSet.setWarningIf(analysisInfo.get("wxWarningIf").toString());
idxBizFanWarningRuleSet.setWarningCycle(analysisInfo.get("wxWarningCycle").toString());
}
}
boolean b = idxBizFanWarningRuleSetService.updateBatchById(idxBizFanWarningRecordList);
return ResponseHelper.buildResponse(b);
}
} }
package com.yeejoin.amos.boot.module.jxiop.biz.controller; package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
...@@ -17,6 +18,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -17,6 +18,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
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.exception.instance.BadRequest;
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;
...@@ -121,59 +123,211 @@ public class IdxBizFanWeightController extends BaseController { ...@@ -121,59 +123,211 @@ public class IdxBizFanWeightController extends BaseController {
@Transactional @Transactional
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@PostMapping(value = "/update") @PostMapping(value = "/update")
@ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新", notes = "根据sequenceNbr更新") @ApiOperation(httpMethod = "POST", value = "根据sequenceNbr更新", notes = "根据sequenceNbr更新")
public ResponseModel<IdxBizFanWeight> update(@RequestBody List<IdxBizFanWeight> list) { public ResponseModel<IdxBizFanWeight> update(@RequestBody Map<String,Object> value) {
//获取所属,同类指标 if (value != null) {
if(list!=null&&list.size()>0){ List<String> list1 = Arrays.asList(value.get("ids").toString().split(","));
IdxBizFanWeight reviewDto= list.get(0); LambdaQueryWrapper<IdxBizFanWeight> qu1 = new LambdaQueryWrapper<>();
LambdaQueryWrapper<IdxBizFanWeight> qu=new LambdaQueryWrapper<>(); qu1.in(!list1.isEmpty(), IdxBizFanWeight::getSequenceNbr, list1);
qu.eq(!StringUtils.isEmpty(reviewDto.getType()),IdxBizFanWeight::getType,reviewDto.getType()); List<IdxBizFanWeight> list = idxBizFanWeightMapper.selectList(qu1);
qu.eq(!StringUtils.isEmpty(reviewDto.getArae()),IdxBizFanWeight::getArae,reviewDto.getArae()); IdxBizFanWeight reviewDto = list.get(0);
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()); // Float list= map.get("data");
qu.eq(!StringUtils.isEmpty(reviewDto.getPointName()),IdxBizFanWeight::getPointName,reviewDto.getPointName());
List<IdxBizFanWeight> listdata = idxBizFanWeightMapper.selectList(qu); //判断是否同一层级
String flagtype = null;
Float value= list.stream().map(e->e.getValue()).reduce(Float::sum).get(); for (IdxBizFanWeight idxBizFanWeight : list) {
if (flagtype == null) {
//设置权重值,
int num= listdata.size()-list.size(); switch (reviewDto.getType()) {
//剩余权重值 case "1":
float formattedNum = Float.parseFloat(new DecimalFormat("0.0000").format((1-value)/num)); flagtype = idxBizFanWeight.getArae() ;
for (IdxBizFanWeight listdatum : listdata) { break;
for (IdxBizFanWeight idxBizPvWeight : list) { case "2":
if(idxBizPvWeight.getSequenceNbr().equals(listdatum.getSequenceNbr())){ flagtype = idxBizFanWeight.getArae() + idxBizFanWeight.getStation();
listdatum.setValue(idxBizPvWeight.getValue());
break; break;
}else{ case "3":
listdatum.setValue(formattedNum); flagtype = idxBizFanWeight.getArae() + idxBizFanWeight.getStation() + idxBizFanWeight.getEquipmentName() ;
break;
break;
case "4":
flagtype = idxBizFanWeight.getArae() + idxBizFanWeight.getStation() + idxBizFanWeight.getEquipmentName() + idxBizFanWeight.getSubarray() ;
break;
case "5":
flagtype = idxBizFanWeight.getArae() + idxBizFanWeight.getStation() + idxBizFanWeight.getEquipmentName() + idxBizFanWeight.getSubarray() + idxBizFanWeight.getPointName() ;
break;
}
} else {
switch (reviewDto.getType()) {
case "1":
if (!flagtype.equals(idxBizFanWeight.getArae() )) {
throw new BadRequest("配置权重必须是同一个层级的数据");
}
break;
case "2":
if (!flagtype.equals(idxBizFanWeight.getArae() + idxBizFanWeight.getStation() )) {
throw new BadRequest("配置权重必须是同一个层级的数据");
}
break;
case "3":
if (!flagtype.equals(idxBizFanWeight.getArae() + idxBizFanWeight.getStation() + idxBizFanWeight.getEquipmentName() )) {
throw new BadRequest("配置权重必须是同一个层级的数据");
}
break;
case "4":
if (!flagtype.equals(idxBizFanWeight.getArae() + idxBizFanWeight.getStation() + idxBizFanWeight.getEquipmentName() + idxBizFanWeight.getSubarray() )) {
throw new BadRequest("配置权重必须是同一个层级的数据");
}
break;
case "5":
if (!flagtype.equals(idxBizFanWeight.getArae() + idxBizFanWeight.getStation() + idxBizFanWeight.getEquipmentName() + idxBizFanWeight.getSubarray() + idxBizFanWeight.getPointName() )) {
throw new BadRequest("配置权重必须是同一个层级的数据");
}
break;
} }
} }
idxBizFanWeightMapper.updateById(listdatum); Float valued = list.size() * Float.valueOf(value.get("data").toString());
}
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);
//设置权重值,
int num = listdata.size() - list.size();
if (num == 0) {
if (valued != 1) {
throw new BadRequest("超出权重最大值限制,层级下权重等级总和为1");
}
}
//值不能大于1
if (valued > 1) {
throw new BadRequest("超出权重最大值限制,层级下权重等级总和为1");
}
if (valued != 1 && num != 0) {
throw new BadRequest("超出权重最大值限制,层级下权重等级总和为1");
}
//剩余权重值
float formattedNum = num != 0 ? Float.parseFloat(new DecimalFormat("0.0000000000").format((1 - valued) / num)) : 0;
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);
} }
return ResponseHelper.buildResponse(null);
}
// @Transactional
// @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
// @PostMapping(value = "/update")
// @ApiOperation(httpMethod = "POST", value = "根据sequenceNbr更新", notes = "根据sequenceNbr更新")
// public ResponseModel<IdxBizFanWeight> update(@RequestBody Map<String,List<IdxBizFanWeight>> map) {
// //获取所属,同类指标
// if(map!=null){
// List<IdxBizFanWeight> list= map.get("data");
// //判断是否同一层级
// String flagtype=null;
// for (IdxBizFanWeight idxBizFanWeight : list) {
// if(flagtype==null){
//
// flagtype= idxBizFanWeight.getArae()+idxBizFanWeight.getStation()+idxBizFanWeight.getEquipmentName()+idxBizFanWeight.getSubarray()+idxBizFanWeight.getPointName()+idxBizFanWeight.getType();
// }else{
// if(!flagtype.equals(idxBizFanWeight.getArae()+idxBizFanWeight.getStation()+idxBizFanWeight.getEquipmentName()+idxBizFanWeight.getSubarray()+idxBizFanWeight.getPointName()+idxBizFanWeight.getType())){
// throw new BadRequest("配置权重必须是同一个层级的数据");
// }
// }
// }
// Float value= list.stream().map(e->e.getValue()).reduce(Float::sum).get();
// 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);
//
// //设置权重值,
// int num= listdata.size()-list.size();
//
// //值不能大于1
// if(value>1){
// throw new BadRequest("超出权重最大值限制,层级下权重等级总和为1");
// }
// if(value!=1&&num!=0){
// throw new BadRequest("超出权重最大值限制,层级下权重等级总和为1");
// }
//
//
//
//
// //剩余权重值
// float formattedNum =num!=0? Float.parseFloat(new DecimalFormat("0.0000000000").format((1-value)/num)):0;
//
// 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, needAuth = false)
@GetMapping (value = "/list")
@ApiOperation(httpMethod = "get", value = "根据sequenceNbr更新", notes = "根据sequenceNbr更新")
public ResponseModel<Map<String,Object>> list( String ids) {
Map<String,Object> data=new HashMap<>();
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) data.put("ids",ids);
@GetMapping (value = "/list") return ResponseHelper.buildResponse(data);
@ApiOperation(httpMethod = "get", value = "根据sequenceNbr更新", notes = "根据sequenceNbr更新") }
public ResponseModel<Map<String,Object>> list( String ids
) { // @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
List<String> list= Arrays.asList(ids.split(",")); // @GetMapping (value = "/list")
LambdaQueryWrapper<IdxBizFanWeight> qu=new LambdaQueryWrapper<>(); // @ApiOperation(httpMethod = "get", value = "根据sequenceNbr更新", notes = "根据sequenceNbr更新")
qu.in(!list.isEmpty(),IdxBizFanWeight::getSequenceNbr,list); // public ResponseModel<Map<String,Object>> list( String ids
List<IdxBizFanWeight> listdata = idxBizFanWeightMapper.selectList(qu); // ) {
Map<String,Object> data=new HashMap<>(); // List<String> list= Arrays.asList(ids.split(","));
// LambdaQueryWrapper<IdxBizFanWeight> qu=new LambdaQueryWrapper<>();
// qu.in(!list.isEmpty(),IdxBizFanWeight::getSequenceNbr,list);
// List<IdxBizFanWeight> listdata = idxBizFanWeightMapper.selectList(qu);
// Map<String,Object> data=new HashMap<>();
//
// data.put("data",listdata);
// return ResponseHelper.buildResponse(data);
// }
data.put("data",listdata);
return ResponseHelper.buildResponse(data);
}
} }
package com.yeejoin.amos.boot.module.jxiop.biz.controller; package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
...@@ -8,7 +9,7 @@ import com.github.pagehelper.PageHelper; ...@@ -8,7 +9,7 @@ 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.dto.IdxBiz3yudDto;
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.entity.IdxBizPvWeight;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvWeightMapper; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.IdxBizPvWeightMapper;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -19,6 +20,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -19,6 +20,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
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.exception.instance.BadRequest;
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;
...@@ -131,57 +133,222 @@ public class IdxBizPvWeightController extends BaseController { ...@@ -131,57 +133,222 @@ public class IdxBizPvWeightController extends BaseController {
return ResponseHelper.buildResponse(list); return ResponseHelper.buildResponse(list);
} }
@Transactional @Transactional
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@PostMapping (value = "/update") @PostMapping(value = "/update")
@ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新", notes = "根据sequenceNbr更新") @ApiOperation(httpMethod = "POST", value = "根据sequenceNbr更新", notes = "根据sequenceNbr更新")
public ResponseModel<IdxBizPvWeight> update(@RequestBody List<IdxBizPvWeight> list) { public ResponseModel<IdxBizPvWeight> update(@RequestBody Map<String,Object> value) {
//获取所属,同类指标 if (value != null) {
if(list!=null&&list.size()>0){ List<String> list1 = Arrays.asList(value.get("ids").toString().split(","));
IdxBizPvWeight reviewDto= list.get(0); LambdaQueryWrapper<IdxBizPvWeight> qu1 = new LambdaQueryWrapper<>();
LambdaQueryWrapper<IdxBizPvWeight> qu=new LambdaQueryWrapper<>(); qu1.in(!list1.isEmpty(), IdxBizPvWeight::getSequenceNbr, list1);
qu.eq(!StringUtils.isEmpty(reviewDto.getType()),IdxBizPvWeight::getType,reviewDto.getType()); List<IdxBizPvWeight> list = idxBizPvWeightMapper.selectList(qu1);
qu.eq(!StringUtils.isEmpty(reviewDto.getArae()),IdxBizPvWeight::getArae,reviewDto.getArae()); IdxBizPvWeight reviewDto = list.get(0);
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()); // Float list= map.get("data");
qu.eq(!StringUtils.isEmpty(reviewDto.getPointName()),IdxBizPvWeight::getPointName,reviewDto.getPointName());
List<IdxBizPvWeight> listdata = idxBizPvWeightMapper.selectList(qu); //判断是否同一层级
String flagtype = null;
Float value= list.stream().map(e->e.getValue()).reduce(Float::sum).get(); for (IdxBizPvWeight idxBizFanWeight : list) {
if (flagtype == null) {
//设置权重值,
int num= listdata.size()-list.size(); switch (reviewDto.getType()) {
//剩余权重值 case "1":
float formattedNum = Float.parseFloat(new DecimalFormat("0.0000").format((1-value)/num)); flagtype = idxBizFanWeight.getArae() ;
for (IdxBizPvWeight listdatum : listdata) { break;
for (IdxBizPvWeight idxBizPvWeight : list) { case "2":
if(idxBizPvWeight.getSequenceNbr().equals(listdatum.getSequenceNbr())){ flagtype = idxBizFanWeight.getArae() + idxBizFanWeight.getStation();
listdatum.setValue(idxBizPvWeight.getValue());
break; break;
}else{ case "3":
listdatum.setValue(formattedNum); flagtype = idxBizFanWeight.getArae() + idxBizFanWeight.getStation() + idxBizFanWeight.getEquipmentName() ;
break;
break;
case "4":
flagtype = idxBizFanWeight.getArae() + idxBizFanWeight.getStation() + idxBizFanWeight.getEquipmentName() + idxBizFanWeight.getSubarray() ;
break;
case "5":
flagtype = idxBizFanWeight.getArae() + idxBizFanWeight.getStation() + idxBizFanWeight.getEquipmentName() + idxBizFanWeight.getSubarray() + idxBizFanWeight.getPointName() ;
break;
}
} else {
switch (reviewDto.getType()) {
case "1":
if (!flagtype.equals(idxBizFanWeight.getArae() )) {
throw new BadRequest("配置权重必须是同一个层级的数据");
}
break;
case "2":
if (!flagtype.equals(idxBizFanWeight.getArae() + idxBizFanWeight.getStation() )) {
throw new BadRequest("配置权重必须是同一个层级的数据");
}
break;
case "3":
if (!flagtype.equals(idxBizFanWeight.getArae() + idxBizFanWeight.getStation() + idxBizFanWeight.getEquipmentName() )) {
throw new BadRequest("配置权重必须是同一个层级的数据");
}
break;
case "4":
if (!flagtype.equals(idxBizFanWeight.getArae() + idxBizFanWeight.getStation() + idxBizFanWeight.getEquipmentName() + idxBizFanWeight.getSubarray() )) {
throw new BadRequest("配置权重必须是同一个层级的数据");
}
break;
case "5":
if (!flagtype.equals(idxBizFanWeight.getArae() + idxBizFanWeight.getStation() + idxBizFanWeight.getEquipmentName() + idxBizFanWeight.getSubarray() + idxBizFanWeight.getPointName() )) {
throw new BadRequest("配置权重必须是同一个层级的数据");
}
break;
}
}
Float valued = list.size() * Float.valueOf(value.get("data").toString());
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);
//设置权重值,
int num = listdata.size() - list.size();
if (num == 0) {
if (valued != 1) {
throw new BadRequest("超出权重最大值限制,层级下权重等级总和为1");
}
}
//值不能大于1
if (valued > 1) {
throw new BadRequest("超出权重最大值限制,层级下权重等级总和为1");
}
if (valued != 1 && num != 0) {
throw new BadRequest("超出权重最大值限制,层级下权重等级总和为1");
}
//剩余权重值
float formattedNum = num != 0 ? Float.parseFloat(new DecimalFormat("0.0000000000").format((1 - valued) / num)) : 0;
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);
} }
idxBizPvWeightMapper.updateById(listdatum);
} }
} }
return ResponseHelper.buildResponse(null); return ResponseHelper.buildResponse(null);
} }
// @Transactional
// @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
// @PostMapping (value = "/update")
// @ApiOperation(httpMethod = "POST", value = "根据sequenceNbr更新", notes = "根据sequenceNbr更新")
// public ResponseModel<IdxBizPvWeight> update(@RequestBody Map<String,List<IdxBizPvWeight>> map) {
// //获取所属,同类指标
// if(map!=null){
// List<IdxBizPvWeight> list= map.get("data");
// //判断是否同一层级
// String flagtype=null;
// for (IdxBizPvWeight idxBizPvWeight : list) {
// if(flagtype==null){
//
// flagtype= idxBizPvWeight.getArae()+idxBizPvWeight.getStation()+idxBizPvWeight.getEquipmentName()+idxBizPvWeight.getSubarray()+idxBizPvWeight.getPointName()+idxBizPvWeight.getType();
// }else{
// if(!flagtype.equals(idxBizPvWeight.getArae()+idxBizPvWeight.getStation()+idxBizPvWeight.getEquipmentName()+idxBizPvWeight.getSubarray()+idxBizPvWeight.getPointName()+idxBizPvWeight.getType())){
// throw new BadRequest("配置权重必须是同一个层级的数据");
// }
// }
// }
// Float value= list.stream().map(e->e.getValue()).reduce(Float::sum).get();
// 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);
//
// //设置权重值,
// int num= listdata.size()-list.size();
//
// //值不能大于1
// if(value>1){
// throw new BadRequest("超出权重最大值限制,层级下权重等级总和为1");
// }
// if(value!=1&&num!=0){
// throw new BadRequest("超出权重最大值限制,层级下权重等级总和为1");
// }
//
// //剩余权重值
//
// float formattedNum =num!=0? Float.parseFloat(new DecimalFormat("0.0000").format((1-value)/num)):0;
//
// 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, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping (value = "/list") @GetMapping (value = "/list")
@ApiOperation(httpMethod = "get", value = "根据sequenceNbr更新", notes = "根据sequenceNbr更新") @ApiOperation(httpMethod = "get", value = "根据sequenceNbr更新", notes = "根据sequenceNbr更新")
public ResponseModel<Map<String,Object>> list( String ids public ResponseModel<Map<String,Object>> list( String ids
) { ) {
List<String> list= Arrays.asList(ids.split(","));
LambdaQueryWrapper<IdxBizPvWeight> qu=new LambdaQueryWrapper<>();
qu.in(!list.isEmpty(),IdxBizPvWeight::getSequenceNbr,list);
List<IdxBizPvWeight> listdata = idxBizPvWeightMapper.selectList(qu);
Map<String,Object> data=new HashMap<>(); Map<String,Object> data=new HashMap<>();
data.put("data",listdata); data.put("ids",ids);
return ResponseHelper.buildResponse(data); return ResponseHelper.buildResponse(data);
} }
// @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
// @GetMapping (value = "/list")
// @ApiOperation(httpMethod = "get", value = "根据sequenceNbr更新", notes = "根据sequenceNbr更新")
// public ResponseModel<Map<String,Object>> list( String ids
// ) {
// List<String> list= Arrays.asList(ids.split(","));
// LambdaQueryWrapper<IdxBizPvWeight> qu=new LambdaQueryWrapper<>();
// qu.in(!list.isEmpty(),IdxBizPvWeight::getSequenceNbr,list);
// List<IdxBizPvWeight> listdata = idxBizPvWeightMapper.selectList(qu);
// Map<String,Object> data=new HashMap<>();
//
// data.put("data",listdata);
// return ResponseHelper.buildResponse(data);
// }
} }
...@@ -151,4 +151,11 @@ public class IdxBizFanWarningRecord{ ...@@ -151,4 +151,11 @@ public class IdxBizFanWarningRecord{
*/ */
@TableField("KKS") @TableField("KKS")
private String kks; private String kks;
/**
* 预警周期
*/
@TableField("WARNING_PERIOD")
private String warningPeriod;
} }
...@@ -64,5 +64,6 @@ public class IdxBizFanWeight { ...@@ -64,5 +64,6 @@ public class IdxBizFanWeight {
*/ */
@TableField("VALUE") @TableField("VALUE")
private Float value; private Float value;
@TableField(exist=false)
private String Symbol_key;
} }
...@@ -152,4 +152,10 @@ public class IdxBizPvWarningRecord{ ...@@ -152,4 +152,10 @@ public class IdxBizPvWarningRecord{
*/ */
@TableField("KKS") @TableField("KKS")
private String kks; private String kks;
/**
* 预警周期
*/
@TableField("WARNING_PERIOD")
private String warningPeriod;
} }
...@@ -65,6 +65,6 @@ public class IdxBizPvWeight { ...@@ -65,6 +65,6 @@ public class IdxBizPvWeight {
*/ */
@TableField("VALUE") @TableField("VALUE")
private Float value; private Float value;
@TableField(exist=false)
private String Symbol_key;
} }
...@@ -234,6 +234,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -234,6 +234,7 @@ public class HealthStatusIndicatorServiceImpl {
idxBizPvWarningRecord.setWarningName(level); idxBizPvWarningRecord.setWarningName(level);
idxBizPvWarningRecord.setCONTENT(idxBizPvHealthIndices.get(0).getPointName() + "连续"+content+"健康指数<"+num ); idxBizPvWarningRecord.setCONTENT(idxBizPvHealthIndices.get(0).getPointName() + "连续"+content+"健康指数<"+num );
idxBizPvWarningRecord.setRecDate(time); idxBizPvWarningRecord.setRecDate(time);
idxBizPvWarningRecord.setWarningPeriod("按时刻");
idxBizPvWarningRecord.setManufacturer(idxBizPvHealthIndices.get(0).getManufacturer()); idxBizPvWarningRecord.setManufacturer(idxBizPvHealthIndices.get(0).getManufacturer());
idxBizPvWarningRecord.setPointName(idxBizPvHealthIndices.get(0).getPointName()); idxBizPvWarningRecord.setPointName(idxBizPvHealthIndices.get(0).getPointName());
idxBizPvWarningRecord.setHealthIndexSeq(idxBizPvHealthIndices.get(0).getHealthIndex().toString()); idxBizPvWarningRecord.setHealthIndexSeq(idxBizPvHealthIndices.get(0).getHealthIndex().toString());
...@@ -381,6 +382,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -381,6 +382,7 @@ public class HealthStatusIndicatorServiceImpl {
idxBizPvWarningRecord.setWarningName(level); idxBizPvWarningRecord.setWarningName(level);
idxBizPvWarningRecord.setCONTENT(idxBizPvHealthIndices.get(0).getPointName() + "连续"+content+"健康指数<"+num ); idxBizPvWarningRecord.setCONTENT(idxBizPvHealthIndices.get(0).getPointName() + "连续"+content+"健康指数<"+num );
idxBizPvWarningRecord.setRecDate(time); idxBizPvWarningRecord.setRecDate(time);
idxBizPvWarningRecord.setWarningPeriod("按小时");
idxBizPvWarningRecord.setManufacturer(idxBizPvHealthIndices.get(0).getManufacturer()); idxBizPvWarningRecord.setManufacturer(idxBizPvHealthIndices.get(0).getManufacturer());
idxBizPvWarningRecord.setPointName(idxBizPvHealthIndices.get(0).getPointName()); idxBizPvWarningRecord.setPointName(idxBizPvHealthIndices.get(0).getPointName());
idxBizPvWarningRecord.setHealthIndexSeq(idxBizPvHealthIndices.get(0).getHealthIndex().toString()); idxBizPvWarningRecord.setHealthIndexSeq(idxBizPvHealthIndices.get(0).getHealthIndex().toString());
...@@ -522,6 +524,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -522,6 +524,7 @@ public class HealthStatusIndicatorServiceImpl {
idxBizPvWarningRecord.setWarningName(level); idxBizPvWarningRecord.setWarningName(level);
idxBizPvWarningRecord.setCONTENT(idxBizPvHealthIndices.get(0).getPointName() + "连续"+content+"健康指数<"+num ); idxBizPvWarningRecord.setCONTENT(idxBizPvHealthIndices.get(0).getPointName() + "连续"+content+"健康指数<"+num );
idxBizPvWarningRecord.setRecDate(time); idxBizPvWarningRecord.setRecDate(time);
idxBizPvWarningRecord.setWarningPeriod("按天");
idxBizPvWarningRecord.setManufacturer(idxBizPvHealthIndices.get(0).getManufacturer()); idxBizPvWarningRecord.setManufacturer(idxBizPvHealthIndices.get(0).getManufacturer());
idxBizPvWarningRecord.setPointName(idxBizPvHealthIndices.get(0).getPointName()); idxBizPvWarningRecord.setPointName(idxBizPvHealthIndices.get(0).getPointName());
idxBizPvWarningRecord.setHealthIndexSeq(idxBizPvHealthIndices.get(0).getHealthIndex().toString()); idxBizPvWarningRecord.setHealthIndexSeq(idxBizPvHealthIndices.get(0).getHealthIndex().toString());
...@@ -665,6 +668,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -665,6 +668,7 @@ public class HealthStatusIndicatorServiceImpl {
idxBizFanWarningRecord.setWarningName(level); idxBizFanWarningRecord.setWarningName(level);
idxBizFanWarningRecord.setCONTENT(idxBizFanHealthIndices.get(0).getPointName() + "连续"+content+"健康指数<"+num ); idxBizFanWarningRecord.setCONTENT(idxBizFanHealthIndices.get(0).getPointName() + "连续"+content+"健康指数<"+num );
idxBizFanWarningRecord.setRecDate(time); idxBizFanWarningRecord.setRecDate(time);
idxBizFanWarningRecord.setWarningPeriod("按时刻");
idxBizFanWarningRecord.setNumber(idxBizFanHealthIndices.get(0).getNumber()); idxBizFanWarningRecord.setNumber(idxBizFanHealthIndices.get(0).getNumber());
idxBizFanWarningRecord.setPointName(idxBizFanHealthIndices.get(0).getPointName()); idxBizFanWarningRecord.setPointName(idxBizFanHealthIndices.get(0).getPointName());
idxBizFanWarningRecord.setHealthIndexSeq(idxBizFanHealthIndices.get(0).getHealthIndex().toString()); idxBizFanWarningRecord.setHealthIndexSeq(idxBizFanHealthIndices.get(0).getHealthIndex().toString());
...@@ -807,6 +811,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -807,6 +811,7 @@ public class HealthStatusIndicatorServiceImpl {
idxBizFanWarningRecord.setWarningName(level); idxBizFanWarningRecord.setWarningName(level);
idxBizFanWarningRecord.setCONTENT(idxBizFanHealthIndices.get(0).getPointName() + "连续"+content+"健康指数<"+num ); idxBizFanWarningRecord.setCONTENT(idxBizFanHealthIndices.get(0).getPointName() + "连续"+content+"健康指数<"+num );
idxBizFanWarningRecord.setRecDate(time); idxBizFanWarningRecord.setRecDate(time);
idxBizFanWarningRecord.setWarningPeriod("按小时");
idxBizFanWarningRecord.setNumber(idxBizFanHealthIndices.get(0).getNumber()); idxBizFanWarningRecord.setNumber(idxBizFanHealthIndices.get(0).getNumber());
idxBizFanWarningRecord.setHealthIndexSeq(idxBizFanHealthIndices.get(0).getHealthIndex().toString()); idxBizFanWarningRecord.setHealthIndexSeq(idxBizFanHealthIndices.get(0).getHealthIndex().toString());
idxBizFanWarningRecord.setHealthLevel(idxBizFanHealthIndices.get(0).getHealthLevel()); idxBizFanWarningRecord.setHealthLevel(idxBizFanHealthIndices.get(0).getHealthLevel());
...@@ -951,6 +956,7 @@ public class HealthStatusIndicatorServiceImpl { ...@@ -951,6 +956,7 @@ public class HealthStatusIndicatorServiceImpl {
idxBizFanWarningRecord.setWarningName(level); idxBizFanWarningRecord.setWarningName(level);
idxBizFanWarningRecord.setCONTENT(idxBizFanHealthIndices.get(0).getPointName() + "连续"+content+"健康指数<"+num ); idxBizFanWarningRecord.setCONTENT(idxBizFanHealthIndices.get(0).getPointName() + "连续"+content+"健康指数<"+num );
idxBizFanWarningRecord.setRecDate(time); idxBizFanWarningRecord.setRecDate(time);
idxBizFanWarningRecord.setWarningPeriod("按天");
idxBizFanWarningRecord.setNumber(idxBizFanHealthIndices.get(0).getNumber()); idxBizFanWarningRecord.setNumber(idxBizFanHealthIndices.get(0).getNumber());
idxBizFanWarningRecord.setHealthIndexSeq(idxBizFanHealthIndices.get(0).getHealthIndex().toString()); idxBizFanWarningRecord.setHealthIndexSeq(idxBizFanHealthIndices.get(0).getHealthIndex().toString());
idxBizFanWarningRecord.setHealthLevel(idxBizFanHealthIndices.get(0).getHealthLevel()); idxBizFanWarningRecord.setHealthLevel(idxBizFanHealthIndices.get(0).getHealthLevel());
......
...@@ -27,7 +27,7 @@ public class MasterDbConfig { ...@@ -27,7 +27,7 @@ public class MasterDbConfig {
private Logger logger = LoggerFactory.getLogger(MasterDbConfig.class); private Logger logger = LoggerFactory.getLogger(MasterDbConfig.class);
// 精确到 master 目录,以便跟其他数据源隔离 // 精确到 master 目录,以便跟其他数据源隔离
private static final String MAPPER_LOCATION = "classpath*:mapper/master/*.xml"; private static final String MAPPER_LOCATION = "classpath*:mapper/*.xml";
@Value("${spring.db1.datasource.url}") @Value("${spring.db1.datasource.url}")
private String dbUrl; private String dbUrl;
......
...@@ -2,7 +2,11 @@ package com.yeejoin.amos.boot.module.jxiop.biz.config; ...@@ -2,7 +2,11 @@ package com.yeejoin.amos.boot.module.jxiop.biz.config;
import com.alibaba.druid.pool.DruidDataSource; import com.alibaba.druid.pool.DruidDataSource;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean; import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
import com.github.pagehelper.PageInterceptor;
import org.apache.ibatis.plugin.Interceptor;
import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -14,6 +18,8 @@ import org.springframework.context.annotation.Configuration; ...@@ -14,6 +18,8 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import java.util.Properties;
import javax.sql.DataSource; import javax.sql.DataSource;
/** /**
...@@ -60,14 +66,30 @@ public class TdEngineConfig { ...@@ -60,14 +66,30 @@ public class TdEngineConfig {
@Bean(name = "taosSqlSessionFactory") @Bean(name = "taosSqlSessionFactory")
public SqlSessionFactory clusterSqlSessionFactory(@Qualifier("taosDataSource") DataSource culsterDataSource) public SqlSessionFactory clusterSqlSessionFactory(@Qualifier("taosDataSource") DataSource culsterDataSource)
throws Exception { throws Exception {
final MybatisSqlSessionFactoryBean sessionFactory = new MybatisSqlSessionFactoryBean(); MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean();
sessionFactory.setDataSource(culsterDataSource); bean.setDataSource(culsterDataSource);
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver() bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(MAPPER_LOCATION));
.getResources(TdEngineConfig.MAPPER_LOCATION));
sessionFactory.setTypeAliasesPackage("com.yeejoin.amos.boot.module.jxiop.biz.entity"); //分页插件
//mybatis 数据库字段与实体类属性驼峰映射配置 Interceptor interceptor = new PageInterceptor();
sessionFactory.getObject().getConfiguration().setMapUnderscoreToCamelCase(true); Properties properties = new Properties();
return sessionFactory.getObject(); properties.setProperty("helperDialect", "mysql");
properties.setProperty("offsetAsPageNum", "true");
properties.setProperty("rowBoundsWithCount", "true");
properties.setProperty("reasonable", "true");
properties.setProperty("supportMethodsArguments","true");
properties.setProperty("params","pageNum=pageNum;pageSize=pageSize" +
"" +
";");
interceptor.setProperties(properties);
bean.setPlugins(new Interceptor[] {interceptor,paginationInterceptor()});
return bean.getObject();
}
@Bean
public PaginationInterceptor paginationInterceptor() {
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
return paginationInterceptor;
} }
} }
package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
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.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.ResultsData;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.AlarmEventServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.EquipAlarmEventServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@RestController
@Api(tags = "event")
@RequestMapping(value = "/event")
public class EventController {
@Autowired
private AlarmEventServiceImpl alarmEventServiceImpl;
@Autowired
private EquipAlarmEventServiceImpl equipAlarmEventServiceImpl;
@Autowired
private StationBasicMapper stationBasicMapper;
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "故障记录API")
@GetMapping("/equipDivergenceEventtList")
public ResponseModel<ResultsData> equipDivergenceEventtList(@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size, @RequestParam(value = "stationId") String stationId) {
ResultsData resultsData = new ResultsData();
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String fanGatewayId = stationBasic.getFanGatewayId();
resultsData = equipAlarmEventServiceImpl.getEquipDivergenceEvent(fanGatewayId,current, size );
return ResponseHelper.buildResponse(resultsData);
}
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "刷新字典API")
// @GetMapping("/dic/refresh")
// public ResponseModel<String> refresh() {
// alarmEventServiceImpl.init();
// return ResponseHelper.buildResponse("success");
// }
}
...@@ -18,10 +18,12 @@ public class EquipDic { ...@@ -18,10 +18,12 @@ public class EquipDic {
@TableId(value = "sequence_nbr", type = IdType.ID_WORKER) @TableId(value = "sequence_nbr", type = IdType.ID_WORKER)
private Long sequenceNumber; private Long sequenceNumber;
@TableField("value") @TableField("dic_value")
Double value; Double dicValue;
@TableField("desc") @TableField("description")
String desc; String description;
@TableField("dic_key")
String dicKey;
} }
package com.yeejoin.amos.boot.module.jxiop.biz.scheduled; package com.yeejoin.amos.boot.module.jxiop.biz.scheduled;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.EquipDicMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.EquipDic;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.EquipDivergenceAlarmEvent;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.MonitorFanIndicatorImpl; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.MonitorFanIndicatorImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.EquipDivergenceAlarmEventMapper;
@Service
@EnableScheduling @EnableScheduling
public class EquipWarnSchedule { public class EquipWarnSchedule {
@Autowired @Autowired
private MonitorFanIndicatorImpl monitorFanIndicatorImpl; private MonitorFanIndicatorImpl monitorFanIndicatorImpl;
@Autowired
private StationBasicMapper stationBasicMapper;
@Autowired
private EquipDivergenceAlarmEventMapper equipDivergenceAlarmEventMapper;
@Autowired
private EquipDicMapper equipDicMapper;
@Scheduled(cron = "${equip.warn.cron}") @Scheduled(cron = "${equip.warn.cron}")
//@PostConstruct
private void doEquipDivergencWarn() { private void doEquipDivergencWarn() {
List<EquipDivergenceAlarmEvent> eventList = new ArrayList<EquipDivergenceAlarmEvent>();
EquipDic equipDic = equipDicMapper
.selectOne(new LambdaQueryWrapper<EquipDic>().eq(EquipDic::getDicKey, "LSVGJYZ"));
LambdaQueryWrapper<StationBasic> wrapper = new LambdaQueryWrapper<>();
wrapper.like(StationBasic::getStationType, "GFDZ");
List<StationBasic> stationList = stationBasicMapper.selectList(wrapper);
for (StationBasic stationBasic : stationList) {
ArrayList<Map<String, Object>> resultList = monitorFanIndicatorImpl.getLSV(stationBasic.getFanGatewayId());
if (!resultList.isEmpty()) {
for (Map<String, Object> map : resultList) {
Double lsv = Double.valueOf( String.valueOf(map.get("lsv")));
if (lsv > equipDic.getDicValue()) {
String zz = (String) map.get("zz");
String nbq = (String) map.get("nbq");
String hlx = (String) map.get("hlx");
EquipDivergenceAlarmEvent equipDivergenceAlarmEvent = new EquipDivergenceAlarmEvent();
equipDivergenceAlarmEvent.setEquipName(zz + "/" + nbq + "/" + hlx);
equipDivergenceAlarmEvent.setGatewayId(stationBasic.getFanGatewayId());
equipDivergenceAlarmEvent.setValue(lsv.toString());
equipDivergenceAlarmEvent.setAlarmGroupName("离散率告警");
equipDivergenceAlarmEvent.setEventDesc("离散率超过告警阈值");
eventList.add(equipDivergenceAlarmEvent);
}
}
}
}
equipDivergenceAlarmEventMapper.save(eventList);
} }
} }
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl; package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper; import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.ColModel; import com.yeejoin.amos.boot.module.jxiop.biz.dto.ColModel;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.DataGridMock; import com.yeejoin.amos.boot.module.jxiop.biz.dto.DataGridMock;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.EquipAlarmEventDto; import com.yeejoin.amos.boot.module.jxiop.biz.dto.EquipAlarmEventDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.ResultsData; import com.yeejoin.amos.boot.module.jxiop.biz.dto.ResultsData;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.EquipAlarmEvent; import com.yeejoin.amos.boot.module.jxiop.biz.entity.EquipAlarmEvent;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.EquipDivergenceAlarmEvent;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.EquipAlarmEventMapper; import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.EquipAlarmEventMapper;
import org.springframework.beans.factory.annotation.Autowired; import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.EquipDivergenceAlarmEventMapper;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
@Service @Service
public class EquipAlarmEventServiceImpl extends BaseService<EquipAlarmEventDto, EquipAlarmEvent, EquipAlarmEventMapper> { public class EquipAlarmEventServiceImpl extends BaseService<EquipAlarmEventDto, EquipAlarmEvent, EquipAlarmEventMapper> {
...@@ -28,6 +32,8 @@ public class EquipAlarmEventServiceImpl extends BaseService<EquipAlarmEventDto, ...@@ -28,6 +32,8 @@ public class EquipAlarmEventServiceImpl extends BaseService<EquipAlarmEventDto,
EquipAlarmEventMapper equipAlarmEventMapper; EquipAlarmEventMapper equipAlarmEventMapper;
@Autowired @Autowired
StationBasicMapper stationBasicMapper; StationBasicMapper stationBasicMapper;
@Autowired
EquipDivergenceAlarmEventMapper equipDivergenceAlarmEventMapper;
public ResultsData getEventByEquipIndex(String gatewayId, int current, int size, String equipIndex, String frontModule) { public ResultsData getEventByEquipIndex(String gatewayId, int current, int size, String equipIndex, String frontModule) {
List<EquipAlarmEventDto> equipAlarmEvents = new ArrayList<>(); List<EquipAlarmEventDto> equipAlarmEvents = new ArrayList<>();
...@@ -68,4 +74,45 @@ public class EquipAlarmEventServiceImpl extends BaseService<EquipAlarmEventDto, ...@@ -68,4 +74,45 @@ public class EquipAlarmEventServiceImpl extends BaseService<EquipAlarmEventDto,
ResultsData resultsData = new ResultsData(DataGridMock, listColModel); ResultsData resultsData = new ResultsData(DataGridMock, listColModel);
return resultsData; return resultsData;
} }
public ResultsData getEquipDivergenceEvent(String gatewayId, int current, int size) {
PageHelper.startPage(current, size);
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_MONTH, -2);
List<EquipDivergenceAlarmEvent> alarmEventList = equipDivergenceAlarmEventMapper.getEventList(gatewayId, null, null,
calendar.getTime());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar car = Calendar.getInstance();
alarmEventList.forEach(i -> {
// if ("true".equals(i.getValue())) {
// i.setValue("合");
// } else if ("false".equals(i.getValue())) {
// i.setValue("分");
// }
long mills = i.getCreatedTime() / 1000000;
car.setTimeInMillis(mills);
// System.out.println(sdf.format(car.getTime()));
i.setTime(sdf.format(car.getTime()));
// car.add(Calendar.HOUR, 12);
// System.out.println(sdf.format(car.getTime()));
});
PageInfo<EquipAlarmEvent> page = new PageInfo(alarmEventList);
// 构建平台数据
DataGridMock DataGridMock = new DataGridMock(current, (int) page.getTotal(), false, current, alarmEventList);
ColModel colModelEventMovement = new ColModel("equipName", "equipName", "设备名称", "设备名称", "dataGrid",
"equipName");
ColModel colModelStationName = new ColModel("eventDesc", "eventDesc", "事件描述", "事件描述", "dataGrid", "eventDesc");
ColModel colModelAlarmGroupName = new ColModel("alarmGroupName", "alarmGroupName", "事件类型", "事件类型", "dataGrid",
"alarmGroupName");
ColModel colModelEventDesc = new ColModel("time", "time", "事件发生时间", "事件发生时间", "dataGrid", "time");
ColModel colModelValueDesc = new ColModel("value", "value", "事件值", "事件值", "dataGrid", "value");
List<ColModel> listColModel = Arrays.asList(colModelEventMovement, colModelStationName, colModelAlarmGroupName,
colModelEventDesc, colModelValueDesc);
ResultsData resultsData = new ResultsData(DataGridMock, listColModel);
return resultsData;
}
} }
...@@ -338,7 +338,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -338,7 +338,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
public List<ESEquipmentsDTO> getFanStatusList(String stationId) { public List<ESEquipmentsDTO> getFanStatusList(String stationId) {
StationBasic stationBasic = getOneByStationNumber(stationId); StationBasic stationBasic = getOneByStationNumber(stationId);
if (stationBasic.getStationName().contains("GFDZ")) { if (stationBasic.getStationType().contains("GFDZ")) {
return new ArrayList<ESEquipmentsDTO>(); return new ArrayList<ESEquipmentsDTO>();
} }
Map<String, List<String>> queryCondtion = new HashMap<>(); Map<String, List<String>> queryCondtion = new HashMap<>();
...@@ -1680,7 +1680,6 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1680,7 +1680,6 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
url = pictureUrl + urls[0]; url = pictureUrl + urls[0];
} else { } else {
url = pictureUrl + urls[1]; url = pictureUrl + urls[1];
;
} }
photoUrls.put(datass.getDisplayName().split("_")[0] + "jddwz", url); photoUrls.put(datass.getDisplayName().split("_")[0] + "jddwz", url);
} }
...@@ -1726,14 +1725,14 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1726,14 +1725,14 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
} }
public HashMap<String, Object> getyw(String gatewayId) { public HashMap<String, Object> getyw(String gatewayId) {
HashMap<String, Object> resultMap = new HashMap<>(); HashMap<String, Object> resultMap = new HashMap<>();
Map<String, List<String>> queryCondtion = new HashMap<>(); Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId)); queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
queryCondtion.put(CommonConstans.QueryStringFrontMoudle, Arrays.asList("1主变")); queryCondtion.put(CommonConstans.QueryStringSystemTypeKeyword, Arrays.asList("模拟量"));
queryCondtion.put(CommonConstans.QueryStringSystemType, Arrays.asList("模拟量")); Map<String,String> likeMap = new HashMap<>();
List<ESEquipments> esEquipmentsList = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class); likeMap.put(CommonConstans.QueryStringFrontMoudle,"1主变");
List<ESEquipments> esEquipmentsList = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class,likeMap);
// TODO: 2023/7/14 数据未整理 ---> 油面温1 油面温2 绕组温度 // TODO: 2023/7/14 数据未整理 ---> 油面温1 油面温2 绕组温度
resultMap.put("value1", "0.0"); resultMap.put("value1", "0.0");
resultMap.put("value2", "0.0"); resultMap.put("value2", "0.0");
...@@ -1741,13 +1740,13 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1741,13 +1740,13 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
resultMap.put("value4", "0.0"); resultMap.put("value4", "0.0");
esEquipmentsList.forEach(item -> { esEquipmentsList.forEach(item -> {
if ("档位".equals(item.getDisplayName())) { if ("档位".equals(item.getDisplayName())) {
resultMap.put("value4", item.getValue()); resultMap.put("value4", String.format("%.0f",item.getValueF()));
} else if ("油面温1".equals(item.getDisplayName())) { } else if ("油面温1".equals(item.getDisplayName())) {
resultMap.put("value1", item.getValue()); resultMap.put("value1", String.format("%.1f",item.getValueF()));
} else if ("油面温2".equals(item.getDisplayName())) { } else if ("油面温2".equals(item.getDisplayName())) {
resultMap.put("value2", item.getValue()); resultMap.put("value2", String.format("%.1f",item.getValueF()));
} else if ("绕组温度".equals(item.getDisplayName())) { } else if ("绕组温度".equals(item.getDisplayName())) {
resultMap.put("value3", item.getValue()); resultMap.put("value3", String.format("%.1f",item.getValueF()));
} }
}); });
return resultMap; return resultMap;
...@@ -1955,70 +1954,76 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -1955,70 +1954,76 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
public ResultsData collectingBox(String gatewayId, int current, int size) { public ResultsData collectingBox(String gatewayId, int current, int size) {
ArrayList<Map<String, Object>> resultList = getLSV(gatewayId); ArrayList<Map<String, Object>> resultList = getLSV(gatewayId);
//构建平台数据 // 构建平台数据
DataGridMock DataGridMock = new DataGridMock(current, resultList.size(), false, current, resultList); DataGridMock DataGridMock = new DataGridMock(current, resultList.size(), false, current, resultList);
ColModel colModelEventMovement = new ColModel("zz", "zz", "子阵", "子阵", "dataGrid", "zz"); ColModel colModelEventMovement = new ColModel("zz", "zz", "子阵", "子阵", "dataGrid", "zz");
ColModel colModelStationName = new ColModel("nbq", "nbq", "逆变器", "逆变器", "dataGrid", "nvq"); ColModel colModelStationName = new ColModel("nbq", "nbq", "逆变器", "逆变器", "dataGrid", "nvq");
ColModel colModelEventDesc = new ColModel("hlx", "hlx", "汇流箱", "汇流箱", "dataGrid", "hlx"); ColModel colModelEventDesc = new ColModel("hlx", "hlx", "汇流箱", "汇流箱", "dataGrid", "hlx");
ColModel colModelAlarmGroupName = new ColModel("avg", "avg", "支路电流平均值", "支路电流平均值", "dataGrid", "avg"); ColModel colModelAlarmGroupName = new ColModel("avg", "avg", "支路电流平均值", "支路电流平均值", "dataGrid", "avg");
ColModel colModelEventTime = new ColModel("lsv", "lsv", "支路电流离散率", "支路电流离散率", "dataGrid", "lsv"); ColModel colModelEventTime = new ColModel("lsv", "lsv", "支路电流离散率", "支路电流离散率", "dataGrid", "lsv");
List<ColModel> listColModel = Arrays.asList(colModelEventMovement, colModelStationName, colModelEventDesc, colModelAlarmGroupName, colModelEventTime); List<ColModel> listColModel = Arrays.asList(colModelEventMovement, colModelStationName, colModelEventDesc,
ResultsData resultsData = new ResultsData(DataGridMock, listColModel); colModelAlarmGroupName, colModelEventTime);
return resultsData; ResultsData resultsData = new ResultsData(DataGridMock, listColModel);
} return resultsData;
}
public ArrayList<Map<String, Object>> getLSV(String gatewayId)
{ public ArrayList<Map<String, Object>> getLSV(String gatewayId) {
ArrayList<Map<String, Object>> resultList = new ArrayList<>(); ArrayList<Map<String, Object>> resultList = new ArrayList<>();
Map<String, List<String>> queryConditon = new HashMap<>(); Map<String, List<String>> queryConditon = new HashMap<>();
queryConditon.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId)); queryConditon.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
Map<String, String> likeMap = new HashMap<>(); Map<String, String> likeMap = new HashMap<>();
likeMap.put(CommonConstans.QueryStringEquipmentIndexNameNotKeyword, "路电流"); likeMap.put(CommonConstans.QueryStringEquipmentIndexNameNotKeyword, "路电流");
List<ESEquipments> list = commonServiceImpl.getListDataByCondtionsAndLike(queryConditon, null, ESEquipments.class, likeMap); List<ESEquipments> list = commonServiceImpl.getListDataByCondtionsAndLike(queryConditon, null,
ESEquipments.class, likeMap);
Map<String, List<String>> queryConditon1 = new HashMap<>();
queryConditon1.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId)); Map<String, List<String>> queryConditon1 = new HashMap<>();
Map<String, String> likeMap1 = new HashMap<>(); queryConditon1.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
likeMap1.put(CommonConstans.QueryStringEquipmentIndexNameNotKeyword, "平均电流"); Map<String, String> likeMap1 = new HashMap<>();
List<ESEquipments> list1 = commonServiceImpl.getListDataByCondtionsAndLike(queryConditon, null, ESEquipments.class, likeMap1); likeMap1.put(CommonConstans.QueryStringEquipmentIndexNameNotKeyword, "平均电流");
List<ESEquipments> list1 = commonServiceImpl.getListDataByCondtionsAndLike(queryConditon, null,
if (!ValidationUtil.isEmpty(list)) { ESEquipments.class, likeMap1);
Map<String, List<ESEquipments>> collect = list.stream().collect(Collectors.groupingBy(ESEquipments::getEquipmentNumber));
for (String s : collect.keySet()) { if (!ValidationUtil.isEmpty(list)) {
List<ESEquipments> indicatorsDtos = collect.get(s); Map<String, List<ESEquipments>> collect = list.stream()
HashMap<String, Object> resultMap = new HashMap<>(); .collect(Collectors.groupingBy(ESEquipments::getEquipmentNumber));
Double avageValue = 0.0; for (String s : collect.keySet()) {
avageValue = indicatorsDtos.stream().filter(e -> !ObjectUtils.isEmpty(e.getValueF())).mapToDouble(l -> Double.parseDouble(l.getValueF().toString())).average().getAsDouble(); List<ESEquipments> indicatorsDtos = collect.get(s);
avageValue = Double.valueOf(String.format(CommonConstans.Twodecimalplaces, avageValue)); HashMap<String, Object> resultMap = new HashMap<>();
resultMap.put("avg", avageValue); Double avageValue = 0.0;
String[] name = s.split("-"); avageValue = indicatorsDtos.stream().filter(e -> !ObjectUtils.isEmpty(e.getValueF()))
resultMap.put("zz", "#" + name[0] + "子阵"); .mapToDouble(l -> Double.parseDouble(l.getValueF().toString())).average().getAsDouble();
resultMap.put("nbq", "逆变器" + name[1]); avageValue = Double.valueOf(String.format(CommonConstans.Twodecimalplaces, avageValue));
resultMap.put("hlx", "#" + name[2] + "汇流箱"); resultMap.put("avg", avageValue);
double lsv = 0.00; String[] name = s.split("-");
if (!ValidationUtil.isEmpty(list1)) { resultMap.put("zz", "#" + name[0] + "子阵");
List<ESEquipments> dtos = list1.stream().filter(e -> e.getEquipmentNumber().equals(s)).collect(Collectors.toList()); resultMap.put("nbq", "逆变器" + name[1]);
if (!ValidationUtil.isEmpty(dtos)) { resultMap.put("hlx", "#" + name[2] + "汇流箱");
for (ESEquipments esEquipments : indicatorsDtos) { double lsv = 0.00;
lsv = lsv + Math.pow(esEquipments.getValueF() - avageValue, 2); if (!ValidationUtil.isEmpty(list1)) {
} List<ESEquipments> dtos = list1.stream().filter(e -> e.getEquipmentNumber().equals(s))
} .collect(Collectors.toList());
lsv = lsv / indicatorsDtos.size(); if (!ValidationUtil.isEmpty(dtos)) {
lsv = Math.sqrt(lsv); for (ESEquipments esEquipments : indicatorsDtos) {
} lsv = lsv + Math.pow(esEquipments.getValueF() - avageValue, 2);
resultMap.put("lsv", String.format(CommonConstans.Twodecimalplaces, lsv)); }
resultList.add(resultMap); }
} lsv = lsv / indicatorsDtos.size();
} lsv = Math.sqrt(lsv);
}
return resultList; resultMap.put("lsv", String.format(CommonConstans.Twodecimalplaces, lsv));
} resultList.add(resultMap);
}
}
return resultList;
}
public List<Map<String, Object>> solarPowerOperation(String gatewayId) { public List<Map<String, Object>> solarPowerOperation(String gatewayId) {
HashMap<String,String> pvNBQStatus =getPvNBQStationBy(gatewayId);
Map<String, List<String>> queryCondtion = new HashMap<>(); Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId)); queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("有功功率", "逆变器效率", "总直流功率", "日发电量", "总发电量")); queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("有功功率", "逆变器效率", "总直流功率", "日发电量", "总发电量"));
...@@ -2036,7 +2041,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -2036,7 +2041,7 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
map.put("sort", s.split("-")[0] + "2"); map.put("sort", s.split("-")[0] + "2");
} }
map.put("type", "兆能");//此处暂时未提供数据 待定 暂写死值 map.put("type", "兆能");//此处暂时未提供数据 待定 暂写死值
map.put("status", "1");//此处暂时未提供数据 待定 暂写死值 map.put("status", pvNBQStatus.get(s));//此处暂时未提供数据 待定 暂写死值
indicatorsDtos.forEach(e -> { indicatorsDtos.forEach(e -> {
switch (e.getEquipmentIndexName()) { switch (e.getEquipmentIndexName()) {
case "总直流功率": case "总直流功率":
...@@ -2195,109 +2200,111 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -2195,109 +2200,111 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
return resultMap; return resultMap;
} }
public Page<Map<String, Object>> nbqStatus(String gatewayId) { public Page<Map<String, Object>> nbqStatus(String gatewayId) {
Map<String, List<String>> queryCondtion = new HashMap<>(); //
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("运行")); // Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId)); // queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("运行"));
Map<String, String> likeMap = new HashMap<>(); // queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
likeMap.put(CommonConstans.QueryStringFrontMoudleNotKeyWord, "逆变器"); // Map<String, String> likeMap = new HashMap<>();
List<ESEquipments> result = commonServiceImpl.getListDataByCondtionsAndLike(queryCondtion, null, ESEquipments.class, likeMap); // likeMap.put(CommonConstans.QueryStringFrontMoudleNotKeyWord, "逆变器");
// 逆变器总数量 // List<ESEquipments> result = commonServiceImpl.getListDataByCondtionsAndLike(queryCondtion, null, ESEquipments.class, likeMap);
Integer totalNumber = result.size(); // // 逆变器总数量
List<String> zcEquipmentNumberList = result.stream().filter(t -> "true".equals(t.getValue())).map(ESEquipments::getEquipmentNumber).collect(Collectors.toList()); // Integer totalNumber = result.size();
Map<String, List<String>> queryCondtion1 = new HashMap<>(); // List<String> zcEquipmentNumberList = result.stream().filter(t -> "true".equals(t.getValue())).map(ESEquipments::getEquipmentNumber).collect(Collectors.toList());
queryCondtion1.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("待机", "故障停机", "告警运行", "限额运行", "停机", "通讯故障", "降额运行")); // Map<String, List<String>> queryCondtion1 = new HashMap<>();
queryCondtion1.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId)); // queryCondtion1.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("待机", "故障停机", "告警运行", "限额运行", "停机", "通讯故障", "降额运行"));
queryCondtion1.put(CommonConstans.QueryStringValueKeyword, Arrays.asList("true")); // queryCondtion1.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
Map<String, String> likeMap1 = new HashMap<>(); // queryCondtion1.put(CommonConstans.QueryStringValueKeyword, Arrays.asList("true"));
likeMap1.put(CommonConstans.QueryStringFrontMoudleNotKeyWord, "逆变器"); // Map<String, String> likeMap1 = new HashMap<>();
List<ESEquipments> result1 = commonServiceImpl.getListDataByCondtionsAndLike(queryCondtion1, null, ESEquipments.class, likeMap1); // likeMap1.put(CommonConstans.QueryStringFrontMoudleNotKeyWord, "逆变器");
List<String> equipmentNumberList = result1.stream().map(ESEquipments::getEquipmentNumber).distinct().collect(Collectors.toList()); // List<ESEquipments> result1 = commonServiceImpl.getListDataByCondtionsAndLike(queryCondtion1, null, ESEquipments.class, likeMap1);
int djNum = 0; // List<String> equipmentNumberList = result1.stream().map(ESEquipments::getEquipmentNumber).distinct().collect(Collectors.toList());
int gzNum = 0; // int djNum = 0;
int gjNum = 0; // int gzNum = 0;
int xeNum = 0; // int gjNum = 0;
int xdNum = 0; // int xeNum = 0;
int txNum = 0; // int xdNum = 0;
int tjNum = 0; // int txNum = 0;
int zcNum = 0; // int tjNum = 0;
Set<String> equipNum = new HashSet<>(); // int zcNum = 0;
for (ESEquipments esEquipments : result1) { // Set<String> equipNum = new HashSet<>();
if (equipmentNumberList.contains(esEquipments.getEquipmentNumber()) && !zcEquipmentNumberList.contains(esEquipments.getEquipmentNumber())) { // for (ESEquipments esEquipments : result1) {
switch (esEquipments.getEquipmentIndexName()) { // if (equipmentNumberList.contains(esEquipments.getEquipmentNumber()) && !zcEquipmentNumberList.contains(esEquipments.getEquipmentNumber())) {
case "待机": // switch (esEquipments.getEquipmentIndexName()) {
djNum += 1; // case "待机":
equipmentNumberList.remove(esEquipments.getEquipmentNumber()); // djNum += 1;
break; // equipmentNumberList.remove(esEquipments.getEquipmentNumber());
case "故障停机": // break;
gzNum += 1; // case "故障停机":
equipmentNumberList.remove(esEquipments.getEquipmentNumber()); // gzNum += 1;
break; // equipmentNumberList.remove(esEquipments.getEquipmentNumber());
case "告警运行": // break;
gjNum += 1; // case "告警运行":
equipmentNumberList.remove(esEquipments.getEquipmentNumber()); // gjNum += 1;
break; // equipmentNumberList.remove(esEquipments.getEquipmentNumber());
case "限额运行": // break;
xeNum += 1; // case "限额运行":
equipmentNumberList.remove(esEquipments.getEquipmentNumber()); // xeNum += 1;
equipNum.add(esEquipments.getEquipmentNumber()); // equipmentNumberList.remove(esEquipments.getEquipmentNumber());
break; // equipNum.add(esEquipments.getEquipmentNumber());
case "停机": // break;
tjNum += 1; // case "停机":
equipmentNumberList.remove(esEquipments.getEquipmentNumber()); // tjNum += 1;
break; // equipmentNumberList.remove(esEquipments.getEquipmentNumber());
case "通讯故障": // break;
xdNum += 1; // case "通讯故障":
equipmentNumberList.remove(esEquipments.getEquipmentNumber()); // xdNum += 1;
break; // equipmentNumberList.remove(esEquipments.getEquipmentNumber());
case "降额运行": // break;
txNum += 1; // case "降额运行":
equipmentNumberList.remove(esEquipments.getEquipmentNumber()); // txNum += 1;
break; // equipmentNumberList.remove(esEquipments.getEquipmentNumber());
} // break;
} // }
} // }
zcNum = totalNumber - djNum - gzNum - gjNum - xeNum - xdNum - txNum - tjNum; // }
// zcNum = totalNumber - djNum - gzNum - gjNum - xeNum - xdNum - txNum - tjNum;
HashMap<String,String> nbpstatus = getPvNBQStationBy(gatewayId);
List<Object> statusList =Arrays.asList(nbpstatus.values().toArray());
Page<Map<String, Object>> mapPage = new Page<>(); Page<Map<String, Object>> mapPage = new Page<>();
ArrayList<Map<String, Object>> resultList = new ArrayList<>(); ArrayList<Map<String, Object>> resultList = new ArrayList<>();
HashMap<String, Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>();
map.put("count", zcNum); map.put("count", statusList.stream().filter(s->s.toString().contains("正常运行")).count());
map.put("equipmentIndexName", "正常运行"); map.put("equipmentIndexName", "正常运行");
map.put("color", "#00AA00"); map.put("color", "#00AA00");
resultList.add(map); resultList.add(map);
HashMap<String, Object> map2 = new HashMap<>(); HashMap<String, Object> map2 = new HashMap<>();
map2.put("count", tjNum); map2.put("count", statusList.stream().filter(s->s.toString().contains("正常停机")).count());
map2.put("equipmentIndexName", "正常停机"); map2.put("equipmentIndexName", "正常停机");
map2.put("color", "#0055FF"); map2.put("color", "#0055FF");
resultList.add(map2); resultList.add(map2);
HashMap<String, Object> map3 = new HashMap<>(); HashMap<String, Object> map3 = new HashMap<>();
map3.put("count", xeNum); map3.put("count", statusList.stream().filter(s->s.toString().contains("限功率")).count());
map3.put("equipmentIndexName", "限功率"); map3.put("equipmentIndexName", "限功率");
map3.put("color", "#A3F5AA"); map3.put("color", "#A3F5AA");
resultList.add(map3); resultList.add(map3);
HashMap<String, Object> map4 = new HashMap<>(); HashMap<String, Object> map4 = new HashMap<>();
map4.put("count", xdNum); map4.put("count", statusList.stream().filter(s->s.toString().contains("限电停机")).count());
map4.put("equipmentIndexName", "限电停机"); map4.put("equipmentIndexName", "限电停机");
map4.put("color", "#FF00FF"); map4.put("color", "#FF00FF");
resultList.add(map4); resultList.add(map4);
HashMap<String, Object> map5 = new HashMap<>(); HashMap<String, Object> map5 = new HashMap<>();
map5.put("count", gjNum); map5.put("count", statusList.stream().filter(s->s.toString().contains("告警运行")).count());
map5.put("equipmentIndexName", "告警运行"); map5.put("equipmentIndexName", "告警运行");
map5.put("color", "#F9AD14"); map5.put("color", "#F9AD14");
resultList.add(map5); resultList.add(map5);
HashMap<String, Object> map6 = new HashMap<>(); HashMap<String, Object> map6 = new HashMap<>();
map6.put("count", gzNum); map6.put("count", statusList.stream().filter(s->s.toString().contains("故障停机")).count());
map6.put("equipmentIndexName", "故障停机"); map6.put("equipmentIndexName", "故障停机");
map6.put("color", "#F91414"); map6.put("color", "#F91414");
resultList.add(map6); resultList.add(map6);
HashMap<String, Object> map7 = new HashMap<>(); HashMap<String, Object> map7 = new HashMap<>();
map7.put("count", djNum); map7.put("count", statusList.stream().filter(s->s.toString().contains("待机状态")).count());
map7.put("equipmentIndexName", "待机"); map7.put("equipmentIndexName", "待机");
map7.put("color", "#00AAFF"); map7.put("color", "#00AAFF");
resultList.add(map7); resultList.add(map7);
HashMap<String, Object> map8 = new HashMap<>(); HashMap<String, Object> map8 = new HashMap<>();
map8.put("count", txNum); map8.put("count", statusList.stream().filter(s->s.toString().contains("通讯中断")).count());
map8.put("equipmentIndexName", "通讯中断"); map8.put("equipmentIndexName", "通讯中断");
map8.put("color", "#7D8E95"); map8.put("color", "#7D8E95");
resultList.add(map8); resultList.add(map8);
...@@ -2521,18 +2528,22 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator { ...@@ -2521,18 +2528,22 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
queryCondition.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId)); queryCondition.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
Map<String, String> shouldCondition = new HashMap<>(); Map<String, String> shouldCondition = new HashMap<>();
shouldCondition.put(CommonConstans.QueryStringFrontMoudle, "逆变器"); shouldCondition.put(CommonConstans.QueryStringFrontMoudle, "逆变器");
List<ESEquipments> totalEquipmentList = commonServiceImpl.getListDataByCondtions(queryCondition, shouldCondition, ESEquipments.class); List<ESEquipments> totalEquipmentList = commonServiceImpl.getListDataByCondtions(queryCondition, null, ESEquipments.class,shouldCondition);
totalEquipmentList.forEach(indicatorsDto -> result.put(indicatorsDto.getEquipmentNumber(), "正常运行")); totalEquipmentList.forEach(indicatorsDto -> result.put(indicatorsDto.getEquipmentNumber(), "正常运行"));
Map<String, List<String>> queryCondition1 = new HashMap<>(); Map<String, List<String>> queryCondition1 = new HashMap<>();
queryCondition1.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("运行", "待机", "故障停机", "告警运行", "限额运行", "停机", "通讯故障", "'降额运行'")); queryCondition1.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("运行", "待机", "故障停机", "告警运行", "限额运行", "停机", "通讯故障", "'降额运行'"));
queryCondition1.put(CommonConstans.QueryStringValueKeyword, Arrays.asList("true")); queryCondition1.put(CommonConstans.QueryStringValueKeyword, Arrays.asList("true"));
queryCondition1.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId)); queryCondition1.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
List<ESEquipments> indicatorsDtoList = commonServiceImpl.getListDataByCondtions(queryCondition1, shouldCondition, ESEquipments.class); List<ESEquipments> indicatorsDtoList = commonServiceImpl.getListDataByCondtions(queryCondition1, null, ESEquipments.class,shouldCondition);
queryCondition.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("总直流功率"));
List<ESEquipments> inputPowerData = commonServiceImpl.getListDataByCondtions(queryCondition, null, ESEquipments.class,shouldCondition);
List<String> inputPowerDataResult = inputPowerData.stream().filter(esEquipments -> !(esEquipments.getValueF() >0)).collect(Collectors.toList()).stream().map(esEquipments -> esEquipments.getEquipmentNumber()).collect(Collectors.toList());
indicatorsDtoList.forEach(esEquipments -> { indicatorsDtoList.forEach(esEquipments -> {
if (!"运行".equals(esEquipments.getEquipmentIndexName())) { if (!"运行".equals(esEquipments.getEquipmentIndexName())) {
result.put(esEquipments.getEquipmentNumber(), CommonConstans.pvStatus.get(esEquipments.getEquipmentIndexName())); result.put(esEquipments.getEquipmentNumber(), CommonConstans.pvStatus.get(esEquipments.getEquipmentIndexName()));
} }
}); });
inputPowerDataResult.forEach(s->result.put(s,"待机状态"));
return result; return result;
} }
......
...@@ -76,7 +76,7 @@ gl.sum.column=日发电量,月发电量,年发电量 ...@@ -76,7 +76,7 @@ gl.sum.column=日发电量,月发电量,年发电量
gl.avg.column=有功功率,日利用小时,瞬时风速 gl.avg.column=有功功率,日利用小时,瞬时风速
equip.warn.cron= 0 0/10 * * * ?
#ES 曲线图定时 0 57 23 * * ? #ES 曲线图定时 0 57 23 * * ?
windSpeed.cron = 0 25 9 * * ? windSpeed.cron = 0 25 9 * * ?
#本地使用 0 0 5 29 2 ? ? 线上使用 0 */5 * * * ? #本地使用 0 0 5 29 2 ? ? 线上使用 0 */5 * * * ?
......
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