瀏覽代碼

同步OA代码提交

“luojun” 9 月之前
父節點
當前提交
4be41a5de9

+ 1 - 1
metadata/entity_pkmapping.properties

@@ -1,4 +1,4 @@
 #
-#Wed Oct 23 19:48:35 CST 2024
+#Sat Oct 26 17:15:27 CST 2024
 2AAAE378=com.kingdee.eas.custom.log.app.SyncLogEntry
 95A0551A=com.kingdee.eas.custom.log.app.SyncLog

+ 1 - 1
metadata/facade_pkmapping.properties

@@ -1,5 +1,5 @@
 #
-#Wed Oct 23 19:48:35 CST 2024
+#Sat Oct 26 17:15:27 CST 2024
 135AEBA4=com.kingdee.eas.custom.synctask.SyncTranForMJFacade
 07053019=com.kingdee.eas.custom.synctask.SyncTranForOAFacade
 C4BFC0BB=com.kingdee.eas.custom.synctask.SyncTranForIOTFacade

+ 50 - 0
src/com/kingdee/eas/basedata/org/app/PersonControllerBeanEx.java

@@ -0,0 +1,50 @@
+package com.kingdee.eas.basedata.org.app;
+
+import com.kingdee.bos.BOSException;
+import com.kingdee.bos.Context;
+import com.kingdee.bos.dao.IObjectPK;
+import com.kingdee.bos.dao.IObjectValue;
+import com.kingdee.bos.metadata.entity.SelectorItemCollection;
+import com.kingdee.eas.basedata.person.PersonInfo;
+import com.kingdee.eas.basedata.person.app.PersonControllerBean;
+import com.kingdee.eas.common.EASBizException;
+import com.kingdee.eas.custom.synctask.SyncTranForOAFacadeFactory;
+import org.apache.log4j.Logger;
+
+/**
+ * @author qingwu
+ * @date 2024/10/25
+ * @apiNote
+ */
+public class PersonControllerBeanEx extends PersonControllerBean {
+    private static Logger logger =
+            Logger.getLogger(PersonControllerBeanEx.class);
+    @Override
+    protected IObjectPK _addnew(Context ctx, IObjectValue model) throws BOSException, EASBizException {
+        logger.error("PersonControllerBeanEx--------------------_addnew");
+        IObjectPK iObjectPK = super._addnew(ctx, model);
+        PersonInfo info = (PersonInfo) model;
+        String id = info.getId().toString();
+        //肮祭�埜善OA
+        SyncTranForOAFacadeFactory.getLocalInstance(ctx).syncPersonToOA(id, null);
+        return iObjectPK;
+    }
+
+    @Override
+    protected void _update(Context ctx, IObjectPK pk, IObjectValue model) throws BOSException, EASBizException {
+        super._update(ctx, pk, model);
+        logger.error("PersonControllerBeanEx--------------------_update");
+        //肮祭郪眽善OA
+        SyncTranForOAFacadeFactory.getLocalInstance(ctx).syncPersonToOA(pk.toString(), null);
+    }
+
+    @Override
+    protected void _updatePartial(Context ctx, IObjectValue model, SelectorItemCollection selector) throws BOSException, EASBizException {
+        super._updatePartial(ctx, model, selector);
+        logger.error("PersonControllerBeanEx--------------------_updatePartial");
+        PersonInfo info = (PersonInfo) model;
+        String id = info.getId().toString();
+        //肮祭郪眽善OA
+        SyncTranForOAFacadeFactory.getLocalInstance(ctx).syncPersonToOA(id, null);
+    }
+}

+ 51 - 45
src/com/kingdee/eas/custom/synctask/SyncTranForOAFacadeControllerBean.java

@@ -131,13 +131,20 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
                 adminOrg.setFullname(orgName);
                 //adminOrg.setParent_code("ITCS");
                 adminOrg.setOrg_code("0");
-                adminOrg.setParent_code(adminOrgUnitInfo.getParent().getNumber());
+                AdminOrgUnitInfo parent = adminOrgUnitInfo.getParent();
+                if (parent != null) {
+                    adminOrg.setParent_code(parent.getNumber());
+                }
                 Map map = new HashMap();
                 //部门负责人
                 PositionInfo responPosition = adminOrgUnitInfo.getResponPosition();
-                String responPositionId = responPosition.getId().toString();
-                PersonPositionInfo personPositionInfo = getOAIDbyPostitonId(ctx, responPositionId);
-                map.put("bmfzr", personPositionInfo.getPerson().getName());
+                if (responPosition != null) {
+                    String responPositionId = responPosition.getId().toString();
+                    PersonPositionInfo personPositionInfo = getOAIDbyPostitonId(ctx, responPositionId);
+                    if (personPositionInfo != null && personPositionInfo.getPerson() != null) {
+                        map.put("bmfzr", personPositionInfo.getPerson().getName());
+                    }
+                }
                 //经理  总监  副总
                 IPosition iPosition = PositionFactory.getLocalInstance(ctx);
                 PositionCollection positionCollection = iPosition.getPositionCollection("where adminOrgUnit = '" + adminOrgUnitInfo.getId() + "'");
@@ -145,25 +152,23 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
                     PositionInfo positionInfo = positionCollection.get(j);
                     String positionName = positionInfo.getName();
                     logger.error("_syncOrgUnitToOA---positionName---" + positionName);
-                    if ("经理".equals(positionName)) {
-                        PersonPositionInfo oaiDbyPostitonId = getOAIDbyPostitonId(ctx, positionInfo.getId().toString());
-                        //String oaid = oaiDbyPostitonId.getPerson().get("oAid").toString();
-                        String personName = oaiDbyPostitonId.getPerson().getName();
-                        map.put("bmjl", personName);
-                    }
-                    if ("总监".equals(positionName)) {
-                        PersonPositionInfo oaiDbyPostitonId = getOAIDbyPostitonId(ctx, positionInfo.getId().toString());
-                        String personName = oaiDbyPostitonId.getPerson().getName();
-                        map.put("jl", personName);
-                    }
-                    if ("副总经理".equals(positionName)) {
-                        PersonPositionInfo oaiDbyPostitonId = getOAIDbyPostitonId(ctx, positionInfo.getId().toString());
-                        String personName = oaiDbyPostitonId.getPerson().getName();
-                        map.put("fz", personName);
+                    if ("经理".equals(positionName) || "总监".equals(positionName) || "副总经理".equals(positionName)) {
+                        PersonPositionInfo oaiDbyPostiton = getOAIDbyPostitonId(ctx, positionInfo.getId().toString());
+                        if (oaiDbyPostiton != null) {
+                            String personName = oaiDbyPostiton.getPerson().getName();
+                            if ("经理".equals(positionName)) {
+                                map.put("bmjl", personName);
+                            }
+                            if ("总监".equals(positionName)) {
+                                map.put("jl", personName);
+                            }
+                            if ("副总经理".equals(positionName)) {
+                                map.put("fz", personName);
+                            }
+                        }
                     }
+                    adminOrg.setCustomData(map);
                 }
-                adminOrg.setCustomData(map);
-                //adminOrg.setOrder((String.valueOf(adminOrgUnitInfo.getIndex())));
                 dataList.add(adminOrg);
             }
             //执行同步组织到OA
@@ -187,7 +192,8 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
      */
     public PersonPositionInfo getOAIDbyPostitonId(Context ctx, String postitonId) throws BOSException {
         IPersonPosition iPersonPosition = PersonPositionFactory.getLocalInstance(ctx);
-        PersonPositionCollection personPositionCollection = iPersonPosition.getPersonPositionCollection("select * ,person.name where primaryPosition = '" + postitonId + "'");
+        PersonPositionCollection personPositionCollection = iPersonPosition
+                .getPersonPositionCollection("select * ,person.name where primaryPosition = '" + postitonId + "'");
         PersonPositionInfo personPositionInfo = personPositionCollection.get(0);
         return personPositionInfo;
     }
@@ -199,7 +205,8 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
      * @param dataList
      * @return
      */
-    public void executeSyncOrgUnitToOA(Context ctx, List dataList, SyncLogInfo syncLogInfo) throws IOException, BOSException, EASBizException {
+    public void executeSyncOrgUnitToOA(Context ctx, List dataList, SyncLogInfo syncLogInfo) throws
+            IOException, BOSException, EASBizException {
         if (dataList != null && dataList.size() > 0) {
             ObjectMapper mapper = new ObjectMapper();
             //封装请求参数
@@ -319,7 +326,8 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
      * @throws BOSException
      */
     @Override
-    protected void _syncPositionToOA(Context ctx, String billds, ActionTypeEnum action) throws BOSException, EASBizException {
+    protected void _syncPositionToOA(Context ctx, String billds, ActionTypeEnum action) throws
+            BOSException, EASBizException {
         ISyncLog iSyncLog = SyncLogFactory.getLocalInstance(ctx);
         SyncLogInfo syncLogInfo = new SyncLogInfo();
         syncLogInfo.setEntityName(SyncEntityNameEnum.postiton);
@@ -394,7 +402,8 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
      * @return
      * @throws IOException
      */
-    public void synScyRequest(Context ctx, String param, String aipUrl, SyncLogInfo syncLogInfo) throws IOException, BOSException, EASBizException {
+    public void synScyRequest(Context ctx, String param, String aipUrl, SyncLogInfo syncLogInfo) throws
+            IOException, BOSException, EASBizException {
         OkHttpClient client = new OkHttpClient();
         MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
         String data = String.format("token = %s &data = %s", getToken(), param);
@@ -425,7 +434,8 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
      * @throws BOSException
      */
     @Override
-    protected void _syncPersonToOA(Context ctx, String billds, ActionTypeEnum action) throws BOSException, EASBizException {
+    protected void _syncPersonToOA(Context ctx, String billds, ActionTypeEnum action)
+            throws BOSException, EASBizException {
         super._syncPersonToOA(ctx, billds, action);
         logger.error("_syncpersonToOA----------------------start");
         logger.error("_syncpersonToOA----------------------billds: " + billds);
@@ -463,10 +473,6 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
             sic.add("primaryPosition.id");
             sic.add("primaryPosition.name");
             sic.add("primaryPosition.number");
-            sic.add("primaryPosition.job.name");
-            sic.add("primaryPosition.job.number");
-            sic.add("primaryPosition.job.jobType.name");
-            sic.add("primaryPosition.job.jobType.number");
             EntityViewInfo entityViewInfo = EntityViewInfo.getInstance(filterInfo, sic, null);
             PersonPositionCollection personPositionCollection = iPersonPosition.getPersonPositionCollection(entityViewInfo);
             for (int i = 0; i < personPositionCollection.size(); i++) {
@@ -479,7 +485,7 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
             logger.error("_syncpersonToOA------------------dataList----- " + mapper.writeValueAsString(dataList));
             //调用执行人员组织到OA
             executeSyncPersonToOA(ctx, dataList, syncLogInfo);
-            _syncPersonFromOAById(ctx, billds);
+            //_syncPersonFromOAById(ctx, billds);
         } catch (IOException e) {
             e.printStackTrace();
             syncLogInfo.setSyncStatus(SyncStatusEnum.ERROR);
@@ -494,7 +500,8 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
      *
      * @param dataList
      */
-    public void executeSyncPersonToOA(Context ctx, List dataList, SyncLogInfo syncLogInfo) throws IOException, BOSException, EASBizException {
+    public void executeSyncPersonToOA(Context ctx, List dataList, SyncLogInfo syncLogInfo) throws
+            IOException, BOSException, EASBizException {
         if (dataList != null && dataList.size() > 0) {
             ObjectMapper mapper = new ObjectMapper();
             //封装请求参数
@@ -533,7 +540,8 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
      * @param personPositionInfo
      * @return
      */
-    public PersonEntity packagingPerson(Context ctx, PersonPositionInfo personPositionInfo) throws BOSException, EASBizException {
+    public PersonEntity packagingPerson(Context ctx, PersonPositionInfo personPositionInfo) throws
+            BOSException, EASBizException {
         SimpleDateFormat originalFormat = new SimpleDateFormat("yyyy-MM-dd");
         //人员
         PersonInfo personInfo = personPositionInfo.getPerson();
@@ -576,17 +584,14 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
         //电子邮件
         person.setEmail(personInfo.getEmail());
         //入职日期
-        IEmpEnrollBizBillEntry iEmpEnrollBizBillEntry = EmpEnrollBizBillEntryFactory.getLocalInstance(ctx);
-        EmpEnrollBizBillEntryCollection empEnrollBizBillEntryCollection = iEmpEnrollBizBillEntry.getEmpEnrollBizBillEntryCollection("where person = '" + personInfo.getId() + "'");
-        if (empEnrollBizBillEntryCollection.size() > 0) {
-            EmpEnrollBizBillEntryInfo empEnrollBizBillEntryInfo = empEnrollBizBillEntryCollection.get(0);
-            Date enrollDate = empEnrollBizBillEntryInfo.getEnrollDate();
-            person.setCompanystartdate(originalFormat.format(enrollDate));
-            //参加工作日期
-            Date jobStartDate = empEnrollBizBillEntryInfo.getJobStartDate();
-            if (jobStartDate != null) {
-                person.setWorkstartdate(originalFormat.format(jobStartDate));
-            }
+        Date enterDate = personPositionInfo.getEnterDate();
+        if (enterDate != null) {
+            person.setCompanystartdate(originalFormat.format(enterDate));
+        }
+        //参加工作日期
+        Date jobStartDate = personPositionInfo.getJobStartDate();
+        if (jobStartDate != null) {
+            person.setWorkstartdate(originalFormat.format(jobStartDate));
         }
         //登录名称
         person.setLoginid(personInfo.getNumber());
@@ -654,7 +659,8 @@ public class SyncTranForOAFacadeControllerBean extends AbstractSyncTranForOAFaca
      * @throws EASBizException
      */
     @Override
-    protected void _syncPersonFromOAByNumber(Context ctx, String personNumbers) throws BOSException, EASBizException {
+    protected void _syncPersonFromOAByNumber(Context ctx, String personNumbers) throws
+            BOSException, EASBizException {
         super._syncPersonFromOAByNumber(ctx, personNumbers);
         ISyncLog iSyncLog = SyncLogFactory.getLocalInstance(ctx);
         logger.error("_syncPersonFromOAByNumber -> personNumbers" + personNumbers);

+ 7 - 1
src/com/kingdee/eas/custom/synctask/entity/PersonEntity.java

@@ -1,5 +1,7 @@
 package com.kingdee.eas.custom.synctask.entity;
 
+import com.fasterxml.jackson.annotation.JsonProperty;
+
 import java.util.HashMap;
 import java.util.Map;
 
@@ -94,10 +96,13 @@ public class PersonEntity {
     // 参加工作日期
     private String workstartdate;
     // 基本信息自定义数据,字段确认请看【组织权限中心】-【自定义设置】-【人员卡片字段定义】-【基本信息】数据库字段名
+    @JsonProperty("base_custom_data")
     private Map baseCustomData;
     // 个人信息自定义数据,字段确认请看【组织权限中心】-【自定义设置】-【人员卡片字段定义】-【个人信息】数据库字段名
+    @JsonProperty("person_custom_data")
     private Map personCustomData;
-    // 工作信息自定义数据,字段确认请看【组织权限中心】-【自定义设置】-【人员卡片字段定义】-【工作信息】数据库字段名
+    // 工作信息自定义数据,字段确认请看【组织权限中心】-【自定义设置】-【人员卡片字段定义】-【工作信息】数据库字段名  work_custom_data
+    @JsonProperty("work_custom_data")
     private Map workCustomData;
 
     public String getWorkcode() {
@@ -443,6 +448,7 @@ public class PersonEntity {
     }
 
     public Map getWorkCustomData() {
+
         return workCustomData;
     }
 

+ 47 - 0
src/com/kingdee/eas/hr/affair/app/FluctuationBizBillControllerBeanEx.java

@@ -0,0 +1,47 @@
+package com.kingdee.eas.hr.affair.app;
+
+import com.kingdee.bos.BOSException;
+import com.kingdee.bos.Context;
+import com.kingdee.bos.dao.IObjectPK;
+import com.kingdee.eas.basedata.person.PersonInfo;
+import com.kingdee.eas.common.EASBizException;
+import com.kingdee.eas.custom.synctask.SyncTranForOAFacadeFactory;
+import com.kingdee.eas.framework.CoreBaseInfo;
+import com.kingdee.eas.hr.affair.FluctuationBizBillEntryCollection;
+import com.kingdee.eas.hr.affair.FluctuationBizBillEntryInfo;
+import com.kingdee.eas.hr.affair.FluctuationBizBillInfo;
+import org.apache.log4j.Logger;
+
+/**
+ * @author qingwu
+ * @date 2024/10/26
+ * @apiNote
+ */
+public class FluctuationBizBillControllerBeanEx extends FluctuationBizBillControllerBean {
+    Logger logger = Logger.getLogger(FluctuationBizBillControllerBeanEx.class);
+
+    @Override
+    public IObjectPK submitEffect(Context ctx, CoreBaseInfo model) throws BOSException, EASBizException {
+        IObjectPK iObjectPK = super.submitEffect(ctx, model);
+        logger.error("FluctuationBizBillControllerBeanEx-----------afterSubmit---------------");
+        FluctuationBizBillInfo fluctuationBizBillInfo = (FluctuationBizBillInfo) model;
+        FluctuationBizBillEntryCollection entrys = fluctuationBizBillInfo.getEntrys();
+        StringBuilder sb = new StringBuilder();
+        for (int i = 0; i < entrys.size(); i++) {
+            FluctuationBizBillEntryInfo fluctuationBizBillEntryInfo = entrys.get(i);
+            PersonInfo person = fluctuationBizBillEntryInfo.getPerson();
+            sb.append(person.getId().toString()).append(",");
+        }
+        sb.deleteCharAt(sb.lastIndexOf(","));
+        logger.error("afterSubmit---------------person------" + sb.toString());
+        try {
+            if (sb.length() > 0) {
+                SyncTranForOAFacadeFactory.getLocalInstance(ctx).syncPersonToOA(sb.toString(), null);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new BOSException("µ÷¶¯Í¬²½ÈËÔ±" + e.getMessage());
+        }
+        return iObjectPK;
+    }
+}

+ 1 - 1
websrc/com/kingdee/eas/custom/synctask/handler/EmployeeListHandlerEx.java

@@ -22,7 +22,7 @@ public class EmployeeListHandlerEx extends EmployeeListHandler {
     public static Logger logger = Logger.getLogger(EmployeeListHandlerEx.class);
     private Context ctx = SHRContext.getInstance().getContext();
 
-    public void syncPersonToOAAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws BOSException, IOException, EASBizException {
+    public void syncPersonToOAAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws BOSException, EASBizException {
         String billIds = request.getParameter("billIds");
         //ͬ²½ÈËÔ±µ½OA
         SyncTranForOAFacadeFactory.getLocalInstance(ctx).syncPersonToOA(billIds, null);

+ 37 - 0
websrc/com/kingdee/eas/custom/synctask/importService/AdminImportFileServiceEx.java

@@ -0,0 +1,37 @@
+package com.kingdee.eas.custom.synctask.importService;
+
+import com.kingdee.bos.BOSException;
+import com.kingdee.bos.Context;
+import com.kingdee.bos.sql.ParserException;
+import com.kingdee.eas.basedata.org.AdminOrgUnitInfo;
+import com.kingdee.eas.common.EASBizException;
+import com.kingdee.eas.custom.synctask.SyncTranForOAFacadeFactory;
+import com.kingdee.eas.framework.CoreBaseInfo;
+import com.kingdee.eas.framework.ICoreBase;
+import com.kingdee.shr.base.syssetting.app.io.fileImport.ImportException;
+import com.kingdee.shr.base.syssetting.app.io.impl.AdminImportFileService;
+import org.apache.log4j.Logger;
+
+/**
+ * @author qingwu
+ * @date 2024/10/26
+ * @apiNote
+ */
+public class AdminImportFileServiceEx extends AdminImportFileService {
+    private static Logger logger = Logger.getLogger(AdminImportFileServiceEx.class);
+
+    @Override
+    protected void submitData(Context ctx, ICoreBase corebase, CoreBaseInfo baseInfo, boolean hasExist) throws ParserException, EASBizException, BOSException {
+        super.submitData(ctx, corebase, baseInfo, hasExist);
+        AdminOrgUnitInfo adminOrgUnitInfo = (AdminOrgUnitInfo) baseInfo;
+        String adminOrgUnitId = adminOrgUnitInfo.getId().toString();
+        logger.error("AdminImportFileServiceEx---billds: " + adminOrgUnitId);
+        try {
+            SyncTranForOAFacadeFactory.getLocalInstance(this.getContext()).syncOrgUnitToOA(adminOrgUnitId, null);
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new ImportException(e);
+        }
+    }
+
+}