提交 524d87bb 作者: 洪东保

根据部门导出会议记录

父级 69dc0d21
...@@ -315,7 +315,12 @@ public class MeetingInfoController { ...@@ -315,7 +315,12 @@ public class MeetingInfoController {
@PostMapping("/statistics") @PostMapping("/statistics")
public void statisticsEmail(@RequestBody EmailStatisticsVo vo, HttpServletResponse response) { public void statisticsEmail(@RequestBody EmailStatisticsVo vo, HttpServletResponse response) {
meetingInfoService.statisticsEmail(vo.getType(), vo.getStartTime(), vo.getEndTime(), response); meetingInfoService.statisticsEmail(vo.getType(), vo.getStartTime(), vo.getEndTime(), response);
} }
@PostMapping("/statisticsByDept")
public void statisticsByDept(@RequestBody EmailStatisticsVo vo, HttpServletResponse response) {
meetingInfoService.statisticsEmail(vo.getStartTime(), vo.getEndTime(), response);
}
} }
...@@ -19,5 +19,6 @@ public interface MeetingInfoService extends IService<MeetingInfo> { ...@@ -19,5 +19,6 @@ public interface MeetingInfoService extends IService<MeetingInfo> {
* 统计邮件推送情况 * 统计邮件推送情况
*/ */
void statisticsEmail(Integer type, Date startTime, Date endTime, HttpServletResponse response); void statisticsEmail(Integer type, Date startTime, Date endTime, HttpServletResponse response);
void statisticsEmail(Date startTime, Date endTime, HttpServletResponse response);
} }
...@@ -5,6 +5,7 @@ import cn.chatbot.openai.completion.chat.ChatMessage; ...@@ -5,6 +5,7 @@ import cn.chatbot.openai.completion.chat.ChatMessage;
import cn.chatbot.openai.completion.chat.ChatMessageRole; import cn.chatbot.openai.completion.chat.ChatMessageRole;
import cn.chatbot.openai.completion.chat.Message; import cn.chatbot.openai.completion.chat.Message;
import cn.chatbot.openai.service.LLMService; import cn.chatbot.openai.service.LLMService;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateField; import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
...@@ -29,10 +30,8 @@ import com.cmeeting.mapper.primary.MeetingRecordTemplateMapper; ...@@ -29,10 +30,8 @@ import com.cmeeting.mapper.primary.MeetingRecordTemplateMapper;
import com.cmeeting.mapper.primary.UserIdMapper; import com.cmeeting.mapper.primary.UserIdMapper;
import com.cmeeting.pojo.MeetingInfo; import com.cmeeting.pojo.MeetingInfo;
import com.cmeeting.pojo.MeetingRecordTemplate; import com.cmeeting.pojo.MeetingRecordTemplate;
import com.cmeeting.service.MeetingInfoService; import com.cmeeting.pojo.UserId;
import com.cmeeting.service.MeetingRecordTemplateService; import com.cmeeting.service.*;
import com.cmeeting.service.TencentMeetingService;
import com.cmeeting.service.WeComService;
import com.cmeeting.util.MinioUtils; import com.cmeeting.util.MinioUtils;
import com.cmeeting.vo.MeetingInfoVO; import com.cmeeting.vo.MeetingInfoVO;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
...@@ -99,17 +98,8 @@ public class MeetingInfoServiceImpl extends ServiceImpl<MeetingInfoMapper, Meeti ...@@ -99,17 +98,8 @@ public class MeetingInfoServiceImpl extends ServiceImpl<MeetingInfoMapper, Meeti
private MeetingInfoMapper meetingInfoMapper; private MeetingInfoMapper meetingInfoMapper;
@Resource @Resource
private UserIdMapper userIdMapper; private UserIdMapper userIdMapper;
@Autowired @Resource
private WeComService weComService; private SysUserSyncService sysUserSyncService;
@Autowired
private TencentMeetingService tencentMeetingService;
@Autowired
private MeetingRecordTemplateService meetingRecordTemplateService;
private String CLIENT_ID = "c06fe7cf-2a89-4099-9805-ce03031938f8";
private String CLIENT_SECRET = "wsu8Q~GxYxPLf2akioQZDRG8NR1EzCAHIAQRVc6u";
private String TENANT_ID = "18653b3e-03c7-499e-8baf-42ef06a814ef";
@Override @Override
public IPage<MeetingInfo> getPage(MeetingInfoVO vo) { public IPage<MeetingInfo> getPage(MeetingInfoVO vo) {
...@@ -423,12 +413,12 @@ public class MeetingInfoServiceImpl extends ServiceImpl<MeetingInfoMapper, Meeti ...@@ -423,12 +413,12 @@ public class MeetingInfoServiceImpl extends ServiceImpl<MeetingInfoMapper, Meeti
} }
} }
/** /**
* 统计邮件推送情况 * 统计邮件推送情况
*/ */
@Override @Override
public void statisticsEmail(Integer type, Date startTime, Date endTime, HttpServletResponse response) { public void statisticsEmail(Integer type, Date startTime, Date endTime, HttpServletResponse response) {
DateTime now = DateUtil.date(); DateTime now = DateUtil.date();
if (ObjectUtils.isEmpty(startTime) || ObjectUtils.isEmpty(endTime)) { if (ObjectUtils.isEmpty(startTime) || ObjectUtils.isEmpty(endTime)) {
if (1== type) { if (1== type) {
...@@ -442,7 +432,7 @@ public class MeetingInfoServiceImpl extends ServiceImpl<MeetingInfoMapper, Meeti ...@@ -442,7 +432,7 @@ public class MeetingInfoServiceImpl extends ServiceImpl<MeetingInfoMapper, Meeti
List<MeetingInfo> meetingInfoList = meetingInfoMapper.selectList(new LambdaQueryWrapper<MeetingInfo>() List<MeetingInfo> meetingInfoList = meetingInfoMapper.selectList(new LambdaQueryWrapper<MeetingInfo>()
// .eq(MeetingInfo::getEmailPushAccess, true) // .eq(MeetingInfo::getEmailPushAccess, true)
.between(MeetingInfo::getStartTime, startTime, endTime)); .between(MeetingInfo::getStartTime, startTime, endTime));
Map<String, List<MeetingInfo>> hostUidMeetingInfoMap = meetingInfoList.stream().collect(Collectors.groupingBy(MeetingInfo::getHostUid)); Map<String, List<MeetingInfo>> hostUidMeetingInfoMap = meetingInfoList.stream().collect(Collectors.groupingBy(MeetingInfo::getHostUid));
Map<String, String> hostMap = new HashMap<>(); Map<String, String> hostMap = new HashMap<>();
meetingInfoList.forEach(meetingInfo -> { meetingInfoList.forEach(meetingInfo -> {
...@@ -546,4 +536,160 @@ public class MeetingInfoServiceImpl extends ServiceImpl<MeetingInfoMapper, Meeti ...@@ -546,4 +536,160 @@ public class MeetingInfoServiceImpl extends ServiceImpl<MeetingInfoMapper, Meeti
IoUtil.close(outputStream); IoUtil.close(outputStream);
} }
} }
private static Map<String, String> DEPT_MAP = new HashMap<>(12);
static {
DEPT_MAP.put("10340", "集团总部");
DEPT_MAP.put("11683", "中集车辆(集团)股份有限公司");
DEPT_MAP.put("11080", "中集安瑞科投资控股(深圳)有限公司");
DEPT_MAP.put("635364", "中集管理培训(深圳)有限公司");
DEPT_MAP.put("612702", "中集世联达集装箱物流(深圳)有限公司");
DEPT_MAP.put("661082", "柏坚货柜机械维修(深圳)有限公司");
DEPT_MAP.put("745168", "中集世联达国际物流有限公司");
DEPT_MAP.put("766268", "中铁集物流装备有限公司");
DEPT_MAP.put("698027", "深圳中集同创供应链有限公司");
DEPT_MAP.put("674199", "中集模块化建筑投资有限公司");
DEPT_MAP.put("698022", "深圳中集共享后勤服务有限公司");
DEPT_MAP.put("707436", "深圳市集家美寓公寓管理有限公司");
}
/**
* 统计邮件推送情况
*/
@Override
public void statisticsEmail(Date startTime, Date endTime, HttpServletResponse response) {
List<MeetingInfo> meetingInfoList = meetingInfoMapper.selectList(new LambdaQueryWrapper<MeetingInfo>()
.between(MeetingInfo::getStartTime, startTime, endTime));
// 查询工号以及部门
List<String> uids = meetingInfoList.stream().map(MeetingInfo::getHostUid).distinct().collect(Collectors.toList());
List<UserId> userIds = userIdMapper.selectList(new LambdaQueryWrapper<UserId>().in(UserId::getTid, uids));
Map<String, String> idMap = userIds.stream().collect(Collectors.toMap(UserId::getTid, UserId::getWid));
Map<String, String> deptMap = new HashMap<>();
for (UserId userId : userIds) {
String deptPathByUserId = sysUserSyncService.getDeptPathByUserId(userId.getWid());
log.info("userId: {} ---- path: {}", userId.getWid(), deptPathByUserId);
deptMap.put(userId.getWid(), deptPathByUserId);
}
Map<String, List<MeetingInfo>> hostUidMeetingInfoMap = new HashMap<>();
for (MeetingInfo meetingInfo : meetingInfoList) {
String path = deptMap.get(idMap.get(meetingInfo.getHostUid()));
for (String deptId : DEPT_MAP.keySet()) {
if (path.contains(deptId)) {
List<MeetingInfo> meetingInfos = hostUidMeetingInfoMap.get(DEPT_MAP.get(deptId));
if (CollUtil.isEmpty(meetingInfos)) {
meetingInfos = new ArrayList<>();
}
meetingInfos.add(meetingInfo);
hostUidMeetingInfoMap.put(DEPT_MAP.get(deptId), meetingInfos);
break;
}
}
}
Map<String, String> hostMap = new HashMap<>();
meetingInfoList.forEach(meetingInfo -> {
if (!hostMap.containsKey(meetingInfo.getHostUid())) {
hostMap.put(meetingInfo.getHostUid(), meetingInfo.getHost());
}
});
// 总计
Map<String, Object> totalMap = new LinkedHashMap<>();
totalMap.put("host", "总计");
List<Map<String, Object>> mapList = new ArrayList<>();
for (Map.Entry<String, List<MeetingInfo>> entry : hostUidMeetingInfoMap.entrySet()) {
// 使用linkedHashMap,保证输出到excel中的顺序
Map<String, Object> map = new LinkedHashMap<>();
List<MeetingInfo> meetingList = entry.getValue();
Integer totalNum = meetingList.size();
// 没有转录文件会议,需要生成会议纪要的会议, 待处理, 处理中, 纪要生成成功, 推送成功, 推送失败
Integer emptyNum=0, emailPushAccessNum=0, newNum=0, generatErrorNum=0, noteGeneratedNum=0, pushSuccessNum=0, pushErrorNum=0;
for (MeetingInfo meetingInfo : meetingList) {
if (meetingInfo.getStatus() == MeetingState.NEW.getCode()) {
newNum++;
} else if (meetingInfo.getStatus() == MeetingState.GENERATE_ERROR.getCode()) {
generatErrorNum++;
} else if (meetingInfo.getStatus() == MeetingState.PUSH_SUCCESS.getCode()) {
pushSuccessNum++;
} else if (meetingInfo.getStatus() == MeetingState.PUSH_ERROR.getCode()) {
pushErrorNum++;
} else if (meetingInfo.getStatus() == MeetingState.EMPTY.getCode()) {
emptyNum++;
}
if (meetingInfo.getIsGenerated() || meetingInfo.getStatus() == MeetingState.NOTE_GENERATED.getCode()) {
noteGeneratedNum++;
}
// 有转录文件 且 email_push_access为true,
if (meetingInfo.getStatus() != MeetingState.EMPTY.getCode() && meetingInfo.getEmailPushAccess()) {
emailPushAccessNum++;
}
}
Integer avaliableNum = totalNum - emptyNum;
map.put("host", entry.getKey());
map.put("totalNum", totalNum);
map.put("avaliableNum", avaliableNum);
map.put("emptyNum", emptyNum);
map.put("emailPushAccessNum", emailPushAccessNum);
map.put("newNum", newNum);
map.put("generatErrorNum", generatErrorNum);
map.put("noteGeneratedNum", noteGeneratedNum);
map.put("pushErrorNum", pushErrorNum);
map.put("pushSuccessNum", pushSuccessNum);
mapList.add(map);
// 计算总计
totalMap.put("totalNum", Integer.valueOf(totalMap.getOrDefault("totalNum", 0).toString()) + totalNum);
totalMap.put("avaliableNum", Integer.valueOf(totalMap.getOrDefault("avaliableNum", 0).toString()) + avaliableNum);
totalMap.put("emptyNum", Integer.valueOf(totalMap.getOrDefault("emptyNum", 0).toString()) + emptyNum);
totalMap.put("emailPushAccessNum", Integer.valueOf(totalMap.getOrDefault("emailPushAccessNum", 0).toString()) + emailPushAccessNum);
totalMap.put("newNum", Integer.valueOf(totalMap.getOrDefault("newNum", 0).toString()) + newNum);
totalMap.put("generatErrorNum", Integer.valueOf(totalMap.getOrDefault("generatErrorNum", 0).toString()) + generatErrorNum);
totalMap.put("noteGeneratedNum", Integer.valueOf(totalMap.getOrDefault("noteGeneratedNum", 0).toString()) + noteGeneratedNum);
totalMap.put("pushErrorNum", Integer.valueOf(totalMap.getOrDefault("pushErrorNum", 0).toString()) + pushErrorNum);
totalMap.put("pushSuccessNum", Integer.valueOf(totalMap.getOrDefault("pushSuccessNum", 0).toString()) + pushSuccessNum);
}
mapList.add(totalMap);
// 导出
OutputStream outputStream = null;
ExcelWriter writer = ExcelUtil.getWriter(true);
try {
String title = String.format("会议纪要推送统计表_%s-%s", DateUtil.format(startTime, "yyyyMMdd"), DateUtil.format(endTime, "yyyyMMdd"));
outputStream = response.getOutputStream();
String fileName = String.format("%s.xlsx", title);
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "utf8"));
writer.addHeaderAlias("host", "部门");
writer.addHeaderAlias("totalNum", "总会议");
writer.addHeaderAlias("avaliableNum", "有效会议");
writer.addHeaderAlias("emptyNum", "没有转录文件");
writer.addHeaderAlias("emailPushAccessNum", "需生成纪要的会议总数");
writer.addHeaderAlias("newNum", "待处理");
writer.addHeaderAlias("generatErrorNum", "处理中");
writer.addHeaderAlias("noteGeneratedNum", "纪要生成成功");
writer.addHeaderAlias("pushSuccessNum", "纪要推送成功");
writer.addHeaderAlias("pushErrorNum", "纪要推送失败");
// 合并单元格后的标题行,使用默认标题样式
writer.merge(writer.getHeaderAlias().size() - 1, title);
// 一次性写出内容,使用默认样式,强制输出标题
writer.write(mapList, true);
writer.flush(outputStream);
} catch (Exception e) {
e.printStackTrace();
} finally {
writer.close();
IoUtil.close(outputStream);
}
}
} }
...@@ -37,6 +37,6 @@ public class SysUserSyncServiceImpl extends ServiceImpl<SysUserSysMapper, SysUse ...@@ -37,6 +37,6 @@ public class SysUserSyncServiceImpl extends ServiceImpl<SysUserSysMapper, SysUse
String parentDeptId = baseMapper.getParentDeptId(deptId,perTenantId); String parentDeptId = baseMapper.getParentDeptId(deptId,perTenantId);
if(StringUtils.isEmpty(parentDeptId)) return deptPath; if(StringUtils.isEmpty(parentDeptId)) return deptPath;
return "/" + parentDeptId + deptPath; return getDeptPath("/" + parentDeptId + deptPath, parentDeptId);
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论