Commit 94a3b577 authored by 朱晨阳's avatar 朱晨阳

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

parents 83dbcaf6 146dcbe1
......@@ -4,7 +4,10 @@ import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.yeejoin.amos.boot.biz.config.BitTypeHandler;
import lombok.Data;
import org.apache.ibatis.type.BigDecimalTypeHandler;
import org.apache.ibatis.type.BigIntegerTypeHandler;
import java.io.Serializable;
import java.util.Date;
......@@ -34,7 +37,7 @@ public class BaseEntity implements Serializable{
/**
* 是否删除
*/
@TableField(value = "is_delete")
@TableField(value = "is_delete",typeHandler = BitTypeHandler.class)
public Boolean isDelete=false;
}
package com.yeejoin.amos.boot.biz.config;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
@MappedJdbcTypes(JdbcType.BIT)
public class BitTypeHandler extends BaseTypeHandler<Boolean> {
@Override
public void setNonNullParameter(PreparedStatement ps, int i, Boolean parameter, JdbcType jdbcType)
throws SQLException {
//原生的boolean会再sql上加上引号比如'0'或者'1',人大金仓不支持,支持不带引号的
//ps.setBoolean(i, parameter);
ps.setInt(i, parameter?1:0);
}
@Override
public Boolean getNullableResult(ResultSet rs, String columnName) throws SQLException {
return rs.getBoolean(columnName);
}
@Override
public Boolean getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
return rs.getBoolean(columnIndex);
}
@Override
public Boolean getNullableResult(java.sql.CallableStatement cs, int columnIndex) throws SQLException {
return cs.getBoolean(columnIndex);
}
}
package com.yeejoin.amos.api.householdapi.constant;
import java.util.HashMap;
/**
* 碳银常量类
* <p>
* ProjectName: amos-boot-zx-biz
* PackageName: com.yeejoin.amos.api.householdapi.constant
*
* @author yangyang
* @version v1.0
* @date 2024/7/15 10:22
*/
public class TanYinConstant {
public static String ACCESS_TOKEN_KEY = "TanYin_Token";
/**
* 获取电站信息
*/
public static String stationListUrl = "/v1/yx/query/station/info";
/**
* 获取客户信息
*/
public static String customerInfoUrl = "/v1/yx/query/customer/info";
/**
* 电站逆变器信息接口
*/
public static String inverterListUrl = "/v1/station/getTodayDetail";
/**
* 获取 Access_Token
*/
public static String getAccessTokenUrl = "/v1/auth/getAccessToken";
/**
* 刷新 Access_Token
*/
public static String refreshAccessTokenUrl = "/v1/auth/refreshAccessToken";
public static final HashMap<String, String> stationStatus = new HashMap<String, String>() {
{
put("0", "在线");
put("1", "离线");
put("2", "异常");
}
};
public static final HashMap<String, String> intoNetWorkStatus = new HashMap<String, String>() {
{
put("0", "普通并网");
}
};
}
......@@ -73,7 +73,8 @@ public class HouseholdTestController {
@Autowired
private TanYinDataAcquisitionService tanYinDataAcquisitionService;
/**
* 新增户用光伏-厂商API haders
......@@ -257,8 +258,25 @@ public class HouseholdTestController {
/* ---------------- 碳银接口 Test -------------- */
@TycloudOperation(ApiLevel = UserType.PUBLIC, needAuth = false)
@PostMapping(value = "/tanyin/station")
@ApiOperation(httpMethod = "POST", value = "电站基本信息接口", notes = "电站基本信息接口")
public void tanyinStation() {
tanYinDataAcquisitionService.stationList();
}
@TycloudOperation(ApiLevel = UserType.PUBLIC, needAuth = false)
@PostMapping(value = "/tanyin/inverter")
@ApiOperation(httpMethod = "POST", value = "电站逆变器信息接口", notes = "电站逆变器信息接口")
public void tanyinInverter() {
tanYinDataAcquisitionService.inverterList();
}
@TycloudOperation(ApiLevel = UserType.PUBLIC, needAuth = false)
@PostMapping(value = "/tanyin/customer")
@ApiOperation(httpMethod = "POST", value = "客户信息查询接口", notes = "客户信息查询接口")
public void tanyinCustomer() {
tanYinDataAcquisitionService.customerInfoList();
}
}
package com.yeejoin.amos.api.householdapi.exception;
import org.apache.commons.lang3.StringUtils;
import org.typroject.tyboot.core.foundation.exception.BaseException;
/**
* 自定义异常
*
* @author yangyang
* @version v1.0
* @date 2023/9/19 12:37
*/
public class BusinessException extends BaseException {
private String code;
public BusinessException(String message) {
super(message, BusinessException.class.getSimpleName(), "错误的请求.");
this.code = "-1";
this.httpStatus = 500;
}
public BusinessException(String errorCode, String message) {
super(message, BusinessException.class.getSimpleName(), message);
if (StringUtils.isBlank(errorCode)) {
this.httpStatus = 500;
this.code = errorCode;
} else {
this.httpStatus = Integer.parseInt(errorCode);
this.code = errorCode;
}
}
public boolean isTokenError() {
return "401".equals(this.code);
}
}
package com.yeejoin.amos.api.householdapi.face.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 碳银Access_Token类
* <p>
* ProjectName: amos-boot-zx-biz
* PackageName: com.yeejoin.amos.api.householdapi.face.dto
*
* @author yangyang
* @version v1.0
* @date 2024/7/16 14:08
*/
@NoArgsConstructor
@Data
public class TanYinAccessTokenDTO {
@ApiModelProperty ("业务请求 token")
@JsonProperty ("access_token")
private String accessToken;
@ApiModelProperty ("有效时间")
@JsonProperty ("expires_in")
private Integer accessTokenExpiresIn;
}
package com.yeejoin.amos.api.householdapi.face.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 碳银接口返回类
* <p>
* ProjectName: amos-boot-zx-biz
* PackageName: com.yeejoin.amos.api.householdapi.face.dto
*
* @author yangyang
* @version v1.0
* @date 2024/7/15 14:03
*/
@NoArgsConstructor
@Data
public class TanYinBaseResultDTO<T> {
@JsonProperty ("code")
private Integer code;
@JsonProperty ("data")
private T data;
@JsonProperty ("msg")
private String msg;
@JsonProperty ("deskey")
private Object deskey;
@JsonProperty ("success")
private Boolean success;
@JsonProperty ("fail")
private Boolean fail;
}
package com.yeejoin.amos.api.householdapi.face.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* 碳银分页请求类
* <p>
* ProjectName: amos-boot-zx-biz
* PackageName: com.yeejoin.amos.api.householdapi.face.dto
*
* @author yangyang
* @version v1.0
* @date 2024/7/16 14:09
*/
@NoArgsConstructor
@Data
public class TanYinPageResultDTO<T> {
@JsonProperty ("pageNo")
private Integer pageNo;
@JsonProperty ("pageSize")
private Integer pageSize;
@JsonProperty ("totalPage")
private Integer totalPage;
@JsonProperty ("total")
private Integer total;
@JsonProperty ("list")
private List<T> list;
@JsonProperty ("start")
private Integer start;
}
......@@ -8,8 +8,12 @@ import java.io.Serializable;
@Data
@TableName(value = "td_hygf_station_power_day",autoResultMap = true)
public class HYGFJPDayPower implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private Long createdTime;
private String tationId;
private String thirdStationId;
private String hour;
private String yearMonthDay;
private Double power;
......
package com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.tdeingine;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 客户信息
* <p>
* ProjectName: amos-boot-zx-biz
* PackageName: com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.tdeingine
*
* @author yangyang
* @version v1.0
* @date 2024/7/15 16:11
*/
@NoArgsConstructor
@Data
@TableName (value = "tanyin_customer_info", autoResultMap = true)
public class TanYinCustomerInfo {
@ApiModelProperty ("客户身份证号码")
@TableField ("customer_id_no")
private String customerIdNo;
@ApiModelProperty ("客户姓名")
@TableField ("customer_name")
private String customerName;
@ApiModelProperty ("客户手机号")
@TableField ("customer_phone")
private String customerPhone;
@ApiModelProperty ("客户并网通过时间 毫秒时间戳")
@TableField ("electric_contract_pass")
private Long electricContractPass;
@ApiModelProperty ("项目编号")
@TableField ("project_no")
private String projectNo;
@TableField("create_time")
private Long createTime;
}
package com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.tdeingine;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 逆变器实时数据
* <p>
* ProjectName: amos-boot-zx-biz
* PackageName: com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.tdeingine
*
* @author yangyang
* @version v1.0
* @date 2024/7/15 16:10
*/
@NoArgsConstructor
@Data
@TableName (value = "tanyin_inveter_info", autoResultMap = true)
public class TanYinInveterInfo {
@TableField ("project_no")
private String projectNo;
@TableField ("device_name")
private String deviceName;
@TableField ("sn")
private String sn;
@TableField ("supplier")
private Integer supplier;
@ApiModelProperty ("更新时间")
@TableField ("gmt_create")
private String gmtCreate;
@ApiModelProperty ("ID")
@TableField ("id_string")
private String idString;
@ApiModelProperty ("功率")
@TableField ("watt")
private String watt;
@ApiModelProperty ("日发电量")
@TableField ("daily_energy")
private String dailyEnergy;
@ApiModelProperty ("总发电量")
@TableField ("total_energy")
private String totalEnergy;
@ApiModelProperty ("逆变器在线状态:在线;1、离线;2、异常")
@TableField ("status")
private String status;
@ApiModelProperty ("故障原因")
@TableField ("error_detail")
private String errorDetail;
@ApiModelProperty ("故障码")
@TableField ("error_code")
private String errorCode;
@ApiModelProperty ("输入电压 1")
@TableField ("vol0")
private String vol0;
@ApiModelProperty ("输入电压 2")
@TableField ("vol1")
private String vol1;
@ApiModelProperty ("输入电压 3")
@TableField ("vol2")
private String vol2;
@ApiModelProperty ("输入电压 4")
@TableField ("vol3")
private String vol3;
@ApiModelProperty ("输入电压 5")
@TableField ("vol4")
private String vol4;
@ApiModelProperty ("输出电压 1")
@TableField ("vol5")
private String vol5;
@ApiModelProperty ("输出电压 2")
@TableField ("vol6")
private String vol6;
@ApiModelProperty ("输出电压 3")
@TableField ("vol7")
private String vol7;
@ApiModelProperty ("输出电压 3")
@TableField ("vol8")
private String vol8;
@ApiModelProperty ("输出电压 3")
@TableField ("vol9")
private String vol9;
@ApiModelProperty ("输入电压 6")
@TableField ("vol10")
private String vol10;
@ApiModelProperty ("输出电压 3")
@TableField ("vol11")
private String vol11;
@ApiModelProperty ("输出电压 3")
@TableField ("vol12")
private String vol12;
@ApiModelProperty ("输出电压 3")
@TableField ("vol13")
private String vol13;
@ApiModelProperty ("输出电压 3")
@TableField ("vol14")
private String vol14;
@ApiModelProperty ("输出电压 3")
@TableField ("vol15")
private String vol15;
@ApiModelProperty ("输入电流 1")
@TableField ("amp0")
private String amp0;
@ApiModelProperty ("输入电流 2")
@TableField ("amp1")
private String amp1;
@ApiModelProperty ("输入电流 3")
@TableField ("amp2")
private String amp2;
@ApiModelProperty ("输入电流 4")
@TableField ("amp3")
private String amp3;
@ApiModelProperty ("输入电流 5")
@TableField ("amp4")
private String amp4;
@ApiModelProperty ("输入电流 6")
@TableField ("amp5")
private String amp5;
@ApiModelProperty ("输入电流 7")
@TableField ("amp6")
private String amp6;
@ApiModelProperty ("输入电流 8")
@TableField ("amp7")
private String amp7;
@ApiModelProperty ("输入电流 9")
@TableField ("amp8")
private String amp8;
@ApiModelProperty ("输入电流 10")
@TableField ("amp9")
private String amp9;
@ApiModelProperty ("输入电流 11")
@TableField ("amp10")
private String amp10;
@ApiModelProperty ("输入电流 12")
@TableField ("amp11")
private String amp11;
@ApiModelProperty ("输入电流 13")
@TableField ("amp12")
private String amp12;
@ApiModelProperty ("输入电流 14")
@TableField ("amp13")
private String amp13;
@ApiModelProperty ("输入电流 15")
@TableField ("amp14")
private String amp14;
@ApiModelProperty ("输入电流 16")
@TableField ("amp15")
private String amp15;
@ApiModelProperty ("温度(单位:摄氏度)")
@TableField ("temperature")
private String temperature;
@TableField ("create_time")
private Long createTime;
}
package com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.tdeingine;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* 电站基本信息
* <p>
* ProjectName: amos-boot-zx-biz
* PackageName: com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.tdeingine
*
* @author yangyang
* @version v1.0
* @date 2024/7/15 16:05
*/
@NoArgsConstructor
@Data
@TableName (value = "tanyin_station_info", autoResultMap = true)
public class TanYinStationInfo {
@ApiModelProperty ("项目编号")
@TableField ("project_no")
private String projectNo;
@ApiModelProperty ("姓名")
@TableField ("customer_name")
private String customerName;
@ApiModelProperty ("手机号")
@TableField ("customer_phone")
private String customerPhone;
@ApiModelProperty ("身份证")
@TableField ("customer_id_no")
private String customerIdNo;
@ApiModelProperty ("省")
@TableField ("province")
private String province;
@ApiModelProperty ("市")
@TableField ("city")
private String city;
@ApiModelProperty ("区")
@TableField ("area")
private String area;
@ApiModelProperty ("镇 + 详细地址")
@TableField ("complete_address")
private String completeAddress;
@TableField (value = "inverterList",exist = false)
private List<InverterListDTO> inverterList;
@ApiModelProperty ("装机容量")
@TableField ("capacity_size")
private String capacitySize;
@ApiModelProperty ("累计总发电量")
@TableField ("total_power")
private String totalPower;
@ApiModelProperty ("当年发电量")
@TableField ("year_power")
private String yearPower;
@ApiModelProperty ("当月发电量")
@TableField ("month_power")
private String monthPower;
@ApiModelProperty ("当日发电量")
@TableField ("day_power")
private String dayPower;
@ApiModelProperty ("纬度")
@TableField ("latitude")
private String latitude;
@ApiModelProperty ("经度")
@TableField ("longitude")
private String longitude;
@TableField ("create_time")
private Long createTime;
@NoArgsConstructor
@Data
public static class InverterListDTO {
private String deviceName;
private Integer supplier;
private String sn;
}
}
package com.yeejoin.amos.api.householdapi.face.orm.mapper.tdengine;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.tdeingine.TanYinCustomerInfo;
import org.apache.ibatis.annotations.Select;
import java.util.List;
public interface TanYinCustomerInfoMapper extends BaseMapper<TanYinCustomerInfo> {
@Select("select project_no from tanyin_customer_info")
List<String> listProjectNo();
}
package com.yeejoin.amos.api.householdapi.face.orm.mapper.tdengine;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.tdeingine.TanYinInveterInfo;
public interface TanYinInveterInfoMapper extends BaseMapper<TanYinInveterInfo> {
}
package com.yeejoin.amos.api.householdapi.face.orm.mapper.tdengine;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.tdeingine.TanYinStationInfo;
public interface TanYinStationInfoMapper extends BaseMapper<TanYinStationInfo> {
}
package com.yeejoin.amos.api.householdapi.face.service;
/**
* <p>
* ProjectName: amos-boot-zx-biz
* PackageName: com.yeejoin.amos.api.householdapi.face.service
*
* @author yangyang
* @version v1.0
* @date 2024/7/15 10:05
*/
public interface TanYinDataAcquisitionService {
/**
* 通过并网时间段查询对应范围内的项目信息
*
* @param
* @return {@link }
* @throws
* @author yangyang
* @date 2024/7/15 16:55
*/
void customerInfoList();
/**
* 电站基本信息
*
* @param
* @return {@link }
* @throws
* @author yangyang
* @date 2024/7/15 16:55
*/
void stationList();
/**
* 电站逆变器信息
*
* @param
* @return {@link }
* @throws
* @author yangyang
* @date 2024/7/15 16:55
*/
void inverterList();
}
......@@ -44,7 +44,7 @@ public class HYGFJPDayPowerImpl implements AscriptionService {
if(hygfjpDayPower!=null&&!hygfjpDayPower.isEmpty()){
for (HYGFJPDayPower dayPower : hygfjpDayPower) {
JpStation jpStation = jpStationMapper.selectOne(new QueryWrapper<JpStation>().
eq("third_station_id", dayPower.getTationId()));
eq("third_station_id", dayPower.getThirdStationId()));
if(jpStation!=null) {
dayPower.setAmosCompanyCode(jpStation.getAmosCompanyCode());
dayPower.setRegionalCompaniesCode(jpStation.getRegionalCompaniesCode());
......
......@@ -260,11 +260,11 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
hygfjpStationPowerHistoryMapper.insert(hygfjpStationPowerHistory);
HYGFJPDayPower hygfjpDayPower = hygfjpDayPowerMapper.selectOne(new QueryWrapper<HYGFJPDayPower>()
.eq("tation_id", stationIds.get(i)).eq("year_month_day", today).eq("hour", hour));
.eq("third_station_id", stationIds.get(i)).eq("year_month_day", today).eq("hour", hour));
if (ObjectUtils.isEmpty(hygfjpDayPower)) {
hygfjpDayPower = new HYGFJPDayPower();
}
hygfjpDayPower.setTationId(stationIds.get(i));
hygfjpDayPower.setThirdStationId(stationIds.get(i));
hygfjpDayPower.setHour(hour);
hygfjpDayPower.setYearMonthDay(today);
hygfjpDayPower.setPower(golangStationDetail.getPower());
......
......@@ -205,11 +205,11 @@ public class GoodWeDataAcquisitionServiceImpl implements GoodWeDataAcquisitionSe
hygfjpStationPowerHistoryMapper.insert(hygfjpStationPowerHistory);
HYGFJPDayPower hygfjpDayPower = hygfjpDayPowerMapper.selectOne(new QueryWrapper<HYGFJPDayPower>()
.eq("tation_id", jpStation.getThirdStationId()).eq("year_month_day", today).eq("hour", hour));
.eq("third_station_id", jpStation.getThirdStationId()).eq("year_month_day", today).eq("hour", hour));
if (org.springframework.util.ObjectUtils.isEmpty(hygfjpDayPower)) {
hygfjpDayPower = new HYGFJPDayPower();
}
hygfjpDayPower.setTationId(goodWeStationList.getPowerstation_id());
hygfjpDayPower.setThirdStationId(goodWeStationList.getPowerstation_id());
hygfjpDayPower.setHour(hour);
hygfjpDayPower.setYearMonthDay(today);
hygfjpDayPower.setPower(jpStation.getRealTimePower());
......
......@@ -366,14 +366,14 @@ public class ImasterDataServiceImpl implements ImasterDataService {
hygfjpStationPowerHistoryMapper.insert(hygfjpStationPowerHistory);
HYGFJPDayPower hygfjpDayPower = hygfjpDayPowerMapper.selectOne(
new QueryWrapper<HYGFJPDayPower>().
eq("tation_id", imasterStationList.getPlantCode()).
eq("third_station_id", imasterStationList.getPlantCode()).
eq("year_month_day", today).
eq("hour", hour)
);
if (ObjectUtils.isEmpty(hygfjpDayPower)) {
hygfjpDayPower = new HYGFJPDayPower();
}
hygfjpDayPower.setTationId(imasterStationList.getPlantCode());
hygfjpDayPower.setThirdStationId(imasterStationList.getPlantCode());
hygfjpDayPower.setHour(hour);
hygfjpDayPower.setYearMonthDay(today);
hygfjpDayPower.setPower(active_power);
......
......@@ -286,12 +286,12 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
hygfjpStationPowerHistoryMapper.insert(hygfjpStationPowerHistory);
HYGFJPDayPower hygfjpDayPower = hygfjpDayPowerMapper
.selectOne(new QueryWrapper<HYGFJPDayPower>().eq("tation_id", ksolarStation.getStationId())
.selectOne(new QueryWrapper<HYGFJPDayPower>().eq("third_station_id", ksolarStation.getStationId())
.eq("year_month_day", today).eq("hour", hour));
if (ObjectUtils.isEmpty(hygfjpDayPower)) {
hygfjpDayPower = new HYGFJPDayPower();
}
hygfjpDayPower.setTationId(ksolarStation.getStationId());
hygfjpDayPower.setThirdStationId(ksolarStation.getStationId());
hygfjpDayPower.setHour(hour);
hygfjpDayPower.setYearMonthDay(today);
hygfjpDayPower.setPower(ksolarStation.getPowerInter());
......
......@@ -442,12 +442,12 @@ public class SofarDataAcquisitionServiceImpl implements SofarDataAcquisitionServ
String today = DateUtil.today();
String hour = new Date().getHours() + ":00";
HYGFJPDayPower hygfjpDayPower = hygfjpDayPowerMapper.selectOne(
new QueryWrapper<HYGFJPDayPower>().eq("tation_id", sunlightDto.getId().toString())
new QueryWrapper<HYGFJPDayPower>().eq("third_station_id", sunlightDto.getId().toString())
.eq("year_month_day", today).eq("hour", hour));
if (ObjectUtils.isEmpty(hygfjpDayPower)) {
hygfjpDayPower = new HYGFJPDayPower();
}
hygfjpDayPower.setTationId(sunlightDto.getId().toString());
hygfjpDayPower.setThirdStationId(sunlightDto.getId().toString());
hygfjpDayPower.setHour(hour);
hygfjpDayPower.setYearMonthDay(today);
hygfjpDayPower.setPower(jpStation.getRealTimePower());
......
......@@ -347,13 +347,13 @@ public class SunlightServiceImpl implements SunlightService {
String today = DateUtil.today();
String hour = new Date().getHours() + ":00";
HYGFJPDayPower hygfjpDayPower = hygfjpDayPowerMapper
.selectOne(new QueryWrapper<HYGFJPDayPower>().eq("tation_id", sunlightDto.getPs_id().toString())
HYGFJPDayPower hygfjpDayPower = hygfjpDayPowerMapper.selectOne(
new QueryWrapper<HYGFJPDayPower>().eq("third_station_id", sunlightDto.getPs_id().toString())
.eq("year_month_day", today).eq("hour", hour));
if (ObjectUtils.isEmpty(hygfjpDayPower)) {
hygfjpDayPower = new HYGFJPDayPower();
}
hygfjpDayPower.setTationId(sunlightDto.getPs_id().toString());
hygfjpDayPower.setThirdStationId(sunlightDto.getPs_id().toString());
hygfjpDayPower.setHour(hour);
hygfjpDayPower.setYearMonthDay(today);
hygfjpDayPower.setPower(jpStation.getRealTimePower());
......@@ -417,9 +417,13 @@ public class SunlightServiceImpl implements SunlightService {
jpStationMapper.insert(jpStation);
}
if (listd != null) {
this.setJpInverte(listd, jpStation, listdtx);
}
if (listd != null) {
this.collectorDetail(listd, jpStation);
}
// 电站报表
// 户用场站日发电量
......@@ -1059,11 +1063,13 @@ public class SunlightServiceImpl implements SunlightService {
try {
TimeUnit.MINUTES.sleep(1);
hygfjpInverterWarn.setCreatedTime(System.currentTimeMillis());
hygfjpInverterWarnMapper.insert(hygfjpInverterWarn);
} catch (Exception e) {
e.printStackTrace();
}
hygfjpInverterWarnMapper.insert(hygfjpInverterWarn);
}
}
}
}
......
......@@ -9,7 +9,8 @@ public enum PVProducerInfoEnum {
JLY("锦浪云","JLY"),
KSOLAR("科士达","KSD"),
YG("阳光","YG"),
HUAWEI("华为","HW");
HUAWEI("华为","HW"),
TANYIN("碳银","TY");
private String name;
......
......@@ -73,3 +73,9 @@ dataRequstScheduled.Sunlight=0 0/50 * * * *
dataRequstScheduled.GoodWe=0 0/3 * * * *
dataRequstScheduled.Sofar=0 0/50 * * * *
# 碳银
tanYin.api.apiUrl=https://userauth.tanwin.cn
tanYin.api.clientSecret=rKrWVa2sXsSZeNAOW43v
tanYin.api.clientKey=yx10001
dataRequestScheduled.tanYin=0 0/10 * * * *
\ No newline at end of file
package com.yeejoin.amos.boot.module.hygf.api.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
*
*
* @author system_generator
* @date 2024-07-15
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="HygfContractCallRecordDto", description="")
public class HygfContractCallRecordDto extends BaseDto {
private static final long serialVersionUID = 1L;
private String contractId;
private String data;
private String status;
}
......@@ -17,7 +17,7 @@ import java.time.format.DateTimeFormatter;
*/
@Data
@Accessors(chain = true)
@TableName("td_hygf_all_power")
@TableName("td_hygf_station_power_all")
public class AllPower {
private static final long serialVersionUID = 1L;
......@@ -26,7 +26,7 @@ public class AllPower {
/**
* 第三方电站id
*/
@TableField("tation_id")
@TableField("third_station_id")
private String thirdStationId;
/**
......
......@@ -13,7 +13,7 @@ import org.springframework.data.annotation.Id;
*/
@Data
@Accessors(chain = true)
@TableName("td_hygf_station_day_generate")
@TableName("td_hygf_station_generate_month")
public class DayGenerate {
@Id
private Long createdTime;
......
......@@ -14,7 +14,7 @@ import lombok.experimental.Accessors;
*/
@Data
@Accessors(chain = true)
@TableName("td_hygf_day_power")
@TableName("td_hygf_station_power_day")
public class DayPower {
private static final long serialVersionUID = 1L;
......@@ -24,7 +24,7 @@ public class DayPower {
/**
* 第三方电站id
*/
@TableField("tation_id")
@TableField("third_station_id")
private String thirdStationId;
/**
......
package com.yeejoin.amos.boot.module.hygf.api.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
/**
*
*
* @author system_generator
* @date 2024-07-15
*/
@Data
@EqualsAndHashCode()
@Accessors(chain = true)
@TableName("hygf_contract_call_record")
public class HygfContractCallRecord {
private static final long serialVersionUID = 1L;
/**
*
*/
@TableField("contract_id")
private String contractId;
/**
*
*/
@TableField("data")
private String data;
/**
*
*/
@TableField("status")
private String status;
@TableField("rec_date")
private Date recDate;
}
......@@ -13,7 +13,7 @@ import org.springframework.data.annotation.Id;
*/
@Data
@Accessors(chain = true)
@TableName("td_hygf_station_month_generate")
@TableName("td_hygf_station_generate_year")
public class MonthGenerate {
@Id
private Long createdTime;
......
......@@ -17,7 +17,7 @@ import java.time.format.DateTimeFormatter;
*/
@Data
@Accessors(chain = true)
@TableName("td_hygf_month_power")
@TableName("td_hygf_station_power_month")
public class MonthPower {
private static final long serialVersionUID = 1L;
......@@ -32,7 +32,7 @@ public class MonthPower {
/**
* 第三方电站id
*/
@TableField("tation_id")
@TableField("third_station_id")
private String thirdStationId;
/**
......
......@@ -13,7 +13,7 @@ import org.springframework.data.annotation.Id;
*/
@Data
@Accessors(chain = true)
@TableName("td_hygf_station_year_generate")
@TableName("td_hygf_station_generate_all")
public class YearGenerate {
@Id
private Long createdTime;
......
......@@ -17,7 +17,7 @@ import java.time.format.DateTimeFormatter;
*/
@Data
@Accessors(chain = true)
@TableName("td_hygf_year_power")
@TableName("td_hygf_station_power_year")
public class YearPower {
private static final long serialVersionUID = 1L;
......@@ -26,7 +26,7 @@ public class YearPower {
/**
* 第三方电站id
*/
@TableField("tation_id")
@TableField("third_station_id")
private String thirdStationId;
/**
......
package com.yeejoin.amos.boot.module.hygf.api.mapper;
import com.yeejoin.amos.boot.module.hygf.api.entity.HygfContractCallRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* Mapper 接口
*
* @author system_generator
* @date 2024-07-15
*/
public interface HygfContractCallRecordMapper extends BaseMapper<HygfContractCallRecord> {
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.hygf.api.mapper.HygfContractCallRecordMapper">
</mapper>
......@@ -31,7 +31,7 @@ import java.util.List;
* @date 2024-01-16
*/
@RestController
@Api(tags = "Api")
@Api(tags = "并网Api")
@RequestMapping(value = "/basic-grid-acceptance")
public class BasicGridAcceptanceController extends BaseController {
......
......@@ -28,7 +28,7 @@ import java.util.List;
* @date 2023-08-22
*/
@RestController
@Api(tags = "Api")
@Api(tags = "合同模板Api")
@RequestMapping(value = "/contract-template")
public class ContractTemplateController extends BaseController {
......
......@@ -33,7 +33,7 @@ import org.typroject.tyboot.core.foundation.enumeration.UserType;
* @date 2024-04-01
*/
@RestController
@Api(tags = "Api")
@Api(tags = "投融资Api")
@RequestMapping(value = "/financing-info")
public class FinancingInfoController extends BaseController {
......
......@@ -46,7 +46,7 @@ import java.util.stream.Collectors;
* @date 2023-08-21
*/
@RestController
@Api(tags = "Api")
@Api(tags = "农户合同Api")
@RequestMapping(value = "/household-contract")
@Slf4j
public class HouseholdContractController extends BaseController {
......
......@@ -24,7 +24,7 @@ import org.typroject.tyboot.core.foundation.enumeration.UserType;
* @date 2024-06-18
*/
@RestController
@Api(tags = "投融审核表Api")
@Api(tags = "发货管理审核表Api")
@RequestMapping(value = "/hygf-preparation-money-auditing")
public class HygfPreparationMoneyAuditingController extends BaseController {
......
......@@ -24,7 +24,7 @@ import org.typroject.tyboot.core.foundation.enumeration.UserType;
* @date 2024-07-02
*/
@RestController
@Api(tags = "Api")
@Api(tags = "发货管理 补货单Api")
@RequestMapping(value = "/hygf-replenishment")
public class HygfReplenishmentController extends BaseController {
......
......@@ -27,7 +27,7 @@ import java.util.Map;
* @date 2023-07-15
*/
@RestController
@Api(tags = "Api")
@Api(tags = "电站管理Api")
@RequestMapping(value = "/power-station")
public class PowerStationController extends BaseController {
......
......@@ -88,6 +88,8 @@ public class QiyuesuoController extends BaseController {
ContractFillMapper contractFillMapper;
@Autowired
PeasantHouseholdServiceImpl peasantHouseholdServiceImpl;
@Autowired
HygfContractCallRecordMapper hygfContractCallRecordMapper;
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "POST", value = "个人token", notes = "个人token")
......@@ -168,6 +170,16 @@ public class QiyuesuoController extends BaseController {
String data = this.aesDerypt(content, secretKey);
System.out.println("契约锁回调接口解析数据" + data);
CallbackDto CallbackDto = JSON.parseObject(data, CallbackDto.class);
HygfContractCallRecord hygfContractCallRecord = new HygfContractCallRecord();
try {
hygfContractCallRecord.setContractId(CallbackDto.getContractId());
hygfContractCallRecord.setRecDate(new Date());
hygfContractCallRecord.setData(JSON.toJSONString(CallbackDto));
hygfContractCallRecordMapper.insert(hygfContractCallRecord);
}catch (Exception e){
log.info("合同记录表保存失败,合同id"+CallbackDto.getContractId());
}
if ("PERSONAL".equals(CallbackDto.getCallbackType())) {
......@@ -228,7 +240,12 @@ public class QiyuesuoController extends BaseController {
}
}
try {
hygfContractCallRecord.setStatus("success");
hygfContractCallRecordMapper.updateById(hygfContractCallRecord);
}catch (Exception e){
log.info("状态更新失败,合同id:"+CallbackDto.getContractId());
}
} catch (Exception e) {
e.printStackTrace();
throw new BadRequest("契约锁回调失败");
......
......@@ -36,7 +36,7 @@ import java.util.List;
* @date 2023-08-29
*/
@RestController
@Api(tags = "Api")
@Api(tags = "区域公司Api")
@RequestMapping(value = "/regional-companies")
public class RegionalCompaniesController extends BaseController {
......
......@@ -23,7 +23,7 @@ import java.util.List;
* @date 2023-08-23
*/
@RestController
@Api(tags = "Api")
@Api(tags = "盖章信息Api")
@RequestMapping(value = "/seal-dictionary")
public class SealDictionaryController extends BaseController {
......
......@@ -162,7 +162,6 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto,UnitInfo,UnitIn
}
@Override
@Transactional
public UnitRegisterDto registerUnit(UnitRegisterDto model) {
UnitInfoDto regUnitInfo = model.getUnitInfoDto();
......
......@@ -227,3 +227,23 @@ cheduled.crons=0 10 0 * * ?
dealer.appcode.manage=studio_normalapp_5155413,studio_normalapp_5133538
dealer.appcode.role=1767363928842571777
dealer.amosDealerId=1767820997374775298
#Seata Config
seata.tx-service-group=hygf-seata
seata.service.grouplist.hygf-seata=47.92.234.253:8091
# Seata 配置
seata.enabled=true
seata.enable-auto-data-source-proxy=false
seata.datasource.autoproxy.datasource-proxy-mode=original
seata.datasource.autoproxy.enabled=true
seata.datasource.autoproxy.data-source-names=mysql
## 47环境 排除es报错引进无用配置 业务未实际使用es
spring.elasticsearch.rest.uris=http://47.92.234.253:9200
spring.elasticsearch.rest.connection-timeout=30000
spring.elasticsearch.rest.username=elastic
spring.elasticsearch.rest.password=123456
spring.elasticsearch.rest.read-timeout=30000
\ No newline at end of file
......@@ -15,7 +15,7 @@ import java.util.Map;
* @createDate: 2023/11/9
*/
public interface UserEmpowerMapper extends BaseMapper<StdUserEmpower> {
@Select("select company_name as companyName , level_ from privilege_company where org_code = #{orgCode}")
@Select("select company_name as companyName , `level` from privilege_company where org_code = #{orgCode}")
CompanyModel getCompanyInfoByOrgCode(String orgCode);
}
......@@ -48,8 +48,8 @@ public class AnalyseController extends BaseController {
@Autowired
CommonServiceImpl commonServiceImpl;
@Autowired
IdxBizFanHealthIndexMapper idxBizFanHealthIndexMapper;
// @Autowired
// IdxBizFanHealthIndexMapper idxBizFanHealthIndexMapper;
@Autowired
IAlarmInfoDetailService iAlarmInfoDetailService;
......@@ -185,7 +185,7 @@ public class AnalyseController extends BaseController {
@ApiOperation(httpMethod = "GET", value = "获取influxdb数据", notes = "获取influxdb数据")
@GetMapping(value = "/getInfluxdbDataByConditon")
public ResponseModel<Map<String, Object>> getInfluxdbDataByConditon(@RequestParam String stationType,
@RequestParam String pointId, @RequestParam(required = false) String startTime,
@RequestParam(required = false) String pointId, @RequestParam(required = false) String startTime,
@RequestParam(required = false) String endTime) {
if (!StringUtils.isEmpty(startTime)) {
......@@ -242,12 +242,12 @@ public class AnalyseController extends BaseController {
|| CharSequenceUtil.isEmpty(map.get("EQUIPINDEX").toString())) {
return ResponseHelper.buildResponse(new HashMap<>());
}
LambdaQueryWrapper<IdxBizFanHealthIndex> indexLambdaQueryWrapper = new LambdaQueryWrapper<>();
indexLambdaQueryWrapper.eq(IdxBizFanHealthIndex::getStation, map.get("STATION"));
indexLambdaQueryWrapper.eq(IdxBizFanHealthIndex::getEquipmentName, map.get("EQUIPNAME"));
indexLambdaQueryWrapper.eq(IdxBizFanHealthIndex::getPointName, map.get("EQUIPINDEX")).last("limit 1");
LambdaQueryWrapper<FanHealthIndex> indexLambdaQueryWrapper = new LambdaQueryWrapper<>();
indexLambdaQueryWrapper.eq(FanHealthIndex::getStation, map.get("STATION"));
indexLambdaQueryWrapper.eq(FanHealthIndex::getEquipmentName, map.get("EQUIPNAME"));
indexLambdaQueryWrapper.eq(FanHealthIndex::getPointName, map.get("EQUIPINDEX")).last("limit 1");
List<IdxBizFanHealthIndex> idxBizFanHealthIndices = idxBizFanHealthIndexMapper
List<FanHealthIndex> idxBizFanHealthIndices = fanHealthIndexMapper
.selectList(indexLambdaQueryWrapper);
if (CollectionUtils.isNotEmpty(idxBizFanHealthIndices)) {
pointId = idxBizFanHealthIndices.get(0).getIndexAddress();
......
......@@ -105,7 +105,6 @@ public class BigScreenAnalyseController extends BaseController {
return ResponseHelper.buildResponse(stringBigDecimalHashMap);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "场站设备健康状态指数与趋势 - 折线图", notes = "场站设备健康状态指数与趋势 - 折线图")
@GetMapping(value = "/getHealthListInfo")
......
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
......@@ -45,6 +46,8 @@ import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
......@@ -770,7 +773,10 @@ public class IdxBizFanHealthIndexController extends BaseController {
Date endDate = DateUtils.dateParse(endTimeTop);
endTimeTop = formatter.format(endDate);
}
//处理空指针问题 如果为空差15天前数据
if(StrUtil.isEmpty(startTimeTop)){
startTimeTop = LocalDateTime.now().minusDays(15).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
}
Date startDate = DateUtils.dateParse(startTimeTop);
startTimeTop = formatter.format(startDate);
List<FanHealthIndexDay> fanHealthIndexDays = fanHealthIndexDayMapper.selectData(healthLevel, area, equipmentName, subSystem, analysisType, analysisObjType, station, pointName, indexAddress, startTimeTop, endTimeTop,null,null, orgCode);
......
package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizFanHealthLevelDto;
......@@ -101,6 +102,13 @@ public class IdxBizFanHealthLevelController extends BaseController {
return ResponseHelper.buildResponse(idxBizFanHealthLevelServiceImpl.queryForIdxBizFanHealthLevelPage(page));
}
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(httpMethod = "GET",value = "健康等级划分", notes = "健康等级划分")
@GetMapping(value = "/queryHealthLevel")
public ResponseModel<JSONObject> queryHealthLevel() {
return ResponseHelper.buildResponse(idxBizFanHealthLevelServiceImpl.queryHealthLevel());
}
/**
* 列表全部数据查询
*
......
package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
......@@ -31,6 +33,8 @@ import javax.servlet.http.HttpServletRequest;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
......@@ -358,8 +362,12 @@ public class IdxBizPvHealthIndexController extends BaseController {
List<PvHealthIndexDay> fanHealthIndexDays = pvHealthIndexDayMapper.selectData(station, requiredType, indexAddress, healthLevel, area, analysisObjType, subarray, pointName, startTimeTop, endTimeTop, equipmentName,(current-1)*size,size, orgCode);
Map<String,Object> map = new HashMap<>();
Double value=null;
if(CollectionUtil.isNotEmpty(fanHealthIndexDays)){
value = Double.parseDouble(df.format(fanHealthIndexDays.get(0).getHealthIndex()));
}
map.put("value", Double.parseDouble(df.format(fanHealthIndexDays.get(0).getHealthIndex())));
map.put("value", value);
return ResponseHelper.buildResponse(map);
......@@ -427,7 +435,10 @@ public class IdxBizPvHealthIndexController extends BaseController {
Date endDate =DateUtils.dateParse(endTimeTop);
endTimeTop = formatter.format(endDate);
}
//处理空指针问题 如果为空差15天前数据
if(StrUtil.isEmpty(startTimeTop)){
startTimeTop = LocalDateTime.now().minusDays(15).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
}
Date startDate = DateUtils.dateParse(startTimeTop);
startTimeTop = formatter.format(startDate);
......
......@@ -130,6 +130,23 @@ public class TDBigScreenAnalyseController extends BaseController {
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "场站设备健康状态指数与趋势 - 仪表盘-10分钟", notes = "场站设备健康状态指数与趋势 - 仪表盘-10分钟")
@GetMapping(value = "/getHealthScoreInfoByMinute")
public ResponseModel<Map<String, Object>> getHealthScoreInfoByMinute(@RequestParam(required = false) String areaCode,
@RequestParam(required = false) String stationCode,
@RequestParam (required = false) String tableName) {
HashMap<String, Object> stringBigDecimalHashMap = new HashMap<>();
if (CharSequenceUtil.isNotEmpty(stationCode)) {
StationBasic stationBasic = stationBasicMapper.selectById(stationCode);
stationCode = stationBasic.getFanGatewayId();
stringBigDecimalHashMap.put("value", idxBizFanHealthIndexMapper.getHealthScoreInfoByStationByMinute(stationCode, tableName));
return ResponseHelper.buildResponse(stringBigDecimalHashMap);
}
stringBigDecimalHashMap.put("value",
idxBizFanHealthIndexMapper.getHealthScoreInfoByLatest(areaCode, stationCode));
return ResponseHelper.buildResponse(stringBigDecimalHashMap);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "场站设备健康状态指数与趋势 - 折线图", notes = "场站设备健康状态指数与趋势 - 折线图")
@GetMapping(value = "/getHealthListInfo")
public ResponseModel<Map<String, Object>> getHealthListInfo(@RequestParam(required = false) String areaCode,
......
......@@ -22,12 +22,13 @@ import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanWarningRecord;
public interface IdxBizFanHealthIndexMapper extends BaseMapper<IdxBizFanHealthIndex> {
BigDecimal getHealthScoreInfo(@Param("areaCode") String areaCode, @Param("stationCode") String stationCode);
BigDecimal getHealthScoreInfoByLatest(@Param("areaCode") String areaCode, @Param("stationCode") String stationCode);
BigDecimal getHealthScoreInfoByStation(@Param("stationCode") String stationCode,
@Param("tableName") String tableName);
BigDecimal getHealthScoreInfoByStationByMinute(@Param("stationCode") String stationCode,
@Param("tableName") String tableName);
BigDecimal getHealthScoreInfoByParam(@Param("areaCode") String areaCode, @Param("stationCode") String stationCode,
@Param("analysisType") String analysisType);
......
......@@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanHealthLevel;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* Mapper 接口
*
......@@ -26,4 +29,9 @@ public interface IdxBizFanHealthLevelMapper extends BaseMapper<IdxBizFanHealthLe
@Param("groupLowerLimit") String groupLowerLimit,
@Param("analysisObjType") String analysisObjType,
@Param("healthLevel") String healthLevel);
/**
* 查询健康等级
* @return
*/
List<Map<String, Object>> queryHealthLevel();
}
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizFanHealthLevelDto;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IdxBizFanHealthLevel;
......@@ -9,6 +12,7 @@ import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.List;
import java.util.Map;
/**
* 服务实现类
......@@ -17,7 +21,7 @@ import java.util.List;
* @date 2023-08-15
*/
@Service
public class IdxBizFanHealthLevelServiceImpl extends BaseService<IdxBizFanHealthLevelDto,IdxBizFanHealthLevel,IdxBizFanHealthLevelMapper> implements IIdxBizFanHealthLevelService {
public class IdxBizFanHealthLevelServiceImpl extends BaseService<IdxBizFanHealthLevelDto, IdxBizFanHealthLevel, IdxBizFanHealthLevelMapper> implements IIdxBizFanHealthLevelService {
/**
* 分页查询
*/
......@@ -31,4 +35,67 @@ public class IdxBizFanHealthLevelServiceImpl extends BaseService<IdxBizFanHealth
public List<IdxBizFanHealthLevelDto> queryForIdxBizFanHealthLevelList() {
return this.queryForList("" , false);
}
/**
* 查询健康等级
* @return
*/
public JSONObject queryHealthLevel() {
List<Map<String, Object>> maps = this.baseMapper.queryHealthLevel();
JSONObject result = new JSONObject();
result.put("colModel", buildColModel());
result.put("dataGridMock", buildDataGridMock(maps));
return result;
}
private JSONObject buildDataGridMock(List<Map<String, Object>> maps) {
JSONObject result = new JSONObject();
JSONArray dataList = new JSONArray();
if (CollectionUtil.isNotEmpty(maps)) {
result.put("total", maps.size());
int i = 0;
for (Map<String, Object> map : maps) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("_id", ++i);
jsonObject.put("title2_measure", map.get("GROUP_UPPER_LIMIT"));
jsonObject.put("title3_measure", map.get("GROUP_LOWER_LIMIT"));
dataList.add(jsonObject);
}
}
result.put("totalPage", 1);
result.put("pageSize", 10);
result.put("current", 1);
result.put("pagination", false);
result.put("dataList", dataList);
return result;
}
private JSONArray buildColModel() {
JSONArray result = new JSONArray();
JSONObject dengji = new JSONObject();
dengji.put("fid", "title1_measure");
dengji.put("dataIndex", "title1_measure");
dengji.put("name", "title1");
dengji.put("title", "健康等级");
dengji.put("type", "dataGrid");
dengji.put("key", "title1_measure");
JSONObject sx = new JSONObject();
sx.put("fid", "title2_measure");
sx.put("dataIndex", "title2_measure");
sx.put("name", "title2");
sx.put("title", "区间上限值");
sx.put("type", "dataGrid");
sx.put("key", "title2_measure");
JSONObject xx = new JSONObject();
xx.put("fid", "title3_measure");
xx.put("dataIndex", "title3_measure");
xx.put("name", "title3");
xx.put("title", "区间下限值");
xx.put("type", "dataGrid");
xx.put("key", "title3_measure");
result.add(dengji);
result.add(sx);
result.add(xx);
return result;
}
}
\ No newline at end of file
......@@ -11,7 +11,7 @@ import java.util.Map;
public interface FanHealthIndexDayMapper extends BaseMapper<FanHealthIndexDay> {
@Select("<script>"+
"SELECT `health_index` AS healthIndex,anomaly,rec_date as recDate, `health_index` AS `value`, substr(analysis_time,1,10) as analysisTime, station,equipment_name AS equipmentName,point_name as pointName, ( CASE HEALTH_LEVEL WHEN '危险' THEN 3 WHEN '警告' THEN 2 WHEN '注意' THEN 1 ELSE 0 END ) AS status FROM analysis_data.fan_health_index_day WHERE analysis_obj_type = #{analysisObjType} and org_code is not null" +
"SELECT distinct `health_index` AS healthIndex,anomaly,rec_date as recDate, `health_index` AS `value`, substr(analysis_time,1,10) as analysisTime, station,equipment_name AS equipmentName,point_name as pointName, ( CASE HEALTH_LEVEL WHEN '危险' THEN 3 WHEN '警告' THEN 2 WHEN '注意' THEN 1 ELSE 0 END ) AS status FROM analysis_data.fan_health_index_day WHERE analysis_obj_type = #{analysisObjType} and org_code is not null" +
"<if test='endTimeTop!= null'> and ts &lt;= #{endTimeTop} </if> " +
"<if test='startTimeTop!= null'> and ts &gt;= #{startTimeTop} </if> " +
"<if test='area!= null'> AND area = #{area} </if> " +
......@@ -34,7 +34,8 @@ public interface FanHealthIndexDayMapper extends BaseMapper<FanHealthIndexDay> {
@Select("<script>"+
"SELECT count(1) FROM analysis_data.fan_health_index_day WHERE analysis_obj_type = #{analysisObjType} and org_code is not null" +
"SELECT count(1) from ( SELECT distinct `health_index` AS healthIndex,anomaly,rec_date as recDate, `health_index` AS `value`, substr(analysis_time,1,10) as analysisTime, station,equipment_name AS equipmentName,point_name as pointName,\n" +
"( CASE HEALTH_LEVEL WHEN '危险' THEN 3 WHEN '警告' THEN 2 WHEN '注意' THEN 1 ELSE 0 END ) AS status FROM analysis_data.fan_health_index_day WHERE analysis_obj_type = #{analysisObjType} and org_code is not null" +
"<if test='endTimeTop!= null'> and ts &lt;= #{endTimeTop} </if> " +
"<if test='startTimeTop!= null'> and ts &gt;= #{startTimeTop} </if> " +
"<if test='area!= null'> AND area = #{area} </if> " +
......@@ -44,7 +45,7 @@ public interface FanHealthIndexDayMapper extends BaseMapper<FanHealthIndexDay> {
"<if test='healthLevel!= null'>AND health_level = #{healthLevel} </if>" +
"<if test='subSystem!= null'>AND sub_system = #{subSystem} </if> " +
"<if test='equipmentName!= null'>AND equipment_name = #{equipmentName} </if>" +
"<if test='orgCode!= null'>AND org_code like '${orgCode}' </if>" +
"<if test='orgCode!= null'>AND org_code like '${orgCode}' </if>)" +
"</script>")
int selectDataTotal(@Param("healthLevel")String healthLevel,@Param("area")String area,@Param("equipmentName")String equipmentName,@Param("subSystem")String subSystem,@Param("analysisType")String analysisType,@Param("analysisObjType")String analysisObjType,@Param("station")String station,@Param("pointName")String pointName, @Param("indexAddress")String indexAddress,@Param("startTimeTop") String startTimeTop, @Param("endTimeTop")String endTimeTop, @Param("orgCode")String orgCode);
......
......@@ -11,7 +11,7 @@ import java.util.Map;
public interface PvHealthIndexDayMapper extends BaseMapper<PvHealthIndexDay> {
@Select("<script>"+
"SELECT `health_index` AS healthIndex,rec_date as recDate, `health_index` AS `value`, rec_date AS recDate, anomaly, substr(analysis_time,1,10) as analysisTime,station,equipment_name AS equipmentName, point_name as pointName, index_address as indexAddress, ( CASE HEALTH_LEVEL WHEN '危险' THEN 3 WHEN '警告' THEN 2 WHEN '注意' THEN 1 ELSE 0 END ) AS status" +
"SELECT distinct `health_index` AS healthIndex,rec_date as recDate, `health_index` AS `value`, rec_date AS recDate, anomaly, substr(analysis_time,1,10) as analysisTime,station,equipment_name AS equipmentName, point_name as pointName, index_address as indexAddress, ( CASE HEALTH_LEVEL WHEN '危险' THEN 3 WHEN '警告' THEN 2 WHEN '注意' THEN 1 ELSE 0 END ) AS status" +
" FROM analysis_data.pv_health_index_day WHERE analysis_obj_type = #{analysisObjType} and org_code is not null" +
"<if test='endTimeTop!= null'> and ts &lt;= #{endTimeTop} </if> " +
"<if test='startTimeTop!= null'> and ts &gt;= #{startTimeTop} </if> " +
......@@ -42,7 +42,7 @@ public interface PvHealthIndexDayMapper extends BaseMapper<PvHealthIndexDay> {
@Select("<script>"+
"SELECT count(1)" +
"SELECT count(1) FROM (SELECT distinct `health_index` AS healthIndex,rec_date as recDate, `health_index` AS `value`, anomaly, substr(analysis_time,1,10) as analysisTime,station,equipment_name AS equipmentName, point_name as pointName, index_address as indexAddress, ( CASE HEALTH_LEVEL WHEN '危险' THEN 3 WHEN '警告' THEN 2 WHEN '注意' THEN 1 ELSE 0 END ) AS status" +
" FROM analysis_data.pv_health_index_day WHERE analysis_obj_type = #{analysisObjType} and org_code is not null" +
"<if test='endTimeTop!= null'> and ts &lt;= #{endTimeTop} </if> " +
"<if test='startTimeTop!= null'> and ts &gt;= #{startTimeTop} </if> " +
......@@ -54,7 +54,7 @@ public interface PvHealthIndexDayMapper extends BaseMapper<PvHealthIndexDay> {
"<if test='subarray!= null'>AND subarray = #{subarray} </if> " +
"<if test='equipmentName!= null'>AND equipment_name = #{equipmentName} </if>" +
// "<if test='gatewayIds != null and gatewayIds.size() > 0'>AND GATEWAY_ID IN <foreach collection='gatewayIds' item='gatewayId' open='(' separator=',' close=')'>#{gatewayId}</foreach></if>" +
"<if test='orgCode!= null'>AND org_code like '${orgCode}' </if>" +
"<if test='orgCode!= null'>AND org_code like '${orgCode}' </if>)" +
"</script>")
int selectDataTotal(@Param("station")String station,@Param("analysisType")String analysisType,@Param("indexAddress")String indexAddress,@Param("healthLevel")String healthLevel,@Param("area")String area,@Param("analysisObjType")String analysisObjType, @Param("subarray")String subarray, @Param("pointName")String pointName,@Param("startTimeTop") String startTimeTop, @Param("endTimeTop")String endTimeTop, @Param("equipmentName")String equipmentName,@Param("orgCode") String orgCode);
......
......@@ -131,12 +131,27 @@
<where>
ANALYSIS_TYPE = '按天'
<!-- AND DATE_ADD(DATE_FORMAT( REC_DATE, '%Y-%m-%d' ),INTERVAL 1 DAY) = CURRENT_DATE-->
AND CURRENT_DATE = get_time_add(1,'DAY')
AND DATE_FORMAT( REC_DATE, '%Y-%m-%d' ) = get_time_sub(1,'DAY')
<if test="stationCode != null and stationCode != ''">
AND GATEWAY_ID = #{stationCode}
AND ANALYSIS_OBJ_TYPE = '场站'
</if>
</where>
limit 1
</select>
<select id="getHealthScoreInfoByStationByMinute" resultType="java.math.BigDecimal">
SELECT
round(IFNULL( HEALTH_INDEX , 100 ), 1) AS healthIndex
FROM
${tableName}
<where>
ANALYSIS_TYPE = '按10分钟'
<if test="stationCode != null and stationCode != ''">
AND GATEWAY_ID = #{stationCode}
AND ANALYSIS_OBJ_TYPE = '场站'
</if>
</where>
order by REC_DATE DESC
limit 1
</select>
<select id="getHealthListInfo" resultType="java.util.Map">
......
......@@ -27,4 +27,8 @@
ANALYSIS_OBJ_TYPE = #{analysisObjType}
AND HEALTH_LEVEL = #{healthLevel}
</update>
<select id="queryHealthLevel" resultType="java.util.Map">
SELECT * FROM idx_biz_fan_health_level where ANALYSIS_OBJ_TYPE = '全域' ORDER BY GROUP_UPPER_LIMIT DESC
</select>
</mapper>
......@@ -490,9 +490,10 @@ public class MonitorFanIdxController extends BaseController {
SimpleDateFormat myFmt2 = new SimpleDateFormat("yyyy");
String monthy = myFmt2.format(new Date());
QueryWrapper<StationPlan> wrapper = new QueryWrapper<>();
wrapper.select(" monthly ,sum(value) value ");
wrapper.select("sum(value) as value ,monthly");
wrapper.eq("year", monthy);
wrapper.eq("station_basic_id", stationBasic.getSequenceNbr());
wrapper.groupBy("monthly");
List<Map<String, Object>> list1 = StationPlanMapper.selectMaps(wrapper);
Double sumValue = list1 != null && !list1.isEmpty() ? (Double) list1.get(0).get("value") : 0;
......
package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.IdPasswordAuthModel;
import com.yeejoin.amos.feign.privilege.util.DesUtil;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
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.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.doc.TycloudResource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;
import java.util.HashMap;
/**
* TODO 临时方案,后续要优化该方案
*
* @ProjectName amos-qms
* @Author yangyang
* @CreateTime 2024-02-20 10:29
* @Description
**/
@RestController
@TycloudResource(module = "OAuth", value = "OAuth")
@RequestMapping(value = "/bigscreen/oauth")
@Api(tags = "大屏对接")
@Slf4j
public class OAuthResource {
public static final String SECRETKEY = "qaz";
private final static String AUTHORIZE = "http://%s/authorize?redirect_uri=%s";
private final static String AUTOLOGIN = "http://%s/autologin?token=%s&userId=%s&redirectURI=%s";
private final static String BIGSCREEN = "/vizagfun/jepc?appId=jepc1&top=monitor&bottom=ovarall";
@Value("${appKey:AMOS_ADMIN}")
private String APP_KEY;
@Value("${product:AMOS-WEB-ADMIN}")
private String PRODUCT;
@Value("${redirect.host:iiet-jepcc.powerchina.cn:8088}")
private String host;
@TycloudOperation(needAuth = false, ApiLevel = UserType.PUBLIC)
@GetMapping("/redirect")
public void getAuth(@RequestParam("loginId") String loginId, @RequestParam("password") String password, HttpServletRequest request, HttpServletResponse response) throws Exception {
if (ValidationUtil.isEmpty(loginId) || ValidationUtil.isEmpty(password)) {
response.sendRedirect(String.format(AUTHORIZE, host, getRedirectURI(null)));
}
String redirectUrl;
// 已取得认证用户信息,执行相应操作…
RequestContext.setAppKey(APP_KEY);
RequestContext.setProduct(PRODUCT);
// 登录
IdPasswordAuthModel idPasswordAuthModel = new IdPasswordAuthModel();
idPasswordAuthModel.setLoginId(loginId);
idPasswordAuthModel.setPassword(password);
FeignClientResult<HashMap<String, Object>> feignClientResult = null;
try {
feignClientResult = Privilege.authClient.idpassword(idPasswordAuthModel);
} catch (Exception e) {
e.printStackTrace();
}
if (feignClientResult == null || feignClientResult.getStatus() != 200) {
redirectUrl = String.format(AUTHORIZE, host, getRedirectURI(null));
log.info("用户[{}]未在平台创建。。。", loginId);
response.sendRedirect(redirectUrl);
}
String userId = (String) feignClientResult.getResult().get("userId");
String amosToken = (String) feignClientResult.getResult().get("token");
redirectUrl = String.format(AUTOLOGIN, host, amosToken, userId, getRedirectURI(BIGSCREEN));
log.info("重定向访问地址:{}", redirectUrl);
response.sendRedirect(redirectUrl);
}
public String getRedirectURI(String redirectUrl) {
if (StringUtils.isEmpty(redirectUrl)) {
return "";
}
return URLEncoder.encode(redirectUrl);
}
}
......@@ -10,7 +10,7 @@ import java.util.Map;
public interface PrivilegeCompanyMapper extends BaseMapper<PrivilegeCompany> {
@Select("select SEQUENCE_NBR as sequenceNbr,ORG_CODE as orgCode,COMPANY_NAME as companyName ,LEVEL from privilege_company where COMPANY_TYPE = 'region' and IS_DELETED = 0 ")
@Select("select SEQUENCE_NBR as sequenceNbr,ORG_CODE as orgCode,COMPANY_NAME as companyName ,`LEVEL` from privilege_company where COMPANY_TYPE = 'region' and IS_DELETED = 0 ")
public List<PrivilegeCompany> getAreaCompany();
......
......@@ -99,3 +99,6 @@ 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=false
\ No newline at end of file
......@@ -19,11 +19,23 @@
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-module-common-biz</artifactId>
<version>${amos-biz-boot.version}</version>
<exclusions>
<exclusion>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk16</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-biz-common</artifactId>
<version>1.0.0</version>
<exclusions>
<exclusion>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk16</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.amosframework.boot</groupId>
......@@ -36,6 +48,11 @@
<artifactId>hutool-all</artifactId>
<version>5.7.22</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15to18</artifactId>
<version>1.69</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.influxdb</groupId>-->
<!-- <artifactId>influxdb-java</artifactId>-->
......
package com.yeejoin.amos.boot.module.jxiop.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.entity.PvDeviceDataEntity;
public interface PvDeviceDataMapper extends BaseMapper<PvDeviceDataEntity> {
}
package com.yeejoin.amos.boot.module.jxiop.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.entity.PvStationDataEntity;
public interface PvStationDataMapper extends BaseMapper<PvStationDataEntity> {
}
package com.yeejoin.amos.boot.module.jxiop.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.entity.StationDailyDataEntity;
public interface StationDailyDataMapper extends BaseMapper<StationDailyDataEntity> {
}
package com.yeejoin.amos.boot.module.jxiop.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.entity.WindDeviceDataEntity;
public interface WindDeviceDataMapper extends BaseMapper<WindDeviceDataEntity> {
}
package com.yeejoin.amos.boot.module.jxiop.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.entity.WindStationDataEntity;
public interface WindStationDataMapper extends BaseMapper<WindStationDataEntity> {
}
package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.factory.JXDZExecute;
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;
@RestController
@RequestMapping(value = "/jxdz")
public class JXDZExecuteController {
@Autowired
JXDZExecute jxdzExecute;
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@GetMapping("/testDay")
public String testDay() {
jxdzExecute.dayInterface();
return "Success";
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@GetMapping("/testHour")
public String testHour() {
jxdzExecute.hourInterface();
return "Success";
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.jxdz.Enum;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum JXDZAccessTypeEnum {
CAIJI(1, "采集"),
BULU(2, "补录"),
;
private Integer code;
private String remark;
}
package com.yeejoin.amos.boot.module.jxiop.biz.jxdz.Enum;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum JXDZCodeEnum {
XZ("W005", "夏造风电站"),
GF("P001", "泰和前进光伏电站"),
;
private String code;
private String remark;
}
package com.yeejoin.amos.boot.module.jxiop.biz.jxdz.Enum;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum JXDZDataTypeEnum {
FDZJC(1, "风电站监测数据"),
GFDZJC(2, "光伏电站监测数据"),
FDZSBJC(3, "风电站设备监测数据"),
GFDZSBJC(4, "光伏电站设备监测数据"),
DZMTSJ(5, "电站每天数据包括:运维、节能减排、发电效率"),
;
private Integer code;
private String remark;
public static JXDZDataTypeEnum getEnumByCode(Integer code) {
for (JXDZDataTypeEnum jxdzDataTypeEnum : JXDZDataTypeEnum.values()) {
if (jxdzDataTypeEnum.getCode().equals(code)) {
return jxdzDataTypeEnum;
}
}
return null;
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.jxdz.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value = "jxdz_pv_device_data", autoResultMap = true)
public class PvDeviceDataEntity extends BaseEntity {
@TableField("code")
private String code;
@TableField("name")
private String name;
/**
* 毫秒级别时间
*/
@TableField("date_time")
private Long dateTime;
/**
*日发电量
*/
@TableField("generation_daily")
private Double GenerationDaily;
/**
*月发电量
*/
@TableField("generation_month")
private Double GenerationMonth;
/**
*年发电量
*/
@TableField("generation_year")
private Double GenerationYear;
/**
*累计发电量
*/
@TableField("generation_gross")
private Double GenerationGross;
}
package com.yeejoin.amos.boot.module.jxiop.biz.jxdz.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value = "jxdz_pv_station_data", autoResultMap = true)
public class PvStationDataEntity extends BaseEntity {
@TableField("code")
private String code;
@TableField("name")
private String name;
/**
* 毫秒级别时间
*/
@TableField("date_time")
private Long dateTime;
/**
*发电功率
*/
@TableField("generation_power")
private Double GenerationPower;
/**
*总辐射
*/
@TableField("total_radiation")
private Double TotalRadiation;
/**
*直接辐射
*/
@TableField("direct_radiation")
private Double DirectRadiation;
/**
*散射辐射
*/
@TableField("scatter_radiation")
private Double ScatterRadiation;
/**
*日发电量
*/
@TableField("generation_daily")
private Double GenerationDaily;
/**
*月发电量
*/
@TableField("generation_month")
private Double GenerationMonth;
/**
*年发电量
*/
@TableField("generation_year")
private Double GenerationYear;
/**
*累计发电量
*/
@TableField("generation_gross")
private Double GenerationGross;
/**
*利用小时数
*/
@TableField("utilize_hours")
private Double UtilizeHours;
/**
*损失电量
*/
@TableField("loss_electricity")
private Double LossElectricity;
/**
*总辐照度
*/
@TableField("total_irradiance")
private Double TotalIrradiance;
/**
*直接辐照度
*/
@TableField("direct_irradiance")
private Double DirectIrradiance;
/**
*散射辐照度
*/
@TableField("scatter_irradiance")
private Double ScatterIrradiance;
/**
* 日上网电量
*/
@TableField("on_grid_energy_daily")
private Double OnGridEnergyDaily;
/**
* 月上网电量
*/
@TableField("on_grid_energy_month")
private Double OnGridEnergyMonth;
/**
* 年上网电量
*/
@TableField("on_grid_energy_year")
private Double OnGridEnergyYear;
/**
* 累计上网电量
*/
@TableField("on_grid_energy_gross")
private Double OnGridEnergyGross;
}
package com.yeejoin.amos.boot.module.jxiop.biz.jxdz.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value = "jxdz_station_daily_data", autoResultMap = true)
public class StationDailyDataEntity extends BaseEntity {
@TableField("code")
private String code;
@TableField("name")
private String name;
/**
* 毫秒级别时间
*/
@TableField("date_time")
private Long dateTime;
/**
* 工作票总数
*/
@TableField("work_ticket_total_nums")
private Double WorkTicketTotalNums;
/**
* 办理中工作票数
*/
@TableField("work_ticket_processing_nums")
private Double WorkTicketProcessingNums;
/**
* 已作废工作票数
*/
@TableField("work_ticket_invalidated_nums")
private Double WorkTicketInvalidatedNums;
/**
* 执行中工作票总数
*/
@TableField("work_ticket_executing_nums")
private Double WorkTicketExecutingNums;
/**
* 已终结的工作票数
*/
@TableField("work_ticket_terminated_nums")
private Double WorkTicketTerminatedNums;
/**
*定期工作任务
*/
@TableField("regular_tasks_nums")
private Double RegularTasksNums;
/**
* 巡检任务数量
*/
@TableField("inspection_tasks_nums")
private Double InspectionTasksNums;
/**
* 工单总数
*/
@TableField("work_order_total_nums")
private Double WorkOrderTotalNums;
/**
* 工单作废数
*/
@TableField("work_order_invalidated_nums")
private Double WorkOrderInvalidatedNums;
/**
* 工单待开工数
*/
@TableField("work_order_to_be_opened_nums")
private Double WorkOrderToBeOpenedNums;
/**
* 工单终结数
*/
@TableField("work_order_terminated_nums")
private Double WorkOrderTerminatedNums;
/**
* 工单开工数
*/
@TableField("work_order_start_nums")
private Double WorkOrderStartNums;
/**
* 二氧化碳减排量
*/
@TableField("co2_emission_reduction")
private Double Co2EmissionReduction;
/**
* 节约标准煤
*/
@TableField("standard_coal_saving")
private Double StandardCoalSaving;
/**
* 二氧化硫减排量
*/
@TableField("so2_emission_reduction")
private Double So2EmissionReduction;
/**
* 碳粉尘减排量
*/
@TableField("carbon_dust_emission_reduction")
private Double CarbonDustEmissionReduction;
/**
* 发电效率
*/
@TableField("generation_efficiency")
private Double GenerationEfficiency;
}
package com.yeejoin.amos.boot.module.jxiop.biz.jxdz.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value = "jxdz_wind_device_data", autoResultMap = true)
public class WindDeviceDataEntity extends BaseEntity {
@TableField("code")
private String code;
@TableField("name")
private String name;
/**
* 毫秒级别时间
*/
@TableField("date_time")
private Long dateTime;
/**
*日发电量
*/
@TableField("generation_daily")
private Double GenerationDaily;
/**
*月发电量
*/
@TableField("generation_month")
private Double GenerationMonth;
/**
*年发电量
*/
@TableField("generation_year")
private Double GenerationYear;
/**
*累计发电量
*/
@TableField("generation_gross")
private Double GenerationGross;
}
package com.yeejoin.amos.boot.module.jxiop.biz.jxdz.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value = "jxdz_wind_station_data", autoResultMap = true)
public class WindStationDataEntity extends BaseEntity {
@TableField("code")
private String code;
@TableField("name")
private String name;
/**
* 毫秒级别时间
*/
@TableField("date_time")
private Long dateTime;
/**
*发电功率
*/
@TableField("generation_power")
private Double GenerationPower;
/**
* 风速
*/
@TableField("wind_speed")
private Double WindSpeed;
/**
*风向
*/
@TableField("wind_direction")
private Double WindDirection;
/**
*日发电量
*/
@TableField("generation_daily")
private Double GenerationDaily;
/**
* 月发电量
*/
@TableField("generation_month")
private Double GenerationMonth;
/**
* 年发电量
*/
@TableField("generation_year")
private Double GenerationYear;
/**
*累计发电量
*/
@TableField("generation_gross")
private Double GenerationGross;
/**
*利用小时数
*/
@TableField("utilize_hours")
private Double UtilizeHours;
/**
*损失电量
*/
@TableField("loss_electricity")
private Double LossElectricity;
/**
* 日上网电量
*/
@TableField("on_grid_energy_daily")
private Double OnGridEnergyDaily;
/**
* 月上网电量
*/
@TableField("on_grid_energy_month")
private Double OnGridEnergyMonth;
/**
* 年上网电量
*/
@TableField("on_grid_energy_year")
private Double OnGridEnergyYear;
/**
* 累计上网电量
*/
@TableField("on_grid_energy_gross")
private Double OnGridEnergyGross;
}
package com.yeejoin.amos.boot.module.jxiop.biz.jxdz.factory;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.Enum.JXDZAccessTypeEnum;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.Enum.JXDZCodeEnum;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.entity.StationDailyDataEntity;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.impl.StationDailyDataServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.utils.JXDZUtils;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.vo.NeedDataVO;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.vo.StationDailyDataVO;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.JXDZMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import java.text.ParseException;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.*;
@Service
public class DZMTSJServiceImpl implements IJXDZService {
@Autowired
JXDZUtils jxdzUtils;
@Autowired
StationDailyDataServiceImpl stationDailyDataService;
@Autowired
JXDZMapper jxdzMapper;
@Override
public void backupData(List list, Long dateTime) {
if (CollectionUtil.isNotEmpty(list)) {
List<StationDailyDataEntity> stationDailyDataEntityList = new ArrayList<>();
list.forEach(item -> {
StationDailyDataEntity stationDailyDataEntity = BeanUtil.copyProperties(item, StationDailyDataEntity.class);
stationDailyDataEntity.setDateTime(dateTime);
stationDailyDataEntityList.add(stationDailyDataEntity);
});
stationDailyDataService.saveBatch(stationDailyDataEntityList);
}
}
@Override
public List buildData(Integer accessType, Long dateTime) {
List<StationDailyDataVO> list = new ArrayList<>();
if (JXDZAccessTypeEnum.BULU.getCode().equals(accessType)) {
List<StationDailyDataEntity> stationDailyDataEntityList = stationDailyDataService.list(new LambdaQueryWrapper<StationDailyDataEntity>().eq(StationDailyDataEntity::getDateTime, dateTime));
list = BeanUtil.copyToList(stationDailyDataEntityList, StationDailyDataVO.class);
} else {
list.add(getBusinessData(JXDZCodeEnum.XZ.getCode(), JXDZCodeEnum.XZ.getRemark()));
list.add(getBusinessData(JXDZCodeEnum.GF.getCode(), JXDZCodeEnum.GF.getRemark()));
}
return list;
}
/**
* 获取业务数据
* @param code
* @param name
* @return
*/
private StationDailyDataVO getBusinessData(String code, String name) {
StationDailyDataVO stationDailyDataVO = new StationDailyDataVO();
if(JXDZCodeEnum.XZ.getCode().equals(code)){
stationDailyDataVO.setCode(JXDZUtils.XZ_CODE);
}else if(JXDZCodeEnum.GF.getCode().equals(code)){
stationDailyDataVO.setCode(JXDZUtils.GF_CODE);
}else {
stationDailyDataVO.setCode(code);
}
stationDailyDataVO.setName(name);
stationDailyDataVO.setWorkTicketTotalNums(jxdzMapper.countWorkTicketTotalByCode(code).doubleValue());
stationDailyDataVO.setWorkTicketProcessingNums(jxdzMapper.countWorkTicketProcessingByCode(code).doubleValue());
stationDailyDataVO.setWorkTicketInvalidatedNums(jxdzMapper.countWorkOrderInvalidatedByCode(code).doubleValue());
stationDailyDataVO.setWorkTicketExecutingNums(jxdzMapper.countWorkTicketInvalidatedByCode(code).doubleValue());
stationDailyDataVO.setWorkTicketTerminatedNums(jxdzMapper.countWorkTicketTerminatedByCode(code).doubleValue());
stationDailyDataVO.setRegularTasksNums(jxdzMapper.countRegularTasksByCode(code).doubleValue());
stationDailyDataVO.setInspectionTasksNums(jxdzMapper.countInspectionTasksByCode(code).doubleValue());
stationDailyDataVO.setWorkOrderTotalNums(jxdzMapper.countWorkOrderTotalByCode(code).doubleValue());
stationDailyDataVO.setWorkOrderInvalidatedNums(jxdzMapper.countWorkOrderToBeOpenedByCode(code).doubleValue());
stationDailyDataVO.setWorkOrderToBeOpenedNums(jxdzMapper.countWorkOrderTotalByCode(code).doubleValue());
stationDailyDataVO.setWorkOrderTerminatedNums(jxdzMapper.countWorkOrderTerminatedByCode(code).doubleValue());
stationDailyDataVO.setWorkOrderStartNums(jxdzMapper.countWorkOrderStartByCode(code).doubleValue());
//调用core 接口
JSONObject jsonObject = new JSONObject();
if (JXDZCodeEnum.XZ.getCode().equals(code)) {
String url = "/core/datastorage/gateway/point/list?groupId=1764453166557986818&dataType=analog";
jsonObject = jxdzUtils.sendCoreGetRequest(url);
} else if (JXDZCodeEnum.GF.getCode().equals(code)) {
String url = "/core/datastorage/gateway/point/list?groupId=1770308721235230721&dataType=analog";
jsonObject = jxdzUtils.sendCoreGetRequest(url);
}
if (jsonObject.getInteger("status") == HttpStatus.OK.value()) {
//补充电站测点信息
supplementStationData(jsonObject.getJSONArray("result"), stationDailyDataVO);
supplementBDData(stationDailyDataVO, code);
//补充其他信息
}
return stationDailyDataVO;
}
/**
* 补充部盾提供的数据
* @param stationDailyDataVO
*/
private void supplementBDData(StationDailyDataVO stationDailyDataVO, String code) {
if (JXDZCodeEnum.GF.getCode().equals(code)) {
try {
String yesterday = DateUtils.dateFormat(Date.from(LocalDate.now().minusDays(1).atStartOfDay(ZoneId.systemDefault()).toInstant()), "yyyy-MM-dd");
String url = "/screen_api?method=scene_screen.large_screen.get_loss_of_electricity&reporting_data=" + yesterday + "&source_station_id=1701778419827638274&station_type=PV";
JSONObject jsonObject = jxdzUtils.sendCoreGetRequest(url);
if (0 == jsonObject.getInteger("status")) {
JSONObject data = jsonObject.getJSONObject("data");
if (!Objects.isNull(data)) {
stationDailyDataVO.setGenerationEfficiency(data.getDouble("comprehensive_efficiency"));
}
}
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
}
/**
* 补充场站数据
* @param result
* @param stationDailyDataVO
*/
private void supplementStationData(JSONArray result, StationDailyDataVO stationDailyDataVO) {
if (CollectionUtil.isNotEmpty(result)) {
for (Object o : result) {
if (o instanceof Map) {
Map map = (Map) o;
JSONObject jsonObject = new JSONObject(map);
String pointName = (String) map.get("pointName");
if ("二氧化碳排放量(t)".equals(pointName)) {
stationDailyDataVO.setCo2EmissionReduction(jsonObject.getDouble("value"));
}
if ("节约标准煤(t)".equals(pointName)) {
stationDailyDataVO.setStandardCoalSaving(jsonObject.getDouble("value"));
}
if ("二氧化硫排放量(t)".equals(pointName)) {
stationDailyDataVO.setSo2EmissionReduction(jsonObject.getDouble("value"));
}
if ("碳粉尘减排量(t)".equals(pointName)) {
stationDailyDataVO.setCarbonDustEmissionReduction(jsonObject.getDouble("value"));
}
if ("发电效率".equals(pointName)) {
stationDailyDataVO.setGenerationEfficiency(jsonObject.getDouble("value"));
}
}
}
}
}
@Override
public void sendData(Integer accessType, NeedDataVO needDataVO, List list) {
if (CollectionUtil.isNotEmpty(list)) {
jxdzUtils.sendJXDZPostRequest("/ngnsyncjiangxiyw/accessdaydata/stationDailyData", accessType, needDataVO, list);
}
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.jxdz.factory;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.Enum.JXDZAccessTypeEnum;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.Enum.JXDZCodeEnum;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.entity.WindStationDataEntity;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.impl.WindStationDataServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.utils.JXDZUtils;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.vo.NeedDataVO;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.vo.WindStationDataVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import java.text.ParseException;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.*;
@Service
public class FDZJCServiceImpl implements IJXDZService {
@Autowired
JXDZUtils jxdzUtils;
@Autowired
WindStationDataServiceImpl windStationDataService;
@Override
public void backupData(List list, Long dateTime) {
if (CollectionUtil.isNotEmpty(list)) {
List<WindStationDataEntity> windStationDataEntityList = new ArrayList<>();
list.forEach(item -> {
WindStationDataEntity windStationDataEntity = BeanUtil.copyProperties(item, WindStationDataEntity.class);
windStationDataEntity.setDateTime(dateTime);
windStationDataEntityList.add(windStationDataEntity);
});
windStationDataService.saveBatch(windStationDataEntityList);
}
}
@Override
public List buildData(Integer accessType, Long dateTime) {
List<WindStationDataVO> list = new ArrayList<>();
if (JXDZAccessTypeEnum.BULU.getCode().equals(accessType)) {
List<WindStationDataEntity> windStationDataEntityList = windStationDataService.list(new LambdaQueryWrapper<WindStationDataEntity>().eq(WindStationDataEntity::getDateTime, dateTime));
list = BeanUtil.copyToList(windStationDataEntityList, WindStationDataVO.class);
} else {
list.add(getBusinessData(JXDZCodeEnum.XZ.getCode(), JXDZCodeEnum.XZ.getRemark()));
}
return list;
}
private WindStationDataVO getBusinessData(String code, String name) {
WindStationDataVO windStationDataVO = new WindStationDataVO();
if(JXDZCodeEnum.XZ.getCode().equals(code)){
windStationDataVO.setCode(JXDZUtils.XZ_CODE);
}else {
windStationDataVO.setCode(code);
}
windStationDataVO.setName(name);
//调用core 接口
JSONObject jsonObject = new JSONObject();
if (JXDZCodeEnum.XZ.getCode().equals(code)) {
String url = "/core/datastorage/gateway/point/list?groupId=1764453166557986818&dataType=analog";
jsonObject = jxdzUtils.sendCoreGetRequest(url);
}
if (jsonObject.getInteger("status") == HttpStatus.OK.value()) {
//补充电站测点信息
supplementStationData(jsonObject.getJSONArray("result"), windStationDataVO);
supplementBDData(windStationDataVO, code);
}
return windStationDataVO;
}
/**
* 补充部盾提供的数据
* @param windStationDataVO
*/
private void supplementBDData(WindStationDataVO windStationDataVO, String code) {
JSONObject jsonObject = new JSONObject();
if (JXDZCodeEnum.XZ.getCode().equals(code)) {
String yesterday = null;
try {
yesterday = DateUtils.dateFormat(Date.from(LocalDate.now().minusDays(1).atStartOfDay(ZoneId.systemDefault()).toInstant()), "yyyy-MM-dd");
} catch (ParseException e) {
throw new RuntimeException(e);
}
String url = "/screen_api?method=scene_screen.large_screen.get_loss_of_electricity&reporting_data=" + yesterday + "&source_station_id=1701779143491878913&station_type=FAN";
jsonObject = jxdzUtils.sendCoreGetRequest(url);
}
if (0 == jsonObject.getInteger("status")) {
JSONObject data = jsonObject.getJSONObject("data");
if (!Objects.isNull(data)) {
windStationDataVO.setLossElectricity(data.getDouble("loss_of_electricity_day"));
windStationDataVO.setOnGridEnergyDaily(data.getDouble("on_grid_energy_day"));
windStationDataVO.setOnGridEnergyMonth(data.getDouble("on_grid_energy_month"));
windStationDataVO.setOnGridEnergyYear(data.getDouble("on_grid_energy_year"));
windStationDataVO.setOnGridEnergyGross(data.getDouble("on_grid_energy"));
}
}
}
/**
* 补充电站数据
* @param result
* @param windStationDataVO
*/
private void supplementStationData(JSONArray result, WindStationDataVO windStationDataVO) {
if (CollectionUtil.isNotEmpty(result)) {
for (Object o : result) {
if (o instanceof Map) {
Map map = (Map) o;
JSONObject jsonObject = new JSONObject(map);
String pointName = (String) map.get("pointName");
if ("发电功率".equals(pointName)) {
windStationDataVO.setGenerationPower(jsonObject.getDouble("value"));
}
if ("瞬时平均风速".equals(pointName)) {
windStationDataVO.setWindSpeed(jsonObject.getDouble("value"));
}
if ("风向".equals(pointName)) {
windStationDataVO.setWindDirection(jsonObject.getDouble("value"));
}
if ("日发电量总和".equals(pointName)) {
windStationDataVO.setGenerationDaily(jsonObject.getDouble("value"));
}
if ("月发电量总和".equals(pointName)) {
windStationDataVO.setGenerationMonth(jsonObject.getDouble("value"));
}
if ("年发电量总和".equals(pointName)) {
windStationDataVO.setGenerationYear(jsonObject.getDouble("value"));
windStationDataVO.setGenerationGross(jsonObject.getDouble("value"));
}
if ("日利用小时数".equals(pointName)) {
windStationDataVO.setUtilizeHours(jsonObject.getDouble("value"));
}
}
}
}
}
@Override
public void sendData(Integer accessType, NeedDataVO needDataVO, List list) {
if (CollectionUtil.isNotEmpty(list)) {
jxdzUtils.sendJXDZPostRequest("/ngnsyncjiangxiyw/accesshourdata/windStationData", accessType, needDataVO, list);
}
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.jxdz.factory;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.Enum.JXDZAccessTypeEnum;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.Enum.JXDZCodeEnum;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.entity.WindDeviceDataEntity;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.impl.WindDeviceDataServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.utils.JXDZUtils;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.vo.NeedDataVO;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.vo.WindDeviceDataVO;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.JXDZMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@Service
public class FDZSBJCServiceImpl implements IJXDZService {
@Autowired
JXDZUtils jxdzUtils;
@Autowired
WindDeviceDataServiceImpl windDeviceDataService;
@Autowired
JXDZMapper jxdzMapper;
@Override
public void backupData(List list, Long dateTime) {
if (CollectionUtil.isNotEmpty(list)) {
List<WindDeviceDataEntity> windDeviceDataEntityList = new ArrayList<>();
list.forEach(item -> {
WindDeviceDataEntity windDeviceDataEntity = BeanUtil.copyProperties(item, WindDeviceDataEntity.class);
windDeviceDataEntity.setDateTime(dateTime);
windDeviceDataEntityList.add(windDeviceDataEntity);
});
windDeviceDataService.saveBatch(windDeviceDataEntityList);
}
}
@Override
public List buildData(Integer accessType, Long dateTime) {
List<WindDeviceDataVO> list = new ArrayList<>();
if (JXDZAccessTypeEnum.BULU.getCode().equals(accessType)) {
List<WindDeviceDataEntity> windDeviceDataEntityList = windDeviceDataService.list(new LambdaQueryWrapper<WindDeviceDataEntity>().eq(WindDeviceDataEntity::getDateTime, dateTime));
list = BeanUtil.copyToList(windDeviceDataEntityList, WindDeviceDataVO.class);
} else {
JSONArray zzBusinessData = getZZBusinessData();
if (CollectionUtil.isNotEmpty(zzBusinessData)) {
for (Object o : zzBusinessData) {
if (o instanceof Map) {
Map map = (Map) o;
JSONObject jsonObject = new JSONObject(map);
if (jsonObject.getString("name").contains("风机")) {
list.add(getWindDeviceDataVO(jsonObject));
}
}
}
}
}
return list;
}
/**
* 获取风电设备数据
* @param jsonObject
* @return
*/
private WindDeviceDataVO getWindDeviceDataVO(JSONObject jsonObject) {
WindDeviceDataVO windDeviceDataVO = new WindDeviceDataVO();
String sequenceNbr = jsonObject.getString("sequenceNbr");
windDeviceDataVO.setName(jsonObject.getString("name"));
windDeviceDataVO.setCode(getWindDeviceCode(jsonObject.getString("name")));
//开始调用具体列表接口
JSONArray windDeviceJSONArray = getWindDeviceDataBySequenceNbr(sequenceNbr);
if (CollectionUtil.isNotEmpty(windDeviceJSONArray)) {
for (Object o : windDeviceJSONArray) {
if (o instanceof Map) {
Map map = (Map) o;
JSONObject result = new JSONObject(map);
String pointName = (String) map.get("pointName");
if ("日发电量".equals(pointName)) {
windDeviceDataVO.setGenerationDaily(result.getDouble("value"));
}
if ("月发电量".equals(pointName)) {
windDeviceDataVO.setGenerationMonth(result.getDouble("value"));
}
if ("年发电量".equals(pointName)) {
windDeviceDataVO.setGenerationYear(result.getDouble("value"));
windDeviceDataVO.setGenerationGross(result.getDouble("value"));
}
}
}
}
return windDeviceDataVO;
}
/**
* 获取风电设备Code
* @param name
* @return
*/
private String getWindDeviceCode(String name) {
String replaceString = name.replace("风机", "");
Integer value = Integer.valueOf(replaceString);
String field = "%#" + value + "风机系统%";
String replaceField = "%#" + replaceString + "风机系统%";
return jxdzMapper.getDeviceCode(JXDZCodeEnum.XZ.getCode(), field, replaceField);
}
/**
* 根据主键获取具体的风电测点数据
* @param sequenceNbr
* @return
*/
private JSONArray getWindDeviceDataBySequenceNbr(String sequenceNbr) {
JSONObject jsonObject = jxdzUtils.sendCoreGetRequest("/core/datastorage/gateway/point/list?groupId=" + sequenceNbr + "&dataType=analog");
if (!Objects.isNull(jsonObject)) {
if (jsonObject.getInteger("status") == HttpStatus.OK.value()) {
return jsonObject.getJSONArray("result");
}
}
return new JSONArray();
}
/**
* 获取装置测点数据
* @return
*/
private JSONArray getZZBusinessData() {
JSONObject jsonObject = jxdzUtils.sendCoreGetRequest("/core/front-gateway-device/tree?gatewayId=1762633242759958530");
if (!Objects.isNull(jsonObject)) {
if (jsonObject.getInteger("status") == HttpStatus.OK.value()) {
JSONArray result = jsonObject.getJSONArray("result");
if (CollectionUtil.isNotEmpty(result)) {
JSONObject firstObject = result.getJSONObject(0).getJSONArray("children").getJSONObject(0);
if (!Objects.isNull(firstObject)) {
JSONArray children = firstObject.getJSONArray("children");
if (CollectionUtil.isNotEmpty(children)) {
for (Object child : children) {
if (child instanceof Map) {
Map map = (Map) child;
JSONObject childJSON = new JSONObject(map);
if ("装置测点".equals(childJSON.getString("name"))) {
return childJSON.getJSONArray("children");
}
}
}
}
}
}
}
}
return new JSONArray();
}
@Override
public void sendData(Integer accessType, NeedDataVO needDataVO, List list) {
if(CollectionUtil.isNotEmpty(list)){
jxdzUtils.sendJXDZPostRequest("/ngnsyncjiangxiyw/accesshourdata/windDeviceData", accessType, needDataVO, list);
}
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.jxdz.factory;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.Enum.JXDZAccessTypeEnum;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.Enum.JXDZCodeEnum;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.entity.PvStationDataEntity;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.impl.PvStationDataServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.utils.JXDZUtils;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.vo.NeedDataVO;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.vo.PvStationDataVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import java.text.ParseException;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.*;
@Service
public class GFDZJCServiceImpl implements IJXDZService {
@Autowired
JXDZUtils jxdzUtils;
@Autowired
PvStationDataServiceImpl pvStationDataService;
@Override
public void backupData(List list, Long dateTime) {
if (CollectionUtil.isNotEmpty(list)) {
List<PvStationDataEntity> pvStationDataEntityList = new ArrayList<>();
list.forEach(item -> {
PvStationDataEntity pvStationDataEntity = BeanUtil.copyProperties(item, PvStationDataEntity.class);
pvStationDataEntity.setDateTime(dateTime);
pvStationDataEntityList.add(pvStationDataEntity);
});
pvStationDataService.saveBatch(pvStationDataEntityList);
}
}
@Override
public List buildData(Integer accessType, Long dateTime) {
List<PvStationDataVO> list = new ArrayList<>();
if (JXDZAccessTypeEnum.BULU.getCode().equals(accessType)) {
List<PvStationDataEntity> windStationDataEntityList = pvStationDataService.list(new LambdaQueryWrapper<PvStationDataEntity>().eq(PvStationDataEntity::getDateTime, dateTime));
list = BeanUtil.copyToList(windStationDataEntityList, PvStationDataVO.class);
} else {
list.add(getBusinessData(JXDZCodeEnum.GF.getCode(), JXDZCodeEnum.GF.getRemark()));
}
return list;
}
private PvStationDataVO getBusinessData(String code, String name) {
PvStationDataVO pvStationDataVO = new PvStationDataVO();
if (JXDZCodeEnum.GF.getCode().equals(code)) {
pvStationDataVO.setCode(JXDZUtils.GF_CODE);
} else {
pvStationDataVO.setCode(code);
}
pvStationDataVO.setName(name);
//调用core 接口
JSONObject jsonObject = new JSONObject();
if (JXDZCodeEnum.GF.getCode().equals(code)) {
String url = "/core/datastorage/gateway/point/list?groupId=1770308721235230721&dataType=analog";
jsonObject = jxdzUtils.sendCoreGetRequest(url);
}
if (jsonObject.getInteger("status") == HttpStatus.OK.value()) {
//补充电站测点信息
supplementStationData(jsonObject.getJSONArray("result"), pvStationDataVO);
supplementBDData(pvStationDataVO, code);
}
return pvStationDataVO;
}
/**
* 补充损失电量
* @param pvStationDataVO
* @param code
*/
private void supplementBDData(PvStationDataVO pvStationDataVO, String code) {
JSONObject jsonObject = new JSONObject();
if (JXDZCodeEnum.GF.getCode().equals(code)) {
String yesterday = null;
try {
yesterday = DateUtils.dateFormat(Date.from(LocalDate.now().minusDays(1).atStartOfDay(ZoneId.systemDefault()).toInstant()), "yyyy-MM-dd");
} catch (ParseException e) {
throw new RuntimeException(e);
}
String url = "/screen_api?method=scene_screen.large_screen.get_loss_of_electricity&reporting_data=" + yesterday + "&source_station_id=1701778419827638274&station_type=PV";
jsonObject = jxdzUtils.sendCoreGetRequest(url);
}
if (0 == jsonObject.getInteger("status")) {
JSONObject data = jsonObject.getJSONObject("data");
if (!Objects.isNull(data)) {
pvStationDataVO.setLossElectricity(data.getDouble("loss_of_electricity_day"));
pvStationDataVO.setOnGridEnergyDaily(data.getDouble("on_grid_energy_day"));
pvStationDataVO.setOnGridEnergyMonth(data.getDouble("on_grid_energy_month"));
pvStationDataVO.setOnGridEnergyYear(data.getDouble("on_grid_energy_year"));
pvStationDataVO.setOnGridEnergyGross(data.getDouble("on_grid_energy"));
}
}
}
/**
* 补充场站数据
* @param result
* @param pvStationDataVO
*/
private void supplementStationData(JSONArray result, PvStationDataVO pvStationDataVO) {
if (CollectionUtil.isNotEmpty(result)) {
for (Object o : result) {
if (o instanceof Map) {
Map map = (Map) o;
JSONObject jsonObject = new JSONObject(map);
String pointName = (String) map.get("pointName");
if ("发电功率".equals(pointName)) {
pvStationDataVO.setGenerationPower((Double) map.get("value"));
}
if ("总辐射".equals(pointName)) {
pvStationDataVO.setTotalRadiation(jsonObject.getDouble("value"));
}
if ("直接辐射".equals(pointName)) {
pvStationDataVO.setDirectRadiation(jsonObject.getDouble("value"));
}
if ("散射辐射".equals(pointName)) {
pvStationDataVO.setScatterRadiation(jsonObject.getDouble("value"));
}
if ("直接辐照度".equals(pointName)) {
pvStationDataVO.setDirectIrradiance(jsonObject.getDouble("value"));
}
if ("总辐照度".equals(pointName)) {
pvStationDataVO.setTotalIrradiance(jsonObject.getDouble("value"));
}
if ("散射辐照度".equals(pointName)) {
pvStationDataVO.setScatterIrradiance(jsonObject.getDouble("value"));
}
if ("日发电量".equals(pointName)) {
pvStationDataVO.setGenerationDaily(jsonObject.getDouble("value"));
}
if ("月发电量".equals(pointName)) {
pvStationDataVO.setGenerationMonth(jsonObject.getDouble("value"));
}
if ("年发电量".equals(pointName)) {
pvStationDataVO.setGenerationYear(jsonObject.getDouble("value"));
}
if ("累计发电量".equals(pointName)) {
pvStationDataVO.setGenerationGross(jsonObject.getDouble("value"));
}
if ("利用小时数".equals(pointName)) {
pvStationDataVO.setUtilizeHours(jsonObject.getDouble("value"));
}
}
}
}
}
@Override
public void sendData(Integer accessType, NeedDataVO needDataVO, List list) {
if (CollectionUtil.isNotEmpty(list)) {
jxdzUtils.sendJXDZPostRequest("/ngnsyncjiangxiyw/accesshourdata/pvStationData", accessType, needDataVO, list);
}
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.jxdz.factory;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.Enum.JXDZAccessTypeEnum;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.Enum.JXDZCodeEnum;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.entity.PvDeviceDataEntity;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.impl.PvDeviceDataServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.utils.JXDZUtils;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.vo.NeedDataVO;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.vo.PvDeviceDataVO;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.JXDZMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@Service
public class GFDZSBJCServiceImpl implements IJXDZService {
@Autowired
JXDZUtils jxdzUtils;
@Autowired
PvDeviceDataServiceImpl pvDeviceDataService;
@Autowired
JXDZMapper jxdzMapper;
@Override
public void backupData(List list, Long dateTime) {
if (CollectionUtil.isNotEmpty(list)) {
List<PvDeviceDataEntity> pvDeviceDataEntityList = new ArrayList<>();
list.forEach(item -> {
PvDeviceDataEntity pvDeviceDataEntity = BeanUtil.copyProperties(item, PvDeviceDataEntity.class);
pvDeviceDataEntity.setDateTime(dateTime);
pvDeviceDataEntityList.add(pvDeviceDataEntity);
});
pvDeviceDataService.saveBatch(pvDeviceDataEntityList);
}
}
@Override
public List buildData(Integer accessType, Long dateTime) {
List<PvDeviceDataVO> list = new ArrayList<>();
if (JXDZAccessTypeEnum.BULU.getCode().equals(accessType)) {
List<PvDeviceDataEntity> windStationDataEntityList = pvDeviceDataService.list(new LambdaQueryWrapper<PvDeviceDataEntity>().eq(PvDeviceDataEntity::getDateTime, dateTime));
list = BeanUtil.copyToList(windStationDataEntityList, PvDeviceDataVO.class);
} else {
JSONArray zzBusinessData = getZZBusinessData();
if (CollectionUtil.isNotEmpty(zzBusinessData)) {
for (Object o : zzBusinessData) {
if (o instanceof Map) {
Map map = (Map) o;
JSONObject jsonObject = new JSONObject(map);
if (jsonObject.getString("name").contains("子阵")) {
list.add(getPvDeviceDataVO(jsonObject));
}
}
}
}
}
return list;
}
/**
* 获取光伏设备数据
* @param jsonObject
* @return
*/
private PvDeviceDataVO getPvDeviceDataVO(JSONObject jsonObject) {
PvDeviceDataVO pvDeviceDataVO = new PvDeviceDataVO();
String sequenceNbr = jsonObject.getString("sequenceNbr");
pvDeviceDataVO.setName(jsonObject.getString("name"));
pvDeviceDataVO.setCode(getPvDeviceCode(jsonObject.getString("name")));
//开始调用具体列表接口
JSONArray windDeviceJSONArray = getPvDeviceDataBySequenceNbr(sequenceNbr);
if (CollectionUtil.isNotEmpty(windDeviceJSONArray)) {
for (Object o : windDeviceJSONArray) {
if (o instanceof Map) {
Map map = (Map) o;
JSONObject result = new JSONObject(map);
String pointLocation = result.getString("pointLocation");
Boolean flag = checkPvDevice(pointLocation, jsonObject.getString("name"));
if (flag) {
String pointName = (String) map.get("pointName");
if (pointName.contains("日发电量")) {
pvDeviceDataVO.setGenerationDaily(result.getDouble("value"));
}
if (pointName.contains("月发电量")) {
pvDeviceDataVO.setGenerationMonth(result.getDouble("value"));
}
if (pointName.contains("年发电量")) {
pvDeviceDataVO.setGenerationYear(result.getDouble("value"));
}
if (pointName.contains("总发电量")) {
pvDeviceDataVO.setGenerationGross(result.getDouble("value"));
}
}
}
}
}
return pvDeviceDataVO;
}
/**
* 校验路径是否是子阵的 路径倒数第三位为子阵
* @param pointLocation
* @param name
* @return
*/
private Boolean checkPvDevice(String pointLocation, String name) {
if (!StrUtil.isEmpty(pointLocation)) {
String[] split = pointLocation.split("/");
if (!Objects.isNull(split)) {
String zdName = split[split.length - 3];
if (zdName.equals(name)) {
return true;
}
}
}
return false;
}
/**
* 获取光伏设备数据根据主键
* @param sequenceNbr
* @return
*/
private JSONArray getPvDeviceDataBySequenceNbr(String sequenceNbr) {
JSONObject jsonObject = jxdzUtils.sendCoreGetRequest("/core/datastorage/gateway/point/list?groupId=" + sequenceNbr + "&dataType=accumulator");
if (!Objects.isNull(jsonObject)) {
if (jsonObject.getInteger("status") == HttpStatus.OK.value()) {
return jsonObject.getJSONArray("result");
}
}
return new JSONArray();
}
/**
* 获取光伏设备Code
* @param name
* @return
*/
private String getPvDeviceCode(String name) {
String replaceString = name.replace("子阵", "");
Integer value = Integer.valueOf(replaceString);
String field = "%#" + value + "光伏阵区系统%";
String replaceField = "%#" + replaceString + "光伏阵区系统%";
return jxdzMapper.getDeviceCode(JXDZCodeEnum.GF.getCode(), field, replaceField);
}
private JSONArray getZZBusinessData() {
JSONObject jsonObject = jxdzUtils.sendCoreGetRequest("/core/front-gateway-device/tree?gatewayId=1762633785632919553");
if (!Objects.isNull(jsonObject)) {
if (jsonObject.getInteger("status") == HttpStatus.OK.value()) {
JSONArray result = jsonObject.getJSONArray("result");
if (CollectionUtil.isNotEmpty(result)) {
JSONObject firstObject = result.getJSONObject(0).getJSONArray("children").getJSONObject(0);
if (!Objects.isNull(firstObject)) {
JSONArray children = firstObject.getJSONArray("children");
if (CollectionUtil.isNotEmpty(children)) {
for (Object child : children) {
if (child instanceof Map) {
Map map = (Map) child;
JSONObject childJSON = new JSONObject(map);
if ("装置测点".equals(childJSON.getString("name"))) {
return childJSON.getJSONArray("children");
}
}
}
}
}
}
}
}
return new JSONArray();
}
@Override
public void sendData(Integer accessType, NeedDataVO needDataVO, List list) {
if(CollectionUtil.isNotEmpty(list)){
jxdzUtils.sendJXDZPostRequest("/ngnsyncjiangxiyw/accesshourdata/pvDeviceData", accessType, needDataVO, list);
}
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.jxdz.factory;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.vo.NeedDataVO;
import java.util.List;
public interface IJXDZService {
/**
* 备份数据
* @param list
* @param dateTime
*/
void backupData(List list, Long dateTime);
/**
* 构建数据
* @param accessType
* @param dateTime
* @return
*/
List buildData(Integer accessType, Long dateTime);
/**
* 发送数据
* @param accessType
* @param needDataVO
* @param list
*/
void sendData(Integer accessType, NeedDataVO needDataVO, List list);
}
package com.yeejoin.amos.boot.module.jxiop.biz.jxdz.factory;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.Enum.JXDZAccessTypeEnum;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.Enum.JXDZDataTypeEnum;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.utils.JXDZUtils;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.vo.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.List;
import java.util.Map;
@Component
@Slf4j
public class JXDZExecute {
@Autowired
JXDZUtils jxdzUtils;
@Autowired
JXDZFactory jxdzFactory;
@Value("${scheduledEnable:false}")
private Boolean scheduledEnable;
@Scheduled(cron = "0 0 */1 * * ?")
public void hourInterface() {
if (!scheduledEnable) {
return;
}
log.info("开始执行小时任务");
//发送请求传入的参数
NeedDataVO needDataVO = new NeedDataVO();
needDataVO.setPlatformId(Long.valueOf(1360001));
needDataVO.setDateTime(LocalDateTime.now().withMinute(0).withSecond(0).withNano(0).atZone(ZoneOffset.systemDefault()).toInstant().toEpochMilli());
//构建数据
IJXDZService fdzjcService = jxdzFactory.getJXDZService(JXDZDataTypeEnum.FDZJC);
IJXDZService gfdzjcService = jxdzFactory.getJXDZService(JXDZDataTypeEnum.GFDZJC);
IJXDZService fdzsbjcService = jxdzFactory.getJXDZService(JXDZDataTypeEnum.FDZSBJC);
IJXDZService gfdzsbjcService = jxdzFactory.getJXDZService(JXDZDataTypeEnum.GFDZSBJC);
List<WindStationDataVO> windStationDataVOList = fdzjcService.buildData(JXDZAccessTypeEnum.CAIJI.getCode(), needDataVO.getDateTime());
List<PvStationDataVO> pvStationDataVOList = gfdzjcService.buildData(JXDZAccessTypeEnum.CAIJI.getCode(), needDataVO.getDateTime());
List<WindDeviceDataVO> windDeviceDataVOList = fdzsbjcService.buildData(JXDZAccessTypeEnum.CAIJI.getCode(), needDataVO.getDateTime());
List<PvDeviceDataVO> pvDeviceDataVOList = gfdzsbjcService.buildData(JXDZAccessTypeEnum.CAIJI.getCode(), needDataVO.getDateTime());
//备份数据
fdzjcService.backupData(windStationDataVOList, needDataVO.getDateTime());
gfdzjcService.backupData(pvStationDataVOList, needDataVO.getDateTime());
fdzsbjcService.backupData(windDeviceDataVOList, needDataVO.getDateTime());
gfdzsbjcService.backupData(pvDeviceDataVOList, needDataVO.getDateTime());
//发送请求
fdzjcService.sendData(JXDZAccessTypeEnum.CAIJI.getCode(), needDataVO, windStationDataVOList);
gfdzjcService.sendData(JXDZAccessTypeEnum.CAIJI.getCode(), needDataVO, pvStationDataVOList);
fdzsbjcService.sendData(JXDZAccessTypeEnum.CAIJI.getCode(), needDataVO, windDeviceDataVOList);
gfdzsbjcService.sendData(JXDZAccessTypeEnum.CAIJI.getCode(), needDataVO, pvDeviceDataVOList);
log.info("小时任务执行成功");
}
@Scheduled(cron = "0 0 1 * * ?")
public void dayInterface() {
if (!scheduledEnable) {
return;
}
log.info("开始执行天任务");
//发送请求传入的参数
NeedDataVO needDataVO = new NeedDataVO();
needDataVO.setPlatformId(Long.valueOf(1360001));
needDataVO.setDateTime(LocalDateTime.now().withHour(0).withMinute(0).withSecond(0).withNano(0).atZone(ZoneOffset.systemDefault()).toInstant().toEpochMilli());
//构建数据
IJXDZService dzmtsjService = jxdzFactory.getJXDZService(JXDZDataTypeEnum.DZMTSJ);
List<StationDailyDataVO> stationDailyDataVOList = dzmtsjService.buildData(JXDZAccessTypeEnum.CAIJI.getCode(), needDataVO.getDateTime());
//备份数据
dzmtsjService.backupData(stationDailyDataVOList, needDataVO.getDateTime());
//发送请求
dzmtsjService.sendData(JXDZAccessTypeEnum.CAIJI.getCode(), needDataVO, stationDailyDataVOList);
//处理补录
listNeed();
log.info("天任务执行成功");
}
/**
* 处理需要补录的数据
*/
private void listNeed() {
log.info("处理补录数据中");
JSONObject listNeedJson = jxdzUtils.sendJXDZGetRequest("/ngnsyncjiangxiyw/needreaccess/listNeed?platformId=1360001");
if (HttpStatus.OK.value() == listNeedJson.getInteger("code")) {
JSONArray data = listNeedJson.getJSONArray("data");
if (CollectionUtil.isNotEmpty(data)) {
log.info("需要补录的数据有{}条", data.size());
for (Object o : data) {
if (o instanceof Map) {
Map needData = (Map) o;
dealListNeedData(new JSONObject(needData));
}
}
} else {
log.info("没有补录的数据需要处理");
}
}
log.info("补录数据处理完成");
}
private void dealListNeedData(JSONObject needData) {
NeedDataVO needDataVO = JSONObject.parseObject(needData.toJSONString(), NeedDataVO.class);
JXDZDataTypeEnum dataTypeEnum = JXDZDataTypeEnum.getEnumByCode(needDataVO.getDataType());
IJXDZService fdzjcService = jxdzFactory.getJXDZService(JXDZDataTypeEnum.FDZJC);
IJXDZService gfdzjcService = jxdzFactory.getJXDZService(JXDZDataTypeEnum.GFDZJC);
IJXDZService fdzsbjcService = jxdzFactory.getJXDZService(JXDZDataTypeEnum.FDZSBJC);
IJXDZService gfdzsbjcService = jxdzFactory.getJXDZService(JXDZDataTypeEnum.GFDZSBJC);
IJXDZService gzmtsjService = jxdzFactory.getJXDZService(JXDZDataTypeEnum.DZMTSJ);
switch (dataTypeEnum) {
case FDZJC:
fdzjcService.sendData(JXDZAccessTypeEnum.BULU.getCode(), needDataVO, fdzjcService.buildData(JXDZAccessTypeEnum.BULU.getCode(), needDataVO.getDateTime()));
break;
case GFDZJC:
gfdzjcService.sendData(JXDZAccessTypeEnum.BULU.getCode(), needDataVO, gfdzjcService.buildData(JXDZAccessTypeEnum.BULU.getCode(), needDataVO.getDateTime()));
break;
case FDZSBJC:
fdzsbjcService.sendData(JXDZAccessTypeEnum.BULU.getCode(), needDataVO, fdzsbjcService.buildData(JXDZAccessTypeEnum.BULU.getCode(), needDataVO.getDateTime()));
break;
case GFDZSBJC:
gfdzsbjcService.sendData(JXDZAccessTypeEnum.BULU.getCode(), needDataVO, gfdzsbjcService.buildData(JXDZAccessTypeEnum.BULU.getCode(), needDataVO.getDateTime()));
break;
case DZMTSJ:
gzmtsjService.sendData(JXDZAccessTypeEnum.BULU.getCode(), needDataVO, gzmtsjService.buildData(JXDZAccessTypeEnum.BULU.getCode(), needDataVO.getDateTime()));
break;
default:
throw new BadRequest("没有找到匹配的补录数据类型");
}
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.jxdz.factory;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.Enum.JXDZDataTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
@Component
public class JXDZFactory {
@Autowired
private FDZJCServiceImpl fdzjcService;
@Autowired
private GFDZJCServiceImpl gfdzjcService;
@Autowired
private FDZSBJCServiceImpl fdzsbjcService;
@Autowired
private GFDZSBJCServiceImpl gfdzsbjcService;
@Autowired
private DZMTSJServiceImpl dzmtsjService;
public IJXDZService getJXDZService(JXDZDataTypeEnum dataType) {
switch (dataType) {
case FDZJC:
return fdzjcService;
case GFDZJC:
return gfdzjcService;
case FDZSBJC:
return fdzsbjcService;
case GFDZSBJC:
return gfdzsbjcService;
case DZMTSJ:
return dzmtsjService;
default:
throw new BadRequest("没有找到匹配的补录数据类型");
}
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.jxdz.impl;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.PvDeviceDataMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.entity.PvDeviceDataEntity;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.service.BaseService;
@Service
public class PvDeviceDataServiceImpl extends BaseService<PvDeviceDataEntity, PvDeviceDataEntity, PvDeviceDataMapper> {
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.jxiop.biz.jxdz.impl;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.PvStationDataMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.entity.PvStationDataEntity;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.service.BaseService;
@Service
public class PvStationDataServiceImpl extends BaseService<PvStationDataEntity, PvStationDataEntity, PvStationDataMapper> {
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.jxiop.biz.jxdz.impl;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationDailyDataMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.entity.StationDailyDataEntity;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.service.BaseService;
@Service
public class StationDailyDataServiceImpl extends BaseService<StationDailyDataEntity, StationDailyDataEntity, StationDailyDataMapper> {
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.jxiop.biz.jxdz.impl;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.WindDeviceDataMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.entity.WindDeviceDataEntity;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.service.BaseService;
@Service
public class WindDeviceDataServiceImpl extends BaseService<WindDeviceDataEntity, WindDeviceDataEntity, WindDeviceDataMapper> {
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.jxiop.biz.jxdz.impl;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.WindStationDataMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.entity.WindStationDataEntity;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.service.BaseService;
@Service
public class WindStationDataServiceImpl extends BaseService<WindStationDataEntity, WindStationDataEntity, WindStationDataMapper> {
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.jxiop.biz.jxdz.utils;
import cn.hutool.core.codec.Base64;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jxiop.biz.jxdz.vo.NeedDataVO;
import com.yeejoin.amos.component.robot.AmosRequestContext;
import lombok.extern.slf4j.Slf4j;
import org.bouncycastle.asn1.gm.GMNamedCurves;
import org.bouncycastle.asn1.x9.X9ECParameters;
import org.bouncycastle.crypto.engines.SM2Engine;
import org.bouncycastle.crypto.params.ECDomainParameters;
import org.bouncycastle.crypto.params.ECPublicKeyParameters;
import org.bouncycastle.crypto.params.ParametersWithRandom;
import org.bouncycastle.math.ec.ECPoint;
import org.bouncycastle.util.encoders.Hex;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.*;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.nio.charset.StandardCharsets;
import java.security.SecureRandom;
import java.util.List;
import java.util.Objects;
/**
* 江西电建工具类
*/
@Component
@Slf4j
public class JXDZUtils {
@Value("${coreIp:iiet-jepcc.powerchina.cn:8088}")
String coreIp;
@Value("${jxdzIp:122.70.153.215:9003}")
String jxdzIp;
@Value("${jxdzTokenUserName:jiangxi_epc}")
String jxdzTokenUserName;
@Value("${jxdzTokenPassword:123456}")
String jxdzTokenPassword;
@Value("${jxdzPublicKey:04508e9c4df8463c784df2dde2536e792851a8f3fd0e5ff29b7bf1a5d9e3f566aa49a7a5fe7683e3dc4dc30dd7bc8773838a9e4fbcf7dfac53461c8777a6aed691}")
String publicKey;
@Autowired
RestTemplate restTemplate;
@Autowired
AmosRequestContext amosRequestContext;
public static String XZ_CODE="PWC20123608280010";
public static String GF_CODE="PPC17063608260011";
private String dataEncrypt(String obj, String publicKey) {
X9ECParameters sm2ECParameters = GMNamedCurves.getByName("sm2p256v1");
ECDomainParameters domainParameters = new ECDomainParameters(sm2ECParameters.getCurve(), sm2ECParameters.getG(),
sm2ECParameters.getN(), sm2ECParameters.getH());
ECPoint pukPoint = sm2ECParameters.getCurve()
.decodePoint(Hex.decode(publicKey));
ECPublicKeyParameters publicKeyParameters = new ECPublicKeyParameters(pukPoint, domainParameters);
SM2Engine.Mode mode = SM2Engine.Mode.C1C3C2;
SM2Engine sm2Engine = new SM2Engine(mode);
// 设置sm2为加密模式
sm2Engine.init(true, new ParametersWithRandom(publicKeyParameters, new SecureRandom()));
byte[] arrayOfBytes = null;
byte[] in = obj.getBytes(StandardCharsets.UTF_8);
try {
arrayOfBytes = sm2Engine.processBlock(in, 0, in.length);
} catch (Exception e) {
e.printStackTrace();
}
return Base64.encode(arrayOfBytes);
}
/**
* 获取token
* @return
*/
private String getToken() {
String url = "http://" + jxdzIp + "/auth/justLogin";
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
JSONObject jsonObject = new JSONObject();
jsonObject.put("username", jxdzTokenUserName);
jsonObject.put("password", jxdzTokenPassword);
HttpEntity<JSONObject> httpEntity = new HttpEntity<>(jsonObject, headers);
try {
ResponseEntity<JSONObject> result = restTemplate.postForEntity(url, httpEntity, JSONObject.class);
if (HttpStatus.OK == result.getStatusCode()) {
JSONObject body = result.getBody();
if (HttpStatus.OK.value() == body.getInteger("code")) {
JSONObject data = body.getJSONObject("data");
return data.getString("access_token");
} else {
throw new BadRequest("获取token失败,失败原因[" + body + "]");
}
} else {
throw new BadRequest("获取token失败,失败原因[" + result + "]");
}
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new BadRequest("获取token失败,失败原因[" + e.getMessage() + "]");
}
}
/**
* 发送GET请求
* @param url
* @return
*/
public JSONObject sendCoreGetRequest(String url) {
String reqUrl = "http://" + coreIp + url;
HttpHeaders headers = new HttpHeaders();
headers.set("Token", amosRequestContext.getToken());
headers.set("Product", amosRequestContext.getProduct());
headers.set("Appkey", amosRequestContext.getAppKey());
HttpEntity entity = new HttpEntity<>(headers);
log.info("发送GET请求,请求地址{}", reqUrl);
try {
ResponseEntity<JSONObject> response = restTemplate.exchange(reqUrl, HttpMethod.GET, entity, JSONObject.class);
if (HttpStatus.OK == response.getStatusCode()) {
log.info("发送请求成功,请求返回体{}", response.getBody());
return response.getBody();
} else {
throw new BadRequest("返回接口异常,失败原因[" + response + "]");
}
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new BadRequest("发送GET请求失败,失败原因[" + e.getMessage() + "]");
}
}
/**
* 发送GET请求
* @param url
* @return
*/
public JSONObject sendJXDZGetRequest(String url) {
String reqUrl = "http://" + jxdzIp + url;
log.info("发送GET请求,请求地址{}", reqUrl);
HttpEntity entity = new HttpEntity<>(buildHttpHeaders());
try {
ResponseEntity<JSONObject> response = restTemplate.exchange(reqUrl, HttpMethod.GET, entity, JSONObject.class);
if (HttpStatus.OK == response.getStatusCode()) {
log.info("发送请求成功,请求返回体{}", response.getBody());
return response.getBody();
} else {
throw new BadRequest("返回接口异常,失败原因[" + response + "]");
}
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new BadRequest("发送GET请求失败,失败原因[" + e.getMessage() + "]");
}
}
/**
* 发送Post请求
* @param url
* @param accessType
* @param needDataVO
* @param data
*/
public void sendJXDZPostRequest(String url, Integer accessType, NeedDataVO needDataVO, List data) {
String reqUrl = "http://" + jxdzIp + url;
log.info("发送POST请求,请求地址{}", reqUrl);
HttpEntity<JSONObject> entity = new HttpEntity<>(buildBody(needDataVO.getPlatformId(), needDataVO.getDateTime(), data, accessType, needDataVO.getReaccessId()), buildHttpHeaders());
try {
ResponseEntity<JSONObject> response = restTemplate.postForEntity(reqUrl, entity, JSONObject.class);
if (HttpStatus.OK == response.getStatusCode()) {
JSONObject body = response.getBody();
if (HttpStatus.OK.value() == body.getInteger("code")) {
log.info("发送JXDZ请求成功,请求返回体{}", response.getBody());
} else {
log.info("发送JXDZ请求失败,请求返回体{}", response.getBody());
throw new BadRequest("发送JXDZ请求失败,失败原因[" + response.getBody() + "]");
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new BadRequest("发送POST请求失败,失败原因[" + e.getMessage() + "]");
}
}
private HttpHeaders buildHttpHeaders() {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
String authorization = "Bearer " + getToken();
headers.set("Authorization", authorization);
return headers;
}
/**
* 构建请求体
* @param platformId
* @param time
* @param data
* @param accessType
* @param reaccessId
* @return
*/
private JSONObject buildBody(Long platformId, Long time, List data, Integer accessType, Long reaccessId) {
JSONObject body = new JSONObject();
body.put("accessType", accessType);
body.put("encryptData", buildEncryptData(platformId, time, data, reaccessId));
return body;
}
/**
* 加密数据
* @param platformId
* @param time
* @param data
* @param reaccessId
* @return
*/
private String buildEncryptData(Long platformId, Long time, List data, Long reaccessId) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("platformId", platformId);
if (!Objects.isNull(reaccessId)) {
jsonObject.put("reaccessId", reaccessId);
}
jsonObject.put("time", time);
jsonObject.put("data", data);
return dataEncrypt(jsonObject.toJSONString(), publicKey);
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.jxdz.vo;
import lombok.Data;
@Data
public class NeedDataVO {
/**
* 补录数据的标识
*/
private Long reaccessId;
/**
* 子系统标识
*/
private Long platformId;
/**
* 需要补录的数据类型
*/
private Integer dataType;
/**
* 毫秒级别时间
*/
private Long dateTime;
}
package com.yeejoin.amos.boot.module.jxiop.biz.jxdz.vo;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
@Data
public class PvDeviceDataVO {
private String code;
private String name;
/**
*日发电量
*/
@JSONField(name = "GenerationDaily")
private Double GenerationDaily;
/**
*月发电量
*/
@JSONField(name = "GenerationMonth")
private Double GenerationMonth;
/**
*年发电量
*/
@JSONField(name = "GenerationYear")
private Double GenerationYear;
/**
*累计发电量
*/
@JSONField(name = "GenerationGross")
private Double GenerationGross;
}
package com.yeejoin.amos.boot.module.jxiop.biz.jxdz.vo;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
@Data
public class PvStationDataVO {
private String code;
private String name;
/**
*发电功率
*/
@JSONField(name = "GenerationPower")
private Double GenerationPower;
/**
*总辐射
*/
@JSONField(name = "TotalRadiation")
private Double TotalRadiation;
/**
*直接辐射
*/
@JSONField(name = "DirectRadiation")
private Double DirectRadiation;
/**
*散射辐射
*/
@JSONField(name = "ScatterRadiation")
private Double ScatterRadiation;
/**
*日发电量
*/
@JSONField(name = "GenerationDaily")
private Double GenerationDaily;
/**
*月发电量
*/
@JSONField(name = "GenerationMonth")
private Double GenerationMonth;
/**
*年发电量
*/
@JSONField(name = "GenerationYear")
private Double GenerationYear;
/**
*累计发电量
*/
@JSONField(name = "GenerationGross")
private Double GenerationGross;
/**
*利用小时数
*/
@JSONField(name = "UtilizeHours")
private Double UtilizeHours;
/**
*损失电量
*/
@JSONField(name = "LossElectricity")
private Double LossElectricity;
/**
*总辐照度
*/
@JSONField(name = "TotalIrradiance")
private Double TotalIrradiance;
/**
*直接辐照度
*/
@JSONField(name = "DirectIrradiance")
private Double DirectIrradiance;
/**
*散射辐照度
*/
@JSONField(name = "ScatterIrradiance")
private Double ScatterIrradiance;
/**
* 日上网电量
*/
@JSONField(name = "OnGridEnergyDaily")
private Double OnGridEnergyDaily;
/**
* 月上网电量
*/
@JSONField(name = "OnGridEnergyMonth")
private Double OnGridEnergyMonth;
/**
* 年上网电量
*/
@JSONField(name = "OnGridEnergyYear")
private Double OnGridEnergyYear;
/**
* 累计上网电量
*/
@JSONField(name = "OnGridEnergyGross")
private Double OnGridEnergyGross;
}
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