|
@@ -3,25 +3,45 @@ package com.xjrsoft.module.oa.service.impl;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
+import com.xjrsoft.common.enums.MeetingTypeEnum;
|
|
|
import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
+import com.xjrsoft.module.base.entity.BaseOfficeBuild;
|
|
|
+import com.xjrsoft.module.oa.dto.MeetingRoomListDto;
|
|
|
+import com.xjrsoft.module.oa.dto.WfMeetingApplyPageDto;
|
|
|
+import com.xjrsoft.module.oa.entity.MeetingConferee;
|
|
|
+import com.xjrsoft.module.oa.entity.MeetingRoom;
|
|
|
import com.xjrsoft.module.oa.entity.WfMeetingApply;
|
|
|
+import com.xjrsoft.module.oa.mapper.MeetingConfereeMapper;
|
|
|
+import com.xjrsoft.module.oa.mapper.MeetingRoomMapper;
|
|
|
import com.xjrsoft.module.oa.mapper.WfMeetingApplyMapper;
|
|
|
import com.xjrsoft.module.oa.service.IWfMeetingApplyService;
|
|
|
+import com.xjrsoft.module.oa.vo.MeetingRoomListVo;
|
|
|
+import com.xjrsoft.module.oa.vo.WfMeetingApplyPageVo;
|
|
|
import com.xjrsoft.module.organization.dto.WeChatSendMessageDto;
|
|
|
import com.xjrsoft.module.organization.entity.User;
|
|
|
import com.xjrsoft.module.organization.service.IUserService;
|
|
|
import com.xjrsoft.module.organization.service.IWeChatService;
|
|
|
import com.xjrsoft.module.workflow.entity.WorkflowExtra;
|
|
|
import com.xjrsoft.module.workflow.entity.WorkflowFormRelation;
|
|
|
+import com.xjrsoft.module.workflow.mapper.WorkflowFormRelationMapper;
|
|
|
import com.xjrsoft.module.workflow.service.IWorkflowExtraService;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
+import org.camunda.bpm.engine.history.HistoricProcessInstance;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.Arrays;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
* @title: 物品申购
|
|
@@ -39,57 +59,166 @@ public class WfMeetingApplyServiceImpl extends MPJBaseServiceImpl<WfMeetingApply
|
|
|
|
|
|
private final IWorkflowExtraService extraService;
|
|
|
|
|
|
- @Override
|
|
|
- public void noticeParticipants(Long id) {
|
|
|
- WfMeetingApply meetingApply = this.getById(id);
|
|
|
- if (meetingApply.getMeetingApplyParticipants() == null || meetingApply.getMeetingApplyParticipants().isEmpty()) {
|
|
|
- return;
|
|
|
- }
|
|
|
- List<String> userIds = Arrays.asList(meetingApply.getMeetingApplyParticipants().split(","));
|
|
|
-
|
|
|
- List<User> userList = userService.list(new QueryWrapper<User>().lambda().in(User::getId, userIds).isNotNull(User::getOpenId));
|
|
|
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
- String startTime = meetingApply.getMeetingApplyS().format(formatter);
|
|
|
- String endTime = meetingApply.getMeetingApplyE().format(formatter);
|
|
|
-
|
|
|
- List<WorkflowExtra> list = extraService.list(
|
|
|
- new MPJLambdaWrapper<WorkflowExtra>()
|
|
|
- .select(WorkflowExtra.class, x -> VoToColumnUtil.fieldsToColumns(WorkflowExtra.class).contains(x.getProperty()))
|
|
|
- .innerJoin(WorkflowFormRelation.class, WorkflowFormRelation::getProcessId, WorkflowExtra::getProcessId)
|
|
|
- .eq(WorkflowFormRelation::getFormId, id)
|
|
|
- .orderByAsc(WorkflowExtra::getStartTime)
|
|
|
- );
|
|
|
- String startUserName = list.get(0).getStartUserName();
|
|
|
+ private final MeetingRoomMapper meetingRoomMapper;
|
|
|
|
|
|
- for (User user : userList) {
|
|
|
- WeChatSendMessageDto weChatSendMessageDto = new WeChatSendMessageDto();
|
|
|
- weChatSendMessageDto.setUserId(user.getOpenId());
|
|
|
- weChatSendMessageDto.setTemplateId("Hign0b3e4WSXe__YmBKyDsBgAjkfNYC7c6yIUHjk3Hg");
|
|
|
- weChatSendMessageDto.setMsgId(IdUtil.getSnowflakeNextId() + "");
|
|
|
- JSONObject paramJson = new JSONObject();
|
|
|
+ private final WorkflowFormRelationMapper workflowFormRelationMapper;
|
|
|
|
|
|
- JSONObject thing2 = new JSONObject();
|
|
|
- thing2.put("value", meetingApply.getMeetingApplyTheme());
|
|
|
- paramJson.put("thing2", thing2);
|
|
|
+ private final MeetingConfereeMapper meetingConfereeMapper;
|
|
|
|
|
|
- JSONObject time5 = new JSONObject();
|
|
|
- time5.put("value", startTime);
|
|
|
- paramJson.put("time5", time5);
|
|
|
+ @Override
|
|
|
+ public List<MeetingRoomListVo> meetingRoomList(MeetingRoomListDto dto) {
|
|
|
+
|
|
|
+ MPJLambdaWrapper<MeetingRoom> meetingRoomMPJLambdaWrapper = new MPJLambdaWrapper<>();
|
|
|
+ meetingRoomMPJLambdaWrapper
|
|
|
+ .select(MeetingRoom::getId)
|
|
|
+ .selectAs(MeetingRoom::getName, MeetingRoomListVo::getName)
|
|
|
+ .selectAs(MeetingRoom::getFloorNum, MeetingRoomListVo::getFloorNum)
|
|
|
+ .selectAs(MeetingRoom::getCapacity, MeetingRoomListVo::getCapacity)
|
|
|
+ .selectAs(BaseOfficeBuild::getName, MeetingRoomListVo::getOfficeBuildIdCn)
|
|
|
+ .leftJoin(BaseOfficeBuild.class, BaseOfficeBuild::getId, MeetingRoom::getOfficeBuildId)
|
|
|
+ .eq(MeetingRoom::getStatus, 1)
|
|
|
+ ;
|
|
|
+ List<MeetingRoomListVo> result = meetingRoomMapper.selectJoinList(MeetingRoomListVo.class, meetingRoomMPJLambdaWrapper);
|
|
|
+
|
|
|
+
|
|
|
+ List<WfMeetingApply> wfMeetingApplyList = this.list(Wrappers.lambdaQuery(WfMeetingApply.class)
|
|
|
+ .eq(WfMeetingApply::getMeetingApplyDate, dto.getMeetingApplyDate())
|
|
|
+ .eq(WfMeetingApply::getMeetingApplyFormat, MeetingTypeEnum.HMT0002.getCode())
|
|
|
+ .ne(WfMeetingApply::getMeetingStatus, 1)
|
|
|
+ );
|
|
|
|
|
|
- JSONObject time6 = new JSONObject();
|
|
|
- time6.put("value", endTime);
|
|
|
- paramJson.put("time6", time6);
|
|
|
+
|
|
|
+ Map<Long, List<WfMeetingApply>> mapByMeetingRoomId = wfMeetingApplyList.stream()
|
|
|
+ .collect(Collectors.groupingBy(WfMeetingApply::getMeetingRoomId));
|
|
|
+
|
|
|
+
|
|
|
+ Map<Long, MeetingRoomListVo> reservationMap = new LinkedHashMap<>();
|
|
|
+ MeetingRoomListVo meetingRoomListVo;
|
|
|
+ for (Map.Entry<Long, List<WfMeetingApply>> entry : mapByMeetingRoomId.entrySet()) {
|
|
|
+ Long key = entry.getKey();
|
|
|
+ List<WfMeetingApply> value = entry.getValue();
|
|
|
+ StringBuilder reservationDetail = new StringBuilder();
|
|
|
+ boolean isReservation = false;
|
|
|
+ meetingRoomListVo = new MeetingRoomListVo();
|
|
|
+ for (WfMeetingApply wfMeetingApply : value) {
|
|
|
+
|
|
|
+ if(!(dto.getMeetingApplyS().isBefore(wfMeetingApply.getMeetingApplyS()) || dto.getMeetingApplyE().isAfter(wfMeetingApply.getMeetingApplyE()))){
|
|
|
+ isReservation = true;
|
|
|
+ }
|
|
|
+ reservationDetail.append(wfMeetingApply.getMeetingApplyS()).append("-").append(wfMeetingApply.getMeetingApplyE()).append("\r\n");
|
|
|
+ }
|
|
|
+ meetingRoomListVo.setReservationDetail(reservationDetail.toString());
|
|
|
+ meetingRoomListVo.setStatus(isReservation ? 1 : 0);
|
|
|
+
|
|
|
+ reservationMap.put(key, meetingRoomListVo);
|
|
|
+ }
|
|
|
|
|
|
- JSONObject thing7 = new JSONObject();
|
|
|
- thing7.put("value", meetingApply.getMeetingApplyAddress());
|
|
|
- paramJson.put("thing7", thing7);
|
|
|
+ for (MeetingRoomListVo vo : result){
|
|
|
+ vo.setStatus(0);
|
|
|
+ MeetingRoomListVo reservationRoom = reservationMap.get(vo.getId());
|
|
|
+ if(ObjectUtils.isNotEmpty(reservationRoom)){
|
|
|
+ vo.setReservationDetail(reservationRoom.getReservationDetail());
|
|
|
+ vo.setStatus(reservationRoom.getStatus());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IPage<WfMeetingApplyPageVo> pageRabAndHand(WfMeetingApplyPageDto dto) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
- JSONObject thing8 = new JSONObject();
|
|
|
- thing8.put("value", startUserName);
|
|
|
- paramJson.put("thing8", thing8);
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void noticeParticipants(Long id) {
|
|
|
+ MPJLambdaWrapper<WfMeetingApply> wrapper = new MPJLambdaWrapper<>();
|
|
|
+ wrapper
|
|
|
+ .disableSubLogicDel()
|
|
|
+ .select(WfMeetingApply::getId)
|
|
|
+ .selectAs(MeetingRoom::getName, WfMeetingApply::getMeetingSummary)
|
|
|
+ .select(WfMeetingApply.class,x -> VoToColumnUtil.fieldsToColumns(WfMeetingApply.class).contains(x.getProperty()))
|
|
|
+ .leftJoin(MeetingRoom.class, MeetingRoom::getId, WfMeetingApply::getMeetingRoomId)
|
|
|
+ .eq(WfMeetingApply::getId, id)
|
|
|
+ ;
|
|
|
+ WfMeetingApply meetingApply = this.selectJoinOne(WfMeetingApply.class, wrapper);
|
|
|
+
|
|
|
+
|
|
|
+ WorkflowFormRelation workflowFormRelation = workflowFormRelationMapper.selectOne(
|
|
|
+ Wrappers.lambdaQuery(WorkflowFormRelation.class)
|
|
|
+ .eq(WorkflowFormRelation::getFormKeyValue, id)
|
|
|
+ );
|
|
|
|
|
|
- weChatSendMessageDto.setContent(paramJson);
|
|
|
- weChatService.sendTemplateMessage(weChatSendMessageDto);
|
|
|
+ if (ObjectUtils.isNotEmpty(meetingApply)
|
|
|
+ && ObjectUtils.isNotEmpty(workflowFormRelation)
|
|
|
+ && HistoricProcessInstance.STATE_COMPLETED.equals(workflowFormRelation.getCurrentState())
|
|
|
+ ) {
|
|
|
+ if (meetingApply.getMeetingApplyParticipants() == null || meetingApply.getMeetingApplyParticipants().isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<String> userIds = Arrays.asList(meetingApply.getMeetingApplyParticipants().split(","));
|
|
|
+
|
|
|
+
|
|
|
+ List<User> userList = userService.list(new QueryWrapper<User>().lambda().in(User::getId, userIds).isNotNull(User::getOpenId));
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ LocalDateTime startLocalDateTime = LocalDateTime.of(meetingApply.getMeetingApplyDate(), meetingApply.getMeetingApplyS());
|
|
|
+ LocalDateTime endLocalDateTime = LocalDateTime.of(meetingApply.getMeetingApplyDate(), meetingApply.getMeetingApplyE());
|
|
|
+ String startTime = startLocalDateTime.format(formatter);
|
|
|
+ String endTime = endLocalDateTime.format(formatter);
|
|
|
+
|
|
|
+
|
|
|
+ List<WorkflowExtra> list = extraService.list(
|
|
|
+ new MPJLambdaWrapper<WorkflowExtra>()
|
|
|
+ .select(WorkflowExtra.class, x -> VoToColumnUtil.fieldsToColumns(WorkflowExtra.class).contains(x.getProperty()))
|
|
|
+ .innerJoin(WorkflowFormRelation.class, WorkflowFormRelation::getProcessId, WorkflowExtra::getProcessId)
|
|
|
+ .eq(WorkflowFormRelation::getFormId, id)
|
|
|
+ .orderByAsc(WorkflowExtra::getStartTime)
|
|
|
+ );
|
|
|
+ String startUserName = list.get(0).getStartUserName();
|
|
|
+
|
|
|
+ MeetingConferee meetingConferee;
|
|
|
+
|
|
|
+
|
|
|
+ for (User user : userList) {
|
|
|
+ meetingConferee = new MeetingConferee();
|
|
|
+ meetingConferee.setWfMeetingApplyId(id);
|
|
|
+ meetingConferee.setUserId(user.getId());
|
|
|
+ meetingConferee.setCheckInStatus(0);
|
|
|
+
|
|
|
+ meetingConfereeMapper.insert(meetingConferee);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ for (User user : userList) {
|
|
|
+ WeChatSendMessageDto weChatSendMessageDto = new WeChatSendMessageDto();
|
|
|
+ weChatSendMessageDto.setUserId(user.getOpenId());
|
|
|
+ weChatSendMessageDto.setTemplateId("Hign0b3e4WSXe__YmBKyDsBgAjkfNYC7c6yIUHjk3Hg");
|
|
|
+ weChatSendMessageDto.setMsgId(IdUtil.getSnowflakeNextId() + "");
|
|
|
+ JSONObject paramJson = new JSONObject();
|
|
|
+
|
|
|
+ JSONObject thing2 = new JSONObject();
|
|
|
+ thing2.put("value", meetingApply.getMeetingApplyTheme());
|
|
|
+ paramJson.put("thing2", thing2);
|
|
|
+
|
|
|
+ JSONObject time5 = new JSONObject();
|
|
|
+ time5.put("value", startTime);
|
|
|
+ paramJson.put("time5", time5);
|
|
|
+
|
|
|
+ JSONObject time6 = new JSONObject();
|
|
|
+ time6.put("value", endTime);
|
|
|
+ paramJson.put("time6", time6);
|
|
|
+
|
|
|
+ JSONObject thing7 = new JSONObject();
|
|
|
+ thing7.put("value", meetingApply.getMeetingSummary());
|
|
|
+ paramJson.put("thing7", thing7);
|
|
|
+
|
|
|
+ JSONObject thing8 = new JSONObject();
|
|
|
+ thing8.put("value", startUserName);
|
|
|
+ paramJson.put("thing8", thing8);
|
|
|
+
|
|
|
+ weChatSendMessageDto.setContent(paramJson);
|
|
|
+ weChatService.sendTemplateMessage(weChatSendMessageDto);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|