Ver código fonte

【深爱-物流-订单创建于取消】

DINGYL 9 meses atrás
pai
commit
fab6328145

+ 5 - 1
src/main/java/com/uas/eis/controller/ERPController.java

@@ -49,5 +49,9 @@ public class ERPController {
     public Map<String, Object> creatOrder(String master,Integer id){
         return erpService.creatOrder(master,id);
     }
-
+    @RequestMapping(value="/erp/cancelOrder")
+    @ResponseBody
+    public Map<String, Object> cancelOrder(String master,Integer id){
+        return erpService.creatOrder(master,id);
+    }
 }

+ 48 - 0
src/main/java/com/uas/eis/entity/LogisticsPrice.java

@@ -0,0 +1,48 @@
+package com.uas.eis.entity;
+
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class LogisticsPrice {
+    private Long lp_Id;
+    private String lp_Code;
+    private Date lp_Indate;
+    private Date lp_Caldate;
+    private String lp_Type;
+    private String lp_Route;
+    private Double lp_Weight;
+    private Double lp_Volume;
+    private String lp_Recipient;
+    private String lp_Tel;
+    private String lp_Add;
+    private String lp_Status;
+    private String lp_StatusCode;
+    private String lp_Recorder;
+    private String lp_Company1;
+    private Double lp_ContractPrice1;
+    private Double lp_RealtimePrice1;
+    private String lp_Company2;
+    private Double lp_ContractPrice2;
+    private Double lp_RealtimePrice2;
+    private String lp_Company3;
+    private Double lp_ContractPrice3;
+    private Double lp_RealtimePrice3;
+    private String lp_TrackingNumber1;
+    private String lp_TrackingNumber2;
+    private String lp_TrackingNumber3;
+    private String lp_FinalCompany;
+    private Date lp_AuditDate;
+    private String lp_AuditMan;
+    private String lp_Province;
+    private String lp_District;
+    private Date lp_SendDateTime;
+    private String lp_Msg1;
+    private String lp_Msg2;
+    private String lp_Msg3;
+    private String lp_TrackingNumber;
+    private String lp_DockingCode;
+    private String lp_ReceiveCompany;
+    private String lp_dockingstatus;
+}

+ 15 - 0
src/main/java/com/uas/eis/entity/sf/FilterAddrInfoDto.java

@@ -0,0 +1,15 @@
+package com.uas.eis.entity.sf;
+
+import lombok.Data;
+
+@Data
+public class FilterAddrInfoDto {
+    private Integer contactType;
+    private String tel;
+    private String country;
+    private String province;
+    private String city;
+    private String county;
+    private String address;
+    private String postCode;
+}

+ 13 - 0
src/main/java/com/uas/eis/entity/sf/OrderFilter.java

@@ -0,0 +1,13 @@
+package com.uas.eis.entity.sf;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class OrderFilter {
+    private Integer filterType; // 筛单类别,对应 Number(1) 类型,Java 中用 Integer 表示
+    private String orderId; // 客户订单号
+    private String monthlyCard; // 月结卡号
+    private List<FilterAddrInfoDto> contactInfos; // 地址信息列表
+}

+ 3 - 0
src/main/java/com/uas/eis/service/ERPService.java

@@ -18,7 +18,10 @@ public interface ERPService {
     Map<String, Object> getLogisticsPrice(String master, Integer id);
 
     Map<String, Object> creatOrder(String master, Integer id);
+    Map<String, Object> cancelOrder(String master, Integer id);
+
     void getSFPrice(String master, Integer id);
     void getKYPrice(String master, Integer id);//用于测试
     void getDOPPrice(String master, Integer id);
+
 }

+ 363 - 37
src/main/java/com/uas/eis/service/Impl/ERPServiceImpl.java

@@ -10,6 +10,7 @@ import com.sf.csim.express.service.IServiceCodeStandard;
 import com.sf.csim.express.service.code.ExpressServiceCodeEnum;
 import com.uas.eis.core.config.SpObserver;
 import com.uas.eis.dao.*;
+import com.uas.eis.entity.LogisticsPrice;
 import com.uas.eis.entity.dop.DoPApiResp;
 import com.uas.eis.entity.dop.DoPPriceQueryReq;
 import com.uas.eis.entity.dop.DoPResponseParam;
@@ -23,6 +24,7 @@ import com.uas.eis.utils.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.stereotype.Service;
 
 import java.util.*;
@@ -41,7 +43,7 @@ public class ERPServiceImpl implements ERPService {
     public Map<String, Object> creatSFOrder(String master, Integer id,String emCode) {
         Map<String,Object> retMap = new HashMap<>();
         retMap.put("success",true);
-        logger.info("creatSFOrder-Begin:master {} id {}",master,id);
+        logger.info("creatSFOrder-Begin: id {}",master,id);
         SpObserver.putSp(master);
         SqlRowList outMsg = baseDao.queryForRowSet(" select pi_inoutno,pi_dockingstatus,pi_title,pi_address,pi_purposename,pi_expresscode,pi_dockingcode " +
                         " from prodinout where pi_id = ? ",id);
@@ -49,7 +51,7 @@ public class ERPServiceImpl implements ERPService {
             if(outMsg.getGeneralString("pi_dockingstatus").equals("已创建")){
                 retMap.put("success",false);
                 retMap.put("message","出货单已创建顺发订单.");
-                logger.info("creatSFOrder-F:master {} id {} err {}",master,id,retMap.get("message"));
+                logger.info("creatSFOrder-F: id {} err {}",master,id,retMap.get("message"));
                 return retMap;
             }
             Object[] obs = baseDao.getFieldsDataByCondition("JYX_ZS.DOCK_SF_CONFIG A "
@@ -57,19 +59,19 @@ public class ERPServiceImpl implements ERPService {
             if(!StringUtil.hasText(obs[0])){
                 retMap.put("success",false);
                 retMap.put("message","请联系管理员配置创建URL.");
-                logger.info("creatSFOrder-F:master {} id {} err {}",master,id,retMap.get("message"));
+                logger.info("creatSFOrder-F: id {} err {}",master,id,retMap.get("message"));
                 return retMap;
             }
             if(!StringUtil.hasText(obs[1])){
                 retMap.put("success",false);
                 retMap.put("message","请联系管理员配置丰桥平台顾客编码.");
-                logger.info("creatSFOrder-F:master {} id {} err {}",master,id,retMap.get("message"));
+                logger.info("creatSFOrder-F: id {} err {}",master,id,retMap.get("message"));
                 return retMap;
             }
             if(!StringUtil.hasText(obs[2])){
                 retMap.put("success",false);
                 retMap.put("message","请联系管理员配置丰桥平台校验码.");
-                logger.info("creatSFOrder-F:master {} id {} err {}",master,id,retMap.get("message"));
+                logger.info("creatSFOrder-F: id {} err {}",master,id,retMap.get("message"));
                 return retMap;
             }
             boolean prodFlag = (Integer.valueOf(obs[3].toString())!=0);
@@ -208,7 +210,7 @@ public class ERPServiceImpl implements ERPService {
                                 baseDao.execute("INSERT INTO MESSAGELOG(ML_ID, ML_DATE, ML_MAN, ML_CONTENT, ML_RESULT, ML_SEARCH, CODE) " +
                                         "values( MESSAGELOG_SEQ.nextval,SYSDATE,'"+emName+"','创建顺发订单','"+retMap.get("message")+"','ProdInOut!Sale|pi_id="+id+"','"+inoutNo+"')");
                                 retMap.put("success",false);
-                                logger.info("creatSFOrder-F:master {} id {} err {}",master,id,retMap.get("message"));
+                                logger.info("creatSFOrder-F: id {} err {}",master,id,retMap.get("message"));
                                 return retMap;
                             }
                         }else {
@@ -216,7 +218,7 @@ public class ERPServiceImpl implements ERPService {
                             baseDao.execute("INSERT INTO MESSAGELOG(ML_ID, ML_DATE, ML_MAN, ML_CONTENT, ML_RESULT, ML_SEARCH, CODE) " +
                                     "values( MESSAGELOG_SEQ.nextval,SYSDATE,'"+emName+"','创建顺发订单','"+retMap.get("message")+"','ProdInOut!Sale|pi_id="+id+"','"+inoutNo+"')");
                             retMap.put("success",false);
-                            logger.info("creatSFOrder-F:master {} id {} err {}",master,id,retMap.get("message"));
+                            logger.info("creatSFOrder-F: id {} err {}",master,id,retMap.get("message"));
                             return retMap;
                         }
                     }else {
@@ -225,7 +227,7 @@ public class ERPServiceImpl implements ERPService {
                         baseDao.execute("INSERT INTO MESSAGELOG(ML_ID, ML_DATE, ML_MAN, ML_CONTENT, ML_RESULT, ML_SEARCH, CODE) " +
                                 "values( MESSAGELOG_SEQ.nextval,SYSDATE,'"+emName+"','创建顺发订单','"+retMap.get("message")+"','ProdInOut!Sale|pi_id="+id+"','"+inoutNo+"')");
                         retMap.put("success",false);
-                        logger.info("creatSFOrder-F:master {} id {} err {}",master,id,retMap.get("message"));
+                        logger.info("creatSFOrder-F: id {} err {}",master,id,retMap.get("message"));
                         return retMap;
                     }
                 }
@@ -235,16 +237,16 @@ public class ERPServiceImpl implements ERPService {
                         "values( MESSAGELOG_SEQ.nextval,SYSDATE,'"+emName+"','创建顺发订单','创建失败:"+(StringUtil.nvl(e.getMessage(),""))+"','ProdInOut!Sale|pi_id="+id+"','"+inoutNo+"')");
                 retMap.put("success",false);
                 retMap.put("message","创建失败"+(StringUtil.nvl(e.getMessage(),"")));
-                logger.info("creatSFOrder-F:master {} id {} err {}",master,id,retMap.get("message"));
+                logger.info("creatSFOrder-F: id {} err {}",master,id,retMap.get("message"));
                 return retMap;
             }
         }else {
             retMap.put("success",false);
             retMap.put("message","没有需要创建的出货单.");
-            logger.info("creatSFOrder-F:master {} id {} err {}",master,id,retMap.get("message"));
+            logger.info("creatSFOrder-F: id {} err {}",master,id,retMap.get("message"));
             return retMap;
         }
-        logger.info("creatSFOrder-End:master {} id {}",master,id);
+        logger.info("creatSFOrder-End: id {}",master,id);
         retMap.put("message","创建成功。");
         return retMap;
     }
@@ -253,14 +255,14 @@ public class ERPServiceImpl implements ERPService {
     public Map<String, Object> cancelSFOrder(String master, Integer id, String emCode) {
         Map<String,Object> retMap = new HashMap<>();
         retMap.put("success",true);
-        logger.info("cancelSFOrder-Begin:master {} id {}",master,id);
+        logger.info("cancelSFOrder-Begin: id {}",master,id);
         SpObserver.putSp(master);
         SqlRowList outMsg = baseDao.queryForRowSet(" select pi_inoutno,pi_dockingstatus,pi_dockingcode from prodinout where pi_id = ? ",id);
         if(outMsg.next()) {
             if (!outMsg.getGeneralString("pi_dockingstatus").equals("已创建")) {
                 retMap.put("success", false);
                 retMap.put("message", "出货单尚未创建顺发订单.");
-                logger.info("cancelSFOrder-F:master {} id {} err {}", master, id, retMap.get("message"));
+                logger.info("cancelSFOrder-F: id {} err {}", master, id, retMap.get("message"));
                 return retMap;
             }
             Object[] obs = baseDao.getFieldsDataByCondition("JYX_ZS.DOCK_SF_CONFIG A "
@@ -268,19 +270,19 @@ public class ERPServiceImpl implements ERPService {
             if (!StringUtil.hasText(obs[0])) {
                 retMap.put("success", false);
                 retMap.put("message", "请联系管理员配置创建URL.");
-                logger.info("cancelSFOrder-F:master {} id {} err {}", master, id, retMap.get("message"));
+                logger.info("cancelSFOrder-F: id {} err {}", master, id, retMap.get("message"));
                 return retMap;
             }
             if (!StringUtil.hasText(obs[1])) {
                 retMap.put("success", false);
                 retMap.put("message", "请联系管理员配置丰桥平台顾客编码.");
-                logger.info("cancelSFOrder-F:master {} id {} err {}", master, id, retMap.get("message"));
+                logger.info("cancelSFOrder-F: id {} err {}", master, id, retMap.get("message"));
                 return retMap;
             }
             if (!StringUtil.hasText(obs[2])) {
                 retMap.put("success", false);
                 retMap.put("message", "请联系管理员配置丰桥平台校验码.");
-                logger.info("cancelSFOrder-F:master {} id {} err {}", master, id, retMap.get("message"));
+                logger.info("cancelSFOrder-F: id {} err {}", master, id, retMap.get("message"));
                 return retMap;
             }
             Object emName = baseDao.getFieldDataByCondition("employee" , "em_name", "em_code='"+emCode+"'");
@@ -348,7 +350,7 @@ public class ERPServiceImpl implements ERPService {
                                 baseDao.execute("INSERT INTO MESSAGELOG(ML_ID, ML_DATE, ML_MAN, ML_CONTENT, ML_RESULT, ML_SEARCH, CODE) " +
                                         "values( MESSAGELOG_SEQ.nextval,SYSDATE,'"+emName+"','取消顺发订单','"+retMap.get("message")+"','ProdInOut!Sale|pi_id="+id+"','"+inoutNo+"')");
                                 retMap.put("success",false);
-                                logger.info("creatSFOrder-F:master {} id {} err {}",master,id,retMap.get("message"));
+                                logger.info("creatSFOrder-F: id {} err {}",master,id,retMap.get("message"));
                                 return retMap;
                             }
                         }else {
@@ -356,7 +358,7 @@ public class ERPServiceImpl implements ERPService {
                                     "values( MESSAGELOG_SEQ.nextval,SYSDATE,'"+emName+"','取消顺发订单','取消失败:["+sfApiRespData.getErrorCode()+"]"+sfApiRespData.getErrorMsg()+"','ProdInOut!Sale|pi_id="+id+"','"+inoutNo+"')");
                             retMap.put("success",false);
                             retMap.put("message","取消失败:["+sfApiRespData.getErrorCode()+"]"+sfApiRespData.getErrorMsg());
-                            logger.info("creatSFOrder-F:master {} id {} err {}",master,id,retMap.get("message"));
+                            logger.info("creatSFOrder-F: id {} err {}",master,id,retMap.get("message"));
                             return retMap;
                         }
                     }else {
@@ -364,7 +366,7 @@ public class ERPServiceImpl implements ERPService {
                         baseDao.execute("INSERT INTO MESSAGELOG(ML_ID, ML_DATE, ML_MAN, ML_CONTENT, ML_RESULT, ML_SEARCH, CODE) " +
                                 "values( MESSAGELOG_SEQ.nextval,SYSDATE,'"+emName+"','创建顺发订单','"+retMap.get("message")+"','ProdInOut!Sale|pi_id="+id+"','"+inoutNo+"')");
                         retMap.put("success",false);
-                        logger.info("creatSFOrder-F:master {} id {} err {}",master,id,retMap.get("message"));
+                        logger.info("creatSFOrder-F: id {} err {}",master,id,retMap.get("message"));
                         return retMap;
                     }
                 }
@@ -374,16 +376,16 @@ public class ERPServiceImpl implements ERPService {
                 baseDao.execute("INSERT INTO MESSAGELOG(ML_ID, ML_DATE, ML_MAN, ML_CONTENT, ML_RESULT, ML_SEARCH, CODE) " +
                         "values( MESSAGELOG_SEQ.nextval,SYSDATE,'"+emName+"','取消顺发订单','"+retMap.get("message")+"','ProdInOut!Sale|pi_id="+id+"','"+inoutNo+"')");
                 retMap.put("success",false);
-                logger.info("creatSFOrder-F:master {} id {} err {}",master,id,retMap.get("message"));
+                logger.info("creatSFOrder-F: id {} err {}",master,id,retMap.get("message"));
                 return retMap;
             }
         }else {
             retMap.put("success",false);
             retMap.put("message","没有需要操作的出货单.");
-            logger.info("cancelSFOrder-F:master {} id {} err {}",master,id,retMap.get("message"));
+            logger.info("cancelSFOrder-F: id {} err {}",master,id,retMap.get("message"));
             return retMap;
         }
-        logger.info("cancelSFOrder-End:master {} id {}",master,id);
+        logger.info("cancelSFOrder-End: id {}",master,id);
         retMap.put("message","取消成功。");
         return retMap;
     }
@@ -423,27 +425,348 @@ public class ERPServiceImpl implements ERPService {
 
         return modelMap;
     }
-    private String creatOrder_SF(Integer id){
-        return "";
+    private Map<String, Object> creatOrder_SF(LogisticsPrice logisticsPrice){
+        Map<String, Object> retMap = new HashMap<String, Object>();
+        logger.info("creatSFOrder-Begin");
+        String emCode=logisticsPrice.getLp_Recorder();
+        Object[] obs = baseDao.getFieldsDataByCondition("SZSI_P.DOCK_LOGISTICS_CONFIG A "
+                , new String[]{"CALL_URL","CLIENT_CODE","CHECK_WORD","ENABLE_"}, "LOGISTICS_='SFTEST' and type_='CREATEORDER' AND A.ENABLE_ = 1");
+        if(!StringUtil.hasText(obs[0])){
+            retMap.put("success",false);
+            retMap.put("message","请联系管理员配置创建URL.");
+            logger.info("creatSFOrder-F:id {} err {}",logisticsPrice.getLp_Id(),retMap.get("message"));
+            return retMap;
+        }
+        if(!StringUtil.hasText(obs[1])){
+            retMap.put("success",false);
+            retMap.put("message","请联系管理员配置丰桥平台顾客编码.");
+            logger.info("creatSFOrder-F:id {} err {}",logisticsPrice.getLp_Id(),retMap.get("message"));
+            return retMap;
+        }
+        if(!StringUtil.hasText(obs[2])){
+            retMap.put("success",false);
+            retMap.put("message","请联系管理员配置丰桥平台校验码.");
+            logger.info("creatSFOrder-F:id {} err {}",logisticsPrice.getLp_Id(),retMap.get("message"));
+            return retMap;
+        }
+        boolean prodFlag = (Integer.valueOf(obs[3].toString())!=0);
+        Object emName = baseDao.getFieldDataByCondition("employee" , "em_name", "em_code='"+emCode+"'");
+        if(emName == null){
+            emName = "管理员("+emCode+")";
+        }
+        String inoutNo = logisticsPrice.getLp_Code();
+        String orderCode = logisticsPrice.getLp_DockingCode();
+        if(orderCode!=null && orderCode.length()>0){
+            orderCode=inoutNo+"-"+(Integer.valueOf(orderCode.split("-")[1])+1);
+        }else {
+            orderCode=inoutNo+"-1";
+        }
+        String CLIENT_CODE = obs[1].toString();  //此处替换为您在丰桥平台获取的顾客编码
+        String CALL_URL = obs[0].toString();
+        String CHECK_WORD = obs[2].toString();
+        String monthlyCard = "7551234567";//7550911545";//后续看是否区分市场部和其他部门 先用市场部门的   测试 7551234567
+        //寄件人
+        Object[] en = baseDao.getFieldsDataByCondition("enterprise" , new String[]{"EN_NAME","EN_DELIVERADDR"}, "1=1");
+        String sendCop = en[0].toString().trim();
+        String sendAddr = en[1].toString();
+        String sendMan = logisticsPrice.getLp_Recorder();
+        String sendMobile = baseDao.getFieldValue("employee","max(em_mobile)","em_name='"+ logisticsPrice.getLp_Recorder()+"'",String.class);
+
+        IServiceCodeStandard standardService = ExpressServiceCodeEnum.EXP_RECE_CREATE_ORDER; //下订单
+        CallExpressServiceTools tools=CallExpressServiceTools.getInstance();
+        Map<String, String> params = new HashMap<String, String>();
+        String timeStamp = String.valueOf(System.currentTimeMillis());
+        String msgData = "";
+        SFCreatOrderReq sfOrder = new SFCreatOrderReq();
+        sfOrder.setOrderId(orderCode);
+        sfOrder.setMonthlyCard(monthlyCard);
+        sfOrder.setTotalWeight(logisticsPrice.getLp_Weight());
+        int expressTypeId=0;
+        if("特快".equals(logisticsPrice.getLp_Type())){
+            expressTypeId=1;
+        }else if("普快".equals(logisticsPrice.getLp_Type())){
+            expressTypeId=2;
+        }else if("物流".equals(logisticsPrice.getLp_Type())){
+            expressTypeId=255;//卡航
+        }
+        sfOrder.setExpressTypeId(expressTypeId);
+        //sfOrder.setIsSignBack(1);//回签
+        //寄件方信息
+        List<SFContactInfo> contactInfoList = new ArrayList<>();
+        SFContactInfo sendInfo = new SFContactInfo();
+        sendInfo.setContactType(1);
+        sendInfo.setCompany(sendCop);
+        sendInfo.setContact(sendMan);
+        sendInfo.setMobile(sendMobile);
+        sendInfo.setAddress(sendAddr);
+        contactInfoList.add(sendInfo);
+        //到件方信息
+        SFContactInfo receiveInfo = new SFContactInfo();
+        receiveInfo.setContactType(2);
+        receiveInfo.setCompany(logisticsPrice.getLp_ReceiveCompany());
+        receiveInfo.setContact(logisticsPrice.getLp_Recipient());
+        receiveInfo.setMobile(logisticsPrice.getLp_Tel());
+        receiveInfo.setAddress(logisticsPrice.getLp_Add());
+        contactInfoList.add(receiveInfo);
+        sfOrder.setContactInfoList(contactInfoList);
+        List<SFCargoDetail> cargoDetails = new ArrayList<>();
+
+        sfOrder.setCargoDetails(cargoDetails);
+        msgData = FlexJsonUtil.toJsonDeep(sfOrder);
+        System.out.println("====请求msgData:" + msgData);
+        try {
+            params.put("partnerID", CLIENT_CODE);  // 顾客编码 ,对应丰桥上获取的clientCode
+            params.put("requestID", UUID.randomUUID().toString().replace("-", ""));
+            params.put("serviceCode",standardService.getCode());// 接口服务码
+            params.put("timestamp", timeStamp);
+            params.put("msgData", msgData);
+            params.put("msgDigest", tools.getMsgDigest(msgData,timeStamp,CHECK_WORD));
+            System.out.println("====调用实际请求:" + params);
+            String result = HttpClientUtil.post(CALL_URL, params);
+            SFApiResp sfApiResp = FlexJsonUtil.fromJson(result, SFApiResp.class);
+            System.out.println("result:"+result);
+            if(sfApiResp!=null){
+                if("A1000".equals(sfApiResp.getApiResultCode())){
+                    String apiResultData = sfApiResp.getApiResultData();
+                    SFCreatOrderResp sfApiRespData =  FlexJsonUtil.fromJson(apiResultData, SFCreatOrderResp.class);
+                    if(sfApiRespData.isSuccess()){
+                        SFCreateOrder sfOrderResp =  sfApiRespData.getMsgData();
+                        StringBuffer waybillNoList = new StringBuffer();
+                        StringBuffer waybillNoP = new StringBuffer();
+                        StringBuffer waybillSon = new StringBuffer();
+                        StringBuffer waybillBack = new StringBuffer();
+                        if(!CollectionUtil.isEmpty(sfOrderResp.getWaybillNoInfoList())){
+                            for (SFWaybillNoInfo sfWaybillNoInfoResp:sfOrderResp.getWaybillNoInfoList()){
+                                String waybillNo = sfWaybillNoInfoResp.getWaybillNo();
+                                if(sfWaybillNoInfoResp.getWaybillType() == 1||sfWaybillNoInfoResp.getWaybillType() == 2){//运单号类型1:母单 2 :子单 3 : 签回单
+                                    System.out.println("顺丰物流单号: ====="+sfWaybillNoInfoResp.getWaybillNo());
+                                    if(waybillNoList.length()>0){
+                                        waybillNoList.append(",");
+                                    }
+                                    waybillNoList.append(waybillNo);
+                                    if(sfWaybillNoInfoResp.getWaybillType() == 1) {
+                                        if (waybillNoP.length() > 0) {
+                                            waybillNoP.append(",");
+                                        }
+                                        waybillNoP.append(waybillNo);
+                                    }else{
+                                        if (waybillSon.length() > 0) {
+                                            waybillSon.append(",");
+                                        }
+                                        waybillSon.append(waybillNo);
+                                    }
+                                }else {
+                                    if(waybillBack.length()>0){
+                                        waybillBack.append(",");
+                                    }
+                                    waybillBack.append(waybillNo);
+                                }
+                            }
+                        }
+                        if(waybillNoList.length()>0){
+                            retMap.put("success",true);
+                            retMap.put("logisticscode",waybillNoList.toString());
+                            retMap.put("dockingcode",orderCode);
+                        } else {
+                            retMap.put("message","创建失败:["+sfApiRespData.getErrorCode()+"]"+sfApiRespData.getErrorMsg());
+                            retMap.put("success",false);
+                            logger.info("creatSFOrder-F:id {} err {}",logisticsPrice.getLp_Id(),retMap.get("message"));
+                            return retMap;
+                        }
+                    }else {
+                        retMap.put("message","创建失败:["+sfApiRespData.getErrorCode()+"]"+sfApiRespData.getErrorMsg());
+                        retMap.put("success",false);
+                        logger.info("creatSFOrder-F: id {} err {}",logisticsPrice.getLp_Id(),retMap.get("message"));
+                        return retMap;
+                    }
+                }else {
+//                        System.out.println("code:"+sfApiResp.getApiResultCode()+"===apiResponseID:"+sfApiResp.getApiResponseID()+"===apiErrorMsg:"+sfApiResp.getApiErrorMsg());
+                    retMap.put("message","创建失败:["+sfApiResp.getApiResultCode()+"]"+sfApiResp.getApiErrorMsg());
+                    retMap.put("success",false);
+                    logger.info("creatSFOrder-F:id {} err {}",logisticsPrice.getLp_Id(),retMap.get("message"));
+                    return retMap;
+                }
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            retMap.put("success",false);
+            retMap.put("message","创建失败"+(StringUtil.nvl(e.getMessage(),"")));
+            logger.info("creatSFOrder-F:id {} err {}",logisticsPrice.getLp_Id(),retMap.get("message"));
+            return retMap;
+        }
+        return retMap;
+    }
+    private Map<String, Object> cancelOrder_SF(LogisticsPrice logisticsPrice){
+        Map<String,Object> retMap = new HashMap<>();
+        retMap.put("success",true);
+        logger.info("cancelSFOrder-Begin: id {}",logisticsPrice.getLp_Id());
+        if(logisticsPrice!=null) {
+            String emCode=logisticsPrice.getLp_Recorder();
+            if (!"已创建".equals(logisticsPrice.getLp_dockingstatus())) {
+                retMap.put("success", false);
+                retMap.put("message", "尚未创建快递订单.");
+                logger.info("cancelSFOrder-F: id {} err {}", logisticsPrice.getLp_Id(), retMap.get("message"));
+                return retMap;
+            }
+            Object[] obs = baseDao.getFieldsDataByCondition("SZSI_P.DOCK_LOGISTICS_CONFIG A "
+                    , new String[]{"CALL_URL","CLIENT_CODE","CHECK_WORD","ENABLE_"}, "LOGISTICS_='SFTEST' and type_='CANCELORDER' AND A.ENABLE_ = 1");
+            if (!StringUtil.hasText(obs[0])) {
+                retMap.put("success", false);
+                retMap.put("message", "请联系管理员配置创建URL.");
+                logger.info("cancelSFOrder-F: id {} err {}",  logisticsPrice.getLp_Id(), retMap.get("message"));
+                return retMap;
+            }
+            if (!StringUtil.hasText(obs[1])) {
+                retMap.put("success", false);
+                retMap.put("message", "请联系管理员配置丰桥平台顾客编码.");
+                logger.info("cancelSFOrder-F: id {} err {}", logisticsPrice.getLp_Id(), retMap.get("message"));
+                return retMap;
+            }
+            if (!StringUtil.hasText(obs[2])) {
+                retMap.put("success", false);
+                retMap.put("message", "请联系管理员配置丰桥平台校验码.");
+                logger.info("cancelSFOrder-F: id {} err {}", logisticsPrice.getLp_Id(), retMap.get("message"));
+                return retMap;
+            }
+            Object emName = baseDao.getFieldDataByCondition("employee" , "em_name", "em_code='"+emCode+"'");
+            if(emName == null){
+                emName = "管理员("+emCode+")";
+            }
+            String inoutNo = logisticsPrice.getLp_Code();
+            String orderCode = logisticsPrice.getLp_DockingCode();
+            String CLIENT_CODE = obs[1].toString();  //丰桥平台获取的顾客编码
+            String CALL_URL = obs[0].toString(); //沙箱环境的地址 -PRO https://sfapi-sbox.sf-express.com/std/service 生产环境的地址 -PRO https://sfapi.sf-express.com/std/service
+            String CHECK_WORD = obs[2].toString(); //丰桥平台获取的校验码 生产环境 "GgO0UoyQ5FssNLItii3olo63bQ80ErAE" 沙箱环境 "rMBhSYRa9OtUPkfX5mow01NlxDWtI411"
+
+            IServiceCodeStandard standardService = ExpressServiceCodeEnum.EXP_RECE_UPDATE_ORDER;//订单取消
+            CallExpressServiceTools tools=CallExpressServiceTools.getInstance();
+            Map<String, String> params = new HashMap<String, String>();
+            String timeStamp = String.valueOf(System.currentTimeMillis());
+            String msgData = "";
+            Map<String,Object> msgDataMap = new HashMap<>();
+            msgDataMap.put("orderId",orderCode);
+            msgDataMap.put("dealType",2);
+            msgData = FlexJsonUtil.toJsonDeep(msgDataMap);
+            try {
+                params.put("partnerID", CLIENT_CODE);  // 顾客编码 ,对应丰桥上获取的clientCode
+                params.put("requestID", UUID.randomUUID().toString().replace("-", ""));
+                params.put("serviceCode",standardService.getCode());// 接口服务码
+                params.put("timestamp", timeStamp);
+                params.put("msgData", msgData);
+                params.put("msgDigest", tools.getMsgDigest(msgData,timeStamp,CHECK_WORD));
+ 	            System.out.println("====调用请求:" + params.get("msgData"));
+                String result = HttpClientUtil.post(CALL_URL, params);
+                System.out.println("===返回结果:" +result);
+                SFApiResp sfApiResp = FlexJsonUtil.fromJson(result, SFApiResp.class);
+                if(sfApiResp!=null){
+                    if("A1000".equals(sfApiResp.getApiResultCode())){
+                        String apiResultData = sfApiResp.getApiResultData();
+                        SFCancelOrderResp sfApiRespData =  FlexJsonUtil.fromJson(apiResultData, SFCancelOrderResp.class);
+                        if(sfApiRespData.isSuccess()){
+                            SFCancelOrder sfOrderResp =  sfApiRespData.getMsgData();
+                            StringBuffer waybillNo = new StringBuffer();
+                            if(!CollectionUtil.isEmpty(sfOrderResp.getWaybillNoInfoList())){
+                                for (SFWaybillNoInfo sfWaybillNoInfoResp:sfOrderResp.getWaybillNoInfoList()){
+                                    if(waybillNo.length()>0){
+                                        waybillNo.append(",");
+                                    }
+                                    waybillNo.append(sfWaybillNoInfoResp.getWaybillNo());
+                                }
+                            }
+                            if(sfOrderResp.getResStatus()==2){
+                                retMap.put("success",true);
+                                retMap.put("logisticscode",waybillNo.length()>0?waybillNo.toString():"");
+                            }else {
+                                if(sfOrderResp.getResStatus()==1){
+                                    retMap.put("message","取消失败:客户订单号与顺丰运单不匹配");
+                                }else {
+                                    retMap.put("message","取消失败:["+sfOrderResp.getResStatus()+"]");
+                                }
+                                retMap.put("success",false);
+                                logger.info("creatSFOrder-F: id {} err {}",logisticsPrice.getLp_Id(),retMap.get("message"));
+                                return retMap;
+                            }
+                        }else {
+                            retMap.put("success",false);
+                            retMap.put("message","取消失败:["+sfApiRespData.getErrorCode()+"]"+sfApiRespData.getErrorMsg());
+                            logger.info("creatSFOrder-F: id {} err {}",logisticsPrice.getLp_Id(),retMap.get("message"));
+                            return retMap;
+                        }
+                    }else {
+                        retMap.put("message","取消失败:["+sfApiResp.getApiResultCode()+"]"+sfApiResp.getApiErrorMsg());
+                        retMap.put("success",false);
+                        logger.info("creatSFOrder-F: id {} err {}",logisticsPrice.getLp_Id(),retMap.get("message"));
+                        return retMap;
+                    }
+                }
+            }catch (Exception e){
+                e.printStackTrace();
+                retMap.put("message","取消失败"+(StringUtil.nvl(e.getMessage(),"")));   retMap.put("success",false);
+                logger.info("creatSFOrder-F: id {} err {}",logisticsPrice.getLp_Id(),retMap.get("message"));
+                return retMap;
+            }
+        }else {
+            retMap.put("success",false);
+            retMap.put("message","没有需要操作的单据.");
+            logger.info("cancelSFOrder-F: id {} err {}",logisticsPrice.getLp_Id(),retMap.get("message"));
+            return retMap;
+        }
+        logger.info("cancelSFOrder-End: id {}",logisticsPrice.getLp_Id());
+        retMap.put("message","取消成功。");
+        return retMap;
+    }
+    private Map<String, Object> creatOrder_DoP(LogisticsPrice logisticsPrice){
+        Map<String, Object> modelMap = new HashMap<String, Object>();
+        logger.info("creatDOPOrder-Begin");
+        return modelMap;
     }
-    private String creatOrder_DoP(Integer id){
-        return "";
+    private Map<String, Object> cancelOrder_DoP(LogisticsPrice logisticsPrice){
+        Map<String, Object> modelMap = new HashMap<String, Object>();
+        logger.info("cancelDOPOrder-Begin");
+        return modelMap;
     }
-    private String creatOrder_KY(Integer id){
-        return "";
+    private Map<String, Object> creatOrder_KY(LogisticsPrice logisticsPrice){
+        Map<String, Object> modelMap = new HashMap<String, Object>();
+        logger.info("creatKYOrder-Begin");
+        return modelMap;
+    }
+    private Map<String, Object> cancelOrder_KY(LogisticsPrice logisticsPrice){
+        Map<String, Object> modelMap = new HashMap<String, Object>();
+        logger.info("cancelKYOrder-Begin");
+        return modelMap;
     }
     @Override
     public Map<String, Object> creatOrder(String master, Integer id) {
         SpObserver.putSp(master);
         Map<String, Object> modelMap = new HashMap<String, Object>();
-        SqlRowList rs = baseDao.queryForRowSet("select lp_finalcompany from LogisticsPrice where lp_id="+id);
-        if(rs.next()){
-            if("顺丰".equals(rs.getGeneralString("lp_finalcompany"))){
-                creatOrder_SF(id);
-            }else if("德邦".equals(rs.getGeneralString("lp_finalcompany"))){
-                creatOrder_DoP(id);
-            }else if("跨越".equals(rs.getGeneralString("lp_finalcompany"))){
-                creatOrder_KY(id);
+        LogisticsPrice logisticsPrice=baseDao.getJdbcTemplate().queryForObject("select * from LogisticsPrice where lp_id="+id, new BeanPropertyRowMapper<LogisticsPrice>(LogisticsPrice.class));
+        if(logisticsPrice != null){
+            if("顺丰".equals(logisticsPrice.getLp_FinalCompany())){
+                creatOrder_SF(logisticsPrice);
+            }else if("德邦".equals(logisticsPrice.getLp_FinalCompany())){
+                creatOrder_DoP(logisticsPrice);
+            }else if("跨越".equals(logisticsPrice.getLp_FinalCompany())){
+                creatOrder_KY(logisticsPrice);
+            }
+        }else{
+            modelMap.put("message", "单据不存在!");
+            modelMap.put("success", false);
+        }
+        return modelMap;
+    }
+
+    @Override
+    public Map<String, Object> cancelOrder(String master, Integer id) {
+        SpObserver.putSp(master);
+        Map<String, Object> modelMap = new HashMap<String, Object>();
+        LogisticsPrice logisticsPrice=baseDao.getJdbcTemplate().queryForObject("select * from LogisticsPrice where lp_id="+id, new BeanPropertyRowMapper<LogisticsPrice>(LogisticsPrice.class));
+        if(logisticsPrice != null){
+            if("顺丰".equals(logisticsPrice.getLp_FinalCompany())){
+                cancelOrder_SF(logisticsPrice);
+            }else if("德邦".equals(logisticsPrice.getLp_FinalCompany())){
+                cancelOrder_DoP(logisticsPrice);
+            }else if("跨越".equals(logisticsPrice.getLp_FinalCompany())){
+                cancelOrder_KY(logisticsPrice);
             }
         }else{
             modelMap.put("message", "单据不存在!");
@@ -474,7 +797,9 @@ public class ERPServiceImpl implements ERPService {
         SqlRowList rs = baseDao.queryForRowSet("select LP_ID, LP_CODE, LP_INDATE, LP_CALDATE, LP_TYPE, LP_ROUTE, LP_WEIGHT, LP_VOLUME, LP_RECIPIENT, LP_TEL, LP_ADD,  LP_RECORDER, LP_COMPANY1,    LP_PROVINCE, LP_DISTRICT, LP_SENDDATETIME,to_char(LP_SENDDATETIME,'yyyy-mm-dd hh24:mi:ss') SENDDATETIME" +
                 " from LogisticsPrice where lp_id="+id);
         if(rs.next()){
-            getPrice_KY(id,rs.getGeneralString("LP_TYPE"),rs.getGeneralDouble("LP_WEIGHT"),rs.getGeneralString("lp_province"),rs.getGeneralString("lp_route"),
+            getPrice_KY(id,rs.getGeneralString("LP_TYPE"),rs.getGeneralDouble("LP_WEIGHT"),
+                    rs.getGeneralString("lp_province"),
+                    rs.getGeneralString("lp_route"),
                     rs.getDate("LP_SENDDATETIME"));
         }
     }
@@ -612,6 +937,7 @@ public class ERPServiceImpl implements ERPService {
                     businessType="160";
                 }
             }
+            System.out.println("businessType:"+businessType);
             params.put("format","json");
             params.put("timestamp",timeStamp);
             String method="open.api.openCommon.queryFreightCharge";

+ 96 - 1
src/test/java/com/uas/eis/UasEisApplicationTests.java

@@ -42,10 +42,105 @@ public class UasEisApplicationTests {
 	}
 	@Test
 	public void TestKY_getprice(){
-	 	erpService.getKYPrice("SZSI_P",3222);
+	 	erpService.getKYPrice("SZSI_P",3268);
 	}
 	@Test
 	public void TestDOP_getprice(){
 		erpService.getDOPPrice("SZSI_P",3222);
 	}
+
+	@Test
+	public void TestCreatOrder(){
+		erpService.creatOrder("SZSI_P",3268);//3267
+	}
+
+	@Test
+	public void TestCancelOrder(){
+		erpService.cancelOrder("SZSI_P",3268);//3267
+	}
+	@Test
+	public void Test() throws UnsupportedEncodingException {
+		String orderCode = "2025040015-3";
+		String CLIENT_CODE = "SABDTMZAMNNB";  //丰桥平台获取的顾客编码
+		String CALL_URL = "https://sfapi-sbox.sf-express.com/std/service"; //沙箱环境的地址 -PRO https://sfapi-sbox.sf-express.com/std/service 生产环境的地址 -PRO https://sfapi.sf-express.com/std/service
+		String CHECK_WORD = "zYSo7GUgOVo9dblSIgYk4KRyvamlaeMc"; //丰桥平台获取的校验码 生产环境 "GgO0UoyQ5FssNLItii3olo63bQ80ErAE" 沙箱环境 "rMBhSYRa9OtUPkfX5mow01NlxDWtI411"
+
+		IServiceCodeStandard standardService = ExpressServiceCodeEnum.EXP_RECE_FILTER_ORDER_BSP;//订单查询
+		CallExpressServiceTools tools=CallExpressServiceTools.getInstance();
+		Map<String, String> params = new HashMap<String, String>();
+		String timeStamp = String.valueOf(System.currentTimeMillis());
+		String msgData = "";
+		/*[
+		{
+			"contactInfos":[
+			{
+				"address":"珠海市高新区唐家湾镇鼎兴路129号9栋7层703-3",
+					"city":"珠海市",
+					"contactType":2,
+					"country":"中国",
+					"county":"高新区",
+					"province":"珠海市",
+					"tel":"13556340543"
+			},
+			{
+				"address":"深圳市龙岗区宝龙工业区宝龙七路3号 “深圳深爱半导体股份有限公司” 收货人:王先生 TEL 13926545249",
+					"city":"深圳市",
+					"contactType":1,
+					"country":"中国",
+					"county":"龙岗区",
+					"province":"广东省"
+			}],
+			"filterType":2,
+				"orderId":"2025040015-3"
+		}]*/
+		Map<String,Object> msgDataMap = new HashMap<>();
+		List<FilterAddrInfoDto> filterAddrInfoDtos = new ArrayList<>();
+		FilterAddrInfoDto filterAddrInfoDto=new FilterAddrInfoDto();
+		filterAddrInfoDto.setContactType(1);
+		filterAddrInfoDto.setAddress("深圳市龙岗区宝龙工业区宝龙七路3号 “深圳深爱半导体股份有限公司” 收货人:王先生 TEL 13926545249");
+		filterAddrInfoDto.setCountry("中国");
+		filterAddrInfoDto.setProvince("广东省");
+		filterAddrInfoDto.setCity("深圳市");
+		filterAddrInfoDto.setCounty("龙岗区");
+		filterAddrInfoDtos.add(filterAddrInfoDto);
+		//msgDataMap.put("monthlyCard","7551234567");
+
+		FilterAddrInfoDto filterAddrInfoDto1=new FilterAddrInfoDto();
+		filterAddrInfoDto1.setContactType(2);
+		filterAddrInfoDto1.setAddress("珠海市高新区唐家湾镇鼎兴路129号9栋7层703-3");
+		filterAddrInfoDto1.setCountry("中国");
+		filterAddrInfoDto1.setProvince("广东省");
+		filterAddrInfoDto1.setCity("珠海市");
+		filterAddrInfoDto1.setCounty("高新区");
+		filterAddrInfoDto1.setTel("13556340543");
+
+		filterAddrInfoDtos.add(filterAddrInfoDto1);
+
+		OrderFilter orderFilter=new OrderFilter();
+		orderFilter.setFilterType(2);
+		orderFilter.setOrderId(orderCode);
+		orderFilter.setContactInfos(filterAddrInfoDtos);
+		List<OrderFilter> orderFilters = new ArrayList<>();
+		orderFilters.add(orderFilter);
+		//msgDataMap.put("monthlyCard","7551234567");
+
+		msgData = FlexJsonUtil.toJsonDeep(orderFilters);
+			params.put("partnerID", CLIENT_CODE);  // 顾客编码 ,对应丰桥上获取的clientCode
+			params.put("requestID", UUID.randomUUID().toString().replace("-", ""));
+			params.put("serviceCode", standardService.getCode());// 接口服务码
+			params.put("timestamp", timeStamp);
+			params.put("msgData", msgData);
+			params.put("msgDigest", tools.getMsgDigest(msgData, timeStamp, CHECK_WORD));
+			System.out.println("====调用请求:" + params.get("msgData"));
+			String result = HttpClientUtil.post(CALL_URL, params);
+			System.out.println("===返回结果:" + result);
+/*
+		{
+			"apiErrorMsg": "",
+				"apiResponseID": "00019633FBAD3F3FED042D78FA0DC53F",
+				"apiResultCode": "A1000",
+				"apiResultData": "{\"success\":true,\"errorCode\":\"S0000\",\"errorMsg\":null,\"msgData\":[{\"orderId\":\"2025040015-3\",\"filterResult\":2,\"originCode\":\"755\",\"destCode\":\"756\",\"remark\":null}]}"
+		}*/
+
+	}
 }