Compare commits
2 Commits
33543e5330
...
468e939ab1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
468e939ab1 | ||
|
|
90b0aa5202 |
@@ -140,6 +140,7 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode REPORT_DOCUMENT_DATA_NOT_EXISTS = new ErrorCode(1_032_100_000, "检测报告明细不存在");
|
||||
ErrorCode REPORT_DOCUMENT_TYPE_NOT_EXISTS = new ErrorCode(1_032_100_000, "报告类型配置不存在");
|
||||
ErrorCode REPORT_DOCUMENT_MAIN_CORRELATION_NOT_EXISTS = new ErrorCode(1_032_100_000, "报告主数据关系不存在");
|
||||
ErrorCode REPORT_DOCUMENT_FILE_NOT_EXISTS = new ErrorCode(1_032_100_000, "检测报告附件不存在");
|
||||
|
||||
ErrorCode BUSINESS_SAMPLE_DISPATCH_NOT_EXISTS = new ErrorCode(1_032_100_000, "样品调拨不存在");
|
||||
ErrorCode BUSINESS_SAMPLE_DISPATCH_DETAIL_NOT_EXISTS = new ErrorCode(1_032_100_000, "样品调拨明细不存在");
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.zt.plat.module.qms.business.reportdoc.async;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Configuration
|
||||
@EnableAsync
|
||||
public class AsyncConfig {
|
||||
@Bean("asyncTaskExecutor")
|
||||
public Executor asyncTaskExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
executor.setCorePoolSize(5);
|
||||
executor.setMaxPoolSize(10);
|
||||
executor.setQueueCapacity(100);
|
||||
executor.setThreadNamePrefix("Async-");
|
||||
executor.initialize();
|
||||
return executor;
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentTy
|
||||
import com.zt.plat.module.qms.business.reportdoc.service.ReportDocumentDataService;
|
||||
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.common.data.service.DataTemplateService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.zt.plat.module.qms.business.reportdoc.controller.admin;
|
||||
|
||||
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 org.springframework.web.bind.annotation.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import com.zt.plat.framework.business.interceptor.BusinessControllerMarker;
|
||||
import com.zt.plat.framework.business.annotation.FileUploadController;
|
||||
import com.zt.plat.framework.business.controller.AbstractFileUploadController;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import jakarta.validation.*;
|
||||
import jakarta.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO;
|
||||
import com.zt.plat.framework.common.pojo.PageParam;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import static com.zt.plat.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import com.zt.plat.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import com.zt.plat.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentFileDO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.service.ReportDocumentFileService;
|
||||
|
||||
@Tag(name = "管理后台 - 检测报告附件")
|
||||
@RestController
|
||||
@RequestMapping("/qms/report-document-file")
|
||||
@Validated
|
||||
@FileUploadController(source = "qms.reportdocumentfile")
|
||||
public class ReportDocumentFileController extends AbstractFileUploadController implements BusinessControllerMarker{
|
||||
|
||||
static {
|
||||
FileUploadController annotation = ReportDocumentFileController.class.getAnnotation(FileUploadController.class);
|
||||
if (annotation != null) {
|
||||
setFileUploadInfo(annotation);
|
||||
}
|
||||
}
|
||||
|
||||
@Resource
|
||||
private ReportDocumentFileService reportDocumentFileService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建检测报告附件")
|
||||
@PreAuthorize("@ss.hasPermission('qms:report-document-file:create')")
|
||||
public CommonResult<ReportDocumentFileRespVO> createReportDocumentFile(@Valid @RequestBody ReportDocumentFileSaveReqVO createReqVO) {
|
||||
return success(reportDocumentFileService.createReportDocumentFile(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新检测报告附件")
|
||||
@PreAuthorize("@ss.hasPermission('qms:report-document-file:update')")
|
||||
public CommonResult<Boolean> updateReportDocumentFile(@Valid @RequestBody ReportDocumentFileSaveReqVO updateReqVO) {
|
||||
reportDocumentFileService.updateReportDocumentFile(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除检测报告附件")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('qms:report-document-file:delete')")
|
||||
public CommonResult<Boolean> deleteReportDocumentFile(@RequestParam("id") Long id) {
|
||||
reportDocumentFileService.deleteReportDocumentFile(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete-list")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@Operation(summary = "批量删除检测报告附件")
|
||||
@PreAuthorize("@ss.hasPermission('qms:report-document-file:delete')")
|
||||
public CommonResult<Boolean> deleteReportDocumentFileList(@RequestBody BatchDeleteReqVO req) {
|
||||
reportDocumentFileService.deleteReportDocumentFileListByIds(req.getIds());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得检测报告附件")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('qms:report-document-file:query')")
|
||||
public CommonResult<ReportDocumentFileRespVO> getReportDocumentFile(@RequestParam("id") Long id) {
|
||||
ReportDocumentFileDO reportDocumentFile = reportDocumentFileService.getReportDocumentFile(id);
|
||||
return success(BeanUtils.toBean(reportDocumentFile, ReportDocumentFileRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得检测报告附件分页")
|
||||
@PreAuthorize("@ss.hasPermission('qms:report-document-file:query')")
|
||||
public CommonResult<PageResult<ReportDocumentFileRespVO>> getReportDocumentFilePage(@Valid ReportDocumentFilePageReqVO pageReqVO) {
|
||||
PageResult<ReportDocumentFileDO> pageResult = reportDocumentFileService.getReportDocumentFilePage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, ReportDocumentFileRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出检测报告附件 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('qms:report-document-file:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportReportDocumentFileExcel(@Valid ReportDocumentFilePageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<ReportDocumentFileDO> list = reportDocumentFileService.getReportDocumentFilePage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "检测报告附件.xls", "数据", ReportDocumentFileRespVO.class,
|
||||
BeanUtils.toBean(list, ReportDocumentFileRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,26 +14,27 @@ import com.zt.plat.framework.excel.core.util.ExcelUtils;
|
||||
import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigUserSignatureDO;
|
||||
import com.zt.plat.module.qms.business.config.service.ConfigUserSignatureService;
|
||||
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.dataobject.ReportDocumentMainDO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentTypeDO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.service.ReportDocumentDataService;
|
||||
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.common.data.dal.dataobject.DataTemplateDO;
|
||||
import com.zt.plat.module.qms.common.data.service.DataTemplateService;
|
||||
import com.zt.plat.module.qms.enums.QmsCommonConstant;
|
||||
import com.zt.plat.module.system.api.iwork.dto.IWorkOperationRespDTO;
|
||||
import com.zt.plat.module.system.api.iwork.dto.IWorkWorkflowCreateReqDTO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
@@ -59,6 +60,19 @@ public class ReportDocumentMainController extends AbstractFileUploadController i
|
||||
@Resource private ReportDocumentDataService reportDocumentDataService;
|
||||
@Resource private ReportDocumentTypeService reportDocumentTypeService;
|
||||
@Resource private ConfigUserSignatureService configUserSignatureService;
|
||||
@Resource private DataTemplateService dataTemplateService;
|
||||
|
||||
@RequestMapping("/testAsyncTask")
|
||||
public CommonResult<String> testAsyncTask(@RequestParam Long id) {
|
||||
ReportDocumentMainSaveReqVO reqVO = new ReportDocumentMainSaveReqVO();
|
||||
reqVO.setId(id);
|
||||
reqVO.setFlowStatus("async");
|
||||
reportDocumentMainService.updateReportDocumentMain(reqVO);
|
||||
|
||||
reportDocumentMainService.testAsyncTask(id);
|
||||
return CommonResult.success("success");
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建检测报告")
|
||||
@@ -78,6 +92,11 @@ public class ReportDocumentMainController extends AbstractFileUploadController i
|
||||
if(typeDO == null){
|
||||
return error(REPORT_DOCUMENT_TYPE_NOT_EXISTS, "报告类型不存在,请刷新后重试");
|
||||
}
|
||||
String dataTemplateKey = typeDO.getReportKey();
|
||||
DataTemplateDO dataTemplateDO = dataTemplateService.getLatestDataByKey(dataTemplateKey);
|
||||
if(dataTemplateDO == null)
|
||||
return error(REPORT_DOCUMENT_TYPE_NOT_EXISTS, "表单编辑器模板不存在,请联系管理员处理");
|
||||
vo.setDataTemplateId(dataTemplateDO.getId());
|
||||
vo.setDocumentTitle(typeDO.getName());
|
||||
vo.setFlowKey(typeDO.getFlowKey());
|
||||
vo.setDocumentType(typeDO.getDocumentType());
|
||||
@@ -235,4 +254,23 @@ public class ReportDocumentMainController extends AbstractFileUploadController i
|
||||
ExcelUtils.write(response, "检测报告业务.xls", "数据", ReportDocumentMainRespVO.class, list);
|
||||
}
|
||||
|
||||
@GetMapping("/testCreateIworkWorkflow")
|
||||
@Operation(summary = "测试发起iwork流程")
|
||||
//@PreAuthorize("@ss.hasPermission('qms:report-document-main:query')")
|
||||
public CommonResult<IWorkOperationRespDTO> createIworkWorkflow() {
|
||||
IWorkWorkflowCreateReqDTO req = new IWorkWorkflowCreateReqDTO();
|
||||
req.setJbr("1001");
|
||||
req.setYybm("2001");
|
||||
req.setFb("3001");
|
||||
req.setSqsj("2025-01-01");
|
||||
req.setYyqx("对外邮寄");
|
||||
// req.setYyfkUrl("https://files.example.com/evidence.pdf");
|
||||
req.setYysy("与客户合同用印");
|
||||
req.setXyywjUrl("http://172.16.46.63:30002/yudao/20251204/%E6%B5%8B%E8%AF%95pdf_1764818842846.pdf?response-cache-control=no-cache%2C%20no-store%2C%20must-revalidate&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20251209T093343Z&X-Amz-SignedHeaders=host&X-Amz-Credential=EKplIEnbNgfYBAZbEJNa%2F20251209%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Expires=86400&X-Amz-Signature=37d63249667ea855f9a51bdf47bbb044d5860c302721f52fff2ba644985bae4c");
|
||||
req.setYysx("检测报告用印");
|
||||
req.setYwxtdjbh("JY-20251209-0001");
|
||||
// CommonResult<IWorkOperationRespDTO> ret = reportDocumentMainService.createIWorkflow(req);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.zt.plat.module.qms.business.reportdoc.controller.vo;
|
||||
|
||||
import lombok.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import com.zt.plat.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static com.zt.plat.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 检测报告附件分页 Request VO")
|
||||
@Data
|
||||
public class ReportDocumentFilePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "报告id", example = "20899")
|
||||
private Long mainId;
|
||||
|
||||
@Schema(description = "文件表ID", example = "25498")
|
||||
private Long fileId;
|
||||
|
||||
@Schema(description = "文件名称", example = "李四")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "路径")
|
||||
private String path;
|
||||
|
||||
@Schema(description = "文件地址", example = "https://www.iocoder.cn")
|
||||
private String url;
|
||||
|
||||
@Schema(description = "文件类型", example = "1")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "版本")
|
||||
private Integer version;
|
||||
|
||||
@Schema(description = "所属部门")
|
||||
private String systemDepartmentCode;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.zt.plat.module.qms.business.reportdoc.controller.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 检测报告附件 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class ReportDocumentFileRespVO {
|
||||
|
||||
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "29698")
|
||||
@ExcelProperty("ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "报告id", example = "20899")
|
||||
@ExcelProperty("报告id")
|
||||
private Long mainId;
|
||||
|
||||
@Schema(description = "文件表ID", example = "25498")
|
||||
@ExcelProperty("文件表ID")
|
||||
private Long fileId;
|
||||
|
||||
@Schema(description = "文件名称", example = "李四")
|
||||
@ExcelProperty("文件名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "路径")
|
||||
@ExcelProperty("路径")
|
||||
private String path;
|
||||
|
||||
@Schema(description = "文件地址", example = "https://www.iocoder.cn")
|
||||
@ExcelProperty("文件地址")
|
||||
private String url;
|
||||
|
||||
@Schema(description = "文件类型", example = "1")
|
||||
@ExcelProperty("文件类型")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "版本")
|
||||
@ExcelProperty("版本")
|
||||
private Integer version;
|
||||
|
||||
@Schema(description = "所属部门")
|
||||
@ExcelProperty("所属部门")
|
||||
private String systemDepartmentCode;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "备注")
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.zt.plat.module.qms.business.reportdoc.controller.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
@Schema(description = "管理后台 - 检测报告附件新增/修改 Request VO")
|
||||
@Data
|
||||
public class ReportDocumentFileSaveReqVO {
|
||||
|
||||
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "29698")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "报告id", example = "20899")
|
||||
private Long mainId;
|
||||
|
||||
@Schema(description = "文件表ID", example = "25498")
|
||||
private Long fileId;
|
||||
|
||||
@Schema(description = "文件名称", example = "李四")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "路径")
|
||||
private String path;
|
||||
|
||||
@Schema(description = "文件地址", example = "https://www.iocoder.cn")
|
||||
private String url;
|
||||
|
||||
@Schema(description = "文件类型", example = "1")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "版本")
|
||||
private Integer version;
|
||||
|
||||
@Schema(description = "所属部门")
|
||||
private String systemDepartmentCode;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -88,4 +88,10 @@ public class ReportDocumentMainPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "表单设计器模板id")
|
||||
private Long dataTemplateId;
|
||||
|
||||
@Schema(description = "附件版本")
|
||||
private Integer documentVersion;
|
||||
|
||||
@Schema(description = "异步执行状态")
|
||||
private String executionStatus;
|
||||
}
|
||||
@@ -115,6 +115,13 @@ public class ReportDocumentMainRespVO {
|
||||
@ExcelProperty("表单设计器模板id")
|
||||
private Long dataTemplateId;
|
||||
|
||||
@Schema(description = "附件版本")
|
||||
@ExcelProperty("附件版本")
|
||||
private Integer documentVersion;
|
||||
|
||||
@Schema(description = "异步执行状态")
|
||||
@ExcelProperty("异步执行状态")
|
||||
private String executionStatus;
|
||||
//==============================扩展字段=======================================
|
||||
@Schema(description = "记录数")
|
||||
@ExcelProperty("记录数")
|
||||
|
||||
@@ -90,6 +90,11 @@ public class ReportDocumentMainSaveReqVO {
|
||||
@Schema(description = "表单设计器模板id")
|
||||
private Long dataTemplateId;
|
||||
|
||||
@Schema(description = "附件版本")
|
||||
private Integer documentVersion;
|
||||
|
||||
@Schema(description = "异步执行状态")
|
||||
private String executionStatus;
|
||||
|
||||
//====================附加属性==============================
|
||||
@Schema(description = "委托id,支持多值")
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.zt.plat.module.qms.business.reportdoc.dal.dataobject;
|
||||
|
||||
import lombok.*;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.zt.plat.framework.mybatis.core.dataobject.BusinessBaseDO;
|
||||
/**
|
||||
* 检测报告附件 DO
|
||||
*
|
||||
* @author 后台管理
|
||||
*/
|
||||
@TableName("t_rpt_doc_file")
|
||||
@KeySequence("t_rpt_doc_file_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
/**
|
||||
* 支持业务基类继承:isBusiness=true 时继承 BusinessBaseDO,否则继承 BaseDO
|
||||
*/
|
||||
public class ReportDocumentFileDO extends BusinessBaseDO {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
/**
|
||||
* 报告id
|
||||
*/
|
||||
@TableField("MAIN_ID")
|
||||
private Long mainId;
|
||||
/**
|
||||
* 文件表ID
|
||||
*/
|
||||
@TableField("FILE_ID")
|
||||
private Long fileId;
|
||||
/**
|
||||
* 文件名称
|
||||
*/
|
||||
@TableField("NAME")
|
||||
private String name;
|
||||
/**
|
||||
* 路径
|
||||
*/
|
||||
@TableField("PATH")
|
||||
private String path;
|
||||
/**
|
||||
* 文件地址
|
||||
*/
|
||||
@TableField("URL")
|
||||
private String url;
|
||||
/**
|
||||
* 文件类型
|
||||
*/
|
||||
@TableField("TP")
|
||||
private String type;
|
||||
/**
|
||||
* 版本
|
||||
*/
|
||||
@TableField("VER")
|
||||
private Integer version;
|
||||
/**
|
||||
* 所属部门
|
||||
*/
|
||||
@TableField("SYS_DEPT_CD")
|
||||
private String systemDepartmentCode;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@TableField("RMK")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -141,4 +141,12 @@ public class ReportDocumentMainDO extends BusinessBaseDO {
|
||||
//表单设计器模板id
|
||||
@TableField("DAT_TMPL_ID")
|
||||
private Long dataTemplateId;
|
||||
|
||||
//表单设计器模板id
|
||||
@TableField("DOC_VER")
|
||||
private Integer documentVersion;
|
||||
|
||||
//异步执行状态
|
||||
@TableField("EXC_STS")
|
||||
private String executionStatus;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.zt.plat.module.qms.business.reportdoc.dal.mapper;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.zt.plat.module.qms.business.reportdoc.controller.vo.ReportDocumentFilePageReqVO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentFileDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 检测报告附件 Mapper
|
||||
*
|
||||
* @author 后台管理
|
||||
*/
|
||||
@Mapper
|
||||
public interface ReportDocumentFileMapper extends BaseMapperX<ReportDocumentFileDO> {
|
||||
|
||||
default PageResult<ReportDocumentFileDO> selectPage(ReportDocumentFilePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<ReportDocumentFileDO>()
|
||||
.eqIfPresent(ReportDocumentFileDO::getMainId, reqVO.getMainId())
|
||||
.eqIfPresent(ReportDocumentFileDO::getFileId, reqVO.getFileId())
|
||||
.likeIfPresent(ReportDocumentFileDO::getName, reqVO.getName())
|
||||
.eqIfPresent(ReportDocumentFileDO::getPath, reqVO.getPath())
|
||||
.eqIfPresent(ReportDocumentFileDO::getUrl, reqVO.getUrl())
|
||||
.eqIfPresent(ReportDocumentFileDO::getType, reqVO.getType())
|
||||
.eqIfPresent(ReportDocumentFileDO::getVersion, reqVO.getVersion())
|
||||
.eqIfPresent(ReportDocumentFileDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
|
||||
.betweenIfPresent(ReportDocumentFileDO::getCreateTime, reqVO.getCreateTime())
|
||||
.eqIfPresent(ReportDocumentFileDO::getRemark, reqVO.getRemark())
|
||||
.orderByDesc(ReportDocumentFileDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
package com.zt.plat.module.qms.business.reportdoc.service;
|
||||
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.zt.plat.framework.common.exception.ServiceException;
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
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.infra.api.file.FileApi;
|
||||
import com.zt.plat.module.infra.api.file.dto.FileCreateReqDTO;
|
||||
import com.zt.plat.module.infra.api.file.dto.FileRespDTO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.controller.vo.ReportDocumentFileSaveReqVO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentFileDO;
|
||||
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.common.data.dal.dataobject.DataTemplateDO;
|
||||
import com.zt.plat.module.qms.common.data.service.DataTemplateService;
|
||||
import com.zt.plat.module.qms.core.code.SequenceUtil;
|
||||
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;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.compress.utils.IOUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.zt.plat.module.qms.enums.ErrorCodeConstants.REPORT_DOCUMENT_FILE_NOT_EXISTS;
|
||||
|
||||
/*
|
||||
* 处理报告附件和发起iwork流程
|
||||
* */
|
||||
@Service("reportDocumentAssistService")
|
||||
@Slf4j
|
||||
public class ReportDocumentAssistService {
|
||||
@Resource
|
||||
private IWorkIntegrationApi iWorkIntegrationApi;
|
||||
|
||||
@Value("${zzjc.html2pdf.addr:}")
|
||||
private String html2pdfAddr;
|
||||
|
||||
@Resource private ReportDocumentDataService reportDocumentDataService;
|
||||
@Resource private ReportDocumentTypeService reportDocumentTypeService;
|
||||
@Resource private ReportDocumentFileService reportDocumentFileService;
|
||||
@Resource private DataTemplateService dataTemplateService;
|
||||
@Resource private SequenceUtil sequenceUtil;
|
||||
@Resource private FileApi fileApi;
|
||||
|
||||
private String sequenceKey = "QMS_REPORT_IWORK_CODE";
|
||||
|
||||
// todo 判断是否更新pdf
|
||||
public boolean checkUpdateDocFile(JSONObject variables){
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* 更新报告附件,并发起iwork流程*/
|
||||
public void updateDocFileAndCreateIWorkflow(JSONObject variables, ReportDocumentMainDO entity) throws IOException {
|
||||
// boolean updateDocFileFlag = true;
|
||||
boolean createIworkWorkflowFlag = false;
|
||||
JSONArray bpmFieldExtensions = variables.getJSONArray("bpmFieldExtensions");
|
||||
if(bpmFieldExtensions == null)
|
||||
bpmFieldExtensions = new JSONArray();
|
||||
for(int i = 0; i < bpmFieldExtensions.size(); i++){
|
||||
JSONObject extension = bpmFieldExtensions.getJSONObject(i);
|
||||
String fieldName = extension.getString("fieldName");
|
||||
String stringValue = extension.getString("stringValue");
|
||||
if(fieldName.equals("creatIWorkFlow") && stringValue.equals("1")){
|
||||
createIworkWorkflowFlag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ReportDocumentFileDO docFile = generatePdf(entity);
|
||||
if(createIworkWorkflowFlag){
|
||||
createIWorkflow(entity, docFile);
|
||||
}
|
||||
// todo 判断是否更新pdf
|
||||
|
||||
// if(!updateDocFileFlag && createIworkWorkflowFlag){
|
||||
// ReportDocumentFileDO docFile = reportDocumentFileService.getReportDocumentFile(entity.getId());
|
||||
// createIWorkflow(entity, docFile);
|
||||
// return;
|
||||
// }
|
||||
|
||||
//更新报告pdf
|
||||
|
||||
// if(updateDocFileFlag){
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
/*
|
||||
* 发起iwork用印*/
|
||||
public CommonResult<IWorkOperationRespDTO> createIWorkflow(ReportDocumentMainDO entity, ReportDocumentFileDO docFile) {
|
||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
IWorkWorkflowCreateReqDTO dto = new IWorkWorkflowCreateReqDTO();
|
||||
dto.setJbr(String.valueOf(loginUser.getId()));
|
||||
dto.setYybm(String.valueOf(loginUser.getVisitDeptId()));
|
||||
dto.setFb(String.valueOf(loginUser.getVisitCompanyId()));
|
||||
dto.setSqsj(sdf.format(new Date()));
|
||||
dto.setYyqx("检测报告用印");
|
||||
dto.setYysy("检测报告用印");
|
||||
// dto.setXyywjUrl(docFile.getUrl());
|
||||
dto.setXyywjUrl("http://172.16.46.63:30002/yudao/20251204/%E6%B5%8B%E8%AF%95pdf_1764818842846.pdf?response-cache-control=no-cache%2C%20no-store%2C%20must-revalidate&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20251209T093343Z&X-Amz-SignedHeaders=host&X-Amz-Credential=EKplIEnbNgfYBAZbEJNa%2F20251209%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Expires=86400&X-Amz-Signature=37d63249667ea855f9a51bdf47bbb044d5860c302721f52fff2ba644985bae4c");
|
||||
dto.setYwxtdjbh(sequenceUtil.genCode(sequenceKey));
|
||||
return iWorkIntegrationApi.createWorkflow(dto);
|
||||
}
|
||||
|
||||
/*
|
||||
* 生成新版pdf文件
|
||||
* 在reportDocumentFile创建新pdf文件
|
||||
* */
|
||||
public ReportDocumentFileDO generatePdf(ReportDocumentMainDO mainDO) throws IOException {
|
||||
String pageFlag = "1"; //分页处理
|
||||
Long typeId = mainDO.getReportDocumentTypeId();
|
||||
ReportDocumentTypeDO typeDO = reportDocumentTypeService.getReportDocumentType(typeId);
|
||||
DataTemplateDO templateDO = dataTemplateService.getDataTemplate(mainDO.getDataTemplateId());
|
||||
CommonResult<JSONArray> result = reportDocumentDataService.assembleDynamicData(mainDO, typeDO, pageFlag);
|
||||
JSONArray data = result.getData();
|
||||
String templateContent = templateDO.getFormContent();
|
||||
JSONObject templateData = new JSONObject();
|
||||
JSONArray tableList = data.getJSONArray(0);
|
||||
templateData.put("headerData", tableList.getJSONObject(0).clone());
|
||||
templateData.put("tableList", tableList);
|
||||
templateData.put("formData", mainDO.getFormData());
|
||||
templateData.put("signatureData", mainDO.getDocumentSignature());
|
||||
|
||||
JSONObject bodyJson = new JSONObject();
|
||||
bodyJson.put("Template", templateContent);
|
||||
bodyJson.put("Data", templateData.toJSONString());
|
||||
String bodyStr = bodyJson.toJSONString();
|
||||
log.info("html2pdf body: " + bodyStr);
|
||||
log.info("html2pdf--start at {}", LocalDateTime.now());
|
||||
HttpResponse response = HttpUtil.createPost(html2pdfAddr)
|
||||
.body(bodyStr)
|
||||
.timeout(15000)
|
||||
.execute();
|
||||
log.info("html2pdf--end at {}", LocalDateTime.now());
|
||||
InputStream inputStream = response.bodyStream(); // 关键:返回原始 InputStream
|
||||
|
||||
//尝试从响应头中提取文件名
|
||||
String contentDisposition = response.header("Content-Disposition");
|
||||
String defaultName = "检测报告.pdf";
|
||||
String filename = extractFilename(contentDisposition).orElse(defaultName);
|
||||
//inputStream转byte[]
|
||||
byte[] fileBytes = IOUtils.toByteArray(inputStream);
|
||||
|
||||
//上传到文件服务
|
||||
FileCreateReqDTO fileCreateReqDTO = new FileCreateReqDTO();
|
||||
fileCreateReqDTO.setName(filename);
|
||||
fileCreateReqDTO.setDirectory(null);
|
||||
fileCreateReqDTO.setType(null);
|
||||
fileCreateReqDTO.setContent(fileBytes);
|
||||
CommonResult<FileRespDTO> fileResult = fileApi.createFileWithReturn(fileCreateReqDTO);
|
||||
if (fileResult == null || !fileResult.isSuccess() || fileResult.getData() == null) {
|
||||
throw new ServiceException(REPORT_DOCUMENT_FILE_NOT_EXISTS.getCode(), "通过文件服务创建附件失败: " + Optional.ofNullable(fileResult).map(CommonResult::getMsg).orElse("未知错误"));
|
||||
}
|
||||
FileRespDTO fileRespDTO = fileResult.getData();
|
||||
//写入ReportDocumentFile
|
||||
ReportDocumentFileSaveReqVO fileSaveReqVO = new ReportDocumentFileSaveReqVO();
|
||||
fileSaveReqVO.setMainId(mainDO.getId());
|
||||
fileSaveReqVO.setFileId(fileRespDTO.getId());
|
||||
fileSaveReqVO.setName(filename);
|
||||
fileSaveReqVO.setPath(fileRespDTO.getDirectory());
|
||||
fileSaveReqVO.setUrl(fileRespDTO.getUrl());
|
||||
fileSaveReqVO.setVersion(mainDO.getDocumentVersion());
|
||||
reportDocumentFileService.createReportDocumentFile(fileSaveReqVO);
|
||||
return BeanUtils.toBean(fileRespDTO, ReportDocumentFileDO.class);
|
||||
}
|
||||
|
||||
private Optional<String> extractFilename(String contentDisposition) {
|
||||
if (contentDisposition != null && contentDisposition.contains("filename=")) {
|
||||
String filename = contentDisposition.substring(contentDisposition.indexOf("filename=") + 9);
|
||||
filename = filename.replaceAll("\"", "").trim();
|
||||
return Optional.of(filename);
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
// private String encodeFilename(String filename) {
|
||||
// try {
|
||||
// return URLEncoder.encode(filename, StandardCharsets.UTF_8.toString())
|
||||
// .replaceAll("\\+", "%20");
|
||||
// } catch (Exception e) {
|
||||
// return "download.bin";
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
@@ -529,13 +529,13 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
String fixedFields = jsonObject.getString("fixedFields"); //固定检测项。如果固定检测项,则以检测项作为数据Key
|
||||
JSONArray fixedFieldsArray = JSONArray.parseArray(fixedFields);
|
||||
if(!ObjectUtils.isEmpty(maxRowCountStr)) maxRowCount = Integer.parseInt(maxRowCountStr);
|
||||
for(int i = 0; i < maxRowCount; i++){
|
||||
JSONObject row = new JSONObject();
|
||||
row.put("sampleNameCode", " ");
|
||||
row.put("sampleName", " ");
|
||||
row.put("sampleCode", " ");
|
||||
rowList.add( row);
|
||||
}
|
||||
// for(int i = 0; i < maxRowCount; i++){
|
||||
// JSONObject row = new JSONObject();
|
||||
// row.put("sampleNameCode", " ");
|
||||
// row.put("sampleName", " ");
|
||||
// row.put("sampleCode", " ");
|
||||
// rowList.add( row);
|
||||
// }
|
||||
for(ReportDocumentDataDO dataDO : dataList) {
|
||||
JSONObject t = new JSONObject();
|
||||
String documentContent = dataDO.getDocumentContent();
|
||||
@@ -582,6 +582,13 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
t.put("sampleCode", emptyText);
|
||||
rowList.add( t);
|
||||
}
|
||||
while(rowList.size() < maxRowCount){
|
||||
JSONObject t = new JSONObject();
|
||||
t.put("sampleNameCode", " ");
|
||||
t.put("sampleName", " ");
|
||||
t.put("sampleCode", " ");
|
||||
rowList.add( t);
|
||||
}
|
||||
return rowList;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.zt.plat.module.qms.business.reportdoc.service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
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 jakarta.validation.*;
|
||||
import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentFileDO;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
|
||||
/**
|
||||
* 检测报告附件 Service 接口
|
||||
*
|
||||
* @author 后台管理
|
||||
*/
|
||||
public interface ReportDocumentFileService {
|
||||
|
||||
ReportDocumentFileDO getByMainIdAndVersion(Long mainId, Integer version);
|
||||
|
||||
|
||||
/**
|
||||
* 创建检测报告附件
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
ReportDocumentFileRespVO createReportDocumentFile(@Valid ReportDocumentFileSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新检测报告附件
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateReportDocumentFile(@Valid ReportDocumentFileSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除检测报告附件
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteReportDocumentFile(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除检测报告附件
|
||||
*
|
||||
* @param ids 编号
|
||||
*/
|
||||
void deleteReportDocumentFileListByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得检测报告附件
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 检测报告附件
|
||||
*/
|
||||
ReportDocumentFileDO getReportDocumentFile(Long id);
|
||||
|
||||
/**
|
||||
* 获得检测报告附件分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 检测报告附件分页
|
||||
*/
|
||||
PageResult<ReportDocumentFileDO> getReportDocumentFilePage(ReportDocumentFilePageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.zt.plat.module.qms.business.reportdoc.service;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
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 org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentFileDO;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
|
||||
import com.zt.plat.module.qms.business.reportdoc.dal.mapper.ReportDocumentFileMapper;
|
||||
|
||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.zt.plat.framework.common.util.collection.CollectionUtils.convertList;
|
||||
import static com.zt.plat.module.qms.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 检测报告附件 Service 实现类
|
||||
*
|
||||
* @author 后台管理
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ReportDocumentFileServiceImpl implements ReportDocumentFileService {
|
||||
|
||||
@Resource
|
||||
private ReportDocumentFileMapper reportDocumentFileMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public ReportDocumentFileDO getByMainIdAndVersion(Long mainId, Integer version) {
|
||||
LambdaQueryWrapper<ReportDocumentFileDO> query = new LambdaQueryWrapper<>();
|
||||
query.eq(ReportDocumentFileDO::getMainId, mainId);
|
||||
query.eq(ReportDocumentFileDO::getVersion, version);
|
||||
return reportDocumentFileMapper.selectOne(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReportDocumentFileRespVO createReportDocumentFile(ReportDocumentFileSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
ReportDocumentFileDO reportDocumentFile = BeanUtils.toBean(createReqVO, ReportDocumentFileDO.class);
|
||||
reportDocumentFileMapper.insert(reportDocumentFile);
|
||||
// 返回
|
||||
return BeanUtils.toBean(reportDocumentFile, ReportDocumentFileRespVO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateReportDocumentFile(ReportDocumentFileSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateReportDocumentFileExists(updateReqVO.getId());
|
||||
// 更新
|
||||
ReportDocumentFileDO updateObj = BeanUtils.toBean(updateReqVO, ReportDocumentFileDO.class);
|
||||
reportDocumentFileMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteReportDocumentFile(Long id) {
|
||||
// 校验存在
|
||||
validateReportDocumentFileExists(id);
|
||||
// 删除
|
||||
reportDocumentFileMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteReportDocumentFileListByIds(List<Long> ids) {
|
||||
// 校验存在
|
||||
validateReportDocumentFileExists(ids);
|
||||
// 删除
|
||||
reportDocumentFileMapper.deleteByIds(ids);
|
||||
}
|
||||
|
||||
private void validateReportDocumentFileExists(List<Long> ids) {
|
||||
List<ReportDocumentFileDO> list = reportDocumentFileMapper.selectByIds(ids);
|
||||
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
|
||||
throw exception(REPORT_DOCUMENT_FILE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateReportDocumentFileExists(Long id) {
|
||||
if (reportDocumentFileMapper.selectById(id) == null) {
|
||||
throw exception(REPORT_DOCUMENT_FILE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReportDocumentFileDO getReportDocumentFile(Long id) {
|
||||
return reportDocumentFileMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ReportDocumentFileDO> getReportDocumentFilePage(ReportDocumentFilePageReqVO pageReqVO) {
|
||||
return reportDocumentFileMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,6 +6,8 @@ import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayReportDat
|
||||
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessSampleEntrustRegistrationDO;
|
||||
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.system.api.iwork.dto.IWorkOperationRespDTO;
|
||||
import com.zt.plat.module.system.api.iwork.dto.IWorkWorkflowCreateReqDTO;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
@@ -83,4 +85,6 @@ public interface ReportDocumentMainService {
|
||||
//发起流程
|
||||
CommonResult<ReportDocumentMainRespVO> createProcessInstance(ReportDocumentMainSaveReqVO entity);
|
||||
|
||||
|
||||
void testAsyncTask(Long id);
|
||||
}
|
||||
@@ -30,13 +30,19 @@ import com.zt.plat.module.qms.business.reportdoc.dal.mapper.ReportDocumentMainMa
|
||||
import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentMainDO;
|
||||
import com.zt.plat.module.qms.enums.QmsBpmConstant;
|
||||
import com.zt.plat.module.qms.enums.QmsCommonConstant;
|
||||
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;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
@@ -65,6 +71,26 @@ public class ReportDocumentMainServiceImpl implements ReportDocumentMainService,
|
||||
@Resource private ReportDocumentTypeService reportDocumentTypeService;
|
||||
@Resource private ConfigUserSignatureService configUserSignatureService;
|
||||
@Resource private BusinessSampleEntrustRegistrationService businessSampleEntrustRegistrationService;
|
||||
@Resource private ReportDocumentAssistService reportDocumentAssistService;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 测试异步执行
|
||||
* */
|
||||
@Async("asyncTaskExecutor")
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void testAsyncTask(Long id) {
|
||||
ReportDocumentMainDO entity = reportDocumentMainMapper.selectById(id);
|
||||
entity.setFlowStatus("success");
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
reportDocumentMainMapper.updateById(entity);
|
||||
}
|
||||
|
||||
/***
|
||||
* 增加报表数据(按样品)
|
||||
@@ -390,12 +416,15 @@ public class ReportDocumentMainServiceImpl implements ReportDocumentMainService,
|
||||
return CommonResult.success(respVO);
|
||||
}
|
||||
|
||||
|
||||
//流程回调
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CommonResult<JSONObject> callback(QmsBpmDTO reqDTO) {
|
||||
JSONObject variables = reqDTO.getVariables();
|
||||
|
||||
//todo 幂等性
|
||||
|
||||
JSONObject variables = reqDTO.getVariables();
|
||||
//流程状态 1-提交(含退回) 4-取消流程
|
||||
String PROCESS_STATUS = variables.getString(QmsBpmConstant.PROCESS_INSTANCE_VARIABLE_STATUS);
|
||||
String mainId = variables.getString("mainId");
|
||||
@@ -423,7 +452,6 @@ public class ReportDocumentMainServiceImpl implements ReportDocumentMainService,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//"RETURN_FLAG_Activity_001": true 标识驳回到发起环节
|
||||
if(variables.containsKey(returnFlagKey) && variables.getString(returnFlagKey).equals("true")){
|
||||
//驳回。流程需要配置退回到发起节点
|
||||
@@ -441,11 +469,29 @@ public class ReportDocumentMainServiceImpl implements ReportDocumentMainService,
|
||||
if("1".equals(lastActivityFlag))
|
||||
entity.setFlowStatus(QmsCommonConstant.COMPLETED); //结束审批
|
||||
}
|
||||
boolean updateDocFileFlag = reportDocumentAssistService.checkUpdateDocFile(variables);
|
||||
if(updateDocFileFlag){
|
||||
Integer version = entity.getDocumentVersion();
|
||||
if(version == null)
|
||||
version = 1;
|
||||
else
|
||||
version++;
|
||||
entity.setDocumentVersion(version); //版本+1
|
||||
}
|
||||
reportDocumentMainMapper.updateById(entity);
|
||||
|
||||
try {
|
||||
reportDocumentAssistService.updateDocFileAndCreateIWorkflow( variables, entity);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
JSONObject ret = new JSONObject();
|
||||
return CommonResult.success(ret);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void assembleSignature(String currentActivityId, ReportDocumentMainDO entity){
|
||||
if(ObjectUtils.isEmpty(currentActivityId) || "null".equals(currentActivityId))
|
||||
return;
|
||||
@@ -472,4 +518,6 @@ public class ReportDocumentMainServiceImpl implements ReportDocumentMainService,
|
||||
entity.setDocumentSignature(signObj.toJSONString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.zt.plat.module.bpm.api.task.BpmProcessInstanceApi;
|
||||
import com.zt.plat.module.bpm.api.task.BpmTaskApi;
|
||||
import com.zt.plat.module.infra.api.file.FileApi;
|
||||
import com.zt.plat.module.system.api.dept.DeptApi;
|
||||
import com.zt.plat.module.system.api.iwork.IWorkIntegrationApi;
|
||||
import com.zt.plat.module.system.api.permission.PermissionApi;
|
||||
import com.zt.plat.module.system.api.sequence.SequenceApi;
|
||||
import com.zt.plat.module.system.api.user.AdminUserApi;
|
||||
@@ -12,6 +13,6 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration(value = "qmsRpcConfiguration", proxyBeanMethods = false)
|
||||
@EnableFeignClients(clients = {FileApi.class, SequenceApi.class, AdminUserApi.class, DeptApi.class, BpmProcessInstanceApi.class, BpmTaskApi.class, PermissionApi.class})
|
||||
@EnableFeignClients(clients = {FileApi.class, SequenceApi.class, AdminUserApi.class, DeptApi.class, BpmProcessInstanceApi.class, BpmTaskApi.class, PermissionApi.class, IWorkIntegrationApi.class})
|
||||
public class RpcConfiguration {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zt.plat.module.qms.business.reportdoc.dal.mapper.ReportDocumentFileMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user