Commit 8dd9cf2d by jianan

Merge branch 'dev_20210322_seal' into dev

parents 0e0e7633 de3040df
package com.yd.api.agms;
import com.yd.api.agms.service.AgmsDashboardService;
import com.yd.api.agms.service.AgmsFortuneService;
import com.yd.api.agms.service.AgmsHiringService;
import com.yd.api.agms.service.*;
import com.yd.api.agms.vo.dashboard.*;
import com.yd.api.agms.service.AgmsStatisticsService;
import com.yd.api.agms.vo.fortune.*;
import com.yd.api.agms.vo.hiring.*;
import com.yd.api.agms.vo.insurer.SealUploadResponseVO;
import com.yd.api.agms.vo.statistics.FinancialStatisticsRequestVO;
import com.yd.api.agms.vo.statistics.FinancialStatisticsResponseVO;
import com.yd.api.agms.vo.statistics.LeadsStatisticsRequestVO;
......@@ -16,10 +14,8 @@ import com.yd.api.practitioner.vo.hiring.HiringApproveResponseVO;
import com.yd.api.result.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
......@@ -35,6 +31,8 @@ public class AgmsController {
private AgmsFortuneService agmsFortuneService;
@Autowired
private AgmsHiringService agmsHiringService;
@Autowired
private AgmsInsurerService agmsInsurerService;
/**
* AGMS -- 财务管理报表
......@@ -286,4 +284,25 @@ public class AgmsController {
result.addResult(responseVO);
return result;
}
/**
* 上传公司印章接口
* @param sealFile
* @param loginId
* @param insurerBranchId
* @param insurerBranchDeptId
* @return
*/
@RequestMapping(value="/sealUpload")
public Object sealUpload(@RequestParam(value = "sealFile") MultipartFile sealFile,
@RequestParam(value = "loginId",required = true) Long loginId,
@RequestParam(value = "insurerBranchId",required = false) Long insurerBranchId,
@RequestParam(value = "insurerBranchDeptId",required = false) Long insurerBranchDeptId) {
JsonResult result = new JsonResult();
SealUploadResponseVO responseVO = agmsInsurerService.sealUpload(sealFile,loginId,insurerBranchId,insurerBranchDeptId);
result.setData(responseVO);
result.addResult(responseVO);
return result;
}
}
package com.yd.api.agms.service;
import com.yd.api.agms.vo.hiring.PractitionerHiringListResponseVO;
import com.yd.api.agms.vo.insurer.SealUploadResponseVO;
import org.springframework.web.multipart.MultipartFile;
/**
* @author xxy
*/
public interface AgmsInsurerService {
/**
* 上传公司印章接口
* @param sealFile
* @param loginId
* @param insurerBranchId
* @param insurerBranchDeptId
* @return
*/
SealUploadResponseVO sealUpload(MultipartFile sealFile, Long loginId, Long insurerBranchId, Long insurerBranchDeptId);
}
package com.yd.api.agms.service.impl;
import com.yd.api.agms.service.AgmsInsurerService;
import com.yd.api.agms.vo.insurer.SealUploadResponseVO;
import com.yd.api.result.CommonResult;
import com.yd.dal.entity.customer.AclInsurerBranch;
import com.yd.dal.entity.customer.AclInsurerBranchDept;
import com.yd.dal.service.customer.AclInsurerBranchDALService;
import com.yd.dal.service.customer.AclInsurerBranchDeptDALService;
import com.yd.util.CommonUtil;
import com.yd.util.config.ZHBErrorConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.*;
import java.net.InetAddress;
import java.util.Date;
/**
* @author xxy
*/
@Service("agmsInsurerService")
@PropertySource({"classpath:pdfconfiguration.properties"})
public class AgmsInsurerServiceImpl implements AgmsInsurerService {
@Value("${pdf.signImage}")
private String signImage;
@Autowired
private AclInsurerBranchDALService aclInsurerBranchDALService;
@Autowired
private AclInsurerBranchDeptDALService aclInsurerBranchDeptDALService;
@Override
public SealUploadResponseVO sealUpload(MultipartFile sealFile, Long loginId, Long insurerBranchId, Long insurerBranchDeptId) {
SealUploadResponseVO responseVO = new SealUploadResponseVO();
boolean success = true;
String message = ZHBErrorConfig.getErrorInfo("800000");
InputStream in = null;
FileOutputStream out = null;
try {
byte[] bytes = sealFile.getBytes();
in = new ByteArrayInputStream(bytes);
InetAddress address = InetAddress.getLocalHost();
File outFile = new File(signImage + sealFile.getOriginalFilename());
System.out.println(address.getHostAddress());
System.out.println("http://" + address.getHostAddress() + signImage + sealFile.getOriginalFilename());
// File outFile = new File("D:\\"+sealFile.getOriginalFilename());
out = new FileOutputStream(outFile);
byte[] bts = new byte[1024];
int len = 0;
while ((len = in.read(bts)) != -1) {
out.write(bts, 0, len);
}
if (!CommonUtil.isNullOrZero(insurerBranchId)) {
AclInsurerBranch branch = new AclInsurerBranch();
branch.setId(insurerBranchId);
branch.setElectronicTaxSeal("http://" + address.getHostAddress() + signImage+sealFile.getOriginalFilename());
branch.setUpdatedAt(new Date());
branch.setUpdatedBy(loginId);
aclInsurerBranchDALService.update(branch);
}
if (!CommonUtil.isNullOrZero(insurerBranchDeptId)) {
AclInsurerBranchDept dept = new AclInsurerBranchDept();
dept.setId(insurerBranchDeptId);
dept.setElectronicTaxSeal("http://" + address.getHostAddress() + signImage+sealFile.getOriginalFilename());
dept.setUpdatedAt(new Date());
dept.setUpdatedBy(loginId);
aclInsurerBranchDeptDALService.update(dept);
}
responseVO.setFileUrl("http://" + address.getHostAddress() + signImage+sealFile.getOriginalFilename());
} catch (Exception e) {
success = false;
message = ZHBErrorConfig.getErrorInfo("830025");
e.printStackTrace();
}finally {
try {
assert in != null;
in.close();
} catch (IOException e) {
e.printStackTrace();
}finally {
try {
assert out != null;
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
responseVO.setCommonResult(new CommonResult(success, message));
return responseVO;
}
}
package com.yd.api.agms.vo.insurer;
import com.yd.api.result.CommonResult;
/**
* @author xxy
*/
public class SealUploadResponseVO {
private String fileUrl;
private CommonResult commonResult;
/**
* 获取
*
* @return the commonResult
*/
public CommonResult getCommonResult() {
return this.commonResult;
}
/**
* 设置
*
* @param commonResult the to set
*/
public void setCommonResult(CommonResult commonResult) {
this.commonResult = commonResult;
}
/**
* 获取
*
* @return the fileUrl
*/
public String getFileUrl() {
return this.fileUrl;
}
/**
* 设置
*
* @param fileUrl the to set
*/
public void setFileUrl(String fileUrl) {
this.fileUrl = fileUrl;
}
@Override
public String toString() {
return "SealUploadResponseVO{" +
"fileUrl='" + fileUrl + '\'' +
", commonResult=" + commonResult +
'}';
}
}
package com.yd.api.practitioner.service;
import com.yd.api.practitioner.vo.hiring.GeneratePDFRequestVO;
import com.yd.dal.entity.customer.AclPractitioner;
import java.util.Map;
public interface PractitionerHiringContractService {
String generatePractitionerContract(String practitionerNO, String contractNo, Long hiringBasicInfoId) throws Exception;
String generatePractitionerContract(AclPractitioner practitioner) throws Exception;
Map<String, String> initHiringBasicInfoData(Long hiringBasicInfoId, String contractNo);
Map<String, String> initHiringImageInfoData(Long hiringBasicInfoId);
Map<String, String> initHiringImageInfoData(Long hiringBasicInfoId, String signImage);
String generatePractitionerPDF(String practitionerNO,Map<String, String> initDatas,Map<String, String> initImages);
String generatePractitionerPDF(AclPractitioner practitioner, String signImage, Map<String, String> initDatas, Map<String, String> initImages) throws Exception;
String getNextContractNo();
}
\ No newline at end of file
......@@ -10,6 +10,8 @@ import com.yd.rmi.cache.SystemConfigService;
import com.yd.util.CommonUtil;
import com.yd.util.HttpUtil;
import com.yd.util.PDFConfiguration;
import com.yd.util.config.ZHBErrorConfig;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -37,16 +39,24 @@ public class PractitionerHiringContractServiceImpl implements PractitionerHiring
private AclPractitionerHiringPersonalStatementsMapper statementsMapper;
@Autowired
private SystemConfigService systemConfigService;
@Autowired
private AclInsurerBranchMapper branchMapper;
@Autowired
private AclInsurerBranchDeptMapper deptMapper;
/**
* 申请经纪人的ID,生成电子合同,在经纪人表中自动生成记录
*
* @param hiringBasicInfoId
* @param practitioner
* @return
*/
@Override
public String generatePractitionerContract(String practitionerNO, String contractNo, Long hiringBasicInfoId) throws Exception {
public String generatePractitionerContract(AclPractitioner practitioner) throws Exception {
String contractNo = practitioner.getContractNo();
Long hiringBasicInfoId = practitioner.getHiringBasicInfoId();
//0、查询分公司电子印章
String signImage = this.getSignImageLocalPath(practitioner);
//1、从DB中按照hiringBasicInfoId,获取经纪人的文字信息
Map<String, String> initDatas = new HashMap<String, String>();
......@@ -54,15 +64,11 @@ public class PractitionerHiringContractServiceImpl implements PractitionerHiring
//2、从DB中按照hiringBasicInfoId,从oss上获取经纪人上传的图片信息,需存本地临时文件
Map<String, String> initImages = new HashMap<String, String>();
initImages = initHiringImageInfoData(hiringBasicInfoId);
initImages = initHiringImageInfoData(hiringBasicInfoId, signImage);
//ag_acl_practitioner.practitioner_code
//String practitionerNO = "YDSH00009";
//String contractNO = "CTSH00009";
//3、PDF模板生成合同文件,存本地临时文件后,上传oss
String contractFile = generatePractitionerPDF(practitionerNO, initDatas, initImages);
String contractFile = generatePractitionerPDF(practitioner, signImage, initDatas, initImages);
//上传至oss ossService
String contractFileOSS = this.putContractFileToOSS(contractFile, hiringBasicInfoId);
......@@ -383,7 +389,7 @@ public class PractitionerHiringContractServiceImpl implements PractitionerHiring
* @return
*/
@Override
public Map<String, String> initHiringImageInfoData(Long hiringBasicInfoId) {
public Map<String, String> initHiringImageInfoData(Long hiringBasicInfoId, String signImage) {
AclPractitionerHiringBasicInfo basicInfo = basicInfoMapper.selectByPrimaryKey(hiringBasicInfoId);
......@@ -401,7 +407,7 @@ public class PractitionerHiringContractServiceImpl implements PractitionerHiring
String personerPicture = this.getImgTolocal(localDirectory,"personerPicture.png", basicInfo.getPersonerPictureOssPath());
images.put("secondPersonerPicture", personerPicture);
//印章从配置文件读
String signImage = PDFConfiguration.getProperty("pdf.signImage");
// String signImage = PDFConfiguration.getProperty("pdf.signImage");
images.put("yindunESignature1001", signImage);
images.put("yindunESignature1201", signImage);
images.put("yindunESignature1401", signImage);
......@@ -589,13 +595,16 @@ public class PractitionerHiringContractServiceImpl implements PractitionerHiring
* @return
*/
@Override
public String generatePractitionerPDF(String practitionerNO, Map<String, String> initDatas, Map<String, String> initImages) {
public String generatePractitionerPDF(AclPractitioner practitioner, String signImage,
Map<String, String> initDatas, Map<String, String> initImages) throws Exception {
String templatePDF = "D:\\pcs12\\templatePractitionerContract.pdf";
templatePDF = PDFConfiguration.getProperty("pdf.template");
//模板文件生成零时文件
String tmpPathPDF = PDFConfiguration.getProperty("pdf.temp.path");
//PDF模板输出结果文件
String practitionerNO = practitioner.getPractitionerCode();
String templateResultPDF = tmpPathPDF + practitionerNO + "-template.pdf";
//按模板填充数据生成结果PDF
PDFTemplate.generatePDF(templatePDF, templateResultPDF, initDatas, initImages);
......@@ -614,8 +623,9 @@ public class PractitionerHiringContractServiceImpl implements PractitionerHiring
String signSourcePDF = templateResultPDF;
//电子印章文件
String signImage = "D:\\pcs12\\上海银盾保险经纪有限公司.png";
signImage = PDFConfiguration.getProperty("pdf.signImage");
// String signImage = "D:\\pcs12\\上海银盾保险经纪有限公司.png";
// signImage = PDFConfiguration.getProperty("pdf.signImage");
float x = 450;
float y = 150;
x = Float.parseFloat(PDFConfiguration.getProperty("pdf.position.x"));
......@@ -629,6 +639,38 @@ public class PractitionerHiringContractServiceImpl implements PractitionerHiring
return signResultPDF;
}
private String getSignImageLocalPath(AclPractitioner practitioner) throws Exception {
Long insurerBranchId = practitioner.getInsurerBranchId();
Long deptId = practitioner.getDeptId();
// 1.获取电子印章url
InputStream inputStream = null;
String electronicTaxSeal = null;
AclInsurerBranchDept dept = deptMapper.selectByPrimaryKey(deptId);
if (dept != null && StringUtils.isNotBlank(dept.getElectronicTaxSeal())) {
electronicTaxSeal = dept.getElectronicTaxSeal();
} else {
AclInsurerBranch insurerBranch = branchMapper.selectByPrimaryKey(insurerBranchId);
if (insurerBranch != null && StringUtils.isNotBlank(insurerBranch.getElectronicTaxSeal())) {
electronicTaxSeal = insurerBranch.getElectronicTaxSeal();
}
}
if (StringUtils.isBlank(electronicTaxSeal)) {
throw new Exception("分公司和部门电子印章url不能同时为空");
}
// 2.从Oss下载电子印章图片到本地
//本地图片目录
String localDirectory = PDFConfiguration.getProperty("pdf.signImage");
String signature = this.getImgTolocal(localDirectory,"signImage.png", electronicTaxSeal);
return signature;
}
@Override
public String getNextContractNo() {
return practitionerHiringMapper.getNextContractNo();
......
......@@ -756,7 +756,7 @@ public class PractitionerHiringServiceImpl implements PractitionerHiringService
if (StringUtils.isEmpty(contractNo)) {
contractNo = hiringContractService.getNextContractNo();
}
String contractOssPath = hiringContractService.generatePractitionerContract(practitionerCode, contractNo, hiringBasicInfoId);
String contractOssPath = hiringContractService.generatePractitionerContract(practitioner);
//4、经纪人表生成经纪人记录ag_acl_practitioner,ag_acl_practitioner.contract_oss_path
// 经纪人经纪人类型级别定义表ag_acl_practitioner_setting
......
package com.yd.dal.entity.customer;
import java.util.Date;
import lombok.Data;
/**
* 保险公司分公司/营业部
*/
@Data
public class AclInsurerBranch {
/**
* serial id
*/
private Long id;
/**
* 分公司/营业部代码
*/
private String branchCode;
/**
* FK ag_acl_insurer.id
*/
private Long insurerId;
/**
* 保险公司名称
*/
private String insurerName;
/**
* 分公司/营业部名称
*/
private String branchName;
/**
* 0=No, 1=Yes
*/
private Integer isActive;
/**
* 有效起日
*/
private Date effectiveStartDate;
/**
* 有效终日
*/
private Date effectiveEndDate;
/**
* 联系人
*/
private String contactName;
/**
* 联系电话
*/
private String contactNo;
/**
* 分公司地址
*/
private String address;
/**
* 分公司电子印章
*/
private String electronicTaxSeal;
/**
* 备注
*/
private String remark;
private Date createdAt;
private Long createdBy;
private Date updatedAt;
private Long updatedBy;
}
\ No newline at end of file
package com.yd.dal.entity.customer;
import java.util.Date;
import lombok.Data;
/**
* 经纪人所属部门
*/
@Data
public class AclInsurerBranchDept {
/**
* serial id
*/
private Long id;
/**
* FK ag_acl_insurer.id
*/
private Long insurerId;
/**
* FK ag_acl_insurer.id
*/
private Long insurerBranchId;
private String deptCode;
/**
* dept name
*/
private String name;
/**
* dept english name
*/
private String nameEn;
/**
* 联系人
*/
private String contactName;
/**
* 联系电话
*/
private String contactNo;
/**
* 部门地址
*/
private String address;
/**
* 经纪人所属部门电子印章
*/
private String electronicTaxSeal;
/**
* memo or tips
*/
private String remark;
/**
* 0=No, 1=Yes
*/
private Integer isActive;
private Date createdAt;
/**
* FK ag_acl_user.id
*/
private Long createdBy;
private Date updatedAt;
/**
* FK ag_acl_user.id
*/
private Long updatedBy;
}
\ No newline at end of file
package com.yd.dal.mapper.customer;
import com.yd.dal.entity.customer.AclInsurerBranchDept;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface AclInsurerBranchDeptMapper {
int deleteByPrimaryKey(Long id);
int insert(AclInsurerBranchDept record);
int insertSelective(AclInsurerBranchDept record);
AclInsurerBranchDept selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(AclInsurerBranchDept record);
int updateByPrimaryKey(AclInsurerBranchDept record);
int updateBatch(List<AclInsurerBranchDept> list);
int updateBatchSelective(List<AclInsurerBranchDept> list);
int batchInsert(@Param("list") List<AclInsurerBranchDept> list);
}
\ No newline at end of file
package com.yd.dal.mapper.customer;
import com.yd.dal.entity.customer.AclInsurerBranch;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface AclInsurerBranchMapper {
int deleteByPrimaryKey(Long id);
int insert(AclInsurerBranch record);
int insertSelective(AclInsurerBranch record);
AclInsurerBranch selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(AclInsurerBranch record);
int updateByPrimaryKey(AclInsurerBranch record);
int updateBatch(List<AclInsurerBranch> list);
int updateBatchSelective(List<AclInsurerBranch> list);
int batchInsert(@Param("list") List<AclInsurerBranch> list);
}
\ No newline at end of file
package com.yd.dal.service.customer;
import com.yd.dal.entity.customer.AclInsurerBranch;
/**
* @author xxy
*/
public interface AclInsurerBranchDALService {
void update(AclInsurerBranch branch);
}
package com.yd.dal.service.customer;
import com.yd.dal.entity.customer.AclInsurerBranchDept;
import java.util.List;
/**
* @author xxy
*/
public interface AclInsurerBranchDeptDALService {
void update(AclInsurerBranchDept dept);
}
package com.yd.dal.service.customer.impl;
import com.yd.dal.entity.customer.AclInsurerBranch;
import com.yd.dal.mapper.customer.AclInsurerBranchMapper;
import com.yd.dal.service.customer.AclInsurerBranchDALService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* @author xxy
*/
@Service("aclInsurerBranchDALService")
public class AclInsurerBranchDALServiceImpl implements AclInsurerBranchDALService {
@Resource
private AclInsurerBranchMapper mapper;
@Override
public void update(AclInsurerBranch branch) {
mapper.updateByPrimaryKeySelective(branch);
}
}
package com.yd.dal.service.customer.impl;
import com.yd.dal.entity.customer.AclInsurerBranchDept;
import com.yd.dal.mapper.customer.AclInsurerBranchDeptMapper;
import com.yd.dal.service.customer.AclInsurerBranchDeptDALService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* @author xxy
*/
@Service("aclInsurerBranchDeptDALService")
public class AclInsurerBranchDeptDALServiceImpl implements AclInsurerBranchDeptDALService {
@Resource
private AclInsurerBranchDeptMapper mapper;
@Override
public void update(AclInsurerBranchDept dept) {
mapper.updateByPrimaryKeySelective(dept);
}
}
pdf.template=/opt/tomcat8/conf/ydpdf/pdfres/templatePractitionerContract.pdf
pdf.signImage=/opt/tomcat8/conf/ydpdf/pdfres/yindunsign.png
pdf.signImage=/opt/tomcat8/conf/ydpdf/pdfres/
pdf.keyStorePath=/opt/tomcat8/conf/ydpdf/pdfres/4929078_m.zuihuibi.cn.pfx
pdf.keyPassword=UC645YlB
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment