| | |
| | | import com.ruoyi.chargingPile.api.vo.SiteDetailVO; |
| | | import com.ruoyi.chargingPile.api.vo.SiteVO; |
| | | import com.ruoyi.chargingPile.api.domain.SiteMenu; |
| | | import com.ruoyi.chargingPile.dto.SiteExcelDTO; |
| | | import com.ruoyi.chargingPile.dto.SiteImportErrorDTO; |
| | | import com.ruoyi.chargingPile.dto.SiteImportResultDTO; |
| | | import com.ruoyi.chargingPile.mapper.SiteMapper; |
| | | import com.ruoyi.chargingPile.service.*; |
| | | import com.ruoyi.chargingPile.util.UUIDUtil; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.utils.poi.ExcelUtil; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.integration.api.elutong.model.*; |
| | | import com.ruoyi.integration.api.feignClient.ELuTongClient; |
| | | import com.ruoyi.integration.api.feignClient.IntegrationClient; |
| | | import com.ruoyi.integration.api.feignClient.TCECClient; |
| | | import com.ruoyi.integration.api.feignClient.*; |
| | | import com.ruoyi.other.api.domain.TVip; |
| | | import com.ruoyi.other.api.domain.Region; |
| | | import com.ruoyi.other.api.feignClient.OtherClient; |
| | | import com.ruoyi.other.api.feignClient.RoleSiteClient; |
| | | import com.ruoyi.other.api.feignClient.UserSiteClient; |
| | | import com.ruoyi.other.api.feignClient.VipClient; |
| | |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import com.ruoyi.system.api.feignClient.SysUserRoleClient; |
| | | import com.ruoyi.system.api.model.SysUserRoleVo; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.InputStream; |
| | | import java.math.BigDecimal; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | import java.util.concurrent.LinkedBlockingDeque; |
| | | import java.util.concurrent.LinkedBlockingQueue; |
| | | import java.util.concurrent.ThreadPoolExecutor; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | |
| | | * @author zhibing.pu |
| | | * @Date 2024/8/7 19:54 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class SiteServiceImpl extends ServiceImpl<SiteMapper, Site> implements ISiteService { |
| | | |
| | | static final int SITE_IMPORT_TITLE_ROWS = 1; |
| | | |
| | | @Resource |
| | | private TChargingGunService chargingGunService; |
| | |
| | | @Resource |
| | | private RoleSiteClient roleSiteClient; |
| | | @Resource |
| | | private OtherClient otherClient; |
| | | @Resource |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private AppUserClient appUserClient; |
| | |
| | | |
| | | @Resource |
| | | private TAccountingStrategyDetailService accountingStrategyDetailService; |
| | | @Resource |
| | | private TAccountingStrategyService accountingStrategyService; |
| | | |
| | | @Resource |
| | | private TPartnerSiteService partnerSiteService; |
| | |
| | | private TCECClient tcecClient; |
| | | |
| | | @Resource ELuTongClient eLuTongClient; |
| | | |
| | | |
| | | @Resource |
| | | private ChengDuJianGuanClient chengDuJianGuanClient; |
| | | @Resource |
| | | private DongFuStationClient dongFuStationClient; |
| | | |
| | | |
| | | /** |
| | | * 获取站点管理列表数据 |
| | |
| | | //非管理员需要根据角色和用户配置查询允许的站点数据 |
| | | //改用roleId=1来判断 |
| | | if(admin.getData()!=1){ |
| | | List<Integer> data = userSiteClient.getSiteIds(sysUser.getUserId()).getData(); |
| | | List<SysUserRoleVo> data2 = sysUserRoleClient.getRoleByUserId(sysUser.getUserId()).getData(); |
| | | if(data2.size() > 0){ |
| | | List<Integer> data1 = roleSiteClient.getSiteIds(data2.get(0).getRoleId()).getData(); |
| | | data.addAll(data1); |
| | | } |
| | | ids = new HashSet<>(data); |
| | | ids = getAssignedSiteIds(sysUser.getUserId()); |
| | | } |
| | | } |
| | | PageInfo<GetSiteListDTO> pageInfo = new PageInfo<>(siteList.getPageCurr(), siteList.getPageSize()); |
| | |
| | | return pageInfo.setRecords(list); |
| | | } |
| | | |
| | | @Override |
| | | public List<Site> listSitesForExport(GetSiteList siteList) { |
| | | siteList.setPageCurr(1); |
| | | siteList.setPageSize(100000); |
| | | List<Integer> ids = getSiteList(siteList).getRecords().stream() |
| | | .map(GetSiteListDTO::getId) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toList()); |
| | | return ids.isEmpty() ? Collections.emptyList() : listByIds(ids); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public SiteImportResultDTO importSites(MultipartFile file, Boolean cover) throws Exception { |
| | | if (file == null || file.isEmpty()) { |
| | | throw new ServiceException("请选择要导入的Excel文件"); |
| | | } |
| | | ExcelUtil<SiteExcelDTO> util = new ExcelUtil<>(SiteExcelDTO.class); |
| | | List<SiteExcelDTO> rows; |
| | | try (InputStream inputStream = file.getInputStream()) { |
| | | rows = util.importExcel(inputStream, SITE_IMPORT_TITLE_ROWS); |
| | | } catch (Exception e) { |
| | | log.error("站点Excel解析失败,fileName={},size={}", file.getOriginalFilename(), file.getSize(), e); |
| | | ServiceException exception = new ServiceException("Excel文件已损坏或格式不正确,请重新下载站点导入模板后填写") |
| | | .setDetailMessage(e.getMessage()); |
| | | exception.initCause(e); |
| | | throw exception; |
| | | } |
| | | if (rows == null || rows.isEmpty()) { |
| | | throw new ServiceException("导入文件没有数据"); |
| | | } |
| | | |
| | | SysUser sysUser = sysUserClient.getSysUser(tokenService.getLoginUser().getUserid()).getData(); |
| | | Integer roleType = sysUser.getRoleType(); |
| | | Integer objectId = sysUser.getObjectId(); |
| | | Map<String, Partner> partnerMap = partnerService.list(new LambdaQueryWrapper<Partner>().eq(Partner::getDelFlag, 0)).stream() |
| | | .filter(item -> StringUtils.isNotEmpty(item.getName())) |
| | | .collect(Collectors.toMap(item -> normalizeImportValue(item.getName()), item -> item, (a, b) -> a)); |
| | | List<TAccountingStrategy> strategies = accountingStrategyService.list( |
| | | new LambdaQueryWrapper<TAccountingStrategy>().eq(TAccountingStrategy::getDelFlag, 0)); |
| | | Map<String, TAccountingStrategy> strategyMap = strategies.stream().filter(item -> StringUtils.isNotEmpty(item.getName())) |
| | | .collect(Collectors.toMap(item -> normalizeImportValue(item.getName()), item -> item, (a, b) -> a)); |
| | | List<Region> regions = otherClient.listAllRegion().getData(); |
| | | if (regions == null) { |
| | | regions = Collections.emptyList(); |
| | | } |
| | | Map<String, Region> regionByCode = regions.stream().filter(item -> StringUtils.isNotEmpty(item.getCode())) |
| | | .collect(Collectors.toMap(Region::getCode, item -> item, (a, b) -> a)); |
| | | Map<Integer, Region> regionById = regions.stream().filter(item -> item.getId() != null) |
| | | .collect(Collectors.toMap(Region::getId, item -> item, (a, b) -> a)); |
| | | |
| | | SiteImportResultDTO result = new SiteImportResultDTO(); |
| | | List<Site> validRows = new ArrayList<>(); |
| | | Set<String> fileCodes = new HashSet<>(); |
| | | Set<String> duplicateCodes = new LinkedHashSet<>(); |
| | | for (int i = 0; i < rows.size(); i++) { |
| | | SiteExcelDTO row = rows.get(i); |
| | | int rowNum = i + SITE_IMPORT_TITLE_ROWS + 2; |
| | | List<String> errors = validateSiteImportRow(row, partnerMap, strategyMap, regionByCode, regionById, |
| | | roleType, objectId, fileCodes); |
| | | String code = row == null ? null : normalizeImportValue(row.getCode()); |
| | | if (!errors.isEmpty()) { |
| | | result.getErrorMessage().add(new SiteImportErrorDTO(rowNum, code, String.join(";", errors))); |
| | | continue; |
| | | } |
| | | Site site = buildImportedSite(row, partnerMap, strategyMap, regionByCode, regionById); |
| | | Site exists = getOne(new LambdaQueryWrapper<Site>().eq(Site::getCode, site.getCode()).eq(Site::getDelFlag, 0)); |
| | | if (exists != null) { |
| | | duplicateCodes.add(site.getCode()); |
| | | site.setId(exists.getId()); |
| | | site.setMark(exists.getMark()); |
| | | } |
| | | validRows.add(site); |
| | | } |
| | | result.setErrorCount(result.getErrorMessage().size()); |
| | | if (result.getErrorCount() > 0) { |
| | | return result; |
| | | } |
| | | if (!duplicateCodes.isEmpty() && !Boolean.TRUE.equals(cover)) { |
| | | result.setNeedConfirm(true); |
| | | result.setDuplicateCodes(new ArrayList<>(duplicateCodes)); |
| | | return result; |
| | | } |
| | | for (Site site : validRows) { |
| | | site.setDelFlag(false); |
| | | if (site.getId() == null) { |
| | | site.setMark(0); |
| | | save(site); |
| | | result.setSuccessCount(result.getSuccessCount() + 1); |
| | | } else { |
| | | updateById(site); |
| | | result.setUpdateCount(result.getUpdateCount() + 1); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private List<String> validateSiteImportRow(SiteExcelDTO row, Map<String, Partner> partnerMap, |
| | | Map<String, TAccountingStrategy> strategyMap, Map<String, Region> regionByCode, Map<Integer, Region> regionById, |
| | | Integer roleType, Integer objectId, Set<String> fileCodes) { |
| | | List<String> errors = new ArrayList<>(); |
| | | if (row == null) { |
| | | errors.add("空行"); |
| | | return errors; |
| | | } |
| | | String code = normalizeImportValue(row.getCode()); |
| | | String partnerName = normalizeImportValue(row.getPartnerName()); |
| | | Partner partner = partnerMap.get(partnerName); |
| | | if (StringUtils.isEmpty(partnerName)) errors.add("归属合作商/服务商不能为空"); |
| | | else if (partner == null || !Arrays.asList(1, 3).contains(partner.getPartnerType())) errors.add("归属合作商/服务商不存在"); |
| | | else if (Integer.valueOf(2).equals(roleType) && !Objects.equals(objectId, partner.getId())) errors.add("无权导入其他合作商/服务商站点"); |
| | | if (StringUtils.isNotEmpty(row.getVenuePartnerName())) { |
| | | Partner venue = partnerMap.get(normalizeImportValue(row.getVenuePartnerName())); |
| | | if (venue == null || !Integer.valueOf(2).equals(venue.getPartnerType())) errors.add("场地方不存在"); |
| | | } |
| | | if (StringUtils.isEmpty(code)) errors.add("站点编号不能为空"); |
| | | else if (!fileCodes.add(code)) errors.add("导入文件内站点编号重复"); |
| | | if (StringUtils.isEmpty(row.getName())) errors.add("站点名称不能为空"); |
| | | if (row.getSiteType() == null) errors.add("站点类型不能为空"); |
| | | if (row.getBusinessCategory() == null) errors.add("经营类别不能为空"); |
| | | if (row.getStatus() == null) errors.add("站点状态不能为空"); |
| | | if (row.getConstructionSite() == null) errors.add("建设场所不能为空"); |
| | | if (row.getTransformerPower() == null) errors.add("变压器功率不能为空"); |
| | | if (row.getMemberDiscountFlag() == null) errors.add("是否参与会员折扣不能为空"); |
| | | if (StringUtils.isEmpty(row.getAreaCode()) || !regionByCode.containsKey(row.getAreaCode().trim())) { |
| | | errors.add("所在区域行政区划代码不存在"); |
| | | } else { |
| | | Region district = regionByCode.get(row.getAreaCode().trim()); |
| | | Region city = regionById.get(district.getParentId()); |
| | | Region province = city == null ? null : regionById.get(city.getParentId()); |
| | | if (city == null || province == null) errors.add("所在区域必须填写区县级行政区划代码"); |
| | | } |
| | | if (StringUtils.isEmpty(row.getAddress())) errors.add("详细地址不能为空"); |
| | | if (StringUtils.isEmpty(row.getLon())) errors.add("经度不能为空"); |
| | | if (StringUtils.isEmpty(row.getLat())) errors.add("纬度不能为空"); |
| | | if (StringUtils.isEmpty(row.getCountryCode())) errors.add("充电站国家代码不能为空"); |
| | | if (StringUtils.isEmpty(row.getPhone())) errors.add("站点电话不能为空"); |
| | | if (StringUtils.isEmpty(row.getServicePhone())) errors.add("服务电话不能为空"); |
| | | if (row.getParkingSpace() == null) errors.add("车位数量不能为空"); |
| | | if (StringUtils.isEmpty(row.getRateDescription())) errors.add("充电电费描述不能为空"); |
| | | if (row.getSort() == null) errors.add("排序不能为空"); |
| | | if (row.getStationClassification() == null) errors.add("电站分类不能为空"); |
| | | if (row.getRoundTheClock() == null) errors.add("7*24小时营业不能为空"); |
| | | if (row.getParkType() == null) errors.add("停车费类型不能为空"); |
| | | if (row.getElectricityType() == null) errors.add("电费类型不能为空"); |
| | | if (row.getBusinessExpandType() == null) errors.add("报装类型不能为空或填写不正确,请填写独立报装或非独立报装"); |
| | | if (row.getCapacity() == null) errors.add("报装电源容量不能为空"); |
| | | if (row.getRatedPower() == null) errors.add("站点额定总功率不能为空"); |
| | | if (row.getPeriodFee() == null) errors.add("是否峰谷分时不能为空"); |
| | | if (StringUtils.isEmpty(row.getOfficialRunTime())) errors.add("正式投运时间不能为空"); |
| | | if (row.getVideoMonitor() == null) errors.add("视频监控配套情况不能为空"); |
| | | if (StringUtils.isEmpty(row.getEquipmentOwnerName())) errors.add("设备所属方名称不能为空"); |
| | | if (StringUtils.isEmpty(row.getResidentNo())) errors.add("供电局用户编号不能为空"); |
| | | if (row.getSupplyType() == null) errors.add("供电类型不能为空"); |
| | | if (StringUtils.isEmpty(row.getWattHourMeterNo())) errors.add("表号不能为空"); |
| | | if (row.getForwardPower() == null) errors.add("外电功率不能为空"); |
| | | if (StringUtils.isEmpty(row.getServiceFee())) errors.add("服务费描述不能为空"); |
| | | if (StringUtils.isEmpty(row.getRecordUniqueNo())) errors.add("充电站全省唯一备案号不能为空"); |
| | | if (StringUtils.isNotEmpty(row.getAccountingStrategyName()) && !strategyMap.containsKey(normalizeImportValue(row.getAccountingStrategyName()))) errors.add("计费模板不存在"); |
| | | if (StringUtils.isNotEmpty(row.getEstablishmentTime())) { |
| | | try { java.time.LocalDateTime.parse(row.getEstablishmentTime().trim(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); } |
| | | catch (Exception e) { errors.add("建站时间格式应为yyyy-MM-dd HH:mm:ss"); } |
| | | } |
| | | return errors; |
| | | } |
| | | |
| | | private Site buildImportedSite(SiteExcelDTO row, Map<String, Partner> partnerMap, |
| | | Map<String, TAccountingStrategy> strategyMap, Map<String, Region> regionByCode, |
| | | Map<Integer, Region> regionById) { |
| | | Site site = new Site(); |
| | | BeanUtils.copyProperties(row, site); |
| | | site.setCode(normalizeImportValue(row.getCode())); |
| | | site.setName(normalizeImportValue(row.getName())); |
| | | site.setPartnerId(partnerMap.get(normalizeImportValue(row.getPartnerName())).getId()); |
| | | if (StringUtils.isNotEmpty(row.getVenuePartnerName())) { |
| | | site.setVenuePartnerId(partnerMap.get(normalizeImportValue(row.getVenuePartnerName())).getId()); |
| | | } |
| | | if (StringUtils.isNotEmpty(row.getAccountingStrategyName())) { |
| | | site.setAccountingStrategyId(strategyMap.get(normalizeImportValue(row.getAccountingStrategyName())).getId()); |
| | | } |
| | | Region district = regionByCode.get(row.getAreaCode().trim()); |
| | | Region city = regionById.get(district.getParentId()); |
| | | Region province = city == null ? null : regionById.get(city.getParentId()); |
| | | site.setDistricts(district.getName()); |
| | | site.setDistrictsCode(district.getCode()); |
| | | if (city != null) { |
| | | site.setCity(city.getName()); |
| | | site.setCityCode(city.getCode()); |
| | | } |
| | | if (province != null) { |
| | | site.setProvince(province.getName()); |
| | | site.setProvinceCode(province.getCode()); |
| | | } |
| | | if (StringUtils.isNotEmpty(row.getEstablishmentTime())) { |
| | | site.setEstablishmentTime(java.time.LocalDateTime.parse(row.getEstablishmentTime().trim(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | } |
| | | site.setImgUrl(""); |
| | | return site; |
| | | } |
| | | |
| | | private String normalizeImportValue(String value) { |
| | | return value == null ? null : value.trim(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public PageInfo<GetSiteListDTO> getSiteList1(Long userId) { |
| | | GetSiteList siteList = new GetSiteList(); |
| | | siteList.setPageCurr(1); |
| | | siteList.setPageSize(9999); |
| | | Set<Integer> ids = null; |
| | | //校验合作商权限 |
| | | SysUser sysUser = sysUserClient.getSysUser(userId).getData(); |
| | | Integer roleType = sysUser.getRoleType(); |
| | | Integer objectId = sysUser.getObjectId(); |
| | | R<Integer> admin = sysUserClient.isAdmin(tokenService.getLoginUser().getUserid()); |
| | | Integer partnerId = null; |
| | | |
| | | //合作商 |
| | | if(roleType == 2){ |
| | | ids = partnerService.authSite(objectId, SiteMenu.SITE_LIST); |
| | | partnerId = sysUser.getObjectId(); |
| | | }else{ |
| | | //非管理员需要根据角色和用户配置查询允许的站点数据 |
| | | R<Integer> admin = sysUserClient.isAdmin(userId); |
| | | if(admin.getData()!=1){ |
| | | List<Integer> data = userSiteClient.getSiteIds(sysUser.getUserId()).getData(); |
| | | List<SysUserRoleVo> data2 = sysUserRoleClient.getRoleByUserId(sysUser.getUserId()).getData(); |
| | | List<Integer> data1 = roleSiteClient.getSiteIds(data2.get(0).getRoleId()).getData(); |
| | | data.addAll(data1); |
| | | ids = new HashSet<>(data); |
| | | ids = getAssignedSiteIds(sysUser.getUserId()); |
| | | if (ids.isEmpty()) { |
| | | ids.add(-1); |
| | | } |
| | | } |
| | | } |
| | | PageInfo<GetSiteListDTO> pageInfo = new PageInfo<>(siteList.getPageCurr(), siteList.getPageSize()); |
| | | List<GetSiteListDTO> list = this.baseMapper.getSiteList(pageInfo, siteList, ids); |
| | | for (GetSiteListDTO getSiteListDTO : list) { |
| | | Integer siteId = getSiteListDTO.getId(); |
| | | getSiteListDTO.setAuthAccountingStrategy(roleType == 1 ? true : partnerService.authMenu(objectId, siteId, SiteMenu.SITE_ACCOUNTING_STRATEGY)); |
| | | //平台账号才有此权限 |
| | | getSiteListDTO.setAuthPartner(roleType == 1 ? true : false); |
| | | getSiteListDTO.setAuthUpdate(roleType == 1 ? true : partnerService.authMenu(objectId, siteId, SiteMenu.SITE_UPDATE)); |
| | | getSiteListDTO.setAuthDelete(roleType == 1 ? true : partnerService.authMenu(objectId, siteId, SiteMenu.SITE_DELETE)); |
| | | PageInfo<GetSiteListDTO> pageInfo = new PageInfo<>(1, 9999); |
| | | return pageInfo.setRecords(this.baseMapper.getSiteOptions(ids, partnerId)); |
| | | } |
| | | |
| | | private Set<Integer> getAssignedSiteIds(Long userId) { |
| | | Set<Integer> siteIds = new HashSet<>(); |
| | | if (userId == null) { |
| | | return siteIds; |
| | | } |
| | | return pageInfo.setRecords(list); |
| | | R<List<Integer>> userSiteResult = userSiteClient.getSiteIds(userId); |
| | | if (userSiteResult != null && userSiteResult.getData() != null) { |
| | | siteIds.addAll(userSiteResult.getData()); |
| | | } |
| | | R<List<SysUserRoleVo>> roleResult = sysUserRoleClient.getRoleByUserId(userId); |
| | | if (roleResult != null && roleResult.getData() != null) { |
| | | for (SysUserRoleVo role : roleResult.getData()) { |
| | | if (role == null || role.getRoleId() == null) { |
| | | continue; |
| | | } |
| | | R<List<Integer>> roleSiteResult = roleSiteClient.getSiteIds(role.getRoleId()); |
| | | if (roleSiteResult != null && roleSiteResult.getData() != null) { |
| | | siteIds.addAll(roleSiteResult.getData()); |
| | | } |
| | | } |
| | | } |
| | | return siteIds; |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | site.setMark(0); |
| | | this.save(site); |
| | | |
| | | //推送成都监管 |
| | | chengDuJianGuanClient.notificationStationInfo(site.getId()); |
| | | if(StringUtils.isNotEmpty(site.getSerAreaCode())){ |
| | | ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.SECONDS, new LinkedBlockingDeque<>()); |
| | | threadPoolExecutor.execute(()->{ |
| | |
| | | if(200 != r.getCode()){ |
| | | System.out.println(r.getMsg()); |
| | | } |
| | | // TODO 东涪推送 |
| | | dongFuStationClient.pushChargingStation(); |
| | | }); |
| | | } |
| | | return AjaxResult.success(); |
| | |
| | | return new ArrayList<ConnectorInfo>(){{ |
| | | for (TChargingGun chargingGun : list) { |
| | | ConnectorInfo connectorInfo = new ConnectorInfo(); |
| | | connectorInfo.setConnectorId(chargingGun.getCode()); |
| | | connectorInfo.setConnectorId(chargingGun.getFullNumber()); |
| | | connectorInfo.setConnectorName(chargingGun.getName()); |
| | | connectorInfo.setConnectorType(0 == chargingGun.getType() ? 6 : chargingGun.getType()); |
| | | connectorInfo.setVoltageUpperLimits(chargingGun.getUpperRatedVoltage().intValue()); |
| | |
| | | |
| | | this.updateById(site); |
| | | tcecClient.superviseNotificationStationInfo(site.getId()); |
| | | //推送成都监管 |
| | | chengDuJianGuanClient.notificationStationInfo(site.getId()); |
| | | if(StringUtils.isNotEmpty(site.getSerAreaCode())){ |
| | | ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.SECONDS, new LinkedBlockingDeque<>()); |
| | | threadPoolExecutor.execute(()->{ |
| | |
| | | if(200 != r.getCode()){ |
| | | System.out.println(r.getMsg()); |
| | | } |
| | | // TODO 东涪推送 |
| | | dongFuStationClient.pushChargingStation(); |
| | | }); |
| | | } |
| | | return AjaxResult.success(); |
| | |
| | | } |
| | | if(null == site.getConstructionSite()){ |
| | | return AjaxResult.error("建设场所不能为空"); |
| | | } |
| | | if(null == site.getTransformerPower()){ |
| | | return AjaxResult.error("变压器功率不能为空"); |
| | | } |
| | | if(null == site.getMemberDiscountFlag()){ |
| | | return AjaxResult.error("请选择是否参与会员折扣"); |
| | | } |
| | | if(StringUtils.isEmpty(site.getProvince()) || StringUtils.isEmpty(site.getProvinceCode()) || |
| | | StringUtils.isEmpty(site.getCity()) || StringUtils.isEmpty(site.getCityCode()) || |
| | |
| | | TVip vip = JSON.parseObject(vipJson, TVip.class); |
| | | if(Objects.nonNull(vip) && vip.getType() == 2){ |
| | | list.forEach(item -> { |
| | | if(Objects.nonNull(vip.getDiscount())){ |
| | | if(Integer.valueOf(1).equals(item.getMemberDiscountFlag()) && Objects.nonNull(vip.getDiscount())){ |
| | | item.setVipElectrovalence(vip.getDiscount().divide(new BigDecimal(10)).multiply(item.getServiceCharge()).add(item.getElectrovalenceOriginal())); |
| | | } |
| | | }); |
| | |
| | | TVip vip = JSON.parseObject(vipJson, TVip.class); |
| | | if(Objects.nonNull(vip) && vip.getType() == 2){ |
| | | list.forEach(item -> { |
| | | item.setVipElectrovalence(vip.getDiscount().divide(new BigDecimal(10)).multiply(item.getServiceCharge()).add(item.getElectrovalenceOriginal())); |
| | | if (Integer.valueOf(1).equals(item.getMemberDiscountFlag())) { |
| | | item.setVipElectrovalence(vip.getDiscount().divide(new BigDecimal(10)).multiply(item.getServiceCharge()).add(item.getElectrovalenceOriginal())); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | |
| | | List<TChargingPile> list1 = chargingPileService.lambdaQuery().eq(TChargingPile::getSiteId, id).eq(TChargingPile::getDelFlag, 0).list(); |
| | | for (TChargingPile tChargingPile : list1) { |
| | | integrationClient.setupBillingModel1(tChargingPile.getCode(), JSON.toJSONString(accountingStrategyDetails)); |
| | | chengDuJianGuanClient.notificationStationFee(tChargingPile.getId()); |
| | | } |
| | | |
| | | //推送三方平台 |
| | | tcecClient.notificationStationChange(Arrays.asList(id)); |
| | | if(1 == site.getIsOpenSynchronization()){ |
| | | //推送三方平台 |
| | | tcecClient.notificationStationChange(Arrays.asList(id)); |
| | | } |
| | | } |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void batchSetAccountingStrategy(List<Integer> ids, Integer accountingStrategyId) { |
| | | if (CollectionUtils.isEmpty(ids)) { |
| | | return; |
| | | } |
| | | this.lambdaUpdate() |
| | | .in(Site::getId, ids) |
| | | .set(Site::getAccountingStrategyId, accountingStrategyId) |
| | | .update(); |
| | | chargingGunService.lambdaUpdate() |
| | | .in(TChargingGun::getSiteId, ids) |
| | | .eq(TChargingGun::getDelFlag, 0) |
| | | .set(TChargingGun::getAccountingStrategyId, accountingStrategyId) |
| | | .update(); |
| | | List<TAccountingStrategyDetail> accountingStrategyDetails = accountingStrategyDetailService.list(new LambdaQueryWrapper<TAccountingStrategyDetail>().eq(TAccountingStrategyDetail::getAccountingStrategyId, accountingStrategyId)); |
| | | List<TChargingPile> chargingPiles = chargingPileService.lambdaQuery().in(TChargingPile::getSiteId, ids).eq(TChargingPile::getDelFlag, 0).list(); |
| | | List<Integer> syncSiteIds = this.lambdaQuery() |
| | | .select(Site::getId, Site::getIsOpenSynchronization) |
| | | .in(Site::getId, ids) |
| | | .eq(Site::getIsOpenSynchronization, 1) |
| | | .list() |
| | | .stream() |
| | | .map(Site::getId) |
| | | .collect(Collectors.toList()); |
| | | new Thread(() -> { |
| | | for (TChargingPile chargingPile : chargingPiles) { |
| | | try { |
| | | integrationClient.setupBillingModel1(chargingPile.getCode(), JSON.toJSONString(accountingStrategyDetails)); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | try { |
| | | chengDuJianGuanClient.notificationStationFee(chargingPile.getId()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | if (!CollectionUtils.isEmpty(syncSiteIds)) { |
| | | try { |
| | | tcecClient.notificationStationChange(syncSiteIds); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }).start(); |
| | | } |
| | | } |