|
@@ -8,9 +8,12 @@ import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
import java.util.Map.Entry;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import com.ym.mec.auth.api.enums.CertificateTypeEnum;
|
|
|
import com.ym.mec.biz.dal.dao.*;
|
|
|
+import com.ym.mec.biz.dal.dto.CirculationUser;
|
|
|
+import com.ym.mec.biz.dal.dto.OAFinancialDto;
|
|
|
import com.ym.mec.biz.dal.enums.CourseViewTypeEnum;
|
|
|
import com.ym.mec.common.controller.BaseController;
|
|
|
import com.ym.mec.common.entity.HttpResponseResult;
|
|
@@ -134,6 +137,9 @@ public class ContractServiceImpl implements ContractService, InitializingBean {
|
|
|
@Autowired
|
|
|
private StudentDao studentDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private EmployeeDao employeeDao;
|
|
|
+
|
|
|
@Value("${contract.baseDir:/var/pdf}")
|
|
|
private String contractBaseDir;
|
|
|
|
|
@@ -1255,4 +1261,95 @@ public class ContractServiceImpl implements ContractService, InitializingBean {
|
|
|
FileUtils.deleteQuietly(srcFile);
|
|
|
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.getWorkOrderId();
|
|
|
+ }
|
|
|
+ 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());
|
|
|
+ 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;
|
|
|
+ }
|
|
|
}
|