Commit ba0a696f authored by huangcb's avatar huangcb

新增接口:电子合同-平台签订

parent 0b1cf3f7
*.class *.class
*.iml *.iml
*.log *.log
/*.fo
/*.iml /*.iml
/.idea/ /.idea/
/log/ /log/
......
<?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
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<alibaba-nacos-discovery.version>2.1.1.RELEASE</alibaba-nacos-discovery.version> <alibaba-nacos-discovery.version>2.1.1.RELEASE</alibaba-nacos-discovery.version>
<alibaba-nacos-config.version>2.1.1.RELEASE</alibaba-nacos-config.version> <alibaba-nacos-config.version>2.1.1.RELEASE</alibaba-nacos-config.version>
<alibaba-fastjson.version>1.2.62</alibaba-fastjson.version> <alibaba-fastjson.version>1.2.62</alibaba-fastjson.version>
<alibaba-druid.version>1.1.21</alibaba-druid.version> <alibaba-druid.version>1.1.22</alibaba-druid.version>
<apache-commons-lang3.version>3.7</apache-commons-lang3.version> <apache-commons-lang3.version>3.7</apache-commons-lang3.version>
<mybatisplus.version>3.3.1</mybatisplus.version> <mybatisplus.version>3.3.1</mybatisplus.version>
</properties> </properties>
...@@ -64,6 +64,11 @@ ...@@ -64,6 +64,11 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId> <artifactId>spring-boot-starter-data-redis</artifactId>
</dependency> </dependency>
<!--lettuce pool连接池-->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId> <artifactId>spring-cloud-starter-openfeign</artifactId>
......
...@@ -303,4 +303,7 @@ public class ErrorMessageComponent { ...@@ -303,4 +303,7 @@ public class ErrorMessageComponent {
@Value("${error-message.contract.online.get-by-number.1001}") @Value("${error-message.contract.online.get-by-number.1001}")
private String contractOnlineGetByNumber1001; private String contractOnlineGetByNumber1001;
@Value("${error-message.contract.online.goods-owner.platform-sign.1001}")
private String contractOnlineGoodsOwnerPlatformSign1001;
} }
...@@ -41,6 +41,22 @@ public class ReqUtils { ...@@ -41,6 +41,22 @@ public class ReqUtils {
} }
} }
/**
* description 获取当前请求的租户ID
* param []
* return java.lang.Long
* author Administrator
* createTime 2020/05/25 13:55
**/
public static Long getRequestTenantId() {
String userId = getRequestHeader(GatewayHeaders.TENANT_ID);
if (StringUtils.isNotBlank(userId)) {
return Long.parseLong(userId);
} else {
return null;
}
}
/** /**
* description 获取当前请求的用户帐号 * description 获取当前请求的用户帐号
* param [] * param []
......
...@@ -28,4 +28,11 @@ public class ContractConstants { ...@@ -28,4 +28,11 @@ public class ContractConstants {
*/ */
public static final Integer CONTRACT_SIGN_COMPLETE_YES = 1; public static final Integer CONTRACT_SIGN_COMPLETE_YES = 1;
public static final Integer CONTRACT_SIGN_COMPLETE_NO = 2; public static final Integer CONTRACT_SIGN_COMPLETE_NO = 2;
/**
* 平台数据是否使用:1使用中,2-未使用
*/
public static final Integer CONTRACT_PLATFORM_DATA_USED_YES = 1;
public static final Integer CONTRACT_PLATFORM_DATA_USED_NO = 2;
} }
...@@ -48,6 +48,19 @@ public class ContractOnlineRecordController { ...@@ -48,6 +48,19 @@ public class ContractOnlineRecordController {
return EResponse.ok(contractOnlineRecordService.goodsOwnerSign(form)); return EResponse.ok(contractOnlineRecordService.goodsOwnerSign(form));
} }
/**
* description 电子合同-平台签订
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/05/25 11:25
**/
@PostMapping("/platformSign")
public EResponse platformSign(@RequestBody @Validated(ValidatorDetail.class) ContractOnlineRecordForm form) throws EException {
contractOnlineRecordService.platformSign(form.getContractNumber());
return EResponse.ok();
}
/** /**
* description 根据合同编号获取合同信息 * description 根据合同编号获取合同信息
* param [form] * param [form]
......
package com.esv.freight.customer.module.contract.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.esv.freight.customer.module.contract.entity.ContractOnlinePlatformDataEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 线上电子合同平台数据表
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-05-21 15:55:34
*/
@Mapper
public interface ContractOnlinePlatformDataDao extends BaseMapper<ContractOnlinePlatformDataEntity> {
}
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 lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 线上电子合同平台数据表
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-05-21 15:55:34
*/
@Data
@TableName("contract_online_platform_data")
public class ContractOnlinePlatformDataEntity 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;
/**
* 公章文件ID
*/
private String sealFileId;
/**
* 公章文件URL
*/
private String sealFileUrl;
/**
* 平台名称
*/
private String platformName;
/**
* 平台组织机构代码
*/
private String platformId;
/**
* 数据名称
*/
private String dataName;
/**
* 是否使用: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.pojo;
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.pojo.ContractOnlinePlatformPojo
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/22 10:05
* @version:1.0
*/
@Data
public class ContractOnlinePlatformPojo {
/**
* 平台名称
*/
private String platformName;
/**
* 平台组织机构代码
*/
private String platformId;
/**
* 承运方签字
*/
private Object platformFreightSealImg;
/**
* 生效时间
*/
private String effectiveTime;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
package com.esv.freight.customer.module.contract.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.esv.freight.customer.module.contract.entity.ContractOnlinePlatformDataEntity;
/**
* 线上电子合同模板表
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-05-21 15:55:34
*/
public interface ContractOnlinePlatformDataService extends IService<ContractOnlinePlatformDataEntity> {
/**
* description 获取使用中的电子合同平台数据
* param []
* return com.esv.freight.customer.module.contract.entity.ContractOnlinePlatformDataEntity
* author Administrator
* createTime 2020/05/25 10:50
**/
ContractOnlinePlatformDataEntity getUsedData();
}
package com.esv.freight.customer.module.contract.service; package com.esv.freight.customer.module.contract.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.esv.freight.customer.common.exception.EException;
import com.esv.freight.customer.module.contract.entity.ContractOnlineRecordEntity; import com.esv.freight.customer.module.contract.entity.ContractOnlineRecordEntity;
import com.esv.freight.customer.module.contract.form.ContractOnlineRecordForm; import com.esv.freight.customer.module.contract.form.ContractOnlineRecordForm;
import com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignGoodsOwnerForm; import com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignGoodsOwnerForm;
...@@ -34,5 +35,14 @@ public interface ContractOnlineRecordService extends IService<ContractOnlineReco ...@@ -34,5 +35,14 @@ public interface ContractOnlineRecordService extends IService<ContractOnlineReco
**/ **/
ContractOnlineRecordVO getContractInfoByNumber(String contractNumber); ContractOnlineRecordVO getContractInfoByNumber(String contractNumber);
/**
* description 电子合同-平台签订
* param [contractNumber]
* return java.lang.Integer
* author Administrator
* createTime 2020/05/25 9:41
**/
Integer platformSign(String contractNumber);
} }
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.module.contract.ContractConstants;
import com.esv.freight.customer.module.contract.dao.ContractOnlinePlatformDataDao;
import com.esv.freight.customer.module.contract.entity.ContractOnlinePlatformDataEntity;
import com.esv.freight.customer.module.contract.service.ContractOnlinePlatformDataService;
import org.springframework.stereotype.Service;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.contract.service.impl.ContractOnlinePlatformDataServiceImpl
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/25 10:51
* @version:1.0
*/
@Service("contractOnlinePlatformDataService")
public class ContractOnlinePlatformDataServiceImpl extends ServiceImpl<ContractOnlinePlatformDataDao, ContractOnlinePlatformDataEntity> implements ContractOnlinePlatformDataService {
@Override
public ContractOnlinePlatformDataEntity getUsedData() {
return this.baseMapper.selectOne(new LambdaQueryWrapper<ContractOnlinePlatformDataEntity>()
.eq(ContractOnlinePlatformDataEntity::getUsed, ContractConstants.CONTRACT_PLATFORM_DATA_USED_YES));
}
}
...@@ -26,11 +26,11 @@ spring: ...@@ -26,11 +26,11 @@ spring:
host: 192.168.31.248 host: 192.168.31.248
port: 6379 port: 6379
password: password:
timeout: 1000 timeout: 3000
jedis: lettuce:
pool: pool:
max-active: 8 max-active: 8
max-wait: -1 max-wait: 3000
max-idle: 8 max-idle: 8
min-idle: 0 min-idle: 0
#mybatis #mybatis
...@@ -249,5 +249,7 @@ error-message: ...@@ -249,5 +249,7 @@ error-message:
goods-owner: goods-owner:
sign: sign:
1001: 无效的货主ID 1001: 无效的货主ID
platform-sign:
1001: 无效的合同编号
get-by-number: get-by-number:
1001: 无效的合同编号 1001: 无效的合同编号
\ No newline at end of file
...@@ -26,11 +26,11 @@ spring: ...@@ -26,11 +26,11 @@ spring:
host: 192.168.31.248 host: 192.168.31.248
port: 6379 port: 6379
password: password:
timeout: 1000 timeout: 3000
jedis: lettuce:
pool: pool:
max-active: 8 max-active: 8
max-wait: -1 max-wait: 3000
max-idle: 8 max-idle: 8
min-idle: 0 min-idle: 0
#mybatis #mybatis
...@@ -225,3 +225,31 @@ error-message: ...@@ -225,3 +225,31 @@ error-message:
1001: 司机与车辆未绑定 1001: 司机与车辆未绑定
1002: 无效的司机ID 1002: 无效的司机ID
1003: 无效的车辆ID 1003: 无效的车辆ID
contract:
offline:
goods-owner:
add:
1001: 无效的货主ID
1002: 合同编号已存在
edit:
1001: 无效的合同ID
1002: 合同编号已存在
delete:
1001: 无效的合同ID
carrier:
add:
1001: 无效的承运商ID
1002: 合同编号已存在
edit:
1001: 无效的合同ID
1002: 合同编号已存在
delete:
1001: 无效的合同ID
online:
goods-owner:
sign:
1001: 无效的货主ID
platform-sign:
1001: 无效的合同编号
get-by-number:
1001: 无效的合同编号
\ 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.ContractOnlinePlatformDataEntity" id="contractOnlinePlatformDataMap">
<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="dataFileId" column="data_file_id"/>
<result property="dataFileUrl" column="data_file_url"/>
<result property="dataName" column="data_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
...@@ -136,22 +136,30 @@ public class WordTest { ...@@ -136,22 +136,30 @@ public class WordTest {
} }
} }
@Test
public void pdf_test() throws Exception {
String sourcePath = "D:\\test\\线上合同-货主.docx";
String pdfPath = "D:\\test\\线上合同-货主-test.pdf";
FileOutputStream fileOutputStream = null;
try {
File file = new File(sourcePath);
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 { private static void setFontMapper(WordprocessingMLPackage mlPackage) throws Exception {
Mapper fontMapper = new IdentityPlusMapper(); Mapper fontMapper = new IdentityPlusMapper();
fontMapper.put("隶书", PhysicalFonts.get("LiSu")); fontMapper.put("等线", PhysicalFonts.get("Arial"));
fontMapper.put("宋体", PhysicalFonts.get("SimSun")); 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); mlPackage.setFontMapper(fontMapper);
} }
......
...@@ -181,4 +181,57 @@ public class ContractOnlineRecordControllerTest extends BaseTestController { ...@@ -181,4 +181,57 @@ public class ContractOnlineRecordControllerTest extends BaseTestController {
JSONObject result = JSONObject.parseObject(responseStr); JSONObject result = JSONObject.parseObject(responseStr);
Assert.assertEquals(1001, result.getIntValue("code")); Assert.assertEquals(1001, result.getIntValue("code"));
} }
/**
* 电子合同-平台签订
**/
@Test
public void c1_platformSign_success_test() throws Exception {
String url = "/contract/online/platformSign";
// 构造数据
ContractOnlineRecordForm form = new ContractOnlineRecordForm();
form.setContractNumber("HZHT20200525000002");
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"));
}
/**
* 电子合同-平台签订
**/
@Test
@Rollback
public void c2_platformSign_wrong_contractNumber_failure_test() throws Exception {
String url = "/contract/online/platformSign";
// 构造数据
ContractOnlineRecordForm form = new ContractOnlineRecordForm();
form.setContractNumber("99999");
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"));
}
} }
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