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
9d58d337
Commit
9d58d337
authored
May 26, 2020
by
huangcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增接口:司机与平台的电子合同-司机签订
parent
99665a71
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
478 additions
and
17 deletions
+478
-17
ErrorMessageComponent.java
...ight/customer/common/component/ErrorMessageComponent.java
+7
-3
ContractOnlineRecordController.java
...e/contract/controller/ContractOnlineRecordController.java
+13
-0
ContractOnlineRecordSignDriverForm.java
...ule/contract/form/ContractOnlineRecordSignDriverForm.java
+104
-0
ContractOnlineDriverPojo.java
...stomer/module/contract/pojo/ContractOnlineDriverPojo.java
+90
-0
ContractOnlineRecordService.java
.../module/contract/service/ContractOnlineRecordService.java
+11
-0
ContractOnlineRecordServiceImpl.java
...ontract/service/impl/ContractOnlineRecordServiceImpl.java
+127
-9
ContractOnlineRecordSignDriverVO.java
.../module/contract/vo/ContractOnlineRecordSignDriverVO.java
+28
-0
application-dev.yml
src/main/resources/application-dev.yml
+5
-1
application-test.yml
src/main/resources/application-test.yml
+5
-1
logback-spring.xml
src/main/resources/logback-spring.xml
+1
-1
ContractOnlineRecordControllerTest.java
...ntract/controller/ContractOnlineRecordControllerTest.java
+87
-2
No files found.
src/main/java/com/esv/freight/customer/common/component/ErrorMessageComponent.java
View file @
9d58d337
...
@@ -299,11 +299,15 @@ public class ErrorMessageComponent {
...
@@ -299,11 +299,15 @@ public class ErrorMessageComponent {
private
String
contractOfflineCarrierDelete1001
;
private
String
contractOfflineCarrierDelete1001
;
@Value
(
"${error-message.contract.online.goods-owner.sign.1001}"
)
@Value
(
"${error-message.contract.online.goods-owner.sign.1001}"
)
private
String
contractOnlineGoodsOwnerAdd1001
;
private
String
contractOnlineGoodsOwnerSign1001
;
@Value
(
"${error-message.contract.online.driver.sign.1001}"
)
private
String
contractOnlineDriverSign1001
;
@Value
(
"${error-message.contract.online.platform.sign.1001}"
)
private
String
contractOnlinePlatformSign1001
;
@Value
(
"${error-message.contract.online.get-by-number.1001}"
)
@Value
(
"${error-message.contract.online.get-by-number.1001}"
)
private
String
contractOnlineGetByNumber1001
;
private
String
contractOnlineGetByNumber1001
;
@Value
(
"${error-message.contract.online.goods-owner.platform-sign.1001}"
)
private
String
contractOnlineGoodsOwnerPlatformSign1001
;
}
}
src/main/java/com/esv/freight/customer/module/contract/controller/ContractOnlineRecordController.java
View file @
9d58d337
...
@@ -4,6 +4,7 @@ import com.esv.freight.customer.common.exception.EException;
...
@@ -4,6 +4,7 @@ import com.esv.freight.customer.common.exception.EException;
import
com.esv.freight.customer.common.response.EResponse
;
import
com.esv.freight.customer.common.response.EResponse
;
import
com.esv.freight.customer.common.validator.groups.ValidatorDetail
;
import
com.esv.freight.customer.common.validator.groups.ValidatorDetail
;
import
com.esv.freight.customer.module.contract.form.ContractOnlineRecordForm
;
import
com.esv.freight.customer.module.contract.form.ContractOnlineRecordForm
;
import
com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignDriverForm
;
import
com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignGoodsOwnerForm
;
import
com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignGoodsOwnerForm
;
import
com.esv.freight.customer.module.contract.service.ContractOnlineRecordService
;
import
com.esv.freight.customer.module.contract.service.ContractOnlineRecordService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -48,6 +49,18 @@ public class ContractOnlineRecordController {
...
@@ -48,6 +49,18 @@ public class ContractOnlineRecordController {
return
EResponse
.
ok
(
contractOnlineRecordService
.
goodsOwnerSign
(
form
));
return
EResponse
.
ok
(
contractOnlineRecordService
.
goodsOwnerSign
(
form
));
}
}
/**
* description 司机与平台的电子合同-司机签订
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/05/26 15:19
**/
@PostMapping
(
"/driver/sign"
)
public
EResponse
driverSign
(
@RequestBody
@Validated
ContractOnlineRecordSignDriverForm
form
)
throws
EException
{
return
EResponse
.
ok
(
contractOnlineRecordService
.
driverSign
(
form
));
}
/**
/**
* description 电子合同-平台签订
* description 电子合同-平台签订
* param [form]
* param [form]
...
...
src/main/java/com/esv/freight/customer/module/contract/form/ContractOnlineRecordSignDriverForm.java
0 → 100644
View file @
9d58d337
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.ContractOnlineRecordSignDriverForm
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/21 17:44
* @version:1.0
*/
@Data
public
class
ContractOnlineRecordSignDriverForm
{
/**
* 司机ID
*/
@NotNull
(
message
=
"参数driverId不能为空"
)
private
Long
driverId
;
/**
* 业务编号(订单号或运单号)
*/
@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
;
/**
* 发货时间
*/
@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
;
/**
* 货主签名数据,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/pojo/ContractOnlineDriverPojo.java
0 → 100644
View file @
9d58d337
package
com
.
esv
.
freight
.
customer
.
module
.
contract
.
pojo
;
import
lombok.Data
;
/**
* @description: 货主与平台签订合同的模板内容项
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.contract.pojo.ContractOnlineDriverPojo
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/22 10:05
* @version:1.0
*/
@Data
public
class
ContractOnlineDriverPojo
{
/**
* 合同编号
*/
private
String
contactNumber
;
/**
* 承运方
*/
private
String
driverName
;
/**
* 承运方身份证号码
*/
private
String
driverId
;
/**
* 承运方
*/
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
Object
driverSignImg
;
/**
* 委托方签字
*/
private
Object
platformFreightSealImg
;
/**
* 生效时间
*/
private
String
effectiveTime
;
}
src/main/java/com/esv/freight/customer/module/contract/service/ContractOnlineRecordService.java
View file @
9d58d337
...
@@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
...
@@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
import
com.esv.freight.customer.common.exception.EException
;
import
com.esv.freight.customer.common.exception.EException
;
import
com.esv.freight.customer.module.contract.entity.ContractOnlineRecordEntity
;
import
com.esv.freight.customer.module.contract.entity.ContractOnlineRecordEntity
;
import
com.esv.freight.customer.module.contract.form.ContractOnlineRecordForm
;
import
com.esv.freight.customer.module.contract.form.ContractOnlineRecordForm
;
import
com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignDriverForm
;
import
com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignGoodsOwnerForm
;
import
com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignGoodsOwnerForm
;
import
com.esv.freight.customer.module.contract.vo.ContractOnlineRecordSignDriverVO
;
import
com.esv.freight.customer.module.contract.vo.ContractOnlineRecordSignGoodsOwnerVO
;
import
com.esv.freight.customer.module.contract.vo.ContractOnlineRecordSignGoodsOwnerVO
;
import
com.esv.freight.customer.module.contract.vo.ContractOnlineRecordVO
;
import
com.esv.freight.customer.module.contract.vo.ContractOnlineRecordVO
;
...
@@ -26,6 +28,15 @@ public interface ContractOnlineRecordService extends IService<ContractOnlineReco
...
@@ -26,6 +28,15 @@ public interface ContractOnlineRecordService extends IService<ContractOnlineReco
**/
**/
ContractOnlineRecordSignGoodsOwnerVO
goodsOwnerSign
(
ContractOnlineRecordSignGoodsOwnerForm
form
);
ContractOnlineRecordSignGoodsOwnerVO
goodsOwnerSign
(
ContractOnlineRecordSignGoodsOwnerForm
form
);
/**
* description 司机与平台的电子合同-司机签订
* param [form]
* return com.esv.freight.customer.module.contract.vo.ContractOnlineRecordSignDriverVO
* author Administrator
* createTime 2020/05/26 15:03
**/
ContractOnlineRecordSignDriverVO
driverSign
(
ContractOnlineRecordSignDriverForm
form
);
/**
/**
* description 根据合同编号获取合同信息
* description 根据合同编号获取合同信息
* param [contractNumber]
* param [contractNumber]
...
...
src/main/java/com/esv/freight/customer/module/contract/service/impl/ContractOnlineRecordServiceImpl.java
View file @
9d58d337
...
@@ -23,14 +23,19 @@ import com.esv.freight.customer.module.contract.dao.ContractOnlineRecordDao;
...
@@ -23,14 +23,19 @@ 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.ContractOnlinePlatformDataEntity
;
import
com.esv.freight.customer.module.contract.entity.ContractOnlineRecordEntity
;
import
com.esv.freight.customer.module.contract.entity.ContractOnlineRecordEntity
;
import
com.esv.freight.customer.module.contract.entity.ContractOnlineTemplateEntity
;
import
com.esv.freight.customer.module.contract.entity.ContractOnlineTemplateEntity
;
import
com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignDriverForm
;
import
com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignGoodsOwnerForm
;
import
com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignGoodsOwnerForm
;
import
com.esv.freight.customer.module.contract.pojo.ContractOnlineDriverPojo
;
import
com.esv.freight.customer.module.contract.pojo.ContractOnlineGoodsOwnerPojo
;
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.pojo.ContractOnlinePlatformPojo
;
import
com.esv.freight.customer.module.contract.service.ContractOnlinePlatformDataService
;
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.ContractOnlineRecordService
;
import
com.esv.freight.customer.module.contract.service.ContractOnlineTemplateService
;
import
com.esv.freight.customer.module.contract.service.ContractOnlineTemplateService
;
import
com.esv.freight.customer.module.contract.vo.ContractOnlineRecordSignDriverVO
;
import
com.esv.freight.customer.module.contract.vo.ContractOnlineRecordSignGoodsOwnerVO
;
import
com.esv.freight.customer.module.contract.vo.ContractOnlineRecordSignGoodsOwnerVO
;
import
com.esv.freight.customer.module.contract.vo.ContractOnlineRecordVO
;
import
com.esv.freight.customer.module.contract.vo.ContractOnlineRecordVO
;
import
com.esv.freight.customer.module.driver.dto.DriverDetailDto
;
import
com.esv.freight.customer.module.driver.service.DriverAccountService
;
import
com.esv.freight.customer.module.goodsowner.GoodsOwnerConstants
;
import
com.esv.freight.customer.module.goodsowner.GoodsOwnerConstants
;
import
com.esv.freight.customer.module.goodsowner.dto.AccountInfoDto
;
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.form.AccountForm
;
...
@@ -64,10 +69,10 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
...
@@ -64,10 +69,10 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
private
static
final
Long
CONTRACT_CACHE_TIME
=
86400L
;
private
static
final
Long
CONTRACT_CACHE_TIME
=
86400L
;
/**
/**
* 货主签名图像宽度、长度
* 货主
/司机
签名图像宽度、长度
**/
**/
private
static
final
int
GOODS_OWN
ER_SIGN_WIDTH
=
150
;
private
static
final
int
CUSTOM
ER_SIGN_WIDTH
=
150
;
private
static
final
int
GOODS_OWN
ER_SIGN_HEIGHT
=
60
;
private
static
final
int
CUSTOM
ER_SIGN_HEIGHT
=
60
;
/**
/**
* 平台公章图像宽度、长度
* 平台公章图像宽度、长度
...
@@ -81,19 +86,21 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
...
@@ -81,19 +86,21 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
private
RedisComponent
redisComponent
;
private
RedisComponent
redisComponent
;
private
ContractOnlineTemplateService
contractOnlineTemplateService
;
private
ContractOnlineTemplateService
contractOnlineTemplateService
;
private
GoodsOwnerAccountService
goodsOwnerAccountService
;
private
GoodsOwnerAccountService
goodsOwnerAccountService
;
private
DriverAccountService
driverAccountService
;
private
ContractOnlinePlatformDataService
contractOnlinePlatformDataService
;
private
ContractOnlinePlatformDataService
contractOnlinePlatformDataService
;
@Autowired
@Autowired
public
ContractOnlineRecordServiceImpl
(
ErrorMessageComponent
errorMessageComponent
,
FeignFileService
feignFileService
,
public
ContractOnlineRecordServiceImpl
(
ErrorMessageComponent
errorMessageComponent
,
FeignFileService
feignFileService
,
FeignBaseService
feignBaseService
,
RedisComponent
redisComponent
,
FeignBaseService
feignBaseService
,
RedisComponent
redisComponent
,
ContractOnlineTemplateService
contractOnlineTemplateService
,
GoodsOwnerAccountService
goodsOwnerAccountService
,
ContractOnlineTemplateService
contractOnlineTemplateService
,
GoodsOwnerAccountService
goodsOwnerAccountService
,
ContractOnlinePlatformDataService
contractOnlinePlatformDataService
)
{
DriverAccountService
driverAccountService
,
ContractOnlinePlatformDataService
contractOnlinePlatformDataService
)
{
this
.
errorMessageComponent
=
errorMessageComponent
;
this
.
errorMessageComponent
=
errorMessageComponent
;
this
.
feignFileService
=
feignFileService
;
this
.
feignFileService
=
feignFileService
;
this
.
feignBaseService
=
feignBaseService
;
this
.
feignBaseService
=
feignBaseService
;
this
.
redisComponent
=
redisComponent
;
this
.
redisComponent
=
redisComponent
;
this
.
contractOnlineTemplateService
=
contractOnlineTemplateService
;
this
.
contractOnlineTemplateService
=
contractOnlineTemplateService
;
this
.
goodsOwnerAccountService
=
goodsOwnerAccountService
;
this
.
goodsOwnerAccountService
=
goodsOwnerAccountService
;
this
.
driverAccountService
=
driverAccountService
;
this
.
contractOnlinePlatformDataService
=
contractOnlinePlatformDataService
;
this
.
contractOnlinePlatformDataService
=
contractOnlinePlatformDataService
;
}
}
...
@@ -105,7 +112,7 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
...
@@ -105,7 +112,7 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
accountForm
.
setId
(
form
.
getGoodsOwnerId
());
accountForm
.
setId
(
form
.
getGoodsOwnerId
());
AccountInfoDto
accountInfo
=
goodsOwnerAccountService
.
getAccountInfo
(
accountForm
);
AccountInfoDto
accountInfo
=
goodsOwnerAccountService
.
getAccountInfo
(
accountForm
);
if
(
null
==
accountInfo
)
{
if
(
null
==
accountInfo
)
{
throw
new
EException
(
1001
,
errorMessageComponent
.
getContractOnlineGoodsOwner
Add
1001
());
throw
new
EException
(
1001
,
errorMessageComponent
.
getContractOnlineGoodsOwner
Sign
1001
());
}
}
// 2:获取电子合同模板数据
// 2:获取电子合同模板数据
...
@@ -173,6 +180,79 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
...
@@ -173,6 +180,79 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
return
vo
;
return
vo
;
}
}
@Override
public
ContractOnlineRecordSignDriverVO
driverSign
(
ContractOnlineRecordSignDriverForm
form
)
{
// 1:获取司机信息
DriverDetailDto
accountInfo
=
driverAccountService
.
getDriverDetailById
(
form
.
getDriverId
());
if
(
null
==
accountInfo
)
{
throw
new
EException
(
1001
,
errorMessageComponent
.
getContractOnlineDriverSign1001
());
}
// 2:获取电子合同模板数据
String
contractTemplateData
=
this
.
getContractOnlineTemplateEntity
(
ContractConstants
.
CONTRACT_TYPE_DRIVER
);
byte
[]
contractTemplateBytes
=
Base64
.
getDecoder
().
decode
(
contractTemplateData
);
// 3:填充电子合同模板
ByteArrayOutputStream
byteArrayOutputStream
=
new
ByteArrayOutputStream
();
ContractOnlineDriverPojo
pojo
;
byte
[]
signBytes
;
XWPFTemplate
template
=
null
;
try
{
template
=
XWPFTemplate
.
compile
(
InputStreamUtils
.
byte2InputStream
(
contractTemplateBytes
));
pojo
=
this
.
getDriverSignDataMap
(
form
,
accountInfo
);
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:保存司机签订后的电子合同文件
String
contractNumber
=
pojo
.
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:保存货主签订后的电子合同记录
ContractOnlineRecordEntity
onlineRecordEntity
=
new
ContractOnlineRecordEntity
();
onlineRecordEntity
.
setContractType
(
ContractConstants
.
CONTRACT_TYPE_DRIVER
);
onlineRecordEntity
.
setSourceFileId
(
feignResJson
.
getString
(
"id"
));
onlineRecordEntity
.
setSourceFileUrl
(
feignResJson
.
getString
(
"url"
));
onlineRecordEntity
.
setContractNumber
(
contractNumber
);
onlineRecordEntity
.
setBusinessNumber
(
form
.
getBusinessNumber
());
onlineRecordEntity
.
setCustomerId
(
form
.
getDriverId
());
onlineRecordEntity
.
setCustomerSignTime
(
new
Date
());
onlineRecordEntity
.
setSignComplete
(
ContractConstants
.
CONTRACT_SIGN_COMPLETE_NO
);
this
.
baseMapper
.
insert
(
onlineRecordEntity
);
// 6:异步保存线上合同目标文件(PDF)及信息
this
.
asyncSaveTargetFileInfo
(
MDC
.
get
(
"traceId"
),
onlineRecordEntity
,
signBytes
);
// 7:返回
ContractOnlineRecordSignDriverVO
vo
=
new
ContractOnlineRecordSignDriverVO
();
vo
.
setContractNumber
(
contractNumber
);
return
vo
;
}
@Override
@Override
public
ContractOnlineRecordVO
getContractInfoByNumber
(
String
contractNumber
)
{
public
ContractOnlineRecordVO
getContractInfoByNumber
(
String
contractNumber
)
{
ContractOnlineRecordEntity
recordEntity
=
this
.
baseMapper
.
selectOne
(
new
LambdaQueryWrapper
<
ContractOnlineRecordEntity
>()
ContractOnlineRecordEntity
recordEntity
=
this
.
baseMapper
.
selectOne
(
new
LambdaQueryWrapper
<
ContractOnlineRecordEntity
>()
...
@@ -197,7 +277,8 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
...
@@ -197,7 +277,8 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
}
}
}
}
}
else
{
}
else
{
// TODO,司机签订的合同
DriverDetailDto
driverDetailDto
=
driverAccountService
.
getDriverDetailById
(
recordEntity
.
getCustomerId
());
customerName
=
driverDetailDto
.
getName
();
}
}
vo
.
setCustomerName
(
customerName
);
vo
.
setCustomerName
(
customerName
);
vo
.
setContractFileId
(
recordEntity
.
getTargetFileId
());
vo
.
setContractFileId
(
recordEntity
.
getTargetFileId
());
...
@@ -245,7 +326,44 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
...
@@ -245,7 +326,44 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
pojo
.
setPlatformName
(
"{{platformName}}"
);
pojo
.
setPlatformName
(
"{{platformName}}"
);
pojo
.
setPlatformId
(
"{{platformId}}"
);
pojo
.
setPlatformId
(
"{{platformId}}"
);
pojo
.
setEffectiveTime
(
"{{effectiveTime}}"
);
pojo
.
setEffectiveTime
(
"{{effectiveTime}}"
);
pojo
.
setGoodsOwnerSignImg
(
new
PictureRenderData
(
GOODS_OWNER_SIGN_WIDTH
,
GOODS_OWNER_SIGN_HEIGHT
,
".png"
,
Base64
.
getDecoder
().
decode
(
form
.
getSignData
())));
pojo
.
setGoodsOwnerSignImg
(
new
PictureRenderData
(
CUSTOMER_SIGN_WIDTH
,
CUSTOMER_SIGN_HEIGHT
,
".png"
,
Base64
.
getDecoder
().
decode
(
form
.
getSignData
())));
pojo
.
setPlatformFreightSealImg
(
"{{@platformFreightSealImg}}"
);
return
pojo
;
}
/**
* description 获取司机签订合同时的数据
* param [form, accountInfo]
* return com.esv.freight.customer.module.contract.pojo.ContractOnlineDriverPojo
* author Administrator
* createTime 2020/05/26 15:16
**/
private
ContractOnlineDriverPojo
getDriverSignDataMap
(
ContractOnlineRecordSignDriverForm
form
,
DriverDetailDto
accountInfo
)
{
ContractOnlineDriverPojo
pojo
=
new
ContractOnlineDriverPojo
();
BeanUtils
.
copyProperties
(
form
,
pojo
);
// 设置合同编号
JSONObject
feignReqJson
=
new
JSONObject
();
feignReqJson
.
put
(
"prefix"
,
"SJHT"
);
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
(
"生成电子合同失败[获取合同编号失败]"
);
}
// 设置司机信息
pojo
.
setDriverId
(
accountInfo
.
getIdCard
());
pojo
.
setDriverName
(
accountInfo
.
getName
());
pojo
.
setPlatformName
(
"{{platformName}}"
);
pojo
.
setPlatformId
(
"{{platformId}}"
);
pojo
.
setEffectiveTime
(
"{{effectiveTime}}"
);
pojo
.
setDriverSignImg
(
new
PictureRenderData
(
CUSTOMER_SIGN_WIDTH
,
CUSTOMER_SIGN_HEIGHT
,
".png"
,
Base64
.
getDecoder
().
decode
(
form
.
getSignData
())));
pojo
.
setPlatformFreightSealImg
(
"{{@platformFreightSealImg}}"
);
pojo
.
setPlatformFreightSealImg
(
"{{@platformFreightSealImg}}"
);
return
pojo
;
return
pojo
;
...
@@ -258,7 +376,7 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
...
@@ -258,7 +376,7 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
ContractOnlineRecordEntity
contractOnlineRecordEntity
=
this
.
baseMapper
.
selectOne
(
new
LambdaQueryWrapper
<
ContractOnlineRecordEntity
>()
ContractOnlineRecordEntity
contractOnlineRecordEntity
=
this
.
baseMapper
.
selectOne
(
new
LambdaQueryWrapper
<
ContractOnlineRecordEntity
>()
.
eq
(
ContractOnlineRecordEntity:
:
getContractNumber
,
contractNumber
));
.
eq
(
ContractOnlineRecordEntity:
:
getContractNumber
,
contractNumber
));
if
(
null
==
contractOnlineRecordEntity
)
{
if
(
null
==
contractOnlineRecordEntity
)
{
throw
new
EException
(
1001
,
errorMessageComponent
.
getContractOnline
GoodsOwner
PlatformSign1001
());
throw
new
EException
(
1001
,
errorMessageComponent
.
getContractOnlinePlatformSign1001
());
}
}
// 2:获取合同数据
// 2:获取合同数据
...
@@ -432,7 +550,7 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
...
@@ -432,7 +550,7 @@ public class ContractOnlineRecordServiceImpl extends ServiceImpl<ContractOnlineR
// 保存PDF文件
// 保存PDF文件
JSONObject
feignReqJson
=
new
JSONObject
();
JSONObject
feignReqJson
=
new
JSONObject
();
feignReqJson
.
put
(
"fileType"
,
"pdf"
);
feignReqJson
.
put
(
"fileType"
,
"pdf"
);
feignReqJson
.
put
(
"fileName"
,
"电子合同-
平台签名-
"
+
contractNumber
+
".pdf"
);
feignReqJson
.
put
(
"fileName"
,
"电子合同-"
+
contractNumber
+
".pdf"
);
feignReqJson
.
put
(
"fileData"
,
Base64
.
getEncoder
().
encodeToString
(
targetFileBytes
));
feignReqJson
.
put
(
"fileData"
,
Base64
.
getEncoder
().
encodeToString
(
targetFileBytes
));
JSONObject
feignResJson
;
JSONObject
feignResJson
;
try
{
try
{
...
...
src/main/java/com/esv/freight/customer/module/contract/vo/ContractOnlineRecordSignDriverVO.java
0 → 100644
View file @
9d58d337
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.ContractOnlineRecordSignDriverVO
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/21 17:54
* @version:1.0
*/
@Data
public
class
ContractOnlineRecordSignDriverVO
{
/**
* 合同编号
*/
private
String
contractNumber
;
@Override
public
String
toString
()
{
return
ToStringBuilder
.
reflectionToString
(
this
,
ToStringStyle
.
JSON_STYLE
);
}
}
src/main/resources/application-dev.yml
View file @
9d58d337
...
@@ -249,7 +249,11 @@ error-message:
...
@@ -249,7 +249,11 @@ error-message:
goods-owner
:
goods-owner
:
sign
:
sign
:
1001
:
无效的货主ID
1001
:
无效的货主ID
platform-sign
:
driver
:
sign
:
1001
:
无效的司机ID
platform
:
sign
:
1001
:
无效的合同编号
1001
:
无效的合同编号
get-by-number
:
get-by-number
:
1001
:
无效的合同编号
1001
:
无效的合同编号
\ No newline at end of file
src/main/resources/application-test.yml
View file @
9d58d337
...
@@ -249,7 +249,11 @@ error-message:
...
@@ -249,7 +249,11 @@ error-message:
goods-owner
:
goods-owner
:
sign
:
sign
:
1001
:
无效的货主ID
1001
:
无效的货主ID
platform-sign
:
driver
:
sign
:
1001
:
无效的司机ID
platform
:
sign
:
1001
:
无效的合同编号
1001
:
无效的合同编号
get-by-number
:
get-by-number
:
1001
:
无效的合同编号
1001
:
无效的合同编号
\ No newline at end of file
src/main/resources/logback-spring.xml
View file @
9d58d337
...
@@ -43,7 +43,7 @@
...
@@ -43,7 +43,7 @@
<!-- mybatis sql日志 日志的级别需要是DEBUG -->
<!-- mybatis sql日志 日志的级别需要是DEBUG -->
<!-- 日志打印的包的范围,及分类日志文件存储 -->
<!-- 日志打印的包的范围,及分类日志文件存储 -->
<logger
name=
"com.esv"
level=
"
INFO
"
additivity=
"false"
>
<logger
name=
"com.esv"
level=
"
DEBUG
"
additivity=
"false"
>
<appender-ref
ref=
"CONSOLE_APPENDER"
/>
<appender-ref
ref=
"CONSOLE_APPENDER"
/>
<appender-ref
ref=
"FILE_APPENDER"
/>
<appender-ref
ref=
"FILE_APPENDER"
/>
</logger>
</logger>
...
...
src/test/java/com/esv/freight/customer/module/contract/controller/ContractOnlineRecordControllerTest.java
View file @
9d58d337
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import
com.esv.freight.customer.BaseTestController
;
import
com.esv.freight.customer.BaseTestController
;
import
com.esv.freight.customer.common.response.ECode
;
import
com.esv.freight.customer.common.response.ECode
;
import
com.esv.freight.customer.module.contract.form.ContractOnlineRecordForm
;
import
com.esv.freight.customer.module.contract.form.ContractOnlineRecordForm
;
import
com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignDriverForm
;
import
com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignGoodsOwnerForm
;
import
com.esv.freight.customer.module.contract.form.ContractOnlineRecordSignGoodsOwnerForm
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.io.IOUtils
;
...
@@ -139,7 +140,7 @@ public class ContractOnlineRecordControllerTest extends BaseTestController {
...
@@ -139,7 +140,7 @@ public class ContractOnlineRecordControllerTest extends BaseTestController {
// 构造数据
// 构造数据
ContractOnlineRecordForm
form
=
new
ContractOnlineRecordForm
();
ContractOnlineRecordForm
form
=
new
ContractOnlineRecordForm
();
form
.
setContractNumber
(
"
HZHT20200526000002
"
);
form
.
setContractNumber
(
"
SJHT20200526000001
"
);
MvcResult
mvcResult
=
this
.
getMockMvc
().
perform
(
MockMvcRequestBuilders
.
post
(
url
)
MvcResult
mvcResult
=
this
.
getMockMvc
().
perform
(
MockMvcRequestBuilders
.
post
(
url
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
...
@@ -191,7 +192,7 @@ public class ContractOnlineRecordControllerTest extends BaseTestController {
...
@@ -191,7 +192,7 @@ public class ContractOnlineRecordControllerTest extends BaseTestController {
// 构造数据
// 构造数据
ContractOnlineRecordForm
form
=
new
ContractOnlineRecordForm
();
ContractOnlineRecordForm
form
=
new
ContractOnlineRecordForm
();
form
.
setContractNumber
(
"
HZHT20200526000002
"
);
form
.
setContractNumber
(
"
SJHT20200526000001
"
);
MvcResult
mvcResult
=
this
.
getMockMvc
().
perform
(
MockMvcRequestBuilders
.
post
(
url
)
MvcResult
mvcResult
=
this
.
getMockMvc
().
perform
(
MockMvcRequestBuilders
.
post
(
url
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
...
@@ -234,4 +235,88 @@ public class ContractOnlineRecordControllerTest extends BaseTestController {
...
@@ -234,4 +235,88 @@ public class ContractOnlineRecordControllerTest extends BaseTestController {
JSONObject
result
=
JSONObject
.
parseObject
(
responseStr
);
JSONObject
result
=
JSONObject
.
parseObject
(
responseStr
);
Assert
.
assertEquals
(
1001
,
result
.
getIntValue
(
"code"
));
Assert
.
assertEquals
(
1001
,
result
.
getIntValue
(
"code"
));
}
}
/**
* 司机与平台的电子合同-司机签订
**/
@Test
public
void
a1_driverSign_success_test
()
throws
Exception
{
String
url
=
"/contract/online/driver/sign"
;
// 构造数据
ContractOnlineRecordSignDriverForm
form
=
new
ContractOnlineRecordSignDriverForm
();
form
.
setDriverId
(
1L
);
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"
);
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_driverSign_failure_test
()
throws
Exception
{
String
url
=
"/contract/online/driver/sign"
;
// 构造数据
ContractOnlineRecordSignDriverForm
form
=
new
ContractOnlineRecordSignDriverForm
();
form
.
setDriverId
(
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"
);
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"
));
}
}
}
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