|
|
@@ -5,11 +5,13 @@ import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.kym.common.enums.EnPlusApi;
|
|
|
import com.kym.common.utils.AESUtil;
|
|
|
+import com.kym.entity.admin.EquipmentInfo;
|
|
|
import com.kym.entity.admin.Station;
|
|
|
import com.kym.entity.admin.vo.StationVo;
|
|
|
import com.kym.entity.enplus.EnStationStatsInfo;
|
|
|
import com.kym.entity.enplus.EnStationStatusInfo;
|
|
|
import com.kym.mapper.admin.StationMapper;
|
|
|
+import com.kym.service.admin.EquipmentInfoService;
|
|
|
import com.kym.service.admin.StationService;
|
|
|
import com.kym.service.enplus.EnPlusService;
|
|
|
import com.kym.service.utils.KymCache;
|
|
|
@@ -21,6 +23,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
@@ -38,12 +41,15 @@ public class StationServiceImpl extends ServiceImpl<StationMapper, Station> impl
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(StationServiceImpl.class);
|
|
|
private final KymCache kymCache;
|
|
|
|
|
|
+ private final EquipmentInfoService equipmentInfoService;
|
|
|
+
|
|
|
|
|
|
private final EnPlusService enPlusService;
|
|
|
|
|
|
- public StationServiceImpl(@Lazy KymCache kymCache, EnPlusService enPlusService) {
|
|
|
+ public StationServiceImpl(@Lazy KymCache kymCache, EnPlusService enPlusService, EquipmentInfoService equipmentInfoService) {
|
|
|
this.kymCache = kymCache;
|
|
|
this.enPlusService = enPlusService;
|
|
|
+ this.equipmentInfoService = equipmentInfoService;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -109,12 +115,25 @@ public class StationServiceImpl extends ServiceImpl<StationMapper, Station> impl
|
|
|
public void pullEnStationInfos() {
|
|
|
var stationVoList = queryStationInfo(1, 1000);
|
|
|
var stationList = new ArrayList<Station>();
|
|
|
+ var equipmentList = new ArrayList<EquipmentInfo>();
|
|
|
stationVoList.forEach(vo -> {
|
|
|
+ if(vo.getEquipmentInfos().size()>0){
|
|
|
+ vo.getEquipmentInfos().forEach(item -> {
|
|
|
+ var equipment = new EquipmentInfo()
|
|
|
+ .setStationId(vo.getStationId())
|
|
|
+ .setShortId(item.getShortId())
|
|
|
+ .setPower(item.getConnectorInfos().get(0).getPower());
|
|
|
+ BeanUtils.copyProperties(item, equipment);
|
|
|
+ equipmentList.add(equipment);
|
|
|
+ });
|
|
|
+ equipmentList.sort(Comparator.comparing(EquipmentInfo::getShortId));
|
|
|
+ }
|
|
|
var station = new Station();
|
|
|
BeanUtils.copyProperties(vo, station);
|
|
|
stationList.add(station);
|
|
|
});
|
|
|
- saveOrUpdateBatch(stationList);
|
|
|
+ // saveBatch(stationList);
|
|
|
+ equipmentInfoService.saveBatch(equipmentList);
|
|
|
}
|
|
|
|
|
|
}
|