package psdi.webclient.beans.workorder;
        import com.coolservlets.beans.jdbc.MXConnection;
        import com.dbms.dbcon.DBCon;
        import com.dbms.dbcon.QueryResult;
        import com.dbms.dbcon.ResultRow;
        import psdi.mbo.MboSetRemote;
        import psdi.security.ConnectionKey;
        import psdi.server.MXServer;
        import psdi.util.MXException;
        import psdi.util.MXSession;
        import psdi.webclient.system.beans.DataBean;

        import java.rmi.RemoteException;
        import java.sql.Connection;

public class CustCMWorkorderAppBean extends WorkorderAppBean{
    public void initializeApp() throws MXException, RemoteException {
        super.initializeApp();
    }
    public void initialize() throws MXException, RemoteException
    {
        super.initialize();
    }
    /**
     * ±£´æÊý¾Ý 2018-6-8 ÐÞ¸Ä
     */
    public int SAVE()throws MXException, RemoteException{
        super.SAVE();
        return 1;
    }
    public int INSERT() throws MXException, RemoteException {
        super.INSERT();
        String sPersonid = getMbo().getUserInfo().getPersonId();
        sPersonid =(sPersonid == null) ?"":sPersonid.trim();
        sPersonid = sPersonid.toUpperCase();
        setValue("reportedby", getMbo().getUserInfo().getUserName(),11L);
        setValue("WO18", getMbo().getUserInfo().getUserName(),11L);
        setValue("lead", getMbo().getUserInfo().getUserName(),11L);
        setValue("worktype", "CM", 11L);
        getMbo().setFieldFlag("reportedby",7L,true);
        getMbo().setFieldFlag("WO18",7L,true);
        ConnectionKey connectionKey = getMbo().getUserInfo().getConnectionKey();
        String LaborDept[] = null;
        try {
            MboSetRemote nPersonSets = getMbo().getMboSet("$PERSON_TEMP","PERSON");
            nPersonSets.setWhere("PERSONID ='" + sPersonid + "'");
            nPersonSets.reset();
            if(nPersonSets != null){
                if(!nPersonSets.isEmpty()){
                    String deptnum = nPersonSets.getMbo(0).getString("DEPARTMENT");
                    deptnum =(deptnum == null)?"":deptnum.trim();
                    String supervisor = nPersonSets.getMbo(0).getString("SUPERVISOR");
                    supervisor =(supervisor == null)?"":supervisor.trim();
                    setValue("HDDEPT", deptnum,11L);
                    setValue("HDONGROUP", deptnum,11L);
                    setValue("supervisor", supervisor,11L);
                    getMbo().setFieldFlag("HDDEPT",7L,true);
                    getMbo().setFieldFlag("HDONGROUP",7L,true);
                }
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return 1;
    }
}
