package com.steering.pss.pncost.base;

import CoreFS.SA06.CoreReturnObject;
import CoreFS.SA08.CoreXmlSqlParsersFactory;

import com.steering.comm.db.DBCommon;
import com.steering.comm.tools.EntityTool;
import com.steering.comm.tools.SqlBuilder;
import com.steering.pss.pncost.entity.CostBaseProcesscostEntity;

public class ComBaseProcesscost extends DBCommon{

    public CoreReturnObject query2(String gang){
        String sql = CoreXmlSqlParsersFactory.getSql("ComBaseProcesscost.query");
        if(!gang.equals("")){
            sql += "AND PLINE_NAME like '%" + gang + "%'";
        }
        return this.getData(sql);
    }
    public CoreReturnObject query(String gang){
        SqlBuilder b = new SqlBuilder("ComBaseProcesscost.query");
        b.Fill(new String[]{gang});
        return this.getData(b.toString());
    }
    public CoreReturnObject isave(String strJSON){
        CostBaseProcesscostEntity batching = EntityTool.getEntityByJSONStr(strJSON, CostBaseProcesscostEntity.class);
        String sql = CoreXmlSqlParsersFactory.getSql("ComBaseProcesscost.isave");
        sql = EntityTool.fillSqlByEntity(sql, batching);
        return this.setData(sql);
    }
    public CoreReturnObject usave(String strJSON,String gang,String duan){
        CostBaseProcesscostEntity batching = EntityTool.getEntityByJSONStr(strJSON, CostBaseProcesscostEntity.class);
        String sql = CoreXmlSqlParsersFactory.getSql("ComBaseProcesscost.usave");
        sql = EntityTool.fillSqlByEntity(sql, batching);
        sql += "AND PLINE_CODE =  '" + gang + "'";
        sql += "AND YEAR =  '" + duan + "'";
        return this.setData(sql);
    }
    public CoreReturnObject delete(String strJSON){
        CostBaseProcesscostEntity batching = EntityTool.getEntityByJSONStr(strJSON, CostBaseProcesscostEntity.class);
        String sql = CoreXmlSqlParsersFactory.getSql("ComBaseProcesscost.delete");
        sql = EntityTool.fillSqlByEntity(sql, batching);
        return this.setData(sql);
    }
    public CoreReturnObject resume(String strJSON){
        CostBaseProcesscostEntity batching = EntityTool.getEntityByJSONStr(strJSON, CostBaseProcesscostEntity.class);
        String sql = CoreXmlSqlParsersFactory.getSql("ComBaseProcesscost.resume");
        sql = EntityTool.fillSqlByEntity(sql, batching);
        return this.setData(sql);
    }
    public CoreReturnObject querynum(String gang,String duan){
        String sql = CoreXmlSqlParsersFactory.getSql("ComBaseProcesscost.querynum");
        if(!gang.equals("")){
            sql += "AND PLINE_CODE = '" + gang + "'";
        }
        if(!duan.equals("")){
            sql += "AND YEAR = '" + duan + "'";
        }
        return this.getData(sql);
    }
    public CoreReturnObject queryMonthone(String gang){
        SqlBuilder b = new SqlBuilder("ComBaseProcesscost.queryMonthone");
        b.Fill(new String[]{gang});
        return this.getData(b.toString());
    }
    public CoreReturnObject queryprice(){
        String sql = CoreXmlSqlParsersFactory.getSql("ComBaseProcesscost.queryprice");
        
        return this.getData(sql);
    }
    public CoreReturnObject querydaxiao(){
        String sql = CoreXmlSqlParsersFactory.getSql("ComBaseProcesscost.querydaxiao");
        return this.getData(sql);
    }
    public CoreReturnObject queryjiage(String pline,String paichan){
        SqlBuilder b = new SqlBuilder("ComBaseProcesscost.queryjiage");
        b.Fill(new String[]{pline,paichan});
        return this.getData(b.toString());
    }
    public CoreReturnObject queryall(String gang){
        SqlBuilder b = new SqlBuilder("ComBaseProcesscost.queryall");
        b.Fill(new String[]{gang});
        return this.getData(b.toString());
    }
}
