package com.engine.htsc.duban.cmd;

import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.User;
import java.util.HashMap;
import java.util.Map;

public class DbsxDeleteCmd extends AbstractCommonCommand<Map<String, Object>> {
    @Override
    public BizLogContext getLogContext() {
        return null;
    }

    public DbsxDeleteCmd(Map<String, Object> params, User user) {
        this.params = params;
        this.user = user;
    }
    @Override
    public Map<String, Object> execute(CommandContext commandContext) {
        RecordSet rs = new RecordSet();
        Map<String, Object> appdate = new HashMap<String, Object>();
        try{
            int flag = 0;
            String billid = Util.null2String(params.get("billid"));
            if(!"".equals(billid))
            {
                int count = 0;
                String sql = " select id from uf_rw where xzsy = "+billid +" and cjzt = 1";
                rs.execute(sql);
                if(rs.next()){
                    count++;
                }
                if(count > 0){
                    flag = -2;
                }else{
                    sql = "delete from uf_xzsx where id="+billid;
                    boolean bool = rs.executeUpdate(sql);
                    if(bool){
                        flag = 1;
                    }else{
                        flag = -1;
                    }
                }
            }
            appdate.put("data",flag+"");
        }catch (Exception e){
            e.printStackTrace();
        }
        return appdate;
    }
}
