فهرست منبع

【集团EDI-新思&歌尔】【新思】

DINGYL 2 ماه پیش
والد
کامیت
0f87fbc269

+ 1 - 0
src/main/java/com/uas/eis/config/SynaConfig.java

@@ -15,4 +15,5 @@ public class SynaConfig {
     private String url_867;
     private String bill_to_address;
     private String BTEDILocationCode;
+    private boolean isProd;
 }

+ 12 - 9
src/main/java/com/uas/eis/core/X12Converter.java

@@ -28,7 +28,7 @@ public class X12Converter {
         writer.setControlSchema(controlSchema);
         return  writer;
     }
-    private void startSegment(EDIStreamWriter writer,String ediId) throws EDIStreamException {
+    private void startSegment(EDIStreamWriter writer,String ediId,SynaConfig synaConfig) throws EDIStreamException {
         writer.writeStartSegment("ISA")
                 .writeElement("00")
                 .writeElement("          ")
@@ -39,14 +39,17 @@ public class X12Converter {
                 .writeElement("ZZ")
                 .writeElement("SYNAPTICST     ")
                 .writeElement(new SimpleDateFormat("yyMMdd").format(new Date())) // GS04 (日期)
-                .writeElement(new SimpleDateFormat("HHmm").format(new Date()))     // GS05 (时间)
+                .writeElement(new SimpleDateFormat("HHmm").format(new Date()))   // GS05 (时间)
                 .writeElement("U")
                 .writeElement(X12_VERSION)
                 .writeElement(ediId)
-                .writeElement("0")
-                .writeElement("T")//T,表示测试数据;P,表示生产数据,这里是T
-                .writeElement("^")
-                .writeEndSegment();
+                .writeElement("0");
+        if(synaConfig.isProd()){
+            writer .writeElement("P");//T,表示测试数据;P,表示生产数据,这里是T
+        }else{
+            writer .writeElement("T");//T,表示测试数据;P,表示生产数据,这里是T
+        }
+        writer.writeElement("^").writeEndSegment();
     }
     private void addGS(EDIStreamWriter writer,String type,String id,String rule) throws EDIStreamException {
         writer.writeStartSegment("GS").writeElement(type)
@@ -65,7 +68,7 @@ public class X12Converter {
         //开始
         writer.startInterchange();
 
-        startSegment(writer,ediId);
+        startSegment(writer,ediId,synaConfig);
         //PO
         addGS(writer,"PO",String.valueOf(po.getPu_id()),"T");
 
@@ -160,7 +163,7 @@ public class X12Converter {
         EDIStreamWriter writer = newEDIWriter(stream);
 
         writer.startInterchange();
-        startSegment(writer,ediId);
+        startSegment(writer,ediId,synaConfig);
         addGS(writer,"PC",String.valueOf(pc.getPc_id()),"X");
 
         int txCount = 1;
@@ -258,7 +261,7 @@ public class X12Converter {
         EDIStreamWriter writer = newEDIWriter(stream);
         writer.startInterchange();
         //开始
-        startSegment(writer,ediId);
+        startSegment(writer,ediId,synaConfig);
         addGS(writer,"PT",String.valueOf(pos.getPs_id()),"X");
 
         int txCount = 1;

+ 2 - 1
src/main/resources/application-dev.yml

@@ -35,4 +35,5 @@ synaptics:
     url_860 : https://syn-oic-poc-axpwqir9ej7o-px.integration.us-phoenix-1.ocp.oraclecloud.com/ic/api/integration/v1/flows/rest/WORLDSHINE860EJ364H_REST_RECEIVE/1.0
     url_867 : https://syn-oic-poc-axpwqir9ej7o-px.integration.us-phoenix-1.ocp.oraclecloud.com/ic/api/integration/v1/flows/rest/WORLDSHINE867JOA3HJ_REST_RECEIVE/1.0
     bill_to_address : ROOM 2708, 27/F, APEC PLAZA, 49 HOI YUEN ROAD KWUN TONG, KOWLOON
-    BTEDILocationCode : WTECH-3925
+    BTEDILocationCode : WTECH-3925
+    isProd: false

+ 2 - 1
src/main/resources/application-prod.yml

@@ -36,4 +36,5 @@ synaptics:
     url_860 : https://syn-oic-poc-axpwqir9ej7o-px.integration.us-phoenix-1.ocp.oraclecloud.com/ic/api/integration/v1/flows/rest/WORLDSHINE860EJ364H_REST_RECEIVE/1.0
     url_867 : https://syn-oic-poc-axpwqir9ej7o-px.integration.us-phoenix-1.ocp.oraclecloud.com/ic/api/integration/v1/flows/rest/WORLDSHINE867JOA3HJ_REST_RECEIVE/1.0
     bill_to_address : ROOM 2708, 27/F, APEC PLAZA, 49 HOI YUEN ROAD KWUN TONG, KOWLOON
-    BTEDILocationCode : WTECH-3925
+    BTEDILocationCode : WTECH-3925
+    isProd: true