ChmConsignmentService.java
7.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
package com.erry.iclear.dateInterface.service;
import com.erry.iclear.dateInterface.api.request.Mawb;
import com.erry.iclear.dateInterface.common.Constant;
import com.erry.iclear.dateInterface.entity.ChmCarryPort;
import com.erry.iclear.dateInterface.entity.ChmConsignment;
import com.erry.iclear.dateInterface.entity.DictionaryEntries;
import com.erry.iclear.dateInterface.repository.ChmConsignmentRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
/**
* @author Administrator
*/
@Service
@Slf4j
public class ChmConsignmentService {
@Autowired
private ChmConsignmentRepository chmConsignmentRepository;
/**
* 转换主单
* @return
*/
public ChmConsignment convertToChmConsignment(Mawb mawb){
ChmConsignment result = new ChmConsignment();
try{
//进出口标志:固定值 E
//报关类型:填写固定值EX,但字典表里没有这个值
// result.setDeclaredDocTypeDic();
// result.setDeclaredCode();
//申报单位代码:固定值 1111980005
result.setDeclaredUnitName(mawb.getAgentName());
//申报单位名称:固定值 联邦快递(中国)有限公司
//提单号:有总单号则取值“总单号_运单号”,没有总单号则取值“运单号”
String billNo[]=mawb.getBillNo().split("_");
result.setConsignmentHeadCode(billNo[0]);
result.setConsignmentCode(billNo[1]);
//合同号
result.setContractCode(mawb.getContrNo());
//主管海关(申报地海关)
result.setCustomsNo(mawb.getCustomMaster());
//征免性质
DictionaryEntries levyTypeDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.LEVY_TYPE+mawb.getCutMode());
result.setTaxNatureDic(levyTypeDictionaryEntries);
result.setTaxNature(levyTypeDictionaryEntries.getChineseName());
//报关/转关关系标志:固定值0 ,但数据字典里没有0
//经停港/指运港
ChmCarryPort chmCarryPort =Constant.chmCarryPortCache.get(mawb.getDistinatePort());
result.setThroughStopPortDic(chmCarryPort);
result.setThroughStopPort(chmCarryPort.getPortNo());
//报关标志
//海关编号
result.setCustomsNo(mawb.getEntryId());
//运费币制
DictionaryEntries currencyDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.CURRENCY_SYSTEM+mawb.getFeeCurr());
result.setTransCurrencyDic(currencyDictionaryEntries);
result.setTransCurrency(currencyDictionaryEntries.getChineseName());
//运费标记:固定值 3
//运费总价
result.setTransCost(mawb.getFeeRate());
//毛重
result.setGrossWeight(BigDecimal.valueOf(mawb.getGrossWet()));
//出入境关闭:固定值 0101
//录入人名称:固定值 必填项,但填的值是空值
//保险费币制
DictionaryEntries insuranceDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.CURRENCY_SYSTEM+mawb.getInsurCurr());
result.setInsuranceCostCurrencyDic(insuranceDictionaryEntries);
result.setInsuranceCostCurrency(insuranceDictionaryEntries.getChineseName());
//保险费标记
//保险费/率
result.setInsuranceCost(mawb.getInsurRate());
//备案号
result.setRecordCode(mawb.getManualNo());
//净重
result.setNetWeight(mawb.getNetWt());
//杂费币制
DictionaryEntries otherDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.CURRENCY_SYSTEM+mawb.getOtherCurr());
result.setInsuranceCostCurrencyDic(otherDictionaryEntries);
result.setInsuranceCostCurrency(otherDictionaryEntries.getChineseName());
//杂费/率
result.setOtherCost(mawb.getOtherRate());
//杂费标志
//消费使用/生产销售单位代码
//消费使用/生产销售单位名称
//件数
result.setCounts(mawb.getPackNo().longValue());
//预录入编号
result.setEnteringNo(mawb.getPreEntryId());
//启运国/运抵国
DictionaryEntries fromCountryDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.COUNTRY+mawb.getOtherCurr());
result.setFromCountryDic(fromCountryDictionaryEntries);
result.setFromCountry(fromCountryDictionaryEntries.getChineseName());
//监管方式
DictionaryEntries tradeModeDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.COUNTRY+mawb.getOtherCurr());
result.setTradeModeDic(tradeModeDictionaryEntries);
result.setTradeMode(tradeModeDictionaryEntries.getChineseName());
//境内收发货人编号
result.setTradeCoSCC(mawb.getTradeCode());
//运输方式代码
DictionaryEntries vehicleWayDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.VEHICLE_WAY_CODE+mawb.getTrafMode());
result.setVehicleWay(vehicleWayDictionaryEntries);
result.setVehicleWayCode(vehicleWayDictionaryEntries.getCode());
//境内收发货人名称
result.setOperateUnitName(mawb.getTradeName());
//成交方式
DictionaryEntries dealModeDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.CLINCH_TYPE+mawb.getTransMode());
result.setDealModeDic(dealModeDictionaryEntries);
result.setDealMode(dealModeDictionaryEntries.getChineseName());
//包装种类
DictionaryEntries packageTypeDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.NEW_PACKAGE_TYPE+mawb.getWrapType());
result.setPackageTypeDic(packageTypeDictionaryEntries);
result.setPackageType(packageTypeDictionaryEntries.getChineseName());
//生产核销单位统一信用代码---报关形式类型
//消费使用/生产销售单位单位统一编码
//贸易国别
DictionaryEntries tradeAreaCodeDictionaryEntries=Constant.dictionaryEntriesCache.get(Constant.COUNTRY+mawb.getTradeAreaCode());
result.setTradeAreaCodeDic(tradeAreaCodeDictionaryEntries);
result.setTradeAreaCode(tradeAreaCodeDictionaryEntries.getChineseName());
//标记及号码
result.setDeclaredRemark(mawb.getMarkNo());
//入境口岸代码:固定值 310302
//存放地点:固定值 空值
//申报人员姓名---报关员证号
result.setDeclaredUnitName(mawb.getDeclareName());
//境外发货人代码
//境外收货人编码
result.setOverseasConsignorCode(mawb.getOverseasConsigneeCode());
//境外收货人名称(外文)
result.setOverseasConsignorFnCname(mawb.getOverseasConsigneeEname());
}catch (Exception e){
log.error("convertToChmConsignment() error:"+e.getMessage());
}
return result;
}
/**
* 保存主单
* @param chmConsignment
* @return
*/
public ChmConsignment saveChmConsignment(ChmConsignment chmConsignment){
try{
return chmConsignmentRepository.save(chmConsignment);
}catch (Exception e){
log.error("saveChmConsignment() error:"+e.getMessage());
}
return null;
}
}