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.TChargingGunDTO;
|
import com.ruoyi.chargingPile.api.model.TChargingGun;
|
import com.ruoyi.chargingPile.api.query.TChargingGunQuery;
|
import com.ruoyi.chargingPile.api.vo.TChargingGunVO;
|
import com.ruoyi.chargingPile.api.vo.TMonitoringEquipmentVO;
|
import com.ruoyi.chargingPile.mapper.TChargingGunMapper;
|
import com.ruoyi.chargingPile.service.TChargingGunService;
|
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;
|
|
/**
|
* <p>
|
* 充电枪 服务实现类
|
* </p>
|
*
|
* @author xiaochen
|
* @since 2024-08-06
|
*/
|
@Service
|
public class TChargingGunServiceImpl extends ServiceImpl<TChargingGunMapper, TChargingGun> implements TChargingGunService {
|
|
@Override
|
public PageInfo<TChargingGunVO> pageList(TChargingGunQuery query) {
|
PageInfo<TChargingGunVO> pageInfo = new PageInfo<>(query.getPageCurr(),query.getPageSize());
|
List<TChargingGunVO> list = this.baseMapper.pageList(query,pageInfo);
|
pageInfo.setRecords(list);
|
return pageInfo;
|
}
|
|
/**
|
* 添加充电枪
|
* @param dto
|
* @return
|
*/
|
@Override
|
public AjaxResult add(TChargingGunDTO dto) {
|
AjaxResult ajaxResult = addVerify(dto);
|
if(ajaxResult.isError()){
|
return ajaxResult;
|
}
|
long count = this.count(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getCode, dto.getCode()).eq(TChargingGun::getDelFlag, 0));
|
if(count > 0){
|
return AjaxResult.error("接口编码已存在");
|
}
|
this.save(dto);
|
return AjaxResult.success();
|
}
|
|
|
/**
|
* 编辑充电枪
|
* @param dto
|
* @return
|
*/
|
@Override
|
public AjaxResult update(TChargingGunDTO dto) {
|
AjaxResult ajaxResult = addVerify(dto);
|
if(ajaxResult.isError()){
|
return ajaxResult;
|
}
|
TChargingGun one = this.getOne(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getCode, dto.getCode()).eq(TChargingGun::getDelFlag, 0));
|
if(null != one && !dto.getId().equals(one.getId())){
|
return AjaxResult.error("接口编码已存在");
|
}
|
this.updateById(dto);
|
return AjaxResult.success();
|
}
|
|
/**
|
* 校验必填项
|
* @param dto
|
* @return
|
*/
|
AjaxResult addVerify(TChargingGunDTO dto){
|
if(StringUtils.isEmpty(dto.getCode())){
|
return AjaxResult.error("接口编码不能为空");
|
}
|
if(StringUtils.isEmpty(dto.getName())){
|
return AjaxResult.error("接口名称不能为空");
|
}
|
if(null == dto.getType()){
|
return AjaxResult.error("接口类型不能为空");
|
}
|
if(null == dto.getStatus()){
|
return AjaxResult.error("接口状态不能为空");
|
}
|
if(null == dto.getChargeMode()){
|
return AjaxResult.error("充电方式不能为空");
|
}
|
if(null == dto.getUpperRatedVoltage()){
|
return AjaxResult.error("额定电压上限不能为空");
|
}
|
if(null == dto.getLowerLimitOfRatedVoltage()){
|
return AjaxResult.error("额定电压下限不能为空");
|
}
|
if(null == dto.getRatedCurrent()){
|
return AjaxResult.error("额定电流不能为空");
|
}
|
if(null == dto.getRatedPower()){
|
return AjaxResult.error("额定功率不能为空");
|
}
|
if(StringUtils.isEmpty(dto.getNationalStandard())){
|
return AjaxResult.error("国家标准不能为空");
|
}
|
return AjaxResult.success();
|
}
|
}
|