Browse Source

对外接口 查询工作人员信息

master
wangchao 5 years ago
parent
commit
03af4c982a
  1. 6
      epmet-module/epmet-ext/epmet-ext-client/pom.xml
  2. 26
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ExtRoleMapResultDTO.java
  3. 82
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ExtStaffInfoResultDTO.java
  4. 10
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java
  5. 5
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java
  6. 12
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java
  7. 9
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java
  8. 9
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java
  9. 72
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java
  10. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/util/ModuleConstant.java
  11. 17
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml
  12. 24
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CommonStaffIdFormDTO.java
  13. 13
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java
  14. 9
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java
  15. 9
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java
  16. 23
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java
  17. 46
      epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml

6
epmet-module/epmet-ext/epmet-ext-client/pom.xml

@ -26,6 +26,12 @@
<version>3.6.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-user-client</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

26
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ExtRoleMapResultDTO.java

@ -0,0 +1,26 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Description
* @ClassName ExtRoleMapResultDTO
* @Auth wangc
* @Date 2020-08-17 09:19
*/
@Data
public class ExtRoleMapResultDTO implements Serializable {
private static final long serialVersionUID = 4988555173286922503L;
/**
* 角色key
* */
private String roleKey;
/**
* 角色名称
* */
private String roleName;
}

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

@ -0,0 +1,82 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @Description
* @ClassName ExtStaffInfoResultDTO
* @Auth wangc
* @Date 2020-08-17 09:14
*/
@Data
public class ExtStaffInfoResultDTO implements Serializable {
private static final long serialVersionUID = 3874334777882476292L;
/**
* 工作人员昵称
* */
private String nickname;
/**
* 工作人员头像
* */
private String profile;
/**
*
* */
private String realName;
/**
* 客户Id
* */
private String customerId;
/**
* 客户名称
* */
private String customerName;
/**
* 机关Id
* */
private String agencyId;
/**
* 机关名称
* */
private String agencyName;
/**
* 机关路径Id
* */
private String agencyIdPath;
/**
* 机关路径名称
* */
private String agencyNamePath;
/**
* 网格Id
* */
private String gridId;
/**
* 网格名称
* */
private String gridName;
/**
* 是否管理员标识 1是0否
* */
private String adminFlag;
/**
* 用户角色列表
* */
private List<ExtRoleMapResultDTO> roleList;
}

10
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java

@ -220,4 +220,14 @@ public interface GovOrgOpenFeignClient {
*/
@PostMapping(value = "/gov/org/customerstaffagency/getagencystaffs",consumes = MediaType.APPLICATION_JSON_VALUE)
Result<List<String>> getAgencyStaffs(@RequestBody AgencyIdFormDTO formDTO);
/**
* @Description User模块调用gov-org查询工作人员所在机关的信息以及客户信息
* @param result
* @return
* @author wangc
* @date 2020.08.17 14:11
**/
@PostMapping("/gov/org/customeragency/staffinfoext")
Result<ExtStaffInfoResultDTO> staffInfoExt(@RequestBody ExtStaffInfoResultDTO result);
}

5
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java

@ -131,4 +131,9 @@ public class GovOrgOpenFeignClientFallback implements GovOrgOpenFeignClient {
public Result<List<String>> getAgencyStaffs(AgencyIdFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getAgencyStaffs", formDTO);
}
@Override
public Result<ExtStaffInfoResultDTO> staffInfoExt(ExtStaffInfoResultDTO result) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "staffInfoExt", result);
}
}

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

@ -193,4 +193,16 @@ public class CustomerAgencyController {
Result<ActSponsorResultDTO> querySponsorList(@PathVariable("staffId") String staffId){
return new Result<ActSponsorResultDTO>().ok(customerAgencyService.querySponsorList(staffId));
}
/**
* @Description 对外接口 获取工作人员基本信息
* @param result ExtStaffInfoResultDTO.class
* @return Result<ExtStaffInfoResultDTO>
* @author wangc
* @date 2020.08.17 13:52
**/
@PostMapping("staffinfoext")
Result<ExtStaffInfoResultDTO> staffInfoExt(@RequestBody ExtStaffInfoResultDTO result){
return new Result<ExtStaffInfoResultDTO>().ok(customerAgencyService.staffInfoExt(result));
}
}

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

@ -124,4 +124,13 @@ public interface CustomerAgencyDao extends BaseDao<CustomerAgencyEntity> {
* @Description 递归查询当前机关的下一级机关列表
**/
List<ArticleGridResultDTO> selectAllSubAgency(@Param("subAgencyPids") String subAgencyPids);
/**
* @Description 查询一个工作人员最近登录的网格以及机关信息
* @param gridId
* @return
* @author wangc
* @date 2020.08.17 09:50
**/
ExtStaffInfoResultDTO selectAgencyAndGridInfoExt(@Param("gridId") String gridId);
}

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

@ -178,4 +178,13 @@ public interface CustomerAgencyService extends BaseService<CustomerAgencyEntity>
* @Date 2020/7/23 20:50
**/
ActSponsorResultDTO querySponsorList(String staffId);
/**
* @Description 查询工作人员的信息多客户/单客户epmet-plugin对外开放调用
* @param result
* @return
* @author wangc
* @date 2020.08.17 09:29
**/
ExtStaffInfoResultDTO staffInfoExt(ExtStaffInfoResultDTO result);
}

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

@ -39,6 +39,7 @@ import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.feign.OperCrmFeignClient;
import com.epmet.redis.CustomerAgencyRedis;
import com.epmet.service.CustomerAgencyService;
import com.epmet.util.ModuleConstant;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -46,6 +47,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.lang.reflect.Field;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
@ -834,4 +836,74 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao
}
/**
* @Description 查询工作人员的信息多客户/单客户epmet-plugin对外开放调用
* @param result
* @return
* @author wangc
* @date 2020.08.17 09:29
**/
@Override
public ExtStaffInfoResultDTO staffInfoExt(ExtStaffInfoResultDTO result) {
//1.查找对应的所属关系,通过最近一次登陆的网格,通过网格查找对应的机关和客户
ExtStaffInfoResultDTO orgInfo =
baseDao.selectAgencyAndGridInfoExt(result.getGridId());
mergeObject(orgInfo,result);
//2.查找客户名称
CustomerDTO customerParam = new CustomerDTO();
customerParam.setId(result.getCustomerId());
Result<CustomerDTO> customerResult =
operCrmFeignClient.getCustomerInfo(customerParam);
if(customerResult.success() && null != customerResult.getData()){
result.setCustomerName(customerResult.getData().getCustomerName());
}
checkFieldAndSetDefault(result);
return result;
}
public <T> void mergeObject(T origin, T destination) {
if (origin == null || destination == null)
return;
if (!origin.getClass().equals(destination.getClass()))
return;
Field[] fields = origin.getClass().getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
try {
fields[i].setAccessible(true);
Object value = fields[i].get(origin);
if (null != value) {
fields[i].set(destination, value);
}
fields[i].setAccessible(false);
} catch (Exception e) {
}
}
}
public <T> void checkFieldAndSetDefault(T origin) {
if (origin == null)
return;
Field[] fields = origin.getClass().getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
try {
fields[i].setAccessible(true);
Object value = fields[i].get(origin);
if (null == value && value.getClass().getName().equals("java.lang.String")) {
fields[i].set(origin, ModuleConstant.EMPTY_STR);
}
fields[i].setAccessible(false);
} catch (Exception e) {
}
}
}
}

2
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/util/ModuleConstant.java

@ -71,4 +71,6 @@ public interface ModuleConstant {
* 组织类型网格
* */
String ORG_TYPE_GRID = "grid";
String EMPTY_STR = "";
}

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

@ -169,4 +169,21 @@
ORDER BY created_time DESC
</select>
<!-- 查询一个工作人员最近登录的网格以及机关信息 -->
<select id="selectAgencyAndGridInfoExt" resultType="com.epmet.dto.result.ExtStaffInfoResultDTO">
SELECT
gridd.GRID_NAME,
agency.ID AS agencyId,
agency.ORGANIZATION_NAME AS agencyName,
agency.PID AS agencyIdPath,
agency.ALL_PARENT_NAME AS agencyNamePath,
agency.CUSTOMER_ID AS customerId
FROM
CUSTOMER_GRID gridd
LEFT JOIN CUSTOMER_AGENCY agency ON gridd.PID = agency.ID
AND agency.DEL_FLAG = '0'
WHERE
gridd.DEL_FLAG = '0'
AND gridd.ID = #{gridId}
</select>
</mapper>

24
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CommonStaffIdFormDTO.java

@ -0,0 +1,24 @@
package com.epmet.dto.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Description 工作人员Id
* @ClassName CommonStaffIdFormDTO
* @Auth wangc
* @Date 2020-08-17 10:28
*/
@Data
public class CommonStaffIdFormDTO implements Serializable {
private static final long serialVersionUID = -5093758817860808310L;
public interface StaffIdGroup extends CustomerClientShowGroup{}
@NotBlank(message = "工作人员Id不能为空" , groups = StaffIdGroup.class)
private String staffId;
}

13
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/CustomerStaffController.java

@ -333,4 +333,17 @@ public class CustomerStaffController {
ValidatorUtils.validateEntity(formDTO);
return new Result<List<StaffSinGridResultDTO>>().ok(customerStaffService.getStaffInfoList(formDTO));
}
/**
* @Description 查找工作人员的信息 - 对外开放接口
* @param staffParam
* @return
* @author wangc
* @date 2020.08.17 10:30
**/
@PostMapping("extstaffinfo")
public Result<ExtStaffInfoResultDTO> extStaffInfo(CommonStaffIdFormDTO staffParam){
ValidatorUtils.validateEntity(staffParam, CommonStaffIdFormDTO.StaffIdGroup.class);
return new Result<ExtStaffInfoResultDTO>().ok(customerStaffService.extStaffInfo(staffParam));
}
}

9
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/CustomerStaffDao.java

@ -153,4 +153,13 @@ public interface CustomerStaffDao extends BaseDao<CustomerStaffEntity> {
* @date 2020/8/13 1:45 下午
*/
List<StaffSinGridResultDTO> getStaffInfoList(@Param("userIds")List<String> userIds);
/**
* @Description 查询工作人员信息 (对外接口)
* @param staffId
* @return
* @author wangc
* @date 2020.08.17 13:26
**/
ExtStaffInfoResultDTO selectStaffInfoExt(@Param("staffId") String staffId);
}

9
epmet-user/epmet-user-server/src/main/java/com/epmet/service/CustomerStaffService.java

@ -266,4 +266,13 @@ public interface CustomerStaffService extends BaseService<CustomerStaffEntity> {
* @date 2020/8/13 1:45 下午
*/
List<StaffSinGridResultDTO> getStaffInfoList( UserIdsFormDTO formDTO);
/**
* @Description 查找工作人员的信息 - 对外开放接口
* @param staffParam
* @return
* @author wangc
* @date 2020.08.17 10:30
**/
ExtStaffInfoResultDTO extStaffInfo(CommonStaffIdFormDTO staffParam);
}

23
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java

@ -576,4 +576,27 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl<CustomerStaffDao,
return staffInfoList;
}
/**
* @Description 查找工作人员的信息 - 对外开放接口
* @param staffParam
* @return
* @author wangc
* @date 2020.08.17 10:30
**/
@Override
public ExtStaffInfoResultDTO extStaffInfo(CommonStaffIdFormDTO staffParam) {
//查找工作人员信息
//最近一次登陆的而网格、人员信息、权限
ExtStaffInfoResultDTO result = baseDao.selectStaffInfoExt(staffParam.getStaffId());
if(null != result) {
Result<ExtStaffInfoResultDTO> govOrgResult =
govOrgOpenFeignClient.staffInfoExt(result);
if(govOrgResult.success() && null != govOrgResult.getData()){
return govOrgResult.getData();
}
}
return null;
}
}

46
epmet-user/epmet-user-server/src/main/resources/mapper/CustomerStaffDao.xml

@ -235,4 +235,50 @@
cs.user_id = #{userId}
</foreach>
</select>
<!-- 工作人员信息Map -->
<resultMap id="StaffInfoAndRoleMap" type="com.epmet.dto.result.ExtStaffInfoResultDTO">
<result property="nickname" column="nickname"/>
<result property="profile" column="profile"/>
<result property="realName" column="realName"/>
<result property="gridId" column="GRID_ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
<collection property="roleList" ofType="com.epmet.dto.result.ExtRoleMapResultDTO">
<result property="roleKey" column="ROLE_KEY" />
<result property="roleName" column="ROLE_NAME" />
</collection>
</resultMap>
<!-- 查询工作人员信息 (对外接口) -->
<select id="selectStaffInfoExt" resultMap="StaffInfoAndRoleMap">
SELECT
staff.REAL_NAME AS nickname,
'' AS PROFILE,
staff.REAL_NAME AS realName,
role.ROLE_KEY,
role.ROLE_NAME,
vis.GRID_ID
FROM
CUSTOMER_STAFF staff
LEFT JOIN (
SELECT
role.STAFF_ID,
rolename.CUSTOMER_ID,
rolename.ROLE_KEY,
rolename.ROLE_NAME
FROM
STAFF_ROLE role
LEFT JOIN GOV_STAFF_ROLE rolename ON role.ROLE_ID = rolename.ID
AND rolename.DEL_FLAG = '0'
WHERE
role.DEL_FLAG = '0'
AND role.STAFF_ID = #{staffId}
) role ON staff.USER_ID = role.STAFF_ID
LEFT JOIN ( SELECT GRID_ID, CUSTOMER_ID, STAFF_ID FROM STAFF_GRID_VISITED WHERE DEL_FLAG = '0' AND STAFF_ID = #{staffId} ORDER BY UPDATED_TIME DESC LIMIT 1 ) vis ON staff.USER_ID = vis.STAFF_ID
AND vis.CUSTOMER_ID = role.CUSTOMER_ID
WHERE
DEL_FLAG = '0'
AND USER_ID = #{staffId}
</select>
</mapper>
Loading…
Cancel
Save