From bfd7201c84e250e88b9a83ba55317b16f08c7a38 Mon Sep 17 00:00:00 2001
From: feige <feige@qq.com>
Date: 星期五, 15 九月 2023 12:00:24 +0800
Subject: [PATCH] 定义了EsModel作为报错到es的数据模型,每个表要存储的是每个表的表明 表对应的主键,以及要被检索的字段

---
 zhang-content/src/main/java/com/ruoyi/service/impl/ZfCollectionServiceImpl.java |   53 ++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 48 insertions(+), 5 deletions(-)

diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfCollectionServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfCollectionServiceImpl.java
index e0f605e..415f1c4 100644
--- a/zhang-content/src/main/java/com/ruoyi/service/impl/ZfCollectionServiceImpl.java
+++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZfCollectionServiceImpl.java
@@ -1,9 +1,11 @@
 package com.ruoyi.service.impl;
 
 
+import com.alibaba.fastjson2.JSONObject;
 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.fasterxml.jackson.core.JsonParser;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.utils.MapUtils;
@@ -17,6 +19,7 @@
 import com.ruoyi.service.ZAuthorityService;
 import com.ruoyi.service.ZInfoUserService;
 import com.ruoyi.service.ZfCollectionService;
+import com.ruoyi.service.ZfLogService;
 import com.ruoyi.util.ArraysUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
@@ -24,10 +27,8 @@
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
+import java.time.LocalDateTime;
+import java.util.*;
 import java.util.stream.Collectors;
 
 import static com.ruoyi.constant.MenuAuthority.*;
@@ -52,6 +53,12 @@
 
     @Resource
     ZAuthorityService zAuthorityService;
+
+    @Resource
+    ZfCollectionMapper zfCollectionMapper;
+
+    @Resource
+    ZfLogService zfLogService;
 
     private LambdaQueryWrapper<ZfCollection> buildCondition(ZfCollection zfCollection,List<Long> familyIdList) {
         LambdaQueryWrapper<ZfCollection> lqw = new LambdaQueryWrapper<>();
@@ -265,7 +272,7 @@
                         bean.setOwnData(0);
                     }
                 }
-        ).collect(Collectors.toList());
+        ).sorted((a,b)-> b.getOwnData()-a.getOwnData()).collect(Collectors.toList());
     }
 
     @Override
@@ -399,7 +406,37 @@
             throw new RuntimeException("浣犳病鏈夋潈闄愭搷浣滄瀹跺涵鐨勬暟鎹�");
         }
 
+        //鍏堣褰曚笅璋佹洿鏂般�佷綍鏃舵洿鏂般�佹洿鏂颁簡鍝噷
+
+//        LambdaQueryWrapper<ZfCollection> lqw = new LambdaQueryWrapper<>();
+//        lqw.eq(ZfCollection::getId,zfCollection.getId());
+//        zfCollectionService.getOne(lqw);
+//        ZfCollection oldData = getOne(lqw);
+//
+//        String oldJson = JSONObject.toJSONString(oldData);
+//        String newJson = JSONObject.toJSONString(zfCollection);
+//
+//        Map oldMap = JSONObject.parseObject(oldJson, Map.class);
+//        Map newMap = JSONObject.parseObject(newJson, Map.class);
+//
+//        for (Object key : oldMap.keySet()) {
+//            if(newMap.get(key)!=null && !newMap.get(key).equals(oldMap.get(key))){
+//                System.out.println(newMap.get(key)+"     "+oldMap.get(key));
+//                Date date = new Date();
+//                System.out.println("鐢ㄦ埛"+myself.getNickName()+"鍦�"+date+"杩欎釜鏃堕棿"+"淇敼浜�<鏀惰棌鑽h獕>妯″潡鐨�"+key+"瀛楁");
+//            }
+//        }
+
+        //鎿嶄綔鍚庡姞鍏ユ棩蹇�
+        ZfLog zfLog = new ZfLog();
+        zfLog.setUpdateTime(LocalDateTime.now());
+        zfLog.setModule("鏀惰棌鑽h獕");
+        zfLog.setUpdater(zInfoUserService.getMyself().getNickName());
+        zfLogService.save(zfLog);
+
+
         if(updateById(zfCollection)){
+
             return AjaxResult.success();
         }else {
             return AjaxResult.error();
@@ -430,6 +467,12 @@
         }
     }
 
+    @Override
+    public AjaxResult listType() {
+        List<String> result = zfCollectionMapper.listType();
+        return AjaxResult.success(result);
+    }
+
 
     @Override
     @Transactional

--
Gitblit v1.9.1