Commit c78fc1fe by jianan

生成pdf后放至oss,ydlife查询经纪人合同

parent 02cf64fd
......@@ -18,8 +18,7 @@ public class PractitionerHiringController {
@Autowired
private PractitionerHiringService practitionerHiringService;
@Autowired
private PractitionerHiringContractService hiringContractService;
/**
* 保存报聘经纪人组织关系
......@@ -236,19 +235,26 @@ public class PractitionerHiringController {
* @param requestVO 请求数据
* @return 响应数据
*/
@RequestMapping("/hiringPDF")
public Object hiringApprove(@RequestBody HiringPDFRequestVO requestVO){
@RequestMapping("/generatePDF")
public Object generatePDF(@RequestBody GeneratePDFRequestVO requestVO){
JsonResult result = new JsonResult();
try {
// PractitionerPDFTest.main(null);
Long hiringBasicInfoId = requestVO.getHiringBasicInfoId();
hiringContractService.generatePractitionerContract(hiringBasicInfoId);
} catch (Exception e) {
e.printStackTrace();
GeneratePDFResponseVO responseVO = practitionerHiringService.generatePDF(requestVO);
result.addResult(responseVO);
result.setData(responseVO);
return result;
}
/**
* 报聘成功后查看经纪人信息
* @param requestVO 请求数据
* @return 响应数据
*/
@RequestMapping("/queryPractitionerInfo")
public Object queryPractitionerInfo(@RequestBody QueryPractitionerInfoRequestVO requestVO){
JsonResult result = new JsonResult();
QueryPractitionerInfoResponseVO responseVO = practitionerHiringService.queryPractitionerInfo(requestVO);
result.addResult(responseVO);
result.setData(responseVO);
return result;
}
}
\ No newline at end of file
package com.yd.api.practitioner.service;
import com.yd.api.practitioner.vo.hiring.GeneratePDFRequestVO;
import java.util.Map;
public interface PractitionerHiringContractService {
String generatePractitionerContract(Long hiringBasicInfoId);
String generatePractitionerContract(String practitionerNO, String contractNo, Long hiringBasicInfoId) throws Exception;
Map<String, String> initHiringBasicInfoData(Long hiringBasicInfoId);
......
......@@ -53,4 +53,7 @@ public interface PractitionerHiringService {
SavePayrollPictureResponseVO savePayrollPicture(SavePayRollPictureRequestVO requestVO);
GeneratePDFResponseVO generatePDF(GeneratePDFRequestVO requestVO);
QueryPractitionerInfoResponseVO queryPractitionerInfo(QueryPractitionerInfoRequestVO requestVO);
}
package com.yd.api.practitioner.service.impl;
import com.yd.api.practitioner.service.PractitionerHiringContractService;
import com.yd.api.practitioner.vo.hiring.GeneratePDFRequestVO;
import com.yd.dal.entity.customer.*;
import com.yd.dal.entity.practitioner.hiring.HiringBasicInfo;
import com.yd.dal.entity.practitioner.hiring.HiringMemberShip;
import com.yd.dal.entity.practitioner.hiring.HiringPersonalStatements;
import com.yd.dal.entity.practitioner.hiring.HiringWorkingExperience;
import com.yd.dal.mapper.customer.*;
import com.yd.dal.mapper.practitioner.PractitionerHiringMapper;
import com.libs.pdf.*;
......@@ -13,15 +10,11 @@ import com.yd.rmi.ali.oss.service.OssService;
import com.yd.util.CommonUtil;
import com.yd.util.HttpUtil;
import com.yd.util.PDFConfiguration;
import com.yd.util.config.ZHBErrorConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;
......@@ -54,7 +47,8 @@ public class PractitionerHiringContractServiceImpl implements PractitionerHiring
* @return
*/
@Override
public String generatePractitionerContract(Long hiringBasicInfoId) {
public String generatePractitionerContract(String practitionerNO, String contractNo, Long hiringBasicInfoId) throws Exception {
//1、从DB中按照hiringBasicInfoId,获取经纪人的文字信息
Map<String, String> initDatas = new HashMap<String, String>();
initDatas = initHiringBasicInfoData(hiringBasicInfoId);
......@@ -63,21 +57,98 @@ public class PractitionerHiringContractServiceImpl implements PractitionerHiring
Map<String, String> initImages = new HashMap<String, String>();
initImages = initHiringImageInfoData(hiringBasicInfoId);
//ag_acl_practitioner.employee_no
String practitionerNO = "YDSH00009";
String contractNO = "CTSH00009";
//ag_acl_practitioner.practitioner_code
//String practitionerNO = "YDSH00009";
//String contractNO = "CTSH00009";
//3、PDF模板生成合同文件,存本地临时文件后,上传oss
String contractFile = generatePractitionerPDF(practitionerNO, initDatas, initImages);
//上传至oss ossService
String contractFileOSS = contractFile;
String contractFileOSS = this.putContractFileToOSS(contractFile, hiringBasicInfoId);
//4、经纪人表生成经纪人记录ag_acl_practitioner,ag_acl_practitioner.contract_oss_path
// 经纪人经纪人类型级别定义表ag_acl_practitioner_setting
return contractFileOSS;
}
private String putContractFileToOSS(String contractFile, Long basicInfoId) throws Exception {
StringBuffer directory = new StringBuffer();
directory.append("brokerHiring/").append(basicInfoId).append("/");
File tempFile =new File(contractFile.trim());
//数据源不存在
if(!tempFile.exists()) {
throw new Exception("目标文件地址不存在!");
}
//非文件类型
if(!tempFile.isFile()) {
throw new Exception("目标文件不是文件类型!");
}
InputStream is = null;
String ossPath = null;
try {
is = new BufferedInputStream(new FileInputStream(tempFile));//读取数据源
String fileName = tempFile.getName();
String key = directory.append(fileName).toString();
ossPath = ossService.putFileToOss(null, key, is);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally {
if(is != null) {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return ossPath;
}
public static String copyFile(String src, String dest) throws IOException, ClassNotFoundException {
File srcFile = new File(src);//源文件数据源
File desFile = new File(dest);//写入到目标数据源
//数据源不存在
if(!srcFile.exists() || !desFile.exists()) {
throw new ClassNotFoundException("源文件或者拷贝目标文件地址不存在!");
}
//非文件类型
if(!srcFile.isFile() || !desFile.isFile()) {
return "源文件或者目标文件不是文件类型!";
}
InputStream is = null;
OutputStream os = null;
byte[] buf = new byte[1024];//缓存区
int len = 0;//读取长度
try {
is = new BufferedInputStream(new FileInputStream(srcFile));//读取数据源
os = new BufferedOutputStream(new FileOutputStream(desFile));//写入到数据源
while((len = is.read(buf)) != -1) { //读取长度不为-1,继续读取
os.write(buf); //读取内容之后马上写入目标数据源
}
os.flush();//输出
return "文件拷贝成功!查看拷贝文件路径:" + desFile.getPath();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally {
if(is != null)
is.close();
if(os != null)
os.close();
}
return "文件拷贝失败";
}
/**
* 申请ID的数据列表
*
......@@ -114,8 +185,8 @@ public class PractitionerHiringContractServiceImpl implements PractitionerHiring
//PDF模板中定义的文字key,和值的集合
Map<String, String> data = new HashMap<String, String>();
//1页
data.put("contactNo", "C-SH-0001");
data.put("practitionerNo", "YDSH00127");
data.put("contactNo", second.getContractNo());
data.put("practitionerNo", second.getPractitionerCode());
data.put("subsystem", memberShip.getSubsystem());
data.put("practitioner", basicInfo.getName());
data.put("idNo", basicInfo.getIdNo());
......@@ -130,12 +201,8 @@ public class PractitionerHiringContractServiceImpl implements PractitionerHiring
data.put("firstPartyAddress", firstPartyAddress);
// 设置一些地址
this.setSomeAddress(data, hiringBasicInfoId);
Calendar now = Calendar.getInstance();
System.out.println("----------------合同年月日------------------");
System.out.println("年: " + now.get(Calendar.YEAR));
System.out.println("月: " + (now.get(Calendar.MONTH) + 1) + "");
System.out.println("日: " + now.get(Calendar.DAY_OF_MONTH));
Calendar now = Calendar.getInstance();
data.put("contactYear", now.get(Calendar.YEAR) + "");
data.put("contactMonth", (now.get(Calendar.MONTH) + 1) + "");
data.put("contactDay", now.get(Calendar.DAY_OF_MONTH) + "");
......@@ -232,7 +299,7 @@ public class PractitionerHiringContractServiceImpl implements PractitionerHiring
if (mentor != null) {
mentorAddress.append(mentor.getProvinceName()).append(mentor.getCityName());
}
data.put("secondMentorAddress", "上海市浦东新区张杨路560号中融恒瑞国际西楼1706室");
data.put("secondMentorAddress", mentorAddress.toString());
data.put("secondMentorMobileNo", mentorMobile);
}
......@@ -369,27 +436,27 @@ public class PractitionerHiringContractServiceImpl implements PractitionerHiring
Long mdDropOptionId = memberShip == null ? null : memberShip.getMdDropOptionId();
if (Long.valueOf("30").equals(mdDropOptionId)) {
images.put("secondPosition1", unCheckFile);
images.put("secondPosition1", checkFile);
return;
}
if (Long.valueOf("32").equals(mdDropOptionId)) {
images.put("secondPosition2", unCheckFile);
images.put("secondPosition2", checkFile);
return;
}
if (Long.valueOf("33").equals(mdDropOptionId)) {
images.put("secondPosition3", unCheckFile);
images.put("secondPosition3", checkFile);
return;
}
if (Long.valueOf("34").equals(mdDropOptionId)) {
images.put("secondPosition4", unCheckFile);
images.put("secondPosition4", checkFile);
return;
}
if (Long.valueOf("35").equals(mdDropOptionId)) {
images.put("secondPosition5", unCheckFile);
images.put("secondPosition5", checkFile);
return;
}
if (Long.valueOf("36").equals(mdDropOptionId)) {
images.put("secondPosition6", unCheckFile);
images.put("secondPosition6", checkFile);
return;
}
......@@ -403,7 +470,7 @@ public class PractitionerHiringContractServiceImpl implements PractitionerHiring
images.put("secondPersonalStatement3", checkFile);
images.put("secondPersonalStatement4", checkFile);
images.put("secondPersonalStatement5", checkFile);
images.put("secondPersonalStatement6", checkFile);
images.put("secondPersonalStatement6", unCheckFile);
}
private void setIDType(Map<String, String> images, String idType, String checkFile, String unCheckFile) {
......@@ -418,7 +485,7 @@ public class PractitionerHiringContractServiceImpl implements PractitionerHiring
return;
}
if (idType.indexOf("台胞") > 0) {
if (idType.indexOf("台胞") > 0) {
images.put("secondIDType2", checkFile);
return;
}
......@@ -511,7 +578,8 @@ public class PractitionerHiringContractServiceImpl implements PractitionerHiring
//准备加盖电子印章的源文件
String signSourcePDF = templateResultPDF;
//电子印章文件
String signImage = "D:\\pcs12\\上海银盾保险经纪有限公司.png";
/*String signImage = "D:\\pcs12\\上海银盾保险经纪有限公司.png";
signImage = PDFConfiguration.getProperty("pdf.signImage");
float x = 450;
float y = 150;
......@@ -521,7 +589,8 @@ public class PractitionerHiringContractServiceImpl implements PractitionerHiring
PDFSign.sign(signResultPDF, password, keyStorePath, signSourcePDF, signImage, x, y);
} catch (Exception e) {
e.printStackTrace();
}
return signResultPDF;
}*/
return templateResultPDF;
}
}
package com.yd.api.practitioner.service.impl;
import com.yd.api.practitioner.service.PractitionerHiringContractService;
import com.yd.api.practitioner.service.PractitionerHiringService;
import com.yd.api.practitioner.vo.hiring.*;
import com.yd.api.result.CommonResult;
......@@ -47,6 +48,10 @@ public class PractitionerHiringServiceImpl implements PractitionerHiringService
private AclPractitionerHiringContractTermsConfirmsMapper contractTermsConfirmsMapper;
@Autowired
private AclPractitionerHiringApproveRecordsMapper recordsMapper;
@Autowired
private PractitionerHiringContractService hiringContractService;
@Autowired
private AclPractitionerMapper aclPractitionerMapper;
private PractitionerHiringDALService practitionerHiringDalService;
private SystemConfigService systemConfigService;
......@@ -474,14 +479,14 @@ public class PractitionerHiringServiceImpl implements PractitionerHiringService
//余下的仅有0.不可审批(未到) 1.可审批两种状态
//approvalIdentity的参数意义0.既是辅导人又是团队长 1.辅导人 2.团队长
//当approvalIdentity为0,1时,审批状态为可审批 当为2时判断辅导人是否审批
if (approvalIdentity == 0 || approvalIdentity == 1){
if (approvalIdentity == 0 || approvalIdentity == 1) {
hiringApproveStatus = 1L;
hiringApproveStepsSeq = 1L;
}else {
} else {
//判断辅导人是否审批,仅需判断hiringApproveRecordsList.isEmpty(),因为辅导人是第一步,团队长为第二步
if (hiringApproveRecordsList.isEmpty()) {
hiringApproveStatus = 0L;
}else {
} else {
hiringApproveStatus = 1L;
hiringApproveStepsSeq = 2L;
}
......@@ -497,15 +502,15 @@ public class PractitionerHiringServiceImpl implements PractitionerHiringService
List<MdPractitionerHiringApproveSteps> hiringApproveStepsList = systemConfigService.findHiringApproveStepsAll();
List<AclPractitionerHiringApproveRecords> hiringApproveRecordsList = new ArrayList<>();
//当approvalIdentity=0时需要保存两条记录
if (approvalIdentity == 0L || approvalIdentity == 1L){
boolean hasStepSeq = addStepToList(requestVO,1,hiringApproveStepsList,hiringApproveRecordsList);
if (approvalIdentity == 0L || approvalIdentity == 1L) {
boolean hasStepSeq = addStepToList(requestVO, 1, hiringApproveStepsList, hiringApproveRecordsList);
if (!hasStepSeq) {
responseVO.setCommonResult(new CommonResult(false, ZHBErrorConfig.getErrorInfo("830025")));
return responseVO;
}
}
if (approvalIdentity == 0L || approvalIdentity == 2L){
boolean hasStepSeq = addStepToList(requestVO,2,hiringApproveStepsList,hiringApproveRecordsList);
if (approvalIdentity == 0L || approvalIdentity == 2L) {
boolean hasStepSeq = addStepToList(requestVO, 2, hiringApproveStepsList, hiringApproveRecordsList);
if (!hasStepSeq) {
responseVO.setCommonResult(new CommonResult(false, ZHBErrorConfig.getErrorInfo("830025")));
return responseVO;
......@@ -678,6 +683,65 @@ public class PractitionerHiringServiceImpl implements PractitionerHiringService
return resp;
}
@Override
public GeneratePDFResponseVO generatePDF(GeneratePDFRequestVO requestVO) {
GeneratePDFResponseVO resp = new GeneratePDFResponseVO();
try {
Long hiringBasicInfoId = requestVO.getHiringBasicInfoId();
Long practitionerId = requestVO.getPractitionerId();
if (hiringBasicInfoId == null) {
resp.setCommonResult(new CommonResult(true, "此经纪人无电子合同"));
return resp;
}
AclPractitioner practitioner = aclPractitionerMapper.selectByPrimaryKey(practitionerId);
String practitionerCode = practitioner == null ? null : practitioner.getPractitionerCode();
String contractNo = practitioner == null ? null : practitioner.getContractNo();
if (StringUtils.isEmpty(practitionerCode) || StringUtils.isEmpty(contractNo)) {
resp.setCommonResult(new CommonResult(true, "内部编号和员工合同编号不能为空,请注意保存"));
return resp;
}
String contractOssPath = hiringContractService.generatePractitionerContract(practitionerCode, contractNo, hiringBasicInfoId);
//4、经纪人表生成经纪人记录ag_acl_practitioner,ag_acl_practitioner.contract_oss_path
// 经纪人经纪人类型级别定义表ag_acl_practitioner_setting
AclPractitioner updateObj = new AclPractitioner();
updateObj.setId(practitionerId);
updateObj.setContractOssPath(contractOssPath);
aclPractitionerMapper.updateByPrimaryKeySelective(updateObj);
resp.setCommonResult(new CommonResult(true, ZHBErrorConfig.getErrorInfo("800000")));
resp.setContractOssPath(contractOssPath);
} catch (Exception e) {
e.printStackTrace();
resp.setCommonResult(new CommonResult(false, e.getMessage()));
}
return resp;
}
@Override
public QueryPractitionerInfoResponseVO queryPractitionerInfo(QueryPractitionerInfoRequestVO requestVO) {
QueryPractitionerInfoResponseVO resp = new QueryPractitionerInfoResponseVO();
try {
Long practitionerId = requestVO.getPractitionerId();
if (practitionerId == null) {
resp.setCommonResult(new CommonResult(false, "practitionerId不能为空"));
} else {
AclPractitioner practitioner = aclPractitionerMapper.selectByPrimaryKey(practitionerId);
resp.setCommonResult(new CommonResult(true, ZHBErrorConfig.getErrorInfo("800000")));
resp.setPractitioner(practitioner);
}
} catch (Exception e) {
e.printStackTrace();
resp.setCommonResult(new CommonResult(false, e.getMessage()));
}
return resp;
}
@SuppressWarnings("unchecked")
private boolean addStepToList(HiringApproveRequestVO requestVO,
int stepSeq,
......@@ -731,7 +795,7 @@ public class PractitionerHiringServiceImpl implements PractitionerHiringService
private String generateKey(int targetUseFor) {
SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd");
return targetUseFor+sdf.format(new Date());
return targetUseFor + sdf.format(new Date());
}
}
......@@ -3,7 +3,7 @@ package com.yd.api.practitioner.vo.hiring;
import lombok.Data;
@Data
public class HiringPDFRequestVO {
public class GeneratePDFRequestVO {
/**
* 经纪人id
*/
......
package com.yd.api.practitioner.vo.hiring;
import com.yd.api.result.CommonResult;
import lombok.Data;
@Data
public class GeneratePDFResponseVO {
private CommonResult commonResult;
private String contractOssPath;
}
package com.yd.api.practitioner.vo.hiring;
import lombok.Data;
@Data
public class QueryPractitionerInfoRequestVO {
/**
* 经纪人id
*/
private Long practitionerId;
}
package com.yd.api.practitioner.vo.hiring;
import com.yd.api.result.CommonResult;
import com.yd.dal.entity.customer.AclPractitioner;
import lombok.Data;
@Data
public class QueryPractitionerInfoResponseVO {
private CommonResult commonResult;
private AclPractitioner practitioner;
}
......@@ -202,5 +202,20 @@ public class AclPractitioner implements Serializable {
*/
private Integer gender;
/**
* 经纪人合同号
*/
private String contractNo;
/**
* 经纪人PDF合同地址
*/
private String contractOssPath;
/**
* 经纪人报聘信息表id
*/
private String hiringBasicInfoId;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
......@@ -41,6 +41,9 @@
<result column="mentor_id" jdbcType="BIGINT" property="mentorId" />
<result column="introducer_id" jdbcType="BIGINT" property="introducerId" />
<result column="gender" jdbcType="INTEGER" property="gender" />
<result column="contract_no" jdbcType="VARCHAR" property="contractNo" />
<result column="contract_oss_path" jdbcType="VARCHAR" property="contractOssPath" />
<result column="hiring_basic_info_id" jdbcType="BIGINT" property="hiringBasicInfoId" />
</resultMap>
<sql id="Base_Column_List">
id, insurer_id, insurer_branch_id, dept_id, subordinate_system_id, practitioner_code,
......@@ -48,7 +51,8 @@
practitioner_reg_company, effective_start_date, effective_end_date, remark, customer_id,
employee_no, is_active, created_at, created_by, updated_at, updated_by, province_id,
province_name, city_id, city_name, cert_list, bio_intro, wechat_id, qq_id, is_profile_show,
is_name_show, is_mobile_show, education_level, mentor_id, introducer_id, gender
is_name_show, is_mobile_show, education_level, mentor_id, introducer_id, gender,
contract_no, contract_oss_path, hiring_basic_info_id
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
......@@ -442,6 +446,15 @@
<if test="gender != null">
gender = #{gender,jdbcType=INTEGER},
</if>
<if test="contractNo != null">
contract_no = #{contractNo,jdbcType=INTEGER},
</if>
<if test="contractOssPath != null">
contract_oss_path = #{contractOssPath,jdbcType=INTEGER},
</if>
<if test="hiringBasicInfoId != null">
hiring_basic_info_id = #{hiringBasicInfoId,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
......
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