Commit eb656d8d authored by huangcb's avatar huangcb

调整接口:货主与平台的电子合同-司机签订

parent f6249cc5
......@@ -312,6 +312,8 @@ public class ErrorMessageComponent {
@Value("${error-message.contract.online.goods-owner.sign.1001}")
private String contractOnlineGoodsOwnerSign1001;
@Value("${error-message.contract.online.goods-owner.sign.1002}")
private String contractOnlineGoodsOwnerSign1002;
@Value("${error-message.contract.online.driver.sign.1001}")
private String contractOnlineDriverSign1001;
......
......@@ -25,6 +25,11 @@ public class ContractOnlineRecordSignGoodsOwnerForm {
*/
@NotNull(message = "参数goodsOwnerId不能为空")
private Long goodsOwnerId;
/**
* 货主签名数据Id
*/
@NotBlank(message = "参数signId不能为空")
private String signId;
/**
* 业务编号(订单号或运单号)
*/
......@@ -97,11 +102,6 @@ public class ContractOnlineRecordSignGoodsOwnerForm {
@Length(max = 50, message = "参数depositCharge长度不合法")
@NotBlank(message = "参数depositCharge不能为空")
private String depositCharge;
/**
* 货主签名数据,base64编码
*/
@NotBlank(message = "参数signData不能为空")
private String signData;
@Override
public String toString() {
......
......@@ -114,6 +114,11 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
if (null == accountInfo) {
throw new EException(1001, errorMessageComponent.getContractOnlineGoodsOwnerSign1001());
}
String goodsOwnerSignData = this.getSignData(form.getSignId());
byte[] goodsOwnerSignBytes = Base64.getDecoder().decode(goodsOwnerSignData);
if (!FileUtils.isValidImage(goodsOwnerSignBytes)) {
throw new EException(1002, errorMessageComponent.getContractOnlineGoodsOwnerSign1002());
}
// 2:获取电子合同模板数据
String contractTemplateData = this.getContractOnlineTemplateEntity(ContractConstants.CONTRACT_TYPE_GOODS_OWNER);
......@@ -126,7 +131,7 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
XWPFTemplate template = null;
try {
template = XWPFTemplate.compile(InputStreamUtils.byte2InputStream(contractTemplateBytes));
pojo = this.getGoodsOwnerSignDataMap(form, accountInfo);
pojo = this.getGoodsOwnerSignDataMap(goodsOwnerSignBytes, form, accountInfo);
template.render(pojo);
template.write(byteArrayOutputStream);
byteArrayOutputStream.flush();
......@@ -187,7 +192,7 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
if (null == accountInfo) {
throw new EException(1001, errorMessageComponent.getContractOnlineDriverSign1001());
}
String driverSignData = this.getDriverSignData(form.getSignId());
String driverSignData = this.getSignData(form.getSignId());
byte[] driverSignBytes = Base64.getDecoder().decode(driverSignData);
if (!FileUtils.isValidImage(driverSignBytes)) {
throw new EException(1002, errorMessageComponent.getContractOnlineDriverSign1002());
......@@ -297,12 +302,12 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
/**
* description 获取货主签订合同时的数据
* param [form, accountInfo]
* param [signBytes, form, accountInfo]
* return java.util.Map<java.lang.String,java.lang.Object>
* author Administrator
* createTime 2020/05/21 19:32
**/
private ContractOnlineGoodsOwnerPojo getGoodsOwnerSignDataMap(ContractOnlineRecordSignGoodsOwnerForm form, AccountInfoDto accountInfo) {
private ContractOnlineGoodsOwnerPojo getGoodsOwnerSignDataMap(byte[] signBytes, ContractOnlineRecordSignGoodsOwnerForm form, AccountInfoDto accountInfo) {
ContractOnlineGoodsOwnerPojo pojo = new ContractOnlineGoodsOwnerPojo();
BeanUtils.copyProperties(form, pojo);
......@@ -331,7 +336,7 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
pojo.setPlatformName("{{platformName}}");
pojo.setPlatformId("{{platformId}}");
pojo.setEffectiveTime("{{effectiveTime}}");
pojo.setGoodsOwnerSignImg(new PictureRenderData(CUSTOMER_SIGN_WIDTH, CUSTOMER_SIGN_HEIGHT, ".png", Base64.getDecoder().decode(form.getSignData())));
pojo.setGoodsOwnerSignImg(new PictureRenderData(CUSTOMER_SIGN_WIDTH, CUSTOMER_SIGN_HEIGHT, ".png", signBytes));
pojo.setPlatformFreightSealImg("{{@platformFreightSealImg}}");
return pojo;
......@@ -339,12 +344,12 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
/**
* description 获取司机签订合同时的数据
* param [driverSignBytes, form, accountInfo]
* param [signBytes, form, accountInfo]
* return com.esv.freight.customer.module.contract.pojo.ContractOnlineDriverPojo
* author Administrator
* createTime 2020/05/26 15:16
**/
private ContractOnlineDriverPojo getDriverSignDataMap(byte[] driverSignBytes, ContractOnlineRecordSignDriverForm form, DriverDetailDto accountInfo) {
private ContractOnlineDriverPojo getDriverSignDataMap(byte[] signBytes, ContractOnlineRecordSignDriverForm form, DriverDetailDto accountInfo) {
ContractOnlineDriverPojo pojo = new ContractOnlineDriverPojo();
BeanUtils.copyProperties(form, pojo);
......@@ -368,7 +373,7 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
pojo.setPlatformName("{{platformName}}");
pojo.setPlatformId("{{platformId}}");
pojo.setEffectiveTime("{{effectiveTime}}");
pojo.setDriverSignImg(new PictureRenderData(CUSTOMER_SIGN_WIDTH, CUSTOMER_SIGN_HEIGHT, ".png", driverSignBytes));
pojo.setDriverSignImg(new PictureRenderData(CUSTOMER_SIGN_WIDTH, CUSTOMER_SIGN_HEIGHT, ".png", signBytes));
pojo.setPlatformFreightSealImg("{{@platformFreightSealImg}}");
return pojo;
......@@ -518,17 +523,17 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
}
/**
* 获取司机签名数据
* 获取签名数据
**/
private String getDriverSignData(String fileId) {
private String getSignData(String fileId) {
JSONObject feignReqJson = new JSONObject();
feignReqJson.put("id", fileId);
JSONObject feignResJson;
try {
feignResJson = FeignUtils.getFeignResultData(feignFileService.getFileData(feignReqJson));
} catch (Exception e) {
log.error("调用[文件服务]获取司机签名数据失败:{}", e.getMessage(), e);
throw new EException("生成电子合同失败[获取司机签名数据失败]");
log.error("调用[文件服务]获取签名数据失败:{}", e.getMessage(), e);
throw new EException("生成电子合同失败[获取签名数据失败]");
}
return feignResJson.getString("fileData");
......
......@@ -31,7 +31,7 @@ public class AppFrontRcvServlet extends HttpServlet {
* createTime 2020/06/02 19:28
**/
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws IOException {
protected void service(HttpServletRequest req, HttpServletResponse resp) {
Map<String, String> reqParam = this.getAllRequestParam(req);
log.info(reqParam.toString());
......
......@@ -270,10 +270,11 @@ error-message:
goods-owner:
sign:
1001: 无效的货主ID
1002: 无效的签名
driver:
sign:
1001: 无效的司机ID
1002: 无效的司机签名
1002: 无效的签名
platform:
sign:
1001: 无效的合同编号
......
......@@ -270,10 +270,11 @@ error-message:
goods-owner:
sign:
1001: 无效的货主ID
1002: 无效的签名
driver:
sign:
1001: 无效的司机ID
1002: 无效的司机签名
1002: 无效的签名
platform:
sign:
1001: 无效的合同编号
......
......@@ -8,7 +8,6 @@ import com.esv.freight.customer.module.contract.form.ContractOnlineRecordQueryFo
import com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignDriverForm;
import com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignGoodsOwnerForm;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.junit.Assert;
import org.junit.FixMethodOrder;
import org.junit.Test;
......@@ -24,11 +23,6 @@ import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.transaction.annotation.Transactional;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Base64;
/**
* @description:
* @project: freight-customer-service
......@@ -68,10 +62,8 @@ public class ContractOnlineRecordControllerTest extends BaseTestController {
form.setReceiveTime("2020-05-28 18:00:00");
form.setFreightCharge("500");
form.setDepositCharge("0");
String filepath = "D:\\test\\张志臣-签名.PNG";
File signFile = new File(filepath);
InputStream input = new FileInputStream(signFile);
form.setSignData(Base64.getEncoder().encodeToString(IOUtils.toByteArray(input)));
String signId = "5ee2161a6069f62ff8ee9b13";
form.setSignId(signId);
MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url)
.contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
......@@ -112,10 +104,8 @@ public class ContractOnlineRecordControllerTest extends BaseTestController {
form.setReceiveTime("2020-05-28 18:00:00");
form.setFreightCharge("500");
form.setDepositCharge("0");
String filepath = "D:\\test\\何锋.jpg";
File signFile = new File(filepath);
InputStream input = new FileInputStream(signFile);
form.setSignData(Base64.getEncoder().encodeToString(IOUtils.toByteArray(input)));
String signId = "5ee2161a6069f62ff8ee9b13";
form.setSignId(signId);
MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url)
.contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
......
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