feat:报告-与流程对接
This commit is contained in:
@@ -11,16 +11,11 @@ import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.framework.excel.core.util.ExcelUtils;
|
||||
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;
|
||||
import com.zt.plat.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.controller.vo.*;
|
||||
import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentMainDO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentTypeDO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.service.ReportDocumentMainService;
|
||||
import com.zt.plat.module.qms.business.reportdoc.service.ReportDocumentTypeService;
|
||||
import com.zt.plat.module.qms.enums.ErrorCodeConstants;
|
||||
import com.zt.plat.module.qms.enums.QmsCommonConstant;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
@@ -29,23 +24,16 @@ import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception0;
|
||||
import static com.zt.plat.framework.common.pojo.CommonResult.error;
|
||||
import static com.zt.plat.framework.common.pojo.CommonResult.success;
|
||||
import static com.zt.plat.module.qms.enums.ErrorCodeConstants.ERROR_CODE_MODULE_COMMON;
|
||||
import static com.zt.plat.module.qms.enums.ErrorCodeConstants.REPORT_DOCUMENT_TYPE_NOT_EXISTS;
|
||||
import static com.zt.plat.module.qms.enums.QmsBpmConstant.BPM_CALLBACK_BEAN_NAME;
|
||||
|
||||
@Tag(name = "管理后台 - 检测报告业务")
|
||||
@RestController
|
||||
@@ -65,7 +53,7 @@ public class ReportDocumentMainController extends AbstractFileUploadController i
|
||||
@Resource private ReportDocumentTypeService reportDocumentTypeService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建检测报告业务")
|
||||
@Operation(summary = "创建检测报告")
|
||||
@PreAuthorize("@ss.hasPermission('qms:report-document-main:create')")
|
||||
public CommonResult<ReportDocumentMainRespVO> createReportDocumentMain(@Valid @RequestBody ReportDocumentMainSaveReqVO createReqVO) {
|
||||
return success(reportDocumentMainService.createReportDocumentMain(createReqVO));
|
||||
@@ -91,44 +79,11 @@ public class ReportDocumentMainController extends AbstractFileUploadController i
|
||||
return success(reportDocumentMainService.createReportDocumentMain(vo));
|
||||
}
|
||||
|
||||
// @Resource private BpmProcessInstanceApi bpmProcessInstanceApi;
|
||||
// @Override
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
// public CommonResult<ReportDocumentMainRespVO> createProcessInstance(ReportDocumentMainSaveReqVO entity) {
|
||||
// LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
// Long id = entity.getId();
|
||||
// DataFormDO dataForm = getDataForm(id);
|
||||
// Long dataCollectionId = dataForm.getDataCollectionId();
|
||||
// DataCollectionDO dataCollection = dataCollectionService.getDataCollection(dataCollectionId);
|
||||
// if(dataCollection == null)
|
||||
// throw exception(ErrorCodeConstants.DATA_FORM_EMPTY_COLLECTION_ID);
|
||||
// if(ObjectUtils.isEmpty(dataCollection.getFlowKey()))
|
||||
// throw exception(ErrorCodeConstants.DATA_COLLECTION_EMPTY_WF_KEY);
|
||||
// JSONObject formData = new JSONObject();
|
||||
// if(dataForm.getFormData() != null)
|
||||
// formData = JSONObject.parseObject(dataForm.getFormData());
|
||||
// formData.put("mainId", id);
|
||||
// formData.put("applyUser", dataForm.getApplyUser());
|
||||
// formData.put("applyUserId", dataForm.getApplyUserId());
|
||||
// formData.put("applyDepartment", dataForm.getApplyDepartment());
|
||||
// formData.put("applyDepartmentId", dataForm.getApplyDepartmentId());
|
||||
// formData.put("applyTime", dataForm.getApplyTime());
|
||||
// Map<String, Object> variables = formData.toJavaObject(Map.class);
|
||||
// variables.put(BPM_CALLBACK_BEAN_NAME, "dataFormService");
|
||||
// BpmProcessInstanceCreateReqDTO reqDTO = new BpmProcessInstanceCreateReqDTO();
|
||||
// reqDTO.setBusinessKey(String.valueOf(id));
|
||||
// reqDTO.setProcessDefinitionKey(dataCollection.getFlowKey());
|
||||
// reqDTO.setVariables(variables);
|
||||
// CommonResult<String> result = bpmProcessInstanceApi.createProcessInstance(loginUser.getId(), reqDTO);
|
||||
// if(!result.isSuccess()){
|
||||
// throw exception0(ERROR_CODE_MODULE_COMMON, result.getMsg());
|
||||
// }
|
||||
// String wfInsId = result.getData();
|
||||
// dataForm.setFlowInstanceId(wfInsId);
|
||||
// dataFormMapper.updateById(dataForm);
|
||||
// return BeanUtils.toBean(dataForm, DataFormRespVO.class);
|
||||
// }
|
||||
|
||||
@PostMapping("/createProcessInstance")
|
||||
@Operation(summary = "发起流程")
|
||||
public CommonResult<ReportDocumentMainRespVO> createProcessInstance(@Valid @RequestBody ReportDocumentMainSaveReqVO createReqVO) {
|
||||
return reportDocumentMainService.createProcessInstance(createReqVO);
|
||||
}
|
||||
|
||||
@PostMapping("/execAddData")
|
||||
@Operation(summary = "增加数据")
|
||||
@@ -146,6 +101,7 @@ public class ReportDocumentMainController extends AbstractFileUploadController i
|
||||
@Operation(summary = "更新检测报告业务")
|
||||
@PreAuthorize("@ss.hasPermission('qms:report-document-main:update')")
|
||||
public CommonResult<Boolean> updateReportDocumentMain(@Valid @RequestBody ReportDocumentMainSaveReqVO updateReqVO) {
|
||||
updateReqVO.setCancelFlag("0");
|
||||
reportDocumentMainService.updateReportDocumentMain(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import static com.zt.plat.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH
|
||||
public class ReportDocumentMainPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "流程实例ID", example = "10765")
|
||||
private Long flowInstanceId;
|
||||
private String flowInstanceId;
|
||||
|
||||
@Schema(description = "报告类型ID", example = "2124")
|
||||
private Long reportDocumentTypeId;
|
||||
|
||||
@@ -19,7 +19,7 @@ public class ReportDocumentMainRespVO {
|
||||
|
||||
@Schema(description = "流程实例ID", example = "10765")
|
||||
@ExcelProperty("流程实例ID")
|
||||
private Long flowInstanceId;
|
||||
private String flowInstanceId;
|
||||
|
||||
@Schema(description = "报告类型ID", example = "2124")
|
||||
@ExcelProperty("报告类型ID")
|
||||
|
||||
@@ -15,7 +15,7 @@ public class ReportDocumentMainSaveReqVO {
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "流程实例ID", example = "10765")
|
||||
private Long flowInstanceId;
|
||||
private String flowInstanceId;
|
||||
|
||||
@Schema(description = "报告类型ID", example = "2124")
|
||||
private Long reportDocumentTypeId;
|
||||
|
||||
@@ -35,7 +35,7 @@ public class ReportDocumentMainDO extends BusinessBaseDO {
|
||||
* 流程实例ID
|
||||
*/
|
||||
@TableField("FLW_INSC_ID")
|
||||
private Long flowInstanceId;
|
||||
private String flowInstanceId;
|
||||
/**
|
||||
* 报告类型ID
|
||||
*/
|
||||
|
||||
@@ -1,41 +1,57 @@
|
||||
package com.zt.plat.module.qms.business.reportdoc.service;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
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.security.core.LoginUser;
|
||||
import com.zt.plat.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import com.zt.plat.module.bpm.api.task.BpmProcessInstanceApi;
|
||||
import com.zt.plat.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
|
||||
import com.zt.plat.module.qms.api.task.BMPCallbackInterface;
|
||||
import com.zt.plat.module.qms.api.task.dto.QmsBpmDTO;
|
||||
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayReportDataDO;
|
||||
import com.zt.plat.module.qms.business.bus.service.BusinessAssayReportDataService;
|
||||
import com.zt.plat.module.qms.business.reportdoc.controller.vo.*;
|
||||
import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentDataDO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.dal.mapper.ReportDocumentMainMapper;
|
||||
import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentMainDO;
|
||||
import com.zt.plat.module.qms.core.constant.CommonConstant;
|
||||
import com.zt.plat.module.qms.enums.ErrorCodeConstants;
|
||||
import com.zt.plat.module.qms.enums.QmsBpmConstant;
|
||||
import com.zt.plat.module.qms.enums.QmsCommonConstant;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception0;
|
||||
import static com.zt.plat.framework.common.pojo.CommonResult.error;
|
||||
import static com.zt.plat.module.qms.enums.ErrorCodeConstants.*;
|
||||
import static com.zt.plat.module.qms.enums.QmsBpmConstant.BPM_CALLBACK_BEAN_NAME;
|
||||
|
||||
/**
|
||||
* 检测报告业务 Service 实现类
|
||||
*
|
||||
* @author 后台管理
|
||||
*/
|
||||
@Service
|
||||
@Service("reportDocumentMainService")
|
||||
@Validated
|
||||
public class ReportDocumentMainServiceImpl implements ReportDocumentMainService {
|
||||
public class ReportDocumentMainServiceImpl implements ReportDocumentMainService, BMPCallbackInterface {
|
||||
|
||||
@Resource private ReportDocumentMainMapper reportDocumentMainMapper;
|
||||
@Resource private BusinessAssayReportDataService businessAssayReportDataService;
|
||||
@Resource private ReportDocumentDataService reportDocumentDataService;
|
||||
|
||||
@Resource private BpmProcessInstanceApi bpmProcessInstanceApi;
|
||||
/***
|
||||
* 增加报表数据
|
||||
* 传入:报告id、 报表数据ids
|
||||
@@ -172,7 +188,65 @@ public class ReportDocumentMainServiceImpl implements ReportDocumentMainService
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<ReportDocumentMainRespVO> createProcessInstance(ReportDocumentMainSaveReqVO entity) {
|
||||
return null;
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CommonResult<ReportDocumentMainRespVO> createProcessInstance(ReportDocumentMainSaveReqVO param) {
|
||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
//当前登录用户昵称
|
||||
String nickName = SecurityFrameworkUtils.getLoginUserNickname();
|
||||
Long id = param.getId();
|
||||
ReportDocumentMainDO entity = getReportDocumentMain(id);
|
||||
JSONObject formData = new JSONObject();
|
||||
if(entity.getFormData() != null)
|
||||
formData = JSONObject.parseObject(entity.getFormData());
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
formData.put("mainId", id);
|
||||
formData.put("applyUser", nickName);
|
||||
formData.put("applyUserId", loginUser.getId());
|
||||
formData.put("applyDepartment", loginUser.getVisitDeptName());
|
||||
formData.put("applyDepartmentId", loginUser.getVisitDeptId());
|
||||
formData.put("applyTime", sdf.format(new Date()));
|
||||
Map<String, Object> variables = formData.toJavaObject(Map.class);
|
||||
variables.put(BPM_CALLBACK_BEAN_NAME, "reportDocumentMainService"); //流程回调时使用的service
|
||||
BpmProcessInstanceCreateReqDTO reqDTO = new BpmProcessInstanceCreateReqDTO();
|
||||
reqDTO.setBusinessKey(String.valueOf(id));
|
||||
reqDTO.setProcessDefinitionKey(entity.getFlowKey());
|
||||
reqDTO.setVariables(variables);
|
||||
CommonResult<String> result = bpmProcessInstanceApi.createProcessInstance(loginUser.getId(), reqDTO);
|
||||
if(!result.isSuccess()){
|
||||
throw exception0(ERROR_CODE_MODULE_COMMON, result.getMsg());
|
||||
}
|
||||
String wfInsId = result.getData();
|
||||
entity.setFlowInstanceId(wfInsId);
|
||||
entity.setFlowStatus(QmsCommonConstant.IN_PROGRESS);
|
||||
reportDocumentMainMapper.updateById(entity);
|
||||
ReportDocumentMainRespVO respVO = BeanUtils.toBean(entity, ReportDocumentMainRespVO.class);
|
||||
return CommonResult.success(respVO);
|
||||
}
|
||||
|
||||
//流程回调
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CommonResult<JSONObject> callback(QmsBpmDTO reqDTO) {
|
||||
JSONObject variables = reqDTO.getVariables();
|
||||
//流程状态 3-拒绝 1-通过 2-完成
|
||||
String PROCESS_STATUS = variables.getString(QmsBpmConstant.PROCESS_INSTANCE_VARIABLE_STATUS);
|
||||
String mainId = variables.getString("mainId");
|
||||
ReportDocumentMainDO entity = getReportDocumentMain(Long.valueOf(mainId));
|
||||
if("3".equals(PROCESS_STATUS)){
|
||||
//驳回
|
||||
entity.setFlowStatus(QmsCommonConstant.REJECT);
|
||||
}
|
||||
if("2".equals(PROCESS_STATUS)){
|
||||
//完成
|
||||
entity.setFlowStatus(QmsCommonConstant.COMPLETED);
|
||||
}
|
||||
//todo 处理意见和签名
|
||||
|
||||
reportDocumentMainMapper.updateById(entity);
|
||||
JSONObject ret = new JSONObject();
|
||||
|
||||
|
||||
return CommonResult.success(ret);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user