| | |
| | | import org.apache.commons.httpclient.methods.StringRequestEntity; |
| | | import org.apache.commons.io.IOUtils; |
| | | import com.jcdm.main.om.productionOrde.*; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | |
| | | import java.util.List; |
| | | |
| | | public class ReceivingServices { |
| | | |
| | | private static final Logger logger = LoggerFactory.getLogger("sys-user"); |
| | | @Autowired |
| | | // private static IOmProductionOrdeInfoService omProductionOrdeInfoService; |
| | | private static IOmProductionOrdeInfoService omProductionOrdeInfoService = BeanUtils.getBean(IOmProductionOrdeInfoService.class); |
| | |
| | | |
| | | public static void insertWebserviceData(String factory,String str) { |
| | | String result = getInterfaceInformationXml(ProductionPlanInformationUrl, getProductionPlanInformationXml(factory,str)); |
| | | logger.info("messageLocation1,"+result); |
| | | String jsonStr = xmlToJSON2(result); |
| | | logger.info("messageLocation5,"+jsonStr); |
| | | if (StrUtil.isNotBlank(jsonStr)){ |
| | | if (!jsonStr.contains("[") && !jsonStr.contains("]")){ |
| | | StringBuilder stringBuilder = new StringBuilder(jsonStr); |
| | | stringBuilder.insert(8,"["); |
| | | stringBuilder.insert(jsonStr.length(),"]"); |
| | | jsonStr = stringBuilder.toString(); |
| | | logger.info("messageLocation6,"+jsonStr); |
| | | } |
| | | Gson gson = new Gson(); |
| | | // 将json字符串转换成对象 |
| | | ItemList itemList = gson.fromJson(jsonStr, ItemList.class); |
| | | if (ObjectUtil.isNotNull(itemList)){ |
| | | logger.info("messageLocation7,"+ itemList); |
| | | } |
| | | for (Item item : itemList.getItem()) { |
| | | logger.info("messageLocation8,"+item); |
| | | OmProductionOrdeInfo ordeInfo = new OmProductionOrdeInfo(); |
| | | ordeInfo.setWorkshopCode(item.getWERKS()); |
| | | ordeInfo.setProductCode(item.getPLNBEZ()); |
| | |
| | | try { |
| | | status = client.executeMethod(postMethod); |
| | | } catch (IOException e) { |
| | | logger.info("errorLocation1,"+e); |
| | | throw new RuntimeException(e); |
| | | } |
| | | if (status == 200) {// 成功 |
| | |
| | | try { |
| | | is = postMethod.getResponseBodyAsStream(); |
| | | } catch (IOException e) { |
| | | logger.info("errorLocation2,"+e); |
| | | throw new RuntimeException(e); |
| | | } |
| | | // 获取请求结果字符串 |
| | |
| | | result = IOUtils.toString(is); |
| | | return result; |
| | | } catch (IOException e) { |
| | | logger.info("errorLocation3,"+e); |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | |
| | | .getAsJsonObject("SOAP:Body") |
| | | .getAsJsonObject("n0:ZPP_CF_MES_005.Response"); |
| | | if (ObjectUtil.isNotNull(result)){ |
| | | logger.info("messageLocation2,"+result); |
| | | String string = result.get("EV_MESSAGE").toString(); |
| | | if (string.contains("查询成功")){ |
| | | logger.info("messageLocation3,"+string); |
| | | JsonObject etData = jsonObject2 |
| | | .getAsJsonObject("SOAP:Envelope") |
| | | .getAsJsonObject("SOAP:Body") |
| | | .getAsJsonObject("n0:ZPP_CF_MES_005.Response") |
| | | .getAsJsonObject("ET_DATA"); |
| | | data = etData.toString(); |
| | | logger.info("messageLocation4,"+data); |
| | | } |
| | | } |
| | | |