| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741 |
- package com.kingdee.eas.hr.perf.handler;
- import cn.hutool.core.util.StrUtil;
- import com.alibaba.fastjson.JSON;
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- import com.google.common.collect.Maps;
- import com.google.common.collect.Sets;
- import com.kingdee.bos.BOSException;
- import com.kingdee.bos.Context;
- import com.kingdee.bos.rabbitmq.guava.Lists;
- import com.kingdee.eas.hr.perf.PerformProTeamCollection;
- import com.kingdee.eas.hr.perf.PerformProTeamFactory;
- import com.kingdee.eas.hr.perf.PersonPerformProCollection;
- import com.kingdee.eas.hr.perf.PersonPerformProFactory;
- import com.kingdee.eas.util.app.DbUtil;
- import com.kingdee.jdbc.rowset.IRowSet;
- import com.kingdee.shr.base.syssetting.api.bean.BatchMessageTipsBody;
- import com.kingdee.shr.base.syssetting.api.bean.BatchMessageTipsHeader;
- import com.kingdee.shr.base.syssetting.context.SHRContext;
- import com.kingdee.shr.base.syssetting.exception.SHRWebException;
- import com.kingdee.shr.base.syssetting.exception.ShrWebBizException;
- import com.kingdee.shr.perfweb.app.exception.SHRPerfWebBizException;
- import com.kingdee.shr.perfweb.planexecute.handler.EvaresultAuditBillEntryListHandler;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.ui.ModelMap;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import java.math.BigDecimal;
- import java.sql.SQLException;
- import java.util.*;
- /**
- * description: EvaresultAuditBillEntryListHandler <br>
- * date: 2025/6/24 12:48 <br>
- * author: lhbj <br>
- * version: 1.0 <br>
- */
- public class EvaresultAuditBillEntryListHandlerEx extends EvaresultAuditBillEntryListHandler {
- /**
- [{"evaResult.pnumber":"0000381","evaResult.pname":"谭梓傲","evaResult.positionName":"物资岗","evaResult.evaObj.perfFile.adminOrgUnit.company.name":"湖南红太阳光电科技有限公司","evaResult.evaObj.perfFile.adminOrgUnit.department.name":"综合管理","evaResult.sumScore":"<span></span>","evaResult.gradeLevel":"","evaResult.auditSumScore":"<span value=\\"86\\">86.00</span>","evaResult.auditGradeLevel":"C","evaResult.auditReason":"<div class=\\"cell-height scrollbarthin\\">正态分布更新结果</div>","evaResult.reviseSumScore":"<span value=\\"86\\">86.00</span>","evaResult.reviseGradeLevel":"C","evaResult.reviseReason":"正态分布更新结果","id":"KQukJy27Skiy1rPPghjkJBdK16Q=","evaResult.id":"Ka7FkRQuTAaPlTaLvJSD3IESG3Q=","bill.id":"m85zTeeDSmaAU2QLbYWMUoZLdW4=","evaResult.evaObj.id":"gjX3giS2RKurkJVjPhnwa4GI54s=","reviseGradeLevelSelect":"[{\\"value\\":\\"S\\",\\"alias\\":\\"S\\"},{\\"value\\":\\"A\\",\\"alias\\":\\"A\\"},{\\"value\\":\\"B\\",\\"alias\\":\\"B\\"},{\\"value\\":\\"C\\",\\"alias\\":\\"C\\"},{\\"value\\":\\"D\\",\\"alias\\":\\"D\\"}]","levelScoreKVInfo":"{\\n \\"90.00~100.00\\": \\"S\\",\\n \\"80.00~90.00\\": \\"A\\",\\n \\"70.00~80.00\\": \\"B\\",\\n \\"60.00~70.00\\": \\"C\\",\\n \\"0.00~60.00\\": \\"D\\"\\n}","scoreLowLimit":"0","scoreUpLimit":"100","evaResult.period.id":"q6myAjHaQLK+wnczfdLCJEUaiOU=","evaResult.reviseFlag":"是","evaResult.auditFlag":"否"}]
- * @param request
- * @param response
- * @param modelMap
- * @throws SHRWebException
- */
- public void verifyBeforeSubmitAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws SHRWebException {
- String entryData = request.getParameter("entryData");
- BatchMessageTipsHeader header = new BatchMessageTipsHeader();
- boolean isExists = true;
- if (!com.kingdee.util.StringUtils.isEmpty(entryData)) {
- int success = 0;
- int fail = 0;
- StringBuilder ids = new StringBuilder();
- List<String> allIdList = new ArrayList<>();
- try {
- Context ctx = SHRContext.getInstance().getContext();
- //明细数据
- JSONArray entryList = JSON.parseArray(entryData);
- for(int i=0;i<entryList.size();i++) {
- JSONObject object = entryList.getJSONObject(i);
- BatchMessageTipsBody body = new BatchMessageTipsBody();
- String id =object.getString("id");
- boolean isSuccess=false;
- String msg="";
- String pnumber = object.getString("evaResult.pnumber");
- String pname = object.getString("evaResult.pname");
- String positionName = object.getString("evaResult.positionName");
- String evaResult = object.getString("evaResult.id");
- //修改后等级
- String auditGradeLevel = object.getString("evaResult.auditGradeLevel");
- body.setId(id);
- ids.append(id).append(",");
- allIdList.add(id);
- //获取跨部门协作绩效等级
- String sql = "select CFDEPGRADELEVEL from T_EVA_EvaResultSummary where fid = ?";
- IRowSet rs = DbUtil.executeQuery(ctx, sql, new String[]{evaResult});
- //当跨部门协作绩效等级为C、D等级的,当期员工绩效不得为高绩效(S、A等级)
- if (rs.next()){
- //跨部门协作绩效等级
- String depgradelevel = rs.getString("CFDEPGRADELEVEL");
- if(StringUtils.isNotBlank(depgradelevel)) {
- switch (depgradelevel) {
- case "S":
- ;
- case "A":
- ;
- case "B":
- isSuccess = true;
- msg = "校验通过";
- success += 1;
- break;
- case "C":
- case "D":
- if ("S".equals(auditGradeLevel) || "A".equals(auditGradeLevel)) {
- isSuccess = false;
- msg = "当跨部门协作绩效等级为C、D等级的,当期员工绩效不得为高绩效(S、A等级)";
- fail += 1;
- } else {
- isSuccess = true;
- msg = "校验通过";
- success += 1;
- }
- break;
- }
- }else {
- msg="没有当跨部门协作绩效等级,请先检查跨部门协作绩效等级";
- isSuccess=true;
- success+=1;
- }
- }else {
- msg="操作失败,数据异常";
- isSuccess=false;
- fail+=1;
- }
- body.setMuitTipsState(isSuccess);
- body.setMuitTipsMessage(msg);
- List<Object> messageListExt = new ArrayList<>();
- messageListExt.add(pnumber);
- messageListExt.add(pname);
- messageListExt.add(positionName);
- body.addMessageListExt(messageListExt);
- header.addResult(body);
- }
- } catch (BOSException | SQLException var7) {
- var7.printStackTrace();
- }
- ids.delete(ids.length()-1,ids.length());
- header.setBillId(ids.toString());
- header.setFailureCount(fail);
- header.setSuccessCount(success);
- }
- this.writeSuccessData(header);
- }
- protected static void addBatchMessageTip(String unvalidEvaObj, String message, BatchMessageTipsHeader batchMessageTipsHeader) {
- BatchMessageTipsBody body = new BatchMessageTipsBody();
- body.setId(unvalidEvaObj);
- body.setMuitTipsState(Boolean.FALSE);
- body.setMuitTipsMessage(message);
- batchMessageTipsHeader.addResult(body);
- batchMessageTipsHeader.setFailureCount(batchMessageTipsHeader.getFailureCount() + 1);
- }
- /**
- * 获取人员项目正态分布规则
- *
- * @param ctx
- * @param idList 非必填
- * @param batchMessage 非必填
- * @return
- * @throws BOSException
- * @throws SQLException
- */
- public Map<String, Map<String, BigDecimal>> getProjectPerformPro(Context ctx, List<String> idList, Map<String, String> batchMessage) throws BOSException, SQLException {
- //获取正态分布规则
- Map<String, Map<String, BigDecimal>> orgLevelMap = Maps.newHashMap();
- PerformProTeamCollection proCollection = PerformProTeamFactory.getLocalInstance(ctx).getPerformProTeamCollection(" where status=1 ");
- if (proCollection.size() == 1) {
- StringBuilder orgPerSql = new StringBuilder();
- orgPerSql.append(" select fp.fid,fpe.CFS,fpe.CFA,fpe.CFB,fpe.CFC,fpe.CFD,fpe.CFORGPERFORMTYPE ");
- orgPerSql.append(" from CT_PF_PerformProTeam fp ");
- orgPerSql.append(" left join CT_PF_PerformProTeamEntry fpe on fp.fid=fpe.FPARENTID ");
- orgPerSql.append(" where fp.CFSTATUS = 1 ");
- orgPerSql.append(" order by fp.FCREATETIME ");
- IRowSet rs = DbUtil.executeQuery(ctx, orgPerSql.toString());
- while (rs.next()) {
- Map<String, BigDecimal> objectMap = Maps.newHashMap();
- String type = rs.getString("CFORGPERFORMTYPE");
- objectMap.put("S", rs.getBigDecimal("CFS"));
- objectMap.put("A", rs.getBigDecimal("CFA"));
- objectMap.put("B", rs.getBigDecimal("CFB"));
- objectMap.put("C", rs.getBigDecimal("CFC"));
- objectMap.put("D", rs.getBigDecimal("CFD"));
- orgLevelMap.put(type, objectMap);
- }
- } else if (proCollection.size() > 1) {
- if (null != batchMessage && null != idList) {
- for (String key : idList) {
- batchMessage.put(key, "存在多个正态分布规则,请检查!");
- }
- }
- } else {
- if (null != batchMessage && null != idList) {
- for (String key : idList) {
- batchMessage.put(key, "不存在正态分布规则,请检查!");
- }
- }
- }
- return orgLevelMap;
- }
- /**
- * 获取人员组织正态分布规则
- *
- * @param ctx
- * @param idList 非必填
- * @param batchMessage 非必填
- * @return
- * @throws BOSException
- * @throws SQLException
- */
- public Map<String, Map<String, BigDecimal>> getPersonPerformPro(Context ctx, List<String> idList, Map<String, String> batchMessage) throws BOSException, SQLException {
- //获取正态分布规则
- Map<String, Map<String, BigDecimal>> orgLevelMap = Maps.newHashMap();
- PersonPerformProCollection proCollection = PersonPerformProFactory.getLocalInstance(ctx).getPersonPerformProCollection(" where state=1 ");
- if (proCollection.size() == 1) {
- StringBuilder orgPerSql = new StringBuilder();
- orgPerSql.append(" select fp.fid,fpe.CFS,fpe.CFA,fpe.CFB,fpe.CFC,fpe.CFD,fpe.CFORGPERFORMTYPE ");
- orgPerSql.append(" from CT_PF_PersonPerformPro fp ");
- orgPerSql.append(" left join CT_PF_PersonPerformProEntry fpe on fp.fid=fpe.FPARENTID ");
- orgPerSql.append(" where fp.CFSTATE = 1 ");
- orgPerSql.append(" order by fp.FCREATETIME ");
- IRowSet rs = DbUtil.executeQuery(ctx, orgPerSql.toString());
- while (rs.next()) {
- Map<String, BigDecimal> objectMap = Maps.newHashMap();
- String type = rs.getString("CFORGPERFORMTYPE");
- objectMap.put("S", rs.getBigDecimal("CFS"));
- objectMap.put("A", rs.getBigDecimal("CFA"));
- objectMap.put("B", rs.getBigDecimal("CFB"));
- objectMap.put("C", rs.getBigDecimal("CFC"));
- objectMap.put("D", rs.getBigDecimal("CFD"));
- orgLevelMap.put(type, objectMap);
- }
- } else if (proCollection.size() > 1) {
- if (null != batchMessage && null != idList) {
- for (String key : idList) {
- batchMessage.put(key, "存在多个正态分布规则,请检查!");
- }
- }
- } else {
- if (null != batchMessage && null != idList) {
- for (String key : idList) {
- batchMessage.put(key, "不存在正态分布规则,请检查!");
- }
- }
- }
- return orgLevelMap;
- }
- /**
- * 获取人员的等级组织分组
- *
- * @param ctx
- * @param entryList
- * @return
- * @throws BOSException
- * @throws SQLException
- */
- public Map<String, Map<String, Object>> getPersonLevelLensMap(Context ctx, JSONArray entryList) throws BOSException, SQLException {
- Map<String, Map<String, Object>> personLevelMap = Maps.newHashMap();
- Map<String, BigDecimal> revLevelMap = Maps.newHashMap();
- for(int i=0;i<entryList.size();i++) {
- JSONObject object = entryList.getJSONObject(i);
- String id =object.getString("id");
- String evaResult = object.getString("evaResult.id");
- //修改后等级
- String auditGradeLevel = object.getString("evaResult.auditGradeLevel");
- BigDecimal l = revLevelMap.get(auditGradeLevel);
- if(Objects.isNull(l)){
- l=BigDecimal.ZERO;
- }
- l=l.add(BigDecimal.ONE);
- revLevelMap.put(auditGradeLevel, l);
- }
- for(int i=0;i<entryList.size();i++) {
- JSONObject object = entryList.getJSONObject(i);
- String id =object.getString("id");
- String evaResult = object.getString("evaResult.id");
- //修改后等级
- String auditGradeLevel = object.getString("evaResult.auditGradeLevel");
- Map<String, Object> map = Maps.newHashMap();
- String key = auditGradeLevel;
- map.put("lens", revLevelMap.get(auditGradeLevel));
- map.put("id",id);
- map.put("evaResult",evaResult);
- map.put("revLevel",auditGradeLevel);
- personLevelMap.put(key, map);
- }
- return personLevelMap;
- }
- /**
- * 根据上季度的组织等级,校验当前周期,当前考核计划,所选员工的所属组织的员工绩效等级分布校验
- *
- * @param request
- * @param response
- * @param modelMap
- * @param batchMessageTipsHeader
- * @throws SHRWebException
- */
- public void beforeAuditEvaResutAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap, BatchMessageTipsHeader batchMessageTipsHeader) throws SHRWebException {
- Context ctx = SHRContext.getInstance().getContext();
- String ids = (String) request.getParameter("ids");
- String period = (String) request.getParameter("period");
- String planId = (String) request.getParameter("planId");
- String entryData = request.getParameter("entryData");
- if (ids == null) {
- throw new ShrWebBizException(new SHRPerfWebBizException(SHRPerfWebBizException.SYSTEMERR));
- }
- try {
- List<String> idList = Lists.newArrayList();
- Set<String> idSet = Sets.newHashSet(idList);
- for (String id : ids.split(",")) {
- idList.add(id);
- }
- //明细数据
- JSONArray entryList = JSON.parseArray(entryData);
- StringBuilder planSql = new StringBuilder();
- planSql.append("select fid,CFPerobjectIdId from T_EVA_PerfPlan where fid=? and CFPerobjectIdId is not null ");
- IRowSet rs = DbUtil.executeQuery(ctx, planSql.toString(), new Object[]{planId});
- if (rs.next()) {
- String CFPerobjectIdId = rs.getString("CFPerobjectIdId");
- Map<String, String> batchMessage = this.beforeAuditProjectEvaResut(ctx, period, planId, idList,entryList);
- if (null != batchMessage && batchMessage.size() > 0) {
- for (Map.Entry<String, String> entry : batchMessage.entrySet()) {
- addBatchMessageTip(entry.getKey(), entry.getValue(), batchMessageTipsHeader);
- idSet.remove(entry.getKey());
- }
- }
- } else {
- Map<String, String> batchMessage = this.beforeAuditEvaResut(ctx, period, planId, idList,entryList);
- if (null != batchMessage && batchMessage.size() > 0) {
- for (Map.Entry<String, String> entry : batchMessage.entrySet()) {
- addBatchMessageTip(entry.getKey(), entry.getValue(), batchMessageTipsHeader);
- idSet.remove(entry.getKey());
- }
- }
- //addBatchMessageSuccessTips(idSet,"验证成功",batchMessageTipsHeader);
- }
- this.setSuccessMessage("验证成功");
- } catch (Exception e) {
- e.printStackTrace();
- throw new ShrWebBizException(e);
- }
- }
- public Map<String, String> beforeAuditProjectEvaResut(Context ctx, String period, String planId, List<String> idList,JSONArray entryList ) throws BOSException, SQLException {
- Map<String, String> batchMessage = Maps.newHashMap();
- StringBuilder selParamId = new StringBuilder("''");
- for (int i = 0; i < idList.size(); i++) {
- selParamId.append(",?");
- }
- //获取正态分布规则
- Map<String, Map<String, BigDecimal>> personPerformMap = this.getProjectPerformPro(ctx, idList, batchMessage);
- if (null != personPerformMap && personPerformMap.size() > 0) {
- //获取组织分组人数
- //Map<String, Map<String, String>> orgLevelMap = this.getProjectLevelCountMap(ctx, period, planId,selParamId, idList);
- //获取人员等级分组
- Map<String, Map<String, Object>> personLevelMap = this.getPersonLevelLensMap(ctx,entryList);
- BigDecimal big100 = new BigDecimal(100);
- for(int i=0;i<entryList.size();i++) {
- JSONObject object = entryList.getJSONObject(i);
- String fid =object.getString("id");
- String evaResult = object.getString("evaResult.id");
- //修改后等级
- String auditGradeLevel = object.getString("evaResult.auditGradeLevel");
- String revLevel = auditGradeLevel;
- if (StrUtil.isBlank(auditGradeLevel)) {
- batchMessage.put(fid, "绩效等级为空,请维护");
- continue;
- }
- StringBuilder sel = new StringBuilder();
- sel.append(" select s1.fid,ppm.CFPROJECTNAME, pp.CFPerobjectIdId, s1.FPERIODID, s1.FEVAPLANID,");
- sel.append(" isnull(s1.FREVISEGRADELEVEL,s1.FGRADELEVEL) revLevel,s1.CFProjectLevel ");
- sel.append(" from T_EVA_EvaResultSummary s1 ");
- sel.append(" left join T_EVA_PerfPlan pp on pp.fid = s1.FEVAPLANID ");
- sel.append(" left join CT_PRO_ProjectManagement ppm on ppm.fid = pp.CFPerobjectIdId ");
- sel.append(" where s1.fid in ('");
- sel.append(evaResult);
- sel.append("') ");
- IRowSet rs = DbUtil.executeQuery(ctx, sel.toString(), idList.toArray());
- if (!rs.next()){
- batchMessage.put(fid, "绩效等级为空,请维护");
- continue;
- }
- String CFPROJECTNAME = rs.getString("CFPROJECTNAME");
- if (StrUtil.isBlank(revLevel)) {
- //String msg = String.format("%s绩效等级为空", CFPROJECTNAME);
- batchMessage.put(fid, "绩效等级为空,请维护");
- continue;
- }
- //项目绩效等级
- String projectLevel = rs.getString("CFProjectLevel");
- if (StrUtil.isBlank(projectLevel)) {
- String msg = String.format("%s项目绩效等级为空", CFPROJECTNAME);
- batchMessage.put(fid, msg);
- continue;
- }
- //该组织的组织绩效等级的正态分布
- Map<String, BigDecimal> personPerform = personPerformMap.get(projectLevel);
- if (null == personPerform) {
- String msg = String.format("没有找到%s项目绩效等级%s的正态分布规则", CFPROJECTNAME, projectLevel);
- batchMessage.put(fid, msg);
- continue;
- }
- //获取该组织下的人员总数
- //Map<String, String> orgMap = orgLevelMap.get(key);
- //获取该组织下的人员各个绩效等级分组汇总
- // String keyRevLevel = FADMINORGUNITID + FPERIODID + FEVAPLANID + revLevel;
- // Map<String, String> personMap = personLevelMap.get(keyRevLevel);
- Map<String, BigDecimal> leveList = Maps.newHashMap();
- //获取该组织下的人员总数
- //Map<String, String> orgMap = orgLevelMap.get(key);
- //获取等级D人数
- String keyRevLevelD = "D";
- Map<String, Object> personMapD = personLevelMap.get(keyRevLevelD);
- BigDecimal dLens = BigDecimal.ZERO;
- if (null != personMapD) {
- dLens = (BigDecimal) personMapD.get("lens");
- leveList.put("D", dLens);
- }
- //获取等级C人数
- String keyRevLevelC = "C";
- Map<String, Object> personMapC = personLevelMap.get(keyRevLevelC);
- BigDecimal cLens = BigDecimal.ZERO;
- if (null != personMapC) {
- cLens = (BigDecimal) personMapC.get("lens");
- leveList.put("C", cLens);
- }
- //获取等级B人数
- String keyRevLevelB = "B";
- Map<String, Object> personMapB = personLevelMap.get(keyRevLevelB);
- BigDecimal bLens = BigDecimal.ZERO;
- if (null != personMapB) {
- bLens = (BigDecimal) personMapB.get("lens");
- leveList.put("B", bLens);
- }
- //获取等级A人数
- String keyRevLevelA = "A";
- Map<String, Object> personMapA = personLevelMap.get(keyRevLevelA);
- BigDecimal aLens = BigDecimal.ZERO;
- if (null != personMapA) {
- aLens = (BigDecimal) personMapA.get("lens");
- leveList.put("A", aLens);
- }
- //获取等级S人数
- String keyRevLevelS = "S";
- Map<String, Object> personMapS = personLevelMap.get(keyRevLevelS);
- BigDecimal sLens = BigDecimal.ZERO;
- if (null != personMapS) {
- sLens = (BigDecimal) personMapS.get("lens");
- leveList.put("S", sLens);
- }
- //总人数
- BigDecimal alls = new BigDecimal(idList.size());
- //当前等级正态分布比例
- BigDecimal scale = personPerform.get(revLevel);
- //创建每个等级的人数列表
- Map<String, BigDecimal> bigsList = Maps.newHashMap();
- BigDecimal bigS = ((personPerform.get("S").divide(big100, BigDecimal.ROUND_HALF_UP, BigDecimal.ROUND_HALF_UP)).multiply(alls).setScale(0, BigDecimal.ROUND_HALF_UP));
- bigsList.put("S", bigS);
- BigDecimal bigA = ((personPerform.get("A").divide(big100, BigDecimal.ROUND_HALF_UP, BigDecimal.ROUND_HALF_UP)).multiply(alls).setScale(0, BigDecimal.ROUND_HALF_UP));
- bigsList.put("A", bigA);
- BigDecimal bigB = ((personPerform.get("B").divide(big100, BigDecimal.ROUND_HALF_UP, BigDecimal.ROUND_HALF_UP)).multiply(alls).setScale(0, BigDecimal.ROUND_HALF_UP));
- bigsList.put("B", bigB);
- BigDecimal bigC = ((personPerform.get("C").divide(big100, BigDecimal.ROUND_HALF_UP, BigDecimal.ROUND_HALF_UP)).multiply(alls).setScale(0, BigDecimal.ROUND_HALF_UP));
- bigsList.put("C", bigC);
- BigDecimal bigD = ((personPerform.get("D").divide(big100, BigDecimal.ROUND_HALF_UP, BigDecimal.ROUND_HALF_UP)).multiply(alls).setScale(0, BigDecimal.ROUND_HALF_UP));
- bigsList.put("D", bigD);
- //已占用数
- BigDecimal lens = BigDecimal.ZERO;
- //进行额度加减
- BigDecimal personSize = BigDecimal.ZERO;
- BigDecimal personMaxSize = BigDecimal.ZERO;
- BigDecimal personMinSize = BigDecimal.ZERO;
- List<String> ldrs = Lists.newArrayList();
- Map<String,String> ldrcd = Maps.newHashMap();
- switch (revLevel) {
- case "A":
- personSize = personSize.add(bigA).subtract(aLens);
- lens = lens.add(aLens);
- if ("A".equals(revLevel)) {
- personMaxSize = personMaxSize.add((bigA));
- } else {
- personMaxSize = personMaxSize.add((bigA).subtract(aLens));
- }
- ldrs.add("A最多%A人,");
- //bigsList.remove("A");
- case "S":
- personSize = personSize.add(bigS).subtract(sLens);
- lens = lens.add(sLens);
- if ("S".equals(revLevel)) {
- personMaxSize = personMaxSize.add((bigS));
- } else {
- personMaxSize = personMaxSize.add((bigS).subtract(sLens));
- }
- ldrs.add("S最多%S人,");
- //bigsList.remove("S");
- case "B":
- case "C":
- if ("C".equals(revLevel)) {
- personMinSize = personMinSize.add((bigC));
- } else {
- personMinSize = personMinSize.add((bigC).subtract(cLens));
- }
- ldrcd.put("C","C最少"+(personMinSize.compareTo(BigDecimal.ZERO) > 0?personMinSize.toPlainString():'0')+"人,");
- //bigsList.remove("C");
- case "D":
- if ("D".equals(revLevel)) {
- personMinSize = personMinSize.add((bigD));
- } else {
- personMinSize = personMinSize.add((bigD).subtract(dLens));
- }
- ldrcd.put("D","D最少"+(personMinSize.compareTo(BigDecimal.ZERO) > 0?personMinSize.toPlainString():'0')+"人,");
- }
- String ld = "当前周期绩效等级为%l的人数为%maxs人,";
- if (personMinSize.compareTo(BigDecimal.ZERO) > 0 || personSize.compareTo(BigDecimal.ZERO) < 0) {
- if(ldrs.size()>0) {
- String ldrstr = ldrs.get(0);
- ld += ldrstr;
- ld = ld.replace("%" + revLevel, (personMaxSize.compareTo(BigDecimal.ZERO) > 0 ? (personMaxSize) : BigDecimal.ZERO).toPlainString());
- }
- ld = ld.replace("%l", revLevel);
- ld = ld.replace("%maxs", (leveList.get(revLevel) == null ? BigDecimal.ZERO : leveList.get(revLevel)).toPlainString());
- for (Map.Entry<String,String> entry : ldrcd.entrySet()) {
- String eKey = entry.getKey();
- String ldr= entry.getValue();
- ld += ldr;
- }
- ld += "请修正后重新审核.";
- batchMessage.put(fid, ld);
- }
- }
- }
- return batchMessage;
- }
- /**
- * 结果直接审核、结果工作流审核,绩效等级分布比例校验人数由整个绩效考核计划的人数改为按选择的人数进行分布比例校验。
- *
- * @param ctx
- * @param period
- * @param planId
- * @param idList
- * @return
- * @throws BOSException
- * @throws SQLException
- */
- public Map<String, String> beforeAuditEvaResut(Context ctx, String period, String planId, List<String> idList,JSONArray entryList) throws BOSException, SQLException {
- Map<String, String> batchMessage = Maps.newHashMap();
- StringBuilder selParamId = new StringBuilder("''");
- for (int i = 0; i < idList.size(); i++) {
- selParamId.append(",?");
- }
- //获取正态分布规则
- Map<String, Map<String, BigDecimal>> personPerformMap = this.getPersonPerformPro(ctx, idList, batchMessage);
- if (null != personPerformMap && personPerformMap.size() > 0) {
- //获取组织分组人数
- //Map<String, Map<String, String>> orgLevelMap = this.getOrgLevelCountMap(ctx, period, planId);
- //获取人员等级分组
- Map<String, Map<String, Object>> personLevelMap = this.getPersonLevelLensMap(ctx, entryList);
- BigDecimal big100 = new BigDecimal(100);
- for(int i=0;i<entryList.size();i++) {
- JSONObject object = entryList.getJSONObject(i);
- String fid = object.getString("id");
- String evaResult = object.getString("evaResult.id");
- //修改后等级
- String auditGradeLevel = object.getString("evaResult.auditGradeLevel");
- if (StrUtil.isBlank(auditGradeLevel)) {
- batchMessage.put(fid, "绩效等级为空,请维护");
- continue;
- }
- StringBuilder sel = new StringBuilder();
- sel.append(" select ers.fid,ers.FADMINORGNAME, ");
- sel.append(" ers.FPERIODID, ers.FEVAPLANID,isnull(ers.FREVISEGRADELEVEL, ers.FGRADELEVEL) revLevel,ers.CFOrgLevel ");
- sel.append(" from T_EVA_EvaResultSummary ers where ers.fid = '");
- sel.append(evaResult);
- sel.append("' ");
- IRowSet rs = DbUtil.executeQuery(ctx, sel.toString());
- String orgLevel="";
- String FADMINORGNAME ="";
- //上季度组织绩效等级
- if (rs.next()){
- orgLevel = rs.getString("CFOrgLevel");
- FADMINORGNAME = rs.getString("FADMINORGNAME");
- if (StringUtils.isBlank(orgLevel)) {
- String msg = String.format("%s上季度组织绩效等级为空", FADMINORGNAME);
- batchMessage.put(fid, msg);
- continue;
- }
- }
- //该组织的组织绩效等级的正态分布
- Map<String, BigDecimal> personPerform = personPerformMap.get(orgLevel);
- if (null == personPerform) {
- String msg = String.format("没有找到%s上季度组织绩效等级%s的正态分布规则", FADMINORGNAME, orgLevel);
- batchMessage.put(fid, msg);
- continue;
- }
- //获取该组织下的人员总数
- //Map<String, String> orgMap = orgLevelMap.get(key);
- Map<String, BigDecimal> leveList = Maps.newHashMap();
- //获取等级D人数
- String keyRevLevelD = "D";
- Map<String, Object> personMapD = personLevelMap.get(keyRevLevelD);
- BigDecimal dLens = BigDecimal.ZERO;
- if (null != personMapD) {
- dLens = (BigDecimal) personMapD.get("lens");
- leveList.put("D", dLens);
- }
- //获取等级C人数
- String keyRevLevelC = "C";
- Map<String, Object> personMapC = personLevelMap.get(keyRevLevelC);
- BigDecimal cLens = BigDecimal.ZERO;
- if (null != personMapC) {
- cLens = (BigDecimal) personMapC.get("lens");
- leveList.put("C", cLens);
- }
- //获取等级B人数
- String keyRevLevelB = "B";
- Map<String, Object> personMapB = personLevelMap.get(keyRevLevelB);
- BigDecimal bLens = BigDecimal.ZERO;
- if (null != personMapB) {
- bLens = (BigDecimal) personMapB.get("lens");
- leveList.put("B", bLens);
- }
- //获取等级A人数
- String keyRevLevelA = "A";
- Map<String, Object> personMapA = personLevelMap.get(keyRevLevelA);
- BigDecimal aLens = BigDecimal.ZERO;
- if (null != personMapA) {
- aLens = (BigDecimal) personMapA.get("lens");
- leveList.put("A", aLens);
- }
- //获取等级S人数
- String keyRevLevelS = "S";
- Map<String, Object> personMapS = personLevelMap.get(keyRevLevelS);
- BigDecimal sLens = BigDecimal.ZERO;
- if (null != personMapS) {
- sLens = (BigDecimal) personMapS.get("lens");
- leveList.put("S", sLens);
- }
- System.out.println("leveList:"+leveList);
- //总人数
- BigDecimal alls = new BigDecimal(idList.size());
- //当前等级正态分布比例
- BigDecimal scale = personPerform.get(auditGradeLevel);
- //创建每个等级的人数列表
- Map<String, BigDecimal> bigsList = Maps.newHashMap();
- BigDecimal bigS = ((personPerform.get("S").divide(big100, BigDecimal.ROUND_HALF_UP, BigDecimal.ROUND_HALF_UP)).multiply(alls).setScale(0, BigDecimal.ROUND_HALF_UP));
- bigsList.put("S", bigS);
- BigDecimal bigA = ((personPerform.get("A").divide(big100, BigDecimal.ROUND_HALF_UP, BigDecimal.ROUND_HALF_UP)).multiply(alls).setScale(0, BigDecimal.ROUND_HALF_UP));
- bigsList.put("A", bigA);
- BigDecimal bigB = ((personPerform.get("B").divide(big100, BigDecimal.ROUND_HALF_UP, BigDecimal.ROUND_HALF_UP)).multiply(alls).setScale(0, BigDecimal.ROUND_HALF_UP));
- bigsList.put("B", bigB);
- BigDecimal bigC = ((personPerform.get("C").divide(big100, BigDecimal.ROUND_HALF_UP, BigDecimal.ROUND_HALF_UP)).multiply(alls).setScale(0, BigDecimal.ROUND_HALF_UP));
- bigsList.put("C", bigC);
- BigDecimal bigD = ((personPerform.get("D").divide(big100, BigDecimal.ROUND_HALF_UP, BigDecimal.ROUND_HALF_UP)).multiply(alls).setScale(0, BigDecimal.ROUND_HALF_UP));
- bigsList.put("D", bigD);
- System.out.println("bigsList:"+bigsList);
- //已占用数
- BigDecimal lens = BigDecimal.ZERO;
- //进行额度加减
- //if ("S".equals(revLevel) || "A".equals(revLevel)||"B".equals(revLevel) || "C".equals(revLevel) || "D".equals(revLevel)) {
- BigDecimal personSize = BigDecimal.ZERO;
- BigDecimal personMaxSize = BigDecimal.ZERO;
- BigDecimal personMinSize = BigDecimal.ZERO;
- List<String> ldrs = Lists.newArrayList();
- Map<String,String> ldrcd = Maps.newHashMap();
- switch (auditGradeLevel) {
- case "A":
- personSize = personSize.add(bigA).subtract(aLens);
- lens = lens.add(aLens);
- if ("A".equals(auditGradeLevel)) {
- personMaxSize = personMaxSize.add((bigA));
- } else {
- personMaxSize = personMaxSize.add((bigA).subtract(aLens));
- }
- ldrs.add("A最多%A人,");
- //bigsList.remove("A");
- case "S":
- personSize = personSize.add(bigS).subtract(sLens);
- lens = lens.add(sLens);
- if ("S".equals(auditGradeLevel)) {
- personMaxSize = personMaxSize.add((bigS));
- } else {
- personMaxSize = personMaxSize.add((bigS).subtract(sLens));
- }
- ldrs.add("S最多%S人,");
- //bigsList.remove("S");
- case "B":
- case "C":
- if ("C".equals(auditGradeLevel)) {
- personMinSize = personMinSize.add((bigC));
- } else {
- personMinSize = personMinSize.add((bigC).subtract(cLens));
- }
- ldrcd.put("C","C最少"+(personMinSize.compareTo(BigDecimal.ZERO) > 0?personMinSize.toPlainString():'0')+"人,");
- //bigsList.remove("C");
- case "D":
- // if (bigD.compareTo(dLens) > 0) {
- // ldrcd.add("D最少" + bigD.toPlainString() + "人,");
- // }
- if ("D".equals(auditGradeLevel)) {
- personMinSize = personMinSize.add((bigD));
- } else {
- personMinSize = personMinSize.add((bigD).subtract(dLens));
- }
- ldrcd.put("D","D最少"+(personMinSize.compareTo(BigDecimal.ZERO) > 0?personMinSize.toPlainString():'0')+"人,");
- }
- String ld = "当前周期绩效等级为%l的人数为%maxs人,";
- if (personMinSize.compareTo(BigDecimal.ZERO) > 0 || personSize.compareTo(BigDecimal.ZERO) < 0) {
- if(ldrs.size()>0){
- String ldrstr = ldrs.get(0);
- ld += ldrstr;
- ld = ld.replace("%" + auditGradeLevel, (personMaxSize.compareTo(BigDecimal.ZERO) > 0 ? (personMaxSize) : BigDecimal.ZERO).toPlainString());
- }
- ld = ld.replace("%l", auditGradeLevel);
- ld = ld.replace("%maxs", (leveList.get(auditGradeLevel) == null ? BigDecimal.ZERO : leveList.get(auditGradeLevel)).toPlainString());
- for (Map.Entry<String,String> entry : ldrcd.entrySet()) {
- String eKey = entry.getKey();
- String ldr= entry.getValue();
- ld += ldr;
- }
- ld += "请修正后重新审核.";
- batchMessage.put(fid, ld);
- }
- }
- }
- return batchMessage;
- }
- }
|