From 00a59b93c16b24e7be77c6f1ce4866c75a2e0431 Mon Sep 17 00:00:00 2001 From: 101captain <237651143@qq.com> Date: 星期二, 19 四月 2022 16:32:21 +0800 Subject: [PATCH] 花城E+防疫修改 --- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngStructAreaServiceImpl.java | 254 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 254 insertions(+), 0 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngStructAreaServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngStructAreaServiceImpl.java new file mode 100644 index 0000000..62df433 --- /dev/null +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngStructAreaServiceImpl.java @@ -0,0 +1,254 @@ +package com.panzhihua.service_community.service.impl; + +import java.util.ArrayList; +import java.util.List; + +import javax.annotation.Resource; + +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; +import org.springframework.util.ObjectUtils; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.panzhihua.common.model.vos.R; +import com.panzhihua.common.model.vos.community.ComMngStructAreaVO; +import com.panzhihua.service_community.dao.ComMngStructAreaDAO; +import com.panzhihua.service_community.model.dos.ComMngStructAreaDO; +import com.panzhihua.service_community.service.ComMngStructAreaService; + +/** + * @program: springcloud_k8s_panzhihuazhihuishequ + * @description: 小区 + * @author: huang.hongfa weixin hhf9596 qq 959656820 + * @create: 2020-12-15 15:48 + **/ +@Service +public class ComMngStructAreaServiceImpl implements ComMngStructAreaService { + @Resource + private ComMngStructAreaDAO comMngStructAreaDAO; + + /** + * 新增小区 + * + * @param comMngStructAreaVO + * 小区信息 + * @return 新增结果 + */ + @Override + public R addArea(ComMngStructAreaVO comMngStructAreaVO) { + ComMngStructAreaDO comMngStructAreaDO = new ComMngStructAreaDO(); + BeanUtils.copyProperties(comMngStructAreaVO, comMngStructAreaDO); + long areaCode = 510000510400000001l;// 攀枝花区域地址编码+000001 + ComMngStructAreaDO comMngStructAreaDO1 = comMngStructAreaDAO.selectOne(new QueryWrapper<ComMngStructAreaDO>() + .lambda().orderByDesc(ComMngStructAreaDO::getAreaCode).last(" limit 1 ")); + if (!ObjectUtils.isEmpty(comMngStructAreaDO1)) { + areaCode = Long.valueOf(comMngStructAreaDO1.getAreaCode()) + 1; + } + comMngStructAreaDO.setAreaCode(areaCode + ""); + int insert = 0; + try { + insert = comMngStructAreaDAO.insert(comMngStructAreaDO); + } catch (Exception e) { + if (e.getMessage().contains("unique_address_detail")) { + return R.fail("小区地址已经存在"); + } + } + if (insert > 0) { + return R.ok(areaCode); + } + return R.fail(); + } + + /** + * 分页查询小区 + * + * @param comMngStructAreaVO + * 查询参数 + * @return 分页结果 + */ + @Override + public R pageArea(ComMngStructAreaVO comMngStructAreaVO) { + Page page = new Page<>(); + Long pageNum = comMngStructAreaVO.getPageNum(); + Long pageSize = comMngStructAreaVO.getPageSize(); + if (null == pageNum || 0 == pageNum) { + pageNum = 1l; + } + if (null == pageSize || 0 == pageSize) { + pageSize = 10l; + } + page.setSize(pageSize); + page.setCurrent(pageNum); + IPage<ComMngStructAreaVO> iPage = comMngStructAreaDAO.pageArea(page, comMngStructAreaVO); + return R.ok(iPage); + } + + /** + * 编辑小区 + * + * @param comMngStructAreaVO + * 编辑内容 + * @return 编辑结果 + */ + @Override + public R putArea(ComMngStructAreaVO comMngStructAreaVO) { + ComMngStructAreaDO comMngStructAreaDO = new ComMngStructAreaDO(); + BeanUtils.copyProperties(comMngStructAreaVO, comMngStructAreaDO); + int update = comMngStructAreaDAO.update(comMngStructAreaDO, new UpdateWrapper<ComMngStructAreaDO>().lambda() + .eq(ComMngStructAreaDO::getAreaCode, comMngStructAreaVO.getAreaCode())); + if (update > 0) { + return R.ok(); + } + return R.fail(); + } + + /** + * 删除小区 + * + * @param comMngStructAreaVO + * 地址编码 + * @return 删除结果 + */ + @Override + public R deleteArea(ComMngStructAreaVO comMngStructAreaVO) { + int delete = comMngStructAreaDAO.delete(new QueryWrapper<ComMngStructAreaDO>().lambda() + .eq(ComMngStructAreaDO::getAreaCode, comMngStructAreaVO.getAreaCode())); + if (delete > 0) { + return R.ok(); + } + return R.fail(); + } + + /** + * 查询小区信息 + * + * @param areaCode + * 小区地址编码 + * @return 小区信息 + */ + @Override + public R selectAreaByAreaCode(String areaCode) { + ComMngStructAreaDO comMngStructAreaDO = comMngStructAreaDAO + .selectOne(new QueryWrapper<ComMngStructAreaDO>().lambda().eq(ComMngStructAreaDO::getAreaCode, areaCode)); + if (ObjectUtils.isEmpty(comMngStructAreaDO)) { + return R.fail(); + } + return R.ok(comMngStructAreaDO); + } + + /** + * 获取小区的地址编码 + * + * @param areaId + * 小区id + * @return 小区地址编码 + */ + @Override + public R selectAreaById(Long areaId) { + ComMngStructAreaDO comMngStructAreaDO = comMngStructAreaDAO.selectById(areaId); + if (ObjectUtils.isEmpty(comMngStructAreaDO)) { + return R.fail("小区不存在"); + } + return R.ok(comMngStructAreaDO.getAreaCode()); + } + + /** + * 查询小区 + * + * @param communityId + * 社区id + * @return 小区集合 + */ + @Override + public R listArea(Long communityId) { + List<ComMngStructAreaVO> comMngStructAreaVOS = new ArrayList<>(); + List<ComMngStructAreaDO> comMngStructAreaDOS = comMngStructAreaDAO.selectList( + new QueryWrapper<ComMngStructAreaDO>().lambda().eq(ComMngStructAreaDO::getCommunityId, communityId)); + if (!ObjectUtils.isEmpty(comMngStructAreaDOS)) { + comMngStructAreaDOS.forEach(comMngStructAreaDO -> { + ComMngStructAreaVO comMngStructAreaVO = new ComMngStructAreaVO(); + BeanUtils.copyProperties(comMngStructAreaDO, comMngStructAreaVO); + comMngStructAreaVOS.add(comMngStructAreaVO); + }); + + } + return R.ok(comMngStructAreaVOS); + } + + /** + * 小区详情 + * + * @param areaId + * 小区id + * @return 小区信息 + */ + @Override + public R detailArea(Long areaId) { + ComMngStructAreaDO comMngStructAreaDO = comMngStructAreaDAO.selectById(areaId); + if (ObjectUtils.isEmpty(comMngStructAreaDO)) { + return R.fail("小区不存在"); + } + ComMngStructAreaVO comMngStructAreaVO = new ComMngStructAreaVO(); + BeanUtils.copyProperties(comMngStructAreaDO, comMngStructAreaVO); + return R.ok(comMngStructAreaVO); + } + + /** + * 选择导入的小区 + * + * @param param + * 小区名字 模糊查询 + * @param communityId + * 社区id + * @return 小区集合 ComMngStructAreaVO + */ + @Override + public R listAreas(String param, Long communityId) { + List<ComMngStructAreaVO> comMngStructAreaVOS = new ArrayList<>(); + comMngStructAreaVOS = comMngStructAreaDAO.listAreas(param, communityId); + if (!ObjectUtils.isEmpty(comMngStructAreaVOS)) { + comMngStructAreaVOS.forEach(comMngStructAreaVO -> { + String roleConnector = comMngStructAreaVO.getRoleConnector(); + String roleFloor = comMngStructAreaVO.getRoleFloor(); + String roleDoor = comMngStructAreaVO.getRoleDoor(); + String doorNum = "1-1-1-" + roleFloor + roleConnector + roleDoor; + if (!ObjectUtils.isEmpty(roleFloor)) { + comMngStructAreaVO.setDoorNum(doorNum); + } + }); + } + return R.ok(comMngStructAreaVOS); + } + + /** + * 检查小区是否已经批量设置过房屋并且返回小区房屋门号规则 + * + * @param id + * 小区id + * @return ComMngStructAreaVO + */ + @Override + public R checkAreaHouse(Long id) { + ComMngStructAreaDO comMngStructAreaDO = comMngStructAreaDAO.selectById(id); + if (null == comMngStructAreaDO) { + return R.fail("小区不存在"); + } + String roleFloor = comMngStructAreaDO.getRoleFloor(); + String roleDoor = comMngStructAreaDO.getRoleDoor(); + String areaCode = comMngStructAreaDO.getAreaCode(); + if (ObjectUtils.isEmpty(roleDoor) || ObjectUtils.isEmpty(roleFloor)) { + return R.fail("小区未批量设置房屋,请先去社区后台配置"); + } + Integer num = comMngStructAreaDAO.selectCountHouseByParentHouseCode(areaCode); + if (num.intValue() == 0) { + return R.fail("小区未批量设置房屋,请先去社区后台配置"); + } + ComMngStructAreaVO comMngStructAreaVO = new ComMngStructAreaVO(); + BeanUtils.copyProperties(comMngStructAreaDO, comMngStructAreaVO); + return R.ok(comMngStructAreaVO); + } + +} -- Gitblit v1.7.1