wei.zhou

提交代码

...@@ -29,11 +29,12 @@ INSERT INTO T_ICLEAR_API_APPINFO VALUES(1,'CTM','iClearExport','b92131f03f19a348 ...@@ -29,11 +29,12 @@ INSERT INTO T_ICLEAR_API_APPINFO VALUES(1,'CTM','iClearExport','b92131f03f19a348
29 29
30 CREATE TABLE T_ICLEAR_API_LOG( 30 CREATE TABLE T_ICLEAR_API_LOG(
31 MSGID int identity(1,1) primary key --PK 31 MSGID int identity(1,1) primary key --PK
32 - ,MSG_TYPE VARCHAR(20) --类型 32 + ,MSG_TYPE VARCHAR(20) --类型: C D
33 ,APPID VARCHAR(20) --用户ID 33 ,APPID VARCHAR(20) --用户ID
34 ,APPKEY VARCHAR(20) --用户key 34 ,APPKEY VARCHAR(20) --用户key
35 ,CREATE_TIME datetime --创建时间 35 ,CREATE_TIME datetime --创建时间
36 ,UPDATE_TIME datetime --更新时间 36 ,UPDATE_TIME datetime --更新时间
37 + ,PUSH_TIME datetime --消息推送时间
37 --,REQUEST_MSG VARCHAR(500) 38 --,REQUEST_MSG VARCHAR(500)
38 ,RECEIVE_RESULT VARCHAR(100) --记录接收后是否验证通过的结果 39 ,RECEIVE_RESULT VARCHAR(100) --记录接收后是否验证通过的结果
39 ,RESPONSE_TIME datetime -- 响应时间 40 ,RESPONSE_TIME datetime -- 响应时间
......
...@@ -3,11 +3,9 @@ package com.erry.iclear.dateInterface.api; ...@@ -3,11 +3,9 @@ package com.erry.iclear.dateInterface.api;
3 import com.erry.iclear.dateInterface.api.request.Mawb; 3 import com.erry.iclear.dateInterface.api.request.Mawb;
4 import com.erry.iclear.dateInterface.api.response.ResultRS; 4 import com.erry.iclear.dateInterface.api.response.ResultRS;
5 import com.erry.iclear.dateInterface.common.Constant; 5 import com.erry.iclear.dateInterface.common.Constant;
6 -import com.erry.iclear.dateInterface.entity.ChmConsignment;
7 -import com.erry.iclear.dateInterface.entity.ChmConsignmentDetail;
8 import com.erry.iclear.dateInterface.entity.IClearApiLog; 6 import com.erry.iclear.dateInterface.entity.IClearApiLog;
9 import com.erry.iclear.dateInterface.service.*; 7 import com.erry.iclear.dateInterface.service.*;
10 -import com.erry.iclear.dateInterface.util.MD5Util; 8 +import com.erry.iclear.dateInterface.util.DateUtils;
11 import com.erry.iclear.dateInterface.util.SHA256Util; 9 import com.erry.iclear.dateInterface.util.SHA256Util;
12 import com.google.gson.Gson; 10 import com.google.gson.Gson;
13 import io.swagger.annotations.ApiOperation; 11 import io.swagger.annotations.ApiOperation;
...@@ -65,8 +63,9 @@ public class CustomsDataInterface { ...@@ -65,8 +63,9 @@ public class CustomsDataInterface {
65 sw.start("save log"); 63 sw.start("save log");
66 64
67 String appId=(String) request.getHeader("Appid"); 65 String appId=(String) request.getHeader("Appid");
68 - String appkey=(String) request.getHeader("Appkey"); 66 + String appKey=(String) request.getHeader("Appkey");
69 - IClearApiLog saveIClearApiLogResult = iClearApiLogService.saveIClearApiLog(iClearApiLogService.convertToIClearApiLog(mawb,appId,appkey)); 67 + String timeStamp=(String) request.getHeader("TimeStamp");
68 + IClearApiLog saveIClearApiLogResult = iClearApiLogService.saveIClearApiLog(iClearApiLogService.convertToIClearApiLog(mawb,appId,appKey,DateUtils.convertToDate(timeStamp)));
70 69
71 70
72 if(!Objects.equals(saveIClearApiLogResult,null)){ 71 if(!Objects.equals(saveIClearApiLogResult,null)){
...@@ -110,22 +109,10 @@ public class CustomsDataInterface { ...@@ -110,22 +109,10 @@ public class CustomsDataInterface {
110 109
111 110
112 //4、保存运单到iclear中 111 //4、保存运单到iclear中
112 +
113 sw.start("saveToIClear"); 113 sw.start("saveToIClear");
114 if(result.getSuccess()==true){ 114 if(result.getSuccess()==true){
115 - ChmConsignment chmConsignment=chmConsignmentService.convertToChmConsignment(mawb); 115 + chmConsignmentService.processChmConsignment(mawb, timeStamp);
116 - List<ChmConsignmentDetail> chmConsignmentDetailList = new ArrayList<>();
117 - mawb.getMawbDetailList().forEach(detail ->{
118 - chmConsignmentDetailList.add(chmConsignmentDetailService.convertToChmConsignmentDetail(detail));
119 - });
120 - chmConsignment.setChmConsignmentDetailList(chmConsignmentDetailList);
121 -
122 - ChmConsignment chmConsignmentSaveResult = chmConsignmentService.saveChmConsignment(chmConsignment);
123 -
124 - if(!Objects.equals(chmConsignmentSaveResult,null)){
125 - log.info("主单"+mawb.getBillNo()+" 保存成功,chmConsignmentId:"+chmConsignmentSaveResult.getId());
126 - }else{
127 - log.info("主单"+mawb.getBillNo()+" 保存失败");
128 - }
129 } 116 }
130 sw.stop(); 117 sw.stop();
131 118
...@@ -150,6 +137,8 @@ public class CustomsDataInterface { ...@@ -150,6 +137,8 @@ public class CustomsDataInterface {
150 } 137 }
151 138
152 139
140 +
141 +
153 /** 142 /**
154 * 校验用户 143 * 校验用户
155 * @param request 144 * @param request
...@@ -220,6 +209,21 @@ public class CustomsDataInterface { ...@@ -220,6 +209,21 @@ public class CustomsDataInterface {
220 } 209 }
221 210
222 211
212 + /**
213 + * 检查状态是否小于已报关
214 + * @param statusCode
215 + * @return
216 + * true:报关之前
217 + * false:报关之后
218 + */
219 + private boolean compareStatusCode(String statusCode){
220 +
221 +
222 + return false;
223 + }
224 +
225 +
226 +
223 } 227 }
224 228
225 229
......
...@@ -47,5 +47,9 @@ public class Constant { ...@@ -47,5 +47,9 @@ public class Constant {
47 47
48 public static String NEW_PACKAGE_TYPE = "NewPackageType_"; 48 public static String NEW_PACKAGE_TYPE = "NewPackageType_";
49 49
50 + public static String TRANSFER_WAY_BILL_STATUS = "transferWaybillStatus_";
51 +
52 + public static String SUPERVISION_MODE ="supervisionMode_";
53 +
50 54
51 } 55 }
......
1 package com.erry.iclear.dateInterface.entity; 1 package com.erry.iclear.dateInterface.entity;
2 2
3 3
4 -import com.erry.iclear.dateInterface.api.request.MawbDetail;
5 import com.fasterxml.jackson.annotation.JsonIgnore; 4 import com.fasterxml.jackson.annotation.JsonIgnore;
6 import lombok.Data; 5 import lombok.Data;
7 import org.springframework.format.annotation.DateTimeFormat; 6 import org.springframework.format.annotation.DateTimeFormat;
...@@ -28,7 +27,7 @@ public class ChmConsignment implements Serializable { ...@@ -28,7 +27,7 @@ public class ChmConsignment implements Serializable {
28 * 运单表ID,自动增加 27 * 运单表ID,自动增加
29 */ 28 */
30 @Id 29 @Id
31 - @GeneratedValue 30 + @GeneratedValue(strategy = GenerationType.IDENTITY)
32 @Column(name = "ID") 31 @Column(name = "ID")
33 private Long id; 32 private Long id;
34 33
......
...@@ -24,7 +24,7 @@ public class ChmConsignmentDetail implements Serializable { ...@@ -24,7 +24,7 @@ public class ChmConsignmentDetail implements Serializable {
24 * 运单明细表ID,自动增加 24 * 运单明细表ID,自动增加
25 */ 25 */
26 @Id 26 @Id
27 - @GeneratedValue 27 + @GeneratedValue(strategy = GenerationType.IDENTITY)
28 @Column(name = "ID") 28 @Column(name = "ID")
29 private Long id; 29 private Long id;
30 30
......
...@@ -20,47 +20,52 @@ public class DictionaryEntries implements Serializable { ...@@ -20,47 +20,52 @@ public class DictionaryEntries implements Serializable {
20 20
21 private static final long serialVersionUID = -8423170334642989557L; 21 private static final long serialVersionUID = -8423170334642989557L;
22 @Id 22 @Id
23 + @GeneratedValue
23 @Column(name = "ID") 24 @Column(name = "ID")
24 private Long id; 25 private Long id;
25 26
26 @Column(name = "CODE") 27 @Column(name = "CODE")
27 private String code; 28 private String code;
28 29
29 - @Column(name = "DICT_CODE")
30 - private String dictCode;
31 -
32 @Column(name = "CHINESE_NAME") 30 @Column(name = "CHINESE_NAME")
33 private String chineseName; 31 private String chineseName;
34 32
35 - @Column(name = "ENGLISH_NAME")
36 - private String englishName;
37 -
38 - @Column(name = "DESCRIPTION")
39 - private String description;
40 -
41 - @Column(name = "STATUS")
42 - private Integer status;
43 -
44 - @Column(name = "EXT1")
45 - private Integer ext1;
46 -
47 - @Column(name = "EXT2")
48 - private String ext2;
49 -
50 - @Column(name = "EXT3")
51 - private String ext3;
52 -
53 - @Column(name = "EXT4")
54 - private BigDecimal ext4;
55 -
56 - @Column(name = "EXT5")
57 - private Integer ext5;
58 -
59 - @Column(name = "ORDINAL")
60 - private Integer ordinal;
61 33
62 - @Column(name = "EXT6") 34 +// @Column(name = "DICT_CODE")
63 - private String ext6; 35 +// private String dictCode;
36 +//
37 +// @Column(name = "ENGLISH_NAME")
38 +// private String englishName;
39 +//
40 +// @Column(name = "DESCRIPTION")
41 +// private String description;
42 +//
43 +// @Column(name = "STATUS")
44 +// private Integer status;
45 +//
46 +// @Column(name="DICT_ID")
47 +// private String dictId;
48 +//
49 +// @Column(name = "EXT1")
50 +// private Integer ext1;
51 +//
52 +// @Column(name = "EXT2")
53 +// private String ext2;
54 +//
55 +// @Column(name = "EXT3")
56 +// private String ext3;
57 +//
58 +// @Column(name = "EXT4")
59 +// private BigDecimal ext4;
60 +//
61 +// @Column(name = "EXT5")
62 +// private Integer ext5;
63 +//
64 +// @Column(name = "ORDINAL")
65 +// private Integer ordinal;
66 +//
67 +// @Column(name = "EXT6")
68 +// private String ext6;
64 69
65 70
66 } 71 }
......
...@@ -38,6 +38,8 @@ public class IClearApiLog implements Serializable { ...@@ -38,6 +38,8 @@ public class IClearApiLog implements Serializable {
38 //收到的json,用 T_ICLEAR_API_MAWB表保存 38 //收到的json,用 T_ICLEAR_API_MAWB表保存
39 //@Column(name= "REQUEST_MSG") 39 //@Column(name= "REQUEST_MSG")
40 //private String request_msg; 40 //private String request_msg;
41 + @Column(name= "PUSH_TIME")
42 + private Date pushTime;
41 43
42 @Column(name= "RECEIVE_RESULT") 44 @Column(name= "RECEIVE_RESULT")
43 private String receiveResult; 45 private String receiveResult;
......
...@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
10 import org.springframework.context.ApplicationContext; 10 import org.springframework.context.ApplicationContext;
11 import org.springframework.context.ApplicationContextAware; 11 import org.springframework.context.ApplicationContextAware;
12 import org.springframework.stereotype.Service; 12 import org.springframework.stereotype.Service;
13 +import org.springframework.util.StopWatch;
13 14
14 import java.util.HashMap; 15 import java.util.HashMap;
15 import java.util.List; 16 import java.util.List;
...@@ -48,6 +49,8 @@ public class IClearApiSystemInit implements InitializingBean, ApplicationContext ...@@ -48,6 +49,8 @@ public class IClearApiSystemInit implements InitializingBean, ApplicationContext
48 @Override 49 @Override
49 public void afterPropertiesSet() throws Exception { 50 public void afterPropertiesSet() throws Exception {
50 try{ 51 try{
52 + StopWatch sw = new StopWatch("initSystemCache");
53 + sw.start("initCache");
51 log.info("init initAppInfo start>>>>>>>>>"); 54 log.info("init initAppInfo start>>>>>>>>>");
52 appInfoService.initAppInfo(); 55 appInfoService.initAppInfo();
53 log.info("init initAppInfo end>>>>>>>>>"); 56 log.info("init initAppInfo end>>>>>>>>>");
...@@ -68,6 +71,8 @@ public class IClearApiSystemInit implements InitializingBean, ApplicationContext ...@@ -68,6 +71,8 @@ public class IClearApiSystemInit implements InitializingBean, ApplicationContext
68 chmCarryPortService.initChmCarryPort(); 71 chmCarryPortService.initChmCarryPort();
69 log.info("init initChmCarryPort start>>>>>>>>>"); 72 log.info("init initChmCarryPort start>>>>>>>>>");
70 73
74 + sw.stop();
75 + System.out.println(sw.prettyPrint());
71 76
72 }catch (Exception e){ 77 }catch (Exception e){
73 log.error("init afterPropertiesSet error:" + e.getMessage()); 78 log.error("init afterPropertiesSet error:" + e.getMessage());
......
...@@ -4,6 +4,7 @@ import com.erry.iclear.dateInterface.entity.ChmConsignment; ...@@ -4,6 +4,7 @@ import com.erry.iclear.dateInterface.entity.ChmConsignment;
4 import org.springframework.data.jpa.repository.JpaRepository; 4 import org.springframework.data.jpa.repository.JpaRepository;
5 import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 5 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6 import org.springframework.data.jpa.repository.Query; 6 import org.springframework.data.jpa.repository.Query;
7 +import org.springframework.data.repository.query.Param;
7 import org.springframework.stereotype.Repository; 8 import org.springframework.stereotype.Repository;
8 9
9 import java.util.Date; 10 import java.util.Date;
...@@ -22,4 +23,13 @@ public interface ChmConsignmentRepository extends JpaSpecificationExecutor<ChmCo ...@@ -22,4 +23,13 @@ public interface ChmConsignmentRepository extends JpaSpecificationExecutor<ChmCo
22 @Query( nativeQuery = true,value ="select * from T_CHM_CONSIGNMENT where CONSIGNMENT_CODE IN ?1 and CREATE_TIME > ?2 " ) 23 @Query( nativeQuery = true,value ="select * from T_CHM_CONSIGNMENT where CONSIGNMENT_CODE IN ?1 and CREATE_TIME > ?2 " )
23 public List<ChmConsignment> findChmByCodeListAndCreateTime(List chmConCodeList, Date createTime); 24 public List<ChmConsignment> findChmByCodeListAndCreateTime(List chmConCodeList, Date createTime);
24 25
26 + /**
27 + * 根据运单号查找
28 + * @param consignmentCode
29 + * @param startDate
30 + * @return
31 + */
32 + @Query( nativeQuery = true,value ="select * from T_CHM_CONSIGNMENT where CONSIGNMENT_CODE = ?1 and CREATE_TIME>= ?2" )
33 + public ChmConsignment findChmConsignmentByConsignmentCode(String consignmentCode,Date startDate);
34 +
25 } 35 }
......
...@@ -15,7 +15,7 @@ import java.util.List; ...@@ -15,7 +15,7 @@ import java.util.List;
15 */ 15 */
16 @Repository 16 @Repository
17 @Transactional(rollbackFor = Exception.class) 17 @Transactional(rollbackFor = Exception.class)
18 -public interface DictionaryEntriesRepository extends JpaRepository<IClearApiLog, Integer>, JpaSpecificationExecutor<IClearApiLog> { 18 +public interface DictionaryEntriesRepository extends JpaRepository<DictionaryEntries, Integer>, JpaSpecificationExecutor<DictionaryEntries> {
19 19
20 /** 20 /**
21 * 根据code查找 21 * 根据code查找
...@@ -30,7 +30,7 @@ public interface DictionaryEntriesRepository extends JpaRepository<IClearApiLog ...@@ -30,7 +30,7 @@ public interface DictionaryEntriesRepository extends JpaRepository<IClearApiLog
30 * 查找全部DictionaryEntries 30 * 查找全部DictionaryEntries
31 * @return 31 * @return
32 */ 32 */
33 - @Query(nativeQuery = true, value = "select * from T_BI_DICTIONARY_ENTRIES where STATUS=1") 33 + @Query(nativeQuery = true, value = "select ID,CODE,CHINESE_NAME from T_BI_DICTIONARY_ENTRIES where STATUS=1")
34 public List<DictionaryEntries> findAllDictionaryEntries(); 34 public List<DictionaryEntries> findAllDictionaryEntries();
35 35
36 36
......
...@@ -6,6 +6,9 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor; ...@@ -6,6 +6,9 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6 import org.springframework.stereotype.Repository; 6 import org.springframework.stereotype.Repository;
7 import org.springframework.transaction.annotation.Transactional; 7 import org.springframework.transaction.annotation.Transactional;
8 8
9 +/**
10 + * @author Administrator
11 + */
9 @Repository 12 @Repository
10 @Transactional(rollbackFor = Exception.class) 13 @Transactional(rollbackFor = Exception.class)
11 public interface MawbDetailRepository extends JpaRepository<MawbDetail, Integer>, JpaSpecificationExecutor<MawbDetail> { 14 public interface MawbDetailRepository extends JpaRepository<MawbDetail, Integer>, JpaSpecificationExecutor<MawbDetail> {
......
...@@ -4,9 +4,11 @@ import com.erry.iclear.dateInterface.api.request.MawbDetail; ...@@ -4,9 +4,11 @@ import com.erry.iclear.dateInterface.api.request.MawbDetail;
4 import com.erry.iclear.dateInterface.common.Constant; 4 import com.erry.iclear.dateInterface.common.Constant;
5 import com.erry.iclear.dateInterface.entity.*; 5 import com.erry.iclear.dateInterface.entity.*;
6 import lombok.extern.slf4j.Slf4j; 6 import lombok.extern.slf4j.Slf4j;
7 +import org.apache.commons.lang3.StringUtils;
7 import org.springframework.stereotype.Service; 8 import org.springframework.stereotype.Service;
8 9
9 import java.math.BigDecimal; 10 import java.math.BigDecimal;
11 +import java.util.Objects;
10 12
11 /** 13 /**
12 * @author Administrator 14 * @author Administrator
...@@ -84,9 +86,12 @@ public class ChmConsignmentDetailService { ...@@ -84,9 +86,12 @@ public class ChmConsignmentDetailService {
84 //申报货物英文名称 86 //申报货物英文名称
85 result.setContentDescription(mawbDetail.getDeclGoodsEname()); 87 result.setContentDescription(mawbDetail.getDeclGoodsEname());
86 //目的地代码 88 //目的地代码
89 + if(StringUtils.isNotBlank(mawbDetail.getDestCode())){
87 OrigplacecodeMapping origplacecodeMapping = Constant.origplacecodeMappingCache.get(mawbDetail.getDestCode()); 90 OrigplacecodeMapping origplacecodeMapping = Constant.origplacecodeMappingCache.get(mawbDetail.getDestCode());
88 result.setOrigplacecodeMapping(origplacecodeMapping); 91 result.setOrigplacecodeMapping(origplacecodeMapping);
89 result.setOrigplacecode(origplacecodeMapping.getOrigplaceName()); 92 result.setOrigplacecode(origplacecodeMapping.getOrigplaceName());
93 + }
94 +
90 95
91 96
92 //境内目的地/境内货源地 97 //境内目的地/境内货源地
......
1 package com.erry.iclear.dateInterface.service; 1 package com.erry.iclear.dateInterface.service;
2 2
3 +import cn.hutool.core.date.DateUtil;
3 import com.erry.iclear.dateInterface.api.request.Mawb; 4 import com.erry.iclear.dateInterface.api.request.Mawb;
4 import com.erry.iclear.dateInterface.common.Constant; 5 import com.erry.iclear.dateInterface.common.Constant;
5 import com.erry.iclear.dateInterface.entity.ChmCarryPort; 6 import com.erry.iclear.dateInterface.entity.ChmCarryPort;
6 import com.erry.iclear.dateInterface.entity.ChmConsignment; 7 import com.erry.iclear.dateInterface.entity.ChmConsignment;
8 +import com.erry.iclear.dateInterface.entity.ChmConsignmentDetail;
7 import com.erry.iclear.dateInterface.entity.DictionaryEntries; 9 import com.erry.iclear.dateInterface.entity.DictionaryEntries;
8 import com.erry.iclear.dateInterface.repository.ChmConsignmentRepository; 10 import com.erry.iclear.dateInterface.repository.ChmConsignmentRepository;
11 +import com.erry.iclear.dateInterface.util.DateUtils;
9 import lombok.extern.slf4j.Slf4j; 12 import lombok.extern.slf4j.Slf4j;
10 import org.springframework.beans.factory.annotation.Autowired; 13 import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.stereotype.Service; 14 import org.springframework.stereotype.Service;
12 15
16 +import javax.transaction.Transactional;
13 import java.math.BigDecimal; 17 import java.math.BigDecimal;
18 +import java.util.ArrayList;
19 +import java.util.Date;
20 +import java.util.List;
21 +import java.util.Objects;
14 22
15 /** 23 /**
16 * @author Administrator 24 * @author Administrator
17 */ 25 */
18 @Service 26 @Service
19 @Slf4j 27 @Slf4j
28 +@Transactional(rollbackOn = Exception.class)
20 public class ChmConsignmentService { 29 public class ChmConsignmentService {
21 30
22 @Autowired 31 @Autowired
23 private ChmConsignmentRepository chmConsignmentRepository; 32 private ChmConsignmentRepository chmConsignmentRepository;
24 33
34 + @Autowired
35 + private ChmConsignmentDetailService chmConsignmentDetailService;
36 +
25 /** 37 /**
26 * 转换主单 38 * 转换主单
27 * @return 39 * @return
28 */ 40 */
29 - public ChmConsignment convertToChmConsignment(Mawb mawb){ 41 + public ChmConsignment convertToChmConsignment(Mawb mawb,Date pushTime){
30 ChmConsignment result = new ChmConsignment(); 42 ChmConsignment result = new ChmConsignment();
31 try{ 43 try{
32 //进出口标志:固定值 E 44 //进出口标志:固定值 E
...@@ -37,9 +49,15 @@ public class ChmConsignmentService { ...@@ -37,9 +49,15 @@ public class ChmConsignmentService {
37 result.setDeclaredUnitName(mawb.getAgentName()); 49 result.setDeclaredUnitName(mawb.getAgentName());
38 //申报单位名称:固定值 联邦快递(中国)有限公司 50 //申报单位名称:固定值 联邦快递(中国)有限公司
39 //提单号:有总单号则取值“总单号_运单号”,没有总单号则取值“运单号” 51 //提单号:有总单号则取值“总单号_运单号”,没有总单号则取值“运单号”
40 - String billNo[]=mawb.getBillNo().split("_"); 52 + String[] billNo=mawb.getBillNo().split("_");
53 + if(billNo.length==1){
54 + result.setConsignmentCode(billNo[0]);
55 + }
56 + if(billNo.length==2){
41 result.setConsignmentHeadCode(billNo[0]); 57 result.setConsignmentHeadCode(billNo[0]);
42 result.setConsignmentCode(billNo[1]); 58 result.setConsignmentCode(billNo[1]);
59 + }
60 +
43 //合同号 61 //合同号
44 result.setContractCode(mawb.getContrNo()); 62 result.setContractCode(mawb.getContrNo());
45 //主管海关(申报地海关) 63 //主管海关(申报地海关)
...@@ -97,13 +115,13 @@ public class ChmConsignmentService { ...@@ -97,13 +115,13 @@ public class ChmConsignmentService {
97 //预录入编号 115 //预录入编号
98 result.setEnteringNo(mawb.getPreEntryId()); 116 result.setEnteringNo(mawb.getPreEntryId());
99 //启运国/运抵国 117 //启运国/运抵国
100 - DictionaryEntries fromCountryDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.COUNTRY+mawb.getOtherCurr()); 118 + DictionaryEntries fromCountryDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.COUNTRY+mawb.getTradeCountry());
101 result.setFromCountryDic(fromCountryDictionaryEntries); 119 result.setFromCountryDic(fromCountryDictionaryEntries);
102 result.setFromCountry(fromCountryDictionaryEntries.getChineseName()); 120 result.setFromCountry(fromCountryDictionaryEntries.getChineseName());
103 121
104 122
105 //监管方式 123 //监管方式
106 - DictionaryEntries tradeModeDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.COUNTRY+mawb.getOtherCurr()); 124 + DictionaryEntries tradeModeDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.SUPERVISION_MODE+mawb.getTradeMode());
107 result.setTradeModeDic(tradeModeDictionaryEntries); 125 result.setTradeModeDic(tradeModeDictionaryEntries);
108 result.setTradeMode(tradeModeDictionaryEntries.getChineseName()); 126 result.setTradeMode(tradeModeDictionaryEntries.getChineseName());
109 127
...@@ -117,8 +135,9 @@ public class ChmConsignmentService { ...@@ -117,8 +135,9 @@ public class ChmConsignmentService {
117 135
118 //境内收发货人名称 136 //境内收发货人名称
119 result.setOperateUnitName(mawb.getTradeName()); 137 result.setOperateUnitName(mawb.getTradeName());
120 - //成交方式 138 + //TODO 成交方式
121 - DictionaryEntries dealModeDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.CLINCH_TYPE+mawb.getTransMode()); 139 +// DictionaryEntries dealModeDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.CLINCH_TYPE+mawb.getTransMode());
140 + DictionaryEntries dealModeDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.CLINCH_TYPE+"CIF");
122 result.setDealModeDic(dealModeDictionaryEntries); 141 result.setDealModeDic(dealModeDictionaryEntries);
123 result.setDealMode(dealModeDictionaryEntries.getChineseName()); 142 result.setDealMode(dealModeDictionaryEntries.getChineseName());
124 143
...@@ -151,7 +170,15 @@ public class ChmConsignmentService { ...@@ -151,7 +170,15 @@ public class ChmConsignmentService {
151 result.setOverseasConsignorFnCname(mawb.getOverseasConsigneeEname()); 170 result.setOverseasConsignorFnCname(mawb.getOverseasConsigneeEname());
152 171
153 172
173 + //运单状态: 待申报海关
174 + DictionaryEntries transferWaybillStatusDictionaryEntries=Constant.dictionaryEntriesCache.get(Constant.TRANSFER_WAY_BILL_STATUS+"5");
175 + result.setConsStatusDic(transferWaybillStatusDictionaryEntries);
176 + result.setConsStatus(transferWaybillStatusDictionaryEntries.getChineseName());
177 + //推送时间作为创建时间,可以用来校验数据的有序性,如果新的推送时间小于已有的创建时间,就不更新数据
178 + result.setCreateTime(pushTime);
179 +
154 }catch (Exception e){ 180 }catch (Exception e){
181 + e.printStackTrace();
155 log.error("convertToChmConsignment() error:"+e.getMessage()); 182 log.error("convertToChmConsignment() error:"+e.getMessage());
156 } 183 }
157 return result; 184 return result;
...@@ -173,4 +200,80 @@ public class ChmConsignmentService { ...@@ -173,4 +200,80 @@ public class ChmConsignmentService {
173 } 200 }
174 201
175 202
203 + /**
204 + * 根据运单号查找数据
205 + * @param consignmentCode
206 + * @return
207 + */
208 + public ChmConsignment findChmConsignmentByConsignmentCode(String consignmentCode, Date startDate){
209 + try {
210 + return chmConsignmentRepository.findChmConsignmentByConsignmentCode(consignmentCode,startDate);
211 + }catch (Exception e){
212 + log.error("findChmConsignmentByConsignmentCode() error:"+ e.getMessage());
213 + }
214 + return null;
215 + }
216 +
217 +
218 + /**
219 + * 保存或更新 iclear中的运单信息
220 + * @param mawb
221 + * @param timeStamp
222 + */
223 + public void processChmConsignment(Mawb mawb, String timeStamp) {
224 + try {
225 + Date pushTime = DateUtils.timeStampToDate(Long.valueOf(timeStamp));
226 +
227 + ChmConsignment chmConsignment=this.convertToChmConsignment(mawb,pushTime);
228 + List<ChmConsignmentDetail> chmConsignmentDetailList = new ArrayList<>();
229 + mawb.getMawbDetailList().forEach(detail ->{
230 + chmConsignmentDetailList.add(chmConsignmentDetailService.convertToChmConsignmentDetail(detail));
231 + });
232 + chmConsignment.setChmConsignmentDetailList(chmConsignmentDetailList);
233 +
234 +
235 + //校验 7天+运单 ,如果有数据并且 还未报关就更新,如果数据就插入
236 + ChmConsignment chmConsignmentDB=this.findChmConsignmentByConsignmentCode(mawb.getBillNo(), DateUtils.addDate(DateUtils.getCurrentDate(),-7));
237 + //新增:如果没有就插入
238 + if (Objects.equals(chmConsignmentDB,null)){
239 + log.info("新增主单"+ mawb.getBillNo());
240 + ChmConsignment chmConsignmentSaveResult = this.saveChmConsignment(chmConsignment);
241 + if(!Objects.equals(chmConsignmentSaveResult,null)){
242 + log.info("主单"+ mawb.getBillNo()+" 保存成功,chmConsignmentId:"+chmConsignmentSaveResult.getId());
243 + }else{
244 + log.info("主单"+ mawb.getBillNo()+" 保存失败");
245 + }
246 + //更新:
247 + //如果有数据并且满足条件后才能更新数据
248 + //条件1、状态为 待申报海关
249 + //条件2、推送时间小于 上次推送的时间
250 + }else if(!Objects.equals(chmConsignmentDB,null)
251 + && Objects.equals(chmConsignmentDB.getConsStatusDic().getCode(),"transferWaybillStatus_5")
252 + && pushTime.getTime()<chmConsignmentDB.getCreateTime().getTime()){
253 + //TODO 更新数据
254 + log.info("更新主单"+ mawb.getBillNo());
255 +
256 + }
257 + }catch (Exception e){
258 + log.error(""+e.getMessage());
259 + }
260 + }
261 +
262 +
263 +
264 +
265 +
266 +
267 +
268 +
269 +
270 +
271 +
272 +
273 +
274 +
275 +
276 +
277 +
278 +
176 } 279 }
......
...@@ -26,6 +26,7 @@ public class DictionaryEntriesService { ...@@ -26,6 +26,7 @@ public class DictionaryEntriesService {
26 try { 26 try {
27 result=dictionaryEntriesRepository.findAllDictionaryEntries(); 27 result=dictionaryEntriesRepository.findAllDictionaryEntries();
28 }catch (Exception e){ 28 }catch (Exception e){
29 + e.printStackTrace();
29 log.error("getAllDictionaryEntries() error:"+e.getMessage()); 30 log.error("getAllDictionaryEntries() error:"+e.getMessage());
30 } 31 }
31 return result; 32 return result;
......
...@@ -38,7 +38,7 @@ public class IClearApiLogService { ...@@ -38,7 +38,7 @@ public class IClearApiLogService {
38 * 创建日志 38 * 创建日志
39 * @return 39 * @return
40 */ 40 */
41 - public IClearApiLog convertToIClearApiLog(Mawb mawb,String appId,String appKey){ 41 + public IClearApiLog convertToIClearApiLog(Mawb mawb,String appId,String appKey,Date pushTime){
42 IClearApiLog result = new IClearApiLog(); 42 IClearApiLog result = new IClearApiLog();
43 try{ 43 try{
44 result.setMsgType(Constant.MSG_TYPE_D); 44 result.setMsgType(Constant.MSG_TYPE_D);
...@@ -46,6 +46,7 @@ public class IClearApiLogService { ...@@ -46,6 +46,7 @@ public class IClearApiLogService {
46 result.setAppKey(appKey); 46 result.setAppKey(appKey);
47 result.setCreateTime(new Date()); 47 result.setCreateTime(new Date());
48 result.setUpdateTime(new Date()); 48 result.setUpdateTime(new Date());
49 + result.setPushTime(pushTime);
49 result.setReceiveResult(null); 50 result.setReceiveResult(null);
50 result.setResponseTime(null); 51 result.setResponseTime(null);
51 result.setSpendTime(null); 52 result.setSpendTime(null);
......
This diff is collapsed. Click to expand it.
1 +package com.erry.iclear.dateInterface;
2 +
3 +import com.erry.iclear.dateInterface.api.request.Mawb;
4 +import com.erry.iclear.dateInterface.api.request.MawbDetail;
5 +import com.erry.iclear.dateInterface.service.ChmConsignmentService;
6 +import org.junit.Test;
7 +import org.springframework.beans.factory.annotation.Autowired;
8 +
9 +import java.math.BigDecimal;
10 +import java.util.ArrayList;
11 +import java.util.Date;
12 +import java.util.List;
13 +
14 +public class ChmConsignmentServiceTest extends IClearApiApplicationTests {
15 +
16 +
17 + @Autowired
18 + private ChmConsignmentService chmConsignmentService;
19 +
20 +
21 + @Test
22 + public void testProcessChmConsignment(){
23 + try{
24 + Mawb mawb = this.createNewMawb();
25 + String timeStamp = String.valueOf(new Date().getTime());
26 + chmConsignmentService.processChmConsignment(mawb,timeStamp);
27 +
28 + }catch (Exception e){
29 + e.printStackTrace();
30 + }
31 + }
32 +
33 + private Mawb createNewMawb(){
34 + MawbDetail d1 = new MawbDetail();
35 + d1.setClassMark("");
36 + d1.setCodeTS("69125472");
37 + d1.setDeclPrice(BigDecimal.valueOf(111.123));
38 + d1.setDeclTotal(BigDecimal.valueOf(788));
39 + d1.setDutyMode("1");
40 + d1.setExgNo("");
41 + d1.setExgVersion("");
42 + d1.setFirstUnit("001");
43 + d1.setFirstQty(11);
44 + d1.setGUnit("007");
45 + d1.setGModel("商品规格、型号");
46 + d1.setGName("餐桌");
47 + d1.setGNo("1");
48 + d1.setGQty(1);
49 + d1.setOriginCountry("US");
50 + d1.setSecondUnit("007");
51 + d1.setSecondQty(2);
52 + d1.setTradeCurr("USD");
53 + d1.setUseTo("");
54 + d1.setWorkUsd(null);
55 + d1.setDestinationCountry("CN");
56 + d1.setCiqCode("");
57 + d1.setDeclGoodsEname("");
58 + d1.setDestCode("");
59 + d1.setDistrictCode("4408W");
60 +
61 +
62 + MawbDetail d2 = new MawbDetail();
63 + d2.setClassMark("");
64 + d2.setCodeTS("69125472");
65 + d2.setDeclPrice(BigDecimal.valueOf(45.72));
66 + d2.setDeclTotal(BigDecimal.valueOf(33));
67 + d2.setDutyMode("1");
68 + d2.setExgNo("");
69 + d2.setExgVersion("");
70 + d2.setFirstUnit("001");
71 + d2.setFirstQty(11);
72 + d2.setGUnit("007");
73 + d2.setGModel("商品规格、型号");
74 + d2.setGName("餐桌");
75 + d2.setGNo("2");
76 + d2.setGQty(22);
77 + d2.setOriginCountry("US");
78 + d2.setSecondUnit("007");
79 + d2.setSecondQty(3);
80 + d2.setTradeCurr("USD");
81 + d2.setUseTo("");
82 + d2.setWorkUsd(null);
83 + d2.setDestinationCountry("CN");
84 + d2.setCiqCode("");
85 + d2.setDeclGoodsEname("");
86 + d2.setDestCode("");
87 + d2.setDistrictCode("4408W");
88 +
89 +
90 +
91 + List<MawbDetail> mawbDetailList = new ArrayList<MawbDetail>();
92 + mawbDetailList.add(d1);
93 + mawbDetailList.add(d2);
94 +
95 +
96 +
97 +
98 + Mawb mawb = new Mawb();
99 + mawb.setIEFlag("E");
100 + mawb.setType("EX");
101 + mawb.setAgentCode("1111980005");
102 + mawb.setAgentName("联邦快递(中国)有限公司");
103 + mawb.setBillNo("202105210784");
104 + mawb.setContrNo("NO.565733");
105 + mawb.setCustomMaster("0101");
106 + mawb.setCutMode("1");//TODO levyType_1 到底是什么code?
107 + mawb.setDeclTrnRel("0");
108 + mawb.setDistinatePort("ASM000");
109 + mawb.setEdiId("001");
110 + mawb.setEntryId("25512456");
111 + mawb.setFeeCurr("USD");
112 + mawb.setFeeMark("3");
113 + mawb.setFeeRate(BigDecimal.valueOf(100.58));
114 + mawb.setGrossWet(500);
115 + mawb.setIEPort("0101");
116 + mawb.setInputerName("");
117 + mawb.setInsurCurr("MOP");
118 + mawb.setInsurMark("3");
119 + mawb.setInsurRate(BigDecimal.valueOf(23.44));
120 + mawb.setManualNo("备案号");
121 + mawb.setNetWt(BigDecimal.valueOf(80));
122 + mawb.setOtherCurr("USD");
123 + mawb.setOtherRate(BigDecimal.valueOf(10));
124 + mawb.setOtherMark("");
125 + mawb.setOwnerCode("Z321654987");
126 + mawb.setOwnerName("上海保险");
127 + mawb.setPackNo(1);
128 + mawb.setPreEntryId("");
129 + mawb.setTradeCountry("US");
130 + mawb.setTradeMode("110");
131 + mawb.setTradeCode("Z321654987");
132 + mawb.setTrafMode("1");
133 + mawb.setTradeName("上海铢怡国际货物运输代理有限公司");
134 + mawb.setTransMode("3");
135 + mawb.setWrapType("22");
136 + mawb.setTradeCodeScc("A74125896321456987");
137 + mawb.setOwnerCodeScc("A74125896321456987");
138 + mawb.setTradeAreaCode("US");
139 + mawb.setMarkNo("N/M");
140 + mawb.setEntyPortCode("310302");
141 + mawb.setGoodsPlace("");
142 + mawb.setDeclareName("张安");
143 + mawb.setOverseasConsignorCode("Z785421");
144 + mawb.setOverseasConsigneeCode("Z785421");
145 + mawb.setOverseasConsigneeEname("出口时必填收件人公司名(原)");
146 + mawb.setMawbDetailList(mawbDetailList);
147 +
148 + return mawb;
149 + }
150 +
151 +}
1 package com.erry.iclear.dateInterface; 1 package com.erry.iclear.dateInterface;
2 2
3 import org.junit.Test; 3 import org.junit.Test;
4 +import org.junit.runner.RunWith;
4 import org.springframework.boot.test.context.SpringBootTest; 5 import org.springframework.boot.test.context.SpringBootTest;
6 +import org.springframework.test.context.ActiveProfiles;
7 +import org.springframework.test.context.junit4.SpringRunner;
8 +import org.springframework.test.context.web.WebAppConfiguration;
5 9
10 +@RunWith(SpringRunner.class)
6 @SpringBootTest 11 @SpringBootTest
12 +@WebAppConfiguration
13 +@ActiveProfiles("dev")
7 class IClearApiApplicationTests { 14 class IClearApiApplicationTests {
8 15
9 @Test 16 @Test
10 - void contextLoads() { 17 + public void contextLoads() {
11 } 18 }
12 19
13 } 20 }
......
1 package com.erry.iclear.dateInterface; 1 package com.erry.iclear.dateInterface;
2 2
3 +import cn.hutool.core.date.DateUtil;
4 +import com.erry.iclear.dateInterface.util.DateUtils;
3 import com.erry.iclear.dateInterface.util.SHA256Util; 5 import com.erry.iclear.dateInterface.util.SHA256Util;
4 6
7 +import java.util.Date;
8 +
5 public class SHA256Test { 9 public class SHA256Test {
6 10
7 public static void main(String[] args) { 11 public static void main(String[] args) {
8 - long time =System.currentTimeMillis(); 12 +// long time =System.currentTimeMillis();
9 - System.out.println(time); 13 +// System.out.println(time);
10 - String str = "CTM"+"iClearExport"+"b92131f03f19a348"+time; 14 +// String str = "CTM"+"iClearExport"+"b92131f03f19a348"+time;
11 - 15 +//
12 - 16 +//
13 - System.out.println(SHA256Util.getSHA256String(str)); 17 +// System.out.println(SHA256Util.getSHA256String(str));
14 18
15 // 19 //
16 // 1623920478192 20 // 1623920478192
17 // eaf279997145f440ab5064e43f1a9cfdac15322886936801d57e022cde29919b 21 // eaf279997145f440ab5064e43f1a9cfdac15322886936801d57e022cde29919b
22 +
23 +//
24 +// //String s ="aaa_2222";
25 +// String s ="2222";
26 +// String str[]=s.split("_");
27 +// System.out.println(str[0]);
28 +// //System.out.println(str[1]);
29 +//
30 +// System.out.println(DateUtils.addDate(DateUtils.getCurrentDate(),-7));
31 +//
32 +
33 + Date currentDate = new Date();
34 + long timeStamp = currentDate.getTime();
35 + System.out.println(timeStamp);
36 + String tStr = String.valueOf(timeStamp);
37 + System.out.println(tStr);
38 + System.out.println(Long.valueOf(tStr));
39 +
40 +
41 +
42 + System.out.println(DateUtils.timeStampToDate(Long.valueOf(tStr)));
43 +
18 } 44 }
19 } 45 }
......