|  | @@ -1263,94 +1263,87 @@ public class ContractServiceImpl implements ContractService, InitializingBean {
 | 
	
		
			
				|  |  |  		return BaseController.succeed();
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@Override
 | 
	
		
			
				|  |  | -	public String transferOaFinancial(OAFinancialDto financialDto) {
 | 
	
		
			
				|  |  | -		List<Integer> circulationUserIds = financialDto.getCirculationUsers().stream().map(CirculationUser::getUserId).collect(Collectors.toList());
 | 
	
		
			
				|  |  | -		List<Integer> executorIds = financialDto.getExecutors().stream().map(CirculationUser::getUserId).collect(Collectors.toList());
 | 
	
		
			
				|  |  | -		circulationUserIds.addAll(executorIds);
 | 
	
		
			
				|  |  | -		List<SysUser> users = employeeDao.getUsers(circulationUserIds);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -		Integer workOrderId = null;
 | 
	
		
			
				|  |  | -		for (SysUser user : users) {
 | 
	
		
			
				|  |  | -			SysUserTsign sysUserTsign = sysUserTsignService.get(user.getId());
 | 
	
		
			
				|  |  | -			if (sysUserTsign == null) {
 | 
	
		
			
				|  |  | -				try {
 | 
	
		
			
				|  |  | -					sysUserTsign = register(user.getId(), user.getRealName(), user.getIdCardNo(), user.getPhone());
 | 
	
		
			
				|  |  | -				} catch (Exception e) {
 | 
	
		
			
				|  |  | -					logger.error("用户电子签章注册失败", e);
 | 
	
		
			
				|  |  | -					throw new BizException(user.getRealName() + "电子签章注册失败");
 | 
	
		
			
				|  |  | -				}
 | 
	
		
			
				|  |  | -			}
 | 
	
		
			
				|  |  | -			for (CirculationUser circulationUser : financialDto.getCirculationUsers()) {
 | 
	
		
			
				|  |  | -				if (workOrderId == null) {
 | 
	
		
			
				|  |  | -					workOrderId = circulationUser.getWorkOrder();
 | 
	
		
			
				|  |  | -				}
 | 
	
		
			
				|  |  | -				if (!circulationUser.getUserId().equals(user.getId())) continue;
 | 
	
		
			
				|  |  | -				circulationUser.setRealName(user.getRealName());
 | 
	
		
			
				|  |  | -				circulationUser.setIdCard(user.getIdCardNo());
 | 
	
		
			
				|  |  | -				circulationUser.setPhone(user.getPhone());
 | 
	
		
			
				|  |  | -				circulationUser.setSysUserTsign(sysUserTsign);
 | 
	
		
			
				|  |  | -			}
 | 
	
		
			
				|  |  | -			for (CirculationUser executor : financialDto.getExecutors()) {
 | 
	
		
			
				|  |  | -				if (!executor.getUserId().equals(user.getId())) continue;
 | 
	
		
			
				|  |  | -				executor.setRealName(user.getRealName());
 | 
	
		
			
				|  |  | -				executor.setIdCard(user.getIdCardNo());
 | 
	
		
			
				|  |  | -				executor.setPhone(user.getPhone());
 | 
	
		
			
				|  |  | -				executor.setSysUserTsign(sysUserTsign);
 | 
	
		
			
				|  |  | -			}
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -		Date date = new Date();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -		// 合成freemarker
 | 
	
		
			
				|  |  | -		String srcPdfPath = contractBaseDir + "/oa/" + dateFormat1.format(date) + "/" + workOrderId + "_" + LocalDateTime.now().getSecond() + ".pdf";
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -		File srcFile = new File(srcPdfPath);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -		File debtFile = new File(srcFile.getParent());
 | 
	
		
			
				|  |  | -		if (!debtFile.exists()) {
 | 
	
		
			
				|  |  | -			debtFile.mkdirs();
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -		FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
 | 
	
		
			
				|  |  | -		templateEngine.setClassForTemplateLoading(ContractServiceImpl.class, "/config/contracts/");
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -		Map<String, Object> params = new HashMap<String, Object>();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -		// 查询参数信息
 | 
	
		
			
				|  |  | -		params.put("organName", financialDto.getOrganName());
 | 
	
		
			
				|  |  | -		params.put("realName", financialDto.getRealName());
 | 
	
		
			
				|  |  | -		params.put("feeType", financialDto.getFeeType());
 | 
	
		
			
				|  |  | -		params.put("totalMoney", financialDto.getTotalMoney().setScale(2, RoundingMode.HALF_UP));
 | 
	
		
			
				|  |  | -		params.put("hasLoan", financialDto.getHasLoan());
 | 
	
		
			
				|  |  | -		params.put("memo", financialDto.getMemo());
 | 
	
		
			
				|  |  | -		params.put("circulationUsers", financialDto.getCirculationUsers());
 | 
	
		
			
				|  |  | -		params.put("executors", financialDto.getExecutors());
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -		templateEngine.render(params, "financial.ftl", srcFile);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -		// 生成借款协议PDF
 | 
	
		
			
				|  |  | -		try {
 | 
	
		
			
				|  |  | -			PDFUtil.renderToPDFByData(ContractServiceImpl.class.getResource("/").getFile(), FileUtils.readFileToString(srcFile), srcPdfPath, "simsun.ttc");
 | 
	
		
			
				|  |  | -		} catch (IOException e) {
 | 
	
		
			
				|  |  | -			logger.error("生成签章协议失败", e);
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -		for (CirculationUser circulationUser : financialDto.getCirculationUsers()) {
 | 
	
		
			
				|  |  | -			eSealPlugin.userSign(circulationUser.getSysUserTsign().getAccountId(), circulationUser.getSysUserTsign().getSealData(),circulationUser.getRealName(), srcPdfPath, srcPdfPath);
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -		for (CirculationUser executor : financialDto.getExecutors()) {
 | 
	
		
			
				|  |  | -			eSealPlugin.userSign(executor.getSysUserTsign().getAccountId(), executor.getSysUserTsign().getSealData(),executor.getRealName(), srcPdfPath, srcPdfPath);
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -		//上传到oss
 | 
	
		
			
				|  |  | -		String dateStrOss = dateFormatOss.format(date);
 | 
	
		
			
				|  |  | -		dateStrOss = "oa/" + dateStrOss + "/" + DateUtil.getHour(date);
 | 
	
		
			
				|  |  | -		String pdfFilePath = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME, dateStrOss, srcFile);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -		FileUtils.deleteQuietly(srcFile);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -		return pdfFilePath;
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public String transferOaFinancial(OAFinancialDto financialDto) {
 | 
	
		
			
				|  |  | +        List<Integer> circulationUserIds = financialDto.getCirculationUsers().stream().map(CirculationUser::getUserId).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +        List<Integer> executorIds = financialDto.getExecutors().stream().map(CirculationUser::getUserId).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +        circulationUserIds.addAll(executorIds);
 | 
	
		
			
				|  |  | +        List<SysUser> users = employeeDao.getUsers(circulationUserIds);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        Integer workOrderId = null;
 | 
	
		
			
				|  |  | +        List<SysUserTsign> sysUserTsigns = new ArrayList<>();
 | 
	
		
			
				|  |  | +        for (SysUser user : users) {
 | 
	
		
			
				|  |  | +            SysUserTsign sysUserTsign = sysUserTsignService.get(user.getId());
 | 
	
		
			
				|  |  | +            if (sysUserTsign == null) {
 | 
	
		
			
				|  |  | +                try {
 | 
	
		
			
				|  |  | +                    sysUserTsign = register(user.getId(), user.getRealName(), user.getIdCardNo(), user.getPhone());
 | 
	
		
			
				|  |  | +                } catch (Exception e) {
 | 
	
		
			
				|  |  | +                    logger.error("用户电子签章注册失败", e);
 | 
	
		
			
				|  |  | +                    throw new BizException(user.getRealName() + "电子签章注册失败");
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            for (CirculationUser circulationUser : financialDto.getCirculationUsers()) {
 | 
	
		
			
				|  |  | +                if (workOrderId == null) {
 | 
	
		
			
				|  |  | +                    workOrderId = circulationUser.getWorkOrder();
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if (!circulationUser.getUserId().equals(user.getId())) continue;
 | 
	
		
			
				|  |  | +                circulationUser.setRealName(user.getRealName());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            for (CirculationUser executor : financialDto.getExecutors()) {
 | 
	
		
			
				|  |  | +                if (!executor.getUserId().equals(user.getId())) continue;
 | 
	
		
			
				|  |  | +                executor.setRealName(user.getRealName());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            sysUserTsigns.add(sysUserTsign);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        financialDto.setSysUserTsigns(sysUserTsigns);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        Date date = new Date();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 合成freemarker
 | 
	
		
			
				|  |  | +        String srcPdfPath = contractBaseDir + "/oa/" + dateFormat1.format(date) + "/" + workOrderId + "_" + LocalDateTime.now().getSecond() + ".pdf";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        File srcFile = new File(srcPdfPath);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        File debtFile = new File(srcFile.getParent());
 | 
	
		
			
				|  |  | +        if (!debtFile.exists()) {
 | 
	
		
			
				|  |  | +            debtFile.mkdirs();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
 | 
	
		
			
				|  |  | +        templateEngine.setClassForTemplateLoading(ContractServiceImpl.class, "/config/contracts/");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        Map<String, Object> params = new HashMap<String, Object>();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 查询参数信息
 | 
	
		
			
				|  |  | +        params.put("organName", financialDto.getOrganName());
 | 
	
		
			
				|  |  | +        params.put("realName", financialDto.getRealName());
 | 
	
		
			
				|  |  | +        params.put("feeType", financialDto.getFeeType());
 | 
	
		
			
				|  |  | +        params.put("totalMoney", financialDto.getTotalMoney().setScale(2, RoundingMode.HALF_UP));
 | 
	
		
			
				|  |  | +        params.put("hasLoan", financialDto.getHasLoan());
 | 
	
		
			
				|  |  | +        params.put("memo", financialDto.getMemo());
 | 
	
		
			
				|  |  | +        params.put("circulationUsers", financialDto.getCirculationUsers());
 | 
	
		
			
				|  |  | +        params.put("executors", financialDto.getExecutors());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        templateEngine.render(params, "financial.ftl", srcFile);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 生成借款协议PDF
 | 
	
		
			
				|  |  | +        try {
 | 
	
		
			
				|  |  | +            PDFUtil.renderToPDFByData(ContractServiceImpl.class.getResource("/").getFile(), FileUtils.readFileToString(srcFile), srcPdfPath, "simsun.ttc");
 | 
	
		
			
				|  |  | +        } catch (IOException e) {
 | 
	
		
			
				|  |  | +            logger.error("生成签章协议失败", e);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        for (SysUserTsign sysUserTsign : financialDto.getSysUserTsigns()) {
 | 
	
		
			
				|  |  | +            eSealPlugin.userSign(sysUserTsign.getAccountId(), sysUserTsign.getSealData(), sysUserTsign.getName(), srcPdfPath, srcPdfPath);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //上传到oss
 | 
	
		
			
				|  |  | +        String dateStrOss = dateFormatOss.format(date);
 | 
	
		
			
				|  |  | +        dateStrOss = "oa/" + dateStrOss + "/" + DateUtil.getHour(date);
 | 
	
		
			
				|  |  | +        String pdfFilePath = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME, dateStrOss, srcFile);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        FileUtils.deleteQuietly(srcFile);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        return pdfFilePath;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  }
 |