EvaresultAuditBillEntryListHandlerEx.java 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  1. package com.kingdee.eas.hr.perf.handler;
  2. import cn.hutool.core.util.StrUtil;
  3. import com.alibaba.fastjson.JSON;
  4. import com.alibaba.fastjson.JSONArray;
  5. import com.alibaba.fastjson.JSONObject;
  6. import com.google.common.collect.Maps;
  7. import com.google.common.collect.Sets;
  8. import com.kingdee.bos.BOSException;
  9. import com.kingdee.bos.Context;
  10. import com.kingdee.bos.rabbitmq.guava.Lists;
  11. import com.kingdee.eas.hr.perf.PerformProTeamCollection;
  12. import com.kingdee.eas.hr.perf.PerformProTeamFactory;
  13. import com.kingdee.eas.hr.perf.PersonPerformProCollection;
  14. import com.kingdee.eas.hr.perf.PersonPerformProFactory;
  15. import com.kingdee.eas.util.app.DbUtil;
  16. import com.kingdee.jdbc.rowset.IRowSet;
  17. import com.kingdee.shr.base.syssetting.api.bean.BatchMessageTipsBody;
  18. import com.kingdee.shr.base.syssetting.api.bean.BatchMessageTipsHeader;
  19. import com.kingdee.shr.base.syssetting.context.SHRContext;
  20. import com.kingdee.shr.base.syssetting.exception.SHRWebException;
  21. import com.kingdee.shr.base.syssetting.exception.ShrWebBizException;
  22. import com.kingdee.shr.perfweb.app.exception.SHRPerfWebBizException;
  23. import com.kingdee.shr.perfweb.planexecute.handler.EvaresultAuditBillEntryListHandler;
  24. import org.apache.commons.lang3.StringUtils;
  25. import org.springframework.ui.ModelMap;
  26. import javax.servlet.http.HttpServletRequest;
  27. import javax.servlet.http.HttpServletResponse;
  28. import java.math.BigDecimal;
  29. import java.sql.SQLException;
  30. import java.util.*;
  31. /**
  32. * description: EvaresultAuditBillEntryListHandler <br>
  33. * date: 2025/6/24 12:48 <br>
  34. * author: lhbj <br>
  35. * version: 1.0 <br>
  36. */
  37. public class EvaresultAuditBillEntryListHandlerEx extends EvaresultAuditBillEntryListHandler {
  38. /**
  39. [{"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":"否"}]
  40. * @param request
  41. * @param response
  42. * @param modelMap
  43. * @throws SHRWebException
  44. */
  45. public void verifyBeforeSubmitAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws SHRWebException {
  46. String entryData = request.getParameter("entryData");
  47. BatchMessageTipsHeader header = new BatchMessageTipsHeader();
  48. boolean isExists = true;
  49. if (!com.kingdee.util.StringUtils.isEmpty(entryData)) {
  50. int success = 0;
  51. int fail = 0;
  52. StringBuilder ids = new StringBuilder();
  53. List<String> allIdList = new ArrayList<>();
  54. try {
  55. Context ctx = SHRContext.getInstance().getContext();
  56. //明细数据
  57. JSONArray entryList = JSON.parseArray(entryData);
  58. for(int i=0;i<entryList.size();i++) {
  59. JSONObject object = entryList.getJSONObject(i);
  60. BatchMessageTipsBody body = new BatchMessageTipsBody();
  61. String id =object.getString("id");
  62. boolean isSuccess=false;
  63. String msg="";
  64. String pnumber = object.getString("evaResult.pnumber");
  65. String pname = object.getString("evaResult.pname");
  66. String positionName = object.getString("evaResult.positionName");
  67. String evaResult = object.getString("evaResult.id");
  68. //修改后等级
  69. String auditGradeLevel = object.getString("evaResult.auditGradeLevel");
  70. if(StringUtils.isBlank(auditGradeLevel)){
  71. auditGradeLevel= object.getString("evaResult.gradeLevel");
  72. }
  73. body.setId(id);
  74. ids.append(id).append(",");
  75. allIdList.add(id);
  76. //获取跨部门协作绩效等级
  77. String sql = "select CFDEPGRADELEVEL from T_EVA_EvaResultSummary where fid = ?";
  78. IRowSet rs = DbUtil.executeQuery(ctx, sql, new String[]{evaResult});
  79. //当跨部门协作绩效等级为C、D等级的,当期员工绩效不得为高绩效(S、A等级)
  80. if (rs.next()){
  81. //跨部门协作绩效等级
  82. String depgradelevel = rs.getString("CFDEPGRADELEVEL");
  83. if(StringUtils.isNotBlank(depgradelevel)) {
  84. switch (depgradelevel) {
  85. case "S":
  86. ;
  87. case "A":
  88. ;
  89. case "B":
  90. isSuccess = true;
  91. msg = "校验通过";
  92. success += 1;
  93. break;
  94. case "C":
  95. case "D":
  96. if ("S".equals(auditGradeLevel) || "A".equals(auditGradeLevel)) {
  97. isSuccess = false;
  98. msg = "当跨部门协作绩效等级为C、D等级的,当期员工绩效不得为高绩效(S、A等级)";
  99. fail += 1;
  100. } else {
  101. isSuccess = true;
  102. msg = "校验通过";
  103. success += 1;
  104. }
  105. break;
  106. }
  107. }else {
  108. msg="没有当跨部门协作绩效等级,请先检查跨部门协作绩效等级";
  109. isSuccess=true;
  110. success+=1;
  111. }
  112. }else {
  113. msg="操作失败,数据异常";
  114. isSuccess=false;
  115. fail+=1;
  116. }
  117. body.setMuitTipsState(isSuccess);
  118. body.setMuitTipsMessage(msg);
  119. List<Object> messageListExt = new ArrayList<>();
  120. messageListExt.add(pnumber);
  121. messageListExt.add(pname);
  122. messageListExt.add(positionName);
  123. body.addMessageListExt(messageListExt);
  124. header.addResult(body);
  125. }
  126. } catch (BOSException | SQLException var7) {
  127. var7.printStackTrace();
  128. }
  129. ids.delete(ids.length()-1,ids.length());
  130. header.setBillId(ids.toString());
  131. header.setFailureCount(fail);
  132. header.setSuccessCount(success);
  133. }
  134. this.writeSuccessData(header);
  135. }
  136. protected static void addBatchMessageTip(String unvalidEvaObj, String message, BatchMessageTipsHeader batchMessageTipsHeader) {
  137. BatchMessageTipsBody body = new BatchMessageTipsBody();
  138. body.setId(unvalidEvaObj);
  139. body.setMuitTipsState(Boolean.FALSE);
  140. body.setMuitTipsMessage(message);
  141. batchMessageTipsHeader.addResult(body);
  142. batchMessageTipsHeader.setFailureCount(batchMessageTipsHeader.getFailureCount() + 1);
  143. }
  144. /**
  145. * 获取人员项目正态分布规则
  146. *
  147. * @param ctx
  148. * @param idList 非必填
  149. * @param batchMessage 非必填
  150. * @return
  151. * @throws BOSException
  152. * @throws SQLException
  153. */
  154. public Map<String, Map<String, BigDecimal>> getProjectPerformPro(Context ctx, List<String> idList, Map<String, String> batchMessage) throws BOSException, SQLException {
  155. //获取正态分布规则
  156. Map<String, Map<String, BigDecimal>> orgLevelMap = Maps.newHashMap();
  157. PerformProTeamCollection proCollection = PerformProTeamFactory.getLocalInstance(ctx).getPerformProTeamCollection(" where status=1 ");
  158. if (proCollection.size() == 1) {
  159. StringBuilder orgPerSql = new StringBuilder();
  160. orgPerSql.append(" select fp.fid,fpe.CFS,fpe.CFA,fpe.CFB,fpe.CFC,fpe.CFD,fpe.CFORGPERFORMTYPE ");
  161. orgPerSql.append(" from CT_PF_PerformProTeam fp ");
  162. orgPerSql.append(" left join CT_PF_PerformProTeamEntry fpe on fp.fid=fpe.FPARENTID ");
  163. orgPerSql.append(" where fp.CFSTATUS = 1 ");
  164. orgPerSql.append(" order by fp.FCREATETIME ");
  165. IRowSet rs = DbUtil.executeQuery(ctx, orgPerSql.toString());
  166. while (rs.next()) {
  167. Map<String, BigDecimal> objectMap = Maps.newHashMap();
  168. String type = rs.getString("CFORGPERFORMTYPE");
  169. objectMap.put("S", rs.getBigDecimal("CFS"));
  170. objectMap.put("A", rs.getBigDecimal("CFA"));
  171. objectMap.put("B", rs.getBigDecimal("CFB"));
  172. objectMap.put("C", rs.getBigDecimal("CFC"));
  173. objectMap.put("D", rs.getBigDecimal("CFD"));
  174. orgLevelMap.put(type, objectMap);
  175. }
  176. } else if (proCollection.size() > 1) {
  177. if (null != batchMessage && null != idList) {
  178. for (String key : idList) {
  179. batchMessage.put(key, "存在多个正态分布规则,请检查!");
  180. }
  181. }
  182. } else {
  183. if (null != batchMessage && null != idList) {
  184. for (String key : idList) {
  185. batchMessage.put(key, "不存在正态分布规则,请检查!");
  186. }
  187. }
  188. }
  189. return orgLevelMap;
  190. }
  191. /**
  192. * 获取人员组织正态分布规则
  193. *
  194. * @param ctx
  195. * @param idList 非必填
  196. * @param batchMessage 非必填
  197. * @return
  198. * @throws BOSException
  199. * @throws SQLException
  200. */
  201. public Map<String, Map<String, BigDecimal>> getPersonPerformPro(Context ctx, List<String> idList, Map<String, String> batchMessage) throws BOSException, SQLException {
  202. //获取正态分布规则
  203. Map<String, Map<String, BigDecimal>> orgLevelMap = Maps.newHashMap();
  204. PersonPerformProCollection proCollection = PersonPerformProFactory.getLocalInstance(ctx).getPersonPerformProCollection(" where state=1 ");
  205. if (proCollection.size() == 1) {
  206. StringBuilder orgPerSql = new StringBuilder();
  207. orgPerSql.append(" select fp.fid,fpe.CFS,fpe.CFA,fpe.CFB,fpe.CFC,fpe.CFD,fpe.CFORGPERFORMTYPE ");
  208. orgPerSql.append(" from CT_PF_PersonPerformPro fp ");
  209. orgPerSql.append(" left join CT_PF_PersonPerformProEntry fpe on fp.fid=fpe.FPARENTID ");
  210. orgPerSql.append(" where fp.CFSTATE = 1 ");
  211. orgPerSql.append(" order by fp.FCREATETIME ");
  212. IRowSet rs = DbUtil.executeQuery(ctx, orgPerSql.toString());
  213. while (rs.next()) {
  214. Map<String, BigDecimal> objectMap = Maps.newHashMap();
  215. String type = rs.getString("CFORGPERFORMTYPE");
  216. objectMap.put("S", rs.getBigDecimal("CFS"));
  217. objectMap.put("A", rs.getBigDecimal("CFA"));
  218. objectMap.put("B", rs.getBigDecimal("CFB"));
  219. objectMap.put("C", rs.getBigDecimal("CFC"));
  220. objectMap.put("D", rs.getBigDecimal("CFD"));
  221. orgLevelMap.put(type, objectMap);
  222. }
  223. } else if (proCollection.size() > 1) {
  224. if (null != batchMessage && null != idList) {
  225. for (String key : idList) {
  226. batchMessage.put(key, "存在多个正态分布规则,请检查!");
  227. }
  228. }
  229. } else {
  230. if (null != batchMessage && null != idList) {
  231. for (String key : idList) {
  232. batchMessage.put(key, "不存在正态分布规则,请检查!");
  233. }
  234. }
  235. }
  236. return orgLevelMap;
  237. }
  238. /**
  239. * 获取人员的等级组织分组
  240. *
  241. * @param ctx
  242. * @param entryList
  243. * @return
  244. * @throws BOSException
  245. * @throws SQLException
  246. */
  247. public Map<String, Map<String, Object>> getPersonLevelLensMap(Context ctx, JSONArray entryList) throws BOSException, SQLException {
  248. Map<String, Map<String, Object>> personLevelMap = Maps.newHashMap();
  249. Map<String, BigDecimal> revLevelMap = Maps.newHashMap();
  250. for(int i=0;i<entryList.size();i++) {
  251. JSONObject object = entryList.getJSONObject(i);
  252. String id =object.getString("id");
  253. String evaResult = object.getString("evaResult.id");
  254. //修改后等级
  255. String auditGradeLevel = object.getString("evaResult.auditGradeLevel");
  256. if(StringUtils.isBlank(auditGradeLevel)){
  257. auditGradeLevel= object.getString("evaResult.gradeLevel");
  258. }
  259. BigDecimal l = revLevelMap.get(auditGradeLevel);
  260. if(Objects.isNull(l)){
  261. l=BigDecimal.ZERO;
  262. }
  263. l=l.add(BigDecimal.ONE);
  264. revLevelMap.put(auditGradeLevel, l);
  265. }
  266. for(int i=0;i<entryList.size();i++) {
  267. JSONObject object = entryList.getJSONObject(i);
  268. String id =object.getString("id");
  269. String evaResult = object.getString("evaResult.id");
  270. //修改后等级
  271. String auditGradeLevel = object.getString("evaResult.auditGradeLevel");
  272. if(StringUtils.isBlank(auditGradeLevel)){
  273. auditGradeLevel= object.getString("evaResult.gradeLevel");
  274. }
  275. Map<String, Object> map = Maps.newHashMap();
  276. String key = auditGradeLevel;
  277. map.put("lens", revLevelMap.get(auditGradeLevel));
  278. map.put("id",id);
  279. map.put("evaResult",evaResult);
  280. map.put("revLevel",auditGradeLevel);
  281. personLevelMap.put(key, map);
  282. }
  283. return personLevelMap;
  284. }
  285. /**
  286. * 根据上季度的组织等级,校验当前周期,当前考核计划,所选员工的所属组织的员工绩效等级分布校验
  287. *
  288. * @param request
  289. * @param response
  290. * @param modelMap
  291. * @param batchMessageTipsHeader
  292. * @throws SHRWebException
  293. */
  294. public void beforeAuditEvaResutAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap, BatchMessageTipsHeader batchMessageTipsHeader) throws SHRWebException {
  295. Context ctx = SHRContext.getInstance().getContext();
  296. String ids = (String) request.getParameter("ids");
  297. String period = (String) request.getParameter("period");
  298. String planId = (String) request.getParameter("planId");
  299. String entryData = request.getParameter("entryData");
  300. if (ids == null) {
  301. throw new ShrWebBizException(new SHRPerfWebBizException(SHRPerfWebBizException.SYSTEMERR));
  302. }
  303. try {
  304. List<String> idList = Lists.newArrayList();
  305. Set<String> idSet = Sets.newHashSet(idList);
  306. for (String id : ids.split(",")) {
  307. idList.add(id);
  308. }
  309. //明细数据
  310. JSONArray entryList = JSON.parseArray(entryData);
  311. StringBuilder planSql = new StringBuilder();
  312. planSql.append("select fid,CFPerobjectIdId from T_EVA_PerfPlan where fid=? and CFPerobjectIdId is not null ");
  313. IRowSet rs = DbUtil.executeQuery(ctx, planSql.toString(), new Object[]{planId});
  314. if (rs.next()) {
  315. String CFPerobjectIdId = rs.getString("CFPerobjectIdId");
  316. Map<String, String> batchMessage = this.beforeAuditProjectEvaResut(ctx, period, planId, idList,entryList);
  317. if (null != batchMessage && batchMessage.size() > 0) {
  318. for (Map.Entry<String, String> entry : batchMessage.entrySet()) {
  319. addBatchMessageTip(entry.getKey(), entry.getValue(), batchMessageTipsHeader);
  320. idSet.remove(entry.getKey());
  321. }
  322. }
  323. } else {
  324. Map<String, String> batchMessage = this.beforeAuditEvaResut(ctx, period, planId, idList,entryList);
  325. if (null != batchMessage && batchMessage.size() > 0) {
  326. for (Map.Entry<String, String> entry : batchMessage.entrySet()) {
  327. addBatchMessageTip(entry.getKey(), entry.getValue(), batchMessageTipsHeader);
  328. idSet.remove(entry.getKey());
  329. }
  330. }
  331. //addBatchMessageSuccessTips(idSet,"验证成功",batchMessageTipsHeader);
  332. }
  333. this.setSuccessMessage("验证成功");
  334. } catch (Exception e) {
  335. e.printStackTrace();
  336. throw new ShrWebBizException(e);
  337. }
  338. }
  339. public Map<String, String> beforeAuditProjectEvaResut(Context ctx, String period, String planId, List<String> idList,JSONArray entryList ) throws BOSException, SQLException {
  340. Map<String, String> batchMessage = Maps.newHashMap();
  341. StringBuilder selParamId = new StringBuilder("''");
  342. for (int i = 0; i < idList.size(); i++) {
  343. selParamId.append(",?");
  344. }
  345. //获取正态分布规则
  346. Map<String, Map<String, BigDecimal>> personPerformMap = this.getProjectPerformPro(ctx, idList, batchMessage);
  347. if (null != personPerformMap && personPerformMap.size() > 0) {
  348. //获取组织分组人数
  349. //Map<String, Map<String, String>> orgLevelMap = this.getProjectLevelCountMap(ctx, period, planId,selParamId, idList);
  350. //获取人员等级分组
  351. Map<String, Map<String, Object>> personLevelMap = this.getPersonLevelLensMap(ctx,entryList);
  352. BigDecimal big100 = new BigDecimal(100);
  353. for(int i=0;i<entryList.size();i++) {
  354. JSONObject object = entryList.getJSONObject(i);
  355. String fid =object.getString("id");
  356. String evaResult = object.getString("evaResult.id");
  357. //修改后等级
  358. String auditGradeLevel = object.getString("evaResult.auditGradeLevel");
  359. if(StringUtils.isBlank(auditGradeLevel)){
  360. auditGradeLevel= object.getString("evaResult.gradeLevel");
  361. }
  362. String revLevel = auditGradeLevel;
  363. if (StrUtil.isBlank(auditGradeLevel)) {
  364. batchMessage.put(fid, "绩效等级为空,请维护");
  365. continue;
  366. }
  367. StringBuilder sel = new StringBuilder();
  368. sel.append(" select s1.fid,ppm.CFPROJECTNAME, pp.CFPerobjectIdId, s1.FPERIODID, s1.FEVAPLANID,");
  369. sel.append(" isnull(s1.FREVISEGRADELEVEL,s1.FGRADELEVEL) revLevel,s1.CFProjectLevel ");
  370. sel.append(" from T_EVA_EvaResultSummary s1 ");
  371. sel.append(" left join T_EVA_PerfPlan pp on pp.fid = s1.FEVAPLANID ");
  372. sel.append(" left join CT_PRO_ProjectManagement ppm on ppm.fid = pp.CFPerobjectIdId ");
  373. sel.append(" where s1.fid in ('");
  374. sel.append(evaResult);
  375. sel.append("') ");
  376. IRowSet rs = DbUtil.executeQuery(ctx, sel.toString(), idList.toArray());
  377. if (!rs.next()){
  378. batchMessage.put(fid, "绩效等级为空,请维护");
  379. continue;
  380. }
  381. String CFPROJECTNAME = rs.getString("CFPROJECTNAME");
  382. if (StrUtil.isBlank(revLevel)) {
  383. //String msg = String.format("%s绩效等级为空", CFPROJECTNAME);
  384. batchMessage.put(fid, "绩效等级为空,请维护");
  385. continue;
  386. }
  387. //项目绩效等级
  388. String projectLevel = rs.getString("CFProjectLevel");
  389. if (StrUtil.isBlank(projectLevel)) {
  390. String msg = String.format("%s项目绩效等级为空", CFPROJECTNAME);
  391. batchMessage.put(fid, msg);
  392. continue;
  393. }
  394. //该组织的组织绩效等级的正态分布
  395. Map<String, BigDecimal> personPerform = personPerformMap.get(projectLevel);
  396. if (null == personPerform) {
  397. String msg = String.format("没有找到%s项目绩效等级%s的正态分布规则", CFPROJECTNAME, projectLevel);
  398. batchMessage.put(fid, msg);
  399. continue;
  400. }
  401. //获取该组织下的人员总数
  402. //Map<String, String> orgMap = orgLevelMap.get(key);
  403. //获取该组织下的人员各个绩效等级分组汇总
  404. // String keyRevLevel = FADMINORGUNITID + FPERIODID + FEVAPLANID + revLevel;
  405. // Map<String, String> personMap = personLevelMap.get(keyRevLevel);
  406. Map<String, BigDecimal> leveList = Maps.newHashMap();
  407. //获取该组织下的人员总数
  408. //Map<String, String> orgMap = orgLevelMap.get(key);
  409. //获取等级D人数
  410. String keyRevLevelD = "D";
  411. Map<String, Object> personMapD = personLevelMap.get(keyRevLevelD);
  412. BigDecimal dLens = BigDecimal.ZERO;
  413. if (null != personMapD) {
  414. dLens = (BigDecimal) personMapD.get("lens");
  415. leveList.put("D", dLens);
  416. }
  417. //获取等级C人数
  418. String keyRevLevelC = "C";
  419. Map<String, Object> personMapC = personLevelMap.get(keyRevLevelC);
  420. BigDecimal cLens = BigDecimal.ZERO;
  421. if (null != personMapC) {
  422. cLens = (BigDecimal) personMapC.get("lens");
  423. leveList.put("C", cLens);
  424. }
  425. //获取等级B人数
  426. String keyRevLevelB = "B";
  427. Map<String, Object> personMapB = personLevelMap.get(keyRevLevelB);
  428. BigDecimal bLens = BigDecimal.ZERO;
  429. if (null != personMapB) {
  430. bLens = (BigDecimal) personMapB.get("lens");
  431. leveList.put("B", bLens);
  432. }
  433. //获取等级A人数
  434. String keyRevLevelA = "A";
  435. Map<String, Object> personMapA = personLevelMap.get(keyRevLevelA);
  436. BigDecimal aLens = BigDecimal.ZERO;
  437. if (null != personMapA) {
  438. aLens = (BigDecimal) personMapA.get("lens");
  439. leveList.put("A", aLens);
  440. }
  441. //获取等级S人数
  442. String keyRevLevelS = "S";
  443. Map<String, Object> personMapS = personLevelMap.get(keyRevLevelS);
  444. BigDecimal sLens = BigDecimal.ZERO;
  445. if (null != personMapS) {
  446. sLens = (BigDecimal) personMapS.get("lens");
  447. leveList.put("S", sLens);
  448. }
  449. //总人数
  450. BigDecimal alls = new BigDecimal(idList.size());
  451. //当前等级正态分布比例
  452. BigDecimal scale = personPerform.get(revLevel);
  453. //创建每个等级的人数列表
  454. Map<String, BigDecimal> bigsList = Maps.newHashMap();
  455. BigDecimal bigS = ((personPerform.get("S").divide(big100, BigDecimal.ROUND_HALF_UP, BigDecimal.ROUND_HALF_UP)).multiply(alls).setScale(0, BigDecimal.ROUND_HALF_UP));
  456. bigsList.put("S", bigS);
  457. BigDecimal bigA = ((personPerform.get("A").divide(big100, BigDecimal.ROUND_HALF_UP, BigDecimal.ROUND_HALF_UP)).multiply(alls).setScale(0, BigDecimal.ROUND_HALF_UP));
  458. bigsList.put("A", bigA);
  459. BigDecimal bigB = ((personPerform.get("B").divide(big100, BigDecimal.ROUND_HALF_UP, BigDecimal.ROUND_HALF_UP)).multiply(alls).setScale(0, BigDecimal.ROUND_HALF_UP));
  460. bigsList.put("B", bigB);
  461. BigDecimal bigC = ((personPerform.get("C").divide(big100, BigDecimal.ROUND_HALF_UP, BigDecimal.ROUND_HALF_UP)).multiply(alls).setScale(0, BigDecimal.ROUND_HALF_UP));
  462. bigsList.put("C", bigC);
  463. BigDecimal bigD = ((personPerform.get("D").divide(big100, BigDecimal.ROUND_HALF_UP, BigDecimal.ROUND_HALF_UP)).multiply(alls).setScale(0, BigDecimal.ROUND_HALF_UP));
  464. bigsList.put("D", bigD);
  465. //已占用数
  466. BigDecimal lens = BigDecimal.ZERO;
  467. //进行额度加减
  468. BigDecimal personSize = BigDecimal.ZERO;
  469. BigDecimal personMaxSize = BigDecimal.ZERO;
  470. BigDecimal personMinSize = BigDecimal.ZERO;
  471. List<String> ldrs = Lists.newArrayList();
  472. Map<String,String> ldrcd = Maps.newHashMap();
  473. switch (revLevel) {
  474. case "A":
  475. personSize = personSize.add(bigA).subtract(aLens);
  476. lens = lens.add(aLens);
  477. if ("A".equals(revLevel)) {
  478. personMaxSize = personMaxSize.add((bigA));
  479. } else {
  480. personMaxSize = personMaxSize.add((bigA).subtract(aLens));
  481. }
  482. ldrs.add("A最多%A人,");
  483. //bigsList.remove("A");
  484. case "S":
  485. personSize = personSize.add(bigS).subtract(sLens);
  486. lens = lens.add(sLens);
  487. if ("S".equals(revLevel)) {
  488. personMaxSize = personMaxSize.add((bigS));
  489. } else {
  490. personMaxSize = personMaxSize.add((bigS).subtract(sLens));
  491. }
  492. ldrs.add("S最多%S人,");
  493. //bigsList.remove("S");
  494. case "B":
  495. case "C":
  496. if ("C".equals(revLevel)) {
  497. personMinSize = personMinSize.add((bigC));
  498. } else {
  499. personMinSize = personMinSize.add((bigC).subtract(cLens));
  500. }
  501. ldrcd.put("C","C最少"+(personMinSize.compareTo(BigDecimal.ZERO) > 0?personMinSize.toPlainString():'0')+"人,");
  502. //bigsList.remove("C");
  503. case "D":
  504. if ("D".equals(revLevel)) {
  505. personMinSize = personMinSize.add((bigD));
  506. } else {
  507. personMinSize = personMinSize.add((bigD).subtract(dLens));
  508. }
  509. ldrcd.put("D","D最少"+(personMinSize.compareTo(BigDecimal.ZERO) > 0?personMinSize.toPlainString():'0')+"人,");
  510. }
  511. String ld = "当前周期绩效等级为%l的人数为%maxs人,";
  512. if (personMinSize.compareTo(BigDecimal.ZERO) > 0 || personSize.compareTo(BigDecimal.ZERO) < 0) {
  513. if(ldrs.size()>0) {
  514. String ldrstr = ldrs.get(0);
  515. ld += ldrstr;
  516. ld = ld.replace("%" + revLevel, (personMaxSize.compareTo(BigDecimal.ZERO) > 0 ? (personMaxSize) : BigDecimal.ZERO).toPlainString());
  517. }
  518. ld = ld.replace("%l", revLevel);
  519. ld = ld.replace("%maxs", (leveList.get(revLevel) == null ? BigDecimal.ZERO : leveList.get(revLevel)).toPlainString());
  520. for (Map.Entry<String,String> entry : ldrcd.entrySet()) {
  521. String eKey = entry.getKey();
  522. String ldr= entry.getValue();
  523. ld += ldr;
  524. }
  525. ld += "请修正后重新审核.";
  526. batchMessage.put(fid, ld);
  527. }
  528. }
  529. }
  530. return batchMessage;
  531. }
  532. /**
  533. * 结果直接审核、结果工作流审核,绩效等级分布比例校验人数由整个绩效考核计划的人数改为按选择的人数进行分布比例校验。
  534. *
  535. * @param ctx
  536. * @param period
  537. * @param planId
  538. * @param idList
  539. * @return
  540. * @throws BOSException
  541. * @throws SQLException
  542. */
  543. public Map<String, String> beforeAuditEvaResut(Context ctx, String period, String planId, List<String> idList,JSONArray entryList) throws BOSException, SQLException {
  544. Map<String, String> batchMessage = Maps.newHashMap();
  545. StringBuilder selParamId = new StringBuilder("''");
  546. for (int i = 0; i < idList.size(); i++) {
  547. selParamId.append(",?");
  548. }
  549. //获取正态分布规则
  550. Map<String, Map<String, BigDecimal>> personPerformMap = this.getPersonPerformPro(ctx, idList, batchMessage);
  551. if (null != personPerformMap && personPerformMap.size() > 0) {
  552. //获取组织分组人数
  553. //Map<String, Map<String, String>> orgLevelMap = this.getOrgLevelCountMap(ctx, period, planId);
  554. //获取人员等级分组
  555. Map<String, Map<String, Object>> personLevelMap = this.getPersonLevelLensMap(ctx, entryList);
  556. BigDecimal big100 = new BigDecimal(100);
  557. for(int i=0;i<entryList.size();i++) {
  558. JSONObject object = entryList.getJSONObject(i);
  559. String fid = object.getString("id");
  560. String evaResult = object.getString("evaResult.id");
  561. //修改后等级
  562. String auditGradeLevel = object.getString("evaResult.auditGradeLevel");
  563. if(StringUtils.isBlank(auditGradeLevel)){
  564. auditGradeLevel= object.getString("evaResult.gradeLevel");
  565. }
  566. if (StrUtil.isBlank(auditGradeLevel)) {
  567. batchMessage.put(fid, "绩效等级为空,请维护");
  568. continue;
  569. }
  570. StringBuilder sel = new StringBuilder();
  571. sel.append(" select ers.fid,ers.FADMINORGNAME, ");
  572. sel.append(" ers.FPERIODID, ers.FEVAPLANID,isnull(ers.FREVISEGRADELEVEL, ers.FGRADELEVEL) revLevel,ers.CFOrgLevel ");
  573. sel.append(" from T_EVA_EvaResultSummary ers where ers.fid = '");
  574. sel.append(evaResult);
  575. sel.append("' ");
  576. IRowSet rs = DbUtil.executeQuery(ctx, sel.toString());
  577. String orgLevel="";
  578. String FADMINORGNAME ="";
  579. //上季度组织绩效等级
  580. if (rs.next()){
  581. orgLevel = rs.getString("CFOrgLevel");
  582. FADMINORGNAME = rs.getString("FADMINORGNAME");
  583. if (StringUtils.isBlank(orgLevel)) {
  584. String msg = String.format("%s上季度组织绩效等级为空", FADMINORGNAME);
  585. batchMessage.put(fid, msg);
  586. continue;
  587. }
  588. }
  589. //该组织的组织绩效等级的正态分布
  590. Map<String, BigDecimal> personPerform = personPerformMap.get(orgLevel);
  591. if (null == personPerform) {
  592. String msg = String.format("没有找到%s上季度组织绩效等级%s的正态分布规则", FADMINORGNAME, orgLevel);
  593. batchMessage.put(fid, msg);
  594. continue;
  595. }
  596. //获取该组织下的人员总数
  597. //Map<String, String> orgMap = orgLevelMap.get(key);
  598. Map<String, BigDecimal> leveList = Maps.newHashMap();
  599. //获取等级D人数
  600. String keyRevLevelD = "D";
  601. Map<String, Object> personMapD = personLevelMap.get(keyRevLevelD);
  602. BigDecimal dLens = BigDecimal.ZERO;
  603. if (null != personMapD) {
  604. dLens = (BigDecimal) personMapD.get("lens");
  605. leveList.put("D", dLens);
  606. }
  607. //获取等级C人数
  608. String keyRevLevelC = "C";
  609. Map<String, Object> personMapC = personLevelMap.get(keyRevLevelC);
  610. BigDecimal cLens = BigDecimal.ZERO;
  611. if (null != personMapC) {
  612. cLens = (BigDecimal) personMapC.get("lens");
  613. leveList.put("C", cLens);
  614. }
  615. //获取等级B人数
  616. String keyRevLevelB = "B";
  617. Map<String, Object> personMapB = personLevelMap.get(keyRevLevelB);
  618. BigDecimal bLens = BigDecimal.ZERO;
  619. if (null != personMapB) {
  620. bLens = (BigDecimal) personMapB.get("lens");
  621. leveList.put("B", bLens);
  622. }
  623. //获取等级A人数
  624. String keyRevLevelA = "A";
  625. Map<String, Object> personMapA = personLevelMap.get(keyRevLevelA);
  626. BigDecimal aLens = BigDecimal.ZERO;
  627. if (null != personMapA) {
  628. aLens = (BigDecimal) personMapA.get("lens");
  629. leveList.put("A", aLens);
  630. }
  631. //获取等级S人数
  632. String keyRevLevelS = "S";
  633. Map<String, Object> personMapS = personLevelMap.get(keyRevLevelS);
  634. BigDecimal sLens = BigDecimal.ZERO;
  635. if (null != personMapS) {
  636. sLens = (BigDecimal) personMapS.get("lens");
  637. leveList.put("S", sLens);
  638. }
  639. System.out.println("leveList:"+leveList);
  640. //总人数
  641. BigDecimal alls = new BigDecimal(idList.size());
  642. //当前等级正态分布比例
  643. BigDecimal scale = personPerform.get(auditGradeLevel);
  644. //创建每个等级的人数列表
  645. Map<String, BigDecimal> bigsList = Maps.newHashMap();
  646. BigDecimal bigS = ((personPerform.get("S").divide(big100, BigDecimal.ROUND_HALF_UP, BigDecimal.ROUND_HALF_UP)).multiply(alls).setScale(0, BigDecimal.ROUND_HALF_UP));
  647. bigsList.put("S", bigS);
  648. BigDecimal bigA = ((personPerform.get("A").divide(big100, BigDecimal.ROUND_HALF_UP, BigDecimal.ROUND_HALF_UP)).multiply(alls).setScale(0, BigDecimal.ROUND_HALF_UP));
  649. bigsList.put("A", bigA);
  650. BigDecimal bigB = ((personPerform.get("B").divide(big100, BigDecimal.ROUND_HALF_UP, BigDecimal.ROUND_HALF_UP)).multiply(alls).setScale(0, BigDecimal.ROUND_HALF_UP));
  651. bigsList.put("B", bigB);
  652. BigDecimal bigC = ((personPerform.get("C").divide(big100, BigDecimal.ROUND_HALF_UP, BigDecimal.ROUND_HALF_UP)).multiply(alls).setScale(0, BigDecimal.ROUND_HALF_UP));
  653. bigsList.put("C", bigC);
  654. BigDecimal bigD = ((personPerform.get("D").divide(big100, BigDecimal.ROUND_HALF_UP, BigDecimal.ROUND_HALF_UP)).multiply(alls).setScale(0, BigDecimal.ROUND_HALF_UP));
  655. bigsList.put("D", bigD);
  656. System.out.println("bigsList:"+bigsList);
  657. //已占用数
  658. BigDecimal lens = BigDecimal.ZERO;
  659. //进行额度加减
  660. //if ("S".equals(revLevel) || "A".equals(revLevel)||"B".equals(revLevel) || "C".equals(revLevel) || "D".equals(revLevel)) {
  661. BigDecimal personSize = BigDecimal.ZERO;
  662. BigDecimal personMaxSize = BigDecimal.ZERO;
  663. BigDecimal personMinSize = BigDecimal.ZERO;
  664. List<String> ldrs = Lists.newArrayList();
  665. Map<String,String> ldrcd = Maps.newHashMap();
  666. switch (auditGradeLevel) {
  667. case "A":
  668. personSize = personSize.add(bigA).subtract(aLens);
  669. lens = lens.add(aLens);
  670. if ("A".equals(auditGradeLevel)) {
  671. personMaxSize = personMaxSize.add((bigA));
  672. } else {
  673. personMaxSize = personMaxSize.add((bigA).subtract(aLens));
  674. }
  675. ldrs.add("A最多%A人,");
  676. //bigsList.remove("A");
  677. case "S":
  678. personSize = personSize.add(bigS).subtract(sLens);
  679. lens = lens.add(sLens);
  680. if ("S".equals(auditGradeLevel)) {
  681. personMaxSize = personMaxSize.add((bigS));
  682. } else {
  683. personMaxSize = personMaxSize.add((bigS).subtract(sLens));
  684. }
  685. ldrs.add("S最多%S人,");
  686. //bigsList.remove("S");
  687. case "B":
  688. case "C":
  689. if ("C".equals(auditGradeLevel)) {
  690. personMinSize = personMinSize.add((bigC));
  691. } else {
  692. personMinSize = personMinSize.add((bigC).subtract(cLens));
  693. }
  694. ldrcd.put("C","C最少"+(personMinSize.compareTo(BigDecimal.ZERO) > 0?personMinSize.toPlainString():'0')+"人,");
  695. //bigsList.remove("C");
  696. case "D":
  697. // if (bigD.compareTo(dLens) > 0) {
  698. // ldrcd.add("D最少" + bigD.toPlainString() + "人,");
  699. // }
  700. if ("D".equals(auditGradeLevel)) {
  701. personMinSize = personMinSize.add((bigD));
  702. } else {
  703. personMinSize = personMinSize.add((bigD).subtract(dLens));
  704. }
  705. ldrcd.put("D","D最少"+(personMinSize.compareTo(BigDecimal.ZERO) > 0?personMinSize.toPlainString():'0')+"人,");
  706. }
  707. String ld = "当前周期绩效等级为%l的人数为%maxs人,";
  708. if (personMinSize.compareTo(BigDecimal.ZERO) > 0 || personSize.compareTo(BigDecimal.ZERO) < 0) {
  709. if(ldrs.size()>0){
  710. String ldrstr = ldrs.get(0);
  711. ld += ldrstr;
  712. ld = ld.replace("%" + auditGradeLevel, (personMaxSize.compareTo(BigDecimal.ZERO) > 0 ? (personMaxSize) : BigDecimal.ZERO).toPlainString());
  713. }
  714. ld = ld.replace("%l", auditGradeLevel);
  715. ld = ld.replace("%maxs", (leveList.get(auditGradeLevel) == null ? BigDecimal.ZERO : leveList.get(auditGradeLevel)).toPlainString());
  716. for (Map.Entry<String,String> entry : ldrcd.entrySet()) {
  717. String eKey = entry.getKey();
  718. String ldr= entry.getValue();
  719. ld += ldr;
  720. }
  721. ld += "请修正后重新审核.";
  722. batchMessage.put(fid, ld);
  723. }
  724. }
  725. }
  726. return batchMessage;
  727. }
  728. }