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.pss.pncost.entity.CostBasePriceEntity;;
public class ComBasePrice extends DBCommon{

    public CoreReturnObject query(String gang){
        String sql = CoreXmlSqlParsersFactory.getSql("ComBasePrice.query");
        if(!gang.equals("")){
            sql += " AND YEAR = '" + gang + "' where t.validflag='1'";
        }
        return this.getData(sql);
    }
    public CoreReturnObject queryPliao(){
        String sql = CoreXmlSqlParsersFactory.getSql("ComBasePrice.queryPliao");
        return this.getData("PmsDao", sql);
    }
    public CoreReturnObject queryNum(String gang,String hejin){
        String sql = CoreXmlSqlParsersFactory.getSql("ComBasePrice.queryNum");
        if(!gang.equals("")){
            sql += "AND ITEM_CODE = '" + gang + "'";
        }
        if(!hejin.equals("")){
            sql += "AND YEAR = '" + hejin + "'";
        }
        return this.getData(sql);
    }
    public CoreReturnObject isave(String strJSON){
        CostBasePriceEntity batching = EntityTool.getEntityByJSONStr(strJSON, CostBasePriceEntity.class);
        String sql = CoreXmlSqlParsersFactory.getSql("ComBasePrice.isave");
        sql = EntityTool.fillSqlByEntity(sql, batching);
        return this.setData(sql);
    }
    public CoreReturnObject usave(String strJSON,String hejin){
        CostBasePriceEntity batching = EntityTool.getEntityByJSONStr(strJSON, CostBasePriceEntity.class);
        String sql = CoreXmlSqlParsersFactory.getSql("ComBasePrice.usave");
        sql = EntityTool.fillSqlByEntity(sql, batching);
        sql += "AND YEAR = '" + hejin + "'";
        return this.setData(sql);
    }
    public CoreReturnObject delete(String strJSON){
        CostBasePriceEntity batching = EntityTool.getEntityByJSONStr(strJSON, CostBasePriceEntity.class);
        String sql = CoreXmlSqlParsersFactory.getSql("ComBasePrice.delete");
        sql = EntityTool.fillSqlByEntity(sql, batching);
        return this.setData(sql);
    }
    public CoreReturnObject resume(String strJSON){
        CostBasePriceEntity batching = EntityTool.getEntityByJSONStr(strJSON, CostBasePriceEntity.class);
        String sql = CoreXmlSqlParsersFactory.getSql("ComBasePrice.resume");
        sql = EntityTool.fillSqlByEntity(sql, batching);
        return this.setData(sql);
    }
}
