Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
customer-service
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SuperHive
back-end
customer-service
Commits
7aef434a
Commit
7aef434a
authored
May 22, 2020
by
huangcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增接口:货主与平台的电子合同-货主签订
parent
f8f980d1
Changes
31
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
1586 additions
and
8 deletions
+1586
-8
hf.fo
hf.fo
+5
-0
pom.xml
pom.xml
+22
-0
ApplicationLoadRunner.java
...ight/customer/common/component/ApplicationLoadRunner.java
+29
-0
BaseDataComponent.java
.../freight/customer/common/component/BaseDataComponent.java
+14
-5
ErrorMessageComponent.java
...ight/customer/common/component/ErrorMessageComponent.java
+3
-0
InputStreamUtils.java
...om/esv/freight/customer/common/util/InputStreamUtils.java
+54
-0
SpringUtils.java
...ava/com/esv/freight/customer/common/util/SpringUtils.java
+42
-0
FeignBaseService.java
...java/com/esv/freight/customer/feign/FeignBaseService.java
+12
-0
FeignFileService.java
...java/com/esv/freight/customer/feign/FeignFileService.java
+50
-0
ContractConstants.java
...v/freight/customer/module/contract/ContractConstants.java
+31
-0
ContractOnlineRecordController.java
...e/contract/controller/ContractOnlineRecordController.java
+48
-0
ContractOnlineTemplateController.java
...contract/controller/ContractOnlineTemplateController.java
+54
-0
ContractOnlineRecordDao.java
...customer/module/contract/dao/ContractOnlineRecordDao.java
+17
-0
ContractOnlineTemplateDao.java
...stomer/module/contract/dao/ContractOnlineTemplateDao.java
+17
-0
ContractOnlineRecordEntity.java
...er/module/contract/entity/ContractOnlineRecordEntity.java
+76
-0
ContractOnlineTemplateEntity.java
.../module/contract/entity/ContractOnlineTemplateEntity.java
+77
-0
ContractOnlineRecordSignGoodsOwnerForm.java
...contract/form/ContractOnlineRecordSignGoodsOwnerForm.java
+110
-0
ContractOnlineTemplateForm.java
...omer/module/contract/form/ContractOnlineTemplateForm.java
+54
-0
ContractOnlineGoodsOwnerPojo.java
...er/module/contract/pojo/ContractOnlineGoodsOwnerPojo.java
+94
-0
ContractOnlineRecordService.java
.../module/contract/service/ContractOnlineRecordService.java
+27
-0
ContractOnlineTemplateService.java
...odule/contract/service/ContractOnlineTemplateService.java
+35
-0
ContractOnlineRecordServiceImpl.java
...ontract/service/impl/ContractOnlineRecordServiceImpl.java
+219
-0
ContractOnlineTemplateServiceImpl.java
...tract/service/impl/ContractOnlineTemplateServiceImpl.java
+43
-0
ContractOnlineRecordSignGoodsOwnerVO.java
...ule/contract/vo/ContractOnlineRecordSignGoodsOwnerVO.java
+28
-0
application-dev.yml
src/main/resources/application-dev.yml
+13
-2
application-test.yml
src/main/resources/application-test.yml
+8
-1
ContractOnlineRecordDao.xml
...ain/resources/mapper/contract/ContractOnlineRecordDao.xml
+23
-0
ContractOnlineTemplateDao.xml
...n/resources/mapper/contract/ContractOnlineTemplateDao.xml
+23
-0
WordTest.java
...t/java/com/esv/freight/customer/common/util/WordTest.java
+158
-0
ContractOnlineRecordControllerTest.java
...ntract/controller/ContractOnlineRecordControllerTest.java
+131
-0
ContractOnlineTemplateControllerTest.java
...ract/controller/ContractOnlineTemplateControllerTest.java
+69
-0
No files found.
hf.fo
0 → 100644
View file @
7aef434a
<?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
pom.xml
View file @
7aef434a
...
@@ -110,6 +110,28 @@
...
@@ -110,6 +110,28 @@
<artifactId>
cglib
</artifactId>
<artifactId>
cglib
</artifactId>
<version>
3.3.0
</version>
<version>
3.3.0
</version>
</dependency>
</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>
<dependency>
<groupId>
com.esv.platform
</groupId>
<groupId>
com.esv.platform
</groupId>
<artifactId>
gateway-common
</artifactId>
<artifactId>
gateway-common
</artifactId>
...
...
src/main/java/com/esv/freight/customer/common/component/ApplicationLoadRunner.java
0 → 100644
View file @
7aef434a
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
);
}
}
src/main/java/com/esv/freight/customer/common/component/BaseDataComponent.java
View file @
7aef434a
...
@@ -5,6 +5,7 @@ import com.esv.freight.customer.common.response.ECode;
...
@@ -5,6 +5,7 @@ import com.esv.freight.customer.common.response.ECode;
import
com.esv.freight.customer.feign.FeignBaseService
;
import
com.esv.freight.customer.feign.FeignBaseService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
/**
/**
...
@@ -20,12 +21,15 @@ import org.springframework.stereotype.Component;
...
@@ -20,12 +21,15 @@ import org.springframework.stereotype.Component;
@Slf4j
@Slf4j
public
class
BaseDataComponent
{
public
class
BaseDataComponent
{
@Value
(
"${spring.application.name}"
)
private
String
applicationName
;
private
FeignBaseService
feignBaseService
;
private
FeignBaseService
feignBaseService
;
private
RedisComponent
redisComponent
;
private
RedisComponent
redisComponent
;
p
ublic
static
final
String
ALL_REGION_MAP_CACHE_KEY
=
"freight-customer-service
::base-data::city::allMap"
;
p
rivate
static
final
String
ALL_REGION_MAP_CACHE_KEY
=
"
::base-data::city::allMap"
;
p
ublic
static
final
Long
ALL_REGION_MAP_CACHE_TIME
=
36000L
;
p
rivate
static
final
Long
ALL_REGION_MAP_CACHE_TIME
=
36000L
;
@Autowired
@Autowired
public
BaseDataComponent
(
FeignBaseService
feignBaseService
,
RedisComponent
redisComponent
)
{
public
BaseDataComponent
(
FeignBaseService
feignBaseService
,
RedisComponent
redisComponent
)
{
...
@@ -42,14 +46,14 @@ public class BaseDataComponent {
...
@@ -42,14 +46,14 @@ public class BaseDataComponent {
**/
**/
public
JSONObject
getAllRegionMap
()
{
public
JSONObject
getAllRegionMap
()
{
JSONObject
allRegionMap
=
new
JSONObject
();
JSONObject
allRegionMap
=
new
JSONObject
();
if
(
redisComponent
.
hasKey
(
ALL_REGION_MAP_CACHE_KEY
))
{
if
(
redisComponent
.
hasKey
(
this
.
getAllRegionMapCacheKey
()
))
{
allRegionMap
=
JSONObject
.
parseObject
((
String
)
redisComponent
.
get
(
ALL_REGION_MAP_CACHE_KEY
));
allRegionMap
=
JSONObject
.
parseObject
((
String
)
redisComponent
.
get
(
this
.
getAllRegionMapCacheKey
()
));
}
else
{
}
else
{
try
{
try
{
JSONObject
feignResultJson
=
feignBaseService
.
getAllRegionMap
(
new
JSONObject
());
JSONObject
feignResultJson
=
feignBaseService
.
getAllRegionMap
(
new
JSONObject
());
if
(
ECode
.
SUCCESS
.
code
()
==
feignResultJson
.
getIntValue
(
"code"
))
{
if
(
ECode
.
SUCCESS
.
code
()
==
feignResultJson
.
getIntValue
(
"code"
))
{
allRegionMap
=
feignResultJson
.
getJSONObject
(
"data"
);
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
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"调用[基础服务]获取全国省市行政区划(键值对)失败:"
+
e
.
getMessage
());
log
.
error
(
"调用[基础服务]获取全国省市行政区划(键值对)失败:"
+
e
.
getMessage
());
...
@@ -58,4 +62,9 @@ public class BaseDataComponent {
...
@@ -58,4 +62,9 @@ public class BaseDataComponent {
return
allRegionMap
;
return
allRegionMap
;
}
}
public
String
getAllRegionMapCacheKey
()
{
return
applicationName
+
ALL_REGION_MAP_CACHE_KEY
;
}
}
}
src/main/java/com/esv/freight/customer/common/component/ErrorMessageComponent.java
View file @
7aef434a
...
@@ -297,4 +297,7 @@ public class ErrorMessageComponent {
...
@@ -297,4 +297,7 @@ public class ErrorMessageComponent {
@Value
(
"${error-message.contract.offline.carrier.delete.1001}"
)
@Value
(
"${error-message.contract.offline.carrier.delete.1001}"
)
private
String
contractOfflineCarrierDelete1001
;
private
String
contractOfflineCarrierDelete1001
;
@Value
(
"${error-message.contract.online.goods-owner.sign.1001}"
)
private
String
contractOnlineGoodsOwnerAdd1001
;
}
}
src/main/java/com/esv/freight/customer/common/util/InputStreamUtils.java
0 → 100644
View file @
7aef434a
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
();
}
}
src/main/java/com/esv/freight/customer/common/util/SpringUtils.java
0 → 100644
View file @
7aef434a
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
);
}
}
src/main/java/com/esv/freight/customer/feign/FeignBaseService.java
View file @
7aef434a
...
@@ -2,6 +2,7 @@ package com.esv.freight.customer.feign;
...
@@ -2,6 +2,7 @@ package com.esv.freight.customer.feign;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
/**
/**
...
@@ -16,6 +17,16 @@ import org.springframework.web.bind.annotation.PostMapping;
...
@@ -16,6 +17,16 @@ import org.springframework.web.bind.annotation.PostMapping;
@FeignClient
(
value
=
"freight-base-service"
)
@FeignClient
(
value
=
"freight-base-service"
)
public
interface
FeignBaseService
{
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 生成编号
* description 生成编号
* param [bodyJson]
* param [bodyJson]
...
@@ -35,4 +46,5 @@ public interface FeignBaseService {
...
@@ -35,4 +46,5 @@ public interface FeignBaseService {
**/
**/
@PostMapping
(
value
=
"/base/geo/city/getAllRegionMap"
)
@PostMapping
(
value
=
"/base/geo/city/getAllRegionMap"
)
JSONObject
getAllRegionMap
(
JSONObject
bodyJson
);
JSONObject
getAllRegionMap
(
JSONObject
bodyJson
);
}
}
src/main/java/com/esv/freight/customer/feign/FeignFileService.java
0 → 100644
View file @
7aef434a
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
);
}
src/main/java/com/esv/freight/customer/module/contract/ContractConstants.java
0 → 100644
View file @
7aef434a
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
;
}
src/main/java/com/esv/freight/customer/module/contract/controller/ContractOnlineRecordController.java
0 → 100644
View file @
7aef434a
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
));
}
}
src/main/java/com/esv/freight/customer/module/contract/controller/ContractOnlineTemplateController.java
0 → 100644
View file @
7aef434a
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
);
}
}
src/main/java/com/esv/freight/customer/module/contract/dao/ContractOnlineRecordDao.java
0 → 100644
View file @
7aef434a
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
>
{
}
src/main/java/com/esv/freight/customer/module/contract/dao/ContractOnlineTemplateDao.java
0 → 100644
View file @
7aef434a
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
>
{
}
src/main/java/com/esv/freight/customer/module/contract/entity/ContractOnlineRecordEntity.java
0 → 100644
View file @
7aef434a
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
;
}
src/main/java/com/esv/freight/customer/module/contract/entity/ContractOnlineTemplateEntity.java
0 → 100644
View file @
7aef434a
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
;
}
src/main/java/com/esv/freight/customer/module/contract/form/ContractOnlineRecordSignGoodsOwnerForm.java
0 → 100644
View file @
7aef434a
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
);
}
}
src/main/java/com/esv/freight/customer/module/contract/form/ContractOnlineTemplateForm.java
0 → 100644
View file @
7aef434a
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
);
}
}
src/main/java/com/esv/freight/customer/module/contract/pojo/ContractOnlineGoodsOwnerPojo.java
0 → 100644
View file @
7aef434a
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
;
}
src/main/java/com/esv/freight/customer/module/contract/service/ContractOnlineRecordService.java
0 → 100644
View file @
7aef434a
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
);
}
src/main/java/com/esv/freight/customer/module/contract/service/ContractOnlineTemplateService.java
0 → 100644
View file @
7aef434a
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
);
}
src/main/java/com/esv/freight/customer/module/contract/service/impl/ContractOnlineRecordServiceImpl.java
0 → 100644
View file @
7aef434a
package
com
.
esv
.
freight
.
customer
.
module
.
contract
.
service
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.deepoove.poi.XWPFTemplate
;
import
com.deepoove.poi.data.PictureRenderData
;
import
com.esv.freight.customer.common.component.ErrorMessageComponent
;
import
com.esv.freight.customer.common.component.RedisComponent
;
import
com.esv.freight.customer.common.exception.EException
;
import
com.esv.freight.customer.common.response.ECode
;
import
com.esv.freight.customer.common.util.FeignUtils
;
import
com.esv.freight.customer.common.util.InputStreamUtils
;
import
com.esv.freight.customer.feign.FeignBaseService
;
import
com.esv.freight.customer.feign.FeignFileService
;
import
com.esv.freight.customer.module.contract.ContractConstants
;
import
com.esv.freight.customer.module.contract.dao.ContractOnlineRecordDao
;
import
com.esv.freight.customer.module.contract.entity.ContractOnlineRecordEntity
;
import
com.esv.freight.customer.module.contract.entity.ContractOnlineTemplateEntity
;
import
com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignGoodsOwnerForm
;
import
com.esv.freight.customer.module.contract.pojo.ContractOnlineGoodsOwnerPojo
;
import
com.esv.freight.customer.module.contract.service.ContractOnlineRecordService
;
import
com.esv.freight.customer.module.contract.service.ContractOnlineTemplateService
;
import
com.esv.freight.customer.module.contract.vo.ContractOnlineRecordSignGoodsOwnerVO
;
import
com.esv.freight.customer.module.goodsowner.GoodsOwnerConstants
;
import
com.esv.freight.customer.module.goodsowner.dto.AccountInfoDto
;
import
com.esv.freight.customer.module.goodsowner.form.AccountForm
;
import
com.esv.freight.customer.module.goodsowner.service.GoodsOwnerAccountService
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.util.Base64
;
import
java.util.Date
;
@Service
(
"contractOnlineRecordService"
)
public
class
ContractOnlineRecordServiceImpl
extends
ServiceImpl
<
ContractOnlineRecordDao
,
ContractOnlineRecordEntity
>
implements
ContractOnlineRecordService
{
@Value
(
"${spring.application.name}"
)
private
String
applicationName
;
private
static
final
Long
CONTRACT_CACHE_TIME
=
86400L
;
/**
* 货主签名图像宽度、长度
**/
private
static
final
int
GOODS_OWNER_SIGN_WIDTH
=
150
;
private
static
final
int
GOODS_OWNER_SIGN_HEIGHT
=
60
;
private
ErrorMessageComponent
errorMessageComponent
;
private
FeignFileService
feignFileService
;
private
FeignBaseService
feignBaseService
;
private
RedisComponent
redisComponent
;
private
ContractOnlineTemplateService
contractOnlineTemplateService
;
private
GoodsOwnerAccountService
goodsOwnerAccountService
;
@Autowired
public
ContractOnlineRecordServiceImpl
(
ErrorMessageComponent
errorMessageComponent
,
FeignFileService
feignFileService
,
FeignBaseService
feignBaseService
,
RedisComponent
redisComponent
,
ContractOnlineTemplateService
contractOnlineTemplateService
,
GoodsOwnerAccountService
goodsOwnerAccountService
)
{
this
.
errorMessageComponent
=
errorMessageComponent
;
this
.
feignFileService
=
feignFileService
;
this
.
feignBaseService
=
feignBaseService
;
this
.
redisComponent
=
redisComponent
;
this
.
contractOnlineTemplateService
=
contractOnlineTemplateService
;
this
.
goodsOwnerAccountService
=
goodsOwnerAccountService
;
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
ContractOnlineRecordSignGoodsOwnerVO
goodsOwnerSign
(
ContractOnlineRecordSignGoodsOwnerForm
form
)
{
// 1:获取货主信息
AccountForm
accountForm
=
new
AccountForm
();
accountForm
.
setId
(
form
.
getGoodsOwnerId
());
AccountInfoDto
accountInfo
=
goodsOwnerAccountService
.
getAccountInfo
(
accountForm
);
if
(
null
==
accountInfo
)
{
throw
new
EException
(
1001
,
errorMessageComponent
.
getContractOnlineGoodsOwnerAdd1001
());
}
// 2:获取电子合同模板数据
String
contractTemplateData
=
this
.
getContractOnlineTemplateEntity
(
ContractConstants
.
CONTRACT_TYPE_GOODS_OWNER
);
byte
[]
contractTemplateBytes
=
Base64
.
getDecoder
().
decode
(
contractTemplateData
);
// 3:填充电子合同模板
ByteArrayOutputStream
byteArrayOutputStream
=
new
ByteArrayOutputStream
();
ContractOnlineGoodsOwnerPojo
contractOnlineGoodsOwnerPojo
;
byte
[]
signBytes
;
XWPFTemplate
template
=
null
;
try
{
template
=
XWPFTemplate
.
compile
(
InputStreamUtils
.
byte2InputStream
(
contractTemplateBytes
));
contractOnlineGoodsOwnerPojo
=
this
.
getGoodsOwnerSignDataMap
(
form
,
accountInfo
);
template
.
render
(
contractOnlineGoodsOwnerPojo
);
template
.
write
(
byteArrayOutputStream
);
byteArrayOutputStream
.
flush
();
signBytes
=
byteArrayOutputStream
.
toByteArray
();
}
catch
(
IOException
e
)
{
log
.
error
(
"填充电子合同模板失败:"
+
e
.
getMessage
());
throw
new
EException
(
ECode
.
SERVER_ERROR
.
code
(),
"生成电子合同失败[填充电子合同模板失败]"
);
}
finally
{
if
(
null
!=
template
)
{
try
{
template
.
close
();
}
catch
(
IOException
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
}
}
IOUtils
.
closeQuietly
(
byteArrayOutputStream
);
}
// 4:保存货主签订后的电子合同文件
String
contractNumber
=
contractOnlineGoodsOwnerPojo
.
getContactNumber
();
JSONObject
feignReqJson
=
new
JSONObject
();
feignReqJson
.
put
(
"fileType"
,
"word"
);
feignReqJson
.
put
(
"fileName"
,
"电子合同-货主签名-"
+
contractNumber
+
".docx"
);
feignReqJson
.
put
(
"fileData"
,
Base64
.
getEncoder
().
encodeToString
(
signBytes
));
JSONObject
feignResJson
;
try
{
feignResJson
=
FeignUtils
.
getFeignResultData
(
feignFileService
.
uploadSingleFile
(
feignReqJson
));
}
catch
(
Exception
e
)
{
log
.
error
(
"调用[文件服务]上传货主签名合同文件数据失败:"
+
e
.
getMessage
());
throw
new
EException
(
"生成电子合同失败[上传货主签名合同文件数据失败]"
);
}
// 5:保存货主签订后的电子合同记录
String
fileId
=
feignResJson
.
getString
(
"id"
);
String
fileUrl
=
feignResJson
.
getString
(
"url"
);
ContractOnlineRecordEntity
onlineRecordEntity
=
new
ContractOnlineRecordEntity
();
onlineRecordEntity
.
setContractType
(
ContractConstants
.
CONTRACT_TYPE_GOODS_OWNER
);
onlineRecordEntity
.
setContractFileId
(
fileId
);
onlineRecordEntity
.
setContractFileUrl
(
fileUrl
);
onlineRecordEntity
.
setContractNumber
(
contractNumber
);
onlineRecordEntity
.
setBusinessNumber
(
form
.
getBusinessNumber
());
onlineRecordEntity
.
setCustomerSignTime
(
new
Date
());
onlineRecordEntity
.
setSignComplete
(
ContractConstants
.
CONTRACT_SIGN_COMPLETE_NO
);
this
.
baseMapper
.
insert
(
onlineRecordEntity
);
// 6:返回
ContractOnlineRecordSignGoodsOwnerVO
vo
=
new
ContractOnlineRecordSignGoodsOwnerVO
();
vo
.
setContractNumber
(
contractNumber
);
return
vo
;
}
/**
* description 获取货主签订合同时的数据
* param [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
)
{
ContractOnlineGoodsOwnerPojo
pojo
=
new
ContractOnlineGoodsOwnerPojo
();
BeanUtils
.
copyProperties
(
form
,
pojo
);
// 设置合同编号
JSONObject
feignReqJson
=
new
JSONObject
();
feignReqJson
.
put
(
"prefix"
,
"HZHT"
);
feignReqJson
.
put
(
"formatter"
,
"yyyyMMdd"
);
feignReqJson
.
put
(
"length"
,
18
);
JSONObject
feignResJson
;
try
{
feignResJson
=
FeignUtils
.
getFeignResultData
(
feignBaseService
.
getBatchId
(
feignReqJson
));
pojo
.
setContactNumber
(
feignResJson
.
getString
(
"batchId"
));
}
catch
(
Exception
e
)
{
log
.
error
(
"调用[基础服务]获取合同编号失败:"
+
e
.
getMessage
());
throw
new
EException
(
"生成电子合同失败[获取合同编号失败]"
);
}
// 设置货主信息
if
(
GoodsOwnerConstants
.
OWNER_TYPE_COMPANY
.
equals
(
accountInfo
.
getOwnerType
()))
{
pojo
.
setGoodsOwnerName
(
accountInfo
.
getOwnerFullName
());
pojo
.
setGoodsOwnerId
(
accountInfo
.
getUniCreditCode
());
}
else
{
pojo
.
setGoodsOwnerName
(
accountInfo
.
getContactor
());
pojo
.
setGoodsOwnerId
(
accountInfo
.
getIdCard
());
}
pojo
.
setPlatformName
(
"{{platformName}}"
);
pojo
.
setPlatformId
(
"{{platformId}}"
);
pojo
.
setEffectiveTime
(
"{{effectiveTime}}"
);
pojo
.
setGoodsOwnerSignImg
(
new
PictureRenderData
(
GOODS_OWNER_SIGN_WIDTH
,
GOODS_OWNER_SIGN_HEIGHT
,
".png"
,
Base64
.
getDecoder
().
decode
(
form
.
getSignData
())));
pojo
.
setPlatformFreightSealImg
(
"{{@platformFreightSealImg}}"
);
return
pojo
;
}
/**
* 获取电子合同模板数据
* contractType:合同类型:1-货主与平台合同、2-司机与平台合同
**/
private
String
getContractOnlineTemplateEntity
(
Integer
contractType
)
{
String
contractTemplateData
;
String
cacheKey
=
applicationName
+
"::online-contract::"
+
contractType
;
contractTemplateData
=
(
String
)
redisComponent
.
get
(
cacheKey
);
if
(
StringUtils
.
isBlank
(
contractTemplateData
))
{
ContractOnlineTemplateEntity
contractOnlineTemplateEntity
=
this
.
contractOnlineTemplateService
.
getUsedTemplate
(
contractType
);
String
fileId
=
contractOnlineTemplateEntity
.
getTemplateFileId
();
JSONObject
feignReqJson
=
new
JSONObject
();
feignReqJson
.
put
(
"id"
,
fileId
);
JSONObject
feignResJson
;
try
{
feignResJson
=
FeignUtils
.
getFeignResultData
(
feignFileService
.
getFileData
(
feignReqJson
));
}
catch
(
Exception
e
)
{
log
.
error
(
"调用[文件服务]获取合同模板数据失败:"
+
e
.
getMessage
());
throw
new
EException
(
"生成电子合同失败[获取合同模板数据失败]"
);
}
contractTemplateData
=
feignResJson
.
getString
(
"fileData"
);
redisComponent
.
set
(
cacheKey
,
contractTemplateData
,
CONTRACT_CACHE_TIME
);
}
return
contractTemplateData
;
}
}
\ No newline at end of file
src/main/java/com/esv/freight/customer/module/contract/service/impl/ContractOnlineTemplateServiceImpl.java
0 → 100644
View file @
7aef434a
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
src/main/java/com/esv/freight/customer/module/contract/vo/ContractOnlineRecordSignGoodsOwnerVO.java
0 → 100644
View file @
7aef434a
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
);
}
}
src/main/resources/application-dev.yml
View file @
7aef434a
...
@@ -53,10 +53,17 @@ mybatis-plus:
...
@@ -53,10 +53,17 @@ mybatis-plus:
id-type
:
AUTO
id-type
:
AUTO
logic-delete-value
:
1
logic-delete-value
:
1
logic-not-delete-value
:
0
logic-not-delete-value
:
0
hystrix
:
command
:
default
:
execution
:
isolation
:
thread
:
timeoutInMilliseconds
:
5000
ribbon
:
ribbon
:
eager-load
:
eager-load
:
enabled
:
true
enabled
:
true
clients
:
freight-base-service,freight-app-service
clients
:
freight-base-service,freight-
file-service,freight-
app-service
error-message
:
error-message
:
goodsowner
:
goodsowner
:
account
:
account
:
...
@@ -237,4 +244,8 @@ error-message:
...
@@ -237,4 +244,8 @@ error-message:
1001
:
无效的合同ID
1001
:
无效的合同ID
1002
:
合同编号已存在
1002
:
合同编号已存在
delete
:
delete
:
1001
:
无效的合同ID
1001
:
无效的合同ID
\ No newline at end of file
online
:
goods-owner
:
sign
:
1001
:
无效的货主ID
\ No newline at end of file
src/main/resources/application-test.yml
View file @
7aef434a
...
@@ -53,10 +53,17 @@ mybatis-plus:
...
@@ -53,10 +53,17 @@ mybatis-plus:
id-type
:
AUTO
id-type
:
AUTO
logic-delete-value
:
1
logic-delete-value
:
1
logic-not-delete-value
:
0
logic-not-delete-value
:
0
hystrix
:
command
:
default
:
execution
:
isolation
:
thread
:
timeoutInMilliseconds
:
5000
ribbon
:
ribbon
:
eager-load
:
eager-load
:
enabled
:
true
enabled
:
true
clients
:
freight-base-service,freight-app-service
clients
:
freight-base-service,freight-
file-service,freight-
app-service
error-message
:
error-message
:
goodsowner
:
goodsowner
:
account
:
account
:
...
...
src/main/resources/mapper/contract/ContractOnlineRecordDao.xml
0 → 100644
View file @
7aef434a
<?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
src/main/resources/mapper/contract/ContractOnlineTemplateDao.xml
0 → 100644
View file @
7aef434a
<?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
src/test/java/com/esv/freight/customer/common/util/WordTest.java
0 → 100644
View file @
7aef434a
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
);
}
}
src/test/java/com/esv/freight/customer/module/contract/controller/ContractOnlineRecordControllerTest.java
0 → 100644
View file @
7aef434a
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"
));
}
}
src/test/java/com/esv/freight/customer/module/contract/controller/ContractOnlineTemplateControllerTest.java
0 → 100644
View file @
7aef434a
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"
));
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment