//package com.prolog.cs.biz.inbound.service.impl;
//
//import com.fasterxml.jackson.databind.JsonNode;
//import com.fasterxml.jackson.databind.ObjectMapper;
//import com.prolog.cs.biz.inbound.model.SupervisionCode;
//import com.taobao.api.ApiException;
//import com.taobao.api.DefaultTaobaoClient;
//import com.taobao.api.TaobaoClient;
//import com.taobao.api.TaobaoResponse;
//import com.taobao.api.internal.util.StringUtils;
//import com.taobao.api.request.AlibabaAlihealthDrugCodeKytQuerycodeRequest;
//import com.taobao.api.request.AlibabaAlihealthDrugKytUploadcircubillRequest;
//import com.taobao.api.response.AlibabaAlihealthDrugKytUploadcircubillResponse;
//import org.dom4j.Document;
//import org.dom4j.DocumentHelper;
//import org.dom4j.Element;
//import org.dom4j.io.OutputFormat;
//import org.dom4j.io.XMLWriter;
//
//import java.io.File;
//import java.io.FileOutputStream;
//import java.io.IOException;
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * 码上放心平台
// *
// * @author tianhl
// * @Date 2017/5/21 16:10
// */
////@Transactional //打开的话测试之后数据可自动回滚
//public class TaobaoMain {
//
//    public static void main(String[] args)throws Exception {
//        //创建Document对象
//        Document document= DocumentHelper.createDocument();
//        //创建元素
//        Element Document = document.addElement("Document");
//        Element events = Document.addElement("Events");
//        Element EventElement=events.addElement("Event");
//        EventElement.addAttribute("Name", "PurchaseWareHouseIn");
//        EventElement.addAttribute("MainAction", "WareHouseIn");
//        Element dataField = EventElement.addElement("DataField");
//
//        List<SupervisionCode> taskLineResultList = new ArrayList<>();
//        SupervisionCode supervisionCode =new SupervisionCode();
//        supervisionCode.setSupervisionCode("0000001");
//        supervisionCode.setId("123546");
//        supervisionCode.setRefBillId("892025905248079872");
//        taskLineResultList.add(supervisionCode);
//        SupervisionCode supervisionCode2 =new SupervisionCode();
//        supervisionCode2.setSupervisionCode("0000002");
//        supervisionCode2.setId("6789655");
//        supervisionCode.setRefBillId("892025905248079872");
//        taskLineResultList.add(supervisionCode2);
//        //遍历集合
//        for(SupervisionCode supervisionCode1:taskLineResultList){
//            //创建子元素并直接添加进根元素
//            Element data = dataField.addElement("Data");
//            data.addAttribute("Code", String.valueOf(supervisionCode1.getSupervisionCode()));
//            data.addAttribute("CorpOrderID", String.valueOf(supervisionCode1.getId()));
//            data.addAttribute("ActDate", "2020-07-16 10:32:06");
//            data.addAttribute("ToCorpID", "");
//        }
//        // 使用 OutputFormat 进行格式化设置
//        OutputFormat format = OutputFormat.createCompactFormat();
//        // 设置是否缩进，默认为 false
//        format.setIndent(false);
//        // 创建 StringWriter 来保存转换后的无格式 XML 字符串
//        java.io.StringWriter stringWriter = new java.io.StringWriter();
//        // 创建 XMLWriter 对象并设置输出流和格式化参数
//        XMLWriter writer = new XMLWriter(stringWriter, format);
//        // 将 Document 对象写入到输出流中，并触发转换操作
//        writer.write(document);
//        String xmlStringWithoutFormatting = stringWriter.toString();
//        System.out.println(xmlStringWithoutFormatting);
//
////		//设置生成xml的格式
////		OutputFormat format=OutputFormat.createPrettyPrint();
////		//设置编码格式
////		format.setEncoding("UTF-8");
////		//创建xml字符输出流
////		XMLWriter writer=new XMLWriter(new FileOutputStream(new File("d://"+taskLineResultList.get(0).getRefBillId()+".xml")),format);
////		//设置是否转义，默认使用转义字符
////		writer.setEscapeText(false);
////		//写出Document对象
////		writer.write(document);
////		//关闭流
////		writer.close();
//
//        String serverUrl ="http://gw.api.taobao.com/router/rest";
//        String appKey ="31829450" ;
//        String appSecret ="ec698ea2ac4accd88006cd8a390b4567";
//        TaobaoClient client = new DefaultTaobaoClient(serverUrl,
//                appKey, appSecret);
//        AlibabaAlihealthDrugKytUploadcircubillRequest req = new AlibabaAlihealthDrugKytUploadcircubillRequest();
//        req.setBillCode("bc001");
//        req.setBillTime(StringUtils.parseDateTime("2017-05-10 16:57:15"));
//        req.setBillType(102L);//单据类型 --102代表采购入库
//        req.setPhysicType(3L);//可任意填写
//        req.setRefUserId("fa3dfe7f41ce42c1b6b6f9505e530e32");//货主企业
//        req.setFromUserId("fa3dfe7f41ce42c1b6b6f9505e530e32");//发货企业
//        req.setToUserId("66677777780507433");//收货企业
//        req.setOperIcCode("31829450");//操作人标识（写appkey编号）
//        req.setOperIcName("张三");//操作人名称
//        String xxx = XmlUtil.createFileZipContentnew(xmlStringWithoutFormatting);
//        req.setFileContent(xxx);//填写单据文件xml的加密串
//        req.setUploadFileName("xxxx.xml");//单据文件名称
//        req.setClientType("2");//请求端类型【暂定都写2】
//
//        AlibabaAlihealthDrugKytUploadcircubillResponse rsp = null;
//        try {
//            rsp = client.execute(req);
//            System.out.println("返回报文："+rsp.getBody());
//            ObjectMapper mapper = new ObjectMapper();
//            JsonNode node = mapper.readTree(rsp.getBody());
//            String model=node.get("alibaba_alihealth_drug_kyt_uploadcircubill_response").get("model").toString();
//            System.out.println("是否成功："+model);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//
//
////        AlibabaAlihealthDrugCodeKytQuerycodeRequest req = new AlibabaAlihealthDrugCodeKytQuerycodeRequest();
////        //AlibabaAlihealthDrugKytListpartsRequest req1=new AlibabaAlihealthDrugKytListpartsRequest();//时空ERP调用接口
////        //alibaba.alihealth.drug.kyt.uploadinoutbill//时空ERP调用接口
////        //req1.set
////        req.setCodes("83651520027728186553");//昆中药感冒疏风颗粒
////        //req.setCodes("81516350599094736814");//999枇杷膏
////        //req.setCodes("81516350599094736815");//999枇杷膏
////        req.setRefEntId("320000000000127967");//企业唯一标识
////        TaobaoResponse rsp = null;
////        try {
////            rsp = client.execute(req);
////            System.out.println(rsp.getBody());
////            ObjectMapper mapper = new ObjectMapper();
////            JsonNode node = mapper.readTree(rsp.getBody());
////            String code_status=node.get("alibaba_alihealth_drug_code_kyt_querycode_response").get("result")
////                    .get("models").get("code_full_info_dto").get(0).get("code_status_type_d_t_o").get("code_status").toString();
////            if("E".equals(code_status)){//code_status I核注O核销A激活C注销E错误码
////
////            }
////            JsonNode produce_info_dto=node.get("alibaba_alihealth_drug_code_kyt_querycode_response").get("result")
////                    .get("models").get("code_full_info_dto").get(0).get("code_produce_info_d_t_o").get("produce_info_list")
////                    .get("produce_info_dto").get(0);
////            String batch_no=produce_info_dto.get("batch_no").toString();
////            String expire_date=produce_info_dto.get("expire_date").toString();
////            String produce_date_str=produce_info_dto.get("produce_date_str").toString();
////            System.out.println("batch_no"+batch_no+",expire_date"+expire_date+",produce_date_str"+produce_date_str);
////        } catch (Exception e) {
////            e.printStackTrace();
////        }
//
//    }
//
//}
