package com.aucma.dms.service.impl;

import com.aucma.dms.mapper.DmsPlanInspectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
 * 巡检计划事务隔离服务。
 * 单独使用 REQUIRES_NEW 推进计划时间，避免影响已提交的工单生成事务。
 */
@Service
public class DmsPlanInspectTxService {

    @Autowired
    private DmsPlanInspectMapper dmsPlanInspectMapper;

    @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
    public int updatePlanNextTimeInNewTx(Long planInspectId, Date nextTime) {
        // 单独新事务提交计划推进：
        // 该事务失败时，不影响已经成功提交的工单生成事务。
        return dmsPlanInspectMapper.updatePlanNextTime(planInspectId, nextTime);
    }
}
