package com.steering.mes.mcp.heatTreatment;

import CoreFS.SA06.CoreReturnObject;
import CoreFS.SA08.CoreXmlSqlParsersFactory;
import CoreFS.SC01.CoreConstantData;
import com.steering.comm.converter.EntityTool;
import com.steering.comm.db.DBCommon;
import com.steering.mes.mcp.entity.HttAppearancecheckRecordEntity;

import java.sql.Connection;
import java.sql.SQLException;

public class HttAppearancecheckRecordService extends DBCommon {

    public CoreReturnObject getHttAppearancecheckRecord(String resultNo ) {
        Object[] params = new Object[] { resultNo  };
        String sql=CoreXmlSqlParsersFactory
                .getSql("HttAppearancecheckRecordService.getHttAppearancecheckRecord");
        if(resultNo!=null&&!resultNo.equals("")){
            sql+="AND T.RESULT_NO='"+resultNo+"'";
        }
        return this.getData(sql);
    }






    public CoreReturnObject addHttAppearancecheckRecord(String json) throws SQLException {

        HttAppearancecheckRecordEntity httAppearancecheckRecordEntity = EntityTool.getEntityByJSONStr(json, HttAppearancecheckRecordEntity.class);
        if(httAppearancecheckRecordEntity.getRecordNo()==null||httAppearancecheckRecordEntity.getRecordNo().equals("")){
            String sql1=CoreXmlSqlParsersFactory
                    .getSql("HttAppearancecheckRecordService.addHttAppearancecheckRecord");
            sql1=  EntityTool.fillSqlByEntity(sql1,httAppearancecheckRecordEntity);
            return this.setData(sql1);

        }else{
            String sql = CoreXmlSqlParsersFactory
                    .getSql("HttAppearancecheckRecordService.updateHttAppearancecheckRecord");
            if(httAppearancecheckRecordEntity.getRecordNo()!=null&&!httAppearancecheckRecordEntity.getRecordNo().equals("")){
                sql+=" AND T.RECORD_NO='"+httAppearancecheckRecordEntity.getRecordNo()+"'";
                sql=  EntityTool.fillSqlByEntity(sql,httAppearancecheckRecordEntity);
            }
            return this.setData(sql);
        }
    }
}
