提交 12f463eb 作者: 张开石

1、修改统计纪要模板使用情况接口

父级 8f1afb93
......@@ -45,4 +45,21 @@ public class StatisticsController {
return R.ok(list);
}
/**
* 纪要模板使用情况的统计
* @param searchValue 用户部门或工号
* @param createTimeStart 开始时间
* @param createTimeEnd 结束时间
* @return
*/
@GetMapping("/exportRecordTemplateUsingInfo")
public R exportRecordTemplateUsingInfo(String searchValue,
@RequestParam("createTimeStart") Date createTimeStart,
@RequestParam("createTimeEnd") Date createTimeEnd) {
List<Map<String, String>> list =meetingInfoService.statistics(searchValue, createTimeStart, createTimeEnd);
return R.ok(list);
}
}
......@@ -2,12 +2,10 @@ package com.cmeeting.mapper.primary;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cmeeting.pojo.MeetingInfo;
import com.cmeeting.vo.MeetingInfoVO;
import com.cmeeting.vo.TencentMeetingVO;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
......@@ -20,15 +18,18 @@ public interface MeetingInfoMapper extends BaseMapper<MeetingInfo> {
/**
* 统计
*
* @param startTime
* @param endTime
* @param dateList
* @param userIdList
* @return
*/
@MapKey("host_uid")
List<Map<String, String>> statistics(@Param("startTime") String startTime,
@Param("endTime") String endTime,
@Param("dateList") List<String> dateList);
@Param("dateList") List<String> dateList,
@Param("userIdList") List<String> userIdList);
// List<MeetingInfo> selectList(MeetingInfoVO vo);
......
......@@ -44,9 +44,11 @@ public interface SysUserSysMapper extends BaseMapper<SysUserSync> {
/**
* 获取用户信息
* @param userIdList
*
* @param searchValue
* @return
*/
@MapKey("userId")
List<Map<String, String>> selectParamByUserIdList(@Param("userIdList") List<String> userIdList);
List<Map<String, String>> selectParamByUserIdList(@Param("tenantId") String tenantId,
@Param("searchValue") String searchValue);
}
......@@ -10,8 +10,6 @@ import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
......@@ -86,6 +84,8 @@ public class MeetingInfoServiceImpl extends ServiceImpl<MeetingInfoMapper, Meeti
private String tencentAdminUserId;
@Value(value = "${llm.api-addr}")
private String llmApiAddr;
@Value("${permission.tenantId}")
public String permissionTenantId;
@Resource
private ProcessLogService processLogService;
@Resource
......@@ -269,46 +269,45 @@ public class MeetingInfoServiceImpl extends ServiceImpl<MeetingInfoMapper, Meeti
List<String> dateList = DateUtil.rangeToList(createTimeStart, createTimeEnd, DateField.DAY_OF_YEAR).stream()
.map(date -> DateUtil.format(date, "yyyy-MM-dd"))
.collect(Collectors.toList());
List<Map<String, String>> userInfoList = sysUserSysMapper.selectParamByUserIdList(permissionTenantId, searchValue);
List<String> userIdList = userInfoList.stream().map(map -> map.get("userId")).collect(Collectors.toList());
String startTime = DateUtil.format(createTimeStart, "yyyy-MM-dd");
String endTime = DateUtil.format(createTimeEnd, "yyyy-MM-dd");
List<Map<String, String>> list = meetingInfoMapper.statistics(startTime, endTime, dateList);
List<String> userIdList = list.stream().map(map -> map.get("userId")).collect(Collectors.toList());
List<Map<String, String>> userInfoList = sysUserSysMapper.selectParamByUserIdList(userIdList);
for (Map<String, String> map : list) {
String userId = map.get("userId");
userInfoList.stream().filter(userInfo -> userInfo.get("userId").equals(userId)).findFirst().ifPresent(userInfo -> {
map.put("name", userInfo.get("name"));
map.put("deptName", userInfo.get("deptName"));
});
List<Map<String, String>> statisticsList = meetingInfoMapper.statistics(startTime, endTime, dateList, userIdList);
for (Map<String, String> userInfo : userInfoList) {
String userId = userInfo.get("userId");
statisticsList.stream().filter(statistics -> statistics.get("userId").equals(userId)).findFirst().ifPresent(userInfo::putAll);
// 横向加法
Integer sum = map.values().stream()
Integer sum = userInfo.values().stream()
// 小于4是为了和用户编号区分开
.filter(value -> NumberUtil.isNumber(value) && value.length() < 4)
.map(value -> Integer.parseInt(value))
.reduce(Integer::sum)
.orElse(0);
map.put("sum", sum.toString());
userInfo.put("sum", sum.toString());
}
userInfoList.removeIf(map -> !map.containsKey("host_uid"));
// 初始化一行用来纵向加和
Map<String, String> map = new LinkedHashMap<>();
for (String key : list.get(0).keySet()) {
map.put(key, "");
Map<String, String> lastRowMap = new LinkedHashMap<>();
for (String key : userInfoList.get(0).keySet()) {
lastRowMap.put(key, "");
}
for (Map<String, String> stringMap : list) {
for (Map<String, String> stringMap : userInfoList) {
for (Map.Entry<String, String> entry : stringMap.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if (NumberUtil.isNumber(value) && value.length() < 4) {
map.put(key, String.valueOf(NumberUtil.add(map.get(key), value)));
lastRowMap.put(key, String.valueOf(NumberUtil.add(lastRowMap.get(key), value)));
}
}
}
map.put("userId", "总计");
list.add(map);
lastRowMap.put("userId", "总计");
userInfoList.add(lastRowMap);
return list;
return userInfoList;
}
/**
......
......@@ -34,7 +34,6 @@
select meeting_id,sub_meeting_id from cmt_meeting_info
</select>
<select id="statistics" resultType="java.util.LinkedHashMap">
SELECT
userid.wid as userId,
......@@ -52,8 +51,16 @@
WHERE
date_format(sync_time, '%Y-%m-%d') BETWEEN #{startTime} AND #{endTime}
GROUP BY host_uid, date_format(sync_time, '%Y-%m-%d')
) AS t
join userid ON userid.tid COLLATE utf8mb4_general_ci = t.host_uid COLLATE utf8mb4_general_ci
) AS t,
userid
where
userid.tid COLLATE utf8mb4_general_ci = t.host_uid COLLATE utf8mb4_general_ci
<if test="userIdList.size > 0">
and userid.wid in
<foreach item="userId" collection="userIdList" open="(" separator="," close=")" index="index">
#{userId}
</foreach>
</if>
GROUP BY t.host_uid, userid.wid
</select>
......
......@@ -149,19 +149,17 @@
<select id="selectParamByUserIdList" resultType="java.util.Map">
SELECT
sys_user_sync.user_id as userId,
sys_user_sync_category.`name` as deptName,
sys_user_sync.`name`,
sys_user_sync_category.`name` as deptName
sys_user_sync.user_id as userId
FROM
sys_user_sync,
sys_user_sync_category
<where>
sys_user_sync.tenant_id = #{tenantId}
and sys_user_sync.dept_id = sys_user_sync_category.dept_id
<if test="userIdList.size > 0">
and sys_user_sync.user_id in
<foreach item="userId" collection="userIdList" index="index" separator="," close=")" open="(">
#{userId}
</foreach>
<if test="searchValue != null and searchValue != ''">
and (sys_user_sync.user_id like concat('%',#{searchValue},'%') or sys_user_sync.name like concat('%',#{searchValue},'%') or sys_user_sync_category.name like concat('%',#{searchValue},'%'))
</if>
</where>
</select>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论