mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-11 03:46:50 +08:00
Compare commits
1 Commits
251114-fea
...
251208-fea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c01a69c9df |
@@ -68,6 +68,9 @@ public class CourseManageApi extends ApiBaseController{
|
||||
@Autowired
|
||||
IOutSideDataService outsideService;
|
||||
|
||||
@Autowired
|
||||
ICourseManageService courseManageService;
|
||||
|
||||
|
||||
@Resource
|
||||
IEmailService service;
|
||||
@@ -688,7 +691,73 @@ public class CourseManageApi extends ApiBaseController{
|
||||
return error("提交课程处理失败",e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 25.12.10新增,提交审核到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) {
|
||||
// 存在历史审核记录,视为编辑审核
|
||||
dto.setAuditType(2);
|
||||
} else {
|
||||
// 无历史审核记录,视为创建审核
|
||||
dto.setAuditType(1);
|
||||
}
|
||||
|
||||
}
|
||||
return success(response);
|
||||
} catch (Exception e) {
|
||||
log.error("提交保存课程信息错误",e);
|
||||
return error("error");
|
||||
}
|
||||
}
|
||||
|
||||
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\">");
|
||||
|
||||
|
||||
@@ -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
|
||||
public class CourseFullDto {
|
||||
/**
|
||||
* 25.12.10新增
|
||||
* 审核类型
|
||||
* 0: 停用审核
|
||||
* 1: 创建审核
|
||||
* 2: 编辑审核
|
||||
* 3:启用审核
|
||||
*/
|
||||
private Integer auditType;
|
||||
/**
|
||||
* 25.12.10新增
|
||||
* 提交审核的用户id
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**是否是新建课程*/
|
||||
private Boolean isNew;
|
||||
|
||||
@@ -31,7 +31,15 @@ public interface ICourseHRBPAuditService {
|
||||
* @return
|
||||
*/
|
||||
CourseHRBPAudit hasAuditing(String courseId);
|
||||
|
||||
|
||||
/**
|
||||
* 25.12.10新增
|
||||
* 检查课程是否已经有过审核记录了
|
||||
* @param courseId
|
||||
* @return
|
||||
*/
|
||||
CourseHRBPAudit hadAuditing(String courseId);
|
||||
|
||||
/**
|
||||
* 根据课程、id获取课程的审核记录
|
||||
* @param info 审核信息
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.xboe.module.course.service;
|
||||
|
||||
import com.xboe.module.course.dto.BPMResponseDto;
|
||||
import com.xboe.module.course.dto.CourseFullDto;
|
||||
|
||||
public interface ICourseManageService {
|
||||
String prepareDisableAuditRequest(CourseFullDto dto);
|
||||
BPMResponseDto callBPMInterface(String jsonRequestBody);
|
||||
}
|
||||
@@ -171,6 +171,19 @@ public class CourseHRBPAuditServiceImpl implements ICourseHRBPAuditService {
|
||||
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
|
||||
public PageList<CourseHRBPAudit> pageList(Integer pageIndex, Integer pageSize, int userType, CourseHRBPAudit info) {
|
||||
QueryBuilder query=QueryBuilder.from(CourseHRBPAudit.class.getSimpleName()+" a,"+Course.class.getSimpleName()+" c");
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 调用外部接口
|
||||
*/
|
||||
@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