lizhenhao 2 лет назад
Родитель
Сommit
5fb2d0ba33

+ 100 - 1
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/cw/projectReport/controller/CwProjectReportSignatureCallBackController.java

@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.TypeReference;
+import com.aliyun.oss.OSSClient;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -15,7 +16,11 @@ import com.jeeplus.common.redis.RedisUtils;
 import com.jeeplus.flowable.model.Flow;
 import com.jeeplus.flowable.service.FlowTaskService;
 import com.jeeplus.sys.domain.User;
+import com.jeeplus.sys.service.OfficeService;
 import com.jeeplus.sys.service.UserService;
+import com.jeeplus.sys.service.dto.OfficeDTO;
+import com.jeeplus.sys.service.dto.PostDTO;
+import com.jeeplus.sys.service.dto.RoleDTO;
 import com.jeeplus.sys.service.dto.UserDTO;
 import com.jeeplus.sys.utils.Global;
 import com.jeeplus.sys.utils.SpringContextHolder;
@@ -42,6 +47,7 @@ import org.flowable.bpmn.model.FlowNode;
 import org.flowable.engine.TaskService;
 import org.flowable.task.api.Task;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.data.redis.connection.jedis.JedisUtils;
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Controller;
@@ -55,6 +61,7 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.*;
 import java.lang.reflect.Type;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 项目签章回调接口Controller
@@ -98,6 +105,8 @@ public class CwProjectReportSignatureCallBackController {
     private FlowTaskService flowTaskService;
     @Autowired
     private TaskService taskService;
+    @Autowired
+    private OfficeService officeService;
 
 
     /**
@@ -525,8 +534,57 @@ public class CwProjectReportSignatureCallBackController {
         page.setSize(-1);
         IPage<UserDTO> pageList = userService.findPage(page, new QueryWrapper<UserDTO>());
         // 将全部用户数据执行保存操作
-        pageList.getRecords().stream().forEach(userDTO -> {
+        pageList.getRecords().stream().forEach(uuu -> {
             try {
+                UserDTO userDTO = userService.get ( uuu.getId() );
+                if(com.jeeplus.sys.utils.StringUtils.isNotBlank(userDTO.getManageOfficeIds())){
+                    //获取当前人管理的部门id
+                    List<String> manageOfficeIdList=Arrays.asList(userDTO.getManageOfficeIds().split(","));
+                    //查询这些部门信息
+                    List<String> officeNameList = officeService.getOfficeNameByIds(manageOfficeIdList);
+                    userDTO.setManageOfficeNameList(officeNameList);
+                }
+                if(ObjectUtil.isNotEmpty(userDTO)) {
+                    if(CollectionUtil.isNotEmpty(userDTO.getCertDTOList())){
+                        userDTO.getCertDTOList().stream().forEach(item->{
+                            if (com.jeeplus.sys.utils.StringUtils.isNotBlank(item.getFileUrl())){
+                                String fileTemporaryLookUrl = this.getFileTemporaryLookUrl(item.getFileUrl());
+                                item.setFileLsUrl(fileTemporaryLookUrl);
+                            }
+                        });
+                    }
+                }
+                //根据office.id 查询部门的所有父节点信息
+                if(null != userDTO.getOfficeDTO() && com.jeeplus.sys.utils.StringUtils.isNotBlank(userDTO.getOfficeDTO().getId())){
+                    OfficeDTO office = officeService.getOfficeById(userDTO.getOfficeDTO().getId());
+                    //将office的父节点信息进行分割并查询赋值
+                    if(null != office){
+                        List<String> officeIdList = Arrays.asList(office.getParentIds().split(","));
+                        Integer sort = 0;
+                        if(null != officeIdList && officeIdList.size()>0){
+                            for (String officeId : officeIdList) {
+                                if(com.jeeplus.sys.utils.StringUtils.isNotBlank(officeId) && !"0".equals(officeId)){
+                                    sort ++ ;
+                                    OfficeDTO officeChild = officeService.getOfficeById(officeId);
+                                    if(null != officeChild) {
+                                        switch (sort){
+                                            case 1:
+                                                userDTO.setCompanyDTO(officeChild);
+                                                break;
+                                            case 2:
+                                                userDTO.setCorporationDTO(officeChild);
+                                                break;
+                                            case 3:
+                                                userDTO.setOfficeDTO(officeChild);
+                                                break;
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+
+                }
                 userService.saveOrUpdate(userDTO);
             } catch (Exception e) {
                 e.printStackTrace();
@@ -534,4 +592,45 @@ public class CwProjectReportSignatureCallBackController {
         });
     }
 
+
+    @Value("${config.accessory.aliyun.aliyunUrl}")
+    private String aliyunUrl;
+    @Value("${config.accessory.aliyun.aliyunDownloadUrl}")
+    private String aliyunDownloadUrl;
+    @Value("${config.accessory.aliyun.endpoint}")
+    private String endpoint;
+    @Value("${config.accessory.aliyun.accessKeyId}")
+    private String accessKeyId;
+    @Value("${config.accessory.aliyun.accessKeySecret}")
+    private String accessKeySecret;
+    @Value("${config.accessory.aliyun.bucketName}")
+    private String bucketName;
+    /**
+     * 阿里云获取临时文件查看url
+     * @param url
+     */
+    public String getFileTemporaryLookUrl(String url){
+        url = url.replace("amp;","");
+        String cons = "";
+        if (url.contains(aliyunUrl)){
+            cons = aliyunUrl;
+        }else if (url.contains("http://gangwan-app.oss-cn-hangzhou.aliyuncs.com")){
+            cons = "http://gangwan-app.oss-cn-hangzhou.aliyuncs.com";
+        }else {
+            cons = aliyunDownloadUrl;
+        }
+        String key = "";
+        String[] split = url.split(cons + "/");
+        if(split.length>1){
+            key = split[1];
+        }else{
+            key = url;
+        }
+        // 指定过期时间为24小时。
+        Date expiration = new Date(new Date().getTime() + 1000 * 60 * 60 * 24 );
+        //初始化OSSClient
+        OSSClient ossClient = new OSSClient(endpoint,accessKeyId,accessKeySecret);
+        return ossClient.generatePresignedUrl(bucketName, key, expiration).toString();
+    }
+
 }