Commit 0938a0f3 authored by chenzhao's avatar chenzhao

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

parents 4ed14472 0bbfedb7
......@@ -8,7 +8,7 @@ import java.util.List;
public interface TanYinCustomerInfoMapper extends BaseMapper<TanYinCustomerInfo> {
@Select("select project_no from tanyin_customer_info group by project_no")
@Select("select project_no from house_pv_data.tanyin_customer_info group by project_no")
List<String> listProjectNo();
}
package com.yeejoin.amos.api.householdapi.face.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapBuilder;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageInfo;
import com.yeejoin.amos.api.householdapi.Utils.RedisUtils;
import com.yeejoin.amos.api.householdapi.Utils.TanYinApiUtils;
import com.yeejoin.amos.api.householdapi.constant.TanYinConstant;
import com.yeejoin.amos.api.householdapi.face.dto.SunlightDto;
import com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.hygf.JpCollector;
import com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.hygf.JpInverter;
import com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.hygf.JpInverterElectricity;
import com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.hygf.JpStation;
......@@ -175,7 +179,6 @@ public class TanYinDataAcquisitionServiceImpl implements TanYinDataAcquisitionSe
*/
@Scheduled (cron = "${dataRequestScheduled.tanYin}")
@Override
public void customerInfoList() {
try {
String startDate = LocalDate.now().minusMonths(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
......@@ -236,16 +239,17 @@ public class TanYinDataAcquisitionServiceImpl implements TanYinDataAcquisitionSe
for (List<String> projectNoList : projectNoLists) {
Map<String, Object> params = MapBuilder.<String, Object>create().put("projectNoList", projectNoList).put("powerDate", powerDate).build();
List<TanYinStationInfo> tanYinStationInfoList = tanYinApiUtils.post("电站基本信息", apiUrl + TanYinConstant.stationListUrl, params, null, TanYinStationInfo.class);
if (CollectionUtils.isEmpty(tanYinStationInfoList)) {
continue;
}
if (!CollectionUtils.isEmpty(tanYinStationInfoList)) {
tanYinStationInfos.addAll(tanYinStationInfoList);
}
}
if (CollectionUtils.isEmpty(tanYinStationInfos)) {
log.warn("-------碳银同步电站结束: 未同步到电站基本信息 -------");
return;
}
List<String> stationIds = tanYinStationInfos.stream().map(TanYinStationInfo::getProjectNo).collect(Collectors.toList());
//删除多余的场站
deleteTyMessage(stationIds);
List<JpStation> jpStations = jpStationMapper.selectList(new QueryWrapper<JpStation>().eq("third_code", PVProducerInfoEnum.TANYIN.getCode()).in("third_station_id", stationIds));
Map<String, JpStation> jpStationMap = jpStations.stream().collect(Collectors.toMap(JpStation::getThirdStationId, Function.identity()));
......@@ -433,6 +437,45 @@ public class TanYinDataAcquisitionServiceImpl implements TanYinDataAcquisitionSe
}
private void deleteTyMessage(List<String> stationIds) {
// 所有场站信息
if(CollectionUtil.isNotEmpty(stationIds)){
//场站
QueryWrapper<JpStation> wrapper = new QueryWrapper<JpStation>().eq("third_code", PVProducerInfoEnum.TANYIN.getCode());
List<JpStation> jpStations = jpStationMapper.selectList(wrapper);
if(CollectionUtil.isNotEmpty(jpStations)){
for (JpStation jpStation : jpStations) {
if(!stationIds.contains(jpStation.getThirdStationId())){
//删除多余数据
jpStationMapper.deleteById(jpStation.getSequenceNbr());
}
}
}
//采集器
QueryWrapper<JpCollector> wrapper1 = new QueryWrapper<JpCollector>().eq("third_code", PVProducerInfoEnum.TANYIN.getCode());
List<JpCollector> jpCollectors = jpCollectorMapper.selectList(wrapper1);
if(CollectionUtil.isNotEmpty(jpCollectors)){
for (JpCollector jpCollector : jpCollectors) {
if(!stationIds.contains(jpCollector.getThirdStationId())){
//删除多余数据
jpCollectorMapper.deleteById(jpCollector.getSequenceNbr());
}
}
}
//逆变器
QueryWrapper<JpInverter> wrapper2 = new QueryWrapper<JpInverter>().eq("third_code", PVProducerInfoEnum.TANYIN.getCode());
List<JpInverter> jpInverters = jpInverterMapper.selectList(wrapper2);
if(CollectionUtil.isNotEmpty(jpInverters)){
for (JpInverter jpInverter : jpInverters) {
if(!stationIds.contains(jpInverter.getThirdStationId())){
//删除多余数据
jpInverterMapper.deleteById(jpInverter.getSequenceNbr());
}
}
}
}
}
@Override
public void inverterList() {
......
......@@ -294,7 +294,8 @@ public class SurveyInformationServiceImpl
}
peasantHousehold
.setPermanentAddressName(permanentAddressName.substring(0, permanentAddressName.length() - 1));
powerStation.setProjectAddress(projectAddressName.substring(0, projectAddressName.length() - 1));
powerStationMapper.updateById(powerStation);
if (OPERATION_TYPE_SUBMIT.equals(operationType)) {
// peasantHousehold.setSurveyOrNot(1);
} else if (OPERATION_TYPE_APPLY.equals(operationType)) {
......
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