1、发布工具流程-关联工具细节调整

2、文档资源管理调整
This commit is contained in:
pan
2024-08-29 22:01:03 +08:00
parent f1b84cb823
commit f0a14bcd3c
19 changed files with 995 additions and 53 deletions

View File

@@ -1,18 +1,12 @@
package com.rzdata.web.controller.common;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.rzdata.common.config.JaConfig;
import com.rzdata.common.constant.Constants;
import com.rzdata.common.core.domain.AjaxResult;
import com.rzdata.common.utils.StringUtils;
import com.rzdata.common.utils.file.FileUploadUtils;
import com.rzdata.common.utils.file.FileUtils;
import com.rzdata.framework.config.ServerConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -21,13 +15,14 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import com.rzdata.common.config.JaConfig;
import com.rzdata.common.constant.Constants;
import com.rzdata.common.core.domain.AjaxResult;
import com.rzdata.common.utils.StringUtils;
import com.rzdata.common.utils.file.FileUploadUtils;
import com.rzdata.common.utils.file.FileUtils;
import com.rzdata.framework.config.ServerConfig;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.util.*;
/**
* 通用请求处理
@@ -92,7 +87,8 @@ public class CommonController
String url = serverConfig.getUrl() + fileName;
AjaxResult ajax = AjaxResult.success();
ajax.put("url", url);
ajax.put("fileName", fileName);
ajax.put("filePath", fileName);
ajax.put("suffixType", FileUploadUtils.extractSuffix(fileName));
ajax.put("newFileName", FileUtils.getName(fileName));
ajax.put("originalFilename", file.getOriginalFilename());
return ajax;
@@ -220,8 +216,10 @@ public class CommonController
Map<String, String> response = new HashMap<>();
String url = serverConfig.getUrl() + fileNamePath;
response.put("url", url);
response.put("fileUrl", finalFilePath);
response.put("fileNamePath", fileNamePath);
response.put("filePath", fileNamePath);
response.put("suffixType", FileUploadUtils.extractSuffix(fileNamePath));
response.put("newFileName", FileUtils.getName(fileNamePath));
response.put("originalFilename", fileName);
return ResponseEntity.ok(response);
} catch (IOException e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);

View File

@@ -10,7 +10,6 @@ import com.rzdata.common.utils.poi.ExcelUtil;
import com.rzdata.web.domain.Document;
import com.rzdata.web.service.IDocumentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
@@ -88,10 +87,20 @@ public class DocumentController extends BaseController
/**
* 删除【文档资源信息】
*/
@Log(title = "请填写功能名称", businessType = BusinessType.DELETE)
@Log(title = "逻辑删除-文档资源信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids)
{
return toAjax(documentService.deleteDocumentByIds(ids));
}
/**
* 发布文档
*/
@Log(title = "【发布逻辑】", businessType = BusinessType.UPDATE)
@PutMapping("/pushDoc/{ids}")
public AjaxResult pushDoc(@PathVariable String[] ids)
{
return toAjax(documentService.pushDoc(ids));
}
}

View File

@@ -0,0 +1,105 @@
package com.rzdata.web.controller.tool;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.rzdata.web.domain.Attachment;
import com.rzdata.web.service.IAttachmentService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.rzdata.common.annotation.Log;
import com.rzdata.common.core.controller.BaseController;
import com.rzdata.common.core.domain.AjaxResult;
import com.rzdata.common.enums.BusinessType;
import com.rzdata.common.utils.poi.ExcelUtil;
import com.rzdata.common.core.page.TableDataInfo;
/**
* 附件Controller
*
* @author panchichun
* @date 2024-08-28
*/
@RestController
@RequestMapping("/system/attachment")
public class AttachmentController extends BaseController
{
@Autowired
private IAttachmentService attachmentService;
/**
* 查询附件列表
*/
@PreAuthorize("@ss.hasPermi('system:attachment:list')")
@GetMapping("/list")
public TableDataInfo list(Attachment attachment)
{
startPage();
List<Attachment> list = attachmentService.selectAttachmentList(attachment);
return getDataTable(list);
}
/**
* 导出附件列表
*/
@PreAuthorize("@ss.hasPermi('system:attachment:export')")
@Log(title = "附件", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, Attachment attachment)
{
List<Attachment> list = attachmentService.selectAttachmentList(attachment);
ExcelUtil<Attachment> util = new ExcelUtil<Attachment>(Attachment.class);
util.exportExcel(response, list, "附件数据");
}
/**
* 获取附件详细信息
*/
@PreAuthorize("@ss.hasPermi('system:attachment:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id)
{
return success(attachmentService.selectAttachmentById(id));
}
/**
* 新增附件
*/
@PreAuthorize("@ss.hasPermi('system:attachment:add')")
@Log(title = "附件", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody Attachment attachment)
{
return toAjax(attachmentService.insertAttachment(attachment));
}
/**
* 修改附件
*/
@PreAuthorize("@ss.hasPermi('system:attachment:edit')")
@Log(title = "附件", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody Attachment attachment)
{
return toAjax(attachmentService.updateAttachment(attachment));
}
/**
* 删除附件
*/
@PreAuthorize("@ss.hasPermi('system:attachment:remove')")
@Log(title = "附件", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids)
{
return toAjax(attachmentService.deleteAttachmentByIds(ids));
}
}

View File

@@ -1,5 +1,6 @@
package com.rzdata.web.controller.tool;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.BooleanUtil;
import cn.hutool.core.util.IdUtil;
import com.blueland.bpmclient.model.ProcessInstanceModel;
@@ -14,7 +15,9 @@ import com.rzdata.common.utils.SecurityUtils;
import com.rzdata.common.utils.StringUtils;
import com.rzdata.common.utils.poi.ExcelUtil;
import com.rzdata.system.service.ISysDeptService;
import com.rzdata.web.domain.Document;
import com.rzdata.web.domain.Tool;
import com.rzdata.web.service.IDocumentService;
import com.rzdata.web.service.IToolService;
import com.rzdata.web.service.IUseApplyService;
import com.rzdata.web.service.WorkflowService;
@@ -25,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* 工具信息Controller
@@ -48,6 +52,10 @@ public class ToolController extends BaseController
@Autowired
private ISysDeptService iSysDeptService;
@Autowired
private IDocumentService iDocumentService;
/**
* 查询工具信息列表
*/
@@ -136,14 +144,26 @@ public class ToolController extends BaseController
if (add) {
tTool.setProcInstId(processInstanceModel.getProcInstId());
toolService.insertTool(tTool);
//保存文档和附件
toolService.addDocAndAtt(tTool);
}else if (BooleanUtil.isTrue(tTool.getEditStatus())){
toolService.updateTool(tTool);
//删除文档和附件
toolService.deleteDocAndAtt(tTool);
//保存文档和附件
toolService.addDocAndAtt(tTool);
}else {
Tool tool = new Tool();
tool.setToolId(tTool.getToolId());
tool.setRecordStatus(tTool.getRecordStatus());
toolService.updateTool(tool);
}
//办结
if(RecordStatusEnum.DONE.getCode().equals(tTool.getRecordStatus())){
//更新文档状态
toolService.updateDocPushStatus(tTool);
}
return AjaxResult.success("操作成功",processInstanceModel);
}else {
return AjaxResult.error();

View File

@@ -0,0 +1,83 @@
package com.rzdata.web.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.rzdata.common.annotation.Excel;
import com.rzdata.common.core.domain.BaseEntity;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.Date;
import java.util.List;
/**
* 附件对象 t_attachment
*
* @author panchichun
* @date 2024-08-28
*/
@Data
public class Attachment extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键 */
private String id;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String fileType;
/** 业务类型 */
@Excel(name = "业务类型")
private String bizType;
/** 文件URL */
@Excel(name = "文件URL")
private String fileUrl;
/** 文件源名称 */
@Excel(name = "文件源名称")
private String fileOldName;
/** 文件新名称 */
@Excel(name = "文件新名称")
private String fileNewName;
/** 文件后缀 */
@Excel(name = "文件后缀")
private String suffixType;
/** 文件大小 */
@Excel(name = "文件大小")
private Long fileSize;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String businessId;
/** 序号 */
@Excel(name = "序号")
private Long sorts;
/** 删除;1是, 0:否 */
@Excel(name = "删除;1是, 0:否")
private String del;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date createDate;
/** 更新时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date updateDate;
/** 失效时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "失效时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date failureTime;
private List<String> businessIds;
}

View File

@@ -6,6 +6,8 @@ import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.List;
/**
* 【请填写功能名称】对象 t_document
*
@@ -58,4 +60,29 @@ public class Document extends BaseEntity {
/** 文档分类id */
@Excel(name = "文档分类id")
private String docCategoryId;
/** 创建人id */
private String createById;
/** 更新人id */
private String updateById;
/** 逻辑删除1删除0未删除 */
private String isDeleted;
/** 主键 **/
private List<String> ids;
/** 附件名称 **/
private Attachment attachment;
/** 关联工具id对象 */
private String toolId;
/**
* 工具名称
*/
private String toolName;
/** 工具信息 **/
private Tool tool;
/** 文档部门名称 **/
private String docRespDeptName;
}

View File

@@ -86,6 +86,7 @@ public class Tool extends BaseEntity
private BpmClientInputModelBo bpmClientInputModel;
/** done办结doing进行中**/
private String recordStatus;
private Boolean editStatus;
@@ -101,4 +102,6 @@ public class Tool extends BaseEntity
private Boolean downloadStatus;
private List<String> excludeFields;
private List<Document> documentList;
}

View File

@@ -0,0 +1,71 @@
package com.rzdata.web.mapper;
import com.rzdata.web.domain.Attachment;
import java.util.List;
/**
* 附件Mapper接口
*
* @author panchichun
* @date 2024-08-28
*/
public interface AttachmentMapper
{
/**
* 查询附件
*
* @param id 附件主键
* @return 附件
*/
public Attachment selectAttachmentById(String id);
/**
* 查询附件列表
*
* @param attachment 附件
* @return 附件集合
*/
public List<Attachment> selectAttachmentList(Attachment attachment);
/**
* 新增附件
*
* @param attachment 附件
* @return 结果
*/
public int insertAttachment(Attachment attachment);
/**
* 修改附件
*
* @param attachment 附件
* @return 结果
*/
public int updateAttachment(Attachment attachment);
/**
* 根据业务id更新附件
* @param attachment
* @return
*/
public int updateAttachmentByBusinessId(Attachment attachment);
/**
* 删除附件
*
* @param id 附件主键
* @return 结果
*/
public int deleteAttachmentById(String id);
/**
* 批量删除附件
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteAttachmentByIds(String[] ids);
public int deleteAttachmentByBusinessId(List<String> list);
}

View File

@@ -53,10 +53,14 @@ public interface DocumentMapper
public int deleteDocumentById(String id);
/**
* 批量删除【请填写功能名称】
* 逻辑删除
*
* @param ids 需要删除的数据主键集合
* @param Document 需要删除的数据主键集合
* @return 结果
*/
public int deleteDocumentByIds(String[] ids);
public int isDeleteDocumentByIds(Document Document);
public int updatePushDoc(Document doc);
public int batchDeleteById(List<String> list);
}

View File

@@ -0,0 +1,70 @@
package com.rzdata.web.service;
import com.rzdata.web.domain.Attachment;
import java.util.List;
/**
* 附件Service接口
*
* @author panchichun
* @date 2024-08-28
*/
public interface IAttachmentService
{
/**
* 查询附件
*
* @param id 附件主键
* @return 附件
*/
public Attachment selectAttachmentById(String id);
/**
* 查询附件列表
*
* @param attachment 附件
* @return 附件集合
*/
public List<Attachment> selectAttachmentList(Attachment attachment);
/**
* 新增附件
*
* @param attachment 附件
* @return 结果
*/
public int insertAttachment(Attachment attachment);
/**
* 修改附件
*
* @param attachment 附件
* @return 结果
*/
public int updateAttachment(Attachment attachment);
public int updateAttachmentByBusinessId(Attachment attachment);
/**
* 批量删除附件
*
* @param ids 需要删除的附件主键集合
* @return 结果
*/
public int deleteAttachmentByIds(String[] ids);
/**
* 根据业务id批量删除
* @param businessIds
* @return
*/
public int deleteAttachmentByBusinessId(List<String> businessIds);
/**
* 删除附件信息
*
* @param id 附件主键
* @return 结果
*/
public int deleteAttachmentById(String id);
}

View File

@@ -28,6 +28,9 @@ public interface IDocumentService
*/
public List<Document> selectDocumentList(Document document);
public List<Document> selectDocumentListAll(Document document);
/**
* 新增【请填写功能名称】
*
@@ -62,4 +65,13 @@ public interface IDocumentService
* @return 结果
*/
public int deleteDocumentById(String id);
/**
* 发布文档
* @param ids
* @return
*/
int pushDoc(String[] ids);
public int batchDeleteById(List<String> docIds);
}

View File

@@ -63,4 +63,18 @@ public interface IToolService
* @return 结果
*/
public int deleteToolByToolId(String toolId);
/**
* 删除文档和附件
* @param tool
*/
public void deleteDocAndAtt(Tool tool);
/**
* 新增文档和附件
* @param tool
*/
public void addDocAndAtt(Tool tool);
void updateDocPushStatus(Tool tTool);
}

View File

@@ -0,0 +1,117 @@
package com.rzdata.web.service.impl;
import java.util.List;
import com.rzdata.web.domain.Attachment;
import com.rzdata.web.mapper.AttachmentMapper;
import com.rzdata.web.service.IAttachmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 附件Service业务层处理
*
* @author panchichun
* @date 2024-08-28
*/
@Service
public class AttachmentServiceImpl implements IAttachmentService
{
@Autowired
private AttachmentMapper attachmentMapper;
/**
* 查询附件
*
* @param id 附件主键
* @return 附件
*/
@Override
public Attachment selectAttachmentById(String id)
{
return attachmentMapper.selectAttachmentById(id);
}
/**
* 查询附件列表
*
* @param attachment 附件
* @return 附件
*/
@Override
public List<Attachment> selectAttachmentList(Attachment attachment)
{
return attachmentMapper.selectAttachmentList(attachment);
}
/**
* 新增附件
*
* @param attachment 附件
* @return 结果
*/
@Override
public int insertAttachment(Attachment attachment)
{
return attachmentMapper.insertAttachment(attachment);
}
/**
* 修改附件
*
* @param attachment 附件
* @return 结果
*/
@Override
public int updateAttachment(Attachment attachment)
{
return attachmentMapper.updateAttachment(attachment);
}
/**
* 修改附件
*
* @param attachment 附件
* @return 结果
*/
@Override
public int updateAttachmentByBusinessId(Attachment attachment)
{
return attachmentMapper.updateAttachmentByBusinessId(attachment);
}
/**
* 批量删除附件
*
* @param ids 需要删除的附件主键
* @return 结果
*/
@Override
public int deleteAttachmentByIds(String[] ids)
{
return attachmentMapper.deleteAttachmentByIds(ids);
}
/**
* 批量删除附件
*
* @param ids 需要删除的附件主键
* @return 结果
*/
@Override
public int deleteAttachmentByBusinessId(List<String> businessIds)
{
return attachmentMapper.deleteAttachmentByBusinessId(businessIds);
}
/**
* 删除附件信息
*
* @param id 附件主键
* @return 结果
*/
@Override
public int deleteAttachmentById(String id)
{
return attachmentMapper.deleteAttachmentById(id);
}
}

View File

@@ -1,14 +1,25 @@
package com.rzdata.web.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.rzdata.common.constant.Constants;
import com.rzdata.common.utils.DateUtils;
import com.rzdata.common.utils.SecurityUtils;
import com.rzdata.web.domain.Attachment;
import com.rzdata.web.domain.Document;
import com.rzdata.web.domain.Tool;
import com.rzdata.web.mapper.DocumentMapper;
import com.rzdata.web.service.IDocumentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* 【请填写功能名称】Service业务层处理
@@ -21,6 +32,10 @@ public class DocumentServiceImpl implements IDocumentService
{
@Autowired
private DocumentMapper documentMapper;
@Autowired
private AttachmentServiceImpl attachmentService;
@Autowired
private ToolServiceImpl toolService;
/**
* 查询【请填写功能名称】
@@ -31,19 +46,65 @@ public class DocumentServiceImpl implements IDocumentService
@Override
public Document selectDocumentById(String docId)
{
return documentMapper.selectDocumentById(docId);
Document document = documentMapper.selectDocumentById(docId);
if(StrUtil.isNotBlank(document.getToolId())){
Tool tool = toolService.selectToolByToolId(document.getToolId());
document.setToolName(tool.getToolName());
}
Attachment attachment = new Attachment();
attachment.setBusinessId(document.getDocId());
attachment.setDel(Constants.STR_ZERO);
List<Attachment> attachments = attachmentService.selectAttachmentList(attachment);
if(CollUtil.isNotEmpty(attachments)){
document.setAttachment(attachments.get(0));
}
return document;
}
/**
* 查询【请填写功能名称】列表
*
* @param Document 【请填写功能名称】
* @param document 【请填写功能名称】
* @return 【请填写功能名称】
*/
@Override
public List<Document> selectDocumentList(Document Document)
public List<Document> selectDocumentList(Document document)
{
return documentMapper.selectDocumentList(Document);
List<Document> documents = documentMapper.selectDocumentList(document);
if(CollUtil.isEmpty(documents)){
return documents;
}
List<String> docIds = documents.stream().map(Document::getDocId).collect(Collectors.toList());
Attachment attachment = new Attachment();
attachment.setBusinessIds(docIds);
attachment.setDel(Constants.STR_ZERO);
List<Attachment> attachments = attachmentService.selectAttachmentList(attachment);
if(CollUtil.isEmpty(attachments)){
return documents;
}
for (Document doc : documents) {
for (Attachment att : attachments) {
if(doc.getDocId().equals(att.getBusinessId())){
doc.setAttachment(att);
break;
}
}
}
return documents;
}
/**
* 查询【请填写功能名称】列表
*
* @param document 【请填写功能名称】
* @return 【请填写功能名称】
*/
@Override
public List<Document> selectDocumentListAll(Document document)
{
List<Document> documents = documentMapper.selectDocumentList(document);
return documents;
}
/**
@@ -60,11 +121,26 @@ public class DocumentServiceImpl implements IDocumentService
return documentMapper.insertDocument(document);
}
@Override
@Transactional(rollbackFor = Exception.class)
public String saveDocument(Document document){
document.setCreateTime(DateUtils.getNowDate());
String docId = IdUtil.simpleUUID();
document.setDocId(docId);
document.setCreateBy(SecurityUtils.getLoginUser().getUsername());
document.setCreateById(String.valueOf(SecurityUtils.getLoginUser().getUserId()));
document.setIsDeleted(Constants.STR_ZERO);
document.setCreateTime(new Date());
int result = documentMapper.insertDocument(document);
if(ObjectUtil.isNotEmpty(document.getAttachment())){
Attachment attachment = document.getAttachment();
attachment.setId(IdUtil.simpleUUID());
attachment.setCreateBy(SecurityUtils.getLoginUser().getUsername());
attachment.setBusinessId(docId);
attachment.setBizType(Constants.DOC_TYPE_DOC);
attachment.setDel(Constants.STR_ZERO);
attachment.setCreateDate(new Date());
attachmentService.insertAttachment(attachment);
}
if(result > 0){
return docId;
}
@@ -74,14 +150,36 @@ public class DocumentServiceImpl implements IDocumentService
/**
* 修改【请填写功能名称】
*
* @param Document 【请填写功能名称】
* @param document 【请填写功能名称】
* @return 结果
*/
@Override
public int updateDocument(Document Document)
@Transactional(rollbackFor = Exception.class)
public int updateDocument(Document document)
{
Document.setUpdateTime(DateUtils.getNowDate());
return documentMapper.updateDocument(Document);
document.setUpdateBy(SecurityUtils.getLoginUser().getUsername());
document.setUpdateById(String.valueOf(SecurityUtils.getLoginUser().getUserId()));
document.setUpdateTime(new Date());
int result = documentMapper.updateDocument(document);
Attachment attParam = document.getAttachment();
if(ObjectUtil.isNotEmpty(attParam) && StrUtil.isBlank(attParam.getId())){
Attachment att = new Attachment();
att.setBusinessId(document.getDocId());
att.setDel(Constants.STR_ONE);
attachmentService.updateAttachmentByBusinessId(att);
Attachment attachment = document.getAttachment();
attachment.setId(IdUtil.simpleUUID());
attachment.setCreateBy(SecurityUtils.getLoginUser().getUsername());
attachment.setBusinessId(document.getDocId());
attachment.setBizType(Constants.DOC_TYPE_DOC);
attachment.setDel(Constants.STR_ZERO);
attachment.setCreateDate(new Date());
attachmentService.insertAttachment(attachment);
}
return result;
}
/**
@@ -93,7 +191,12 @@ public class DocumentServiceImpl implements IDocumentService
@Override
public int deleteDocumentByIds(String[] ids)
{
return documentMapper.deleteDocumentByIds(ids);
Document doc = new Document();
doc.setIds(Arrays.asList(ids));
doc.setUpdateBy(SecurityUtils.getLoginUser().getUsername());
doc.setUpdateById(String.valueOf(SecurityUtils.getLoginUser().getUserId()));
doc.setUpdateTime(new Date());
return documentMapper.isDeleteDocumentByIds(doc);
}
/**
@@ -107,5 +210,31 @@ public class DocumentServiceImpl implements IDocumentService
{
return documentMapper.deleteDocumentById(id);
}
/**
* 发布文档
* @param ids
* @return
*/
@Override
public int pushDoc(String[] ids) {
Document doc = new Document();
doc.setIds(Arrays.asList(ids));
doc.setUpdateBy(SecurityUtils.getLoginUser().getUsername());
doc.setUpdateById(String.valueOf(SecurityUtils.getLoginUser().getUserId()));
doc.setDocStatus(Constants.DOC_STATUS_YFB);
doc.setUpdateTime(new Date());
return documentMapper.updatePushDoc(doc);
}
/**
* 删除附件
* @param docIds
* @return
*/
@Override
public int batchDeleteById(List<String> docIds){
return documentMapper.batchDeleteById(docIds);
}
}

View File

@@ -1,17 +1,23 @@
package com.rzdata.web.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.BooleanUtil;
import cn.hutool.core.util.IdUtil;
import com.rzdata.common.constant.Constants;
import com.rzdata.common.utils.DateUtils;
import com.rzdata.common.utils.SecurityUtils;
import com.rzdata.web.domain.Document;
import com.rzdata.web.domain.Tool;
import com.rzdata.web.mapper.ToolMapper;
import com.rzdata.web.service.IAttachmentService;
import com.rzdata.web.service.IDocumentService;
import com.rzdata.web.service.IToolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.stream.Collectors;
/**
* 工具信息Service业务层处理
@@ -25,6 +31,12 @@ public class ToolServiceImpl implements IToolService
@Autowired
private ToolMapper toolMapper;
@Autowired
private IAttachmentService iAttachmentService;
@Autowired
private IDocumentService documentService;
/**
* 查询工具信息
*
@@ -84,11 +96,43 @@ public class ToolServiceImpl implements IToolService
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int updateTool(Tool tool)
{
tool.setUpdateBy(SecurityUtils.getUserId().toString());
tool.setUpdateTime(DateUtils.getNowDate());
return toolMapper.updateTool(tool);
int result = toolMapper.updateTool(tool);
deleteDocAndAtt(tool);
addDocAndAtt(tool);
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteDocAndAtt(Tool tool) {
List<Document> documentList = tool.getDocumentList();
if(CollUtil.isEmpty(documentList)){
return;
}
//先删除,后新增
List<String> docIds = documentList.stream().map(Document::getDocId).collect(Collectors.toList());
iAttachmentService.deleteAttachmentByBusinessId(docIds);
documentService.batchDeleteById(docIds);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void addDocAndAtt(Tool tool) {
List<Document> documentList = tool.getDocumentList();
if(CollUtil.isEmpty(documentList)){
return;
}
//新增
for (Document document : documentList) {
document.setToolId(tool.getToolId());
document.setDocStatus(Constants.DOC_STATUS_SHZ);
documentService.saveDocument(document);
}
}
/**
@@ -114,4 +158,17 @@ public class ToolServiceImpl implements IToolService
{
return toolMapper.deleteToolByToolId(toolId);
}
@Override
public void updateDocPushStatus(Tool tTool) {
Document document = new Document();
document.setToolId(tTool.getToolId());
List<Document> documents = documentService.selectDocumentListAll(document);
if(CollUtil.isEmpty(documents)){
return;
}
List<String> ids = documents.stream().map(Document::getDocId).collect(Collectors.toList());
String[] idsArray = ids.stream().toArray(String[]::new);
documentService.pushDoc(idsArray);
}
}