fix:iwork用印及回调调试
This commit is contained in:
@@ -2,11 +2,13 @@ package com.zt.plat.module.qms.business.reportdoc.controller.admin;
|
||||
|
||||
import com.zt.plat.module.infra.api.file.FileApi;
|
||||
import com.zt.plat.module.infra.api.file.dto.FileRespDTO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.constant.ReportDocConstant;
|
||||
import com.zt.plat.module.qms.business.reportdoc.controller.vo.ReportDocumentFilePageReqVO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.controller.vo.ReportDocumentFileRespVO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.controller.vo.ReportDocumentFileSaveReqVO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentMainDO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.service.ReportDocumentMainService;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -110,9 +112,17 @@ public class ReportDocumentFileController extends AbstractFileUploadController i
|
||||
Integer version = vo.getVersion();
|
||||
if(version == null){
|
||||
ReportDocumentMainDO mainDO = reportDocumentMainService.getReportDocumentMain(mainId);
|
||||
version = mainDO.getDocumentVersion();
|
||||
// version = mainDO.getDocumentVersion();
|
||||
}
|
||||
// if(type != null)
|
||||
// entity
|
||||
if(ObjectUtils.isEmpty(vo.getType()))
|
||||
vo.setType(ReportDocConstant.REPORT_DOCUMENT_BUSINESS_FILE_SOURCE_IWORK);
|
||||
ReportDocumentFileDO entity = reportDocumentFileService.getByQueryVO(vo);
|
||||
if(entity == null){
|
||||
vo.setType("");
|
||||
entity = reportDocumentFileService.getByQueryVO(vo);
|
||||
}
|
||||
ReportDocumentFileDO entity = reportDocumentFileService.getByMainIdAndVersion(mainId, version);
|
||||
if(entity == null){
|
||||
return CommonResult.success(null);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,34 @@
|
||||
package com.zt.plat.module.qms.business.reportdoc.listener;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.zt.plat.framework.common.enums.UserTypeEnum;
|
||||
import com.zt.plat.framework.security.core.LoginUser;
|
||||
import com.zt.plat.framework.web.core.util.WebFrameworkUtils;
|
||||
import com.zt.plat.module.qms.business.reportdoc.service.ReportDocumentAssistService;
|
||||
import com.zt.plat.module.qms.business.reportdoc.service.ReportDocumentMainService;
|
||||
import com.zt.plat.module.qms.common.dic.controller.vo.DictionaryBusinessRespVO;
|
||||
import com.zt.plat.module.qms.common.dic.dal.dataobject.DictionaryBusinessDO;
|
||||
import com.zt.plat.module.qms.common.dic.service.DictionaryBusinessService;
|
||||
import com.zt.plat.module.system.api.permission.RoleApi;
|
||||
import com.zt.plat.module.system.mq.iwork.IWorkBizCallbackMessage;
|
||||
import com.zt.plat.module.system.mq.iwork.IWorkBizCallbackResultMessage;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
||||
import org.apache.rocketmq.spring.core.RocketMQListener;
|
||||
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@@ -27,6 +43,7 @@ public class IWorkBizCallbackListener implements RocketMQListener<IWorkBizCallba
|
||||
|
||||
@Resource private ReportDocumentAssistService reportDocumentAssistService;
|
||||
@Resource private ReportDocumentMainService reportDocumentMainService;
|
||||
@Resource private DictionaryBusinessService dictionaryBusinessService;
|
||||
@Override
|
||||
public void onMessage(IWorkBizCallbackMessage message) {
|
||||
log.info("收到 iWork 回调: requestId={}", message.getRequestId());
|
||||
@@ -34,6 +51,8 @@ public class IWorkBizCallbackListener implements RocketMQListener<IWorkBizCallba
|
||||
|
||||
IWorkBizCallbackResultMessage result;
|
||||
try {
|
||||
LoginUser loginUser = initLoginUser();
|
||||
setLoginUser(loginUser);
|
||||
// 处理业务逻辑
|
||||
processCallback(message);
|
||||
|
||||
@@ -62,6 +81,47 @@ public class IWorkBizCallbackListener implements RocketMQListener<IWorkBizCallba
|
||||
rocketMQTemplate.syncSend(IWorkBizCallbackResultMessage.TOPIC, result);
|
||||
}
|
||||
|
||||
private LoginUser initLoginUser(){
|
||||
|
||||
DictionaryBusinessRespVO dicDO = dictionaryBusinessService.getDataByDataKey("report_doc_iwork_conf").getData();
|
||||
if(dicDO == null || ObjectUtils.isEmpty(dicDO.getCustomConfig())){
|
||||
String msg = "业务参数字典缺少用印iwork配置,配置key:report_doc_iwork_conf";
|
||||
log.error(msg);
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
String report_doc_iwork_conf = dicDO.getCustomConfig();
|
||||
JSONObject jsonObject = JSONObject.parseObject(report_doc_iwork_conf);
|
||||
|
||||
LoginUser loginUser = new LoginUser();
|
||||
loginUser.setId(jsonObject.getLong("qms_user_id"));
|
||||
loginUser.setUserType(UserTypeEnum.ADMIN.getValue());
|
||||
loginUser.setTenantId(jsonObject.getLong("qms_tenant_id"));
|
||||
loginUser.setExpiresTime(LocalDateTime.now().plusHours(1));
|
||||
|
||||
//设置用户信息
|
||||
Map<String, String> info = new HashMap<>();
|
||||
info.put(LoginUser.INFO_KEY_NICKNAME, jsonObject.getString("qms_user_name"));
|
||||
info.put(LoginUser.INFO_KEY_TENANT_ID, jsonObject.getString("qms_tenant_id"));
|
||||
loginUser.setInfo( info);
|
||||
return loginUser;
|
||||
}
|
||||
|
||||
|
||||
private void setLoginUser(LoginUser loginUser){
|
||||
//设置到Spring Security上下文
|
||||
Authentication authentication = new UsernamePasswordAuthenticationToken(loginUser, null, Collections.emptyList());
|
||||
SecurityContextHolder.getContext().setAuthentication(authentication);
|
||||
|
||||
//设置到web请求上下文,供DefaultDBFieldHandler使用
|
||||
HttpServletRequest request = WebFrameworkUtils.getRequest();
|
||||
if(request != null){
|
||||
WebFrameworkUtils.setLoginUserId(request, loginUser.getId());
|
||||
WebFrameworkUtils.setLoginUserType(request, loginUser.getUserType());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 处理报告用印iwork回调逻辑
|
||||
* 1. 解析 payload 获取回调数据
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.zt.plat.module.qms.business.reportdoc.service;
|
||||
|
||||
/**
|
||||
* 动态报表数据接口
|
||||
* */
|
||||
public interface DynamicReportDataService {
|
||||
}
|
||||
@@ -22,6 +22,8 @@ import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentTy
|
||||
import com.zt.plat.module.qms.business.reportdoc.listener.ReportDocListenerConstant;
|
||||
import com.zt.plat.module.qms.common.data.dal.dataobject.DataTemplateDO;
|
||||
import com.zt.plat.module.qms.common.data.service.DataTemplateService;
|
||||
import com.zt.plat.module.qms.common.dic.controller.vo.DictionaryBusinessRespVO;
|
||||
import com.zt.plat.module.qms.common.dic.service.DictionaryBusinessService;
|
||||
import com.zt.plat.module.system.api.iwork.IWorkIntegrationApi;
|
||||
import com.zt.plat.module.system.api.iwork.dto.IWorkOperationRespDTO;
|
||||
import com.zt.plat.module.system.api.iwork.dto.IWorkWorkflowCreateReqDTO;
|
||||
@@ -60,7 +62,7 @@ public class ReportDocumentAssistService {
|
||||
@Resource private DataTemplateService dataTemplateService;
|
||||
@Resource private FileApi fileApi;
|
||||
@Resource private BusinessFileApi businessFileApi;
|
||||
|
||||
@Resource private DictionaryBusinessService dictionaryBusinessService;
|
||||
// private String sequenceKey = "QMS_REPORT_IWORK_CODE";
|
||||
|
||||
// todo 判断是否更新pdf
|
||||
@@ -100,12 +102,20 @@ public class ReportDocumentAssistService {
|
||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
IWorkWorkflowCreateReqDTO dto = new IWorkWorkflowCreateReqDTO();
|
||||
|
||||
String operatorUserId = "455"; //iWork 操作人用户编号
|
||||
String jbr = "455"; //用印申请人
|
||||
String yybm = "1055"; //用印部门
|
||||
String fb = "170"; //用印单位
|
||||
|
||||
DictionaryBusinessRespVO dicVo = dictionaryBusinessService.getDataByDataKey("report_doc_iwork_conf").getData();
|
||||
String report_doc_iwork_conf = "";
|
||||
if(dicVo != null)
|
||||
report_doc_iwork_conf = dicVo.getCustomConfig();
|
||||
if(ObjectUtils.isEmpty(report_doc_iwork_conf)){
|
||||
String msg = "业务参数字典缺少用印iwork配置,配置key:report_doc_iwork_conf";
|
||||
log.error(msg);
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
JSONObject jsonObject = JSONObject.parseObject(report_doc_iwork_conf);
|
||||
String operatorUserId = jsonObject.getString("iwork_operatorUserId"); //iWork 操作人用户编号
|
||||
String jbr = jsonObject.getString("iwork_jbr"); //用印申请人
|
||||
String yybm = jsonObject.getString("iwork_yybm"); //用印部门
|
||||
String fb = jsonObject.getString("iwork_fb"); //用印单位
|
||||
|
||||
dto.setOperatorUserId(operatorUserId);
|
||||
dto.setJbr(jbr);
|
||||
|
||||
@@ -16,7 +16,7 @@ import com.zt.plat.framework.common.pojo.PageResult;
|
||||
*/
|
||||
public interface ReportDocumentFileService {
|
||||
|
||||
ReportDocumentFileDO getByMainIdAndVersion(Long mainId, Integer version);
|
||||
ReportDocumentFileDO getByQueryVO(ReportDocumentFileSaveReqVO vo);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,10 +35,14 @@ public class ReportDocumentFileServiceImpl implements ReportDocumentFileService
|
||||
|
||||
|
||||
@Override
|
||||
public ReportDocumentFileDO getByMainIdAndVersion(Long mainId, Integer version) {
|
||||
public ReportDocumentFileDO getByQueryVO(ReportDocumentFileSaveReqVO vo) {
|
||||
LambdaQueryWrapper<ReportDocumentFileDO> query = new LambdaQueryWrapper<>();
|
||||
query.eq(ReportDocumentFileDO::getMainId, mainId);
|
||||
query.eq(ReportDocumentFileDO::getVersion, version);
|
||||
if(vo.getMainId() != null)
|
||||
query.eq(ReportDocumentFileDO::getMainId, vo.getMainId());
|
||||
if(vo.getType() != null)
|
||||
query.eq(ReportDocumentFileDO::getType, vo.getType());
|
||||
if(vo.getVersion() != null)
|
||||
query.eq(ReportDocumentFileDO::getVersion, vo.getVersion());
|
||||
query.orderByDesc(ReportDocumentFileDO::getCreateTime);
|
||||
query.last("LIMIT 1");
|
||||
return reportDocumentFileMapper.selectOne(query);
|
||||
|
||||
@@ -73,6 +73,7 @@ public interface ReportDocumentMainService {
|
||||
* @return 检测报告业务
|
||||
*/
|
||||
ReportDocumentMainDO getReportDocumentMain(Long id);
|
||||
|
||||
ReportDocumentMainDO getByCode(String code);
|
||||
|
||||
/**
|
||||
@@ -89,5 +90,5 @@ public interface ReportDocumentMainService {
|
||||
|
||||
void testAsyncTask(Long id);
|
||||
|
||||
public CommonResult<String> execCallBackByIwork(IWorkBizCallbackMessage message);
|
||||
CommonResult<String> execCallBackByIwork(IWorkBizCallbackMessage message);
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.framework.datapermission.core.annotation.DeptDataPermissionIgnore;
|
||||
import com.zt.plat.framework.security.core.LoginUser;
|
||||
import com.zt.plat.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import com.zt.plat.module.bpm.api.task.BpmProcessInstanceApi;
|
||||
@@ -63,6 +64,7 @@ import static com.zt.plat.module.qms.enums.QmsBpmConstant.BPM_CALLBACK_BEAN_NAME
|
||||
@Service("reportDocumentMainService")
|
||||
@Validated
|
||||
@Slf4j
|
||||
@DeptDataPermissionIgnore(enable = "true")
|
||||
public class ReportDocumentMainServiceImpl implements ReportDocumentMainService, BMPCallbackInterface {
|
||||
|
||||
@Resource private ReportDocumentMainMapper reportDocumentMainMapper;
|
||||
@@ -641,7 +643,7 @@ public class ReportDocumentMainServiceImpl implements ReportDocumentMainService,
|
||||
if(taskList.isEmpty())
|
||||
throw exception0(ERROR_CODE_MODULE_COMMON, "流程任务查询失败,请联系管理员处理");
|
||||
String taskId = taskList.get(taskList.size() - 1).getId();
|
||||
//驳回后重新提交
|
||||
//提交流程
|
||||
BpmTaskApproveReqDTO reqVO = new BpmTaskApproveReqDTO();
|
||||
reqVO.setId(taskId);
|
||||
CommonResult<Boolean> result = bpmProcessInstanceApi.approveTask(reqVO);
|
||||
|
||||
Reference in New Issue
Block a user