Browse Source

政府端-组织机构模块-部门接口

master
sunyuchao 5 years ago
parent
commit
99c0d0e0ca
  1. 78
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyFormDTO.java
  2. 43
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AgencydetailFormDTO.java
  3. 48
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditAgencyFormDTO.java
  4. 42
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/RemoveAgencyFormDTO.java
  5. 43
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/SubAgencyFormDTO.java
  6. 40
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AddAgencyResultDTO.java
  7. 82
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencydetailResultDTO.java
  8. 46
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ParentListResultDTO.java
  9. 48
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/SubAgencyResultDTO.java
  10. 45
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/SubListResultDTO.java
  11. 25
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerAgencyConstant.java
  12. 77
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java
  13. 18
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java
  14. 45
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java
  15. 138
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java
  16. 22
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml

78
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyFormDTO.java

@ -0,0 +1,78 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 添加组织-接口入参
*
* @author sun
*/
@Data
public class AddAgencyFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 上级机关组织Id(当前机关组织添加下级组织)
*/
@NotBlank(message = "上级机关组织ID不能为空")
private String pid;
/**
* 机构组织名称
*/
@NotBlank(message = "组织名称不能为空")
private String agencyName;
/**
* 机关级别社区级community
* 街道:street,
* 区县级: district,
* 市级: city
* 省级:province 机关级别社区级community街道:street,区县级: district,市级: city省级:province
*/
private String level;
/**
* 地区编码
*/
private Integer areaCode;
/**
* 国家
*/
private String country;
/**
* 省份
*/
private String province;
/**
* 城市
*/
private String city;
}

43
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AgencydetailFormDTO.java

@ -0,0 +1,43 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 组织首页-获取组织机构信息接口入参
*
* @author sun
*/
@Data
public class AgencydetailFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 机关组织Id
*/
@NotBlank(message = "机关组织ID不能为空")
private String agencyId;
}

48
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditAgencyFormDTO.java

@ -0,0 +1,48 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 组织名称编辑-接口入参
*
* @author sun
*/
@Data
public class EditAgencyFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 机关组织Id
*/
@NotBlank(message = "机关组织ID不能为空")
private String agencyId;
/**
* 机关组织名称
*/
@NotBlank(message = "机关组织名称不能为空")
private String agencyName;
}

42
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/RemoveAgencyFormDTO.java

@ -0,0 +1,42 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 删除组织机关-接口入参
*
* @author sun
*/
@Data
public class RemoveAgencyFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 机关组织Id
*/
@NotBlank(message = "机关组织ID不能为空")
private String agencyId;
}

43
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/SubAgencyFormDTO.java

@ -0,0 +1,43 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 组织首页-下级机关列表-接口入参
*
* @author sun
*/
@Data
public class SubAgencyFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 机关组织Id
*/
@NotBlank(message = "机关组织ID不能为空")
private String agencyId;
}

40
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AddAgencyResultDTO.java

@ -0,0 +1,40 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* 添加组织-接口返参
*
* @author sun
*/
@Data
public class AddAgencyResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 机关组织Id
*/
private String agencyId;
}

82
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencydetailResultDTO.java

@ -0,0 +1,82 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dto.result;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.List;
/**
* 组织首页-获取组织机构信息接口返参
*
* @author sun
*/
@Data
public class AgencydetailResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 机关组织Id
*/
private String agencyId;
/**
* 组织名称
*/
private String agencyName;
/**
* 机关级别社区级community
* 街道:street,
* 区县级: district,
* 市级: city
* 省级:province 机关级别社区级community街道:street,区县级: district,市级: city省级:province
*/
private String level;
/**
* 地区编码
*/
private Integer areaCode;
/**
* 国家
*/
private String country;
/**
* 省份
*/
private String province;
/**
* 城市
*/
private String city;
/**
* 本机关的所有上级机关
*/
private List<ParentListResultDTO> parentList;
}

46
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ParentListResultDTO.java

@ -0,0 +1,46 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dto.result;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 组织首页-获取组织机构信息接口-本机关的所有上级机关信息
*
* @author sun
*/
@Data
public class ParentListResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 机关组织Id
*/
private String id;
/**
* 机关组织名称
*/
private String name;
}

48
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/SubAgencyResultDTO.java

@ -0,0 +1,48 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dto.result;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.List;
/**
* 组织首页-下级机关列表-接口返参
*
* @author sun
*/
@Data
public class SubAgencyResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 下级机关总数
*/
private Integer subAgencyCount;
/**
* 下级机关总数
*/
private List<SubListResultDTO> agencyList;
}

45
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/SubListResultDTO.java

@ -0,0 +1,45 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* 组织首页-下级机关列表-查询本机关的直属下一级机关
*
* @author sun
*/
@Data
public class SubListResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 机关组织Id
*/
private String agencyId;
/**
* 机关组织名称
*/
private String agencyName;
}

25
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerAgencyConstant.java

@ -0,0 +1,25 @@
package com.epmet.constant;
/**
* @author sun
* @dscription
*/
public interface CustomerAgencyConstant {
/**
* 组织名称编辑修改失败
*/
String UPDATE_EXCEPTION = "组织机构信息更新失败";
/**
* 添加组织失败
*/
String SAVE_EXCEPTION = "组织机构新增失败";
/**
* 不允许删除组织
*/
String NOT_DEL_AGENCY = "当前组织存在下级组织,不允许删除";
/**
* 组织删除失败
*/
String DEL_EXCEPTION = "组织删除失败";
}

77
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java

@ -26,8 +26,11 @@ 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.CustomerAgencyDTO;
import com.epmet.dto.form.StaffOrgFormDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.AddAgencyResultDTO;
import com.epmet.dto.result.AgencydetailResultDTO;
import com.epmet.dto.result.StaffOrgsResultDTO;
import com.epmet.dto.result.SubAgencyResultDTO;
import com.epmet.excel.CustomerAgencyExcel;
import com.epmet.service.CustomerAgencyService;
import org.springframework.beans.factory.annotation.Autowired;
@ -47,24 +50,24 @@ import java.util.Map;
@RestController
@RequestMapping("customeragency")
public class CustomerAgencyController {
@Autowired
private CustomerAgencyService customerAgencyService;
@GetMapping("page")
public Result<PageData<CustomerAgencyDTO>> page(@RequestParam Map<String, Object> params){
public Result<PageData<CustomerAgencyDTO>> page(@RequestParam Map<String, Object> params) {
PageData<CustomerAgencyDTO> page = customerAgencyService.page(params);
return new Result<PageData<CustomerAgencyDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<CustomerAgencyDTO> get(@PathVariable("id") String id){
public Result<CustomerAgencyDTO> get(@PathVariable("id") String id) {
CustomerAgencyDTO data = customerAgencyService.get(id);
return new Result<CustomerAgencyDTO>().ok(data);
}
@PostMapping
public Result save(@RequestBody CustomerAgencyDTO dto){
public Result save(@RequestBody CustomerAgencyDTO dto) {
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
customerAgencyService.save(dto);
@ -72,7 +75,7 @@ public class CustomerAgencyController {
}
@PutMapping
public Result update(@RequestBody CustomerAgencyDTO dto){
public Result update(@RequestBody CustomerAgencyDTO dto) {
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
customerAgencyService.update(dto);
@ -80,7 +83,7 @@ public class CustomerAgencyController {
}
@DeleteMapping
public Result delete(@RequestBody String[] ids){
public Result delete(@RequestBody String[] ids) {
//效验数据
AssertUtils.isArrayEmpty(ids, "id");
customerAgencyService.delete(ids);
@ -94,14 +97,70 @@ public class CustomerAgencyController {
}
/**
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.result.StaffOrgsResultDTO>>
* @param staffOrgsFormDTO
* @return com.epmet.commons.tools.utils.Result<java.util.List < com.epmet.dto.result.StaffOrgsResultDTO>>
* @Author yinzuomei
* @Description 登录-获取工作人员所有组织
* @Date 2020/4/20 21:59
**/
@PostMapping("getStaffOrgList")
public Result<List<StaffOrgsResultDTO>> getStaffOrgList(@RequestBody StaffOrgFormDTO staffOrgsFormDTO){
public Result<List<StaffOrgsResultDTO>> getStaffOrgList(@RequestBody StaffOrgFormDTO staffOrgsFormDTO) {
return customerAgencyService.getStaffOrgList(staffOrgsFormDTO);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 添加组织
*/
@PostMapping("addagency")
public Result<AddAgencyResultDTO> addAgency(@RequestBody AddAgencyFormDTO formDTO) {
return customerAgencyService.addAgency(formDTO);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 组织名称编辑
*/
@PostMapping("editagency")
public Result editAgency(@RequestBody EditAgencyFormDTO formDTO) {
return customerAgencyService.editAgency(formDTO);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 删除组织机关
*/
@PostMapping("removeagency")
public Result removeAgency(@RequestBody RemoveAgencyFormDTO formDTO) {
return customerAgencyService.removeAgency(formDTO);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 组织首页-获取组织机构信息
*/
@PostMapping("agencydetail")
public Result<AgencydetailResultDTO> agencyDetail(@RequestBody AgencydetailFormDTO formDTO) {
return customerAgencyService.agencyDetail(formDTO);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 组织首页-下级机关列表
*/
@PostMapping("subagencylist")
public Result<SubAgencyResultDTO> subAgencyList(@RequestBody SubAgencyFormDTO formDTO) {
return customerAgencyService.subAgencyList(formDTO);
}
}

18
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java

@ -18,7 +18,9 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.result.ParentListResultDTO;
import com.epmet.dto.result.StaffOrgsResultDTO;
import com.epmet.dto.result.SubListResultDTO;
import com.epmet.entity.CustomerAgencyEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -41,4 +43,20 @@ public interface CustomerAgencyDao extends BaseDao<CustomerAgencyEntity> {
* @Date 2020/4/20 21:48
**/
List<StaffOrgsResultDTO> selectStaffOrgList(@Param("customerIdList") List<String> customerIdList);
/**
* @param listStr
* @return
* @Author sun
* @Description 查询当前机关的所有上级组织信息
**/
List<ParentListResultDTO> selectPAgencyById(@Param("listStr") List<String> listStr);
/**
* @param pId
* @return
* @Author sun
* @Description 组织首页-下级机关列表
**/
List<SubListResultDTO> selectSubAgencyById(@Param("pId") String pId);
}

45
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java

@ -21,8 +21,11 @@ import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.dto.form.StaffOrgFormDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.AddAgencyResultDTO;
import com.epmet.dto.result.AgencydetailResultDTO;
import com.epmet.dto.result.StaffOrgsResultDTO;
import com.epmet.dto.result.SubAgencyResultDTO;
import com.epmet.entity.CustomerAgencyEntity;
import java.util.List;
@ -104,4 +107,44 @@ public interface CustomerAgencyService extends BaseService<CustomerAgencyEntity>
* @Date 2020/4/20 21:45
**/
Result<List<StaffOrgsResultDTO>> getStaffOrgList(StaffOrgFormDTO staffOrgsFormDTO);
/**
* @param formDTO
* @return
* @Author sun
* @Description 添加组织
*/
Result<AddAgencyResultDTO> addAgency(AddAgencyFormDTO formDTO);
/**
* @param formDTO
* @return
* @Author sun
* @Description 组织名称编辑
*/
Result editAgency(EditAgencyFormDTO formDTO);
/**
* @param formDTO
* @return
* @Author sun
* @Description 删除组织机关
*/
Result removeAgency(RemoveAgencyFormDTO formDTO);
/**
* @param formDTO
* @return
* @Author sun
* @Description 组织首页-获取组织机构信息
*/
Result<AgencydetailResultDTO> agencyDetail(AgencydetailFormDTO formDTO);
/**
* @param formDTO
* @return
* @Author sun
* @Description 组织首页-下级机关列表
*/
Result<SubAgencyResultDTO> subAgencyList(SubAgencyFormDTO formDTO);
}

138
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java

@ -21,21 +21,27 @@ 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.constant.NumConstant;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.CustomerAgencyConstant;
import com.epmet.dao.CustomerAgencyDao;
import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.dto.form.StaffOrgFormDTO;
import com.epmet.dto.result.StaffOrgsResultDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.entity.CustomerAgencyEntity;
import com.epmet.redis.CustomerAgencyRedis;
import com.epmet.service.CustomerAgencyService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@ -49,6 +55,7 @@ import java.util.Map;
@Service
public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao, CustomerAgencyEntity> implements CustomerAgencyService {
private static final Logger log = LoggerFactory.getLogger(CustomerAgencyServiceImpl.class);
@Autowired
private CustomerAgencyRedis customerAgencyRedis;
@ -68,8 +75,8 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao
return ConvertUtils.sourceToTarget(entityList, CustomerAgencyDTO.class);
}
private QueryWrapper<CustomerAgencyEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
private QueryWrapper<CustomerAgencyEntity> getWrapper(Map<String, Object> params) {
String id = (String) params.get(FieldConstant.ID_HUMP);
QueryWrapper<CustomerAgencyEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
@ -112,4 +119,127 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao
List<StaffOrgsResultDTO> list = baseDao.selectStaffOrgList(staffOrgsFormDTO.getCustomerIdList());
return new Result<List<StaffOrgsResultDTO>>().ok(list);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 添加组织
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result<AddAgencyResultDTO> addAgency(AddAgencyFormDTO formDTO) {
Result<AddAgencyResultDTO> result = new Result<AddAgencyResultDTO>();
AddAgencyResultDTO addAgencyResultDTO = new AddAgencyResultDTO();
//0:属性映射赋值
CustomerAgencyEntity entity = ConvertUtils.sourceToTarget(formDTO, CustomerAgencyEntity.class);
entity.setOrganizationName(formDTO.getAgencyName());
entity.setTotalUser(NumConstant.ZERO);
//1:查询上级机关信息
CustomerAgencyEntity parentEntity = baseDao.selectById(formDTO.getPid());
entity.setCustomerId(parentEntity.getCustomerId());
if (null == parentEntity.getPid()) {
entity.setPids(parentEntity.getId());
entity.setAllParentName(parentEntity.getOrganizationName());
} else {
entity.setPids(":" + parentEntity.getId());
entity.setAllParentName("-" + parentEntity.getOrganizationName());
}
//2:保存组织信息
if (baseDao.insert(entity) < NumConstant.ONE) {
log.error(CustomerAgencyConstant.SAVE_EXCEPTION);
throw new RenException(CustomerAgencyConstant.SAVE_EXCEPTION);
}
//3:返回新组织Id
addAgencyResultDTO.setAgencyId(entity.getId());
return result.ok(addAgencyResultDTO);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 组织名称编辑
*/
@Override
@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());
if (baseDao.updateById(entity) < NumConstant.ONE) {
log.error(CustomerAgencyConstant.UPDATE_EXCEPTION);
throw new RenException(CustomerAgencyConstant.UPDATE_EXCEPTION);
}
return result;
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 删除组织机关
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result removeAgency(RemoveAgencyFormDTO formDTO) {
Result result = new Result();
//1:查询当前机关是否存在所属下级机关,存在下级的不能删除
List<SubListResultDTO> agencyList = baseDao.selectSubAgencyById(formDTO.getAgencyId());
if (null != agencyList && agencyList.size() > NumConstant.ZERO) {
result.setMsg(CustomerAgencyConstant.NOT_DEL_AGENCY);
return result;
}
//2:删除当前机关组织(逻辑删)
if (baseDao.deleteById(formDTO.getAgencyId()) < NumConstant.ONE) {
log.error(CustomerAgencyConstant.DEL_EXCEPTION);
throw new RenException(CustomerAgencyConstant.DEL_EXCEPTION);
}
return result;
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 组织首页-获取组织机构信息
*/
@Override
public Result<AgencydetailResultDTO> agencyDetail(AgencydetailFormDTO formDTO) {
AgencydetailResultDTO agencydetailResultDTO = new AgencydetailResultDTO();
//1:查询本机关详细信息
CustomerAgencyEntity entity = baseDao.selectById(formDTO.getAgencyId());
if (null == entity) {
return new Result<AgencydetailResultDTO>().ok(agencydetailResultDTO);
}
agencydetailResultDTO = ConvertUtils.sourceToTarget(entity, AgencydetailResultDTO.class);
agencydetailResultDTO.setAgencyId(entity.getId());
agencydetailResultDTO.setAgencyName(entity.getOrganizationName());
//2:查询本机关的所有上级机关,按自上而下层级顺序
if (null == entity.getPids()) {
return new Result<AgencydetailResultDTO>().ok(agencydetailResultDTO);
}
List<String> listStr = Arrays.asList(entity.getPids().split(":"));
List<ParentListResultDTO> parentList = baseDao.selectPAgencyById(listStr);
agencydetailResultDTO.setParentList(parentList);
return new Result<AgencydetailResultDTO>().ok(agencydetailResultDTO);
}
/**
* @param formDTO
* @return
* @Author sun
* @Description 组织首页-下级机关列表
*/
@Override
public Result<SubAgencyResultDTO> subAgencyList(SubAgencyFormDTO formDTO) {
SubAgencyResultDTO subAgencyResultDTO = new SubAgencyResultDTO();
//1:根据当前机关Id查询直属下一级机关列表
List<SubListResultDTO> agencyList = baseDao.selectSubAgencyById(formDTO.getAgencyId());
subAgencyResultDTO.setAgencyList(agencyList);
//2:统计下一级机关数
subAgencyResultDTO.setSubAgencyCount(agencyList.size());
return new Result<SubAgencyResultDTO>().ok(subAgencyResultDTO);
}
}

22
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml

@ -37,4 +37,26 @@
#{customerId}
</foreach>
</select>
<select id="selectPAgencyById" resultType="com.epmet.dto.result.ParentListResultDTO">
SELECT
id,
organization_name AS 'name'
FROM customer_agency
WHERE del_flag = '0'
AND id IN
<foreach item="id" collection="listStr" open="(" separator="," close=")" index="">
#{id}
</foreach>
</select>
<select id="selectSubAgencyById" resultType="com.epmet.dto.result.SubListResultDTO">
SELECT
id AS 'agencyId',
organization_name AS 'agencyName'
FROM customer_agency
WHERE del_flag = '0'
AND pid = #{pId}
ORDER BY CREATED_TIME DESC
</select>
</mapper>
Loading…
Cancel
Save