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.common.EASBizException;
import com.kingdee.eas.framework.CoreBaseInfo;
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.base.syssetting.web.json.JSONUtils;
import com.kingdee.shr.compensation.util.CmpStrUtil;
import com.kingdee.shr.perfweb.app.base.evalplan.EvaResultSummaryAuditBillFactory;
import com.kingdee.shr.perfweb.app.base.evalplan.IEvaResultSummaryAuditBill;
import com.kingdee.shr.perfweb.app.exception.SHRPerfWebBizException;
import com.kingdee.shr.perfweb.app.resource.SHRPerfWebResource;
import com.kingdee.shr.perfweb.planexecute.handler.EvaresultAuditBillEditHandler;
import com.kingdee.shr.perfweb.util.SHRPerfWebResourceUtil;
import org.apache.commons.lang3.StringUtils;
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.sql.SQLException;
import java.util.*;
/**
* @BelongsProject: dataImpExp820
* @BelongsPackage: com.kingdee.eas.hr.perf.handler
* @Author: lhbj
* @CreateTime: 2025-01-10 19:09
* @Description: TODO
* @Version: 1.0
*/
public class EvaresultAuditBillEditHandlerEx extends EvaresultAuditBillEditHandler {
private static Logger logger = LoggerFactory.getLogger(EvaresultAuditBillEditHandlerEx.class);
/**
[{"evaResult.pnumber":"0000381","evaResult.pname":"谭梓傲","evaResult.positionName":"物资岗","evaResult.evaObj.perfFile.adminOrgUnit.company.name":"湖南红太阳光电科技有限公司","evaResult.evaObj.perfFile.adminOrgUnit.department.name":"综合管理","evaResult.sumScore":"","evaResult.gradeLevel":"","evaResult.auditSumScore":"86.00","evaResult.auditGradeLevel":"C","evaResult.auditReason":"
正态分布更新结果
","evaResult.reviseSumScore":"86.00","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)) {
String period = request.getParameter("period");
String planId = request.getParameter("planId");
String billId = request.getParameter("billId");
String ids = request.getParameter("ids");
List rowList = Lists.newArrayList();
for (String id : billId.split(",")) {
rowList.add(id);
}
header=this.verifyToDep(request,response,modelMap);
if(header.getFailureCount()<=0&&header.getSuccessCount()>0){
header = this.beforeAuditEvaResutProject(ids,period,planId,entryData);
}
header.setBillId(billId.toString());
}
this.writeSuccessData(header);
}
protected static Set getErrorIdsByBatchMessageTip(BatchMessageTipsHeader batchMessageTipsHeader) {
Set errorIds = new HashSet();
Iterator var2 = batchMessageTipsHeader.getResult().iterator();
while(var2.hasNext()) {
BatchMessageTipsBody body = (BatchMessageTipsBody)var2.next();
if (!body.isMuitTipsState()) {
errorIds.add(body.getId());
}
}
return errorIds;
}
protected static void addBatchMessageSuccessTips(Set ids, String message, BatchMessageTipsHeader batchMessageTipsHeader) {
Iterator var3 = ids.iterator();
while(var3.hasNext()) {
String id = (String)var3.next();
BatchMessageTipsBody body = new BatchMessageTipsBody();
body.setId(id);
body.setMuitTipsState(Boolean.TRUE);
body.setMuitTipsMessage(com.kingdee.util.StringUtils.isEmpty(message) ? SHRPerfWebResourceUtil.getRes(SHRPerfWebResource.OPERATESUCCESS, SHRContext.getInstance().getContext()) : message);
batchMessageTipsHeader.addResult(body);
}
}
public BatchMessageTipsHeader verifyToDep(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 allIdList = new ArrayList<>();
try {
Context ctx = SHRContext.getInstance().getContext();
//明细数据
JSONArray entryList = JSON.parseArray(entryData);
for(int i=0;i 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);
}
return (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> getProjectPerformPro(Context ctx, List idList, Map batchMessage) throws BOSException, SQLException {
//获取正态分布规则
Map> 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 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> getPersonPerformPro(Context ctx, List idList, Map batchMessage) throws BOSException, SQLException {
//获取正态分布规则
Map> 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 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> getPersonLevelLensMap(Context ctx, JSONArray entryList) throws BOSException, SQLException {
Map> personLevelMap = Maps.newHashMap();
Map revLevelMap = Maps.newHashMap();
for(int i=0;i 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;
}
/**
* 根据上季度的组织等级,校验当前周期,当前考核计划,所选员工的所属组织的员工绩效等级分布校验
*
* @throws SHRWebException
*/
public BatchMessageTipsHeader beforeAuditEvaResutProject(String ids, String period, String planId, String entryData) throws SHRWebException {
Context ctx = SHRContext.getInstance().getContext();
BatchMessageTipsHeader batchMessageTipsHeader = new BatchMessageTipsHeader();
if (ids == null) {
throw new ShrWebBizException(new SHRPerfWebBizException(SHRPerfWebBizException.SYSTEMERR));
}
try {
int fail = 0;
List idList = Lists.newArrayList();
for (String id : ids.split(",")) {
idList.add(id);
}
Set idSet = Sets.newHashSet();
idSet.addAll(idList);
int success = idList.size();
//明细数据
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 batchMessage = this.beforeAuditProjectEvaResut(ctx, period, planId, idList,entryList);
if (null != batchMessage && batchMessage.size() > 0) {
for (Map.Entry entry : batchMessage.entrySet()) {
addBatchMessageTip(entry.getKey(), entry.getValue(), batchMessageTipsHeader);
idSet.remove(entry.getKey());
}
}
} else {
Map batchMessage = this.beforeAuditEvaResut(ctx, period, planId, idList,entryList);
if (null != batchMessage && batchMessage.size() > 0) {
for (Map.Entry entry : batchMessage.entrySet()) {
addBatchMessageTip(entry.getKey(), entry.getValue(), batchMessageTipsHeader);
idSet.remove(entry.getKey());
}
}
//addBatchMessageSuccessTips(idSet,"验证成功",batchMessageTipsHeader);
}
this.addBatchMessageSuccessTips(idSet,"验证成功",batchMessageTipsHeader);
batchMessageTipsHeader.setSuccessCount(idList.size()-batchMessageTipsHeader.getFailureCount());
} catch (Exception e) {
e.printStackTrace();
throw new ShrWebBizException(e);
}
batchMessageTipsHeader.setBillId(ids.toString());
return batchMessageTipsHeader;
}
public BigDecimal getLens(String levelID, Map> personLevelMap){
Map personMap = personLevelMap.get(levelID);
BigDecimal lens = BigDecimal.ZERO;
if (null != personMap) {
lens = (BigDecimal) personMap.get("lens");
}
return lens;
}
public Map beforeAuditProjectEvaResut(Context ctx, String period, String planId, List idList,JSONArray entryList ) throws BOSException, SQLException {
Map batchMessage = Maps.newHashMap();
StringBuilder selParamId = new StringBuilder("''");
for (int i = 0; i < idList.size(); i++) {
selParamId.append(",?");
}
//获取正态分布规则
Map> personPerformMap = this.getProjectPerformPro(ctx, idList, batchMessage);
if (null != personPerformMap && personPerformMap.size() > 0) {
//获取组织分组人数
//Map> orgLevelMap = this.getProjectLevelCountMap(ctx, period, planId,selParamId, idList);
//获取人员等级分组
Map> personLevelMap = this.getPersonLevelLensMap(ctx,entryList);
BigDecimal big100 = new BigDecimal(100);
for(int i=0;i personPerform = personPerformMap.get(projectLevel);
if (null == personPerform) {
String msg = String.format("没有找到%s项目绩效等级%s的正态分布规则", CFPROJECTNAME, projectLevel);
batchMessage.put(fid, msg);
continue;
}
//获取该组织下的人员总数
//Map orgMap = orgLevelMap.get(key);
//获取该组织下的人员各个绩效等级分组汇总
// String keyRevLevel = FADMINORGUNITID + FPERIODID + FEVAPLANID + revLevel;
// Map personMap = personLevelMap.get(keyRevLevel);
Map leveList = Maps.newHashMap();
//获取该组织下的人员总数
//Map orgMap = orgLevelMap.get(key);
//获取等级D人数
String keyRevLevelD = "D";
BigDecimal dLens = this.getLens(keyRevLevelD,personLevelMap);
leveList.put("D", dLens);
//获取等级C人数
String keyRevLevelC = "C";
BigDecimal cLens = this.getLens(keyRevLevelC,personLevelMap);
leveList.put("C", cLens);
//获取等级B人数
String keyRevLevelB = "B";
BigDecimal bLens = this.getLens(keyRevLevelB,personLevelMap);
leveList.put("B", bLens);
//获取等级A人数
String keyRevLevelA = "A";
BigDecimal aLens = this.getLens(keyRevLevelA,personLevelMap);
leveList.put("A", aLens);
//获取等级S人数
String keyRevLevelS = "S";
BigDecimal sLens = this.getLens(keyRevLevelS,personLevelMap);
leveList.put("S", sLens);
//总人数
BigDecimal alls = new BigDecimal(idList.size());
//当前等级正态分布比例
BigDecimal scale = personPerform.get(revLevel);
//创建每个等级的人数列表
Map 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;
BigDecimal personMaxASize = BigDecimal.ZERO;
BigDecimal personMaxSSize = BigDecimal.ZERO;
BigDecimal personMinCSize = BigDecimal.ZERO;
BigDecimal personMinDSize = BigDecimal.ZERO;
BigDecimal personMinVSize = BigDecimal.ZERO;
List ldrs = Lists.newArrayList();
Map 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));
}
personMaxASize = new BigDecimal(personMaxSize.toPlainString());
ldrs.add("A最多"+personMaxASize.toPlainString()+"人,");
//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));
}
personMaxSSize = new BigDecimal(personMaxSize.toPlainString());
ldrs.add("S最多"+personMaxSSize.toPlainString()+"人,");
//bigsList.remove("S");
case "B":
case "C":
personMinVSize=personMinVSize.add(bigC).subtract(cLens);
if ("C".equals(revLevel)) {
personMinSize = personMinSize.add((bigC));
} else {
personMinSize = personMinSize.add((bigC).subtract(cLens));
}
personMinCSize = new BigDecimal(bigC.toPlainString());
//bigsList.remove("C");
case "D":
personMinVSize=personMinVSize.add(bigD).subtract(dLens);
if ("D".equals(revLevel)) {
personMinSize = personMinSize.add((bigD));
} else {
personMinSize = personMinSize.add((bigD).subtract(dLens));
}
personMinDSize = new BigDecimal(bigD.add(bigC).toPlainString());
}
switch (revLevel) {
case "A":
case "S":
case "B":
ldrcd.put("C", "C最少" + (personMinCSize.compareTo(BigDecimal.ZERO) > 0 ? personMinCSize.toPlainString() : '0') + "人或者D最少" + (personMinDSize.compareTo(BigDecimal.ZERO) > 0 ? personMinDSize.toPlainString() : "0") + "人,");
break;
case "C":
ldrcd.put("C", "C最少" + (bigC.compareTo(BigDecimal.ZERO) > 0 ? bigC.toPlainString() : '0') + "人或者D最少" + (personMinDSize.compareTo(BigDecimal.ZERO) > 0 ? personMinDSize.toPlainString() : "0") + "人,");
break;
case "D":
ldrcd.put("D", "D最少" + bigD + "人,");
}
String ld = "当前周期绩效等级为%l的人数为%maxs人,";
if (personMinVSize.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 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 beforeAuditEvaResut(Context ctx, String period, String planId, List idList,JSONArray entryList) throws BOSException, SQLException {
Map batchMessage = Maps.newHashMap();
StringBuilder selParamId = new StringBuilder("''");
for (int i = 0; i < idList.size(); i++) {
selParamId.append(",?");
}
//获取正态分布规则
Map> personPerformMap = this.getPersonPerformPro(ctx, idList, batchMessage);
if (null != personPerformMap && personPerformMap.size() > 0) {
//获取组织分组人数
//Map> orgLevelMap = this.getOrgLevelCountMap(ctx, period, planId);
//获取人员等级分组
Map> personLevelMap = this.getPersonLevelLensMap(ctx, entryList);
BigDecimal big100 = new BigDecimal(100);
for(int i=0;i personPerform = personPerformMap.get(orgLevel);
if (null == personPerform) {
String msg = String.format("没有找到%s上季度组织绩效等级%s的正态分布规则", FADMINORGNAME, orgLevel);
batchMessage.put(fid, msg);
continue;
}
//获取该组织下的人员总数
//Map orgMap = orgLevelMap.get(key);
Map leveList = Maps.newHashMap();
//获取等级D人数
String keyRevLevelD = "D";
BigDecimal dLens = this.getLens(keyRevLevelD,personLevelMap);
leveList.put("D", dLens);
//获取等级C人数
String keyRevLevelC = "C";
BigDecimal cLens = this.getLens(keyRevLevelC,personLevelMap);
leveList.put("C", cLens);
//获取等级B人数
String keyRevLevelB = "B";
BigDecimal bLens = this.getLens(keyRevLevelB,personLevelMap);
leveList.put("B", bLens);
//获取等级A人数
String keyRevLevelA = "A";
BigDecimal aLens = this.getLens(keyRevLevelA,personLevelMap);
leveList.put("A", aLens);
//获取等级S人数
String keyRevLevelS = "S";
BigDecimal sLens = this.getLens(keyRevLevelS,personLevelMap);
leveList.put("S", sLens);
System.out.println("leveList:"+leveList);
//总人数
BigDecimal alls = new BigDecimal(idList.size());
//当前等级正态分布比例
BigDecimal scale = personPerform.get(auditGradeLevel);
//创建每个等级的人数列表
Map 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;
BigDecimal personMaxASize = BigDecimal.ZERO;
BigDecimal personMaxSSize = BigDecimal.ZERO;
BigDecimal personMinCSize = BigDecimal.ZERO;
BigDecimal personMinDSize = BigDecimal.ZERO;
BigDecimal personMinVSize = BigDecimal.ZERO;
List ldrs = Lists.newArrayList();
Map 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));
}
personMaxASize = new BigDecimal(personMaxSize.toPlainString());
ldrs.add("A最多"+personMaxASize.toPlainString()+"人,");
//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));
}
personMaxSSize = new BigDecimal(personMaxSize.toPlainString());
ldrs.add("S最多"+personMaxSSize.toPlainString()+"人,");
//bigsList.remove("S");
case "B":
case "C":
personMinVSize=personMinVSize.add(bigC).subtract(cLens);
if ("C".equals(auditGradeLevel)) {
personMinSize = personMinSize.add((bigC));
} else {
personMinSize = personMinSize.add((bigC).subtract(cLens));
}
personMinCSize = new BigDecimal(bigC.toPlainString());
//bigsList.remove("C");
case "D":
personMinVSize=personMinVSize.add(bigD).subtract(dLens);
if ("D".equals(auditGradeLevel)) {
personMinSize = personMinSize.add((bigD));
} else {
personMinSize = personMinSize.add((bigD).subtract(dLens));
}
personMinDSize = new BigDecimal(bigD.add(bigC).toPlainString());
}
switch (auditGradeLevel) {
case "A":
case "S":
case "B":
ldrcd.put("C", "C最少" + (personMinCSize.compareTo(BigDecimal.ZERO) > 0 ? personMinCSize.toPlainString() : '0') + "人或者D最少" + (personMinDSize.compareTo(BigDecimal.ZERO) > 0 ? personMinDSize.toPlainString() : "0") + "人,");
break;
case "C":
ldrcd.put("C", "C最少" + (bigC.compareTo(BigDecimal.ZERO) > 0 ? bigC.toPlainString() : '0') + "人或者D最少" + (personMinDSize.compareTo(BigDecimal.ZERO) > 0 ? personMinDSize.toPlainString() : "0") + "人,");
break;
case "D":
ldrcd.put("D", "D最少" + bigD + "人,");
}
String ld = "当前周期绩效等级为%l的人数为%maxs人,";
if (personMinVSize.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 entry : ldrcd.entrySet()) {
String eKey = entry.getKey();
String ldr= entry.getValue();
ld += ldr;
}
ld += "请修正后重新审核.";
batchMessage.put(fid, ld);
}
}
}
return batchMessage;
}
protected void verifyModel(HttpServletRequest request, HttpServletResponse response, CoreBaseInfo model) throws SHRWebException {
}
}