New file |
| | |
| | | package com.ruoyi.service.impl;
|
| | |
|
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
| | | 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.MapUtils;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.common.utils.poi.ExcelUtil;
|
| | | import com.ruoyi.domain.*;
|
| | | import com.ruoyi.mapper.MeetingMapper;
|
| | | 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 org.springframework.transaction.annotation.Transactional;
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import java.io.IOException;
|
| | | import java.time.LocalDateTime;
|
| | | import java.util.*;
|
| | | import java.util.stream.Collectors;
|
| | |
|
| | | import static com.ruoyi.constant.MenuAuthority.*;
|
| | |
|
| | | @Slf4j
|
| | | @Service
|
| | | public class MeetingServiceImpl extends ServiceImpl<MeetingMapper, Meeting> implements MeetingService {
|
| | |
|
| | | @Resource
|
| | | ZInfoUserService zInfoUserService;
|
| | |
|
| | | @Resource
|
| | | ZAuthorityService zAuthorityService;
|
| | |
|
| | | @Resource
|
| | | private EsService esSer;
|
| | |
|
| | | @Resource
|
| | | ZfLogService zfLogService;
|
| | |
|
| | | @Resource
|
| | | private RestHighLevelClient restHighLevelClient;
|
| | |
|
| | | @Resource
|
| | | private MeetingService meetingService;
|
| | |
|
| | | private LambdaQueryWrapper<Meeting> buildCondition(Meeting meeting) {
|
| | | LambdaQueryWrapper<Meeting> lqw = new LambdaQueryWrapper<>();
|
| | | // lqw.in(ZfDoctor::getFamilyId,familyIdList);
|
| | | lqw.orderByDesc(Meeting::getCreateTime);
|
| | | lqw.like(StringUtils.isNotEmpty(meeting.getPlace()), Meeting::getPlace, meeting.getPlace())
|
| | | .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;
|
| | | }
|
| | | private LambdaQueryWrapper<Meeting> uniqueCondition(Meeting meeting){
|
| | | LambdaQueryWrapper<Meeting> lqw = new LambdaQueryWrapper<>();
|
| | | lqw.eq(!StringUtils.isEmpty(meeting.getPlace()), Meeting::getPlace, meeting.getPlace());
|
| | | lqw.eq(!StringUtils.isEmpty(meeting.getApplyApart()), Meeting::getApplyApart, meeting.getApplyApart());
|
| | | lqw.eq(!StringUtils.isEmpty(meeting.getTitle()), Meeting::getTitle, meeting.getTitle());
|
| | | lqw.eq(!StringUtils.isEmpty(meeting.getConnPhone()), Meeting::getConnPhone, meeting.getConnPhone());
|
| | | // lqw.eq(meeting.getFamilyId()!=null,Meeting::getFamilyId,meeting.getFamilyId());
|
| | | lqw.eq(!StringUtils.isEmpty(String.valueOf(meeting.getApplyPerson())), Meeting::getApplyPerson, meeting.getApplyPerson());
|
| | | lqw.eq(!StringUtils.isEmpty(String.valueOf(meeting.getPartPeople())), Meeting::getPartPeople, meeting.getPartPeople());
|
| | | lqw.eq(!StringUtils.isEmpty(String.valueOf(meeting.getConnPerson())), Meeting::getConnPerson, meeting.getConnPerson());
|
| | | return lqw;
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | @Override
|
| | | public AjaxResult selectDataList(Meeting meeting, Integer pageNum, Integer pageSize) {
|
| | | //要查自己家庭的
|
| | | ZInfoUser myself = zInfoUserService.getMyself();
|
| | | if(myself==null)
|
| | | {
|
| | | // System.out.println("ssssss");
|
| | | return AjaxResult.success("您没加入到对应的家庭,请联系管理员");
|
| | | }
|
| | | Long familyId = myself.getFamilyId();
|
| | | // //也要查别人授权的
|
| | | // List<ZAuthority> authority = zAuthorityService.getAuthority();
|
| | | // List<Long> idList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(DOCTOR_LIST)).map(ZAuthority::getFid).collect(Collectors.toList());
|
| | | // //加上自己家庭的id
|
| | | // idList.add(familyId);
|
| | | // String familyIds = listFamilyIds();
|
| | | // String secondFamilyAuthority = listSecondFamilyIds();
|
| | | LambdaQueryWrapper<Meeting> lqw = buildCondition(meeting);
|
| | |
|
| | |
|
| | | Page<Meeting> meetingPage = new Page<>(pageNum, pageSize);
|
| | | Page<Meeting> pageResult = page(meetingPage, lqw);
|
| | |
|
| | | List<Meeting> beanRecords = pageResult.getRecords();//得到查询出来的数据
|
| | | // System.out.println(beanRecords);
|
| | |
|
| | |
|
| | |
|
| | | HashMap<String, Object> data = MapUtils.getResult(pageResult, beanRecords);
|
| | | return AjaxResult.success(data); }
|
| | |
|
| | |
|
| | |
|
| | | @Override
|
| | | public List<Meeting> selectByCondition(Meeting meeting) {
|
| | | //要查自己家庭的
|
| | | ZInfoUser myself = zInfoUserService.getMyself();
|
| | | System.out.println("================");
|
| | |
|
| | | // Long familyId = myself.getFamilyId();
|
| | | //
|
| | | // //也要查别人授权的
|
| | | // List<ZAuthority> authority = zAuthorityService.getAuthority();
|
| | | // List<Long> idList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(EVENT_LIST)).map(ZAuthority::getFid).collect(Collectors.toList());
|
| | | // //加上自己家庭的id
|
| | | // idList.add(familyId);
|
| | |
|
| | | LambdaQueryWrapper<Meeting> lambdaQueryWrapper = buildCondition(meeting);
|
| | | List<Meeting> beanRecords = list(lambdaQueryWrapper);
|
| | | log.info("从数据库中查到的为:{}", beanRecords);
|
| | | return beanRecords;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<Meeting> selectByIds(Long[] ids) {
|
| | | List<Meeting> list = new ArrayList<>();
|
| | | if (ids.length != 0)
|
| | | list = listByIds(Arrays.asList(ids));
|
| | | else
|
| | | list = list();
|
| | | return list;
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public AjaxResult importExcel(MultipartFile file) {
|
| | | ExcelUtil<Meeting> util = new ExcelUtil<>(Meeting.class);
|
| | | List<Meeting> dataList = null;
|
| | | try {
|
| | | dataList = util.importExcel(file.getInputStream());
|
| | | } catch (Exception e) {
|
| | | throw new RuntimeException(e);
|
| | | }
|
| | | log.info("数据列表为:{}", dataList);
|
| | |
|
| | |
|
| | | for (Meeting meeting : dataList) {
|
| | | meetingService.addData(meeting);
|
| | | }
|
| | |
|
| | | return AjaxResult.success("导入数据成功");
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | public AjaxResult updateData(Meeting meeting) {
|
| | | // ZInfoUser myself = zInfoUserService.getMyself();
|
| | | // Long familyId = myself.getFamilyId();
|
| | | //
|
| | | // //先根据id查询出数据的familyId,看看有没有权限操作
|
| | | // Long dataFamilyId = getById(zfDoctor.getId()).getFamilyId();
|
| | | //
|
| | | // List<ZAuthority> authority = zAuthorityService.getAuthority();
|
| | | // List<Long> familyIdList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(DOCTOR_LIST_UPDATE)).map(ZAuthority::getFid).collect(Collectors.toList());
|
| | | // familyIdList.add(familyId);
|
| | |
|
| | | // if (dataFamilyId!=null && !familyIdList.contains(dataFamilyId)) {
|
| | | // throw new RuntimeException("你没有权限操作此家庭的数据");
|
| | | // }
|
| | |
|
| | | //操作后加入日志
|
| | | ZfLog zfLog = new ZfLog();
|
| | | zfLog.setUpdateTime(LocalDateTime.now());
|
| | | zfLog.setModule("会议");
|
| | | zfLog.setUpdater(zInfoUserService.getMyself().getNickName());
|
| | | zfLogService.save(zfLog);
|
| | |
|
| | | if(updateById(meeting)){
|
| | | //到数据库中查询对应的数据
|
| | | Meeting dataById = getById(meeting.getId());
|
| | |
|
| | | //先到es中查询到对应那条数据在es的id
|
| | | EsModel esResult = esSer.findByCtId(dataById.getId().intValue(), "会议");
|
| | |
|
| | | if (esResult == null){
|
| | | return AjaxResult.success();
|
| | | }
|
| | |
|
| | | //操作es修改数据
|
| | | EsModel newModel = new EsModel();
|
| | | if(meeting.getPlace()!=null){
|
| | | newModel.setBy1(meeting.getPlace());
|
| | | }else {
|
| | | newModel.setBy1(dataById.getPlace());
|
| | | }
|
| | |
|
| | | if(meeting.getApplyApart()!=null){
|
| | | newModel.setBy2(meeting.getApplyApart());
|
| | | }else {
|
| | | newModel.setBy2(dataById.getApplyApart());
|
| | | }
|
| | |
|
| | | if(meeting.getTitle()!=null){
|
| | | newModel.setBy3(meeting.getTitle());
|
| | | }else {
|
| | | newModel.setBy3(dataById.getTitle());
|
| | | }
|
| | | if(meeting.getConnPhone()!=null){
|
| | | newModel.setBy4(meeting.getConnPhone());
|
| | | }else {
|
| | | newModel.setBy4(dataById.getConnPhone());
|
| | | }
|
| | |
|
| | | if(StringUtils.isEmpty(String.valueOf(meeting.getApplyPerson()))){
|
| | | newModel.setBy5(String.valueOf(meeting.getApplyPerson()));
|
| | | }else {
|
| | | newModel.setBy5(String.valueOf(dataById.getApplyPerson()));
|
| | | }
|
| | |
|
| | | if(StringUtils.isEmpty(String.valueOf(meeting.getPartPeople()))){
|
| | | newModel.setBy6(String.valueOf(meeting.getPartPeople()));
|
| | | }else {
|
| | | newModel.setBy6(String.valueOf(dataById.getPartPeople()));
|
| | | }
|
| | |
|
| | | if(StringUtils.isEmpty(String.valueOf(meeting.getConnPerson()))){
|
| | | newModel.setBy7(String.valueOf(meeting.getConnPerson()));
|
| | | }else {
|
| | | newModel.setBy7(String.valueOf(dataById.getConnPerson()));
|
| | | }
|
| | |
|
| | |
|
| | | UpdateRequest updateRequest = new UpdateRequest("allsearchdata", esResult.getId());
|
| | | updateRequest.doc(
|
| | | "by1",newModel.getBy1(),
|
| | | "by2",newModel.getBy2(),
|
| | | "by3",newModel.getBy3(),
|
| | | "by4",newModel.getBy4(),
|
| | | "by6",newModel.getBy6(),
|
| | | "by7",newModel.getBy7()
|
| | | );
|
| | |
|
| | | 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<Meeting> dataList = meetingService.listByIds(Arrays.asList(ids));
|
| | | //
|
| | | // ZInfoUser myself = zInfoUserService.getMyself();
|
| | | // Long familyId = myself.getFamilyId();
|
| | | //
|
| | | // List<ZAuthority> authority = zAuthorityService.getAuthority();
|
| | | // List<Long> familyIdList = authority.stream().filter(auth -> auth.getAuthority().toString().equals(EVENT_LIST_REMOVE)).map(ZAuthority::getFid).collect(Collectors.toList());
|
| | | // familyIdList.add(familyId);
|
| | | //
|
| | | // for (Meeting data : dataList) {
|
| | | // if (!familyIdList.contains(data.getFamilyId())){
|
| | | // throw new RuntimeException("你没有权限操作此家庭的数据");
|
| | | // }
|
| | | // }
|
| | |
|
| | | List<Meeting> meetings = listByIds(Arrays.asList(ids));
|
| | |
|
| | | if (meetingService.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 addData(Meeting meeting) {
|
| | |
|
| | | 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 (meeting.getFamilyId()!=null && !familyIdList.contains(zfEvent.getFamilyId())) {
|
| | | // throw new RuntimeException("你没有权限操作此家庭的数据");
|
| | | // }
|
| | | //
|
| | | ////
|
| | | // if(meeting.getFamilyId() == null){
|
| | | // //默认添加自己家庭的数据
|
| | | // zfEvent.setFamilyId(familyId);
|
| | | // }
|
| | | //
|
| | | // 判断是否有重复数据
|
| | | LambdaQueryWrapper<Meeting> lqw = uniqueCondition(meeting);
|
| | | List<Meeting> list = list(lqw);
|
| | |
|
| | | if(list.size()>0){
|
| | | throw new RuntimeException("请勿新增重复数据");
|
| | | }
|
| | |
|
| | | if (save(meeting)) {
|
| | | EsModel esModel = new EsModel();
|
| | | Long inte =meeting.getId();
|
| | | String uuid = UUID.randomUUID().toString().replace("-","");
|
| | | esModel.setId(uuid);
|
| | | esModel.setCtId(Long.valueOf(inte));
|
| | | esModel.setCtTableName("会议记录");
|
| | | esModel.setBy1(meeting.getPlace());
|
| | | esModel.setBy2(meeting.getApplyApart());
|
| | | esModel.setBy3(meeting.getTitle());
|
| | | esModel.setBy4(meeting.getConnPhone());
|
| | | esModel.setBy5(String.valueOf(meeting.getApplyPerson()));
|
| | | esModel.setBy6(String.valueOf(meeting.getPartPeople()));
|
| | | esModel.setBy7(String.valueOf(meeting.getConnPerson()));
|
| | | //这里存储查询详情的路径
|
| | | esModel.setBy5("/zMeeting");
|
| | | // esModel.setFid(familyId);
|
| | | esSer.insertTable(esModel);
|
| | |
|
| | | return AjaxResult.success();
|
| | | } else {
|
| | | return AjaxResult.error();
|
| | |
|
| | | }
|
| | | }
|
| | | }
|