From 86d65e6f837ff14b090ffc3312c013987b6f67d8 Mon Sep 17 00:00:00 2001
From: zqy <2522236926@qq.com>
Date: 星期二, 14 十月 2025 21:59:13 +0800
Subject: [PATCH] 荣誉 新增两个字段的查询
---
zhang-content/src/main/java/com/ruoyi/service/impl/ZfEquipShareServiceImpl.java | 239 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 238 insertions(+), 1 deletions(-)
diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfEquipShareServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfEquipShareServiceImpl.java
index 726adaf..f3ea927 100644
--- a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfEquipShareServiceImpl.java
+++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfEquipShareServiceImpl.java
@@ -1,2 +1,239 @@
-package com.ruoyi.service.impl;public class ZfEquipShareServiceImpl {
+
+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.core.domain.entity.SysUser;
+import com.ruoyi.common.utils.MapUtils;
+import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.domain.*;
+import com.ruoyi.mapper.ZfShareMapper;
+import com.ruoyi.service.*;
+import lombok.extern.slf4j.Slf4j;
+import org.elasticsearch.action.delete.DeleteRequest;
+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.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Service
+@Slf4j
+public class ZfEquipShareServiceImpl extends ServiceImpl<ZfShareMapper, ZfShare> implements ZfEquipShareService {
+ @Resource
+ ZfEquipmentService zfEquipmentService;
+
+ @Resource
+ private ZInfoUserService zInfoUserService;
+
+ @Resource
+ private RestHighLevelClient restHighLevelClient;
+
+ @Resource
+ EsService esService;
+
+
+
+ private LambdaQueryWrapper<ZfShare> uniqueCondition(ZfShare zfShare) {
+ LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>();
+ lqw.eq(StringUtils.isNotEmpty(String.valueOf(zfShare.getShareId())), ZfShare::getShareId, zfShare.getShareId());
+ lqw.eq(StringUtils.isNotEmpty(String.valueOf(zfShare.getShareContent())), ZfShare::getShareContent, zfShare.getShareContent());
+ lqw.eq(StringUtils.isNotEmpty(String.valueOf(zfShare.getSysMenuId())), ZfShare::getSysMenuId, zfShare.getSysMenuId());
+ return lqw;
+ }
+
+ @Override
+ public List<ZfShare> getAuthority() {
+ SysUser user = SecurityUtils.getLoginUser().getUser();
+ Long userId = user.getUserId();
+
+ LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>();
+ lqw.eq(ZfShare::getShareId,userId);
+
+ return list(lqw);
+ }
+
+ public Long getUserId(){
+ ZInfoUser myself = zInfoUserService.getMyself();
+ return myself.getUserId();
+
+ }
+
+ public void addData(ZfShare za)
+ {
+ LambdaQueryWrapper<ZfShare> lqw = uniqueCondition(za);
+ List<ZfShare> list = list(lqw);
+
+ if(list.size()>0){
+ throw new RuntimeException("璇峰嬁鍒嗕韩閲嶅鏁版嵁");
+ }
+ else {
+ save(za);
+ }
+
+ }
+
+ @Override
+ public AjaxResult saveZa(ShareMore shareMore) {
+ Long [] shareIds = shareMore.getShareIds();
+ Long [] shareContents = shareMore.getShareContents();
+ for (Long shareId : shareIds) {
+ for (Long shareContent : shareContents) {
+ ZfShare za = new ZfShare();
+ za.setUserId(getUserId());
+ za.setShareContent(shareContent);
+ za.setShareId(shareId);
+ za.setSysMenuId(2017L);
+ addData(za);
+ }
+ }
+ // Long []
+ // if(bl)
+ return AjaxResult.success("鍒嗕韩鎴愬姛!");
+ }
+
+ @Override
+ public AjaxResult listByFidAid(ShareMore shareMore, Integer pageNo, Integer pageSize) {
+ Long [] shareIds = shareMore.getShareIds();
+ List<ZfEquipment> beanRecord3 = new ArrayList<>();
+ for (Long shareId : shareIds) {
+ {
+ LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>();
+ lqw.eq(ZfShare::getShareId,shareId)
+ .eq(ZfShare::getSysMenuId,shareMore.getSysMenuId())
+ .eq(ZfShare::getUserId, getUserId());
+ List<ZfShare> beanRecords = list(lqw);
+ for (ZfShare beanRecord : beanRecords ) {
+ beanRecord3.add(zfEquipmentService.getById(beanRecord.getShareContent()));
+ }
+ }
+ }
+ List<ZfEquipment> record = beanRecord3.stream().skip((pageNo-1)*pageSize).limit(pageSize).collect(Collectors.toList());
+
+ int totalPage = (beanRecord3.size() -1) / pageSize +1;
+
+ Page<ZfEquipment> zfEquipmentPage = new Page<>(pageNo, pageSize,totalPage);
+ HashMap<String, Object> data = MapUtils.getShareResult(zfEquipmentPage, record,beanRecord3.size());
+
+ return AjaxResult.success(data);
+ }
+
+ @Override
+ public AjaxResult deleteZa(ShareMore shareMore) {
+ Long [] shareIds = shareMore.getShareIds();
+ Long [] shareContents = shareMore.getShareContents();
+ for(Long shareId : shareIds)
+ for(Long shareContent: shareContents)
+ {
+ LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>();
+ lqw.eq(ZfShare::getShareId,shareId)
+ .eq(ZfShare::getShareContent, shareContent)
+ .eq(ZfShare::getSysMenuId, shareMore.getSysMenuId())
+ .eq(ZfShare::getUserId, getUserId());
+
+ remove(lqw);
+ // addData(za);
+ }
+ return AjaxResult.success("鏁版嵁鏀跺洖鎴愬姛!");
+ }
+
+ @Override
+ public AjaxResult listByUserId() {
+ HashMap<Long,List<ZfEquipment>> bs = new HashMap<>();
+ LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>();
+ lqw.eq(ZfShare::getShareId,getUserId());
+ lqw.eq(ZfShare::getSysMenuId,2017L);
+ List<ZfShare> beanRecords = list(lqw);
+ List<ZfEquipment> b1 = new ArrayList<>();
+ for (ZfShare beanRecord : beanRecords ) {
+ b1.add(zfEquipmentService.getById(beanRecord.getShareContent()));
+ bs.put(beanRecord.getUserId(),b1);
+ }
+ log.info("浠庢暟鎹簱涓煡鍒扮殑涓�:{}", bs);
+ return AjaxResult.success(bs);
+ }
+
+ @Override
+ public AjaxResult listUserId(Integer pageNo, Integer pageSize) {
+ List<ZfEquipment> bs = new ArrayList<>();
+ LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>();
+ lqw.eq(ZfShare::getShareId,getUserId());
+ lqw.eq(ZfShare::getSysMenuId,2017L);
+ List<ZfShare> beanRecords = list(lqw);
+ for (ZfShare beanRecord : beanRecords ) {
+ ZfEquipment bs2 = zfEquipmentService.getById(beanRecord.getShareContent());
+ bs2.setShareId(beanRecord.getUserId().intValue());
+ bs.add(bs2);
+ }
+ log.info("浠庢暟鎹簱涓煡鍒扮殑涓�:{}", bs);
+ List<ZfEquipment> record = bs.stream().skip((pageNo-1)*pageSize).limit(pageSize).collect(Collectors.toList());
+
+ int totalPage = (bs.size() -1) / pageSize +1;
+
+ Page<ZfEquipment> zfEquipmentPage = new Page<>(pageNo, pageSize,totalPage);
+ HashMap<String, Object> data = MapUtils.getShareResult(zfEquipmentPage, record,bs.size());
+ return AjaxResult.success(data);
+ }
+
+ @Override
+ public Long getShareId(ZfDownload zfDownload) {
+ LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>();
+ lqw.eq(ZfShare::getShareId, zfDownload.getDownloadId())
+ .eq(ZfShare::getShareContent, zfDownload.getDownloadContent())
+ .eq(ZfShare::getSysMenuId, zfDownload.getSysMenuId());
+ List<ZfShare> beanRecords = list(lqw);
+ if (beanRecords.size() != 0){
+ return beanRecords.get(0).getUserId();
+ }
+ else {
+ return null;
+ }
+ }
+
+ @Override
+ public Boolean deleteByContentId(Long[] ids) {
+ List<Long> id = new ArrayList<>();
+
+ LambdaQueryWrapper<ZfShare> lqw = new LambdaQueryWrapper<>();
+ lqw.in(ids != null, ZfShare::getShareContent, ids)
+ .eq(ZfShare::getSysMenuId, 2017L);
+
+ List<ZfShare> zfShares = list(lqw);
+ if (zfShares.size() == 0){
+ return true;
+ }
+ for (ZfShare zfShare: zfShares) {
+ id.add(zfShare.getId());
+ }
+
+ System.out.println(id);
+ if (removeByIds(id)) {
+ //鍒犻櫎es涓殑鏁版嵁
+ zfShares.forEach(zfDoctorDownload -> {
+ EsModel esModel = esService.findByCtId(zfDoctorDownload.getId().intValue(), "瀹跺ぇ浜嬭鍒嗕韩鍒犻櫎");
+ if (esModel != null) {
+ DeleteRequest deleteRequest = new DeleteRequest("allsearchdata", esModel.getId());
+ System.out.println(deleteRequest);
+ try {
+ restHighLevelClient.delete(deleteRequest, RequestOptions.DEFAULT);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ });
+ return true;
+ } else {
+ return false;
+ }
+ }
+
}
--
Gitblit v1.9.1