package cn.com.victorysoft.business.calc.service;

import cn.com.victorysoft.business.calc.dao.AbnormalDataSyncDao;
import cn.com.victorysoft.business.calc.dao.FlushDataSyncDao;
import cn.com.victorysoft.business.condition.service.AbnormalUnitService;
import cn.com.victorysoft.business.condition.service.AbnormalWellService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Date;

/**
 * 异常井数据同步服务
 */
@Slf4j
@Service
public class AbnormalDataSyncService {

    @Resource
    private AbnormalDataSyncDao abnormalDataSyncDao;
    @Resource
    private AbnormalWellService abnormalWellService;
    @Resource
    private AbnormalUnitService abnormalUnitService;

    /**
     * 同步异常井日度数据
     */
    @Transactional
    public void syncAbnormalWell(Date date) {
        // 先删除
        abnormalWellService.deleteByDate(date);
        abnormalDataSyncDao.syncAbnormalWell(date);
    }

    /**
     * 汇总单位异常井日度数据
     */
    @Transactional
    public void summaryAbnormalUnit(Date date) {
        // 先删除
        abnormalUnitService.deleteByDate(date);
        abnormalDataSyncDao.summaryAbnormalUnit(date, "unitcode");
        abnormalDataSyncDao.summaryAbnormalUnit(date, "unitcode_area");
        abnormalDataSyncDao.summaryAbnormalUnit(date, "unitcode_company");
        abnormalDataSyncDao.summaryAbnormalUnit(date, "unitcode_group");
    }
}
