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/ide/IDocumentService.java  |   29 +++++++
 src/main/java/com/product/file/service/DocumentService.java       |   95 +++++++++++++++++++++++
 src/main/java/com/product/file/controller/DocumentConstoller.java |   60 +++++++++++++++
 3 files changed, 184 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/product/file/controller/DocumentConstoller.java b/src/main/java/com/product/file/controller/DocumentConstoller.java
index 0cf90b3..123edb9 100644
--- a/src/main/java/com/product/file/controller/DocumentConstoller.java
+++ b/src/main/java/com/product/file/controller/DocumentConstoller.java
@@ -25,6 +25,7 @@
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.*;
+import java.util.function.DoubleConsumer;
 
 /**
  * Copyright LX-BASE
@@ -382,6 +383,65 @@
         }
     }
 
+
+    @RequestMapping(value = "/getApplyDocument/{version}", method = RequestMethod.POST)
+    @ApiVersion(1)
+    public String getApplyDocument(HttpServletRequest request){
+        DataTableEntity applyDocument = documentService.getApplyDocument();
+        return OK_List(applyDocument);
+
+    }
+
+
+    /**
+     * 鏂囨。鐢宠淇濆瓨涓庢洿鏂�
+     * @param request
+     * @return
+     */
+    @RequestMapping(value = "/addOrUpdateApplyDocument/{version}", method = RequestMethod.POST)
+    @ApiVersion(1)
+    public String addOrUpdateApplyDocument(HttpServletRequest request){
+        //鑾峰彇鍙傛暟
+        FieldSetEntity fse = null;
+        Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
+        if (bean != null) {
+            RequestParameterEntity reqp = (RequestParameterEntity) bean;
+            fse = reqp.getFormData();
+        }
+        //鍒ゆ柇鍙傛暟鏄惁涓虹┖
+        if (fse == null) {
+            SpringMVCContextHolder
+                    .getSystemLogger().error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText());
+            return this.error(DocumentCode.DOCUMENT_FORM_NODATA.getValue(), DocumentCode.DOCUMENT_FORM_NODATA.getText());
+        }
+        documentService.addOrUpdateApplyDocument(fse);
+        return  OK();
+    }
+
+    /**
+     * 鍊熼槄鏂囨。鎺掑悕
+     * @return
+     */
+    @RequestMapping(value = "/getApplayFileSort/{version}", method = RequestMethod.POST)
+    @ApiVersion(1)
+    public String getApplayFileSort(){
+        DataTableEntity applayFileSort = documentService.getApplayFileSort();
+        return  OK_List(applayFileSort);
+    }
+
+
+    /**
+     * 鏂囨。鍊熼槄浜哄憳鎺掑悕
+     * @return
+     */
+    @RequestMapping(value = "/getApplayUserSort/{version}", method = RequestMethod.POST)
+    @ApiVersion(1)
+    public String getApplayUserSort(){
+        DataTableEntity applayFileSort = documentService.getApplayUserSort();
+        return  OK_List(applayFileSort);
+    }
+
 }
 
 
+
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;
+    }
 }
diff --git a/src/main/java/com/product/file/service/ide/IDocumentService.java b/src/main/java/com/product/file/service/ide/IDocumentService.java
index fb94c34..58709f1 100644
--- a/src/main/java/com/product/file/service/ide/IDocumentService.java
+++ b/src/main/java/com/product/file/service/ide/IDocumentService.java
@@ -4,6 +4,7 @@
 import com.product.core.entity.DataTableEntity;
 import com.product.core.entity.FieldSetEntity;
 import com.product.core.exception.BaseException;
+import org.jsoup.Connection;
 
 /**
  * Copyright LX-BASE
@@ -115,4 +116,32 @@
    * @throws BaseException
    */
   DataTableEntity getDocumentLog(FieldSetEntity fieldSet)throws BaseException;
+
+  /**
+   * 鑾峰彇鍊熼槄鏂囨。鐨勫垪琛�
+   * @return
+   * @throws BaseException
+   */
+  DataTableEntity getApplyDocument() throws BaseException;
+
+  /**
+   * 鏇存柊娣诲姞鍊熼槄鐢宠
+   * @throws BaseException
+   */
+  void  addOrUpdateApplyDocument(FieldSetEntity fse) throws  BaseException;
+
+  /**
+   * 鑾峰彇鍊熼槄鏂囨。鎺掑悕
+   * @return
+   * @throws BaseException
+   */
+
+  DataTableEntity getApplayFileSort() throws BaseException;
+
+  /**
+   * 鑾峰彇鍊熼槄浜烘帓鍚�
+   * @return
+   * @throws BaseException
+   */
+  DataTableEntity getApplayUserSort() throws BaseException;
 }

--
Gitblit v1.9.2