package cn.superdesk.uniorder.executor.scheduler.kafka._inner;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import cn.superdesk.uniorder.common.enums.common.CommonServiceNoEnum;
import cn.superdesk.uniorder.executor.scheduler.config.env.EnvOutputConstant;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.File;


/**
 * @Description: Java类作用描述
 * @Author: linjinyu
 * @CreateDate: 2022/5/16 10:34 上午
 * @UpdateUser: linjinyu
 * @UpdateDate: 2022/5/16 10:34 上午
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
public class BaseInnerHandleService {

    @Autowired
    private EnvOutputConstant envOutputConstant;


    protected void tmpLogWithAccountingOrderSn(
            String handlerName,
            String accountingOrderSn,
            String messageKey,
            String messageBody,
            String now) {

        String excelExportPathRoot             = envOutputConstant.getPathRoot();
        String excelExportRelativePathTemplate = envOutputConstant.getPathTemplate();
        String excelExportRelativePathStorage  = envOutputConstant.getPathStorage();

        String relativePath = File.separator + "middle" +
                File.separator + "event" +
                File.separator + handlerName +
                File.separator + messageKey +
                File.separator + accountingOrderSn +
                File.separator;

//		String templateRelativePath = excelExportPathRoot + excelExportRelativePathTemplate + relativePath;
//		String templateFullPath;

        String targetFullPath = excelExportPathRoot + excelExportRelativePathStorage;

        String targetResponseFileName          = StrUtil.format("{}_{}_{}.json", now, messageKey, accountingOrderSn);
        String targetResponseWriteFileFullPath = targetFullPath + relativePath + targetResponseFileName;
        FileUtil.touch(targetResponseWriteFileFullPath);
        FileUtil.writeUtf8String(messageBody, targetResponseWriteFileFullPath);// CharsetUtil.CHARSET_UTF_8

    }

    protected void tmpLog(String targetFullPath, String relativePath, String type, String jsonBody, String now) {

        String targetWriteFileName     = StrUtil.format("{}_{}.json", type, now);
        String targetWriteFileFullPath = targetFullPath + relativePath + targetWriteFileName;
        FileUtil.touch(targetWriteFileFullPath);
        FileUtil.writeUtf8String(jsonBody, targetWriteFileFullPath);// CharsetUtil.CHARSET_UTF_8

    }

}
