Browse Source

Merge remote-tracking branch 'remotes/origin/dev' into dev_pyscreen

# Conflicts:
#	epmet-auth/src/main/java/com/epmet/dto/form/SsoLoginFormDTO.java
#	epmet-auth/src/main/java/com/epmet/service/SsoService.java
#	epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java
dev_shibei_match
jianjun 5 years ago
parent
commit
18e0cff3ab
  1. 24
      epmet-auth/src/main/java/com/epmet/controller/SsoController.java
  2. 53
      epmet-auth/src/main/java/com/epmet/dto/form/SsoEnteOrgFormDTO.java
  3. 25
      epmet-auth/src/main/java/com/epmet/dto/form/SsoLoginFormDTO.java
  4. 14
      epmet-auth/src/main/java/com/epmet/service/SsoService.java
  5. 291
      epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java
  6. 5
      epmet-commons/epmet-common-clienttoken/src/main/java/com/epmet/common/token/constant/LoginConstant.java
  7. 2
      epmet-gateway/src/main/resources/bootstrap.yml
  8. 16
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govissue/result/IssueInfoDTO.java
  9. 19
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govproject/form/ProjectDistributionFormDTO.java
  10. 25
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govproject/result/ProjectDistributionResultDTO.java
  11. 7
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/resigroup/ResiTopicDTO.java
  12. 25
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/GovProjectController.java
  13. 7
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govissue/IssueDao.java
  14. 8
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govproject/ProjectDao.java
  15. 5
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/resigroup/ResiTopicDao.java
  16. 7
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govissue/GovIssueService.java
  17. 5
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govissue/impl/GovIssueServiceImpl.java
  18. 8
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govproject/GovProjectService.java
  19. 39
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govproject/impl/GovProjectServiceImpl.java
  20. 6
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/resigroup/ResiGroupService.java
  21. 12
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/resigroup/impl/ResiGroupServiceImpl.java
  22. 17
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govissue/IssueDao.xml
  23. 18
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govproject/ProjectDao.xml
  24. 21
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/resigroup/ResiTopicDao.xml

24
epmet-auth/src/main/java/com/epmet/controller/SsoController.java

@ -4,6 +4,7 @@ import com.epmet.commons.thirdplat.apiservice.jcet.JcetApiService;
import com.epmet.commons.thirdplat.bean.ThirdPlatUserInfo;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.SsoEnteOrgFormDTO;
import com.epmet.dto.form.SsoLoginFormDTO;
import com.epmet.dto.form.SsoLoginOperFormDTO;
import com.epmet.dto.result.SsoLoginResultDTO;
@ -64,4 +65,27 @@ public class SsoController {
return new Result<ThirdPlatUserInfo>().ok(userInfoByTicket);
}
/**
* @param formDTO
* @Author sun
* @Description 1ticket自动登录获取内部token
**/
@PostMapping("work/login")
public Result<UserTokenResultDTO> ssoWorkLogin(@RequestBody SsoLoginFormDTO formDTO){
ValidatorUtils.validateEntity(formDTO, SsoLoginFormDTO.SsoLoginForm.class);
return new Result<UserTokenResultDTO>().ok(ssoService.ssoWorkLogin(formDTO));
}
/**
* @param formDTO
* @Author sun
* @Description 4自动进入组织-返回token
**/
@PostMapping(value = "work/enterorg")
public Result<UserTokenResultDTO> enterOrg(@RequestBody SsoEnteOrgFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, SsoEnteOrgFormDTO.AddUserShowGroup.class, SsoEnteOrgFormDTO.AddUserInternalGroup.class);
UserTokenResultDTO userTokenResultDTO = ssoService.enterOrg(formDTO);
return new Result<UserTokenResultDTO>().ok(userTokenResultDTO);
}
}

53
epmet-auth/src/main/java/com/epmet/dto/form/SsoEnteOrgFormDTO.java

@ -0,0 +1,53 @@
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 4自动进入组织-返回token
* @Author sun
*/
@Data
public class SsoEnteOrgFormDTO implements Serializable {
public interface AddUserInternalGroup {}
public interface AddUserShowGroup extends CustomerClientShowGroup {}
/**
* wxCode
*/
@NotBlank(message = "ticket不能为空",groups = {AddUserInternalGroup.class})
private String ticket;
/**
* 手机号
*/
@NotBlank(message = "手机号不能为空",groups = {AddUserShowGroup.class})
private String mobile;
/**
* 选择的组织所属的id
*/
@NotBlank(message = "客户id不能为空",groups = {AddUserInternalGroup.class})
private String customerId;
/**
* 选择的要进入的组织(根组织id)
*/
@NotBlank(message = "组织id不能为空",groups = {AddUserInternalGroup.class})
private String rootAgencyId;
/**
* resi居民段gov工作端
*/
@NotBlank(message = "app不能为空",groups = SsoLoginFormDTO.SsoLoginForm.class)
private String app;
/**
* app居民段app工作端
*/
@NotBlank(message = "client不能为空",groups = SsoLoginFormDTO.SsoLoginForm.class)
private String client;
}

25
epmet-auth/src/main/java/com/epmet/dto/form/SsoLoginFormDTO.java

@ -14,11 +14,7 @@ public class SsoLoginFormDTO implements Serializable {
private static final long serialVersionUID = -6543952487970013031L;
public interface SsoLoginForm {
}
public interface ThirdPlatformLoginForm {
}
public interface SsoLoginForm{}
/**
* sso票据有效期为300秒
@ -33,25 +29,14 @@ public class SsoLoginFormDTO implements Serializable {
private String appId;
/**
* app类型 resi居民段work工作端
* app类型 resi居民段gov工作端
*/
@NotBlank(message = "app不能为空", groups = SsoLoginForm.class)
private String app;
@NotBlank(message = "client不能为空", groups = SsoLoginForm.class)
private String client;
/**
* 上游系统token
* app居民段app工作端
*/
@NotBlank(message = "token不能为空", groups = {ThirdPlatformLoginForm.class})
private String thirdToken;
/**
* 上游系统token
*
* @see com.epmet.enums.ThirdPlatformEnum
*/
@NotBlank(message = "token不能为空", groups = {ThirdPlatformLoginForm.class})
private String platform;
@NotBlank(message = "client不能为空", groups = SsoLoginForm.class)
private String client;
}

14
epmet-auth/src/main/java/com/epmet/service/SsoService.java

@ -1,5 +1,6 @@
package com.epmet.service;
import com.epmet.dto.form.SsoEnteOrgFormDTO;
import com.epmet.dto.form.SsoLoginFormDTO;
import com.epmet.dto.form.SsoLoginOperFormDTO;
import com.epmet.dto.result.SsoLoginResultDTO;
@ -19,6 +20,19 @@ public interface SsoService {
*/
SsoLoginResultDTO ssoLogin(SsoLoginFormDTO formDTO);
/**
* @param formDTO
* @Author sun
* @Description 1ticket自动登录获取内部token
**/
UserTokenResultDTO ssoWorkLogin(SsoLoginFormDTO formDTO);
/**
* @param formDTO
* @Author sun
* @Description 4自动进入组织-返回token
**/
UserTokenResultDTO enterOrg(SsoEnteOrgFormDTO formDTO);
/**
* desc: sso登陆运营端
*

291
epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java

@ -2,12 +2,18 @@ package com.epmet.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.epmet.common.token.constant.LoginConstant;
import com.epmet.commons.thirdplat.apiservice.AbstractApiService;
import com.epmet.commons.thirdplat.bean.ThirdPlatUserInfo;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.security.dto.GovTokenDto;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.*;
import com.epmet.dto.*;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.dto.PaCustomerDTO;
import com.epmet.dto.UserDTO;
import com.epmet.dto.form.*;
@ -18,6 +24,7 @@ import com.epmet.dto.result.UserTokenResultDTO;
import com.epmet.enums.ThirdPlatformEnum;
import com.epmet.feign.EpmetUserFeignClient;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.feign.OperCrmOpenFeignClient;
import com.epmet.jwt.JwtTokenProperties;
import com.epmet.jwt.JwtTokenUtils;
@ -30,10 +37,14 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* @Author zxc
@ -60,6 +71,12 @@ public class SsoServiceImpl implements SsoService {
@Autowired
private OperCrmOpenFeignClient operCrmOpenFeignClient;
@Autowired
private GovOrgOpenFeignClient govOrgOpenFeignClient;
@Autowired
private CpUserDetailRedis cpUserDetailRedis;
@Autowired
private EpmetUserFeignClient epmetUserFeignClient;
@ -232,6 +249,280 @@ public class SsoServiceImpl implements SsoService {
return customer.getId();
}
/**
* @param formDTO
* @Author sun
* @Description 1ticket自动登录获取内部token
**/
@Override
public UserTokenResultDTO ssoWorkLogin(SsoLoginFormDTO formDTO) {
//1.根据appId查询客户id
String customerId = getCustomerId(formDTO.getAppId());
//2.客户Id换取第三方apiService,根据ticket换取华为Id
Result<ThirdplatApiserviceResultDTO> apiServiceResult = operCrmOpenFeignClient.getApiServiceByCustomerId(new ApiServiceFormDTO(customerId));
if (!apiServiceResult.success()) {
throw new RenException("【SSO登录】调用OperCrm获取ApiService接口失败:", apiServiceResult.getInternalMsg());
}
if (apiServiceResult.getData() == null || StringUtils.isBlank(apiServiceResult.getData().getApiServiceName())) {
throw new RenException("【SSO登录】调用OperCrm获取ApiService,查询到的结果为空:", apiServiceResult.toString());
}
ThirdPlatUserInfo userInfo;
try {
AbstractApiService apiService = (AbstractApiService) SpringContextUtils.getBean(apiServiceResult.getData().getApiServiceName());
userInfo = apiService.getUserInfoByTicket(formDTO.getTicket());
} catch (Exception e) {
throw new RenException(e.getMessage());
}
if (null == userInfo){
throw new RenException(EpmetErrorCode.THIRD_PLAT_REQUEST_ERROR.getCode(),
"【SSO登录】调用第三方平台查询用户信息失败,用户信息为空");
}
//3.根据华为openId查询用户是否存在历史登陆信息
Result<StaffLatestAgencyResultDTO> latestStaffWechat = epmetUserOpenFeignClient.getLatestStaffWechatLoginRecord(userInfo.getOpenId());
if (!latestStaffWechat.success() || null == latestStaffWechat.getData()) {
logger.error(String.format("没有获取到用户最近一次登录账户信息,code[%s],msg[%s]", EpmetErrorCode.PLEASE_LOGIN.getCode(), EpmetErrorCode.PLEASE_LOGIN.getMsg()));
throw new RenException(EpmetErrorCode.PLEASE_LOGIN.getCode());
}
StaffLatestAgencyResultDTO staffLatestAgencyResultDTO = latestStaffWechat.getData();
//4.记录staff_wechat
this.savestaffwechat(staffLatestAgencyResultDTO.getStaffId(), userInfo.getOpenId());
//5.记录登录日志
this.saveStaffLoginRecord(staffLatestAgencyResultDTO);
//6.获取用户token
String token = this.generateGovWxmpToken(staffLatestAgencyResultDTO.getStaffId(), formDTO.getApp(), formDTO.getClient());
//7.保存到redis
this.saveLatestGovTokenDto(staffLatestAgencyResultDTO, userInfo, token);
UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO();
userTokenResultDTO.setToken(token);
return userTokenResultDTO;
}
/**
* @param userId openid
* @Author sun
* @Description 保存微信和当前登录用户关系
**/
private Result savestaffwechat(String userId, String openid) {
StaffWechatFormDTO staffWechatFormDTO = new StaffWechatFormDTO();
staffWechatFormDTO.setUserId(userId);
staffWechatFormDTO.setWxOpenId(openid);
return epmetUserOpenFeignClient.saveStaffWechat(staffWechatFormDTO);
}
/**
* @param latestStaffWechatLoginDTO
* @Author sun
* @Description 保存登录日志
**/
private Result saveStaffLoginRecord(StaffLatestAgencyResultDTO latestStaffWechatLoginDTO) {
StaffLoginAgencyRecordFormDTO staffLoginAgencyRecordFormDTO = new StaffLoginAgencyRecordFormDTO();
staffLoginAgencyRecordFormDTO.setCustomerId(latestStaffWechatLoginDTO.getCustomerId());
staffLoginAgencyRecordFormDTO.setStaffId(latestStaffWechatLoginDTO.getStaffId());
staffLoginAgencyRecordFormDTO.setWxOpenId(latestStaffWechatLoginDTO.getWxOpenId());
staffLoginAgencyRecordFormDTO.setMobile(latestStaffWechatLoginDTO.getMobile());
staffLoginAgencyRecordFormDTO.setAgencyId(latestStaffWechatLoginDTO.getAgencyId());
Result staffLoginRecordResult = epmetUserOpenFeignClient.saveStaffLoginRecord(staffLoginAgencyRecordFormDTO);
return staffLoginRecordResult;
}
/**
* @Description 生成政府端小程序业务token Key
* @Author sun
**/
private String generateGovWxmpToken(String staffId, String app, String client) {
Map<String, Object> map = new HashMap<>();
map.put("app", app);
map.put("client", client);
map.put("userId", staffId);
String token = jwtTokenUtils.createToken(map);
logger.info("app:" + app + ";client:" + client + ";userId:" + staffId + ";生成token[" + token + "]");
return token;
}
/**
* @Description 保存tokenDto到redis
* @Author sun
**/
private void saveLatestGovTokenDto(StaffLatestAgencyResultDTO staffLatestAgency, ThirdPlatUserInfo userInfo, String token) {
int expire = jwtTokenProperties.getExpire();
GovTokenDto govTokenDto = new GovTokenDto();
govTokenDto.setApp(LoginConstant.APP_GOV);
govTokenDto.setClient(LoginConstant.CLIENT_WXMP);
govTokenDto.setUserId(staffLatestAgency.getStaffId());
govTokenDto.setOpenId(userInfo.getOpenId());
govTokenDto.setSessionKey("");
govTokenDto.setUnionId("");
govTokenDto.setToken(token);
govTokenDto.setUpdateTime(System.currentTimeMillis());
govTokenDto.setExpireTime(jwtTokenUtils.getExpiration(token).getTime());
govTokenDto.setRootAgencyId(staffLatestAgency.getAgencyId());
govTokenDto.setCustomerId(staffLatestAgency.getCustomerId());
//设置部门,网格,角色列表
govTokenDto.setDeptIdList(getDeptartmentIdList(staffLatestAgency.getStaffId()));
govTokenDto.setGridIdList(getGridIdList(staffLatestAgency.getStaffId()));
CustomerAgencyDTO agency = getAgencyByStaffId(staffLatestAgency.getStaffId());
if (agency != null) {
govTokenDto.setAgencyId(agency.getId());
govTokenDto.setRoleList(queryGovStaffRoles(staffLatestAgency.getStaffId(), agency.getId()));
}
govTokenDto.setOrgIdPath(getOrgIdPath(staffLatestAgency.getStaffId()));
cpUserDetailRedis.set(govTokenDto, expire);
logger.info("截止时间:" + DateUtils.format(jwtTokenUtils.getExpiration(token), "yyyy-MM-dd HH:mm:ss"));
}
public Set<String> getDeptartmentIdList(String staffId) {
try {
Result<List<DepartmentListResultDTO>> deptListResult = govOrgOpenFeignClient.getDepartmentListByStaffId(staffId);
if (deptListResult.success()) {
if (!CollectionUtils.isEmpty(deptListResult.getData())) {
Set<String> deptIdLists = deptListResult.getData().stream().map(dept -> dept.getDepartmentId()).collect(Collectors.toSet());
return deptIdLists;
}
} else {
logger.error("登录:查询部门列表,远程调用返回错误:{}", deptListResult.getMsg());
}
} catch (Exception e) {
String errorStackTrace = ExceptionUtils.getErrorStackTrace(e);
logger.error("登录:查询部门列表异常:{}", errorStackTrace);
}
return null;
}
/**
* 根据工作人员ID查询网格ID列表
* @param staffId
*/
public Set<String> getGridIdList(String staffId) {
Result<List<GridByStaffResultDTO>> result = govOrgOpenFeignClient.listGridsbystaffid(staffId);
if (!result.success()) {
logger.error("登录:查询网格列表,远程调用返回错误:{}", result.getMsg());
return null;
} else {
List<GridByStaffResultDTO> grids = result.getData();
return grids.stream().map(grid -> grid.getGridId()).collect(Collectors.toSet());
}
}
/**
* 根据staffId查询所属的组织机构
*
* @param staffId
*/
public CustomerAgencyDTO getAgencyByStaffId(String staffId) {
Result<CustomerAgencyDTO> result = govOrgOpenFeignClient.getAgencyByStaff(staffId);
if (!result.success()) {
logger.error("登录:查询登录人所属的机关OrgIdPath失败:{}", result.getMsg());
return null;
}
return result.getData();
}
/**
* 查询人员在某机关单位下的角色列表
* @param staffId orgId
*/
public List<GovTokenDto.Role> queryGovStaffRoles(String staffId, String orgId) {
StaffRoleFormDTO formDTO = new StaffRoleFormDTO();
formDTO.setStaffId(staffId);
formDTO.setOrgId(orgId);
Result<List<GovStaffRoleDTO>> gridResult = epmetUserOpenFeignClient.getRolesOfStaff(formDTO);
if (!CollectionUtils.isEmpty(gridResult.getData())) {
//return gridResult.getData().stream().map(role -> role.getId()).collect(Collectors.toSet());
return ConvertUtils.sourceToTarget(gridResult.getData(), GovTokenDto.Role.class);
}
return null;
}
/**
* 查询工作人员的OrgIdPath
* @param staffId
*/
public String getOrgIdPath(String staffId) {
Result<CustomerAgencyDTO> result = govOrgOpenFeignClient.getAgencyByStaff(staffId);
if (!result.success()) {
logger.error("登录:查询登录人所属的机关OrgIdPath失败:{}", result.getMsg());
return null;
}
CustomerAgencyDTO agency = result.getData();
if (agency != null) {
if ("0".equals(agency.getPid())) {
// 顶级
return agency.getId();
} else {
return agency.getPids().concat(":").concat(agency.getId());
}
}
return null;
}
/**
* @param formDTO
* @Author sun
* @Description 4自动进入组织-返回token
**/
@Override
public UserTokenResultDTO enterOrg(SsoEnteOrgFormDTO formDTO) {
//1、需要校验要登录的客户,是否被禁用
CustomerStaffFormDTO customerStaffFormDTO = new CustomerStaffFormDTO();
customerStaffFormDTO.setCustomerId(formDTO.getCustomerId());
customerStaffFormDTO.setMobile(formDTO.getMobile());
Result<CustomerStaffDTO> customerStaffDTOResult = epmetUserOpenFeignClient.getCustomerStaffInfo(customerStaffFormDTO);
if (!customerStaffDTOResult.success() || null == customerStaffDTOResult.getData()) {
logger.error(String.format("获取工作人员信息失败,手机号[%s],客户id:[%s],code[%s],msg[%s]", formDTO.getMobile(), formDTO.getCustomerId(), customerStaffDTOResult.getCode(), customerStaffDTOResult.getMsg()));
throw new RenException(customerStaffDTOResult.getCode());
}
CustomerStaffDTO customerStaff = customerStaffDTOResult.getData();
//2.客户Id换取第三方apiService,根据ticket换取华为Id
Result<ThirdplatApiserviceResultDTO> apiServiceResult = operCrmOpenFeignClient.getApiServiceByCustomerId(new ApiServiceFormDTO(formDTO.getCustomerId()));
if (!apiServiceResult.success()) {
throw new RenException("【SSO登录】调用OperCrm获取ApiService接口失败:", apiServiceResult.getInternalMsg());
}
if (apiServiceResult.getData() == null || StringUtils.isBlank(apiServiceResult.getData().getApiServiceName())) {
throw new RenException("【SSO登录】调用OperCrm获取ApiService,查询到的结果为空:", apiServiceResult.toString());
}
ThirdPlatUserInfo userInfo;
try {
AbstractApiService apiService = (AbstractApiService) SpringContextUtils.getBean(apiServiceResult.getData().getApiServiceName());
userInfo = apiService.getUserInfoByTicket(formDTO.getTicket());
} catch (Exception e) {
throw new RenException(e.getMessage());
}
if (null == userInfo){
throw new RenException(EpmetErrorCode.THIRD_PLAT_REQUEST_ERROR.getCode(),
"【SSO登录】调用第三方平台查询用户信息失败,用户信息为空");
}
//3、记录staff_wechat,并记录用户激活状态,激活时间
this.savestaffwechat(customerStaff.getUserId(), userInfo.getOpenId());
//4、记录登录日志
StaffLatestAgencyResultDTO staffLatestAgencyResultDTO = new StaffLatestAgencyResultDTO();
staffLatestAgencyResultDTO.setCustomerId(formDTO.getCustomerId());
staffLatestAgencyResultDTO.setStaffId(customerStaff.getUserId());
staffLatestAgencyResultDTO.setWxOpenId(userInfo.getOpenId());
staffLatestAgencyResultDTO.setMobile(formDTO.getMobile());
staffLatestAgencyResultDTO.setAgencyId(formDTO.getRootAgencyId());
this.saveStaffLoginRecord(staffLatestAgencyResultDTO);
//5.1、获取用户token
String token = this.generateGovWxmpToken(customerStaff.getUserId(), formDTO.getApp(), formDTO.getClient());
//5.2、保存到redis
StaffLatestAgencyResultDTO staffLatestAgency = new StaffLatestAgencyResultDTO();
staffLatestAgency.setAgencyId(formDTO.getRootAgencyId());
staffLatestAgency.setCustomerId(formDTO.getCustomerId());
staffLatestAgency.setStaffId(customerStaff.getUserId());
this.saveLatestGovTokenDto(staffLatestAgency, userInfo, token);
UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO();
userTokenResultDTO.setToken(token);
return userTokenResultDTO;
}
public static void main(String[] args) {
String url = "https://epmet-ext9.elinkservice.cn/platform/unifiedAuth/loginCheck";
String platformToken = "1348803062424166401_dd08e23b0d524879a5c67e7f2ffd1468";

5
epmet-commons/epmet-common-clienttoken/src/main/java/com/epmet/common/token/constant/LoginConstant.java

@ -40,4 +40,9 @@ public interface LoginConstant {
* E事通服务号
*/
String CLIENT_MP = "mp";
/**
* 手机App
*/
String CLIENT_APP = "app";
}

2
epmet-gateway/src/main/resources/bootstrap.yml

@ -468,7 +468,7 @@ epmet:
- /epmet/ext/**
- /epmetuser/customerstaff/customerlist
- /message/template/**
- /data/aggregator/project/projectdistribution
swaggerUrls:
jwt:

16
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govissue/result/IssueInfoDTO.java

@ -0,0 +1,16 @@
package com.epmet.dataaggre.dto.govissue.result;
import lombok.Data;
/**
* 描述一下
*
* @author yinzuomei@elink-cn.com
* @date 2021/2/24 12:12
*/
@Data
public class IssueInfoDTO {
private String issueId;
private String gridId;
private String topicId;
}

19
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govproject/form/ProjectDistributionFormDTO.java

@ -0,0 +1,19 @@
package com.epmet.dataaggre.dto.govproject.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 项目分布实时只适用于e事通客户入参
*
* @author yinzuomei@elink-cn.com
* @date 2021/2/24 11:04
*/
@Data
public class ProjectDistributionFormDTO implements Serializable {
private String gridId;
@NotBlank(message = "customerId不能为空")
private String customerId;
}

25
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govproject/result/ProjectDistributionResultDTO.java

@ -0,0 +1,25 @@
package com.epmet.dataaggre.dto.govproject.result;
import lombok.Data;
import java.io.Serializable;
/**
* 项目分布实时只适用于e事通客户返参
*
* @author yinzuomei@elink-cn.com
* @date 2021/2/24 11:05
*/
@Data
public class ProjectDistributionResultDTO implements Serializable {
private String projectId;
private String projectTitle;
private String statusDesc;
private String longitude;
private String latitude;
// @JsonIgnore
private String issueId;
// @JsonIgnore
private String statusCode;
private String gridId;
}

7
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/resigroup/ResiTopicDTO.java

@ -17,9 +17,10 @@
package com.epmet.dataaggre.dto.resigroup;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
@ -128,4 +129,8 @@ public class ResiTopicDTO implements Serializable {
*/
private String issueId;
/**
* 话题所属网格id
*/
private String gridId;
}

25
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/GovProjectController.java

@ -5,14 +5,16 @@ import com.epmet.commons.tools.annotation.RequirePermission;
import com.epmet.commons.tools.enums.RequirePermissionEnum;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dataaggre.dto.govproject.form.AllProjectFormDTO;
import com.epmet.dataaggre.dto.govproject.form.ProjectDistributionFormDTO;
import com.epmet.dataaggre.dto.govproject.result.AllProjectResultDTO;
import com.epmet.dataaggre.dto.govproject.result.ProjectDistributionResultDTO;
import com.epmet.dataaggre.service.govproject.GovProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @Author zxc
@ -39,4 +41,19 @@ public class GovProjectController {
AllProjectResultDTO result = govProjectService.allProjectList(tokenDto, formDTO);
return new Result<AllProjectResultDTO>().ok(result);
}
/**
* @param customerId
* @param formDTO
* @author yinzuomei 项目分布实时只适用于e事通客户返参
* @description 目前在用龙湾大屏调用此接口接口内写死了 按照立项时间降序取前100个项目
* @Date 2021/2/24 13:17
**/
@PostMapping("projectdistribution")
public Result<List<ProjectDistributionResultDTO>> queryProjectDistribution(@RequestHeader("CustomerId") String customerId,
@RequestBody ProjectDistributionFormDTO formDTO){
formDTO.setCustomerId(customerId);
ValidatorUtils.validateEntity(formDTO);
return new Result<List<ProjectDistributionResultDTO>>().ok(govProjectService.queryProjectDistribution(formDTO));
}
}

7
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govissue/IssueDao.java

@ -21,10 +21,7 @@ import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dataaggre.dto.govissue.form.ClosedIssueListFormDTO;
import com.epmet.dataaggre.dto.govissue.form.ShiftProjectIssueListFormDTO;
import com.epmet.dataaggre.dto.govissue.form.VotingIssueListFormDTO;
import com.epmet.dataaggre.dto.govissue.result.ClosedIssueListResultDTO;
import com.epmet.dataaggre.dto.govissue.result.IssueListResultDTO;
import com.epmet.dataaggre.dto.govissue.result.IssueShiftProjectResultDTO;
import com.epmet.dataaggre.dto.govissue.result.VotingIssueListResultDTO;
import com.epmet.dataaggre.dto.govissue.result.*;
import com.epmet.dataaggre.entity.govissue.IssueEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -75,4 +72,6 @@ public interface IssueDao extends BaseDao<IssueEntity> {
List<ClosedIssueListResultDTO> selectClosedListGov(ClosedIssueListFormDTO fromDTO);
Integer selectIssueCount(@Param("gridIds") List<String> gridIds,@Param("issueType")String issueType);
List<IssueInfoDTO> selectShiftProjectIssueList(@Param("customerId") String customerId, @Param("gridId") String gridId);
}

8
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/govproject/ProjectDao.java

@ -18,18 +18,17 @@
package com.epmet.dataaggre.dao.govproject;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dataaggre.dto.govproject.form.AllProjectFormDTO;
import com.epmet.dataaggre.dto.govproject.result.ProjectInfoDTO;
import com.epmet.dataaggre.dto.govissue.result.IssueListResultDTO;
import com.epmet.dataaggre.dto.govproject.ProjectDTO;
import com.epmet.dataaggre.dto.govproject.form.AllProjectFormDTO;
import com.epmet.dataaggre.dto.govproject.result.ProjectDistributionResultDTO;
import com.epmet.dataaggre.dto.govproject.result.ProjectInfoDTO;
import com.epmet.dataaggre.entity.govproject.ProjectEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.List;
/**
* 项目表
*
@ -68,4 +67,5 @@ public interface ProjectDao extends BaseDao<ProjectEntity> {
**/
List<String> selectDepartmentNameList(ProjectDTO project);
List<ProjectDistributionResultDTO> selectList(@Param("customerId") String customerId,@Param("list")List<String> issueIds);
}

5
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/resigroup/ResiTopicDao.java

@ -18,8 +18,12 @@
package com.epmet.dataaggre.dao.resigroup;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dataaggre.dto.resigroup.ResiTopicDTO;
import com.epmet.dataaggre.entity.resigroup.ResiTopicEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 话题信息表
@ -30,4 +34,5 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ResiTopicDao extends BaseDao<ResiTopicEntity> {
List<ResiTopicDTO> selectTopicInfoByIds(@Param("list") List<String> topicIds);
}

7
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govissue/GovIssueService.java

@ -5,10 +5,7 @@ import com.epmet.dataaggre.dto.govissue.form.AllIssueFormDTO;
import com.epmet.dataaggre.dto.govissue.form.ClosedIssueListFormDTO;
import com.epmet.dataaggre.dto.govissue.form.ShiftProjectIssueListFormDTO;
import com.epmet.dataaggre.dto.govissue.form.VotingIssueListFormDTO;
import com.epmet.dataaggre.dto.govissue.result.AllIssueResultDTO;
import com.epmet.dataaggre.dto.govissue.result.ClosedIssueListResultDTO;
import com.epmet.dataaggre.dto.govissue.result.ShiftProjectIssueListResultDTO;
import com.epmet.dataaggre.dto.govissue.result.VotingIssueListResultDTO;
import com.epmet.dataaggre.dto.govissue.result.*;
import java.util.List;
@ -46,4 +43,6 @@ public interface GovIssueService {
* @author sun
**/
List<ClosedIssueListResultDTO> closedIssueList(ClosedIssueListFormDTO fromDTO);
List<IssueInfoDTO> selectShiftProjectIssueList(String customerId,String gridId);
}

5
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govissue/impl/GovIssueServiceImpl.java

@ -313,4 +313,9 @@ public class GovIssueServiceImpl implements GovIssueService {
return resultList;
}
@Override
public List<IssueInfoDTO> selectShiftProjectIssueList(String customerId,String gridId) {
return issueDao.selectShiftProjectIssueList(customerId,gridId);
}
}

8
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govproject/GovProjectService.java

@ -1,12 +1,11 @@
package com.epmet.dataaggre.service.govproject;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.dataaggre.dto.govissue.result.IssueListResultDTO;
import com.epmet.dataaggre.dto.govproject.form.AllProjectFormDTO;
import com.epmet.dataaggre.dto.govproject.form.ProjectDistributionFormDTO;
import com.epmet.dataaggre.dto.govproject.result.AllProjectResultDTO;
import java.util.List;
import com.epmet.dataaggre.dto.govissue.result.IssueListResultDTO;
import com.epmet.dataaggre.dto.govproject.result.ProjectDistributionResultDTO;
import com.epmet.dataaggre.dto.govproject.result.ShiftProjectResultDTO;
import java.util.List;
@ -41,4 +40,5 @@ public interface GovProjectService {
List<ShiftProjectResultDTO> getProjectByIssue(List<String> issueIdList);
List<ProjectDistributionResultDTO> queryProjectDistribution(ProjectDistributionFormDTO formDTO);
}

39
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govproject/impl/GovProjectServiceImpl.java

@ -8,17 +8,21 @@ import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dataaggre.constant.DataSourceConstant;
import com.epmet.dataaggre.constant.ProjectConstant;
import com.epmet.dataaggre.dao.govorg.CustomerStaffAgencyDao;
import com.epmet.dataaggre.dao.govproject.ProjectDao;
import com.epmet.dataaggre.dto.govissue.result.IssueInfoDTO;
import com.epmet.dataaggre.dto.govissue.result.IssueListResultDTO;
import com.epmet.dataaggre.dto.govorg.CustomerStaffAgencyDTO;
import com.epmet.dataaggre.dto.govproject.ProjectDTO;
import com.epmet.dataaggre.dto.govproject.form.AllProjectFormDTO;
import com.epmet.dataaggre.dto.govproject.form.ProjectDistributionFormDTO;
import com.epmet.dataaggre.dto.govproject.result.AllProjectResultDTO;
import com.epmet.dataaggre.dto.govproject.result.ProjectDistributionResultDTO;
import com.epmet.dataaggre.dto.govproject.result.ProjectInfoDTO;
import com.epmet.dataaggre.dto.govproject.result.ShiftProjectResultDTO;
import com.epmet.dataaggre.dto.resigroup.ResiTopicDTO;
import com.epmet.dataaggre.service.govissue.GovIssueService;
import com.epmet.dataaggre.service.govorg.GovOrgService;
import com.epmet.dataaggre.service.govproject.GovProjectService;
import com.epmet.dataaggre.service.resigroup.ResiGroupService;
import com.epmet.dto.form.TimestampIntervalFormDTO;
import com.epmet.dto.form.WorkMinuteFormDTO;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
@ -46,6 +50,10 @@ public class GovProjectServiceImpl implements GovProjectService {
private GovOrgService govOrgService;
@Autowired
private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient;
@Autowired
private GovIssueService govIssueService;
@Autowired
private ResiGroupService resiGroupService;
/**
* @Description 查询项目信息
@ -103,6 +111,33 @@ public class GovProjectServiceImpl implements GovProjectService {
return resultList;
}
@Override
public List<ProjectDistributionResultDTO> queryProjectDistribution(ProjectDistributionFormDTO formDTO) {
List<ProjectDistributionResultDTO> resultDTOList = new ArrayList<>();
List<IssueInfoDTO> issueInfoDTOList = govIssueService.selectShiftProjectIssueList(formDTO.getCustomerId(), formDTO.getGridId());
if (CollectionUtils.isNotEmpty(issueInfoDTOList)) {
List<String> topicIds = issueInfoDTOList.stream().map(data -> data.getTopicId()).collect(Collectors.toList());
// log.info("话题id集合:" + JSON.toJSONString(topicIds, true));
List<ResiTopicDTO> topicInfoDTOList = resiGroupService.selectTopicInfoByIds(topicIds);
List<String> issueIds = issueInfoDTOList.stream().map(data -> data.getIssueId()).collect(Collectors.toList());
// log.info("议题id集合:" + JSON.toJSONString(issueIds, true));
resultDTOList = projectDao.selectList(formDTO.getCustomerId(),issueIds);
for (ProjectDistributionResultDTO project : resultDTOList) {
for (ResiTopicDTO topicInfoDTO : topicInfoDTOList) {
if (project.getIssueId().equals(topicInfoDTO.getIssueId())) {
//维度
project.setLatitude(topicInfoDTO.getDimension());
//经度
project.setLongitude(topicInfoDTO.getLongitude());
project.setGridId(topicInfoDTO.getGridId());
break;
}
}
}
}
return resultDTOList;
}
/**
* 全部项目

6
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/resigroup/ResiGroupService.java

@ -1,8 +1,14 @@
package com.epmet.dataaggre.service.resigroup;
import com.epmet.dataaggre.dto.resigroup.ResiTopicDTO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @Author zxc
* @DateTime 2020/12/25 上午9:21
*/
public interface ResiGroupService {
List<ResiTopicDTO> selectTopicInfoByIds(@Param("topicIds") List<String> topicIds);
}

12
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/resigroup/impl/ResiGroupServiceImpl.java

@ -2,10 +2,15 @@ package com.epmet.dataaggre.service.resigroup.impl;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.dataaggre.constant.DataSourceConstant;
import com.epmet.dataaggre.dao.resigroup.ResiTopicDao;
import com.epmet.dataaggre.dto.resigroup.ResiTopicDTO;
import com.epmet.dataaggre.service.resigroup.ResiGroupService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Author zxc
* @DateTime 2020/12/25 上午9:21
@ -14,4 +19,11 @@ import org.springframework.stereotype.Service;
@DataSource(DataSourceConstant.RESI_GROUP)
@Slf4j
public class ResiGroupServiceImpl implements ResiGroupService {
@Autowired
private ResiTopicDao resiTopicDao;
@Override
public List<ResiTopicDTO> selectTopicInfoByIds(List<String> topicIds) {
return resiTopicDao.selectTopicInfoByIds(topicIds);
}
}

17
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govissue/IssueDao.xml

@ -107,4 +107,21 @@
</foreach>)
</select>
<select id="selectShiftProjectIssueList" parameterType="map" resultType="com.epmet.dataaggre.dto.govissue.result.IssueInfoDTO">
SELECT
i.ID as issueId,
i.GRID_ID as gridId,
i.SOURCE_ID as topicId
FROM
issue i
WHERE
i.DEL_FLAG = '0'
AND i.ISSUE_STATUS = 'shift_project'
and i.SOURCE_TYPE='resi_topic'
AND i.CUSTOMER_ID = #{customerId}
<if test="gridId != null and gridId.trim() != ''">
AND i.GRID_ID = #{gridId}
</if>
order by i.SHIFTED_TIME desc limit 100
</select>
</mapper>

18
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govproject/ProjectDao.xml

@ -124,4 +124,22 @@
AND p.id = #{id}
</select>
<select id="selectList" parameterType="map" resultType="com.epmet.dataaggre.dto.govproject.result.ProjectDistributionResultDTO">
SELECT
p.id AS projectId,
p.TITLE AS projectTitle,
( CASE WHEN p.`STATUS` = 'pending' THEN '处理中' WHEN p.`STATUS` = 'closed' THEN '已结案' ELSE '' END ) AS statusDesc,
p.`STATUS` as statusCode,
p.ORIGIN_ID as issueId
FROM
project p
WHERE
p.DEL_FLAG = '0'
and p.CUSTOMER_ID=#{customerId}
and p.ORIGIN_ID in
<foreach item="issueId" collection="list" separator="," open="(" close=")" index="">
#{issueId}
</foreach>
order by CREATED_TIME desc limit 100
</select>
</mapper>

21
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/resigroup/ResiTopicDao.xml

@ -2,5 +2,24 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dataaggre.dao.resigroup.ResiTopicDao">
<select id="selectTopicInfoByIds" parameterType="map" resultType="com.epmet.dataaggre.dto.resigroup.ResiTopicDTO">
SELECT
rt.id ,
rt.ISSUE_ID ,
rt.LONGITUDE,
rt.DIMENSION,
RG.GRID_ID
FROM
resi_topic rt
LEFT JOIN resi_group RG
ON(RT.GROUP_ID=RG.ID)
WHERE rt.DEL_FLAG='0'
AND rt.SHIFT_ISSUE = '1'
and LENGTH(rt.LONGITUDE)>0
AND LENGTH(RT.DIMENSION)>0
and rt.id in
<foreach item="topicId" collection="list" separator="," open="(" close=")" index="">
#{topicId}
</foreach>
</select>
</mapper>
Loading…
Cancel
Save