huangjn преди 3 години
родител
ревизия
b3fe18ccfa
променени са 19 файла, в които са добавени 262 реда и са изтрити 235 реда
  1. 9 0
      blade-ops-api/blade-resource-api/src/main/java/org/springblade/resource/feign/NewIOSSClient.java
  2. 0 135
      blade-ops/blade-resource/src/main/java/org/springblade/resource/endpoint/OssEndpoint.java
  3. 11 0
      blade-ops/blade-resource/src/main/java/org/springblade/resource/feign/NewIOSSClientImpl.java
  4. 1 1
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/feign/InformationQueryClient.java
  5. 4 4
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/feign/TaskClient.java
  6. 1 1
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/TaskApprovalVO.java
  7. 6 0
      blade-service-api/blade-e-visa-api/src/main/java/org/springblade/evisa/feign/EVisaClient.java
  8. 2 1
      blade-service-api/blade-e-visa-api/src/main/java/org/springblade/evisa/vo/EVisaTaskApprovalVO.java
  9. 0 7
      blade-service/blade-business/src/main/java/org/springblade/business/controller/TaskController.java
  10. 2 2
      blade-service/blade-business/src/main/java/org/springblade/business/feignClient/InformationQueryClientImpl.java
  11. 1 1
      blade-service/blade-business/src/main/java/org/springblade/business/service/IInformationQueryService.java
  12. 4 4
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/InformationQueryServiceImpl.java
  13. 6 2
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TaskServiceImpl.java
  14. 10 0
      blade-service/blade-e-visa/pom.xml
  15. 8 6
      blade-service/blade-e-visa/src/main/java/org/springblade/evisa/feign/EVisaClientImpl.java
  16. 1 3
      blade-service/blade-e-visa/src/main/java/org/springblade/evisa/redissionUtil/DistributedRedisLock.java
  17. 8 0
      blade-service/blade-e-visa/src/main/java/org/springblade/evisa/service/EVisaService.java
  18. 170 64
      blade-service/blade-e-visa/src/main/java/org/springblade/evisa/service/impl/EVisaServiceImpl.java
  19. 18 4
      blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ExcelTabController.java

+ 9 - 0
blade-ops-api/blade-resource-api/src/main/java/org/springblade/resource/feign/NewIOSSClient.java

@@ -3,9 +3,14 @@ package org.springblade.resource.feign;
 import org.springblade.core.launch.constant.AppConstant;
 import org.springblade.core.oss.model.BladeFile;
 import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.http.MediaType;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
 
 @FeignClient(value = AppConstant.APPLICATION_RESOURCE_NAME)
 public interface NewIOSSClient {
@@ -13,6 +18,10 @@ public interface NewIOSSClient {
     String API_PREFIX = "/newOSSClient";
     String UPLOAD_FILE_INFO = API_PREFIX + "/uploadFileInfo";
     String UPLOAD_FILE_INFO_BYTE = API_PREFIX + "/uploadFileInfoByte";
+    String UPLOAD_FILE_INFO_INPUT_STREAM = API_PREFIX + "/uploadFileInfoInputStream";
+
+    @PostMapping(value = UPLOAD_FILE_INFO_INPUT_STREAM, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
+    BladeFile uploadFileByInputStream(MultipartFile file);
 
     @PostMapping(UPLOAD_FILE_INFO)
     BladeFile uploadFile(@RequestParam String fileName, @RequestParam String localFileUrl);

+ 0 - 135
blade-ops/blade-resource/src/main/java/org/springblade/resource/endpoint/OssEndpoint.java

@@ -213,141 +213,6 @@ public class OssEndpoint {
 		return R.data(newBladeFile);
 	}
 
-//	/**
-//	 * png 和 jpg 转 pdf
-//	 * @param originalFilename 文件名称
-//	 * @param is 文件输入流
-//	 * @return 上传结果对象
-//	 */
-//	private NewBladeFile pngOrJpgToPdf(String originalFilename, InputStream is){
-//		String pdfFileUrl = "";
-//		try{
-//			com.itextpdf.text.Document document = new com.itextpdf.text.Document();
-//			document.setMargins(0,0,0,0);
-//			ByteArrayOutputStream bos = new ByteArrayOutputStream();
-//			PdfWriter.getInstance(document, bos);
-//			document.open();
-//			Image image = Image.getInstance(this.InputStreamToBytes(is));
-//			// 设置页面宽高与图片一致
-//			document.setPageSize(new Rectangle(image.getScaledWidth(), image.getScaledHeight()));
-//			// 图片居中(感觉没啥用)
-//			image.setAlignment(Image.ALIGN_CENTER);
-//			// 新建一页添加图片
-//			document.newPage();
-//			document.add(image);
-//			document.close();
-//
-//			//上传文件
-//			InputStream pdfInput = new ByteArrayInputStream(bos.toByteArray());
-//			BladeFile bladeFile = this.ossBuilder.template().putFile(originalFilename,pdfInput);
-//			pdfFileUrl = bladeFile.getLink();
-//
-//		}catch (Exception e){
-//			e.printStackTrace();
-//		}
-//
-//		NewBladeFile newBladeFile = new NewBladeFile();
-//		newBladeFile.setPdfUrl(pdfFileUrl);
-//		newBladeFile.setPage(1);
-//
-//		return newBladeFile;
-//	}
-//
-//	/**
-//	 * 获取字节数组
-//	 */
-//	private byte[] InputStreamToBytes(InputStream is) throws IOException {
-//		BufferedInputStream bis = new BufferedInputStream(is);
-//		ByteArrayOutputStream os = new ByteArrayOutputStream();
-//		int date = -1;
-//		while ((date = bis.read()) != -1) {
-//			os.write(date);
-//		}
-//		return os.toByteArray();
-//	}
-
-//	/**
-//	 * word 转 pdf
-//	 * @param originalFilename 文件名称
-//	 * @param is 文件输入流
-//	 * @return 上传结果对象
-//	 */
-//	private NewBladeFile wordToPdf(String originalFilename, InputStream is){
-//		String pdfFileUrl = "";
-//		int page = 0;
-//		try{
-//			com.aspose.words.Document document = new com.aspose.words.Document(is);
-//
-//			DocumentBuilder documentBuilder = new DocumentBuilder(document);
-//			com.aspose.words.Font font = documentBuilder.getFont();
-//
-//			font.setName("宋体");
-//
-//			ByteArrayOutputStream bos = new ByteArrayOutputStream();
-//			document.save(bos,com.aspose.words.SaveFormat.PDF);
-//
-//			//上传文件
-//			InputStream pdfInput = new ByteArrayInputStream(bos.toByteArray());
-//			BladeFile bladeFile = this.ossBuilder.template().putFile(originalFilename,pdfInput);
-//			pdfFileUrl = bladeFile.getLink();
-//
-//			//获取页数
-//			page = document.getPageCount();
-//
-//		}catch (Exception e){
-//			e.printStackTrace();
-//		}
-//		NewBladeFile newBladeFile = new NewBladeFile();
-//		newBladeFile.setPdfUrl(pdfFileUrl);
-//		newBladeFile.setPage(page);
-//		return newBladeFile;
-//	}
-
-//	/**
-//	 * excel 转 pdf
-//	 * @param originalFilename 文件名称
-//	 * @param is 文件输入流
-//	 * @return 上传结果对象
-//	 */
-//	private NewBladeFile excelToPdf(String originalFilename, InputStream is){
-//		String pdfFileUrl = "";
-//		int page = 0;
-//		try{
-//			org.apache.poi.ss.usermodel.Workbook ss = WorkbookFactory.create(is);
-//
-//			for(int i = 0, l = ss.getNumberOfSheets(); i < l; i ++){
-//				Sheet sheet = ss.getSheetAt(i);
-//				//去掉表格虚线
-//				sheet.setPrintGridlines(false);
-//				//设置 整个工作表为一页
-//				sheet.setFitToPage(true);
-//			}
-//
-//			ByteArrayOutputStream outReport = new ByteArrayOutputStream();
-//			ss.write(outReport);
-//			com.aspose.cells.Workbook wb = new com.aspose.cells.Workbook(new ByteArrayInputStream(outReport.toByteArray()));
-//
-//			ByteArrayOutputStream bos = new ByteArrayOutputStream();
-//			wb.save(bos, SaveFormat.PDF);
-//			bos.flush();
-//			//上传文件
-//			InputStream pdfInput = new ByteArrayInputStream(bos.toByteArray());
-//			BladeFile bladeFile = this.ossBuilder.template().putFile(originalFilename,pdfInput);
-//			pdfFileUrl = bladeFile.getLink();
-//
-//			//获取页数
-//			page = wb.getWorksheets().getActiveSheetIndex() + 1;
-//
-//			bos.close();
-//		}catch (Exception e){
-//			e.printStackTrace();
-//		}
-//		NewBladeFile newBladeFile = new NewBladeFile();
-//		newBladeFile.setPdfUrl(pdfFileUrl);
-//		newBladeFile.setPage(page);
-//		return  newBladeFile;
-//	}
-
 	/**
 	 * 上传文件
 	 *

+ 11 - 0
blade-ops/blade-resource/src/main/java/org/springblade/resource/feign/NewIOSSClientImpl.java

@@ -5,6 +5,7 @@ import org.springblade.core.oss.model.BladeFile;
 import org.springblade.core.tenant.annotation.NonDS;
 import org.springblade.resource.builder.oss.OssBuilder;
 import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
 
 import java.io.ByteArrayInputStream;
 import java.io.File;
@@ -21,6 +22,16 @@ public class NewIOSSClientImpl implements NewIOSSClient {
      */
     private final OssBuilder ossBuilder;
 
+    @Override
+    public BladeFile uploadFileByInputStream(MultipartFile file) {
+        try{
+            return this.ossBuilder.template().putFile(file.getOriginalFilename(), file.getInputStream());
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return null;
+    }
+
     @Override
     public BladeFile updateFile(byte[] fileByte, String fileName) {
         try{

+ 1 - 1
blade-service-api/blade-business-api/src/main/java/org/springblade/business/feign/InformationQueryClient.java

@@ -25,6 +25,6 @@ public interface InformationQueryClient {
      * @param sourceType 1原生2数据化
      */
     @PostMapping(API_PREFIX + "/saveOrUpdateInformationQueryData")
-    void saveOrUpdateInformationQueryData(@RequestParam Long wbsId, @RequestParam String fileName, @RequestParam Integer classify, @RequestParam Integer sourceType);
+    void saveOrUpdateInformationQueryData(@RequestParam String wbsId, @RequestParam String fileName, @RequestParam Integer classify, @RequestParam Integer sourceType);
 
 }

+ 4 - 4
blade-service-api/blade-business-api/src/main/java/org/springblade/business/feign/TaskClient.java

@@ -23,9 +23,9 @@ public interface TaskClient {
     String API_PREFIX = "/api/business/task";
     String START_TASK = API_PREFIX + "/start-task";
     String ABOLISH_TASK = API_PREFIX + "/abolish-task";
-    String QUERY_FORM_DATA_ID = "/query-form-data-id";
-    String QUERY_BUSINESS_DATA = "/query-business-data";
-    String QUERY_APPROVAL_USER = "/query-approval-user";
+    String QUERY_FORM_DATA_ID = API_PREFIX + "/query-form-data-id";
+    String QUERY_BUSINESS_DATA = API_PREFIX + "/query-business-data";
+    String QUERY_APPROVAL_USER = API_PREFIX + "/query-approval-user";
 
     @GetMapping(QUERY_APPROVAL_USER)
     List<TaskParallel> queryApprovalUser(@RequestParam String formDataIds);
@@ -33,7 +33,7 @@ public interface TaskClient {
     /**
      * 获取业务数据
      */
-    @GetMapping(QUERY_BUSINESS_DATA)
+    @PostMapping(QUERY_BUSINESS_DATA)
     TaskApprovalVO queryBusinessData(@RequestBody TaskApprovalVO taskApprovalVO);
 
     /**

+ 1 - 1
blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/TaskApprovalVO.java

@@ -44,7 +44,7 @@ public class TaskApprovalVO {
     }
 
     @Data
-    public class ApprovalFile {
+    public static class ApprovalFile {
 
         private String fileName;
 

+ 6 - 0
blade-service-api/blade-e-visa-api/src/main/java/org/springblade/evisa/feign/EVisaClient.java

@@ -34,4 +34,10 @@ public interface EVisaClient {
     @PostMapping(API_PREFIX + "/certification")
     String certification(@RequestParam String pdfUrl, @RequestParam String fileName, @RequestParam String contractId);
 
+    /**
+     * 验签
+     */
+    @PostMapping(API_PREFIX + "/checkSeal")
+    String checkSeal(@RequestParam String pdfUrl);
+    
 }

+ 2 - 1
blade-service-api/blade-e-visa-api/src/main/java/org/springblade/evisa/vo/EVisaTaskApprovalVO.java

@@ -6,6 +6,7 @@ import lombok.Data;
 import java.util.ArrayList;
 import java.util.List;
 
+@Data
 public class EVisaTaskApprovalVO {
 
     /**
@@ -43,7 +44,7 @@ public class EVisaTaskApprovalVO {
     }
 
     @Data
-    public class ApprovalFile {
+    public static class ApprovalFile {
 
         private String fileName;
 

+ 0 - 7
blade-service/blade-business/src/main/java/org/springblade/business/controller/TaskController.java

@@ -479,13 +479,6 @@ public class TaskController extends BladeController {
 	@ApiOperationSupport(order = 2)
 	@ApiOperation(value = "完成/审批任务")
 	public R<Boolean> completeApprovalTask(@RequestBody TaskApprovalVO taskApprovalVO){
-		//工程文件
-		TaskApprovalVO archiveFileVO = this.taskService.queryBusinessData(taskApprovalVO);
-		if(archiveFileVO != null){
-			//获取相关联的pdf
-			taskApprovalVO.setApprovalFileList(archiveFileVO.getApprovalFileList());
-		}
-
 		return R.data(this.taskService.completeApprovalTask(taskApprovalVO));
 	}
 

+ 2 - 2
blade-service/blade-business/src/main/java/org/springblade/business/feignClient/InformationQueryClientImpl.java

@@ -13,7 +13,7 @@ public class InformationQueryClientImpl implements InformationQueryClient {
     private final IInformationQueryService iInformationQueryService;
 
     @Override
-    public void saveOrUpdateInformationQueryData(Long wbsId, String fileName, Integer classify, Integer sourceType) {
-        this.iInformationQueryService.saveOrUpdateInformationQueryData( wbsId, fileName, classify, sourceType);
+    public void saveOrUpdateInformationQueryData(String wbsId, String fileName, Integer classify, Integer sourceType) {
+        this.iInformationQueryService.saveOrUpdateInformationQueryData(wbsId, fileName, classify, sourceType);
     }
 }

+ 1 - 1
blade-service/blade-business/src/main/java/org/springblade/business/service/IInformationQueryService.java

@@ -40,7 +40,7 @@ public interface IInformationQueryService extends BaseService<InformationQuery>
 	 * @param classify 1施工2质检
 	 * @param sourceType 1原生2数据化
 	 */
-	void saveOrUpdateInformationQueryData(Long wbsId, String fileName, Integer classify, Integer sourceType);
+	void saveOrUpdateInformationQueryData(String wbsId, String fileName, Integer classify, Integer sourceType);
 
 	/**
 	 * 获取当前合同段下所有的上报批次

+ 4 - 4
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/InformationQueryServiceImpl.java

@@ -34,11 +34,11 @@ public class InformationQueryServiceImpl extends BaseServiceImpl<InformationQuer
 	private final WbsTreeContractClient wbsTreeContractClient;
 
 	@Override
-	public void saveOrUpdateInformationQueryData(Long primaryKeyId, String fileName, Integer classify, Integer sourceType) {
+	public void saveOrUpdateInformationQueryData(String primaryKeyId, String fileName, Integer classify, Integer sourceType) {
 		BladeUser user = AuthUtil.getUser();
 
 		//判断当前填报节点下是否已经存在相应数据
-		InformationQuery oldData = this.baseMapper.getInformationQueryByWbsId(primaryKeyId, classify);
+		InformationQuery oldData = this.baseMapper.getInformationQueryByWbsId(Long.parseLong(primaryKeyId), classify);
 
 		if(oldData != null){
 			//存在记录,修改
@@ -63,7 +63,7 @@ public class InformationQueryServiceImpl extends BaseServiceImpl<InformationQuer
 			this.baseMapper.updateById(oldData);
 		} else {
 			//首先根据wbsId获取合同段ID和项目ID
-			WbsTreeContract contractTree = this.wbsTreeContractClient.getContractWbsTreeByPrimaryKeyId(primaryKeyId);
+			WbsTreeContract contractTree = this.wbsTreeContractClient.getContractWbsTreeByPrimaryKeyId(Long.parseLong(primaryKeyId));
 			//新增基础数据
 			InformationQuery newData = new InformationQuery();
 			//设置文件题名
@@ -77,7 +77,7 @@ public class InformationQueryServiceImpl extends BaseServiceImpl<InformationQuer
 			//施工资料还是质检资料
 			newData.setClassify(classify);
 			//节点ID
-			newData.setWbsId(primaryKeyId);
+			newData.setWbsId(Long.parseLong(primaryKeyId));
 			//是否是试验节点
 			newData.setIsExperiment(contractTree.getIsExpernode());
 			//数据ID

+ 6 - 2
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TaskServiceImpl.java

@@ -188,7 +188,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
             String eVisaStatus = this.eVisaClient.eVisa(JSONObject.parseObject(JSONObject.toJSONString(taskApprovalVO), EVisaTaskApprovalVO.class));
             //todo ============================ 执行电签区域 ============================
 
-            //电签状态为999(错误状态)的就需要重新提交请求
+            //电签状态分为success/notPfxOrFile/error,当状态为error时就需要重新提交请求
             if("success".equals(eVisaStatus)){
                 //完成/审批当前分支流程
                 this.newFlowClient.completeApprovalTask(taskId, parallelProcessInstanceId, comment).getData();
@@ -213,8 +213,11 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
                         this.updateBusinessDataByFormDataId(task, 2);
                     }
                 }
-            } else {
+            } else if("error".equals(eVisaStatus)) {
                 System.out.println("循环调用电签");
+            } else {
+                //notPfxOrFile,没有证书或证书文件过期等
+                return false;
             }
         } else {
             //废除,遵循只要某一个分支流程废除,则主流程废除、其它分支流程均自动结束
@@ -232,6 +235,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
                     if(parallel.getEVisaStatus() != null && parallel.getEVisaStatus() != -1){
                         //不为空说明已经执行电签,需要撤签
                         // todo =================== 撤签调用 ===================
+                        System.out.println("循环调用撤签");
                         // todo =================== 撤签调用 ===================
                     }
                     if(!new Integer("2").equals(parallel.getStatus())){

+ 10 - 0
blade-service/blade-e-visa/pom.xml

@@ -185,6 +185,16 @@
             <version>2.9.1.RELEASE</version>
             <scope>compile</scope>
         </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-test</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.pdfbox</groupId>
+            <artifactId>pdfbox</artifactId>
+            <version>2.0.20</version>
+            <scope>compile</scope>
+        </dependency>
         <!-- 电签相关 end -->
 
     </dependencies>

+ 8 - 6
blade-service/blade-e-visa/src/main/java/org/springblade/evisa/feign/EVisaClientImpl.java

@@ -1,16 +1,11 @@
 package org.springblade.evisa.feign;
 
+import cfca.paperless.dto.bean.CertBean;
 import lombok.AllArgsConstructor;
-import org.springblade.common.constant.EVisaConstant;
-import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.evisa.service.EVisaService;
 import org.springblade.evisa.vo.EVisaMakeSealVO;
 import org.springblade.evisa.vo.EVisaTaskApprovalVO;
-import org.springblade.evisa.vo.SealPdfVO;
-import org.springblade.evisa.vo.SealStrategyVO;
 import org.springframework.web.bind.annotation.RestController;
-
-import java.util.ArrayList;
 import java.util.List;
 
 @RestController
@@ -19,6 +14,13 @@ public class EVisaClientImpl implements EVisaClient {
 
     private final EVisaService eVisaService;
 
+    @Override
+    public String checkSeal(String pdfUrl) {
+        List<CertBean> beans = this.eVisaService.checkSeal(pdfUrl);
+
+        return null;
+    }
+
     @Override
     public String certification(String pdfUrl, String fileName, String contractId) {
         return this.eVisaService.certification(pdfUrl, fileName, contractId);

+ 1 - 3
blade-service/blade-e-visa/src/main/java/org/springblade/evisa/redissionUtil/DistributedRedisLock.java

@@ -32,9 +32,7 @@ public class DistributedRedisLock {
         if(time == null || time == 0){
             time = 180;
         }
-        _log.info("======lock==="+lockName+"===" + time + "=="+new Date() +"=="+Thread.currentThread().getName());
         myLock.lock(time, TimeUnit.SECONDS);
-        _log.info("======lock==="+lockName+"===" + time + "=="+new Date() +"=="+Thread.currentThread().getName());
         //加锁成功
         return true;
     }
@@ -106,7 +104,7 @@ public class DistributedRedisLock {
 
     private static Redisson getRedisson(){
         config.useSingleServer()
-                .setAddress("" + RedissonManager.SPRING_REDIS_HOST + ":" + RedissonManager.SPRING_REDIS_PORT)
+                .setAddress("redis://" + RedissonManager.SPRING_REDIS_HOST + ":" + RedissonManager.SPRING_REDIS_PORT)
                 .setConnectionPoolSize(500);
         if (StringUtil.isNotEmpty(RedissonManager.SPRING_REDIS_PASSWORD)) {
             config.useSingleServer().setPassword(RedissonManager.SPRING_REDIS_PASSWORD);

+ 8 - 0
blade-service/blade-e-visa/src/main/java/org/springblade/evisa/service/EVisaService.java

@@ -1,8 +1,11 @@
 package org.springblade.evisa.service;
 
+import cfca.paperless.dto.bean.CertBean;
 import org.springblade.evisa.vo.EVisaMakeSealVO;
 import org.springblade.evisa.vo.EVisaTaskApprovalVO;
 
+import java.util.List;
+
 public interface EVisaService {
 
     /**
@@ -20,4 +23,9 @@ public interface EVisaService {
      */
     String createSeal(EVisaMakeSealVO makeSealDto);
 
+    /**
+     * 验签
+     */
+    List<CertBean> checkSeal(String pdfUrl);
+
 }

+ 170 - 64
blade-service/blade-e-visa/src/main/java/org/springblade/evisa/service/impl/EVisaServiceImpl.java

@@ -13,21 +13,28 @@ import cfca.paperless.dto.ResponseHead;
 import cfca.paperless.dto.bean.*;
 import cfca.paperless.dto.request.requestbody.tx20.MakeSealRequestBody;
 import cfca.paperless.dto.request.requestbody.tx40.CompoundSealPdfListRequestBody;
+import cfca.paperless.dto.request.requestbody.tx40.VerifyPdfSealRequestBody;
 import cfca.paperless.dto.request.tx20.MakeSealRequest;
 import cfca.paperless.dto.request.tx40.CompoundSealPdfListDetachedRequest;
+import cfca.paperless.dto.request.tx40.VerifyPdfSealRequest;
 import cfca.paperless.dto.response.responsebody.tx20.MakeSealResponseBody;
 import cfca.paperless.dto.response.responsebody.tx40.CompoundSealPdfListDetachedResponseBody;
+import cfca.paperless.dto.response.responsebody.tx40.VerifyPdfSealResponseBody;
 import cfca.paperless.dto.response.tx20.MakeSealResponse;
 import cfca.paperless.dto.response.tx40.CompoundSealPdfListDetachedResponse;
+import cfca.paperless.dto.response.tx40.VerifyPdfSealResponse;
 import com.alibaba.fastjson.JSONObject;
 import lombok.AllArgsConstructor;
+import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringUtils;
+import org.apache.pdfbox.pdmodel.PDDocument;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springblade.business.feign.TaskClient;
 import org.springblade.business.vo.TaskApprovalVO;
 import org.springblade.common.constant.EVisaConstant;
 import org.springblade.common.utils.CommonUtil;
+import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.core.oss.model.BladeFile;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.evisa.redissionUtil.DistributedRedisLock;
@@ -39,7 +46,9 @@ import org.springblade.evisa.vo.SealStrategyVO;
 import org.springblade.manager.entity.SignPfxFile;
 import org.springblade.manager.feign.SignPfxClient;
 import org.springblade.resource.feign.NewIOSSClient;
+import org.springframework.mock.web.MockMultipartFile;
 import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.imageio.*;
 import javax.imageio.metadata.IIOInvalidTreeException;
@@ -50,6 +59,7 @@ import java.awt.image.BufferedImage;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -65,6 +75,12 @@ public class EVisaServiceImpl implements EVisaService {
 
     private static final double INCH_2_CM = 2.54d;
 
+    private static final String ERROR = "error";
+
+    private static final String NOT_PFX_OR_FILE = "notPfxOrFile";
+
+    private static final String SUCCESS = "success";
+
     private static final Logger logger = LoggerFactory.getLogger(EVisaServiceImpl.class);
 
     private final SignPfxClient signPfxClient;
@@ -76,37 +92,58 @@ public class EVisaServiceImpl implements EVisaService {
     @Override
     public String certification(String pdfUrl, String fileName, String contractId) {
         try{
-            //准备签章策略
-            List<SealStrategyVO> sealStrategyVOS = new ArrayList<>();
             //根据当前合同段获取相关的证书
             List<SignPfxFile> pfxFiles = this.signPfxClient.querySignPfxByUserIdOrContractId("", contractId);
             if(pfxFiles == null || pfxFiles.size() <= 0){
-                return "error";
+                return NOT_PFX_OR_FILE;
             }
-            SealStrategyVO vo = new SealStrategyVO();
-            vo.setSealCode(EVisaConstant.SIGN_SEAL_CODE + AuthUtil.getUserId().toString().substring(0, EVisaConstant.USER_ID_SUB));
-            vo.setSealPassword(AuthUtil.getUserId().toString().substring(0, EVisaConstant.USER_ID_SUB));
-            vo.setSealPerson(AuthUtil.getUserAccount());
-            //使用默认写死的透明图片
-            vo.setImageUrl("authentication");
-            //使用坐标定位 ,坐标固定
-            vo.setSealType("2");
-            vo.setLx("100");
-            vo.setLy("100");
-            vo.setPage("1");
-            sealStrategyVOS.add(vo);
+            //找到合同章
+            SignPfxFile contractPfx = null;
+            for(SignPfxFile pfxFile : pfxFiles){
+                if("2".equals(pfxFile.getPfxType())){
+                    //找到当前合同段的合同章类型
+                    contractPfx = pfxFile;
+                    break;
+                }
+            }
+            //没有找到合同章,直接返回
+            if(contractPfx == null){
+                return NOT_PFX_OR_FILE;
+            }
+
+            //准备签章策略
+            List<SealStrategyVO> sealStrategyVOS = new ArrayList<>();
 
+            //获取需要认证的文件
+            InputStream pdfInputStream = CommonUtil.getOSSInputStream(pdfUrl);
+            //获取这份文件的页数并设置签章策略
+            //获取PDF文件
+            PDDocument document = PDDocument.load(pdfInputStream);
+            int page = document.getPages().getCount();
+            for(int i = 0; i < page; i ++){
+                SealStrategyVO vo = new SealStrategyVO();
+                vo.setSealCode(EVisaConstant.SIGN_SEAL_CODE + contractPfx.getCertificatePassword());
+                vo.setSealPassword(contractPfx.getCertificatePassword());
+                vo.setSealPerson(contractPfx.getCertificateUserName());
+                //使用默认写死的透明图片
+                vo.setImageUrl("authentication");
+                //使用坐标定位 ,坐标固定
+                vo.setSealType("2");
+                vo.setLx("100");
+                vo.setLy("100");
+                vo.setPage(( i + 1) + "");
+                sealStrategyVOS.add(vo);
+            }
             SealPdfVO pdfVO = new SealPdfVO();
             pdfVO.setStrategyVoList(sealStrategyVOS);
 
-            //获取认证文件
+            //获取字节
             byte[] fileByte = CommonUtil.InputStreamToBytes(CommonUtil.getOSSInputStream(pdfUrl));
             //兼容大文件签章
             Object[] result;
             //大于50M的单个文件采用大文件签章处理
             if(fileByte.length > 52428800){
                 result = null;
-
             } else {
                 //普通文件签章
                 result = this.signPdf(pdfVO, fileByte);
@@ -114,12 +151,13 @@ public class EVisaServiceImpl implements EVisaService {
             if(result != null){
                 if(result[0] != null){
                     byte[] newPdfData = (byte[])result[0];
-                    //重新上传覆盖
-                    BladeFile bladeFile = this.newIOSSClient.updateFile(newPdfData, pdfUrl.substring(pdfUrl.lastIndexOf("/") + 1, pdfUrl.lastIndexOf(".")));
+                    MultipartFile files = new MockMultipartFile("file", SnowFlakeUtil.getId() + ".pdf", "text/plain", IOUtils.toByteArray(new ByteArrayInputStream(newPdfData)));
+                    //重新上传
+                    BladeFile bladeFile = this.newIOSSClient.uploadFileByInputStream(files);
                     if(bladeFile != null){
-                        return "success" + "@@@@" + bladeFile.getLink();
+                        return SUCCESS + "@@@@" + bladeFile.getLink();
                     } else {
-                        return "error";
+                        return ERROR;
                     }
                 } else {
                     String s = result[1].toString();
@@ -137,10 +175,11 @@ public class EVisaServiceImpl implements EVisaService {
         return null;
     }
 
-
-
     @Override
     public String eVisa(EVisaTaskApprovalVO task) {
+        if(true){
+            return SUCCESS;
+        }
         //todo 这里应当是配置限制参数,初版暂时写死
         int batch = 20;
 
@@ -148,26 +187,67 @@ public class EVisaServiceImpl implements EVisaService {
         List<SignPfxFile> userPfxList = this.signPfxClient.querySignPfxByUserIdOrContractId(AuthUtil.getUserId().toString(), "");
         if(userPfxList == null || userPfxList.size() <= 0){
             //没有签章,不执行电签
-            return "error";
+            return NOT_PFX_OR_FILE;
         }
 
         //根据任务类型获取对应的文件信息
         TaskApprovalVO taskFile = this.taskClient.queryBusinessData(JSONObject.parseObject(JSONObject.toJSONString(task), TaskApprovalVO.class));
         if(taskFile == null || taskFile.getApprovalFileList().size() <= 0){
             //没有找到业务文件,取消签章
-            return "error";
+            return NOT_PFX_OR_FILE;
         }
 
         //上锁
         if(DistributedRedisLock.acquire(AuthUtil.getUserId().toString(), batch)){
+            try{
+                //获取需要签章的数据
+                List<TaskApprovalVO.ApprovalFile> files = taskFile.getApprovalFileList();
+                for(TaskApprovalVO.ApprovalFile file : files){
+                    //获取PDF文件
+                    PDDocument document = PDDocument.load(CommonUtil.getOSSInputStream(file.getFileUrl()));
+                    int page = document.getPages().getCount();
+
+                    //准备签章策略
+                    List<SealStrategyVO> sealStrategyVOS = new ArrayList<>();
+                    for(int i = 0; i <page; i ++){
+                        //设置签章策略
+                        SealStrategyVO vo = new SealStrategyVO();
+                        vo.setSealCode(EVisaConstant.SIGN_SEAL_CODE + AuthUtil.getUserId());
+                        vo.setSealPassword(AuthUtil.getUserId().toString().substring(0, EVisaConstant.USER_ID_SUB));
+                        vo.setSealPerson(AuthUtil.getNickName());
+                        //设置签字文件
+                        vo.setImageUrl(userPfxList.get(0).getCertificateFileUrl());
+                        vo.setSealType("3");
+
+                        //todo ====================== 暂时缺少关键信息 =====================
+                        //todo ====================== 暂时缺少关键信息 =====================
+
+                        //设置页
+                        vo.setPage(( i + 1) + "");
+                        sealStrategyVOS.add(vo);
+                    }
+                    SealPdfVO pdfVO = new SealPdfVO();
+                    pdfVO.setStrategyVoList(sealStrategyVOS);
 
+                    //获取字节
+                    byte[] fileByte = CommonUtil.InputStreamToBytes(CommonUtil.getOSSInputStream(file.getFileUrl()));
+                    //执行电签
+                    Object[] result = this.signPdf(pdfVO, fileByte);
+                    if(result == null){
+                        return ERROR;
+                    }
+                }
+            }catch (Exception e){
+                e.printStackTrace();
+                return ERROR;
+            }
         }
 
-        return "success";
+        return SUCCESS;
     }
 
     /**
-     * 签章(坐标方式)
+     * 签章
      */
     private Object[] signPdf(SealPdfVO pdfVO, byte[] fileByte){
         Object[] result = new Object[2];
@@ -182,11 +262,11 @@ public class EVisaServiceImpl implements EVisaService {
             String transactionNo = GUIDUtil.generateId();
             //机构编码非空
             String organizationCode = EVisaConstant.organizationCode;
-
             //操作员编码 可为空(企业类型不能为空)
             String operatorCode = EVisaConstant.operationCode;
             //渠道编码 可为空
             String channelCode = "";
+
             //设置属性
             requestHead.setBasicInfo(transactionNo, organizationCode,operatorCode,channelCode);
 
@@ -231,7 +311,7 @@ public class EVisaServiceImpl implements EVisaService {
             if(ClientConstants.CODE_SUCCESS.equals(responseHead.getCode())){
                 List<PdfBean4Response> pdfBeanList = responseBody.getPdfBeans();
                 if(pdfBeanList!=null && pdfBeanList.size()>0){
-                    PdfBean4Response pdfBean4Response =pdfBeanList.get(0);
+                    PdfBean4Response pdfBean4Response = pdfBeanList.get(0);
                     result[0] = pdfBean4Response.getPdf();
                 }
             }else{
@@ -394,41 +474,6 @@ public class EVisaServiceImpl implements EVisaService {
         metadata.mergeTree("javax_imageio_1.0", root);
     }
 
-    /**
-     * 签章(线程方式)
-     */
-    private boolean signPdf(){
-        StringBuffer stringbuffer = new StringBuffer();
-        try{
-            PaperlessClient paperlessClient = new PaperlessClient(SIGN_HOST, SIGN_PORT, 3000, 20000);
-
-            paperlessClient.setSSL(false);
-            //*****************************************************************************
-            CompoundSealPdfListDetachedRequest compoundSealPdfListDetachedRequest = new  CompoundSealPdfListDetachedRequest();
-
-            RequestHead requestHead = new RequestHead();
-            //业务流水号 非空
-            String transactionNo = GUIDUtil.generateId();
-            //机构编码非空
-            String organizationCode = EVisaConstant.organizationCode;
-            //操作员编码 可为空(企业类型不能为空)
-            String operatorCode = EVisaConstant.operationCode;
-            //渠道编码 可为空
-            String channelCode = "";
-
-            //设置属性
-            requestHead.setBasicInfo(transactionNo, organizationCode,operatorCode,channelCode);
-
-            compoundSealPdfListDetachedRequest.setHead(requestHead);
-            //*****************************************************************************
-
-        }catch (Exception e){
-            e.printStackTrace();
-        }
-
-        return false;
-    }
-
     /**
      * 创建印模
      */
@@ -501,4 +546,65 @@ public class EVisaServiceImpl implements EVisaService {
 
         return null;
     }
+
+    @Override
+    public List<CertBean> checkSeal(String pdfUrl) {
+        try{
+            PaperlessClient paperlessClient = new PaperlessClient(SIGN_HOST, SIGN_PORT, 300000, 1800000);
+            paperlessClient.setSSL(false);
+
+            /*==================================================================================*/
+            //构造请求对象
+            VerifyPdfSealRequest verifyPdfSealRequest = new VerifyPdfSealRequest();
+            RequestHead requestHead = new RequestHead();
+            //业务流水号 非空
+            String transactionNo = GUIDUtil.generateId();
+            //机构编码非空
+            String organizationCode = EVisaConstant.organizationCode;
+            //操作员编码 可为空
+            String operatorCode = EVisaConstant.operationCode;
+            //渠道编码 可为空
+            String channelCode = EVisaConstant.channelCode;
+            //设置属性
+            requestHead.setBasicInfo(transactionNo, organizationCode,operatorCode,channelCode);
+
+            verifyPdfSealRequest.setHead(requestHead);
+            /*==================================================================================*/
+            VerifyPdfSealRequestBody requestBody = new VerifyPdfSealRequestBody();
+
+            byte[] pdfData = CommonUtil.InputStreamToBytes(CommonUtil.getOSSInputStream(pdfUrl));
+            // 数据源类型 1 pdf文件路径 2 pdf文件字节流
+            requestBody.setInputType(BaseConstants.INPUT_TYPE_FILEDATA);
+            requestBody.setPdfData(pdfData);
+
+            /*验证类型
+             * 验证项包括以下4项:①验证印章的签名②验证签章时间点证书是否有效③验证书链④验CRL
+             sealVerifyType=1时,验证前3项
+             sealVerifyType=2时,验证全部4项
+             */
+            String sealVerifyType = BaseConstants.SEAL_VERIFY_TYPE_1;
+            requestBody.setSealVerifyType(sealVerifyType);
+
+            verifyPdfSealRequest.setBody(requestBody);
+
+            /*==================================================================================*/
+            ResponseDto responseDto = paperlessClient.execute(verifyPdfSealRequest);
+            /*==================================================================================*/
+
+            VerifyPdfSealResponse verifyPdfSealResponse = (VerifyPdfSealResponse)responseDto;
+
+            ResponseHead  responseHead = verifyPdfSealResponse.getHead();
+            VerifyPdfSealResponseBody responseBody = verifyPdfSealResponse.getBody();
+
+            if(ClientConstants.CODE_SUCCESS.equals(responseHead.getCode())){
+                return responseBody.getCertBeans();
+            } else {
+                logger.info("【电签模块】{}","验签接口响应code:" + responseHead.getCode());
+                return null;
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            return null;
+        }
+    }
 }

+ 18 - 4
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ExcelTabController.java

@@ -33,6 +33,7 @@ import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
 import org.jsoup.select.Elements;
+import org.springblade.business.feign.InformationQueryClient;
 import org.springblade.common.utils.MathUtil;
 import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.core.log.exception.ServiceException;
@@ -100,6 +101,9 @@ public class ExcelTabController extends BladeController {
 
 	private final JdbcTemplate jdbcTemplate;
 
+	//客户端资料查询接口
+	private final InformationQueryClient informationQueryClient;
+
 	/**
 	 * 详情
 	 */
@@ -497,8 +501,9 @@ public class ExcelTabController extends BladeController {
 		if(wbsTreeContract.getHtmlUrl()==null){
 			return R.fail("请上传清表!");
 		}
-		File file1 = ResourceUtil.getFile(wbsTreeContract.getHtmlUrl());
-		FileInputStream fileInputStream = new FileInputStream(file1);
+//		File file1 = ResourceUtil.getFile(wbsTreeContract.getHtmlUrl());
+//		FileInputStream fileInputStream = new FileInputStream(file1);
+		FileInputStream fileInputStream = new FileInputStream(new File("D:\\project" + wbsTreeContract.getHtmlUrl()));
 		String htmlString =  IoUtil.readToString(fileInputStream);
 		htmlString = htmlString.replaceAll("placeholder","placeholderxx");
 		// 解析 style
@@ -557,9 +562,15 @@ public class ExcelTabController extends BladeController {
 		String contractId = dataInfo.getString("contractId");
 		String pkeyId = dataInfo.getString("pkeyId");
 		String projectId = dataInfo.getString("projectId");
+
+		//huangjn 填报的类型,施工或监理
+		String classify = dataInfo.getString("classify");
+		//huangjn 填报的类型,施工或监理
+
 		dataInfo.remove("contractId");
 		dataInfo.remove("pkeyId");
 		dataInfo.remove("projectId");
+		dataInfo.remove("classify");
 
 		// 去掉
 		Map<String,String> dataMap = new HashMap<>();
@@ -610,8 +621,8 @@ public class ExcelTabController extends BladeController {
 		String tabName = wbsTreeContract.getInitTableName();
 
 		String sqlInfo = "INSERT INTO "+tabName+" ( ";
-		String keyStr = "";
-		String valStr = "";
+		String keyStr = "id,";
+		String valStr = SnowFlakeUtil.getId() + ",";
 		for (String keys : dataMap2.keySet()){
 			keyStr += keys+",";
 			valStr += "'"+dataMap2.get(keys)+"',";
@@ -625,6 +636,9 @@ public class ExcelTabController extends BladeController {
 		System.out.println(sqlInfo);
 		jdbcTemplate.execute(sqlInfo);
 
+		//huangjn 保存成功后调用生成资料查询列表数据
+		this.informationQueryClient.saveOrUpdateInformationQueryData(pkeyId, "文件名称", Integer.parseInt(classify), 2);
+		//huangjn 保存成功后调用生成资料查询列表数据
 
 		return  R.success("1");
 	}