1、关联工具独立出来

2、工具管理对应的都要调整
This commit is contained in:
pan 2024-09-05 08:58:44 +08:00
parent 3b86d79ea0
commit 6f70344177
13 changed files with 101 additions and 59 deletions

View File

@ -38,7 +38,6 @@ public class AttachmentController extends BaseController
/**
* 查询附件列表
*/
@PreAuthorize("@ss.hasPermi('system:attachment:list')")
@GetMapping("/list")
public TableDataInfo list(Attachment attachment)
{
@ -50,7 +49,6 @@ public class AttachmentController extends BaseController
/**
* 导出附件列表
*/
@PreAuthorize("@ss.hasPermi('system:attachment:export')")
@Log(title = "附件", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, Attachment attachment)
@ -63,7 +61,6 @@ public class AttachmentController extends BaseController
/**
* 获取附件详细信息
*/
@PreAuthorize("@ss.hasPermi('system:attachment:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id)
{
@ -73,7 +70,6 @@ public class AttachmentController extends BaseController
/**
* 新增附件
*/
@PreAuthorize("@ss.hasPermi('system:attachment:add')")
@Log(title = "附件", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody Attachment attachment)
@ -84,7 +80,6 @@ public class AttachmentController extends BaseController
/**
* 修改附件
*/
@PreAuthorize("@ss.hasPermi('system:attachment:edit')")
@Log(title = "附件", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody Attachment attachment)
@ -95,7 +90,6 @@ public class AttachmentController extends BaseController
/**
* 删除附件
*/
@PreAuthorize("@ss.hasPermi('system:attachment:remove')")
@Log(title = "附件", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids)

View File

@ -1,6 +1,5 @@
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;
@ -170,17 +169,16 @@ public class ToolController extends BaseController
if (add) {
tTool.setProcInstId(processInstanceModel.getProcInstId());
toolService.insertTool(tTool);
//保存文档和附件
toolService.addDocAndAtt(tTool);
//保存附件
toolService.addFileList(tTool);
//记录申请数据
toolService.recordToolApply(tTool);
} else if (BooleanUtil.isTrue(tTool.getEditStatus())){
toolService.updateTool(tTool);
//删除文档和附件
toolService.deleteDocAndAtt(tTool);
//保存文档和附件
toolService.addDocAndAtt(tTool);
//删除附件
toolService.delFile(tTool);
//保存附件
toolService.addFileList(tTool);
} else {
Tool tool = new Tool();
tool.setToolId(tTool.getToolId());

View File

@ -65,12 +65,10 @@ public class Attachment extends BaseEntity
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;
@ -80,4 +78,7 @@ public class Attachment extends BaseEntity
private Date failureTime;
private List<String> businessIds;
/** 文件名称 **/
private String fileName;
}

View File

@ -21,8 +21,14 @@ public class DownloadCount extends BaseEntity
private String id;
/** 工具id */
@Excel(name = "工具id")
private String toolId;
@Excel(name = "业务id")
private String businessId;
/** 业务类型 */
private String businessType;
/** 附件id */
private String attId;
/** 附件名称 */
private String attName;
/** 创建人id */
@Excel(name = "创建人id")

View File

@ -104,6 +104,7 @@ public class Tool extends BaseEntity
private List<String> excludeFields;
private List<Document> documentList;
private List<Attachment> attachmentList;
/** 工具类型名称 **/

View File

@ -1,6 +1,7 @@
package com.rzdata.web.mapper;
import com.rzdata.web.domain.Attachment;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -68,4 +69,6 @@ public interface AttachmentMapper
public int deleteAttachmentByIds(String[] ids);
public int deleteAttachmentByBusinessId(List<String> list);
int batchInsert(@Param("attachmentList") List<Attachment> attachmentList);
}

View File

@ -67,4 +67,11 @@ public interface IAttachmentService
* @return 结果
*/
public int deleteAttachmentById(String id);
/**
* 批量插入
* @param batch
* @return
*/
public int batchInsert(List<Attachment> batch);
}

View File

@ -69,13 +69,13 @@ public interface IToolService
* 删除文档和附件
* @param tool
*/
public void deleteDocAndAtt(Tool tool);
public void delFile(Tool tool);
/**
* 新增文档和附件
* @param tool
*/
public void addDocAndAtt(Tool tool);
public void addFileList(Tool tool);
void recordToolApply(Tool tool);

View File

@ -114,4 +114,9 @@ public class AttachmentServiceImpl implements IAttachmentService
{
return attachmentMapper.deleteAttachmentById(id);
}
@Override
public int batchInsert(List<Attachment> batch) {
return attachmentMapper.batchInsert(batch);
}
}

View File

@ -16,10 +16,7 @@ import com.rzdata.common.utils.SecurityUtils;
import com.rzdata.system.service.ISysDeptService;
import com.rzdata.system.service.ISysDictTypeService;
import com.rzdata.system.service.ISysUserService;
import com.rzdata.web.domain.Document;
import com.rzdata.web.domain.Tool;
import com.rzdata.web.domain.ToolApply;
import com.rzdata.web.domain.TzMessage;
import com.rzdata.web.domain.*;
import com.rzdata.web.domain.bo.BpmClientInputModelBo;
import com.rzdata.web.mapper.ToolMapper;
import com.rzdata.web.service.*;
@ -28,10 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
@ -143,37 +137,42 @@ public class ToolServiceImpl implements IToolService
tool.setUpdateBy(SecurityUtils.getUserId().toString());
tool.setUpdateTime(DateUtils.getNowDate());
int result = toolMapper.updateTool(tool);
deleteDocAndAtt(tool);
addDocAndAtt(tool);
delFile(tool);
addFileList(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);
public void delFile(Tool tool) {
List<String> toolIds = Collections.singletonList(tool.getToolId());
iAttachmentService.deleteAttachmentByBusinessId(toolIds);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void addDocAndAtt(Tool tool) {
List<Document> documentList = tool.getDocumentList();
if(CollUtil.isEmpty(documentList)){
public void addFileList(Tool tool) {
List<Attachment> attachmentList = tool.getAttachmentList();
if(CollUtil.isEmpty(attachmentList)){
return;
}
//新增
for (Document document : documentList) {
document.setToolId(tool.getToolId());
document.setDocStatus(Constants.DOC_STATUS_SHZ);
documentService.saveDocument(document);
for (Attachment attachment : attachmentList) {
attachment.setId(String.valueOf(snowflake.nextId()));
attachment.setBusinessId(tool.getToolId());
attachment.setBizType(Constants.ATT_TYPE_TOOL);
attachment.setDel(Constants.STR_ZERO);
attachment.setCreateBy(String.valueOf(SecurityUtils.getLoginUser().getUserId()));
attachment.setCreateDate(new Date());
}
// 使用AtomicInteger来跟踪索引
AtomicInteger counter = new AtomicInteger(0);
// 使用Stream API进行分组
Map<Integer, List<Attachment>> grouped = attachmentList.stream()
.collect(Collectors.groupingBy(
e -> counter.getAndIncrement() / 500
));
// 对每个子列表进行批量插入
grouped.values().forEach(batch -> iAttachmentService.batchInsert(batch));
}
@Override

View File

@ -21,10 +21,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" />
<result property="updateDate" column="update_date" />
<result property="failureTime" column="failure_time" />
<result property="fileName" column="file_name" />
</resultMap>
<sql id="selectAttachmentVo">
select id, biz_type, file_url, file_old_name, file_new_name, suffix_type, file_size, business_id, sorts, remark, del, create_by, create_date, update_by, update_date, failure_time from t_attachment
select id, biz_type, file_url, file_old_name, file_new_name, suffix_type,
file_size, business_id, sorts, remark, del, create_by, create_date,
update_by, update_date, failure_time, file_old_name as file_name
from t_attachment
</sql>
<select id="selectAttachmentList" parameterType="Attachment" resultMap="AttachmentResult">
@ -158,4 +162,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</delete>
<insert id="batchInsert" parameterType="java.util.List">
INSERT INTO t_attachment (id, biz_type, file_url, file_old_name, file_new_name, suffix_type, file_size, business_id, sorts, remark, del, create_by, create_date)
VALUES
<foreach item="item" index="index" collection="attachmentList" open="(" separator="),(" close=")">
#{item.id}, #{item.bizType}, #{item.fileUrl}, #{item.fileOldName}, #{item.fileNewName}, #{item.suffixType}, #{item.fileSize}, #{item.businessId}, #{item.sorts}, #{item.remark}, #{item.del}, #{item.createBy}, #{item.createDate}
</foreach>
</insert>
</mapper>

View File

@ -6,7 +6,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="DownloadCount" id="DownloadCountResult">
<result property="id" column="id" />
<result property="toolId" column="tool_id" />
<result property="businessId" column="business_id" />
<result property="businessType" column="business_type" />
<result property="attId" column="att_id" />
<result property="attName" column="att_name" />
<result property="createBy" column="create_by" />
<result property="createById" column="create_by_id" />
<result property="createTime" column="create_time" />
@ -20,15 +23,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectDownloadCountVo">
select id, tool_id, create_by, create_by_id, create_time, update_by, update_by_id, update_time from t_download_count
select id, business_id,business_type,att_id,att_name
create_by, create_by_id, create_time, update_by, update_by_id, update_time from t_download_count
</sql>
<select id="selectDownloadCountList" parameterType="DownloadCount" resultMap="DownloadCountResult">
select
tdc.tool_id,tl.tool_code,tl.tool_name,sum(1) as tool_down_num
tdc.business_id,tdc.att_name,tl.tool_code,tl.tool_name,sum(1) as tool_down_num
from t_download_count tdc
left join t_tool tl on tdc.tool_id = tl.tool_id
left join t_tool tl on tdc.business_id = tl.tool_id
<where>
and business_type = 'tool'
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
AND date_format(tdc.create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
</if>
@ -42,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND tl.tool_name like concat('%', #{toolName}, '%')
</if>
</where>
group by tdc.tool_id,tl.tool_code,tl.tool_name
group by tdc.business_id,tdc.att_name,tl.tool_code,tl.tool_name
</select>
<select id="selectDownloadCountById" parameterType="String" resultMap="DownloadCountResult">
@ -54,7 +59,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
insert into t_download_count
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="toolId != null">tool_id,</if>
<if test="businessId != null">business_id,</if>
<if test="businessType != null">business_type,</if>
<if test="attId != null">att_id,</if>
<if test="attName != null">att_name,</if>
<if test="createBy != null">create_by,</if>
<if test="createById != null">create_by_id,</if>
<if test="createTime != null">create_time,</if>
@ -64,7 +72,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="toolId != null">#{toolId},</if>
<if test="businessId != null">#{businessId},</if>
<if test="businessType != null">#{businessType},</if>
<if test="attId != null">#{attId},</if>
<if test="attName != null">#{attName},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createById != null">#{createById},</if>
<if test="createTime != null">#{createTime},</if>
@ -77,7 +88,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateDownloadCount" parameterType="DownloadCount">
update t_download_count
<trim prefix="SET" suffixOverrides=",">
<if test="toolId != null">tool_id = #{toolId},</if>
<if test="businessId != null">business_id = #{businessId},</if>
<if test="businessType != null">business_type = #{businessType},</if>
<if test="attId != null">att_id = #{attId},</if>
<if test="attName != null">att_name = #{attName},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createById != null">create_by_id = #{createById},</if>
<if test="createTime != null">create_time = #{createTime},</if>
@ -102,12 +116,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="userDownList" parameterType="DownloadCount" resultMap="DownloadCountResult">
select
tdc.tool_id,su.nick_name,tdc.create_time,sum(1) as tool_down_num
tdc.business_id,tdc.att_name,su.nick_name,tdc.create_time,sum(1) as tool_down_num
from t_download_count tdc
left join sys_user su on tdc.create_by_id = su.user_id
<where>
<if test="toolId != null and toolId != ''">
AND tool_id = #{toolId}
<if test="businessId != null and businessId != ''">
AND business_id = #{businessId}
</if>
</where>
group by su.nick_name

View File

@ -192,6 +192,8 @@ public class Constants
/** 文档-doc **/
public static final String DOC_TYPE_DOC = "doc";
/** 工具状态 **/
public static final String ATT_TYPE_TOOL = "tool";
public static final String STR_ZERO = "0";