From d6e5539aea008584f3f46c8a6203b950bd1a1937 Mon Sep 17 00:00:00 2001 From: zxc <954985705@qq.com> Date: Thu, 30 Apr 2020 11:16:47 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BD=91=E6=A0=BC=E6=B7=BB=E5=8A=A0=E3=80=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/dto/StaffGridListDTO.java | 4 ++- .../java/com/epmet/dao/CustomerGridDao.java | 9 ++----- .../service/impl/CustomerGridServiceImpl.java | 26 ++++++++----------- .../main/resources/mapper/CustomerGridDao.xml | 2 +- 4 files changed, 17 insertions(+), 24 deletions(-) diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/StaffGridListDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/StaffGridListDTO.java index 263405df0c..a4787ffcef 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/StaffGridListDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/StaffGridListDTO.java @@ -2,12 +2,14 @@ package com.epmet.dto; import lombok.Data; +import java.io.Serializable; + /** * @Auther zxc * @Create 2020-04-23 10:38 */ @Data -public class StaffGridListDTO { +public class StaffGridListDTO implements Serializable { private static final long serialVersionUID = 1L; diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java index 3997ccc809..70f4361032 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java @@ -18,17 +18,12 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; -import com.epmet.dto.UserIdAndPidDTO; +import com.epmet.dto.*; import com.epmet.dto.form.ListCustomerGridFormDTO; import com.epmet.dto.form.SelectGridNameByGridIdFormDTO; import com.epmet.dto.result.*; -import com.epmet.commons.tools.utils.Result; -import com.epmet.dto.CustomerGridDTO; -import com.epmet.dto.CustomerStaffGridDTO; -import com.epmet.dto.UserIdDTO; import com.epmet.dto.form.CustomerGridFormDTO; import com.epmet.dto.form.DeleteGridFormDTO; -import com.epmet.dto.form.ListCustomerGridFormDTO; import com.epmet.dto.result.CustomerGridForStrangerResultDTO; import com.epmet.entity.CustomerGridEntity; import org.apache.ibatis.annotations.Mapper; @@ -120,7 +115,7 @@ public interface CustomerGridDao extends BaseDao { * @param gridName * @return */ - String selectGridIdByGridName(@Param("gridName") String gridName, @Param("agencyId") String pid, @Param("gridId") String gridId); + AddGridResultDTO selectGridIdByGridName(@Param("gridName") String gridName, @Param("agencyId") String pid, @Param("gridId") String gridId); /** * 编辑网格信息 diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java index 352e80c13f..7004e084cf 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java @@ -45,6 +45,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -200,19 +201,17 @@ public class CustomerGridServiceImpl extends BaseServiceImpl addGrid(TokenDto tokenDto, AddGridFormDTO addGridFormDTO) { //查询是否重名 - String checkGridName = baseDao.selectGridIdByGridName(addGridFormDTO.getGridName(),addGridFormDTO.getAgencyId(),null); - if (checkGridName!=null){ + AddGridResultDTO gridResult = baseDao.selectGridIdByGridName(addGridFormDTO.getGridName(), addGridFormDTO.getAgencyId(), null); + if (gridResult!=null){ return new Result().error(EpmetErrorCode.NOT_ADD_GRID.getCode()); } - //查询地区编码 - String areaCode = customerAgencyDao.selectAreaCodeByAgencyId(addGridFormDTO.getAgencyId()); - CustomerGridEntity customerGridEntity = new CustomerGridEntity(); - customerGridEntity.setAreaCode(areaCode); CustomerAgencyDTO customerAgencyDTO=customerAgencyService.get(addGridFormDTO.getAgencyId()); - customerGridEntity.setCustomerId(customerAgencyDTO.getCustomerId());//查询customerId - customerGridEntity.setGridName(addGridFormDTO.getGridName()); - customerGridEntity.setManageDistrict(addGridFormDTO.getManageDistrict()); + CustomerGridEntity customerGridEntity = new CustomerGridEntity(); + BeanUtils.copyProperties(addGridFormDTO,customerGridEntity); + customerGridEntity.setAreaCode(customerAgencyDTO.getAreaCode()); + customerGridEntity.setCustomerId(customerAgencyDTO.getCustomerId()); customerGridEntity.setPid(addGridFormDTO.getAgencyId()); + //所有上级机构id,必须包括当前机构id (放在所有上级机构id后) if(StringUtils.isBlank(customerAgencyDTO.getPids())){ customerGridEntity.setPids(addGridFormDTO.getAgencyId()); }else{ @@ -222,12 +221,9 @@ public class CustomerGridServiceImpl extends BaseServiceImpl().ok(addGridResultDTO); } @@ -239,8 +235,8 @@ public class CustomerGridServiceImpl extends BaseServiceImpl - SELECT id AS gridId FROM