package com.app.hxqh.udsaistand;

import psdi.mbo.Mbo;
import psdi.mbo.MboRemote;
import psdi.mbo.MboSet;
import psdi.util.MXException;

import java.rmi.RemoteException;
import java.util.Date;

/**
 * 安全点检标准主表
 * edit 20240703
 */
public class UdSaistandMbo extends Mbo implements MboRemote {

    public UdSaistandMbo(MboSet ms) throws MXException, RemoteException {
        super(ms);
    }

    @Override
    public void add() throws MXException, RemoteException {
        super.add();
        setValue("UDSAISTANDNUM", getInt("UDSAISTANDID")+"",2L);
        setValue("STATUS", "EDIT",2L);
        setValue("STATUSTIME", new Date(),2L);
    }

    @Override
    public void init() throws MXException {
        super.init();
        try{
            String status = getString("STATUS");
            String[] mainFields = new String[] {"DESCRIPTION","REMARKS"};
            if(!"EDIT".equalsIgnoreCase(status) && !isNew()){
                setFieldFlag(mainFields, 7L, true);
                getMboSet("UDSAISTANDLINE").setFlag(7L, true);
            }
        }catch (Exception e){

        }
    }

    @Override
    public void save() throws MXException, RemoteException {
        super.save();
        if(isModified("STATUS")){
            setValue("STATUSTIME", new Date(), 2L);
        }
    }
}
