package com.hzya.frame.plugin.cinvoice.plugin;

import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.base.PluginBaseEntity;
import com.hzya.frame.plugin.cinvoice.service.ICInvoiceImportPluginService;
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 2025/4/18 15:12
 **/
public class CInvoiceImportPluginInitializer extends PluginBaseEntity {
    Logger logger = LoggerFactory.getLogger(getClass());
    @Autowired
    private ICInvoiceImportPluginService pluginService;
    /***
     * 插件初始化方法
     * @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 "CInvoiceImportPluginInitializer";
    }

    /****
     * 插件的名称
     * @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 {
        logger.info("======开始执OA发票批量导入有度税务插件======:{}",requestJson.toString());
        pluginService.importInvoice(requestJson);
        return BaseResult.getSuccessMessageEntity("执行成功");
    }
}
