Browse Source

政府端-组织、部门模块程序优化

dev_shibei_match
sunyuchao 5 years ago
parent
commit
2d84ce7787
  1. 5
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditAgencyFormDTO.java
  2. 10
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencysResultDTO.java
  3. 5
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartmentDetailResultDTO.java
  4. 1
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java
  5. 9
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java
  6. 52
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java
  7. 6
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/DepartmentServiceImpl.java
  8. 47
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml

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

@ -45,4 +45,9 @@ public class EditAgencyFormDTO implements Serializable {
@NotBlank(message = "机关组织名称不能为空")
private String agencyName;
/**
* token中用户Id
*/
private String userId;
}

10
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AgencysResultDTO.java

@ -57,11 +57,6 @@ public class AgencysResultDTO implements Serializable {
*/
private Integer areaCode;
/**
* 国家
*/
private String country;
/**
* 省份
*/
@ -72,6 +67,11 @@ public class AgencysResultDTO implements Serializable {
*/
private String city;
/**
* 区县
*/
private String district;
/**
* 本机关的所有上级机关
*/

5
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/DepartmentDetailResultDTO.java

@ -33,6 +33,11 @@ public class DepartmentDetailResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 组织机构Id
*/
private String agencyId;
/**
* 部门Id
*/

1
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java

@ -68,6 +68,7 @@ public class AgencyController {
*/
@PostMapping("editagency")
public Result editAgency(@LoginUser TokenDto tokenDTO, @RequestBody EditAgencyFormDTO formDTO) {
formDTO.setUserId(tokenDTO.getUserId());
ValidatorUtils.validateEntity(formDTO);
return agencyService.editAgency(formDTO);
}

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

@ -18,6 +18,7 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.dto.result.AgencyListResultDTO;
import com.epmet.dto.result.ParentListResultDTO;
import com.epmet.dto.result.StaffOrgsResultDTO;
@ -68,4 +69,12 @@ public interface CustomerAgencyDao extends BaseDao<CustomerAgencyEntity> {
* @Description 获取组织列表
**/
List<AgencyListResultDTO> selectAgencyList(@Param("pId") String pId);
/**
* @param customerAgencyDTO
* @return
* @Author sun
* @Description 查询当前组织的所有下级组织列表
**/
List<CustomerAgencyDTO> selectFindList(CustomerAgencyDTO customerAgencyDTO);
}

52
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java

@ -24,10 +24,12 @@ 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.*;
import com.epmet.dto.result.*;
import com.epmet.entity.CustomerAgencyEntity;
import com.epmet.service.AgencyService;
import com.epmet.service.CustomerAgencyService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -35,8 +37,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.*;
/**
* 机关单位信息
@ -49,6 +50,8 @@ public class AgencyServiceImpl implements AgencyService {
private static final Logger log = LoggerFactory.getLogger(AgencyServiceImpl.class);
@Autowired
private CustomerAgencyDao customerAgencyDao;
@Autowired
private CustomerAgencyService customerAgencyService;
/**
* @param formDTO
@ -103,10 +106,46 @@ public class AgencyServiceImpl implements AgencyService {
CustomerAgencyEntity entity = new CustomerAgencyEntity();
entity.setId(formDTO.getAgencyId());
entity.setOrganizationName(formDTO.getAgencyName());
//1:更新当前组织信息
if (customerAgencyDao.updateById(entity) < NumConstant.ONE) {
log.error(CustomerAgencyConstant.UPDATE_EXCEPTION);
throw new RenException(CustomerAgencyConstant.UPDATE_EXCEPTION);
}
//2:查询当前组织的所有下级组织列表(查询pids字段值包含该组织id的数据)
CustomerAgencyDTO agencyDTO = new CustomerAgencyDTO();
agencyDTO.setPids(formDTO.getAgencyId());
List<CustomerAgencyDTO> agencyList = customerAgencyDao.selectFindList(agencyDTO);
if (null == agencyList || agencyList.size() < NumConstant.ONE) {
return result;
}
//3:循环组织列表,查询每一个组织的所有上级组织重新拼接所有上级名称(allParentName)字段值
List<CustomerAgencyEntity> editList = new ArrayList<>();
Date date = new Date();
agencyList.forEach(agency->{
CustomerAgencyEntity customerAgencyEntity = new CustomerAgencyEntity();
//3-1:查询当前组织的所有上级组织
List<String> listStr = Arrays.asList(agency.getPids().split(":"));
List<ParentListResultDTO> parentList = customerAgencyDao.selectPAgencyById(listStr);
//3-2:重新拼接当前组织的所有上级名称字段值,将组织Id和拼好的值存入集合
StringBuffer allParentName = new StringBuffer();
parentList.forEach(parents->{
if(StringUtils.isBlank(allParentName)){
allParentName.append(parents.getName());
}else {
allParentName.append("-").append(parents.getName());
}
});
customerAgencyEntity.setId(agency.getId());
customerAgencyEntity.setAllParentName(allParentName.toString());
customerAgencyEntity.setUpdatedBy(formDTO.getUserId());
customerAgencyEntity.setUpdatedTime(date);
editList.add(customerAgencyEntity);
});
//4:批量更新因一个组织名称变动而引起的其他组织字段值的变动
if (!customerAgencyService.updateBatchById(editList)) {
log.error(CustomerAgencyConstant.UPDATE_EXCEPTION);
throw new RenException(CustomerAgencyConstant.UPDATE_EXCEPTION);
}
return result;
}
@ -151,9 +190,11 @@ public class AgencyServiceImpl implements AgencyService {
@Override
public Result<AgencysResultDTO> agencyDetail(AgencydetailFormDTO formDTO) {
AgencysResultDTO agencysResultDTO = new AgencysResultDTO();
List<ParentListResultDTO> parentList = new ArrayList<>();
//1:查询本机关详细信息
CustomerAgencyEntity entity = customerAgencyDao.selectById(formDTO.getAgencyId());
if (null == entity) {
agencysResultDTO.setParentList(parentList);
return new Result<AgencysResultDTO>().ok(agencysResultDTO);
}
agencysResultDTO = ConvertUtils.sourceToTarget(entity, AgencysResultDTO.class);
@ -161,10 +202,11 @@ public class AgencyServiceImpl implements AgencyService {
agencysResultDTO.setAgencyName(entity.getOrganizationName());
//2:查询本机关的所有上级机关,按自上而下层级顺序
if (null == entity.getPids()) {
agencysResultDTO.setParentList(parentList);
return new Result<AgencysResultDTO>().ok(agencysResultDTO);
}
List<String> listStr = Arrays.asList(entity.getPids().split(":"));
List<ParentListResultDTO> parentList = customerAgencyDao.selectPAgencyById(listStr);
parentList = customerAgencyDao.selectPAgencyById(listStr);
agencysResultDTO.setParentList(parentList);
return new Result<AgencysResultDTO>().ok(agencysResultDTO);
}
@ -180,7 +222,7 @@ public class AgencyServiceImpl implements AgencyService {
SubAgencyResultDTO subAgencyResultDTO = new SubAgencyResultDTO();
//1:根据当前机关Id查询直属下一级机关列表
List<SubListResultDTO> agencyList = customerAgencyDao.selectSubAgencyById(formDTO.getAgencyId());
subAgencyResultDTO.setAgencyList(agencyList);
subAgencyResultDTO.setAgencyList(null == agencyList ? new ArrayList<SubListResultDTO>() : agencyList);
//2:统计下一级机关数
subAgencyResultDTO.setSubAgencyCount(agencyList.size());
return new Result<SubAgencyResultDTO>().ok(subAgencyResultDTO);
@ -195,7 +237,7 @@ public class AgencyServiceImpl implements AgencyService {
@Override
public Result<List<AgencyListResultDTO>> agencyList(AgencyListFormDTO formDTO) {
List<AgencyListResultDTO> agencyList = customerAgencyDao.selectAgencyList(formDTO.getAgencyId());
return new Result<List<AgencyListResultDTO>>().ok(agencyList);
return new Result<List<AgencyListResultDTO>>().ok(null == agencyList ? new ArrayList<AgencyListResultDTO>() : agencyList);
}
@Override

6
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/DepartmentServiceImpl.java

@ -48,6 +48,7 @@ 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;
@ -162,6 +163,7 @@ public class DepartmentServiceImpl implements DepartmentService {
//2:查询部门下工作人员的用户Id集合
List<String> userIdList = customerStaffDepartmentDao.selectUserIdByDepartmentId(formDTO.getDepartmentId());
if (null == userIdList || userIdList.size() < NumConstant.ONE) {
departmentDetailResultDTO.setStaffList(new ArrayList<DepartInStaffListResultDTO>());
return result.ok(departmentDetailResultDTO);
}
DepartmentInStaffFormDTO departmentInStaffFormDTO = new DepartmentInStaffFormDTO();
@ -192,7 +194,7 @@ public class DepartmentServiceImpl implements DepartmentService {
DepartmentInAgencyResultDTO departmentInAgencyResultDTO = new DepartmentInAgencyResultDTO();
//1:根据当前机关Id查询该机关下的直属部门列表
List<DepartmentListResultDTO> departmentList = customerDepartmentDao.selectDepartmentListByAgencyId(formDTO.getAgencyId());
departmentInAgencyResultDTO.setDepartmentList(departmentList);
departmentInAgencyResultDTO.setDepartmentList(null == departmentList ? new ArrayList<DepartmentListResultDTO>() : departmentList);
//2:统计下一级机关数
departmentInAgencyResultDTO.setDepartmentCount(departmentList.size());
return new Result<DepartmentInAgencyResultDTO>().ok(departmentInAgencyResultDTO);
@ -207,7 +209,7 @@ public class DepartmentServiceImpl implements DepartmentService {
@Override
public Result<List<DepartmentListResultDTO>> departmentList(DepartmentListFormDTO formDTO) {
List<DepartmentListResultDTO> departmentList = customerDepartmentDao.selectDepartmentList(formDTO.getAgencyId());
return new Result<List<DepartmentListResultDTO>>().ok(departmentList);
return new Result<List<DepartmentListResultDTO>>().ok((null == departmentList ? new ArrayList<DepartmentListResultDTO>() : departmentList));
}
/**

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

@ -3,23 +3,26 @@
<mapper namespace="com.epmet.dao.CustomerAgencyDao">
<resultMap type="com.epmet.entity.CustomerAgencyEntity" id="customerAgencyMap">
<result property="id" column="ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="pid" column="PID"/>
<result property="pids" column="PIDS"/>
<result property="allParentName" column="ALL_PARENT_NAME"/>
<result property="organizationName" column="ORGANIZATION_NAME"/>
<result property="level" column="LEVEL"/>
<result property="areaCode" column="AREA_CODE"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
<result property="totalUser" column="TOTAL_USER"/>
</resultMap>
<sql id="sql">
ca.id AS "id",
ca.customer_id AS "customerId",
ca.pid AS "pid",
ca.pids AS "pids",
ca.all_parent_name AS "allParentName",
ca.organization_name AS "organizationName",
ca.level AS "level",
ca.area_code AS "areaCode",
ca.total_user AS "totalUser",
ca.province AS "province",
ca.city AS "city",
ca.district AS "district",
ca.del_flag AS "delflag",
ca.revision AS "revision",
ca.created_by AS "createdby",
ca.created_time AS "createdtime",
ca.updated_by AS "updatedby",
ca.updated_time AS "updatedtime"
</sql>
<!-- 查询客户对应的根级组织 -->
<select id="selectStaffOrgList" parameterType="map" resultType="com.epmet.dto.result.StaffOrgsResultDTO">
@ -71,4 +74,14 @@
AND pid = #{pId}
ORDER BY created_time DESC
</select>
<select id="selectFindList" parameterType="com.epmet.dto.CustomerAgencyDTO" resultType="com.epmet.dto.CustomerAgencyDTO">
SELECT
<include refid="sql"></include>
FROM customer_agency ca
WHERE ca.del_flag = '0'
<if test='pids != "" and pids != null'>
AND ca.pids LIKE concat('%', #{pids}, '%')
</if>
</select>
</mapper>
Loading…
Cancel
Save