|
@@ -5,6 +5,7 @@ import java.io.IOException;
|
|
import java.text.DateFormat;
|
|
import java.text.DateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
import org.apache.commons.io.FileUtils;
|
|
import org.apache.commons.io.FileUtils;
|
|
@@ -15,8 +16,11 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
|
|
+import com.ym.mec.biz.dal.entity.SysUserContracts;
|
|
|
|
+import com.ym.mec.biz.dal.entity.SysUserContracts.ContractType;
|
|
import com.ym.mec.biz.dal.entity.SysUserTsign;
|
|
import com.ym.mec.biz.dal.entity.SysUserTsign;
|
|
import com.ym.mec.biz.service.ContractService;
|
|
import com.ym.mec.biz.service.ContractService;
|
|
|
|
+import com.ym.mec.biz.service.SysUserContractsService;
|
|
import com.ym.mec.biz.service.SysUserTsignService;
|
|
import com.ym.mec.biz.service.SysUserTsignService;
|
|
import com.ym.mec.common.exception.BizException;
|
|
import com.ym.mec.common.exception.BizException;
|
|
import com.ym.mec.thirdparty.eseal.ESealPlugin;
|
|
import com.ym.mec.thirdparty.eseal.ESealPlugin;
|
|
@@ -34,6 +38,9 @@ public class ContractServiceImpl implements ContractService {
|
|
private SysUserFeignService sysUserFeignService;
|
|
private SysUserFeignService sysUserFeignService;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
|
+ private SysUserContractsService sysUserContractsService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
private ESealPlugin eSealPlugin;
|
|
private ESealPlugin eSealPlugin;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -76,7 +83,7 @@ public class ContractServiceImpl implements ContractService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public boolean transferRegisterContract(Integer userId, Map<String, Object> params) {
|
|
|
|
|
|
+ public boolean transferRegisterContract(Integer userId) {
|
|
|
|
|
|
SysUserTsign sysUserTsign = sysUserTsignService.get(userId);
|
|
SysUserTsign sysUserTsign = sysUserTsignService.get(userId);
|
|
|
|
|
|
@@ -85,7 +92,7 @@ public class ContractServiceImpl implements ContractService {
|
|
}
|
|
}
|
|
|
|
|
|
// 合成freemarker
|
|
// 合成freemarker
|
|
- String srcPdfPath = contractBaseDir + "/" + userId + ".pdf";
|
|
|
|
|
|
+ String srcPdfPath = contractBaseDir + "/register/" + userId + ".pdf";
|
|
File debtFile = new File(contractBaseDir);
|
|
File debtFile = new File(contractBaseDir);
|
|
if (!debtFile.exists()) {
|
|
if (!debtFile.exists()) {
|
|
debtFile.mkdirs();
|
|
debtFile.mkdirs();
|
|
@@ -94,6 +101,8 @@ public class ContractServiceImpl implements ContractService {
|
|
FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
|
|
FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
|
|
templateEngine.setClassForTemplateLoading(ContractServiceImpl.class, "/config/contracts/");
|
|
templateEngine.setClassForTemplateLoading(ContractServiceImpl.class, "/config/contracts/");
|
|
|
|
|
|
|
|
+ Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
+
|
|
templateEngine.render(params, "register.ftl", new File(srcPdfPath));
|
|
templateEngine.render(params, "register.ftl", new File(srcPdfPath));
|
|
|
|
|
|
// 生成借款协议PDF
|
|
// 生成借款协议PDF
|
|
@@ -101,7 +110,7 @@ public class ContractServiceImpl implements ContractService {
|
|
PDFUtil.renderToPDFByData(ContractServiceImpl.class.getResource("/").getFile(), FileUtils.readFileToString(new File(srcPdfPath)), srcPdfPath,
|
|
PDFUtil.renderToPDFByData(ContractServiceImpl.class.getResource("/").getFile(), FileUtils.readFileToString(new File(srcPdfPath)), srcPdfPath,
|
|
"config/fonts/simsun.ttc");
|
|
"config/fonts/simsun.ttc");
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
- throw new BizException("生产pdf协议失败", e);
|
|
|
|
|
|
+ throw new BizException("生成pdf协议失败", e);
|
|
}
|
|
}
|
|
|
|
|
|
eSealPlugin.userSign(sysUserTsign.getAccountId(), sysUserTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
eSealPlugin.userSign(sysUserTsign.getAccountId(), sysUserTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
@@ -111,16 +120,24 @@ public class ContractServiceImpl implements ContractService {
|
|
String dateStrOss = dateFormatOss.format(date);
|
|
String dateStrOss = dateFormatOss.format(date);
|
|
String pdfFilePath = storagePlugin.uploadFile(dateStrOss, new File(srcPdfPath));
|
|
String pdfFilePath = storagePlugin.uploadFile(dateStrOss, new File(srcPdfPath));
|
|
|
|
|
|
|
|
+ SysUserContracts sysUserContracts = new SysUserContracts();
|
|
|
|
+ sysUserContracts.setCreateTime(date);
|
|
|
|
+ sysUserContracts.setType(ContractType.REGISTER);
|
|
|
|
+ sysUserContracts.setUrl(pdfFilePath);
|
|
|
|
+ sysUserContracts.setUserId(userId);
|
|
|
|
+
|
|
|
|
+ sysUserContractsService.insert(sysUserContracts);
|
|
|
|
+
|
|
FileUtils.deleteQuietly(new File(srcPdfPath));
|
|
FileUtils.deleteQuietly(new File(srcPdfPath));
|
|
|
|
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public String queryRegisterContract(Integer userId, Map<String, Object> params) {
|
|
|
|
|
|
+ public String queryRegisterContract(Integer userId) {
|
|
|
|
|
|
// 合成freemarker
|
|
// 合成freemarker
|
|
- String srcPdfPath = contractBaseDir + "/" + userId + ".pdf";
|
|
|
|
|
|
+ String srcPdfPath = contractBaseDir + "/register/" + userId + ".pdf";
|
|
File debtFile = new File(contractBaseDir);
|
|
File debtFile = new File(contractBaseDir);
|
|
if (!debtFile.exists()) {
|
|
if (!debtFile.exists()) {
|
|
debtFile.mkdirs();
|
|
debtFile.mkdirs();
|
|
@@ -129,6 +146,8 @@ public class ContractServiceImpl implements ContractService {
|
|
FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
|
|
FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
|
|
templateEngine.setClassForTemplateLoading(ContractServiceImpl.class, "/config/contracts/");
|
|
templateEngine.setClassForTemplateLoading(ContractServiceImpl.class, "/config/contracts/");
|
|
|
|
|
|
|
|
+ Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
+
|
|
templateEngine.render(params, "register.ftl", new File(srcPdfPath));
|
|
templateEngine.render(params, "register.ftl", new File(srcPdfPath));
|
|
|
|
|
|
String result = "";
|
|
String result = "";
|
|
@@ -142,4 +161,85 @@ public class ContractServiceImpl implements ContractService {
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public boolean transferCoursesContract(Integer userId, Integer musicGroupId) {
|
|
|
|
+ SysUserTsign sysUserTsign = sysUserTsignService.get(userId);
|
|
|
|
+
|
|
|
|
+ if (sysUserTsign == null) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 合成freemarker
|
|
|
|
+ String srcPdfPath = contractBaseDir + "/courses/" + userId + ".pdf";
|
|
|
|
+ File debtFile = new File(contractBaseDir);
|
|
|
|
+ if (!debtFile.exists()) {
|
|
|
|
+ debtFile.mkdirs();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
|
|
|
|
+ templateEngine.setClassForTemplateLoading(ContractServiceImpl.class, "/config/contracts/");
|
|
|
|
+
|
|
|
|
+ Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
+
|
|
|
|
+ //查询参数信息
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ templateEngine.render(params, "courses.ftl", new File(srcPdfPath));
|
|
|
|
+
|
|
|
|
+ // 生成借款协议PDF
|
|
|
|
+ try {
|
|
|
|
+ PDFUtil.renderToPDFByData(ContractServiceImpl.class.getResource("/").getFile(), FileUtils.readFileToString(new File(srcPdfPath)), srcPdfPath,
|
|
|
|
+ "config/fonts/simsun.ttc");
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ throw new BizException("生成pdf协议失败", e);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ eSealPlugin.userSign(sysUserTsign.getAccountId(), sysUserTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
|
+
|
|
|
|
+ Date date = new Date();
|
|
|
|
+ // 上传到oss
|
|
|
|
+ String dateStrOss = dateFormatOss.format(date);
|
|
|
|
+ String pdfFilePath = storagePlugin.uploadFile(dateStrOss, new File(srcPdfPath));
|
|
|
|
+
|
|
|
|
+ SysUserContracts sysUserContracts = new SysUserContracts();
|
|
|
|
+ sysUserContracts.setCreateTime(date);
|
|
|
|
+ sysUserContracts.setType(ContractType.REGISTER);
|
|
|
|
+ sysUserContracts.setUrl(pdfFilePath);
|
|
|
|
+ sysUserContracts.setUserId(userId);
|
|
|
|
+
|
|
|
|
+ sysUserContractsService.insert(sysUserContracts);
|
|
|
|
+
|
|
|
|
+ FileUtils.deleteQuietly(new File(srcPdfPath));
|
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public String queryCoursesContract(Integer userId, Integer musicGroupId) {
|
|
|
|
+
|
|
|
|
+ // 合成freemarker
|
|
|
|
+ String srcPdfPath = contractBaseDir + "/courses/" + userId + ".pdf";
|
|
|
|
+ File debtFile = new File(contractBaseDir);
|
|
|
|
+ if (!debtFile.exists()) {
|
|
|
|
+ debtFile.mkdirs();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
|
|
|
|
+ templateEngine.setClassForTemplateLoading(ContractServiceImpl.class, "/config/contracts/");
|
|
|
|
+
|
|
|
|
+ Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
+
|
|
|
|
+ templateEngine.render(params, "courses.ftl", new File(srcPdfPath));
|
|
|
|
+
|
|
|
|
+ String result = "";
|
|
|
|
+ try {
|
|
|
|
+ result = FileUtils.readFileToString(new File(srcPdfPath));
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ throw new BizException("读取课程协议出错", e);
|
|
|
|
+ }
|
|
|
|
+ FileUtils.deleteQuietly(new File(srcPdfPath));
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|