| | |
| | | package com.ruoyi.chargingPile.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.chargingPile.api.dto.GetSiteListDTO; |
| | | import com.ruoyi.chargingPile.api.model.Site; |
| | | import com.ruoyi.chargingPile.api.query.GetSiteList; |
| | | import com.ruoyi.chargingPile.mapper.SiteMapper; |
| | | import com.ruoyi.chargingPile.service.ISiteService; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | |
| | | */ |
| | | @Service |
| | | public class SiteServiceImpl extends ServiceImpl<SiteMapper, Site> implements ISiteService { |
| | | |
| | | |
| | | /** |
| | | * 获取站点管理列表数据 |
| | | * @param siteList |
| | | * @return |
| | | */ |
| | | @Override |
| | | public PageInfo<GetSiteListDTO> getSiteList(GetSiteList siteList) { |
| | | PageInfo<GetSiteListDTO> pageInfo = new PageInfo<>(siteList.getPageCurr(), siteList.getPageSize()); |
| | | List<GetSiteListDTO> list = this.baseMapper.getSiteList(pageInfo, siteList); |
| | | return pageInfo.setRecords(list); |
| | | } |
| | | |
| | | /** |
| | | * 添加站点信息 |
| | | * @param site |
| | | * @return |
| | | */ |
| | | @Override |
| | | public AjaxResult addSite(Site site) { |
| | | AjaxResult ajaxResult = addSiteVerify(site); |
| | | if(ajaxResult.isError()){ |
| | | return ajaxResult; |
| | | } |
| | | Site one = this.getOne(new LambdaQueryWrapper<Site>().eq(Site::getCode, site.getCode()).eq(Site::getDelFlag, 0)); |
| | | if(null != one){ |
| | | return AjaxResult.error("站点编号重复"); |
| | | } |
| | | site.setMark(0); |
| | | this.save(site); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 编辑站点 |
| | | * @param site |
| | | * @return |
| | | */ |
| | | @Override |
| | | public AjaxResult editSite(Site site) { |
| | | AjaxResult ajaxResult = addSiteVerify(site); |
| | | if(ajaxResult.isError()){ |
| | | return ajaxResult; |
| | | } |
| | | Site one = this.getOne(new LambdaQueryWrapper<Site>().eq(Site::getCode, site.getCode()).eq(Site::getDelFlag, 0)); |
| | | if(null != one && !one.getCode().equals(site.getCode())){ |
| | | return AjaxResult.error("站点编号重复"); |
| | | } |
| | | this.updateById(site); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | /** |
| | | * 校验必填项 |
| | | * @param site |
| | | * @return |
| | | */ |
| | | AjaxResult addSiteVerify(Site site){ |
| | | if(null == site.getPartnerId()){ |
| | | return AjaxResult.error("合作商不能为空"); |
| | | } |
| | | if(StringUtils.isEmpty(site.getCode())){ |
| | | return AjaxResult.error("站点编号不能为空"); |
| | | } |
| | | if(StringUtils.isEmpty(site.getName())){ |
| | | return AjaxResult.error("站点名称不能为空"); |
| | | } |
| | | if(null == site.getSiteType()){ |
| | | return AjaxResult.error("站点类型不能为空"); |
| | | } |
| | | if(null == site.getBusinessCategory()){ |
| | | return AjaxResult.error("经营类别不能为空"); |
| | | } |
| | | if(null == site.getStatus()){ |
| | | return AjaxResult.error("站点状态不能为空"); |
| | | } |
| | | if(null == site.getConstructionSite()){ |
| | | return AjaxResult.error("建设场所不能为空"); |
| | | } |
| | | if(StringUtils.isEmpty(site.getProvince()) || StringUtils.isEmpty(site.getProvinceCode()) || |
| | | StringUtils.isEmpty(site.getCity()) || StringUtils.isEmpty(site.getCityCode()) || |
| | | StringUtils.isEmpty(site.getDistricts()) || StringUtils.isEmpty(site.getDistrictsCode())){ |
| | | return AjaxResult.error("所在区域不能为空"); |
| | | } |
| | | if(StringUtils.isEmpty(site.getAddress())){ |
| | | return AjaxResult.error("详细地址不能为空"); |
| | | } |
| | | if(StringUtils.isEmpty(site.getLon()) || StringUtils.isEmpty(site.getLat())){ |
| | | return AjaxResult.error("地图位置不能为空"); |
| | | } |
| | | if(StringUtils.isEmpty(site.getPhone())){ |
| | | return AjaxResult.error("站点电话不能为空"); |
| | | } |
| | | if(StringUtils.isEmpty(site.getServicePhone())){ |
| | | return AjaxResult.error("服务电话不能为空"); |
| | | } |
| | | if(null == site.getParkingSpace()){ |
| | | return AjaxResult.error("车位数量不能为空"); |
| | | } |
| | | if(null == site.getSort()){ |
| | | return AjaxResult.error("排序不能为空"); |
| | | } |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | /** |
| | | * 删除站点 |
| | | * @param id 站点id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public AjaxResult delSite(Integer id) { |
| | | //查询是否有关联数据 |
| | | //充电桩 |
| | | // todo 待完善 |
| | | Site site = this.getById(id); |
| | | site.setDelFlag(true); |
| | | this.updateById(site); |
| | | return AjaxResult.success(); |
| | | } |
| | | } |