GtiitEmpOrgRelationService.java 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. package com.kingdee.shr.customer.gtiit.osf;
  2. import java.sql.SQLException;
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5. import java.util.List;
  6. import java.util.Map;
  7. import org.slf4j.Logger;
  8. import org.slf4j.LoggerFactory;
  9. import org.apache.commons.lang3.StringUtils;
  10. import com.kingdee.bos.BOSException;
  11. import com.kingdee.bos.Context;
  12. import com.kingdee.bos.bsf.service.app.IHRMsfService;
  13. import com.kingdee.eas.common.EASBizException;
  14. import com.kingdee.eas.util.app.DbUtil;
  15. import com.kingdee.jdbc.rowset.IRowSet;
  16. import com.kingdee.shr.customer.gtiit.osf.util.DateUtils;
  17. /**
  18. * 获取员工任职历史记录的接口
  19. * @author cb
  20. *
  21. */
  22. public class GtiitEmpOrgRelationService implements IHRMsfService {
  23. private static final Logger logger = LoggerFactory.getLogger(GtiitOrgPositionService.class);
  24. @Override
  25. public Object process(Context ctx, Map param) throws EASBizException, BOSException {
  26. // 开始日期
  27. String startDate = (String) param.get("startDate");
  28. // 截止日期
  29. String endDate = (String) param.get("endDate");
  30. String sql="SELECT\r\n" +
  31. " he.fid ID,\r\n" +
  32. " bp.fnumber PERSON_NUMBER,\r\n" +
  33. " bp.cfsurname LAST_NAME,\r\n" +
  34. " bp.cfmiddlenames MIDDLE_NAMES,\r\n" +
  35. " bp.CFGivenName FIRST_NAME,\r\n" +
  36. " bp.cflocalname LOCAL_NAME,\r\n" +
  37. " bp.fname_l2 DISPLAY_NAME,\r\n" +
  38. " he.fstartdatetime EFFECTIVE_START_DATE,\r\n" +
  39. " he.fenddatetime EFFECTIVE_END_DATE,\r\n" +
  40. " oa.FNUMBER DEPARTMENT_CODE,\r\n" +
  41. " oa.FNAME_l2 DEPARTMENT_NAME,\r\n" +
  42. " oa.FSIMPLENAME DEPARTMENT_SHORT_NAME,\r\n" +
  43. " he.fjobtxt JOB_NAME,\r\n" +
  44. " op.FNAME_l1 POSITION,\r\n" +
  45. " op.FNUMBER POSITION_CODE,\r\n" +
  46. " wc.fname_l1 WORK_CATE,\r\n" +
  47. " mf.fname_l1 FULL_PART_TIME,\r\n" +
  48. " ma.Fnumber MANAGER_PERSON_NUMBER,\r\n" +
  49. " ma.Fname_l2 MANAGER_NAME,\r\n" +
  50. " he.cfadmintitle ADMIN_TITLE,\r\n" +
  51. " mat.fname_l1 ACADEMIC_TITLE,\r\n" +
  52. " hj.fname_l1 JOB2,\r\n" +
  53. " xyz.name JOB_LEVEL,\r\n" +
  54. " he.fassigntype PRIMARY_FLAG,\r\n" +
  55. "CASE\r\n" +
  56. " \r\n" +
  57. " WHEN helr.FLABORRELATIONSTATEID IN (\r\n" +
  58. " SELECT\r\n" +
  59. " fid \r\n" +
  60. " FROM\r\n" +
  61. " T_HR_BDEmployeeType \r\n" +
  62. " WHERE\r\n" +
  63. " FNUMBER NOT IN ( 'S08', 'S09', '009', '010', '011' )) THEN\r\n" +
  64. " 1 ELSE 0 \r\n" +
  65. " END AS ASSIGNMENT_STATUS_TYPE,\r\n" +
  66. " he.FCREATETIME ERP_CREATION_DATE,\r\n" +
  67. " he.FLASTUPDATETIME ERP_LAST_UPDATE_DATE \r\n" +
  68. " FROM\r\n" +
  69. " T_HR_EmpOrgRelation he\r\n" +
  70. " LEFT JOIN t_bd_person bp ON bp.fid = he.fpersonid\r\n" +
  71. " LEFT JOIN T_ORG_Admin oa ON oa.fid = he.fadminorgid\r\n" +
  72. " LEFT JOIN T_ORG_Position op ON op.FID = he.fpositionid\r\n" +
  73. " LEFT JOIN CT_MP_WorkerCategory wc ON wc.fid = he.cfworkercategoryid\r\n" +
  74. " LEFT JOIN CT_MP_Fullorpart mf ON mf.fid = he.cfftorptid\r\n" +
  75. " LEFT JOIN T_BD_Person ma ON ma.fid = he.cflinemanagernamei\r\n" +
  76. " LEFT JOIN CT_MP_AcademicTitle mat ON mat.fid = he.cfacademictitleid\r\n" +
  77. " LEFT JOIN CT_HR_Job2 hj ON hj.fid = he.cfjobsid\r\n" +
  78. " LEFT JOIN T_HR_EmpLaborRelation helr ON helr.fpersonid = he.fpersonid\r\n" +
  79. " LEFT JOIN (\r\n" +
  80. " SELECT\r\n" +
  81. " hjg.fname_l2 name,\r\n" +
  82. " a.fid fpersonid \r\n" +
  83. " FROM\r\n" +
  84. " T_HR_JobGrade hjg\r\n" +
  85. " LEFT JOIN (\r\n" +
  86. " SELECT\r\n" +
  87. " * \r\n" +
  88. " FROM\r\n" +
  89. " T_HR_EmpPostRank \r\n" +
  90. " WHERE\r\n" +
  91. " FLEFFDT = ( SELECT MAX ( FLEFFDT ) FROM T_HR_EmpPostRank )) a ON hjg.FID = a.FJOBGRADEID \r\n" +
  92. " ) xyz ON xyz.fpersonid = he.fpersonid";
  93. if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate)) {
  94. startDate = DateUtils.formatDate(startDate, true);
  95. endDate = DateUtils.formatDate(endDate, false);
  96. sql += " where he.FLASTUPDATETIME >= '" + startDate + "' and he.FLASTUPDATETIME <= '" + endDate + "'";
  97. }
  98. List<String> fieldList = initMappingField();
  99. logger.info(">>> GtiitEmpOrgRelationService 的执行 sql = " + sql);
  100. IRowSet rs = DbUtil.executeQuery(ctx, sql.toString());
  101. List<Map<String, String>> dataList = this.getRsListData(fieldList, rs);
  102. return dataList;
  103. }
  104. private List<String> initMappingField() {
  105. List<String> list = new ArrayList<>();
  106. list.add("ID");
  107. list.add("PERSON_NUMBER");
  108. list.add("LAST_NAME");
  109. list.add("MIDDLE_NAMES");
  110. list.add("FIRST_NAME");
  111. list.add("LOCAL_NAME");
  112. list.add("DISPLAY_NAME");
  113. list.add("EFFECTIVE_START_DATE");
  114. list.add("EFFECTIVE_END_DATE");
  115. list.add("DEPARTMENT_CODE");
  116. list.add("DEPARTMENT_NAME");
  117. list.add("DEPARTMENT_SHORT_NAME");
  118. list.add("JOB_NAME");
  119. list.add("POSITION");
  120. list.add("POSITION_CODE");
  121. list.add("WORK_CATE");
  122. list.add("FULL_PART_TIME");
  123. list.add("MANAGER_PERSON_NUMBER");
  124. list.add("MANAGER_NAME");
  125. list.add("ADMIN_TITLE");
  126. list.add("ACADEMIC_TITLE");
  127. list.add("JOB2");
  128. list.add("JOB_LEVEL");
  129. list.add("PRIMARY_FLAG");
  130. list.add("ASSIGNMENT_STATUS_TYPE");
  131. list.add("ERP_CREATION_DATE");
  132. list.add("ERP_LAST_UPDATE_DATE");
  133. return list;
  134. }
  135. private List<Map<String, String>> getRsListData(List<String> fieldList, IRowSet rs) throws BOSException {
  136. List<Map<String, String>> dataList = new ArrayList<>();
  137. try {
  138. while (rs.next()) {
  139. HashMap<String, String> dataMap = new HashMap<>();
  140. int i = 0;
  141. for (int size = fieldList.size(); i < size; ++i) {
  142. String field = fieldList.get(i);
  143. if ("PRIMARY_FLAG".equals(field)) {
  144. dataMap.put(field, "1".equals(rs.getString(field)) ? "是" : "否");
  145. }else if("ASSIGNMENT_STATUS_TYPE".equals(field)){
  146. dataMap.put(field, "1".equals(rs.getString(field)) ? "ACTIVE" : "INACTIVE");
  147. } else {
  148. dataMap.put(field, rs.getString(field));
  149. }
  150. }
  151. dataList.add(dataMap);
  152. }
  153. return dataList;
  154. } catch (SQLException ex) {
  155. throw new BOSException(ex);
  156. }
  157. }
  158. }