ExpandAssessServiceImpl.java 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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, String adminId) 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.*");
  108. sic.add("adminOrg.*");
  109. sic.add("principal.*");
  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. if (!StringUtils.isEmpty(adminId)) {
  116. filterItems.add(new FilterItemInfo("adminOrg.id", adminId));
  117. }
  118. EntityViewInfo entityViewInfo = EntityViewInfo.getInstance(filterInfo, sic, null);
  119. return iExpandAssessEntry.getExpandAssessEntryCollection(entityViewInfo);
  120. }
  121. /**
  122. * 过滤组织
  123. */
  124. @Override
  125. public String getAdminOrgFilter(Context ctx, String billID) throws ShrWebBizException, BOSException {
  126. ExpandAssessEntryCollection entrys = getCurrentPersonEqualsPrincipal(ctx, billID, "");
  127. Set set = new HashSet<>();
  128. StringBuilder sb = new StringBuilder();
  129. //去重操作
  130. for (int i = entrys.size() - 1; i >= 0; i--) {
  131. ExpandAssessEntryInfo expandAssessEntryInfo = entrys.get(i);
  132. String adminId = expandAssessEntryInfo.getAdminOrg().getId().toString();
  133. if (set.contains(adminId)) {
  134. entrys.remove(expandAssessEntryInfo);
  135. } else {
  136. set.add(adminId);
  137. sb.append("'").append(adminId).append("',");
  138. }
  139. }
  140. // 删除最后一个逗号
  141. if (sb.length() > 0) {
  142. sb.deleteCharAt(sb.length() - 1);
  143. }
  144. return sb.toString();
  145. }
  146. @Override
  147. public void verifyStatus(String trs) {
  148. }
  149. @Override
  150. public void deleteExpandAssessEntry(Context ctx, String idArray) throws BOSException, ShrWebBizException, EASBizException {
  151. IExpandAssessEntry iExpandAssessEntry = ExpandAssessEntryFactory.getLocalInstance(ctx);
  152. FilterInfo filterInfo = new FilterInfo();
  153. filterInfo.getFilterItems().add(new FilterItemInfo("id", AtsUtil.toSet(idArray), CompareType.INCLUDE));
  154. EntityViewInfo entityViewInfo = EntityViewInfo.getInstance(filterInfo, null, null);
  155. ExpandAssessEntryCollection expandAssessEntryCollection = iExpandAssessEntry.getExpandAssessEntryCollection(entityViewInfo);
  156. if (expandAssessEntryCollection.size() > 0) {
  157. for (int i = 0; i < expandAssessEntryCollection.size(); i++) {
  158. ExpandAssessEntryInfo expandAssessEntryInfo = expandAssessEntryCollection.get(i);
  159. if (expandAssessEntryInfo.getAsseStatus() == (ExpandStatusEunm.START) ||
  160. expandAssessEntryInfo.getAsseStatus() == (ExpandStatusEunm.ASSESUBMINT) ||
  161. expandAssessEntryInfo.getAsseStatus() == (ExpandStatusEunm.PRINCIPALSUBMIT)) {
  162. throw new ShrWebBizException("只能删除未启动考核的数据!!");
  163. }
  164. }
  165. }
  166. iExpandAssessEntry.delete(filterInfo);
  167. }
  168. @Override
  169. public ExpandAssessEntryCollection getEntrysByBill(Context ctx, String billId) throws ShrWebBizException, BOSException {
  170. if (StringUtils.isEmpty(billId)) {
  171. throw new ShrWebBizException("拓展人员考核周期ID不可为空!");
  172. }
  173. IExpandAssessEntry iExpandAssessEntry = ExpandAssessEntryFactory.getLocalInstance(ctx);
  174. SelectorItemCollection sic = new SelectorItemCollection();
  175. sic.add("*");
  176. sic.add("assessor.name");
  177. sic.add("adminOrg.name");
  178. sic.add("principal.name");
  179. FilterInfo filterInfo = new FilterInfo();
  180. FilterItemCollection filterItems = filterInfo.getFilterItems();
  181. filterItems.add(new FilterItemInfo("parent.id", billId));
  182. EntityViewInfo entityViewInfo = EntityViewInfo.getInstance(filterInfo, sic, null);
  183. return iExpandAssessEntry.getExpandAssessEntryCollection(entityViewInfo);
  184. }
  185. }