Browse Source

网格添加、修改代码优化

dev_shibei_match
zxc 5 years ago
parent
commit
d6e5539aea
  1. 4
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/StaffGridListDTO.java
  2. 9
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java
  3. 26
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java
  4. 2
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml

4
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;

9
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<CustomerGridEntity> {
* @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);
/**
* 编辑网格信息

26
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<CustomerGridDao, Cu
@Transactional(rollbackFor = Exception.class)
public Result<AddGridResultDTO> 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<CustomerGridDao, Cu
customerGridEntity.setPids(customerAgencyDTO.getPids().concat(":").concat(addGridFormDTO.getAgencyId()));
}
}
//查询所有上级组织id
baseDao.insert(customerGridEntity);
//查询刚刚添加的gridId
String gridId = baseDao.selectGridIdByGridName(addGridFormDTO.getGridName(),addGridFormDTO.getAgencyId(),null);
AddGridResultDTO addGridResultDTO = new AddGridResultDTO();
addGridResultDTO.setGridId(gridId);
AddGridResultDTO addGridResultDTO = baseDao.selectGridIdByGridName(addGridFormDTO.getGridName(), addGridFormDTO.getAgencyId(), null);
return new Result<AddGridResultDTO>().ok(addGridResultDTO);
}
@ -239,8 +235,8 @@ public class CustomerGridServiceImpl extends BaseServiceImpl<CustomerGridDao, Cu
@Override
@Transactional(rollbackFor = Exception.class)
public Result editGrid(TokenDto tokenDto, EditGridFormDTO editGridFormDTO) {
String checkGridName = baseDao.selectGridIdByGridName(editGridFormDTO.getGridName(),editGridFormDTO.getAgencyId(),editGridFormDTO.getGridId());
if (checkGridName!=null){
AddGridResultDTO gridId = baseDao.selectGridIdByGridName(editGridFormDTO.getGridName(), editGridFormDTO.getAgencyId(), editGridFormDTO.getGridId());
if (gridId!=null){
return new Result().error(EpmetErrorCode.NOT_ADD_GRID.getCode());
}
CustomerGridDTO customerGridDTO = new CustomerGridDTO();

2
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml

@ -176,7 +176,7 @@
</select>
<!-- 根据gridName查询gridId -->
<select id="selectGridIdByGridName" resultType="string">
<select id="selectGridIdByGridName" resultType="com.epmet.dto.result.AddGridResultDTO">
SELECT
id AS gridId
FROM

Loading…
Cancel
Save