
package com.lideeyunji.core.framework.enhance.example.report.xtsy;

import com.lideeyunji.tool.framework.common.util.json.JsonUtils;
import com.lideeyunji.core.framework.config.aspect.enhancereport.model.EnhanceReportContext;
import com.lideeyunji.core.framework.config.aspect.enhancereport.plugin.ReportAfterAdvicePlugin;
import com.lideeyunji.core.framework.utils.Func;
import com.lideeyunji.core.framework.utils.FuncWeb;
import com.lideeyunji.tool.framework.yunji.utils.lideeYunJiUtils;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * 报表-系统首页-单表
 */
@Component("exampleXtsyLineReportEnhance")
public class ExampleXtsyLineReportEnhance implements ReportAfterAdvicePlugin {

    @Override
    public void execute(EnhanceReportContext enhanceContext) {
        List<Map<String, Object>> records = enhanceContext.getResult().getRecords();
        if (Func.isEmpty(records)) {
            return;
        }
        String jsonStr = lideeYunJiUtils.getMap2Str(records.get(0), "value");
        List<Map<String, Object>> list = (List<Map<String, Object>>) (List<?>) JsonUtils.parseArray(jsonStr, Map.class);
        FuncWeb.setReportResult(enhanceContext, list);
    }
}
