正在显示
7 个修改的文件
包含
170 行增加
和
34 行删除
@@ -37,23 +37,23 @@ spring: | @@ -37,23 +37,23 @@ spring: | ||
37 | #eureka主机名,会在控制页面中显示 | 37 | #eureka主机名,会在控制页面中显示 |
38 | #DEV环境关闭注册。 | 38 | #DEV环境关闭注册。 |
39 | features: | 39 | features: |
40 | - enabled: false | 40 | + enabled: true |
41 | discovery: | 41 | discovery: |
42 | - enabled: false | 42 | + enabled: true |
43 | service-registry: | 43 | service-registry: |
44 | auto-registration: | 44 | auto-registration: |
45 | - enabled: false | 45 | + enabled: true |
46 | 46 | ||
47 | datasource: | 47 | datasource: |
48 | type: com.alibaba.druid.pool.DruidDataSource | 48 | type: com.alibaba.druid.pool.DruidDataSource |
49 | #oracle | 49 | #oracle |
50 | driver-class-name: oracle.jdbc.OracleDriver | 50 | driver-class-name: oracle.jdbc.OracleDriver |
51 | - url: jdbc:oracle:thin:@192.168.1.199:10069:CGODB | ||
52 | - username: CGONMS | ||
53 | - password: 1q2w3e4r | ||
54 | -# url: jdbc:oracle:thin:@192.168.1.253:1522:ORCLL | 51 | +# url: jdbc:oracle:thin:@192.168.1.199:10069:CGODB |
55 | # username: CGONMS | 52 | # username: CGONMS |
56 | -# password: vmvnv1v2 | 53 | +# password: 1q2w3e4r |
54 | + url: jdbc:oracle:thin:@192.168.1.253:1522:ORCLL | ||
55 | + username: CGONMS | ||
56 | + password: vmvnv1v2 | ||
57 | #spring datasource mysql,注意编码配置,缺少数据库编码配置容易引起中文入库乱码 | 57 | #spring datasource mysql,注意编码配置,缺少数据库编码配置容易引起中文入库乱码 |
58 | # url: jdbc:mysql://127.0.0.1:3307/statistics?useUnicode=true&characterEncoding=utf8 | 58 | # url: jdbc:mysql://127.0.0.1:3307/statistics?useUnicode=true&characterEncoding=utf8 |
59 | # username: root | 59 | # username: root |
@@ -133,13 +133,25 @@ jwt: | @@ -133,13 +133,25 @@ jwt: | ||
133 | max-alive: 300 | 133 | max-alive: 300 |
134 | # 舱单生成配置 | 134 | # 舱单生成配置 |
135 | customs: | 135 | customs: |
136 | + # 操作员IC卡姓名 | ||
137 | + inputOpName: 翟梦一 | ||
138 | + # 操作员IC卡号 | ||
139 | + inputOpId: 8930000085548 | ||
140 | + # 报关公司 | ||
141 | + applyName: 河南航空货运发展有限公司 | ||
142 | + # 报关公司海关十位编码 | ||
143 | + applyCode: 4101888126 | ||
144 | + # 报关公司组织机构代码 | ||
145 | + copCode: 70678920X | ||
136 | #生成报文文件夹路径,尾部要带斜杠/ | 146 | #生成报文文件夹路径,尾部要带斜杠/ |
137 | xml-path: customTemplate/ | 147 | xml-path: customTemplate/ |
148 | + # 海关通道数据传输人识别号 | ||
138 | transport-number: 460470678920X | 149 | transport-number: 460470678920X |
139 | # 转关运抵相关配置 | 150 | # 转关运抵相关配置 |
140 | transarrive: | 151 | transarrive: |
141 | #生成报文文件夹路径,尾部要带斜杠/ | 152 | #生成报文文件夹路径,尾部要带斜杠/ |
142 | xml-save: transarriveSend/ | 153 | xml-save: transarriveSend/ |
154 | + | ||
143 | sso: | 155 | sso: |
144 | witheIP: 10.5.14.108,10.5.14.109,10.5.14.110 | 156 | witheIP: 10.5.14.108,10.5.14.109,10.5.14.110 |
145 | info: | 157 | info: |
1 | +package com.tianbo.analysis.config; | ||
2 | + | ||
3 | +import lombok.extern.slf4j.Slf4j; | ||
4 | +import org.springframework.boot.context.properties.ConfigurationProperties; | ||
5 | +import org.springframework.stereotype.Component; | ||
6 | + | ||
7 | + | ||
8 | +/** | ||
9 | + * @author mrz | ||
10 | + * 海关相关配置 | ||
11 | + */ | ||
12 | +@Slf4j | ||
13 | +@Component | ||
14 | +@ConfigurationProperties(prefix = "customs") | ||
15 | +public class CustomsProperties { | ||
16 | + private String inputOpName; | ||
17 | + private String inputOpId; | ||
18 | + private String applyName; | ||
19 | + private String applyCode; | ||
20 | + private String copCode; | ||
21 | + private Transarrive transarrive; | ||
22 | + | ||
23 | + public String getInputOpName() { | ||
24 | + return inputOpName; | ||
25 | + } | ||
26 | + | ||
27 | + public void setInputOpName(String inputOpName) { | ||
28 | + this.inputOpName = inputOpName; | ||
29 | + } | ||
30 | + | ||
31 | + public String getInputOpId() { | ||
32 | + return inputOpId; | ||
33 | + } | ||
34 | + | ||
35 | + public void setInputOpId(String inputOpId) { | ||
36 | + this.inputOpId = inputOpId; | ||
37 | + } | ||
38 | + | ||
39 | + public String getApplyName() { | ||
40 | + return applyName; | ||
41 | + } | ||
42 | + | ||
43 | + public void setApplyName(String applyName) { | ||
44 | + this.applyName = applyName; | ||
45 | + } | ||
46 | + | ||
47 | + public String getApplyCode() { | ||
48 | + return applyCode; | ||
49 | + } | ||
50 | + | ||
51 | + public void setApplyCode(String applyCode) { | ||
52 | + this.applyCode = applyCode; | ||
53 | + } | ||
54 | + | ||
55 | + public String getCopCode() { | ||
56 | + return copCode; | ||
57 | + } | ||
58 | + | ||
59 | + public void setCopCode(String copCode) { | ||
60 | + this.copCode = copCode; | ||
61 | + } | ||
62 | + | ||
63 | + public Transarrive getTransarrive() { | ||
64 | + return transarrive; | ||
65 | + } | ||
66 | + | ||
67 | + public void setTransarrive(Transarrive transarrive) { | ||
68 | + this.transarrive = transarrive; | ||
69 | + } | ||
70 | + | ||
71 | + public static class Transarrive { | ||
72 | + private String xmlSave; | ||
73 | + | ||
74 | + public String getXmlSave() { | ||
75 | + return xmlSave; | ||
76 | + } | ||
77 | + | ||
78 | + public void setXmlSave(String xmlSave) { | ||
79 | + this.xmlSave = xmlSave; | ||
80 | + } | ||
81 | + } | ||
82 | +} |
@@ -107,6 +107,10 @@ public class TRANSTOARRIVEEXPORT { | @@ -107,6 +107,10 @@ public class TRANSTOARRIVEEXPORT { | ||
107 | return customscode; | 107 | return customscode; |
108 | } | 108 | } |
109 | 109 | ||
110 | + /** | ||
111 | + * | ||
112 | + * @param customscode 海关关区 | ||
113 | + */ | ||
110 | public void setCustomscode(String customscode) { | 114 | public void setCustomscode(String customscode) { |
111 | this.customscode = customscode == null ? null : customscode.trim(); | 115 | this.customscode = customscode == null ? null : customscode.trim(); |
112 | } | 116 | } |
@@ -358,4 +362,9 @@ public class TRANSTOARRIVEEXPORT { | @@ -358,4 +362,9 @@ public class TRANSTOARRIVEEXPORT { | ||
358 | public void setUpdatetime(Date updatetime) { | 362 | public void setUpdatetime(Date updatetime) { |
359 | this.updatetime = updatetime; | 363 | this.updatetime = updatetime; |
360 | } | 364 | } |
365 | + | ||
366 | + @Override | ||
367 | + public String toString() { | ||
368 | + return super.toString(); | ||
369 | + } | ||
361 | } | 370 | } |
@@ -2,6 +2,7 @@ package com.tianbo.analysis.service.imp; | @@ -2,6 +2,7 @@ package com.tianbo.analysis.service.imp; | ||
2 | 2 | ||
3 | import com.github.pagehelper.PageHelper; | 3 | import com.github.pagehelper.PageHelper; |
4 | import com.github.pagehelper.PageInfo; | 4 | import com.github.pagehelper.PageInfo; |
5 | +import com.tianbo.analysis.config.CustomsProperties; | ||
5 | import com.tianbo.analysis.dao.TRANSTOARRIVEEXPORTMapper; | 6 | import com.tianbo.analysis.dao.TRANSTOARRIVEEXPORTMapper; |
6 | import com.tianbo.analysis.model.ResultJson; | 7 | import com.tianbo.analysis.model.ResultJson; |
7 | import com.tianbo.analysis.model.TRANSTOARRIVEEXPORT; | 8 | import com.tianbo.analysis.model.TRANSTOARRIVEEXPORT; |
@@ -39,6 +40,9 @@ public class TransArriveExportImpl implements TransArriveExportService { | @@ -39,6 +40,9 @@ public class TransArriveExportImpl implements TransArriveExportService { | ||
39 | @Autowired | 40 | @Autowired |
40 | private TemplateEngine templateEngine; | 41 | private TemplateEngine templateEngine; |
41 | 42 | ||
43 | + @Autowired | ||
44 | + private CustomsProperties customsProperties; | ||
45 | + | ||
42 | @Value("${customs.transarrive.xml-save}") | 46 | @Value("${customs.transarrive.xml-save}") |
43 | private String saveXmlForSendDir; | 47 | private String saveXmlForSendDir; |
44 | 48 | ||
@@ -67,6 +71,15 @@ public class TransArriveExportImpl implements TransArriveExportService { | @@ -67,6 +71,15 @@ public class TransArriveExportImpl implements TransArriveExportService { | ||
67 | 71 | ||
68 | @Override | 72 | @Override |
69 | public ResultJson send(TRANSTOARRIVEEXPORT record) { | 73 | public ResultJson send(TRANSTOARRIVEEXPORT record) { |
74 | + //设置海关相关信息配置 | ||
75 | + record.setApplycode(customsProperties.getApplyCode()); | ||
76 | + record.setApplyname(customsProperties.getApplyName()); | ||
77 | + record.setCopcode(customsProperties.getCopCode()); | ||
78 | + record.setCustomscode("4604"); | ||
79 | + //操作员IC卡号 | ||
80 | + record.setInputopid(customsProperties.getInputOpId()); | ||
81 | + // 操作员姓名 | ||
82 | + record.setInputopname(customsProperties.getInputOpName()); | ||
70 | ResultJson resultJson= new ResultJson(); | 83 | ResultJson resultJson= new ResultJson(); |
71 | try{ | 84 | try{ |
72 | 85 | ||
@@ -85,45 +98,49 @@ public class TransArriveExportImpl implements TransArriveExportService { | @@ -85,45 +98,49 @@ public class TransArriveExportImpl implements TransArriveExportService { | ||
85 | //生成的文件名 | 98 | //生成的文件名 |
86 | String fileName = messageID + ".xml"; | 99 | String fileName = messageID + ".xml"; |
87 | //生成的报文路径,带斜杠 | 100 | //生成的报文路径,带斜杠 |
88 | - String filePath = saveXmlForSendDir+fileName; | 101 | + String filePath = customsProperties.getTransarrive().getXmlSave()+fileName; |
89 | File file = ResourceUtils.getFile(filePath); | 102 | File file = ResourceUtils.getFile(filePath); |
90 | /** | 103 | /** |
91 | * 中文的地方在模板中要用utext,否则中文会被 escape 转义 | 104 | * 中文的地方在模板中要用utext,否则中文会被 escape 转义 |
92 | */ | 105 | */ |
93 | String xmlStr = templateEngine.process("transToArrive/EXPORT_DECLARE_TPL.xml",context); | 106 | String xmlStr = templateEngine.process("transToArrive/EXPORT_DECLARE_TPL.xml",context); |
94 | 107 | ||
95 | - boolean valied = XmlTools.validateXMLSchema("xsd/ETAImportMessage.xsd", xmlStr); | ||
96 | - if (valied){ | ||
97 | - FileUtils.writeStringToFile(file,xmlStr, StandardCharsets.UTF_8); | 108 | + boolean valied = XmlTools.validateXMLSchemaThrowError("xsd/ETAImportMessage.xsd", xmlStr); |
109 | + if (valied) { | ||
110 | + FileUtils.writeStringToFile(file, xmlStr, StandardCharsets.UTF_8); | ||
98 | //todo:更新发送状态,插入发送日志 | 111 | //todo:更新发送状态,插入发送日志 |
99 | 112 | ||
100 | resultJson.setCode("200"); | 113 | resultJson.setCode("200"); |
101 | resultJson.setMsg("报文发送成功"); | 114 | resultJson.setMsg("报文发送成功"); |
102 | - }else { | ||
103 | - resultJson.setCode("400"); | ||
104 | - resultJson.setMsg("报文发送失败,报文校验不通过"); | ||
105 | - resultJson.setError("报文发送失败,报文校验不通过"); | 115 | + log.info("[XML-BUILD]- 报文已生成到目录{}",filePath); |
106 | } | 116 | } |
107 | }catch (FileNotFoundException e){ | 117 | }catch (FileNotFoundException e){ |
108 | e.printStackTrace(); | 118 | e.printStackTrace(); |
109 | resultJson.setCode("401"); | 119 | resultJson.setCode("401"); |
110 | - resultJson.setMsg("报文发送失败,文件未找到,"+e.toString()); | ||
111 | - resultJson.setError("报文发送失败,文件未找到,"+e.toString()); | 120 | + resultJson.setMsg("报文发送失败,文件未找到"); |
121 | + resultJson.setError(e.toString()); | ||
122 | + log.error("报文发送失败,[{}]文件未找到",e.toString()); | ||
112 | }catch (IOException e) { | 123 | }catch (IOException e) { |
113 | e.printStackTrace(); | 124 | e.printStackTrace(); |
114 | resultJson.setCode("402"); | 125 | resultJson.setCode("402"); |
115 | - resultJson.setMsg("报文发送失败,文件读取失败,"+e.toString()); | ||
116 | - resultJson.setError("报文发送失败,文件读取失败,"+e.toString()); | 126 | + resultJson.setMsg("报文发送失败,文件读取失败"); |
127 | + resultJson.setError(e.toString()); | ||
128 | + log.error("报文发送失败,[{}]文件IO读取失败",e.toString()); | ||
117 | }catch (TemplateInputException e){ | 129 | }catch (TemplateInputException e){ |
118 | resultJson.setCode("404"); | 130 | resultJson.setCode("404"); |
119 | - resultJson.setMsg("报文发送失败,报文模板未找到,"+e.toString()); | ||
120 | - resultJson.setError("报文发送失败,报文模板未找到,"+e.toString()); | 131 | + resultJson.setMsg("报文发送失败,报文模板未找到"); |
132 | + resultJson.setError(e.toString()); | ||
133 | + log.error("报文发送失败,[{}]报文模板未找到",e.toString()); | ||
121 | }catch (SAXParseException e){ | 134 | }catch (SAXParseException e){ |
122 | - log.error("[XML-ERR]-xml报文校验失败:{}",e.getMessage()); | 135 | + log.error("[XML-ERR]-xml报文校验失败:[{}]", e.getMessage()); |
136 | + resultJson.setCode("400"); | ||
137 | + resultJson.setMsg("报文发送失败,报文校验不通过"); | ||
138 | + resultJson.setError(e.getMessage()); | ||
123 | } catch (Exception ignored){ | 139 | } catch (Exception ignored){ |
124 | resultJson.setCode("405"); | 140 | resultJson.setCode("405"); |
125 | - resultJson.setMsg("报文发送失败,其他错误"+ignored.toString()); | ||
126 | - resultJson.setError("报文发送失败,其他错误"+ignored.toString()); | 141 | + resultJson.setMsg("报文发送失败,其他错误"); |
142 | + resultJson.setError(ignored.toString()); | ||
143 | + log.error("[XML-ERR]-报文发送失败,其他错误:[{}]", ignored.getMessage()); | ||
127 | } | 144 | } |
128 | return resultJson; | 145 | return resultJson; |
129 | } | 146 | } |
@@ -47,4 +47,16 @@ public class XmlTools { | @@ -47,4 +47,16 @@ public class XmlTools { | ||
47 | } | 47 | } |
48 | return true; | 48 | return true; |
49 | } | 49 | } |
50 | + | ||
51 | + public static boolean validateXMLSchemaThrowError(String xsdPath, String xmlStr) throws IOException,SAXException { | ||
52 | + ByteArrayInputStream bais = new ByteArrayInputStream(xmlStr.getBytes("UTF-8")); | ||
53 | + SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); | ||
54 | + Schema schema = factory.newSchema(new File(xsdPath)); | ||
55 | + Validator validator = schema.newValidator(); | ||
56 | + | ||
57 | + Source source = new StreamSource(bais); | ||
58 | + validator.validate(source); | ||
59 | + | ||
60 | + return true; | ||
61 | + } | ||
50 | } | 62 | } |
@@ -56,16 +56,16 @@ | @@ -56,16 +56,16 @@ | ||
56 | <include refid="Base_Column_List" /> | 56 | <include refid="Base_Column_List" /> |
57 | from CGONMS.TRANS_TO_ARRIVE_EXPORT | 57 | from CGONMS.TRANS_TO_ARRIVE_EXPORT |
58 | where 1=1 | 58 | where 1=1 |
59 | - <if test="customscode != null" > | 59 | + <if test="customscode != null and customscode != ''" > |
60 | and CustomsCode = #{customscode,jdbcType=VARCHAR} | 60 | and CustomsCode = #{customscode,jdbcType=VARCHAR} |
61 | </if> | 61 | </if> |
62 | - <if test="username != null" > | 62 | + <if test="username != null and username != ''"> |
63 | and USERNAME = #{username,jdbcType=VARCHAR} | 63 | and USERNAME = #{username,jdbcType=VARCHAR} |
64 | </if> | 64 | </if> |
65 | - <if test="trafmode != null" > | 65 | + <if test="trafmode != null and trafmode != ''" > |
66 | and TrafMode = #{trafmode,jdbcType=VARCHAR} | 66 | and TrafMode = #{trafmode,jdbcType=VARCHAR} |
67 | </if> | 67 | </if> |
68 | - <if test="unloadcode != null" > | 68 | + <if test="unloadcode != null and unloadcode != ''" > |
69 | and UnloadCode = #{unloadcode,jdbcType=VARCHAR} | 69 | and UnloadCode = #{unloadcode,jdbcType=VARCHAR} |
70 | </if> | 70 | </if> |
71 | <if test="creattime != null" > | 71 | <if test="creattime != null" > |
1 | import com.tianbo.analysis.NmmsAdminApplication; | 1 | import com.tianbo.analysis.NmmsAdminApplication; |
2 | +import com.tianbo.analysis.config.CustomsProperties; | ||
2 | import com.tianbo.analysis.model.TRANSTOARRIVEEXPORT; | 3 | import com.tianbo.analysis.model.TRANSTOARRIVEEXPORT; |
3 | import com.tianbo.analysis.service.TransArriveExportService; | 4 | import com.tianbo.analysis.service.TransArriveExportService; |
4 | import lombok.extern.slf4j.Slf4j; | 5 | import lombok.extern.slf4j.Slf4j; |
@@ -12,19 +13,22 @@ import java.util.Date; | @@ -12,19 +13,22 @@ import java.util.Date; | ||
12 | public class TransAriiveTest { | 13 | public class TransAriiveTest { |
13 | 14 | ||
14 | @Autowired | 15 | @Autowired |
16 | + private CustomsProperties customsProperties; | ||
17 | + | ||
18 | + @Autowired | ||
15 | TransArriveExportService transArriveExportService; | 19 | TransArriveExportService transArriveExportService; |
16 | 20 | ||
17 | @org.junit.jupiter.api.Test | 21 | @org.junit.jupiter.api.Test |
18 | public void send(){ | 22 | public void send(){ |
19 | TRANSTOARRIVEEXPORT t = new TRANSTOARRIVEEXPORT(); | 23 | TRANSTOARRIVEEXPORT t = new TRANSTOARRIVEEXPORT(); |
20 | //海关信息及IC卡相关部分 | 24 | //海关信息及IC卡相关部分 |
21 | - t.setApplycode("4101888126"); | ||
22 | - t.setApplyname("河南航空货运发展有限公司"); | ||
23 | - t.setCopcode("70678920X"); | 25 | + t.setApplycode(customsProperties.getApplyCode()); |
26 | + t.setApplyname(customsProperties.getApplyName()); | ||
27 | + t.setCopcode(customsProperties.getCopCode()); | ||
24 | t.setCustomscode("4604"); | 28 | t.setCustomscode("4604"); |
25 | //操作员IC卡号 | 29 | //操作员IC卡号 |
26 | - t.setInputopid("8930000085548"); | ||
27 | - t.setInputopname("翟梦一"); | 30 | + t.setInputopid(customsProperties.getInputOpId()); |
31 | + t.setInputopname(customsProperties.getInputOpName()); | ||
28 | t.setCertno("21212321321321"); | 32 | t.setCertno("21212321321321"); |
29 | 33 | ||
30 | t.setSeqno(""); | 34 | t.setSeqno(""); |
-
请 注册 或 登录 后发表评论