Commit 541608fc authored by chenzhao's avatar chenzhao

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

parents 21bcda80 3441dd41
......@@ -65,7 +65,15 @@ public class DeviceController extends BaseController {
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "监盘大屏 - 获取历史告警数据")
@GetMapping("/historyNationwideByPage")
public ResponseModel<Page<IndexDto>> historyNationwideByPage(@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size,
@RequestParam(value = "stationBasicId") String stationBasicId) {
Page<IndexDto> resultsData = monitorFanIndicatorImpl.historyNationwideByPage( current, size, stationBasicId);
return ResponseHelper.buildResponse(resultsData);
}
......
......@@ -129,7 +129,7 @@ public class LargeScreenImpl {
int month = currentDate.getMonthValue();
QueryWrapper<StationPlan> wrapper = new QueryWrapper<>();
wrapper.select("sum(value) as sum_value");
wrapper.select("ifnull(sum(value), 0) as sum_value");
wrapper.eq("monthly", month);
List<Map<String, Object>> list = StationPlanMapper.selectMaps(wrapper);
Double sumValue = list != null && !list.isEmpty() ? (Double) list.get(0).get("sum_value") : 0;
......@@ -139,8 +139,8 @@ public class LargeScreenImpl {
mapdta.put("YJHWC", ybfb);
QueryWrapper<StationPlan> wrapper1 = new QueryWrapper<>();
wrapper1.select("sum(value) as sum_value");
List<Map<String, Object>> list1 = StationPlanMapper.selectMaps(wrapper);
wrapper1.select("ifnull(sum(value), 0) as sum_value");
List<Map<String, Object>> list1 = StationPlanMapper.selectMaps(wrapper1);
Double sumValuen = list1 != null && !list1.isEmpty() ? (Double) list1.get(0).get("sum_value") : 0;
Double ybfbn = sumValuen > 0 ? mapdta.get("NFD") / sumValue * 100 : 0;
ybfbn = new BigDecimal(ybfbn).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
......
......@@ -34,6 +34,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.velocity.runtime.directive.Break;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.elasticsearch.common.recycler.Recycler;
import org.elasticsearch.index.Index;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
......@@ -192,6 +193,29 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
}
public Page<IndexDto> historyNationwideByPage(int current, int size, String stationBasicId) {
StationBasic stationBasic = stationBasicMapper.selectById(stationBasicId);
String gateway = stationBasic.getFanGatewayId();
String table = gateway;
StringBuffer querysql = new StringBuffer("SELECT createdTime ,gatewayId,address,valueLabel,equipmentSpecificName,value FROM iot_data_%s WHERE isAlarm='1' and value!=valueLabel and value!='0.0' and gatewayId= %s ORDER BY time desc LIMIT %d OFFSET %d ");
StringBuffer querysqlcount = new StringBuffer("SELECT count(value) FROM iot_data_%s WHERE isAlarm='1' and value!='0.0' and value!=valueLabel and gatewayId= %s ");
gateway = String.format("'%s'", gateway);
String querysqln = String.format(querysql.toString(), table, gateway, size, (current - 1) *size);
String querysqlcountn = String.format(querysqlcount.toString(), table, gateway);
//每个分机的指标数据
List<IndexDto> list = influxDButils.getListData(querysqln, IndexDto.class);
List<IndexDto> list1 = influxDButils.getListData(querysqlcountn, IndexDto.class);
//对于查询到的告警信息进行按照时间顺序进行排序
ArrayList<IndexDto> lisSort= (ArrayList<IndexDto>) list.stream().sorted(Comparator.comparing(IndexDto::getTimeString,Comparator.comparingLong(Long::parseLong)).reversed()).collect(Collectors.toList());
Page<IndexDto> indexDtoPage = new Page<>();
indexDtoPage.setTotal(list1.size());
indexDtoPage.setRecords(lisSort);
indexDtoPage.setCurrent(current);
indexDtoPage.setSize(size);
return indexDtoPage;
}
public IPage<IndexDto> getFanIdxInfoByPage(String equipNum, String stationId, String frontModule, int current, int size, String systemType) {
StationBasic stationBasic = getOneByStationNumber(stationId);
......
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
......@@ -29,6 +30,7 @@ import com.yeejoin.amos.feign.privilege.model.DepartmentModel;
import com.yeejoin.amos.feign.privilege.model.LoginInfoModel;
import com.yeejoin.amos.feign.privilege.util.DesUtil;
import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.paho.client.mqttv3.MqttException;
......@@ -41,6 +43,7 @@ import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import springfox.documentation.spring.web.json.Json;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Field;
......@@ -55,6 +58,7 @@ import java.util.stream.Collectors;
* @author system_generator
* @date 2023-04-20
*/
@Slf4j
@Service
public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBasic, PersonBasicMapper> implements IPersonBasicService {
......@@ -482,8 +486,10 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
usd.setUserName(personAccount.getAccountName());
usd.setLockStatus("UNLOCK");
usd.setUserId(personAccount.getPuserId());
usd.setOriginalPassword(oldpersonAccount.getPassword());
//新增平台用户
AgencyUserModel agencyUserModel = this.updateuser(personAccount.getPuserId(), usd);
log.info("更新平台账户信息::"+ JSONObject.toJSONString(usd));
//设置userID
usd.setUserId(agencyUserModel.getUserId());
//设置工号
......@@ -616,8 +622,8 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
//修改平台用户
private AgencyUserModel updateuser(String userId, AgencyUserModel userDto) {
FeignClientResult<AgencyUserModel> amosUser = Privilege.agencyUserClient.update(userDto, userId);
FeignClientResult<AgencyUserModel> amosUser1 = Privilege.agencyUserClient.modifyPassword(userId,userDto);
AgencyUserModel user = new AgencyUserModel();
if (!ObjectUtils.isEmpty(amosUser)) {
if (amosUser.getStatus() == 200) {
user = amosUser.getResult();
......@@ -625,6 +631,13 @@ public class PersonBasicServiceImpl extends BaseService<PersonBasicDto, PersonBa
throw new RuntimeException(amosUser.getMessage());
}
}
if (!ObjectUtils.isEmpty(amosUser1)) {
if (amosUser1.getStatus() == 200) {
user = amosUser1.getResult();
} else {
throw new RuntimeException(amosUser1.getMessage());
}
}
return user;
}
private LoginInfoModel updateLoginInfo(String loginId,AgencyUserModel userDto) {
......
package com.yeejoin.amos.boot.module.jxiop.biz.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import java.io.Serializable;
......@@ -25,4 +24,6 @@ public class StationCacheInfoDto implements Serializable {
private String fanGatewayId;
//升压站网关
private String boosterGatewayId;
//片区code
private String areaCode;
}
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import cn.hutool.extra.pinyin.PinyinUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jxiop.api.entity.MapRegion;
import com.yeejoin.amos.boot.module.jxiop.api.entity.Region;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.MapRegionMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.RegionMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationPlanMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments;
......@@ -33,6 +38,7 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
......@@ -56,6 +62,11 @@ public class CommonServiceImpl {
@Autowired
private StationBasicMapper stationBasicMapper;
@Resource
private RegionMapper regionMapper;
@Resource
private MapRegionMapper mapRegionMapper;
/**
* 带参数 求平均值
*/
......@@ -178,6 +189,13 @@ public class CommonServiceImpl {
return value;
}
/**
* @deprecated 获取场站的设备总数
* @param queryDto
* @param keysum
* @param clas
* @return
*/
public Integer getCount(List<QueryDto> queryDto, String keysum, Class clas) {
BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery();
for (QueryDto dto : queryDto) {
......@@ -225,7 +243,6 @@ public class CommonServiceImpl {
return Double.valueOf(String.format("%.2f", totalvalue));
}
public Double getNumByIndicatior(String gatewayId, String indicator) {
String sql = "SELECT * FROM indicators_" + gatewayId + " where equipmentIndexName=~/" + indicator + "$/";
Double totalvalue = 0.00;
......@@ -256,6 +273,12 @@ public class CommonServiceImpl {
return Double.valueOf(String.format("%.2f", avageValue));
}
/**
*
* @param mapList 查询出来的influxdb数据
* @param indicator 指标名称
* @return 该指标的求和数据
*/
public Double getTotalByIndicatior(List<Map<String, Object>> mapList, String indicator) {
Double totalvalue = 0.0000;
try {
......@@ -281,10 +304,21 @@ public class CommonServiceImpl {
return Double.valueOf(String.format("%.2f", avageValue));
}
/**
* 根据场站Number获取装机容量
* @param WERKS
* @return
*/
public Double getStationCapactityByStationWerks(String WERKS) {
return sjglZsjZsbtzMapper.getStationCapactityByStationWerks(WERKS);
}
/**
* @deprecated 根据发电量获取社会贡献
* @param totalSocialContribution
* @return
*/
public Page<SocialContributionDto> getSocialContributionDtoList(Double totalSocialContribution) {
Page<SocialContributionDto> socialContributionDtoPage = new Page<SocialContributionDto>();
List<SocialContributionDto> socialContributionDtoList = new ArrayList<>();
......@@ -327,12 +361,40 @@ public class CommonServiceImpl {
return socialContributionDtoPage;
}
/**
* @deprecated 获取缓存场站信息数据
* @return 缓存的场站信息
*/
public List<StationCacheInfoDto> getListStationCacheInfoDto() {
List<StationCacheInfoDto> stationCacheInfoDtoList = redisTemplate.opsForList().range("station_info_cache", 0, -1);
if (ObjectUtils.isEmpty(stationCacheInfoDtoList)) {
try {
stationCacheDataInit.run();
stationCacheInfoDtoList = redisTemplate.opsForList().range("station_info_cache", 0, -1);
List<StationCacheInfoDto> stationCacheInfoDtos = new ArrayList<>();
List<Region> regionList = regionMapper.selectList(new QueryWrapper<Region>().eq("LEVEL", 1));
List<MapRegion> mapRegionList = mapRegionMapper.selectList(new QueryWrapper<MapRegion>().isNotNull("name"));
List<StationBasic> stationBasicList = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().isNotNull("belong_area").isNotNull("fan_gateway_id"));
stationBasicList.forEach(stationBasic -> {
StationCacheInfoDto stationCacheInfoDto = new StationCacheInfoDto();
stationCacheInfoDto.setStationId(stationBasic.getSequenceNbr().toString());
stationCacheInfoDto.setStationName(stationBasic.getStationName());
stationCacheInfoDto.setStationType(stationBasic.getStationType());
stationCacheInfoDto.setBelongProvince(regionList.stream().filter(region -> region.getRegionCode().toString().equals(stationBasic.getBelongArea().replace("[","").split(",")[0])).map(region -> region.getRegionName()).collect(Collectors.toList()).get(0));
stationCacheInfoDto.setBelongArea(mapRegionList.stream().filter(mapRegion -> mapRegion.getProvince().contains(stationCacheInfoDto.getBelongProvince().substring(0,2))||mapRegion.getProvince().contains(stationCacheInfoDto.getBelongProvince().substring(0,3))).map(mapRegion -> mapRegion.getName()).collect(Collectors.toList()).get(0));
stationCacheInfoDto.setAreaCode(mapRegionList.stream().filter(mapRegion -> mapRegion.getProvince().contains(stationCacheInfoDto.getBelongProvince().substring(0,2))||mapRegion.getProvince().contains(stationCacheInfoDto.getBelongProvince().substring(0,3))).map(mapRegion -> mapRegion.getAreaCode()).collect(Collectors.toList()).get(0));
stationCacheInfoDto.setInstalledCapacity(String.format("%.2f",sjglZsjZsbtzMapper.getStationCapactityByStationWerks(stationBasic.getStationNumber())));
List<QueryDto> queryDtoList = new ArrayList<>();
queryDtoList.add(new QueryDto("gatewayId",stationBasic.getFanGatewayId()));
queryDtoList.add(new QueryDto("equipmentIndexName.keyword","有功功率"));
if(!stationBasic.getStationType().equals("FDZ")){
queryDtoList.add(new QueryDto("frontModule","逆变器"));
}
stationCacheInfoDto.setEquipmentNumbers(this.getCount(queryDtoList,"equipmentNumber.Keyword", ESEquipments.class).toString());
stationCacheInfoDto.setFanGatewayId(stationBasic.getFanGatewayId());
stationCacheInfoDto.setBoosterGatewayId(stationBasic.getBoosterGatewayId());
stationCacheInfoDtos.add(stationCacheInfoDto);
});
redisTemplate.opsForList().leftPushAll("station_info_cache",stationCacheInfoDtos);
return stationCacheInfoDtos;
} catch (Exception e) {
throw new RuntimeException(e);
}
......@@ -340,13 +402,36 @@ public class CommonServiceImpl {
return stationCacheInfoDtoList;
}
/**
* @deprecated 根据场站id获取缓存数据中的场站对象
* @param stationId 场站id
* @return 缓存的场站对象
*/
public StationCacheInfoDto getStationCacheInfoDtoByStationId(String stationId) {
StationCacheInfoDto stationCacheInfoDto = this.getListStationCacheInfoDto().stream().filter(stationCacheInfoDto1 -> stationCacheInfoDto1.getStationId().equals(stationId)).collect(Collectors.toList()).get(0);
return stationCacheInfoDto;
}
/**
* @deprecated 根据场站id获取场站的首字母缩写
* @param stationid 场站id
* @return 返回该场站的名称拼音缩写
*/
public String getFanDevicePrefix(String stationid) {
StationBasic stationBasic = stationBasicMapper.selectById(stationid);
return PinyinUtil.getFirstLetter(stationBasic.getStationName().split("风")[0], "").toUpperCase(Locale.ROOT);
}
/**
* @deprecated 将查询条件进行组装
* @param searchCondtionMap 需要查询的数据的 条件map
* @return List<QueryDto> QueryDtolist 用于给传值
*/
public List<QueryDto> getQueryDtoList(Map<String,String> searchCondtionMap){
List<QueryDto> result = new ArrayList<>();
searchCondtionMap.keySet().forEach(s -> {
result.add(new QueryDto(s,searchCondtionMap.get(s)));
});
return result;
}
}
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