Commit 728e7f77 by yxdubhe_bot

merge:feature-modifyEmail-230207:operator:hzhuyuanyuan@corp.netease.com:auto_bra…

merge:feature-modifyEmail-230207:operator:hzhuyuanyuan@corp.netease.com:auto_branch_merge_by_branchService_end
parents 01463113 2a1df136
Pipeline #45145 passed with stages
in 3 minutes 52 seconds
...@@ -4,6 +4,7 @@ import org.springframework.boot.SpringApplication; ...@@ -4,6 +4,7 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableAsync;
import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig; import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig;
import com.netease.yanxuan.missa.client.annotation.EnableMissaClients; import com.netease.yanxuan.missa.client.annotation.EnableMissaClients;
...@@ -18,6 +19,7 @@ import tk.mybatis.spring.annotation.MapperScan; ...@@ -18,6 +19,7 @@ import tk.mybatis.spring.annotation.MapperScan;
@EnableApolloConfig @EnableApolloConfig
@EnableMissaClients(basePackages = "com.netease.mail.yanxuan.change") @EnableMissaClients(basePackages = "com.netease.mail.yanxuan.change")
@SpringBootApplication @SpringBootApplication
@EnableAsync
public class Application extends SpringBootServletInitializer { public class Application extends SpringBootServletInitializer {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
......
...@@ -37,6 +37,7 @@ import com.github.pagehelper.PageHelper; ...@@ -37,6 +37,7 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.netease.mail.yanxuan.change.biz.config.AppConfig; import com.netease.mail.yanxuan.change.biz.config.AppConfig;
import com.netease.mail.yanxuan.change.biz.meta.exception.ExceptionFactory; import com.netease.mail.yanxuan.change.biz.meta.exception.ExceptionFactory;
import com.netease.mail.yanxuan.change.biz.service.BuildAndSendEmail;
import com.netease.mail.yanxuan.change.biz.service.ChangeFileService; import com.netease.mail.yanxuan.change.biz.service.ChangeFileService;
import com.netease.mail.yanxuan.change.biz.service.ChangeFlowExecService; import com.netease.mail.yanxuan.change.biz.service.ChangeFlowExecService;
import com.netease.mail.yanxuan.change.biz.service.ChangeFlowService; import com.netease.mail.yanxuan.change.biz.service.ChangeFlowService;
...@@ -102,7 +103,6 @@ import com.netease.mail.yanxuan.change.integration.item.meta.SpuTO; ...@@ -102,7 +103,6 @@ import com.netease.mail.yanxuan.change.integration.item.meta.SpuTO;
import com.netease.mail.yanxuan.change.integration.item.param.BatchQuerySpuInfoParam; import com.netease.mail.yanxuan.change.integration.item.param.BatchQuerySpuInfoParam;
import com.netease.mail.yanxuan.change.integration.item.param.CommonIdsParamQuery; import com.netease.mail.yanxuan.change.integration.item.param.CommonIdsParamQuery;
import com.netease.mail.yanxuan.change.integration.qc.meta.QcCategoryVO; import com.netease.mail.yanxuan.change.integration.qc.meta.QcCategoryVO;
import com.netease.mail.yanxuan.change.integration.todo.ChangeExecuteEmailDTO;
import com.netease.yanxuan.flowx.sdk.meta.controller.communal.AjaxResponse; import com.netease.yanxuan.flowx.sdk.meta.controller.communal.AjaxResponse;
import com.netease.yanxuan.flowx.sdk.meta.dto.base.FlowDataDTO; import com.netease.yanxuan.flowx.sdk.meta.dto.base.FlowDataDTO;
import com.netease.yanxuan.flowx.sdk.meta.dto.base.UserBaseDTO; import com.netease.yanxuan.flowx.sdk.meta.dto.base.UserBaseDTO;
...@@ -171,6 +171,9 @@ public class ChangeFlowBiz { ...@@ -171,6 +171,9 @@ public class ChangeFlowBiz {
@Autowired @Autowired
private QCService qcService; private QCService qcService;
@Autowired
private BuildAndSendEmail buildAndSendEmail;
public String createAndSubmit(ChangeFlowCreateReq changeFlowCreateReq) { public String createAndSubmit(ChangeFlowCreateReq changeFlowCreateReq) {
String uid = RequestLocalBean.getUid(); String uid = RequestLocalBean.getUid();
String name = RequestLocalBean.getName(); String name = RequestLocalBean.getName();
...@@ -298,51 +301,7 @@ public class ChangeFlowBiz { ...@@ -298,51 +301,7 @@ public class ChangeFlowBiz {
changeRecord.setState(ChangeStatusEnum.IN.getStatus()); changeRecord.setState(ChangeStatusEnum.IN.getStatus());
changeRecord.setUpdateTime(DateUtils.getCurrentTime()); changeRecord.setUpdateTime(DateUtils.getCurrentTime());
changeFlowService.updateRecord(changeRecord); changeFlowService.updateRecord(changeRecord);
HashMap<String, Object> param = new HashMap<>(); buildAndSendEmail.buildAndSendEmailCreate(changeRecord, changeExecRecords, changeType, changeCommander, changeFlowCreateReq);
param.put("changeId", changeRecord.getFlowId());
param.put("changeSubject", ChangeSubjectEnum.getChangeSubjectEnum(changeRecord.getChangeSubject()).getDesc());
param.put("changeContent", changeRecord.getChangeContent());
param.put("changeReason", changeRecord.getChangeReason());
IusUserInfoRsp user = iusService.queryUserInfo(changeRecord.getChangeCommander());
param.put("changeCommander", user == null ? changeRecord.getChangeCommander() : user.getName());
param.put("changeCommanderEmail", changeRecord.getChangeCommander());
param.put("flowUrl", changeRecord.getFlowId());
List<ChangeExecuteEmailDTO> dataList = new ArrayList<>();
changeExecRecords.forEach(i -> {
ChangeExecuteEmailDTO changeExecuteEmailDTO = new ChangeExecuteEmailDTO();
changeExecuteEmailDTO.setChangeExecDepartment(i.getChangeExecDepartment());
changeExecuteEmailDTO.setChangeExecUser(i.getChangeExecUser());
changeExecuteEmailDTO.setChangeRiskDesc(i.getChangeRiskDesc());
changeExecuteEmailDTO.setChangeExecProject(i.getChangeExecProject());
changeExecuteEmailDTO.setChangeChecking(i.getChangeChecking());
dataList.add(changeExecuteEmailDTO);
});
param.put("dataList", dataList);
String subjectParam = ChangeSubjectEnum.getChangeSubjectEnum(changeRecord.getChangeSubject()).getDesc() + changeType
+ changeRecord.getFlowId().toString();
List<ChangeFlowExecVO> changeFlowExecRecord = changeFlowExecService
.getChangeFlowExecRecord(changeRecord.getId());
List<String> execUserEmailList = changeFlowExecRecord.stream().map(ChangeFlowExecVO::getChangeExecUserEmail)
.collect(Collectors.toList());
// 获取指定人的上级部门主管邮箱
List<String> ccList = getDepartmentInfo(execUserEmailList);
// 变更执行,抄送:所有变更行动人上一级LEADER,变更负责人、变更转交人(如有)
ccList.add(changeCommander);
// 变更执行,收件人:所有变更行动人+变更管理QM(cuiyixian@corp.netease.com)
execUserEmailList.add(appConfig.getChangeManageQM());
qcSendEmail(execUserEmailList, ccList, subjectParam, EmailTemplateEnum.YX_QC_CHANGE_EXECUTE, param);
// 如果是供应商,再次发送供应商邮件
if (changeFlowCreateReq.getCreateSource().equals(CreateSourceEnum.TONG_ZHOU.getType())) {
sendSupplierEmail.sendSupplierEmail(changeRecord.getCreateSupplier(), subjectParam,
EmailTemplateEnum.YX_QC_CHANGE_EXECUTE, param);
}
// 如果是其他端发起但是是供应商变更,再次发送供应商邮件
if (!changeFlowCreateReq.getCreateSource().equals(CreateSourceEnum.TONG_ZHOU.getType())
&& ChangeSubjectEnum.SUPPLIER.getType().equals(changeRecord.getChangeSubject())) {
sendSupplierEmail.sendSupplierEmail(changeRecord.getChangeSupplier(), subjectParam,
EmailTemplateEnum.YX_QC_CHANGE_EXECUTE, param);
}
return flowId; return flowId;
} }
// 如果发起人≠变更负责人,停留在变更申请提交节点,发送邮件 // 如果发起人≠变更负责人,停留在变更申请提交节点,发送邮件
...@@ -616,51 +575,7 @@ public class ChangeFlowBiz { ...@@ -616,51 +575,7 @@ public class ChangeFlowBiz {
} }
log.debug("[CHANGE_FLOW_SUBMIT] changeFiles:{}, uploadFiles:{}, allFiles:{}", JSON.toJSONString(changeFiles), log.debug("[CHANGE_FLOW_SUBMIT] changeFiles:{}, uploadFiles:{}, allFiles:{}", JSON.toJSONString(changeFiles),
JSON.toJSONString(uploadFiles), JSON.toJSONString(allFiles)); JSON.toJSONString(uploadFiles), JSON.toJSONString(allFiles));
HashMap<String, Object> param = new HashMap<>(); buildAndSendEmail.buildAndSendEmailSubmit(changeRecord, changeExecRecords);
param.put("changeId", changeRecord.getFlowId());
param.put("changeSubject", ChangeSubjectEnum.getChangeSubjectEnum(changeRecord.getChangeSubject()).getDesc());
param.put("changeContent", changeRecord.getChangeContent());
param.put("changeReason", changeRecord.getChangeReason());
IusUserInfoRsp user = iusService.queryUserInfo(changeRecord.getChangeCommander());
param.put("changeCommander", user == null ? changeRecord.getChangeCommander() : user.getName());
param.put("changeCommanderEmail", changeRecord.getChangeCommander());
param.put("flowUrl", changeRecord.getFlowId());
param.put("dataList", changeExecRecords);
ChangeConfigPo changeConfigPoV1 = changeConfigService.queryInfoPo(changeRecord.getParentChangeClassId(), changeRecord.getSonChangeClassId());
StringBuilder changeTypeV1 = new StringBuilder();
try {
changeTypeV1.append(changeConfigPoV1.getChangeTypes().get(0).getTypeName());
changeTypeV1.append(changeConfigPoV1.getChangeTypes().get(1).getTypeName());
} catch (Exception e) {
log.error("queryInfoPo error:{}", JSON.toJSONString(changeConfigPoV1));
}
String subjectParam = ChangeSubjectEnum.getChangeSubjectEnum(changeRecord.getChangeSubject()).getDesc() + changeTypeV1
+ changeRecord.getFlowId().toString();
// 负责人
String changeCommander = changeRecord.getChangeCommander();
List<ChangeFlowExecVO> changeFlowExecRecord = changeFlowExecService
.getChangeFlowExecRecord(changeRecord.getId());
List<String> execUserEmailList = changeFlowExecRecord.stream().map(ChangeFlowExecVO::getChangeExecUserEmail)
.collect(Collectors.toList());
// 获取指定人的上级部门主管邮箱
List<String> ccList = getDepartmentInfo(execUserEmailList);
// 变更执行,抄送:所有变更行动人上一级LEADER,变更负责人、变更转交人(如有)
ccList.add(changeCommander);
// 变更执行,收件人:所有变更行动人+变更管理QM(cuiyixian@corp.netease.com)
execUserEmailList.add(appConfig.getChangeManageQM());
qcSendEmail(execUserEmailList, ccList, subjectParam,
EmailTemplateEnum.YX_QC_CHANGE_EXECUTE, param);
// 如果是供应商,再次发送供应商邮件
if (changeRecord.getCreateSource().equals(CreateSourceEnum.TONG_ZHOU.getType())) {
sendSupplierEmail.sendSupplierEmail(changeRecord.getCreateSupplier(), subjectParam,
EmailTemplateEnum.YX_QC_CHANGE_EXECUTE, param);
}
// 如果是其他端发起但是是供应商变更,再次发送供应商邮件
if (!changeRecord.getCreateSource().equals(CreateSourceEnum.TONG_ZHOU.getType())
&& ChangeSubjectEnum.SUPPLIER.getType().equals(changeRecord.getChangeSubject())) {
sendSupplierEmail.sendSupplierEmail(changeRecord.getChangeSupplier(), subjectParam,
EmailTemplateEnum.YX_QC_CHANGE_EXECUTE, param);
}
return submitNode; return submitNode;
case CHANGE_FLOW_CONFIRM: case CHANGE_FLOW_CONFIRM:
Integer changeResult = changeFlowSubmitReq.getChangeResult(); Integer changeResult = changeFlowSubmitReq.getChangeResult();
......
/**
* @(#)AsyncBuildConfig.java, 2023/2/8.
* <p/>
* Copyright 2023 Netease, Inc. All rights reserved.
* NETEASE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.netease.mail.yanxuan.change.biz.config;
import java.util.concurrent.Executor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
/**
* @Author zcwang
* @Date 2023/2/8
*/
@Configuration
public class AsyncBuildConfig {
@Bean(name = "asyncBuild")
public Executor getAsyncExecutor() {
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setCorePoolSize(5);
taskExecutor.setMaxPoolSize(10);
taskExecutor.setThreadNamePrefix("asyncBuild-");
taskExecutor.initialize();
return taskExecutor;
}
}
\ No newline at end of file
/**
* @(#)AsyncEmailConfig.java, 2023/2/8.
* <p/>
* Copyright 2023 Netease, Inc. All rights reserved.
* NETEASE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.netease.mail.yanxuan.change.biz.config;
import java.util.concurrent.Executor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
/**
* @Author zcwang
* @Date 2023/2/8
*/
@Configuration
public class AsyncEmailConfig {
@Bean(name = "asyncEmail")
public Executor getAsyncExecutor() {
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setCorePoolSize(5);
taskExecutor.setMaxPoolSize(10);
taskExecutor.setThreadNamePrefix("asyncEmail-");
taskExecutor.initialize();
return taskExecutor;
}
}
\ No newline at end of file
/**
* @(#)buildAndSendEmail.java, 2023/2/7.
* <p/>
* Copyright 2023 Netease, Inc. All rights reserved.
* NETEASE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.netease.mail.yanxuan.change.biz.service;
import java.util.List;
import com.netease.mail.yanxuan.change.dal.entity.ChangeExecRecord;
import com.netease.mail.yanxuan.change.dal.entity.ChangeRecord;
import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeFlowCreateReq;
/**
* @Author zcwang
* @Date 2023/2/7
*/
public interface BuildAndSendEmail {
/**
* 创建工单,创建人=变更负责人,组装提交数据,并发送邮件
* @param changeRecord
* @param changeExecRecords
* @param changeType
* @param changeCommander
* @param changeFlowCreateReq
*/
void buildAndSendEmailCreate(ChangeRecord changeRecord, List<ChangeExecRecord> changeExecRecords, StringBuilder changeType, String changeCommander, ChangeFlowCreateReq changeFlowCreateReq);
/**
* 提交工单,变更确认节点,组装提交数据,并发送邮件
* @param changeRecord
* @param changeExecRecords
*/
void buildAndSendEmailSubmit(ChangeRecord changeRecord, List<ChangeExecRecord> changeExecRecords);
}
\ No newline at end of file
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