|
|
@@ -0,0 +1,345 @@
|
|
|
+package com.kingdee.eas.hr.perf.handler.importService;
|
|
|
+
|
|
|
+import com.google.common.collect.Maps;
|
|
|
+import com.kingdee.bos.BOSException;
|
|
|
+import com.kingdee.bos.Context;
|
|
|
+import com.kingdee.eas.basedata.person.PersonInfo;
|
|
|
+import com.kingdee.eas.common.EASBizException;
|
|
|
+import com.kingdee.eas.framework.CoreBaseInfo;
|
|
|
+import com.kingdee.eas.util.app.DbUtil;
|
|
|
+import com.kingdee.jdbc.rowset.IRowSet;
|
|
|
+import com.kingdee.shr.base.syssetting.app.io.fileImport.BaseColumnInfo;
|
|
|
+import com.kingdee.shr.base.syssetting.app.io.fileImport.BaseRowInfo;
|
|
|
+import com.kingdee.shr.base.syssetting.app.io.fileImport.ImportException;
|
|
|
+import com.kingdee.shr.base.syssetting.context.SHRContext;
|
|
|
+import com.kingdee.shr.base.syssetting.exception.ShrWebBizException;
|
|
|
+import com.kingdee.shr.compensation.util.CmpSQLUtil;
|
|
|
+import com.kingdee.shr.perfweb.app.base.evalplan.*;
|
|
|
+import com.kingdee.shr.perfweb.app.base.perfmancescore.PerfScorLevelDefineCollection;
|
|
|
+import com.kingdee.shr.perfweb.app.base.perfmancescore.PerfScorLevelDefineFactory;
|
|
|
+import com.kingdee.shr.perfweb.app.base.perfmancescore.PerfScorLevelDefineInfo;
|
|
|
+import com.kingdee.shr.perfweb.app.exception.SHRPerfWebBizException;
|
|
|
+import com.kingdee.shr.perfweb.service.EvaResultSummaryFileService;
|
|
|
+import com.kingdee.shr.perfweb.util.EvaResultSumRevisionLogService;
|
|
|
+import com.kingdee.shr.perfweb.util.GetEntityInfoUtils;
|
|
|
+import com.kingdee.shr.perfweb.util.SHRPerfWebResourceUtil;
|
|
|
+import com.kingdee.shr.perfweb.utils.AESUtil;
|
|
|
+import com.kingdee.shr.perfweb.utils.PerfWorkFlowUtils;
|
|
|
+import com.kingdee.util.StringUtils;
|
|
|
+import org.apache.poi.ss.usermodel.CellStyle;
|
|
|
+import org.apache.poi.ss.usermodel.DataFormat;
|
|
|
+import org.apache.poi.ss.usermodel.DataValidationHelper;
|
|
|
+import org.apache.poi.ss.util.CellRangeAddressList;
|
|
|
+import org.apache.poi.xssf.usermodel.*;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.ui.ModelMap;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.net.URLDecoder;
|
|
|
+import java.sql.SQLException;
|
|
|
+import java.sql.Timestamp;
|
|
|
+import java.text.DecimalFormat;
|
|
|
+import java.util.Iterator;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
+
|
|
|
+/**
|
|
|
+ * description: EvaResultSummaryFileExService <br>
|
|
|
+ * date: 2025/10/15 10:09 <br>
|
|
|
+ * author: lhbj <br>
|
|
|
+ * version: 1.0 <br>
|
|
|
+ */
|
|
|
+public class EvaResultSummaryFileExService extends EvaResultSummaryFileService {
|
|
|
+ Map<String, Map<String, Object>> performanceLevel;
|
|
|
+ public EvaResultSummaryFileExService(){
|
|
|
+ this.performanceLevel=this.getPerformanceLevelByLevel();
|
|
|
+ }
|
|
|
+ private static Logger logger = LoggerFactory.getLogger(EvaResultSummaryFileExService.class);
|
|
|
+ protected void initFillColumn() {
|
|
|
+ super.initFillColumn();
|
|
|
+// this.fillColumn.add("ID");
|
|
|
+// this.fillColumn.add("pnumber");
|
|
|
+// this.fillColumn.add("pname");
|
|
|
+// this.fillColumn.add("hrOrgUnit");
|
|
|
+// this.fillColumn.add("positionName");
|
|
|
+// this.fillColumn.add("company");
|
|
|
+// this.fillColumn.add("department");
|
|
|
+// this.fillColumn.add("flowStatus");
|
|
|
+// this.fillColumn.add("sumScore");
|
|
|
+// this.fillColumn.add("gradeLevel");
|
|
|
+// this.fillColumn.add("reviseSumScore");
|
|
|
+// this.fillColumn.add("reviseGradeLevel");
|
|
|
+// this.fillColumn.add("reviseReason");
|
|
|
+// this.fillColumn.add("employeeType");
|
|
|
+
|
|
|
+ this.fillColumn.add("coefficient");
|
|
|
+ this.fillColumn.add("perCoefficient");
|
|
|
+ this.fillColumn.add("perMaxCoefficient");
|
|
|
+ this.fillColumn.add("perMinCoefficient");
|
|
|
+ }
|
|
|
+ public void completeGenerateExcel(Map<String, BaseColumnInfo> columnInfoMap, XSSFWorkbook wb, XSSFSheet sheet) {
|
|
|
+ String isNeedEmpty = this.getCustomParam("isNeedEmpty");
|
|
|
+ if ("1".equals(isNeedEmpty)) {
|
|
|
+ int beginRow = 4;
|
|
|
+ int i = beginRow;
|
|
|
+ short row_heigth = 300;
|
|
|
+ Map<Integer, String> columnIndexFn = this.getColumnIndexFn(columnInfoMap);
|
|
|
+ Set<Integer> keyNumSet = columnIndexFn.keySet();
|
|
|
+ DataFormat format = wb.createDataFormat();
|
|
|
+ CellStyle testStyle = wb.createCellStyle();
|
|
|
+ testStyle.setDataFormat(format.getFormat("@"));
|
|
|
+
|
|
|
+ for(int columnIndex = 0; columnIndex < columnInfoMap.size(); ++columnIndex) {
|
|
|
+ sheet.setDefaultColumnStyle(columnIndex, testStyle);
|
|
|
+ }
|
|
|
+
|
|
|
+ String sql = this.buildQuerySql();
|
|
|
+ System.out.println("buildQuerySql2:"+sql);
|
|
|
+ if (!StringUtils.isEmpty(sql)) {
|
|
|
+ String perfScoreLevelId = null;
|
|
|
+
|
|
|
+ try {
|
|
|
+ IRowSet rs = CmpSQLUtil.executeQuery(this.getContext(), sql);
|
|
|
+
|
|
|
+ for(DecimalFormat df = new DecimalFormat("#.##"); rs.next(); ++i) {
|
|
|
+ if (perfScoreLevelId == null) {
|
|
|
+ perfScoreLevelId = rs.getString("perfScorLevel");
|
|
|
+ }
|
|
|
+
|
|
|
+ XSSFRow row = sheet.createRow(i);
|
|
|
+ row.setHeight(row_heigth);
|
|
|
+
|
|
|
+ String value;
|
|
|
+ XSSFCell cell;
|
|
|
+ for(Iterator var20 = keyNumSet.iterator(); var20.hasNext(); cell.setCellValue(value)) {
|
|
|
+ int columnIndex = (Integer)var20.next();
|
|
|
+ cell = row.createCell(columnIndex);
|
|
|
+ String propName = (String)columnIndexFn.get(columnIndex);
|
|
|
+ value = rs.getString(propName);
|
|
|
+ if ("flowStatus".equals(propName) && !StringUtils.isEmpty(value)) {
|
|
|
+ PerfEvaObjectWFStatusEnum wFStatusEnum = PerfEvaObjectWFStatusEnum.getEnum(Integer.valueOf(value));
|
|
|
+ if (null != wFStatusEnum) {
|
|
|
+ value = wFStatusEnum.getAlias();
|
|
|
+ }
|
|
|
+ } else if (("reviseSumScore".equals(propName) || "sumScore".equals(propName)) && !StringUtils.isEmpty(value)) {
|
|
|
+ value = df.format(Float.valueOf(value));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!StringUtils.isEmpty(perfScoreLevelId)) {
|
|
|
+ int reviseGradeIndex = -1;
|
|
|
+ Iterator var31 = keyNumSet.iterator();
|
|
|
+
|
|
|
+ while(var31.hasNext()) {
|
|
|
+ Integer index = (Integer)var31.next();
|
|
|
+ if ("reviseGradeLevel".equals(columnIndexFn.get(index))) {
|
|
|
+ reviseGradeIndex = index;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (reviseGradeIndex > 0) {
|
|
|
+ PerfScorLevelDefineCollection levelColl = PerfScorLevelDefineFactory.getRemoteInstance().getPerfScorLevelDefineCollection("select perfLevelName where perfScoreLevel='" + perfScoreLevelId + "' order by perfLevelName");
|
|
|
+ if (!levelColl.isEmpty()) {
|
|
|
+ DataValidationHelper dataValidationHelper = sheet.getDataValidationHelper();
|
|
|
+ String[] validata = new String[levelColl.size()];
|
|
|
+
|
|
|
+ for(i = 0; i < levelColl.size(); ++i) {
|
|
|
+ validata[i] = levelColl.get(i).getString("perfLevelName");
|
|
|
+ }
|
|
|
+
|
|
|
+ XSSFDataValidationConstraint dvConstraint = (XSSFDataValidationConstraint)dataValidationHelper.createExplicitListConstraint(validata);
|
|
|
+ CellRangeAddressList addressList = new CellRangeAddressList(beginRow, 500, reviseGradeIndex, reviseGradeIndex);
|
|
|
+ XSSFDataValidation validation = (XSSFDataValidation)dataValidationHelper.createValidation(dvConstraint, addressList);
|
|
|
+ sheet.addValidationData(validation);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (BOSException var27) {
|
|
|
+ logger.error("", var27);
|
|
|
+ throw new ImportException(new SHRPerfWebBizException(SHRPerfWebBizException.SYSTEMERROCCURED));
|
|
|
+ } catch (SQLException var28) {
|
|
|
+ logger.error("", var28);
|
|
|
+ throw new ImportException(new SHRPerfWebBizException(SHRPerfWebBizException.SYSTEMERROCCURED));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ protected void importUpdateOnly(BaseRowInfo row) throws ImportException {
|
|
|
+ CoreBaseInfo coreBaseInfo = this.transRowToObejct(row);
|
|
|
+ Context ctx = this.getContext();
|
|
|
+
|
|
|
+ try {
|
|
|
+ Map<String, Map<String, Object>> performanceLevel = this.getPerformanceLevelByLevel();
|
|
|
+ String id = coreBaseInfo.getString("ID");
|
|
|
+ IEvaResultSummary iEvaResultSummary = EvaResultSummaryFactory.getLocalInstance(ctx);
|
|
|
+ EvaResultSummaryInfo evaResultSummaryInfo = GetEntityInfoUtils.getEvaResultSummaryInfoById(ctx, id);
|
|
|
+ String reviseScore = null;
|
|
|
+ String sumScore = null;
|
|
|
+ EvaResultSummaryInfo old = GetEntityInfoUtils.getEvaResultSummaryInfoById(ctx, id);
|
|
|
+ reviseScore = old.get("reviseSumScore") == null ? null : old.get("reviseSumScore").toString();
|
|
|
+ sumScore = old.get("sumScore") == null ? null : old.get("sumScore").toString();
|
|
|
+ String reviseLevel = old.getReviseGradeLevel();
|
|
|
+
|
|
|
+ try {
|
|
|
+ if (reviseScore == null) {
|
|
|
+ reviseScore = sumScore;
|
|
|
+ reviseLevel = old.getGradeLevel();
|
|
|
+ }
|
|
|
+ } catch (Exception var14) {
|
|
|
+ logger.error(var14.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (null != coreBaseInfo.getString("reviseSumScore")) {
|
|
|
+ evaResultSummaryInfo.put("reviseSumScore", (double)coreBaseInfo.getFloat("reviseSumScore"));
|
|
|
+ } else {
|
|
|
+ evaResultSummaryInfo.put("reviseSumScore", (Object)null);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (null != coreBaseInfo.getString("reviseGradeLevel")) {
|
|
|
+ evaResultSummaryInfo.setReviseGradeLevel(coreBaseInfo.getString("reviseGradeLevel"));
|
|
|
+ } else {
|
|
|
+ evaResultSummaryInfo.put("reviseGradeLevel", (Object)null);
|
|
|
+ }
|
|
|
+
|
|
|
+ evaResultSummaryInfo.setReviseReason(coreBaseInfo.getString("reviseReason"));
|
|
|
+ if (null != evaResultSummaryInfo.getEvaObj()) {
|
|
|
+ try {
|
|
|
+ PerfScorLevelDefineInfo scoreLevelDefineInfo = PerfWorkFlowUtils.getPerfScoreLevelDefineInfo(ctx, evaResultSummaryInfo.getEvaObj().getId().toString(), evaResultSummaryInfo.getReviseGradeLevel());
|
|
|
+ if (null != scoreLevelDefineInfo && null != scoreLevelDefineInfo.getId()) {
|
|
|
+ evaResultSummaryInfo.put("perfScorLevelDefine", scoreLevelDefineInfo.getId().toString());
|
|
|
+ }
|
|
|
+ } catch (BOSException var13) {
|
|
|
+ logger.error("", var13);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //绩效系数
|
|
|
+ if (null != coreBaseInfo.getBigDecimal("perCoefficient")) {
|
|
|
+ BigDecimal perCoefficient = coreBaseInfo.getBigDecimal("perCoefficient");
|
|
|
+ String reviseGradeLevel = coreBaseInfo.getString("gradeLevel");
|
|
|
+ if (null != coreBaseInfo.getString("reviseGradeLevel")) {
|
|
|
+ reviseGradeLevel= coreBaseInfo.getString("reviseGradeLevel");
|
|
|
+ }
|
|
|
+ Map<String, Object> pLevel=performanceLevel.get(reviseGradeLevel);
|
|
|
+ BigDecimal coefficient = (BigDecimal) pLevel.get("coefficient");
|
|
|
+ BigDecimal maxcoefficient = (BigDecimal) pLevel.get("maxcoefficient");
|
|
|
+ BigDecimal mincoefficient = (BigDecimal) pLevel.get("mincoefficient");
|
|
|
+ if(!(perCoefficient.compareTo(maxcoefficient)<=0&&perCoefficient.compareTo(mincoefficient)>=0)){
|
|
|
+ throw new ImportException("所修改的绩效系数" + perCoefficient.toPlainString() + ",大于最大绩效系数" + maxcoefficient.toPlainString() + "或者小于最小绩效系数" + mincoefficient.toPlainString() + "!");
|
|
|
+ }else {
|
|
|
+ evaResultSummaryInfo.put("coefficient",coefficient);
|
|
|
+ evaResultSummaryInfo.put("perCoefficient",perCoefficient);
|
|
|
+ evaResultSummaryInfo.put("perMaxCoefficient",maxcoefficient);
|
|
|
+ evaResultSummaryInfo.put("perMinCoefficient",mincoefficient);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ evaResultSummaryInfo.setCalibrationTime((Timestamp)null);
|
|
|
+ evaResultSummaryInfo.setCalibrater((PersonInfo)null);
|
|
|
+ evaResultSummaryInfo.setCalibrationStatus(CalibrationStatusEnum.UNCALIBRATED);
|
|
|
+ iEvaResultSummary.save(evaResultSummaryInfo);
|
|
|
+ if (evaResultSummaryInfo != null && evaResultSummaryInfo != null && evaResultSummaryInfo.getEvaObj() != null) {
|
|
|
+ try {
|
|
|
+ EvaResultSumRevisionLogService evaResultSumRevisionLogService = new EvaResultSumRevisionLogService();
|
|
|
+ evaResultSumRevisionLogService.generatedEvaResultSumRevisionLog(ctx, EvaResultSumLogSourceEnum.IMPORTREVISION, evaResultSummaryInfo, reviseScore, reviseLevel);
|
|
|
+ } catch (Exception var12) {
|
|
|
+ logger.error(var12.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (BOSException var15) {
|
|
|
+ logger.error("", var15);
|
|
|
+ } catch (EASBizException var16) {
|
|
|
+ logger.error("", var16);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ protected String buildQuerySql() {
|
|
|
+ Context ctx = this.getContext();
|
|
|
+ String encryptDynamicSql = this.getCustomParam("dynamicSql");
|
|
|
+ String dynamicSql = "";
|
|
|
+ if (StringUtils.isEmpty(encryptDynamicSql)) {
|
|
|
+ System.out.println("dynamicSql1:"+dynamicSql);
|
|
|
+ return dynamicSql;
|
|
|
+ } else {
|
|
|
+ try {
|
|
|
+ logger.error("encryptDynamicSql: " + encryptDynamicSql);
|
|
|
+ String decodeStr = URLDecoder.decode(encryptDynamicSql, "UTF-8");
|
|
|
+ logger.error("decodeStr: " + decodeStr);
|
|
|
+ dynamicSql = AESUtil.decryptToString(decodeStr, "EvaResultSummaryQuery");
|
|
|
+ System.out.println("dynamicSql2:"+dynamicSql);
|
|
|
+ } catch (Exception var11) {
|
|
|
+ logger.error("【PERFWEB-EvaResultSummaryFileService#buildQuerySql】it's fail to build the export sql!");
|
|
|
+ logger.error("", var11);
|
|
|
+ System.out.println("dynamicSql3:"+dynamicSql);
|
|
|
+ return dynamicSql;
|
|
|
+ }
|
|
|
+
|
|
|
+ int fromIndex = dynamicSql.indexOf("FROM", 0);
|
|
|
+ int orderIndex = dynamicSql.indexOf("ORDER", 0);
|
|
|
+ String fromToOrder = dynamicSql.substring(fromIndex - 1, orderIndex);
|
|
|
+ String orderToLast = dynamicSql.substring(orderIndex - 1, dynamicSql.length());
|
|
|
+ StringBuilder sql = new StringBuilder();
|
|
|
+ String mlFlag = SHRPerfWebResourceUtil.getMlFlag(ctx);
|
|
|
+ sql.append("SELECT ").append("\"EVARESULTSUMMARY\".FID AS \"ID\",")
|
|
|
+ .append("\"EVARESULTSUMMARY\".FPnumber AS \"pnumber\",")
|
|
|
+ .append("\"PERSON\".FName" + mlFlag + " AS \"pname\",")
|
|
|
+ .append("\"HRORGUNIT\".FName" + mlFlag + " AS \"hrOrgUnit\",")
|
|
|
+ .append("\"POSITION\".FName" + mlFlag + " AS \"positionName\",")
|
|
|
+ .append("\"COMPANY\".FName" + mlFlag + " AS \"company\",")
|
|
|
+ .append("\"DEPARTMENT\".FName" + mlFlag + " AS \"department\",")
|
|
|
+ .append("\"EVAOBJ\".FWorkFlowStatus AS \"flowStatus\",")
|
|
|
+ .append("\"EVARESULTSUMMARY\".FSumScore AS \"sumScore\",")
|
|
|
+ .append("\"EVARESULTSUMMARY\".FGradeLevel AS \"gradeLevel\",")
|
|
|
+ .append("\"EVARESULTSUMMARY\".FReviseSumScore AS \"reviseSumScore\",")
|
|
|
+ .append("\"EVARESULTSUMMARY\".FReviseGradeLevel AS \"reviseGradeLevel\",")
|
|
|
+ .append("\"EVARESULTSUMMARY\".FReviseReason AS \"reviseReason\",")
|
|
|
+
|
|
|
+ .append("\"EVARESULTSUMMARY\".CFcoefficient AS \"coefficient\",")
|
|
|
+ .append("\"EVARESULTSUMMARY\".CFperCoefficient AS \"perCoefficient\",")
|
|
|
+ .append("\"EVARESULTSUMMARY\".CFperMaxCoefficient AS \"perMaxCoefficient\",")
|
|
|
+ .append("\"EVARESULTSUMMARY\".CFperMinCoefficient AS \"perMinCoefficient\",")
|
|
|
+
|
|
|
+ .append("\"EMPLOYEETYPE\".FName" + mlFlag + " AS \"employeeType\",")
|
|
|
+ .append("\"EVARESULTSUMMARY\".FPerfScorLevelID AS \"perfScorLevel\" ").append(fromToOrder);
|
|
|
+ String selectIds = this.getCustomParam("selectIds");
|
|
|
+ if (!StringUtils.isEmpty(selectIds)) {
|
|
|
+ sql.append(" and \"EVARESULTSUMMARY\".FID in('" + selectIds.replace(",", "','") + "') ");
|
|
|
+ }
|
|
|
+ sql.append(" and \"EVARESULTSUMMARY\".FBillState <> '3'");
|
|
|
+ sql.append(" ORDER BY ").append("\"ADMINORGUNIT\".FSortCode ASC,").append("\"ADMINORGUNIT\".FLongNumber ASC,").append("\"POSITION\".FIndex ASC,").append("\"POSITION\".FNumber ASC,").append("\"PERSON\".FIndex ASC,").append("\"PERSON\".FNumber ASC");
|
|
|
+ System.out.println("buildQuerySql4:"+sql);
|
|
|
+ return sql.toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public Map<String, Map<String, Object>> getPerformanceLevelByLevel() throws ImportException {
|
|
|
+
|
|
|
+ Map<String, Map<String, Object>> result = Maps.newHashMap();
|
|
|
+ try {
|
|
|
+ Context ctx = SHRContext.getInstance().getContext();
|
|
|
+ String sql = "select CFLEVEL,CFCOEFFICIENT,CFMAXCOEFFICIENT,CFMINCOEFFICIENT from CT_PER_PerformanceLevel ";
|
|
|
+ IRowSet rs = DbUtil.executeQuery(ctx, sql.toString());
|
|
|
+ while (rs.next()) {
|
|
|
+ Map<String, Object> map = Maps.newHashMap();
|
|
|
+ String CFLEVEL = rs.getString("CFLEVEL");
|
|
|
+ BigDecimal CFCOEFFICIENT = rs.getBigDecimal("CFCOEFFICIENT");
|
|
|
+ BigDecimal CFMAXCOEFFICIENT = rs.getBigDecimal("CFMAXCOEFFICIENT");
|
|
|
+ BigDecimal CFMINCOEFFICIENT = rs.getBigDecimal("CFMINCOEFFICIENT");
|
|
|
+ map.put("level", CFLEVEL);
|
|
|
+ map.put("coefficient", CFCOEFFICIENT);
|
|
|
+ map.put("maxcoefficient", CFMAXCOEFFICIENT);
|
|
|
+ map.put("mincoefficient", CFMINCOEFFICIENT);
|
|
|
+ result.put(CFLEVEL, map);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ throw new ImportException(e.getMessage());
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+}
|