package weaver.interfaces.organization.cronjob;

import com.engine.common.util.ServiceUtil;
import com.engine.organization.entity.chart.params.StatisticsParam;
import com.engine.organization.service.ChartService;
import com.engine.organization.service.impl.ChartServiceImpl;
import org.apache.commons.lang3.StringUtils;
import weaver.hrm.User;
import weaver.interfaces.schedule.BaseCronJob;

/**
 * @Author liang.cheng
 * @Date 2023/9/14 9:20 AM
 * @Description: 人数统计
 * @Version 1.0
 */
public class StatisticsPersonCron extends BaseCronJob {

    private ChartService getChartService(User user) {
        return ServiceUtil.getService(ChartServiceImpl.class, user);
    }

    private String companyId;


    public String getCompanyId() {
        return companyId;
    }

    public void setCompanyId(String companyId) {
        this.companyId = companyId;
    }

    @Override
    public void execute() {
        Integer value = StringUtils.isNotBlank(companyId) ? Integer.parseInt(companyId) : null;
        StatisticsParam build = StatisticsParam.builder().companyId(value).build();
        User user = new User();
        user.setUid(1);
        getChartService(user).recordStatistics(build);
    }
}
