package com.miyzh.controller;

import com.miyzh.entity.UploadExceptionLog;
import com.miyzh.mapper.pre.UploadExcepctionLogMapper;
import com.miyzh.service.UploadService;
import com.miyzh.service.WsClientService;
import com.miyzh.utils.DesUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * description: WsCtroller
 * date: 2020/6/16 9:38
 * author: SZQ
 */

@RestController
@RequestMapping("ws")
public class WsController {

    @Autowired
    private WsClientService wsClientService;

    @Autowired
    private UploadExcepctionLogMapper uploadExpectionLogMapper;

    @Autowired
    private UploadService uploadService;


    @RequestMapping("uploadPatBillInfo")
    public String uploadPatBillInfo() throws Exception {
        UploadExceptionLog uploadExceptionLog = new UploadExceptionLog();
        String param = "<Request>" +
                "<TradeCode>uploadPatBillInfo</TradeCode>" +
                "<Version></Version>" +
                "<YLJGDM>87029</YLJGDM>" +
                "<YLJGXZQH>即墨区</YLJGXZQH>" +
                "<AgentIP></AgentIP>" +
                "<AgentMAC></AgentMAC>" +
                "<JYSJ>2020-06-23 11:39:41</JYSJ>" +
                "<SERIAL_NUMBER>0000000182962568</SERIAL_NUMBER>" +
                "<HS_NUMBER></HS_NUMBER>" +
                "<Patient_IDStr></Patient_IDStr>" +
                "<HS_PATIENT_NAME>123</HS_PATIENT_NAME>" +
                "<CBRXZQH></CBRXZQH>" +
                "<BENEFIT_TYPE_CODE>12</BENEFIT_TYPE_CODE>" +
                "<BENEFIT_TYPE>职工</BENEFIT_TYPE>" +
                "<BMI_CONVERED_AMOUNT></BMI_CONVERED_AMOUNT>" +
                "<CKC892></CKC892>" +
                "<PatientBenefitGroupCode>1</PatientBenefitGroupCode>" +
                "<BENEFIT_GROUP_ID></BENEFIT_GROUP_ID>" +
                "<MpName></MpName>" +
                "<GENDER>1</GENDER>" +
                "<PATIENT_BIRTH></PATIENT_BIRTH>" +
                "<MCardNo></MCardNo>" +
                "<CardType></CardType>" +
                "<CardNo></CardNo>" +
                "<PayUnit></PayUnit>" +
                "<HS_STATUS></HS_STATUS>" +
                "<Contact></Contact>" +
                "<DOC_NUMBER></DOC_NUMBER>" +
                "<BNo></BNo>" +
                "<MEDICAL_TYPE></MEDICAL_TYPE>" +
                "<JZWYBH></JZWYBH>" +
                "<BDate>2012-03-11 16:15:00</BDate>" +
                "<HOSPITAL_ID>123</HOSPITAL_ID>" +
                "<HospitalType>123</HospitalType>" +
                "<HOSPITAL_LEVEL>1</HOSPITAL_LEVEL>" +
                "<DeptCode></DeptCode>" +
                "<AKF005></AKF005>" +
                "<HS_DIAGNOSIS_IN_NAME></HS_DIAGNOSIS_IN_NAME>" +
                "<HS_DIAGNOSIS_OUT_NAME></HS_DIAGNOSIS_OUT_NAME>" +
                "<DIAGNOSIS_IN>012</DIAGNOSIS_IN>" +
                "<DIAGNOSIS_OUT>12</DIAGNOSIS_OUT>" +
                "<ICD1></ICD1>" +
                "<ICD2></ICD2>" +
                "<ICD3></ICD3>" +
                "<ICD4></ICD4>" +
                "<ICD5></ICD5>" +
                "<ICD6></ICD6>" +
                "<ICD7></ICD7>" +
                "<ICD8></ICD8>" +
                "<ICD9></ICD9>" +
                "<ICD10></ICD10>" +
                "<ICD11></ICD11>" +
                "<ICD12></ICD12>" +
                "<ICD13></ICD13>" +
                "<ICD14></ICD14>" +
                "<ICD15></ICD15>" +
                "<ICD16></ICD16>" +
                "<IN_DATE>2012-02-02</IN_DATE>" +
                "<OUT_DATE>2012-02-12</OUT_DATE>" +
                "<SETTLE_DATE>2012-02-12</SETTLE_DATE>" +
                "<CDate>2012-02-02</CDate>" +
                "<TOTAL_COST>12000</TOTAL_COST>" +
                "<MtCode>1</MtCode>" +
                "<Refund>0</Refund>" +
                "<RefundBNo>45544965</RefundBNo>" +
                "<HName></HName>" +
                "<FHID></FHID>" +
                "<FHName></FHName>" +
                "<THName></THName>" +
                "<DPVisit></DPVisit>" +
                "<OHReasonCode></OHReasonCode>" +
                "<CDBNo></CDBNo>" +
                "<CDICD></CDICD>" +
                "<IsPregnant></IsPregnant>" +
                "<IsLactation></IsLactation>" +
                "<Height></Height>" +
                "<Weight></Weight>" +
                "<TInHosp></TInHosp>" +
                "<ChargeBNo></ChargeBNo>" +
                "<DPMpName></DPMpName>" +
                "<DPDist></DPDist>" +
                "<Bed></Bed>" +
                "<BillDetailList>" +
                "<BillDetail>" +
                "<BDetailNo>44545</BDetailNo>" +
                "<BNo></BNo >" +
                "<DOC_NUMBER></DOC_NUMBER>" +
                "<ITEM_DATE>2012-02-02</ITEM_DATE>" +
                "<ITEM_ID>1</ITEM_ID>" +
                "<ITEM_NAME></ITEM_NAME>" +
                "<ITEM_TYPE></ITEM_TYPE>" +
                "<USAGE_UNIT></USAGE_UNIT>" +
                "<Specification></Specification>" +
                "<Z_PhysicianAP></Z_PhysicianAP>" +
                "<DocLevel></DocLevel>" +
                "<PRICE>120</PRICE>" +
                "<NUMBERS></NUMBERS>" +
                "<COSTS></COSTS>" +
                "<DeptCode></DeptCode>" +
                "<DEPTNAME></DEPTNAME>" +
                "<AKF005></AKF005>" +
                "<DocName></DocName>" +
                "<USAGE></USAGE>" +
                "<DOUSAGE></DOUSAGE>" +
                "<FREQUENCY_INTERVAL></FREQUENCY_INTERVAL>" +
                "<USAGE_DAYS></USAGE_DAYS>" +
                "<ELIGIBLE_AMOUNT></ELIGIBLE_AMOUNT>" +
                "<DocLevel></DocLevel>" +
                "</BillDetail>" +
                "<BillDetail>" +
                "<BDetailNo>44546</BDetailNo>" +
                "<BNo></BNo >" +
                "<DOC_NUMBER></DOC_NUMBER>" +
                "<ITEM_DATE>2012-02-02</ITEM_DATE>" +
                "<ITEM_ID>1</ITEM_ID>" +
                "<ITEM_NAME></ITEM_NAME>" +
                "<ITEM_TYPE></ITEM_TYPE>" +
                "<USAGE_UNIT></USAGE_UNIT>" +
                "<Specification></Specification>" +
                "<Z_PhysicianAP></Z_PhysicianAP>" +
                "<DocLevel></DocLevel>" +
                "<PRICE>120</PRICE>" +
                "<NUMBERS></NUMBERS>" +
                "<COSTS></COSTS>" +
                "<DeptCode></DeptCode>" +
                "<DEPTNAME></DEPTNAME>" +
                "<AKF005></AKF005>" +
                "<DocName></DocName>" +
                "<USAGE></USAGE>" +
                "<DOUSAGE></DOUSAGE>" +
                "<FREQUENCY_INTERVAL></FREQUENCY_INTERVAL>" +
                "<USAGE_DAYS></USAGE_DAYS>" +
                "<ELIGIBLE_AMOUNT></ELIGIBLE_AMOUNT>" +
                "<DocLevel></DocLevel>" +
                "</BillDetail>" +
                "</BillDetailList>" +
                "</Request>";
//        uploadExceptionLog.setUploadInfo(DesUtil.decrypt(param));
        uploadExceptionLog.setUploadInfo(param);
        return uploadService.upload(uploadExceptionLog);
    }

    @RequestMapping("uploadDocStatus")
    public String uploadDocStatus() throws Exception {
        try{
            UploadExceptionLog uploadExceptionLog = new UploadExceptionLog();
            String param =
            "<Request>" +
                "<TradeCode>uploadDocStatus</TradeCode>" +
                "<Version></Version>" +
                "<YLJGDM></YLJGDM>" +
                "<YLJGXZQH></YLJGXZQH>" +
                "<AgentIP></AgentIP>" +
                "<AgentMAC></AgentMAC>" +
                "<JYSJ></JYSJ>" +
                "<SERIAL_NUMBER>202003141202022</SERIAL_NUMBER>" +
                "<STATUS>0</STATUS>	" +
            "</Request>";
            uploadExceptionLog.setUploadInfo(DesUtil.decrypt(param));
            return uploadService.upload(uploadExceptionLog);
           
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    @RequestMapping("test")
    public String test() throws Exception {
        try{
            String webUrl = "http://zs2.sjtt.com.cn/webservice/WebService.asmx?wsdl";
            String methodName = "AgentQuery";
            String param = "青岛";
            return wsClientService.callWebSV(webUrl, methodName, param);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }


//    public static void main(String[] args) {
//        WsClientService wsClientService = new WsClientService();
//        try{
////            String webUrl = "http://zs2.sjtt.com.cn/webservice/WebService.asmx?wsdl";
//            String webUrl = "http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl";
//            String methodName = "getWeatherbyCityName";
//            String param = "青岛";
//            String str = wsClientService.callWebSV(webUrl, methodName, param);
//            System.out.println(str);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }


}

