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

import cn.hutool.core.date.DateUtil;
import com.jeelowcode.core.framework.config.aspect.enhancereport.model.EnhanceReportContext;
import com.jeelowcode.core.framework.config.aspect.enhancereport.plugin.ReportAfterAdvicePlugin;
import com.jeelowcode.core.framework.utils.Func;
import com.jeelowcode.framework.utils.utils.JeeLowCodeUtils;
import org.springframework.stereotype.Component;

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

/**
 * 系统首页-数据会员-各品类占比
 */
@Component("exampleMemberProductPercentageReportEnhance")
public class ExampleMemberProductPercentageReportEnhance implements ReportAfterAdvicePlugin {

    @Override
    public void execute(EnhanceReportContext enhanceContext) {
        List<Map<String, Object>> records = enhanceContext.getResult().getRecords();
        if (Func.isEmpty(records)) {
            return;
        }
        records.forEach(item -> item.put("sj", DateUtil.format(JeeLowCodeUtils.getMap2DateTime(item, "sj"), "yyyy-MM")));
    }
}
