From 458bed025c92c45ce7cfca3e685b9cb9548c61d3 Mon Sep 17 00:00:00 2001
From: fei <791364011@qq.com>
Date: 星期一, 06 十月 2025 08:54:53 +0800
Subject: [PATCH] 提交证书
---
zhang-content/src/main/java/com/ruoyi/service/impl/ZfEquipDownloadServiceImpl.java | 160 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 159 insertions(+), 1 deletions(-)
diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfEquipDownloadServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfEquipDownloadServiceImpl.java
index 224d078..e925f03 100644
--- a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfEquipDownloadServiceImpl.java
+++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfEquipDownloadServiceImpl.java
@@ -1,2 +1,160 @@
-package com.ruoyi.service.impl;public class ZfEquipDownloadServiceImpl {
+
+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.domain.ZInfoUser;
+import com.ruoyi.domain.ZfDownload;
+import com.ruoyi.domain.ZfEconomy;
+import com.ruoyi.domain.ZfEquipment;
+import com.ruoyi.mapper.ZfDownloadMapper;
+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.*;
+import java.util.stream.Collectors;
+
+@Slf4j
+@Service
+public class ZfEquipDownloadServiceImpl extends ServiceImpl<ZfDownloadMapper,ZfDownload> implements ZfEquipDownloadService {
+ @Resource
+ EsService esService;
+
+ @Resource
+ ZfEquipShareService zfEquipShareService;
+
+ @Resource
+ ZfEquipmentService zfEquipmentService;
+
+
+ @Resource
+ ZInfoUserService zInfoUserService;
+
+ @Resource
+ private RestHighLevelClient restHighLevelClient;
+
+ private LambdaQueryWrapper<ZfDownload> buildCondition(ZfDownload zfDownload, Long userId) {
+ LambdaQueryWrapper<ZfDownload> lqw = new LambdaQueryWrapper<>();
+ lqw.in(ZfDownload::getDownloadId,userId);
+ lqw.orderByDesc(ZfDownload::getDownloadId);
+ lqw.like(zfDownload.getDownloadId() != null, ZfDownload::getDownloadId, zfDownload.getDownloadId())
+ .like(zfDownload.getDownloadContent() != null, ZfDownload::getDownloadContent, zfDownload.getDownloadContent())
+ .eq( ZfDownload::getSysMenuId, zfDownload.getSysMenuId());
+ return lqw;
+ }
+ private LambdaQueryWrapper<ZfDownload> uniqueCondition(ZfDownload zfDownload) {
+ LambdaQueryWrapper<ZfDownload> lqw = new LambdaQueryWrapper<>();
+ lqw.eq(StringUtils.isNotEmpty(String.valueOf(zfDownload.getDownloadId())), ZfDownload::getDownloadId, zfDownload.getDownloadId())
+ .eq(StringUtils.isNotEmpty(String.valueOf(zfDownload.getDownloadContent())), ZfDownload::getDownloadContent, zfDownload.getDownloadContent())
+ .eq(ZfDownload::getSysMenuId, zfDownload.getSysMenuId());
+ return lqw;
+ }
+
+ public Long getUserId() {
+ ZInfoUser myself = zInfoUserService.getMyself();
+ return myself.getUserId();
+ }
+ @Override
+ public AjaxResult addData(ZfDownload zfDownload) {
+ zfDownload.setDownloadId(getUserId());
+ LambdaQueryWrapper<ZfDownload> lqw = uniqueCondition(zfDownload);
+ List<ZfDownload> list = list(lqw);
+ if (list.size() > 0) {
+ throw new RuntimeException("璇峰嬁閲嶅涓嬭浇鏁版嵁");
+ }
+
+ zfDownload.setDownloadId(getUserId());
+ zfDownload.setShareId(zfEquipShareService.getShareId(zfDownload));
+ if (save(zfDownload)) {
+ EsModel esModel = new EsModel();
+ Integer inte = zfDownload.getId().intValue();
+ String uuid = UUID.randomUUID().toString().replace("-", "");
+ esModel.setId(uuid);
+ esModel.setCtId(Long.valueOf(inte));
+ esModel.setCtTableName("瀹跺涵璁惧");
+
+ esModel.setBy1(String.valueOf(zfDownload.getDownloadId()));
+ esModel.setBy2(String.valueOf(zfDownload.getDownloadContent()));
+ esModel.setBy3(String.valueOf(zfDownload.getShareId()));
+ //杩欓噷瀛樺偍鏌ヨ璇︽儏鐨勮矾寰�
+ esService.insertTable(esModel);
+ return AjaxResult.success();
+ } else {
+ return AjaxResult.error();
+ }
+ }
+
+ @Override
+ public Boolean deleteData(Long[] ids) {
+ List<Long> id = new ArrayList<>();
+
+ LambdaQueryWrapper<ZfDownload> lqw = new LambdaQueryWrapper<>();
+ lqw.in(ids != null, ZfDownload::getDownloadContent, ids)
+ .eq(ZfDownload::getSysMenuId, 2017L);
+
+ List<ZfDownload> zfDownloads = list(lqw);
+ System.out.println(zfDownloads);
+ if (zfDownloads.size() == 0){
+ return true;
+ }
+ for (ZfDownload zfDownload: zfDownloads) {
+ id.add(zfDownload.getId());
+ }
+ System.out.println("15102120202121212122222222221");
+ System.out.println(id);
+ if (removeByIds(id)) {
+ System.out.println("4535468486525852");
+
+ //鍒犻櫎es涓殑鏁版嵁
+ zfDownloads.stream().forEach(zfDoctorDownload -> {
+ EsModel esModel = esService.findByCtId(zfDoctorDownload.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 true;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public AjaxResult selectDoctorList(ZfDownload zfDownload, Integer pageNo, Integer pageSize) {
+ ZInfoUser myself = zInfoUserService.getMyself();
+ LambdaQueryWrapper<ZfDownload> lqw = buildCondition(zfDownload,myself.getUserId());
+ List<ZfDownload> beanRecords = list(lqw);
+ List<ZfEquipment> bs = new ArrayList<>();
+ for (ZfDownload a: beanRecords) {
+ if (zfEquipmentService.getById(a.getDownloadContent()) != null) {
+ ZfEquipment ds = zfEquipmentService.getById(a.getDownloadContent());
+ ds.setShareId(a.getShareId().intValue());
+ bs.add(ds);
+ }
+ }
+ 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);
+ }
+
}
--
Gitblit v1.9.1