package cn.service.impl;

import java.util.Map;
import org.springframework.stereotype.Service;
import cn.common.exception.BusinessException;
import cn.orm.abs.ISqlToyDao;
import cn.pojo.entity.TSysJobLog;
import cn.service.IJobLogService;
import cn.util.core.LogKit;
import cn.util.string.JsonKit;
import cn.util.time.TimeKit;
import javax.annotation.Resource;

/**
 * <p>
 * 定时任务调度日志表 服务实现类
 */
@Service
public class JobLogServiceImpl implements IJobLogService
{
	@Resource
	private ISqlToyDao daoService;
	/**
	 * 新增任务日志
	 * @param jobLog 调度日志信息
	 * OK: 
	 * int result = daoService.insertAndGenIndex(SQLConst.TABLE_LOG_JOB,mapRecord);
	 * LogUtil.println("写定时任务调度日志入库(日志ID："+result+")");
	 * No:
	 * Object result = daoService.save(jobLog); 原因不明
	 */
	@Override
	public void addJobLog(TSysJobLog jobLog) 
	{
		jobLog.setCreateTime(TimeKit.getNowLocalDateTime());
		Map<String, Object> mapRecord = JsonKit.jsonObjToMap(jobLog);
		Boolean result = false;
		try {
			result = daoService.insert(TABLE_LOG_JOB,mapRecord,true);
		} catch (BusinessException e) {
			LogKit.info(e);
		}
		LogKit.println("写定时任务调度日志入库("+(result? "成功":"失败")+")");
	}
	//任务调度日志
	private static final String TABLE_LOG_JOB = "t_sys_job_log";
}
