|
@@ -198,6 +198,83 @@ public class EVisaServiceImpl implements EVisaService {
|
|
|
|
|
|
@Override
|
|
|
public String eVisaContractSeal(EVisaTaskApprovalVO task, String finalPdfUrl) {
|
|
|
+ //获取任务对应表格的电签配置
|
|
|
+ List<JSONObject> eVisaConfigList = this.taskClient.queryBusinessTableEVisaConfig(task.getParallelProcessInstanceId(), "true");
|
|
|
+ if(eVisaConfigList == null || eVisaConfigList.size() == 0){
|
|
|
+ //没有电签配置,默认当前任务为不签字审批,返回成功
|
|
|
+ return finalPdfUrl;
|
|
|
+ }
|
|
|
+
|
|
|
+ String sysBatch = ParamCache.getValue(CommonConstant.SYS_USER_TASK_BATCH);
|
|
|
+ int batch = 2;
|
|
|
+ if(CommonUtil.checkIsBigDecimal(sysBatch)){
|
|
|
+ batch = new Integer(sysBatch);
|
|
|
+ }
|
|
|
+
|
|
|
+ //确定合同段并获取合同章
|
|
|
+ List<SignPfxFile> userPfxList = this.signPfxClient.querySignPfxByUserIdOrContractId("", this.taskClient.queryTaskContractId(task.getParallelProcessInstanceId()));
|
|
|
+ if(userPfxList == null || userPfxList.size() <= 0){
|
|
|
+ //没有签章,不执行电签
|
|
|
+ return finalPdfUrl;
|
|
|
+ }
|
|
|
+
|
|
|
+ //上锁
|
|
|
+ if(DistributedRedisLock.acquire(AuthUtil.getUserId().toString(), batch)){
|
|
|
+ try{
|
|
|
+ //准备签章策略
|
|
|
+ List<SealStrategyVO> sealStrategyVOS = new ArrayList<>();
|
|
|
+ for(JSONObject eVisaConfig : eVisaConfigList){
|
|
|
+ //找到类型与之对应的合同章
|
|
|
+ Iterator<SignPfxFile> iterator = userPfxList.iterator();
|
|
|
+ while (iterator.hasNext()){
|
|
|
+ SignPfxFile next = iterator.next();
|
|
|
+ if(eVisaConfig.getString("type").equals(next.getPfxType())){
|
|
|
+ //设置签章策略
|
|
|
+ SealStrategyVO vo = new SealStrategyVO();
|
|
|
+ vo.setSealCode(EVisaConstant.SIGN_SEAL_CODE + next.getCertificatePassword());
|
|
|
+ vo.setSealPassword(next.getCertificatePassword());
|
|
|
+ vo.setSealPerson(next.getCertificateUserName() + System.currentTimeMillis());
|
|
|
+ //设置签字文件
|
|
|
+ vo.setImageUrl(next.getSignatureFileUrl());
|
|
|
+ vo.setSealType("3");
|
|
|
+
|
|
|
+ vo.setCompanySeal(true);
|
|
|
+
|
|
|
+ vo.setKeyword(eVisaConfig.getString("KEY"));
|
|
|
+ vo.setOffSetX(eVisaConfig.getString("X"));
|
|
|
+ vo.setOffSetY(eVisaConfig.getString("Y"));
|
|
|
+
|
|
|
+ sealStrategyVOS.add(vo);
|
|
|
+ iterator.remove();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ SealPdfVO pdfVO = new SealPdfVO();
|
|
|
+ pdfVO.setStrategyVoList(sealStrategyVOS);
|
|
|
+
|
|
|
+ //获取字节
|
|
|
+ byte[] fileByte = CommonUtil.InputStreamToBytes(CommonUtil.getOSSInputStream(finalPdfUrl));
|
|
|
+ //执行电签
|
|
|
+ Object[] result = this.signPdf(pdfVO, fileByte);
|
|
|
+ if(result != null){
|
|
|
+ if(result[0] != null){
|
|
|
+ MultipartFile newFiles = new MockMultipartFile("file", SnowFlakeUtil.getId() + ".pdf", "text/plain", IOUtils.toByteArray(new ByteArrayInputStream((byte[])result[0])));
|
|
|
+ //重新上传
|
|
|
+ BladeFile bladeFile = this.newIOSSClient.uploadFileByInputStream(newFiles);
|
|
|
+ if(bladeFile != null){
|
|
|
+ finalPdfUrl = bladeFile.getLink();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //释放锁
|
|
|
+ DistributedRedisLock.release(AuthUtil.getUserId().toString());
|
|
|
+
|
|
|
return finalPdfUrl;
|
|
|
}
|
|
|
|
|
@@ -226,7 +303,7 @@ public class EVisaServiceImpl implements EVisaService {
|
|
|
return SUCCESS + "@@@@" + taskFile.getApprovalFileList().get(0).getFileUrl();
|
|
|
}
|
|
|
|
|
|
- //首先获取当前用户的证书信息
|
|
|
+ //获取当前用户的证书信息
|
|
|
List<SignPfxFile> userPfxList = this.signPfxClient.querySignPfxByUserIdOrContractId(AuthUtil.getUserId().toString(), "");
|
|
|
if(userPfxList == null || userPfxList.size() <= 0){
|
|
|
//没有签章,不执行电签
|
|
@@ -241,32 +318,23 @@ public class EVisaServiceImpl implements EVisaService {
|
|
|
List<TaskApprovalVO.ApprovalFile> files = taskFile.getApprovalFileList();
|
|
|
//这里的文件只会是一张拼接好的PDF
|
|
|
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 ++){
|
|
|
- for(JSONObject eVisaConfig : eVisaConfigList){
|
|
|
- //设置签章策略
|
|
|
- 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).getSignatureFileUrl());
|
|
|
- vo.setSealType("3");
|
|
|
-
|
|
|
- vo.setKeyword(eVisaConfig.getString("KEY"));
|
|
|
- vo.setLx(eVisaConfig.getString("X"));
|
|
|
- vo.setLy(eVisaConfig.getString("Y"));
|
|
|
-
|
|
|
- //设置页
|
|
|
-// vo.setPage(( i + 1) + "");
|
|
|
- sealStrategyVOS.add(vo);
|
|
|
- }
|
|
|
-// }
|
|
|
+ for (JSONObject eVisaConfig : eVisaConfigList) {
|
|
|
+ //设置签章策略
|
|
|
+ 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).getSignatureFileUrl());
|
|
|
+ vo.setSealType("3");
|
|
|
+
|
|
|
+ vo.setKeyword(eVisaConfig.getString("KEY"));
|
|
|
+ vo.setOffSetX(eVisaConfig.getString("X"));
|
|
|
+ vo.setOffSetY(eVisaConfig.getString("Y"));
|
|
|
+ sealStrategyVOS.add(vo);
|
|
|
+ }
|
|
|
SealPdfVO pdfVO = new SealPdfVO();
|
|
|
pdfVO.setStrategyVoList(sealStrategyVOS);
|
|
|
|
|
@@ -426,7 +494,6 @@ public class EVisaServiceImpl implements EVisaService {
|
|
|
String visible = "1";
|
|
|
sealStrategy.setVisible(visible);
|
|
|
|
|
|
- byte[] imageData = null;
|
|
|
if(!"authentication".equals(vo.getImageUrl())){
|
|
|
String imageUrl = vo.getImageUrl();
|
|
|
if(StringUtils.isEmpty(imageUrl)){
|
|
@@ -434,7 +501,7 @@ public class EVisaServiceImpl implements EVisaService {
|
|
|
return null;
|
|
|
}
|
|
|
//获取字节
|
|
|
- imageData = CommonUtil.InputStreamToBytes(CommonUtil.getOSSInputStream(imageUrl));
|
|
|
+ byte[] imageData = CommonUtil.InputStreamToBytes(CommonUtil.getOSSInputStream(imageUrl));
|
|
|
//对图片进行扣白底
|
|
|
imageData = ImageUtil.transferAlpha(imageData);
|
|
|
|
|
@@ -443,21 +510,22 @@ public class EVisaServiceImpl implements EVisaService {
|
|
|
imageData = ImageUtil.resizeImage(imageData,540,540);
|
|
|
}else {
|
|
|
imageData = ImageUtil.resizeImage(imageData,480,132);
|
|
|
+// imageData = ImageUtil.resizeImage(imageData,540,540);
|
|
|
}
|
|
|
|
|
|
//图片dpi设置
|
|
|
imageData = this.handleDpi(imageData);
|
|
|
- }
|
|
|
- if (imageData != null) {
|
|
|
- //图片进行Base64编码/
|
|
|
- String imageDataString = new String(Base64.encode(imageData), StandardCharsets.UTF_8);
|
|
|
- sealStrategy.setSealImage(imageDataString);
|
|
|
- }
|
|
|
|
|
|
- if("authentication".equals(vo.getImageUrl())){
|
|
|
+ if (imageData != null) {
|
|
|
+ //图片进行Base64编码/
|
|
|
+ String imageDataString = new String(Base64.encode(imageData), StandardCharsets.UTF_8);
|
|
|
+ sealStrategy.setSealImage(imageDataString);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
//工程文件认证的 是要用透明图片
|
|
|
sealStrategy.setSealImage(EVisaConstant.base64String);
|
|
|
}
|
|
|
+
|
|
|
sealStrategy.setSealMiscInfo(vo.getSealPerson(), vo.getSealLocation(), vo.getSealReason());
|
|
|
|
|
|
//关键字签章
|