package com.sunda.spmsweb.ibmmqcontroller;

import com.sunda.spmscommon.ResponseResult;
import com.sunda.spmsweb.ibmmqservice.SendMessageInterface;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: spms
 * @description: mqcontroller
 * @author: Wayne Wu
 * @create: 2020-11-03 14:26
 **/
@RestController
@RequestMapping("/mqtest")
@Api(tags = "IBM MQ 接口", description = "IBM MQ 测试")
public class mqcontroller {

    @Autowired
    SendMessageInterface sendMessageInterface;

    /***

    @RequestMapping("/Z_RFC_STORE_01")
    @ApiOperation(value = "物料主数据 Z_RFC_STORE_01",notes = "手动发送消息", httpMethod = "POST")
    public ResponseResult Z_RFC_STORE_01(){
        return sendMessageInterface.Z_RFC_STORE_01();
    }

    @RequestMapping("/Z_RFC_STORE_03")
    @ApiOperation(value = "组织机构码 Z_RFC_STORE_03",notes = "手动发送消息", httpMethod = "POST")
    public ResponseResult Z_RFC_STORE_03(){
        return sendMessageInterface.Z_RFC_STORE_03();
    }

    @RequestMapping("/Z_RFC_STORE_06")
    @ApiOperation(value = "语言代码配置 Z_RFC_STORE_06",notes = "手动发送消息", httpMethod = "POST")
    public ResponseResult Z_RFC_STORE_06(){
        return sendMessageInterface.Z_RFC_STORE_06();
    }

    @RequestMapping("/Z_RFC_STORE_09")
    @ApiOperation(value = "同步客户信用 Z_RFC_STORE_09",notes = "手动发送消息", httpMethod = "POST")
    public ResponseResult Z_RFC_STORE_09(){
        return sendMessageInterface.Z_RFC_STORE_09();
    }

    @RequestMapping("/sendMsg")
    @ApiOperation(value = "手动发送指定消息/暂无需token",notes = "手动发送消息\n\n" +
            "{\n" +
            "\t\"REQUEST\": {\n" +
            "\t\t\"ESB_ATTRS\": {\n" +
            "\t\t\t\"Application_ID\": \"00020000000004\",\n" +
            "\t\t\t\"Transaction_ID\": \"\"\n" +
            "\t\t},\n" +
            "\t\t\"REQUEST_DATA\": {\n" +
            "\t\t\t\"reqAppId\": \"SPMS\",\n" +
            "\t\t\t\"rfcName\": \"Z_RFC_STORE_09\",\n" +
            "\t\t\t\"date\": \"\",\n" +
            "\t\t\t\"tableName\": \"\",\n" +
            "\t\t\t\"isSyn\": \"0\"\n" +
            "\t\t}\n" +
            "\t}\n" +
            "}", httpMethod = "POST")
    public ResponseResult getMaterialList(@RequestBody JSONObject doc){
        return sendMessageInterface.sendMessage(doc);
    }

//    @RequestMapping("/sendSRM")
//    @ApiOperation(value = "提交请购单及明细到SRM",notes = "提交请购单及明细到SRM", httpMethod = "POST")
//    public ResponseResult sendSRM(){
//        return sendMessageInterface.sendSRM();
//    }
//
//    @RequestMapping("/getApplicantOrder")
//    @ApiOperation(value = "获取一个请购单及明细信息",notes = "获取一个请购单及明细信息", httpMethod = "GET")
//    public ResponseResult getApplicantOrder(){
//        return sendMessageInterface.getApplicantOrder();
//    }

    @RequestMapping("/Z_SPMS_GETFACTORY")
    @ApiOperation(value = "SAP公司工厂信息",notes = "SAP公司工厂信息", httpMethod = "GET")
    public ResponseResult Z_SPMS_GETFACTORY(){
        return sendMessageInterface.Z_SPMS_GETFACTORY();
    }

    @RequestMapping("/Z_SPMS_GETWAREHOUSE")
    @ApiOperation(value = "SAP仓库信息",notes = "SAP仓库信息", httpMethod = "GET")
    public ResponseResult Z_SPMS_GETWAREHOUSE(){
        return sendMessageInterface.Z_SPMS_GETWAREHOUSE();
    }

    @RequestMapping("/Z_SPMS_GETCOSTCENTER")
    @ApiOperation(value = "SAP成本中心信息",notes = "SAP成本中心信息", httpMethod = "GET")
    public ResponseResult Z_SPMS_GETCOSTCENTER(){
        return sendMessageInterface.Z_SPMS_GETCOSTCENTER();
    }

    ***/

    //ed64f63d663141028cad97a42510da89
    @RequestMapping("/spmsSrmPurchaseInfo")
    @ApiOperation(value = "SPMS请购单MQ推送SRM",notes = "SPMS请购单MQ推送SRM。按工厂请购单 oaBianhao，" +
            "手动将工厂请购单表头及行项目信息推送MQ到SRM，示例工厂请购单 oaBianhao = 958139", httpMethod = "POST")
    public ResponseResult spmsSrmPurchaseInfo(String oaBianhao){
        return ResponseResult.success().add("result", sendMessageInterface.spms_srm_purchase_info2(oaBianhao));
    }
}
