zqy
2024-04-30 5e877672f949b10287f265cc14b4085719d091c3
提交会议统计
1个文件已修改
4个文件已添加
286 ■■■■■ 已修改文件
zhang-content/src/main/java/com/ruoyi/domain/MeetingStatistic.java 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhang-content/src/main/java/com/ruoyi/mapper/MeetingStatisticMapper.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhang-content/src/main/java/com/ruoyi/service/MeetingStatisticService.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhang-content/src/main/java/com/ruoyi/service/impl/MeetingServiceImpl.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhang-content/src/main/java/com/ruoyi/service/impl/MeetingStatisticServiceImpl.java 216 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhang-content/src/main/java/com/ruoyi/domain/MeetingStatistic.java
New file
@@ -0,0 +1,43 @@
package com.ruoyi.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@Data
@TableName("meeting_statistic")
public class MeetingStatistic {
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    /**
     * 家庭号
     */
    private Long familyId;
    /**
     * 使用时间
     */
    private String useTime;
    /**
     * 会议室名称
     */
    private String conferenceRoom;
    /**
     * 标题
     */
    private String title;
    /**
     * 申请人
     */
    private String applyPerson;
    /**
     * 审批人
     */
    private int ratifyPerson;
    /**
     * 状态
     */
    private int status;
}
zhang-content/src/main/java/com/ruoyi/mapper/MeetingStatisticMapper.java
New file
@@ -0,0 +1,9 @@
package com.ruoyi.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.domain.MeetingStatistic;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface MeetingStatisticMapper extends BaseMapper<MeetingStatistic> {
}
zhang-content/src/main/java/com/ruoyi/service/MeetingStatisticService.java
New file
@@ -0,0 +1,16 @@
package com.ruoyi.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.domain.MeetingStatistic;
public interface MeetingStatisticService extends IService<MeetingStatistic> {
    AjaxResult updateData(MeetingStatistic meetingStatistic);
    AjaxResult deleteData(Long[] ids);
    AjaxResult countData(Long[] familyId ,String applyPerson );
    AjaxResult addData(MeetingStatistic meetingStatistic);
}
zhang-content/src/main/java/com/ruoyi/service/impl/MeetingServiceImpl.java
@@ -59,8 +59,6 @@
                .like(StringUtils.isNotEmpty(meeting.getApplyApart()), Meeting::getApplyApart, meeting.getApplyApart());
//                .like(Integer.valueOf(meeting.getApplyPerson())!=null, Meeting::getApplyPerson, meeting.getApplyPerson());
        lqw.between(meeting.getHappenStartTime() != null && meeting.getHappenEndTime() != null, Meeting::getStartTime, meeting.getHappenStartTime(), meeting.getHappenEndTime());
        return lqw;
zhang-content/src/main/java/com/ruoyi/service/impl/MeetingStatisticServiceImpl.java
New file
@@ -0,0 +1,216 @@
package com.ruoyi.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.EsModel;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.domain.*;
import com.ruoyi.mapper.MeetingStatisticMapper;
import com.ruoyi.service.*;
import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import static com.ruoyi.constant.MenuAuthority.EVENT_LIST_ADD;
@Slf4j
@Service
public class MeetingStatisticServiceImpl extends ServiceImpl<MeetingStatisticMapper, MeetingStatistic> implements MeetingStatisticService {
    @Resource
    ZInfoUserService zInfoUserService;
    @Resource
    ZfLogService zfLogService;
    @Resource
    private RestHighLevelClient restHighLevelClient;
    @Resource
    private EsService esSer;
    @Resource
    ZAuthorityService zAuthorityService;
    @Resource
    private MeetingStatisticService meetingStatisticService;
    private LambdaQueryWrapper<MeetingStatistic> uniqueCondition(MeetingStatistic meetingStatistic){
        LambdaQueryWrapper<MeetingStatistic> lqw = new LambdaQueryWrapper<>();
        lqw.eq(!StringUtils.isEmpty(meetingStatistic.getUseTime()), MeetingStatistic::getUseTime, meetingStatistic.getUseTime());
        lqw.eq(!StringUtils.isEmpty(meetingStatistic.getConferenceRoom()), MeetingStatistic::getConferenceRoom, meetingStatistic.getConferenceRoom());
        lqw.eq(!StringUtils.isEmpty(meetingStatistic.getTitle()), MeetingStatistic::getTitle, meetingStatistic.getTitle());
//        lqw.eq(meetingStatistic.getFamilyId()!=null,MeetingStatistic::getFamilyId,meeting.getFamilyId());
        lqw.eq(!StringUtils.isEmpty(meetingStatistic.getApplyPerson()), MeetingStatistic::getApplyPerson, meetingStatistic.getApplyPerson());
        lqw.eq(!StringUtils.isEmpty(String.valueOf(meetingStatistic.getRatifyPerson())), MeetingStatistic::getRatifyPerson, meetingStatistic.getRatifyPerson());
        lqw.eq(!StringUtils.isEmpty(String.valueOf(meetingStatistic.getStatus())), MeetingStatistic::getStatus, meetingStatistic.getStatus());
        lqw.eq(!StringUtils.isEmpty(String.valueOf(meetingStatistic.getFamilyId())), MeetingStatistic::getFamilyId, meetingStatistic.getFamilyId());
        return lqw;
    }
    @Override
    public AjaxResult updateData(MeetingStatistic meetingStatistic) {
        ZfLog zfLog = new ZfLog();
        zfLog.setUpdateTime(LocalDateTime.now());
        zfLog.setModule("会议审批");
        zfLog.setUpdater(zInfoUserService.getMyself().getNickName());
        zfLogService.save(zfLog);
        System.out.println("===================================="+meetingStatistic);
        if(updateById(meetingStatistic)){
            //到数据库中查询对应的数据
            MeetingStatistic dataById = getById(meetingStatistic.getId());
            //先到es中查询到对应那条数据在es的id
            EsModel esResult = esSer.findByCtId(dataById.getId().intValue(), "会议");
            System.out.println("===================================="+meetingStatistic);
            if (esResult == null){
                return AjaxResult.success();
            }
            //操作es修改数据
            EsModel newModel = new EsModel();
//            System.out.println(meeting);
//            System.out.println("=============="+meetingStatistic.getConnPhone());
//            if(meetingStatistic.getUseTime()!=null){
//                newModel.setBy2(meetingStatistic.getUseTime());
//            }else {
//                newModel.setBy2(dataById.getUseTime());
//            }
//            if(meetingStatistic.getConferenceRoom()!=null){
//                newModel.setBy3(meetingStatistic.getConferenceRoom());
//            }else {
//                newModel.setBy3(dataById.getConferenceRoom());
//            }
            if(meetingStatistic.getTitle()!=null){
                newModel.setBy4(meetingStatistic.getTitle());
            }else {
                newModel.setBy4(dataById.getTitle());
            }
            if(meetingStatistic.getApplyPerson()!=null){
                newModel.setBy5(meetingStatistic.getApplyPerson());
            }else {
                newModel.setBy5(dataById.getApplyPerson());
            }
//            if(meetingStatistic.getRatifyPerson() == 0){
//                newModel.setBy10(meetingStatistic.getRatifyPerson());
//            }else {
//                newModel.setBy10(dataById.getRatifyPerson());
//            }
//            if(meetingStatistic.getStatus() == 0){
//                newModel.setBy11(meetingStatistic.getStatus());
//            }else {
//                newModel.setBy11(dataById.getStatus());
//            }
            UpdateRequest updateRequest = new UpdateRequest("allsearchdata", esResult.getId());
            updateRequest.doc(
                    "by1",newModel.getBy4(),
                    "by2",newModel.getBy5()
            );
            try {
                restHighLevelClient.update(updateRequest, RequestOptions.DEFAULT);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return AjaxResult.success();
        }else {
            return AjaxResult.error();
        }
    }
    @Override
    public AjaxResult deleteData(Long[] ids) {
        List<MeetingStatistic> meetings = listByIds(Arrays.asList(ids));
        if (meetingStatisticService.removeByIds(Arrays.asList(ids))) {
            //删除es中的数据
            meetings.stream().forEach(meeting -> {
                EsModel esModel = esSer.findByCtId((meeting.getId().intValue()), "会议");
                if (esModel != null){
                    DeleteRequest deleteRequest = new DeleteRequest("allsearchdata", esModel.getId());
                    try {
                        restHighLevelClient.delete(deleteRequest,RequestOptions.DEFAULT);
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                }
            });
            return AjaxResult.success();
        }else {
            return AjaxResult.error();
        }
    }
    @Override
    public AjaxResult countData(Long[] familyId ,String applyPerson) {
        return null;
    }
    @Override
    public AjaxResult addData(MeetingStatistic meetingStatistic) {
        ZInfoUser myself = zInfoUserService.getMyself();
        Long familyId = myself.getFamilyId();
        if(familyId == null){
            throw new RuntimeException("您还未加入任何家庭");
        }
        List<ZAuthority> authority = zAuthorityService.getAuthority();
        List<Long> familyIdList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(EVENT_LIST_ADD)).map(ZAuthority::getFid).collect(Collectors.toList());
        familyIdList.add(familyId);
        if (meetingStatistic.getFamilyId()!=null && !familyIdList.contains(meetingStatistic.getFamilyId())) {
            throw new RuntimeException("你没有权限操作此家庭的数据");
        }
        if(meetingStatistic.getFamilyId() == null){
            //默认添加自己家庭的数据
            meetingStatistic.setFamilyId(familyId);
        }
        //判断是否有重复数据
        LambdaQueryWrapper<MeetingStatistic> lqw = uniqueCondition(meetingStatistic);
        List<MeetingStatistic> list = list(lqw);
        if(list.size()>0){
            throw new RuntimeException("请勿新增重复数据");
        }
        if (save(meetingStatistic)) {
            EsModel esModel = new EsModel();
            Long inte = meetingStatistic.getId();
            String uuid = UUID.randomUUID().toString().replace("-","");
            esModel.setId(uuid);
            esModel.setCtId(inte);
            esModel.setCtTableName("会议统计");
            esModel.setBy1(meetingStatistic.getTitle());
            esModel.setBy5(meetingStatistic.getApplyPerson());
            //这里存储查询详情的路径
            esModel.setBy5("/zMeetingStatistic");
            esModel.setFid(familyId);
            esSer.insertTable(esModel);
            return AjaxResult.success();
        } else {
            return AjaxResult.error();
        }
    }
}