package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.collect;

import cn.estsh.i3plus.ext.mes.pcn.api.busi.ISxThirdPartyDbCollectDataMethodService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.SxThirdPartyDbCollectDataModel;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class SxThirdPartyDbCollectDataMethodGetDateService implements ISxThirdPartyDbCollectDataMethodService {

    @Override
    public Object exec(SxThirdPartyDbCollectDataModel collect, Object obj) {
        try {
            BaseBean baseBean = (BaseBean) obj;
            return null != baseBean ? baseBean.getModifyDatetime() : TimeTool.getNowTime(true);
        } catch (Exception e) {
            throw new ImppBusiException(String.format("[%s]执行异常:%s", this.getClass().getSimpleName(), e.getMessage()));
        }
    }
}
