Commit 18ca8bac by jx-art

邮箱发送 删除无用类 --- 测试发送邮箱接口。。。

parent 8503b981
Pipeline #43159 passed with stages
in 1 minute 41 seconds
//package com.netease.mail.yanxuan.change.integration.email.conig; package com.netease.mail.yanxuan.change.integration.email.conig;
//
//import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.parser.ParserConfig; import com.alibaba.fastjson.parser.ParserConfig;
//import com.netease.mail.yanxuan.change.integration.email.enums.EmailType; import com.netease.mail.yanxuan.change.integration.email.exception.RpcException;
//import com.netease.mail.yanxuan.change.integration.email.exception.RpcException; import com.netease.mail.yanxuan.change.integration.email.exception.RpcStatusException;
//import com.netease.mail.yanxuan.change.integration.email.exception.RpcStatusException; import com.netease.mail.yanxuan.change.integration.email.exception.RpcTimeoutException;
//import com.netease.mail.yanxuan.change.integration.email.exception.RpcTimeoutException; import com.netease.mail.yanxuan.change.integration.email.util.EncodeUtil;
//import com.netease.mail.yanxuan.change.integration.email.util.EncodeUtil; import com.netease.mail.yanxuan.change.integration.email.util.HttpClientUtil;
//import com.netease.mail.yanxuan.change.integration.email.util.HttpClientUtil; import org.slf4j.Logger;
//import org.aspectj.weaver.Checker; import org.slf4j.LoggerFactory;
//import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Value;
//import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component;
//import org.springframework.beans.factory.annotation.Value; import org.springframework.util.StringUtils;
//import org.springframework.stereotype.Component; import java.io.IOException;
//import org.springframework.util.CollectionUtils; import java.util.Map;
//import org.springframework.util.StringUtils;
// /**
//import java.io.IOException; * rpc 请求封装,在 HttpClientUtil 基础上加入了返回值处理和日志
//import java.util.List; *
//import java.util.Map; * @author lwtang
// * @date 2019-02-19
///** */
// * rpc 请求封装,在 HttpClientUtil 基础上加入了返回值处理和日志 @Component
// * public class RpcTemplate {
// * @author lwtang
// * @date 2019-02-19
// */ private Logger logger = LoggerFactory.getLogger(RpcTemplate.class);
//@Component
//public class RpcTemplate { @Value("${act.rpc.get.retry:1}")
// private int rpcGetRetry;
//
// private Logger logger = LoggerFactory.getLogger(RpcTemplate.class); @Value("${act.rpc.post.retry:0}")
// private int rpcPostRetry;
// @Value("${act.rpc.get.retry:1}")
// private int rpcGetRetry; public RpcTemplate() {
// ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
// @Value("${act.rpc.post.retry:0}") }
// private int rpcPostRetry;
// private String convertParam(Object param) {
// public RpcTemplate() { if (param instanceof String) {
// ParserConfig.getGlobalInstance().setAutoTypeSupport(true); return (String) param;
// } }
// String reqParam = "";
// private String convertParam(Object param) { if (param instanceof Map) {
// if (param instanceof String) { reqParam = EncodeUtil.encodeMap((Map) param);
// return (String) param; } else if (param != null) {
// } reqParam = JSON.toJSONString(param);
// String reqParam = ""; }
// if (param instanceof Map) { return reqParam;
// reqParam = EncodeUtil.encodeMap((Map) param); }
// } else if (param != null) {
// reqParam = JSON.toJSONString(param); private <T> T execute(String url, Object params, CallHandler<T> handler,
// } CallTemplate callTemplate, int retryTime, Method method) {
// return reqParam; int tryTimes = 0;
// } RpcException rpcException = null;
// String respBody = null;
// private <T> T execute(String url, Object params, CallHandler<T> handler, int statusCode = 200;
// CallTemplate callTemplate, int retryTime, Method method) { while (tryTimes <= retryTime) {
// int tryTimes = 0; long startTime = System.currentTimeMillis();
// RpcException rpcException = null; try {
// String respBody = null; respBody = callTemplate.executeCall();
// int statusCode = 200; if (StringUtils.isEmpty(respBody)) {
// while (tryTimes <= retryTime) { throw new RpcException("response empty");
// long startTime = System.currentTimeMillis(); }
// try {
// respBody = callTemplate.executeCall(); T t = handler.handle(respBody);
// if (StringUtils.isEmpty(respBody)) { return t;
// throw new RpcException("response empty"); } catch (RpcTimeoutException e) {
// } rpcException = e;
// } catch (RpcStatusException e) {
// T t = handler.handle(respBody); rpcException = e;
// return t; statusCode = e.getCode();
// } catch (RpcTimeoutException e) { } catch (RpcException e) {
// rpcException = e; rpcException = e;
// } catch (RpcStatusException e) { } catch (Exception e) {
// rpcException = e; rpcException = new RpcException(e);
// statusCode = e.getCode(); } finally {
// } catch (RpcException e) { if (logger.isDebugEnabled()) {
// rpcException = e; long costTime = System.currentTimeMillis() - startTime;
// } catch (Exception e) { String reqParam = convertParam(params);
// rpcException = new RpcException(e); logger.debug(
// } finally { "process request, url={}, method={}, params={}, statusCode = {}, response={}, cost={}ms",
// if (logger.isDebugEnabled()) { url, method.name(), reqParam, statusCode, respBody, costTime);
// long costTime = System.currentTimeMillis() - startTime; }
// String reqParam = convertParam(params); }
// logger.debug( tryTimes++;
// "process request, url={}, method={}, params={}, statusCode = {}, response={}, cost={}ms", }
// url, method.name(), reqParam, statusCode, respBody, costTime);
// } logger.error("request error, url={}, params={}, statusCode = {}, respBody={}", url,
// } convertParam(params), statusCode, respBody, rpcException);
// tryTimes++;
// } if (rpcException == null) {
// rpcException = new RpcException("服务异常");
// logger.error("request error, url={}, params={}, statusCode = {}, respBody={}", url, }
// convertParam(params), statusCode, respBody, rpcException); throw rpcException;
// }
// if (rpcException == null) {
// rpcException = new RpcException("服务异常"); /**
// } * Get 请求
// throw rpcException; *
// } * @param url
// * @param params
// /** * @param header
// * Get 请求 * @param timeout
// * * -1 取默认的超时时间
// * @param url * @param handler
// * @param params * @param <T>
// * @param header * @return
// * @param timeout */
// * -1 取默认的超时时间 public <T> T get(String url, Map<String, Object> params, Map<String, String> header,
// * @param handler int timeout, CallHandler<T> handler, Integer retryTimes) {
// * @param <T> CallTemplate template = () -> HttpClientUtil.get(url, params, header, timeout);
// * @return return this.execute(url, params, handler, template, retryTimes, Method.GET);
// */ }
// public <T> T get(String url, Map<String, Object> params, Map<String, String> header,
// int timeout, CallHandler<T> handler, Integer retryTimes) { public <T> T get(String url, Map<String, Object> params, CallHandler<T> handler) {
// CallTemplate template = () -> HttpClientUtil.get(url, params, header, timeout); return get(url, params, null, -1, handler, rpcGetRetry);
// return this.execute(url, params, handler, template, retryTimes, Method.GET); }
// }
// /**
// public <T> T get(String url, Map<String, Object> params, CallHandler<T> handler) { * Post请求(url encoded)
// return get(url, params, null, -1, handler, rpcGetRetry); *
// } * @param url
// * @param params
// /** * @param timeout
// * Post请求(url encoded) * @param handler
// * * @param <T>
// * @param url * @return
// * @param params */
// * @param timeout public <T> T post(String url, Map<String, Object> params, int timeout, CallHandler<T> handler,
// * @param handler Integer retryTime) {
// * @param <T> CallTemplate template = () -> HttpClientUtil.post(url, params, timeout);
// * @return return this.execute(url, params, handler, template, retryTime, Method.POST);
// */ }
// public <T> T post(String url, Map<String, Object> params, int timeout, CallHandler<T> handler,
// Integer retryTime) { /**
// CallTemplate template = () -> HttpClientUtil.post(url, params, timeout); * Post请求(url encoded)
// return this.execute(url, params, handler, template, retryTime, Method.POST); *
// } * @param url
// * @param params
// /** * @param timeout
// * Post请求(url encoded) * @param handler
// * * @param <T>
// * @param url * @return
// * @param params */
// * @param timeout public <T> T post(String url, Map<String, Object> params, int timeout, CallHandler<T> handler) {
// * @param handler CallTemplate template = () -> HttpClientUtil.post(url, params, timeout);
// * @param <T> return this.execute(url, params, handler, template, rpcPostRetry, Method.POST);
// * @return }
// */
// public <T> T post(String url, Map<String, Object> params, int timeout, CallHandler<T> handler) { /**
// CallTemplate template = () -> HttpClientUtil.post(url, params, timeout); * Post Json请求
// return this.execute(url, params, handler, template, rpcPostRetry, Method.POST); *
// } * @param url
// * @param params
// /** * @param timeout
// * Post Json请求 * @param handler
// * * @param <T>
// * @param url * @return
// * @param params */
// * @param timeout public <T> T postJson(String url, String params, int timeout, CallHandler<T> handler,
// * @param handler Integer retryTime) {
// * @param <T> CallTemplate template = () -> HttpClientUtil.postJson(url, params, timeout);
// * @return return this.execute(url, params, handler, template, retryTime, Method.POST);
// */ }
// public <T> T postJson(String url, String params, int timeout, CallHandler<T> handler,
// Integer retryTime) { /**
// CallTemplate template = () -> HttpClientUtil.postJson(url, params, timeout); * Post Json请求
// return this.execute(url, params, handler, template, retryTime, Method.POST); *
// } * @param url
// * @param params
// /** * @param timeout
// * Post Json请求 * @param handler
// * * @param <T>
// * @param url * @return
// * @param params */
// * @param timeout public <T> T postJson(String url, String params, int timeout, CallHandler<T> handler) {
// * @param handler CallTemplate template = () -> HttpClientUtil.postJson(url, params, timeout);
// * @param <T> return this.execute(url, params, handler, template, rpcPostRetry, Method.POST);
// * @return }
// */
// public <T> T postJson(String url, String params, int timeout, CallHandler<T> handler) { enum RpcStatus {
// CallTemplate template = () -> HttpClientUtil.postJson(url, params, timeout);
// return this.execute(url, params, handler, template, rpcPostRetry, Method.POST); /**
// } * 成功
// */
// enum RpcStatus { SUCCESS(1),
//
// /** /**
// * 成功 * 告警(请求成功,但非理想值)
// */ */
// SUCCESS(1), WARNING(2),
//
// /** /**
// * 告警(请求成功,但非理想值) * 异常
// */ */
// WARNING(2), EXCEPTION(3),
//
// /** /**
// * 异常 * 超时
// */ */
// EXCEPTION(3), TIMEOUT(4);
//
// /** private int value;
// * 超时
// */ RpcStatus(int value) {
// TIMEOUT(4); this.value = value;
// }
// private int value;
// public int getValue() {
// RpcStatus(int value) { return value;
// this.value = value; }
// } }
//
// public int getValue() { enum Method {
// return value;
// } /**
// } * Get请求
// */
// enum Method { GET,
//
// /** /**
// * Get请求 * Post表单请求
// */ */
// GET, POST,
// }
// /**
// * Post表单请求 /**
// */ * 模板调用
// POST, */
// } @FunctionalInterface
// public interface CallTemplate {
// /**
// * 模板调用 /**
// */ * 模板调用类
// @FunctionalInterface */
// public interface CallTemplate { String executeCall();
// }
// /**
// * 模板调用类 /**
// */ * 报文解析
// String executeCall(); */
// } @FunctionalInterface
// public interface CallHandler<T> {
// /**
// * 报文解析 /**
// */ * 报文解析
// @FunctionalInterface *
// public interface CallHandler<T> { * @param resp
// * response body
// /** */
// * 报文解析 T handle(String resp) throws IOException;
// *
// * @param resp /**
// * response body * 校验数据体
// */ *
// T handle(String resp) throws IOException; * @param t
// * @return
// /** */
// * 校验数据体 default boolean check(T t) {
// * return true;
// * @param t }
// * @return }
// */
// default boolean check(T t) { }
// return true;
// }
// }
//
//}
//package com.netease.mail.yanxuan.change.integration.email.conig;
//
//
//import java.util.List;
//import java.util.Optional;
//import java.util.stream.Collectors;
//
//
//import com.netease.mail.yanxuan.change.integration.email.email.JumpLinkModel;
//import com.netease.mail.yanxuan.change.integration.email.email.ProblemConfigureModel;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.stereotype.Component;
//
//import com.ctrip.framework.apollo.spring.annotation.EnableAutoUpdateApolloConfig;
//import com.ctrip.framework.apollo.spring.annotation.ValueMapping;
//
//import lombok.Data;
//import org.springframework.util.CollectionUtils;
///**
// * 第三方平台通用apollo配置
// */
//@Data
//@Component
//@EnableAutoUpdateApolloConfig("3rd.base")
//public class ThirdCommonApolloConfig {
//
// private static final String DEFAULT = "default";
//
// /**
// * 异常超级管理员(各个接入的服务业务架构统一角色id)
// */
// @Value("${abnormalAdminRoleId:7956010101}")
// private Long abnormalAdminRoleId;
//
// /**
// * 各工作台待办跳转链接
// */
// @ValueMapping("${jumpLink:[]}")
// private List<JumpLinkModel> jumpLinkMap;
//
// /**
// * 各工作台邮件
// */
// @ValueMapping("${emailFlowUrl:[]}")
// private List<JumpLinkModel> emailFlowUrl;
//
//
// /**
// * 根据产品号获取跳转链接
// *
// * @param productCode
// * @return
// */
// public Optional<JumpLinkModel> getJumpLinkByProductCode(String productCode) {
// List<JumpLinkModel> list = jumpLinkMap.stream().filter(x -> productCode.equals(x.getProductCode()))
// .collect(Collectors.toList());
// if (!CollectionUtils.isEmpty(list)) {
// return Optional.of(list.get(0));
// } else {
// list = jumpLinkMap.stream().filter(x -> DEFAULT.equals(x.getProductCode())).collect(Collectors.toList());
// if (!CollectionUtils.isEmpty(list)) {
// return Optional.of(list.get(0));
// }
// }
// return Optional.of(jumpLinkMap.get(0));
// }
//
// @ValueMapping("${warehouseConfigureModel:{}}")
// private ProblemConfigureModel warehouseConfigureModel;
//
// @ValueMapping("${carrierConfigureModel:{}}")
// private ProblemConfigureModel carrierConfigureModel;
//
//}
package com.netease.mail.yanxuan.change.integration.email.dto;
import lombok.Data;
@Data
public class DeptIdLevelLeaderDTO {
private Integer level;
private Boolean locked;
private Integer orgPosId;
private String orgPosName;
private Integer parentOrgPosId;
private Integer postType;
private Integer rootOrgPosId;
private Integer staffStatus;
private String uid;
private Long userId;
private String userName;
private Integer userType;
}
package com.netease.mail.yanxuan.change.integration.email.dto;
import java.io.Serializable;
public class OrgPosDTO implements Serializable {
private static final long serialVersionUID = 4406420123437327405L;
private int level;
private long orgPosId;
private String orgPosName;
private long parentOrgPosId;
private Integer posStructType;
public int getLevel() {
return level;
}
public void setLevel(int level) {
this.level = level;
}
public long getOrgPosId() {
return orgPosId;
}
public void setOrgPosId(long orgPosId) {
this.orgPosId = orgPosId;
}
public String getOrgPosName() {
return orgPosName;
}
public void setOrgPosName(String orgPosName) {
this.orgPosName = orgPosName;
}
public long getParentOrgPosId() {
return parentOrgPosId;
}
public void setParentOrgPosId(long parentOrgPosId) {
this.parentOrgPosId = parentOrgPosId;
}
public int getPosStructType() {
return posStructType;
}
public void setPosStructType(int posStructType) {
this.posStructType = posStructType;
}
}
package com.netease.mail.yanxuan.change.integration.email.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class RoleBaseDTO {
/**
* 角色唯一id
*/
private Long roleId;
/**
* 角色名称
*/
private String name;
private String remark;
private Long updateTime;
/**
* 是否被锁定
*/
private Boolean locked;
/**
* 创建id
*/
private Long creatorId;
private Integer type;
private Long expireTime;
}
package com.netease.mail.yanxuan.change.integration.email.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ThirdOrgPosDTO {
private String deptId;
private Integer level;
private Integer orgPosId;
private String orgPosName;
private Integer parentOrgPosId;
private Integer posStructType;
private Integer rootOrgPosId;
}
package com.netease.mail.yanxuan.change.integration.email.dto;
import lombok.Data;
@Data
public class UserInfoDTO {
private Long createTime;
private Integer deptIdLevel1;
private Integer deptIdLevel2;
private Integer deptIdLevel3;
private Integer deptIdLevel4;
/**
* 一级部门
*/
private String deptLevel1;
/**
* 二级部门
*/
private String deptLevel2;
/**
* 三级部门
*/
private String deptLevel3;
/**
* 四级部门
*/
private String deptLevel4;
private String extEmail;
private Long firstLoginTime;
private Long lastLoginTime;
private Boolean locked;
private String name;
private Integer orgPosId;
private String srcCode;
/**
* 用户的身份信息,0 正式,1 试用,2 外包,3 派遣,4 实习-签三方,5 实习-未签三方,6 离职
*/
private Integer staffStatus;
private String uid;
private Long userId;
private Integer userType;
}
package com.netease.mail.yanxuan.change.integration.email.dto;
import java.io.Serializable;
/**
* @author hzfujieqi
*/
public class UserOrgMetaDTO implements Serializable {
private static final long serialVersionUID = -2381352783777881742L;
//用户职位ID
private long orgPosId;
//用户id
private long userId;
//用户的上一级职位id
private long parentOrgPosId;
//用户的邮箱
private String uid;
//用户的真名
private String userName;
//用户的职位级别
private int level;
//职位名称
private String orgPosName;
//锁定状态
private Boolean locked;
//职位类型
private int posType;
//业务方附加信息
private String extInfo;
public long getOrgPosId() {
return orgPosId;
}
public void setOrgPosId(long orgPosId) {
this.orgPosId = orgPosId;
}
public long getUserId() {
return userId;
}
public void setUserId(long userId) {
this.userId = userId;
}
public long getParentOrgPosId() {
return parentOrgPosId;
}
public void setParentOrgPosId(long parentOrgPosId) {
this.parentOrgPosId = parentOrgPosId;
}
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public int getLevel() {
return level;
}
public void setLevel(int level) {
this.level = level;
}
public String getOrgPosName() {
return orgPosName;
}
public void setOrgPosName(String orgPosName) {
this.orgPosName = orgPosName;
}
public Boolean getLocked() {
return locked;
}
public void setLocked(Boolean locked) {
this.locked = locked;
}
public int getPosType() {
return posType;
}
public void setPosType(int posType) {
this.posType = posType;
}
public String getExtInfo() {
return extInfo;
}
public void setExtInfo(String extInfo) {
this.extInfo = extInfo;
}
@Override
public String toString() {
return "UserOrgMetaDTO{" + "orgPosId=" + orgPosId + ", userId=" + userId + ", parentOrgPosId=" + parentOrgPosId
+ ", uid='" + uid + '\'' + ", userName='" + userName + '\'' + ", level=" + level + ", orgPosName='"
+ orgPosName + '\'' + ", locked=" + locked + ", posType=" + posType + ", extInfo='" + extInfo + '\'' + '}';
}
}
package com.netease.mail.yanxuan.change.integration.email.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class UserProductRoleStaticsInfosDTO {
private String uid;
private String name;
private Boolean locked;
private Boolean isVirtual;
/**
* 组织身份权限
*/
private List<RoleBaseDTO> groupIdentityProductRoleInfos;
/**
* 特殊权限
*/
private List<RoleBaseDTO> userProductRoleInfoVos;
}
package com.netease.mail.yanxuan.change.integration.email.dto;
import java.util.List;
public class UserUniteOrgMetaDTO extends UserOrgMetaDTO {
private static final long serialVersionUID = -1682465589038072525L;
/**
* 关联类型 type NORMAL(0, "普通职员"), DERECT(1, "指导员"), MANAGER(2, "负责人");
*/
private int type;
/**
* 员工职责
*/
private String duty;
/**
* 员工状态
*/
private int staffStatus;
/**
* 员工工号
*/
private String employeeNum;
/**
* 员工在职信息类型,OAWorkInfoEnum(0-不在OA,1-在严选事业部,2-在外部门)
*/
private int workInfoType;
/**
* 在职状态,EmployeeStateEnum(0-试用,1-正式,5-离职)
*/
private int workState;
/**
* 0-未收藏,1-已收藏
*/
private int focusStatus;
/**
* 所在的其他职位列表,不包含当前职位
*/
private List<OrgPosDTO> multiOrgPoss;
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public String getDuty() {
return duty;
}
public void setDuty(String duty) {
this.duty = duty;
}
public int getStaffStatus() {
return staffStatus;
}
public void setStaffStatus(int staffStatus) {
this.staffStatus = staffStatus;
}
public String getEmployeeNum() {
return employeeNum;
}
public void setEmployeeNum(String employeeNum) {
this.employeeNum = employeeNum;
}
public int getWorkInfoType() {
return workInfoType;
}
public void setWorkInfoType(int workInfoType) {
this.workInfoType = workInfoType;
}
public int getWorkState() {
return workState;
}
public void setWorkState(int workState) {
this.workState = workState;
}
public int getFocusStatus() {
return focusStatus;
}
public void setFocusStatus(int focusStatus) {
this.focusStatus = focusStatus;
}
public List<OrgPosDTO> getMultiOrgPoss() {
return multiOrgPoss;
}
public void setMultiOrgPoss(List<OrgPosDTO> multiOrgPoss) {
this.multiOrgPoss = multiOrgPoss;
}
}
package com.netease.mail.yanxuan.change.integration.email.email;
import lombok.Builder;
import lombok.Data;
@Data
@Builder
public class AbnormalBathEventEhcEmailModel {
private String creator;
private String abnormalName;
private String taskFlowId;
private String deliverUserEmail;
private String deliverUserName;
private String cancelUserEmail;
private String cancelUserName;
private String url;
private String discoverDescription;
private String discoverTime;
}
package com.netease.mail.yanxuan.change.integration.email.email;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class AbnormalEhcEmailModel {
/**
* 异常创建人
*/
private String createUid;
/**
* 异常问题名称
*/
private String abnormalName;
/**
* 工单id
*/
private String flowId;
/**
* 异常问题负责人
*/
private String abnormalPrincipalUid;
/**
* 异常问题负责人
*/
private String abnormalPrincipalUserName;
/**
* 操作人邮箱
*/
private String operatorUid;
/**
* 操作人姓名
*/
private String operatorUserName;
/**
* 审批人邮箱
*/
private String approverUid;
/**
* 审批人姓名
*/
private String approverUserName;
/**
* 工单链接
*/
private String flowUrl;
/**
* 发现描述
*/
private String discoverDescription;
/**
* 发现时间
*/
private String discoverTime;
}
package com.netease.mail.yanxuan.change.integration.email.email;
import lombok.Builder;
import lombok.Data;
@Data
@Builder
public class AbnormalPunishFlowEhcEmailModel {
private String creator;
private String abnormalName;
private String taskFlowId;
private String execUserEmail;
private String execUserName;
private String cancelUserEmail;
private String cancelUserName;
private String deliverUserEmail;
private String deliverUserName;
private String approveUserEmail;
private String approveUserName;
private String url;
private String discoverDescription;
private String discoverTime;
}
package com.netease.mail.yanxuan.change.integration.email.email;
import lombok.Builder;
import lombok.Data;
@Data
@Builder
public class AbnormalTaskFlowEhcEmailModel {
private String creator;
private String abnormalName;
private String taskFlowId;
private String taskTypeName;
private String execUserEmail;
private String execUserName;
private String cancelUserEmail;
private String cancelUserName;
private String execUser;
private String execName;
private String approveUserEmail;
private String approveUserName;
private String url;
private Integer execUserType;
private String discoverDescription;
private String discoverTime;
private String taskDescription;
}
package com.netease.mail.yanxuan.change.integration.email.email;
import com.netease.mail.yanxuan.change.integration.email.dto.UserProductRoleStaticsInfosDTO;
import lombok.Data;
@Data
public class AllUserProductRoleInfosResponseResult {
private Integer code;
private String errorCode;
private String errorMsg;
private SearchResult<UserProductRoleStaticsInfosDTO> data;
}
\ No newline at end of file
//package com.netease.mail.yanxuan.change.integration.email.email;
//
//import org.assertj.core.util.Lists;
//import lombok.SneakyThrows;
//import org.springframework.beans.BeanUtils;
//
//import java.util.ArrayList;
//import java.util.List;
//
//public class BaseConvertor {
// @SneakyThrows
// public static <T> T convert(Object object, final Class<T> clazz) {
// if (object == null) {
// return null;
// }
// T t = clazz.newInstance();
// BeanUtils.copyProperties(object, t);
// return t;
// }
//
// @SneakyThrows
// public static void copyProperties(Object source, Object target) {
// BeanUtils.copyProperties(source, target);
// }
//
// @SneakyThrows
// public static <T> List<T> convert(List<?> objects, final Class<T> clazz) {
// if (org.apache.commons.collections.CollectionUtils.isEmpty(objects)) {
// return new ArrayList<>();
// }
// List<T> retList = Lists.newArrayList();
// objects.forEach(object -> {
// try {
// T t = clazz.newInstance();
// BeanUtils.copyProperties(object, t);
// retList.add(t);
// } catch (Exception ex) {
// try {
// throw ex;
// } catch (InstantiationException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// }
// });
// return retList;
// }
//}
package com.netease.mail.yanxuan.change.integration.email.email;
/**
* 常量定义
*
* @author lwtang
* @date 2018-10-16
*/
public class Constants {
public static final String EHC_PRODUCT_CODE = "ehc";
public static final Integer ONE_HUNDRED = 100;
public static final Integer ONE_THOUSAND = 1000;
public static final String SQE_NAME = "sqe_name:%s";
public static final Integer MAX_QUERY_SIZE = 200;
public static final String REQUEST_HEADER_PRODUCT_CODE = "product-code";
/**
* GlobalId 自增redis值
*/
public static final String ABNORMAL_FLOW_GLOBAL_ID = "abnormalFlowGlobalId";
public static final String TASK_FLOW_GLOBAL_ID = "taskFlowGlobalId";
/**
* GlobalId前缀
*/
public static final String ABNORMAL_FLOW_GLOBAL_NAME = "QC-ABNORMAL-FLOW-";
/**
* 所有异常工单缓存key
*/
public static final String ALL_ABNORMAL_FLOW_KEY = "all_abnormal_flow";
/**
* 新增工单key
*/
public static final String ADD_NEW_FLOW_KEY = "add_new_flow_%s";
/**
*
*/
public static final String TITLE_1 = "您好,系统内临期、延期的异常、任务处理工单汇总如下,请及时处理!";
/**
*
*/
public static final String TITLE_2 = "您好,您的小组成员临期或过期的异常问题处理工单如下,请及时处理!";
/**
*
*/
public static final String TITLE_3 = "您好,系统内临期、延期的异常、任务处理工单汇总如下,无需您处理,请知悉!";
/**
* 舆情配置附加信息 前N个周期的数据均超过阈值
*/
public static final String ABNORMAL_RULE_EXCEEDING_CYCLE_NUM = "前%s个周期的数据均超过阈值";
/**
* 舆情配置附加信息 前N个周期的数据对比呈现持续上升趋势
*/
public static final String ABNORMAL_RULE_RISING_CYCLE_NUM = "前%s个周期的数据对比呈现持续上升趋势";
/**
* 舆情配置附加信息 且
*/
public static final String ABNORMAL_RULE_AND = "且";
/**
* 舆情配置附加信息 或
*/
public static final String ABNORMAL_RULE_OR = "或";
/**
* 通用配置入口id 谛听标签入库
*/
public static final String COMMON_MAX_ID = "maxId";
/**
* 通用配置入口id 普通标签入库
*/
public static final String COMMON_ID = "maxId";
/**
* 正常工单缓存key
*/
public static final String FLOW_CACHE_KEY = "flow_cache_key";
/**
* 过期工单缓存key
*/
public static final String OVERDUE_FLOW_CACHE_KEY = "overdue_flow_cache_key";
/**
* helios cacheName
*/
public static final String EHC_CACHE_LIST = "EHC_CACHE_LIST";
public static final String EHC_CACHE_STRING = "EHC_CACHE_STRING";
/**
* 正常工单缓存key
*/
public static final String EHC_FLOW_CACHE_KEY = "ehc_flow_cache_key";
/**
* 过期工单缓存key
*/
public static final String EHC_OVERDUE_FLOW_CACHE_KEY = "ehc_overdue_flow_cache_key";
public static final String FLOW_ASSIGNED_PROCESSOR_UID = "flow_assigned_processor_uid_";
public static final String FLOW_APPROVE_USER = "flow_approve_user_";
public static final String AUTO_SUBMIT_FLOW = "auto_submit_flow_";
public static final String APPROVER_USER = "approver_user_";
/**
* 舆情异常创建 退货
*/
public static final String RETURN = "退货";
/**
* 舆情异常创建 差评
*/
public static final String BAD_REVIEW = "差评";
/**
* redis 商品前缀 itemId 退/换货 时间类型 二级问题
*/
public static final String RECEIVE_GOODS = "goods_%s_%s_%s_%s";
/**
* redis 供应商前缀 supplierId 退/换货 时间类型 二级问题
*/
public static final String RECEIVE_SUPPLIER = "goods_%s_%s_%s_%s";
/**
* 异常创建信息 商品
*/
public static final String ABNORMAL_CREATE_FIRST_GOOD = "%s-%s在质量%s排行榜发现商品:%s+%s存在质量问题。";
public static final String ABNORMAL_CREATE_SECOND_GOOD = "该商品总计%s次数%s pcs,销量%s pcs,质量%s率为%s%%。";
public static final String ABNORMAL_CREATE_THIRD_GOOD = "其中当前质量问题:%s,有质量%s%s pcs,该问题质量%s率为%s%%。";
public static final String ABNORMAL_CREATE_FOURTH_GOOD = "该商品历史累计%s率为%s%%。";
/**
* 异常创建信息 userName
*/
public static final String ABNORMAL_CREATE_USER_NAME = "品控工作台";
public static final String ABNORMAL_CREATE_USER_EMAIL = "yanxuan@service.netease.com";
public static final String ABNORMAL_CREATE_PRODUCT_CODE = "ecr";
public static final String ABNORMAL_CREATE_PROBLEM_GOODS = "%s%s,质量问题:%s";
public static final String ABNORMAL_CREATE_PROBLEM_SUPPLIER = "%s%s,质量问题:%s";
/**
* 异常创建信息 供应商
*/
public static final String ABNORMAL_CREATE_FIRST_SUPPLIER = "%s-%s在质量%s排行榜发现商品:%s+%s存在质量问题。";
public static final String ABNORMAL_CREATE_SECOND_SUPPLIER = "该供应商总计%s次数%s pcs,销量%s pcs,质量%s率为%s%%。";
public static final String ABNORMAL_CREATE_THIRD_SUPPLIER = "其中当前质量问题:%s,有质量%s%s pcs,该问题质量%s率为%s%%。";
public static final String ABNORMAL_CREATE_FOURTH_SUPPLIER = "该供应商历史累计%s率为%s%%。";
/**
* 异常创建信息 数据更新异常
*/
public static final String ABNORMAL_CREATE_DATA_UPDATE_NOT = "数仓数据%s未更新。";
public static final String ABNORMAL_CREATE_DATA = "品控ECR舆情监控异常创建,";
/**
* 周
*/
public static final String ABNORMAL_CREATE_WEEKS = "周";
/**
* 月
*/
public static final String ABNORMAL_CREATE_MONTH = "月";
/**
* 节点错误
*/
public static final String FLOWX_NODE_ERROR = "%s节点无法保存或提交";
public static final String SUBMIT_OPERATION = "提交工单";
public static final String AUTO_SUBMIT_OPERATION = "系统自动提交工单";
public static final String SYSTEM_AUTO_SUBMIT_OPERATION = "系统自动提交工单";
public static final String SYSTEM_USERNAME = "系统自动提交";
/**
* 批量事件任务工单TopoID
*/
public static final String BATHTOPOID = "ehc_batch_event_task_flow";
/**
* 批量任务人员类型
*/
public static final String EXECUTORTYPE= "严选人员";
/**
* hash map 初始化大小
*/
public static final Integer INIT_HASH_MAP_SIZE = 10;
public static final String SUPPLIER_PREFIX = "YX";
/**
* 解决措施工单过期缓存key
*/
public static final String EHC_TASK_FLOW_OVERDUE_CACHE_KEY = "ehc_task_flow_overdue_cache_key";
/**
* 解决措施工单正常缓存key
*/
public static final String EHC_TASK_FLOW_CACHE_KEY = "ehc_task_flow_cache_key";
/**
* 供应商惩罚工单过期key
*/
public static final String EHC_PUNISH_FLOW_OVERDUE_CACHE_KEY = "ehc_punish_flow_overdue_cache_key";
/**
* 供应商惩罚工单正常key
*/
public static final String EHC_PUNISH_FLOW_CACHE_KEY = "ehc_punish_flow_cache_key";
/**
* 批量事件工单过期key
*/
public static final String EHC_EVENT_FLOW_OVERDUE_CACHE_KEY = "ehc_event_flow_overdue_cache_key";
/**
* 批量事件工单正常key
*/
public static final String EHC_EVENT_FLOW_CACHE_KEY = "ehc_event_flow_cache_key";
/**
* 对比参数默认值
*/
public static final Integer ALL_VALUE = -1;
// 工单业务数据操作key
public static final String FLOW_OPERATION_KEY = "operation";
public static final String YANXUAN_NOS_PREFIX_URL = "yanxuan.nosdn.127.net";
/**
* 默认一页数据量
*/
public static final Integer DEFAULT_PAGE_SIZE = 10;
/**
* 默认页码
*/
public static final Integer DEFAULT_PAGE_NUM = 1;
/**
* 异常问题名称最大长度
*/
public static final int ABNORMAL_NAME_MAX_LENGTH = 500;
/**
* 异常问题描述最大长度
*/
public static final int ABNORMAL_DISCOVER_DESC_MAX_LENGTH = 800;
/**
* 审核依据最大长度
*/
public static final int ABNORMAL_AUDIT_BASIS_MAX_LENGTH = 50;
/**
* 审核内容最大长度
*/
public static final int ABNORMAL_AUDIT_CONTENT_MAX_LENGTH = 500;
/**
* 标签最大长度
*/
public static final int LABEL_MAX_LENGTH = 2000;
public static final String ABNORMAL_PROBLEM_NAME_WAREHOUSE = "%s仓库涉及%s单延迟未发货";
public static final String ABNORMAL_PROBLEM_DESCRIPTION_WAREHOUSE = "%s仓库涉及%s单延迟未发货";
public static final String ABNORMAL_PROBLEM_NAME_CARRIER = "%sB端运输%s件异常商品";
public static final String ABNORMAL_PROBLEM_DESCRIPTION_CARRIER = "%s从%s到%s的B端干线运输环节,产生%s件异常商品,仓库以物流原因操作转次";
public static final String ABNORMAL_CREATE_NAME = "异常中心";
public static final String ABNORMAL_CREATE_EMAIL = "yanxuan@corp.netease.com";
}
package com.netease.mail.yanxuan.change.integration.email.email;
import com.netease.mail.yanxuan.change.integration.email.dto.DeptIdLevelLeaderDTO;
import lombok.Data;
import java.util.List;
@Data
public class DeptIdLevelResponseResult {
private Integer code;
private String errorMsg;
private String errorCode;
private List<DeptIdLevelLeaderDTO> data;
}
...@@ -32,7 +32,7 @@ public class EmailEhcFactor { ...@@ -32,7 +32,7 @@ public class EmailEhcFactor {
/** /**
* 邮件类型 * 邮件类型
* *
* @see EmailTypeEnum * @see
*/ */
private String type; private String type;
} }
//package com.netease.mail.yanxuan.change.integration.email.email; package com.netease.mail.yanxuan.change.integration.email.email;
//
//import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
//import com.netease.mail.yanxuan.change.integration.email.conig.RpcTemplate; import com.netease.mail.yanxuan.change.integration.email.conig.RpcTemplate;
//import com.netease.mail.yanxuan.change.common.bean.ResponseCode; import com.netease.mail.yanxuan.change.common.bean.ResponseCode;
//import com.netease.mail.yanxuan.change.integration.email.exception.RpcException; import com.netease.mail.yanxuan.change.integration.email.exception.RpcException;
//
//import java.io.IOException; import java.io.IOException;
//
//public class EmailTemplateRpcResult<T> implements RpcTemplate.CallHandler<T> { public class EmailTemplateRpcResult<T> implements RpcTemplate.CallHandler<T> {
//
// private static final String CODE = "code"; private static final String CODE = "code";
//
// private static final String RESULT = "data"; private static final String RESULT = "data";
//
// private static final String MESSAGE = "errorMessage"; private static final String MESSAGE = "errorMessage";
//
// private Class<T> tClass; private Class<T> tClass;
//
// public EmailTemplateRpcResult(Class<T> tClass){ public EmailTemplateRpcResult(Class<T> tClass){
// this.tClass = tClass; this.tClass = tClass;
// } }
//
// @Override @Override
// public T handle(String resp) throws IOException { public T handle(String resp) throws IOException {
// JSONObject rpcResult = JSON.parseObject(resp); JSONObject rpcResult = JSON.parseObject(resp);
// EmailTemplateResponResult responResult = new EmailTemplateResponResult(); EmailTemplateResponResult responResult = new EmailTemplateResponResult();
// int code = rpcResult.getIntValue(CODE); int code = rpcResult.getIntValue(CODE);
// if(code == ResponseCode.SUCCESS.getCode()){ if(code == ResponseCode.SUCCESS.getCode()){
// String data = rpcResult.getString(RESULT); String data = rpcResult.getString(RESULT);
// responResult.setData(data); responResult.setData(data);
// return (T) responResult; return (T) responResult;
// } }
// String errorMessage = rpcResult.getString(MESSAGE); String errorMessage = rpcResult.getString(MESSAGE);
// throw new RpcException("email template response error, code : " + code + " , errorMessage : " + errorMessage); throw new RpcException("email template response error, code : " + code + " , errorMessage : " + errorMessage);
// } }
//} }
package com.netease.mail.yanxuan.change.integration.email.email;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class FlowEhcOverTimeEmailModel {
/**
* 主工单
*/
private List<OverTimeUserVo> abnormalEhcEmailModels;
/**
* 子工单
*/
private List<TaskEhcFlowOverTimeEmailModel> taskEhcFlowOverTimeEmailModels;
}
\ No newline at end of file
//package com.netease.mail.yanxuan.change.integration.email.email;
//
//import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.JSONObject;
//import com.netease.mail.yanxuan.change.integration.email.conig.RpcTemplate;
//import com.netease.mail.yanxuan.change.common.bean.ResponseCode;
//import com.netease.mail.yanxuan.change.integration.email.exception.RpcException;
//import com.netease.mail.yanxuan.change.integration.email.dto.UserInfoDTO;
//import java.io.IOException;
//
//public class IusRpcResult<T> implements RpcTemplate.CallHandler<T> {
//
// private static final String CODE = "code";
//
// private static final String RESULT = "data";
//
// private static final String ERROR_CODE = "errorCode";
//
// private static final String ERROR_MESSAGE = "errorMsg";
//
// private Class<T> tClass;
//
// public IusRpcResult(Class<T> tClass) {
// this.tClass = tClass;
// }
//
// @Override
// public T handle(String resp) throws IOException {
// JSONObject rpcResult = JSON.parseObject(resp);
// ResponseResult responResult = new ResponseResult();
// int code = rpcResult.getIntValue(CODE);
// if (code == ResponseCode.SUCCESS.getCode()) {
// String data = rpcResult.getString(RESULT);
// UserInfoDTO jsonObject = JSON.parseObject(data, UserInfoDTO.class);
// responResult.setData(jsonObject);
// return (T) responResult;
// }
// String errorMessage = rpcResult.getString(ERROR_MESSAGE);
// Integer errorCode = rpcResult.getInteger(ERROR_CODE);
// throw new RpcException("ius response error, resp=" + JSON.toJSONString(resp) + " , errorCode : " + errorCode
// + " , errorMessage : " + errorMessage);
// }
//}
package com.netease.mail.yanxuan.change.integration.email.email;
import lombok.Data;
@Data
public class JumpLinkModel {
/**
* 产品号
*/
private String productCode;
/**
* 跳转链接
*/
private String url;
}
//package com.netease.mail.yanxuan.change.integration.email.email;
//
//import lombok.Builder;
//import lombok.Data;
//import java.util.List;
//
//@Data
//@Builder
//public class OverTimeFlowVo {
//
// /**
// * 用户邮箱
// */
// private String uid;
//
// /**
// * 工单列表
// */
// private List<OverTimeUserVo> flowIdList;
//
// @Override
// protected Object clone() throws CloneNotSupportedException {
// OverTimeFlowVo vo = (OverTimeFlowVo) super.clone();
// vo.setUid(vo.getUid());
// vo.setFlowIdList(BaseConvertor.convert(vo.getFlowIdList(), OverTimeUserVo.class));
// return vo;
// }
//}
package com.netease.mail.yanxuan.change.integration.email.email;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class OverTimeUserVo {
/**
* 接收人邮箱
*/
private String uid;
/**
* 接收人名字
*/
private String uname;
/**
* 工单id
*/
private String flowId;
/**
* 异常问题名称
*/
private String abnormalName;
/**
* 1:主工单,2:临时措施,3:供应商惩罚,4:批量事件
*
* @see com.netease.mail.yanxuan.ehc.core.meta.enums.FlowCheckTypeEnum
*/
private Integer type;
/**
* 当前节点
*/
private String currentNode;
/**
* 当前节点名称
*/
private String currentNodeName;
/**
* 异常负责人
*/
private String abnormalPrincipalUserName;
/**
* 执行人
*/
private String processUserName;
/**
* 异常问题类型
*/
private Long problemTypeId;
/**
* 异常问题类型名称
*/
private String problemTypeName;
/**
* 对应的监控规则(异常问题工单)
*
* @see com.netease.mail.yanxuan.ehc.core.meta.enums.MonitoringRulesEnum
*/
private String monitoringRule;
/**
* 剩余/延期天数(如果延期展示负数)
*/
private Long surplusDays;
/**
* 时间状态
*
* @see com.netease.mail.yanxuan.ehc.core.meta.enums.EmailTimeStatusEnum
*/
private Integer timeStatus;
/**
* 时间状态
*/
private String timeStatusName;
/**
* 创建时间
*/
private String createTime;
/**
* 截止时间
*/
private String deadLineTime;
/**
* 工单跳转链接
*/
private String flowUrl;
/**
* 部门名称
*/
private String execUserOrgPosName;
}
package com.netease.mail.yanxuan.change.integration.email.email;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class Pagination implements Serializable {
/**
* 当前⻚,从1开始
*/
private Integer page;
/**
* ⻚⼤⼩
*/
private Integer size;
/**
* 总⻚数
*/
private Integer totalPage;
/**
* 结果总数
*/
private Integer total;
public Pagination(Integer page, Integer size) {
this.page = page;
this.size = size;
this.total = 0;
this.totalPage = 0;
}
}
//package com.netease.mail.yanxuan.change.integration.email.email;
//
//import com.netease.mail.yanxuan.qc.service.client.meta.abnormal.LabelModel;
//import lombok.Data;
//
//import java.util.List;
//
//@Data
//public class ProblemConfigureModel {
// /**
// * 问题类型配置表id
// */
// private Long problemTypeId;
// /**
// * 异常环节
// */
// private List<LabelModel> abnormalLinks;
// /**
// * 问题分类
// */
// private List<LabelModel> flowProblems;
//}
package com.netease.mail.yanxuan.change.integration.email.email;
import com.netease.mail.yanxuan.change.integration.email.dto.UserInfoDTO;
import lombok.Data;
import java.util.List;
@Data
public class QueryUserInfoResponseResult {
private Integer code;
private String errorMsg;
private String errorCode;
private List<UserInfoDTO> data;
}
package com.netease.mail.yanxuan.change.integration.email.email;
import lombok.Data;
import java.util.List;
@Data
public class QueryUserInfoVO {
/**
* uid
*/
private List<String> uids;
/**
* 物流单号
*/
private Boolean locked;
/**
* 创建时间区间
*/
private Long startCreateTime;
}
package com.netease.mail.yanxuan.change.integration.email.email;
import lombok.Data;
@Data
public class ResponseResult {
private Integer code;
private Integer errorCode;
private Object data;
private String errorMsg;
}
package com.netease.mail.yanxuan.change.integration.email.email;
import com.netease.yanxuan.flowx.sdk.meta.dto.base.UserBaseDTO;
import lombok.Data;
import java.util.List;
@Data
public class RoleResponseResult {
private Integer code;
private Integer errorCode;
private List<UserBaseDTO> data;
private String errorMsg;
}
//package com.netease.mail.yanxuan.change.integration.email.email;
//
//import com.alibaba.fastjson.JSON;
//import com.netease.mail.yanxuan.change.integration.email.conig.RpcTemplate;
//
//import java.io.IOException;
//
///**
// * 直接序列化返回对象
// *
// * @author lwtang
// * @date 2019-02-20
// */
//public class RpcObjectHandler<T> implements RpcTemplate.CallHandler<T> {
//
// private Class<T> tClass;
//
//
// public RpcObjectHandler(Class<T> tClass) {this.tClass = tClass;}
//
// @Override
// public T handle(String resp) throws IOException {
// return JSON.parseObject(resp, tClass);
// }
//}
package com.netease.mail.yanxuan.change.integration.email.email;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class SearchResult<T> {
private Pagination pagination;
private List<T> result;
}
\ No newline at end of file
package com.netease.mail.yanxuan.change.integration.email.email;
import lombok.Data;
@Data
public class SupplierEmailResponseResult {
private Integer code;
private String desc;
private Object data;
}
package com.netease.mail.yanxuan.change.integration.email.email;
import lombok.Data;
@Data
public class SupplierEmailSendReq {
/**
* 供应商id
*/
private String supplierId;
/**
* 标题
*/
private String mailSubject;
/**
* 内容
*/
private String mailContent;
private Integer isAllAccountResolved = 1;
}
package com.netease.mail.yanxuan.change.integration.email.email;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class TaskEhcFlowOverTimeEmailModel {
private String taskFlowId;
private String url;
private String abnormalName;
/**
* @see com.netease.mail.yanxuan.ehc.core.meta.enums.AllTaskFlowTypeEnum
*/
private String taskFlowType;
private String uid;
private String uname;
/**
* 待处理人
*/
private String processUserName;
/**
* @see com.netease.mail.yanxuan.ehc.core.meta.enums.EmailTimeStatusEnum
*/
private String timeStatusName;
private String createTime;
private String expectedFinishTime;
private Long delayDay;
/**
* 部门
*/
private String execUserOrgPosName;
}
package com.netease.mail.yanxuan.change.integration.email.email;
import com.netease.mail.yanxuan.change.integration.email.dto.UserUniteOrgMetaDTO;
import lombok.Data;
import java.util.List;
@Data
public class UserUniteOrgMetaResponseResult {
private Integer code;
private String errorMsg;
private String errorCode;
private List<UserUniteOrgMetaDTO> data;
}
package com.netease.mail.yanxuan.change.integration.email.email;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserVO {
/**
* 用户名
*/
private String userName;
/**
* 用户邮箱
*/
private String userEmail;
/**
* 用户部门
*/
private Long orgId;
/**
用户部门名称
*/
private String orgName;
}
package com.netease.mail.yanxuan.change.integration.email.enums;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.util.CollectionUtils;
public enum AllTaskFlowTypeEnum {
/**
* 临时措施
*/
TEMPORARY_MEASURE(1,"临时措施"),
/**
* 纠正措施
*/
CORRECT_MEASURE(2,"纠正措施"),
/**
* 验证结果
*/
VERIFY_RESULT(3,"验证结果"),
/**
* 供应商惩罚措施工单
*/
SUPPLIER_PUNISHMENT(4, "供应商惩罚措施"),
/**
* 批量事件工单
*/
BATCH_EVENT(5, "批量事件");
private Integer type;
private String name;
AllTaskFlowTypeEnum(Integer type, String name) {
this.type = type;
this.name = name;
}
public static String getName(Integer type) {
List<AllTaskFlowTypeEnum> list = Arrays.stream(AllTaskFlowTypeEnum.values())
.filter(e -> e.getType().equals(type)).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(list)) {
return list.get(0).getName();
}
return "";
}
public Integer getType() {
return type;
}
public String getName() {
return name;
}
}
package com.netease.mail.yanxuan.change.integration.email.enums;
import lombok.AllArgsConstructor;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.util.CollectionUtils;
@AllArgsConstructor
public enum ExecUserTypeEnum {
YANXUAN_MEMBER(1,"严选人员"),
SUPPLIER(2,"供应商"),
LOGISTICS_SERVICE_PROVIDER(3,"物流服务商"),
WAREHOUSE_SERVICE_PROVIDER(4,"仓库服务商"),
RETURN_WAREHOUSE_SERVICE_PROVIDER(5,"退货仓服务商");
private int value;
private String name;
public static String getName(Integer type) {
List<ExecUserTypeEnum> collect = Arrays.stream(ExecUserTypeEnum.values())
.filter(e -> e.getValue().equals(type)).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(collect)) {
return collect.get(0).getName();
}
return "";
}
public String getName() {
return name;
}
public Integer getValue() {
return value;
}
}
package com.netease.mail.yanxuan.change.integration.email.enums;
public enum OrgUserTypeEnum {
STAFF(0, "普通员工"),
INSTRUCTOR(1, "指导员"),
PRINCIPAL(2, "负责人");
/**
* 属性值
*/
private int value;
/**
* 属性名称
*/
private String name;
public static OrgUserTypeEnum getByValue(int result) {
for (OrgUserTypeEnum w: OrgUserTypeEnum.values()) {
if (w.getValue() == result) {
return w;
}
}
return null;
}
OrgUserTypeEnum(int value, String name) {
this.value = value;
this.name = name;
}
public int getValue() {
return value;
}
public String getName() {
return name;
}
}
package com.netease.mail.yanxuan.change.integration.email.enums;
import lombok.AllArgsConstructor;
@AllArgsConstructor
public enum ProductCodeEnum {
/**
* 异常管理中心
*/
EHC("ehc", "异常管理中心"),
/**
* 品控
*/
QC("qc", "品控"),
/**
* 承运商平台
*/
CARRIER("carrier", "承运商"),
/**
* 仓配
*/
ARK("ark", "仓配"),
/**
* 商品中心
*/
ITEM_CENTER("ic", "商品中心"),
/**
* 同舟系统
*/
SUPPLIER_API("supplier_api", "同舟"),
/**
* 大黄蜂
*/
HORNET("hornet", "大黄蜂"),
/**
* 供应商协同
*/
YXSUPPLIER("yxsupplier", "供应商协同"),
/**
* 采购
*/
PMC("pmc", "采购"),
/**
* 逆向管理系统
*/
SUPPLIER_RL("yanxuan-supplier-rl", "逆向管理系统"),
/**
* 销退系统
*/
SALES_RETURN("yanxuan-sales-return", "销退系统");
public static ProductCodeEnum getByValue(String code) {
for (ProductCodeEnum c: ProductCodeEnum.values()) {
if (c.getCode().equals(code)) {
return c;
}
}
return null;
}
private String code;
private String name;
public String getCode() {
return code;
}
public String getName() {
return name;
}
}
package com.netease.mail.yanxuan.change.integration.email.enums;
import lombok.AllArgsConstructor;
@AllArgsConstructor
public enum StaffStatusEnum {
/**
* 正式
*/
OFFICIAL(0, "正式"),
/**
* 试用
*/
TRIAL(1, "试用"),
/**
* 外包
*/
WB(2, "外包"),
/**
* 离职
*/
DIMISSION(6, "离职"),
;
public static StaffStatusEnum getByValue(Integer code) {
for (StaffStatusEnum c: StaffStatusEnum.values()) {
if (c.getType().equals(code)) {
return c;
}
}
return null;
}
private Integer type;
private String name;
public Integer getType() {
return type;
}
public String getName() {
return name;
}
}
package com.netease.mail.yanxuan.change.integration.email.exception; package com.netease.mail.yanxuan.change.integration.email.exception;
import com.netease.mail.yanxuan.change.integration.email.exception.RpcException;
/** /**
* http status code 非 200 * http status code 非 200
* *
......
//package com.netease.mail.yanxuan.change.integration.email.service;
//
//import com.netease.mail.yanxuan.change.integration.email.email.*;
//import com.netease.mail.yanxuan.change.integration.email.enums.EmailEhcFlowEnum;
//import java.io.File;
//import java.util.Collection;
//import java.util.List;
//
//public interface IEmailEhcService {
// /**
// * 任务工单发送邮件
// *
// * @param toList
// * 收件人列表
// * @param ccList
// * 抄送人列表
// * @param model
// * 要素
// * @param emailEhcFlowEnum
// */
// void sendTaskEmail(Collection<String> toList, Collection<String> ccList, AbnormalTaskFlowEhcEmailModel model,
// EmailEhcFlowEnum emailEhcFlowEnum);
//
// /**
// * 供应商专属邮件发送
// *
// * @param supplierId
// * @param model
// * @param emailEhcFlowEnum
// */
// void sendSupplierEmail(String supplierId, AbnormalTaskFlowEhcEmailModel model, EmailEhcFlowEnum emailEhcFlowEnum);
//
// /**
// * 供应商惩罚工单发送邮件
// *
// * @param toList
// * @param ccList
// * @param model
// * @param emailEhcFlowEnum
// */
// void sendPunishEmail(Collection<String> toList, Collection<String> ccList, AbnormalPunishFlowEhcEmailModel model,
// EmailEhcFlowEnum emailEhcFlowEnum);
//
// /**
// * 异常问题工单发送邮件
// *
// * @param toList
// * 收件人列表
// * @param ccList
// * 抄送人列表.
// * @param emailEhcFlowEnum
// * 邮件模板
// * @param abnormalEhcEmailModel
// * 数据
// */
// void sendAbnormalEmail(Collection<String> toList, Collection<String> ccList, EmailEhcFlowEnum emailEhcFlowEnum,
// AbnormalEhcEmailModel abnormalEhcEmailModel);
//
// /**
// * 批量事件工单发送邮件
// *
// * @param toList
// * @param ccList
// * @param model
// * @param
// */
// void sendBathEventEmail(Collection<String> toList, Collection<String> ccList, AbnormalBathEventEhcEmailModel model,
// EmailEhcFlowEnum emailEhcFlowEnum);
//
// /**
// * 临期/过期工单发送邮件
// *
// * @param toList
// * @param ccList
// * @param model
// * @param emailEhcFlowEnum
// */
// void sendOverTimeEmail(Collection<String> toList, Collection<String> ccList, FlowEhcOverTimeEmailModel model,
// EmailEhcFlowEnum emailEhcFlowEnum);
//
// /**
// * 邮件发送
// *
// * @param toList
// * 收件人列表
// * @param ccList
// * 抄送人列表
// * @param factor
// * 要素
// * @param fileList
// * 附件
// */
// void sendEmail(Collection<String> toList, Collection<String> ccList, EmailEhcFactor factor, List<File> fileList);
//
// /**
// * 获取邮件发送工单地址
// *
// * @param uid
// * @return
// */
// String getEmailContentUrl(String uid);
//
// /**
// * 获取异常任务工单邮件发送地址
// *
// * @param uid
// * @param execUserType
// * @return
// */
// String getTaskFlowEmailUrl(String uid, Integer execUserType);
//}
//package com.netease.mail.yanxuan.change.integration.email.service; package com.netease.mail.yanxuan.change.integration.email.service;
//
//import com.netease.mail.yanxuan.change.integration.email.email.EmailFactor; import com.netease.mail.yanxuan.change.integration.email.email.EmailFactor;
//import java.io.File; import java.io.File;
//import java.util.Collection; import java.util.Collection;
//import java.util.List; import java.util.List;
//
///** /**
// * 发送邮件 * 发送邮件
// */ */
//public interface IEmailService { public interface IEmailService {
//
// /** /**
// * @param to 收件人 * @param to 收件人
// * @param emailFactor 邮件要素 * @param emailFactor 邮件要素
// */ */
// void sendEmail(String to, EmailFactor emailFactor); void sendEmail(String to, EmailFactor emailFactor);
//
// /** /**
// * @param toList 收件人列表 * @param toList 收件人列表
// * @param factor 要素 * @param factor 要素
// */ */
// void sendEmail(Collection<String> toList, EmailFactor factor); void sendEmail(Collection<String> toList, EmailFactor factor);
//
// /** /**
// * @param toList 收件人 * @param toList 收件人
// * @param ccList 抄送人 * @param ccList 抄送人
// * @param factor 要素 * @param factor 要素
// * @param fileList 附件 * @param fileList 附件
// */ */
// void sendEmail(String toList, String ccList, EmailFactor factor,List<File> fileList); void sendEmail(String toList, String ccList, EmailFactor factor,List<File> fileList);
//
// /** /**
// * *
// * @param toList 收件人列表 * @param toList 收件人列表
// * @param ccList 抄送人列表 * @param ccList 抄送人列表
// * @param factor 要素 * @param factor 要素
// */ */
// void sendEmail(Collection<String> toList, Collection<String> ccList, EmailFactor factor); void sendEmail(Collection<String> toList, Collection<String> ccList, EmailFactor factor);
//
// /** /**
// * @param toList 收件人列表 * @param toList 收件人列表
// * @param ccList 抄送人列表 * @param ccList 抄送人列表
// * @param factor 要素 * @param factor 要素
// * @param fileList 附件 * @param fileList 附件
// */ */
// void sendEmail(Collection<String> toList, Collection<String> ccList, EmailFactor factor, List<File> fileList); void sendEmail(Collection<String> toList, Collection<String> ccList, EmailFactor factor, List<File> fileList);
//
//
//} }
//package com.netease.mail.yanxuan.change.integration.email.service;
//
//import java.util.List;
//
//import com.netease.mail.yanxuan.change.integration.email.dto.DeptIdLevelLeaderDTO;
//import com.netease.mail.yanxuan.change.integration.email.dto.ThirdOrgPosDTO;
//import com.netease.mail.yanxuan.change.integration.email.dto.UserInfoDTO;
//import com.netease.mail.yanxuan.change.integration.email.dto.UserUniteOrgMetaDTO;
//import com.netease.mail.yanxuan.change.integration.email.email.SearchResult;
//import com.netease.mail.yanxuan.change.integration.email.dto.UserProductRoleStaticsInfosDTO;
//import com.netease.mail.yanxuan.change.integration.email.email.UserVO;
//import com.netease.yanxuan.flowx.sdk.meta.dto.base.UserBaseDTO;
//
///**
// * @author jiyuwang 商品是否有模块化受控标准
// */
//public interface IIusService {
//
// /**
// * 获取用户的部门信息和在职情况
// *
// * @param uid
// * @return
// */
// UserInfoDTO getUserInfo(String uid);
//
// /**
// * 查询用户集合,不传时查全部
// * http://yx.mail.netease.com/bee#/interface/list;serviceCode=yanxuan-ius;branchName=master;selectedInterface=1010712
// * @param productCode
// * @param uid
// * @return
// */
// List<UserInfoDTO> queryUserInfo(String productCode, String uid);
//
// /**
// * 根据uid获取部门
// *
// * @param uid
// * @return
// */
// String getOrgByUid(String uid);
//
// /**
// * 判断用户是否离职
// *
// * @param uid
// * @return true: 离职;false: 未离职
// */
// boolean checkUserIsLeave(String uid);
//
// /**
// * 获取部门负责人
// *
// * @param uid
// * @param orgPosId
// * @return
// */
// List<DeptIdLevelLeaderDTO> getDeptIdLevelLeader(String uid, Integer orgPosId);
//
// /**
// * 根据用户获取三级部门负责人
// *
// * @param uid
// * @return
// */
// List<DeptIdLevelLeaderDTO> getThreeLevelDeptLeader(String uid);
//
// /**
// * 获取四级部门负责人
// * @param uid
// * @return
// */
// List<DeptIdLevelLeaderDTO> getForthLevelDeptLeader(String uid);
//
// /**
// * 模糊查询用户信息
// */
// List<UserUniteOrgMetaDTO> fuzzyQueryUserInformation(int queryType, String keyword);
//
// /**
// * 模糊查询用户信息(权限中心)
// */
// List<UserUniteOrgMetaDTO> fuzzyQueryUserInfo(Long orgPosId, int level, int type, int queryType, String keyword);
//
// /**
// * 获得该系统下的该用户组织身份权限或者特殊权限
// *
// * @param staff
// * @param roleId
// * @param orgPosId
// * @param stationId
// * @param locked
// * @param keyword
// * @param curPage
// * @param pageSize
// * @return
// */
// SearchResult<UserProductRoleStaticsInfosDTO> getAllUserProductRoleInfos(Integer staff, Long roleId, Long orgPosId,
// Integer stationId, Integer locked, String keyword, Integer curPage, Integer pageSize);
//
// /**
// * 根据产品号和 roleId 获取用户列表
// *
// * @param productCode
// * @param roleId
// * @return
// */
// List<UserBaseDTO> listUserByRoleId(String productCode, Long roleId);
//
// /**
// * 根据uid获取三级部门人员相关信息
// * @param uid
// * @return
// */
// UserVO lv3UserInfo(String uid);
//
// /**
// * 获取用户所在系统编码(弃用)
// *
// * @param uid
// * @return
// */
// @Deprecated
// List<String> listProductHasUid(String uid);
//
// /**
// * 三级部门查询列表
// * @param name
// * @return
// */
// List<ThirdOrgPosDTO> getThirdOrgPosName(String name);
//
//
//
//
//}
//package com.netease.mail.yanxuan.change.integration.email.service;
//
//
//import com.netease.mail.yanxuan.change.integration.email.email.SupplierEmailResponseResult;
//import com.netease.mail.yanxuan.change.integration.email.email.SupplierEmailSendReq;
//
//public interface ISupplierEmailService {
//
// SupplierEmailResponseResult sendSupplierEmail(SupplierEmailSendReq req);
//}
\ No newline at end of file
//package com.netease.mail.yanxuan.change.integration.email.service; package com.netease.mail.yanxuan.change.integration.email.service;
//
//import java.io.File; import java.io.File;
//import java.util.Collection; import java.util.Collection;
//import java.util.List; import java.util.List;
//
//public interface IUasEhcClient { public interface IUasEhcClient {
//
// /** /**
// * 邮件发送 * 邮件发送
// * *
// * @param subject * @param subject
// * @param content * @param content
// * @param toList * @param toList
// * @param ccList * @param ccList
// * @param fileList * @param fileList
// */ */
// void sendEmail(String subject, String content, Collection<String> toList, Collection<String> ccList, void sendEmail(String subject, String content, Collection<String> toList, Collection<String> ccList,
// List<File> fileList); List<File> fileList);
//} }
\ No newline at end of file \ No newline at end of file
package com.netease.mail.yanxuan.change.integration.email.service;
import java.io.File;
import java.util.Collection;
import java.util.List;
/**
* @author WangJiaXiang
* @date 2022/11/28/028$
*/
public interface UasClientService {
void sendEmail(String subject, String content, Collection<String> toList, Collection<String> ccList, List<File> fileList);
}
/*
package com.netease.mail.yanxuan.change.integration.email.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.netease.mail.yanxuan.change.integration.email.conig.ThirdCommonApolloConfig;
import com.netease.mail.yanxuan.change.integration.email.dto.UserInfoDTO;
import com.netease.mail.yanxuan.change.integration.email.email.*;
import com.netease.mail.yanxuan.change.integration.email.enums.*;
import com.netease.mail.yanxuan.change.integration.email.service.IEmailEhcService;
import com.netease.mail.yanxuan.change.integration.email.service.IIusService;
import com.netease.mail.yanxuan.change.integration.email.service.IUasEhcClient;
import com.netease.mail.yanxuan.change.integration.email.service.ISupplierEmailService;
import org.assertj.core.util.Lists;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class EmailEhcServiceImpl implements IEmailEhcService {
private Logger logger = LoggerFactory.getLogger(EmailEhcServiceImpl.class);
@Autowired
private IUasEhcClient uasEhcClient;
@Autowired
private EmailTemplateServiceImpl emailTemplateService;
@Autowired
private ISupplierEmailService supplierEmailService;
@Autowired
private ThirdCommonApolloConfig thirdCommonApolloConfig;
@Autowired
private IIusService iusService;
*/
/**
* 主工单微应用地址
*//*
private static final String ABNORMAL_FLOW_EMAIL_URL = "/error-center-node#/problem/detail/%s";
*/
/**
* 临时措施微应用地址
*//*
private static final String TASK_FLOW_EMAIL_URL = "/error-center-node#/sonwork/measures/%s?newFlow=true";
private static final String TASK_FLOW_EMAIL_URL_SUPPLIER = "&pageFrom=todo";
*/
/**
* 惩罚供应商微应用地址
*//*
private static final String PUNISH_FLOW_EMAIL_URL = "/error-center-node#/sonwork/punish/%s?newFlow=true";
*/
/**
* 批量事件工单微应用地址
*//*
private static final String EVENT_FLOW_EMAIL_URL = "/error-center-node#/sonwork/batch/%s";
@Override
@Async
public void sendTaskEmail(Collection<String> toList, Collection<String> ccList, AbnormalTaskFlowEhcEmailModel model,
EmailEhcFlowEnum emailEhcFlowEnum) {
String subject = emailEhcFlowEnum.getSubject();
subject = String.format(subject, model.getTaskTypeName(), model.getAbnormalName(), model.getTaskFlowId());
//邮件url
for (String str: toList) {
try {
List<String> uidLists = new ArrayList<>();
model.setUrl(getTaskFlowEmailUrl(str, model.getExecUserType()));
model.setUrl(model.getUrl() + String.format(TASK_FLOW_EMAIL_URL, model.getTaskFlowId()));
logger.debug("[sendTaskEmail] url:{}", JSON.toJSONString(model.getUrl()));
uidLists.add(str);
EmailEhcFactor factor = EmailEhcFactor.builder()
.data(JSONObject.parseObject(JSON.toJSONString(model), Map.class))
.emailEhcFlowEnum(emailEhcFlowEnum).subject(subject).type(EmailTypeEnum.TEXT.getType()).build();
logger.debug("[sendTaskEmail] flowId:{}, factor:{}", model.getTaskFlowId(), JSON.toJSONString(factor));
this.sendEmail(uidLists, ccList, factor, null);
} catch (Exception e) {
logger.error("[sendTaskEmail] flowId:{}, str={}, e={}", model.getTaskFlowId(), str, e);
}
}
}
@Override
public void sendSupplierEmail(String supplierId, AbnormalTaskFlowEhcEmailModel model,
EmailEhcFlowEnum emailEhcFlowEnum) {
SupplierEmailSendReq req = new SupplierEmailSendReq();
req.setSupplierId(supplierId);
req.setMailSubject(String.format(emailEhcFlowEnum.getSubject(), model.getTaskTypeName(),
model.getAbnormalName(), model.getTaskFlowId()));
model.setUrl(getTaskFlowEmailUrl(null, model.getExecUserType()));
model.setUrl(
model.getUrl() + String.format(TASK_FLOW_EMAIL_URL, model.getTaskFlowId()) + TASK_FLOW_EMAIL_URL_SUPPLIER);
EmailEhcFactor factor = EmailEhcFactor.builder()
.data(JSONObject.parseObject(JSON.toJSONString(model), Map.class)).emailEhcFlowEnum(emailEhcFlowEnum)
.subject(req.getMailSubject()).type(EmailTypeEnum.TEXT.getType()).build();
req.setMailContent(content(factor));
logger.debug("[sendSupplierEmail] 发送供应商邮件内容 flowId:{}, req:{}", model.getTaskFlowId(), JSON.toJSONString(req));
supplierEmailService.sendSupplierEmail(req);
}
@Override
@Async
public void sendPunishEmail(Collection<String> toList, Collection<String> ccList,
AbnormalPunishFlowEhcEmailModel model, EmailEhcFlowEnum emailEhcFlowEnum) {
String subject = emailEhcFlowEnum.getSubject();
subject = String.format(subject, model.getAbnormalName(), model.getTaskFlowId());
//邮件url
for (String str: toList) {
try {
List<String> uidLists = new ArrayList<>();
model.setUrl(getEmailContentUrl(str));
model.setUrl(model.getUrl() + String.format(PUNISH_FLOW_EMAIL_URL, model.getTaskFlowId()));
uidLists.add(str);
EmailEhcFactor factor = EmailEhcFactor.builder()
.data(JSONObject.parseObject(JSON.toJSONString(model), Map.class))
.emailEhcFlowEnum(emailEhcFlowEnum).subject(subject).type(EmailTypeEnum.TEXT.getType()).build();
logger.debug("[sendPunishEmail]flowId:{}, factor:{}", model.getTaskFlowId(), JSON.toJSONString(factor));
this.sendEmail(uidLists, ccList, factor, null);
} catch (Exception e) {
logger.error("[sendPunishEmail] str={}, e={}", str, e);
}
}
}
@Override
@Async
public void sendBathEventEmail(Collection<String> toList, Collection<String> ccList,
AbnormalBathEventEhcEmailModel model, EmailEhcFlowEnum emailEhcFlowEnum) {
String subject = emailEhcFlowEnum.getSubject();
logger.debug("[sendBathEventEmail] before subject:{}", subject);
subject = String.format(subject, model.getAbnormalName(), model.getTaskFlowId());
logger.debug("[sendBathEventEmail] after subject:{}", subject);
//邮件url
for (String str: toList) {
List<String> uidLists = new ArrayList<>();
model.setUrl(getEmailContentUrl(str));
model.setUrl(model.getUrl() + String.format(EVENT_FLOW_EMAIL_URL, model.getTaskFlowId()));
logger.debug("[sendBathEventEmail] url:{}", JSON.toJSONString(model.getUrl()));
uidLists.add(str);
EmailEhcFactor factor = EmailEhcFactor.builder()
.data(JSONObject.parseObject(JSON.toJSONString(model), Map.class)).emailEhcFlowEnum(emailEhcFlowEnum)
.subject(subject).type(EmailTypeEnum.TEXT.getType()).build();
logger.debug("[sendBathEventEmail] flowId:{}, factor:{}", model.getTaskFlowId(), JSON.toJSONString(factor));
this.sendEmail(uidLists, ccList, factor, null);
}
}
@Override
public void sendOverTimeEmail(Collection<String> toList, Collection<String> ccList, FlowEhcOverTimeEmailModel model,
EmailEhcFlowEnum emailEhcFlowEnum) {
logger.info("[sendOverTimeEmail] toList={}, ccList={}", JSON.toJSONString(toList), JSON.toJSONString(ccList));
String subject = emailEhcFlowEnum.getSubject();
//邮件url
for (String str: toList) {
List<String> uidLists = new ArrayList<>();
if (!CollectionUtils.isEmpty(model.getAbnormalEhcEmailModels())) {
model.getAbnormalEhcEmailModels().stream().forEach(f -> {
f.setFlowUrl(getEmailContentUrl(str));
f.setFlowUrl(f.getFlowUrl() + String.format(ABNORMAL_FLOW_EMAIL_URL, f.getFlowId()));
logger.debug("[sendOverTimeEmail] url:{}", JSON.toJSONString(f.getFlowUrl()));
});
}
if (!CollectionUtils.isEmpty(model.getTaskEhcFlowOverTimeEmailModels())) {
model.getTaskEhcFlowOverTimeEmailModels().stream().forEach(f -> {
f.setUrl(getEmailContentUrl(str));
if (f.getTaskFlowType().equals(AllTaskFlowTypeEnum.SUPPLIER_PUNISHMENT.getName())) {
f.setUrl(f.getUrl() + String.format(PUNISH_FLOW_EMAIL_URL, f.getTaskFlowId()));
} else if (f.getTaskFlowType().equals(AllTaskFlowTypeEnum.BATCH_EVENT.getName())) {
f.setUrl(f.getUrl() + String.format(EVENT_FLOW_EMAIL_URL, f.getTaskFlowId()));
} else {
f.setUrl(f.getUrl() + String.format(TASK_FLOW_EMAIL_URL, f.getTaskFlowId()));
}
logger.debug("[sendOverTimeEmail] url:{}", JSON.toJSONString(f.getUrl()));
});
}
uidLists.add(str);
EmailEhcFactor factor = EmailEhcFactor.builder()
.data(JSONObject.parseObject(JSON.toJSONString(model), Map.class)).emailEhcFlowEnum(emailEhcFlowEnum)
.subject(subject).type(EmailTypeEnum.TEXT.getType()).build();
this.sendEmail(uidLists, ccList, factor, null);
}
}
@Override
@Async
public void sendAbnormalEmail(Collection<String> toList, Collection<String> ccList,
EmailEhcFlowEnum emailEhcFlowEnum, AbnormalEhcEmailModel abnormalEhcEmailModel) {
String subject = String.format(emailEhcFlowEnum.getSubject(), abnormalEhcEmailModel.getAbnormalName(),
abnormalEhcEmailModel.getFlowId());
// 收件人
for (String uid: toList) {
String prefixUrl = getEmailContentUrl(uid);
String flowUrl = prefixUrl + String.format(ABNORMAL_FLOW_EMAIL_URL, abnormalEhcEmailModel.getFlowId());
abnormalEhcEmailModel.setFlowUrl(flowUrl);
EmailEhcFactor factor = EmailEhcFactor.builder()
.data(JSONObject.parseObject(JSON.toJSONString(abnormalEhcEmailModel), Map.class))
.emailEhcFlowEnum(emailEhcFlowEnum).subject(subject).type(EmailTypeEnum.TEXT.getType()).build();
factor.setSubject(subject);
this.sendEmail(Lists.newArrayList(uid), ccList, factor, null);
logger.debug("[sendAbnormalEmail] flowId={}, toList={}, ccList={}, factor={}",
abnormalEhcEmailModel.getFlowId(), uid, null, JSON.toJSONString(factor));
ccList = null;
}
}
@Override
@Async
public void sendEmail(Collection<String> toList, Collection<String> ccList, EmailEhcFactor factor,
List<File> fileList) {
logger.info("[sendEmail] toList:{}, ccList:{}, factor:{}", JSON.toJSONString(toList),
JSON.toJSONString(ccList), JSON.toJSONString(factor));
if (factor != null) {
String content = content(factor);
String subject = factor.getSubject();
if (!CollectionUtils.isEmpty(toList)) {
toList = toList.stream().filter(StringUtils::hasText).collect(Collectors.toList());
}
if (!CollectionUtils.isEmpty(ccList)) {
ccList = ccList.stream().filter(StringUtils::hasText).collect(Collectors.toList());
}
//发送邮件
uasEhcClient.sendEmail(subject, content, toList, ccList, fileList);
}
}
*/
/**
* 根据邮件模版获取邮件内容
*
* @param emailFactor
* @return
*//*
private String content(EmailEhcFactor emailFactor) {
EmailEhcFlowEnum emailEhcFlowEnum = emailFactor.getEmailEhcFlowEnum();
return emailTemplateService.template(emailEhcFlowEnum.getCode(), emailFactor.getData(), emailFactor.getType());
}
*/
/**
* 根据apollo配置获取邮件通知主应用url(如果没有,则默认返回第一个主应用url)
*
* @param uid
* @return
*//*
@Override
public String getEmailContentUrl(final String uid) {
List<JumpLinkModel> emailUrlList = thirdCommonApolloConfig.getEmailFlowUrl();
for (JumpLinkModel vo: emailUrlList) {
List<UserInfoDTO> userList = iusService.queryUserInfo(vo.getProductCode(), uid);
if (!CollectionUtils.isEmpty(userList)
&& !StaffStatusEnum.DIMISSION.getType().equals(userList.get(0).getStaffStatus())) {
// 解锁且是非离职状态
logger.info("[getEmailContentUrl] uid={}, vo={}", uid, JSON.toJSONString(vo));
return vo.getUrl();
}
}
return thirdCommonApolloConfig.getEmailFlowUrl().get(0).getUrl();
}
@Override
public String getTaskFlowEmailUrl(String uid, Integer execUserType) {
logger.info("[getTaskFlowEmailUrl] uid:{}, execUserType:{}", uid, execUserType);
List<String> urlList = new ArrayList<>();
if (ExecUserTypeEnum.YANXUAN_MEMBER.getValue().equals(execUserType)) {
// 严选人员
return getEmailContentUrl(uid);
} else if (ExecUserTypeEnum.LOGISTICS_SERVICE_PROVIDER.getValue().equals(execUserType)) {
// 物流服务商
urlList.addAll(thirdCommonApolloConfig.getEmailFlowUrl().stream()
.filter(f -> f.getProductCode().equals(ProductCodeEnum.CARRIER.getCode())).map(JumpLinkModel::getUrl)
.collect(Collectors.toList()));
} else if (ExecUserTypeEnum.WAREHOUSE_SERVICE_PROVIDER.getValue().equals(execUserType)) {
// 系统仓
urlList.addAll(thirdCommonApolloConfig.getEmailFlowUrl().stream()
.filter(f -> f.getProductCode().equals(ProductCodeEnum.HORNET.getCode())).map(JumpLinkModel::getUrl)
.collect(Collectors.toList()));
} else if (ExecUserTypeEnum.SUPPLIER.getValue().equals(execUserType)) {
// 供应商
urlList.addAll(thirdCommonApolloConfig.getEmailFlowUrl().stream()
.filter(f -> f.getProductCode().equals(ProductCodeEnum.SUPPLIER_API.getCode()))
.map(JumpLinkModel::getUrl).collect(Collectors.toList()));
}
logger.debug("[getTaskFlowEmailUrl] urlList={}", JSON.toJSONString(urlList));
if (CollectionUtils.isEmpty(urlList)) {
// 如果没有,则默认返回第一个主应用url
urlList.add(thirdCommonApolloConfig.getEmailFlowUrl().get(0).getUrl());
}
return urlList.get(0);
}
}
*/
/*
package com.netease.mail.yanxuan.change.integration.email.service.impl; package com.netease.mail.yanxuan.change.integration.email.service.impl;
import com.netease.mail.yanxuan.change.integration.email.email.EmailFactor; import com.netease.mail.yanxuan.change.integration.email.email.EmailFactor;
import com.netease.mail.yanxuan.change.integration.email.enums.EmailTemplateEnum;
import com.netease.mail.yanxuan.change.integration.email.service.IEmailService; import com.netease.mail.yanxuan.change.integration.email.service.IEmailService;
import com.netease.mail.yanxuan.change.integration.email.enums.EmailParamEnum; import com.netease.mail.yanxuan.change.integration.email.enums.EmailParamEnum;
import com.netease.mail.yanxuan.change.integration.email.enums.EmailTemplateEnum; import com.netease.mail.yanxuan.change.integration.email.service.UasClientService;
import com.netease.mail.yanxuan.change.common.util.RequestUtil;
import com.netease.mail.yanxuan.qc.service.client.remote.UasClient;
import com.netease.mail.yanxuan.qc.service.client.utils.http.HttpClientTemplate;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import javax.annotation.PostConstruct;
import java.io.File; import java.io.File;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
...@@ -26,20 +20,11 @@ import java.util.stream.Collectors; ...@@ -26,20 +20,11 @@ import java.util.stream.Collectors;
public class EmailServiceImpl implements IEmailService { public class EmailServiceImpl implements IEmailService {
@Autowired @Autowired
private UasClient uasClient; private UasClientService uasClient;
@Autowired @Autowired
private EmailTemplateServiceImpl emailTemplateService; private EmailTemplateServiceImpl emailTemplateService;
@Autowired
private HttpClientTemplate httpClientTemplate;
@PostConstruct
private void init() {
httpClientTemplate.init();
httpClientTemplate.setDefaultCharset(RequestUtil.CHAR_SET);
}
@Override @Override
@Async("asyncEmail") @Async("asyncEmail")
public void sendEmail(String to, EmailFactor emailFactor) { public void sendEmail(String to, EmailFactor emailFactor) {
...@@ -79,7 +64,7 @@ public class EmailServiceImpl implements IEmailService { ...@@ -79,7 +64,7 @@ public class EmailServiceImpl implements IEmailService {
if (!CollectionUtils.isEmpty(ccList)) { if (!CollectionUtils.isEmpty(ccList)) {
ccList = ccList.stream().filter(e -> e != null).collect(Collectors.toList()); ccList = ccList.stream().filter(e -> e != null).collect(Collectors.toList());
} }
this.uasClient.sendEmail(factor.getSubject(), content, toList, ccList, null); uasClient.sendEmail(factor.getSubject(), content, toList, ccList, null);
} }
} }
...@@ -104,17 +89,17 @@ public class EmailServiceImpl implements IEmailService { ...@@ -104,17 +89,17 @@ public class EmailServiceImpl implements IEmailService {
if (!CollectionUtils.isEmpty(ccList)) { if (!CollectionUtils.isEmpty(ccList)) {
ccList = ccList.stream().filter(e -> e != null).collect(Collectors.toList()); ccList = ccList.stream().filter(e -> e != null).collect(Collectors.toList());
} }
this.uasClient.sendEmail(subject, content, toList, ccList, fileList); uasClient.sendEmail(subject, content, toList, ccList, fileList);
} }
} }
*/
/** /**
* 根据邮件模版获取邮件内容 * 根据邮件模版获取邮件内容
* *
* @param emailFactor * @param emailFactor
* @return * @return
*//* */
public String content(EmailFactor emailFactor) { public String content(EmailFactor emailFactor) {
EmailTemplateEnum emailTemplateEnum = emailFactor.getEmailTemplateEnum(); EmailTemplateEnum emailTemplateEnum = emailFactor.getEmailTemplateEnum();
...@@ -123,4 +108,4 @@ public class EmailServiceImpl implements IEmailService { ...@@ -123,4 +108,4 @@ public class EmailServiceImpl implements IEmailService {
} }
} }
*/
/*
package com.netease.mail.yanxuan.change.integration.email.service.impl; package com.netease.mail.yanxuan.change.integration.email.service.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
...@@ -34,4 +33,3 @@ public class EmailTemplateServiceImpl { ...@@ -34,4 +33,3 @@ public class EmailTemplateServiceImpl {
return emailTemplateResponResult.getData(); return emailTemplateResponResult.getData();
} }
} }
*/
/*
package com.netease.mail.yanxuan.change.integration.email.service.impl; package com.netease.mail.yanxuan.change.integration.email.service.impl;
import java.io.File; import java.io.File;
...@@ -6,42 +5,34 @@ import java.util.Collection; ...@@ -6,42 +5,34 @@ import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.netease.mail.yanxuan.change.common.bean.ResponseCode; import com.netease.mail.yanxuan.change.common.bean.ResponseCode;
import com.netease.mail.yanxuan.change.integration.email.service.IUasEhcClient; import com.netease.mail.yanxuan.change.integration.email.service.IUasEhcClient;
import com.netease.mail.yanxuan.change.integration.flow.email.EmailRpcService;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.netease.mail.yanxuan.qc.service.client.utils.http.HttpClientExecutor;
import com.netease.yanxuan.sc.guard.lib.meta.enums.guard.Type;
@Service @Service
public class IUasClientEhcImpl implements IUasEhcClient { public class IUasClientEhcImpl implements IUasEhcClient {
private static final String PUSH_EMAIL = "/push/email/yanxuan-sc-ehc"; //请求地址 http://127.0.0.1:8550/proxy/online.logistics-uas.service.mailsaas/push/email/yanxuan-sc-ehc
public static final String CODE = "code"; public static final String CODE = "code";
private Logger logger = LoggerFactory.getLogger(EmailEhcServiceImpl.class); private Logger logger = LoggerFactory.getLogger(IUasClientEhcImpl.class);
@Autowired @Autowired
private HttpClientExecutor httpClientExecutor; private EmailRpcService rpcService;
@Value("${rpc.url.uas.basic}")
private String uasUrl;
@Override @Override
public void sendEmail(String subject, String content, Collection<String> toList, Collection<String> ccList, public void sendEmail(String subject, String content, Collection<String> toList, Collection<String> ccList,
List<File> fileList) { List<File> fileList) {
if (!CollectionUtils.isEmpty(toList)) { if (!CollectionUtils.isEmpty(toList)) {
String url = uasUrl + PUSH_EMAIL;
Map<String, String> params = new HashMap(); Map<String, String> params = new HashMap();
params.put("subject", subject); params.put("subject", subject);
params.put("content", content); params.put("content", content);
...@@ -54,7 +45,7 @@ public class IUasClientEhcImpl implements IUasEhcClient { ...@@ -54,7 +45,7 @@ public class IUasClientEhcImpl implements IUasEhcClient {
} }
String res = null; String res = null;
try { try {
res = this.httpClientExecutor.doPost(url, params); res = this.rpcService.sendEmailInfo(params);
} catch (Exception e) { } catch (Exception e) {
logger.error("[sendEmail] params={}, e={}", JSON.toJSONString(params), e); logger.error("[sendEmail] params={}, e={}", JSON.toJSONString(params), e);
} }
...@@ -62,11 +53,11 @@ public class IUasClientEhcImpl implements IUasEhcClient { ...@@ -62,11 +53,11 @@ public class IUasClientEhcImpl implements IUasEhcClient {
JSON.toJSONString(ccList), JSON.toJSONString(params), JSON.toJSONString(res)); JSON.toJSONString(ccList), JSON.toJSONString(params), JSON.toJSONString(res));
JSONObject jsonObject = JSON.parseObject(res); JSONObject jsonObject = JSON.parseObject(res);
if (jsonObject.getInteger(CODE) != ResponseCode.SUCCESS.getCode()) { if (jsonObject.getInteger(CODE) != ResponseCode.SUCCESS.getCode()) {
this.logger.error(Type.RPC.toString(), "SendEmail", null, this.logger.error("SendEmail", null,
"send email failed, subject={},toList={},ccList={}", "send email failed, subject={},toList={},ccList={}",
new Object[] { subject, JSON.toJSONString(toList), JSON.toJSONString(ccList) }); new Object[] { subject, JSON.toJSONString(toList), JSON.toJSONString(ccList) });
} }
} }
} }
} }
*/
/*
package com.netease.mail.yanxuan.change.integration.email.service.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.netease.mail.yanxuan.change.integration.email.conig.RpcTemplate;
import com.netease.mail.yanxuan.change.integration.email.dto.*;
import com.netease.mail.yanxuan.change.integration.email.email.*;
import com.netease.mail.yanxuan.change.integration.email.service.IIusService;
import com.netease.mail.yanxuan.change.common.bean.AjaxResult;
import com.netease.mail.yanxuan.change.integration.email.enums.OrgUserTypeEnum;
import com.netease.mail.yanxuan.change.integration.email.enums.StaffStatusEnum;
import com.netease.yanxuan.flowx.sdk.meta.dto.base.UserBaseDTO;
import org.assertj.core.util.Lists;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import com.alibaba.fastjson.JSON;
import com.netease.mailsaas.core.utils.Assert;
import com.netease.yanxuan.qc.parent.utils.LoginUserUtils;
@Service
public class IusServiceImpl implements IIusService {
@Value("${rpc.url.ius.basic}")
private String iusUrl;
private Logger logger = LoggerFactory.getLogger(IusServiceImpl.class);
@Autowired
private RpcTemplate rpcTemplate;
*/
/**
* 接口地址
*//*
private static final String USER_INFO_SUFFIX = "/icac/user/getUserInfo.json";
private static final String QUERY_USER_INFO_SUFFIX = "/v1/%s/user/query";
private static final String DEPT_LEVEL_LEADER = "/icac/user/uniteOrg/getPartLeaders.json";
private static final String FUZZY_USERINFO = "/icac/user/uniteOrg/fuzzyPartSubUserByOrgPosId.json";
private static final String ALL_USER_ROLE_INFOS = "/carrier/user/business/getAllUserProductRoleInfos.json";
private static final String LIST_USER_BY_ROLE_ID = "/%s/user/listUserByRoleId.json";
private static final String LIST_PRODUCT_HAS_UID = "/qc/product/listProductHasUid.json";
private static final String THIRD_ORG_POS_URL = "/v1/ehc/allTeam/pos/query";
private static final Integer THIRD_ORG_POS_LEVEL = 97;
@Override
@Cacheable(value = Constants.EHC_CACHE_STRING, key = "'getUserInfo'+#uid")
public UserInfoDTO getUserInfo(String uid) {
if (!StringUtils.hasText(uid)) {
return null;
}
Map<String, Object> params = new HashMap<>();
params.put("uid", uid);
ResponseResult result = null;
try {
result = rpcTemplate.post(iusUrl + USER_INFO_SUFFIX, params, 5000,
new IusRpcResult<>(ResponseResult.class));
} catch (Exception e) {
logger.error("[getUserInfo] uid={}, e={}", uid, e);
}
if (result == null) {
return null;
}
return (UserInfoDTO) result.getData();
}
@Override
public List<UserInfoDTO> queryUserInfo(String productCode, String uid) {
if (!StringUtils.hasText(uid)) {
return null;
}
QueryUserInfoVO req = new QueryUserInfoVO();
req.setUids(Lists.newArrayList(uid));
req.setLocked(false);
QueryUserInfoResponseResult result = null;
String url = iusUrl + String.format(QUERY_USER_INFO_SUFFIX, productCode);
try {
result = rpcTemplate.postJson(url, JSON.toJSONString(req), 5000,
new RpcObjectHandler<>(QueryUserInfoResponseResult.class));
} catch (Exception e) {
logger.error("[queryUserInfo] uid={}, e={}", uid, e);
}
if (result == null) {
return null;
}
return result.getData();
}
@Override
@Cacheable(value = Constants.EHC_CACHE_STRING, key = "'getOrgByUid'+#uid")
public String getOrgByUid(String uid) {
UserInfoDTO userInfoDTO = getUserInfo(uid);
if (userInfoDTO == null) {
return null;
}
String orgName = userInfoDTO.getDeptLevel3();
if (!StringUtils.hasText(orgName)) {
orgName = "无三级部门";
}
// if (!StringUtils.hasText(orgName)) {
// orgName = userInfoDTO.getDeptLevel2();
// }
// if (!StringUtils.hasText(orgName)) {
// orgName = userInfoDTO.getDeptLevel1();
// }
logger.info("[getOrgByUid] orgName={}", orgName);
return orgName;
}
@Override
public boolean checkUserIsLeave(String uid) {
UserInfoDTO userInfoDTO = getUserInfo(uid);
if (userInfoDTO != null && !StaffStatusEnum.DIMISSION.getType().equals(userInfoDTO.getStaffStatus())) {
// 离职
return true;
}
return false;
}
@Override
public List<DeptIdLevelLeaderDTO> getDeptIdLevelLeader(String uid, Integer orgPosId) {
Map<String, Object> params = new HashMap<>();
params.put("uid", uid);
params.put("orgPosId", orgPosId);
DeptIdLevelResponseResult levelResponseResult = null;
try {
levelResponseResult = rpcTemplate.post(iusUrl + DEPT_LEVEL_LEADER, params, 500,
new RpcObjectHandler<>(DeptIdLevelResponseResult.class));
} catch (Exception ex) {
logger.error("[getDeptIdLevelLeader] ex={}", ex);
}
if (levelResponseResult == null) {
return null;
}
return levelResponseResult.getData();
}
@Override
public List<DeptIdLevelLeaderDTO> getThreeLevelDeptLeader(String uid) {
UserInfoDTO userInfoDTO = getUserInfo(uid);
logger.info("[getThreeLevelDeptLeader] userInfoDTO={}", JSON.toJSONString(userInfoDTO));
if (userInfoDTO == null) {
return null;
}
List<DeptIdLevelLeaderDTO> userList = getDeptIdLevelLeader(userInfoDTO.getUid(), userInfoDTO.getDeptIdLevel3());
if (!CollectionUtils.isEmpty(userList)) {
List<DeptIdLevelLeaderDTO> filterList = userList.stream()
.filter(user -> OrgUserTypeEnum.PRINCIPAL.getValue() == user.getUserType()
&& userInfoDTO.getDeptIdLevel3().equals(user.getOrgPosId()))
.collect(Collectors.toList());
return filterList;
}
return null;
}
@Override
public List<DeptIdLevelLeaderDTO> getForthLevelDeptLeader(String uid) {
UserInfoDTO userInfoDTO = getUserInfo(uid);
logger.info("[getForthLevelDeptLeader] userInfoDTO={}", JSON.toJSONString(userInfoDTO));
if (userInfoDTO == null) {
return null;
}
List<DeptIdLevelLeaderDTO> userList = getDeptIdLevelLeader(userInfoDTO.getUid(), userInfoDTO.getDeptIdLevel4());
logger.debug("[getForthLevelDeptLeader] userList={}", JSON.toJSONString(userList));
if (!CollectionUtils.isEmpty(userList)) {
List<DeptIdLevelLeaderDTO> filterList = userList.stream()
.filter(user -> OrgUserTypeEnum.PRINCIPAL.getValue() == user.getUserType()
&& userInfoDTO.getDeptIdLevel4().equals(user.getOrgPosId()))
.collect(Collectors.toList());
logger.debug("[getForthLevelDeptLeader] filterList={}", JSON.toJSONString(filterList));
return filterList;
}
return Lists.newArrayList();
}
@Override
public List<UserUniteOrgMetaDTO> fuzzyQueryUserInfo(Long orgPosId, int level, int type, int queryType,
String keyword) {
Map<String, Object> params = new HashMap<>();
params.put("orgPosId", orgPosId);
params.put("level", level);
params.put("type", type);
params.put("queryType", queryType);
params.put("keyword", keyword);
UserUniteOrgMetaResponseResult result = null;
try {
result = rpcTemplate.post(iusUrl + FUZZY_USERINFO, params, 500,
new RpcObjectHandler<>(UserUniteOrgMetaResponseResult.class));
} catch (Exception ex) {
logger.error("fuzzyQueryUserInfo: ex={}", ex);
}
if (result == null) {
return null;
}
return result.getData();
}
@Override
public SearchResult<UserProductRoleStaticsInfosDTO> getAllUserProductRoleInfos(Integer staff, Long roleId,
Long orgPosId, Integer stationId, Integer locked, String keyword, Integer curPage, Integer pageSize) {
Map<String, Object> params = new HashMap<>();
params.put("staff", staff);
if (roleId != null) {
params.put("roleId", roleId);
}
params.put("orgPosId", orgPosId);
params.put("stationId", stationId);
params.put("locked", locked);
if (keyword != null) {
params.put("keyword", keyword);
}
params.put("curPage", curPage);
params.put("pageSize", pageSize);
AllUserProductRoleInfosResponseResult roleInfosResponseResult = null;
try {
roleInfosResponseResult = rpcTemplate.get(iusUrl + ALL_USER_ROLE_INFOS, params,
new RpcObjectHandler<>(AllUserProductRoleInfosResponseResult.class));
} catch (Exception ex) {
logger.error("[getAllUserProductRoleInfos] ex={}", ex);
}
if (roleInfosResponseResult == null) {
return null;
}
return roleInfosResponseResult.getData();
}
@Override
// @Cacheable(value = Constants.EHC_CACHE_STRING, key = "'listUserByRoleId'+#productCode+#roleId")
public List<UserBaseDTO> listUserByRoleId(String productCode, Long roleId) {
logger.info("[listUserByRoleId] productCode={}, roleId={}", productCode, roleId);
Map<String, Object> params = new HashMap<>();
params.put("roleId", roleId);
RoleResponseResult result = null;
try {
result = rpcTemplate.post(String.format(iusUrl + LIST_USER_BY_ROLE_ID, productCode), params, 500,
new RpcObjectHandler<>(RoleResponseResult.class));
} catch (Exception ex) {
logger.error("[listUserByRoleId] roleId={}, ex={}", roleId, ex);
}
if (result == null) {
return null;
}
return result.getData();
}
@Override
public List<UserUniteOrgMetaDTO> fuzzyQueryUserInformation(int queryType, String keyword) {
String baseUid = LoginUserUtils.getLoginUserEmail();
UserInfoDTO baseUser = getUserInfo(baseUid);
Assert.notNull(baseUser, "查询用户信息失败,获取基础信息异常。");
Assert.notNull(baseUser.getDeptIdLevel3(), "查询用户信息失败,获取用户【" + baseUid + "】三级部门失败");
List<UserUniteOrgMetaDTO> result = fuzzyQueryUserInfo((long) baseUser.getDeptIdLevel3(), -1, 0, queryType,
keyword);
return result;
}
@Override
public UserVO lv3UserInfo(String uid) {
UserVO user = new UserVO();
user.setUserEmail(uid);
UserInfoDTO userInfoDTO = getUserInfo(uid);
if (userInfoDTO == null) {
return user;
}
if (!StringUtils.hasText(userInfoDTO.getDeptLevel3())) {
user.setUserName(userInfoDTO.getName());
user.setOrgId((long) userInfoDTO.getDeptIdLevel3());
user.setOrgName("无三级部门");
return user;
}
user.setUserName(userInfoDTO.getName());
user.setOrgId((long) userInfoDTO.getDeptIdLevel3());
user.setOrgName(userInfoDTO.getDeptLevel3());
return user;
}
@Override
public List<String> listProductHasUid(String uid) {
if (StringUtils.isEmpty(uid)) {
logger.info("[listProductHasUid] uid -> null");
return null;
}
Map<String, Object> params = new HashMap<>();
params.put("uid", uid);
AjaxResult<List<String>> result = null;
try {
result = rpcTemplate.post(iusUrl + LIST_PRODUCT_HAS_UID, params, 500,
new RpcObjectHandler<>(AjaxResult.class));
} catch (Exception e) {
logger.error("[listProductHasUid] 接口调用错误 e:{}", e);
}
if (result == null) {
return null;
}
return result.getData();
}
@Override
public List<ThirdOrgPosDTO> getThirdOrgPosName(String name) {
Map<String, Object> params = new HashMap<>();
params.put("levels", THIRD_ORG_POS_LEVEL);
AjaxResult<List<ThirdOrgPosDTO>> result = null;
try {
result = rpcTemplate.get(iusUrl + THIRD_ORG_POS_URL, params, new RpcObjectHandler<>(AjaxResult.class));
} catch (Exception e) {
logger.error("[getThirdOrgPosName] 接口调用错误 e:{}", e);
}
if (result == null) {
return null;
}
//搜索
List<ThirdOrgPosDTO> thirdOrgPosDTOS = JSON.parseArray(JSON.toJSONString(result.getData()),
ThirdOrgPosDTO.class);
return thirdOrgPosNameFuzzySearch(thirdOrgPosDTOS, name);
}
private List<ThirdOrgPosDTO> thirdOrgPosNameFuzzySearch(List<ThirdOrgPosDTO> orgPosDTOList, String name) {
if (!CollectionUtils.isEmpty(orgPosDTOList)) {
orgPosDTOList = orgPosDTOList.stream().filter(f -> f.getOrgPosName().contains(name))
.collect(Collectors.toList());
return orgPosDTOList;
}
return null;
}
}
*/
/*
package com.netease.mail.yanxuan.change.integration.email.service.impl;
import com.alibaba.fastjson.JSON;
import com.netease.mail.yanxuan.change.integration.email.conig.RpcTemplate;
import com.netease.mail.yanxuan.change.integration.email.email.RpcObjectHandler;
import com.netease.mail.yanxuan.change.integration.email.email.SupplierEmailResponseResult;
import com.netease.mail.yanxuan.change.integration.email.email.SupplierEmailSendReq;
import com.netease.mail.yanxuan.change.integration.email.service.ISupplierEmailService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Value;
@Service
public class SupplierEmailServiceImpl implements ISupplierEmailService {
private Logger logger = LoggerFactory.getLogger(SupplierEmailServiceImpl.class);
@Autowired
private RpcTemplate rpcTemplate;
@Value("${rpc.url.supplier.purchase}")
private String emailUrl;
*/
/**
* 接口
*//*
private static final String SUPPLIER_EMAIL_SEND = "/api/supplier/msg/sendMail.json";
@Override
public SupplierEmailResponseResult sendSupplierEmail(SupplierEmailSendReq req) {
logger.info("[sendSupplierEmail] req:{}", JSON.toJSONString(req));
SupplierEmailResponseResult responseResult = null;
try {
responseResult = rpcTemplate.postJson(emailUrl+SUPPLIER_EMAIL_SEND,
JSON.toJSONString(req),500, new RpcObjectHandler<>(SupplierEmailResponseResult.class));
}catch (Exception e) {
logger.error("[sendSupplierEmail] 供应商邮件发送失败 e:{}",e.getMessage());
}
if (responseResult == null) {
return null;
}
return responseResult;
}
}
*/
package com.netease.mail.yanxuan.change.integration.email.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.netease.mail.yanxuan.change.integration.email.service.UasClientService;
import com.netease.mail.yanxuan.change.integration.flow.email.EmailRpcService;
import org.apache.commons.lang.StringUtils;
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.io.File;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author WangJiaXiang
* @date 2022/11/28/028$
*/
@Service
public class UasClientServiceImpl implements UasClientService {
Logger logger = LoggerFactory.getLogger(UasClientServiceImpl.class);
@Autowired
private EmailRpcService service;
/*
*
* emailPath=/push/email/
* rpcConfig.getUasApi()=http://127.0.0.1:8550/proxy/online.logistics-uas.service.mailsaas
* UPLOAD_FILE /push/email/attach/{0}/upload.json
*/
public void sendEmail(String subject, String content, Collection<String> toList, Collection<String> ccList, List<File> fileList) {
if (!CollectionUtils.isEmpty(toList)) {
//String url = MessageFormat.format("http://{0}{1}/{2}", this.thirdPartyDrmConfig.getUasHostInner(), "/push/email/", this.thirdPartyDrmConfig.getUasProduct());
Map<String, String> params = new HashMap();
params.put("subject", subject);
params.put("content", content);
params.put("to", StringUtils.join(toList, ","));
params.put("topic", "qc");
if (!CollectionUtils.isEmpty(ccList)) {
params.put("cc", StringUtils.join(ccList, ","));
}
String res = service.sendEmail(params);
this.logger.info("[op:sendEmail] res={} ", new Object[]{res});
JSONObject jsonObject = JSON.parseObject(res);
if (jsonObject.getInteger("code") != 200) {
this.logger.error("SendEmail", (String)null, "send email failed, subject={},toList={},ccList={}", new Object[]{subject, JSON.toJSONString(toList), JSON.toJSONString(ccList)});
}
}
}
}
//package com.netease.mail.yanxuan.change.integration.email.util; package com.netease.mail.yanxuan.change.integration.email.util;
//
//import java.net.URLDecoder; import java.net.URLDecoder;
//import java.net.URLEncoder; import java.net.URLEncoder;
//import java.util.ArrayList; import java.util.ArrayList;
//import java.util.List; import java.util.List;
//import java.util.Map; import java.util.Map;
//import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
//
///** /**
// * @author lwtang * @author lwtang
// * @date 2019-02-19 * @date 2019-02-19
// */ */
//public class EncodeUtil { public class EncodeUtil {
//
// private static final char[] CHARS = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', private static final char[] CHARS = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8',
// '9', 'a', 'b', 'c', 'd', 'e', 'f' }; '9', 'a', 'b', 'c', 'd', 'e', 'f' };
//
// public static String encode(String text) { public static String encode(String text) {
// try { try {
// return URLEncoder.encode(text, "UTF-8"); return URLEncoder.encode(text, "UTF-8");
// } catch (Exception e) { } catch (Exception e) {
// return text; return text;
// } }
// } }
//
// public static String encodeMap(Map<?, ?> map) { public static String encodeMap(Map<?, ?> map) {
// List<String> lines = new ArrayList<>(); List<String> lines = new ArrayList<>();
// for (Map.Entry<?, ?> entry: map.entrySet()) { for (Map.Entry<?, ?> entry: map.entrySet()) {
// lines.add(String.valueOf(entry.getKey()) + "=" + String.valueOf(entry.getValue())); lines.add(String.valueOf(entry.getKey()) + "=" + String.valueOf(entry.getValue()));
// } }
// return StringUtils.join(lines, "&"); return StringUtils.join(lines, "&");
// } }
//
// public static String decode(String text) { public static String decode(String text) {
// try { try {
// return URLDecoder.decode(text, "UTF-8"); return URLDecoder.decode(text, "UTF-8");
// } catch (Exception e) { } catch (Exception e) {
// return text; return text;
// } }
// } }
//
// public static String ASCIIHex(String text) { public static String ASCIIHex(String text) {
// byte[] bytes = text.getBytes(); byte[] bytes = text.getBytes();
// char[] chars = new char[bytes.length * 2]; char[] chars = new char[bytes.length * 2];
// for (int i = 0; i < bytes.length; i++) { for (int i = 0; i < bytes.length; i++) {
// chars[2 * i] = CHARS[bytes[i] >> 4]; chars[2 * i] = CHARS[bytes[i] >> 4];
// chars[2 * i + 1] = CHARS[bytes[i] % 16]; chars[2 * i + 1] = CHARS[bytes[i] % 16];
// } }
// return new String(chars).toUpperCase(); return new String(chars).toUpperCase();
// } }
//
//} }
//package com.netease.mail.yanxuan.change.integration.email.util; package com.netease.mail.yanxuan.change.integration.email.util;
//
//import com.netease.mail.yanxuan.change.integration.email.exception.RpcConnectException; import com.netease.mail.yanxuan.change.integration.email.exception.RpcConnectException;
//import com.netease.mail.yanxuan.change.integration.email.exception.RpcException; import com.netease.mail.yanxuan.change.integration.email.exception.RpcException;
//import com.netease.mail.yanxuan.change.integration.email.exception.RpcStatusException; import com.netease.mail.yanxuan.change.integration.email.exception.RpcStatusException;
//import com.netease.mail.yanxuan.change.integration.email.exception.RpcTimeoutException; import com.netease.mail.yanxuan.change.integration.email.exception.RpcTimeoutException;
//import org.apache.http.Consts; import org.apache.http.Consts;
//import org.apache.http.Header; import org.apache.http.Header;
//import org.apache.http.HttpEntity; import org.apache.http.HttpEntity;
//import org.apache.http.client.config.RequestConfig; import org.apache.http.client.config.RequestConfig;
//import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.entity.UrlEncodedFormEntity;
//import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.CloseableHttpResponse;
//import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpGet;
//import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPost;
//import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.client.methods.HttpRequestBase;
//import org.apache.http.config.*; import org.apache.http.config.*;
//import org.apache.http.conn.socket.ConnectionSocketFactory; import org.apache.http.conn.socket.ConnectionSocketFactory;
//import org.apache.http.conn.socket.PlainConnectionSocketFactory; import org.apache.http.conn.socket.PlainConnectionSocketFactory;
//import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
//import org.apache.http.entity.ContentType; import org.apache.http.entity.ContentType;
//import org.apache.http.entity.StringEntity; import org.apache.http.entity.StringEntity;
//import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
//import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.client.HttpClients;
//import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
//import org.apache.http.message.BasicHeader; import org.apache.http.message.BasicHeader;
//import org.apache.http.message.BasicNameValuePair; import org.apache.http.message.BasicNameValuePair;
//import org.apache.http.ssl.SSLContexts; import org.apache.http.ssl.SSLContexts;
//import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
//import org.slf4j.Logger; import org.slf4j.Logger;
//import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
//
//import javax.net.ssl.SSLContext; import javax.net.ssl.SSLContext;
//import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManager;
//import javax.net.ssl.X509TrustManager; import javax.net.ssl.X509TrustManager;
//import java.io.IOException; import java.io.IOException;
//import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
//import java.net.ConnectException; import java.net.ConnectException;
//import java.net.SocketTimeoutException; import java.net.SocketTimeoutException;
//import java.net.URI; import java.net.URI;
//import java.net.URLEncoder; import java.net.URLEncoder;
//import java.nio.charset.CodingErrorAction; import java.nio.charset.CodingErrorAction;
//import java.security.KeyManagementException; import java.security.KeyManagementException;
//import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
//import java.security.cert.CertificateException; import java.security.cert.CertificateException;
//import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
//import java.util.HashMap; import java.util.HashMap;
//import java.util.List; import java.util.List;
//import java.util.Map; import java.util.Map;
//import java.util.stream.Collectors; import java.util.stream.Collectors;
//
///** /**
// * HttpClient 封装 * HttpClient 封装
// * *
// * @author lwtang * @author lwtang
// * @date 2019-02-19 * @date 2019-02-19
// */ */
//public class HttpClientUtil { public class HttpClientUtil {
//
// private static final Logger LOG = LoggerFactory.getLogger(HttpClientUtil.class); private static final Logger LOG = LoggerFactory.getLogger(HttpClientUtil.class);
//
// private static final int DEFAULT_TIME_OUT = 5000; private static final int DEFAULT_TIME_OUT = 5000;
//
// private static final String DEFAULT_ENCODING = "UTF-8"; private static final String DEFAULT_ENCODING = "UTF-8";
//
// private static PoolingHttpClientConnectionManager connManager = null; private static PoolingHttpClientConnectionManager connManager = null;
//
// private static CloseableHttpClient httpclient = null; private static CloseableHttpClient httpclient = null;
//
//
// static { static {
// try { try {
// SSLContext sslContext = SSLContexts.custom().build(); SSLContext sslContext = SSLContexts.custom().build();
// sslContext.init(null, new TrustManager[] { new DefaultTrustManager() }, null); sslContext.init(null, new TrustManager[] { new DefaultTrustManager() }, null);
//
// Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder
// .<ConnectionSocketFactory>create() .<ConnectionSocketFactory>create()
// .register("http", PlainConnectionSocketFactory.INSTANCE) .register("http", PlainConnectionSocketFactory.INSTANCE)
// .register("https", new SSLConnectionSocketFactory(sslContext)).build(); .register("https", new SSLConnectionSocketFactory(sslContext)).build();
//
// connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry); connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
// httpclient = HttpClients.custom().setConnectionManager(connManager).build(); httpclient = HttpClients.custom().setConnectionManager(connManager).build();
// // Create socket configuration // Create socket configuration
// SocketConfig socketConfig = SocketConfig.custom().setSoKeepAlive(true) SocketConfig socketConfig = SocketConfig.custom().setSoKeepAlive(true)
// .setSoReuseAddress(true).setSoTimeout(DEFAULT_TIME_OUT).setTcpNoDelay(true).build(); .setSoReuseAddress(true).setSoTimeout(DEFAULT_TIME_OUT).setTcpNoDelay(true).build();
// connManager.setDefaultSocketConfig(socketConfig); connManager.setDefaultSocketConfig(socketConfig);
// // Create message constraints // Create message constraints
// MessageConstraints messageConstraints = MessageConstraints.custom() MessageConstraints messageConstraints = MessageConstraints.custom()
// .setMaxHeaderCount(200).setMaxLineLength(2000).build(); .setMaxHeaderCount(200).setMaxLineLength(2000).build();
// // Create connection configuration // Create connection configuration
// ConnectionConfig connectionConfig = ConnectionConfig.custom() ConnectionConfig connectionConfig = ConnectionConfig.custom()
// .setMalformedInputAction(CodingErrorAction.IGNORE) .setMalformedInputAction(CodingErrorAction.IGNORE)
// .setUnmappableInputAction(CodingErrorAction.IGNORE).setCharset(Consts.UTF_8) .setUnmappableInputAction(CodingErrorAction.IGNORE).setCharset(Consts.UTF_8)
// .setMessageConstraints(messageConstraints).build(); .setMessageConstraints(messageConstraints).build();
// connManager.setDefaultConnectionConfig(connectionConfig); connManager.setDefaultConnectionConfig(connectionConfig);
// connManager.setMaxTotal(300); connManager.setMaxTotal(300);
// connManager.setDefaultMaxPerRoute(100); connManager.setDefaultMaxPerRoute(100);
// } catch (KeyManagementException e) { } catch (KeyManagementException e) {
// LOG.error("KeyManagementException", e); LOG.error("KeyManagementException", e);
// } catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
// LOG.error("NoSuchAlgorithmException", e); LOG.error("NoSuchAlgorithmException", e);
// } }
// } }
//
// public static String get(String url, Map<String, Object> params, Map<String, String> header, public static String get(String url, Map<String, Object> params, Map<String, String> header,
// int timeout) { int timeout) {
// return doGet(url, params, header, DEFAULT_ENCODING, timeout); return doGet(url, params, header, DEFAULT_ENCODING, timeout);
// } }
//
// public static String doGet(String url, Map<String, Object> params, Map<String, String> header, public static String doGet(String url, Map<String, Object> params, Map<String, String> header,
// String encoding, int timeout) { String encoding, int timeout) {
// String responseString = null; String responseString = null;
//
// HttpGet get = new HttpGet(); HttpGet get = new HttpGet();
// fillUrl(url, params, encoding, get); fillUrl(url, params, encoding, get);
// fillHeader(header, get); fillHeader(header, get);
// fillConfig(timeout, timeout, get); fillConfig(timeout, timeout, get);
//
// try { try {
// CloseableHttpResponse response = httpclient.execute(get); CloseableHttpResponse response = httpclient.execute(get);
// try { try {
// int resHttpCode = response.getStatusLine().getStatusCode(); int resHttpCode = response.getStatusLine().getStatusCode();
// if( resHttpCode != 200) { if( resHttpCode != 200) {
// throw new RpcStatusException(resHttpCode, "status code " + resHttpCode + " not equal 200"); throw new RpcStatusException(resHttpCode, "status code " + resHttpCode + " not equal 200");
// } }
// HttpEntity entity = response.getEntity(); HttpEntity entity = response.getEntity();
// try { try {
// if (entity != null) { if (entity != null) {
// responseString = EntityUtils.toString(entity, encoding); responseString = EntityUtils.toString(entity, encoding);
// } }
// } finally { } finally {
// if (entity != null) { if (entity != null) {
// entity.getContent().close(); entity.getContent().close();
// } }
// } }
// return responseString; return responseString;
// } catch (Exception e) { } catch (Exception e) {
// LOG.error("[HttpUtils Get response error]", e); LOG.error("[HttpUtils Get response error]", e);
// throw e; throw e;
// } finally { } finally {
// if (response != null) { if (response != null) {
// response.close(); response.close();
// } }
// } }
// } catch (ConnectException e) { } catch (ConnectException e) {
// throw new RpcConnectException("request connect failed!"); throw new RpcConnectException("request connect failed!");
// } catch (SocketTimeoutException e) { } catch (SocketTimeoutException e) {
// throw new RpcTimeoutException("request timeout!"); throw new RpcTimeoutException("request timeout!");
// } catch (IOException e) { } catch (IOException e) {
// LOG.error("[query webservice error]", e); LOG.error("[query webservice error]", e);
// } finally { } finally {
// get.releaseConnection(); get.releaseConnection();
// } }
// return responseString; return responseString;
// } }
//
//
//
// public static String postJson(String url, String params, int timeout) { public static String postJson(String url, String params, int timeout) {
// Map<String, String> header = new HashMap<>(); Map<String, String> header = new HashMap<>();
// header.put("Content-type", ContentType.APPLICATION_JSON.getMimeType()); header.put("Content-type", ContentType.APPLICATION_JSON.getMimeType());
// return doPost(url, new StringEntity(params, DEFAULT_ENCODING), header, DEFAULT_ENCODING, return doPost(url, new StringEntity(params, DEFAULT_ENCODING), header, DEFAULT_ENCODING,
// timeout); timeout);
// } }
//
//
// public static String post(String url, Map<String, Object> params, int timeout) { public static String post(String url, Map<String, Object> params, int timeout) {
// Map<String, String> header = new HashMap<>(); Map<String, String> header = new HashMap<>();
// header.put("Content-type", ContentType.APPLICATION_FORM_URLENCODED.getMimeType()); header.put("Content-type", ContentType.APPLICATION_FORM_URLENCODED.getMimeType());
//
// HttpEntity httpEntity = null; HttpEntity httpEntity = null;
// if (params != null && params.size() > 0) { if (params != null && params.size() > 0) {
// List<BasicNameValuePair> formParams = params.entrySet().stream() List<BasicNameValuePair> formParams = params.entrySet().stream()
// .map(entry -> new BasicNameValuePair(entry.getKey(), .map(entry -> new BasicNameValuePair(entry.getKey(),
// entry.getValue() == null ? "" : entry.getValue().toString())) entry.getValue() == null ? "" : entry.getValue().toString()))
// .collect(Collectors.toList()); .collect(Collectors.toList());
//
// try { try {
// httpEntity = new UrlEncodedFormEntity(formParams, DEFAULT_ENCODING); httpEntity = new UrlEncodedFormEntity(formParams, DEFAULT_ENCODING);
// } catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
// throw new RpcException(e); throw new RpcException(e);
// } }
// } }
// return doPost(url, httpEntity, header, DEFAULT_ENCODING, timeout); return doPost(url, httpEntity, header, DEFAULT_ENCODING, timeout);
// } }
//
//
// public static String doPost(String url, HttpEntity params, Map<String, String> header, public static String doPost(String url, HttpEntity params, Map<String, String> header,
// String encoding, int timeout) { String encoding, int timeout) {
// String responseContent = null; String responseContent = null;
//
// HttpPost post = new HttpPost(url); HttpPost post = new HttpPost(url);
//
// fillHeader(header, post); fillHeader(header, post);
// fillConfig(timeout, timeout, post); fillConfig(timeout, timeout, post);
//
// post.setEntity(params); post.setEntity(params);
// try { try {
// CloseableHttpResponse response = httpclient.execute(post); CloseableHttpResponse response = httpclient.execute(post);
// try { try {
// HttpEntity entity = response.getEntity(); HttpEntity entity = response.getEntity();
// responseContent = EntityUtils.toString(entity, encoding); responseContent = EntityUtils.toString(entity, encoding);
// } finally { } finally {
// if (response != null) { if (response != null) {
// response.close(); response.close();
// } }
// } }
// } catch (ConnectException e) { } catch (ConnectException e) {
// throw new RpcConnectException("request connect failed!"); throw new RpcConnectException("request connect failed!");
// } catch (SocketTimeoutException e) { } catch (SocketTimeoutException e) {
// throw new RpcTimeoutException("request timeout!"); throw new RpcTimeoutException("request timeout!");
// } catch (IOException e) { } catch (IOException e) {
// LOG.error("[query webservice error]", e); LOG.error("[query webservice error]", e);
// } finally { } finally {
// post.releaseConnection(); post.releaseConnection();
// } }
// return responseContent; return responseContent;
// } }
//
// /** /**
// * concat url * concat url
// */ */
// private static String fillUrl(String url, Map<String, Object> params, String encoding, private static String fillUrl(String url, Map<String, Object> params, String encoding,
// HttpRequestBase requestBase) { HttpRequestBase requestBase) {
// StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
// sb.append(url); sb.append(url);
// int i = 0; int i = 0;
// if (params != null && params.size() > 0) { if (params != null && params.size() > 0) {
// for (Map.Entry<String, Object> entry: params.entrySet()) { for (Map.Entry<String, Object> entry: params.entrySet()) {
// if (i == 0 && !url.contains("?")) { if (i == 0 && !url.contains("?")) {
// sb.append("?"); sb.append("?");
// } else { } else {
// sb.append("&"); sb.append("&");
// } }
// sb.append(entry.getKey()); sb.append(entry.getKey());
// sb.append("="); sb.append("=");
// Object v = entry.getValue(); Object v = entry.getValue();
// String value = v == null ? "" : v.toString(); String value = v == null ? "" : v.toString();
// encoding = encoding == null ? Consts.UTF_8.name() : encoding; encoding = encoding == null ? Consts.UTF_8.name() : encoding;
// try { try {
// sb.append(URLEncoder.encode(value, encoding)); sb.append(URLEncoder.encode(value, encoding));
// } catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
// LOG.warn("encoding common get params error, value={}", value, e); LOG.warn("encoding common get params error, value={}", value, e);
// try { try {
// sb.append(URLEncoder.encode(value, encoding)); sb.append(URLEncoder.encode(value, encoding));
// } catch (Exception ex) { } catch (Exception ex) {
// e.printStackTrace(); e.printStackTrace();
// } }
// } }
// i++; i++;
// } }
// } }
// requestBase.setURI(URI.create(sb.toString())); requestBase.setURI(URI.create(sb.toString()));
// return sb.toString(); return sb.toString();
// } }
//
//
// private static void fillHeader(Map<String, String> header, HttpRequestBase requestBase) { private static void fillHeader(Map<String, String> header, HttpRequestBase requestBase) {
// if (header == null || header.size() == 0) { if (header == null || header.size() == 0) {
// return; return;
// } }
//
// Header[] headers = header.entrySet().stream() Header[] headers = header.entrySet().stream()
// .map(entry -> new BasicHeader(entry.getKey(), entry.getValue())) .map(entry -> new BasicHeader(entry.getKey(), entry.getValue()))
// .collect(Collectors.toList()).toArray(new Header[header.size()]); .collect(Collectors.toList()).toArray(new Header[header.size()]);
//
// if (headers.length > 0) { if (headers.length > 0) {
// requestBase.setHeaders(headers); requestBase.setHeaders(headers);
// } }
// } }
//
//
// /** /**
// * fill common conf * fill common conf
// */ */
// private static void fillConfig(int connectTimeout, int soTimeout, HttpRequestBase requestBase) { private static void fillConfig(int connectTimeout, int soTimeout, HttpRequestBase requestBase) {
// if (connectTimeout <= 0) { if (connectTimeout <= 0) {
// connectTimeout = DEFAULT_TIME_OUT; connectTimeout = DEFAULT_TIME_OUT;
// } }
// if (soTimeout <= 0) { if (soTimeout <= 0) {
// soTimeout = DEFAULT_TIME_OUT; soTimeout = DEFAULT_TIME_OUT;
// } }
//
// RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(soTimeout) RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(soTimeout)
// .setConnectTimeout(connectTimeout).setConnectionRequestTimeout(connectTimeout).build(); .setConnectTimeout(connectTimeout).setConnectionRequestTimeout(connectTimeout).build();
// requestBase.setConfig(requestConfig); requestBase.setConfig(requestConfig);
// } }
//
//
// public static class DefaultTrustManager implements X509TrustManager { public static class DefaultTrustManager implements X509TrustManager {
//
// @Override @Override
// public void checkClientTrusted(X509Certificate[] x509Certificates, String s) public void checkClientTrusted(X509Certificate[] x509Certificates, String s)
// throws CertificateException {} throws CertificateException {}
//
// @Override @Override
// public void checkServerTrusted(X509Certificate[] x509Certificates, String s) public void checkServerTrusted(X509Certificate[] x509Certificates, String s)
// throws CertificateException {} throws CertificateException {}
//
// @Override @Override
// public X509Certificate[] getAcceptedIssuers() { public X509Certificate[] getAcceptedIssuers() {
// return new X509Certificate[0]; return new X509Certificate[0];
// } }
// } }
//
//} }
package com.netease.mail.yanxuan.change.integration.flow.email;
import com.netease.yanxuan.missa.client.annotation.MissaClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping;
import java.util.Map;
/**
* @author WangJiaXiang
* @date 2022/11/28/028$
*/
@Service
@MissaClient(serviceCode = "logistics-uas")
public interface EmailRpcService {
//yanxuan-qc-change-system
@PostMapping("/push/email/attach/yanxuan-qc-change-system/upload.json")
String sendEmail(Map<String, String> params);
//
//yanxuan-sc-ehc
@PostMapping("/push/email/bpm_risk_evaluation_11")
String sendEmailInfo(Map<String, String> params);
}
...@@ -17,7 +17,7 @@ import java.util.List; ...@@ -17,7 +17,7 @@ import java.util.List;
*/ */
@Service @Service
@MissaClient(serviceCode = "yanxuan-ius") @MissaClient(serviceCode = "yanxuan-ius")
public interface FlowIusRpcService { public interface IusRpcService {
@GetMapping("/v1/qc/user/get") @GetMapping("/v1/qc/user/get")
AjaxResponse<IusUserInfoRsp> queryUserInfo(@RequestParam(name = "uid")String uid); AjaxResponse<IusUserInfoRsp> queryUserInfo(@RequestParam(name = "uid")String uid);
......
package com.netease.mail.yanxuan.change.web.controller; package com.netease.mail.yanxuan.change.web.controller;
import com.alibaba.fastjson.JSONObject;
import com.netease.mail.yanxuan.change.biz.service.InteriorChangeConfigService;
import com.netease.mail.yanxuan.change.common.bean.AjaxResult; import com.netease.mail.yanxuan.change.common.bean.AjaxResult;
import com.netease.mail.yanxuan.change.biz.service.change.AdminChangeConfigService; import com.netease.mail.yanxuan.change.biz.service.change.AdminChangeConfigService;
import com.netease.mail.yanxuan.change.dal.meta.model.po.ChangeCommanderPO;
import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeConfigQueryReq; import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeConfigQueryReq;
import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeConfigReq; import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeConfigReq;
import com.netease.mail.yanxuan.change.dal.meta.model.rpc.GoodsResponseRpc; import com.netease.mail.yanxuan.change.integration.email.service.UasClientService;
import com.netease.mail.yanxuan.change.integration.flow.ius.*; import com.netease.mail.yanxuan.change.integration.flow.ius.*;
import com.netease.yanxuan.flowx.sdk.meta.controller.communal.AjaxResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/** /**
...@@ -114,35 +105,22 @@ public class ChangeConfigController { ...@@ -114,35 +105,22 @@ public class ChangeConfigController {
} }
@Autowired @Autowired
private FlowIusRpcService iusRpcService; private IusRpcService iusRpcService;
@GetMapping("/test")
public AjaxResponse<IusUserInfoRsp> queryGoods(){
return iusRpcService.queryUserInfo("grp.gyhtest1001@corp.netease.com");
}
private static Logger logger = LoggerFactory.getLogger(ChangeConfigController.class);
@GetMapping("/test1")
public AjaxResponse<HashMap<String, List<SecondaryDepartments>>> queryGoods1(){
ArrayList<String> strings = new ArrayList<>();
strings.add("grp.gyhtest1001@corp.netease.com");
return iusRpcService.queryDepartment(new IusDepartmentReq(strings));
}
@GetMapping("/test2")
public AjaxResponse<List<OrgPosLeaderChainRsp>> queryGoods2(){
AjaxResponse<List<OrgPosLeaderChainRsp>> objectAjaxResponse = iusRpcService.queryLeaderChain("grp.gyhtest1001@corp.netease.com");
return objectAjaxResponse;
}
//private static Logger logger = LoggerFactory.getLogger(ChangeConfigController.class);
@Autowired @Autowired
private InteriorChangeConfigService changeConfigService; private UasClientService iEmailService;
@PostMapping("/test3") @GetMapping("/test")
public GoodsResponseRpc queryCommanderInfo(@RequestBody ChangeCommanderPO changeCommander){ public void queryCommanderInfo(){
return changeConfigService.queryCommanderInfo(changeCommander); ArrayList<String> strings = new ArrayList<>();
strings.add("wb.tanglongwei@mesg.corp.netease.com");
iEmailService.sendEmail("测试标题","{\n" +
" \"headline\" : \"测试标题\",\n" +
" \"text\" : \"测试文本内容\"\n" +
"}", strings,null,null);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment