春风项目四线(合箱线、总装线)
wujian
2024-08-03 131e8c0adbd4f56e1f7e7f877ff1b03e1683314f
jcdm-main/src/main/java/com/jcdm/main/webservice/service/ReceivingServices.java
@@ -1,12 +1,15 @@
package com.jcdm.main.webservice.service;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.jcdm.common.exception.ServiceException;
import com.jcdm.main.da.collectionParamConf.service.IDaCollectionParamConfService;
import com.jcdm.main.da.opcuaconfig.init.BeanUtils;
import com.jcdm.main.om.productionOrde.domain.OmProductionOrdeInfo;
@@ -36,7 +39,8 @@
//    private static IOmProductionOrdeInfoService omProductionOrdeInfoService;
    private static IOmProductionOrdeInfoService omProductionOrdeInfoService = BeanUtils.getBean(IOmProductionOrdeInfoService.class);
    public static final String ProductionPlanInformationUrl = "http://podqapp.cfmoto.com.cn:50100/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_MES&receiverParty=&receiverService=&interface=SI_ZPP_CF_MES_005_SYN_OUT&interfaceNamespace=http://cfmoto.com/xi/MES";
    public static final String ProductionPlanInformationUrl = "http://popappdb.cfmoto.com.cn:50100/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_MES&receiverParty=&receiverService=&interface=SI_ZPP_CF_MES_005_SYN_OUT&interfaceNamespace=http%3A%2F%2Fcfmoto.com%2Fxi%2FMES";
//    public static final String ProductionPlanInformationUrl = "http://podqapp.cfmoto.com.cn:50200/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_MES&receiverParty=&receiverService=&interface=SI_ZPP_CF_MES_005_SYN_OUT&interfaceNamespace=http://cfmoto.com/xi/MES";
    public static void main(String[] args) throws Exception {
//        getInterfaceInformationXml(ProductionPlanInformationUrl,getProductionPlanInformationXml("A0055577"));
@@ -104,26 +108,38 @@
//        }
    }
    
    public static void insertWebserviceData(String str) {
        String result = getInterfaceInformationXml(ProductionPlanInformationUrl, getProductionPlanInformationXml(str));
    public static void insertWebserviceData(String factory,String str) {
        String result = getInterfaceInformationXml(ProductionPlanInformationUrl, getProductionPlanInformationXml(factory,str));
        String jsonStr = xmlToJSON2(result);
        Gson gson = new Gson();
        // 将json字符串转换成对象
        ItemList itemList = gson.fromJson(jsonStr, ItemList.class);
        for (Item item : itemList.getItem()) {
            OmProductionOrdeInfo ordeInfo = new OmProductionOrdeInfo();
            ordeInfo.setProductCode(item.getPLNBEZ());
            ordeInfo.setProductName(item.getMAKTX());
            ordeInfo.setLineCode(item.getFEVOR());
            ordeInfo.setWorkOrderNo(item.getAUFNR());
            ordeInfo.setPlanQty((long) Double.parseDouble(item.getPSMNG()));
            ordeInfo.setProductionNotice(item.getZSCTZD());
            ordeInfo.setTypeZ(item.getFERTH());
            ordeInfo.setCreateUser(item.getZUSER());
            //ordeInfo.setCreateTime(item.getZDATE());
            ordeInfo.setDemandDate(item.getGSTRP());//开工日期
            omProductionOrdeInfoService.insertOmProductionOrdeInfo(ordeInfo);
        if (StrUtil.isNotBlank(jsonStr)){
            if (!jsonStr.contains("[") && !jsonStr.contains("]")){
                StringBuilder stringBuilder = new StringBuilder(jsonStr);
                stringBuilder.insert(8,"[");
                stringBuilder.insert(jsonStr.length(),"]");
                jsonStr = stringBuilder.toString();
            }
            Gson gson = new Gson();
            // 将json字符串转换成对象
            ItemList itemList = gson.fromJson(jsonStr, ItemList.class);
            for (Item item : itemList.getItem()) {
                OmProductionOrdeInfo ordeInfo = new OmProductionOrdeInfo();
                ordeInfo.setWorkshopCode(item.getWERKS());
                ordeInfo.setProductCode(item.getPLNBEZ());
                ordeInfo.setProductName(item.getMAKTX());
                ordeInfo.setLineCode(item.getFEVOR());
                ordeInfo.setWorkOrderNo(item.getAUFNR());
                ordeInfo.setPlanQty((long) Double.parseDouble(item.getPSMNG()));
                ordeInfo.setProductionNotice(item.getZSCTZD());
                ordeInfo.setTypeZ(item.getFERTH());
                ordeInfo.setCreateUser(item.getZUSER());
                //ordeInfo.setCreateTime(item.getZDATE());
                ordeInfo.setDemandDate(item.getGSTRP());//开工日期
                omProductionOrdeInfoService.insertOmProductionOrdeInfo(ordeInfo);
            }
        } else {
            throw new ServiceException("未接收到数据,请检查");
        }
    }
    public static String getInterfaceInformationXml(String url,String xml){
@@ -177,15 +193,15 @@
        return "接口调用错误";
    }
    public static String getProductionPlanInformationXml(String str){
    public static String getProductionPlanInformationXml(String factory,String planNo){
        String content = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:sap-com:document:sap:rfc:functions\">\n" +
                "   <soapenv:Header/>\n" +
                "   <soapenv:Body>\n" +
                "      <urn:ZPP_CF_MES_005>\n" +
                "         <!--Optional:-->\n" +
                "         <IV_WERKS>1000</IV_WERKS>\n" +
                "         <IV_WERKS>"+factory+"</IV_WERKS>\n" +
                "         <!--Optional:-->\n" +
                "         <IV_ZSCTZD>"+str+"</IV_ZSCTZD>\n" +
                "         <IV_ZSCTZD>"+planNo+"</IV_ZSCTZD>\n" +
                "      </urn:ZPP_CF_MES_005>\n" +
                "   </soapenv:Body>\n" +
                "</soapenv:Envelope>";
@@ -200,15 +216,26 @@
     */
    public static String xmlToJSON2(String xmlStr){
        JSONObject jsonObject1 = cn.hutool.json.XML.toJSONObject(xmlStr, true);
        String data = new String();
        Gson gson = new Gson();
        JsonObject jsonObject2 = gson.fromJson(jsonObject1.toString(), JsonObject.class);
        JsonObject etData = jsonObject2
        JsonObject result = jsonObject2
                .getAsJsonObject("SOAP:Envelope")
                .getAsJsonObject("SOAP:Body")
                .getAsJsonObject("n0:ZPP_CF_MES_005.Response")
                .getAsJsonObject("ET_DATA");
        return etData.toString();
                .getAsJsonObject("n0:ZPP_CF_MES_005.Response");
        if (ObjectUtil.isNotNull(result)){
            String string = result.get("EV_MESSAGE").toString();
            if (string.contains("查询成功")){
                JsonObject etData = jsonObject2
                        .getAsJsonObject("SOAP:Envelope")
                        .getAsJsonObject("SOAP:Body")
                        .getAsJsonObject("n0:ZPP_CF_MES_005.Response")
                        .getAsJsonObject("ET_DATA");
                data = etData.toString();
            }
        }
        return data;
    }
    /**
     * 方式--贰