PageRenderTime 85ms CodeModel.GetById 18ms app.highlight 61ms RepoModel.GetById 1ms app.codeStats 0ms

/webccr/src/com/emis/caesar/senao/event/button/TBtnINSU.java

https://bitbucket.org/sanliou/synccr
Java | 585 lines | 457 code | 36 blank | 92 comment | 77 complexity | 388009d1cdeba41b3a8cc455930e80ad MD5 | raw file
  1package com.emis.caesar.senao.event.button;
  2
  3import com.emis.caesar.senao.data.TEntryEdit;
  4import com.emis.caesar.senao.data.TEntryEdits;
  5import com.emis.caesar.senao.event.TForceAssignSalesEventContext;
  6import com.emis.caesar.senao.unit.TCcrConst;
  7import com.emis.caesar.senao.unit.TInsuData;
  8import com.emis.caesar.senao.unit.sale.TExItem;
  9import com.emis.caesar.senao.unit.sale.TProduct;
 10import com.emis.caesar.senao.unit.sale.TSaleItem;
 11import com.emis.caesar.senao.util.CcrUtil;
 12import com.emis.caesar.senao.util.GenUtil;
 13import com.emis.caesar.senao.webAPI.HTTPUtil;
 14import com.emis.caesar.senao.webAPI.WebApiUtil;
 15import com.emis.db.emisSQLCache;
 16import com.emis.util.emisUtil;
 17import com.emis.util.emisXmlUtil;
 18import org.w3c.dom.Document;
 19import org.w3c.dom.Element;
 20import org.w3c.dom.Node;
 21import org.w3c.dom.NodeList;
 22
 23import java.io.ByteArrayInputStream;
 24
 25//ERP CHECK USE ADD BY DAFF 20181224
 26import org.apache.http.NameValuePair;
 27import org.apache.http.message.BasicNameValuePair;
 28import java.util.List;
 29import java.util.ArrayList;
 30import com.emis.caesar.senao.Json.CheckImeiHead;
 31/**
 32 * 手機保險(年繳) 不可能客訂
 33 * 哪些交易流程狀態下可執行: 等待交易,正在交易
 34 * 流程說明:
 35 * 1.先輸入IMEI碼
 36 * 2.取得保費資訊函數 GET_INSU_PRICE
 37 */
 38public class TBtnINSU extends TForceAssignSalesEventContext {
 39    private String sType = "";  // INSU / INSU_OL add by daff 20180615
 40    private String sfrom = "";  // INSU / INSU_OL add by daff 20180615
 41    private TEntryEdits FoEntryIMEI = null; // 輸入IMEI
 42    private String IMEI = "";
 43    private String PNO = ""; // 保險料號
 44    private int LIST_PRICE = 0; // 建議售價
 45    private String CHT_MM_NO = ""; // 組合包
 46    private String PAYMENT = ""; // 繳費型態
 47    private int POEXP = 0; // 專案成本(保費)
 48    private int DEDUCTIBLE = 0; // 自負額
 49    private String OD_END_DATE = ""; // 終止日期
 50    private String PRODUCTTYPE = ""; // 產品代號
 51    private String PERIODS = ""; // 期數(月數)
 52    private int COMPEN_1 = 0; // 最高賠償次數
 53    private int DEDUCTIBLE_ORG = 0; // 自負額原機維修
 54    private String PONO = ""; // 保單號碼
 55    private TInsuData InsuData = null;
 56    //CCR IMEI GET CHANGE TO DB FUNCTION  ADD BY DAFF 20180629
 57    private String sP_BRAND= ""; //廠牌
 58    private String sP_NAME= ""; //品名
 59    private String sP_VPN= ""; //機型
 60    private String sP_NO= ""; //料號
 61    private int sP_PRICE = 0; //建議售價
 62
 63    //Erp imei check add by daff 20181224
 64    private String SALEDATE = ""; // 線上銷售日期
 65    private String AGNTNO = ""; // 通路別代碼
 66    private String ITEMNO = ""; // 料號
 67
 68    //ADD BY DAFF 新鈦金月繳版修正
 69    boolean stepGetInsp = true;
 70    private String sS_NO= "";
 71    private String sPERIODS= "";
 72    private String sREPORT_FILENAME= "";
 73    public TBtnINSU() {
 74        super();
 75        // 該事件執行成功后的下一個流程
 76        // FiNextState = TCcrConst.CPS_LOCK_PAY;
 77    }
 78
 79    // 神腦線上購機O2O/臨櫃CCR 區分 add by daff 20180615
 80    //ADD BY DAFF 新鈦金月繳版修正 20190322
 81    public TBtnINSU(String sType_) {
 82        super();
 83        FiNextState = TCcrConst.CPS_LOCK_PAY;
 84        sType = sType_;
 85        if ("INSU".equals(sType)){
 86            sfrom = TCcrConst.INSU;
 87            PAYMENT = TCcrConst.PAYMENT_O ;
 88        }
 89        else if("INSU_OL".equals(sType)){
 90            sfrom = TCcrConst.INSU_OL;
 91            PAYMENT = TCcrConst.PAYMENT_O ;
 92        } else if("INSU_M".equals(sType)){
 93            sfrom = TCcrConst.INSU;
 94            PAYMENT = TCcrConst.PAYMENT_M ;
 95        } else if("INSU_OL_M".equals(sType)){
 96            sfrom = TCcrConst.INSU_OL;
 97            PAYMENT = TCcrConst.PAYMENT_M ;
 98        }else{
 99            sfrom = TCcrConst.INSU;
100            PAYMENT = TCcrConst.PAYMENT_O ;
101        }
102        //CcrUtil.setMessage("SOURCE_FROM:" + TCcrConst.s_from);
103    }
104
105    /**
106     * 檢核在哪些交易流程狀態下可執行
107     */
108    protected boolean inCcrSate() {
109        int aRunSate[] = { TCcrConst.CPS_WAIT_SALE, TCcrConst.CPS_SALE};
110        return GenUtil.isIntKeyInArray(aRunSate, FoCcr.getCurrnetState());
111    }
112
113    /**
114     * 彈出窗體裡面的按鈕事件
115     */
116    public boolean runEventMethod(String sMethod_) {
117        if (sMethod_.equals("entryIMEIok")) {
118            return entryIMEIok();
119        } else if (sMethod_.equals("entryIMEIcancel")) {
120            return Cancel();
121        } else if (sMethod_.equals("clickOK")) {
122            return execute();
123        } else {
124            return super.runEventMethod(sMethod_);
125        }
126    }
127
128    /**
129     * 取消
130     * @return boolean
131     */
132    protected boolean Cancel() {
133        FsErrMsg = TCcrConst.MSG_HIDE;
134        return eventOver(false);
135    }
136
137    protected boolean entryIMEIok() {
138        CcrUtil.setMessage("IMEI輸入:" + FoEntryIMEI.getEdit(0).getText());
139        String msg = "";
140        if (!emisUtil.isEmpty(FoEntryIMEI.getEdit(0).getText())) {
141            IMEI = FoEntryIMEI.getEdit(0).getText().toUpperCase();   //add by Ares 20200602 IMEI轉成大寫
142            sS_NO =FoCcr.getStore().getFLDxS_NO(); //ADD BY DAFF 新鈦金月繳版修正 20190322
143            //ADD BY DAFF 新鈦金月繳版修正 20190322 start
144            //剛剛已經開過分期視窗了 第二次我就不給他開了
145            if(stepGetInsp){
146                if(sfrom.equals("O2O")){
147                    String API_ERP_RESULT = doCallErpChkimei(IMEI, "POS");
148                    if (!emisUtil.isEmpty(API_ERP_RESULT)) {
149                        FsErrMsg = API_ERP_RESULT;
150                        CcrUtil.setMessage("FsErrMsg:" + FsErrMsg);
151                        return eventOver(false);
152                    }
153                }
154                stepGetInsp = false;
155                return WinInsuInspNo();
156            }
157            sPERIODS = getInsuData().getPERIODS();
158            //add by daff 20181224 erpimeicheck START
159            if (sfrom.equals("O2O")) {
160                //ADD BY DAFF  INSUINSP
161                msg = FoCcr.getDbData.GET_INSU_ERPIMEI_PRICE(ITEMNO,SALEDATE,AGNTNO,PAYMENT,sS_NO,sPERIODS);
162            }else {
163                //ADD BY DAFF  INSUINSP
164                msg = FoCcr.getDbData.GET_INSU_PRICE(IMEI,sfrom,PAYMENT,sS_NO,sPERIODS);
165            }
166            //ADD BY DAFF 新鈦金月繳版修正 20190322 end
167            //add by daff 20181224 erpimeicheck END
168//      msg = "Y,4000,2880,S711,48xxxxxxxx,Y,SENMA6,1000,12,0,3";
169            if (!emisUtil.isEmpty(msg)) {
170                // Y(成功),建議售價,保費,組合包,保險料號,繳費型態,產品代號,自負額,保險期數(月),自負額原機維修,最高賠償次數
171                // N(失敗),組合包,失敗原因 (N,S711,取得核保價格異常)
172                String [] result = msg.split(",");
173                if (result != null && "Y".equals(result[0])) {
174                    String API_RESULT = doCallInsu(result);
175//          API_RESULT = "";
176                    if (!emisUtil.isEmpty(API_RESULT)) {
177                        FsErrMsg = API_RESULT;
178                        return eventOver(false);
179                    }
180                    //
181                    PNO = result[4];
182                    LIST_PRICE = emisUtil.parseInt(result[1]);
183                    CHT_MM_NO = result[3];
184                    PAYMENT = result[5];
185                    POEXP = emisUtil.parseInt(result[2]);
186                    DEDUCTIBLE = emisUtil.parseInt(result[7]);
187                    OD_END_DATE = emisUtil.getAfterDay(emisUtil.parseInt(result[8]));
188                    PRODUCTTYPE = result[6];
189                    PERIODS = result[8];
190                    COMPEN_1 = emisUtil.parseInt(result[10]);
191                    DEDUCTIBLE_ORG = emisUtil.parseInt(result[9]);
192
193                    //CCR IMEI GET CHANGE TO DB FUNCTION  ADD BY DAFF 20180629
194                    // ,廠牌,品名,機型,料號,建議售價
195                    sP_BRAND= result[11];
196                    sP_NAME= result[12];
197                    sP_VPN= result[13];
198                    sP_NO= result[14];
199                    sP_PRICE= emisUtil.parseInt(result[15]);
200                    //ADD BY DAFF 新鈦金月繳版修正 20190322
201                    sREPORT_FILENAME = result[16];
202
203                } else {
204                    if (result.length == 3) {
205                        FsErrMsg = result[2] + "(" + result[1] + ")";
206                    } else {
207                        FsErrMsg = result[1];
208                    }
209                    return eventOver(false);
210                }
211            } else {
212                FsErrMsg = "無法取得GET_INSU_PRICE函數";
213                return eventOver(false);
214            }
215        } else {
216            FsErrMsg = "IMEI不能為空";
217            return eventOver(false);
218        }
219        return openWinInfoData();
220    }
221    // 開啟保險分期畫面
222    //ADD BY DAFF 新鈦金月繳版修正 20190322
223    protected boolean WinInsuInspNo() {
224        FoCcr.UInotify.swInsuInsp(this, "entryIMEIok", "entryIMEIcancel",IMEI,sfrom,PAYMENT,sS_NO,ITEMNO,SALEDATE,AGNTNO);
225        return eventOver(true);
226    }
227    // 開啟基本資料畫面
228    protected boolean openWinInfoData() {
229        FoCcr.UInotify.swInsuInfo(this, "clickOK", "entryIMEIcancel");
230        return eventOver(true);
231    }
232
233    // 檢核資訊
234    protected boolean verifyPrecondition() {
235        // 呼叫API要有SL_KEY
236        if (!forceAssignSales()) {
237            return eventOver(false);
238        }
239
240        // 檢查是否有輸入業務員
241        if (FoCcr.getUser() == null) {
242            FsErrMsg = "請輸入業務員";
243            return eventOver(false);
244        } else {
245            if ("".equals(FoCcr.getUser().getFLDxST_KEY())) {
246                FsErrMsg = "請輸入業務員";
247                return eventOver(false);
248            }
249        }
250
251        // 小計會有問題要先換狀態
252        FoCcr.setCurrnetState(TCcrConst.CPS_SALE);
253        NotifyMainFormUpdate();
254
255        return entryData();
256    }
257
258    // 輸入資料
259    protected boolean entryData() {
260        // 彈出視窗輸入IMEI(主要是掃條碼自帶enter鍵, 不適合於輸入框直接刷入)
261        FoEntryIMEI = new TEntryEdits("輸入");
262        FoEntryIMEI.addEdit(new TEntryEdit("IMEI", true, true));
263        FoCcr.UInotify.swEntryEdits(FoEntryIMEI, this, "entryIMEIok", "entryIMEIcancel");
264        return handover();
265    }
266
267    // 執行交易品項新增&結束
268    public boolean execute() {
269        String result = addSaleItem();
270        if (!emisUtil.isEmpty(result)) {
271            FsErrMsg = result;
272            return eventOver(false);
273        }
274        //
275        CcrUtil.setMessage("Enter payment and lock pay");
276        // 幫做小計
277        FoSale.setInsuSfrom(sfrom);//神腦保險年繳代收保費 增加付款方式UI ADD BY DAFF 20190110
278        FoCcr.BTNnotify.runBtnEvent(TCcrConst.BTN_SUBTOTAL);
279        //
280        if (FoSale !=null && FoSale.getUnpaidAmout() != 0) {
281          FiNextState = TCcrConst.CPS_LOCK_PAY;
282          setNextCcrState();
283      }
284        return eventOver(true);
285		// 原因網頁程式彈窗也不會停止後續的程式碼
286		//return finalProcedure();
287		
288    }
289
290    // 新增交易項
291    public String addSaleItem() {
292        // 商品項  
293//    PONO = "CHTAAC000000001";
294        //神腦保險年繳代收保費 增加付款方式UI ADD BY DAFF 20190110START
295        FoSale.setInsuSPoexp(POEXP);
296        FoSale.setCHT_MM_TYPE(PRODUCTTYPE);
297        FoSale.setPONO_B(PONO);
298        //神腦保險年繳代收保費 增加付款方式UI ADD BY DAFF 20190110 END
299        FoSale.setREPORT_FILENAME(sREPORT_FILENAME);//ADD BY DAFF 新鈦金月繳版修正 20190322
300        String result =  "";
301        TProduct product = new TProduct();
302        boolean isOK = FoCcr.getDbData.getProduct(
303                FoCcr.getStore().getFLDxS_NO(), PNO, product);
304        if (!isOK) {
305            result = "查無保險料號(" + PNO + ")";
306            return result;
307        }
308        // 檢核5本交易是否該屬性一致
309        String msg5 = CcrUtil.isSalable5(FoSale, product);
310        if (!emisUtil.isEmpty(msg5)) {
311            return msg5;
312        }
313        // 檢核6是否能混合商品 
314        String msg6 = CcrUtil.isSalable6(FoSale, product);
315        if (!emisUtil.isEmpty(msg6)) {
316            return msg6;
317        }
318
319        TSaleItem saleItem = new TSaleItem(product);
320        saleItem.setQty(1);
321        saleItem.setActCode(TSaleItem.NORMAL_PLU);
322        saleItem.setFsBusType(product.getFLDxBUS_TYPE());
323        saleItem.setPONO(PONO);
324        saleItem.setCHT_MM_TYPE(PRODUCTTYPE);
325        saleItem.setPOEXP(POEXP);
326        // 將資料填入TInsuData
327        InsuData.setCHT_MM_NO(CHT_MM_NO);
328        InsuData.setPONO(PONO);
329        InsuData.setCHA_IMEI(IMEI);
330        InsuData.setPAYMENT(PAYMENT);
331        TProduct product_imei = new TProduct();
332
333        boolean isOK2 = FoCcr.getDbData.getProductFromIMEI(
334                FoCcr.getStore().getFLDxS_NO(), IMEI, product_imei, false);
335
336        //CCR IMEI GET CHANGE TO DB FUNCTION  ADD BY DAFF 20180629  START
337		/*
338		if (!isOK2) {
339		  result = "查無IMEI料號(" + IMEI + ")";
340		  return result;
341		}
342		InsuData.setSUPNO(product_imei.getFLDxP_BRAND());
343		InsuData.setMARADESC(product_imei.getFLDxP_NAME());
344		InsuData.setMODEL(product_imei.getFLDxP_VPN());
345		InsuData.setMOBILE_P_NO(product_imei.getFLDxP_NO());
346		InsuData.setLIST_PRICE((int) product_imei.getPrice());
347		*/
348        InsuData.setSUPNO(sP_BRAND);
349        InsuData.setMARADESC(sP_NAME);
350        InsuData.setMODEL(sP_VPN);
351        InsuData.setMOBILE_P_NO(sP_NO);
352        InsuData.setLIST_PRICE((int) sP_PRICE);
353        //CCR IMEI GET CHANGE TO DB FUNCTION  ADD BY DAFF 20180629   END
354
355        InsuData.setPOEXP(POEXP);
356        InsuData.setDEDUCTIBLE(DEDUCTIBLE);
357        InsuData.setOD_END_DATE(OD_END_DATE);
358        InsuData.setPRODUCTTYPE(PRODUCTTYPE);
359        InsuData.setPERIODS(PERIODS);
360        InsuData.setCOMPEN_1(COMPEN_1);
361        InsuData.setDEDUCTIBLE_ORG(DEDUCTIBLE_ORG);
362        InsuData.setSFROM(sfrom);// 超級新鈦金 年繳版區分 神腦線上/臨櫃辦理 兩種專案 add by daff 20180615
363        saleItem.setoInsuData(InsuData);
364        // IMEI
365        TExItem tExItem = new TExItem();
366        tExItem.setSn(1);
367        tExItem.setNo(IMEI);
368        tExItem.setSL_MOB_NO(PONO); //存入保單號
369        saleItem.addExItem(tExItem);
370        //
371        FoSale.addSaleItem(saleItem);
372        return result;
373    }
374
375    // 通知主畫面變更內容顯示
376    protected void NotifyMainFormUpdate() {
377        FoCcr.UInotify.updateMainForm();
378    }
379
380    // 即時核保 API
381    private String doCallInsu(String [] data) {
382        CcrUtil.setMessage("=====Call 即時核保 API=====");
383        String result = "";
384        String url = "";
385        String API_NO = emisSQLCache.SYS_PARAMS_INSU;
386        String HeaderType = "XML";
387        String SL_KEY = FoCcr.getCurrentSale().getPrimarykey();
388        String API_CALL_TIME = emisUtil.todayDateFormatAll("/");
389        //
390        url = WebApiUtil.getWEBAPI_URL(API_NO);
391        if (emisUtil.isEmpty(url)) {
392            result = "WEBAPI異常, 請確認系統設定資料!";
393            return result;
394        }
395        //
396        try {
397            String xml = generateInvokeXml(data);
398            CcrUtil.setMessage("INSU_DATA=" + xml);
399            //
400            String response = HTTPUtil.sendPost(API_NO, url, xml, SL_KEY, API_CALL_TIME, HeaderType);
401            CcrUtil.setMessage("response:" + response);
402            if (emisUtil.isEmpty(response)) {
403                result = "網頁連線有問題!!";
404                FoCcr.wrDataToDb.UpdAPI_LOG_HS(API_NO, API_CALL_TIME, false);
405                return result;
406            }
407            //
408            String response2 = AnalyzeResponse(response);
409            if (!emisUtil.isEmpty(response2)) {
410                result = response2;
411                return result;
412            }
413        } catch (Exception e) {
414            result = "ERROR:" + e.getMessage();
415            CcrUtil.setMessage(emisUtil.getStackTrace(e));
416        }
417        return result;
418    }
419
420    // 生成 即時核保 input XML
421    private String generateInvokeXml(String [] data) {
422        StringBuffer sb = new StringBuffer();
423
424        sb.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
425        sb.append("<INSU_DATA>\n");
426        //CcrUtil.createNode(sb, "SOURCE_FROM", "CCR");  // 系統串接來源(固定值 : CCR )
427        CcrUtil.createNode(sb, "SOURCE_FROM", sfrom);  // 系統串接來源 改按鈕傳遞 add by daff 20180615
428        CcrUtil.createNode(sb, "IMEI", IMEI);          // IMEI
429        CcrUtil.createNode(sb, "PAYMENT", data[5]);    // 繳費型態
430        CcrUtil.createNode(sb, "LIST_PRICE", data[1]); // 建議售價
431        CcrUtil.createNode(sb, "POEXP", data[2]);      // 保費
432        CcrUtil.createNode(sb, "WAPPACK", data[3]);    // 組合包
433        sb.append("</INSU_DATA>");
434
435        return sb.toString();
436    }
437
438    // 解析即時核保回傳值
439    private String AnalyzeResponse(String resp) {
440        String result = "";
441        ByteArrayInputStream bis = null;
442        boolean isOK = false;
443        String msg = "";
444        try {
445            bis = new ByteArrayInputStream(resp.getBytes(CcrUtil.CHARSET));
446            Document doc = emisXmlUtil.getXML(bis);
447            NodeList Nodelist = doc.getElementsByTagName("SERVICE_ACK");
448            for (int i = 0; i < Nodelist.getLength(); i++) {
449                Node node = Nodelist.item(i);
450                Node child = node.getFirstChild();
451                while (child != null) {
452                    if (child.getNodeType() == node.ELEMENT_NODE) {
453                        Element element = (Element) child;
454                        if (child.getNodeName().equals(element.getTagName())) {
455                            if (child.getFirstChild() != null) {
456                                if ("OPERATIONRESULT".equals(child.getNodeName())) {
457                                    if ("S".equals(element.getFirstChild().getNodeValue())) {
458                                        isOK = true;
459                                    }
460                                } else if ("DETAILDESCRIPTION".equals(child.getNodeName())) {
461                                    msg = element.getFirstChild().getNodeValue();
462                                } else if ("PONO".equals(child.getNodeName())) {
463                                    PONO = element.getFirstChild().getNodeValue();
464                                }
465                            }
466                        }
467                    }
468                    child= child.getNextSibling();
469                }
470            }
471            //
472            if (!isOK) {
473                result = "ERROR:" + msg;
474                PONO = "";
475            }
476        } catch (Exception e) {
477            result = "ERROR:" + e.getMessage();
478            CcrUtil.setMessage(emisUtil.getStackTrace(e));
479        } finally {
480            try {
481                if(bis != null) bis.close();
482            } catch (Exception e) {
483            }
484        }
485        return result;
486    }
487
488    public TInsuData getInsuData() {
489        return InsuData;
490    }
491
492    public void setInsuData(TInsuData insuData) {
493        InsuData = insuData;
494    }
495
496    // 解析ERPIMEICHECK回傳值 add by daff 20181224
497    private String ErpCheckImeiResponse(String resp) {
498        String result = "";
499        ByteArrayInputStream bis = null;
500        boolean isOK = false;
501        try {
502            bis = new ByteArrayInputStream(resp.getBytes(CcrUtil.CHARSET));
503            Document doc = emisXmlUtil.getXML(bis);
504            NodeList Nodelist = doc.getElementsByTagName("PDSNINFO");
505            for (int i = 0; i < Nodelist.getLength(); i++) {
506                Node node = Nodelist.item(i);
507                Node child = node.getFirstChild();
508                while (child != null) {
509                    if (child.getNodeType() == node.ELEMENT_NODE) {
510                        Element element = (Element) child;
511                        if (child.getNodeName().equals(element.getTagName())) {
512                            if (child.getFirstChild() != null) {
513                                if ("SALEDATE".equals(child.getNodeName())) {
514                                    SALEDATE = element.getFirstChild().getNodeValue();
515                                    CcrUtil.setMessage("SALEDATE:"+SALEDATE);
516                                }
517                                if ("AGNTNO".equals(child.getNodeName())) {
518                                    AGNTNO = element.getFirstChild().getNodeValue();
519                                    CcrUtil.setMessage("AGNTNO:"+AGNTNO);
520                                }
521                                if ("ITEMNO".equals(child.getNodeName())) {
522                                    ITEMNO = element.getFirstChild().getNodeValue();
523                                    CcrUtil.setMessage("ITEMNO:"+ITEMNO);
524                                }
525                            }
526                        }
527                    }
528                    child= child.getNextSibling();
529                }
530            }
531        } catch (Exception e) {
532            result = "ERROR:" + e.getMessage();
533            CcrUtil.setMessage(emisUtil.getStackTrace(e));
534        } finally {
535            try {
536                if(bis != null) bis.close();
537            } catch (Exception e) {
538            }
539        }
540        return result;
541    }
542    // ERPIMEICHECK API ADD BY DAFF 20181224
543    private String doCallErpChkimei(String SERIAL_NO , String SOURCE_FROM ) {
544        CcrUtil.setMessage("=====Call ERPIMEICHECK API=====");
545        String result = "";
546        String url = "";
547        String API_NO = emisSQLCache.SYS_PARAMS_INSU_O2O_CHKIMEI;
548        String HeaderType = "XML";
549        String SL_KEY = FoCcr.getCurrentSale().getPrimarykey();
550        String API_CALL_TIME = emisUtil.todayDateFormatAll("/");
551
552        url = WebApiUtil.getWEBAPI_URL(API_NO);
553        if (emisUtil.isEmpty(url)) {
554            result = "WEBAPI異常, 請確認系統設定資料!";
555            return result;
556        }
557
558        CheckImeiHead requestHead = new CheckImeiHead();
559        requestHead.setSERIALNO(SERIAL_NO);
560        requestHead.setSOURCE_FROM(SOURCE_FROM);
561        List<NameValuePair> nvps = new ArrayList<NameValuePair>();
562        nvps.add(new BasicNameValuePair("SERIAL_NO", requestHead.getSERIALNO()));
563        nvps.add(new BasicNameValuePair("SOURCE_FROM", requestHead.getSOURCE_FROM()));
564
565        try {
566            String response = HTTPUtil.sendPost(API_NO, url,nvps, SL_KEY, API_CALL_TIME);
567            CcrUtil.setMessage("response:" + response);
568            if (emisUtil.isEmpty(response)) {
569                result = "網頁連線有問題!!";
570                FoCcr.wrDataToDb.UpdAPI_LOG_HS(API_NO, API_CALL_TIME, false);
571                return result;
572            }
573            //
574            String response2 = ErpCheckImeiResponse(response);
575            if (!emisUtil.isEmpty(response2)) {
576                result = response2;
577                return result;
578            }
579        } catch (Exception e) {
580            result = "ERROR:" + e.getMessage();
581            CcrUtil.setMessage(emisUtil.getStackTrace(e));
582        }
583        return result;
584    }
585}