|
|
@@ -0,0 +1,349 @@
|
|
|
+package com.kingdee.shr.customer.synosf;
|
|
|
+
|
|
|
+import com.kingdee.bos.BOSException;
|
|
|
+import com.kingdee.bos.Context;
|
|
|
+import com.kingdee.bos.bsf.service.app.IHRMsfService;
|
|
|
+import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
|
|
|
+import com.kingdee.eas.base.permission.PermItemFactory;
|
|
|
+import com.kingdee.eas.base.permission.PermItemInfo;
|
|
|
+import com.kingdee.eas.base.permission.UserFactory;
|
|
|
+import com.kingdee.eas.base.permission.UserInfo;
|
|
|
+import com.kingdee.eas.common.EASBizException;
|
|
|
+import com.kingdee.eas.hr.emp.EmployeeInterfacePermBizException;
|
|
|
+import com.kingdee.eas.util.app.ContextUtil;
|
|
|
+import com.kingdee.eas.util.app.DbUtil;
|
|
|
+import com.kingdee.jdbc.rowset.IRowSet;
|
|
|
+import com.kingdee.shr.base.permission.api.service.SHRFunctionPermissionService;
|
|
|
+import com.kingdee.shr.integration.oa.util.IntegrateOAUtil;
|
|
|
+import com.kingdee.shr.integration.oa.util.MappingFieldInfo;
|
|
|
+import com.kingdee.util.StringUtils;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Calendar;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取人员数据
|
|
|
+ * @author coyle
|
|
|
+ * 202601
|
|
|
+ */
|
|
|
+public class GetAllPersonInfoService implements IHRMsfService {
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(GetAllPersonInfoService.class);
|
|
|
+
|
|
|
+ public Object process(Context ctx, Map param) throws EASBizException, BOSException {
|
|
|
+ Object obj = param.get("filterType");
|
|
|
+ String type = null;
|
|
|
+ if (obj != null) {
|
|
|
+ type = String.valueOf(obj);
|
|
|
+ }
|
|
|
+
|
|
|
+ logger.error("InteOAGetPersonDataService enter and filterType = " + (obj == null ? "" : obj.toString()));
|
|
|
+ new ArrayList();
|
|
|
+ String personPermItem = "fffffff0-ffff-efff-e22e-0000000dfa25PERMITEM";
|
|
|
+ PermItemInfo permItem = PermItemFactory.getLocalInstance(ctx).getPermItemInfo(new ObjectUuidPK(personPermItem));
|
|
|
+
|
|
|
+ try {
|
|
|
+ SHRFunctionPermissionService.checkCurrnetUserFunctionPermission(ctx, permItem);
|
|
|
+ } catch (Exception var12) {
|
|
|
+ logger.error(var12.getMessage(), var12);
|
|
|
+ String userId = ContextUtil.getCurrentUserInfo(ctx).getId().toString();
|
|
|
+ UserInfo userInfo = UserFactory.getLocalInstance(ctx).getUserInfo(new ObjectUuidPK(userId));
|
|
|
+ throw new EmployeeInterfacePermBizException(EmployeeInterfacePermBizException.NO_FUNCTION_PERMISSION,
|
|
|
+ new Object[]{userInfo.getName(), permItem.getAlias()});
|
|
|
+ }
|
|
|
+
|
|
|
+ List<MappingFieldInfo> fieldList = this.initMappingField();
|
|
|
+ StringBuffer sql = IntegrateOAUtil.getSelectFieldSql(fieldList);
|
|
|
+ sql.append(" from t_bd_person person");
|
|
|
+ sql.append(" left join t_pm_user puser on person.fid=puser.FPersonID AND puser.FISDELETE = '0' AND puser.FForbidden = '0' ");
|
|
|
+ sql.append(" left join T_HR_PersonPosition pp on pp.fpersonId=person.fid");
|
|
|
+ sql.append(" left join T_HR_EmpLaborRelation laber on laber.fpersonId=person.fid");
|
|
|
+// sql.append(" left join T_HR_PersonOtherInfo pother on pother.fpersonId=person.fid");
|
|
|
+ sql.append(" left join T_ORG_Admin org on pp.FPersonDep=org.fid");
|
|
|
+ sql.append(" left join T_HR_BDEmployeeType empType on empType.fid=person.FEmployeeTypeID");
|
|
|
+ sql.append(" left join T_BD_HRFolk folk on person.FFolkID=folk.fid");
|
|
|
+ sql.append(" left join T_BD_Nationality nation on person.FNationalityID=nation.fid");
|
|
|
+ sql.append(" left join T_ORG_Admin comp on pp.FCompanyID =comp.fid");
|
|
|
+
|
|
|
+ sql.append(" left join T_ORG_Position position on pp.FPrimaryPositionID =position.fid");
|
|
|
+// sql.append(" left join T_HR_EmpLaborRelation elr on person.fid = elr.fpersonid ");
|
|
|
+ sql.append(" left join T_HR_BDEmployeeType etype on laber.FLABORRELATIONSTATEID = etype.fid ");
|
|
|
+ //职级
|
|
|
+ sql.append(" left join T_HR_EmpPostRank epr on person.fid = epr.FPersonID and epr. FIsLatest = 1 ");
|
|
|
+ sql.append(" left join T_HR_JobGrade jobGrade on epr.FJobGradeID = jobGrade.fid ");
|
|
|
+ sql.append(" left join CT_MP_WorkCity city on person.cfworkcityid = city.fid ");
|
|
|
+ //直接上级
|
|
|
+ sql.append(" left join T_ORG_Position parentPosi on position.FPARENTID = parentPosi.fid ");
|
|
|
+ sql.append(" left join T_HR_PersonPosition superiorpp on parentPosi.FID= superiorpp.FPRIMARYPOSITIONID ");
|
|
|
+ sql.append(" left join T_BD_Person superiorp on superiorpp.fpersonid = superiorp.fid ");
|
|
|
+ sql.append(" left join t_pm_user superioru on superiorp.fid = superioru.FPersonID AND superioru.FISDELETE = '0' AND superioru.FForbidden = '0' ");
|
|
|
+
|
|
|
+ sql.append(" left join T_ORG_Job job on position.fjobid = job.fid ");
|
|
|
+ // HRJob
|
|
|
+ //T_ORG_Job
|
|
|
+
|
|
|
+
|
|
|
+ sql.append(
|
|
|
+ " left join (select min(u1.fcreatetime) fcreatetime ,u1.fpersonid fpersonid from t_pm_user u1 group by fpersonid) userEarly on userEarly.fpersonid=person.fid and userEarly.fcreatetime=puser.fcreatetime ");
|
|
|
+ if (!StringUtils.isEmpty(type) ) {
|
|
|
+ if(!"1".equals(type)){
|
|
|
+ sql.append(" where empType.fuserstate = 2");
|
|
|
+ }else {
|
|
|
+ sql.append(" where empType.fuserstate = 1");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String updateDate = this.increDateParam(param);
|
|
|
+ if (!StringUtils.isEmpty(updateDate)) {
|
|
|
+ sql.append(" and person.FLastUpdateTime>= " + updateDate);
|
|
|
+ }
|
|
|
+ sql.append(" and org.FIsStartSHR=1");
|
|
|
+ System.out.print("sql:"+sql.toString() );
|
|
|
+ IRowSet rs = DbUtil.executeQuery(ctx, sql.toString());
|
|
|
+ List<HashMap<String, String>> dataList = IntegrateOAUtil.getRsListData(fieldList, rs);
|
|
|
+ return dataList;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<MappingFieldInfo> initMappingField() {
|
|
|
+ List<MappingFieldInfo> list = new ArrayList();
|
|
|
+ MappingFieldInfo fieldInfo = new MappingFieldInfo();
|
|
|
+// fieldInfo.setOaField("username");
|
|
|
+// fieldInfo.setShrField("person.FName_L2");
|
|
|
+// list.add(fieldInfo);
|
|
|
+// fieldInfo = new MappingFieldInfo();
|
|
|
+// fieldInfo.setOaField("status");
|
|
|
+// fieldInfo.setShrField("empType.fuserstate");
|
|
|
+// list.add(fieldInfo);
|
|
|
+// fieldInfo = new MappingFieldInfo();
|
|
|
+// fieldInfo.setOaField("address");
|
|
|
+// fieldInfo.setShrField("person.FAddress_l2");
|
|
|
+// list.add(fieldInfo);
|
|
|
+// fieldInfo = new MappingFieldInfo();
|
|
|
+// fieldInfo.setOaField("descn");
|
|
|
+// fieldInfo.setShrField("person.FDescription_L2");
|
|
|
+// list.add(fieldInfo);
|
|
|
+// fieldInfo = new MappingFieldInfo();
|
|
|
+// fieldInfo.setOaField("fcreateTime");
|
|
|
+// fieldInfo.setShrField("person.fcreateTime");
|
|
|
+// list.add(fieldInfo);
|
|
|
+// fieldInfo = new MappingFieldInfo();
|
|
|
+// fieldInfo.setOaField("flastUpdateTime");
|
|
|
+// fieldInfo.setShrField("person.FLastUpdateTime");
|
|
|
+// list.add(fieldInfo);
|
|
|
+//
|
|
|
+// fieldInfo = new MappingFieldInfo();
|
|
|
+// fieldInfo.setOaField("formalDate");
|
|
|
+// fieldInfo.setShrField("laber.FActualFormalDate");
|
|
|
+// list.add(fieldInfo);
|
|
|
+// fieldInfo = new MappingFieldInfo();
|
|
|
+// fieldInfo.setOaField("jobStartDate");
|
|
|
+// fieldInfo.setShrField("pother.FjobStartDate");
|
|
|
+// list.add(fieldInfo);
|
|
|
+// fieldInfo = new MappingFieldInfo();
|
|
|
+// fieldInfo.setOaField("joinGroupDate");
|
|
|
+// fieldInfo.setShrField("pp.FJoinGroupDate");
|
|
|
+// list.add(fieldInfo);
|
|
|
+// fieldInfo = new MappingFieldInfo();
|
|
|
+// fieldInfo.setOaField("org_number");
|
|
|
+// fieldInfo.setShrField("org.FNumber");
|
|
|
+// list.add(fieldInfo);
|
|
|
+// fieldInfo = new MappingFieldInfo();
|
|
|
+// fieldInfo.setOaField("folk_number");
|
|
|
+// fieldInfo.setShrField("folk.FNumber");
|
|
|
+// list.add(fieldInfo);
|
|
|
+// fieldInfo = new MappingFieldInfo();
|
|
|
+// fieldInfo.setOaField("folk_name");
|
|
|
+// fieldInfo.setShrField("folk.fname_l2");
|
|
|
+// list.add(fieldInfo);
|
|
|
+// fieldInfo = new MappingFieldInfo();
|
|
|
+// fieldInfo.setOaField("nation_number");
|
|
|
+// fieldInfo.setShrField("nation.FNumber");
|
|
|
+// list.add(fieldInfo);
|
|
|
+// fieldInfo = new MappingFieldInfo();
|
|
|
+// fieldInfo.setOaField("nation_name");
|
|
|
+// fieldInfo.setShrField("nation.fname_l2");
|
|
|
+// list.add(fieldInfo);
|
|
|
+// fieldInfo = new MappingFieldInfo();
|
|
|
+// fieldInfo.setOaField("empType_number");
|
|
|
+// fieldInfo.setShrField("empType.FNumber");
|
|
|
+// list.add(fieldInfo);
|
|
|
+// fieldInfo = new MappingFieldInfo();
|
|
|
+// fieldInfo.setOaField("empType_name");
|
|
|
+// fieldInfo.setShrField("empType.fname_l2");
|
|
|
+// list.add(fieldInfo);
|
|
|
+// fieldInfo = new MappingFieldInfo();
|
|
|
+// fieldInfo.setOaField("user_forbidden");
|
|
|
+// fieldInfo.setShrField("puser.Fforbidden");
|
|
|
+// list.add(fieldInfo);
|
|
|
+// fieldInfo = new MappingFieldInfo();
|
|
|
+// fieldInfo.setOaField("user_isDelete");
|
|
|
+// fieldInfo.setShrField("puser.FIsDelete");
|
|
|
+// list.add(fieldInfo);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+//workcode 人员编码(工号)
|
|
|
+ fieldInfo = new MappingFieldInfo();
|
|
|
+ fieldInfo.setOaField("workcode");
|
|
|
+ fieldInfo.setShrField("person.FNumber");
|
|
|
+ list.add(fieldInfo);
|
|
|
+//loginid 账号(主账号)
|
|
|
+ fieldInfo = new MappingFieldInfo();
|
|
|
+ fieldInfo.setOaField("loginid");
|
|
|
+ fieldInfo.setShrField("puser.FNumber");
|
|
|
+ list.add(fieldInfo);
|
|
|
+//branchNubmer
|
|
|
+ fieldInfo = new MappingFieldInfo();
|
|
|
+ fieldInfo.setOaField("branchNubmer");
|
|
|
+ fieldInfo.setShrField("comp.FNumber");
|
|
|
+ list.add(fieldInfo);
|
|
|
+ //departmentid 部门编码
|
|
|
+ fieldInfo = new MappingFieldInfo();
|
|
|
+ fieldInfo.setOaField("departmentid");
|
|
|
+ fieldInfo.setShrField("org.fnumber");
|
|
|
+ list.add(fieldInfo);
|
|
|
+//lastname 姓名 字符 60 否
|
|
|
+ fieldInfo = new MappingFieldInfo();
|
|
|
+ fieldInfo.setOaField("lastname");
|
|
|
+ fieldInfo.setShrField("person.fname_l2");
|
|
|
+ list.add(fieldInfo);
|
|
|
+ //sex 性别 字符
|
|
|
+ fieldInfo = new MappingFieldInfo();
|
|
|
+ fieldInfo.setOaField("sex");
|
|
|
+ fieldInfo.setShrField("CASE person.FGender WHEN '1' THEN '男' WHEN '2' THEN '女' ELSE NULL END ");
|
|
|
+ list.add(fieldInfo);
|
|
|
+
|
|
|
+
|
|
|
+ //positionName 职位名称 字符 60 否
|
|
|
+ fieldInfo = new MappingFieldInfo();
|
|
|
+ fieldInfo.setOaField("positionName");
|
|
|
+ fieldInfo.setShrField("position.fname_l2");
|
|
|
+ list.add(fieldInfo);
|
|
|
+ fieldInfo = new MappingFieldInfo();
|
|
|
+ fieldInfo.setOaField("positionNum");
|
|
|
+ fieldInfo.setShrField("position.fnumber");
|
|
|
+ list.add(fieldInfo);
|
|
|
+ //job 职务
|
|
|
+ fieldInfo = new MappingFieldInfo();
|
|
|
+ fieldInfo.setOaField("jobNum");
|
|
|
+ fieldInfo.setShrField("job.fnumber");
|
|
|
+ list.add(fieldInfo);
|
|
|
+ fieldInfo = new MappingFieldInfo();
|
|
|
+ fieldInfo.setOaField("jobName");
|
|
|
+ fieldInfo.setShrField("job.fname_l2");
|
|
|
+ list.add(fieldInfo);
|
|
|
+
|
|
|
+ //joblevel 职级名称 字符 20 是 T6.2 按照职务体系设置 FJobLevelID
|
|
|
+ fieldInfo = new MappingFieldInfo();
|
|
|
+ fieldInfo.setOaField("joblevel");
|
|
|
+ fieldInfo.setShrField("jobGrade.fname_l2");
|
|
|
+ list.add(fieldInfo);
|
|
|
+ //managerid 直接上级账号 字符 60 superiorp
|
|
|
+ fieldInfo = new MappingFieldInfo();
|
|
|
+ fieldInfo.setOaField("managerid");
|
|
|
+ fieldInfo.setShrField("superioru.fnumber");
|
|
|
+ list.add(fieldInfo);
|
|
|
+ //status 状态(在职、试用、离职)
|
|
|
+ fieldInfo = new MappingFieldInfo();
|
|
|
+ fieldInfo.setOaField("status");
|
|
|
+ fieldInfo.setShrField(" CASE etype.cfOaState WHEN 'PROBATION' THEN '试用' WHEN 'ON_THE_JOB' THEN '在职' WHEN 'RESIGNED' THEN '离职' ELSE NULL END ");
|
|
|
+ list.add(fieldInfo);
|
|
|
+ //telephone 办公电话 字符 20 是
|
|
|
+ fieldInfo = new MappingFieldInfo();
|
|
|
+ fieldInfo.setOaField("telephone");
|
|
|
+ fieldInfo.setShrField("person.FOfficePhone");
|
|
|
+ list.add(fieldInfo);
|
|
|
+ //mobile 移动电话 字符 20 是
|
|
|
+ fieldInfo = new MappingFieldInfo();
|
|
|
+ fieldInfo.setOaField("mobile");
|
|
|
+ fieldInfo.setShrField("person.FCell");
|
|
|
+ list.add(fieldInfo);
|
|
|
+ //mobilecall 其他电话 字符 20 是
|
|
|
+ fieldInfo = new MappingFieldInfo();
|
|
|
+ fieldInfo.setOaField("mobilecall");
|
|
|
+ fieldInfo.setShrField("person.FHomePhone");
|
|
|
+ list.add(fieldInfo);
|
|
|
+ //fax 传真 字符 50
|
|
|
+ fieldInfo = new MappingFieldInfo();
|
|
|
+ fieldInfo.setOaField("fax");
|
|
|
+ fieldInfo.setShrField("''");
|
|
|
+ list.add(fieldInfo);
|
|
|
+ //email 邮箱 字符 50 否
|
|
|
+ fieldInfo = new MappingFieldInfo();
|
|
|
+ fieldInfo.setOaField("email");
|
|
|
+ fieldInfo.setShrField("person.FEMail");
|
|
|
+ list.add(fieldInfo);
|
|
|
+ //birthday 出生日期 字符 10 是 格式:(yyyy-MM-dd)
|
|
|
+ fieldInfo = new MappingFieldInfo();
|
|
|
+ fieldInfo.setOaField("birthday");
|
|
|
+// fieldInfo.setShrField("person.FBirthday");
|
|
|
+ fieldInfo.setShrField("TO_CHAR(person.FBirthday, 'YYYY-MM-DD')");
|
|
|
+ list.add(fieldInfo);
|
|
|
+ //certificatenum 身份证号码 字符 18 是
|
|
|
+ fieldInfo = new MappingFieldInfo();
|
|
|
+ fieldInfo.setOaField("certificatenum");
|
|
|
+ fieldInfo.setShrField("person.FIDCardNO");
|
|
|
+ list.add(fieldInfo);
|
|
|
+ //passport 护照号 字符 50 是
|
|
|
+ fieldInfo = new MappingFieldInfo();
|
|
|
+ fieldInfo.setOaField("passport");
|
|
|
+ fieldInfo.setShrField("person.FPassportNO");
|
|
|
+ list.add(fieldInfo);
|
|
|
+ //hiredate 入职日期 字符 10 是
|
|
|
+ fieldInfo = new MappingFieldInfo();
|
|
|
+ fieldInfo.setOaField("hiredate");
|
|
|
+// fieldInfo.setShrField("laber.FEnterDate");
|
|
|
+ fieldInfo.setShrField("TO_CHAR(laber.FEnterDate, 'YYYY-MM-DD')");
|
|
|
+ list.add(fieldInfo);
|
|
|
+ //probationenddate 实际转正日期 字符 10 是
|
|
|
+ fieldInfo = new MappingFieldInfo();
|
|
|
+ fieldInfo.setOaField("probationenddate");
|
|
|
+// fieldInfo.setShrField("laber.FACTUALFORMALDATE");
|
|
|
+ fieldInfo.setShrField("TO_CHAR(laber.FACTUALFORMALDATE, 'YYYY-MM-DD')");
|
|
|
+ list.add(fieldInfo);
|
|
|
+ //workCityCode 工作城市编码 字符 20 否
|
|
|
+ fieldInfo = new MappingFieldInfo();
|
|
|
+ fieldInfo.setOaField("workCityCode");
|
|
|
+ fieldInfo.setShrField("city.fnumber");
|
|
|
+ list.add(fieldInfo);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String increDateParam(Map param) throws BOSException {
|
|
|
+ String daysAgoStr = (String) param.get("daysAgo");
|
|
|
+ if (!StringUtils.isEmpty(daysAgoStr)) {
|
|
|
+ Integer daysAgo = 0;
|
|
|
+
|
|
|
+ try {
|
|
|
+ daysAgo = Integer.parseInt(daysAgoStr);
|
|
|
+ } catch (NumberFormatException var5) {
|
|
|
+ var5.printStackTrace();
|
|
|
+ throw new BOSException("daysAgo must is an integer");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (daysAgo >= 0 && daysAgo <= 30) {
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.add(5, -daysAgo);
|
|
|
+ calendar.set(11, 0);
|
|
|
+ calendar.set(12, 0);
|
|
|
+ calendar.set(13, 0);
|
|
|
+ return "{ts'" + (new SimpleDateFormat("yyyy-MM-dd")).format(calendar.getTime()) + "'}";
|
|
|
+ } else {
|
|
|
+ throw new BOSException("daysAgo is an integer where 0 <= daysAgo <= 30");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|