huanghongfa
2021-09-02 177249c76aeea0b4bf8d8816d4994e3b445b45ce
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngStructAreaServiceImpl.java
@@ -1,23 +1,23 @@
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.BatchhouseVO;
import com.panzhihua.common.model.vos.community.ComActDynVO;
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;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/**
 * @program: springcloud_k8s_panzhihuazhihuishequ
@@ -29,22 +29,25 @@
public class ComMngStructAreaServiceImpl implements ComMngStructAreaService {
    @Resource
    private ComMngStructAreaDAO comMngStructAreaDAO;
    /**
     * 新增小区
     *
     * @param comMngStructAreaVO 小区信息
     * @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 "));
        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;
            areaCode = Long.valueOf(comMngStructAreaDO1.getAreaCode()) + 1;
        }
        comMngStructAreaDO.setAreaCode(areaCode+"");
        comMngStructAreaDO.setAreaCode(areaCode + "");
        int insert = 0;
        try {
            insert = comMngStructAreaDAO.insert(comMngStructAreaDO);
@@ -53,7 +56,7 @@
                return R.fail("小区地址已经存在");
            }
        }
        if (insert>0) {
        if (insert > 0) {
            return R.ok(areaCode);
        }
        return R.fail();
@@ -62,7 +65,8 @@
    /**
     * 分页查询小区
     *
     * @param comMngStructAreaVO 查询参数
     * @param comMngStructAreaVO
     *            查询参数
     * @return 分页结果
     */
    @Override
@@ -70,10 +74,10 @@
        Page page = new Page<>();
        Long pageNum = comMngStructAreaVO.getPageNum();
        Long pageSize = comMngStructAreaVO.getPageSize();
        if (null==pageNum||0==pageNum) {
        if (null == pageNum || 0 == pageNum) {
            pageNum = 1l;
        }
        if (null==pageSize||0==pageSize) {
        if (null == pageSize || 0 == pageSize) {
            pageSize = 10l;
        }
        page.setSize(pageSize);
@@ -85,15 +89,17 @@
    /**
     * 编辑小区
     *
     * @param comMngStructAreaVO 编辑内容
     * @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) {
        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();
@@ -102,13 +108,15 @@
    /**
     * 删除小区
     *
     * @param comMngStructAreaVO 地址编码
     * @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) {
        int delete = comMngStructAreaDAO.delete(new QueryWrapper<ComMngStructAreaDO>().lambda()
            .eq(ComMngStructAreaDO::getAreaCode, comMngStructAreaVO.getAreaCode()));
        if (delete > 0) {
            return R.ok();
        }
        return R.fail();
@@ -117,12 +125,14 @@
    /**
     * 查询小区信息
     *
     * @param areaCode 小区地址编码
     * @param areaCode
     *            小区地址编码
     * @return 小区信息
     */
    @Override
    public R selectAreaByAreaCode(String areaCode) {
        ComMngStructAreaDO comMngStructAreaDO = comMngStructAreaDAO.selectOne(new QueryWrapper<ComMngStructAreaDO>().lambda().eq(ComMngStructAreaDO::getAreaCode, areaCode));
        ComMngStructAreaDO comMngStructAreaDO = comMngStructAreaDAO
            .selectOne(new QueryWrapper<ComMngStructAreaDO>().lambda().eq(ComMngStructAreaDO::getAreaCode, areaCode));
        if (ObjectUtils.isEmpty(comMngStructAreaDO)) {
            return R.fail();
        }
@@ -132,7 +142,8 @@
    /**
     * 获取小区的地址编码
     *
     * @param areaId 小区id
     * @param areaId
     *            小区id
     * @return 小区地址编码
     */
    @Override
@@ -147,17 +158,19 @@
    /**
     * 查询小区
     *
     * @param communityId 社区id
     * @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));
        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);
                ComMngStructAreaVO comMngStructAreaVO = new ComMngStructAreaVO();
                BeanUtils.copyProperties(comMngStructAreaDO, comMngStructAreaVO);
                comMngStructAreaVOS.add(comMngStructAreaVO);
            });
@@ -168,7 +181,8 @@
    /**
     * 小区详情
     *
     * @param areaId 小区id
     * @param areaId
     *            小区id
     * @return 小区信息
     */
    @Override
@@ -177,28 +191,30 @@
        if (ObjectUtils.isEmpty(comMngStructAreaDO)) {
            return R.fail("小区不存在");
        }
        ComMngStructAreaVO comMngStructAreaVO=new ComMngStructAreaVO();
        BeanUtils.copyProperties(comMngStructAreaDO,comMngStructAreaVO);
        ComMngStructAreaVO comMngStructAreaVO = new ComMngStructAreaVO();
        BeanUtils.copyProperties(comMngStructAreaDO, comMngStructAreaVO);
        return R.ok(comMngStructAreaVO);
    }
    /**
     * 选择导入的小区
     *
     * @param param       小区名字 模糊查询
     * @param communityId 社区id
     * @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);
        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;
                String doorNum = "1-1-1-" + roleFloor + roleConnector + roleDoor;
                if (!ObjectUtils.isEmpty(roleFloor)) {
                    comMngStructAreaVO.setDoorNum(doorNum);
                }
@@ -210,29 +226,29 @@
    /**
     * 检查小区是否已经批量设置过房屋并且返回小区房屋门号规则
     *
     * @param id 小区id
     * @param id
     *            小区id
     * @return ComMngStructAreaVO
     */
    @Override
    public R checkAreaHouse(Long id) {
        ComMngStructAreaDO comMngStructAreaDO = comMngStructAreaDAO.selectById(id);
        if (null==comMngStructAreaDO) {
        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)) {
        if (ObjectUtils.isEmpty(roleDoor) || ObjectUtils.isEmpty(roleFloor)) {
            return R.fail("小区未批量设置房屋,请先去社区后台配置");
        }
        Integer num=comMngStructAreaDAO.selectCountHouseByParentHouseCode(areaCode);
        if (num.intValue()==0) {
        Integer num = comMngStructAreaDAO.selectCountHouseByParentHouseCode(areaCode);
        if (num.intValue() == 0) {
            return R.fail("小区未批量设置房屋,请先去社区后台配置");
        }
        ComMngStructAreaVO comMngStructAreaVO=new ComMngStructAreaVO();
        BeanUtils.copyProperties(comMngStructAreaDO,comMngStructAreaVO);
        ComMngStructAreaVO comMngStructAreaVO = new ComMngStructAreaVO();
        BeanUtils.copyProperties(comMngStructAreaDO, comMngStructAreaVO);
        return R.ok(comMngStructAreaVO);
    }
}