+ * 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.
+ *
+ * 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.
+ *
+ * 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.dao;
+
+import com.epmet.commons.mybatis.dao.BaseDao;
+import com.epmet.entity.CustomerOrgParameterEntity;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * 客户组织相关参数表
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2021-04-12
+ */
+@Mapper
+public interface CustomerOrgParameterDao extends BaseDao {
+
+ /**
+ * @return com.epmet.entity.CustomerOrgParameterEntity
+ * @param customerId
+ * @param parameterKey
+ * @author yinzuomei
+ * @description 根据customerId查询参数(area_code_switch)值
+ * @Date 2021/4/12 14:26
+ **/
+ CustomerOrgParameterEntity selectByCustomerId(@Param("customerId") String customerId, @Param("parameterKey") String parameterKey);
+}
\ No newline at end of file
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerAgencyEntity.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerAgencyEntity.java
index 5306281a03..ee327e421e 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerAgencyEntity.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerAgencyEntity.java
@@ -80,17 +80,17 @@ public class CustomerAgencyEntity extends BaseEpmetEntity {
private Integer totalUser;
/**
- * 省份
+ * 省
*/
private String province;
/**
- * 城市
+ * 【城市】名称
*/
private String city;
/**
- * 区县
+ * 【区县】名称
*/
private String district;
@@ -98,4 +98,14 @@ public class CustomerAgencyEntity extends BaseEpmetEntity {
* 当前组织的上级行政地区编码add0204;举例平阴县对应的是济南市3701
*/
private String parentAreaCode;
+
+ /**
+ * 街道
+ */
+ private String street;
+
+ /**
+ * 【社区】名称0409
+ */
+ private String community;
}
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerDepartmentEntity.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerDepartmentEntity.java
index ba9b1ddcd5..cb54609d3f 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerDepartmentEntity.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerDepartmentEntity.java
@@ -60,4 +60,8 @@ public class CustomerDepartmentEntity extends BaseEpmetEntity {
*/
private Integer totalUser;
+ /**
+ * 部门所属的行政地区编码:实际就是所属组织的地区编码
+ */
+ private String areaCode;
}
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerOrgParameterEntity.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerOrgParameterEntity.java
new file mode 100644
index 0000000000..489118f7c8
--- /dev/null
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/CustomerOrgParameterEntity.java
@@ -0,0 +1,66 @@
+/**
+ * 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.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Date;
+
+/**
+ * 客户组织相关参数表
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2021-04-12
+ */
+@Data
+@EqualsAndHashCode(callSuper=false)
+@TableName("customer_org_parameter")
+public class CustomerOrgParameterEntity extends BaseEpmetEntity {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 客户ID
+ */
+ private String customerId;
+
+ /**
+ * 参数键 eg:area_code_switch
+ */
+ private String parameterKey;
+
+ /**
+ * 参数名 eg:是否开启区域编码
+ */
+ private String parameterName;
+
+ /**
+ * 参数值 eg:开启:open;关闭:closed
+ */
+ private String parameterValue;
+
+ /**
+ * 参数说明 eg:open:当前客户新增组织需要选择areaCode;closed: 无需选择区域编码
+ */
+ private String description;
+
+}
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java
index 2eb012ca11..381fb7256a 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/AgencyService.java
@@ -108,4 +108,13 @@ public interface AgencyService {
* @Date 2020/7/16 17:13
**/
void saveRootAgency(AddAgencyAndStaffFormDTO agencyAndStaff);
+
+ /**
+ * 添加组织V2
+ *
+ * @param formDTO rule id
+ * @return com.epmet.dto.result.AddAgencyResultDTO
+ */
+ AddAgencyResultDTO addAgencyV2(AddAgencyV2FormDTO formDTO);
+
}
\ No newline at end of file
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java
index 8051ca63f5..59941f1f60 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java
@@ -234,4 +234,6 @@ public interface CustomerAgencyService extends BaseService
* @author sun
**/
OrganizeTreeResultDTO organizeTree(String agencyId);
+
+ void checkAgencyName(String agencyName,String customerId,String level,String agencyId);
}
\ No newline at end of file
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerOrgParameterService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerOrgParameterService.java
new file mode 100644
index 0000000000..a57bdc26a1
--- /dev/null
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerOrgParameterService.java
@@ -0,0 +1,104 @@
+/**
+ * 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.commons.mybatis.service.BaseService;
+import com.epmet.commons.tools.page.PageData;
+import com.epmet.dto.CustomerOrgParameterDTO;
+import com.epmet.entity.CustomerOrgParameterEntity;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 客户组织相关参数表
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2021-04-12
+ */
+public interface CustomerOrgParameterService extends BaseService {
+
+ /**
+ * 默认分页
+ *
+ * @param params
+ * @return PageData
+ * @author generator
+ * @date 2021-04-12
+ */
+ PageData page(Map params);
+
+ /**
+ * 默认查询
+ *
+ * @param params
+ * @return java.util.List
+ * @author generator
+ * @date 2021-04-12
+ */
+ List list(Map params);
+
+ /**
+ * 单条查询
+ *
+ * @param id
+ * @return CustomerOrgParameterDTO
+ * @author generator
+ * @date 2021-04-12
+ */
+ CustomerOrgParameterDTO get(String id);
+
+ /**
+ * 默认保存
+ *
+ * @param dto
+ * @return void
+ * @author generator
+ * @date 2021-04-12
+ */
+ void save(CustomerOrgParameterDTO dto);
+
+ /**
+ * 默认更新
+ *
+ * @param dto
+ * @return void
+ * @author generator
+ * @date 2021-04-12
+ */
+ void update(CustomerOrgParameterDTO dto);
+
+ /**
+ * 批量删除
+ *
+ * @param ids
+ * @return void
+ * @author generator
+ * @date 2021-04-12
+ */
+ void delete(String[] ids);
+
+ /**
+ * @return java.lang.String
+ * @param customerId
+ * @author yinzuomei
+ * @description 根据customerId查询参数(area_code_switch)值open: 选择地区编码必填;closed: 无需选择地区编码;;0409新增返参;没配置,返回closed
+ * @Date 2021/4/12 14:23
+ **/
+ String getAreaCodeSwitch(String customerId);
+}
\ No newline at end of file
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java
index f507af7c29..e83b78ba77 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java
@@ -19,6 +19,7 @@ package com.epmet.service.impl;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.constant.NumConstant;
+import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.security.user.LoginUserUtil;
@@ -33,10 +34,13 @@ import com.epmet.dto.GovStaffRoleDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.entity.CustomerAgencyEntity;
+import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.redis.CustomerAgencyRedis;
import com.epmet.service.AgencyService;
import com.epmet.service.CustomerAgencyService;
+import com.epmet.service.CustomerOrgParameterService;
+import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -45,7 +49,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
/**
* 机关单位信息
@@ -70,6 +76,12 @@ public class AgencyServiceImpl implements AgencyService {
private CustomerGridDao customerGridDao;
@Autowired
private LoginUserUtil loginUserUtil;
+ @Autowired
+ private CustomerOrgParameterService customerOrgParameterService;
+ @Autowired
+ private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient;
+
+
/**
* @param formDTO
* @return
@@ -120,11 +132,12 @@ public class AgencyServiceImpl implements AgencyService {
@Transactional(rollbackFor = Exception.class)
public Result editAgency(EditAgencyFormDTO formDTO) {
Result result = new Result();
- CustomerAgencyEntity entity = new CustomerAgencyEntity();
- entity.setId(formDTO.getAgencyId());
- entity.setOrganizationName(formDTO.getAgencyName());
+ CustomerAgencyEntity originalEntity = customerAgencyDao.selectById(formDTO.getAgencyId());
+ //当前客户下,同级组织中,组织名称不允许重复
+ customerAgencyService.checkAgencyName(formDTO.getAgencyName(),originalEntity.getCustomerId(),originalEntity.getLevel(),originalEntity.getId());
+ originalEntity.setOrganizationName(formDTO.getAgencyName());
//1:更新当前组织信息
- if (customerAgencyDao.updateById(entity) < NumConstant.ONE) {
+ if (customerAgencyDao.updateById(originalEntity) < NumConstant.ONE) {
log.error(CustomerAgencyConstant.UPDATE_EXCEPTION);
throw new RenException(CustomerAgencyConstant.UPDATE_EXCEPTION);
}
@@ -137,9 +150,7 @@ public class AgencyServiceImpl implements AgencyService {
}
//3:循环组织列表,查询每一个组织的所有上级组织重新拼接所有上级名称(allParentName)字段值
List editList = new ArrayList<>();
- Date date = new Date();
agencyList.forEach(agency->{
- CustomerAgencyEntity customerAgencyEntity = new CustomerAgencyEntity();
//3-1:查询当前组织的所有上级组织
List listStr = Arrays.asList(agency.getPids().split(":"));
List parentList = customerAgencyDao.selectPAgencyById(listStr);
@@ -152,10 +163,9 @@ public class AgencyServiceImpl implements AgencyService {
allParentName.append("-").append(parents.getName());
}
});
- customerAgencyEntity.setId(agency.getId());
+ CustomerAgencyEntity customerAgencyEntity = ConvertUtils.sourceToTarget(agency,CustomerAgencyEntity.class);
customerAgencyEntity.setAllParentName(allParentName.toString());
customerAgencyEntity.setUpdatedBy(formDTO.getUserId());
- customerAgencyEntity.setUpdatedTime(date);
editList.add(customerAgencyEntity);
});
//4:批量更新因一个组织名称变动而引起的其他组织字段值的变动
@@ -235,9 +245,38 @@ public class AgencyServiceImpl implements AgencyService {
List listStr = Arrays.asList(entity.getPids().split(":"));
parentList = customerAgencyDao.selectPAgencyById(listStr);
agencysResultDTO.setParentList(parentList);
+ agencysResultDTO.setAreaCodeSwitch(customerOrgParameterService.getAreaCodeSwitch(entity.getCustomerId()));
+ agencysResultDTO.setAreaName(StrConstant.EPMETY_STR);
+ agencysResultDTO.setAreaCode(StringUtils.isNotBlank(entity.getAreaCode())?entity.getAreaCode():StrConstant.EPMETY_STR);
+ //查询组织区划的名称
+ if (null != entity && StringUtils.isNotBlank(entity.getAreaCode())) {
+ switch (entity.getLevel()) {
+ case CustomerAgencyConstant.PROVINCE_LEVEL:
+ agencysResultDTO.setAreaName(null == entity.getProvince() ? StrConstant.EPMETY_STR : entity.getProvince());
+ break;
+ case CustomerAgencyConstant.CITY_LEVEL:
+ agencysResultDTO.setAreaName(null == entity.getCity() ? StrConstant.EPMETY_STR : entity.getCity());
+ break;
+ case CustomerAgencyConstant.DISTRICT:
+ agencysResultDTO.setAreaName(null == entity.getDistrict() ? StrConstant.EPMETY_STR : entity.getDistrict());
+ break;
+ case CustomerAgencyConstant.STREET_LEVEL:
+ agencysResultDTO.setAreaName(null == entity.getStreet() ? StrConstant.EPMETY_STR : entity.getStreet());
+ break;
+ case CustomerAgencyConstant.COMMUNITY_LEVEL:
+ agencysResultDTO.setAreaName(null == entity.getCommunity() ? StrConstant.EPMETY_STR : entity.getCommunity());
+ break;
+ default:
+ agencysResultDTO.setAreaName(StrConstant.EPMETY_STR);
+ }
+ }
return new Result().ok(agencysResultDTO);
}
+ public static void main(String[] args) {
+ String m="1234";
+ System.out.println(m.equals("1234") ? "yes" : "no");
+ }
/**
* @param formDTO
* @return
@@ -380,4 +419,99 @@ public class AgencyServiceImpl implements AgencyService {
}
+ /**
+ * 添加组织V2
+ *
+ * @param formDTO rule id
+ * @return com.epmet.dto.result.AddAgencyResultDTO
+ */
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public AddAgencyResultDTO addAgencyV2(AddAgencyV2FormDTO formDTO) {
+ CustomerAgencyDTO parent = customerAgencyService.get(formDTO.getParentAgencyId());
+ if (null == parent) {
+ throw new RenException(String.format("添加组织失败:没有找到上级组织信息,agencyId=%s", formDTO.getParentAgencyId()));
+ }
+ AddAgencyResultDTO resultDTO = new AddAgencyResultDTO();
+ resultDTO.setAreaCodeSwitch(formDTO.getAreaCodeSwitch());
+ CustomerAgencyEntity insertEntity=this.constructInsertEntity(formDTO,parent);
+ //判断areaCodeSwitch:open: 选择地区编码必填;closed: 无需选择地区编码
+ if (CustomerAgencyConstant.AREA_CODE_SWITCH_OPEN.equals(formDTO.getAreaCodeSwitch())) {
+ //校验areaCode是否被使用过
+ if (!"other".equals(formDTO.getAreaCode())) {
+ List agencyIds = customerAgencyDao.selectAgencyIdsByAreaCode(insertEntity.getAreaCode(),null);
+ if (CollectionUtils.isNotEmpty(agencyIds)) {
+ //已经被占用,提示
+ throw new RenException(EpmetErrorCode.AREA_CODE_ALREADY_EXISTS.getCode(), EpmetErrorCode.AREA_CODE_ALREADY_EXISTS.getMsg());
+ }
+ }else{
+ //如果选择的是other,需要自定义一个编码
+ AddAreaCodeFormDTO addAreaCodeFormDTO = new AddAreaCodeFormDTO();
+ addAreaCodeFormDTO.setCurrentAreaLevel(formDTO.getLevel());
+ addAreaCodeFormDTO.setParentAreaCode(parent.getAreaCode());
+ addAreaCodeFormDTO.setName(formDTO.getAgencyName());
+ Result addAreaCodeResult = epmetCommonServiceOpenFeignClient.addAreaCode(addAreaCodeFormDTO);
+ if (!addAreaCodeResult.success() || StringUtils.isBlank(addAreaCodeResult.getData())) {
+ throw new RenException("自定义area_code异常" + addAreaCodeResult.getInternalMsg());
+ }
+ insertEntity.setAreaCode(addAreaCodeResult.getData());
+ }
+ }
+ customerAgencyDao.insert(insertEntity);
+ //3:返回新组织Id
+ resultDTO.setAgencyId(insertEntity.getId());
+ resultDTO.setAreaCode(insertEntity.getAreaCode());
+ return resultDTO;
+ }
+
+ private CustomerAgencyEntity constructInsertEntity(AddAgencyV2FormDTO formDTO, CustomerAgencyDTO parent) {
+ CustomerAgencyEntity insertEntity = ConvertUtils.sourceToTarget(formDTO, CustomerAgencyEntity.class);
+ insertEntity.setOrganizationName(formDTO.getAgencyName());
+ insertEntity.setTotalUser(NumConstant.ZERO);
+ insertEntity.setPid(parent.getId());
+ insertEntity.setCustomerId(parent.getCustomerId());
+ insertEntity.setParentAreaCode(parent.getAreaCode());
+ if (StringUtils.isBlank(parent.getPid()) || NumConstant.ZERO_STR.equals(parent.getPid())) {
+ //如果上级是根级组织
+ insertEntity.setPids(parent.getId());
+ insertEntity.setAllParentName(parent.getOrganizationName());
+ } else {
+ insertEntity.setPids(parent.getPids().concat(StrConstant.COLON).concat(parent.getId()));
+ insertEntity.setAllParentName(parent.getAllParentName().concat(StrConstant.HYPHEN).concat(parent.getOrganizationName()));
+ }
+ switch(parent.getLevel())
+ {
+ case CustomerAgencyConstant.PROVINCE_LEVEL:
+ insertEntity.setLevel(CustomerAgencyConstant.CITY_LEVEL);
+ insertEntity.setProvince(parent.getProvince());
+ insertEntity.setCity(formDTO.getAreaName());
+ break;
+ case CustomerAgencyConstant.CITY_LEVEL:
+ insertEntity.setLevel(CustomerAgencyConstant.DISTRICT);
+ insertEntity.setProvince(parent.getProvince());
+ insertEntity.setCity(parent.getCity());
+ insertEntity.setDistrict(formDTO.getAreaName());
+ break;
+ case CustomerAgencyConstant.DISTRICT:
+ insertEntity.setLevel(CustomerAgencyConstant.STREET_LEVEL);
+ insertEntity.setProvince(parent.getProvince());
+ insertEntity.setCity(parent.getCity());
+ insertEntity.setDistrict(parent.getDistrict());
+ insertEntity.setStreet(formDTO.getAreaName());
+ break;
+ case CustomerAgencyConstant.STREET_LEVEL:
+ insertEntity.setLevel(CustomerAgencyConstant.COMMUNITY_LEVEL);
+ insertEntity.setProvince(parent.getProvince());
+ insertEntity.setCity(parent.getCity());
+ insertEntity.setDistrict(parent.getDistrict());
+ insertEntity.setStreet(parent.getStreet());
+ insertEntity.setCommunity(formDTO.getAreaName());
+ break;
+ default:
+ log.info("parent.getLevel()="+parent.getLevel());
+ break;
+ }
+ return insertEntity;
+ }
+
}
\ No newline at end of file
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java
index bc91668e7c..3753412331 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java
@@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant;
+import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
@@ -40,6 +41,7 @@ import com.epmet.feign.OperCrmFeignClient;
import com.epmet.redis.CustomerAgencyRedis;
import com.epmet.service.CustomerAgencyService;
import com.epmet.util.ModuleConstant;
+import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -1057,4 +1059,12 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl entityList = baseDao.checkAgencyName(agencyName,customerId,level,agencyId);
+ if (CollectionUtils.isNotEmpty(entityList)) {
+ throw new RenException(EpmetErrorCode.AGENCY_NAME_ALREADY_EXISTS.getCode(), EpmetErrorCode.AGENCY_NAME_ALREADY_EXISTS.getMsg());
+ }
+ }
+
}
\ No newline at end of file
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 c87958e926..5c2c4599de 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
@@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant;
+import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
@@ -244,6 +245,10 @@ public class CustomerGridServiceImpl extends BaseServiceImpl
+ * 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.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
+import com.epmet.commons.tools.constant.FieldConstant;
+import com.epmet.commons.tools.page.PageData;
+import com.epmet.commons.tools.utils.ConvertUtils;
+import com.epmet.constant.CustomerAgencyConstant;
+import com.epmet.dao.CustomerOrgParameterDao;
+import com.epmet.dto.CustomerOrgParameterDTO;
+import com.epmet.entity.CustomerOrgParameterEntity;
+import com.epmet.service.CustomerOrgParameterService;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 客户组织相关参数表
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2021-04-12
+ */
+@Service
+public class CustomerOrgParameterServiceImpl extends BaseServiceImpl implements CustomerOrgParameterService {
+
+ @Override
+ public PageData page(Map params) {
+ IPage page = baseDao.selectPage(
+ getPage(params, FieldConstant.CREATED_TIME, false),
+ getWrapper(params)
+ );
+ return getPageData(page, CustomerOrgParameterDTO.class);
+ }
+
+ @Override
+ public List list(Map params) {
+ List entityList = baseDao.selectList(getWrapper(params));
+
+ return ConvertUtils.sourceToTarget(entityList, CustomerOrgParameterDTO.class);
+ }
+
+ private QueryWrapper getWrapper(Map params){
+ String id = (String)params.get(FieldConstant.ID_HUMP);
+
+ QueryWrapper wrapper = new QueryWrapper<>();
+ wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
+
+ return wrapper;
+ }
+
+ @Override
+ public CustomerOrgParameterDTO get(String id) {
+ CustomerOrgParameterEntity entity = baseDao.selectById(id);
+ return ConvertUtils.sourceToTarget(entity, CustomerOrgParameterDTO.class);
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void save(CustomerOrgParameterDTO dto) {
+ CustomerOrgParameterEntity entity = ConvertUtils.sourceToTarget(dto, CustomerOrgParameterEntity.class);
+ insert(entity);
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void update(CustomerOrgParameterDTO dto) {
+ CustomerOrgParameterEntity entity = ConvertUtils.sourceToTarget(dto, CustomerOrgParameterEntity.class);
+ updateById(entity);
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void delete(String[] ids) {
+ // 逻辑删除(@TableLogic 注解)
+ baseDao.deleteBatchIds(Arrays.asList(ids));
+ }
+
+ /**
+ * @param customerId
+ * @return java.lang.String
+ * @author yinzuomei
+ * @description 根据customerId查询参数(area_code_switch)值open: 选择地区编码必填;closed: 无需选择地区编码;;0409新增返参;没配置,返回closed
+ * @Date 2021/4/12 14:23
+ **/
+ @Override
+ public String getAreaCodeSwitch(String customerId) {
+ CustomerOrgParameterEntity entity = baseDao.selectByCustomerId(customerId, CustomerAgencyConstant.AREA_CODE_SWITCH);
+ if (null == entity || StringUtils.isBlank(entity.getParameterValue())) {
+ return CustomerAgencyConstant.AREA_CODE_SWITCH_CLOSED;
+ }
+ return entity.getParameterValue();
+ }
+
+}
\ No newline at end of file
diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/DepartmentServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/DepartmentServiceImpl.java
index 5b53e49d0b..41d87332ed 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/DepartmentServiceImpl.java
+++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/DepartmentServiceImpl.java
@@ -18,6 +18,7 @@
package com.epmet.service.impl;
import com.epmet.commons.tools.constant.NumConstant;
+import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.security.dto.TokenDto;
@@ -90,6 +91,8 @@ public class DepartmentServiceImpl implements DepartmentService {
//1:查询当前组织机构信息,获取客户Id
CustomerAgencyEntity parentEntity = customerAgencyDao.selectById(formDTO.getAgencyId());
entity.setCustomerId(parentEntity.getCustomerId());
+ //新增area_code,部门的area_code=所属组织的area_code
+ entity.setAreaCode(null!=parentEntity&&StringUtils.isNotBlank(parentEntity.getAreaCode())?parentEntity.getAreaCode(): StrConstant.EPMETY_STR);
//2:保存部门信息
if (customerDepartmentDao.insert(entity) < NumConstant.ONE) {
log.error(CustomerDepartmentConstant.SAVE_EXCEPTION);
diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/logback-spring.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/logback-spring.xml
index 24d44d88f9..6c2d82a05b 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/resources/logback-spring.xml
+++ b/epmet-module/gov-org/gov-org-server/src/main/resources/logback-spring.xml
@@ -128,14 +128,14 @@
15
-
+
diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml
index 87f00d6652..ea6f94a1e8 100644
--- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml
+++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml
@@ -399,4 +399,32 @@
UPDATED_TIME=NOW()
where id=#{agencyId}
+
+
+
+
\ No newline at end of file
diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerOrgParameterDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerOrgParameterDao.xml
new file mode 100644
index 0000000000..7e5cc8da13
--- /dev/null
+++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerOrgParameterDao.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
\ No newline at end of file