ChmConsignmentDetailService.java
6.43 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
package com.erry.iclear.dateInterface.service;
import com.erry.iclear.dateInterface.api.request.MawbDetail;
import com.erry.iclear.dateInterface.common.Constant;
import com.erry.iclear.dateInterface.entity.*;
import com.erry.iclear.dateInterface.repository.ChmConsignmentDetailRepository;
import com.erry.iclear.dateInterface.repository.ChmConsignmentRepository;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* @author Administrator
*/
@Service
@Slf4j
public class ChmConsignmentDetailService {
@Autowired
private ChmConsignmentDetailRepository chmConsignmentDetailRepository;
/**
* 转换运单明细
* @param mawbDetail
* @return
*/
public ChmConsignmentDetail convertToChmConsignmentDetail(MawbDetail mawbDetail,ChmConsignment chmConsignment){
ChmConsignmentDetail result = new ChmConsignmentDetail();
try{
result.setChmConsignment(chmConsignment);
//归类标志
//商品编号
result.setSkuCode(mawbDetail.getCodeTS());
//申报单价
result.setOriRegion(mawbDetail.getDeclPrice());
//申报总价
result.setAmount(mawbDetail.getDeclTotal());
//征免方式
DictionaryEntries levyTypeDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.LEVY_TYPE+mawbDetail.getDutyMode());
result.setLevyTypeDic(levyTypeDictionaryEntries);
result.setLevyType(levyTypeDictionaryEntries.getChineseName());
//货号
//版本号
//第一计量单位(法定单位)
DictionaryEntries firstUnitDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.TRANSACTION_UNIT+ mawbDetail.getFirstUnit());
result.setUnitLegalFirstId(firstUnitDictionaryEntries);
result.setKnockdownUnit(firstUnitDictionaryEntries.getChineseName());
//第一法定数量
result.setQtyLegalFirst(BigDecimal.valueOf(mawbDetail.getFirstQty().doubleValue()));
//成交计量单位
DictionaryEntries knockdownUnitEntries = Constant.dictionaryEntriesCache.get(Constant.TRANSACTION_UNIT+ mawbDetail.getFirstUnit());
result.setKnockdownUnitDic(knockdownUnitEntries);
result.setKnockdownUnit(knockdownUnitEntries.getChineseName());
//商品规格、型号
result.setModel(mawbDetail.getGmodel());
//商品名称
result.setSkuName(mawbDetail.getGname());
//商品序号
//成交数量
result.setKnockdownNumber(BigDecimal.valueOf(mawbDetail.getGqty().doubleValue()));
//原产国
DictionaryEntries habitatDictonaryEntries = Constant.dictionaryEntriesCache.get(Constant.COUNTRY+ mawbDetail.getOriginCountry());
result.setHabitatDic(habitatDictonaryEntries);
result.setHabitat(habitatDictonaryEntries.getChineseName());
//第二计量单位
DictionaryEntries secondUnitDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.TRANSACTION_UNIT+ mawbDetail.getSecondUnit());
result.setUnitLegalSecondId(secondUnitDictionaryEntries);
result.setUnitLegalSecond(secondUnitDictionaryEntries.getChineseName());
//第二法定数量
result.setQtyLegalSecond(BigDecimal.valueOf(mawbDetail.getSecondQty().doubleValue()));
//成交币制
DictionaryEntries currencyDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.CURRENCY_SYSTEM+ mawbDetail.getTradeCurr());
result.setCurrencyDic(currencyDictionaryEntries);
result.setCurrency(currencyDictionaryEntries.getChineseName());
//用途/生产厂家
//工缴费
//最终目的国
DictionaryEntries destinationCountryDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.COUNTRY+ mawbDetail.getDestinationCountry());
result.setDestinationCountryDic(destinationCountryDictionaryEntries);
result.setDestinationCountry(destinationCountryDictionaryEntries.getChineseName());
//检验检疫编码
//申报货物英文名称
result.setContentDescription(mawbDetail.getDeclGoodsEname());
//目的地代码
if(StringUtils.isNotBlank(mawbDetail.getDestCode())){
OrigplacecodeMapping origplacecodeMapping = Constant.origplacecodeMappingCache.get(mawbDetail.getDestCode());
result.setOrigplacecodeMapping(origplacecodeMapping);
result.setOrigplacecode(origplacecodeMapping.getOrigplaceName());
}
//境内目的地/境内货源地
DomesticDestinationMapping domesticDestinationDictionaryEntries = Constant.domesticDestinationMappingCache.get(mawbDetail.getDistrictCode());
result.setDomesticDestinationMapping(domesticDestinationDictionaryEntries);
result.setDomesticDestination(destinationCountryDictionaryEntries.getChineseName());
}catch (Exception e){
log.error("convertToChmConsignmentDetail() error:"+e.getMessage());
}
return result;
}
public List<ChmConsignmentDetail> findChmConsignmentDetailListByConsignmentCode(Long consignmentId){
List<ChmConsignmentDetail> result = new ArrayList<>();
try{
result= chmConsignmentDetailRepository.findChmConsignmentDetailByConsignmentCode(consignmentId);
}catch (Exception e){
log.error("findChmConsignmentDetailListByConsignmentCode() error:"+e.getMessage());
}
return result;
}
public void saveDetailList(List<ChmConsignmentDetail> chmConsignmentDetailList){
chmConsignmentDetailRepository.saveAll(chmConsignmentDetailList);
}
public void saveChmConsignmentDetail(ChmConsignmentDetail consignmentDetail){
chmConsignmentDetailRepository.save(consignmentDetail);
}
public void deleteChmConsignmentDetail(Long id){
chmConsignmentDetailRepository.deleteById(id);
}
public void deleteChmConsignmentDetailBatch(List<Long> idList){
chmConsignmentDetailRepository.deleteChmConsignmentDetailByChnConIdList(idList);
}
}