mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-13 21:06:48 +08:00
Compare commits
3 Commits
251114-fea
...
251208-fea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
639ac253f1 | ||
|
|
f43d52c210 | ||
|
|
c01a69c9df |
@@ -68,6 +68,9 @@ public class CourseManageApi extends ApiBaseController{
|
|||||||
@Autowired
|
@Autowired
|
||||||
IOutSideDataService outsideService;
|
IOutSideDataService outsideService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ICourseManageService courseManageService;
|
||||||
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
IEmailService service;
|
IEmailService service;
|
||||||
@@ -688,6 +691,100 @@ public class CourseManageApi extends ApiBaseController{
|
|||||||
return error("提交课程处理失败",e.getMessage());
|
return error("提交课程处理失败",e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 25.12.10新增,提交审核到BPM
|
||||||
|
*暂无BPM接口
|
||||||
|
*非空判断需要加/日志
|
||||||
|
*/
|
||||||
|
@PostMapping("/bpm-submit")
|
||||||
|
@AutoLog(module = "课程",action = "提交审核到BPM",info = "")
|
||||||
|
public JsonResponse<BPMResponseDto> submitBPMCourseFull(@RequestBody CourseFullDto dto){
|
||||||
|
try {
|
||||||
|
BPMResponseDto response = null;
|
||||||
|
//首先判断是否为停用审核
|
||||||
|
if(dto.getAuditType() != null && dto.getAuditType()==0)
|
||||||
|
{
|
||||||
|
// 准备停用审核的JSON请求体,暂时先按照京东方大学堂后端调用BPM系统需要的接口文档的入参示例完成,等到有外部接口时再修改
|
||||||
|
String jsonRequestBody = courseManageService.prepareDisableAuditRequest(dto);
|
||||||
|
|
||||||
|
// TODO: 调用BPM接口
|
||||||
|
//BPMResponseDto bpmResponsedto= courseManageService.callBPMInterface(jsonRequestBody);
|
||||||
|
|
||||||
|
// 构造返回结果
|
||||||
|
//实际使用中,返回的值从BPM接口返回的JSON中获取
|
||||||
|
BPMResponseDto bpmResponsedto = new BPMResponseDto();
|
||||||
|
bpmResponsedto.setStatus("success");
|
||||||
|
bpmResponsedto.setAuditId("audit123456");
|
||||||
|
bpmResponsedto.setAuditApprover("管理员hrbp");
|
||||||
|
return success(bpmResponsedto);
|
||||||
|
|
||||||
|
}
|
||||||
|
//再判断是否为启用审核
|
||||||
|
else if(dto.getAuditType() != null && dto.getAuditType()==3)
|
||||||
|
{
|
||||||
|
// 准备启用审核的JSON请求体,暂时先按照京东方大学堂后端调用BPM系统需要的接口文档的入参示例完成,等到有外部接口时再修改
|
||||||
|
String jsonRequestBody = courseManageService.prepareDisableAuditRequest(dto);
|
||||||
|
|
||||||
|
// TODO: 调用BPM接口
|
||||||
|
// BPMResponseDto bpmResponsedto= courseManageService.callBPMInterface(jsonRequestBody);
|
||||||
|
|
||||||
|
// 构造返回结果
|
||||||
|
//实际使用中,返回的值从BPM接口返回的JSON中获取
|
||||||
|
BPMResponseDto bpmResponsedto = new BPMResponseDto();
|
||||||
|
bpmResponsedto.setStatus("success");
|
||||||
|
bpmResponsedto.setAuditId("audit123456");
|
||||||
|
bpmResponsedto.setAuditApprover("管理员hrbp");
|
||||||
|
return success(bpmResponsedto);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
//通过查看在boe_course_hrbp_audit表当中,有没有旧的审核记录数据,判断为创建审核还是编辑审核
|
||||||
|
//注:此处需要查一下查看表的时候需要限定审核记录的状态嘛,先查再问项目经理
|
||||||
|
String courseId=dto.getCourse().getId();
|
||||||
|
CourseHRBPAudit previousAudit = hrbpAuditService.hadAuditing(courseId);
|
||||||
|
if (previousAudit != null) {
|
||||||
|
// 存在历史审核记录,视为编辑审核
|
||||||
|
//编辑课程审核,需要后端服务整理出本次编辑的内容与编辑前的前后差异,提交至BPM系统。
|
||||||
|
dto.setAuditType(2);
|
||||||
|
} else {
|
||||||
|
// 无历史审核记录,视为创建审核
|
||||||
|
dto.setAuditType(1);
|
||||||
|
// 准备创建审核的JSON请求体,暂时先按照京东方大学堂后端调用BPM系统需要的接口文档的入参示例完成,等到有外部接口时再修改
|
||||||
|
String jsonRequestBody = courseManageService.prepareCreateAuditRequest(dto);
|
||||||
|
// TODO: 调用BPM接口
|
||||||
|
// BPMResponseDto bpmResponsedto= courseManageService.callBPMInterface(jsonRequestBody);
|
||||||
|
|
||||||
|
// 构造返回结果
|
||||||
|
//实际使用中,返回的值从BPM接口返回的JSON中获取
|
||||||
|
BPMResponseDto bpmResponsedto = new BPMResponseDto();
|
||||||
|
bpmResponsedto.setStatus("success");
|
||||||
|
bpmResponsedto.setAuditId("audit123456");
|
||||||
|
bpmResponsedto.setAuditApprover("管理员hrbp");
|
||||||
|
return success(bpmResponsedto);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
return success(response);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("提交保存课程信息错误",e);
|
||||||
|
return error("error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 25.12.12新增,审核完成的回调接口
|
||||||
|
*/
|
||||||
|
@PostMapping("/audit/callback")
|
||||||
|
public JsonResponse<String> callbackBPM(@RequestBody BPMCallbackDto dto){
|
||||||
|
try {
|
||||||
|
|
||||||
|
|
||||||
|
return success("");
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("回调错误",e);
|
||||||
|
return error("error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String createEmailHtml(String name,String orgId, String orgName,String createBy,String courseName) throws Exception {
|
private String createEmailHtml(String name,String orgId, String orgName,String createBy,String courseName) throws Exception {
|
||||||
StringBuffer htmlMsg=new StringBuffer("<div style=\"line-height:30px;border:2px solid #2990ca;padding:20px\">");
|
StringBuffer htmlMsg=new StringBuffer("<div style=\"line-height:30px;border:2px solid #2990ca;padding:20px\">");
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.xboe.module.course.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 25.12.12新增,BPM回调接口入参
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class BPMCallbackDto {
|
||||||
|
/**
|
||||||
|
* 审批流程ID
|
||||||
|
*/
|
||||||
|
private String auditId;
|
||||||
|
/**
|
||||||
|
* 审核结果,可选值:`success` (通过), `reject` (驳回)
|
||||||
|
*/
|
||||||
|
private String auditResult;
|
||||||
|
/**
|
||||||
|
* 最终审核意见
|
||||||
|
* auditResult为reject时,传最后驳回时的驳回意见
|
||||||
|
*/
|
||||||
|
private String auditComment;
|
||||||
|
/**
|
||||||
|
* 最终审核人
|
||||||
|
* auditResult为reject时,传最后驳回的用户
|
||||||
|
*/
|
||||||
|
private String lastAuditUser;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.xboe.module.course.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
/**
|
||||||
|
* 25.12.10新增,提交审核到BPM时的返回结果
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class BPMResponseDto {
|
||||||
|
/**
|
||||||
|
* 调用BPM返回的状态:success/error
|
||||||
|
*/
|
||||||
|
private String status;
|
||||||
|
/**
|
||||||
|
* 调用BPM成功时返回的审批单ID
|
||||||
|
*/
|
||||||
|
private String auditId;
|
||||||
|
/**
|
||||||
|
* 调用BPM成功时返回的审批人姓名
|
||||||
|
*/
|
||||||
|
private String auditApprover;
|
||||||
|
/**
|
||||||
|
* 调用BPM失败时返回的错误信息
|
||||||
|
*/
|
||||||
|
private String message;
|
||||||
|
}
|
||||||
@@ -18,6 +18,20 @@ import lombok.Data;
|
|||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class CourseFullDto {
|
public class CourseFullDto {
|
||||||
|
/**
|
||||||
|
* 25.12.10新增
|
||||||
|
* 审核类型
|
||||||
|
* 0: 停用审核
|
||||||
|
* 1: 创建审核
|
||||||
|
* 2: 编辑审核
|
||||||
|
* 3:启用审核
|
||||||
|
*/
|
||||||
|
private Integer auditType;
|
||||||
|
/**
|
||||||
|
* 25.12.10新增
|
||||||
|
* 提交审核的用户id
|
||||||
|
*/
|
||||||
|
private String userId;
|
||||||
|
|
||||||
/**是否是新建课程*/
|
/**是否是新建课程*/
|
||||||
private Boolean isNew;
|
private Boolean isNew;
|
||||||
|
|||||||
@@ -32,6 +32,14 @@ public interface ICourseHRBPAuditService {
|
|||||||
*/
|
*/
|
||||||
CourseHRBPAudit hasAuditing(String courseId);
|
CourseHRBPAudit hasAuditing(String courseId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 25.12.10新增
|
||||||
|
* 检查课程是否已经有过审核记录了
|
||||||
|
* @param courseId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
CourseHRBPAudit hadAuditing(String courseId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据课程、id获取课程的审核记录
|
* 根据课程、id获取课程的审核记录
|
||||||
* @param info 审核信息
|
* @param info 审核信息
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.xboe.module.course.service;
|
||||||
|
|
||||||
|
import com.xboe.module.course.dto.BPMResponseDto;
|
||||||
|
import com.xboe.module.course.dto.CourseFullDto;
|
||||||
|
|
||||||
|
public interface ICourseManageService {
|
||||||
|
/**
|
||||||
|
* 25.12.10新增,调用外部接口前,启用/停用进行数据准备和json请求体构建
|
||||||
|
*/
|
||||||
|
String prepareDisableAuditRequest(CourseFullDto dto);
|
||||||
|
/**
|
||||||
|
* 25.12.10新增,调用外部接口前,创建进行数据准备和json请求体构建
|
||||||
|
*/
|
||||||
|
String prepareCreateAuditRequest(CourseFullDto dto);
|
||||||
|
/**
|
||||||
|
* 25.12.10新增,BPM外部接口调用
|
||||||
|
*/
|
||||||
|
BPMResponseDto callBPMInterface(String jsonRequestBody);
|
||||||
|
}
|
||||||
@@ -171,6 +171,19 @@ public class CourseHRBPAuditServiceImpl implements ICourseHRBPAuditService {
|
|||||||
return hrbp;
|
return hrbp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 25.12.10新增
|
||||||
|
* 检查课程是否已经有过审核记录了
|
||||||
|
* @param courseId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public CourseHRBPAudit hadAuditing(String courseId) {
|
||||||
|
//未审核的
|
||||||
|
CourseHRBPAudit hrbp = courseHRBPAuditDao.findOne(FieldFilters.eq("courseId", courseId),FieldFilters.eq("status", 9));
|
||||||
|
return hrbp;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageList<CourseHRBPAudit> pageList(Integer pageIndex, Integer pageSize, int userType, CourseHRBPAudit info) {
|
public PageList<CourseHRBPAudit> pageList(Integer pageIndex, Integer pageSize, int userType, CourseHRBPAudit info) {
|
||||||
QueryBuilder query=QueryBuilder.from(CourseHRBPAudit.class.getSimpleName()+" a,"+Course.class.getSimpleName()+" c");
|
QueryBuilder query=QueryBuilder.from(CourseHRBPAudit.class.getSimpleName()+" a,"+Course.class.getSimpleName()+" c");
|
||||||
|
|||||||
@@ -0,0 +1,133 @@
|
|||||||
|
package com.xboe.module.course.service.impl;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.xboe.core.utils.OkHttpUtil;
|
||||||
|
import com.xboe.module.course.dto.BPMResponseDto;
|
||||||
|
import com.xboe.module.course.dto.CourseFullDto;
|
||||||
|
import com.xboe.module.course.service.ICourseManageService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CourseManageServiceImpl implements ICourseManageService {
|
||||||
|
@Autowired
|
||||||
|
private OkHttpUtil okHttpUtil;
|
||||||
|
/**
|
||||||
|
* 启用/停用调用外部接口前讲DTO转换成JSON字符串
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String prepareDisableAuditRequest(CourseFullDto dto) {
|
||||||
|
try {
|
||||||
|
// 创建顶层对象
|
||||||
|
Map<String, Object> request = new HashMap<>();
|
||||||
|
|
||||||
|
// 构造auditContent部分
|
||||||
|
Map<String, Object> auditContent = new HashMap<>();
|
||||||
|
//auditContent.put("auditType", "停用课程");
|
||||||
|
if(dto.getAuditType()==0)
|
||||||
|
{
|
||||||
|
auditContent.put("auditType", "停用课程");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
auditContent.put("auditType", "启用课程");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构造courseInfo部分
|
||||||
|
Map<String, String> courseInfo = new HashMap<>();
|
||||||
|
courseInfo.put("name", dto.getCourse().getName());
|
||||||
|
auditContent.put("courseInfo", courseInfo);
|
||||||
|
|
||||||
|
// 将auditContent放入请求体
|
||||||
|
request.put("auditContent", auditContent);
|
||||||
|
|
||||||
|
// 添加用户ID
|
||||||
|
request.put("userId", dto.getUserId());
|
||||||
|
|
||||||
|
// 转换为JSON字符串
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
return objectMapper.writeValueAsString(request);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
throw new RuntimeException("构造停用审核JSON请求体失败", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 创建调用外部接口前讲DTO转换成JSON字符串
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String prepareCreateAuditRequest(CourseFullDto dto) {
|
||||||
|
try {
|
||||||
|
// 创建顶层对象
|
||||||
|
Map<String, Object> request = new HashMap<>();
|
||||||
|
|
||||||
|
// 构造auditContent部分
|
||||||
|
Map<String, Object> auditContent = new HashMap<>();
|
||||||
|
auditContent.put("auditType", "创建课程");
|
||||||
|
// 构造courseInfo部分
|
||||||
|
Map<String, Object> courseInfo = new HashMap<>();
|
||||||
|
courseInfo.put("name", dto.getCourse().getName());
|
||||||
|
//几级分类?几级归属?
|
||||||
|
courseInfo.put("sysType", dto.getCourse().getSysType1());
|
||||||
|
courseInfo.put("resOwner", dto.getCourse().getResOwner1());
|
||||||
|
courseInfo.put("teacherName", dto.getCourse().getTeacher());
|
||||||
|
courseInfo.put("forUsers", dto.getCourse().getForUsers());
|
||||||
|
courseInfo.put("tags", dto.getCourse().getTags());
|
||||||
|
courseInfo.put("device", dto.getCourse().getDevice());
|
||||||
|
courseInfo.put("coverImg", dto.getCourse().getCoverImg());
|
||||||
|
courseInfo.put("value", dto.getCourse().getValue());
|
||||||
|
courseInfo.put("summary", dto.getCourse().getSummary());
|
||||||
|
//课程目录,等到拿到BPM接口,需要查看getCatalogTree()得到的格式是否与BPM需要的格式一致
|
||||||
|
courseInfo.put("sections", dto.getCatalogTree());
|
||||||
|
auditContent.put("courseInfo", courseInfo);
|
||||||
|
|
||||||
|
// 将auditContent放入请求体
|
||||||
|
request.put("auditContent", auditContent);
|
||||||
|
|
||||||
|
// 添加用户ID
|
||||||
|
request.put("userId", dto.getUserId());
|
||||||
|
|
||||||
|
// 转换为JSON字符串
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
return objectMapper.writeValueAsString(request);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("构造创建审核JSON请求体失败", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 调用BPM外部接口
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public BPMResponseDto callBPMInterface(String jsonRequestBody){
|
||||||
|
try {
|
||||||
|
String token = "";
|
||||||
|
// BPM接口地址,先按照接口文档写,得到实际的地址之后再修改
|
||||||
|
String url = "http://bpm-system-address/xboe/bpm/audit/submit";
|
||||||
|
// 设置请求头
|
||||||
|
Map<String, String> headers = new HashMap<>();
|
||||||
|
headers.put("Content-Type", "application/json");
|
||||||
|
// 添加认证头
|
||||||
|
headers.put("Authorization", "Bearer " + token);
|
||||||
|
// Map转String数组
|
||||||
|
List<String> headerList = new ArrayList<>();
|
||||||
|
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||||
|
headerList.add(entry.getKey() + ":" + entry.getValue());
|
||||||
|
}
|
||||||
|
String[] headerArr = headerList.toArray(new String[0]);
|
||||||
|
// 发送POST请求
|
||||||
|
String response = okHttpUtil.doPostJson(url, jsonRequestBody,headerArr);
|
||||||
|
// 解析响应
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
return objectMapper.readValue(response, BPMResponseDto.class);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("调用BPM接口失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user