package cn.hnthyy.thmz.service.impl.his.zy;

import cn.hnthyy.thmz.mapper.his.zy.ZyDayclosingRecordMapper;
import cn.hnthyy.thmz.service.his.zy.ZyDayclosingRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

@Service
public class ZyDayclosingRecordServiceImpl implements ZyDayclosingRecordService {
    @SuppressWarnings("all")
    @Autowired
    private ZyDayclosingRecordMapper zyDayclosingRecordMapper;


    @Override
    @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
    public void dayclosing() {
        Date lastCloseDate = zyDayclosingRecordMapper.selectLastCloseDate();
        Date closeDate = new Date();
        zyDayclosingRecordMapper.insertZyDayclosingRecord(closeDate, lastCloseDate);
        zyDayclosingRecordMapper.updateZyLedgerFile(closeDate, lastCloseDate);

    }
}
