Commit 7aef434a authored by huangcb's avatar huangcb

新增接口:货主与平台的电子合同-货主签订

parent f8f980d1
<?xml version="1.0" encoding="utf-8"?><fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"><ns2:layout-master-set xmlns:ns2="http://www.w3.org/1999/XSL/Format" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" xmlns:w16cid="http://schemas.microsoft.com/office/word/2016/wordml/cid" xmlns:w16se="http://schemas.microsoft.com/office/word/2015/wordml/symex" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"><ns2:simple-page-master margin-bottom="17mm" margin-left="1.25in" margin-right="1.25in" margin-top="15mm" master-name="s1-simple" page-height="297mm" page-width="210mm"><ns2:region-body column-count="1" column-gap="0.3in" margin-bottom="420.0pt" margin-left="0mm" margin-right="0mm" margin-top="420.0pt"/><ns2:region-before extent="420.0pt" region-name="xsl-region-before-simple"/><ns2:region-after extent="420.0pt" region-name="xsl-region-after-simple"/></ns2:simple-page-master><ns2:page-sequence-master master-name="s1"><ns2:repeatable-page-master-alternatives><ns2:conditional-page-master-reference master-reference="s1-simple"/></ns2:repeatable-page-master-alternatives></ns2:page-sequence-master></ns2:layout-master-set><fo:page-sequence force-page-count="no-force" id="section_s1" format="" master-reference="s1"><fo:static-content flow-name="xsl-footnote-separator"><fo:block><fo:leader rule-thickness="0.5pt" rule-style="solid" leader-length="100%" leader-pattern="rule"/></fo:block></fo:static-content><fo:flow flow-name="xsl-region-body"><fo:block break-before="auto" space-after="14mm" space-before="14mm" text-align="justify"><inline xmlns="http://www.w3.org/1999/XSL/Format" font-size="48.0pt"><inline font-family="等线">BODY CONTENT</inline></inline></fo:block><fo:block break-before="auto" space-after="14mm" space-before="14mm" text-align="justify"><inline xmlns="http://www.w3.org/1999/XSL/Format" font-size="48.0pt"><inline font-family="等线">BODY CONTENT</inline></inline></fo:block><fo:block break-before="auto" space-after="14mm" space-before="14mm" text-align="justify"><inline xmlns="http://www.w3.org/1999/XSL/Format" font-size="48.0pt"><inline font-family="等线">BODY CONTENT</inline></inline></fo:block><fo:block break-before="auto" space-after="14mm" space-before="14mm" text-align="justify"><inline xmlns="http://www.w3.org/1999/XSL/Format" font-size="48.0pt"><inline font-family="等线">BODY CONTENT</inline></inline></fo:block>
</fo:flow></fo:page-sequence></fo:root>
\ No newline at end of file
......@@ -110,6 +110,28 @@
<artifactId>cglib</artifactId>
<version>3.3.0</version>
</dependency>
<!-- Word模板引擎 -->
<dependency>
<groupId>com.deepoove</groupId>
<artifactId>poi-tl</artifactId>
<version>1.7.3</version>
</dependency>
<!-- word转pdf -->
<dependency>
<groupId>org.docx4j</groupId>
<artifactId>docx4j</artifactId>
<version>6.1.2</version>
</dependency>
<dependency>
<groupId>org.docx4j</groupId>
<artifactId>docx4j-export-fo</artifactId>
<version>8.1.6</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.20</version>
</dependency>
<dependency>
<groupId>com.esv.platform</groupId>
<artifactId>gateway-common</artifactId>
......
package com.esv.freight.customer.common.component;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.common.component.ApplicationLoadRunner
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/22 14:57
* @version:1.0
*/
@Slf4j
@Component
public class ApplicationLoadRunner implements ApplicationRunner {
@Value("${spring.application.name}")
private String applicationName;
@Override
public void run(ApplicationArguments var) {
log.info("-------------------- [{}]初始化完成 --------------------", applicationName);
}
}
......@@ -5,6 +5,7 @@ import com.esv.freight.customer.common.response.ECode;
import com.esv.freight.customer.feign.FeignBaseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
/**
......@@ -20,12 +21,15 @@ import org.springframework.stereotype.Component;
@Slf4j
public class BaseDataComponent {
@Value("${spring.application.name}")
private String applicationName;
private FeignBaseService feignBaseService;
private RedisComponent redisComponent;
public static final String ALL_REGION_MAP_CACHE_KEY = "freight-customer-service::base-data::city::allMap";
public static final Long ALL_REGION_MAP_CACHE_TIME = 36000L;
private static final String ALL_REGION_MAP_CACHE_KEY = "::base-data::city::allMap";
private static final Long ALL_REGION_MAP_CACHE_TIME = 36000L;
@Autowired
public BaseDataComponent(FeignBaseService feignBaseService, RedisComponent redisComponent) {
......@@ -42,14 +46,14 @@ public class BaseDataComponent {
**/
public JSONObject getAllRegionMap() {
JSONObject allRegionMap = new JSONObject();
if (redisComponent.hasKey(ALL_REGION_MAP_CACHE_KEY)) {
allRegionMap = JSONObject.parseObject((String) redisComponent.get(ALL_REGION_MAP_CACHE_KEY));
if (redisComponent.hasKey(this.getAllRegionMapCacheKey())) {
allRegionMap = JSONObject.parseObject((String) redisComponent.get(this.getAllRegionMapCacheKey()));
} else {
try {
JSONObject feignResultJson = feignBaseService.getAllRegionMap(new JSONObject());
if (ECode.SUCCESS.code() == feignResultJson.getIntValue("code")) {
allRegionMap = feignResultJson.getJSONObject("data");
redisComponent.set(ALL_REGION_MAP_CACHE_KEY, allRegionMap.toJSONString(), ALL_REGION_MAP_CACHE_TIME);
redisComponent.set(this.getAllRegionMapCacheKey(), allRegionMap.toJSONString(), ALL_REGION_MAP_CACHE_TIME);
}
} catch (Exception e) {
log.error("调用[基础服务]获取全国省市行政区划(键值对)失败:" + e.getMessage());
......@@ -58,4 +62,9 @@ public class BaseDataComponent {
return allRegionMap;
}
public String getAllRegionMapCacheKey() {
return applicationName + ALL_REGION_MAP_CACHE_KEY;
}
}
......@@ -297,4 +297,7 @@ public class ErrorMessageComponent {
@Value("${error-message.contract.offline.carrier.delete.1001}")
private String contractOfflineCarrierDelete1001;
@Value("${error-message.contract.online.goods-owner.sign.1001}")
private String contractOnlineGoodsOwnerAdd1001;
}
package com.esv.freight.customer.common.util;
import lombok.extern.slf4j.Slf4j;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
/**
* @description: byte数组和InputStream的相互转换工具类
* @project: freight-customer-service
* @name: com.esv.freight.customer.common.util.InputStreamUtils
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/21 19:11
* @version:1.0
*/
@Slf4j
public class InputStreamUtils {
/**
* description byte数组转InputStream
* param [bytes]
* return java.io.InputStream
* author Administrator
* createTime 2020/05/21 19:14
**/
public static InputStream byte2InputStream(byte[] bytes) {
return new ByteArrayInputStream(bytes);
}
/**
* description InputStream转byte数组
* param [inputStream]
* return byte[]
* author Administrator
* createTime 2020/05/21 19:15
**/
public static byte[] inputStream2byte(InputStream inputStream) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] buff = new byte[100];
int rc = 0;
try {
while ((rc = inputStream.read(buff, 0, 100)) > 0) {
byteArrayOutputStream.write(buff, 0, rc);
}
} catch (IOException e) {
log.error(e.getMessage(), e);
}
return byteArrayOutputStream.toByteArray();
}
}
package com.esv.freight.customer.common.util;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.common.util.SpringUtils
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/22 14:42
* @version:1.0
*/
@Component
public class SpringUtils implements ApplicationContextAware {
private static ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContextParam) throws BeansException {
applicationContext=applicationContextParam;
}
public static Object getObject(String id) {
Object object = null;
object = applicationContext.getBean(id);
return object;
}
public static <T> T getObject(Class<T> tClass) {
return applicationContext.getBean(tClass);
}
public static Object getBean(String tClass) {
return applicationContext.getBean(tClass);
}
public <T> T getBean(Class<T> tClass) {
return applicationContext.getBean(tClass);
}
}
......@@ -2,6 +2,7 @@ package com.esv.freight.customer.feign;
import com.alibaba.fastjson.JSONObject;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
/**
......@@ -16,6 +17,16 @@ import org.springframework.web.bind.annotation.PostMapping;
@FeignClient(value = "freight-base-service")
public interface FeignBaseService {
/**
* description 连通性测试
* param []
* return com.alibaba.fastjson.JSONObject
* author Administrator
* createTime 2020/05/22 14:05
**/
@GetMapping(value = "/base/test/ping")
JSONObject pingTest();
/**
* description 生成编号
* param [bodyJson]
......@@ -35,4 +46,5 @@ public interface FeignBaseService {
**/
@PostMapping(value = "/base/geo/city/getAllRegionMap")
JSONObject getAllRegionMap(JSONObject bodyJson);
}
package com.esv.freight.customer.feign;
import com.alibaba.fastjson.JSONObject;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.feign.FeignFileService
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/17 17:56
* @version:1.0
*/
@FeignClient(value = "freight-file-service")
public interface FeignFileService {
/**
* description 连通性测试
* param []
* return com.alibaba.fastjson.JSONObject
* author Administrator
* createTime 2020/05/22 14:05
**/
@GetMapping(value = "/file/test/ping")
JSONObject pingTest();
/**
* description 上传单个文件
* param [bodyJson]
* return com.alibaba.fastjson.JSONObject
* author Administrator
* createTime 2020/05/21 16:28
**/
@PostMapping(value = "/file/upload/single")
JSONObject uploadSingleFile(JSONObject bodyJson);
/**
* description 获取文件数据
* param [bodyJson]
* return com.alibaba.fastjson.JSONObject
* author Administrator
* createTime 2020/05/21 17:59
**/
@PostMapping(value = "/file/download/getFileData")
JSONObject getFileData(JSONObject bodyJson);
}
package com.esv.freight.customer.module.contract;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.contract.ContractConstants
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/21 18:56
* @version:1.0
*/
public class ContractConstants {
/**
* 合同类型:1-货主与平台合同、2-司机与平台合同
*/
public static final Integer CONTRACT_TYPE_GOODS_OWNER = 1;
public static final Integer CONTRACT_TYPE_DRIVER = 2;
/**
* 是否使用:1使用中,2-未使用
*/
public static final Integer CONTRACT_TEMPLATE_USED_YES = 1;
public static final Integer CONTRACT_TEMPLATE_USED_NO = 2;
/**
* 合同签订完成:1-是,2-否
*/
public static final Integer CONTRACT_SIGN_COMPLETE_YES = 1;
public static final Integer CONTRACT_SIGN_COMPLETE_NO = 2;
}
package com.esv.freight.customer.module.contract.controller;
import com.esv.freight.customer.common.exception.EException;
import com.esv.freight.customer.common.response.EResponse;
import com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignGoodsOwnerForm;
import com.esv.freight.customer.module.contract.service.ContractOnlineRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.contract.controller.ContractOnlineRecordController
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/22 11:08
* @version:1.0
*/
@Slf4j
@RestController
@RequestMapping("/contract/online")
@Validated
public class ContractOnlineRecordController {
private ContractOnlineRecordService contractOnlineRecordService;
@Autowired
public ContractOnlineRecordController(ContractOnlineRecordService contractOnlineRecordService) {
this.contractOnlineRecordService = contractOnlineRecordService;
}
/**
* description 货主与平台的电子合同-货主签订
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/05/22 11:10
**/
@PostMapping("/goodsowner/sign")
public EResponse goodsOwnerSign(@RequestBody @Validated ContractOnlineRecordSignGoodsOwnerForm form) throws EException {
return EResponse.ok(contractOnlineRecordService.goodsOwnerSign(form));
}
}
package com.esv.freight.customer.module.contract.controller;
import com.alibaba.fastjson.JSONObject;
import com.esv.freight.customer.common.exception.EException;
import com.esv.freight.customer.common.response.EResponse;
import com.esv.freight.customer.common.validator.groups.ValidatorInsert;
import com.esv.freight.customer.module.contract.form.ContractOnlineTemplateForm;
import com.esv.freight.customer.module.contract.service.ContractOnlineTemplateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @description: 电子合同模板Controller
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.contract.controller.ContractOnlineTemplateController
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/21 17:07
* @version:1.0
*/
@Slf4j
@RestController
@RequestMapping("/contract/online/template")
@Validated
public class ContractOnlineTemplateController {
private ContractOnlineTemplateService contractOnlineTemplateService;
@Autowired
public ContractOnlineTemplateController(ContractOnlineTemplateService contractOnlineTemplateService) {
this.contractOnlineTemplateService = contractOnlineTemplateService;
}
/**
* description 增加电子合同模板
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/05/21 17:11
**/
@PostMapping("/add")
public EResponse add(@RequestBody @Validated(ValidatorInsert.class) ContractOnlineTemplateForm form) throws EException {
Long id = contractOnlineTemplateService.addTemplate(form);
JSONObject data = new JSONObject();
data.put("id", id);
return EResponse.ok(data);
}
}
package com.esv.freight.customer.module.contract.dao;
import com.esv.freight.customer.module.contract.entity.ContractOnlineRecordEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* 线上电子合同记录表
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-05-21 15:55:34
*/
@Mapper
public interface ContractOnlineRecordDao extends BaseMapper<ContractOnlineRecordEntity> {
}
package com.esv.freight.customer.module.contract.dao;
import com.esv.freight.customer.module.contract.entity.ContractOnlineTemplateEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* 线上电子合同模板表
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-05-21 15:55:34
*/
@Mapper
public interface ContractOnlineTemplateDao extends BaseMapper<ContractOnlineTemplateEntity> {
}
package com.esv.freight.customer.module.contract.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 线上电子合同记录表
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-05-21 15:55:34
*/
@Data
@TableName("contract_online_record")
public class ContractOnlineRecordEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
@TableId
private Long id;
/**
* 租户ID
*/
@TableField(fill = FieldFill.INSERT)
private Long tenantId;
/**
* 部门ID
*/
@TableField(fill = FieldFill.INSERT)
private Long departmentId;
/**
* 合同类型:1-货主与平台合同、2-司机与平台合同
*/
private Integer contractType;
/**
* 合同文件ID
*/
private String contractFileId;
/**
* 合同文件URL
*/
private String contractFileUrl;
/**
* 合同编号
*/
private String contractNumber;
/**
* 业务编号(订单号或运单号)
*/
private String businessNumber;
/**
* 客户(货主或司机)签订时间
*/
private Date customerSignTime;
/**
* 平台签订时间
*/
private Date platformSignTime;
/**
* 合同签订完成:1-是,2-否
*/
private Integer signComplete;
/**
* 合同生效时间
*/
private Date effectiveTime;
}
package com.esv.freight.customer.module.contract.entity;
import com.baomidou.mybatisplus.annotation.*;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 线上电子合同模板表
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-05-21 15:55:34
*/
@Data
@TableName("contract_online_template")
public class ContractOnlineTemplateEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
@TableId
private Long id;
/**
* 租户ID
*/
@TableField(fill = FieldFill.INSERT)
private Long tenantId;
/**
* 部门ID
*/
@TableField(fill = FieldFill.INSERT)
private Long departmentId;
/**
* 合同类型:1-货主与平台合同、2-司机与平台合同
*/
private Integer contractType;
/**
* 合同模板文件ID
*/
private String templateFileId;
/**
* 合同模板文件URL
*/
private String templateFileUrl;
/**
* 合同模板名称
*/
private String templateName;
/**
* 是否使用:1使用中,2-未使用
*/
private Integer used;
/**
* 创建者
*/
@TableField(fill = FieldFill.INSERT)
private String createUser;
/**
* 修改者
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private String updateUser;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
private Date createTime;
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateTime;
}
package com.esv.freight.customer.module.contract.form;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignGoodsownerForm
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/21 17:44
* @version:1.0
*/
@Data
public class ContractOnlineRecordSignGoodsOwnerForm {
/**
* 货主ID
*/
@NotNull(message = "参数goodsOwnerId不能为空")
private Long goodsOwnerId;
/**
* 业务编号(订单号或运单号)
*/
@Length(max = 50, message = "参数businessNumber长度不合法")
@NotBlank(message = "参数businessNumber不能为空")
private String businessNumber;
/**
* 货物名称
*/
@Length(max = 50, message = "参数goodsName长度不合法")
@NotBlank(message = "参数goodsName不能为空")
private String goodsName;
/**
* 货物总量
*/
@Length(max = 50, message = "参数goodsTotal长度不合法")
@NotBlank(message = "参数goodsTotal不能为空")
private String goodsTotal;
/**
* 货物单位
*/
@Length(max = 50, message = "参数goodsUnit长度不合法")
@NotBlank(message = "参数goodsUnit不能为空")
private String goodsUnit;
/**
* 货物单价
*/
@Length(max = 50, message = "参数goodsUnitPrice长度不合法")
@NotBlank(message = "参数goodsUnitPrice不能为空")
private String goodsUnitPrice;
/**
* 货物总价
*/
@Length(max = 50, message = "参数goodsTotalPrice长度不合法")
@NotBlank(message = "参数goodsTotalPrice不能为空")
private String goodsTotalPrice;
/**
* 发货地址
*/
@Length(max = 200, message = "参数deliverAddress长度不合法")
@NotBlank(message = "参数deliverAddress不能为空")
private String deliverAddress;
/**
* 收货地址
*/
@Length(max = 200, message = "参数receiveAddress长度不合法")
@NotBlank(message = "参数receiveAddress不能为空")
private String receiveAddress;
/**
* abc
*/
@Length(max = 50, message = "参数deliverTime长度不合法")
@NotBlank(message = "参数deliverTime不能为空")
private String deliverTime;
/**
* 交货时间
*/
@Length(max = 50, message = "参数receiveTime长度不合法")
@NotBlank(message = "参数receiveTime不能为空")
private String receiveTime;
/**
* 运费
*/
@Length(max = 50, message = "参数freightCharge长度不合法")
@NotBlank(message = "参数freightCharge不能为空")
private String freightCharge;
/**
* 定金
*/
@Length(max = 50, message = "参数depositCharge长度不合法")
@NotBlank(message = "参数depositCharge不能为空")
private String depositCharge;
/**
* 货主签名数据,base64编码
*/
@NotBlank(message = "参数signData不能为空")
private String signData;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
package com.esv.freight.customer.module.contract.form;
import com.esv.freight.customer.common.validator.groups.ValidatorInsert;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.contract.form.ContractOnlineTemplateForm
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/21 16:48
* @version:1.0
*/
@Data
public class ContractOnlineTemplateForm {
/**
* 合同类型:1-货主与平台合同、2-司机与平台合同
*/
@Range(min = 1, max = 2, message = "参数contractType不合法", groups = {ValidatorInsert.class})
@NotNull(message = "参数contractType不能为空", groups = {ValidatorInsert.class})
private Integer contractType;
/**
* 合同模板文件ID
*/
@Length(max = 64, message = "参数templateFileId长度不合法", groups = {ValidatorInsert.class})
@NotBlank(message = "参数templateFileId不能为空", groups = {ValidatorInsert.class})
private String templateFileId;
/**
* 合同模板文件URL
*/
@Length(max = 200, message = "参数templateFileUrl长度不合法", groups = {ValidatorInsert.class})
@NotBlank(message = "参数templateFileUrl不能为空", groups = {ValidatorInsert.class})
private String templateFileUrl;
/**
* 合同模板名称
*/
@Length(max = 50, message = "参数templateName长度不合法", groups = {ValidatorInsert.class})
@NotBlank(message = "参数templateName不能为空", groups = {ValidatorInsert.class})
private String templateName;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
package com.esv.freight.customer.module.contract.pojo;
import lombok.Data;
/**
* @description: 货主与平台签订合同的模板内容项
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.contract.pojo.ContractOnlineGoodsOwnerPojo
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/22 10:05
* @version:1.0
*/
@Data
public class ContractOnlineGoodsOwnerPojo {
/**
* 合同编号
*/
private String contactNumber;
/**
* 托运方
*/
private String goodsOwnerName;
/**
* 托运方身份证号码/组织机构代码
*/
private String goodsOwnerId;
/**
* 承运方
*/
private String platformName;
/**
* 承运方组织机构代码
*/
private String platformId;
/**
* 货物名称
*/
private String goodsName;
/**
* 货物总量
*/
private String goodsTotal;
/**
* 货物单位
*/
private String goodsUnit;
/**
* 货物单价
*/
private String goodsUnitPrice;
/**
* 货物总价
*/
private String goodsTotalPrice;
/**
* 发货地址
*/
private String deliverAddress;
/**
* 收货地址
*/
private String receiveAddress;
/**
* 发货时间
*/
private String deliverTime;
/**
* 交货时间
*/
private String receiveTime;
/**
* 本次运输运费
*/
private String freightCharge;
/**
* 预付定金
*/
private String depositCharge;
/**
* 托运方签字
*/
private Object goodsOwnerSignImg;
/**
* 承运方签字
*/
private Object platformFreightSealImg;
/**
* 生效时间
*/
private String effectiveTime;
}
package com.esv.freight.customer.module.contract.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.esv.freight.customer.module.contract.entity.ContractOnlineRecordEntity;
import com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignGoodsOwnerForm;
import com.esv.freight.customer.module.contract.vo.ContractOnlineRecordSignGoodsOwnerVO;
/**
* 线上电子合同记录表
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-05-21 15:55:34
*/
public interface ContractOnlineRecordService extends IService<ContractOnlineRecordEntity> {
/**
* description 货主与平台的电子合同-货主签订
* param [form]
* return com.esv.freight.customer.module.contract.vo.ContractOnlineRecordSignGoodsOwnerVO
* author Administrator
* createTime 2020/05/21 18:01
**/
ContractOnlineRecordSignGoodsOwnerVO goodsOwnerSign(ContractOnlineRecordSignGoodsOwnerForm form);
}
package com.esv.freight.customer.module.contract.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.esv.freight.customer.module.contract.entity.ContractOnlineTemplateEntity;
import com.esv.freight.customer.module.contract.form.ContractOnlineTemplateForm;
/**
* 线上电子合同模板表
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-05-21 15:55:34
*/
public interface ContractOnlineTemplateService extends IService<ContractOnlineTemplateEntity> {
/**
* description 增加电子合同模板
* param [form]
* return java.lang.Long
* author Administrator
* createTime 2020/05/21 17:02
**/
Long addTemplate(ContractOnlineTemplateForm form);
/**
* description 获取使用中的电子合同模板
* param [contractType]
* return com.esv.freight.customer.module.contract.entity.ContractOnlineTemplateEntity
* author Administrator
* createTime 2020/05/21 17:39
**/
ContractOnlineTemplateEntity getUsedTemplate(Integer contractType);
}
package com.esv.freight.customer.module.contract.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.esv.freight.customer.feign.FeignFileService;
import com.esv.freight.customer.module.contract.ContractConstants;
import com.esv.freight.customer.module.contract.dao.ContractOnlineTemplateDao;
import com.esv.freight.customer.module.contract.entity.ContractOnlineTemplateEntity;
import com.esv.freight.customer.module.contract.form.ContractOnlineTemplateForm;
import com.esv.freight.customer.module.contract.service.ContractOnlineTemplateService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service("contractOnlineTemplateService")
public class ContractOnlineTemplateServiceImpl extends ServiceImpl<ContractOnlineTemplateDao, ContractOnlineTemplateEntity> implements ContractOnlineTemplateService {
private FeignFileService feignFileService;
@Autowired
public ContractOnlineTemplateServiceImpl(FeignFileService feignFileService) {
this.feignFileService = feignFileService;
}
@Override
public Long addTemplate(ContractOnlineTemplateForm form) {
ContractOnlineTemplateEntity contractOnlineTemplateEntity = new ContractOnlineTemplateEntity();
BeanUtils.copyProperties(form, contractOnlineTemplateEntity);
// 默认未使用
contractOnlineTemplateEntity.setUsed(ContractConstants.CONTRACT_TEMPLATE_USED_NO);
this.baseMapper.insert(contractOnlineTemplateEntity);
return contractOnlineTemplateEntity.getId();
}
@Override
public ContractOnlineTemplateEntity getUsedTemplate(Integer contractType) {
return this.baseMapper.selectOne(new LambdaQueryWrapper<ContractOnlineTemplateEntity>()
.eq(ContractOnlineTemplateEntity::getContractType, contractType)
.eq(ContractOnlineTemplateEntity::getUsed, ContractConstants.CONTRACT_TEMPLATE_USED_YES));
}
}
\ No newline at end of file
package com.esv.freight.customer.module.contract.vo;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.contract.vo.ContractOnlineRecordSignGoodsOwnerVO
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/21 17:54
* @version:1.0
*/
@Data
public class ContractOnlineRecordSignGoodsOwnerVO {
/**
* 合同编号
*/
private String contractNumber;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
......@@ -53,10 +53,17 @@ mybatis-plus:
id-type: AUTO
logic-delete-value: 1
logic-not-delete-value: 0
hystrix:
command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 5000
ribbon:
eager-load:
enabled: true
clients: freight-base-service,freight-app-service
clients: freight-base-service,freight-file-service,freight-app-service
error-message:
goodsowner:
account:
......@@ -237,4 +244,8 @@ error-message:
1001: 无效的合同ID
1002: 合同编号已存在
delete:
1001: 无效的合同ID
\ No newline at end of file
1001: 无效的合同ID
online:
goods-owner:
sign:
1001: 无效的货主ID
\ No newline at end of file
......@@ -53,10 +53,17 @@ mybatis-plus:
id-type: AUTO
logic-delete-value: 1
logic-not-delete-value: 0
hystrix:
command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 5000
ribbon:
eager-load:
enabled: true
clients: freight-base-service,freight-app-service
clients: freight-base-service,freight-file-service,freight-app-service
error-message:
goodsowner:
account:
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.esv.freight.customer.module.contract.dao.ContractOnlineRecordDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.esv.freight.customer.module.contract.entity.ContractOnlineRecordEntity" id="contractOnlineRecordMap">
<result property="id" column="id"/>
<result property="tenantId" column="tenant_id"/>
<result property="departmentId" column="department_id"/>
<result property="contractType" column="contract_type"/>
<result property="contractFileId" column="contract_file_id"/>
<result property="contractFileUrl" column="contract_file_url"/>
<result property="contractNumber" column="contract_number"/>
<result property="businessNumber" column="business_number"/>
<result property="customerSignTime" column="customer_sign_time"/>
<result property="platformSignTime" column="platform_sign_time"/>
<result property="signComplete" column="sign_complete"/>
<result property="effectiveTime" column="effective_time"/>
</resultMap>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.esv.freight.customer.module.contract.dao.ContractOnlineTemplateDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.esv.freight.customer.module.contract.entity.ContractOnlineTemplateEntity" id="contractOnlineTemplateMap">
<result property="id" column="id"/>
<result property="tenantId" column="tenant_id"/>
<result property="departmentId" column="department_id"/>
<result property="contractType" column="contract_type"/>
<result property="templateFileId" column="template_file_id"/>
<result property="templateFileUrl" column="template_file_url"/>
<result property="templateName" column="template_name"/>
<result property="used" column="used"/>
<result property="createUser" column="create_user"/>
<result property="updateUser" column="update_user"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
</resultMap>
</mapper>
\ No newline at end of file
package com.esv.freight.customer.common.util;
import com.baomidou.mybatisplus.core.toolkit.BeanUtils;
import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.data.PictureRenderData;
import com.esv.freight.customer.module.contract.pojo.ContractOnlineGoodsOwnerPojo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.docx4j.Docx4J;
import org.docx4j.fonts.IdentityPlusMapper;
import org.docx4j.fonts.Mapper;
import org.docx4j.fonts.PhysicalFonts;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;
import java.io.File;
import java.io.FileOutputStream;
import java.util.HashMap;
import java.util.Map;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.common.util.WordTest
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/21 10:49
* @version:1.0
*/
@SpringBootTest
@Slf4j
public class WordTest {
@Test
public void simple_test() throws Exception {
String sourcePath = "D:\\test\\线上合同-货主.docx";
String targetPath = "D:\\test\\线上合同-货主-合成.docx";
String pdfPath = "D:\\test\\线上合同-货主-PDF.pdf";
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("contactNumber", System.currentTimeMillis());
dataMap.put("goodsOwnerName", "黄朝斌测试有限公司01");
dataMap.put("goodsOwnerId", "1234567890");
dataMap.put("platformName", "英思唯网络货运平台");
dataMap.put("platformId", "123422345678");
dataMap.put("goodsName", "test");
dataMap.put("goodsTotal", "test");
dataMap.put("goodsUnit", "test");
dataMap.put("goodsUnitPrice", "test");
dataMap.put("goodsTotalPrice", "test");
dataMap.put("deliverAddress", "test");
dataMap.put("receiveAddress", "test");
dataMap.put("deliverTime", "test");
dataMap.put("receiveTime", "test");
dataMap.put("freightCharge", "test");
dataMap.put("depositCharge", "test");
// dataMap.put("signTime", DateUtils.getSysdateStr());
dataMap.put("signTime", "{{signTime}}");
dataMap.put("goodsOnwerSignImg", new PictureRenderData(150, 60, "D:\\test\\何锋.jpg"));
dataMap.put("platformFreightSealImg", new PictureRenderData(203, 220, "D:\\test\\公章.jpg"));
XWPFTemplate template = XWPFTemplate.compile(sourcePath);
template.render(dataMap);
FileOutputStream out = new FileOutputStream(targetPath);
template.write(out);
out.flush();
out.close();
template.close();
FileOutputStream fileOutputStream = null;
try {
File file = new File(targetPath);
fileOutputStream = new FileOutputStream(new File(pdfPath));
WordprocessingMLPackage mlPackage = WordprocessingMLPackage.load(file);
setFontMapper(mlPackage);
Docx4J.toPDF(mlPackage, new FileOutputStream(new File(pdfPath)));
} catch (Exception e) {
e.printStackTrace();
log.error("docx文档转换为PDF失败");
} finally {
IOUtils.closeQuietly(fileOutputStream);
}
}
@Test
public void pojo_test() throws Exception {
String sourcePath = "D:\\test\\线上合同-货主.docx";
String targetPath = "D:\\test\\线上合同-货主-合成.docx";
String pdfPath = "D:\\test\\线上合同-货主-PDF.pdf";
ContractOnlineGoodsOwnerPojo pojo = new ContractOnlineGoodsOwnerPojo();
pojo.setContactNumber(String.valueOf(System.currentTimeMillis()));
pojo.setGoodsOwnerName("黄朝斌测试有限公司01");
pojo.setGoodsOwnerId("1234567890");
pojo.setPlatformName("英思唯网络货运平台");
pojo.setPlatformId("123422345678");
pojo.setGoodsName("test");
pojo.setGoodsTotal("test");
pojo.setGoodsUnit("test");
pojo.setGoodsUnitPrice("test");
pojo.setGoodsTotalPrice("test");
pojo.setDeliverAddress("test");
pojo.setDeliverTime("test");
pojo.setReceiveAddress("test");
pojo.setReceiveTime("test");
pojo.setFreightCharge("test");
pojo.setDepositCharge("test");
pojo.setEffectiveTime("{{effectiveTime}}");
pojo.setGoodsOwnerSignImg(new PictureRenderData(150, 60, "D:\\test\\何锋.jpg"));
pojo.setPlatformFreightSealImg("{{@platformFreightSealImg}}");
// Map<String, Object> dataMap = BeanUtils.beanToMap(pojo);
// dataMap.put("platformFreightSealImg", "{{@platformFreightSealImg}}");
XWPFTemplate template = XWPFTemplate.compile(sourcePath);
template.render(pojo);
FileOutputStream out = new FileOutputStream(targetPath);
template.write(out);
out.flush();
out.close();
template.close();
FileOutputStream fileOutputStream = null;
try {
File file = new File(targetPath);
fileOutputStream = new FileOutputStream(new File(pdfPath));
WordprocessingMLPackage mlPackage = WordprocessingMLPackage.load(file);
setFontMapper(mlPackage);
Docx4J.toPDF(mlPackage, new FileOutputStream(new File(pdfPath)));
} catch (Exception e) {
e.printStackTrace();
log.error("docx文档转换为PDF失败");
} finally {
IOUtils.closeQuietly(fileOutputStream);
}
}
private static void setFontMapper(WordprocessingMLPackage mlPackage) throws Exception {
Mapper fontMapper = new IdentityPlusMapper();
fontMapper.put("隶书", PhysicalFonts.get("LiSu"));
fontMapper.put("宋体", PhysicalFonts.get("SimSun"));
fontMapper.put("微软雅黑", PhysicalFonts.get("Microsoft Yahei"));
fontMapper.put("黑体", PhysicalFonts.get("SimHei"));
fontMapper.put("楷体", PhysicalFonts.get("KaiTi"));
fontMapper.put("新宋体", PhysicalFonts.get("NSimSun"));
fontMapper.put("华文行楷", PhysicalFonts.get("STXingkai"));
fontMapper.put("华文仿宋", PhysicalFonts.get("STFangsong"));
fontMapper.put("宋体扩展", PhysicalFonts.get("simsun-extB"));
fontMapper.put("仿宋", PhysicalFonts.get("FangSong"));
fontMapper.put("仿宋_GB2312", PhysicalFonts.get("FangSong_GB2312"));
fontMapper.put("幼圆", PhysicalFonts.get("YouYuan"));
fontMapper.put("华文宋体", PhysicalFonts.get("STSong"));
fontMapper.put("华文中宋", PhysicalFonts.get("STZhongsong"));
mlPackage.setFontMapper(fontMapper);
}
}
package com.esv.freight.customer.module.contract.controller;
import com.alibaba.fastjson.JSONObject;
import com.esv.freight.customer.BaseTestController;
import com.esv.freight.customer.common.response.ECode;
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;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
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
* @name: com.esv.freight.customer.module.contract.controller.ContractOnlineRecordControllerTest
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/22 11:11
* @version:1.0
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Transactional
@Rollback(false)
public class ContractOnlineRecordControllerTest extends BaseTestController {
/**
* 货主与平台的电子合同-货主签订
**/
@Test
public void a1_goodsOwnerSign_success_test() throws Exception {
String url = "/contract/online/goodsowner/sign";
// 构造数据
ContractOnlineRecordSignGoodsOwnerForm form = new ContractOnlineRecordSignGoodsOwnerForm();
form.setGoodsOwnerId(4L);
form.setBusinessNumber("DD" + System.currentTimeMillis());
form.setGoodsName("煤炭");
form.setGoodsTotal("5");
form.setGoodsUnit("吨");
form.setGoodsUnitPrice("230");
form.setGoodsTotalPrice("1150");
form.setDeliverAddress("辽宁沈阳市沈河区惠工街10号卓越大厦2710");
form.setDeliverTime("2020-05-28 11:00:00");
form.setReceiveAddress("辽宁沈阳市沈河区泉园二路85号");
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)));
MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url)
.contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
.headers(this.getDefaultHttpHeaders())
.content(form.toString()))
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().isOk())
.andReturn();
String responseStr = mvcResult.getResponse().getContentAsString();
log.info(responseStr);
JSONObject result = JSONObject.parseObject(responseStr);
Assert.assertEquals(ECode.SUCCESS.code(), result.getIntValue("code"));
Assert.assertTrue(result.getJSONObject("data").containsKey("contractNumber"));
}
/**
* 货主与平台的电子合同-货主签订:无效的货主ID
**/
@Test
@Rollback
public void a2_goodsOwnerSign_failure_test() throws Exception {
String url = "/contract/online/goodsowner/sign";
// 构造数据
ContractOnlineRecordSignGoodsOwnerForm form = new ContractOnlineRecordSignGoodsOwnerForm();
form.setGoodsOwnerId(99999L);
form.setBusinessNumber("DD" + System.currentTimeMillis());
form.setGoodsName("煤炭");
form.setGoodsTotal("5");
form.setGoodsUnit("吨");
form.setGoodsUnitPrice("230");
form.setGoodsTotalPrice("1150");
form.setDeliverAddress("辽宁沈阳市沈河区惠工街10号卓越大厦2710");
form.setDeliverTime("2020-05-28 11:00:00");
form.setReceiveAddress("辽宁沈阳市沈河区泉园二路85号");
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)));
MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url)
.contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
.headers(this.getDefaultHttpHeaders())
.content(form.toString()))
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().isOk())
.andReturn();
String responseStr = mvcResult.getResponse().getContentAsString();
log.info(responseStr);
JSONObject result = JSONObject.parseObject(responseStr);
Assert.assertEquals(1001, result.getIntValue("code"));
}
}
package com.esv.freight.customer.module.contract.controller;
import com.alibaba.fastjson.JSONObject;
import com.esv.freight.customer.BaseTestController;
import com.esv.freight.customer.common.response.ECode;
import com.esv.freight.customer.module.contract.form.ContractOnlineTemplateForm;
import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.transaction.annotation.Transactional;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.contract.controller.ContractOnlineTemplateControllerTest
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/21 17:21
* @version:1.0
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Transactional
@Rollback(false)
public class ContractOnlineTemplateControllerTest extends BaseTestController {
/**
* 新增合同
**/
@Test
public void a1_add_success_test() throws Exception {
String url = "/contract/online/template/add";
// 构造数据
ContractOnlineTemplateForm form = new ContractOnlineTemplateForm();
form.setContractType(1);
form.setTemplateFileId("5ec72b8d29c85620fcd68a03");
form.setTemplateFileUrl("http://192.168.31.248:8082/file/download/direct/F0CB59DBCA5793E9C1F9CB66A88DE74EE862D2A0706953E859324BA88B8172ED94C7B9B54577E79AAD679F3667E257C9");
form.setTemplateName("货主与平台电子合同测试模板");
MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url)
.contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
.headers(this.getDefaultHttpHeaders())
.content(form.toString()))
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().isOk())
.andReturn();
String responseStr = mvcResult.getResponse().getContentAsString();
log.info(responseStr);
JSONObject result = JSONObject.parseObject(responseStr);
Assert.assertEquals(ECode.SUCCESS.code(), result.getIntValue("code"));
Assert.assertTrue(result.getJSONObject("data").containsKey("id"));
}
}
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