/*     */ package com.kingdee.shr.recuritment.util;
/*     */ 
/*     */ import com.kingdee.bos.BOSException;
/*     */ import com.kingdee.bos.Context;
/*     */ import com.kingdee.bos.ctrl.kdf.data.datasource.BOSQueryDataSource;
/*     */ import com.kingdee.bos.ctrl.kdf.data.datasource.DSParam;
/*     */ import com.kingdee.bos.dao.query.IQueryExecutor;
/*     */ import com.kingdee.bos.dao.query.QueryExecutorFactory;
/*     */ import com.kingdee.bos.metadata.IMetaDataPK;
/*     */ import com.kingdee.bos.metadata.MetaDataPK;
/*     */ import com.kingdee.bos.metadata.entity.EntityViewInfo;
/*     */ import com.kingdee.bos.metadata.entity.FilterInfo;
/*     */ import com.kingdee.bos.metadata.entity.FilterItemInfo;
/*     */ import com.kingdee.bos.metadata.query.util.CompareType;
/*     */ import com.kingdee.eas.hr.emp.PrintMetaConfigCollection;
/*     */ import com.kingdee.eas.hr.emp.PrintMetaConfigFactory;
/*     */ import com.kingdee.eas.hr.emp.PrintMetaConfigInfo;
/*     */ import com.kingdee.jdbc.rowset.IRowSet;
/*     */ import com.kingdee.shr.base.syssetting.context.SHRContext;
/*     */ import com.kingdee.shr.component.report.CommonDataProvider;
/*     */ import com.kingdee.shr.recuritment.RecRegisterCollection;
/*     */ import com.kingdee.shr.recuritment.RecRegisterFactory;
/*     */ import com.kingdee.shr.recuritment.app.util.db.RecDBUtils;
/*     */ import com.kingdee.ws.ca.utils.StringUtils;
/*     */ import java.sql.ResultSetMetaData;
/*     */ import java.sql.SQLException;
/*     */ import java.util.ArrayList;
/*     */ import java.util.List;
/*     */ import org.apache.log4j.Logger;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class InterviewResultPrintHelpDataProvider1 extends CommonDataProvider {
/*     */    private static Logger logger = Logger.getLogger(InterviewResultPrintHelpDataProvider1.class);
/*     */    private String billId;
/*     */    private String queryPK = null;
/*     */ 
/*     */    public InterviewResultPrintHelpDataProvider1(String billId) {
/*  47 */       this.billId = billId;
/*  48 */    }
/*     */ 
/*     */ 
/*     */    public InterviewResultPrintHelpDataProvider1() {
/*  52 */    }
/*     */ 
/*     */    public InterviewResultPrintHelpDataProvider1(String billId, String queryPK) {
/*  55 */       this.billId = billId;
/*  56 */       this.queryPK = queryPK;
/*  57 */    }
/*     */ 
/*     */    public IRowSet execute(BOSQueryDataSource ds) {
				if(null == ctx) {
		/*  60 */       Context ctx = SHRContext.getInstance().getContext();
				}
/*  61 */       IRowSet iRowSet = null;
/*  62 */       String str_ds = ds.getID();
/*  63 */       if ("RecRegisterPersonBaseQuery".equals(str_ds)) {
/*     */          try {
/*  65 */             RecRegisterCollection coll = RecRegisterFactory.getLocalInstance(ctx).getRecRegisterCollection("WHERE resumeBaseRec in ( SELECT FResumeBaseRecID FROM T_REC_InterviewResult WHERE FID = '" + this.billId + "')");
/*     */ 
/*  67 */             if (coll.size() > 0 && coll.get(0).getTalent() != null) {
/*  68 */                this.billId = coll.get(0).getTalent().getId().toString();
/*     */             }
/*  70 */          } catch (BOSException var15) {
/*  71 */             logger.error(var15.getMessage(), var15);
/*     */          }      }
/*     */ 
/*     */       try {
/*  75 */          String sql = "select * where dynamicQueryName = '" + str_ds + "'";
/*  76 */          PrintMetaConfigInfo printMetaConfigInfo = null;
/*  77 */          PrintMetaConfigCollection coll = PrintMetaConfigFactory.getLocalInstance(ctx).getPrintMetaConfigCollection(sql);
/*  78 */          if (coll == null || coll.size() < 1) {
/*  79 */             return iRowSet;
/*     */          }
/*  81 */          printMetaConfigInfo = coll.get(0);
/*     */ 
/*  83 */          IQueryExecutor exec = null;
/*  84 */          IMetaDataPK queryPK = new MetaDataPK(printMetaConfigInfo.getDynamicQueryPath());
					if(null == ctx) {
						ctx = SHRContext.getInstance().getContext();
					}
/*  85 */          exec = QueryExecutorFactory.getLocalInstance(ctx, queryPK);
/*  86 */          exec.option().isAutoTranslateEnum = true;
/*  87 */          EntityViewInfo ev = new EntityViewInfo();   
					FilterInfo  filter ;
/*  88 */          if (printMetaConfigInfo.getOtherDataFilterPattern() == null) {
/*  89 */             ArrayList paramList = ds.getParams();
/*  90 */             if (paramList != null && paramList.size() > 0) {
/*  91 */                DSParam dsParam = (DSParam)paramList.get(0);
/*  92 */                   filter = new FilterInfo();
/*  93 */                filter.getFilterItems().add(new FilterItemInfo(dsParam.getColName(), dsParam.getValue().toString(), CompareType.INCLUDE));
/*  94 */                ev.setFilter(filter);            
					 } else {             
/*  95 */                if (printMetaConfigInfo.getDataFilterPattern() != null) {
/*  96 */                   filter = new FilterInfo();
/*  97 */                   filter.getFilterItems().add(new FilterItemInfo(printMetaConfigInfo.getDataFilterPattern(), this.billId, CompareType.INCLUDE));
/*  98 */                   ev.setFilter(filter);
/*     */                } else {
/* 100 */                   filter = new FilterInfo();
/* 101 */                   filter.getFilterItems().add(new FilterItemInfo("id", this.billId, CompareType.INCLUDE));
/* 102 */                   ev.setFilter(filter);
/*     */                }            }
/*     */          } else {
/* 105 */             if (this.billId.contains(",")) {
/* 106 */                this.billId = this.billId.replaceAll(",", "','");
/*     */             }
/* 108 */             String filterSql = printMetaConfigInfo.getOtherDataFilterPattern();
/* 109 */             String fql = printMetaConfigInfo.getDataFilterPattern() + " in ('" + this.billId + "') " + filterSql;
/* 110 */             filter = new FilterInfo(fql);
/* 111 */             ev.setFilter(filter);
/*     */          }
/* 113 */          exec.setObjectView(ev);
/* 114 */          iRowSet = exec.executeQuery();
/* 115 */          iRowSet = otherSpecialHandling(ctx, ds, iRowSet, printMetaConfigInfo, this.billId);
/*     */ 
/* 117 */          if (logger.isDebugEnabled()) {
/* 118 */             logger.debug("******************************************test套打测试日志start***********************************");
/* 119 */             logger.debug("testID:" + str_ds);
/* 120 */             logger.debug("testSql:" + exec.getSQL());
/*     */          }
/* 122 */          ResultSetMetaData rsmd = iRowSet.getMetaData();
/* 123 */          int count = rsmd.getColumnCount();
/* 124 */          iRowSet.first();
/* 125 */          if (iRowSet != null && iRowSet.next()) {
/* 126 */             for(int i = 0; i < count; ++i) {
/* 127 */                String value = iRowSet.getObject(i + 1) == null ? "" : iRowSet.getObject(i + 1).toString();
/* 128 */                if (logger.isDebugEnabled()) {
/* 129 */                   logger.debug("testColumn:" + rsmd.getColumnName(i + 1) + "=(" + value + ")");
/*     */                }            }
/*     */          }
/*     */ 
/* 133 */          if (logger.isDebugEnabled()) {
/* 134 */             logger.debug("******************************************test套打测试日志start***********************************");
/*     */          }
/* 136 */       } catch (Exception var16) {
/* 137 */          logger.error(var16.getMessage(), var16);
/*     */       }
/* 139 */       return iRowSet;
/*     */    }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */    public static IRowSet otherSpecialHandling(Context ctx, BOSQueryDataSource ds, IRowSet iRowSet, PrintMetaConfigInfo printMetaConfigInfo, String billId) {
/* 147 */       String str_ds = ds.getID();
/* 148 */       if ("com.kingdee.shr.recuritment.app.InterviewPlanUseQuery".equals(printMetaConfigInfo.getDynamicQueryPath()) && iRowSet != null) {
/*     */ 
/* 150 */          iRowSet = getInterviewPlanDetailResult(ctx, printMetaConfigInfo, iRowSet, billId);
/*     */       }
/*     */ 
/* 153 */       return iRowSet;
/*     */    }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */    public static IRowSet getInterviewPlanDetailResult(Context ctx, PrintMetaConfigInfo printMetaConfigInfo, IRowSet iRowSet, String tempName) {
/* 162 */       IRowSet result = null;
/*     */       try {
/* 164 */          result = iRowSet.createCopy();         StringBuilder detailEvaluate;
/* 165 */          if (result != null) {
/* 166 */             for(; result.next(); result.updateString("detailEvaluate", detailEvaluate.toString())) {
/* 167 */                String interviewPlan = result.getString("id");
/*     */ 
/* 169 */                List<Object[]> datas = null;
/* 170 */                StringBuilder detailResult = new StringBuilder();
/* 171 */                String sql = "SELECT FInterviewerName,FResult,FScore,JOBGRADE.FName_l2 FJobGrade,FRemark from  T_REC_IPISDetailResult as RESULT LEFT OUTER JOIN T_HR_JobGrade AS JOBGRADE ON RESULT.FJobGradeId = JOBGRADE.FID WHERE FInterviewPlanId = ? and FSaveState = 0";
/*     */ 
/* 173 */                datas = RecDBUtils.getQueryData(ctx, sql, new Object[]{interviewPlan});          
/* 174 */                if (datas != null && datas.size() > 0) {
/* 175 */                   Object[] interviewResult = null;                  
/* 176 */                   for(int i = 0; i < datas.size(); ++i) {
/* 177 */                      interviewResult = (Object[])datas.get(i);
/* 178 */                      String FResult = "";
/* 179 */                      switch(Integer.parseInt((String)interviewResult[1])) {
/*     */                      case -1:
/* 181 */                         FResult = "待录入";
/*     */                         break;        
								case 3:
/* 184 */                         FResult = "通过";
/* 185 */                         break;
/*     */                      case 4:
/* 187 */                         FResult = "不通过";
/* 188 */                         break;
/*     */                      case 0:                     case 5:                     case 1:
/* 190 */                         FResult = "放弃面试";
/*     */                      case 2:
/*     */                      default:
/* 193 */                         FResult = "待录入";
/*     */                      }
/* 195 */                      detailResult.append(interviewResult[0]).append("(").append(FResult);
/* 196 */                      if (!StringUtils.isEmpty((String)interviewResult[2])) {
/* 197 */                         detailResult.append(" ").append(interviewResult[2]);
/*     */                      }
/* 199 */                      if (!StringUtils.isEmpty((String)interviewResult[3])) {
/* 200 */                         detailResult.append(" ").append(interviewResult[3]);
/*     */                      }
/* 202 */                      detailResult.append(")");
/* 203 */                      if (!StringUtils.isEmpty((String)interviewResult[4])) {
/* 204 */                         detailResult.append(": ").append(interviewResult[4]);
/*     */                      }
/* 206 */                      detailResult.append("\n");
/*     */                   }
/*     */                }
/*     */ 
/* 210 */                result.updateString("detailResult", detailResult.toString());
/*     */ 
/*     */ 
/* 213 */                detailEvaluate = new StringBuilder();
/* 214 */                sql = "SELECT FInterviewerName,FResult,FRemark from  T_REC_IPISDetailEvaluate WHERE FInterviewPlanId = ? and FSaveState = 0";
/* 215 */                datas = RecDBUtils.getQueryData(ctx, sql, new Object[]{interviewPlan});
/* 216 */                if (datas != null && datas.size() > 0) {
/* 217 */                   Object[] evaluateResult = null;                 
/* 218 */                   for(int i=0;   i < datas.size(); ++i) {
/* 219 */                      evaluateResult = (Object[])datas.get(i);
/* 220 */                      detailEvaluate.append(evaluateResult[0]);
/* 221 */                      if (!StringUtils.isEmpty((String)evaluateResult[1])) {
/* 222 */                         detailEvaluate.append("(").append(evaluateResult[1]).append(")");
/*     */                      }
/* 224 */                      if (!StringUtils.isEmpty((String)evaluateResult[2])) {
/* 225 */                         detailEvaluate.append(": ").append(evaluateResult[2]);
/*     */                      }
/* 227 */                      detailEvaluate.append("\n");
/*     */ 
/*     */                   }
/*     */                }
/*     */             }
/*     */          }
/* 233 */       } catch (SQLException var13) {
/* 234 */          logger.error(var13.getMessage(), var13);
/* 235 */       } catch (BOSException var14) {
/* 236 */          logger.error(var14.getMessage(), var14);
/*     */       }
/* 238 */       return result;
/*     */    }
/*     */ }
