统计代码

This commit is contained in:
pan 2024-08-31 16:11:20 +08:00
parent d732771032
commit b6a66db6cb
20 changed files with 1252 additions and 10 deletions

View File

@ -0,0 +1,118 @@
package com.rzdata.web.controller.tool;
import javax.servlet.http.HttpServletResponse;
import com.rzdata.common.utils.poi.ExcelUtil;
import com.rzdata.web.domain.DownloadCount;
import com.rzdata.web.service.IDownloadCountService;
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.core.page.TableDataInfo;
import java.util.List;
/**
* 工具下载统计Controller
*
* @author 潘驰春
* @date 2024-08-31
*/
@RestController
@RequestMapping("/system/count")
public class DownloadCountController extends BaseController
{
@Autowired
private IDownloadCountService downloadCountService;
/**
* 查询工具下载统计列表
*/
@GetMapping("/list")
public TableDataInfo list(DownloadCount downloadCount)
{
startPage();
List<DownloadCount> list = downloadCountService.selectDownloadCountList(downloadCount);
return getDataTable(list);
}
/**
* 根据详情统计
*/
@GetMapping("/user/down/list")
public TableDataInfo userDownList(DownloadCount downloadCount)
{
startPage();
List<DownloadCount> list = downloadCountService.userDownList(downloadCount);
return getDataTable(list);
}
/**
* 导出工具下载统计列表
*/
@PreAuthorize("@ss.hasPermi('system:count:export')")
@Log(title = "工具下载统计", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DownloadCount downloadCount)
{
List<DownloadCount> list = downloadCountService.selectDownloadCountList(downloadCount);
ExcelUtil<DownloadCount> util = new ExcelUtil<DownloadCount>(DownloadCount.class);
util.exportExcel(response, list, "工具下载统计数据");
}
/**
* 获取工具下载统计详细信息
*/
@PreAuthorize("@ss.hasPermi('system:count:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id)
{
return success(downloadCountService.selectDownloadCountById(id));
}
/**
* 新增工具下载统计
*/
@PreAuthorize("@ss.hasPermi('system:count:add')")
@Log(title = "工具下载统计", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DownloadCount downloadCount)
{
return toAjax(downloadCountService.insertDownloadCount(downloadCount));
}
/**
* 修改工具下载统计
*/
@PreAuthorize("@ss.hasPermi('system:count:edit')")
@Log(title = "工具下载统计", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DownloadCount downloadCount)
{
return toAjax(downloadCountService.updateDownloadCount(downloadCount));
}
/**
* 删除工具下载统计
*/
@PreAuthorize("@ss.hasPermi('system:count:remove')")
@Log(title = "工具下载统计", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids)
{
return toAjax(downloadCountService.deleteDownloadCountByIds(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;
@ -15,7 +14,6 @@ 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;
@ -27,9 +25,8 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.Map;
/**
* 工具信息Controller
@ -165,6 +162,8 @@ public class ToolController extends BaseController
if(RecordStatusEnum.DONE.getCode().equals(tTool.getRecordStatus())){
//更新文档状态
toolService.updateDocPushStatus(tTool);
//给消息中心发送消息
toolService.sendTzMessage(tTool);
}
return AjaxResult.success("操作成功",processInstanceModel);
}else {
@ -191,4 +190,14 @@ public class ToolController extends BaseController
{
return toAjax(toolService.deleteToolByToolIds(toolIds));
}
/**
* 工具统计
*/
@GetMapping("/statistics")
public AjaxResult statistics()
{
return AjaxResult.success(toolService.statistics());
}
}

View File

@ -0,0 +1,112 @@
package com.rzdata.web.controller.tool;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.rzdata.web.domain.TzMessage;
import com.rzdata.web.service.ITzMessageService;
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 ja
* @date 2024-08-31
*/
@RestController
@RequestMapping("/system/message")
public class TzMessageController extends BaseController
{
@Autowired
private ITzMessageService tzMessageService;
/**
* 查询消息列表
*/
@PreAuthorize("@ss.hasPermi('system:message:list')")
@GetMapping("/list")
public TableDataInfo list(TzMessage tzMessage)
{
startPage();
List<TzMessage> list = tzMessageService.selectTzMessageList(tzMessage);
return getDataTable(list);
}
/**
* 导出消息列表
*/
@Log(title = "消息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, TzMessage tzMessage)
{
List<TzMessage> list = tzMessageService.selectTzMessageList(tzMessage);
ExcelUtil<TzMessage> util = new ExcelUtil<TzMessage>(TzMessage.class);
util.exportExcel(response, list, "消息数据");
}
/**
* 获取消息详细信息
*/
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id)
{
return success(tzMessageService.selectTzMessageById(id));
}
/**
* 新增消息
*/
@PreAuthorize("@ss.hasPermi('system:message:add')")
@Log(title = "消息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody TzMessage tzMessage)
{
return toAjax(tzMessageService.insertTzMessage(tzMessage));
}
/**
* 修改消息
*/
@Log(title = "消息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody TzMessage tzMessage)
{
return toAjax(tzMessageService.updateTzMessage(tzMessage));
}
/**
* 删除消息
*/
@Log(title = "消息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids)
{
return toAjax(tzMessageService.deleteTzMessageByIds(ids));
}
/**
* 全部标记已读
*/
@Log(title = "全部标记已读", businessType = BusinessType.UPDATE)
@PostMapping("/allMarkedRead")
public AjaxResult allMarkedRead(@RequestBody TzMessage tzMessage)
{
return toAjax(tzMessageService.allMarkedRead(tzMessage));
}
}

View File

@ -133,6 +133,11 @@ public class UseApplyController extends BaseController
updateStatus.setRecordStatus(useApply.getRecordStatus());
useApplyService.updateUseApply(updateStatus);
}
//办结
if(RecordStatusEnum.DONE.getCode().equals(useApply)){
//给消息中心发送消息
useApplyService.sendTzMessage(useApply);
}
return AjaxResult.success("操作成功",processInstanceModel);
}else {
return AjaxResult.error();

View File

@ -0,0 +1,42 @@
package com.rzdata.web.domain;
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;
/**
* 工具下载统计对象 t_download_count
*
* @author 潘驰春
* @date 2024-08-31
*/
@Data
public class DownloadCount extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键 */
private String id;
/** 工具id */
@Excel(name = "工具id")
private String toolId;
/** 创建人id */
@Excel(name = "创建人id")
private String createById;
/** 更新人id */
@Excel(name = "更新人id")
private String updateById;
/** 工具code */
private String toolCode;
/** 工具名称 */
private String toolName;
/** 工具下载数量 */
private String toolDownNum;
}

View File

@ -0,0 +1,38 @@
package com.rzdata.web.domain;
import com.rzdata.common.annotation.Excel;
import com.rzdata.common.core.domain.BaseEntity;
import lombok.Data;
/**
* 消息对象 tz_message
*
* @author ja
* @date 2024-08-31
*/
@Data
public class TzMessage extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 消息id */
private String id;
/** 消息接收者id */
@Excel(name = "消息接收者id")
private String receiverId;
/** 状态2已读1未读 */
@Excel(name = "状态", readConverterExp = "2=已读1未读")
private Integer states;
/** 消息推送内容 */
@Excel(name = "消息推送内容")
private String content;
/** 逻辑删除标记:1删除;0未删除 */
@Excel(name = "逻辑删除标记:1删除;0未删除")
private String deleted;
private String createById;
private String updateById;
}

View File

@ -0,0 +1,64 @@
package com.rzdata.web.mapper;
import com.rzdata.web.domain.DownloadCount;
import java.util.List;
/**
* 工具下载统计Mapper接口
*
* @author 潘驰春
* @date 2024-08-31
*/
public interface DownloadCountMapper
{
/**
* 查询工具下载统计
*
* @param id 工具下载统计主键
* @return 工具下载统计
*/
public DownloadCount selectDownloadCountById(String id);
/**
* 查询工具下载统计列表
*
* @param downloadCount 工具下载统计
* @return 工具下载统计集合
*/
public List<DownloadCount> selectDownloadCountList(DownloadCount downloadCount);
/**
* 新增工具下载统计
*
* @param downloadCount 工具下载统计
* @return 结果
*/
public int insertDownloadCount(DownloadCount downloadCount);
/**
* 修改工具下载统计
*
* @param downloadCount 工具下载统计
* @return 结果
*/
public int updateDownloadCount(DownloadCount downloadCount);
/**
* 删除工具下载统计
*
* @param id 工具下载统计主键
* @return 结果
*/
public int deleteDownloadCountById(String id);
/**
* 批量删除工具下载统计
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteDownloadCountByIds(String[] ids);
List<DownloadCount> userDownList(DownloadCount downloadCount);
}

View File

@ -3,6 +3,7 @@ package com.rzdata.web.mapper;
import com.rzdata.web.domain.Tool;
import java.util.List;
import java.util.Map;
/**
* 工具信息Mapper接口
@ -63,4 +64,8 @@ public interface ToolMapper
* @return 结果
*/
public int deleteToolByToolIds(String[] toolIds);
List<Map<String, Object>> countToolType();
List<Map<String, Object>> toolSource();
List<Map<String, Object>> recordStatus();
}

View File

@ -0,0 +1,77 @@
package com.rzdata.web.mapper;
import com.rzdata.web.domain.TzMessage;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 消息Mapper接口
*
* @author ja
* @date 2024-08-31
*/
public interface TzMessageMapper
{
/**
* 查询消息
*
* @param id 消息主键
* @return 消息
*/
public TzMessage selectTzMessageById(String id);
/**
* 查询消息列表
*
* @param tzMessage 消息
* @return 消息集合
*/
public List<TzMessage> selectTzMessageList(TzMessage tzMessage);
/**
* 新增消息
*
* @param tzMessage 消息
* @return 结果
*/
public int insertTzMessage(TzMessage tzMessage);
/**
* 修改消息
*
* @param tzMessage 消息
* @return 结果
*/
public int updateTzMessage(TzMessage tzMessage);
/**
* 删除消息
*
* @param id 消息主键
* @return 结果
*/
public int deleteTzMessageById(String id);
/**
* 批量删除消息
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteTzMessageByIds(String[] ids);
/**
* 更新所有的消息为已读
* @param tzMessage
* @return
*/
public int updateAllMarkedRead(TzMessage tzMessage);
/**
* 批量插入
* @param tzMessageList
* @return
*/
public int batchInsert(@Param("tzMessageList") List<TzMessage> tzMessageList);
}

View File

@ -0,0 +1,69 @@
package com.rzdata.web.service;
import com.rzdata.web.domain.DownloadCount;
import java.util.List;
/**
* 工具下载统计Service接口
*
* @author 潘驰春
* @date 2024-08-31
*/
public interface IDownloadCountService
{
/**
* 查询工具下载统计
*
* @param id 工具下载统计主键
* @return 工具下载统计
*/
public DownloadCount selectDownloadCountById(String id);
/**
* 查询工具下载统计列表
*
* @param downloadCount 工具下载统计
* @return 工具下载统计集合
*/
public List<DownloadCount> selectDownloadCountList(DownloadCount downloadCount);
/**
* 新增工具下载统计
*
* @param downloadCount 工具下载统计
* @return 结果
*/
public int insertDownloadCount(DownloadCount downloadCount);
/**
* 修改工具下载统计
*
* @param downloadCount 工具下载统计
* @return 结果
*/
public int updateDownloadCount(DownloadCount downloadCount);
/**
* 批量删除工具下载统计
*
* @param ids 需要删除的工具下载统计主键集合
* @return 结果
*/
public int deleteDownloadCountByIds(String[] ids);
/**
* 删除工具下载统计信息
*
* @param id 工具下载统计主键
* @return 结果
*/
public int deleteDownloadCountById(String id);
/**
* 用户下载列表
* @param downloadCount
* @return
*/
List<DownloadCount> userDownList(DownloadCount downloadCount);
}

View File

@ -3,6 +3,7 @@ package com.rzdata.web.service;
import com.rzdata.web.domain.Tool;
import java.util.List;
import java.util.Map;
/**
* 工具信息Service接口
@ -77,4 +78,8 @@ public interface IToolService
public void addDocAndAtt(Tool tool);
void updateDocPushStatus(Tool tTool);
void sendTzMessage(Tool tTool);
Map<String, Object> statistics();
}

View File

@ -0,0 +1,67 @@
package com.rzdata.web.service;
import com.rzdata.web.domain.TzMessage;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
/**
* 消息Service接口
*
* @author ja
* @date 2024-08-31
*/
public interface ITzMessageService
{
/**
* 查询消息
*
* @param id 消息主键
* @return 消息
*/
public TzMessage selectTzMessageById(String id);
/**
* 查询消息列表
*
* @param tzMessage 消息
* @return 消息集合
*/
public List<TzMessage> selectTzMessageList(TzMessage tzMessage);
/**
* 新增消息
*
* @param tzMessage 消息
* @return 结果
*/
public int insertTzMessage(TzMessage tzMessage);
/**
* 修改消息
*
* @param tzMessage 消息
* @return 结果
*/
public int updateTzMessage(TzMessage tzMessage);
/**
* 批量删除消息
*
* @param ids 需要删除的消息主键集合
* @return 结果
*/
public int deleteTzMessageByIds(String[] ids);
/**
* 删除消息信息
*
* @param id 消息主键
* @return 结果
*/
public int deleteTzMessageById(String id);
int allMarkedRead(TzMessage tzMessage);
public int batchInsert(List<TzMessage> tzMessageList);
}

View File

@ -63,4 +63,6 @@ public interface IUseApplyService
public int deleteUseApplyById(String id);
boolean checkUseApply(String toolId, String userId);
void sendTzMessage(UseApply useApply);
}

View File

@ -0,0 +1,101 @@
package com.rzdata.web.service.impl;
import java.util.List;
import com.rzdata.common.utils.DateUtils;
import com.rzdata.web.domain.DownloadCount;
import com.rzdata.web.mapper.DownloadCountMapper;
import com.rzdata.web.service.IDownloadCountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 工具下载统计Service业务层处理
*
* @author 潘驰春
* @date 2024-08-31
*/
@Service
public class DownloadCountServiceImpl implements IDownloadCountService
{
@Autowired
private DownloadCountMapper downloadCountMapper;
/**
* 查询工具下载统计
*
* @param id 工具下载统计主键
* @return 工具下载统计
*/
@Override
public DownloadCount selectDownloadCountById(String id)
{
return downloadCountMapper.selectDownloadCountById(id);
}
/**
* 查询工具下载统计列表
*
* @param downloadCount 工具下载统计
* @return 工具下载统计
*/
@Override
public List<DownloadCount> selectDownloadCountList(DownloadCount downloadCount)
{
return downloadCountMapper.selectDownloadCountList(downloadCount);
}
/**
* 新增工具下载统计
*
* @param downloadCount 工具下载统计
* @return 结果
*/
@Override
public int insertDownloadCount(DownloadCount downloadCount)
{
downloadCount.setCreateTime(DateUtils.getNowDate());
return downloadCountMapper.insertDownloadCount(downloadCount);
}
/**
* 修改工具下载统计
*
* @param downloadCount 工具下载统计
* @return 结果
*/
@Override
public int updateDownloadCount(DownloadCount downloadCount)
{
downloadCount.setUpdateTime(DateUtils.getNowDate());
return downloadCountMapper.updateDownloadCount(downloadCount);
}
/**
* 批量删除工具下载统计
*
* @param ids 需要删除的工具下载统计主键
* @return 结果
*/
@Override
public int deleteDownloadCountByIds(String[] ids)
{
return downloadCountMapper.deleteDownloadCountByIds(ids);
}
/**
* 删除工具下载统计信息
*
* @param id 工具下载统计主键
* @return 结果
*/
@Override
public int deleteDownloadCountById(String id)
{
return downloadCountMapper.deleteDownloadCountById(id);
}
@Override
public List<DownloadCount> userDownList(DownloadCount downloadCount) {
return downloadCountMapper.userDownList(downloadCount);
}
}

View File

@ -1,23 +1,37 @@
package com.rzdata.web.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.BooleanUtil;
import cn.hutool.core.util.IdUtil;
import com.rzdata.common.annotation.DataScope;
import com.rzdata.common.constant.Constants;
import com.rzdata.common.core.domain.entity.SysDictData;
import com.rzdata.common.core.domain.entity.SysUser;
import com.rzdata.common.utils.DateUtils;
import com.rzdata.common.utils.SecurityUtils;
import com.rzdata.system.service.ISysDictDataService;
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.TzMessage;
import com.rzdata.web.domain.UseApplyItem;
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 com.rzdata.web.service.ITzMessageService;
import lombok.extern.slf4j.Slf4j;
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.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/**
@ -26,6 +40,7 @@ import java.util.stream.Collectors;
* @author ja
* @date 2024-07-15
*/
@Slf4j
@Service
public class ToolServiceImpl implements IToolService
{
@ -38,6 +53,21 @@ public class ToolServiceImpl implements IToolService
@Autowired
private IDocumentService documentService;
@Autowired
private ISysUserService sysUserService;
@Autowired
private Snowflake snowflake;
@Autowired
private ITzMessageService tzMessageService;
@Autowired
private ISysDictTypeService sysDictTypeService;
/**
* 查询工具信息
*
@ -173,4 +203,103 @@ public class ToolServiceImpl implements IToolService
String[] idsArray = ids.stream().toArray(String[]::new);
documentService.pushDoc(idsArray);
}
/**
* 给消息中心发送消息
*/
@Override
public void sendTzMessage(Tool tTool) {
try{
SysUser sysUser = new SysUser();
sysUser.setStatus("0");
sysUser.setDelFlag("0");
String content = tTool.getToolName() + "已发布";
List<SysUser> sysUsers = sysUserService.selectUserList(sysUser);
List<TzMessage> addList = new ArrayList<>();
for (SysUser user : sysUsers) {
TzMessage tzMessage = new TzMessage();
//雪花
tzMessage.setId(String.valueOf(snowflake.nextId()));
tzMessage.setReceiverId(String.valueOf(user.getUserId()));
tzMessage.setStates(1);
tzMessage.setContent(content);
tzMessage.setDeleted("0");
tzMessage.setCreateTime(DateUtils.getNowDate());
tzMessage.setCreateBy(SecurityUtils.getLoginUser().getUsername());
tzMessage.setCreateById(String.valueOf(SecurityUtils.getLoginUser().getUserId()));
addList.add(tzMessage);
}
// 使用AtomicInteger来跟踪索引
AtomicInteger counter = new AtomicInteger(0);
// 使用Stream API进行分组
Map<Integer, List<TzMessage>> grouped = addList.stream()
.collect(Collectors.groupingBy(
e -> counter.getAndIncrement() / 500
));
// 对每个子列表进行批量插入
grouped.values().forEach(batch -> tzMessageService.batchInsert(batch));
}catch (Exception e){
log.error("UseApplyServiceImpl-->sendTzMessage--发送消息中心异常--e###", e);
}
}
@Override
public Map<String, Object> statistics() {
Map<String, Object> result = new HashMap<>();
List<Map<String, Object>> countToolType = toolMapper.countToolType();
List<Map<String, Object>> toolSource = toolMapper.toolSource();
List<Map<String, Object>> recordStatus = toolMapper.recordStatus();
//组织数据
assembleData(countToolType, toolSource, recordStatus);
result.put("countToolType", countToolType);
result.put("toolSource", toolSource);
result.put("recordStatus", recordStatus);
return result;
}
private void assembleData(List<Map<String, Object>> countToolType, List<Map<String, Object>> toolSource, List<Map<String, Object>> recordStatus) {
List<SysDictData> toolTypeList = sysDictTypeService.selectDictDataByType("tool_type");
List<SysDictData> flowStatusList = sysDictTypeService.selectDictDataByType("flow_status");
List<SysDictData> toolSourceList = sysDictTypeService.selectDictDataByType("tool_source");
if(CollUtil.isNotEmpty(countToolType)){
for (Map<String, Object> map : countToolType) {
map.put("value", map.get("statistics"));
for (SysDictData sysDictData : toolTypeList) {
if(sysDictData.getDictValue().equals(map.get("types"))){
map.put("name", sysDictData.getDictLabel());
break;
}
}
}
}
if(CollUtil.isNotEmpty(toolSource)){
for (Map<String, Object> map : toolSource) {
map.put("value", map.get("statistics"));
for (SysDictData sysDictData : toolSourceList) {
if(sysDictData.getDictValue().equals(map.get("types"))){
map.put("name", sysDictData.getDictLabel());
break;
}
}
}
}
if(CollUtil.isNotEmpty(recordStatus)){
for (Map<String, Object> map : recordStatus) {
map.put("value", map.get("statistics"));
for (SysDictData sysDictData : flowStatusList) {
if(sysDictData.getDictValue().equals(map.get("types"))){
map.put("name", sysDictData.getDictLabel());
break;
}
}
}
}
}
}

View File

@ -0,0 +1,120 @@
package com.rzdata.web.service.impl;
import java.util.List;
import com.rzdata.common.utils.DateUtils;
import com.rzdata.common.utils.SecurityUtils;
import com.rzdata.web.domain.TzMessage;
import com.rzdata.web.mapper.TzMessageMapper;
import com.rzdata.web.service.ITzMessageService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
/**
* 消息Service业务层处理
*
* @author ja
* @date 2024-08-31
*/
@Service
public class TzMessageServiceImpl implements ITzMessageService
{
@Autowired
private TzMessageMapper tzMessageMapper;
/**
* 查询消息
*
* @param id 消息主键
* @return 消息
*/
@Override
public TzMessage selectTzMessageById(String id)
{
return tzMessageMapper.selectTzMessageById(id);
}
/**
* 查询消息列表
*
* @param tzMessage 消息
* @return 消息
*/
@Override
public List<TzMessage> selectTzMessageList(TzMessage tzMessage)
{
return tzMessageMapper.selectTzMessageList(tzMessage);
}
/**
* 新增消息
*
* @param tzMessage 消息
* @return 结果
*/
@Override
public int insertTzMessage(TzMessage tzMessage)
{
tzMessage.setCreateTime(DateUtils.getNowDate());
tzMessage.setCreateBy(SecurityUtils.getLoginUser().getUsername());
tzMessage.setCreateById(String.valueOf(SecurityUtils.getLoginUser().getUserId()));
return tzMessageMapper.insertTzMessage(tzMessage);
}
/**
* 修改消息
*
* @param tzMessage 消息
* @return 结果
*/
@Override
public int updateTzMessage(TzMessage tzMessage)
{
tzMessage.setUpdateTime(DateUtils.getNowDate());
tzMessage.setUpdateBy(SecurityUtils.getLoginUser().getUsername());
tzMessage.setUpdateById(String.valueOf(SecurityUtils.getLoginUser().getUserId()));
return tzMessageMapper.updateTzMessage(tzMessage);
}
/**
* 批量删除消息
*
* @param ids 需要删除的消息主键
* @return 结果
*/
@Override
public int deleteTzMessageByIds(String[] ids)
{
return tzMessageMapper.deleteTzMessageByIds(ids);
}
/**
* 删除消息信息
*
* @param id 消息主键
* @return 结果
*/
@Override
public int deleteTzMessageById(String id)
{
return tzMessageMapper.deleteTzMessageById(id);
}
/**
* 全部标记已读
* @param tzMessage
* @return
*/
@Override
public int allMarkedRead( TzMessage tzMessage) {
tzMessage.setCreateById(String.valueOf(SecurityUtils.getLoginUser().getUserId()));
return tzMessageMapper.updateAllMarkedRead(tzMessage);
}
@Override
public int batchInsert(List<TzMessage> tzMessageList) {
return tzMessageMapper.batchInsert(tzMessageList);
}
}

View File

@ -1,15 +1,24 @@
package com.rzdata.web.service.impl;
import java.util.List;
import cn.hutool.core.lang.Snowflake;
import com.rzdata.common.core.domain.entity.SysUser;
import com.rzdata.common.utils.DateUtils;
import com.rzdata.common.utils.SecurityUtils;
import com.rzdata.web.domain.Tool;
import org.apache.ibatis.annotations.Param;
import com.rzdata.system.service.ISysUserService;
import com.rzdata.web.domain.TzMessage;
import com.rzdata.web.domain.UseApply;
import com.rzdata.web.domain.UseApplyItem;
import com.rzdata.web.mapper.UseApplyMapper;
import com.rzdata.web.service.ITzMessageService;
import com.rzdata.web.service.IUseApplyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.rzdata.web.mapper.UseApplyMapper;
import com.rzdata.web.domain.UseApply;
import com.rzdata.web.service.IUseApplyService;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/**
* 使用申请Service业务层处理
@ -17,12 +26,25 @@ import com.rzdata.web.service.IUseApplyService;
* @author ja
* @date 2024-08-21
*/
@Slf4j
@Service
public class UseApplyServiceImpl implements IUseApplyService
{
@Autowired
private UseApplyMapper useApplyMapper;
@Autowired
private ISysUserService sysUserService;
@Autowired
private Snowflake snowflake;
@Autowired
private ITzMessageService tzMessageService;
/**
* 查询使用申请
*
@ -106,4 +128,27 @@ public class UseApplyServiceImpl implements IUseApplyService
public boolean checkUseApply(String toolId, String userId){
return useApplyMapper.checkUseApply(toolId, userId)>0;
}
@Override
public void sendTzMessage(UseApply useApply) {
try{
SysUser sysUser = sysUserService.selectUserById(Long.valueOf(useApply.getUserId()));
UseApplyItem useApplyItem = useApply.getItemList().get(0);
String toolName = useApplyItem.getToolName();
String content = toolName + "下载权限已通过";
TzMessage tzMessage = new TzMessage();
//雪花
tzMessage.setId(String.valueOf(snowflake.nextId()));
tzMessage.setReceiverId(String.valueOf(sysUser.getUserId()));
tzMessage.setStates(1);
tzMessage.setContent(content);
tzMessage.setDeleted("0");
tzMessageService.insertTzMessage(tzMessage);
}catch (Exception e){
log.error("UseApplyServiceImpl-->sendTzMessage--发送消息中心异常--e###", e);
}
}
}

View File

@ -0,0 +1,109 @@
<?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.rzdata.web.mapper.DownloadCountMapper">
<resultMap type="DownloadCount" id="DownloadCountResult">
<result property="id" column="id" />
<result property="toolId" column="tool_id" />
<result property="createBy" column="create_by" />
<result property="createById" column="create_by_id" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateById" column="update_by_id" />
<result property="updateTime" column="update_time" />
<result property="toolCode" column="tool_code" />
<result property="toolName" column="tool_name" />
<result property="toolDownNum" column="tool_down_num" />
</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
</sql>
<select id="selectDownloadCountList" parameterType="DownloadCount" resultMap="DownloadCountResult">
select
tdc.tool_id,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
<where>
<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>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
AND date_format(tdc.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
</if>
</where>
group by tdc.tool_id,tl.tool_code,tl.tool_name
</select>
<select id="selectDownloadCountById" parameterType="String" resultMap="DownloadCountResult">
<include refid="selectDownloadCountVo"/>
where id = #{id}
</select>
<insert id="insertDownloadCount" parameterType="DownloadCount">
insert into t_download_count
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="toolId != null">tool_id,</if>
<if test="createBy != null">create_by,</if>
<if test="createById != null">create_by_id,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateById != null">update_by_id,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="toolId != null">#{toolId},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createById != null">#{createById},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateById != null">#{updateById},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateDownloadCount" parameterType="DownloadCount">
update t_download_count
<trim prefix="SET" suffixOverrides=",">
<if test="toolId != null">tool_id = #{toolId},</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>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateById != null">update_by_id = #{updateById},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteDownloadCountById" parameterType="String">
delete from t_download_count where id = #{id}
</delete>
<delete id="deleteDownloadCountByIds" parameterType="String">
delete from t_download_count where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="userDownList" parameterType="DownloadCount" resultMap="DownloadCountResult">
select
tdc.tool_id,su.nick_name,t1.,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>
</where>
group by su.nick_name
</select>
</mapper>

View File

@ -193,4 +193,14 @@
#{toolId}
</foreach>
</delete>
<select id="countToolType" resultType="java.util.Map">
select tool_type as types,sum(1) as statistics from t_tool where record_status != 'cancel' group by tool_type;
</select>
<select id="toolSource" resultType="java.util.Map">
select tool_source as types,sum(1) as statistics from t_tool where record_status != 'cancel' group by tool_source;
</select>
<select id="recordStatus" resultType="java.util.Map">
select record_status as types,sum(1) as statistics from t_tool where record_status != 'cancel' group by record_status;
</select>
</mapper>

View File

@ -0,0 +1,115 @@
<?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.rzdata.web.mapper.TzMessageMapper">
<resultMap type="TzMessage" id="TzMessageResult">
<result property="id" column="id" />
<result property="receiverId" column="receiver_id" />
<result property="states" column="states" />
<result property="content" column="content" />
<result property="deleted" column="deleted" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="createById" column="create_by_id" />
<result property="updateById" column="update_by_id" />
</resultMap>
<sql id="selectTzMessageVo">
select id, receiver_id, states, content, deleted, create_by, create_time, update_by, update_time, remark,create_by_id,update_by_id from tz_message
</sql>
<select id="selectTzMessageList" parameterType="TzMessage" resultMap="TzMessageResult">
<include refid="selectTzMessageVo"/>
<where>
<if test="receiverId != null and receiverId != ''"> and receiver_id = #{receiverId}</if>
<if test="states != null "> and states = #{states}</if>
<if test="content != null and content != ''"> and content like concat('%', #{content}, '%')</if>
<if test="createById != null and deleted != ''"> and create_by_id = #{createById}</if>
and deleted = '0'
</where>
</select>
<select id="selectTzMessageById" parameterType="String" resultMap="TzMessageResult">
<include refid="selectTzMessageVo"/>
where id = #{id}
</select>
<insert id="insertTzMessage" parameterType="TzMessage">
insert into tz_message
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="receiverId != null">receiver_id,</if>
<if test="states != null">states,</if>
<if test="content != null and content != ''">content,</if>
<if test="deleted != null and deleted != ''">deleted,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
<if test="createById != null">create_by_id,</if>
<if test="updateById != null">update_by_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="receiverId != null">#{receiverId},</if>
<if test="states != null">#{states},</if>
<if test="content != null and content != ''">#{content},</if>
<if test="deleted != null and deleted != ''">#{deleted},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
<if test="createById != null">#{create_by_id},</if>
<if test="updateById != null">#{update_by_id},</if>
</trim>
</insert>
<update id="updateTzMessage" parameterType="TzMessage">
update tz_message
<trim prefix="SET" suffixOverrides=",">
<if test="receiverId != null">receiver_id = #{receiverId},</if>
<if test="states != null">states = #{states},</if>
<if test="content != null and content != ''">content = #{content},</if>
<if test="deleted != null and deleted != ''">deleted = #{deleted},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createById != null">create_by_id = #{createById},</if>
<if test="updateById != null">update_by_id = #{updateById},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteTzMessageById" parameterType="String">
delete from tz_message where id = #{id}
</delete>
<delete id="deleteTzMessageByIds" parameterType="String">
delete from tz_message where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<update id="updateAllMarkedRead" parameterType="TzMessage">
update tz_message set states = '2' where create_by_id = #{createById}
</update>
<!-- 批量插入 -->
<insert id="batchInsert" parameterType="java.util.List">
insert into tz_message (id, receiver_id, states, content, deleted, create_by, create_time
values
<foreach item="item" index="index" collection="tzMessageList" open="(" separator="),(" close=")">
#{item.id}, #{item.receiverId}, #{item.states}, #{item.content}, #{item.deleted}, #{item.createBy}, #{item.createTime}
</foreach>
</insert>
</mapper>