From f7fdd04ab30bb9a88d8399895776fa4c15673e86 Mon Sep 17 00:00:00 2001
From: 18756 <1875631620@qq.com>
Date: 星期五, 23 八月 2024 15:43:09 +0800
Subject: [PATCH] 文档借阅功能8.23

---
 src/main/java/com/product/file/service/DocumentService.java |   95 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 95 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/product/file/service/DocumentService.java b/src/main/java/com/product/file/service/DocumentService.java
index febc3bd..03257d8 100644
--- a/src/main/java/com/product/file/service/DocumentService.java
+++ b/src/main/java/com/product/file/service/DocumentService.java
@@ -1,5 +1,7 @@
 package com.product.file.service;
 
+import cn.hutool.core.lang.UUID;
+import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.product.common.collect.ListUtils;
 import com.product.common.collect.MapUtils;
@@ -467,4 +469,97 @@
         return baseDao.listTable("SELECT CONCAT(b.show_name, a.state) log,a.created_utc_datetime FROM PRODUCT_OA_document_log a LEFT JOIN product_sys_staffs b on a.created_by = b.user_id WHERE document_uuid = ? ORDER BY a.created_utc_datetime DESC",
                 new String[]{fieldSetEntity.getString(CmnConst.DOCUMENT_UUID)}, fieldSetEntity.getInteger(CmnConst.PAGESIZE), fieldSetEntity.getInteger(CmnConst.CPAGE));
     }
+
+    @Override
+    public DataTableEntity getApplyDocument() throws BaseException {
+
+        DataTableEntity product_oa_document = baseDao.listTable("product_oa_document");
+
+        return product_oa_document;
+    }
+
+    @Override
+    public void addOrUpdateApplyDocument(FieldSetEntity fse) throws BaseException {
+
+        String[] attachment = new String[0];
+        if(ObjectUtil.isNotEmpty(fse.getString("uuid"))){
+            UUID uuid = UUID.randomUUID();
+            fse.setValue("uuid",uuid);
+            baseDao.add(fse);
+
+            if(ObjectUtil.isNotEmpty(fse.getString("attachment_uuid"))){
+                String attachment_uuid = fse.getString("attachment_uuid");
+                attachment= attachment_uuid.split(",");
+            }
+            for (int i = 0; i < attachment.length; i++) {
+                FieldSetEntity fieldSetEntity = new FieldSetEntity();
+                fieldSetEntity.setTableName("product_oa_document_borrow_sub");
+                fieldSetEntity.setValue("borrow_uuid",uuid);
+                fieldSetEntity.setValue("sub_uuid",attachment[i]);
+
+            }
+
+        }else {
+            String uuid = fse.getString("uuid");
+            String filter="borrow_uuid='"+uuid+"'";
+            //鍒犻櫎鍘熸潵闄勪欢淇℃伅
+            baseDao.delete("product_oa_document_borrow_sub",filter,new Object[]{});
+            baseDao.update(fse);
+            if(ObjectUtil.isNotEmpty(fse.getString("attachment_uuid"))){
+                String attachment_uuid = fse.getString("attachment_uuid");
+                attachment= attachment_uuid.split(",");
+            }
+
+            //閲嶆柊璺熸柊闄勪欢淇℃伅
+            for (int i = 0; i < attachment.length; i++) {
+                FieldSetEntity fieldSetEntity = new FieldSetEntity();
+                fieldSetEntity.setTableName("product_oa_document_borrow_sub");
+                fieldSetEntity.setValue("borrow_uuid",uuid);
+                fieldSetEntity.setValue("sub_uuid",attachment[i]);
+                baseDao.add(fieldSetEntity);
+
+            }
+
+
+        }
+
+    }
+
+    @Override
+    public DataTableEntity getApplayFileSort() throws BaseException {
+        StringBuilder sb=new StringBuilder();
+        sb.append(" SELECT b.* FROM (");
+        sb.append(" SELECT t.uuid,t.file_name,s.show_name,t.created_utc_datetime,count(t.uuid) as applyCount");
+        sb.append(" FROM product_oa_document_borrow_sub b");
+        sb.append(" JOIN product_oa_document t");
+        sb.append(" on b.sub_uuid=t.uuid");
+        sb.append(" JOIN product_sys_staffs s ");
+        sb.append(" on t.created_by=s.user_id");
+        sb.append(" group by t.file_name,t.uuid,s.show_name,t.created_utc_datetime");
+        sb.append(" )b order by  b.applyCount asc");
+        DataTableEntity dataTableEntity = baseDao.listTable(sb.toString());
+        return dataTableEntity;
+    }
+
+    @Override
+    public DataTableEntity getApplayUserSort() throws BaseException {
+        StringBuilder sb=new StringBuilder();
+        sb.append(" SELECT a.borrower,a.show_name,a.applayCount,a.applayFileCount ");
+        sb.append(" FROM (");
+        sb.append(" SELECT w.borrower,");
+        sb.append(" (select   count(borrower)  from  product_oa_document_borrow group by borrower ) as  applayCount,");
+        sb.append(" count(sub_uuid) as applayFileCount ");
+        sb.append(" FROM product_oa_document_borrow  w ");
+        sb.append(" JOIN product_oa_document_borrow_sub b");
+        sb.append(" on b.borrow_uuid=w.uuid");
+        sb.append(" JOIN product_oa_document t");
+        sb.append(" on b.sub_uuid=t.uuid");
+        sb.append(" JOIN product_sys_staffs s");
+        sb.append(" on w.borrower=s.user_id");
+        sb.append(" GROUP BY w.borrower,s.show_name");
+        sb.append(" )a");
+        sb.append(" order by a.applayCount,a.applayFileCount asc");
+        DataTableEntity dataTableEntity = baseDao.listTable(sb.toString());
+        return dataTableEntity;
+    }
 }

--
Gitblit v1.9.2