package com.hzya.frame.plugin.ht.plugin;

import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.base.PluginBaseEntity;
import com.hzya.frame.seeyon.invoice.service.impl.InvoiceServiceImpl;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @Description
 * @Author xiangerlin
 * @Date 2024/8/22 16:39
 **/
public class MakeInvoicePluginInitializer extends PluginBaseEntity {

    @Autowired
    private InvoiceServiceImpl invoiceService;
    Logger logger = LoggerFactory.getLogger(getClass());
    /***
     * 插件初始化方法
     * @Author 👻👻👻👻👻👻👻👻 gjh
     * @Date 2023-08-02 10:48
     * @Param []
     * @return void
     **/
    @Override
    public void initialize() {
        logger.info(getPluginLabel() + "執行初始化方法initialize()");
    }

    /****
     * 插件销毁方法
     * @author 👻👻👻👻👻👻👻👻 gjh
     * @date 2023-08-02 10:48
     * @return void
     **/
    @Override
    public void destroy() {
        logger.info(getPluginLabel() + "執行銷毀方法destroy()");
    }

    /****
     * 插件的ID
     * @author 👻👻👻👻👻👻👻👻 gjh
     * @date 2023-08-02 10:48
     * @return void
     **/
    @Override
    public String getPluginId() {
        return "MakeInvoicePluginInitializer";
    }

    /****
     * 插件的名称
     * @author 👻👻👻👻👻👻👻👻 gjh
     * @date 2023-08-02 10:48
     * @return void
     **/
    @Override
    public String getPluginName() {
        return "OA开票申请同步税务平台插件";
    }

    /****
     * 插件的显示值
     * @author 👻👻👻👻👻👻👻👻 gjh
     * @date 2023-08-02 10:48
     * @return void
     **/
    @Override
    public String getPluginLabel() {
        return "OA开票申请同步税务平台插件";
    }

    /***
     * 插件类型 1、场景插件
     * @Author 👻👻👻👻👻👻👻👻 gjh
     * @Date 2023-08-02 14:01
     * @Param []
     * @return java.lang.String
     **/
    @Override
    public String getPluginType() {
        return "1";
    }

    /***
     * 执行业务代码
     * @Author 👻👻👻👻👻👻👻👻 gjh
     * @Date 2023-08-07 11:20
     * @param requestJson  执行业务代码的参数
     * @return void
     **/
    @Override
    public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception {
        try {
            logger.info("======开始执行杭泰开票申请单同步========");
            return invoiceService.queryArchives(requestJson);
        }catch (Exception e){
            logger.info("======执行杭泰开票申请单同步失败:{}========",e.getMessage());
            e.printStackTrace();
        }
        return null;
    }
}
