package com.app.hxqh.udreport;

import psdi.app.workorder.WO;
import psdi.app.workorder.WOSet;
import psdi.mbo.Mbo;
import psdi.mbo.MboRemote;
import psdi.mbo.MboSet;
import psdi.mbo.MboSetRemote;
import psdi.util.MXException;
import psdi.webclient.system.controller.WebClientEvent;

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

/**
 * 缺陷管理Mbo
 */
public class UdReportMbo extends Mbo implements MboRemote {

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

    @Override
    public void init() throws MXException {
        super.init();
        try {
            String status = getString("STATUS");
            String[] mainFields = new String[] {"LOCATION","ASSETNUM","MAJOR","FAILURECODE","DEFETYPE","HDONGROUP","HDDEPT","RESDEPT","ISZZXQ","ISBBZ","DESCRIPTION","PROBLEMCODE","FAULTCAUSE","REMEDY"};
            if("EDIT".equalsIgnoreCase(status)){
                setFlag(7L, false);
            }
            if("INPRG".equalsIgnoreCase(status) || "COMP".equalsIgnoreCase(status) || "CAN".equalsIgnoreCase(status)){
                setFieldFlag(mainFields, 7L, true);
            }
        } catch (RemoteException e) {
            e.printStackTrace();
        }

    }

    @Override
    public void save() throws MXException, RemoteException {
        super.save();
        String app = getThisMboSet().getApp();
//        if ("UDREPORT".equalsIgnoreCase(app) ) {//缺陷管理
            String status=getString("STATUS");
//            if("COMP".equalsIgnoreCase(status) && isModified()){
//                MboSetRemote woSet = getMboSet("$UDWORKORDER","UDWORKORDER","1=2");
//                MboRemote workorderMbo = woSet.addAtEnd(11L);
//                workorderMbo.setValue("CREATEBY", getString("CREATEBY"),11L);
//                workorderMbo.setValue("lead", getString("CREATEBY"),11L);
//                workorderMbo.setValue("description", "缺陷单"+getString("UDREPORTNUM"));
//                workorderMbo.setValue("STATUS", "EDIT",11L);
//                workorderMbo.setValue("ASSETNUM", getString("ASSETNUM"),11L);
//                workorderMbo.setValue("LOCATION", getString("LOCATION"),11L);
//                workorderMbo.setValue("HDDEPT", getString("HDDEPT"),11L);
//                workorderMbo.setValue("WOREQNUM", getString("UDREPORTNUM"),11L);
//                workorderMbo.setValue("GDLY", "UDREPORT",11L);
//                workorderMbo.setValue("FAILURECODE", getString("FAILURECODE"),11L);
//                workorderMbo.setValue("PROBLEMCODE", getString("PROBLEMCODE"),11L);
//                workorderMbo.setValue("FAULTCAUSE", getString("FAULTCAUSE"),11L);
//                workorderMbo.setValue("REMEDY", getString("REMEDY"),11L);
//                workorderMbo.setValue("APPNAME", "UDWORKORDER",11L);
//            }

//        }

    }

    @Override
    public void add() throws MXException, RemoteException {
        super.add();

    }

}
