Commit c5d34da6 by jianan

客户告知书2

parent 85542eee
......@@ -3,9 +3,7 @@ package com.yd.api.practitioner;
import com.yd.api.practitioner.service.PractitionerBasicInfoService;
import com.yd.api.practitioner.service.PractitionerService;
import com.yd.api.practitioner.service.ScheduleTrackService;
import com.yd.api.practitioner.vo.informed.QueryInformedSheetByIdResponseVO;
import com.yd.api.practitioner.vo.informed.SaveInformedSheetRequestVO;
import com.yd.api.practitioner.vo.informed.UpdateInformedSheetByIdRequestVO;
import com.yd.api.practitioner.vo.informed.*;
import com.yd.api.practitioner.vo.login.CanSeeSalaryListResponseVO;
import com.yd.api.practitioner.vo.login.PractitionerLoginRequestVO;
import com.yd.api.practitioner.vo.login.PractitionerLoginResponseVO;
......@@ -696,10 +694,19 @@ public class PractitionerController {
return result;
}
@RequestMapping("/updateInformedSheetById")
public Object updateInformedSheetById(@RequestBody UpdateInformedSheetByIdRequestVO requestVO) {
@RequestMapping("/signInformedSheet")
public Object signInformedSheet(@RequestBody SignInformedSheetRequestVO requestVO) {
JsonResult result = new JsonResult();
CommonResultIDResponseVO responseVO = practitionerService.updateInformedSheetById(requestVO);
CommonResultIDResponseVO responseVO = practitionerService.signInformedSheet(requestVO);
result.addResult(responseVO);
result.setData(responseVO);
return result;
}
@RequestMapping("/queryInformedSheetList")
public Object queryInformedSheetList(@RequestBody QueryInformedSheetListRequestVO requestVO) {
JsonResult result = new JsonResult();
QueryInformedSheetListResponseVO responseVO = practitionerService.queryInformedSheetList(requestVO);
result.addResult(responseVO);
result.setData(responseVO);
return result;
......
package com.yd.api.practitioner.service;
import com.yd.api.practitioner.vo.informed.QueryInformedSheetByIdResponseVO;
import com.yd.api.practitioner.vo.informed.SaveInformedSheetRequestVO;
import com.yd.api.practitioner.vo.informed.UpdateInformedSheetByIdRequestVO;
import com.yd.api.practitioner.vo.informed.*;
import com.yd.api.practitioner.vo.login.CanSeeSalaryListResponseVO;
import com.yd.api.practitioner.vo.login.PractitionerLoginRequestVO;
import com.yd.api.practitioner.vo.login.PractitionerLoginResponseVO;
......@@ -256,4 +254,8 @@ public interface PractitionerService {
QueryInformedSheetByIdResponseVO queryInformedSheetById(IDRequestVO requestVO);
CommonResultIDResponseVO updateInformedSheetById(UpdateInformedSheetByIdRequestVO requestVO);
CommonResultIDResponseVO signInformedSheet(SignInformedSheetRequestVO requestVO);
QueryInformedSheetListResponseVO queryInformedSheetList(QueryInformedSheetListRequestVO requestVO);
}
......@@ -546,6 +546,9 @@ public class PractitionerHiringContractServiceImpl implements PractitionerHiring
}
//获取头像流
InputStream inputStream = (InputStream) input.get("is");
if (null == inputStream) {
return null;
}
String filePath = localDirectory + filename;
byte[] data = new byte[1024];
......
......@@ -2,12 +2,12 @@ package com.yd.api.practitioner.service.impl;
import com.github.pagehelper.PageHelper;
import com.google.common.base.Strings;
import com.libs.pdf.PDFTemplate;
import com.yd.api.customer.service.CustomerService;
import com.yd.api.customer.vo.register.RegisterRequestVO;
import com.yd.api.customer.vo.register.RegisterResponseVO;
import com.yd.api.practitioner.vo.informed.QueryInformedSheetByIdResponseVO;
import com.yd.api.practitioner.vo.informed.SaveInformedSheetRequestVO;
import com.yd.api.practitioner.vo.informed.UpdateInformedSheetByIdRequestVO;
import com.yd.api.practitioner.vo.hiring.CommonResultResponseVO;
import com.yd.api.practitioner.vo.informed.*;
import com.yd.api.practitioner.vo.login.CanSeeSalaryListResponseVO;
import com.yd.api.practitioner.vo.login.PractitionerLoginBasicInfo;
import com.yd.api.practitioner.vo.login.PractitionerLoginRequestVO;
......@@ -67,9 +67,11 @@ import com.yd.rmi.tencent.wechatinterf.pojo.ticket.TicketRequest;
import com.yd.rmi.tencent.wechatinterf.pojo.token.TokenRequest;
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.beanutils.BeanPropertyValueEqualsPredicate;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -3555,7 +3557,7 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
// 数据库实体
AgPoInformed informed = new AgPoInformed();
BeanUtils.copyProperties(requestVO, informed);
informed.setStatus("0");
informed.setIsActive(1);
Date curDate = new Date();
......@@ -3620,4 +3622,197 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
}
return resp;
}
@Override
public CommonResultIDResponseVO signInformedSheet(SignInformedSheetRequestVO requestVO) {
CommonResultIDResponseVO resp = new CommonResultIDResponseVO();
Long id = requestVO.getId();
String imgStr = requestVO.getImgStr();
try {
if (StringUtils.isBlank(imgStr)) {
resp.setCommonResult(new CommonResult(false, "file不可为空"));
return resp;
}
if (imgStr.indexOf("data:image/png;") != -1) {
imgStr = imgStr.replace("data:image/png;base64,", "");
}
byte[] fileBytes = Base64.getDecoder().decode(imgStr);
InputStream inputStream = new ByteArrayInputStream(fileBytes);
// 上传图片至阿里云
StringBuffer fileName = new StringBuffer();
fileName.append("InformedSheet/").append(id).append("/");
String originalFilename = generateKey(10);
String key = fileName.append(originalFilename).append(".png").toString();
String putFileToOss = ossService.putFileToOss(null, key, inputStream);
// 保存入库
AgPoInformed informed = informedMapper.selectByPrimaryKey(requestVO.getId());
informed.setId(id);
informed.setSignOssPath(putFileToOss);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
String signDate = format.format(new Date());
informed.setSignDate(signDate);
informed.setStatus("1");
informedMapper.updateByPrimaryKeySelective(informed);
resp.setCommonResult(new CommonResult(true, ZHBErrorConfig.getErrorInfo("800000")));
// 生成pdf
new Thread(new Runnable() {
private String getImgTolocal(String localDirectory, String filename, String imgUrl) {
Map<String, Object> input = HttpUtil.getInput(imgUrl);
if (!(boolean) input.get("success")) {
return null;
}
//获取头像流
InputStream inputStream = (InputStream) input.get("is");
if (null == inputStream) {
return null;
}
String filePath = localDirectory + filename;
byte[] data = new byte[1024];
int len = 0;
FileOutputStream fileOutputStream = null;
try {
fileOutputStream = new FileOutputStream(filePath);
while ((len = inputStream.read(data)) != -1) {
fileOutputStream.write(data, 0, len);
}
return filePath;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (fileOutputStream != null) {
try {
fileOutputStream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
return null;
}
private String putContractFileToOSS(String businessType, String file, Long recordId) throws Exception {
StringBuffer directory = new StringBuffer();
directory.append(businessType).append("/").append(recordId).append("/");
File tempFile =new File(file.trim());
//数据源不存在
if(!tempFile.exists()) {
throw new RuntimeException("目标文件地址不存在!");
}
//非文件类型
if(!tempFile.isFile()) {
throw new RuntimeException("目标文件不是文件类型!");
}
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;
}
@Override
public void run() {
AgPoInformed informed = informedMapper.selectByPrimaryKey(requestVO.getId());
if (informed != null) {
String templatePDF = PDFConfiguration.getProperty("informed.pdf.template");
//模板文件生成临时文件目录
String tmpPathPDF = PDFConfiguration.getProperty("informed.pdf.temp.path");
//PDF模板输出结果文件
String templateResultPDF = tmpPathPDF + informed.getId() + "-signedInformed.pdf";
//填充数据
Map<String, String> initDatas = new HashMap<>();
Map<String, String> initImages = new HashMap<>();
//下载图片
String signPicture = this.getImgTolocal(tmpPathPDF,"sign.png", informed.getSignOssPath());
initImages.put("p_name", signPicture);
String pDate = informed.getSignDate();
initDatas.put("p_date", pDate);
//按模板填充数据生成结果PDF
PDFTemplate.generatePDF(templatePDF, templateResultPDF, initDatas, initImages);
try {
//上传至oss ossService
String ossPath = this.putContractFileToOSS("informed", templateResultPDF, informed.getId());
informed.setInformedOssPath(ossPath);
informedMapper.updateByPrimaryKeySelective(informed);
}catch (Exception e) {
e.printStackTrace();
}
}
}
}).start();
} catch (Exception e) {
e.printStackTrace();
resp.setCommonResult(new CommonResult(false, "保存失败"));
}
return resp;
}
@Override
public QueryInformedSheetListResponseVO queryInformedSheetList(QueryInformedSheetListRequestVO requestVO) {
QueryInformedSheetListResponseVO resp = new QueryInformedSheetListResponseVO();
try {
AgPoInformed informed = new AgPoInformed();
BeanUtils.copyProperties(requestVO, informed);
List<AgPoInformed> list = informedMapper.selectByRecord(informed);
resp.setList(list);
resp.setCommonResult(new CommonResult(true, ZHBErrorConfig.getErrorInfo("800000")));
} catch (Exception e) {
e.printStackTrace();
resp.setCommonResult(new CommonResult(false, e.getMessage()));
}
return resp;
}
}
package com.yd.api.practitioner.vo.informed;
import lombok.Data;
@Data
public class QueryInformedSheetListRequestVO {
private Long practitionerId;
private String customerName;
private String customerMobile;
private String policyNo;
private String signDate;
}
package com.yd.api.practitioner.vo.informed;
import com.yd.api.result.CommonResult;
import com.yd.dal.entity.customer.AgPoInformed;
import lombok.Data;
import java.util.List;
@Data
public class QueryInformedSheetListResponseVO {
private CommonResult commonResult;
private List<AgPoInformed> list;
}
package com.yd.api.practitioner.vo.informed;
import lombok.Data;
@Data
public class SignInformedSheetRequestVO {
private Long id;
private String imgStr;
}
......@@ -59,6 +59,11 @@ public class AgPoInformed implements Serializable {
private String signDate;
/**
* 客户签名url
*/
private String signOssPath;
/**
* 签署状态, 0=未签署; 1=已签署;
*/
private String status;
......@@ -313,4 +318,12 @@ public class AgPoInformed implements Serializable {
sb.append("]");
return sb.toString();
}
public String getSignOssPath() {
return signOssPath;
}
public void setSignOssPath(String signOssPath) {
this.signOssPath = signOssPath;
}
}
\ No newline at end of file
......@@ -2,6 +2,8 @@ package com.yd.dal.mapper.customer;
import com.yd.dal.entity.customer.AgPoInformed;
import java.util.List;
public interface AgPoInformedMapper {
int deleteByPrimaryKey(Long id);
......@@ -14,4 +16,6 @@ public interface AgPoInformedMapper {
int updateByPrimaryKeySelective(AgPoInformed record);
int updateByPrimaryKey(AgPoInformed record);
List<AgPoInformed> selectByRecord(AgPoInformed record);
}
\ No newline at end of file
......@@ -226,4 +226,25 @@
updated_by = #{updatedBy,jdbcType=BIGINT}
where id = #{id,jdbcType=BIGINT}
</update>
<select id="selectByRecord" parameterType="com.yd.dal.entity.customer.AgPoInformed" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from ag_po_informed
where 1=1
<if test="customerName != null">
and customer_name = #{customerName,jdbcType=VARCHAR}
</if>
<if test="customerMobile != null">
and customer_mobile = #{customerMobile,jdbcType=VARCHAR}
</if>
<if test="updatedAt != null">
and practitioner_id = #{updatedAt,jdbcType=BIGINT}
</if>
<if test="policyNo != null">
and policy_no = #{policyNo,jdbcType=VARCHAR}
</if>
<if test="signDate != null">
and sign_date = #{signDate,jdbcType=VARCHAR}
</if>
</select>
</mapper>
\ No newline at end of file
......@@ -8,9 +8,13 @@ pdf.uncheck=/opt/tomcat8/conf/ydpdf/pdfres/uncheck.png
pdf.temp.path=/opt/tomcat8/temp/
pdf.firstParty=上海银盾保险经纪有限公司
pdf.firstParty=\u4E0A\u6D77\u94F6\u76FE\u4FDD\u9669\u7ECF\u7EAA\u6709\u9650\u516C\u53F8
pdf.firstPartyResponser=Wan Shuang Lian
pdf.firstPartyAddress=上海市浦东新区张杨路560号中融恒瑞国际西楼1706室
pdf.firstPartyAddress=\u4E0A\u6D77\u5E02\u6D66\u4E1C\u65B0\u533A\u5F20\u6768\u8DEF560\u53F7\u4E2D\u878D\u6052\u745E\u56FD\u9645\u897F\u697C1706\u5BA4
pdf.position.x=450
pdf.position.y=150
#\u5BA2\u6237\u544A\u77E5\u4E66\u76EE\u5F55
informed.pdf.template=/opt/tomcat8/conf/ydpdf/informed/templateInformed.pdf
informed.pdf.temp.path=/opt/tomcat8/conf/ydpdf/informed
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