Commit ca25c1d0 by 王志超

feat: 行动项必填项校验

parent 1362551f
package com.netease.mail.yanxuan.change.biz.biz; package com.netease.mail.yanxuan.change.biz.biz;
import com.netease.mail.yanxuan.change.biz.meta.exception.ExceptionFactory;
import com.netease.mail.yanxuan.change.common.bean.ResponseCode;
import com.netease.mail.yanxuan.change.common.util.DateUtils; import com.netease.mail.yanxuan.change.common.util.DateUtils;
import com.netease.mail.yanxuan.change.dal.entity.ChangeExecRecord; import com.netease.mail.yanxuan.change.dal.entity.ChangeExecRecord;
import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeExecConfigReq; import com.netease.mail.yanxuan.change.dal.meta.model.req.ChangeExecConfigReq;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -32,10 +34,30 @@ public class ChangeExecRecordBiz { ...@@ -32,10 +34,30 @@ public class ChangeExecRecordBiz {
List<ChangeExecConfigReq> changeExecProjectList, List<ChangeExecConfigReq> changeExecProjectList,
String subFlowId, String subFlowId,
Long subFlowRecordId) { Long subFlowRecordId) {
// 校验列表不为空
if (CollectionUtils.isEmpty(changeExecProjectList)) { if (CollectionUtils.isEmpty(changeExecProjectList)) {
return new ArrayList<>(); throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项列表不能为空");
} }
// 校验每个行动项的必填字段
changeExecProjectList.forEach(c -> {
if (StringUtils.isBlank(c.getChangeExecUser())) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中变更行动人不能为空");
}
if (StringUtils.isBlank(c.getChangeExecUserEmail())) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中变更行动人邮箱不能为空");
}
if (StringUtils.isBlank(c.getChangeRiskDesc())) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中变更风险描述不能为空");
}
if (StringUtils.isBlank(c.getChangeExecProject())) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中行动项内容不能为空");
}
if (c.getChangeExecFinishTime() == null || c.getChangeExecFinishTime() <= 0) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中变更完成时间不能为空");
}
});
return changeExecProjectList.stream().map(c -> { return changeExecProjectList.stream().map(c -> {
ChangeExecRecord changeExecRecord = new ChangeExecRecord(); ChangeExecRecord changeExecRecord = new ChangeExecRecord();
changeExecRecord.setChangeRecordId(changeRecordId); changeExecRecord.setChangeRecordId(changeRecordId);
......
...@@ -76,7 +76,6 @@ import com.netease.mail.yanxuan.change.integration.flow.ius.IusRpcService; ...@@ -76,7 +76,6 @@ import com.netease.mail.yanxuan.change.integration.flow.ius.IusRpcService;
import com.netease.mail.yanxuan.change.integration.flow.ius.req.IusDepartmentReq; import com.netease.mail.yanxuan.change.integration.flow.ius.req.IusDepartmentReq;
import com.netease.mail.yanxuan.change.integration.flow.ius.rsp.IusUserInfoRsp; import com.netease.mail.yanxuan.change.integration.flow.ius.rsp.IusUserInfoRsp;
import com.netease.mail.yanxuan.change.integration.flow.ius.rsp.SecondaryDepartments; import com.netease.mail.yanxuan.change.integration.flow.ius.rsp.SecondaryDepartments;
import com.netease.mail.yanxuan.change.integration.flow.ius.rsp.leaderChain;
import com.netease.mail.yanxuan.change.integration.flow.supplier.rsp.SupplierSimpleRsp; import com.netease.mail.yanxuan.change.integration.flow.supplier.rsp.SupplierSimpleRsp;
import com.netease.mail.yanxuan.change.integration.item.SimplePhyCateGoryResultCo; import com.netease.mail.yanxuan.change.integration.item.SimplePhyCateGoryResultCo;
import com.netease.mail.yanxuan.change.integration.item.meta.SpuTO; import com.netease.mail.yanxuan.change.integration.item.meta.SpuTO;
...@@ -146,6 +145,9 @@ public class ChangeFlowBiz { ...@@ -146,6 +145,9 @@ public class ChangeFlowBiz {
private IusRpcService iusRpcService; private IusRpcService iusRpcService;
@Autowired @Autowired
private DepartmentLeaderBiz departmentLeaderBiz;
@Autowired
private SupplierSendService sendSupplierEmail; private SupplierSendService sendSupplierEmail;
@Autowired @Autowired
...@@ -454,7 +456,7 @@ public class ChangeFlowBiz { ...@@ -454,7 +456,7 @@ public class ChangeFlowBiz {
// 发起变更,收件人:变更负责人 // 发起变更,收件人:变更负责人
List<String> receiver = Collections.singletonList(changeCommander); List<String> receiver = Collections.singletonList(changeCommander);
List<String> ccList = getDepartmentInfo(receiver); List<String> ccList = departmentLeaderBiz.getDepartmentLeaders(receiver);
// 发起变更,抄送:变更负责人上一级主管、变更管理QM // 发起变更,抄送:变更负责人上一级主管、变更管理QM
ccList.add(appConfig.getChangeManageQM()); ccList.add(appConfig.getChangeManageQM());
qcSendEmail(receiver, ccList, subjectParam, EmailTemplateEnum.YX_QC_CHANGE_RELEASE_FLOW, param); qcSendEmail(receiver, ccList, subjectParam, EmailTemplateEnum.YX_QC_CHANGE_RELEASE_FLOW, param);
...@@ -470,31 +472,6 @@ public class ChangeFlowBiz { ...@@ -470,31 +472,6 @@ public class ChangeFlowBiz {
} }
} }
public List<String> getDepartmentInfo(List<String> receiver) {
IusDepartmentReq iusDepartmentReq = new IusDepartmentReq();
iusDepartmentReq.setHasOrgPos(true);
iusDepartmentReq.setIcac(true);
iusDepartmentReq.setUids(receiver);
HashMap<String, List<SecondaryDepartments>> map = iusService.queryDepartment(iusDepartmentReq);
log.info("[getDepartmentInfo] receiver: {}, map:{}", receiver, JSON.toJSONString(map));
ArrayList<List<SecondaryDepartments>> secondaryDepartments = new ArrayList<>(map.values());
List<String> ccList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(secondaryDepartments)) {
// 外层循环是不同人,内层循环是相同人不同部门
for (List<SecondaryDepartments> secondaryDepartment : secondaryDepartments) {
for (SecondaryDepartments dep : secondaryDepartment) {
List<leaderChain> leaderChainList = dep.getLeaderChainList();
if (CollectionUtils.isNotEmpty(leaderChainList)) {
ccList.add(leaderChainList.get(leaderChainList.size()-1).getUid());
}
}
}
}
if (CollectionUtils.isNotEmpty(ccList)) {
ccList = ccList.stream().distinct().collect(Collectors.toList());
}
return ccList;
}
/** /**
* 严选QC端发送邮件 * 严选QC端发送邮件
...@@ -780,7 +757,7 @@ public class ChangeFlowBiz { ...@@ -780,7 +757,7 @@ public class ChangeFlowBiz {
List<String> userEmailList = execRecord.stream().map(ChangeFlowExecVO::getChangeExecUserEmail) List<String> userEmailList = execRecord.stream().map(ChangeFlowExecVO::getChangeExecUserEmail)
.collect(Collectors.toList()); .collect(Collectors.toList());
// 变更确认,抄送人:所有变更行动人上一级LEADER+变更管理委员会(yx_change_SC@qun.mail.163.com) // 变更确认,抄送人:所有变更行动人上一级LEADER+变更管理委员会(yx_change_SC@qun.mail.163.com)
List<String> list = this.getDepartmentInfo(userEmailList); List<String> list = departmentLeaderBiz.getDepartmentLeaders(userEmailList);
list.add(appConfig.getChangeCommittee()); list.add(appConfig.getChangeCommittee());
userEmailList.add(changeRecord.getChangeCommander()); userEmailList.add(changeRecord.getChangeCommander());
userEmailList.add(appConfig.getChangeManageQM()); userEmailList.add(appConfig.getChangeManageQM());
...@@ -849,7 +826,7 @@ public class ChangeFlowBiz { ...@@ -849,7 +826,7 @@ public class ChangeFlowBiz {
List<String> userEmails = execRecordList.stream().map(ChangeFlowExecVO::getChangeExecUserEmail) List<String> userEmails = execRecordList.stream().map(ChangeFlowExecVO::getChangeExecUserEmail)
.collect(Collectors.toList()); .collect(Collectors.toList());
// 变更确认,抄送人:所有变更行动人上一级LEADER+变更管理委员会(yx_change_SC@qun.mail.163.com) // 变更确认,抄送人:所有变更行动人上一级LEADER+变更管理委员会(yx_change_SC@qun.mail.163.com)
List<String> departmentInfoList = this.getDepartmentInfo(userEmails); List<String> departmentInfoList = departmentLeaderBiz.getDepartmentLeaders(userEmails);
departmentInfoList.add(appConfig.getChangeCommittee()); departmentInfoList.add(appConfig.getChangeCommittee());
userEmails.add(changeRecord.getChangeCommander()); userEmails.add(changeRecord.getChangeCommander());
userEmails.add(appConfig.getChangeManageQM()); userEmails.add(appConfig.getChangeManageQM());
...@@ -955,7 +932,7 @@ public class ChangeFlowBiz { ...@@ -955,7 +932,7 @@ public class ChangeFlowBiz {
receiver.addAll(userEmailList); receiver.addAll(userEmailList);
// 取消变更,抄送人:变更负责人+变更行动人上一级主管、变更管理QM(cuiyixian@corp.netease.com) // 取消变更,抄送人:变更负责人+变更行动人上一级主管、变更管理QM(cuiyixian@corp.netease.com)
userEmailList.addAll(receiver); userEmailList.addAll(receiver);
List<String> ccList = this.getDepartmentInfo(userEmailList); List<String> ccList = departmentLeaderBiz.getDepartmentLeaders(userEmailList);
ccList.add(appConfig.getChangeManageQM()); ccList.add(appConfig.getChangeManageQM());
// 取消变更,收件人:变更发起人(供应商邮箱号或严选发起人)、变更负责人、变更行动人 // 取消变更,收件人:变更发起人(供应商邮箱号或严选发起人)、变更负责人、变更行动人
String creator = changeRecord.getCreator(); String creator = changeRecord.getCreator();
...@@ -1051,6 +1028,7 @@ public class ChangeFlowBiz { ...@@ -1051,6 +1028,7 @@ public class ChangeFlowBiz {
changeFlowVO.setChangeProfit(changeRecord.getChangeProfit()); changeFlowVO.setChangeProfit(changeRecord.getChangeProfit());
changeFlowVO.setChangeProfitAmount(changeRecord.getChangeProfitAmount()); changeFlowVO.setChangeProfitAmount(changeRecord.getChangeProfitAmount());
changeFlowVO.setChangeProfitDesc(changeRecord.getChangeProfitDesc()); changeFlowVO.setChangeProfitDesc(changeRecord.getChangeProfitDesc());
changeFlowVO.setBatchDescription(changeRecord.getBatchDescription());
String itemJsonStr = changeRecord.getChangeItem(); String itemJsonStr = changeRecord.getChangeItem();
String changeSkuJson = changeRecord.getChangeSku(); String changeSkuJson = changeRecord.getChangeSku();
if (StringUtils.isNotBlank(itemJsonStr)) { if (StringUtils.isNotBlank(itemJsonStr)) {
...@@ -1491,7 +1469,7 @@ public class ChangeFlowBiz { ...@@ -1491,7 +1469,7 @@ public class ChangeFlowBiz {
// 转交,收件人:变更转交人(工单接收人)、变更负责人(工单转交人) // 转交,收件人:变更转交人(工单接收人)、变更负责人(工单转交人)
List<String> receiver = Arrays.asList(changeCommander, deliverUser); List<String> receiver = Arrays.asList(changeCommander, deliverUser);
// 转交,抄送人:变更发起人+原变更负责人上一级主管、变更转交人(工单接收人)上一级主管+变更行动项负责人 // 转交,抄送人:变更发起人+原变更负责人上一级主管、变更转交人(工单接收人)上一级主管+变更行动项负责人
List<String> ccList = this.getDepartmentInfo(receiver); List<String> ccList = departmentLeaderBiz.getDepartmentLeaders(receiver);
ccList.add(changeRecord.getCreator()); ccList.add(changeRecord.getCreator());
List<ChangeFlowExecVO> execRecord = changeFlowExecService List<ChangeFlowExecVO> execRecord = changeFlowExecService
.getChangeFlowExecRecord(changeRecord.getId()); .getChangeFlowExecRecord(changeRecord.getId());
......
...@@ -83,6 +83,9 @@ public class ChangeSubFlowBiz { ...@@ -83,6 +83,9 @@ public class ChangeSubFlowBiz {
private ChangeExecRecordBiz changeExecRecordBiz; private ChangeExecRecordBiz changeExecRecordBiz;
@Autowired @Autowired
private DepartmentLeaderBiz departmentLeaderBiz;
@Autowired
private IusRpcService iusRpcService; private IusRpcService iusRpcService;
@Autowired @Autowired
...@@ -189,7 +192,7 @@ public class ChangeSubFlowBiz { ...@@ -189,7 +192,7 @@ public class ChangeSubFlowBiz {
String expectedDepartment = subFlowRecord.getChangeExecDepartment(); String expectedDepartment = subFlowRecord.getChangeExecDepartment();
String expectedUserEmail = subFlowRecord.getChangeExecUserEmail(); String expectedUserEmail = subFlowRecord.getChangeExecUserEmail();
// 校验所有行动项的部门+邮箱必须与子单记录一致 // 校验所有行动项的必填字段和部门+邮箱必须与子单记录一致
changeExecProjectList.forEach(execConfig -> { changeExecProjectList.forEach(execConfig -> {
String dept = execConfig.getChangeExecDepartment(); String dept = execConfig.getChangeExecDepartment();
String userEmail = execConfig.getChangeExecUserEmail(); String userEmail = execConfig.getChangeExecUserEmail();
...@@ -204,6 +207,20 @@ public class ChangeSubFlowBiz { ...@@ -204,6 +207,20 @@ public class ChangeSubFlowBiz {
String.format("行动项的部门+人组合必须与子单记录一致。子单记录:部门[%s],行动人[%s];当前行动项:部门[%s],行动人[%s]", String.format("行动项的部门+人组合必须与子单记录一致。子单记录:部门[%s],行动人[%s];当前行动项:部门[%s],行动人[%s]",
expectedDepartment, expectedUserEmail, dept, userEmail)); expectedDepartment, expectedUserEmail, dept, userEmail));
} }
// 校验必填字段
if (StringUtils.isBlank(execConfig.getChangeExecUser())) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中变更行动人不能为空");
}
if (StringUtils.isBlank(execConfig.getChangeRiskDesc())) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中变更风险描述不能为空");
}
if (StringUtils.isBlank(execConfig.getChangeExecProject())) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中行动项内容不能为空");
}
if (execConfig.getChangeExecFinishTime() == null || execConfig.getChangeExecFinishTime() <= 0) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动项中变更完成时间不能为空");
}
}); });
// 删除子单下所有行动项 // 删除子单下所有行动项
...@@ -222,8 +239,17 @@ public class ChangeSubFlowBiz { ...@@ -222,8 +239,17 @@ public class ChangeSubFlowBiz {
subFlowRecord.setSubFlowNode(nextNodeId); subFlowRecord.setSubFlowNode(nextNodeId);
subFlowRecord.setStatus(ChangeSubFlowStatusEnum.WAIT_APPROVE_ACTION_PLAN.getStatus()); subFlowRecord.setStatus(ChangeSubFlowStatusEnum.WAIT_APPROVE_ACTION_PLAN.getStatus());
subFlowRecord.setUpdateTime(DateUtils.getCurrentTime()); subFlowRecord.setUpdateTime(DateUtils.getCurrentTime());
// todo: 获取上级领导 // 获取上级领导:根据行动人邮箱获取其部门上级领导(必须存在)
subFlowRecord.setApprover(""); String execUserEmail = subFlowRecord.getChangeExecUserEmail();
if (StringUtils.isBlank(execUserEmail)) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST, "行动人邮箱不能为空");
}
String leaderEmail = departmentLeaderBiz.getDepartmentLeader(execUserEmail);
if (StringUtils.isBlank(leaderEmail)) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST,
String.format("行动人[%s]的部门上级领导不存在", execUserEmail));
}
subFlowRecord.setApprover(leaderEmail);
changeSubFlowRecordService.update(subFlowRecord); changeSubFlowRecordService.update(subFlowRecord);
return nextNodeId; return nextNodeId;
......
package com.netease.mail.yanxuan.change.biz.biz;
import com.netease.mail.yanxuan.change.biz.service.rpc.IusService;
import com.netease.mail.yanxuan.change.integration.flow.ius.req.IusDepartmentReq;
import com.netease.mail.yanxuan.change.integration.flow.ius.rsp.SecondaryDepartments;
import com.netease.mail.yanxuan.change.integration.flow.ius.rsp.leaderChain;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.stream.Collectors;
/**
* 部门领导查询业务类
*
* @author system
*/
@Component
@Slf4j
public class DepartmentLeaderBiz {
@Autowired
private IusService iusService;
/**
* 批量获取用户的部门上级领导列表
*
* @param userEmails 用户邮箱列表
* @return 上级领导邮箱列表(去重)
*/
public List<String> getDepartmentLeaders(List<String> userEmails) {
if (CollectionUtils.isEmpty(userEmails)) {
return new ArrayList<>();
}
IusDepartmentReq iusDepartmentReq = new IusDepartmentReq();
iusDepartmentReq.setHasOrgPos(true);
iusDepartmentReq.setIcac(true);
iusDepartmentReq.setUids(userEmails);
HashMap<String, List<SecondaryDepartments>> map = iusService.queryDepartment(iusDepartmentReq);
ArrayList<List<SecondaryDepartments>> secondaryDepartments = new ArrayList<>(map.values());
List<String> leaderList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(secondaryDepartments)) {
// 外层循环是不同人,内层循环是相同人不同部门
for (List<SecondaryDepartments> secondaryDepartment : secondaryDepartments) {
for (SecondaryDepartments dep : secondaryDepartment) {
List<leaderChain> leaderChainList = dep.getLeaderChainList();
if (CollectionUtils.isNotEmpty(leaderChainList)) {
// 获取上一级领导(leaderChainList 的最后一个元素,列表是从上往下逐级下降的:最上级 -> ... -> 上一级)
leaderChain directLeader = leaderChainList.get(leaderChainList.size() - 1);
if (directLeader != null && StringUtils.isNotBlank(directLeader.getUid())) {
leaderList.add(directLeader.getUid());
}
}
}
}
}
// 去重
if (CollectionUtils.isNotEmpty(leaderList)) {
leaderList = leaderList.stream().distinct().collect(Collectors.toList());
}
return leaderList;
}
/**
* 获取单个用户的部门上级领导(取第一个)
*
* @param userEmail 用户邮箱
* @return 上级领导邮箱,如果不存在则返回 null
*/
public String getDepartmentLeader(String userEmail) {
if (StringUtils.isBlank(userEmail)) {
return null;
}
List<String> leaders = getDepartmentLeaders(Collections.singletonList(userEmail));
if (CollectionUtils.isNotEmpty(leaders)) {
return leaders.get(0);
}
return null;
}
}
...@@ -110,6 +110,11 @@ public class ChangeFlowVO { ...@@ -110,6 +110,11 @@ public class ChangeFlowVO {
* 变更收益金额 * 变更收益金额
*/ */
private String changeProfitAmount; private String changeProfitAmount;
/**
* 批次说明
*/
private String batchDescription;
/** /**
* 变更商品列表 * 变更商品列表
*/ */
......
...@@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.netease.mail.yanxuan.change.biz.biz.ChangeFlowBiz; import com.netease.mail.yanxuan.change.biz.biz.ChangeFlowBiz;
import com.netease.mail.yanxuan.change.biz.biz.DepartmentLeaderBiz;
import com.netease.mail.yanxuan.change.biz.service.change.ChangeConfigService; import com.netease.mail.yanxuan.change.biz.service.change.ChangeConfigService;
import com.netease.mail.yanxuan.change.biz.service.rpc.QCService; import com.netease.mail.yanxuan.change.biz.service.rpc.QCService;
import com.netease.mail.yanxuan.change.common.bean.AjaxResult; import com.netease.mail.yanxuan.change.common.bean.AjaxResult;
...@@ -54,6 +55,9 @@ public class TestController { ...@@ -54,6 +55,9 @@ public class TestController {
@Autowired @Autowired
private ChangeSubFlowBiz changeSubFlowBiz; private ChangeSubFlowBiz changeSubFlowBiz;
@Autowired
private DepartmentLeaderBiz departmentLeaderBiz;
// @PostMapping("/submit") // @PostMapping("/submit")
// public AjaxResult<Void> submit(Long id) { // public AjaxResult<Void> submit(Long id) {
// ChangeRecord record = changeFlowService.getById(id); // ChangeRecord record = changeFlowService.getById(id);
...@@ -97,7 +101,7 @@ public class TestController { ...@@ -97,7 +101,7 @@ public class TestController {
@GetMapping("/ccList") @GetMapping("/ccList")
public AjaxResult<List<String>> ccList(@RequestParam List<String> receiver){ public AjaxResult<List<String>> ccList(@RequestParam List<String> receiver){
return AjaxResult.success(changeFlowBiz.getDepartmentInfo(receiver)); return AjaxResult.success(departmentLeaderBiz.getDepartmentLeaders(receiver));
} }
@GetMapping("/getByOneAndTwo") @GetMapping("/getByOneAndTwo")
......
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