From b65a654296ec856de39477e5f979ec9f0d7aed99 Mon Sep 17 00:00:00 2001 From: lzh Date: Tue, 26 Oct 2021 17:33:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E5=8C=BA=E7=AE=A1=E7=90=86=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=EF=BC=8C=E4=BF=AE=E6=94=B9=EF=BC=8C=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=EF=BC=8C=E5=88=A0=E9=99=A4=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/constant/NeighborhoodConstant.java | 15 ++ .../epmet/dto/form/IcNeighborHoodFormDTO.java | 110 +++++++++++ .../dto/form/ListIcNeighborHoodFormDTO.java | 73 +++++++ .../dto/result/IcNeighborHoodResultDTO.java | 36 ++++ .../controller/NeighborHoodController.java | 133 +++++++++++++ .../java/com/epmet/dao/IcNeighborHoodDao.java | 9 +- .../epmet/service/NeighborHoodService.java | 43 ++++ .../service/impl/NeighborHoodServiceImpl.java | 186 ++++++++++++++++++ .../resources/mapper/IcNeighborHoodDao.xml | 17 ++ 9 files changed, 621 insertions(+), 1 deletion(-) create mode 100644 epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/constant/NeighborhoodConstant.java create mode 100644 epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcNeighborHoodFormDTO.java create mode 100644 epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/ListIcNeighborHoodFormDTO.java create mode 100644 epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcNeighborHoodResultDTO.java create mode 100644 epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java create mode 100644 epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/NeighborHoodService.java create mode 100644 epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/NeighborHoodServiceImpl.java diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/constant/NeighborhoodConstant.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/constant/NeighborhoodConstant.java new file mode 100644 index 0000000000..a7b77e0b90 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/constant/NeighborhoodConstant.java @@ -0,0 +1,15 @@ +package com.epmet.constant; + +/** + * @Author zxc + * @DateTime 2020/11/10 5:18 下午 + */ +public interface NeighborhoodConstant { + + String NEIGHBOR_HOOD= "neighbourHood"; + + String BUILDING = "building"; + + String HOUSE = "house"; + +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcNeighborHoodFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcNeighborHoodFormDTO.java new file mode 100644 index 0000000000..76a0e52504 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/IcNeighborHoodFormDTO.java @@ -0,0 +1,110 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto.form; + +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + + + +@Data +public class IcNeighborHoodFormDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + public interface DeleteGroup extends CustomerClientShowGroup { + } + /** + * 小区id + */ + @NotBlank(message = "小区id不能为空", groups = {UpdateGroup.class,DeleteGroup.class}) + private String neighborHoodId; + + /** + * 小区名称 + */ + @NotBlank(message = "小区名称不能为空", groups = {AddGroup.class, UpdateGroup.class}) + @Length(max=50,message = "小区名称不能超过50个字", groups = {AddGroup.class, UpdateGroup.class}) + private String neighborHoodName; + + /** + * 客户id + */ + /* @NotBlank(message = "客户id不能为空", groups = {AddGroup.class, UpdateGroup.class}) + private String customerId;*/ + + /** + * 组织id + */ + @NotBlank(message = "组织id不能为空", groups = {AddGroup.class, UpdateGroup.class}) + private String agencyId; + + + /** + * 网格id + */ + @NotBlank(message = "网格id不能为空", groups = {AddGroup.class, UpdateGroup.class}) + private String gridId; + /** + * 关联物业id + */ + @NotBlank(message = "关联物业ID不能为空", groups = {UpdateGroup.class}) + private String propertyId; + + /** + * 详细地址 + */ + @NotBlank(message = "详细地址不能为空", groups = {AddGroup.class, UpdateGroup.class}) + private String address; + + /** + * 备注 + */ + @NotBlank(message = "备注不能为空", groups = {UpdateGroup.class}) + @Length(max=500,message = "备注不能超过500个字", groups = {AddGroup.class, UpdateGroup.class}) + private String remark; + /** + * 坐标位置 + */ + @NotBlank(message = "坐标位置不能为空", groups = {AddGroup.class, UpdateGroup.class}) + private String location; + + + /** + * 中心点位:经度 + */ + @NotBlank(message = "经度不能为空", groups = {UpdateGroup.class}) + private String longitude; + + /** + * 中心点位:纬度 + */ + @NotBlank(message = "维度不能为空", groups = {UpdateGroup.class}) + private String latitude; + + + + + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/ListIcNeighborHoodFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/ListIcNeighborHoodFormDTO.java new file mode 100644 index 0000000000..49839dfe4a --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/ListIcNeighborHoodFormDTO.java @@ -0,0 +1,73 @@ +package com.epmet.dto.form;/** + * Created by 11 on 2020/3/19. + */ + +import lombok.Data; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Pattern; +import java.io.Serializable; + +/** + * @Description 陌生人导览查询附近网格传参定义 + * @ClassName ListCustomerGridFormDTO + * @Author wangc + * @date 2020.03.19 15:00 + */ +@Data +public class ListIcNeighborHoodFormDTO implements Serializable{ + + private static final long serialVersionUID = -1L; + + + /** + * 当前页 + * */ + private Integer pageNo = 1; + + /** + * 每页显示数量 + * */ + private Integer pageSize = 20; + + /** + * 组织ID + */ + private String agencyId; + /** + * 网格ID + */ + private String gridId; + /** + * 小区名字 + */ + private String neighborHoodName; + /** + * 楼栋名字 + */ + private String buildingName; + /** + * 房主姓名 + */ + private String ownerName; + /** + * 房主电话 + */ + private String ownerPhone; + /** + * 数据类型【小区:neighbourHood,楼栋:building,房屋:house】 + */ +// @Pattern(regexp = "^(neighbourHood|building|house)?$",message = "数据类型选择错误") + private String dataType; + /** + * 楼栋ID + */ + private String buildingId; + /** + * 小区ID + */ + private String neighborHoodId; + + +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcNeighborHoodResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcNeighborHoodResultDTO.java new file mode 100644 index 0000000000..77358255e1 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/IcNeighborHoodResultDTO.java @@ -0,0 +1,36 @@ +package com.epmet.dto.result; + +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +/** + * @Description 网格列表信息 + * @ClassName GridListInfoResultDTO + * @Author wangc + * @date 2020.04.23 14:21 + */ +@Data +public class IcNeighborHoodResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + /** + * 总条数 + * */ + private Long total; + + /** + * 数据类型【小区:neighbourHood,楼栋:building,房屋:house】 + * */ + private String dataType; + + /** + * 结果集 + */ + private List> list; + + +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java new file mode 100644 index 0000000000..bde7b11c0c --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/NeighborHoodController.java @@ -0,0 +1,133 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.controller; + +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.dto.IcNeighborHoodDTO; +import com.epmet.dto.form.IcNeighborHoodFormDTO; +import com.epmet.dto.form.ListIcNeighborHoodFormDTO; +import com.epmet.dto.result.IcNeighborHoodResultDTO; +import com.epmet.service.IcNeighborHoodService; +import com.epmet.service.NeighborHoodService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + + +/** + * 小区表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-25 + */ +@RestController +@RequestMapping("neighborhood") +public class NeighborHoodController { + + @Autowired + private IcNeighborHoodService icNeighborHoodService; + @Autowired + private NeighborHoodService neighborHoodService; + + + + + @PostMapping("neighborhoodlist") + public Result neighborhoodlist(@RequestBody ListIcNeighborHoodFormDTO formDTO){ + //效验数据 + ValidatorUtils.validateEntity(ListIcNeighborHoodFormDTO.class); + IcNeighborHoodResultDTO icNeighborHoodResultDTO = neighborHoodService.listNeighborhood(formDTO); + return new Result().ok(icNeighborHoodResultDTO); + + } + + @PostMapping("neighborhoodadd") + public Result neighborhoodadd(@LoginUser TokenDto tokenDTO, @RequestBody IcNeighborHoodFormDTO formDTO){ + //效验数据 + ValidatorUtils.validateEntity(formDTO, AddGroup.class); + String customerId = tokenDTO.getCustomerId(); + + neighborHoodService.AddNeighborhood(customerId,formDTO); + return new Result(); + } + + @PostMapping("neighborhoodupdate") + public Result neighborhoodupdate(@LoginUser TokenDto tokenDTO, @RequestBody IcNeighborHoodFormDTO formDTO){ + //效验数据 + ValidatorUtils.validateEntity(formDTO, UpdateGroup.class); + String customerId = tokenDTO.getCustomerId(); + neighborHoodService.UpdateNeighborhood(customerId,formDTO); + return new Result(); + } + + @PostMapping("neighborhooddel") + public Result neighborhooddel(@LoginUser TokenDto tokenDTO, @RequestBody IcNeighborHoodFormDTO formDTO){ + //效验数据 + ValidatorUtils.validateEntity(formDTO, IcNeighborHoodFormDTO.DeleteGroup.class); + String neighborHoodId = formDTO.getNeighborHoodId(); + neighborHoodService.DelNeighborhood(neighborHoodId); + return new Result(); + } + + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = icNeighborHoodService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + IcNeighborHoodDTO data = icNeighborHoodService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody IcNeighborHoodDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + icNeighborHoodService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody IcNeighborHoodDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + icNeighborHoodService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + icNeighborHoodService.delete(ids); + return new Result(); + } + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java index 1635ddcce2..9616584401 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcNeighborHoodDao.java @@ -17,9 +17,15 @@ package com.epmet.dao; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Constants; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.entity.IcNeighborHoodEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.Map; /** * 小区表 @@ -29,5 +35,6 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface IcNeighborHoodDao extends BaseDao { - + + IPage> searchNeighborhoodByPage(IPage page,@Param(Constants.WRAPPER) QueryWrapper neighborHoodEntityQueryWrapper); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/NeighborHoodService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/NeighborHoodService.java new file mode 100644 index 0000000000..7b25482b6a --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/NeighborHoodService.java @@ -0,0 +1,43 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.dto.form.IcNeighborHoodFormDTO; +import com.epmet.dto.form.ListIcNeighborHoodFormDTO; +import com.epmet.dto.result.IcNeighborHoodResultDTO; + +/** + * 小区表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-10-25 + */ +public interface NeighborHoodService{ + + void AddNeighborhood(String customerId, IcNeighborHoodFormDTO formDTO); + + IcNeighborHoodResultDTO listNeighborhood(ListIcNeighborHoodFormDTO formDTO); + + void UpdateNeighborhood(String customerId, IcNeighborHoodFormDTO formDTO); + + /** + * 删除小区 + * @param neighborHoodId + */ + void DelNeighborhood(String neighborHoodId); +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/NeighborHoodServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/NeighborHoodServiceImpl.java new file mode 100644 index 0000000000..b6c2a4347c --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/NeighborHoodServiceImpl.java @@ -0,0 +1,186 @@ +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.constant.NeighborhoodConstant; +import com.epmet.dao.IcNeighborHoodDao; +import com.epmet.dao.IcNeighborHoodPropertyDao; +import com.epmet.dto.CustomerAgencyDTO; +import com.epmet.dto.IcNeighborHoodDTO; +import com.epmet.dto.IcNeighborHoodPropertyDTO; +import com.epmet.dto.form.IcNeighborHoodFormDTO; +import com.epmet.dto.form.ListIcNeighborHoodFormDTO; +import com.epmet.dto.result.IcNeighborHoodResultDTO; +import com.epmet.entity.IcNeighborHoodEntity; +import com.epmet.entity.IcNeighborHoodPropertyEntity; +import com.epmet.feign.GovOrgOpenFeignClient; +import com.epmet.service.IcNeighborHoodPropertyService; +import com.epmet.service.IcNeighborHoodService; +import com.epmet.service.NeighborHoodService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.StringUtils; + +import javax.annotation.Resource; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +@Slf4j +@Service +public class NeighborHoodServiceImpl implements NeighborHoodService { + + @Autowired + private GovOrgOpenFeignClient govOrgOpenFeignClient; + + + @Autowired + private IcNeighborHoodService icNeighborHoodService; + + @Autowired + private IcNeighborHoodPropertyService icNeighborHoodPropertyService; + + @Resource + private IcNeighborHoodPropertyDao icNeighborHoodPropertyDao; + + @Resource + private IcNeighborHoodDao icNeighborHoodDao; + + @Override + @Transactional(rollbackFor = Exception.class) + public void AddNeighborhood(String customerId, IcNeighborHoodFormDTO formDTO) { + IcNeighborHoodDTO icNeighborHoodDTO = ConvertUtils.sourceToTarget(formDTO, IcNeighborHoodDTO.class); + icNeighborHoodDTO.setCustomerId(customerId); + Result customerAgencyResult = govOrgOpenFeignClient.getAgencyById(icNeighborHoodDTO.getAgencyId()); +// customerAgency.getData().get + if (!customerAgencyResult.success()) { + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } + CustomerAgencyDTO customerAgencyDTO = Optional.ofNullable(customerAgencyResult.getData()).orElse(new CustomerAgencyDTO()); + icNeighborHoodDTO.setParentAgencyId(customerAgencyDTO.getPid()); + icNeighborHoodDTO.setAgencyPids(customerAgencyDTO.getPids()); + icNeighborHoodService.save(icNeighborHoodDTO); + + //设置物业关联 + String propertyId = formDTO.getPropertyId(); + if(!StringUtils.isEmpty(propertyId)){ + //保存物业关系表 + IcNeighborHoodPropertyDTO icNeighborHoodPropertyDTO = new IcNeighborHoodPropertyDTO(); + icNeighborHoodPropertyDTO.setNeighborHoodId(icNeighborHoodDTO.getId()); + icNeighborHoodPropertyDTO.setPropertyId(propertyId); + icNeighborHoodPropertyService.save(icNeighborHoodPropertyDTO); + } + } + + /** + * 查询 + * @param formDTO + */ + @Override + public IcNeighborHoodResultDTO listNeighborhood(ListIcNeighborHoodFormDTO formDTO) { + String dataType = formDTO.getDataType(); + Integer pageNo = formDTO.getPageNo(); + Integer pageSize = formDTO.getPageSize(); + + + + IcNeighborHoodResultDTO result = new IcNeighborHoodResultDTO(); + result.setDataType(dataType); + + if(StringUtils.isEmpty(dataType)|| NeighborhoodConstant.NEIGHBOR_HOOD.equals(dataType)){ + //如果类型是neighbourHood 查小区 + IPage> resultMap = searchNeighborhood(formDTO); + result.setTotal(resultMap.getTotal()); + result.setList(resultMap.getRecords()); + }else if(NeighborhoodConstant.BUILDING.equals(dataType)){ + //如果类型是building 查楼栋 + IPage> resultMap = searchNeighborhood(formDTO); + }else if(NeighborhoodConstant.HOUSE.equals(dataType)){ + //如果类型是house 查房屋 + IPage> resultMap = searchNeighborhood(formDTO); + } + return result; + + } + /** + * 更新 + * @param customerId + * @param formDTO + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void UpdateNeighborhood(String customerId, IcNeighborHoodFormDTO formDTO) { + IcNeighborHoodDTO icNeighborHoodDTO = ConvertUtils.sourceToTarget(formDTO, IcNeighborHoodDTO.class); + icNeighborHoodDTO.setId(formDTO.getNeighborHoodId()); + icNeighborHoodDTO.setCustomerId(customerId); + + Result customerAgencyResult = govOrgOpenFeignClient.getAgencyById(icNeighborHoodDTO.getAgencyId()); +// customerAgency.getData().get + if (!customerAgencyResult.success()) { + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } + CustomerAgencyDTO customerAgencyDTO = Optional.ofNullable(customerAgencyResult.getData()).orElse(new CustomerAgencyDTO()); + icNeighborHoodDTO.setParentAgencyId(customerAgencyDTO.getPid()); + icNeighborHoodDTO.setAgencyPids(customerAgencyDTO.getPids()); + icNeighborHoodService.update(icNeighborHoodDTO); + + //设置物业关联 + String propertyId = formDTO.getPropertyId(); + String neighborHoodId = icNeighborHoodDTO.getId(); + if(!StringUtils.isEmpty(propertyId)){ + //更新物业关系表 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(IcNeighborHoodPropertyEntity::getNeighborHoodId,neighborHoodId); + IcNeighborHoodPropertyEntity icNeighborHoodProperty = icNeighborHoodPropertyDao.selectOne(queryWrapper); + icNeighborHoodProperty = Optional.ofNullable(icNeighborHoodProperty).orElse(new IcNeighborHoodPropertyEntity()); + icNeighborHoodProperty.setNeighborHoodId(neighborHoodId); + icNeighborHoodProperty.setPropertyId(propertyId); + if(StringUtils.isEmpty(icNeighborHoodProperty.getId())){ + //插入 + icNeighborHoodPropertyService.insert(icNeighborHoodProperty); + }else{ + //更新 + icNeighborHoodPropertyService.updateById(icNeighborHoodProperty); + } + + + } + } + + /** + * 删除 + * @param neighborHoodId + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void DelNeighborhood(String neighborHoodId) { + //删除小区 + icNeighborHoodService.deleteById(neighborHoodId); + //删除小区物业关联 + Map columnMap = new HashMap<>(); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(IcNeighborHoodPropertyEntity::getNeighborHoodId,neighborHoodId); + icNeighborHoodPropertyDao.delete(queryWrapper); + + } + + private IPage> searchNeighborhood(ListIcNeighborHoodFormDTO formDTO) { + + IPage page = new Page(formDTO.getPageNo(),formDTO.getPageSize()); + + QueryWrapper neighborHoodEntityQueryWrapper = new QueryWrapper<>(); + neighborHoodEntityQueryWrapper.lambda() + .eq(!StringUtils.isEmpty(formDTO.getNeighborHoodId()),IcNeighborHoodEntity::getId,formDTO.getNeighborHoodId()) + .like(!StringUtils.isEmpty(formDTO.getNeighborHoodName()),IcNeighborHoodEntity::getNeighborHoodName,formDTO.getNeighborHoodName()); + + + return icNeighborHoodDao.searchNeighborhoodByPage(page, neighborHoodEntityQueryWrapper); + } +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml index b76ab56c4b..8a057c3a9f 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcNeighborHoodDao.xml @@ -25,5 +25,22 @@ + + \ No newline at end of file