SecurityDeclarationService.java
5.5 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
package com.agent.service.system;
import com.agent.entity.Constant;
import com.agent.entity.agent.SecurityDeclarationEntity;
import com.agent.entity.agent.SecurityManifestEntity;
import com.agent.repository.system.SecurityDeclarationRepository;
import com.agent.repository.system.SecurityManifestRepository;
import com.agent.service.BasicService;
import com.agent.vo.agent.SDVo;
import com.agent.xml.common.XmlHead;
import com.agent.xml.manifestdeclare.*;
import com.agent.xml.secuity.SecurityDeclarationXml;
import com.plugin.easyui.EasyPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import java.util.Date;
/**
* @Auther: shenhl
* @Date: 2019/4/24 16:46
*/
@Service
public class SecurityDeclarationService extends BasicService<SecurityManifestEntity> {
@Autowired
private SecurityDeclarationRepository securityDeclarationRepository;
@Autowired
private SecurityManifestRepository securityManifestRepository;
/**
* 分页查询
*
* @param pageForm 分页对象
* @return 包含分页信息和数据的分页对象
*/
public Page<SecurityManifestEntity> getPage(EasyPage<SecurityManifestEntity> pageForm) {
PageRequest pageRequest = buildPageRequest(pageForm);
Specification<SecurityManifestEntity> spec = buildSpecification(pageForm);
Page<SecurityManifestEntity> page = securityManifestRepository.findAll(spec, pageRequest);
return page;
}
public int findWaybill(String waybill){
return securityDeclarationRepository.findWaybill(waybill);
}
public SecurityDeclarationEntity save(SecurityDeclarationEntity securityDeclarationEntity){
return securityDeclarationRepository.save(securityDeclarationEntity);
}
public SecurityDeclarationEntity findOne(Long id){
return securityDeclarationRepository.findOne(id);
}
public int update(SecurityDeclarationEntity sd){
return securityDeclarationRepository.update(sd.getId(), sd.getSd_waybill(),
sd.getSd_cargo_agent_name(), sd.getSd_cargo_shipper_name(),
sd.getSd_iata_number(), sd.getSd_transport_certificate(),
sd.getSd_transportation_prove(), sd.getUSER_ID(), sd.getOperation_time());
}
// 安检申报发送NDLR
public ManifestDeclareMsgXml sendNDLRXml(SDVo sdVo) {
// 同时生成2分报文 并且发送
ManifestDeclareMsgXml dms = new ManifestDeclareMsgXml();
ManifestDeclareMetaXml mdme = new ManifestDeclareMetaXml();
mdme.setSndr("NDLR");
mdme.setRcvr("");
mdme.setSeqn(sdVo.getSd_waybill());
mdme.setDdtm(Constant.dateTimeFormatnumber.format(new Date()));
mdme.setType("HYXX");
mdme.setStyp("AJXX");
dms.setMeta(mdme);
DeclarePreparemasterXmlBody body = generateXml(sdVo);
dms.setDeclarepreparemasterxmlbody(body);
System.out.println(dms.toString());
return dms;
}
// 安检申报公共报文
private DeclarePreparemasterXmlBody generateXml(SDVo sdVo) {
// 生成报文
DeclarePreparemasterXmlBody body = new DeclarePreparemasterXmlBody();
// 设置xml开头
XmlHead head = new XmlHead();
head.setMessageID("CN_MT2201_1P0_460470678920X_" + Constant.dateTimeFormatnumber.format(new Date()));
head.setFunctionCode("9");
head.setMessageType("MT2201MASTER");
head.setSenderID("460470678920X_DXPENT0000460002_" + Constant.dateTimeFormatnumber.format(new Date()));
head.setReceiverID("4604_" + Constant.dateTimeFormatnumber.format(new Date()));
head.setSendTime(Constant.dateTimeFormatnumber.format(new Date()));
head.setVersion("1.0");
body.setHead(head);
// 安检申报 共用预配舱单
ManifestDeclarationXml dec = new ManifestDeclarationXml();
// 承运人
ManifestCarrierXml carr = new ManifestCarrierXml();
carr.setId(sdVo.getCarrier());
dec.setCarrier(carr);
// 目的站
ManifestDesXml md = new ManifestDesXml();
md.setId(sdVo.getDestinationstation());
dec.setDes(md);
// +"/"+sdVo.getDestinationstation()
// 航班号-航班日期
ManifestBorderTransportMeansXml mt = new ManifestBorderTransportMeansXml();
mt.setJourneyid(sdVo.getCarrier()+sdVo.getFlightno() + "/" + Constant.dateFormat.format(sdVo.getFlightdate()));
dec.setBordertransportmeans(mt);
// 运单号
ManifestTransportContractDocumentXml mac = new ManifestTransportContractDocumentXml();
mac.setId(sdVo.getSd_waybill());
SecurityDeclarationXml sdXml = new SecurityDeclarationXml();
sdXml.setCargoAgentName(sdVo.getSd_cargo_agent_name());
sdXml.setCargoName(sdVo.getSd_cargo_name());
sdXml.setCargoType(sdVo.getSd_cargo_type().substring(0, sdVo.getSd_cargo_type().length()-1));
sdXml.setShipperName(sdVo.getSd_cargo_shipper_name());
sdXml.setIataNo(sdVo.getSd_iata_number());
sdXml.setPiece(sdVo.getTotalpiece());
sdXml.setWeight(sdVo.getTotalweight());
sdXml.setTransportCertificate(sdVo.getSd_transport_certificate());
sdXml.setTransportationProve(sdVo.getSd_transportation_prove());
dec.setSecurityDeclarationXml(sdXml);
body.setDeclaration(dec);
return body;
}
}