Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Fedex
/
iClear-api
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
zelong.shao
2023-09-05 15:33:23 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
028024a8a6a2b7e32994e1542e1341b60f3a3fdf
028024a8
1 parent
e4ed6f27
API提交数据修改
2023年9月5日15:31:55 szl
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
244 additions
and
43 deletions
src/main/java/com/erry/iclear/dateInterface/api/CustomsDataInterface.java
src/main/java/com/erry/iclear/dateInterface/api/FedexDataInterface.java
src/main/java/com/erry/iclear/dateInterface/common/Constant.java
src/main/java/com/erry/iclear/dateInterface/entity/ChmConsignment.java
src/main/java/com/erry/iclear/dateInterface/repository/ChmConsignmentRepository.java
src/main/java/com/erry/iclear/dateInterface/repository/OrganizationRepository.java
src/main/java/com/erry/iclear/dateInterface/repository/TaskInfoRepository.java
src/main/java/com/erry/iclear/dateInterface/service/ChmConsignmentService.java
src/main/java/com/erry/iclear/dateInterface/service/FedexService.java
src/main/java/com/erry/iclear/dateInterface/service/MawbService.java
src/main/java/com/erry/iclear/dateInterface/api/CustomsDataInterface.java
View file @
028024a
package
com
.
erry
.
iclear
.
dateInterface
.
api
;
import
com.erry.iclear.dateInterface.api.request.MawbDetail
;
import
com.erry.iclear.dateInterface.enums.ErrorCodeEnum
;
import
com.erry.iclear.dateInterface.api.request.Mawb
;
import
com.erry.iclear.dateInterface.api.response.ResultRS
;
import
com.erry.iclear.dateInterface.entity.IClearApiLog
;
import
com.erry.iclear.dateInterface.enums.ErrorCodeEnum
;
import
com.erry.iclear.dateInterface.repository.MawbAdd
;
import
com.erry.iclear.dateInterface.service.*
;
import
com.erry.iclear.dateInterface.util.StringUtil
;
...
...
@@ -17,7 +16,9 @@ import org.springframework.validation.annotation.Validated;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.*
;
import
java.util.Date
;
import
java.util.Map
;
import
java.util.Objects
;
/**
* @author Administrator
...
...
@@ -118,7 +119,7 @@ public class CustomsDataInterface {
//2、TODO 校验主单
sw
.
start
(
"checkMawb"
);
result
=
mawbService
.
checkMawb
(
mawb
);
result
=
mawbService
.
checkMawb
(
mawb
,
appId
);
if
(!
result
.
getSuccess
()){
return
result
;
}
...
...
src/main/java/com/erry/iclear/dateInterface/api/FedexDataInterface.java
View file @
028024a
...
...
@@ -110,7 +110,7 @@ public class FedexDataInterface {
sw
.
stop
();
sw
.
start
(
"checkFedexMawb"
);
ResultRS
iclearCheckRs
=
fedexService
.
checkFedexMawb
(
saveMawbFedexResult
,
appInfo
);
ResultRS
iclearCheckRs
=
fedexService
.
checkFedexMawb
(
saveMawbFedexResult
,
appInfo
,
appId
);
//返回结果
ResultRS
result
=
new
ResultRS
(
Boolean
.
TRUE
,
ErrorCodeEnum
.
SUCCESS
.
getCode
(),
null
,
null
);
if
(
nonEmptyCheck
.
getSuccess
()
&&
iclearCheckRs
.
getSuccess
()){
...
...
@@ -195,7 +195,7 @@ public class FedexDataInterface {
//2、TODO 校验主单
sw
.
start
(
"checkFedexMawb"
);
result
=
fedexService
.
checkFedexMawb
(
saveMawbFedexResult
,
null
);
result
=
fedexService
.
checkFedexMawb
(
saveMawbFedexResult
,
null
,
appId
);
if
(!
result
.
getSuccess
()){
return
result
;
}
...
...
@@ -216,6 +216,7 @@ public class FedexDataInterface {
return
result
;
}
sw
.
stop
();
log
.
info
(
"saveIClearApiLogResult.getCreateTime():"
+
saveIClearApiLogResult
.
getCreateTime
());
ChmConsignment
chmGetId
=
chmConsignmentRepository
.
findChmConsignmentByConsignmentCode
(
saveIClearApiLogResult
.
getBillNo
(),
saveIClearApiLogResult
.
getCreateTime
());
//调用IClear接口进行运单推送EXP002
String
objJson
=
JsonToJava
.
toJson
(
chmGetId
.
getId
());
...
...
src/main/java/com/erry/iclear/dateInterface/common/Constant.java
View file @
028024a
...
...
@@ -100,4 +100,21 @@ public class Constant {
* 监管条件
*/
public
static
final
String
supervise_condition
=
"superviseRestrict"
;
/**
* DM004接收取件信息
*/
public
static
final
String
FILE_TYPE_GET_PICK_INFORMATION
=
"fileType_5"
;
//OSPR状态
/**
* 未完成
*/
public
static
final
String
OSPR_STATUS_INCOMPLETED
=
"OSPRStatus_1"
;
//扫描代码
/**
* C类已取件
*/
public
static
final
String
SCAN_CODE_TAKEN_PART
=
"scanCode_1"
;
}
...
...
src/main/java/com/erry/iclear/dateInterface/entity/ChmConsignment.java
View file @
028024a
...
...
@@ -3,7 +3,6 @@ package com.erry.iclear.dateInterface.entity;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
lombok.Data
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
javax.persistence.*
;
import
java.io.Serializable
;
...
...
@@ -413,6 +412,62 @@ public class ChmConsignment implements Serializable {
@Column
(
name
=
"EANNO"
)
private
String
eanNo
;
/**
* 扫描代码ID
*/
@JsonIgnore
@ManyToOne
(
targetEntity
=
DictionaryEntries
.
class
)
@JoinColumn
(
name
=
"SCAN_CODE_ID"
)
private
DictionaryEntries
scanCodeDic
;
/**
* 扫描代码
*/
@Column
(
name
=
"SCAN_CODE"
)
private
String
scanCode
;
/**
* 扫描状态日期
*/
@Column
(
name
=
"SCAN_STATUS_TIME"
)
private
Date
scanStatusTime
;
/**
* 运单类型ID
*/
// @JsonIgnore
// @ManyToOne(targetEntity = DictionaryEntries.class)
// @JoinColumn(name = "CONS_TYPE_ID")
// private DictionaryEntries consTypeDic;
/**
* OSPR状态ID
*/
@JsonIgnore
@ManyToOne
(
targetEntity
=
DictionaryEntries
.
class
)
@JoinColumn
(
name
=
"OSPR_STATUS_ID"
)
private
DictionaryEntries
osprStatusDic
;
/**
* 站点
*/
@JsonIgnore
@ManyToOne
(
targetEntity
=
Organization
.
class
)
@JoinColumn
(
name
=
"STATION_ID"
)
private
Organization
station
;
/**
* 站点名称
*/
@Column
(
name
=
"STATION_NAME"
)
private
String
stationName
;
/**
* 取件日期
*/
@Column
(
name
=
"PICK_UP_DATE"
)
private
Date
pickUpDate
;
@OneToMany
(
mappedBy
=
"chmConsignment"
,
cascade
=
CascadeType
.
ALL
)
private
List
<
ChmConsignmentDetail
>
chmConsignmentDetailList
;
...
...
src/main/java/com/erry/iclear/dateInterface/repository/ChmConsignmentRepository.java
View file @
028024a
...
...
@@ -4,7 +4,6 @@ import com.erry.iclear.dateInterface.entity.ChmConsignment;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.query.Param
;
import
org.springframework.stereotype.Repository
;
import
java.util.Date
;
...
...
@@ -33,6 +32,15 @@ public interface ChmConsignmentRepository extends JpaSpecificationExecutor<ChmCo
public
ChmConsignment
findChmConsignmentByConsignmentCode
(
String
consignmentCode
,
Date
startDate
);
/**
* 根据运单号查找多条数据
* @param consignmentCode
* @param startDate
* @return
*/
@Query
(
nativeQuery
=
true
,
value
=
"select * from T_CHM_CONSIGNMENT where CONSIGNMENT_CODE = ?1 and CREATE_TIME>= ?2 and CREATOR = ?3"
)
public
List
<
ChmConsignment
>
findChmConsignmentByConsignmentCodes
(
String
consignmentCode
,
Date
startDate
,
String
creator
);
/**
* 根据运单ID查运单
* @param id
* @return
...
...
src/main/java/com/erry/iclear/dateInterface/repository/OrganizationRepository.java
0 → 100644
View file @
028024a
package
com
.
erry
.
iclear
.
dateInterface
.
repository
;
import
com.erry.iclear.dateInterface.entity.Organization
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.query.Param
;
import
org.springframework.stereotype.Repository
;
@Repository
public
interface
OrganizationRepository
extends
JpaSpecificationExecutor
<
Organization
>,
JpaRepository
<
Organization
,
Long
>
{
@Query
(
nativeQuery
=
true
,
value
=
"select top 1 * from T_AU_ORGANIZATION o where o.NAME = :name "
)
public
Organization
findOrganizationByName
(
@Param
(
"name"
)
String
name
);
}
src/main/java/com/erry/iclear/dateInterface/repository/TaskInfoRepository.java
0 → 100644
View file @
028024a
package
com
.
erry
.
iclear
.
dateInterface
.
repository
;
import
com.erry.iclear.dateInterface.entity.TaskInfo
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.query.Param
;
import
org.springframework.stereotype.Repository
;
@Repository
public
interface
TaskInfoRepository
extends
JpaSpecificationExecutor
<
TaskInfo
>,
JpaRepository
<
TaskInfo
,
Long
>
{
@Query
(
nativeQuery
=
true
,
value
=
"select top 1 * from T_TASK_INFO info where info.FILE_TYPE_ID = :fileTypeId and "
+
"info.AWB_NUMBER = :consignmentCode order by CREATE_TIME DESC"
)
public
TaskInfo
findTaskInfoByConsignment
(
@Param
(
"fileTypeId"
)
Long
taskStatusId
,
@Param
(
"consignmentCode"
)
String
consignmentCode
);
}
src/main/java/com/erry/iclear/dateInterface/service/ChmConsignmentService.java
View file @
028024a
package
com
.
erry
.
iclear
.
dateInterface
.
service
;
//import cn.hutool.core.date.DateUtil;
import
com.erry.iclear.dateInterface.api.request.MawbDetail
;
import
com.erry.iclear.dateInterface.enums.ErrorCodeEnum
;
import
com.erry.iclear.dateInterface.api.request.FedexMawb
;
import
com.erry.iclear.dateInterface.api.request.FedexReceipt
;
import
com.erry.iclear.dateInterface.api.request.Mawb
;
import
com.erry.iclear.dateInterface.api.response.ResultRS
;
import
com.erry.iclear.dateInterface.common.Constant
;
import
com.erry.iclear.dateInterface.entity.*
;
import
com.erry.iclear.dateInterface.repository.ChmConsignmentRepository
;
import
com.erry.iclear.dateInterface.repository.DictionaryEntriesRepository
;
import
com.erry.iclear.dateInterface.repository.SysUserRepository
;
import
com.erry.iclear.dateInterface.enums.ErrorCodeEnum
;
import
com.erry.iclear.dateInterface.repository.*
;
import
com.erry.iclear.dateInterface.util.DateUtils
;
import
com.erry.iclear.dateInterface.util.NumberUtils
;
import
com.erry.iclear.dateInterface.util.StringUtil
;
...
...
@@ -20,13 +18,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
javax.transaction.Transactional
;
import
javax.validation.Valid
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
* @author Administrator
...
...
@@ -51,6 +46,12 @@ public class ChmConsignmentService {
@Autowired
private
SysUserRepository
sysUserRepository
;
@Autowired
private
TaskInfoRepository
taskInfoRepository
;
@Autowired
private
OrganizationRepository
organizationRepository
;
/**
* 转换主单
* @return
...
...
@@ -232,7 +233,7 @@ public class ChmConsignmentService {
//推送时间作为创建时间,可以用来校验数据的有序性,如果新的推送时间小于已有的创建时间,就不更新数据
result
.
setCreateTime
(
new
Date
());
result
.
setUpdateTime
(
pushTime
);
result
.
setUpdateTime
(
new
Date
()
);
result
.
setCreator
(
creator
);
}
catch
(
Exception
e
){
...
...
@@ -294,12 +295,9 @@ public class ChmConsignmentService {
//推送时间作为创建时间,可以用来校验数据的有序性,如果新的推送时间小于已有的创建时间,就不更新数据
result
.
setCreateTime
(
new
Date
());
result
.
setUpdateTime
(
pushTime
);
if
(!
creator
.
equals
(
"IDE-ICLEAR-API"
)){
SysUser
sysUser
=
sysUserRepository
.
findUserByLoginName
(
creator
);
result
.
setCreatorId
(
sysUser
);
result
.
setCreator
(
sysUser
.
getLoginName
());
}
}
catch
(
Exception
e
){
result
=
null
;
...
...
@@ -492,6 +490,20 @@ public class ChmConsignmentService {
}
/**
* 根据运单号查找多条数据
* @param consignmentCode
* @return
*/
public
List
<
ChmConsignment
>
findChmConsignmentByConsignmentCodes
(
String
consignmentCode
,
Date
startDate
,
String
creator
){
try
{
return
chmConsignmentRepository
.
findChmConsignmentByConsignmentCodes
(
consignmentCode
,
startDate
,
creator
);
}
catch
(
Exception
e
){
log
.
error
(
"findChmConsignmentByConsignmentCode() error:"
+
e
.
getMessage
());
}
return
null
;
}
/**
* 保存或更新 iclear中的运单信息
* @param mawb
* @param timeStamp
...
...
@@ -513,10 +525,29 @@ public class ChmConsignmentService {
chmConsignment
.
setChmConsignmentDetailList
(
chmConsignmentDetailList
);
//2、校验 7天+运单 ,如果有数据并且 还未报关就更新,如果数据就插入
ChmConsignment
chmConsignmentDB
=
this
.
findChmConsignmentByConsignmentCode
(
chmConsignment
.
getConsignmentCode
(),
DateUtils
.
addDate
(
DateUtils
.
getCurrentDate
(),-
7
));
ChmConsignment
chmConsignmentDB
=
null
;
// ChmConsignment chmConsignmentDB=this.findChmConsignmentByConsignmentCode(chmConsignment.getConsignmentCode(), DateUtils.addDate(DateUtils.getCurrentDate(),-7));
List
<
ChmConsignment
>
chmConsignmentDBs
=
this
.
findChmConsignmentByConsignmentCodes
(
chmConsignment
.
getConsignmentCode
(),
DateUtils
.
addDate
(
DateUtils
.
getCurrentDate
(),-
7
),
creator
);
List
<
ChmConsignment
>
newChmConsignments
=
new
ArrayList
<
ChmConsignment
>();
for
(
ChmConsignment
chmConsignments
:
chmConsignmentDBs
)
{
//如果有该用户曾经提交过得,运单状态为预审不通过或者中心审核已通过并且没有dm004的优先覆盖
if
(
chmConsignments
.
getConsStatusDic
().
getCode
().
equals
(
"transferWaybillStatus_3"
)){
chmConsignmentDB
=
chmConsignments
;
break
;
}
else
if
((
chmConsignments
.
getConsStatusDic
().
getCode
().
equals
(
"transferWaybillStatus_15"
)
||
chmConsignments
.
getConsStatusDic
().
getCode
().
equals
(
"transferWaybillStatus_1"
)
||
chmConsignments
.
getConsStatusDic
().
getCode
().
equals
(
"transferWaybillStatus_24"
))){
//如果有新建、sep新建、草稿状态的,先存下来,按创建日期排序覆盖最后一个
newChmConsignments
.
add
(
chmConsignments
);
}
}
if
(
chmConsignmentDB
==
null
&&
!
newChmConsignments
.
isEmpty
()){
List
<
ChmConsignment
>
sortList
=
newChmConsignments
.
stream
().
sorted
(
Comparator
.
comparing
(
ChmConsignment:
:
getCreateTime
).
reversed
()).
collect
(
Collectors
.
toList
());
chmConsignmentDB
=
sortList
.
get
(
0
);
}
//获取用户账号信息
SysUser
sysUser
=
sysUserRepository
.
findUserByLoginName
(
"CUSTOMS"
);
SysUser
sysUser
=
sysUserRepository
.
findUserByLoginName
(
creator
);
//设置当前运单创建人ID
chmConsignment
.
setCreatorId
(
sysUser
);
//设置创建人名称
...
...
@@ -526,6 +557,8 @@ public class ChmConsignmentService {
//新增:如果没有就插入
if
(
Objects
.
equals
(
chmConsignmentDB
,
null
)){
log
.
info
(
"新增主单"
+
mawb
.
getBillNo
());
//如果有dm004把dm004更新上去
updateDM004
(
chmConsignment
);
ChmConsignment
chmConsignmentSaveResult
=
this
.
saveChmConsignment
(
chmConsignment
);
if
(!
Objects
.
equals
(
chmConsignmentSaveResult
,
null
)){
log
.
info
(
"主单"
+
mawb
.
getBillNo
()+
" 保存成功,chmConsignmentId:"
+
chmConsignmentSaveResult
.
getId
());
...
...
@@ -540,9 +573,9 @@ public class ChmConsignmentService {
//条件1、状态为 待申报海关
//条件2、本次推送时间 > 上次推送的时间
}
else
if
(!
Objects
.
equals
(
chmConsignmentDB
,
null
)
&&
Objects
.
equals
(
chmConsignmentDB
.
getConsStatusDic
().
getCode
(),
"transferWaybillStatus_5"
)
//
&& Objects.equals(chmConsignmentDB.getConsStatusDic().getCode(),"transferWaybillStatus_5")
//TODO 提交时需要打开
&&
pushTime
.
getTime
()>
chmConsignmentDB
.
getUpdateTime
().
getTime
()
//
&& pushTime.getTime()>chmConsignmentDB.getUpdateTime().getTime()
){
//更新数据
log
.
info
(
"更新主单"
+
mawb
.
getBillNo
());
...
...
@@ -555,11 +588,13 @@ public class ChmConsignmentService {
}
}
}
//如果有dm004把dm004更新上去
updateDM004
(
chmConsignment
);
chmConsignment
.
setId
(
chmConsignmentDB
.
getId
());
chmConsignment
.
setCreateTime
(
chmConsignmentDB
.
getCreateTime
());
chmConsignment
.
setUpdateTime
(
pushTime
);
chmConsignment
.
setUpdateTime
(
new
Date
()
);
ChmConsignment
updateResult
=
this
.
saveChmConsignment
(
chmConsignment
);
if
(!
Objects
.
equals
(
updateResult
,
null
)){
log
.
info
(
"主单"
+
mawb
.
getBillNo
()+
" 更新成功,chmConsignmentId:"
+
updateResult
.
getId
());
...
...
@@ -571,13 +606,48 @@ public class ChmConsignmentService {
}
}
}
catch
(
Exception
e
){
log
.
error
(
""
+
e
.
getMessage
());
log
.
error
(
""
+
e
.
getMessage
()
,
e
);
}
result
.
setSuccess
(
Boolean
.
TRUE
);
return
result
;
}
/**
* 如果dm004已经来了,但是运单未提交,则直接更新dm004的数据
*/
public
ChmConsignment
updateDM004
(
ChmConsignment
chmConsignment
){
TaskInfo
taskInfo
=
new
TaskInfo
();
DictionaryEntries
dictionaryEntries
=
dictionaryEntriesRepository
.
findDictionaryEntriesByCode
(
Constant
.
FILE_TYPE_GET_PICK_INFORMATION
);
taskInfo
=
taskInfoRepository
.
findTaskInfoByConsignment
(
dictionaryEntries
.
getId
(),
chmConsignment
.
getConsignmentCode
());
if
(
StringUtil
.
isEmpty
(
chmConsignment
.
getScanCode
())
&&
taskInfo
!=
null
){
chmConsignment
.
setScanCode
(
taskInfo
.
getScanCode
());
chmConsignment
.
setScanCodeDic
(
taskInfo
.
getScanCodeDic
());
chmConsignment
.
setScanStatusTime
(
taskInfo
.
getScanStatusTime
());
//D类OSPR未完成可以修改站点
Organization
organizationByName
=
organizationRepository
.
findOrganizationByName
(
taskInfo
.
getStationName
());
if
(
organizationByName
!=
null
){
DictionaryEntries
dictionaryEntries3
=
dictionaryEntriesRepository
.
findDictionaryEntriesByCode
(
Constant
.
consType_D
);
if
(
chmConsignment
.
getConsType
().
equals
(
dictionaryEntries3
.
getChineseName
())){
if
(
chmConsignment
.
getOsprStatusDic
()!=
null
){
if
(
chmConsignment
.
getOsprStatusDic
().
getCode
().
equals
(
Constant
.
OSPR_STATUS_INCOMPLETED
)){
chmConsignment
.
setStation
(
organizationByName
);
chmConsignment
.
setStationName
(
organizationByName
.
getName
());
}
}
}
else
{
chmConsignment
.
setStation
(
organizationByName
);
chmConsignment
.
setStationName
(
organizationByName
.
getName
());
}
}
if
(
taskInfo
.
getScanCode
().
equals
(
Constant
.
SCAN_CODE_TAKEN_PART
)){
chmConsignment
.
setPickUpDate
(
taskInfo
.
getScanStatusTime
());
}
}
return
chmConsignment
;
}
/**
* 保存或更新 iclear中的运单信息
* @param fedexMawb
* @param timeStamp
...
...
@@ -598,14 +668,32 @@ public class ChmConsignmentService {
chmConsignmentDetailList
.
add
(
chmConsignmentDetailService
.
convertToChmConsignmentDetailFedex
(
detail
,
chmConsignment
,
Boolean
.
FALSE
));
});
chmConsignment
.
setChmConsignmentDetailList
(
chmConsignmentDetailList
);
ChmConsignment
chmConsignmentDB
=
null
;
//2、校验 7天+运单 ,如果有数据并且 还未报关就更新,如果数据就插入
ChmConsignment
chmConsignmentDB
=
this
.
findChmConsignmentByConsignmentCode
(
chmConsignment
.
getConsignmentCode
(),
DateUtils
.
addDate
(
DateUtils
.
getCurrentDate
(),-
7
));
List
<
ChmConsignment
>
chmConsignments
=
this
.
findChmConsignmentByConsignmentCodes
(
chmConsignment
.
getConsignmentCode
(),
DateUtils
.
addDate
(
DateUtils
.
getCurrentDate
(),-
7
),
creator
);
//如果没有C类待申报,从list中拿时间最晚的一条去覆盖
List
<
ChmConsignment
>
newChmConsignments
=
new
ArrayList
<
ChmConsignment
>();
for
(
ChmConsignment
consignment
:
chmConsignments
)
{
//如果是C类待申报的,覆盖
if
(
consignment
.
getConsStatusDic
().
getCode
().
equals
(
"transferWaybillStatus_16"
)){
chmConsignmentDB
=
consignment
;
break
;
}
else
if
((
consignment
.
getConsStatusDic
().
getCode
().
equals
(
"transferWaybillStatus_15"
)
||
consignment
.
getConsStatusDic
().
getCode
().
equals
(
"transferWaybillStatus_1"
)
||
consignment
.
getConsStatusDic
().
getCode
().
equals
(
"transferWaybillStatus_24"
))){
newChmConsignments
.
add
(
consignment
);
}
}
if
(
chmConsignmentDB
==
null
&&
!
newChmConsignments
.
isEmpty
()){
List
<
ChmConsignment
>
sortList
=
newChmConsignments
.
stream
().
sorted
(
Comparator
.
comparing
(
ChmConsignment:
:
getCreateTime
).
reversed
()).
collect
(
Collectors
.
toList
());
chmConsignmentDB
=
sortList
.
get
(
0
);
}
//3、新增或更新
//新增:如果没有就插入,或者存在草稿、sep新建、新建的并且运单id不一样就新增一条
//新增:如果没有就插入
if
(
Objects
.
equals
(
chmConsignmentDB
,
null
)){
log
.
info
(
"新增主单"
+
fedexMawb
.
getBillNo
());
//如果有dm004把dm004更新上去
updateDM004
(
chmConsignment
);
ChmConsignment
chmConsignmentSaveResult
=
this
.
saveChmConsignment
(
chmConsignment
);
if
(!
Objects
.
equals
(
chmConsignmentSaveResult
,
null
)){
log
.
info
(
"主单"
+
fedexMawb
.
getBillNo
()+
" 保存成功,chmConsignmentId:"
+
chmConsignmentSaveResult
.
getId
());
...
...
@@ -620,9 +708,9 @@ public class ChmConsignmentService {
//条件1、状态为 C类待申报
//条件2、本次推送时间 > 上次推送的时间
}
else
if
(!
Objects
.
equals
(
chmConsignmentDB
,
null
)
&&
Objects
.
equals
(
chmConsignmentDB
.
getConsStatusDic
().
getCode
(),
"transferWaybillStatus_16"
)
//
&& Objects.equals(chmConsignmentDB.getConsStatusDic().getCode(),"transferWaybillStatus_16")
//TODO 提交时需要打开
&&
pushTime
.
getTime
()>
chmConsignmentDB
.
getUpdateTime
().
getTime
()
//
&& pushTime.getTime()>chmConsignmentDB.getUpdateTime().getTime()
){
//更新数据
log
.
info
(
"更新主单"
+
fedexMawb
.
getBillNo
());
...
...
@@ -635,9 +723,10 @@ public class ChmConsignmentService {
}
}
}
//如果有dm004把dm004更新上去
updateDM004
(
chmConsignment
);
chmConsignment
.
setId
(
chmConsignmentDB
.
getId
());
chmConsignment
.
setCreateTime
(
chmConsignmentDB
.
getCreateTime
());
//
chmConsignment.setCreateTime(chmConsignmentDB.getCreateTime());
chmConsignment
.
setUpdateTime
(
pushTime
);
ChmConsignment
updateResult
=
this
.
saveChmConsignment
(
chmConsignment
);
if
(!
Objects
.
equals
(
updateResult
,
null
)){
...
...
src/main/java/com/erry/iclear/dateInterface/service/FedexService.java
View file @
028024a
...
...
@@ -113,13 +113,13 @@ public class FedexService {
* @param fedexMawb
* @return
*/
public
ResultRS
checkFedexMawb
(
FedexMawb
fedexMawb
,
AppInfo
appInfo
){
public
ResultRS
checkFedexMawb
(
FedexMawb
fedexMawb
,
AppInfo
appInfo
,
String
appId
){
ResultRS
result
=
new
ResultRS
(
Boolean
.
FALSE
,
null
,
null
,
null
);
try
{
log
.
info
(
"checkMawb start>>>>>>>>>> mawb:"
+
gson
.
toJson
(
fedexMawb
));
//1、将请求转换为运单
ChmConsignment
chmConsignment
=
consignmentService
.
convertToChmConsignmentFedex
(
fedexMawb
,
null
,
"IDE-ICLEAR-API"
,
appInfo
);
ChmConsignment
chmConsignment
=
consignmentService
.
convertToChmConsignmentFedex
(
fedexMawb
,
null
,
appId
,
appInfo
);
if
(
Objects
.
equals
(
chmConsignment
,
null
)){
result
.
setCode
(
ErrorCodeEnum
.
ERROR_7
.
getCode
());
result
.
setMsg
(
ErrorCodeEnum
.
ERROR_7
.
getName
());
...
...
src/main/java/com/erry/iclear/dateInterface/service/MawbService.java
View file @
028024a
...
...
@@ -2,15 +2,15 @@ package com.erry.iclear.dateInterface.service;
import
com.erry.iclear.dateInterface.api.request.FedexMawb
;
import
com.erry.iclear.dateInterface.api.request.FedexMawbDetail
;
import
com.erry.iclear.dateInterface.common.Constant
;
import
com.erry.iclear.dateInterface.entity.DictionaryEntries
;
import
com.erry.iclear.dateInterface.enums.ErrorCodeEnum
;
import
com.erry.iclear.dateInterface.api.request.Mawb
;
import
com.erry.iclear.dateInterface.api.request.MawbDetail
;
import
com.erry.iclear.dateInterface.api.response.IClearCheckResult
;
import
com.erry.iclear.dateInterface.api.response.ResultRS
;
import
com.erry.iclear.dateInterface.common.Constant
;
import
com.erry.iclear.dateInterface.entity.ChmConsignment
;
import
com.erry.iclear.dateInterface.entity.ChmConsignmentDetail
;
import
com.erry.iclear.dateInterface.entity.DictionaryEntries
;
import
com.erry.iclear.dateInterface.enums.ErrorCodeEnum
;
import
com.erry.iclear.dateInterface.repository.DictionaryEntriesRepository
;
import
com.erry.iclear.dateInterface.repository.MawbRepository
;
import
com.erry.iclear.dateInterface.util.HttpUtils
;
...
...
@@ -23,7 +23,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
javax.validation.Valid
;
import
java.util.*
;
/**
...
...
@@ -301,12 +300,12 @@ public class MawbService {
* @param mawb
* @return
*/
public
ResultRS
checkMawb
(
Mawb
mawb
){
public
ResultRS
checkMawb
(
Mawb
mawb
,
String
appId
){
ResultRS
result
=
new
ResultRS
(
Boolean
.
FALSE
,
null
,
null
,
null
);
try
{
log
.
info
(
"checkMawb start>>>>>>>>>> mawb:"
+
gson
.
toJson
(
mawb
));
//1、将请求转换为运单
ChmConsignment
chmConsignment
=
consignmentService
.
convertToChmConsignment
(
mawb
,
null
,
"IDE-ICLEAR-API"
);
ChmConsignment
chmConsignment
=
consignmentService
.
convertToChmConsignment
(
mawb
,
null
,
appId
);
if
(
Objects
.
equals
(
chmConsignment
,
null
)){
result
.
setCode
(
ErrorCodeEnum
.
ERROR_30001
.
getCode
());
result
.
setMsg
(
ErrorCodeEnum
.
ERROR_30001
.
getName
());
...
...
Please
register
or
login
to post a comment