| | |
| | | */ |
| | | package org.sxkj.gd.flyer.service.impl; |
| | | |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.sxkj.common.utils.HeaderUtils; |
| | | import org.sxkj.gd.flyer.entity.GdFlyerEntity; |
| | | import org.sxkj.gd.flyer.param.GdFlyerPageParam; |
| | | import org.sxkj.gd.flyer.vo.GdFlyerVO; |
| | | import org.sxkj.gd.flyer.excel.GdFlyerExcel; |
| | | import org.sxkj.gd.flyer.mapper.GdFlyerMapper; |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.sxkj.gd.utils.GdGeoAddressUtil; |
| | | import org.sxkj.system.cache.SysCache; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | public class GdFlyerServiceImpl extends BaseServiceImpl<GdFlyerMapper, GdFlyerEntity> implements IGdFlyerService { |
| | | |
| | | @Override |
| | | public IPage<GdFlyerVO> selectGdFlyerPage(IPage<GdFlyerVO> page, GdFlyerVO gdFlyer) { |
| | | public IPage<GdFlyerVO> selectGdFlyerPage(IPage<GdFlyerVO> page, GdFlyerPageParam gdFlyer) { |
| | | if (!AuthUtil.isAdministrator()) { |
| | | List<Long> deptList = SysCache.getDeptChildIds(Long.valueOf(AuthUtil.getDeptId())); |
| | | gdFlyer.setDeptList(deptList); |
| | | } |
| | | // 通过经纬度获取行政区划 |
| | | if (StringUtil.isNotBlank(gdFlyer.getLongitude()) && StringUtil.isNotBlank(gdFlyer.getLatitude())) { |
| | | String areaCode = GdGeoAddressUtil.getCountyCode(Double.valueOf(gdFlyer.getLongitude()), Double.valueOf(gdFlyer.getLatitude())); |
| | | // 去掉前面三位数字 |
| | | if (areaCode != null && areaCode.length() > 3) { |
| | | areaCode = areaCode.substring(3); |
| | | } |
| | | gdFlyer.setAreaCode(HeaderUtils.fillZero(areaCode)); |
| | | } |
| | | |
| | | return page.setRecords(baseMapper.selectGdFlyerPage(page, gdFlyer)); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public List<GdFlyerExcel> exportGdFlyer(Wrapper<GdFlyerEntity> queryWrapper) { |
| | | List<GdFlyerExcel> gdFlyerList = baseMapper.exportGdFlyer(queryWrapper); |
| | | //gdFlyerList.forEach(gdFlyer -> { |
| | | // gdFlyerList.forEach(gdFlyer -> { |
| | | // gdFlyer.setTypeName(DictCache.getValue(DictEnum.YES_NO, GdFlyer.getType())); |
| | | //}); |
| | | return gdFlyerList; |
| | | } |
| | | |
| | | /** |
| | | * 新增或修改 |
| | | * @param convert 飞手实体对象 |
| | | * @return 保存或更新成功返回true,失败返回false |
| | | */ |
| | | @Override |
| | | public boolean saveOrUpdateFlyer(GdFlyerEntity convert) { |
| | | // 步骤1:校验电话号码是否为空 |
| | | if (StringUtil.isNotBlank(convert.getFlyerPhone())) { |
| | | // 步骤2:查询数据库中是否存在相同电话号码的记录 |
| | | Long count = baseMapper.selectCount( |
| | | new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<GdFlyerEntity>() |
| | | .eq(GdFlyerEntity::getFlyerPhone, convert.getFlyerPhone()) |
| | | .ne(convert.getId() != null, GdFlyerEntity::getId, convert.getId()) |
| | | ); |
| | | // 步骤3:如果存在重复的电话号码,抛出异常 |
| | | if (count > 0) { |
| | | throw new RuntimeException("电话号码已存在,请使用其他电话号码"); |
| | | } |
| | | } |
| | | convert.setAreaCode(HeaderUtils.processAreaCode(convert.getRegionCode())); |
| | | // 步骤4:执行保存或更新操作 |
| | | return saveOrUpdate(convert); |
| | | } |
| | | } |