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
ba0a696f
Commit
ba0a696f
authored
May 25, 2020
by
huangcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增接口:电子合同-平台签订
parent
0b1cf3f7
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
554 additions
and
35 deletions
+554
-35
.gitignore
.gitignore
+1
-0
hf.fo
hf.fo
+0
-5
pom.xml
pom.xml
+6
-1
ErrorMessageComponent.java
...ight/customer/common/component/ErrorMessageComponent.java
+3
-0
ReqUtils.java
...n/java/com/esv/freight/customer/common/util/ReqUtils.java
+16
-0
ContractConstants.java
...v/freight/customer/module/contract/ContractConstants.java
+7
-0
ContractOnlineRecordController.java
...e/contract/controller/ContractOnlineRecordController.java
+13
-0
ContractOnlinePlatformDataDao.java
...er/module/contract/dao/ContractOnlinePlatformDataDao.java
+17
-0
ContractOnlinePlatformDataEntity.java
...ule/contract/entity/ContractOnlinePlatformDataEntity.java
+84
-0
ContractOnlinePlatformPojo.java
...omer/module/contract/pojo/ContractOnlinePlatformPojo.java
+41
-0
ContractOnlinePlatformDataService.java
...e/contract/service/ContractOnlinePlatformDataService.java
+25
-0
ContractOnlineRecordService.java
.../module/contract/service/ContractOnlineRecordService.java
+10
-0
ContractOnlinePlatformDataServiceImpl.java
...t/service/impl/ContractOnlinePlatformDataServiceImpl.java
+28
-0
ContractOnlineRecordServiceImpl.java
...ontract/service/impl/ContractOnlineRecordServiceImpl.java
+169
-9
application-dev.yml
src/main/resources/application-dev.yml
+5
-3
application-test.yml
src/main/resources/application-test.yml
+32
-4
ContractOnlinePlatformDataDao.xml
...sources/mapper/contract/ContractOnlinePlatformDataDao.xml
+23
-0
WordTest.java
...t/java/com/esv/freight/customer/common/util/WordTest.java
+21
-13
ContractOnlineRecordControllerTest.java
...ntract/controller/ContractOnlineRecordControllerTest.java
+53
-0
No files found.
.gitignore
View file @
ba0a696f
*.class
*.iml
*.log
/*.fo
/*.iml
/.idea/
/log/
...
...
hf.fo
deleted
100644 → 0
View file @
0b1cf3f7
<?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 @
ba0a696f
...
...
@@ -22,7 +22,7 @@
<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-fastjson.version>
1.2.62
</alibaba-fastjson.version>
<alibaba-druid.version>
1.1.2
1
</alibaba-druid.version>
<alibaba-druid.version>
1.1.2
2
</alibaba-druid.version>
<apache-commons-lang3.version>
3.7
</apache-commons-lang3.version>
<mybatisplus.version>
3.3.1
</mybatisplus.version>
</properties>
...
...
@@ -64,6 +64,11 @@
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-redis
</artifactId>
</dependency>
<!--lettuce pool连接池-->
<dependency>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-pool2
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-openfeign
</artifactId>
...
...
src/main/java/com/esv/freight/customer/common/component/ErrorMessageComponent.java
View file @
ba0a696f
...
...
@@ -303,4 +303,7 @@ public class ErrorMessageComponent {
@Value
(
"${error-message.contract.online.get-by-number.1001}"
)
private
String
contractOnlineGetByNumber1001
;
@Value
(
"${error-message.contract.online.goods-owner.platform-sign.1001}"
)
private
String
contractOnlineGoodsOwnerPlatformSign1001
;
}
src/main/java/com/esv/freight/customer/common/util/ReqUtils.java
View file @
ba0a696f
...
...
@@ -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 获取当前请求的用户帐号
* param []
...
...
src/main/java/com/esv/freight/customer/module/contract/ContractConstants.java
View file @
ba0a696f
...
...
@@ -28,4 +28,11 @@ public class ContractConstants {
*/
public
static
final
Integer
CONTRACT_SIGN_COMPLETE_YES
=
1
;
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
;
}
src/main/java/com/esv/freight/customer/module/contract/controller/ContractOnlineRecordController.java
View file @
ba0a696f
...
...
@@ -48,6 +48,19 @@ public class ContractOnlineRecordController {
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 根据合同编号获取合同信息
* param [form]
...
...
src/main/java/com/esv/freight/customer/module/contract/dao/ContractOnlinePlatformDataDao.java
0 → 100644
View file @
ba0a696f
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
>
{
}
src/main/java/com/esv/freight/customer/module/contract/entity/ContractOnlinePlatformDataEntity.java
0 → 100644
View file @
ba0a696f
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
;
}
src/main/java/com/esv/freight/customer/module/contract/pojo/ContractOnlinePlatformPojo.java
0 → 100644
View file @
ba0a696f
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
);
}
}
src/main/java/com/esv/freight/customer/module/contract/service/ContractOnlinePlatformDataService.java
0 → 100644
View file @
ba0a696f
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
();
}
src/main/java/com/esv/freight/customer/module/contract/service/ContractOnlineRecordService.java
View file @
ba0a696f
package
com
.
esv
.
freight
.
customer
.
module
.
contract
.
service
;
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.form.ContractOnlineRecordForm
;
import
com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignGoodsOwnerForm
;
...
...
@@ -34,5 +35,14 @@ public interface ContractOnlineRecordService extends IService<ContractOnlineReco
**/
ContractOnlineRecordVO
getContractInfoByNumber
(
String
contractNumber
);
/**
* description 电子合同-平台签订
* param [contractNumber]
* return java.lang.Integer
* author Administrator
* createTime 2020/05/25 9:41
**/
Integer
platformSign
(
String
contractNumber
);
}
src/main/java/com/esv/freight/customer/module/contract/service/impl/ContractOnlinePlatformDataServiceImpl.java
0 → 100644
View file @
ba0a696f
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
));
}
}
src/main/java/com/esv/freight/customer/module/contract/service/impl/ContractOnlineRecordServiceImpl.java
View file @
ba0a696f
...
...
@@ -9,16 +9,21 @@ 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.DateUtils
;
import
com.esv.freight.customer.common.util.FeignUtils
;
import
com.esv.freight.customer.common.util.InputStreamUtils
;
import
com.esv.freight.customer.common.util.ReqUtils
;
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.ContractOnlinePlatformDataEntity
;
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.pojo.ContractOnlinePlatformPojo
;
import
com.esv.freight.customer.module.contract.service.ContractOnlinePlatformDataService
;
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
;
...
...
@@ -29,6 +34,11 @@ 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.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.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
@@ -37,6 +47,7 @@ import org.springframework.transaction.annotation.Transactional;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.Base64
;
import
java.util.Date
;
...
...
@@ -55,23 +66,32 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
private
static
final
int
GOODS_OWNER_SIGN_WIDTH
=
150
;
private
static
final
int
GOODS_OWNER_SIGN_HEIGHT
=
60
;
/**
* 平台公章图像宽度、长度
**/
private
static
final
int
PLATFORM_SEAL_WIDTH
=
200
;
private
static
final
int
PLATFORM_SEAL_HEIGHT
=
200
;
private
ErrorMessageComponent
errorMessageComponent
;
private
FeignFileService
feignFileService
;
private
FeignBaseService
feignBaseService
;
private
RedisComponent
redisComponent
;
private
ContractOnlineTemplateService
contractOnlineTemplateService
;
private
GoodsOwnerAccountService
goodsOwnerAccountService
;
private
ContractOnlinePlatformDataService
contractOnlinePlatformDataService
;
@Autowired
public
ContractOnlineRecordServiceImpl
(
ErrorMessageComponent
errorMessageComponent
,
FeignFileService
feignFileService
,
FeignBaseService
feignBaseService
,
RedisComponent
redisComponent
,
ContractOnlineTemplateService
contractOnlineTemplateService
,
GoodsOwnerAccountService
goodsOwnerAccountService
)
{
ContractOnlineTemplateService
contractOnlineTemplateService
,
GoodsOwnerAccountService
goodsOwnerAccountService
,
ContractOnlinePlatformDataService
contractOnlinePlatformDataService
)
{
this
.
errorMessageComponent
=
errorMessageComponent
;
this
.
feignFileService
=
feignFileService
;
this
.
feignBaseService
=
feignBaseService
;
this
.
redisComponent
=
redisComponent
;
this
.
contractOnlineTemplateService
=
contractOnlineTemplateService
;
this
.
goodsOwnerAccountService
=
goodsOwnerAccountService
;
this
.
contractOnlinePlatformDataService
=
contractOnlinePlatformDataService
;
}
@Override
...
...
@@ -91,13 +111,13 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
// 3:填充电子合同模板
ByteArrayOutputStream
byteArrayOutputStream
=
new
ByteArrayOutputStream
();
ContractOnlineGoodsOwnerPojo
contractOnlineGoodsOwnerP
ojo
;
ContractOnlineGoodsOwnerPojo
p
ojo
;
byte
[]
signBytes
;
XWPFTemplate
template
=
null
;
try
{
template
=
XWPFTemplate
.
compile
(
InputStreamUtils
.
byte2InputStream
(
contractTemplateBytes
));
contractOnlineGoodsOwnerP
ojo
=
this
.
getGoodsOwnerSignDataMap
(
form
,
accountInfo
);
template
.
render
(
contractOnlineGoodsOwnerP
ojo
);
p
ojo
=
this
.
getGoodsOwnerSignDataMap
(
form
,
accountInfo
);
template
.
render
(
p
ojo
);
template
.
write
(
byteArrayOutputStream
);
byteArrayOutputStream
.
flush
();
signBytes
=
byteArrayOutputStream
.
toByteArray
();
...
...
@@ -116,7 +136,7 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
}
// 4:保存货主签订后的电子合同文件
String
contractNumber
=
contractOnlineGoodsOwnerP
ojo
.
getContactNumber
();
String
contractNumber
=
p
ojo
.
getContactNumber
();
JSONObject
feignReqJson
=
new
JSONObject
();
feignReqJson
.
put
(
"fileType"
,
"word"
);
feignReqJson
.
put
(
"fileName"
,
"电子合同-货主签名-"
+
contractNumber
+
".docx"
);
...
...
@@ -173,7 +193,7 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
}
}
}
else
{
// TODO,司机签订的合同
}
vo
.
setCustomerName
(
customerName
);
vo
.
setCustomerSignTime
(
recordEntity
.
getCustomerSignTime
().
getTime
());
...
...
@@ -225,17 +245,113 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
return
pojo
;
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Integer
platformSign
(
String
contractNumber
)
{
// 1:判断合同号是否有效
ContractOnlineRecordEntity
contractOnlineRecordEntity
=
this
.
baseMapper
.
selectOne
(
new
LambdaQueryWrapper
<
ContractOnlineRecordEntity
>()
.
eq
(
ContractOnlineRecordEntity:
:
getContractNumber
,
contractNumber
));
if
(
null
==
contractOnlineRecordEntity
)
{
throw
new
EException
(
1001
,
errorMessageComponent
.
getContractOnlineGoodsOwnerPlatformSign1001
());
}
// 2:获取合同数据
JSONObject
feignReqJson
=
new
JSONObject
();
feignReqJson
.
put
(
"id"
,
contractOnlineRecordEntity
.
getContractFileId
());
JSONObject
feignResJson
;
try
{
feignResJson
=
FeignUtils
.
getFeignResultData
(
feignFileService
.
getFileData
(
feignReqJson
));
}
catch
(
Exception
e
)
{
log
.
error
(
"调用[文件服务]获取合同数据失败:"
+
e
.
getMessage
());
throw
new
EException
(
"平台签订电子合同失败[获取合同数据失败]"
);
}
String
contractFileData
=
feignResJson
.
getString
(
"fileData"
);
byte
[]
contractFileBytes
=
Base64
.
getDecoder
().
decode
(
contractFileData
);
// 3:获取平台签名或盖章数据
ContractOnlinePlatformPojo
pojo
=
this
.
getContractOnlinePlatformData
();
Date
effectiveTime
=
new
Date
();
pojo
.
setEffectiveTime
(
DateUtils
.
format
(
effectiveTime
));
pojo
.
setPlatformFreightSealImg
(
new
PictureRenderData
(
PLATFORM_SEAL_WIDTH
,
PLATFORM_SEAL_HEIGHT
,
".png"
,
Base64
.
getDecoder
().
decode
((
String
)
pojo
.
getPlatformFreightSealImg
())));
// 4:增加平台签名或盖章
ByteArrayOutputStream
byteArrayOutputStream
=
new
ByteArrayOutputStream
();
byte
[]
signBytes
;
XWPFTemplate
template
=
null
;
try
{
template
=
XWPFTemplate
.
compile
(
InputStreamUtils
.
byte2InputStream
(
contractFileBytes
));
template
.
render
(
pojo
);
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:Word转换为PDF
InputStream
inputStream
=
InputStreamUtils
.
byte2InputStream
(
signBytes
);
ByteArrayOutputStream
pdfOutputStream
=
new
ByteArrayOutputStream
();
byte
[]
pdfBytes
;
try
{
WordprocessingMLPackage
mlPackage
=
WordprocessingMLPackage
.
load
(
inputStream
);
setFontMapper
(
mlPackage
);
Docx4J
.
toPDF
(
mlPackage
,
pdfOutputStream
);
pdfBytes
=
pdfOutputStream
.
toByteArray
();
}
catch
(
Exception
e
)
{
log
.
error
(
"平台签订电子合同失败:"
+
e
.
getMessage
());
throw
new
EException
(
ECode
.
SERVER_ERROR
.
code
(),
"平台签订电子合同失败[Word转PDF失败]"
);
}
finally
{
IOUtils
.
closeQuietly
(
inputStream
);
IOUtils
.
closeQuietly
(
pdfOutputStream
);
}
// 5:保存PDF文件
feignReqJson
=
new
JSONObject
();
feignReqJson
.
put
(
"fileType"
,
"pdf"
);
feignReqJson
.
put
(
"fileName"
,
"电子合同-平台签名-"
+
contractNumber
+
".pdf"
);
feignReqJson
.
put
(
"fileData"
,
Base64
.
getEncoder
().
encodeToString
(
pdfBytes
));
try
{
feignResJson
=
FeignUtils
.
getFeignResultData
(
feignFileService
.
uploadSingleFile
(
feignReqJson
));
}
catch
(
Exception
e
)
{
log
.
error
(
"调用[文件服务]上传平台签名合同文件数据失败:"
+
e
.
getMessage
());
throw
new
EException
(
"平台签订电子合同失败[上传平台签名合同文件数据失败]"
);
}
// 6:更新合同记录
String
fileId
=
feignResJson
.
getString
(
"id"
);
String
fileUrl
=
feignResJson
.
getString
(
"url"
);
ContractOnlineRecordEntity
onlineRecordEntity
=
new
ContractOnlineRecordEntity
();
onlineRecordEntity
.
setId
(
contractOnlineRecordEntity
.
getId
());
onlineRecordEntity
.
setContractFileId
(
fileId
);
onlineRecordEntity
.
setContractFileUrl
(
fileUrl
);
onlineRecordEntity
.
setPlatformSignTime
(
effectiveTime
);
onlineRecordEntity
.
setEffectiveTime
(
effectiveTime
);
onlineRecordEntity
.
setSignComplete
(
ContractConstants
.
CONTRACT_SIGN_COMPLETE_YES
);
return
this
.
baseMapper
.
updateById
(
onlineRecordEntity
);
}
/**
* 获取电子合同模板数据
* contractType:合同类型:1-货主与平台合同、2-司机与平台合同
**/
private
String
getContractOnlineTemplateEntity
(
Integer
contractType
)
{
String
contractTemplateData
;
String
cacheKey
=
applicationName
+
"::online-contract::"
+
contractType
;
String
cacheKey
=
applicationName
+
"::online-contract::"
+
contractType
+
"::"
+
ReqUtils
.
getRequestTenantId
()
;
contractTemplateData
=
(
String
)
redisComponent
.
get
(
cacheKey
);
if
(
StringUtils
.
isBlank
(
contractTemplateData
))
{
ContractOnlineTemplateEntity
contractOnlineTemplateE
ntity
=
this
.
contractOnlineTemplateService
.
getUsedTemplate
(
contractType
);
String
fileId
=
contractOnlineTemplateE
ntity
.
getTemplateFileId
();
ContractOnlineTemplateEntity
e
ntity
=
this
.
contractOnlineTemplateService
.
getUsedTemplate
(
contractType
);
String
fileId
=
e
ntity
.
getTemplateFileId
();
JSONObject
feignReqJson
=
new
JSONObject
();
feignReqJson
.
put
(
"id"
,
fileId
);
...
...
@@ -253,4 +369,48 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
return
contractTemplateData
;
}
/**
* 获取线上电子合同平台数据
**/
private
ContractOnlinePlatformPojo
getContractOnlinePlatformData
()
{
ContractOnlinePlatformPojo
pojo
;
String
cacheKey
=
applicationName
+
"::online-contract::platform-data::"
+
ReqUtils
.
getRequestTenantId
();
String
cacheValue
=
(
String
)
redisComponent
.
get
(
cacheKey
);
if
(
StringUtils
.
isBlank
(
cacheValue
))
{
ContractOnlinePlatformDataEntity
entity
=
this
.
contractOnlinePlatformDataService
.
getUsedData
();
String
fileId
=
entity
.
getSealFileId
();
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
(
"生成电子合同失败[获取合同平台数据失败]"
);
}
String
fileData
=
feignResJson
.
getString
(
"fileData"
);
pojo
=
new
ContractOnlinePlatformPojo
();
pojo
.
setPlatformFreightSealImg
(
fileData
);
pojo
.
setPlatformName
(
entity
.
getPlatformName
());
pojo
.
setPlatformId
(
entity
.
getPlatformId
());
redisComponent
.
set
(
cacheKey
,
pojo
.
toString
(),
CONTRACT_CACHE_TIME
);
}
else
{
pojo
=
JSONObject
.
toJavaObject
(
JSONObject
.
parseObject
(
cacheValue
),
ContractOnlinePlatformPojo
.
class
);
}
return
pojo
;
}
/**
* Word转PDF,设置字体
**/
private
static
void
setFontMapper
(
WordprocessingMLPackage
mlPackage
)
throws
Exception
{
Mapper
fontMapper
=
new
IdentityPlusMapper
();
fontMapper
.
put
(
"宋体"
,
PhysicalFonts
.
get
(
"SimSun"
));
fontMapper
.
put
(
"等线"
,
PhysicalFonts
.
get
(
"Arial"
));
mlPackage
.
setFontMapper
(
fontMapper
);
}
}
\ No newline at end of file
src/main/resources/application-dev.yml
View file @
ba0a696f
...
...
@@ -26,11 +26,11 @@ spring:
host
:
192.168.31.248
port
:
6379
password
:
timeout
:
1
000
jedis
:
timeout
:
3
000
lettuce
:
pool
:
max-active
:
8
max-wait
:
-1
max-wait
:
3000
max-idle
:
8
min-idle
:
0
#mybatis
...
...
@@ -249,5 +249,7 @@ error-message:
goods-owner
:
sign
:
1001
:
无效的货主ID
platform-sign
:
1001
:
无效的合同编号
get-by-number
:
1001
:
无效的合同编号
\ No newline at end of file
src/main/resources/application-test.yml
View file @
ba0a696f
...
...
@@ -26,11 +26,11 @@ spring:
host
:
192.168.31.248
port
:
6379
password
:
timeout
:
1
000
jedis
:
timeout
:
3
000
lettuce
:
pool
:
max-active
:
8
max-wait
:
-1
max-wait
:
3000
max-idle
:
8
min-idle
:
0
#mybatis
...
...
@@ -224,4 +224,32 @@ error-message:
vehicle-check-bind
:
1001
:
司机与车辆未绑定
1002
:
无效的司机ID
1003
:
无效的车辆ID
\ No newline at end of file
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
src/main/resources/mapper/contract/ContractOnlinePlatformDataDao.xml
0 → 100644
View file @
ba0a696f
<?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
src/test/java/com/esv/freight/customer/common/util/WordTest.java
View file @
ba0a696f
...
...
@@ -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
{
Mapper
fontMapper
=
new
IdentityPlusMapper
();
fontMapper
.
put
(
"
隶书"
,
PhysicalFonts
.
get
(
"LiSu
"
));
fontMapper
.
put
(
"
等线"
,
PhysicalFonts
.
get
(
"Arial
"
));
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
View file @
ba0a696f
...
...
@@ -181,4 +181,57 @@ public class ContractOnlineRecordControllerTest extends BaseTestController {
JSONObject
result
=
JSONObject
.
parseObject
(
responseStr
);
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"
));
}
}
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