release-v1.0 #1

Merged
panchichun merged 41 commits from release-v1.0 into main 2024-09-13 17:03:09 +08:00
13 changed files with 101 additions and 59 deletions
Showing only changes of commit 6f70344177 - Show all commits

View File

@ -38,7 +38,6 @@ public class AttachmentController extends BaseController
/** /**
* 查询附件列表 * 查询附件列表
*/ */
@PreAuthorize("@ss.hasPermi('system:attachment:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(Attachment attachment) 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) @Log(title = "附件", businessType = BusinessType.EXPORT)
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, Attachment attachment) 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}") @GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String 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) @Log(title = "附件", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@RequestBody Attachment attachment) 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) @Log(title = "附件", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody Attachment attachment) 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) @Log(title = "附件", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids) public AjaxResult remove(@PathVariable String[] ids)

View File

@ -1,6 +1,5 @@
package com.rzdata.web.controller.tool; package com.rzdata.web.controller.tool;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.BooleanUtil; import cn.hutool.core.util.BooleanUtil;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import com.blueland.bpmclient.model.ProcessInstanceModel; import com.blueland.bpmclient.model.ProcessInstanceModel;
@ -170,17 +169,16 @@ public class ToolController extends BaseController
if (add) { if (add) {
tTool.setProcInstId(processInstanceModel.getProcInstId()); tTool.setProcInstId(processInstanceModel.getProcInstId());
toolService.insertTool(tTool); toolService.insertTool(tTool);
//保存文档和附件 //保存附件
toolService.addDocAndAtt(tTool); toolService.addFileList(tTool);
//记录申请数据 //记录申请数据
toolService.recordToolApply(tTool); toolService.recordToolApply(tTool);
} else if (BooleanUtil.isTrue(tTool.getEditStatus())){ } else if (BooleanUtil.isTrue(tTool.getEditStatus())){
toolService.updateTool(tTool); toolService.updateTool(tTool);
//删除文档和附件 //删除附件
toolService.deleteDocAndAtt(tTool); toolService.delFile(tTool);
//保存文档和附件 //保存附件
toolService.addDocAndAtt(tTool); toolService.addFileList(tTool);
} else { } else {
Tool tool = new Tool(); Tool tool = new Tool();
tool.setToolId(tTool.getToolId()); tool.setToolId(tTool.getToolId());

View File

@ -65,12 +65,10 @@ public class Attachment extends BaseEntity
private String del; private String del;
/** 创建时间 */ /** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date createDate; private Date createDate;
/** 更新时间 */ /** 更新时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date updateDate; private Date updateDate;
@ -80,4 +78,7 @@ public class Attachment extends BaseEntity
private Date failureTime; private Date failureTime;
private List<String> businessIds; private List<String> businessIds;
/** 文件名称 **/
private String fileName;
} }

View File

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

View File

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

View File

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

View File

@ -67,4 +67,11 @@ public interface IAttachmentService
* @return 结果 * @return 结果
*/ */
public int deleteAttachmentById(String id); 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 * @param tool
*/ */
public void deleteDocAndAtt(Tool tool); public void delFile(Tool tool);
/** /**
* 新增文档和附件 * 新增文档和附件
* @param tool * @param tool
*/ */
public void addDocAndAtt(Tool tool); public void addFileList(Tool tool);
void recordToolApply(Tool tool); void recordToolApply(Tool tool);

View File

@ -114,4 +114,9 @@ public class AttachmentServiceImpl implements IAttachmentService
{ {
return attachmentMapper.deleteAttachmentById(id); 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.ISysDeptService;
import com.rzdata.system.service.ISysDictTypeService; import com.rzdata.system.service.ISysDictTypeService;
import com.rzdata.system.service.ISysUserService; import com.rzdata.system.service.ISysUserService;
import com.rzdata.web.domain.Document; import com.rzdata.web.domain.*;
import com.rzdata.web.domain.Tool;
import com.rzdata.web.domain.ToolApply;
import com.rzdata.web.domain.TzMessage;
import com.rzdata.web.domain.bo.BpmClientInputModelBo; import com.rzdata.web.domain.bo.BpmClientInputModelBo;
import com.rzdata.web.mapper.ToolMapper; import com.rzdata.web.mapper.ToolMapper;
import com.rzdata.web.service.*; import com.rzdata.web.service.*;
@ -28,10 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -143,37 +137,42 @@ public class ToolServiceImpl implements IToolService
tool.setUpdateBy(SecurityUtils.getUserId().toString()); tool.setUpdateBy(SecurityUtils.getUserId().toString());
tool.setUpdateTime(DateUtils.getNowDate()); tool.setUpdateTime(DateUtils.getNowDate());
int result = toolMapper.updateTool(tool); int result = toolMapper.updateTool(tool);
deleteDocAndAtt(tool); delFile(tool);
addDocAndAtt(tool); addFileList(tool);
return result; return result;
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void deleteDocAndAtt(Tool tool) { public void delFile(Tool tool) {
List<Document> documentList = tool.getDocumentList(); List<String> toolIds = Collections.singletonList(tool.getToolId());
if(CollUtil.isEmpty(documentList)){ iAttachmentService.deleteAttachmentByBusinessId(toolIds);
return;
}
//先删除后新增
List<String> docIds = documentList.stream().map(Document::getDocId).collect(Collectors.toList());
iAttachmentService.deleteAttachmentByBusinessId(docIds);
documentService.batchDeleteById(docIds);
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void addDocAndAtt(Tool tool) { public void addFileList(Tool tool) {
List<Document> documentList = tool.getDocumentList(); List<Attachment> attachmentList = tool.getAttachmentList();
if(CollUtil.isEmpty(documentList)){ if(CollUtil.isEmpty(attachmentList)){
return; return;
} }
//新增 for (Attachment attachment : attachmentList) {
for (Document document : documentList) { attachment.setId(String.valueOf(snowflake.nextId()));
document.setToolId(tool.getToolId()); attachment.setBusinessId(tool.getToolId());
document.setDocStatus(Constants.DOC_STATUS_SHZ); attachment.setBizType(Constants.ATT_TYPE_TOOL);
documentService.saveDocument(document); 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 @Override

View File

@ -21,10 +21,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
<result property="updateDate" column="update_date" /> <result property="updateDate" column="update_date" />
<result property="failureTime" column="failure_time" /> <result property="failureTime" column="failure_time" />
<result property="fileName" column="file_name" />
</resultMap> </resultMap>
<sql id="selectAttachmentVo"> <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> </sql>
<select id="selectAttachmentList" parameterType="Attachment" resultMap="AttachmentResult"> <select id="selectAttachmentList" parameterType="Attachment" resultMap="AttachmentResult">
@ -158,4 +162,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach> </foreach>
</delete> </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> </mapper>

View File

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

View File

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