package com.skr.mdm.service.impl.reload.handler;

import com.skr.mdm.annotation.MdmReloadHandler;
import com.skr.mdm.bean.so.ReloadSO;
import com.skr.mdm.bean.so.content.ContentDocumentSO;
import com.skr.mdm.dao.ContentDocumentDao;
import com.skr.mdm.enums.StrategyEquipmentStateEnum;
import com.skr.mdm.service.impl.reload.ReloadHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @author nfq
 * @date 2022/06/10 14:53
 */
@MdmReloadHandler
@Slf4j
public class ContentDocumentReloadHandler implements ReloadHandler {

    @Autowired
    private ContentDocumentDao contentDocumentDao;

    @Override
    public void doHandler(ReloadSO reloadSO, Integer equipmentId) {
        try {
            List<ContentDocumentSO> contentDocumentSOList = contentDocumentDao.listContentByEquipmentId(equipmentId, StrategyEquipmentStateEnum.ISSUING.getState());
            reloadSO.setContentList(contentDocumentSOList);
        } catch (Exception e) {
            log.error("卸载重装文档异常：" + equipmentId, e);
        }
    }
}
