Browse Source

sjj 提交

sjj_dev
zhouhaibin 3 weeks ago
parent
commit
7837d3fae4
  1. 4
      ruoyi-admin/src/main/resources/application-dev.yml
  2. 4
      ruoyi-admin/src/main/resources/application-test.yml
  3. 2
      ruoyi-admin/src/main/resources/application.yml
  4. BIN
      ruoyi-admin/src/main/resources/fonts/consola.ttf
  5. BIN
      ruoyi-admin/src/main/resources/fonts/consolab.ttf
  6. BIN
      ruoyi-admin/src/main/resources/fonts/consolai.ttf
  7. BIN
      ruoyi-admin/src/main/resources/fonts/consolaz.ttf
  8. 111
      zaojiaManagement/zaojia-productManagement/src/main/java/org/dromara/productManagement/controller/SjjDocumentTasksController.java
  9. 88
      zaojiaManagement/zaojia-productManagement/src/main/java/org/dromara/productManagement/domain/SjjDocumentTasks.java
  10. 48
      zaojiaManagement/zaojia-productManagement/src/main/java/org/dromara/productManagement/domain/bo/SjjDocumentTasksBo.java
  11. 73
      zaojiaManagement/zaojia-productManagement/src/main/java/org/dromara/productManagement/domain/vo/SjjDocumentTasksVo.java
  12. 15
      zaojiaManagement/zaojia-productManagement/src/main/java/org/dromara/productManagement/mapper/SjjDocumentTasksMapper.java
  13. 70
      zaojiaManagement/zaojia-productManagement/src/main/java/org/dromara/productManagement/service/ISjjDocumentTasksService.java
  14. 75
      zaojiaManagement/zaojia-productManagement/src/main/java/org/dromara/productManagement/service/impl/DocumentTaskResultsServiceImpl.java
  15. 40
      zaojiaManagement/zaojia-productManagement/src/main/java/org/dromara/productManagement/service/impl/DocumentTasksServiceImpl.java
  16. 210
      zaojiaManagement/zaojia-productManagement/src/main/java/org/dromara/productManagement/service/impl/SjjDocumentTasksServiceImpl.java
  17. 7
      zaojiaManagement/zaojia-productManagement/src/main/resources/mapper/productManagement/SjjDocumentTasksMapper.xml

4
ruoyi-admin/src/main/resources/application-dev.yml

@ -52,8 +52,8 @@ spring:
# url: jdbc:mysql://localhost:3306/zaojia?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
# username: root
# password: root
# url: jdbc:mysql://10.1.21.250:3306/aitable?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
url: jdbc:mysql://218.0.1.42:53306/aitable?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
url: jdbc:mysql://10.1.21.250:3306/sjjtable?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
# url: jdbc:mysql://218.0.1.42:53306/sjjtable?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
username: root
password: 'HXj-6nR|D8xy*h#!I&:('
# 从库数据源

4
ruoyi-admin/src/main/resources/application-test.yml

@ -50,7 +50,7 @@ spring:
driverClassName: com.mysql.cj.jdbc.Driver
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
url: jdbc:mysql://localhost:3306/aitable?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
url: jdbc:mysql://localhost:3306/sjjtable?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
username: root
password: HXj-6nR|D8xy*h#!I&:(
# 从库数据源
@ -282,6 +282,6 @@ justauth:
# maxConnectNumPerRoute: 100
chat:
# 聊天机器人配置
filePath: /guoYanXinXi/data/software/minio/data/ruoyi/
filePath: /guoYanXinXi/data/software/minio/data/sjj/
tempfilePath: /guoYanXinXi/data/software/app/tempfile/
chatUrl: http://127.0.0.1:8081

2
ruoyi-admin/src/main/resources/application.yml

@ -71,7 +71,7 @@ spring:
basename: i18n/messages
profiles:
#@profiles.active@
active: dev
active: test
# 文件上传
servlet:
multipart:

BIN
ruoyi-admin/src/main/resources/fonts/consola.ttf

Binary file not shown.

BIN
ruoyi-admin/src/main/resources/fonts/consolab.ttf

Binary file not shown.

BIN
ruoyi-admin/src/main/resources/fonts/consolai.ttf

Binary file not shown.

BIN
ruoyi-admin/src/main/resources/fonts/consolaz.ttf

Binary file not shown.

111
zaojiaManagement/zaojia-productManagement/src/main/java/org/dromara/productManagement/controller/SjjDocumentTasksController.java

@ -0,0 +1,111 @@
package org.dromara.productManagement.controller;
import java.util.List;
import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.web.core.BaseController;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.productManagement.domain.vo.SjjDocumentTasksVo;
import org.dromara.productManagement.domain.bo.SjjDocumentTasksBo;
import org.dromara.productManagement.service.ISjjDocumentTasksService;
import org.dromara.common.mybatis.core.page.TableDataInfo;
/**
* 审计局标书任务
*
* @author Lion Li
* @date 2025-04-13
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/productManagement/SjjDocumentTasks")
public class SjjDocumentTasksController extends BaseController {
private final ISjjDocumentTasksService sjjDocumentTasksService;
/**
* 查询审计局标书任务列表
*/
@SaCheckPermission("productManagement:SjjDocumentTasks:list")
@GetMapping("/list")
public TableDataInfo<SjjDocumentTasksVo> list(SjjDocumentTasksBo bo, PageQuery pageQuery) {
return sjjDocumentTasksService.queryPageList(bo, pageQuery);
}
/**
* 导出审计局标书任务列表
*/
@SaCheckPermission("productManagement:SjjDocumentTasks:export")
@Log(title = "审计局标书任务", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(SjjDocumentTasksBo bo, HttpServletResponse response) {
List<SjjDocumentTasksVo> list = sjjDocumentTasksService.queryList(bo);
ExcelUtil.exportExcel(list, "审计局标书任务", SjjDocumentTasksVo.class, response);
}
/**
* 获取审计局标书任务详细信息
*
* @param id 主键
*/
@SaCheckPermission("productManagement:SjjDocumentTasks:query")
@GetMapping("/{id}")
public R<SjjDocumentTasksVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable String id) {
return R.ok(sjjDocumentTasksService.queryById(id));
}
/**
* 新增审计局标书任务
*/
@SaCheckPermission("productManagement:SjjDocumentTasks:add")
@Log(title = "审计局标书任务", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping()
public R<Void> add(@Validated(AddGroup.class) @RequestBody SjjDocumentTasksBo bo) {
return toAjax(sjjDocumentTasksService.insertByBo(bo));
}
/**
* 修改审计局标书任务
*/
@SaCheckPermission("productManagement:SjjDocumentTasks:edit")
@Log(title = "审计局标书任务", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping()
public R<Void> edit(@Validated(EditGroup.class) @RequestBody SjjDocumentTasksBo bo) {
return toAjax(sjjDocumentTasksService.updateByBo(bo));
}
/**
* 删除审计局标书任务
*
* @param ids 主键串
*/
@SaCheckPermission("productManagement:SjjDocumentTasks:remove")
@Log(title = "审计局标书任务", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public R<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable String[] ids) {
return toAjax(sjjDocumentTasksService.deleteWithValidByIds(List.of(ids), true));
}
@DeleteMapping("/ossRemoveById/{ids}")
public R<Void> ossRemoveById(@NotEmpty(message = "主键不能为空")
@PathVariable String[] ids) {
return toAjax(sjjDocumentTasksService.ossRemoveById(List.of(ids), true));
}
}

88
zaojiaManagement/zaojia-productManagement/src/main/java/org/dromara/productManagement/domain/SjjDocumentTasks.java

@ -0,0 +1,88 @@
package org.dromara.productManagement.domain;
import org.dromara.common.tenant.core.TenantEntity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
/**
* 审计局标书任务对象 sjj_document_tasks
*
* @author Lion Li
* @date 2025-04-13
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("sjj_document_tasks")
public class SjjDocumentTasks extends TenantEntity {
@Serial
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
@TableId(value = "id")
private String id;
/**
* 任务名称
*/
private String taskName;
/**
* 招标文件名称
*/
private String tenderDocumentName;
/**
* 投标文件名称
*/
private String bidDocumentName;
/**
* 进度状态
*/
private String progressStatus;
/**
* 删除标志
*/
@TableLogic
private String delFlag;
/**
* 版本号
*/
@Version
private Long version;
/**
* 任务组ID
*/
private Long groupId;
/**
* 列队任务ID
*/
private String taskId;
/**
* 审核结果
*/
private String resultType;
/**
* 招标文件对象存储ID
*/
private String tenderDocOssId;
/**
* 投标文件对象存储ID
*/
private String bidDocOssId;
private String deleteFlag;
}

48
zaojiaManagement/zaojia-productManagement/src/main/java/org/dromara/productManagement/domain/bo/SjjDocumentTasksBo.java

@ -0,0 +1,48 @@
package org.dromara.productManagement.domain.bo;
import org.dromara.productManagement.domain.SjjDocumentTasks;
import org.dromara.common.mybatis.core.domain.BaseEntity;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import lombok.EqualsAndHashCode;
import jakarta.validation.constraints.*;
/**
* 审计局标书任务业务对象 sjj_document_tasks
*
* @author Lion Li
* @date 2025-04-13
*/
@Data
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = SjjDocumentTasks.class, reverseConvertGenerate = false)
public class SjjDocumentTasksBo extends BaseEntity {
private String id;
/**
* 任务名称
*/
@NotBlank(message = "任务名称不能为空", groups = { AddGroup.class, EditGroup.class })
private String taskName;
/**
* 招标文件名称
*/
private String tenderDocumentName;
/**
* 投标文件名称
*/
private String bidDocumentName;
private String bidDocOssId;
private String tenderDocOssId;
/**
* 进度状态
*/
private String progressStatus;
private String deleteFlag;
}

73
zaojiaManagement/zaojia-productManagement/src/main/java/org/dromara/productManagement/domain/vo/SjjDocumentTasksVo.java

@ -0,0 +1,73 @@
package org.dromara.productManagement.domain.vo;
import org.dromara.productManagement.domain.SjjDocumentTasks;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import org.dromara.common.excel.annotation.ExcelDictFormat;
import org.dromara.common.excel.convert.ExcelDictConvert;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
/**
* 审计局标书任务视图对象 sjj_document_tasks
*
* @author Lion Li
* @date 2025-04-13
*/
@Data
@ExcelIgnoreUnannotated
@AutoMapper(target = SjjDocumentTasks.class)
public class SjjDocumentTasksVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
private Long id;
/**
* 任务名称
*/
@ExcelProperty(value = "任务名称")
private String taskName;
/**
* 招标文件名称
*/
@ExcelProperty(value = "招标文件名称")
private String tenderDocumentName;
/**
* 投标文件名称
*/
@ExcelProperty(value = "投标文件名称")
private String bidDocumentName;
/**
* 进度状态
*/
@ExcelProperty(value = "进度状态", converter = ExcelDictConvert.class)
@ExcelDictFormat(dictType = "document_task_status")
private String progressStatus;
/**
* 审核结果
*/
@ExcelProperty(value = "审核结果", converter = ExcelDictConvert.class)
@ExcelDictFormat(dictType = "document_task_status")
private String resultType;
private String deleteFlag;
/**
* 招标文件对象存储ID
*/
private String tenderDocOssId;
/**
* 投标文件对象存储ID
*/
private String bidDocOssId;
}

15
zaojiaManagement/zaojia-productManagement/src/main/java/org/dromara/productManagement/mapper/SjjDocumentTasksMapper.java

@ -0,0 +1,15 @@
package org.dromara.productManagement.mapper;
import org.dromara.productManagement.domain.SjjDocumentTasks;
import org.dromara.productManagement.domain.vo.SjjDocumentTasksVo;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
/**
* 审计局标书任务Mapper接口
*
* @author Lion Li
* @date 2025-04-13
*/
public interface SjjDocumentTasksMapper extends BaseMapperPlus<SjjDocumentTasks, SjjDocumentTasksVo> {
}

70
zaojiaManagement/zaojia-productManagement/src/main/java/org/dromara/productManagement/service/ISjjDocumentTasksService.java

@ -0,0 +1,70 @@
package org.dromara.productManagement.service;
import org.dromara.productManagement.domain.vo.SjjDocumentTasksVo;
import org.dromara.productManagement.domain.bo.SjjDocumentTasksBo;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.mybatis.core.page.PageQuery;
import java.util.Collection;
import java.util.List;
/**
* 审计局标书任务Service接口
*
* @author Lion Li
* @date 2025-04-13
*/
public interface ISjjDocumentTasksService {
/**
* 查询审计局标书任务
*
* @param id 主键
* @return 审计局标书任务
*/
SjjDocumentTasksVo queryById(String id);
/**
* 分页查询审计局标书任务列表
*
* @param bo 查询条件
* @param pageQuery 分页参数
* @return 审计局标书任务分页列表
*/
TableDataInfo<SjjDocumentTasksVo> queryPageList(SjjDocumentTasksBo bo, PageQuery pageQuery);
/**
* 查询符合条件的审计局标书任务列表
*
* @param bo 查询条件
* @return 审计局标书任务列表
*/
List<SjjDocumentTasksVo> queryList(SjjDocumentTasksBo bo);
/**
* 新增审计局标书任务
*
* @param bo 审计局标书任务
* @return 是否新增成功
*/
Boolean insertByBo(SjjDocumentTasksBo bo);
/**
* 修改审计局标书任务
*
* @param bo 审计局标书任务
* @return 是否修改成功
*/
Boolean updateByBo(SjjDocumentTasksBo bo);
/**
* 校验并批量删除审计局标书任务信息
*
* @param ids 待删除的主键集合
* @param isValid 是否进行有效性校验
* @return 是否删除成功
*/
Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid);
Boolean ossRemoveById(List<String> ids, Boolean b);
}

75
zaojiaManagement/zaojia-productManagement/src/main/java/org/dromara/productManagement/service/impl/DocumentTaskResultsServiceImpl.java

@ -220,19 +220,19 @@ public class DocumentTaskResultsServiceImpl implements IDocumentTaskResultsServi
} else {
// 单文件下载
DocumentTaskResults result = list.get(0);
DocumentTasksVo documentTasksVo = documentTasksService.queryById(list.get(0).getDocumentTaskId());
String documentName = documentTasksVo.getDocumentName();
String taskName = documentTasksVo.getTaskName();
String taskType = documentTasksVo.getTaskType();
String label = dictTypeService.getDictLabel(taskType, taskName);
String pdfFileName = label + "_" + documentName + "_" + ".pdf";
// DocumentTasksVo documentTasksVo = documentTasksService.queryById(list.get(0).getDocumentTaskId());
// String documentName = documentTasksVo.getDocumentName();
// String taskName = documentTasksVo.getTaskName();
// String taskType = documentTasksVo.getTaskType();
//
// String label = dictTypeService.getDictLabel(taskType, taskName);
String pdfFileName = "结果" + ".pdf";
String tempDir = System.getProperty("java.io.tmpdir");
String pdfPath = tempDir + File.separator + pdfFileName;
String resultText = result.getResult();
if (taskName.equals(TaskEnum.SchemeTask.SCHEME_EVALUATION.getValue())) {
resultText = cleanHtml(result.getResult());
}
// if (taskName.equals(TaskEnum.SchemeTask.SCHEME_EVALUATION.getValue())) {
// resultText = cleanHtml(result.getResult());
// }
// 转换Markdown为PDF
convertMarkdownToPdf(resultText, pdfPath);
@ -285,6 +285,13 @@ public class DocumentTaskResultsServiceImpl implements IDocumentTaskResultsServi
.addAttributes(":all", "style", "class")
.addAttributes("table", "border", "cellpadding", "cellspacing");
htmlContent = Jsoup.clean(htmlContent, "", safelist, settings);
// 处理代码块 - 将code标签替换为带内联样式的div (不使用class)
htmlContent = htmlContent.replaceAll("(?s)<pre><code>(.*?)</code></pre>",
"<div style='background-color:#f6f8fa;border:1px solid #ddd;'>$1</div>");
// 处理行内代码 - 将行内code替换为带内联样式的span (不使用class)
htmlContent = htmlContent.replaceAll("<code>(.*?)</code>",
"<span style='background-color:#f6f8fa;border:1px solid #ddd;'>$1</span>");
// 使用 NekoHTML 进一步处理
// 创建完整的HTML文档,使用微软雅黑
@ -336,34 +343,44 @@ public class DocumentTaskResultsServiceImpl implements IDocumentTaskResultsServi
</body>
</html>
""",
// 特殊处理code标签,确保其内容不被换行破坏
htmlContent.replace("<br>", "\n"));
// 配置Flying Saucer
ITextRenderer pdfRenderer = new ITextRenderer();
// 配置Flying Saucer
ITextRenderer pdfRenderer = new ITextRenderer();
// 主要使用微软雅黑,但也加载其他字体作为备选
// 从classpath加载字体
try (InputStream is = getClass().getResourceAsStream("/fonts/msyh.ttc")) {
File tempFont = File.createTempFile("msyh", ".ttc");
FileUtils.copyInputStreamToFile(is, tempFont);
pdfRenderer.getFontResolver().addFont(tempFont.getAbsolutePath(), BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
tempFont.deleteOnExit();
}
// 主要使用微软雅黑,但也加载其他字体作为备选
// 从classpath加载字体
try (InputStream is = getClass().getResourceAsStream("/fonts/msyh.ttc")) {
File tempFont = File.createTempFile("msyh", ".ttc");
FileUtils.copyInputStreamToFile(is, tempFont);
pdfRenderer.getFontResolver().addFont(tempFont.getAbsolutePath(), BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
tempFont.deleteOnExit();
}
try (InputStream consolas = getClass().getResourceAsStream("/fonts/consolas.ttf")){
if (consolas != null) {
File tempConsolas = File.createTempFile("consolas", ".ttf");
FileUtils.copyInputStreamToFile(consolas, tempConsolas);
pdfRenderer.getFontResolver().addFont(tempConsolas.getAbsolutePath(), BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
tempConsolas.deleteOnExit();
}
}
// 设置文档
pdfRenderer.setDocumentFromString(html);
// 设置文档
pdfRenderer.setDocumentFromString(html);
// 设置输出编码和基础URL
pdfRenderer.getSharedContext().setBaseURL("file:///");
// 设置输出编码和基础URL
pdfRenderer.getSharedContext().setBaseURL("file:///");
// 布局和创建PDF
pdfRenderer.layout();
// 布局和创建PDF
pdfRenderer.layout();
try (OutputStream os = new FileOutputStream(outputPath)) {
pdfRenderer.createPDF(os, true);
}
try (OutputStream os = new FileOutputStream(outputPath)) {
pdfRenderer.createPDF(os, true);
}
}
// 添加文件到ZIP

40
zaojiaManagement/zaojia-productManagement/src/main/java/org/dromara/productManagement/service/impl/DocumentTasksServiceImpl.java

@ -236,26 +236,26 @@ public class DocumentTasksServiceImpl extends BaseTaskService implements IDocume
String destPath = destDir + File.separator + originalfileName;
File destFile = new File(destPath);
FileUtil.writeFromStream(file.getInputStream(), destFile);
if (!suffix.equals(".docx")) {
// ProcessBuilder builder = new ProcessBuilder("unoconv", "-o", destDir, "-f", "docx", destFile.getAbsolutePath());
ProcessBuilder builder = new ProcessBuilder("libreoffice", "--headless", "--convert-to", "docx",destPath, "--outdir", destDir);
Process process = builder.start();
int completed = process.waitFor();
if (completed != 0) {
InputStream errorStream = process.getErrorStream();
String errorMessage = new String(errorStream.readAllBytes());
process.destroyForcibly();
String failMsg = suffix + "转docx失败,可以尝试用WORD或WPS打开文件,另存为docx文件,再尝试上传。 错误信息: " + errorMessage;
throw new RuntimeException(failMsg);
} else {
process.destroyForcibly();
destPath = destPath.substring(0, destPath.lastIndexOf(".")) + ".docx";
}
}
//校验文件是否可用
if(!MyHttpUtils.sendFileCheckMessage(chatUrl + "/back/checkFile", destPath)){
throw new RuntimeException("文件无法正常打开。可以尝试用WORD或WPS打开文件,进行修复并另存,用另存的文件再做一次尝试。");
}
// if (!suffix.equals(".docx")) {
//// ProcessBuilder builder = new ProcessBuilder("unoconv", "-o", destDir, "-f", "docx", destFile.getAbsolutePath());
// ProcessBuilder builder = new ProcessBuilder("libreoffice", "--headless", "--convert-to", "docx",destPath, "--outdir", destDir);
// Process process = builder.start();
// int completed = process.waitFor();
// if (completed != 0) {
// InputStream errorStream = process.getErrorStream();
// String errorMessage = new String(errorStream.readAllBytes());
// process.destroyForcibly();
// String failMsg = suffix + "转docx失败,可以尝试用WORD或WPS打开文件,另存为docx文件,再尝试上传。 错误信息: " + errorMessage;
// throw new RuntimeException(failMsg);
// } else {
// process.destroyForcibly();
// destPath = destPath.substring(0, destPath.lastIndexOf(".")) + ".docx";
// }
// }
// //校验文件是否可用
// if(!MyHttpUtils.sendFileCheckMessage(chatUrl + "/back/checkFile", destPath)){
// throw new RuntimeException("文件无法正常打开。可以尝试用WORD或WPS打开文件,进行修复并另存,用另存的文件再做一次尝试。");
// }
SysOssVo upload = ossService.upload(new File(destPath));
return upload;
}

210
zaojiaManagement/zaojia-productManagement/src/main/java/org/dromara/productManagement/service/impl/SjjDocumentTasksServiceImpl.java

@ -0,0 +1,210 @@
package org.dromara.productManagement.service.impl;
import okhttp3.*;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.mybatis.core.page.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.productManagement.domain.DocumentTasks;
import org.dromara.productManagement.mapper.DocumentTasksMapper;
import org.dromara.system.domain.vo.SysOssVo;
import org.dromara.system.service.ISysOssService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.dromara.productManagement.domain.bo.SjjDocumentTasksBo;
import org.dromara.productManagement.domain.vo.SjjDocumentTasksVo;
import org.dromara.productManagement.domain.SjjDocumentTasks;
import org.dromara.productManagement.mapper.SjjDocumentTasksMapper;
import org.dromara.productManagement.service.ISjjDocumentTasksService;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Collection;
/**
* 审计局标书任务Service业务层处理
*
* @author Lion Li
* @date 2025-04-13
*/
@RequiredArgsConstructor
@Service
public class SjjDocumentTasksServiceImpl implements ISjjDocumentTasksService {
private final SjjDocumentTasksMapper baseMapper;
private final DocumentTasksMapper documentTasksMapper;
protected final ISysOssService ossService;
@Value("${chat.filePath}")
protected String fileRootPath;
@Value("${chat.chatUrl}")
protected String chatUrl;
@Value("${chat.tempfilePath}")
protected String tempfilePath;
/**
* 查询审计局标书任务
*
* @param id 主键
* @return 审计局标书任务
*/
@Override
public SjjDocumentTasksVo queryById(String id){
return baseMapper.selectVoById(id);
}
/**
* 分页查询审计局标书任务列表
*
* @param bo 查询条件
* @param pageQuery 分页参数
* @return 审计局标书任务分页列表
*/
@Override
public TableDataInfo<SjjDocumentTasksVo> queryPageList(SjjDocumentTasksBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<SjjDocumentTasks> lqw = buildQueryWrapper(bo);
Page<SjjDocumentTasksVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
return TableDataInfo.build(result);
}
/**
* 查询符合条件的审计局标书任务列表
*
* @param bo 查询条件
* @return 审计局标书任务列表
*/
@Override
public List<SjjDocumentTasksVo> queryList(SjjDocumentTasksBo bo) {
LambdaQueryWrapper<SjjDocumentTasks> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
}
private LambdaQueryWrapper<SjjDocumentTasks> buildQueryWrapper(SjjDocumentTasksBo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<SjjDocumentTasks> lqw = Wrappers.lambdaQuery();
lqw.like(StringUtils.isNotBlank(bo.getTaskName()), SjjDocumentTasks::getTaskName, bo.getTaskName());
lqw.like(StringUtils.isNotBlank(bo.getTenderDocumentName()), SjjDocumentTasks::getTenderDocumentName, bo.getTenderDocumentName());
lqw.like(StringUtils.isNotBlank(bo.getBidDocumentName()), SjjDocumentTasks::getBidDocumentName, bo.getBidDocumentName());
lqw.eq(StringUtils.isNotBlank(bo.getDeleteFlag()), SjjDocumentTasks::getDeleteFlag, bo.getDeleteFlag());
lqw.eq(StringUtils.isNotBlank(bo.getProgressStatus()), SjjDocumentTasks::getProgressStatus, bo.getProgressStatus());
lqw.orderByDesc(SjjDocumentTasks::getCreateTime);
return lqw;
}
/**
* 新增审计局标书任务
*
* @param bo 审计局标书任务
* @return 是否新增成功
*/
@Override
public Boolean insertByBo(SjjDocumentTasksBo bo) {
SjjDocumentTasks add = MapstructUtils.convert(bo, SjjDocumentTasks.class);
String bidDocOssId = add.getBidDocOssId();
String tenderDocOssId = add.getTenderDocOssId();
SysOssVo bidFileInfo = ossService.getById(Long.valueOf(bidDocOssId));
String bidDocName = bidFileInfo.getOriginalName();
String bidDocPath = fileRootPath + bidFileInfo.getFileName();
SysOssVo tenderFileInfo = ossService.getById(Long.valueOf(tenderDocOssId));
String tenderDocName = tenderFileInfo.getOriginalName();
String tenderDocPath = fileRootPath + tenderFileInfo.getFileName();
add.setBidDocumentName(bidDocName);
add.setTenderDocumentName(tenderDocName);
add.setProgressStatus("PENDING");
validEntityBeforeSave(add);
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
bo.setId(add.getId());
}
DocumentTasks documentTasks = new DocumentTasks();
documentTasks.setId(Long.valueOf(add.getId()));
documentTasksMapper.insert(documentTasks);
//发起请求
OkHttpClient client = new OkHttpClient.Builder().build();
if (chatUrl == null) {
throw new IllegalArgumentException("无效的任务名称: " + add.getTaskName());
}
// Request request = new Request.Builder()
// .url(url+"?userId="+ LoginHelper.getUserId()+"&taskId="+taskId+"&filename="+filename+"&taskName="+taskName+"&priority="+priority)
// .build();
HttpUrl.Builder urlBuilder = HttpUrl.parse(chatUrl +"/back/taskStart").newBuilder();
urlBuilder.addQueryParameter("userId", String.valueOf(LoginHelper.getUserId()));
urlBuilder.addQueryParameter("taskId", String.valueOf(add.getId()));
urlBuilder.addQueryParameter("filename", bidDocPath+"\n"+tenderDocPath);
urlBuilder.addQueryParameter("taskName", add.getTaskName());
urlBuilder.addQueryParameter("priority", "1");
Request request = new Request.Builder()
.url(urlBuilder.build())
.build();
// 使用异步调用
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
e.printStackTrace(); // 处理请求失败
}
@Override
public void onResponse(Call call, Response response) throws IOException {
// 忽略返回内容
response.close(); // 确保响应被关闭
}
});
return flag;
}
/**
* 修改审计局标书任务
*
* @param bo 审计局标书任务
* @return 是否修改成功
*/
@Override
public Boolean updateByBo(SjjDocumentTasksBo bo) {
SjjDocumentTasks update = MapstructUtils.convert(bo, SjjDocumentTasks.class);
validEntityBeforeSave(update);
return baseMapper.updateById(update) > 0;
}
/**
* 保存前的数据校验
*/
private void validEntityBeforeSave(SjjDocumentTasks entity){
//TODO 做一些数据校验,如唯一约束
}
/**
* 校验并批量删除审计局标书任务信息
*
* @param ids 待删除的主键集合
* @param isValid 是否进行有效性校验
* @return 是否删除成功
*/
@Override
public Boolean deleteWithValidByIds(Collection<String> ids, Boolean isValid) {
if(isValid){
//TODO 做一些业务上的校验,判断是否需要校验
}
return baseMapper.deleteByIds(ids) > 0;
}
@Override
public Boolean ossRemoveById(List<String> ids, Boolean b) {
List<SjjDocumentTasksVo> sjjDocumentTasksVos = baseMapper.selectVoByIds(ids);
for (SjjDocumentTasksVo sjjDocumentTasksVo : sjjDocumentTasksVos) {
ossService.deleteWithValidByIds(Collections.singletonList(Long.valueOf(sjjDocumentTasksVo.getTenderDocOssId())), true);
ossService.deleteWithValidByIds(Collections.singletonList(Long.valueOf(sjjDocumentTasksVo.getBidDocOssId())), true);
SjjDocumentTasks convert = MapstructUtils.convert(sjjDocumentTasksVo, SjjDocumentTasks.class);
convert.setDeleteFlag("Y");
baseMapper.updateById(convert);
}
return true;
}
}

7
zaojiaManagement/zaojia-productManagement/src/main/resources/mapper/productManagement/SjjDocumentTasksMapper.xml

@ -0,0 +1,7 @@
<?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="org.dromara.productManagement.mapper.SjjDocumentTasksMapper">
</mapper>
Loading…
Cancel
Save