Commit d1eac0ba authored by hezhuozhi's avatar hezhuozhi

Merge remote-tracking branch 'origin/developer' into developer

parents 359cb987 65b8929a
......@@ -279,4 +279,11 @@ public class HouseholdTestController {
public void tanyinCustomer() {
tanYinDataAcquisitionService.customerInfoList();
}
@TycloudOperation(ApiLevel = UserType.PUBLIC, needAuth = false)
@PostMapping(value = "/tanyin/inverAlram")
@ApiOperation(httpMethod = "POST", value = "电站逆变器故障接口", notes = "电站逆变器故障接口")
public void tanyinInverAlram() {
tanYinDataAcquisitionService.inverAlramInfo();
}
}
......@@ -64,6 +64,7 @@ import org.springframework.util.ObjectUtils;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
......@@ -474,11 +475,16 @@ public class TanYinDataAcquisitionServiceImpl implements TanYinDataAcquisitionSe
.put("endDate", endDate).build();
PageInfo<TanYinAlramInfo> tanYinInveterInfo = tanYinApiUtils.postPage("电站逆变器故障信息", apiUrl + TanYinConstant.inverterAlramUrl, JSON.toJSONString(params), null, TanYinAlramInfo.class);
List<TanYinAlramInfo> tanYinAlramInfos = tanYinInveterInfo.getList();
if (CollectionUtils.isEmpty(tanYinAlramInfos)) {
log.warn("-------碳银同步电站逆变器故障信息结束: 未获取到逆变器故障信息 ------- ");
return;
}
for (TanYinAlramInfo tanYinAlramInfo : tanYinAlramInfos) {
tanYinAlramInfo.setCreateTime(System.currentTimeMillis());
tanYinAlramInfoMapper.insert(tanYinAlramInfo);
HYGFJPInverterWarn hygfjpInverterWarn = new HYGFJPInverterWarn();
// 做查询
hygfjpInverterWarn.setTime(System.currentTimeMillis());
hygfjpInverterWarn.setSnCode(tanYinAlramInfo.getSn());
hygfjpInverterWarn.setThirdStationId(jpStation.getThirdStationId());
......@@ -494,14 +500,16 @@ public class TanYinDataAcquisitionServiceImpl implements TanYinDataAcquisitionSe
hygfjpInverterWarn.setTreatment(tanYinAlramInfo.getSolution());
hygfjpInverterWarn.setState(tanYinAlramInfo.getStatus());
if (!ObjectUtils.isEmpty(tanYinAlramInfo.getFaultEndTime())) {
hygfjpInverterWarn.setRecoverTime(Long.valueOf(tanYinAlramInfo.getFaultEndTime()));
Date faultEndTimeDt = Date.from(LocalDate.parse(tanYinAlramInfo.getFaultEndTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd")).atStartOfDay(ZoneId.systemDefault()).toInstant());
hygfjpInverterWarn.setRecoverTime(faultEndTimeDt.getTime());
}
if (!ObjectUtils.isEmpty(tanYinAlramInfo.getFaultOccurTime())) {
hygfjpInverterWarn.setStartTime(Long.valueOf(tanYinAlramInfo.getFaultOccurTime()));
Date faultOccurTimeDt = Date.from(LocalDate.parse(tanYinAlramInfo.getFaultOccurTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd")).atStartOfDay(ZoneId.systemDefault()).toInstant());
hygfjpInverterWarn.setStartTime(faultOccurTimeDt.getTime());
}
hygfjpInverterWarn.setTimeLong(null);
if ((!ObjectUtils.isEmpty(tanYinAlramInfo.getFaultOccurTime())) && (!ObjectUtils.isEmpty(tanYinAlramInfo.getFaultEndTime()))) {
hygfjpInverterWarn.setTimeLong(this.convertDate(hygfjpInverterWarn.getRecoverTime()) - this.convertDate(hygfjpInverterWarn.getStartTime()));
hygfjpInverterWarn.setTimeLong(this.convertDate(hygfjpInverterWarn.getRecoverTime()) - this.convertDate(hygfjpInverterWarn.getStartTime()));
}
if (ObjectUtils.isEmpty(hygfjpInverterWarn.getCreatedTime())) {
hygfjpInverterWarn.setCreatedTime(System.currentTimeMillis());
......
package com.yeejoin.amos.boot.module.hygf.biz.controller;
import java.util.List;
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.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.hygf.api.entity.UnitInfo;
import com.yeejoin.amos.boot.module.hygf.api.mapper.PersonnelBusinessMapper;
import com.yeejoin.amos.boot.module.hygf.api.mapper.UnitInfoMapper;
import com.yeejoin.amos.boot.module.hygf.api.util.CommonResponseNewUtil;
import com.yeejoin.amos.boot.module.hygf.biz.service.impl.PeasantHouseholdServiceImpl;
import com.yeejoin.amos.boot.module.hygf.biz.service.impl.SurveyInformationServiceImpl;
import com.yeejoin.amos.boot.module.standard.api.entity.PublicAgencyUser;
import com.yeejoin.amos.boot.module.standard.api.mapper.PublicAgencyUserMapper;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.util.AesUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/**
* 农户信息
*
* @author system_generator
* @date 2023-07-07
*/
@RestController
@Api(tags = "农户信息Api")
@RequestMapping(value = "/test")
public class TestController extends BaseController {
@Autowired
SurveyInformationServiceImpl surveyInformationServiceImpl;
@Autowired
PeasantHouseholdServiceImpl peasantHouseholdServiceImpl;
@Autowired
RedisUtils redisUtils;
private static final String regionRedis = "app_region_redis";
@Autowired
PersonnelBusinessMapper personnelBusinessMapper;
@Autowired
UnitInfoMapper unitInfoMapper;
@Autowired
PublicAgencyUserMapper publicAgencyUserMapper;
/**
* 新增农户信息
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/initpw")
@ApiOperation(httpMethod = "GET", value = "新增农户信息", notes = "新增农户信息")
public ResponseModel<Object> initpw() {
// 经销商管理员
List<UnitInfo> list = unitInfoMapper.selectList(null);
for (UnitInfo unitInfo : list) {
try {
int ph = unitInfo.getAdminPhone().length();
String npwd = "Zxnk_" + unitInfo.getAdminPhone().substring(ph - 4, ph);
String npwdm = AesUtil.encode(npwd, "qaz");
unitInfo.setAdminLoginPwd(npwdm);
FeignClientResult<AgencyUserModel> re = Privilege.agencyUserClient
.queryByUserId(unitInfo.getAdminUserId());
AgencyUserModel ag = re.getResult();
ag.setPassword(AesUtil.encode(npwd, "qaz"));
ag.setRePassword(AesUtil.encode(npwd, "qaz"));
Privilege.agencyUserClient.restorePassword(unitInfo.getAdminUserId());
ag.setOriginalPassword(AesUtil.encode("Z2%Op9.q", "qaz"));
Privilege.agencyUserClient.modifyPassword(unitInfo.getAdminUserId(), ag);
unitInfoMapper.updateById(unitInfo);
} catch (Exception e) {
e.printStackTrace();
}
}
// 经销商子人员
List<PublicAgencyUser> list2 = publicAgencyUserMapper.selectList(null);
for (PublicAgencyUser unitInfo : list2) {
try {
int ph = unitInfo.getEmergencyTelephone().length();
String npwd = "Zxnk_" + unitInfo.getEmergencyTelephone().substring(ph - 4, ph);
String npwdm = AesUtil.encode(npwd, "qaz");
unitInfo.setPassword(npwdm);
FeignClientResult<AgencyUserModel> re = Privilege.agencyUserClient
.queryByUserId(unitInfo.getAmosUserId());
AgencyUserModel ag = re.getResult();
ag.setPassword(AesUtil.encode(npwd, "qaz"));
ag.setRePassword(AesUtil.encode(npwd, "qaz"));
Privilege.agencyUserClient.restorePassword(unitInfo.getAmosUserId());
ag.setOriginalPassword(AesUtil.encode("Z2%Op9.q", "qaz"));
Privilege.agencyUserClient.modifyPassword(unitInfo.getAmosUserId(), ag);
publicAgencyUserMapper.updateById(unitInfo);
} catch (Exception e) {
e.printStackTrace();
}
}
return CommonResponseNewUtil.success();
}
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import cn.hutool.core.date.DateUtil;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -22,11 +26,16 @@ import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.TdengineTimeServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanHealthIndexMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanWaringRecordMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvHealthIndexMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvWaringRecordMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanWarningRecord;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvWarningRecord;
import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.utils.TimeRangeUtil;
import cn.hutool.core.date.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -187,7 +196,7 @@ public class TestController extends BaseController {
time = DateUtil.offsetMinute(time, -DateUtil.minute(time) % 10);
String format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00");
time = DateUtil.parse(format, "yyyy-MM-dd HH:mm:00");
tdengineTimeService.insertMomentDataTest("2024-07-25 08:00:00");
tdengineTimeService.insertMomentDataTest("2024-07-24 08:00:00");
} catch (Exception e) {
e.printStackTrace();
}
......@@ -202,9 +211,75 @@ public class TestController extends BaseController {
time = DateUtil.offsetMinute(time, -DateUtil.minute(time) % 10);
String format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00");
time = DateUtil.parse(format, "yyyy-MM-dd HH:mm:00");
tdengineTimeService.insertMomentDataPvTest("2024-07-25 08:00:00");
tdengineTimeService.insertMomentDataPvTest("2024-07-24 08:00:00");
//区域 全域最后统一生成
tdengineTimeService.insertMomentDataAllTest("2024-07-24 08:00:00");
} catch (Exception e) {
e.printStackTrace();
}
}
@Autowired
PvHealthIndexMapper pvHealthIndexMapper;
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "test2", notes = "test1")
@GetMapping("/clear-health-cf")
public void clearHealthCf(@RequestParam(value = "startTime", required = false) String startTime)
throws ParseException {
List<String> type = new ArrayList<>();
type.add("按10分钟");
type.add("按小时");
type.add("按天");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
List<String> mList = TimeRangeUtil.getMomentInfo(sdf.parse(startTime), new Date());
for (String d : mList) {
LambdaQueryWrapper<FanHealthIndex> wf = new LambdaQueryWrapper<>();
wf.eq(FanHealthIndex::getAnalysisTime, d);
wf.orderByAsc(FanHealthIndex::getTs);
wf.eq(FanHealthIndex::getAnalysisObjType, "测点");
for (String s : type) {
wf.eq(FanHealthIndex::getAnalysisType, s);
List<FanHealthIndex> list = fanHealthIndexMapper.selectList(wf);
Map<String, List<FanHealthIndex>> lm = list.stream()
.collect(Collectors.groupingBy(FanHealthIndex::getIndexAddress));
for (Entry<String, List<FanHealthIndex>> m : lm.entrySet()) {
List<FanHealthIndex> pl = m.getValue();
if (pl.size() > 1) {
pl = pl.subList(1, pl.size());
}
List<Long> ts = pl.stream().map(FanHealthIndex::getTs).collect(Collectors.toList());
LambdaQueryWrapper<FanHealthIndex> df = new LambdaQueryWrapper<>();
for (Long ts1 : ts) {
df.eq(FanHealthIndex::getTs, ts1);
fanHealthIndexMapper.delete(df);
}
}
}
LambdaQueryWrapper<PvHealthIndex> pf = new LambdaQueryWrapper<>();
pf.eq(PvHealthIndex::getAnalysisTime, d);
pf.orderByAsc(PvHealthIndex::getTs);
pf.eq(PvHealthIndex::getAnalysisObjType, "测点");
for (String s : type) {
pf.eq(PvHealthIndex::getAnalysisType, s);
List<PvHealthIndex> listp = pvHealthIndexMapper.selectList(pf);
Map<String, List<PvHealthIndex>> lmp = listp.stream()
.collect(Collectors.groupingBy(PvHealthIndex::getIndexAddress));
for (Entry<String, List<PvHealthIndex>> m : lmp.entrySet()) {
List<PvHealthIndex> pl = m.getValue();
if (pl.size() > 1) {
pl = pl.subList(1, pl.size());
}
List<Long> ts = pl.stream().map(PvHealthIndex::getTs).collect(Collectors.toList());
LambdaQueryWrapper<PvHealthIndex> df = new LambdaQueryWrapper<>();
for (Long ts1 : ts) {
df.eq(PvHealthIndex::getTs, ts1);
pvHealthIndexMapper.delete(df);
}
}
}
}
}
}
......@@ -37,4 +37,7 @@ public class HealthIndexDTO {
private String analysisTime;
private String kks;
private String orgCode;
private String manufacturer;
private String deviceType;
}
package com.yeejoin.amos.boot.module.jxiop.biz.listener;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl;
import lombok.extern.slf4j.Slf4j;
import java.text.ParseException;
import java.util.Date;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.component.emq.EmqxListener;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.TdengineTimeServiceImpl;
import cn.hutool.core.date.DateUtil;
import lombok.extern.slf4j.Slf4j;
/**
* @author Administrator
*/
......@@ -16,43 +26,70 @@ import org.typroject.tyboot.component.emq.EmqxListener;
@Slf4j
public class SyncESDataToTdengineMqttListener extends EmqxListener {
@Autowired
private CommonServiceImpl commonServiceImpl;
@Autowired
CommonServiceImpl commonServiceImpl;
@Override
public void processMessage(String topic, MqttMessage mqttMessage) {
log.info(topic + "收到数据同步成功,开始计算健康指数!");
byte[] payload = mqttMessage.getPayload();
String str = new String(payload);
String msg = JSON.parse(str).toString();
JSONObject jsonObject = JSONObject.parseObject(msg);
String flag = jsonObject.get("sync_flag").toString();
if ("success".equals(flag)){
//开始异步计算光伏的健康指数算法
new Thread(()->{
//调用光伏的健康指数算法
commonServiceImpl.healthWarningMinuteByPv();
}).start();
//开始异步计算风机的健康指数算法
new Thread(()->{
//调用风机的健康指数算法
commonServiceImpl.healthWarningMinuteByFan();
}).start();
}
if ("pvsuccess".equals(flag)){
//开始异步计算光伏的健康指数算法
new Thread(()->{
//调用光伏的健康指数算法
commonServiceImpl.healthWarningMinuteByPv();
}).start();
}
if ("fansuccess".equals(flag)){
//开始异步计算光伏的健康指数算法
new Thread(()->{
//调用光伏的健康指数算法
commonServiceImpl.healthWarningMinuteByFan();
}).start();
}
}
private TdengineTimeServiceImpl tdengineTimeService;
@Override
public void processMessage(String topic, MqttMessage mqttMessage) throws InterruptedException, ParseException {
log.info(topic + "收到数据同步成功,开始计算健康指数!");
byte[] payload = mqttMessage.getPayload();
String str = new String(payload);
String msg = JSON.parse(str).toString();
JSONObject jsonObject = JSONObject.parseObject(msg);
String flag = jsonObject.get("sync_flag").toString();
if ("success".equals(flag)) {
Date time = new Date();
time = DateUtil.offsetMinute(time, -DateUtil.minute(time) % 10);
String format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00");
time = DateUtil.parse(format, "yyyy-MM-dd HH:mm:00");
ExecutorService excutorService = Executors.newFixedThreadPool(4);
int taskCount = 2;
final CountDownLatch latch = new CountDownLatch(taskCount);
excutorService.submit(()->{
commonServiceImpl.healthWarningMinuteByFan();
latch.countDown();
});
excutorService.submit(()->{
commonServiceImpl.healthWarningMinuteByPv();
latch.countDown();
});
System.out.println("等待所有任务完成..");
latch.await();
System.out.println("所有任务完成");
//区域 全域最后统一生成
tdengineTimeService.insertMomentDataAll(format);
// // 开始异步计算光伏的健康指数算法
// new Thread(() -> {
// // 调用光伏的健康指数算法
// commonServiceImpl.healthWarningMinuteByPv();
// }).start();
// // 开始异步计算风机的健康指数算法
// new Thread(() -> {
// // 调用风机的健康指数算法
// commonServiceImpl.healthWarningMinuteByFan();
// }).start();
}
if ("pvsuccess".equals(flag)) {
// 开始异步计算光伏的健康指数算法
new Thread(() -> {
// 调用光伏的健康指数算法
commonServiceImpl.healthWarningMinuteByPv();
}).start();
}
if ("fansuccess".equals(flag)) {
// 开始异步计算光伏的健康指数算法
new Thread(() -> {
// 调用光伏的健康指数算法
commonServiceImpl.healthWarningMinuteByFan();
}).start();
}
}
}
......@@ -90,8 +90,34 @@ public interface IFanHealthIndexService {
*/
List<FanHealthIndex> getInfoListByGroupByQgFan(String startTime, String tableName, String analysisObjectType);
/**
* 光伏 & 风电加权平均计算 :区域
*
*
* @param startTime startTime
* @param fanTableName fanTableName
* @param pvTableName pvTableName
* @param analysisObjectType analysisObjectType
* @return {@link List< HealthIndexDTO>}
* @author yangyang
* @throws
* @date 2024/7/25 14:01
*/
List<HealthIndexDTO> getInfoListByGroupByQy(String startTime, String fanTableName, String pvTableName, String analysisObjectType);
/**
* 光伏 & 风电加权平均计算 :全域【所有 / 全国】
*
*
* @param startTime startTime
* @param fanTableName fanTableName
* @param pvTableName pvTableName
* @param analysisObjectType analysisObjectType
* @return {@link List< HealthIndexDTO>}
* @author yangyang
* @throws
* @date 2024/7/25 14:01
*/
List<HealthIndexDTO> getInfoListByGroupByQg(String startTime, String fanTableName, String pvTableName, String analysisObjectType);
FanHealthIndex toFanHealthIndex(HealthIndexDTO healthIndex);
......
......@@ -58,14 +58,14 @@ public class FanHealthIndexServiceImpl implements IFanHealthIndexService {
List<IdxBizFanWeight> idxBizFanWeights = idxBizFanWeightMapper.selectList(idxBizFanWeightQueryWrapper);
Map<String, Float> weightMap = idxBizFanWeights.stream().collect(Collectors.toMap(o -> o.getArae() + o.getStation() + o.getEquipmentName() + o.getSubarray() + o.getPointName(), IdxBizFanWeight::getValue));
// 开始计算加权平均
Map<String, List<FanHealthIndex>> fanHealthIndicesZxtMap = fanHealthIndicesZxt.stream().collect(Collectors.groupingBy(o -> o.getGatewayId() + o.getStation() + o.getAnalysisObjType() + o.getArea() + o.getSubSystem() + o.getEquipmentName() + o.getNumber() + o.getOrgCode()));
Map<String, List<FanHealthIndex>> fanHealthIndicesZxtMap = fanHealthIndicesZxt.stream().collect(Collectors.groupingBy(o -> o.getGatewayId() + o.getIndexAddress() + o.getStation() + o.getAnalysisObjType() + o.getAnalysisObjSeq() + o.getWeight() + o.getArea() + o.getSubSystem() + o.getEquipmentName() + o.getNumber() + o.getPointName() + o.getKks() + o.getOrgCode()));
List<FanHealthIndex> fanHealthIndicesZxtNews = new ArrayList<>();
fanHealthIndicesZxtMap.forEach((k, v) -> {
FanHealthIndex fanHealthIndex = new FanHealthIndex();
fanHealthIndex.setIndexAddress(v.get(0).getIndexAddress());
fanHealthIndex.setGatewayId(v.get(0).getGatewayId());
fanHealthIndex.setStation(v.get(0).getStation());
fanHealthIndex.setAnalysisObjType("测点");
fanHealthIndex.setAnalysisObjType(v.get(0).getAnalysisObjType());
fanHealthIndex.setAnalysisObjSeq(v.get(0).getAnalysisObjSeq());
fanHealthIndex.setWeight(v.get(0).getWeight());
fanHealthIndex.setArea(v.get(0).getArea());
......@@ -73,7 +73,7 @@ public class FanHealthIndexServiceImpl implements IFanHealthIndexService {
fanHealthIndex.setNumber(v.get(0).getNumber());
fanHealthIndex.setEquipmentName(v.get(0).getEquipmentName());
fanHealthIndex.setPointName(v.get(0).getPointName());
fanHealthIndex.setKks(v.get(0).getNumber());
fanHealthIndex.setKks(v.get(0).getKks());
fanHealthIndex.setOrgCode(v.get(0).getOrgCode());
// 例如 子系统 = (测点1 * 测点1权重 + 测点2 * 测点2权重 + .... 测点n权重) / (测点1权重 + 测点2权重 + .... 测点n权重)
// 但是测点是没有权重的,所以子系统无法计算加权平均
......@@ -380,7 +380,7 @@ public class FanHealthIndexServiceImpl implements IFanHealthIndexService {
weightMap.putAll(fanWeightMap);
weightMap.putAll(pvWeightMap);
// 开始计算加权平均
Map<String, List<HealthIndexDTO>> fanHealthIndicesZxtMap = healthIndexDTOS.stream().collect(Collectors.groupingBy(o -> o.getAnalysisObjType() + o.getArea() + o.getOrgCode()));
Map<String, List<HealthIndexDTO>> fanHealthIndicesZxtMap = healthIndexDTOS.stream().collect(Collectors.groupingBy(o -> o.getAnalysisObjType() + o.getArea()));
List<HealthIndexDTO> fanHealthIndicesZxtNews = new ArrayList<>();
fanHealthIndicesZxtMap.forEach((k, v) -> {
HealthIndexDTO healthIndex = new HealthIndexDTO();
......@@ -426,7 +426,7 @@ public class FanHealthIndexServiceImpl implements IFanHealthIndexService {
weightMap.putAll(pvWeightMap);
// 开始计算加权平均
Map<String, List<HealthIndexDTO>> fanHealthIndicesZxtMap = healthIndexDTOS.stream().collect(Collectors.groupingBy(o -> o.getAnalysisObjType() + o.getOrgCode()));
Map<String, List<HealthIndexDTO>> fanHealthIndicesZxtMap = healthIndexDTOS.stream().collect(Collectors.groupingBy(o -> o.getAnalysisObjType()));
List<HealthIndexDTO> fanHealthIndicesZxtNews = new ArrayList<>();
fanHealthIndicesZxtMap.forEach((k, v) -> {
HealthIndexDTO healthIndex = new HealthIndexDTO();
......@@ -475,8 +475,8 @@ public class FanHealthIndexServiceImpl implements IFanHealthIndexService {
public Double getWeight(Supplier<String> key, Map<String, Float> weightMap) {
Float weight = weightMap.get(key.get());
if (weight == null) {
log.error("计算加权平均异常【" + key.get() + "】没有配置测点权重");
throw new RuntimeException("【" + key.get() + "】没有配置测点权重");
log.error("计算加权平均异常【" + key.get() + "】未配置权重");
throw new RuntimeException("【" + key.get() + "】未配置权重");
}
return weight.doubleValue();
}
......
......@@ -162,7 +162,7 @@ public class PvHealthIndexServiceImpl implements IPvHealthIndexService {
String analysisObjectType) {
List<PvHealthIndex> pvHealthIndices = pvHealthIndexMapper.getInfoList(startTime, tableName, analysisObjectType);
QueryWrapper<IdxBizPvWeight> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("type", "4");
queryWrapper.eq("type", "3");
queryWrapper.isNotNull("value");
List<IdxBizPvWeight> idxBizFanWeights = idxBizPvWeightMapper.selectList(queryWrapper);
Map<String, Float> weightMap = idxBizFanWeights.stream().collect(Collectors.toMap(o -> o.getArae() + o.getStation() + o.getEquipmentName() + o.getSubarray(), IdxBizPvWeight::getValue));
......@@ -218,7 +218,7 @@ public class PvHealthIndexServiceImpl implements IPvHealthIndexService {
String analysisObjectType) {
List<PvHealthIndex> pvHealthIndices = pvHealthIndexMapper.getInfoList(startTime, tableName, analysisObjectType);
QueryWrapper<IdxBizPvWeight> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("type", "3");
queryWrapper.eq("type", "4");
queryWrapper.isNotNull("value");
List<IdxBizPvWeight> idxBizFanWeights = idxBizPvWeightMapper.selectList(queryWrapper);
Map<String, Float> weightMap = idxBizFanWeights.stream().collect(Collectors.toMap(o -> o.getArae() + o.getStation() + o.getEquipmentName(), IdxBizPvWeight::getValue));
......@@ -371,8 +371,8 @@ public class PvHealthIndexServiceImpl implements IPvHealthIndexService {
public Double getWeight(Supplier<String> key, Map<String, Float> weightMap) {
Float weight = weightMap.get(key.get());
if (weight == null) {
log.error("计算加权平均异常【" + key.get() + "】没有配置测点权重");
throw new RuntimeException("没有配置测点权重");
log.error("计算加权平均异常【" + key.get() + "】未配置权重");
throw new RuntimeException("未配置权重");
}
return weight.doubleValue();
}
......
......@@ -533,9 +533,12 @@
<select id="getInfoList" resultType="com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex">
select
index_address,
gateway_id ,
station,
analysis_obj_type,
analysis_obj_seq,
weight,
area,
sub_system,
equipment_name,
......@@ -543,6 +546,7 @@
anomaly,
org_code,
health_index,
kks,
point_name
from
#{tableName}
......
......@@ -296,15 +296,21 @@
<select id="getInfoList" resultType="com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex">
select
index_address,
gateway_id ,
station,
analysis_obj_type,
analysis_obj_seq,
weight,
area,
subarray,
manufacturer,
equipment_name,
anomaly,
org_code,
health_index,
device_type,
kks,
point_name
from
#{tableName}
......
package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import java.util.List;
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.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jxiop.api.entity.PersonAccount;
import com.yeejoin.amos.boot.module.jxiop.api.entity.PersonBasic;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.PersonAccountMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.PersonBasicMapper;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.util.AesUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/**
* 农户信息
*
* @author system_generator
* @date 2023-07-07
*/
@RestController
@Api(tags = "农户信息Api")
@RequestMapping(value = "/test")
public class TestController extends BaseController {
@Autowired
PersonBasicMapper personBasicMapper;
@Autowired
PersonAccountMapper personAccountMapper;
/**
* 新增农户信息
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/initpw")
@ApiOperation(httpMethod = "GET", value = "刷新基础管理信息", notes = "刷新基础管理信息")
public ResponseModel<Object> initpw() {
// 基础管理员
List<PersonAccount> list = personAccountMapper.selectList(null);
int i = 0;
for (PersonAccount unitInfo : list) {
System.out.println();
System.out.println(++i+"/"+list.size());
try {
PersonBasic personBasic =personBasicMapper.selectById(unitInfo.getPersonId());
int ph = personBasic.getPhone().length();
String npwd = "Zxnk_" + personBasic.getPhone().substring(ph - 4, ph);
String npwdm = AesUtil.encode(npwd, "qaz");
unitInfo.setPassword(npwdm);
unitInfo.setSecondaryPassword(npwdm);
FeignClientResult<AgencyUserModel> re = Privilege.agencyUserClient
.queryByUserId(unitInfo.getPuserId());
AgencyUserModel ag = re.getResult();
ag.setPassword(AesUtil.encode(npwd, "qaz"));
ag.setRePassword(AesUtil.encode(npwd, "qaz"));
Privilege.agencyUserClient.restorePassword(unitInfo.getPuserId());
ag.setOriginalPassword(AesUtil.encode("Z2%Op9.q", "qaz"));
Privilege.agencyUserClient.modifyPassword(unitInfo.getPuserId(), ag);
personAccountMapper.updateById(unitInfo);
} catch (Exception e) {
e.printStackTrace();
}
}
return new ResponseModel<>();
}
}
\ No newline at end of file
## DB properties:
spring.db1.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.db1.datasource.url=jdbc:mysql://10.20.1.157:3306/production?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
spring.db1.datasource.username=root
spring.db1.datasource.password=Yeejoin@2020
spring.db2.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.db2.datasource.url=jdbc:mysql://10.20.1.157:3306/amos_project?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
spring.db2.datasource.username=root
spring.db2.datasource.password=Yeejoin@2020
spring.db3.datasource.driver-class-name: com.mysql.cj.jdbc.Driver
spring.db3.datasource.url=jdbc:mysql://10.20.1.157:3306/amos_mcb?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull
spring.db3.datasource.username=root
spring.db3.datasource.password=Yeejoin@2020
## eureka properties:
eureka.instance.hostname=10.20.1.160
eureka.client.serviceUrl.defaultZone=http://admin:a1234560@${eureka.instance.hostname}:10001/eureka/
## redis properties:
spring.redis.database=1
spring.redis.host=10.20.1.210
spring.redis.port=6379
spring.redis.password=yeejoin@2020
spring.cache.type=GENERIC
j2cache.open-spring-cache=true
j2cache.cache-clean-mode=passive
j2cache.allow-null-values=true
j2cache.redis-client=lettuce
j2cache.l2-cache-open=true
j2cache.broadcast=net.oschina.j2cache.cache.support.redis.SpringRedisPubSubPolicy
j2cache.L1.provider_class=caffeine
j2cache.L2.provider_class=net.oschina.j2cache.cache.support.redis.SpringRedisProvider
j2cache.L2.config_section=lettuce
j2cache.sync_ttl_to_redis=true
j2cache.default_cache_null_object=false
j2cache.serialization=fst
caffeine.properties=/caffeine.properties
lettuce.mode=single
lettuce.namespace=
lettuce.storage=generic
lettuce.channel=j2cache
lettuce.scheme=redis
lettuce.hosts=${spring.redis.host}:${spring.redis.port}
lettuce.password=${spring.redis.password}
lettuce.database=${spring.redis.database}
lettuce.sentinelMasterId=
lettuce.maxTotal=100
lettuce.maxIdle=10
lettuce.minIdle=10
lettuce.timeout=10000
emqx.clean-session=true
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://10.20.1.210:2883
emqx.user-name=super
emqx.password=a123456
emqx.max-inflight=1000
spring.influx.url=http://39.98.246.31:8086
spring.influx.password=Yeejoin@2020
spring.influx.user=root
spring.influx.database=iot_platform
spring.influx.retention_policy=default
spring.influx.retention_policy_time=30d
spring.influx.actions=10000
spring.influx.bufferLimit=20000
knife4j.production=false
knife4j.enable=true
knife4j.basic.enable=true
knife4j.basic.username=admin
knife4j.basic.password=a1234560
management.security.enabled=true
spring.security.user.name=admin
spring.security.user.password=a1234560
fire-rescue=123
mybatis-plus.global-config.db-config.update-strategy=ignored
# user-amos setting : This value is the secretkey for person manage moudle accout password encryption.please don't change it!!!
amos.secret.key=qaz
# if your service can't be access ,you can use this setting , you need change ip as your.
#eureka.instance.prefer-ip-address=true
#eureka.instance.ip-address=172.16.3.122
spring.activemq.broker-url=tcp://10.20.1.210:61616
spring.activemq.user=admin
spring.activemq.password=admin
spring.jms.pub-sub-domain=false
myqueue=amos.privilege.v1.JXIOP.AQSC_FDGL.userBusiness
modifypasswordqueue= amos.privilege.v1.JXIOP.AMOS_ADMIN.modifyPassword
yth.qg.id=1
emqx.client-user-name=admin
emqx.client-password=public
logic=
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
<property name="LOG_HOME" value="log" />
<property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %-50.50logger{50} - %msg [%file:%line] %n" />
<!-- 按照每天生成日志文件 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/ccs.log.%d{yyyy-MM-dd}.log</FileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>7</MaxHistory>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<pattern>${LOG_PATTERN}</pattern>
</encoder>
<!--日志文件最大的大小-->
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>30mb</MaxFileSize>
</triggeringPolicy>
</appender>
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!--myibatis log configure-->
<logger name="com.apache.ibatis" level="DEBUG"/>
<logger name="java.sql.Connection" level="DEBUG"/>
<logger name="java.sql.Statement" level="DEBUG"/>
<logger name="java.sql.PreparedStatement" level="DEBUG"/>
<logger name="com.baomidou.mybatisplus" level="DEBUG"/>
<logger name="org.springframework" level="DEBUG"/>
<logger name="org.typroject" level="DEBUG"/>
<logger name="com.yeejoin" level="DEBUG"/>
<!-- 日志输出级别 -->
<root level="INFO">
<appender-ref ref="FILE" />
<appender-ref ref="STDOUT" />
</root>
</configuration>
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