18756
2024-08-23 f7fdd04ab30bb9a88d8399895776fa4c15673e86
文档借阅功能8.23
已修改3个文件
184 ■■■■■ 文件已修改
src/main/java/com/product/file/controller/DocumentConstoller.java 60 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/file/service/DocumentService.java 95 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/file/service/ide/IDocumentService.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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);
    }
}
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;
    }
}
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;
}