Commit 813d0df3 authored by 朱晨阳's avatar 朱晨阳

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

parents 1f189d7f 554a1b0c
...@@ -147,7 +147,12 @@ public class ImasterUtils { ...@@ -147,7 +147,12 @@ public class ImasterUtils {
} else { } else {
jsonArray = handlerResponseByResultResolveruleOther(ResultResolveRule, respone); jsonArray = handlerResponseByResultResolveruleOther(ResultResolveRule, respone);
if (!ObjectUtils.isEmpty(jsonArray)) { if (!ObjectUtils.isEmpty(jsonArray)) {
try {
result = JSONArray.parseArray(jsonArray.toJSONString(), tClass); result = JSONArray.parseArray(jsonArray.toJSONString(), tClass);
} catch (Exception e) {
e.printStackTrace();
logger.error("华为数据解析错误(getResPonseOther):" + jsonArray.toJSONString());
}
} }
} }
} else { } else {
...@@ -207,15 +212,16 @@ public class ImasterUtils { ...@@ -207,15 +212,16 @@ public class ImasterUtils {
JSONObject jsonObject = JSONObject.parseObject(response); JSONObject jsonObject = JSONObject.parseObject(response);
JSONArray jsonArray = new JSONArray(); JSONArray jsonArray = new JSONArray();
JSONArray jsonArrayRet = new JSONArray(); JSONArray jsonArrayRet = new JSONArray();
if (ObjectUtil.isNotEmpty(resultResovle)) { if (ObjectUtil.isNotEmpty(resultResovle)&&ObjectUtil.isNotEmpty(jsonObject)) {
String[] rules = resultResovle.split(","); String[] rules = resultResovle.split(",");
if (rules.length > 0) { if (rules.length > 0) {
for (int i = 0; i < rules.length; i++) { for (int i = 0; i < rules.length; i++) {
if ("ACCESS_FREQUENCY_IS_TOO_HIGH".equals(jsonObject.get(rules[i]))) {
logger.error("华为数据解析错误(handlerResponseByResultResolveruleOther):请求系统次数太频繁,无法获取接口数据");
continue;
}
try { try {
jsonObject = (JSONObject) jsonObject.get(rules[i]); jsonObject = (JSONObject) jsonObject.get(rules[i]);
if (jsonObject == null) {
jsonArray = (JSONArray) jsonObject.get(rules[i]);
}
} catch (Exception exception) { } catch (Exception exception) {
try { try {
jsonArray = (JSONArray) jsonObject.get(rules[i]); jsonArray = (JSONArray) jsonObject.get(rules[i]);
......
...@@ -116,7 +116,14 @@ public class SunlightUtil { ...@@ -116,7 +116,14 @@ public class SunlightUtil {
{ {
put("1", "在线"); put("1", "在线");
put("0", "离线"); put("0", "离线");
put("2","报警" ); }
};
public static final HashMap<String, String> gzzt= new HashMap<String, String>() {
{
put("1", "故障");
put("2", "报警");
put("4", "正常" );
} }
}; };
......
...@@ -19,7 +19,7 @@ public class ImasterInverterListDetails { ...@@ -19,7 +19,7 @@ public class ImasterInverterListDetails {
Double mppt_total_cap ; Double mppt_total_cap ;
Double pv24_i ; Double pv24_i ;
Double pv8_u ; Double pv8_u ;
Double open_time ; String open_time ;
Double pv22_u ; Double pv22_u ;
Double a_i ; Double a_i ;
Double pv24_u ; Double pv24_u ;
...@@ -43,7 +43,7 @@ public class ImasterInverterListDetails { ...@@ -43,7 +43,7 @@ public class ImasterInverterListDetails {
Double mppt_power ; Double mppt_power ;
Double pv13_u ; Double pv13_u ;
int run_state ; int run_state ;
Double close_time ; String close_time ;
Double pv19_i ; Double pv19_i ;
Double mppt_7_cap ; Double mppt_7_cap ;
Double mppt_5_cap ; Double mppt_5_cap ;
......
...@@ -46,13 +46,14 @@ import java.util.concurrent.TimeUnit; ...@@ -46,13 +46,14 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
/** /**
* @author DELL * @author DELL
*/ */
@Service @Service
public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionService { public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionService {
@Autowired @Autowired
KsolarRequestUtil kSolarRequestUtil; KsolarRequestUtil kSolarRequestUtil;
...@@ -94,7 +95,7 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -94,7 +95,7 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
@Autowired @Autowired
private JpInverterMapper jpInverterMapper; private JpInverterMapper jpInverterMapper;
//监盘逆变器电量mapper // 监盘逆变器电量mapper
@Autowired @Autowired
private JpInverterElectricityMapper jpInverterElectricityMapper; private JpInverterElectricityMapper jpInverterElectricityMapper;
@Autowired @Autowired
...@@ -126,12 +127,8 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -126,12 +127,8 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
logger.info("-------科士达同步场站开始" + ts + "------- " + sdf.format(new Date())); logger.info("-------科士达同步场站开始" + ts + "------- " + sdf.format(new Date()));
HashMap<String, Object> requestInfo = new HashMap<>(); HashMap<String, Object> requestInfo = new HashMap<>();
String requestParaminfo = JSON.toJSONString(requestInfo); String requestParaminfo = JSON.toJSONString(requestInfo);
List<KsolarStationList> kSolarStationListList = kSolarRequestUtil.getResPonse( List<KsolarStationList> kSolarStationListList = kSolarRequestUtil.getResPonse(KSolarConstant.stationListUrl,
KSolarConstant.stationListUrl, KSolarConstant.requestGET, requestParaminfo, KSolarConstant.resovle_rows, KsolarStationList.class);
KSolarConstant.requestGET,
requestParaminfo,
KSolarConstant.resovle_rows,
KsolarStationList.class);
for (KsolarStationList kSolarStation : kSolarStationListList) { for (KsolarStationList kSolarStation : kSolarStationListList) {
kSolarStation.setCreatedTime(System.currentTimeMillis()); kSolarStation.setCreatedTime(System.currentTimeMillis());
kSolarStationMapper.insert(kSolarStation); kSolarStationMapper.insert(kSolarStation);
...@@ -165,11 +162,8 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -165,11 +162,8 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
String requestParaminfo = JSON.toJSONString(requestInfo); String requestParaminfo = JSON.toJSONString(requestInfo);
String url = KSolarConstant.stationInfoByIdUrl + "?stationId=" + ksolarStation.getStationId(); String url = KSolarConstant.stationInfoByIdUrl + "?stationId=" + ksolarStation.getStationId();
// 获取电站详情 // 获取电站详情
List<KsolarStationDetails> ksolarStationDetailsList = kSolarRequestUtil.getResPonse( List<KsolarStationDetails> ksolarStationDetailsList = kSolarRequestUtil.getResPonse(url,
url, KSolarConstant.requestPOST, requestParaminfo, KSolarConstant.resovle_data,
KSolarConstant.requestPOST,
requestParaminfo,
KSolarConstant.resovle_data,
KsolarStationDetails.class); KsolarStationDetails.class);
// 获取单个电站的发电量和收益 // 获取单个电站的发电量和收益
KsolarStationEarn stationEarn = getStationEarn(ksolarStation.getStationId()); KsolarStationEarn stationEarn = getStationEarn(ksolarStation.getStationId());
...@@ -183,9 +177,9 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -183,9 +177,9 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
for (KsolarStationDetails ksolarStationDetail : ksolarStationDetailsList) { for (KsolarStationDetails ksolarStationDetail : ksolarStationDetailsList) {
ksolarStationDetail.setCreatedTime(System.currentTimeMillis()); ksolarStationDetail.setCreatedTime(System.currentTimeMillis());
JpStation jpStation = jpStationMapper.selectOne(new QueryWrapper<JpStation>(). JpStation jpStation = jpStationMapper.selectOne(
eq("third_code", PVProducerInfoEnum.KSOLAR.getCode()). new QueryWrapper<JpStation>().eq("third_code", PVProducerInfoEnum.KSOLAR.getCode())
eq("third_station_id", ksolarStation.getStationId())); .eq("third_station_id", ksolarStation.getStationId()));
// 给户用光伏存储的数据赋值 // 给户用光伏存储的数据赋值
if (ObjectUtils.isEmpty(jpStation)) { if (ObjectUtils.isEmpty(jpStation)) {
jpStation = new JpStation(); jpStation = new JpStation();
...@@ -196,14 +190,15 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -196,14 +190,15 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
jpStation.setPrice(ksolarStationDetail.getElecPrice()); jpStation.setPrice(ksolarStationDetail.getElecPrice());
jpStation.setAddress(ksolarStationDetail.getStationAddressDetail()); jpStation.setAddress(ksolarStationDetail.getStationAddressDetail());
jpStation.setLongitude(ksolarStationDetail.getLongitude()); jpStation.setLongitude(ksolarStationDetail.getLongitude());
jpStation.setOnGridType("自发自用");//客户确认 jpStation.setOnGridType("自发自用");// 客户确认
jpStation.setRatedPower(4360.4);//客户确认 jpStation.setRatedPower(4360.4);// 客户确认
jpStation.setLatitude(ksolarStationDetail.getLatitude()); jpStation.setLatitude(ksolarStationDetail.getLatitude());
jpStation.setThirdCode(PVProducerInfoEnum.KSOLAR.getCode()); jpStation.setThirdCode(PVProducerInfoEnum.KSOLAR.getCode());
// 业主姓名 // 业主姓名
jpStation.setUserName(ksolarStation.getUserName()); jpStation.setUserName(ksolarStation.getUserName());
jpStation.setState(KSolarConstant.collectStaus.get(String.valueOf(ksolarStation.getStatus()))); jpStation.setState(KSolarConstant.collectStaus.get(String.valueOf(ksolarStation.getStatus())));
jpStation.setRealTimePower(ksolarStation.getPowerInter() != null ? ksolarStation.getPowerInter() / 1000 : 0.0); jpStation.setRealTimePower(
ksolarStation.getPowerInter() != null ? ksolarStation.getPowerInter() / 1000 : 0.0);
jpStation.setDayGenerate(ksolarStation.getDayGeneration()); jpStation.setDayGenerate(ksolarStation.getDayGeneration());
jpStation.setAccumulatedPower(ksolarStation.getTotalGeneration()); jpStation.setAccumulatedPower(ksolarStation.getTotalGeneration());
...@@ -243,7 +238,8 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -243,7 +238,8 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
// 业主电话 // 业主电话
// jpStation.setUserPhone(String.valueOf(golangStationDetail.getUsermobile())); // jpStation.setUserPhone(String.valueOf(golangStationDetail.getUsermobile()));
// 电站联系人 // 电站联系人
// jpStation.setStationContact(String.valueOf(golangStationDetail.getMobile()).toLowerCase().replace("null", "")); // jpStation.setStationContact(String.valueOf(golangStationDetail.getMobile()).toLowerCase().replace("null",
// ""));
// 组件数量 // 组件数量
// jpStation.setModuleCount(ObjectUtils.isEmpty(Math.toIntExact(golangStationDetail.getModule()))?0:Math.toIntExact(golangStationDetail.getModule())); // jpStation.setModuleCount(ObjectUtils.isEmpty(Math.toIntExact(golangStationDetail.getModule()))?0:Math.toIntExact(golangStationDetail.getModule()));
jpStation.setRecDate(new Date()); jpStation.setRecDate(new Date());
...@@ -253,10 +249,7 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -253,10 +249,7 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
jpStationMapper.insert(jpStation); jpStationMapper.insert(jpStation);
} }
// 增加td 电站区域公司,经销商绑定表
//增加td 电站区域公司,经销商绑定表
// TdJpStation tdJpStation = tdJpStationMapper.selectOne(new QueryWrapper<TdJpStation>(). // TdJpStation tdJpStation = tdJpStationMapper.selectOne(new QueryWrapper<TdJpStation>().
// eq("third_code",PVProducerInfoEnum.KSOLAR.getCode()). // eq("third_code",PVProducerInfoEnum.KSOLAR.getCode()).
// eq("third_station_id", ksolarStation.getStationId())); // eq("third_station_id", ksolarStation.getStationId()));
...@@ -285,21 +278,16 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -285,21 +278,16 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
hygfjpStationPowerHistory.setThirdCode(jpStation.getThirdCode()); hygfjpStationPowerHistory.setThirdCode(jpStation.getThirdCode());
hygfjpStationPowerHistory.setTime(System.currentTimeMillis()); hygfjpStationPowerHistory.setTime(System.currentTimeMillis());
//新加 // 新加
hygfjpStationPowerHistory.setAmosCompanyCode(jpStation.getAmosCompanyCode()); hygfjpStationPowerHistory.setAmosCompanyCode(jpStation.getAmosCompanyCode());
hygfjpStationPowerHistory.setRegionalCompaniesCode(jpStation.getRegionalCompaniesCode()); hygfjpStationPowerHistory.setRegionalCompaniesCode(jpStation.getRegionalCompaniesCode());
hygfjpStationPowerHistory.setStationName(jpStation.getName()); hygfjpStationPowerHistory.setStationName(jpStation.getName());
hygfjpStationPowerHistory.setStationState(jpStation.getState()); hygfjpStationPowerHistory.setStationState(jpStation.getState());
hygfjpStationPowerHistoryMapper.insert(hygfjpStationPowerHistory); hygfjpStationPowerHistoryMapper.insert(hygfjpStationPowerHistory);
HYGFJPDayPower hygfjpDayPower = hygfjpDayPowerMapper.selectOne( HYGFJPDayPower hygfjpDayPower = hygfjpDayPowerMapper
new QueryWrapper<HYGFJPDayPower>(). .selectOne(new QueryWrapper<HYGFJPDayPower>().eq("tation_id", ksolarStation.getStationId())
eq("tation_id", ksolarStation.getStationId()). .eq("year_month_day", today).eq("hour", hour));
eq("year_month_day", today).
eq("hour", hour)
);
if (ObjectUtils.isEmpty(hygfjpDayPower)) { if (ObjectUtils.isEmpty(hygfjpDayPower)) {
hygfjpDayPower = new HYGFJPDayPower(); hygfjpDayPower = new HYGFJPDayPower();
} }
...@@ -308,7 +296,7 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -308,7 +296,7 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
hygfjpDayPower.setYearMonthDay(today); hygfjpDayPower.setYearMonthDay(today);
hygfjpDayPower.setPower(ksolarStation.getPowerInter()); hygfjpDayPower.setPower(ksolarStation.getPowerInter());
//新加 // 新加
hygfjpDayPower.setAmosCompanyCode(jpStation.getAmosCompanyCode()); hygfjpDayPower.setAmosCompanyCode(jpStation.getAmosCompanyCode());
hygfjpDayPower.setRegionalCompaniesCode(jpStation.getRegionalCompaniesCode()); hygfjpDayPower.setRegionalCompaniesCode(jpStation.getRegionalCompaniesCode());
hygfjpDayPower.setStationName(jpStation.getName()); hygfjpDayPower.setStationName(jpStation.getName());
...@@ -324,9 +312,9 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -324,9 +312,9 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
ksolarStationDetailsMapper.insert(ksolarStationDetail); ksolarStationDetailsMapper.insert(ksolarStationDetail);
Date today1 = new Date(); Date today1 = new Date();
//户用场站日发电量 // 户用场站日发电量
TdHYGFStationDayGenerate tdHYGFStationDayGenerate = tdHYGFStationDayGenerateMapper.selectOne(new QueryWrapper<TdHYGFStationDayGenerate>() TdHYGFStationDayGenerate tdHYGFStationDayGenerate = tdHYGFStationDayGenerateMapper
.eq("third_station_id", stationId) .selectOne(new QueryWrapper<TdHYGFStationDayGenerate>().eq("third_station_id", stationId)
.eq("day_time", DateUtil.format(today1, "yyyy-MM-dd")) .eq("day_time", DateUtil.format(today1, "yyyy-MM-dd"))
.eq("year_month", DateUtil.format(today1, "yyyy-MM"))); .eq("year_month", DateUtil.format(today1, "yyyy-MM")));
if (ObjectUtils.isEmpty(tdHYGFStationDayGenerate)) { if (ObjectUtils.isEmpty(tdHYGFStationDayGenerate)) {
...@@ -339,7 +327,7 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -339,7 +327,7 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
tdHYGFStationDayGenerate.setFullhour(jpStation.getDayGenerate() / jpStation.getCapacity()); tdHYGFStationDayGenerate.setFullhour(jpStation.getDayGenerate() / jpStation.getCapacity());
tdHYGFStationDayGenerate.setIncome(jpStation.getDayIncome()); tdHYGFStationDayGenerate.setIncome(jpStation.getDayIncome());
//新加 // 新加
tdHYGFStationDayGenerate.setAmosCompanyCode(jpStation.getAmosCompanyCode()); tdHYGFStationDayGenerate.setAmosCompanyCode(jpStation.getAmosCompanyCode());
tdHYGFStationDayGenerate.setRegionalCompaniesCode(jpStation.getRegionalCompaniesCode()); tdHYGFStationDayGenerate.setRegionalCompaniesCode(jpStation.getRegionalCompaniesCode());
tdHYGFStationDayGenerate.setStationName(jpStation.getName()); tdHYGFStationDayGenerate.setStationName(jpStation.getName());
...@@ -351,9 +339,9 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -351,9 +339,9 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
} else { } else {
tdHYGFStationDayGenerateMapper.insert(tdHYGFStationDayGenerate); tdHYGFStationDayGenerateMapper.insert(tdHYGFStationDayGenerate);
} }
//户用场站月发电量 // 户用场站月发电量
TdHYGFStationMonthGenerate tdHYGFStationMonthGenerate = tdHYGFStationMonthGenerateMapper.selectOne(new QueryWrapper<TdHYGFStationMonthGenerate>() TdHYGFStationMonthGenerate tdHYGFStationMonthGenerate = tdHYGFStationMonthGenerateMapper
.eq("third_station_id", stationId) .selectOne(new QueryWrapper<TdHYGFStationMonthGenerate>().eq("third_station_id", stationId)
.eq("month_time", DateUtil.format(today1, "yyyy-MM")) .eq("month_time", DateUtil.format(today1, "yyyy-MM"))
.eq("year", DateUtil.format(today1, "yyyy"))); .eq("year", DateUtil.format(today1, "yyyy")));
if (ObjectUtils.isEmpty(tdHYGFStationMonthGenerate)) { if (ObjectUtils.isEmpty(tdHYGFStationMonthGenerate)) {
...@@ -366,7 +354,7 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -366,7 +354,7 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
tdHYGFStationMonthGenerate.setFullhour(jpStation.getMonthGenerate() / jpStation.getCapacity()); tdHYGFStationMonthGenerate.setFullhour(jpStation.getMonthGenerate() / jpStation.getCapacity());
tdHYGFStationMonthGenerate.setIncome(jpStation.getMonthIncome()); tdHYGFStationMonthGenerate.setIncome(jpStation.getMonthIncome());
//新加 // 新加
tdHYGFStationMonthGenerate.setAmosCompanyCode(jpStation.getAmosCompanyCode()); tdHYGFStationMonthGenerate.setAmosCompanyCode(jpStation.getAmosCompanyCode());
tdHYGFStationMonthGenerate.setRegionalCompaniesCode(jpStation.getRegionalCompaniesCode()); tdHYGFStationMonthGenerate.setRegionalCompaniesCode(jpStation.getRegionalCompaniesCode());
tdHYGFStationMonthGenerate.setStationName(jpStation.getName()); tdHYGFStationMonthGenerate.setStationName(jpStation.getName());
...@@ -378,9 +366,9 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -378,9 +366,9 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
} else { } else {
tdHYGFStationMonthGenerateMapper.insert(tdHYGFStationMonthGenerate); tdHYGFStationMonthGenerateMapper.insert(tdHYGFStationMonthGenerate);
} }
//户用场站年发电量 // 户用场站年发电量
TdHYGFStationYearGenerate tdHYGFStationYearGenerate = tdHYGFStationYearGenerateMapper.selectOne(new QueryWrapper<TdHYGFStationYearGenerate>() TdHYGFStationYearGenerate tdHYGFStationYearGenerate = tdHYGFStationYearGenerateMapper
.eq("third_station_id", stationId) .selectOne(new QueryWrapper<TdHYGFStationYearGenerate>().eq("third_station_id", stationId)
.eq("year_time", DateUtil.format(today1, "yyyy")) .eq("year_time", DateUtil.format(today1, "yyyy"))
.eq("year", DateUtil.format(today1, "yyyy"))); .eq("year", DateUtil.format(today1, "yyyy")));
if (ObjectUtils.isEmpty(tdHYGFStationYearGenerate)) { if (ObjectUtils.isEmpty(tdHYGFStationYearGenerate)) {
...@@ -392,7 +380,7 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -392,7 +380,7 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
tdHYGFStationYearGenerate.setGenerate(jpStation.getYearGenerate()); tdHYGFStationYearGenerate.setGenerate(jpStation.getYearGenerate());
tdHYGFStationYearGenerate.setFullhour(jpStation.getYearGenerate() / jpStation.getCapacity()); tdHYGFStationYearGenerate.setFullhour(jpStation.getYearGenerate() / jpStation.getCapacity());
tdHYGFStationYearGenerate.setIncome(jpStation.getYearIncome()); tdHYGFStationYearGenerate.setIncome(jpStation.getYearIncome());
//新加 // 新加
tdHYGFStationYearGenerate.setAmosCompanyCode(jpStation.getAmosCompanyCode()); tdHYGFStationYearGenerate.setAmosCompanyCode(jpStation.getAmosCompanyCode());
tdHYGFStationYearGenerate.setRegionalCompaniesCode(jpStation.getRegionalCompaniesCode()); tdHYGFStationYearGenerate.setRegionalCompaniesCode(jpStation.getRegionalCompaniesCode());
tdHYGFStationYearGenerate.setStationName(jpStation.getName()); tdHYGFStationYearGenerate.setStationName(jpStation.getName());
...@@ -427,12 +415,8 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -427,12 +415,8 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
HashMap<String, Object> requestInfo = new HashMap<>(1); HashMap<String, Object> requestInfo = new HashMap<>(1);
String requestParaminfo = JSON.toJSONString(requestInfo); String requestParaminfo = JSON.toJSONString(requestInfo);
String url = KSolarConstant.stationEarnUrl + "?stationId=" + stationId; String url = KSolarConstant.stationEarnUrl + "?stationId=" + stationId;
List<KsolarStationEarn> ksolarStationEarns = kSolarRequestUtil.getResPonse( List<KsolarStationEarn> ksolarStationEarns = kSolarRequestUtil.getResPonse(url, KSolarConstant.requestGET,
url, requestParaminfo, KSolarConstant.resovle_data, KsolarStationEarn.class);
KSolarConstant.requestGET,
requestParaminfo,
KSolarConstant.resovle_data,
KsolarStationEarn.class);
if (!CollectionUtils.isEmpty(ksolarStationEarns)) { if (!CollectionUtils.isEmpty(ksolarStationEarns)) {
ksolarStationEarn = ksolarStationEarns.get(0); ksolarStationEarn = ksolarStationEarns.get(0);
...@@ -466,16 +450,15 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -466,16 +450,15 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
attribId = "202"; attribId = "202";
stime = year; stime = year;
} }
String url = KSolarConstant.stationEarnChartUrl + "?stationId=" + stationId + "&attribId=" + attribId + "&stime=" + stime; String url = KSolarConstant.stationEarnChartUrl + "?stationId=" + stationId + "&attribId=" + attribId
List<KsolarStationEarnChart> ksolarStationEarnCharts = kSolarRequestUtil.getResPonse( + "&stime=" + stime;
url, List<KsolarStationEarnChart> ksolarStationEarnCharts = kSolarRequestUtil.getResPonse(url,
KSolarConstant.requestGET, KSolarConstant.requestGET, requestParaminfo, KSolarConstant.resovle_arr, KsolarStationEarnChart.class);
requestParaminfo,
KSolarConstant.resovle_arr,
KsolarStationEarnChart.class);
double earnValues = 0; double earnValues = 0;
if (!CollectionUtils.isEmpty(ksolarStationEarnCharts)) { if (!CollectionUtils.isEmpty(ksolarStationEarnCharts)) {
earnValues += ksolarStationEarnCharts.stream().mapToDouble(ksolarStationEarnChart -> Double.parseDouble(ksolarStationEarnChart.getEarnValue())).sum(); earnValues += ksolarStationEarnCharts.stream()
.mapToDouble(ksolarStationEarnChart -> Double.parseDouble(ksolarStationEarnChart.getEarnValue()))
.sum();
} }
if ("year".equals(type)) { if ("year".equals(type)) {
map.put("yearEarn", earnValues); map.put("yearEarn", earnValues);
...@@ -506,24 +489,20 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -506,24 +489,20 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
} }
HashMap<String, Object> requestInfo = new HashMap<>(1); HashMap<String, Object> requestInfo = new HashMap<>(1);
String requestParaminfo = JSON.toJSONString(requestInfo); String requestParaminfo = JSON.toJSONString(requestInfo);
String url = KSolarConstant.stationCollectListUrl + "?stationId=" + ksolarStationList.getStationId() + "&pageNumber=1&pageSize=200"; String url = KSolarConstant.stationCollectListUrl + "?stationId=" + ksolarStationList.getStationId()
List<KsolarStationCollectList> result = kSolarRequestUtil.getResPonse( + "&pageNumber=1&pageSize=200";
url, List<KsolarStationCollectList> result = kSolarRequestUtil.getResPonse(url, KSolarConstant.requestGET,
KSolarConstant.requestGET, requestParaminfo, KSolarConstant.resovle_rows, KsolarStationCollectList.class);
requestParaminfo,
KSolarConstant.resovle_rows,
KsolarStationCollectList.class
);
for (KsolarStationCollectList ksolarStationCollectList : result) { for (KsolarStationCollectList ksolarStationCollectList : result) {
ksolarStationCollectList.setCreatedTime(System.currentTimeMillis()); ksolarStationCollectList.setCreatedTime(System.currentTimeMillis());
ksolarStationCollectList.setThirdStationId(ksolarStationList.getStationId()); ksolarStationCollectList.setThirdStationId(ksolarStationList.getStationId());
ksolarStationCollectListMapper.insert(ksolarStationCollectList); ksolarStationCollectListMapper.insert(ksolarStationCollectList);
JpCollector jpCollector = jpCollectorMapper.selectOne(new QueryWrapper<JpCollector>(). JpCollector jpCollector = jpCollectorMapper.selectOne(new QueryWrapper<JpCollector>()
eq("third_station_id", ksolarStationCollectList.getThirdStationId()). .eq("third_station_id", ksolarStationCollectList.getThirdStationId())
eq("sn_code", ksolarStationCollectList.getCollectId().trim()). .eq("sn_code", ksolarStationCollectList.getCollectId().trim())
eq("third_code", PVProducerInfoEnum.KSOLAR.getCode())); .eq("third_code", PVProducerInfoEnum.KSOLAR.getCode()));
if (ObjectUtils.isEmpty(jpCollector)) { if (ObjectUtils.isEmpty(jpCollector)) {
jpCollector = new JpCollector(); jpCollector = new JpCollector();
} }
...@@ -546,14 +525,14 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -546,14 +525,14 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
jpCollector.setThirdStationId(ksolarStationCollectList.getThirdStationId()); jpCollector.setThirdStationId(ksolarStationCollectList.getThirdStationId());
// 第三方厂商标识 // 第三方厂商标识
jpCollector.setThirdCode(PVProducerInfoEnum.KSOLAR.getCode()); jpCollector.setThirdCode(PVProducerInfoEnum.KSOLAR.getCode());
//第三方厂商标识 // 第三方厂商标识
jpCollector.setState(KSolarConstant.collectStaus.get(ksolarStationCollectList.getStatus())); jpCollector.setState(KSolarConstant.collectStaus.get(ksolarStationCollectList.getStatus()));
jpCollector.setStationName(ksolarStationCollectList.getStationName()); jpCollector.setStationName(ksolarStationCollectList.getStationName());
jpCollector.setAddr(ksolarStationCollectList.getAddress()); jpCollector.setAddr(ksolarStationCollectList.getAddress());
jpCollector.setName(ksolarStationCollectList.getCollectName()); jpCollector.setName(ksolarStationCollectList.getCollectName());
jpCollector.setVersion(ksolarStationCollectList.getCollectVersion()); jpCollector.setVersion(ksolarStationCollectList.getCollectVersion());
jpCollector.setType(ksolarStationCollectList.getDeviceModel()); jpCollector.setType(ksolarStationCollectList.getDeviceModel());
//信号强度 // 信号强度
jpCollector.setSignalStrength(String.valueOf(ksolarStationCollectList.getSignal())); jpCollector.setSignalStrength(String.valueOf(ksolarStationCollectList.getSignal()));
jpCollector.setRecDate(new Date()); jpCollector.setRecDate(new Date());
if (ObjectUtils.isEmpty(jpCollector.getSequenceNbr())) { if (ObjectUtils.isEmpty(jpCollector.getSequenceNbr())) {
...@@ -572,24 +551,26 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -572,24 +551,26 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
} }
} }
} }
logger.info("-------科士达同步采集器开始" + ts + "------- " + sdf.format(new Date())); logger.info("-------科士达同步采集器结束" + ts + "------- " + sdf.format(new Date()));
} }
@Scheduled(cron = "${dataRequstScheduled.keshida}") @Scheduled(cron = "${dataRequstScheduled.keshida}")
@Override @Override
@Async @Async
@PostConstruct
public void collectorDetail() { public void collectorDetail() {
long ts = System.currentTimeMillis(); long ts = System.currentTimeMillis();
logger.info("-------科士达同步采集器详情/逆变器开始" + ts + "------- " + sdf.format(new Date())); logger.info("-------科士达同步采集器详情/逆变器开始" + ts + "------- " + sdf.format(new Date()));
List<JpCollector> jpCollectorlist = jpCollectorMapper.selectList(new QueryWrapper<JpCollector>(). List<JpCollector> jpCollectorlist = jpCollectorMapper
eq("third_code", PVProducerInfoEnum.KSOLAR.getCode())); .selectList(new QueryWrapper<JpCollector>().eq("third_code", PVProducerInfoEnum.KSOLAR.getCode()));
List<String> collectIds = ksolarStationCollectListMapper.getCollectIds(); List<String> collectIds = ksolarStationCollectListMapper.getCollectIds();
if (!CollectionUtils.isEmpty(collectIds)) { if (!CollectionUtils.isEmpty(collectIds)) {
collectIds.forEach(collectId -> { collectIds.forEach(collectId -> {
LambdaQueryWrapper<KsolarStationCollectList> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<KsolarStationCollectList> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(KsolarStationCollectList::getCollectId, collectId); wrapper.eq(KsolarStationCollectList::getCollectId, collectId);
wrapper.orderByDesc(KsolarStationCollectList::getCreatedTime); wrapper.orderByDesc(KsolarStationCollectList::getCreatedTime);
List<KsolarStationCollectList> ksolarStationCollectLists = ksolarStationCollectListMapper.selectList(wrapper); List<KsolarStationCollectList> ksolarStationCollectLists = ksolarStationCollectListMapper
.selectList(wrapper);
if (!CollectionUtils.isEmpty(ksolarStationCollectLists)) { if (!CollectionUtils.isEmpty(ksolarStationCollectLists)) {
KsolarStationCollectList ksolarStationCollectList = ksolarStationCollectLists.get(0); KsolarStationCollectList ksolarStationCollectList = ksolarStationCollectLists.get(0);
try { try {
...@@ -600,31 +581,29 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -600,31 +581,29 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
HashMap<String, Object> requestInfo = new HashMap<>(1); HashMap<String, Object> requestInfo = new HashMap<>(1);
String requestParaminfo = JSON.toJSONString(requestInfo); String requestParaminfo = JSON.toJSONString(requestInfo);
String url = KSolarConstant.stationCollectDataUrl + "?collectId=" + collectId; String url = KSolarConstant.stationCollectDataUrl + "?collectId=" + collectId;
List<KsolarStationCollectData> result = kSolarRequestUtil.getResPonse( List<KsolarStationCollectData> result = kSolarRequestUtil.getResPonse(url,
url, KSolarConstant.requestGET, requestParaminfo, KSolarConstant.resovle_data,
KSolarConstant.requestGET, KsolarStationCollectData.class);
requestParaminfo,
KSolarConstant.resovle_data,
KsolarStationCollectData.class
);
if (jpCollectorlist != null && jpCollectorlist.size() > 0) { if (jpCollectorlist != null && jpCollectorlist.size() > 0) {
JpCollector jpCollectorflag = null; JpCollector jpCollectorflag = null;
for (JpCollector jpCollector : jpCollectorlist) { for (JpCollector jpCollector : jpCollectorlist) {
if (jpCollector.getSnCode().equals(ksolarStationCollectList.getCollectId().trim()) && KSolarConstant.collectStaus.get("1").equals(jpCollector.getState())) { if (jpCollector.getSnCode().equals(ksolarStationCollectList.getCollectId().trim())
&& KSolarConstant.collectStaus.get("1").equals(jpCollector.getState())) {
jpCollectorflag = jpCollector; jpCollectorflag = jpCollector;
break; break;
} }
} }
if (jpCollectorflag != null) { if (jpCollectorflag != null) {
//离线状态 // 离线状态
JpInverter jpInverter = jpInverterMapper.selectOne(new QueryWrapper<JpInverter>(). JpInverter jpInverter = jpInverterMapper.selectOne(new QueryWrapper<JpInverter>()
eq("collector_sn_code", jpCollectorflag.getSnCode().trim()) ); .eq("collector_sn_code", jpCollectorflag.getSnCode().trim()));
if (ObjectUtils.isEmpty(jpInverter)) { if (ObjectUtils.isEmpty(jpInverter)) {
jpInverter = new JpInverter(); jpInverter = new JpInverter();
} }
jpInverter.setCapacity(KSolarConstant.Capacity.get(StringUtils.lowerCase(jpCollectorflag.getName()))); jpInverter.setCapacity(
KSolarConstant.Capacity.get(StringUtils.lowerCase(jpCollectorflag.getName())));
jpInverter.setSnCode(jpInverter.getSnCode()); jpInverter.setSnCode(jpInverter.getSnCode());
jpInverter.setId(jpInverter.getId()); jpInverter.setId(jpInverter.getId());
jpInverter.setState(jpCollectorflag.getState()); jpInverter.setState(jpCollectorflag.getState());
...@@ -647,19 +626,16 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -647,19 +626,16 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
if (!ObjectUtils.isEmpty(jpInverter.getSequenceNbr())) { if (!ObjectUtils.isEmpty(jpInverter.getSequenceNbr())) {
jpInverterMapper.updateById(jpInverter); jpInverterMapper.updateById(jpInverter);
} else { } else {
if(StringUtils.isNotEmpty(jpInverter.getSnCode())){ if (StringUtils.isNotEmpty(jpInverter.getSnCode().trim())) {
jpInverterMapper.insert(jpInverter); jpInverterMapper.insert(jpInverter);
} }
} }
for (int k1 = 1; k1 < 13; k1++) { for (int k1 = 1; k1 < 13; k1++) {
JpInverterElectricity jpInverterElectricity = jpInverterElectricityMapper.selectOne(new QueryWrapper<JpInverterElectricity>(). JpInverterElectricity jpInverterElectricity = jpInverterElectricityMapper
eq("sn_code", jpInverter.getSnCode().trim()). .selectOne(new QueryWrapper<JpInverterElectricity>()
eq("type", "直流"). .eq("sn_code", jpInverter.getSnCode().trim()).eq("type", "直流")
eq("name", "PV" + k1) .eq("name", "PV" + k1));
);
if (ObjectUtils.isEmpty(jpInverterElectricity)) { if (ObjectUtils.isEmpty(jpInverterElectricity)) {
jpInverterElectricity = new JpInverterElectricity(); jpInverterElectricity = new JpInverterElectricity();
} }
...@@ -679,11 +655,10 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -679,11 +655,10 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
} }
} }
JpInverterElectricity jpInverterElectricityR = jpInverterElectricityMapper.selectOne(new QueryWrapper<JpInverterElectricity>(). JpInverterElectricity jpInverterElectricityR = jpInverterElectricityMapper
eq("sn_code", jpInverter.getSnCode().trim()). .selectOne(new QueryWrapper<JpInverterElectricity>()
eq("type", "交流"). .eq("sn_code", jpInverter.getSnCode().trim()).eq("type", "交流")
eq("name", "RS") .eq("name", "RS"));
);
if (ObjectUtils.isEmpty(jpInverterElectricityR)) { if (ObjectUtils.isEmpty(jpInverterElectricityR)) {
jpInverterElectricityR = new JpInverterElectricity(); jpInverterElectricityR = new JpInverterElectricity();
} }
...@@ -702,11 +677,10 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -702,11 +677,10 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
jpInverterElectricityMapper.updateById(jpInverterElectricityR); jpInverterElectricityMapper.updateById(jpInverterElectricityR);
} }
JpInverterElectricity jpInverterElectricityS = jpInverterElectricityMapper.selectOne(new QueryWrapper<JpInverterElectricity>(). JpInverterElectricity jpInverterElectricityS = jpInverterElectricityMapper
eq("sn_code", jpInverter.getSnCode().trim()). .selectOne(new QueryWrapper<JpInverterElectricity>()
eq("type", "交流"). .eq("sn_code", jpInverter.getSnCode().trim()).eq("type", "交流")
eq("name", "ST") .eq("name", "ST"));
);
if (ObjectUtils.isEmpty(jpInverterElectricityS)) { if (ObjectUtils.isEmpty(jpInverterElectricityS)) {
jpInverterElectricityS = new JpInverterElectricity(); jpInverterElectricityS = new JpInverterElectricity();
} }
...@@ -724,12 +698,10 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -724,12 +698,10 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
jpInverterElectricityMapper.updateById(jpInverterElectricityS); jpInverterElectricityMapper.updateById(jpInverterElectricityS);
} }
JpInverterElectricity jpInverterElectricityT = jpInverterElectricityMapper
JpInverterElectricity jpInverterElectricityT = jpInverterElectricityMapper.selectOne(new QueryWrapper<JpInverterElectricity>(). .selectOne(new QueryWrapper<JpInverterElectricity>()
eq("sn_code", jpInverter.getSnCode().trim()). .eq("sn_code", jpInverter.getSnCode().trim()).eq("type", "交流")
eq("type", "交流"). .eq("name", "TR"));
eq("name", "TR")
);
if (ObjectUtils.isEmpty(jpInverterElectricityT)) { if (ObjectUtils.isEmpty(jpInverterElectricityT)) {
jpInverterElectricityT = new JpInverterElectricity(); jpInverterElectricityT = new JpInverterElectricity();
} }
...@@ -765,8 +737,15 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -765,8 +737,15 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
// 逆变器历史 // 逆变器历史
String today = DateUtil.today(); String today = DateUtil.today();
HYGFJPInverterHistory hygfjpInverterHistory = hygfjpInverterHistoryMapper.selectOne( HYGFJPInverterHistory hygfjpInverterHistory =null;
new QueryWrapper<HYGFJPInverterHistory>().eq("sn_code", jpInverter.getSnCode().trim()).eq("date", today)); try {
hygfjpInverterHistory = hygfjpInverterHistoryMapper
.selectOne(new QueryWrapper<HYGFJPInverterHistory>()
.eq("sn_code", jpInverter.getSnCode().trim()).eq("date", today));
} catch (Exception e) {
e.printStackTrace();
logger.error("科士达逆变器日历史数据错误:"+jpInverter.getSnCode().trim()+","+today);
}
if (ObjectUtils.isEmpty(hygfjpInverterHistory)) { if (ObjectUtils.isEmpty(hygfjpInverterHistory)) {
hygfjpInverterHistory = new HYGFJPInverterHistory(); hygfjpInverterHistory = new HYGFJPInverterHistory();
} }
...@@ -785,23 +764,20 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -785,23 +764,20 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
} else { } else {
hygfjpInverterHistoryMapper.insert(hygfjpInverterHistory); hygfjpInverterHistoryMapper.insert(hygfjpInverterHistory);
} }
} else { } else {
if (!CollectionUtils.isEmpty(result)) { if (!CollectionUtils.isEmpty(result)) {
result.forEach(ksolarStationCollectData -> { result.forEach(ksolarStationCollectData -> {
List<JpInverter> jpInverterList = jpInverterMapper.selectList(new QueryWrapper<JpInverter>(). List<JpInverter> jpInverterList = jpInverterMapper
eq("third_station_id", ksolarStationCollectList.getThirdStationId()). .selectList(new QueryWrapper<JpInverter>()
eq("third_code", PVProducerInfoEnum.KSOLAR.getCode()). .eq("third_station_id",
like("sn_code", ksolarStationCollectData.getInverterId().trim()) ksolarStationCollectList.getThirdStationId())
.isNotNull("sn_code") .eq("third_code", PVProducerInfoEnum.KSOLAR.getCode())
.eq("sn_code", ksolarStationCollectData.getInverterId().trim())
.orderByDesc("update_time")); .orderByDesc("update_time"));
JpInverter jpInverter =jpInverterList.get(0); JpInverter jpInverter = new JpInverter();
if (ObjectUtils.isEmpty(jpInverter)) { if (jpInverterList.size() > 0) {
jpInverter = new JpInverter(); jpInverter = jpInverterList.get(0);
} }
// 品牌 // 品牌
// jpInverter.setBrand(inverterDetailDto.getName()); // jpInverter.setBrand(inverterDetailDto.getName());
// 国标 // 国标
...@@ -812,19 +788,24 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -812,19 +788,24 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
// jpInverter.setCapacity(); // jpInverter.setCapacity();
if (jpCollectorlist != null && jpCollectorlist.size() > 0) { if (jpCollectorlist != null && jpCollectorlist.size() > 0) {
for (JpCollector jpCollector : jpCollectorlist) { for (JpCollector jpCollector : jpCollectorlist) {
if (jpCollector.getSnCode().equals(ksolarStationCollectList.getCollectId().trim())) { if (jpCollector.getSnCode()
jpInverter.setCapacity(KSolarConstant.Capacity.get(StringUtils.lowerCase(jpCollector.getName()))); .equals(ksolarStationCollectList.getCollectId().trim())) {
jpInverter.setCapacity(KSolarConstant.Capacity
.get(StringUtils.lowerCase(jpCollector.getName())));
} }
} }
} }
jpInverter.setSnCode(ksolarStationCollectData.getInverterId().trim()); jpInverter.setSnCode(ksolarStationCollectData.getInverterId().trim());
jpInverter.setId(ksolarStationCollectData.getInverterId().trim()); jpInverter.setId(ksolarStationCollectData.getInverterId().trim());
jpInverter.setState(KSolarConstant.collectStaus.get(ksolarStationCollectData.getStatus())); jpInverter.setState(
KSolarConstant.collectStaus.get(ksolarStationCollectData.getStatus()));
jpInverter.setCollectorId(ksolarStationCollectList.getCollectId().trim()); jpInverter.setCollectorId(ksolarStationCollectList.getCollectId().trim());
jpInverter.setCollectorSnCode(ksolarStationCollectList.getCollectId().trim()); jpInverter.setCollectorSnCode(ksolarStationCollectList.getCollectId().trim());
jpInverter.setUpdateTime(new Date()); jpInverter.setUpdateTime(new Date());
jpInverter.setCurrentPower(ksolarStationCollectData.getPowerApparent() != null ? ksolarStationCollectData.getPowerApparent() / 1000 : null); jpInverter.setCurrentPower(ksolarStationCollectData.getPowerApparent() != null
? ksolarStationCollectData.getPowerApparent() / 1000
: null);
jpInverter.setDayPowerGeneration(ksolarStationCollectData.getDayGeneration()); jpInverter.setDayPowerGeneration(ksolarStationCollectData.getDayGeneration());
jpInverter.setMonthPowerGeneration(ksolarStationCollectData.getMonthGeneration()); jpInverter.setMonthPowerGeneration(ksolarStationCollectData.getMonthGeneration());
jpInverter.setYearPowerGeneration(ksolarStationCollectData.getYearGeneration()); jpInverter.setYearPowerGeneration(ksolarStationCollectData.getYearGeneration());
...@@ -839,33 +820,37 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -839,33 +820,37 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
if (!ObjectUtils.isEmpty(jpInverter.getSequenceNbr())) { if (!ObjectUtils.isEmpty(jpInverter.getSequenceNbr())) {
jpInverterMapper.updateById(jpInverter); jpInverterMapper.updateById(jpInverter);
} else { } else {
if(StringUtils.isNotEmpty(jpInverter.getSnCode())){ if (StringUtils.isNotEmpty(jpInverter.getSnCode().trim())) {
jpInverterMapper.insert(jpInverter); jpInverterMapper.insert(jpInverter);
} }
} }
String jsonString = JSON.toJSONString(ksolarStationCollectData); String jsonString = JSON.toJSONString(ksolarStationCollectData);
Map<String, Object> hanlderResult = JSON.parseObject(jsonString, Map.class); Map<String, Object> hanlderResult = JSON.parseObject(jsonString, Map.class);
for (int k1 = 1; k1 < 13; k1++) { for (int k1 = 1; k1 < 13; k1++) {
JpInverterElectricity jpInverterElectricity = jpInverterElectricityMapper.selectOne(new QueryWrapper<JpInverterElectricity>(). JpInverterElectricity jpInverterElectricity = jpInverterElectricityMapper
eq("sn_code", ksolarStationCollectData.getInverterId().trim()). .selectOne(new QueryWrapper<JpInverterElectricity>()
eq("type", "直流"). .eq("sn_code", ksolarStationCollectData.getInverterId().trim())
eq("name", "PV" + k1) .eq("type", "直流").eq("name", "PV" + k1));
);
if (ObjectUtils.isEmpty(jpInverterElectricity)) { if (ObjectUtils.isEmpty(jpInverterElectricity)) {
jpInverterElectricity = new JpInverterElectricity(); jpInverterElectricity = new JpInverterElectricity();
} }
jpInverterElectricity.setInverterId(ksolarStationCollectData.getInverterId().trim()); jpInverterElectricity
jpInverterElectricity.setSnCode(ksolarStationCollectData.getInverterId().trim()); .setInverterId(ksolarStationCollectData.getInverterId().trim());
jpInverterElectricity
.setSnCode(ksolarStationCollectData.getInverterId().trim());
jpInverterElectricity.setThirdCode(PVProducerInfoEnum.KSOLAR.getCode()); jpInverterElectricity.setThirdCode(PVProducerInfoEnum.KSOLAR.getCode());
jpInverterElectricity.setThirdStationId(ksolarStationCollectList.getThirdStationId()); jpInverterElectricity
.setThirdStationId(ksolarStationCollectList.getThirdStationId());
jpInverterElectricity.setType("直流"); jpInverterElectricity.setType("直流");
jpInverterElectricity.setName("PV" + k1); jpInverterElectricity.setName("PV" + k1);
jpInverterElectricity.setVoltage(Double.valueOf(hanlderResult.get("voltagePv" + k1).toString())); jpInverterElectricity.setVoltage(
jpInverterElectricity.setCurrent(Double.valueOf(hanlderResult.get("currentPv" + k1).toString())); Double.valueOf(hanlderResult.get("voltagePv" + k1).toString()));
jpInverterElectricity.setPower(Double.valueOf(hanlderResult.get("powerPv" + k1).toString())); jpInverterElectricity.setCurrent(
Double.valueOf(hanlderResult.get("currentPv" + k1).toString()));
jpInverterElectricity
.setPower(Double.valueOf(hanlderResult.get("powerPv" + k1).toString()));
if (ObjectUtils.isEmpty(jpInverterElectricity.getSequenceNbr())) { if (ObjectUtils.isEmpty(jpInverterElectricity.getSequenceNbr())) {
jpInverterElectricityMapper.insert(jpInverterElectricity); jpInverterElectricityMapper.insert(jpInverterElectricity);
} else { } else {
...@@ -873,18 +858,19 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -873,18 +858,19 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
} }
} }
JpInverterElectricity jpInverterElectricityR = jpInverterElectricityMapper.selectOne(new QueryWrapper<JpInverterElectricity>(). JpInverterElectricity jpInverterElectricityR = jpInverterElectricityMapper
eq("sn_code", ksolarStationCollectData.getInverterId().trim()). .selectOne(new QueryWrapper<JpInverterElectricity>()
eq("type", "交流"). .eq("sn_code", ksolarStationCollectData.getInverterId().trim())
eq("name", "RS") .eq("type", "交流").eq("name", "RS"));
);
if (ObjectUtils.isEmpty(jpInverterElectricityR)) { if (ObjectUtils.isEmpty(jpInverterElectricityR)) {
jpInverterElectricityR = new JpInverterElectricity(); jpInverterElectricityR = new JpInverterElectricity();
} }
jpInverterElectricityR.setInverterId(ksolarStationCollectData.getInverterId().trim()); jpInverterElectricityR
.setInverterId(ksolarStationCollectData.getInverterId().trim());
jpInverterElectricityR.setSnCode(ksolarStationCollectData.getInverterId().trim()); jpInverterElectricityR.setSnCode(ksolarStationCollectData.getInverterId().trim());
jpInverterElectricityR.setThirdCode(PVProducerInfoEnum.KSOLAR.getCode()); jpInverterElectricityR.setThirdCode(PVProducerInfoEnum.KSOLAR.getCode());
jpInverterElectricityR.setThirdStationId(ksolarStationCollectList.getThirdStationId()); jpInverterElectricityR
.setThirdStationId(ksolarStationCollectList.getThirdStationId());
jpInverterElectricityR.setFrequency(ksolarStationCollectData.getFrequencyRs()); jpInverterElectricityR.setFrequency(ksolarStationCollectData.getFrequencyRs());
jpInverterElectricityR.setType("交流"); jpInverterElectricityR.setType("交流");
jpInverterElectricityR.setName("RS"); jpInverterElectricityR.setName("RS");
...@@ -896,18 +882,19 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -896,18 +882,19 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
jpInverterElectricityMapper.updateById(jpInverterElectricityR); jpInverterElectricityMapper.updateById(jpInverterElectricityR);
} }
JpInverterElectricity jpInverterElectricityS = jpInverterElectricityMapper.selectOne(new QueryWrapper<JpInverterElectricity>(). JpInverterElectricity jpInverterElectricityS = jpInverterElectricityMapper
eq("sn_code", ksolarStationCollectData.getInverterId().trim()). .selectOne(new QueryWrapper<JpInverterElectricity>()
eq("type", "交流"). .eq("sn_code", ksolarStationCollectData.getInverterId().trim())
eq("name", "ST") .eq("type", "交流").eq("name", "ST"));
);
if (ObjectUtils.isEmpty(jpInverterElectricityS)) { if (ObjectUtils.isEmpty(jpInverterElectricityS)) {
jpInverterElectricityS = new JpInverterElectricity(); jpInverterElectricityS = new JpInverterElectricity();
} }
jpInverterElectricityS.setInverterId(ksolarStationCollectData.getInverterId().trim()); jpInverterElectricityS
.setInverterId(ksolarStationCollectData.getInverterId().trim());
jpInverterElectricityS.setSnCode(ksolarStationCollectData.getInverterId().trim()); jpInverterElectricityS.setSnCode(ksolarStationCollectData.getInverterId().trim());
jpInverterElectricityS.setThirdCode(PVProducerInfoEnum.KSOLAR.getCode()); jpInverterElectricityS.setThirdCode(PVProducerInfoEnum.KSOLAR.getCode());
jpInverterElectricityS.setThirdStationId(ksolarStationCollectList.getThirdStationId()); jpInverterElectricityS
.setThirdStationId(ksolarStationCollectList.getThirdStationId());
jpInverterElectricityS.setType("交流"); jpInverterElectricityS.setType("交流");
jpInverterElectricityS.setName("ST"); jpInverterElectricityS.setName("ST");
jpInverterElectricityS.setVoltage(ksolarStationCollectData.getVoltageSt()); jpInverterElectricityS.setVoltage(ksolarStationCollectData.getVoltageSt());
...@@ -918,19 +905,19 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -918,19 +905,19 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
jpInverterElectricityMapper.updateById(jpInverterElectricityS); jpInverterElectricityMapper.updateById(jpInverterElectricityS);
} }
JpInverterElectricity jpInverterElectricityT = jpInverterElectricityMapper
JpInverterElectricity jpInverterElectricityT = jpInverterElectricityMapper.selectOne(new QueryWrapper<JpInverterElectricity>(). .selectOne(new QueryWrapper<JpInverterElectricity>()
eq("sn_code", ksolarStationCollectData.getInverterId().trim()). .eq("sn_code", ksolarStationCollectData.getInverterId().trim())
eq("type", "交流"). .eq("type", "交流").eq("name", "TR"));
eq("name", "TR")
);
if (ObjectUtils.isEmpty(jpInverterElectricityT)) { if (ObjectUtils.isEmpty(jpInverterElectricityT)) {
jpInverterElectricityT = new JpInverterElectricity(); jpInverterElectricityT = new JpInverterElectricity();
} }
jpInverterElectricityT.setInverterId(ksolarStationCollectData.getInverterId().trim()); jpInverterElectricityT
.setInverterId(ksolarStationCollectData.getInverterId().trim());
jpInverterElectricityT.setSnCode(ksolarStationCollectData.getInverterId().trim()); jpInverterElectricityT.setSnCode(ksolarStationCollectData.getInverterId().trim());
jpInverterElectricityT.setThirdCode(PVProducerInfoEnum.KSOLAR.getCode()); jpInverterElectricityT.setThirdCode(PVProducerInfoEnum.KSOLAR.getCode());
jpInverterElectricityT.setThirdStationId(ksolarStationCollectList.getThirdStationId()); jpInverterElectricityT
.setThirdStationId(ksolarStationCollectList.getThirdStationId());
jpInverterElectricityT.setType("交流"); jpInverterElectricityT.setType("交流");
jpInverterElectricityT.setName("TR"); jpInverterElectricityT.setName("TR");
jpInverterElectricityT.setVoltage(ksolarStationCollectData.getVoltageTr()); jpInverterElectricityT.setVoltage(ksolarStationCollectData.getVoltageTr());
...@@ -943,9 +930,11 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -943,9 +930,11 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
// //
HYGFJPInverterElecHistory hygfjpInverterElecHistory = new HYGFJPInverterElecHistory(); HYGFJPInverterElecHistory hygfjpInverterElecHistory = new HYGFJPInverterElecHistory();
hygfjpInverterElecHistory.setThirdStationId(ksolarStationCollectList.getThirdStationId()); hygfjpInverterElecHistory
.setThirdStationId(ksolarStationCollectList.getThirdStationId());
hygfjpInverterElecHistory.setCreatedTime(System.currentTimeMillis()); hygfjpInverterElecHistory.setCreatedTime(System.currentTimeMillis());
hygfjpInverterElecHistory.setSnCode(ksolarStationCollectData.getInverterId().trim()); hygfjpInverterElecHistory
.setSnCode(ksolarStationCollectData.getInverterId().trim());
hygfjpInverterElecHistory.setUAcCurrent(ksolarStationCollectData.getCurrentR()); hygfjpInverterElecHistory.setUAcCurrent(ksolarStationCollectData.getCurrentR());
hygfjpInverterElecHistory.setVAcCurrent(ksolarStationCollectData.getCurrents()); hygfjpInverterElecHistory.setVAcCurrent(ksolarStationCollectData.getCurrents());
...@@ -959,8 +948,10 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -959,8 +948,10 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
// 逆变器历史 // 逆变器历史
String today = DateUtil.today(); String today = DateUtil.today();
HYGFJPInverterHistory hygfjpInverterHistory = hygfjpInverterHistoryMapper.selectOne( HYGFJPInverterHistory hygfjpInverterHistory = hygfjpInverterHistoryMapper
new QueryWrapper<HYGFJPInverterHistory>().eq("sn_code", ksolarStationCollectData.getInverterId()).eq("date", today)); .selectOne(new QueryWrapper<HYGFJPInverterHistory>()
.eq("sn_code", ksolarStationCollectData.getInverterId())
.eq("date", today));
if (ObjectUtils.isEmpty(hygfjpInverterHistory)) { if (ObjectUtils.isEmpty(hygfjpInverterHistory)) {
hygfjpInverterHistory = new HYGFJPInverterHistory(); hygfjpInverterHistory = new HYGFJPInverterHistory();
} }
...@@ -968,11 +959,13 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -968,11 +959,13 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
// 满发小时数 // 满发小时数
// hygfjpInverterHistory.setGenerationHours(inverterDetailDto.getFullHour()); // hygfjpInverterHistory.setGenerationHours(inverterDetailDto.getFullHour());
hygfjpInverterHistory.setDate(today); hygfjpInverterHistory.setDate(today);
hygfjpInverterHistory.setThirdStationId(ksolarStationCollectList.getThirdStationId()); hygfjpInverterHistory
.setThirdStationId(ksolarStationCollectList.getThirdStationId());
hygfjpInverterHistory.setInverterId(ksolarStationCollectData.getInverterId()); hygfjpInverterHistory.setInverterId(ksolarStationCollectData.getInverterId());
hygfjpInverterHistory.setSnCode(jpInverter.getSnCode().trim()); hygfjpInverterHistory.setSnCode(jpInverter.getSnCode().trim());
hygfjpInverterHistory.setThirdCode(PVProducerInfoEnum.KSOLAR.getCode()); hygfjpInverterHistory.setThirdCode(PVProducerInfoEnum.KSOLAR.getCode());
hygfjpInverterHistory.setPowerGeneration(ksolarStationCollectData.getTotalGeneration()); hygfjpInverterHistory
.setPowerGeneration(ksolarStationCollectData.getTotalGeneration());
if (ObjectUtils.isEmpty(hygfjpInverterHistory.getCreatedTime())) { if (ObjectUtils.isEmpty(hygfjpInverterHistory.getCreatedTime())) {
hygfjpInverterHistory.setCreatedTime(System.currentTimeMillis()); hygfjpInverterHistory.setCreatedTime(System.currentTimeMillis());
hygfjpInverterHistoryMapper.insert(hygfjpInverterHistory); hygfjpInverterHistoryMapper.insert(hygfjpInverterHistory);
...@@ -980,74 +973,89 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -980,74 +973,89 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
hygfjpInverterHistoryMapper.insert(hygfjpInverterHistory); hygfjpInverterHistoryMapper.insert(hygfjpInverterHistory);
} }
//-----------------------户用光伏日报表---------------------- // -----------------------户用光伏日报表----------------------
TdHYGFInverterDayGenerate tdHYGFInverterDayGenerate = new TdHYGFInverterDayGenerate(); TdHYGFInverterDayGenerate tdHYGFInverterDayGenerate = new TdHYGFInverterDayGenerate();
tdHYGFInverterDayGenerate.setCreatedTime(System.currentTimeMillis()); tdHYGFInverterDayGenerate.setCreatedTime(System.currentTimeMillis());
tdHYGFInverterDayGenerate.setThirdStationId(jpInverter.getThirdStationId()); tdHYGFInverterDayGenerate.setThirdStationId(jpInverter.getThirdStationId());
tdHYGFInverterDayGenerate.setSnCode(jpInverter.getSnCode()); tdHYGFInverterDayGenerate.setSnCode(jpInverter.getSnCode());
tdHYGFInverterDayGenerate.setName(jpInverter.getName()); tdHYGFInverterDayGenerate.setName(jpInverter.getName());
tdHYGFInverterDayGenerate.setWorkStatus(jpInverter.getState()); tdHYGFInverterDayGenerate.setWorkStatus(jpInverter.getState());
//交流电压 // 交流电压
tdHYGFInverterDayGenerate.setDcv1(jpInverterElectricityR.getVoltage()); tdHYGFInverterDayGenerate.setDcv1(jpInverterElectricityR.getVoltage());
tdHYGFInverterDayGenerate.setDcv2(jpInverterElectricityS.getVoltage()); tdHYGFInverterDayGenerate.setDcv2(jpInverterElectricityS.getVoltage());
tdHYGFInverterDayGenerate.setDcv3(jpInverterElectricityT.getVoltage()); tdHYGFInverterDayGenerate.setDcv3(jpInverterElectricityT.getVoltage());
//交流电流 // 交流电流
// tdHYGFInverterDayGenerate.setDcv4(inverterDetailDto.getUAc4()); // tdHYGFInverterDayGenerate.setDcv4(inverterDetailDto.getUAc4());
tdHYGFInverterDayGenerate.setDcc1(jpInverterElectricityR.getCurrent()); tdHYGFInverterDayGenerate.setDcc1(jpInverterElectricityR.getCurrent());
tdHYGFInverterDayGenerate.setDcc2(jpInverterElectricityS.getCurrent()); tdHYGFInverterDayGenerate.setDcc2(jpInverterElectricityS.getCurrent());
tdHYGFInverterDayGenerate.setDcc3(jpInverterElectricityT.getCurrent()); tdHYGFInverterDayGenerate.setDcc3(jpInverterElectricityT.getCurrent());
// tdHYGFInverterDayGenerate.setDcc4(inverterDetailDto.getIAc4()); // tdHYGFInverterDayGenerate.setDcc4(inverterDetailDto.getIAc4());
//直流电压 // 直流电压
tdHYGFInverterDayGenerate.setAcv1(Double.valueOf(hanlderResult.get("voltagePv1").toString())); tdHYGFInverterDayGenerate
tdHYGFInverterDayGenerate.setAcv2(Double.valueOf(hanlderResult.get("voltagePv2").toString())); .setAcv1(Double.valueOf(hanlderResult.get("voltagePv1").toString()));
tdHYGFInverterDayGenerate.setAcv3(Double.valueOf(hanlderResult.get("voltagePv3").toString())); tdHYGFInverterDayGenerate
tdHYGFInverterDayGenerate.setAcv4(Double.valueOf(hanlderResult.get("voltagePv4").toString())); .setAcv2(Double.valueOf(hanlderResult.get("voltagePv2").toString()));
//直流电流 tdHYGFInverterDayGenerate
tdHYGFInverterDayGenerate.setAcc1(Double.valueOf(hanlderResult.get("currentPv1").toString())); .setAcv3(Double.valueOf(hanlderResult.get("voltagePv3").toString()));
tdHYGFInverterDayGenerate.setAcc2(Double.valueOf(hanlderResult.get("currentPv2").toString())); tdHYGFInverterDayGenerate
tdHYGFInverterDayGenerate.setAcc3(Double.valueOf(hanlderResult.get("currentPv3").toString())); .setAcv4(Double.valueOf(hanlderResult.get("voltagePv4").toString()));
tdHYGFInverterDayGenerate.setAcc4(Double.valueOf(hanlderResult.get("currentPv4").toString())); // 直流电流
tdHYGFInverterDayGenerate
tdHYGFInverterDayGenerate.setPv1(Double.valueOf(hanlderResult.get("powerPv1").toString())); .setAcc1(Double.valueOf(hanlderResult.get("currentPv1").toString()));
tdHYGFInverterDayGenerate.setPv2(Double.valueOf(hanlderResult.get("powerPv2").toString())); tdHYGFInverterDayGenerate
tdHYGFInverterDayGenerate.setPv3(Double.valueOf(hanlderResult.get("powerPv3").toString())); .setAcc2(Double.valueOf(hanlderResult.get("currentPv2").toString()));
tdHYGFInverterDayGenerate.setPv4(Double.valueOf(hanlderResult.get("powerPv4").toString())); tdHYGFInverterDayGenerate
//功率 .setAcc3(Double.valueOf(hanlderResult.get("currentPv3").toString()));
tdHYGFInverterDayGenerate
.setAcc4(Double.valueOf(hanlderResult.get("currentPv4").toString()));
tdHYGFInverterDayGenerate
.setPv1(Double.valueOf(hanlderResult.get("powerPv1").toString()));
tdHYGFInverterDayGenerate
.setPv2(Double.valueOf(hanlderResult.get("powerPv2").toString()));
tdHYGFInverterDayGenerate
.setPv3(Double.valueOf(hanlderResult.get("powerPv3").toString()));
tdHYGFInverterDayGenerate
.setPv4(Double.valueOf(hanlderResult.get("powerPv4").toString()));
// 功率
tdHYGFInverterDayGenerate.setTotalPower(jpInverter.getCurrentPower()); tdHYGFInverterDayGenerate.setTotalPower(jpInverter.getCurrentPower());
// //频率 // //频率
tdHYGFInverterDayGenerate.setFrequency(String.valueOf(jpInverterElectricityR.getFrequency())); tdHYGFInverterDayGenerate
.setFrequency(String.valueOf(jpInverterElectricityR.getFrequency()));
// //功率因数 // //功率因数
tdHYGFInverterDayGenerate.setPowerFactor(1.0); tdHYGFInverterDayGenerate.setPowerFactor(1.0);
tdHYGFInverterDayGenerate.setDayGen(jpInverter.getDayPowerGeneration()); tdHYGFInverterDayGenerate.setDayGen(jpInverter.getDayPowerGeneration());
tdHYGFInverterDayGenerate.setMonthGen(jpInverter.getMonthPowerGeneration()); tdHYGFInverterDayGenerate.setMonthGen(jpInverter.getMonthPowerGeneration());
tdHYGFInverterDayGenerate.setYearGen(jpInverter.getYearPowerGeneration()); tdHYGFInverterDayGenerate.setYearGen(jpInverter.getYearPowerGeneration());
tdHYGFInverterDayGenerate.setTotalGen(jpInverter.getTotalPowerGeneration()); tdHYGFInverterDayGenerate.setTotalGen(jpInverter.getTotalPowerGeneration());
tdHYGFInverterDayGenerate.setIgbtTemp(ObjectUtils.isEmpty(jpInverter.getIgbtTemperature()) ? null : Double.valueOf(jpInverter.getIgbtTemperature())); tdHYGFInverterDayGenerate
.setIgbtTemp(ObjectUtils.isEmpty(jpInverter.getIgbtTemperature()) ? null
: Double.valueOf(jpInverter.getIgbtTemperature()));
tdHYGFInverterDayGenerate.setIncome(null); tdHYGFInverterDayGenerate.setIncome(null);
tdHYGFInverterDayGenerate.setFullhour(0.0d); tdHYGFInverterDayGenerate.setFullhour(0.0d);
tdHYGFInverterDayGenerate.setFullhour(jpInverter.getDayPowerGeneration() / jpInverter.getCapacity()); tdHYGFInverterDayGenerate
.setFullhour(jpInverter.getDayPowerGeneration() / jpInverter.getCapacity());
//电站区域经销商, // 电站区域经销商,
JpStation jpStation = jpStationMapper.selectOne(new QueryWrapper<JpStation>(). JpStation jpStation = jpStationMapper.selectOne(new QueryWrapper<JpStation>()
eq("third_code",PVProducerInfoEnum.KSOLAR.getCode()). .eq("third_code", PVProducerInfoEnum.KSOLAR.getCode())
eq("third_station_id", String.valueOf(jpInverter.getThirdStationId()))); .eq("third_station_id", String.valueOf(jpInverter.getThirdStationId())));
if(jpStation!=null){ if (jpStation != null) {
tdHYGFInverterDayGenerate.setAmosCompanyCode(jpStation.getAmosCompanyCode()); tdHYGFInverterDayGenerate.setAmosCompanyCode(jpStation.getAmosCompanyCode());
tdHYGFInverterDayGenerate.setRegionalCompaniesCode(jpStation.getRegionalCompaniesCode()); tdHYGFInverterDayGenerate
.setRegionalCompaniesCode(jpStation.getRegionalCompaniesCode());
tdHYGFInverterDayGenerate.setStationName(jpStation.getName()); tdHYGFInverterDayGenerate.setStationName(jpStation.getName());
tdHYGFInverterDayGenerate.setStationState(jpStation.getState()); tdHYGFInverterDayGenerate.setStationState(jpStation.getState());
} }
tdHYGFInverterDayGenerateMapper.insert(tdHYGFInverterDayGenerate); tdHYGFInverterDayGenerateMapper.insert(tdHYGFInverterDayGenerate);
//户用场站月发电量 // 户用场站月发电量
Date today1 = new Date(); Date today1 = new Date();
TdHYGFInverterMonthGenerate tdHYGFInverterMonthGenerate = tdHYGFInverterMonthGenerateMapper.selectOne(new QueryWrapper<TdHYGFInverterMonthGenerate>() TdHYGFInverterMonthGenerate tdHYGFInverterMonthGenerate = tdHYGFInverterMonthGenerateMapper
.selectOne(new QueryWrapper<TdHYGFInverterMonthGenerate>()
.eq("third_station_id", jpInverter.getThirdStationId()) .eq("third_station_id", jpInverter.getThirdStationId())
.eq("sn_code", jpInverter.getSnCode()) .eq("sn_code", jpInverter.getSnCode())
.eq("day_time", DateUtil.format(today1, "yyyy-MM-dd")) .eq("day_time", DateUtil.format(today1, "yyyy-MM-dd"))
...@@ -1062,11 +1070,13 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -1062,11 +1070,13 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
tdHYGFInverterMonthGenerate.setGenerate(jpInverter.getDayPowerGeneration()); tdHYGFInverterMonthGenerate.setGenerate(jpInverter.getDayPowerGeneration());
tdHYGFInverterMonthGenerate.setName(jpInverter.getName()); tdHYGFInverterMonthGenerate.setName(jpInverter.getName());
tdHYGFInverterMonthGenerate.setFullhour(jpInverter.getDayPowerGeneration() / jpInverter.getCapacity()); tdHYGFInverterMonthGenerate
//新加 .setFullhour(jpInverter.getDayPowerGeneration() / jpInverter.getCapacity());
if(jpStation!=null){ // 新加
if (jpStation != null) {
tdHYGFInverterMonthGenerate.setAmosCompanyCode(jpStation.getAmosCompanyCode()); tdHYGFInverterMonthGenerate.setAmosCompanyCode(jpStation.getAmosCompanyCode());
tdHYGFInverterMonthGenerate.setRegionalCompaniesCode(jpStation.getRegionalCompaniesCode()); tdHYGFInverterMonthGenerate
.setRegionalCompaniesCode(jpStation.getRegionalCompaniesCode());
tdHYGFInverterMonthGenerate.setStationName(jpStation.getName()); tdHYGFInverterMonthGenerate.setStationName(jpStation.getName());
tdHYGFInverterMonthGenerate.setStationState(jpStation.getState()); tdHYGFInverterMonthGenerate.setStationState(jpStation.getState());
...@@ -1078,8 +1088,9 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -1078,8 +1088,9 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
} else { } else {
tdHYGFInverterMonthGenerateMapper.insert(tdHYGFInverterMonthGenerate); tdHYGFInverterMonthGenerateMapper.insert(tdHYGFInverterMonthGenerate);
} }
//户用场站年发电量 // 户用场站年发电量
TdHYGFInverterYearGenerate tdHYGFInverterYearGenerate = tdHYGFInverterYearGenerateMapper.selectOne(new QueryWrapper<TdHYGFInverterYearGenerate>() TdHYGFInverterYearGenerate tdHYGFInverterYearGenerate = tdHYGFInverterYearGenerateMapper
.selectOne(new QueryWrapper<TdHYGFInverterYearGenerate>()
.eq("third_station_id", jpInverter.getThirdStationId()) .eq("third_station_id", jpInverter.getThirdStationId())
.eq("sn_code", jpInverter.getSnCode()) .eq("sn_code", jpInverter.getSnCode())
.eq("month_time", DateUtil.format(today1, "yyyy-MM")) .eq("month_time", DateUtil.format(today1, "yyyy-MM"))
...@@ -1094,26 +1105,28 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -1094,26 +1105,28 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
tdHYGFInverterYearGenerate.setGenerate(jpInverter.getMonthPowerGeneration()); tdHYGFInverterYearGenerate.setGenerate(jpInverter.getMonthPowerGeneration());
tdHYGFInverterYearGenerate.setName(jpInverter.getName()); tdHYGFInverterYearGenerate.setName(jpInverter.getName());
tdHYGFInverterYearGenerate.setFullhour(jpInverter.getMonthPowerGeneration() / jpInverter.getCapacity()); tdHYGFInverterYearGenerate.setFullhour(
jpInverter.getMonthPowerGeneration() / jpInverter.getCapacity());
//新加 // 新加
if(jpStation!=null){ if (jpStation != null) {
tdHYGFInverterYearGenerate.setAmosCompanyCode(jpStation.getAmosCompanyCode()); tdHYGFInverterYearGenerate.setAmosCompanyCode(jpStation.getAmosCompanyCode());
tdHYGFInverterYearGenerate.setRegionalCompaniesCode(jpStation.getRegionalCompaniesCode()); tdHYGFInverterYearGenerate
.setRegionalCompaniesCode(jpStation.getRegionalCompaniesCode());
tdHYGFInverterYearGenerate.setStationName(jpStation.getName()); tdHYGFInverterYearGenerate.setStationName(jpStation.getName());
tdHYGFInverterYearGenerate.setStationState(jpStation.getState()); tdHYGFInverterYearGenerate.setStationState(jpStation.getState());
} }
if (ObjectUtils.isEmpty(tdHYGFInverterYearGenerate.getCreatedTime())) { if (ObjectUtils.isEmpty(tdHYGFInverterYearGenerate.getCreatedTime())) {
tdHYGFInverterYearGenerate.setCreatedTime(System.currentTimeMillis()); tdHYGFInverterYearGenerate.setCreatedTime(System.currentTimeMillis());
tdHYGFInverterYearGenerateMapper.insert(tdHYGFInverterYearGenerate); tdHYGFInverterYearGenerateMapper.insert(tdHYGFInverterYearGenerate);
} else { } else {
tdHYGFInverterYearGenerateMapper.insert(tdHYGFInverterYearGenerate); tdHYGFInverterYearGenerateMapper.insert(tdHYGFInverterYearGenerate);
} }
//户用场站年发电量 // 户用场站年发电量
TdHYGFInverterTotalGenerate tdHYGFInverterTotalGenerate = tdHYGFInverterTotalGenerateMapper.selectOne(new QueryWrapper<TdHYGFInverterTotalGenerate>() TdHYGFInverterTotalGenerate tdHYGFInverterTotalGenerate = tdHYGFInverterTotalGenerateMapper
.selectOne(new QueryWrapper<TdHYGFInverterTotalGenerate>()
.eq("third_station_id", jpInverter.getThirdStationId()) .eq("third_station_id", jpInverter.getThirdStationId())
.eq("sn_code", jpInverter.getSnCode()) .eq("sn_code", jpInverter.getSnCode())
.eq("year_time", DateUtil.format(today1, "yyyy")) .eq("year_time", DateUtil.format(today1, "yyyy"))
...@@ -1128,15 +1141,17 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -1128,15 +1141,17 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
tdHYGFInverterTotalGenerate.setGenerate(jpInverter.getYearPowerGeneration()); tdHYGFInverterTotalGenerate.setGenerate(jpInverter.getYearPowerGeneration());
tdHYGFInverterTotalGenerate.setFullhour(0.0d); tdHYGFInverterTotalGenerate.setFullhour(0.0d);
tdHYGFInverterTotalGenerate.setName(jpInverter.getName()); tdHYGFInverterTotalGenerate.setName(jpInverter.getName());
//新加 // 新加
if(jpStation!=null){ if (jpStation != null) {
tdHYGFInverterTotalGenerate.setAmosCompanyCode(jpStation.getAmosCompanyCode()); tdHYGFInverterTotalGenerate.setAmosCompanyCode(jpStation.getAmosCompanyCode());
tdHYGFInverterTotalGenerate.setRegionalCompaniesCode(jpStation.getRegionalCompaniesCode()); tdHYGFInverterTotalGenerate
.setRegionalCompaniesCode(jpStation.getRegionalCompaniesCode());
tdHYGFInverterTotalGenerate.setStationName(jpStation.getName()); tdHYGFInverterTotalGenerate.setStationName(jpStation.getName());
tdHYGFInverterTotalGenerate.setStationState(jpStation.getState()); tdHYGFInverterTotalGenerate.setStationState(jpStation.getState());
} }
tdHYGFInverterTotalGenerate.setFullhour(jpInverter.getYearPowerGeneration() / jpInverter.getCapacity()); tdHYGFInverterTotalGenerate.setFullhour(
jpInverter.getYearPowerGeneration() / jpInverter.getCapacity());
if (ObjectUtils.isEmpty(tdHYGFInverterTotalGenerate.getCreatedTime())) { if (ObjectUtils.isEmpty(tdHYGFInverterTotalGenerate.getCreatedTime())) {
tdHYGFInverterTotalGenerate.setCreatedTime(System.currentTimeMillis()); tdHYGFInverterTotalGenerate.setCreatedTime(System.currentTimeMillis());
tdHYGFInverterTotalGenerateMapper.insert(tdHYGFInverterTotalGenerate); tdHYGFInverterTotalGenerateMapper.insert(tdHYGFInverterTotalGenerate);
...@@ -1146,13 +1161,10 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -1146,13 +1161,10 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
}); });
} }
} }
} }
// if (!CollectionUtils.isEmpty(result)) { // if (!CollectionUtils.isEmpty(result)) {
// result.forEach(ksolarStationCollectData -> { // result.forEach(ksolarStationCollectData -> {
// JpInverter jpInverter = jpInverterMapper.selectOne(new QueryWrapper<JpInverter>(). // JpInverter jpInverter = jpInverterMapper.selectOne(new QueryWrapper<JpInverter>().
...@@ -1360,7 +1372,6 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -1360,7 +1372,6 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
public void inverterDetail() { public void inverterDetail() {
} }
@Scheduled(cron = "${dataRequstScheduled.keshida}") @Scheduled(cron = "${dataRequstScheduled.keshida}")
@Override @Override
@Async @Async
...@@ -1372,9 +1383,10 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -1372,9 +1383,10 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
} catch (InterruptedException e) { } catch (InterruptedException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
List<JpInverter> ksdInverterList = jpInverterMapper.selectList(new QueryWrapper<JpInverter>(). List<JpInverter> ksdInverterList = jpInverterMapper
eq("third_code", PVProducerInfoEnum.KSOLAR.getCode())); .selectList(new QueryWrapper<JpInverter>().eq("third_code", PVProducerInfoEnum.KSOLAR.getCode()));
ksdInverterList = ksdInverterList.stream().filter(jpInverter -> !ObjectUtils.isEmpty(jpInverter.getSnCode())).collect(Collectors.toList()); ksdInverterList = ksdInverterList.stream().filter(jpInverter -> !ObjectUtils.isEmpty(jpInverter.getSnCode()))
.collect(Collectors.toList());
Map<String, String> ksdInverterListMap = new HashMap<>(); Map<String, String> ksdInverterListMap = new HashMap<>();
ksdInverterList.forEach(jpInverter -> { ksdInverterList.forEach(jpInverter -> {
...@@ -1385,13 +1397,8 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -1385,13 +1397,8 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
HashMap<String, Object> requestInfo = new HashMap<>(1); HashMap<String, Object> requestInfo = new HashMap<>(1);
String requestParaminfo = JSON.toJSONString(requestInfo); String requestParaminfo = JSON.toJSONString(requestInfo);
String url = KSolarConstant.stationCollectAlarmUrl + "?pageNumber=1&pageSize=200"; String url = KSolarConstant.stationCollectAlarmUrl + "?pageNumber=1&pageSize=200";
List<KsolarAlarmDto> result = kSolarRequestUtil.getResPonse( List<KsolarAlarmDto> result = kSolarRequestUtil.getResPonse(url, KSolarConstant.requestGET, requestParaminfo,
url, KSolarConstant.resovle_rows, KsolarAlarmDto.class);
KSolarConstant.requestGET,
requestParaminfo,
KSolarConstant.resovle_rows,
KsolarAlarmDto.class
);
if (!CollectionUtils.isEmpty(result)) { if (!CollectionUtils.isEmpty(result)) {
for (KsolarAlarmDto ksolarAlarmDto : result) { for (KsolarAlarmDto ksolarAlarmDto : result) {
if (!ObjectUtils.isEmpty(ksolarAlarmDto.getInverterId())) { if (!ObjectUtils.isEmpty(ksolarAlarmDto.getInverterId())) {
...@@ -1406,12 +1413,12 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -1406,12 +1413,12 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
if (ObjectUtils.isEmpty(snCode)) { if (ObjectUtils.isEmpty(snCode)) {
continue; continue;
} }
List<HYGFJPInverterWarn> list = hygfjpInverterWarnMapper.selectList(new QueryWrapper<HYGFJPInverterWarn>() List<HYGFJPInverterWarn> list = hygfjpInverterWarnMapper
.eq("sn_code", snCode) .selectList(new QueryWrapper<HYGFJPInverterWarn>().eq("sn_code", snCode).eq("start_time",
.eq("start_time", DateUtil.parse(ksolarAlarmDto.getSaveTime(), DatePattern.NORM_DATETIME_PATTERN).getTime()) DateUtil.parse(ksolarAlarmDto.getSaveTime(), DatePattern.NORM_DATETIME_PATTERN)
.getTime())
.eq("third_code", PVProducerInfoEnum.KSOLAR.getCode()) .eq("third_code", PVProducerInfoEnum.KSOLAR.getCode())
.eq("third_station_id", ksolarAlarmDto.getStationId()) .eq("third_station_id", ksolarAlarmDto.getStationId()));
);
HYGFJPInverterWarn hygfjpInverterWarn = new HYGFJPInverterWarn(); HYGFJPInverterWarn hygfjpInverterWarn = new HYGFJPInverterWarn();
if (!ObjectUtils.isEmpty(list)) { if (!ObjectUtils.isEmpty(list)) {
hygfjpInverterWarn = list.get(0); hygfjpInverterWarn = list.get(0);
...@@ -1424,19 +1431,18 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -1424,19 +1431,18 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
hygfjpInverterWarn.setContent(ksolarAlarmDto.getMessage()); hygfjpInverterWarn.setContent(ksolarAlarmDto.getMessage());
hygfjpInverterWarn.setThirdCode(PVProducerInfoEnum.KSOLAR.getCode()); hygfjpInverterWarn.setThirdCode(PVProducerInfoEnum.KSOLAR.getCode());
hygfjpInverterWarn.setTreatment(ksolarAlarmDto.getSolution()); hygfjpInverterWarn.setTreatment(ksolarAlarmDto.getSolution());
hygfjpInverterWarn.setStartTime(DateUtil.parse(ksolarAlarmDto.getSaveTime(), DatePattern.NORM_DATETIME_PATTERN).getTime()); hygfjpInverterWarn.setStartTime(
DateUtil.parse(ksolarAlarmDto.getSaveTime(), DatePattern.NORM_DATETIME_PATTERN).getTime());
hygfjpInverterWarn.setState(KSolarConstant.alarmstatus.get(ksolarAlarmDto.getStatus())); hygfjpInverterWarn.setState(KSolarConstant.alarmstatus.get(ksolarAlarmDto.getStatus()));
hygfjpInverterWarn.setTimeLong(null); hygfjpInverterWarn.setTimeLong(null);
hygfjpInverterWarn.setRecoverTime(null); hygfjpInverterWarn.setRecoverTime(null);
// 电站区域经销商,
JpStation jpStation = jpStationMapper.selectOne(
new QueryWrapper<JpStation>().eq("third_code", PVProducerInfoEnum.KSOLAR.getCode())
.eq("third_station_id", ksolarAlarmDto.getStationId()));
if (jpStation != null) {
//电站区域经销商,
JpStation jpStation = jpStationMapper.selectOne(new QueryWrapper<JpStation>().
eq("third_code", PVProducerInfoEnum.KSOLAR.getCode()).
eq("third_station_id", ksolarAlarmDto.getStationId()));
if(jpStation!=null){
hygfjpInverterWarn.setAmosCompanyCode(jpStation.getAmosCompanyCode()); hygfjpInverterWarn.setAmosCompanyCode(jpStation.getAmosCompanyCode());
hygfjpInverterWarn.setRegionalCompaniesCode(jpStation.getRegionalCompaniesCode()); hygfjpInverterWarn.setRegionalCompaniesCode(jpStation.getRegionalCompaniesCode());
hygfjpInverterWarn.setStationName(jpStation.getName()); hygfjpInverterWarn.setStationName(jpStation.getName());
...@@ -1444,13 +1450,14 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -1444,13 +1450,14 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
} }
if (StringUtils.isNotBlank(ksolarAlarmDto.getRemoveTime())) { if (StringUtils.isNotBlank(ksolarAlarmDto.getRemoveTime())) {
hygfjpInverterWarn.setRecoverTime(DateUtil.parse(ksolarAlarmDto.getRemoveTime(), DatePattern.NORM_DATETIME_PATTERN).getTime()); hygfjpInverterWarn.setRecoverTime(DateUtil
.parse(ksolarAlarmDto.getRemoveTime(), DatePattern.NORM_DATETIME_PATTERN).getTime());
} }
if (!ObjectUtils.isEmpty(ksolarAlarmDto.getSaveTime()) && !ObjectUtils.isEmpty(ksolarAlarmDto.getRemoveTime())) { if (!ObjectUtils.isEmpty(ksolarAlarmDto.getSaveTime())
hygfjpInverterWarn.setTimeLong(hygfjpInverterWarn.getRecoverTime() - hygfjpInverterWarn.getStartTime()); && !ObjectUtils.isEmpty(ksolarAlarmDto.getRemoveTime())) {
hygfjpInverterWarn
.setTimeLong(hygfjpInverterWarn.getRecoverTime() - hygfjpInverterWarn.getStartTime());
} }
if (ObjectUtils.isEmpty(hygfjpInverterWarn.getCreatedTime())) { if (ObjectUtils.isEmpty(hygfjpInverterWarn.getCreatedTime())) {
hygfjpInverterWarn.setCreatedTime(System.currentTimeMillis()); hygfjpInverterWarn.setCreatedTime(System.currentTimeMillis());
......
...@@ -5,7 +5,10 @@ import cn.hutool.core.date.DateUtil; ...@@ -5,7 +5,10 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.gson.JsonObject;
import com.qiniu.util.Json;
import com.yeejoin.amos.api.householdapi.Utils.SunlightUtil; import com.yeejoin.amos.api.householdapi.Utils.SunlightUtil;
import com.yeejoin.amos.api.householdapi.constant.ImasterConstant; import com.yeejoin.amos.api.householdapi.constant.ImasterConstant;
import com.yeejoin.amos.api.householdapi.constant.KSolarConstant; import com.yeejoin.amos.api.householdapi.constant.KSolarConstant;
...@@ -43,6 +46,8 @@ import java.util.concurrent.TimeUnit; ...@@ -43,6 +46,8 @@ import java.util.concurrent.TimeUnit;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
/** /**
* @description: * @description:
* @author: tw * @author: tw
...@@ -114,7 +119,6 @@ public class SunlightServiceImpl implements SunlightService { ...@@ -114,7 +119,6 @@ public class SunlightServiceImpl implements SunlightService {
for (Sunlight sunlight : list) { for (Sunlight sunlight : list) {
sunlight.setCreatedTime(System.currentTimeMillis()); sunlight.setCreatedTime(System.currentTimeMillis());
sunlightMapper.insert(sunlight); sunlightMapper.insert(sunlight);
} }
logger.info("-------阳光同步电站/逆变器/采集器结束" + ts + "------- " + sdf.format(new Date())); logger.info("-------阳光同步电站/逆变器/采集器结束" + ts + "------- " + sdf.format(new Date()));
...@@ -194,36 +198,69 @@ public class SunlightServiceImpl implements SunlightService { ...@@ -194,36 +198,69 @@ public class SunlightServiceImpl implements SunlightService {
jpStation.setSnCode(sunlightDto.getPs_id().toString());// sncode jpStation.setSnCode(sunlightDto.getPs_id().toString());// sncode
try {
Map<String, String> map = sunlightDto.getTotal_capcity(); Map<String, String> map = sunlightDto.getTotal_capcity();
jpStation.setCapacity( if (map != null && map.get("unit") != null && !map.get("unit").isEmpty()
map != null && map.get("unit") != null ? SunlightUtil.zj.get(String.valueOf(map.get("unit"))) && !"--".equals(map.get("value"))) {
* Double.valueOf(String.valueOf(map.get("value"))) : null);// 装机容量 jpStation.setCapacity(SunlightUtil.zj.get(String.valueOf(map.get("unit")))
* Double.valueOf(String.valueOf(map.get("value"))));// 装机容量
}
Map<String, String> map1 = sunlightDto.getCurr_power(); Map<String, String> map1 = sunlightDto.getCurr_power();
jpStation.setRealTimePower( if (map1 != null && map1.get("unit") != null && !map1.get("unit").isEmpty()
map1 != null && map1.get("unit") != null ? SunlightUtil.GL.get(String.valueOf(map1.get("unit"))) && !"--".equals(map1.get("value"))) {
* Double.valueOf(String.valueOf(map1.get("value"))) : null);// 实时功率 jpStation.setRealTimePower(SunlightUtil.GL.get(String.valueOf(map1.get("unit")))
* Double.valueOf(String.valueOf(map1.get("value"))));// 实时功率
}
Map<String, String> map2 = sunlightDto.getToday_energy(); Map<String, String> map2 = sunlightDto.getToday_energy();
jpStation.setDayGenerate( if (map2 != null && map2.get("unit") != null && !map2.get("unit").isEmpty()
map2 != null && map2.get("unit") != null ? SunlightUtil.fd.get(String.valueOf(map2.get("unit"))) && !"--".equals(map2.get("value"))) {
* Double.valueOf(String.valueOf(map2.get("value"))) : null);// 日发电量 jpStation.setDayGenerate(SunlightUtil.fd.get(String.valueOf(map2.get("unit")))
* Double.valueOf(String.valueOf(map2.get("value"))));// 日发电量
}
Map<String, String> map3 = sunlightDto.getTotal_energy(); Map<String, String> map3 = sunlightDto.getTotal_energy();
jpStation.setAccumulatedPower( if (map3 != null && map3.get("unit") != null && !map3.get("unit").isEmpty()
map3 != null && map3.get("unit") != null ? SunlightUtil.fd.get(String.valueOf(map3.get("unit"))) && !"--".equals(map3.get("value"))) {
* Double.valueOf(String.valueOf(map3.get("value"))) : null);// 累计发电量 jpStation.setAccumulatedPower(SunlightUtil.fd.get(String.valueOf(map3.get("unit")))
* Double.valueOf(String.valueOf(map3.get("value"))));// 累计发电量
}
Map<String, String> map4 = sunlightDto.getToday_income(); Map<String, String> map4 = sunlightDto.getToday_income();
jpStation.setDayIncome( if (map4 != null && map4.get("unit") != null && !map4.get("unit").isEmpty()
map4 != null && map4.get("unit") != null ? SunlightUtil.sy.get(String.valueOf(map4.get("unit"))) && !"--".equals(map4.get("value"))) {
* Double.valueOf(String.valueOf(map4.get("value"))) : null);// 日收益 jpStation.setDayIncome(SunlightUtil.sy.get(String.valueOf(map4.get("unit")))
* Double.valueOf(String.valueOf(map4.get("value"))));// 日收益
}
Map<String, String> map5 = sunlightDto.getTotal_income(); Map<String, String> map5 = sunlightDto.getTotal_income();
jpStation.setCumulativeIncome( if (map5 != null && map5.get("unit") != null && !map5.get("unit").isEmpty()
map5 != null && map5.get("unit") != null ? SunlightUtil.sy.get(String.valueOf(map5.get("unit"))) && !"--".equals(map5.get("value"))) {
* Double.valueOf(String.valueOf(map5.get("value"))) : null);// 累计收益 jpStation.setCumulativeIncome(SunlightUtil.sy.get(String.valueOf(map5.get("unit")))
if (sunlightDto.getPs_fault_status() > 2) { * Double.valueOf(String.valueOf(map5.get("value"))));// 累计收益
jpStation.setState(SunlightUtil.zt.get(sunlightDto.getPs_status() + ""));// 电站状态 }
} catch (Exception e) {
e.printStackTrace();
logger.error("阳光数据错误:" + com.alibaba.fastjson.JSONObject.toJSONString(sunlightDto));
}
// 0离线 1在线
// 1故障 2告警 4正常
if ("0".equals(sunlightDto.getPs_status().toString())) {
jpStation.setState("离线");
} else if ("1".equals(sunlightDto.getPs_status().toString())) {
if ("1".equals(sunlightDto.getPs_fault_status().toString())
|| "2".equals(sunlightDto.getPs_fault_status().toString())) {
jpStation.setState("报警");
} else if ("4".equals(sunlightDto.getPs_fault_status().toString())) {
jpStation.setState("在线");
} else {
jpStation.setState("在线");
}
} else { } else {
jpStation.setState("报警");// 电站状态 jpStation.setState("在线");
} }
// 获取电站下通讯模块 // 获取电站下通讯模块
...@@ -307,11 +344,6 @@ public class SunlightServiceImpl implements SunlightService { ...@@ -307,11 +344,6 @@ public class SunlightServiceImpl implements SunlightService {
jpStation.setYearGenerate(js != null ? Double.valueOf(js.get(0).get("4") + "") / 1000 : null); jpStation.setYearGenerate(js != null ? Double.valueOf(js.get(0).get("4") + "") / 1000 : null);
// 年收益 // 年收益
jpStation.setYearIncome(js != null ? Double.valueOf(js.get(0).get("4") + "") / 1000 : null); jpStation.setYearIncome(js != null ? Double.valueOf(js.get(0).get("4") + "") / 1000 : null);
if (!ObjectUtils.isEmpty(jpStation.getSequenceNbr())) {
jpStationMapper.updateById(jpStation);
} else {
jpStationMapper.insert(jpStation);
}
String today = DateUtil.today(); String today = DateUtil.today();
String hour = new Date().getHours() + ":00"; String hour = new Date().getHours() + ":00";
...@@ -373,10 +405,21 @@ public class SunlightServiceImpl implements SunlightService { ...@@ -373,10 +405,21 @@ public class SunlightServiceImpl implements SunlightService {
// tdJpStation.setCreatedTime(System.currentTimeMillis()); // tdJpStation.setCreatedTime(System.currentTimeMillis());
// tdJpStationMapper.insert(tdJpStation); // tdJpStationMapper.insert(tdJpStation);
// } // }
}
JpStation jpStationOld = jpStationMapper.selectOne(
new LambdaQueryWrapper<JpStation>().eq(JpStation::getThirdStationId, jpStation.getThirdStationId())
.eq(JpStation::getThirdCode, PVProducerInfoEnum.YG.getCode()));
if (jpStationOld != null) {
jpStation.setSequenceNbr(jpStationOld.getSequenceNbr());
jpStationMapper.updateById(jpStation);
} else {
jpStationMapper.insert(jpStation);
}
this.setJpInverte(listd, jpStation, listdtx); this.setJpInverte(listd, jpStation, listdtx);
this.collectorDetail(listd, jpStation); this.collectorDetail(listd, jpStation);
}
// 电站报表 // 电站报表
// 户用场站日发电量 // 户用场站日发电量
...@@ -490,7 +533,6 @@ public class SunlightServiceImpl implements SunlightService { ...@@ -490,7 +533,6 @@ public class SunlightServiceImpl implements SunlightService {
@Override @Override
public void run() { public void run() {
try { try {
for (Device device : devices) { for (Device device : devices) {
if (device != null) { if (device != null) {
// 获取逆变器信息存库 // 获取逆变器信息存库
...@@ -505,12 +547,24 @@ public class SunlightServiceImpl implements SunlightService { ...@@ -505,12 +547,24 @@ public class SunlightServiceImpl implements SunlightService {
jpInverter.setSnCode(device.getDevice_sn()); jpInverter.setSnCode(device.getDevice_sn());
jpInverter.setId(device.getUuid().toString()); jpInverter.setId(device.getUuid().toString());
if (device.getGetPs_fault_status() > 2) { // 0离线 1在线
jpInverter.setState(SunlightUtil.zt.get(device.getDev_status() + "")); // 1故障 2告警 4正常
if ("0".equals(device.getDev_status())) {
jpInverter.setState("离线");
} else if ("1".equals(device.getDev_status())) {
if ("1".equals(device.getDev_fault_status())
|| "2".equals(device.getDev_fault_status())) {
jpInverter.setState("报警");
} else if ("4".equals(device.getDev_fault_status())) {
jpInverter.setState("在线");
} else { } else {
jpInverter.setState("报警");// 电站状态 jpInverter.setState("在线");
} }
} else {
jpInverter.setState("在线");
}
// logger.error("阳光数据解析(逆变器),无法获取状态:" +
// com.alibaba.fastjson.JSONObject.toJSONString(device));
jpInverter.setUpdateTime(new Date()); jpInverter.setUpdateTime(new Date());
jpInverter.setDayPowerGeneration(jpStation.getDayGenerate()); jpInverter.setDayPowerGeneration(jpStation.getDayGenerate());
jpInverter.setMonthPowerGeneration(jpStation.getMonthGenerate()); jpInverter.setMonthPowerGeneration(jpStation.getMonthGenerate());
...@@ -916,7 +970,7 @@ public class SunlightServiceImpl implements SunlightService { ...@@ -916,7 +970,7 @@ public class SunlightServiceImpl implements SunlightService {
jpCollector.setState("报警");// 电站状态 jpCollector.setState("报警");// 电站状态
} }
} else { } else {
//如果获取不了逆变器状态 并且逆变器没状态就默认离线 // 如果获取不了逆变器状态 并且逆变器没状态就默认离线
if (jpCollector.getState() == null) { if (jpCollector.getState() == null) {
jpCollector.setState("离线"); jpCollector.setState("离线");
} }
......
...@@ -13,6 +13,7 @@ import com.yeejoin.amos.boot.module.jxiop.biz.Enum.WarningPeriodEnum; ...@@ -13,6 +13,7 @@ import com.yeejoin.amos.boot.module.jxiop.biz.Enum.WarningPeriodEnum;
import com.yeejoin.amos.boot.module.jxiop.biz.service.IPermissionService; import com.yeejoin.amos.boot.module.jxiop.biz.service.IPermissionService;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.*; import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.*;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
...@@ -241,26 +242,25 @@ public class TDBigScreenAnalyseController extends BaseController { ...@@ -241,26 +242,25 @@ public class TDBigScreenAnalyseController extends BaseController {
List<Integer> jgList = new ArrayList<>(); List<Integer> jgList = new ArrayList<>();
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
FeignClientResult<List<CompanyModel>> listFeignClientResult = Privilege.companyClient.queryAgencyList("AREA"); // FeignClientResult<List<CompanyModel>> listFeignClientResult = Privilege.companyClient.queryAgencyList("AREA");
//
List<CompanyModel> companyModels = new ArrayList<>(); // List<CompanyModel> companyModels = new ArrayList<>();
//
if (!ObjectUtils.isEmpty(listFeignClientResult)) { // if (!ObjectUtils.isEmpty(listFeignClientResult)) {
if (listFeignClientResult.getStatus() == 200) { // if (listFeignClientResult.getStatus() == 200) {
companyModels = listFeignClientResult.getResult(); // companyModels = listFeignClientResult.getResult();
} else { // } else {
throw new RuntimeException(listFeignClientResult.getMessage()); // throw new RuntimeException(listFeignClientResult.getMessage());
} // }
} // }
List<String> collect = companyModels.stream().map(t -> t.getCompanyName()).collect(Collectors.toList()); // List<String> collect = companyModels.stream().map(t -> t.getCompanyName()).collect(Collectors.toList());
if ("idx_biz_fan_warning_record".equals(tableName)) { if ("idx_biz_fan_warning_record".equals(tableName)) {
list = collect; // list = collect;
// list = Arrays.asList("华中片区", "西北片区", "西南片区", "华南片区", "华东片区", "东北片区", "华北片区"); list = Arrays.asList("华中区域", "西北区域", "西南区域", "华南区域", "华东区域", "东北区域", "华北区域");
} else { } else {
list = collect; // list = collect;
Collections.reverse(list); list = Arrays.asList("华北区域", "东北区域", "华东区域", "华南区域", "西南区域", "西北区域", "华中区域");
// list = Arrays.asList("华北片区", "东北片区", "华东片区", "华南片区", "西南片区", "西北片区", "华中片区");
} }
list.forEach(item -> { list.forEach(item -> {
wxList.add(wxMap.getOrDefault(item, 0)); wxList.add(wxMap.getOrDefault(item, 0));
...@@ -295,18 +295,22 @@ public class TDBigScreenAnalyseController extends BaseController { ...@@ -295,18 +295,22 @@ public class TDBigScreenAnalyseController extends BaseController {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
FeignClientResult<List<CompanyModel>> listFeignClientResult = Privilege.companyClient.queryAgencyList("AREA"); // FeignClientResult<List<CompanyModel>> listFeignClientResult = Privilege.companyClient.queryAgencyList("AREA");
//
// List<CompanyModel> companyModels = new ArrayList<>();
//
// if (!ObjectUtils.isEmpty(listFeignClientResult)) {
// if (listFeignClientResult.getStatus() == 200) {
// companyModels = listFeignClientResult.getResult();
// } else {
// throw new RuntimeException(listFeignClientResult.getMessage());
// }
// }
// list = companyModels.stream().map(CompanyModel::getCompanyName).collect(Collectors.toList());
//
list = Arrays.asList("华北区域", "东北区域", "华东区域", "华南区域", "西南区域", "西北区域", "华中区域");
List<CompanyModel> companyModels = new ArrayList<>();
if (!ObjectUtils.isEmpty(listFeignClientResult)) {
if (listFeignClientResult.getStatus() == 200) {
companyModels = listFeignClientResult.getResult();
} else {
throw new RuntimeException(listFeignClientResult.getMessage());
}
}
list = companyModels.stream().map(CompanyModel::getCompanyName).collect(Collectors.toList());
List<Object> seriesData = new ArrayList<>(); List<Object> seriesData = new ArrayList<>();
list.forEach(item -> seriesData.add(collect.getOrDefault(item, 100.0))); list.forEach(item -> seriesData.add(collect.getOrDefault(item, 100.0)));
resultMap.put("axisData", list); resultMap.put("axisData", list);
...@@ -337,6 +341,10 @@ public class TDBigScreenAnalyseController extends BaseController { ...@@ -337,6 +341,10 @@ public class TDBigScreenAnalyseController extends BaseController {
} }
Integer count = fanWaringRecordMapper.getEquipWarningInfoByPageCount(arae, station, stationType, warningName, Integer count = fanWaringRecordMapper.getEquipWarningInfoByPageCount(arae, station, stationType, warningName,
stationId, startDate, endDate); stationId, startDate, endDate);
//前端存在分页bug 此处限制分页后筛选导致页面超出问题
if (count > 0 && current > (count/10 + 1)){
current = 1;
}
// List<IdxBizFanWarningRecord> idxBizFanWarningRecordIPage = // List<IdxBizFanWarningRecord> idxBizFanWarningRecordIPage =
// idxBizFanWarningRecordMapper.getEquipWarningInfoByPage(arae, station, // idxBizFanWarningRecordMapper.getEquipWarningInfoByPage(arae, station,
// stationType, (current - 1) * size, size, warningName, stationId, startDate, // stationType, (current - 1) * size, size, warningName, stationId, startDate,
...@@ -347,6 +355,7 @@ public class TDBigScreenAnalyseController extends BaseController { ...@@ -347,6 +355,7 @@ public class TDBigScreenAnalyseController extends BaseController {
Page<FanWarningRecord> idxBizFanWarningRecordPage = new Page<>(current, size); Page<FanWarningRecord> idxBizFanWarningRecordPage = new Page<>(current, size);
idxBizFanWarningRecordPage.setRecords(idxBizFanWarningRecordIPage); idxBizFanWarningRecordPage.setRecords(idxBizFanWarningRecordIPage);
idxBizFanWarningRecordPage.setTotal(count); idxBizFanWarningRecordPage.setTotal(count);
idxBizFanWarningRecordPage.setCurrent(current);
return ResponseHelper.buildResponse(idxBizFanWarningRecordPage); return ResponseHelper.buildResponse(idxBizFanWarningRecordPage);
} }
...@@ -816,9 +825,11 @@ public class TDBigScreenAnalyseController extends BaseController { ...@@ -816,9 +825,11 @@ public class TDBigScreenAnalyseController extends BaseController {
StationBasic stationBasic = stationBasicMapper.selectById(stationId); StationBasic stationBasic = stationBasicMapper.selectById(stationId);
String nameByIndexAddress = idxBizFanHealthIndexMapper.getPointNameByIndexAddress(indexAddress, tableName, String nameByIndexAddress = idxBizFanHealthIndexMapper.getPointNameByIndexAddress(indexAddress, tableName,
stationBasic.getFanGatewayId()); stationBasic.getFanGatewayId());
int num = 0 ;
if (StringUtils.isNotEmpty(tableName2)){
num = idxBizFanHealthIndexMapper.getIsWarningByPointId(indexAddress, stationBasic.getFanGatewayId(), tableName2);
}
int num = idxBizFanHealthIndexMapper.getIsWarningByPointId(indexAddress, stationBasic.getFanGatewayId(),
tableName2);
HashMap<String, Object> resultMap = new HashMap<>(); HashMap<String, Object> resultMap = new HashMap<>();
resultMap.put("text", nameByIndexAddress); resultMap.put("text", nameByIndexAddress);
......
...@@ -167,7 +167,12 @@ public class TdengineTimeServiceImpl { ...@@ -167,7 +167,12 @@ public class TdengineTimeServiceImpl {
levelDesc = item.getHealthLevel(); levelDesc = item.getHealthLevel();
break; break;
} }
if (healthIndex == 0 && item.getGroupLowerLimit() == healthIndex){
levelDesc = item.getHealthLevel();
break;
} }
}
return levelDesc; return levelDesc;
} }
......
...@@ -290,7 +290,7 @@ ...@@ -290,7 +290,7 @@
<where> <where>
ANALYSIS_OBJ_TYPE = '场站' ANALYSIS_OBJ_TYPE = '场站'
AND ANALYSIS_TYPE = '按天' AND ANALYSIS_TYPE = '按天'
AND DATE_FORMAT( REC_DATE, "%Y-%m-%d" ) = CURRENT_DATE AND DATE_FORMAT( REC_DATE, "%Y-%m-%d" ) = CURRENT_DATE - INTERVAL 1 DAY
<if test="areaCode != null and areaCode != ''"> <if test="areaCode != null and areaCode != ''">
AND ARAE like concat('%', #{areaCode}, '%') AND ARAE like concat('%', #{areaCode}, '%')
</if> </if>
...@@ -306,7 +306,7 @@ ...@@ -306,7 +306,7 @@
<where> <where>
ANALYSIS_OBJ_TYPE = '场站' ANALYSIS_OBJ_TYPE = '场站'
AND ANALYSIS_TYPE = '按天' AND ANALYSIS_TYPE = '按天'
AND DATE_FORMAT( REC_DATE, "%Y-%m-%d" ) = CURRENT_DATE AND DATE_FORMAT( REC_DATE, "%Y-%m-%d" ) = CURRENT_DATE - INTERVAL 1 DAY
<if test="areaCode != null and areaCode != ''"> <if test="areaCode != null and areaCode != ''">
AND ARAE like concat('%', #{areaCode}, '%') AND ARAE like concat('%', #{areaCode}, '%')
</if> </if>
...@@ -453,7 +453,7 @@ ...@@ -453,7 +453,7 @@
<where> <where>
ANALYSIS_OBJ_TYPE = '子系统' ANALYSIS_OBJ_TYPE = '子系统'
AND ANALYSIS_TYPE = '按天' AND ANALYSIS_TYPE = '按天'
AND DATE_FORMAT( REC_DATE, "%Y-%m-%d" ) = CURRENT_DATE AND DATE_FORMAT( REC_DATE, "%Y-%m-%d" ) = CURRENT_DATE - INTERVAL 1 DAY
<if test="equipmentName != null and equipmentName != ''"> <if test="equipmentName != null and equipmentName != ''">
AND EQUIPMENT_NAME like concat( '%', #{equipmentName} ,'风机') AND EQUIPMENT_NAME like concat( '%', #{equipmentName} ,'风机')
</if> </if>
...@@ -490,7 +490,7 @@ ...@@ -490,7 +490,7 @@
<where> <where>
ANALYSIS_OBJ_TYPE = '设备' ANALYSIS_OBJ_TYPE = '设备'
AND ANALYSIS_TYPE = '按天' AND ANALYSIS_TYPE = '按天'
AND DATE_FORMAT( REC_DATE, "%Y-%m-%d" ) = CURRENT_DATE AND DATE_FORMAT( REC_DATE, "%Y-%m-%d" ) = CURRENT_DATE - INTERVAL 1 DAY
<if test="gatewayId != null and gatewayId != ''"> <if test="gatewayId != null and gatewayId != ''">
AND GATEWAY_ID = #{gatewayId} AND GATEWAY_ID = #{gatewayId}
</if> </if>
...@@ -608,7 +608,7 @@ ...@@ -608,7 +608,7 @@
<where> <where>
ANALYSIS_OBJ_TYPE = '子阵' ANALYSIS_OBJ_TYPE = '子阵'
AND ANALYSIS_TYPE = '按天' AND ANALYSIS_TYPE = '按天'
AND DATE_FORMAT( REC_DATE, "%Y-%m-%d" ) = CURRENT_DATE AND DATE_FORMAT( REC_DATE, "%Y-%m-%d" ) = CURRENT_DATE - INTERVAL 1 DAY
<if test="gatewayId != null and gatewayId != ''"> <if test="gatewayId != null and gatewayId != ''">
AND GATEWAY_ID = #{gatewayId} AND GATEWAY_ID = #{gatewayId}
</if> </if>
...@@ -625,7 +625,7 @@ ...@@ -625,7 +625,7 @@
<where> <where>
ANALYSIS_OBJ_TYPE = '设备' ANALYSIS_OBJ_TYPE = '设备'
AND ANALYSIS_TYPE = '按天' AND ANALYSIS_TYPE = '按天'
AND DATE_FORMAT( REC_DATE, "%Y-%m-%d" ) = CURRENT_DATE AND DATE_FORMAT( REC_DATE, "%Y-%m-%d" ) = CURRENT_DATE - INTERVAL 1 DAY
<if test="subarray != null and subarray != ''"> <if test="subarray != null and subarray != ''">
AND SUBARRAY = concat('#', #{subarray}) AND SUBARRAY = concat('#', #{subarray})
</if> </if>
......
...@@ -4,8 +4,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -4,8 +4,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.List;
import java.util.Map; import java.util.Map;
@FeignClient(name = "${amos.idx.name:AMOS-IDX}", path = "idx", configuration = {FeignConfiguration.class}) @FeignClient(name = "${amos.idx.name:AMOS-IDX}", path = "idx", configuration = {FeignConfiguration.class})
...@@ -24,4 +28,23 @@ public interface IdxFeign { ...@@ -24,4 +28,23 @@ public interface IdxFeign {
@GetMapping("/table/getPage") @GetMapping("/table/getPage")
FeignClientResult<Page<Map<String, Object>>> getPage(@RequestParam Map<String, Object> map); FeignClientResult<Page<Map<String, Object>>> getPage(@RequestParam Map<String, Object> map);
@RequestMapping(value = "/publicAnalysis/getStationMessage", method = RequestMethod.GET, consumes = "application/json")
FeignClientResult<List<Map<String, Object>>> getStationMark(@RequestParam(value = "code") String code);
@RequestMapping(value = "/publicAnalysis/appletSroce", method = RequestMethod.GET, consumes = "application/json")
Map<String, Object> getStationMarkList(@RequestParam(value = "code") String code,
@RequestParam(value = "pageNumber") String pageNumber,
@RequestParam(value = "pageSize") String pageSize);
@RequestMapping(value = "/jxIopAnalysis/stationRanking", method = RequestMethod.GET, consumes = "application/json")
FeignClientResult<Map<String, Object>> stationRanking(@RequestParam("pageNumber") Long pageNumber,
@RequestParam("pageSize") Long pageSize,
@RequestParam(required = false, value = "stationType") String type,
@RequestParam(required = false, value = "parentCode") String parentCode);
} }
...@@ -69,4 +69,8 @@ public interface StationBasicMapper extends BaseMapper<StationBasic> { ...@@ -69,4 +69,8 @@ public interface StationBasicMapper extends BaseMapper<StationBasic> {
*/ */
List<StationBasicDto> getStationBasicListAll(); List<StationBasicDto> getStationBasicListAll();
StationBasicDto getStationInfoByCode(@Param("stationCode")String stationCode);
List<StationBasicDto> getStationsByAreaCode(@Param("areaCode")String stationCode);
} }
...@@ -192,4 +192,25 @@ ...@@ -192,4 +192,25 @@
FROM FROM
station_basic station_basic
</select> </select>
<select id="getStationInfoByCode" resultType="com.yeejoin.amos.boot.module.jxiop.api.dto.StationBasicDto">
select
*
from
station_basic
where
station_code = #{stationCode}
</select>
<select id="getStationsByAreaCode" resultType="com.yeejoin.amos.boot.module.jxiop.api.dto.StationBasicDto">
select
*
from
station_basic
where
area_code = #{areaCode}
and
is_delete = 0
</select>
</mapper> </mapper>
package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import cn.hutool.core.map.MapBuilder;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jxiop.api.dto.StationBasicDto;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESMoonPowerGeneration;
import com.yeejoin.amos.boot.module.jxiop.biz.constants.CommonConstans;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.CommonMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.EarningsForecastImpl;
import org.apache.http.client.HttpClient;
import org.elasticsearch.action.get.GetResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.stream.Collectors;
import static com.alibaba.fastjson.JSON.toJSONString;
import static java.lang.Boolean.TRUE;
@RestController
@RequestMapping("earningsForecast")
public class EarningsForecastController {
@Autowired
private StationBasicMapper stationBasicMapper;
@Autowired
private EarningsForecastImpl earningsForecast;
@RequestMapping(value = "earningsForecast",method = RequestMethod.GET)
@TycloudOperation(needAuth = false,ApiLevel = UserType.AGENCY)
public ResponseModel<Object> earningsForecast (@RequestParam(required = true,value = "stationId") Long stationId,
@RequestParam(required = true,value = "type") String type){
return ResponseHelper.buildResponse(earningsForecast.earningsForecast(stationId,type));
}
@RequestMapping(value = "getStationListByArae",method = RequestMethod.GET)
@TycloudOperation(needAuth = false,ApiLevel = UserType.AGENCY)
public ResponseModel<List<Map<String,Object>>> getStationListByArae(String araeCode,String stationType){
List<Map<String,Object>> maps = new ArrayList<>();
if (stationType.equals("FDZ")){
stationBasicMapper.getStationsByAreaCode(araeCode).stream().filter(a->a.getStationType().equals(stationType)).forEach(e->{
maps.add(MapBuilder.<String,Object>create().put("text",e.getStationName()).put("value",e.getSequenceNbr()).build());
});
}else {
stationBasicMapper.getStationsByAreaCode(araeCode).stream().filter(a->!a.getStationType().equals(stationType)).forEach(e->{
maps.add(MapBuilder.<String,Object>create().put("text",e.getStationName()).put("value",e.getSequenceNbr()).build());
});
}
return ResponseHelper.buildResponse(maps);
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.mapper2;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
public interface CommonMapper {
List<Map<String,String>> selectAgo10Month();
List<Map<String,String>> selectLast3Month();
}
...@@ -31,6 +31,7 @@ import org.elasticsearch.search.aggregations.bucket.terms.ParsedStringTerms; ...@@ -31,6 +31,7 @@ import org.elasticsearch.search.aggregations.bucket.terms.ParsedStringTerms;
import org.elasticsearch.search.aggregations.bucket.terms.Terms; import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder; import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
import org.elasticsearch.search.aggregations.metrics.AvgAggregationBuilder; import org.elasticsearch.search.aggregations.metrics.AvgAggregationBuilder;
import org.elasticsearch.search.aggregations.metrics.Sum;
import org.elasticsearch.search.aggregations.metrics.SumAggregationBuilder; import org.elasticsearch.search.aggregations.metrics.SumAggregationBuilder;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
...@@ -423,7 +424,7 @@ public class CommonServiceImpl { ...@@ -423,7 +424,7 @@ public class CommonServiceImpl {
return null; return null;
} }
public <T> List<T> getListDataByCondtions(Map<String, List<String>> mustQuerCondtion, Map<String, String> shouldQuerCondtion, Class<T> tClass, Map<String, String> likeQuerCondtion) { public <T> TreeMap<String, Double> getListDataByCondtionsSum(Map<String, List<String>> mustQuerCondtion, List<Map<String, String>> shouldQuerCondtion, Class<T> tClass, Map<String, String> likeQuerCondtion) {
BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery(); BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery();
if (!ObjectUtils.isEmpty(mustQuerCondtion)) { if (!ObjectUtils.isEmpty(mustQuerCondtion)) {
for (String key : mustQuerCondtion.keySet()) { for (String key : mustQuerCondtion.keySet()) {
...@@ -432,9 +433,14 @@ public class CommonServiceImpl { ...@@ -432,9 +433,14 @@ public class CommonServiceImpl {
} }
} }
if (!ObjectUtils.isEmpty(shouldQuerCondtion)) { if (!ObjectUtils.isEmpty(shouldQuerCondtion)) {
for (String key : shouldQuerCondtion.keySet()) { BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
queryBuilder.should(QueryBuilders.wildcardQuery(key, shouldQuerCondtion.get(key))); shouldQuerCondtion.forEach(e->{
for (String key : e.keySet()) {
boolQueryBuilder.should(QueryBuilders.wildcardQuery(key, e.get(key)));
} }
});
boolQueryBuilder.minimumShouldMatch(1);
queryBuilder.must(boolQueryBuilder);
} }
if (!ObjectUtils.isEmpty(likeQuerCondtion)) { if (!ObjectUtils.isEmpty(likeQuerCondtion)) {
...@@ -442,15 +448,33 @@ public class CommonServiceImpl { ...@@ -442,15 +448,33 @@ public class CommonServiceImpl {
queryBuilder.must(QueryBuilders.wildcardQuery(key, "*" + likeQuerCondtion.get(key) + "*")); queryBuilder.must(QueryBuilders.wildcardQuery(key, "*" + likeQuerCondtion.get(key) + "*"));
} }
} }
// 如果只对一个字段进行分组写一个就好
TermsAggregationBuilder tb1 = AggregationBuilders.terms("group_day").field("day.keyword");// gatewayId
tb1.subAggregation(AggregationBuilders.sum("sum_valueDouble").field("value"));
Query query = new NativeSearchQueryBuilder() Query query = new NativeSearchQueryBuilder()
.withQuery(queryBuilder) .withQuery(queryBuilder).addAggregation(tb1)
.build(); .build();
query.setTrackTotalHits(true); query.setTrackTotalHits(true);
SearchHits search = elasticsearchTemplate.search(query, tClass); SearchHits search = elasticsearchTemplate.search(query, tClass);
if (search.hasSearchHits()) { if (search.hasSearchHits()) {
List<SearchHit<T>> searchHitList = search.getSearchHits(); List<SearchHit<T>> searchHitList = search.getSearchHits();
List<T> list = searchHitList.stream().map(hit -> hit.getContent()).collect(Collectors.toList()); Terms groupDayAgg = search.getAggregations().get("group_day");
return list; TreeMap<String, Double> groupedSums = new TreeMap<>();
for (Terms.Bucket entry : groupDayAgg.getBuckets()) {
// 获取分组的键(即 "day" 字段的值)
String day = entry.getKeyAsString();
// 获取该分组下的 "sum_valueDouble" 聚合结果
Sum sumAgg = entry.getAggregations().get("sum_valueDouble");
double sumValue = sumAgg.getValue();
// 在这里处理每个分组和对应的总和
// 例如,你可以将它们存储在一个Map中,键是日期,值是总和
groupedSums.put(day, sumValue);
}
return groupedSums;
} }
return null; return null;
} }
......
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESMoonPowerGeneration;
import com.yeejoin.amos.boot.module.jxiop.biz.constants.CommonConstans;
import com.yeejoin.amos.boot.module.jxiop.biz.mapper2.CommonMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class EarningsForecastImpl {
@Autowired
private CommonServiceImpl commonService;
@Autowired
private CommonMapper commonMapper;
@Value("${forecast.url}")
private String forecastUrl;
@Autowired
private StationBasicMapper stationBasicMapper;
public Object earningsForecast (Long stationId, String type){
List<Map<String, String>> list = commonMapper.selectAgo10Month();
List<Map<String, String>> lastThreeMonth = commonMapper.selectLast3Month();
Map<String, List<String>> queryCondtion1 = new HashMap<>();
StationBasic stationBasic = stationBasicMapper.selectById(stationId);
if (type.equals("FDZ")){
queryCondtion1.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getFanGatewayId()));
}else {
queryCondtion1.put(CommonConstans.QueryStringGateWayId,Arrays.asList(stationBasic.getBoosterGatewayId()));
}
List<Map<String, String>> objects = new ArrayList<>();
TreeMap<String, String> months= new TreeMap<>();
list.forEach(e->{
Map<String, String> likeQueryCondtion = new HashMap<>();
likeQueryCondtion.put("id.keyword",e.get("MonthYear")+"*");
objects.add(likeQueryCondtion);
String key = e.get("MonthYear").split("-")[1];
months.put(String.valueOf(Integer.parseInt(key)),e.get("MonthYear"));
});
TreeMap<String, Double> map = commonService.getListDataByCondtionsSum(queryCondtion1,objects, ESMoonPowerGeneration.class,null);
TreeMap<String, Double> carbonDioxide = new TreeMap<>();
TreeMap<String, Double> standardCoal = new TreeMap<>();
TreeMap<String, Double> toner = new TreeMap<>();
TreeMap<String, Double> sulfurDioxide = new TreeMap<>();
//计算历史月发电量的收益
map.keySet().forEach(e->{
carbonDioxide.put(months.get(e), Double.valueOf(String.format("%.3f",map.get(e) * CommonConstans.carbonDioxide)));
standardCoal.put(months.get(e),Double.valueOf(String.format("%.3f",map.get(e) * CommonConstans.standardCoal)));
toner.put(months.get(e),Double.valueOf(String.format("%.3f",map.get(e) * CommonConstans.toner)));
sulfurDioxide.put(months.get(e),Double.valueOf(String.format("%.3f",map.get(e) * CommonConstans.sulfurDioxide)));
});
List<TreeMap<String,List<List<String>>>> resultList = new ArrayList<>();
TreeMap<String,List<List<String>>> Co2Map = new TreeMap();
TreeMap<String,List<List<String>>> standardCoalMap = new TreeMap();
TreeMap<String,List<List<String>>> tonerMap = new TreeMap();
TreeMap<String,List<List<String>>> sulfurDioxideMap = new TreeMap();
TreeMap<String,List<List<String>>> Co2ForecastMap = new TreeMap();
TreeMap<String,List<List<String>>> standardCoalForecastMap = new TreeMap();
TreeMap<String,List<List<String>>> tonerForecastMap = new TreeMap();
TreeMap<String,List<List<String>>> sulfurDioxideForecastMap = new TreeMap();
//组装历史数据折线图数据
List<List<String>> Co2List = this.buildResultData(carbonDioxide);
Co2Map.put("data",Co2List);
List<List<String>> standardCoalList = this.buildResultData(standardCoal);
standardCoalMap.put("data",standardCoalList);
List<List<String>> tonerList = this.buildResultData(toner);
tonerMap.put("data",tonerList);
List<List<String>> sulfurDioxideList = this.buildResultData(sulfurDioxide);
sulfurDioxideMap.put("data",sulfurDioxideList);
//查询预测收益接口
JSONObject carbonDioxideData = getResponse("二氧化碳减排量", carbonDioxide.values().stream().collect(Collectors.toList()));
JSONObject standardCoalData = getResponse("标准煤减排量", standardCoal.values().stream().collect(Collectors.toList()));
JSONObject tonerData = getResponse("炭粉尘减排量", toner.values().stream().collect(Collectors.toList()));
JSONObject sulfurDioxideData = getResponse("二氧化硫减排量", sulfurDioxide.values().stream().collect(Collectors.toList()));
//将预测返回的数据组装成组件需要的格式
List<List<String>> carbonDioxideList = this.buildData(lastThreeMonth, carbonDioxideData, Co2List);
Co2ForecastMap.put("data",carbonDioxideList);
List<List<String>> standardCoalLists = this.buildData(lastThreeMonth, standardCoalData, standardCoalList);
standardCoalForecastMap.put("data",standardCoalLists);
List<List<String>> tonerLists = this.buildData(lastThreeMonth, tonerData, tonerList);
tonerForecastMap.put("data",tonerLists);
List<List<String>> sulfurDioxideLists = this.buildData(lastThreeMonth, sulfurDioxideData, sulfurDioxideList);
sulfurDioxideForecastMap .put("data",sulfurDioxideLists);
resultList.add(Co2Map);
resultList.add(standardCoalMap);
resultList.add(tonerMap);
resultList.add(sulfurDioxideMap);
resultList.add(Co2ForecastMap);
resultList.add(standardCoalForecastMap);
resultList.add(tonerForecastMap);
resultList.add(sulfurDioxideForecastMap);
return resultList;
}
List<List<String>> buildResultData( TreeMap<String, Double> map){
List<List<String>> lists = new ArrayList<>();
map.keySet().forEach(e->{
List<String> list = Arrays.asList(e, String.valueOf(map.get(e)));
lists.add(list);
});
return lists;
}
String buildParams(String name, List<Double> values){
HashMap<Object, Object> requestParams = new HashMap<>();
HashMap<Object, Object> valueLabel = new HashMap<>();
HashMap<Object, Object> value = new HashMap<>();
value.put("值",values);
valueLabel.put(name,value);
value.put("名称",name);
HashMap<Object, Object> params = new HashMap<>();
HashMap<Object, Object> basic = new HashMap<>();
HashMap<Object, Object> dispPrecision = new HashMap<>();
dispPrecision.put("disp_precision",3);
params.put("config",dispPrecision);
basic.put("data",name);
basic.put("seasonal_length",values.size()/2);
basic.put("model_type","additive");
basic.put("model_component_type","seasonal_only");
basic.put("is_generate_forecast",true);
basic.put("forecast_number","3");
params.put("basic",basic);
requestParams.put("params",params);
requestParams.put("dataset",valueLabel);
return JSON.toJSONString(requestParams);
}
JSONObject getResponse(String name, List<Double> values){
String requestParam=buildParams(name,values);
Map<String, String> hashMaphead = new HashMap<>();
hashMaphead.put("Content-Type","application/x-www-form-urlencoded;charset=utf-8");
String respone = HttpUtil.createPost(forecastUrl).headerMap(hashMaphead, false).
body(requestParam).execute().body();
return JSONObject.parseObject(respone);
}
List<List<String>> buildData(List<Map<String, String>> data,JSONObject obj,List<List<String>> lists ){
List<List<String>> newList = new ArrayList<>();
newList.addAll(lists);
JSONObject dataObject = obj.getJSONObject("data");
// 从data对象中提取forecast和history数组
JSONArray forecastArray = dataObject.getJSONArray("forecast");
for (int i = 0; i < forecastArray.size(); i++) {
List<String> list = Arrays.asList(data.get(i).get("MonthYear"),forecastArray.getString(i));
newList.add(list);
}
return newList;
}
}
<?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.jxiop.biz.mapper2.CommonMapper">
<select id="selectAgo10Month" resultType="map">
WITH RECURSIVE month_sequence AS (
SELECT 0 AS num
UNION ALL
SELECT num + 1 FROM month_sequence WHERE num &lt; 9
)
SELECT DATE_FORMAT(DATE_SUB(NOW(), INTERVAL (num + 1) MONTH), '%Y-%m') AS MonthYear
FROM month_sequence
ORDER BY MonthYear DESC;
</select>
<select id="selectLast3Month" resultType="map">
WITH RECURSIVE month_sequence AS (
SELECT 0 AS num
UNION ALL
SELECT num + 1 FROM month_sequence WHERE num &lt; 2
)
SELECT DATE_FORMAT(DATE_SUB(NOW(), INTERVAL -(num ) MONTH), '%Y-%m') AS MonthYear
FROM month_sequence
ORDER BY MonthYear ASC;
</select>
</mapper>
package com.yeejoin.amos.boot.module.jxiop.api.amosprojectmapper;
public interface CompanyMapper {
public String getAreaCompanyCode(String code);
}
package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.common.biz.utils.CommonResponseUtil;
import com.yeejoin.amos.boot.module.jxiop.api.dto.StationBasicDto;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.MonitorFanIndicatorMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.api.util.CommonResponse;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments;
import com.yeejoin.amos.boot.module.jxiop.biz.constants.CommonConstans;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.AppletMonitorServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.MonitorFanIndicatorImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.*;
@RestController
@Api(tags = "小程序-监盘")
@RequestMapping(value = "/applet")
public class AppletMonitorController {
@Autowired
AppletMonitorServiceImpl appletMonitorService;
@Autowired
StationBasicMapper stationBasicMapper;
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "风机布置图-总概览")
@GetMapping("/CockpitData")
public ResponseModel<Map<String, Object>> getData(@RequestParam(value = "code") String code,
@RequestParam(value = "level") String level) {
if ("station".equals(level)){
StationBasicDto stationBasic = stationBasicMapper.getStationInfoByCode(code);
if (stationBasic.getStationType().equals("FDZ")) {
return ResponseHelper.buildResponse(appletMonitorService.getFanStationInfo(stationBasic));
}else {
return ResponseHelper.buildResponse(appletMonitorService.getPvStationInfo(stationBasic));
}
}else {
return ResponseHelper.buildResponse(appletMonitorService.getAreaInfo(code));
}
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.jxiop.api.dto.StationBasicDto;
import com.yeejoin.amos.boot.module.jxiop.api.feign.IdxFeign;
import com.yeejoin.amos.boot.module.jxiop.api.amosprojectmapper.CompanyMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments;
import com.yeejoin.amos.boot.module.jxiop.biz.constants.CommonConstans;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.ESEquipmentsDTO;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.component.robot.AmosRequestContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class AppletMonitorServiceImpl {
@Autowired
CommonServiceImpl commonServiceImpl;
@Autowired
StationBasicMapper stationBasicMapper;
@Autowired
CompanyMapper companyMapper;
@Autowired
CommonServiceImpl commonService;
@Autowired
MonitorFanIndicatorImpl monitorFanIndicator;
@Autowired
IdxFeign idxFeign;
@Autowired
AmosRequestContext requestContext;
public Map<String,Object> getFanStationInfo(StationBasicDto stationBasic ){
String gatewayId = stationBasic.getFanGatewayId();
Map<String, Object> columnMap = new HashMap<>();
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("30秒平均风速", "日发电量", "月发电量", "年发电量"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(gatewayId));
List<ESEquipments> result2 = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
columnMap.put("日发电量", String.format(CommonConstans.Fourdecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result2, "日发电量")));
columnMap.put("月发电量", String.format(CommonConstans.Fourdecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result2, "月发电量")));
columnMap.put("年发电量", String.format(CommonConstans.Fourdecimalplaces, commonServiceImpl.getSumByEquipmentIndxName(result2, "年发电量")));
columnMap.put("30秒平均风速", String.format(CommonConstans.Twodecimalplaces, commonServiceImpl.getAvagerByEquipmentIndxName(result2, "30秒平均风速")));
Map<String, List<String>> queryCondtion1 = new HashMap<>();
queryCondtion1.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("220kV夏雩线212线路测控装置PCS-9705TA有功功率一次值"));
queryCondtion1.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getBoosterGatewayId()));
List<ESEquipments> result1 = commonService.getListDataByCondtions(queryCondtion1, null, ESEquipments.class);
columnMap.put("有功功率", String.format("%.2f", result1.get(0).getValueF()));
String num = monitorFanIndicator.getEquipCount(gatewayId, "FDZ");
columnMap.put("风机台数", num);
Double capacityl = commonService.getStationCapactityByStationWerks(stationBasic.getStationNumber());
columnMap.put("装机容量", String.format("%.2f", capacityl));
Map<String, Object> data = new HashMap<>();
data.put("installedCapacity", columnMap.get("装机容量").toString());
data.put("dayPowerGeneration", columnMap.get("日发电量").toString());
data.put("equipNum", columnMap.get("风机台数").toString().replace(".0", ""));
data.put("monthPowerGeneration", columnMap.get("月发电量").toString());
data.put("windSpeed", columnMap.get("30秒平均风速").toString());
data.put("yearPowerGeneration", columnMap.get("年发电量").toString());
data.put("activePower", columnMap.get("有功功率"));
data.put("dailyUseOfHour", String.format("%.2f", ((Double.parseDouble(columnMap.get("日发电量").toString()) * 10) / (Double.parseDouble(columnMap.get("装机容量").toString())))));
//风机运行 及 停机
List<ESEquipmentsDTO> equipmentsDTOS = monitorFanIndicator.getFanStatusList(String.valueOf(stationBasic.getSequenceNbr()));
Map<String, Long> countMap = equipmentsDTOS.stream()
.collect(Collectors.groupingBy(ESEquipmentsDTO::getAddress, Collectors.counting()));
data.put("closeNum", countMap.containsKey("停机状态") ? String.valueOf(countMap.get("停机状态")) : "0");
data.put("operationNum",Integer.parseInt(num) - Integer.parseInt(data.get("closeNum").toString()));
Map<String, Object> stationMark = idxFeign.getStationMarkList(stationBasic.getProjectOrgCode(),"1","4");
// Map<String, Object> result = stationMark.getResult();
List<String> list = Arrays.asList("P1", "S1", "H2", "V1");
// P1 工况管控分数 S1 设备管控分数 H2 其他分数 V1 人员管控分数
list.forEach(e->{
data.put(e,stationMark.get(e));
});
data.put("value",stationMark.get("value"));
return data;
}
public Map<String,Object> getPvStationInfo(StationBasicDto stationBasic){
String gatewayId = stationBasic.getFanGatewayId();
String boosterGatewayId = stationBasic.getBoosterGatewayId();
String[] columnList = new String[]{CommonConstans.taiHeGenIndicatorDay, CommonConstans.taiHeGenIndicatorMonth, CommonConstans.taiHeGenIndicatorYear};
Map<String, Object> columnMap = new HashMap<>();
//日 月 年发电量同仅统计逆变器数据
List<Map<String, Object>> mapList;
for (String column : columnList) {
Double result = commonService.getTotalByIndicatiorByGF(boosterGatewayId, column);
columnMap.put(column, result);
}
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("南瑞光差保护_313P", "WTX-801_25_WTX-801_总辐射累计", "WTX-801_25_WTX-801_总辐射", "313光差保护_总反向有功电度"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationBasic.getBoosterGatewayId()));
List<ESEquipments> result1 = commonService.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
columnMap.put("有功功率", String.format("%.2f", commonService.getSumByEquipmentIndxName(result1, "南瑞光差保护_313P") * CommonConstans.kwToMv));
String num = monitorFanIndicator.getEquipCount(gatewayId, "GF");
columnMap.put("风机台数", num);
Double capacityl = commonService.getStationCapactityByStationWerks(stationBasic.getStationNumber());
//装机容量保留两位小数
columnMap.put("装机容量", String.format("%.2f", capacityl));
Map<String, Object> data = new HashMap<>();
data.put("installedCapacity", columnMap.get("装机容量").toString());
data.put("dayPowerGeneration", columnMap.get(CommonConstans.taiHeGenIndicatorDay).toString());
data.put("equipNum", columnMap.get("风机台数").toString().replace(".0", ""));
data.put("monthPowerGeneration", columnMap.get(CommonConstans.taiHeGenIndicatorMonth).toString());
data.put("irradiation", String.format("%.2f", commonService.getSumByEquipmentIndxName(result1, "WTX-801_25_WTX-801_总辐射")));
data.put("yearPowerGeneration", columnMap.get(CommonConstans.taiHeGenIndicatorYear).toString());
data.put("activePower", columnMap.get("有功功率").toString());
data.put("dailyUseOfHour", String.format("%.2f", ((Double.parseDouble(columnMap.get(CommonConstans.taiHeGenIndicatorDay).toString()) * CommonConstans.wkwhToMv) / (Double.parseDouble(columnMap.get("装机容量").toString())))));
data.put("globalRadiation", String.format("%.2f", commonService.getSumByEquipmentIndxName(result1, "WTX-801_25_WTX-801_总辐射累计")));
//综合效率 = 发电量/理论发电量
//理论发电量 = 峰值日照数 * 总装机容量
//峰值日照数 = 累计辐照度/3.6
Double todayPower = Double.valueOf(columnMap.get(CommonConstans.taiHeGenIndicatorDay).toString());
Double total = commonService.getSumByEquipmentIndxName(result1, "WTX-801_25_WTX-801_总辐射累计");
if (todayPower > 0 && total > 0) {
Double overallEfficiency = todayPower * CommonConstans.wkwhToMv / ((total / 3.6) * capacityl);
data.put("combinedEfficiency", String.format("%.2f", overallEfficiency * 100) + "%");//综合效率
} else {
data.put("combinedEfficiency", "0.00%");//综合效率
}
Map<String, Object> stationMark = idxFeign.getStationMarkList(stationBasic.getProjectOrgCode(),"1","4");
List<String> list = Arrays.asList("P1", "S1", "H2", "V1");
// P1 工况管控分数 S1 设备管控分数 H2 其他分数 V1 人员管控分数
list.forEach(e->{
data.put(e,stationMark.get(e));
});
data.put("value",stationMark.get("value"));
return data;
}
public Map<String,Object> getAreaInfo(String code) {
List<StationBasicDto> stations = stationBasicMapper.getStationsByAreaCode(code);
Map<String, Object> result = new HashMap<>();
//全部场站的总装机容量
double installedCapacity = stations.stream().mapToDouble(StationBasicDto::getInstalledCapacity).sum();
result.put("installedCapacity",String.format("%.2f",installedCapacity));
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("南瑞光差保护_313P", "WTX-801_25_WTX-801_总辐射累计", "WTX-801_25_WTX-801_总辐射", "313光差保护_总反向有功电度"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, stations.stream().map(StationBasicDto::getBoosterGatewayId).collect(Collectors.toList()));
List<ESEquipments> result1 = commonService.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
List<StationBasicDto> fdz = stations.stream().filter(e -> e.getStationType().equals("FDZ")).collect(Collectors.toList());
Map<String, List<String>> queryCondtion2 = new HashMap<>();
queryCondtion2.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("220kV夏雩线212线路测控装置PCS-9705TA有功功率一次值"));
queryCondtion2.put(CommonConstans.QueryStringGateWayId, Arrays.asList(fdz.get(0).getBoosterGatewayId()));
List<ESEquipments> result2 = commonService.getListDataByCondtions(queryCondtion2, null, ESEquipments.class);
stations.removeAll(fdz);
List<Map<String,Object>> list = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
data.put("type","风电");
data.put("installedCapacity",String.format("%.2f",fdz.stream().mapToDouble(StationBasicDto::getInstalledCapacity).sum()));
data.put("num",stations.size());
data.put("activePower",String.format("%.2f", result2.get(0).getValueF()));
list.add(data);
Map<String, Object> data2 = new HashMap<>();
data2.put("type","光伏");
data2.put("installedCapacity",String.format("%.2f",stations.stream().mapToDouble(StationBasicDto::getInstalledCapacity).sum()));
data2.put("num",fdz.size());
data2.put("activePower",String.format("%.2f", commonService.getSumByEquipmentIndxName(result1, "南瑞光差保护_313P") * CommonConstans.kwToMv));
list.add(data2);
result.put("stationList",list);
result.put("activePower",commonService.getSumByEquipmentIndxName(result1, "南瑞光差保护_313P") * CommonConstans.kwToMv+result2.get(0).getValueF());
double fzl = (commonService.getSumByEquipmentIndxName(result1, "南瑞光差保护_313P") * CommonConstans.kwToMv+result2.get(0).getValueF())/installedCapacity;
String load = String.format(CommonConstans.Fourdecimalplaces, fzl);
result.put("load",load);
String areaCompanyCode = companyMapper.getAreaCompanyCode(code);
Map<String, Object> stationMark = idxFeign.getStationMarkList(areaCompanyCode,"1","4");
List<String> params = Arrays.asList("P1", "S1", "H2", "V1");
// P1 工况管控分数 S1 设备管控分数 H2 其他分数 V1 人员管控分数
params.forEach(e->{
result.put(e,stationMark.get(e));
});
result.put("value",stationMark.get("value"));
//获取区域场站排名
FeignClientResult<Map<String, Object>> map = idxFeign.stationRanking(1L, Long.MAX_VALUE, "FDZ", areaCompanyCode);
FeignClientResult<Map<String, Object>> map1 = idxFeign.stationRanking(1L, Long.MAX_VALUE, "JZSGFDZ", areaCompanyCode);;
Map<String, Object> result3 = map.getResult();
Map<String, Object> result4 = map1.getResult();
result.put("rankingFD", result3.get("records"));
result.put("rankingGF", result4.get("records"));
Map<String, List<String>> queryCondtion1 = new HashMap<>();
List<String> collect = fdz.stream().map(StationBasicDto::getFanGatewayId).collect(Collectors.toList());
collect.addAll(stations.stream().map(StationBasicDto::getBoosterGatewayId).collect(Collectors.toList()));
queryCondtion1.put(CommonConstans.QueryStringGateWayId, collect);
Map<String, String> likeMap = new HashMap<String, String>();
likeMap.put(CommonConstans.QueryStringEquipmentIndexName, "发电量");
List<ESEquipments> resultWarn = commonServiceImpl.getListDataByCondtions(queryCondtion1, null,
ESEquipments.class, likeMap);
double dayPowerGeneration = resultWarn.stream().filter(e -> e.getEquipmentIndexName().contains("日发电量")).mapToDouble(ESEquipments::getValueF).sum();
double monthPowerGeneration = resultWarn.stream().filter(e -> e.getEquipmentIndexName().contains("月发电量")).mapToDouble(ESEquipments::getValueF).sum();
double yearPowerGeneration = resultWarn.stream().filter(e -> e.getEquipmentIndexName().contains("年发电量")).mapToDouble(ESEquipments::getValueF).sum();
result.put("dayPowerGeneration",String.format("%.4f",dayPowerGeneration));
result.put("monthPowerGeneration",String.format("%.4f",monthPowerGeneration));
result.put("yearPowerGeneration",String.format("%.4f",yearPowerGeneration));
return result;
}
}
<?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.jxiop.api.amosprojectmapper.CompanyMapper">
<select id="getAreaCompanyCode" resultType="string">
select
ORG_CODE
from
privilege_company
where
COMPANY_CODE = #{code}
and
LEVEL = 'area'
and IS_DELETED = 0
</select>
</mapper>
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