ExpandAssessServiceImpl.java 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. package com.kingdee.eas.custom.expandassess.service.impl;
  2. import com.kingdee.bos.BOSException;
  3. import com.kingdee.bos.Context;
  4. import com.kingdee.bos.metadata.entity.*;
  5. import com.kingdee.bos.metadata.query.util.CompareType;
  6. import com.kingdee.eas.common.EASBizException;
  7. import com.kingdee.eas.custom.expandassess.*;
  8. import com.kingdee.eas.custom.expandassess.app.ExpandStatusEunm;
  9. import com.kingdee.eas.custom.expandassess.app.PeriodStatusEnum;
  10. import com.kingdee.eas.custom.expandassess.service.ExpandAssessService;
  11. import com.kingdee.eas.framework.CoreBaseCollection;
  12. import com.kingdee.eas.hr.ats.AtsUtil;
  13. import com.kingdee.eas.util.app.ContextUtil;
  14. import com.kingdee.shr.base.syssetting.exception.ShrWebBizException;
  15. import com.kingdee.util.StringUtils;
  16. import java.util.HashSet;
  17. import java.util.Set;
  18. /**
  19. * @author qingwu
  20. * @date 2024/5/17
  21. * @apiNote
  22. */
  23. public class ExpandAssessServiceImpl implements ExpandAssessService {
  24. @Override
  25. public boolean verifyeriodLockOrNot(Context ctx, String billId) throws BOSException, ShrWebBizException {
  26. IExpandAssess iExpandAssess = ExpandAssessFactory.getLocalInstance(ctx);
  27. ExpandAssessCollection expandAssessCollection = iExpandAssess.getExpandAssessCollection("where id = '" + billId + "'");
  28. if (expandAssessCollection.size() > 0) {
  29. ExpandAssessInfo expandAssessInfo = expandAssessCollection.get(0);
  30. if (expandAssessInfo.getPeriodStatus() == PeriodStatusEnum.LOCK) {
  31. return true;
  32. }
  33. }
  34. return false;
  35. }
  36. @Override
  37. public QuarterlyRatioCollection getQuarterlyRatioByYear(Context ctx, int year) throws BOSException {
  38. //季度比例
  39. IQuarterlyRatio iQuarterlyRatio = QuarterlyRatioFactory.getLocalInstance(ctx);
  40. QuarterlyRatioCollection quarterlyRatioCollection = iQuarterlyRatio.getQuarterlyRatioCollection(" where year = '" + year + "'");
  41. if (quarterlyRatioCollection.size() > 0) {
  42. QuarterlyRatioInfo quarterlyRatioInfo = quarterlyRatioCollection.get(0);
  43. if (quarterlyRatioInfo.getQuarterOne() != 0 ||
  44. quarterlyRatioInfo.getQuarterTwo() != 0 ||
  45. quarterlyRatioInfo.getQuarterThree() != 0 ||
  46. quarterlyRatioInfo.getQuarterFour() != 0) {
  47. return quarterlyRatioCollection;
  48. } else {
  49. return null;
  50. }
  51. } else {
  52. return null;
  53. }
  54. }
  55. @Override
  56. public ExpandAssessEntryCollection qeruyEntryByBillIdAndAdminOrg(Context ctx, String billId, String adminOrgId) throws BOSException {
  57. IExpandAssessEntry iExpandAssessEntry = ExpandAssessEntryFactory.getLocalInstance(ctx);
  58. //当前登录员工id
  59. String currentPersonId = ContextUtil.getCurrentUserInfo(ctx).getPerson().getId().toString();
  60. FilterInfo filterInfo = new FilterInfo();
  61. filterInfo.getFilterItems().add(new FilterItemInfo("parent.id", billId));
  62. filterInfo.getFilterItems().add(new FilterItemInfo("adminOrg.id", adminOrgId));
  63. filterInfo.getFilterItems().add(new FilterItemInfo("assestatus", 3));
  64. filterInfo.getFilterItems().add(new FilterItemInfo("principal.id", currentPersonId));
  65. SelectorItemCollection sic = new SelectorItemCollection();
  66. sic.add("parent.*");
  67. sic.add("*");
  68. EntityViewInfo entityViewInfo = EntityViewInfo.getInstance(filterInfo, sic, null);
  69. return iExpandAssessEntry.getExpandAssessEntryCollection(entityViewInfo);
  70. }
  71. @Override
  72. public void updateAsseStatusAll(Context ctx, String idArray, ExpandStatusEunm eunm1, ExpandStatusEunm eunm2, String errorText) throws BOSException, ShrWebBizException, EASBizException {
  73. IExpandAssessEntry iExpandAssessEntry = ExpandAssessEntryFactory.getLocalInstance(ctx);
  74. FilterInfo filterInfo = new FilterInfo();
  75. filterInfo.getFilterItems().add(new FilterItemInfo("id", AtsUtil.toSet(idArray), CompareType.INCLUDE));
  76. EntityViewInfo entityViewInfo = EntityViewInfo.getInstance(filterInfo, null, null);
  77. ExpandAssessEntryCollection expandAssessEntryCollection = iExpandAssessEntry.getExpandAssessEntryCollection(entityViewInfo);
  78. CoreBaseCollection collection = new CoreBaseCollection();
  79. if (expandAssessEntryCollection.size() > 0) {
  80. for (int i = 0; i < expandAssessEntryCollection.size(); i++) {
  81. ExpandAssessEntryInfo expandAssessEntryInfo = expandAssessEntryCollection.get(i);
  82. if (expandAssessEntryInfo.getAsseStatus() == eunm1) {
  83. expandAssessEntryInfo.setAsseStatus(eunm2);
  84. collection.add(expandAssessEntryInfo);
  85. } else {
  86. throw new ShrWebBizException(errorText);
  87. }
  88. }
  89. }
  90. iExpandAssessEntry.updateBatchData(collection);
  91. }
  92. /**
  93. * 获取当前登录人等于评分人的数据
  94. *
  95. * @param billId
  96. * @return
  97. */
  98. public ExpandAssessEntryCollection getCurrentPersonEqualsPrincipal(Context ctx, String billId) throws ShrWebBizException, BOSException {
  99. //当前登录员工id
  100. String currentPersonId = ContextUtil.getCurrentUserInfo(ctx).getPerson().getId().toString();
  101. if (StringUtils.isEmpty(billId)) {
  102. throw new ShrWebBizException("拓展人员考核周期ID不可为空!");
  103. }
  104. IExpandAssessEntry iExpandAssessEntry = ExpandAssessEntryFactory.getLocalInstance(ctx);
  105. SelectorItemCollection sic = new SelectorItemCollection();
  106. sic.add("*");
  107. sic.add("assessor.name");
  108. sic.add("adminOrg.name");
  109. sic.add("principal.name");
  110. FilterInfo filterInfo = new FilterInfo();
  111. FilterItemCollection filterItems = filterInfo.getFilterItems();
  112. filterItems.add(new FilterItemInfo("parent.id", billId));
  113. filterItems.add(new FilterItemInfo("principal.id", currentPersonId));
  114. filterItems.add(new FilterItemInfo("assestatus", 3));
  115. EntityViewInfo entityViewInfo = EntityViewInfo.getInstance(filterInfo, sic, null);
  116. return iExpandAssessEntry.getExpandAssessEntryCollection(entityViewInfo);
  117. }
  118. /**
  119. * 过滤组织
  120. */
  121. @Override
  122. public String getAdminOrgFilter(Context ctx, String billID) throws ShrWebBizException, BOSException {
  123. ExpandAssessEntryCollection entrys = getCurrentPersonEqualsPrincipal(ctx, billID);
  124. Set set = new HashSet<>();
  125. StringBuilder sb = new StringBuilder();
  126. //去重操作
  127. for (int i = entrys.size() - 1; i >= 0; i--) {
  128. ExpandAssessEntryInfo expandAssessEntryInfo = entrys.get(i);
  129. String adminId = expandAssessEntryInfo.getAdminOrg().getId().toString();
  130. if (set.contains(adminId)) {
  131. entrys.remove(expandAssessEntryInfo);
  132. } else {
  133. set.add(adminId);
  134. sb.append("'").append(adminId).append("',");
  135. }
  136. }
  137. // 删除最后一个逗号
  138. if (sb.length() > 0) {
  139. sb.deleteCharAt(sb.length() - 1);
  140. }
  141. return sb.toString();
  142. }
  143. @Override
  144. public void verifyStatus(String trs) {
  145. }
  146. @Override
  147. public void deleteExpandAssessEntry(Context ctx, String idArray) throws BOSException, ShrWebBizException, EASBizException {
  148. IExpandAssessEntry iExpandAssessEntry = ExpandAssessEntryFactory.getLocalInstance(ctx);
  149. FilterInfo filterInfo = new FilterInfo();
  150. filterInfo.getFilterItems().add(new FilterItemInfo("id", AtsUtil.toSet(idArray), CompareType.INCLUDE));
  151. EntityViewInfo entityViewInfo = EntityViewInfo.getInstance(filterInfo, null, null);
  152. ExpandAssessEntryCollection expandAssessEntryCollection = iExpandAssessEntry.getExpandAssessEntryCollection(entityViewInfo);
  153. if (expandAssessEntryCollection.size() > 0) {
  154. for (int i = 0; i < expandAssessEntryCollection.size(); i++) {
  155. ExpandAssessEntryInfo expandAssessEntryInfo = expandAssessEntryCollection.get(i);
  156. if (expandAssessEntryInfo.getAsseStatus() == (ExpandStatusEunm.START) ||
  157. expandAssessEntryInfo.getAsseStatus() == (ExpandStatusEunm.ASSESUBMINT) ||
  158. expandAssessEntryInfo.getAsseStatus() == (ExpandStatusEunm.PRINCIPALSUBMIT)) {
  159. throw new ShrWebBizException("只能删除未启动考核的数据!!");
  160. }
  161. }
  162. }
  163. iExpandAssessEntry.delete(filterInfo);
  164. }
  165. @Override
  166. public ExpandAssessEntryCollection getEntrysByBill(Context ctx, String billId) throws ShrWebBizException, BOSException {
  167. if (StringUtils.isEmpty(billId)) {
  168. throw new ShrWebBizException("拓展人员考核周期ID不可为空!");
  169. }
  170. IExpandAssessEntry iExpandAssessEntry = ExpandAssessEntryFactory.getLocalInstance(ctx);
  171. SelectorItemCollection sic = new SelectorItemCollection();
  172. sic.add("*");
  173. sic.add("assessor.name");
  174. sic.add("adminOrg.name");
  175. sic.add("principal.name");
  176. FilterInfo filterInfo = new FilterInfo();
  177. FilterItemCollection filterItems = filterInfo.getFilterItems();
  178. filterItems.add(new FilterItemInfo("parent.id", billId));
  179. EntityViewInfo entityViewInfo = EntityViewInfo.getInstance(filterInfo, sic, null);
  180. return iExpandAssessEntry.getExpandAssessEntryCollection(entityViewInfo);
  181. }
  182. }