From 071c75942f0b205af31649fc847e32e0776b9d60 Mon Sep 17 00:00:00 2001 From: e Date: Tue, 19 Mar 2024 14:10:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E7=9B=9B=E4=BB=A3=E7=A0=81--wujiang?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/DayouTechnologyInterfaceFacade.wsdd | 10 + src/RishengHaiKangHRFacade.wsdd | 10 + src/RishengInterfaceFacade.wsdd | 10 + src/RishengPendingMessageFacade.wsdd | 10 + ...stractRishengHaiKangHRFacadeControllerBean.java | 135 ++++ ...stractRishengInterfaceFacadeControllerBean.java | 159 ++++ ...tRishengPendingMessageFacadeControllerBean.java | 87 ++ .../eas/custom/risheng/AssignmentEventHandler.java | 87 ++ .../kingdee/eas/custom/risheng/FWOASyncHrData.java | 251 ++++++ .../kingdee/eas/custom/risheng/HKSyncHrData.java | 25 + .../custom/risheng/IRishengHaiKangHRFacade.java | 22 + .../custom/risheng/IRishengInterfaceFacade.java | 23 + .../risheng/IRishengPendingMessageFacade.java | 20 + .../eas/custom/risheng/RishengHaiKangHRFacade.java | 93 +++ .../risheng/RishengHaiKangHRFacadeController.java | 25 + .../RishengHaiKangHRFacadeControllerBean.java | 162 ++++ .../risheng/RishengHaiKangHRFacadeFactory.java | 30 + .../eas/custom/risheng/RishengInterfaceFacade.java | 107 +++ .../risheng/RishengInterfaceFacadeController.java | 26 + .../RishengInterfaceFacadeControllerBean.java | 894 +++++++++++++++++++++ .../risheng/RishengInterfaceFacadeFactory.java | 30 + .../risheng/RishengPendingMessageFacade.java | 65 ++ .../RishengPendingMessageFacadeController.java | 23 + .../RishengPendingMessageFacadeControllerBean.java | 342 ++++++++ .../RishengPendingMessageFacadeFactory.java | 30 + .../custom/risheng/SendTodoMessageTaskHandler.java | 45 ++ .../kingdee/eas/custom/risheng/SyncDataFacade.java | 21 + .../eas/custom/risheng/SyncHRDataInterface.java | 9 + .../custom/risheng/util/HttpRequestSecUtil.java | 408 ++++++++++ .../eas/custom/risheng/util/HttpRequestUtil.java | 245 ++++++ .../WSRishengHaiKangHRFacadeSrvProxy.java | 88 ++ .../WSRishengInterfaceFacadeSrvProxy.java | 98 +++ .../WSRishengPendingMessageFacadeSrvProxy.java | 68 ++ 33 files changed, 3658 insertions(+) create mode 100644 src/DayouTechnologyInterfaceFacade.wsdd create mode 100644 src/RishengHaiKangHRFacade.wsdd create mode 100644 src/RishengInterfaceFacade.wsdd create mode 100644 src/RishengPendingMessageFacade.wsdd create mode 100644 src/com/kingdee/eas/custom/risheng/AbstractRishengHaiKangHRFacadeControllerBean.java create mode 100644 src/com/kingdee/eas/custom/risheng/AbstractRishengInterfaceFacadeControllerBean.java create mode 100644 src/com/kingdee/eas/custom/risheng/AbstractRishengPendingMessageFacadeControllerBean.java create mode 100644 src/com/kingdee/eas/custom/risheng/AssignmentEventHandler.java create mode 100644 src/com/kingdee/eas/custom/risheng/FWOASyncHrData.java create mode 100644 src/com/kingdee/eas/custom/risheng/HKSyncHrData.java create mode 100644 src/com/kingdee/eas/custom/risheng/IRishengHaiKangHRFacade.java create mode 100644 src/com/kingdee/eas/custom/risheng/IRishengInterfaceFacade.java create mode 100644 src/com/kingdee/eas/custom/risheng/IRishengPendingMessageFacade.java create mode 100644 src/com/kingdee/eas/custom/risheng/RishengHaiKangHRFacade.java create mode 100644 src/com/kingdee/eas/custom/risheng/RishengHaiKangHRFacadeController.java create mode 100644 src/com/kingdee/eas/custom/risheng/RishengHaiKangHRFacadeControllerBean.java create mode 100644 src/com/kingdee/eas/custom/risheng/RishengHaiKangHRFacadeFactory.java create mode 100644 src/com/kingdee/eas/custom/risheng/RishengInterfaceFacade.java create mode 100644 src/com/kingdee/eas/custom/risheng/RishengInterfaceFacadeController.java create mode 100644 src/com/kingdee/eas/custom/risheng/RishengInterfaceFacadeControllerBean.java create mode 100644 src/com/kingdee/eas/custom/risheng/RishengInterfaceFacadeFactory.java create mode 100644 src/com/kingdee/eas/custom/risheng/RishengPendingMessageFacade.java create mode 100644 src/com/kingdee/eas/custom/risheng/RishengPendingMessageFacadeController.java create mode 100644 src/com/kingdee/eas/custom/risheng/RishengPendingMessageFacadeControllerBean.java create mode 100644 src/com/kingdee/eas/custom/risheng/RishengPendingMessageFacadeFactory.java create mode 100644 src/com/kingdee/eas/custom/risheng/SendTodoMessageTaskHandler.java create mode 100644 src/com/kingdee/eas/custom/risheng/SyncDataFacade.java create mode 100644 src/com/kingdee/eas/custom/risheng/SyncHRDataInterface.java create mode 100644 src/com/kingdee/eas/custom/risheng/util/HttpRequestSecUtil.java create mode 100644 src/com/kingdee/eas/custom/risheng/util/HttpRequestUtil.java create mode 100644 src/com/kingdee/eas/custom/risheng/webservice/WSRishengHaiKangHRFacadeSrvProxy.java create mode 100644 src/com/kingdee/eas/custom/risheng/webservice/WSRishengInterfaceFacadeSrvProxy.java create mode 100644 src/com/kingdee/eas/custom/risheng/webservice/WSRishengPendingMessageFacadeSrvProxy.java diff --git a/src/DayouTechnologyInterfaceFacade.wsdd b/src/DayouTechnologyInterfaceFacade.wsdd new file mode 100644 index 0000000..58a4469 --- /dev/null +++ b/src/DayouTechnologyInterfaceFacade.wsdd @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/RishengHaiKangHRFacade.wsdd b/src/RishengHaiKangHRFacade.wsdd new file mode 100644 index 0000000..16ddf2d --- /dev/null +++ b/src/RishengHaiKangHRFacade.wsdd @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/RishengInterfaceFacade.wsdd b/src/RishengInterfaceFacade.wsdd new file mode 100644 index 0000000..d0f3668 --- /dev/null +++ b/src/RishengInterfaceFacade.wsdd @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/RishengPendingMessageFacade.wsdd b/src/RishengPendingMessageFacade.wsdd new file mode 100644 index 0000000..1dfe991 --- /dev/null +++ b/src/RishengPendingMessageFacade.wsdd @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/com/kingdee/eas/custom/risheng/AbstractRishengHaiKangHRFacadeControllerBean.java b/src/com/kingdee/eas/custom/risheng/AbstractRishengHaiKangHRFacadeControllerBean.java new file mode 100644 index 0000000..7a3d74b --- /dev/null +++ b/src/com/kingdee/eas/custom/risheng/AbstractRishengHaiKangHRFacadeControllerBean.java @@ -0,0 +1,135 @@ +package com.kingdee.eas.custom.risheng; + +import javax.ejb.*; +import java.rmi.RemoteException; +import com.kingdee.bos.*; +import com.kingdee.bos.util.BOSObjectType; +import com.kingdee.bos.metadata.IMetaDataPK; +import com.kingdee.bos.metadata.rule.RuleExecutor; +import com.kingdee.bos.metadata.MetaDataPK; +//import com.kingdee.bos.metadata.entity.EntityViewInfo; +import com.kingdee.bos.framework.ejb.AbstractEntityControllerBean; +import com.kingdee.bos.framework.ejb.AbstractBizControllerBean; +//import com.kingdee.bos.dao.IObjectPK; +import com.kingdee.bos.dao.IObjectValue; +import com.kingdee.bos.dao.IObjectCollection; +import com.kingdee.bos.service.ServiceContext; +import com.kingdee.bos.service.IServiceContext; +import com.kingdee.eas.framework.Result; +import com.kingdee.eas.framework.LineResult; +import com.kingdee.eas.framework.exception.EASMultiException; +import com.kingdee.bos.dao.ormapping.ObjectUuidPK; + +import com.kingdee.eas.common.EASBizException; +import java.lang.String; + + + +public abstract class AbstractRishengHaiKangHRFacadeControllerBean extends AbstractBizControllerBean implements RishengHaiKangHRFacadeController +{ + protected AbstractRishengHaiKangHRFacadeControllerBean() + { + } + + protected BOSObjectType getBOSType() + { + return new BOSObjectType("FE79E785"); + } + + public String syncAdminOrg(Context ctx, String data) throws BOSException, EASBizException + { + try { + ServiceContext svcCtx = createServiceContext(new MetaDataPK("5ec9f78c-3290-436c-a1a6-2fc01230e621"), new Object[]{ctx, data}); + invokeServiceBefore(svcCtx); + if(!svcCtx.invokeBreak()) { + String retValue = (String)_syncAdminOrg(ctx, data); + svcCtx.setMethodReturnValue(retValue); + } + invokeServiceAfter(svcCtx); + return (String)svcCtx.getMethodReturnValue(); + } catch (BOSException ex) { + throw ex; + } catch (EASBizException ex0) { + throw ex0; + } finally { + super.cleanUpServiceState(); + } + } + protected String _syncAdminOrg(Context ctx, String data) throws BOSException, EASBizException + { + return null; + } + + public String syncPerson(Context ctx, String data) throws BOSException, EASBizException + { + try { + ServiceContext svcCtx = createServiceContext(new MetaDataPK("6fbe0ce6-b218-4707-bc26-16a8398d760b"), new Object[]{ctx, data}); + invokeServiceBefore(svcCtx); + if(!svcCtx.invokeBreak()) { + String retValue = (String)_syncPerson(ctx, data); + svcCtx.setMethodReturnValue(retValue); + } + invokeServiceAfter(svcCtx); + return (String)svcCtx.getMethodReturnValue(); + } catch (BOSException ex) { + throw ex; + } catch (EASBizException ex0) { + throw ex0; + } finally { + super.cleanUpServiceState(); + } + } + protected String _syncPerson(Context ctx, String data) throws BOSException, EASBizException + { + return null; + } + + public String syncEmpLeaves(Context ctx, String data) throws BOSException, EASBizException + { + try { + ServiceContext svcCtx = createServiceContext(new MetaDataPK("4a0e4eca-ff66-4bd4-9b08-36e7ae6df4ac"), new Object[]{ctx, data}); + invokeServiceBefore(svcCtx); + if(!svcCtx.invokeBreak()) { + String retValue = (String)_syncEmpLeaves(ctx, data); + svcCtx.setMethodReturnValue(retValue); + } + invokeServiceAfter(svcCtx); + return (String)svcCtx.getMethodReturnValue(); + } catch (BOSException ex) { + throw ex; + } catch (EASBizException ex0) { + throw ex0; + } finally { + super.cleanUpServiceState(); + } + } + protected String _syncEmpLeaves(Context ctx, String data) throws BOSException, EASBizException + { + return null; + } + + public String syncEmpLeavesRestore(Context ctx, String data) throws BOSException, EASBizException + { + try { + ServiceContext svcCtx = createServiceContext(new MetaDataPK("8140a7fe-6a15-4874-ba91-4b947284947c"), new Object[]{ctx, data}); + invokeServiceBefore(svcCtx); + if(!svcCtx.invokeBreak()) { + String retValue = (String)_syncEmpLeavesRestore(ctx, data); + svcCtx.setMethodReturnValue(retValue); + } + invokeServiceAfter(svcCtx); + return (String)svcCtx.getMethodReturnValue(); + } catch (BOSException ex) { + throw ex; + } catch (EASBizException ex0) { + throw ex0; + } finally { + super.cleanUpServiceState(); + } + } + protected String _syncEmpLeavesRestore(Context ctx, String data) throws BOSException, EASBizException + { + return null; + } + +} \ No newline at end of file diff --git a/src/com/kingdee/eas/custom/risheng/AbstractRishengInterfaceFacadeControllerBean.java b/src/com/kingdee/eas/custom/risheng/AbstractRishengInterfaceFacadeControllerBean.java new file mode 100644 index 0000000..b8f561a --- /dev/null +++ b/src/com/kingdee/eas/custom/risheng/AbstractRishengInterfaceFacadeControllerBean.java @@ -0,0 +1,159 @@ +package com.kingdee.eas.custom.risheng; + +import javax.ejb.*; +import java.rmi.RemoteException; +import com.kingdee.bos.*; +import com.kingdee.bos.util.BOSObjectType; +import com.kingdee.bos.metadata.IMetaDataPK; +import com.kingdee.bos.metadata.rule.RuleExecutor; +import com.kingdee.bos.metadata.MetaDataPK; +//import com.kingdee.bos.metadata.entity.EntityViewInfo; +import com.kingdee.bos.framework.ejb.AbstractEntityControllerBean; +import com.kingdee.bos.framework.ejb.AbstractBizControllerBean; +//import com.kingdee.bos.dao.IObjectPK; +import com.kingdee.bos.dao.IObjectValue; +import com.kingdee.bos.dao.IObjectCollection; +import com.kingdee.bos.service.ServiceContext; +import com.kingdee.bos.service.IServiceContext; +import com.kingdee.eas.framework.Result; +import com.kingdee.eas.framework.LineResult; +import com.kingdee.eas.framework.exception.EASMultiException; +import com.kingdee.bos.dao.ormapping.ObjectUuidPK; + +import com.kingdee.eas.common.EASBizException; +import java.lang.String; + + + +public abstract class AbstractRishengInterfaceFacadeControllerBean extends AbstractBizControllerBean implements RishengInterfaceFacadeController +{ + protected AbstractRishengInterfaceFacadeControllerBean() + { + } + + protected BOSObjectType getBOSType() + { + return new BOSObjectType("81647F35"); + } + + public String syncAdminOrgInfo(Context ctx, String data) throws BOSException, EASBizException + { + try { + ServiceContext svcCtx = createServiceContext(new MetaDataPK("90b14237-2dc7-4f12-a02b-07d4ac132528"), new Object[]{ctx, data}); + invokeServiceBefore(svcCtx); + if(!svcCtx.invokeBreak()) { + String retValue = (String)_syncAdminOrgInfo(ctx, data); + svcCtx.setMethodReturnValue(retValue); + } + invokeServiceAfter(svcCtx); + return (String)svcCtx.getMethodReturnValue(); + } catch (BOSException ex) { + throw ex; + } catch (EASBizException ex0) { + throw ex0; + } finally { + super.cleanUpServiceState(); + } + } + protected String _syncAdminOrgInfo(Context ctx, String data) throws BOSException, EASBizException + { + return null; + } + + public String syncEmployeeInfo(Context ctx, String data) throws BOSException, EASBizException + { + try { + ServiceContext svcCtx = createServiceContext(new MetaDataPK("51e57a64-e2d2-4ff7-ab38-bb3727fff137"), new Object[]{ctx, data}); + invokeServiceBefore(svcCtx); + if(!svcCtx.invokeBreak()) { + String retValue = (String)_syncEmployeeInfo(ctx, data); + svcCtx.setMethodReturnValue(retValue); + } + invokeServiceAfter(svcCtx); + return (String)svcCtx.getMethodReturnValue(); + } catch (BOSException ex) { + throw ex; + } catch (EASBizException ex0) { + throw ex0; + } finally { + super.cleanUpServiceState(); + } + } + protected String _syncEmployeeInfo(Context ctx, String data) throws BOSException, EASBizException + { + return null; + } + + public String syncPositionInfo(Context ctx, String data) throws BOSException, EASBizException + { + try { + ServiceContext svcCtx = createServiceContext(new MetaDataPK("fe6c7efd-1ac5-4358-94a3-15a13c696422"), new Object[]{ctx, data}); + invokeServiceBefore(svcCtx); + if(!svcCtx.invokeBreak()) { + String retValue = (String)_syncPositionInfo(ctx, data); + svcCtx.setMethodReturnValue(retValue); + } + invokeServiceAfter(svcCtx); + return (String)svcCtx.getMethodReturnValue(); + } catch (BOSException ex) { + throw ex; + } catch (EASBizException ex0) { + throw ex0; + } finally { + super.cleanUpServiceState(); + } + } + protected String _syncPositionInfo(Context ctx, String data) throws BOSException, EASBizException + { + return null; + } + + public String syncJoblevelInfo(Context ctx, String data) throws BOSException, EASBizException + { + try { + ServiceContext svcCtx = createServiceContext(new MetaDataPK("17470ca5-628a-4584-923c-c6fc0b9fc8f5"), new Object[]{ctx, data}); + invokeServiceBefore(svcCtx); + if(!svcCtx.invokeBreak()) { + String retValue = (String)_syncJoblevelInfo(ctx, data); + svcCtx.setMethodReturnValue(retValue); + } + invokeServiceAfter(svcCtx); + return (String)svcCtx.getMethodReturnValue(); + } catch (BOSException ex) { + throw ex; + } catch (EASBizException ex0) { + throw ex0; + } finally { + super.cleanUpServiceState(); + } + } + protected String _syncJoblevelInfo(Context ctx, String data) throws BOSException, EASBizException + { + return null; + } + + public String syncPersonPositionInfo(Context ctx, String data) throws BOSException, EASBizException + { + try { + ServiceContext svcCtx = createServiceContext(new MetaDataPK("97aff530-a207-4665-8aeb-31fa9267da08"), new Object[]{ctx, data}); + invokeServiceBefore(svcCtx); + if(!svcCtx.invokeBreak()) { + String retValue = (String)_syncPersonPositionInfo(ctx, data); + svcCtx.setMethodReturnValue(retValue); + } + invokeServiceAfter(svcCtx); + return (String)svcCtx.getMethodReturnValue(); + } catch (BOSException ex) { + throw ex; + } catch (EASBizException ex0) { + throw ex0; + } finally { + super.cleanUpServiceState(); + } + } + protected String _syncPersonPositionInfo(Context ctx, String data) throws BOSException, EASBizException + { + return null; + } + +} \ No newline at end of file diff --git a/src/com/kingdee/eas/custom/risheng/AbstractRishengPendingMessageFacadeControllerBean.java b/src/com/kingdee/eas/custom/risheng/AbstractRishengPendingMessageFacadeControllerBean.java new file mode 100644 index 0000000..2fe23be --- /dev/null +++ b/src/com/kingdee/eas/custom/risheng/AbstractRishengPendingMessageFacadeControllerBean.java @@ -0,0 +1,87 @@ +package com.kingdee.eas.custom.risheng; + +import javax.ejb.*; +import java.rmi.RemoteException; +import com.kingdee.bos.*; +import com.kingdee.bos.util.BOSObjectType; +import com.kingdee.bos.metadata.IMetaDataPK; +import com.kingdee.bos.metadata.rule.RuleExecutor; +import com.kingdee.bos.metadata.MetaDataPK; +//import com.kingdee.bos.metadata.entity.EntityViewInfo; +import com.kingdee.bos.framework.ejb.AbstractEntityControllerBean; +import com.kingdee.bos.framework.ejb.AbstractBizControllerBean; +//import com.kingdee.bos.dao.IObjectPK; +import com.kingdee.bos.dao.IObjectValue; +import com.kingdee.bos.dao.IObjectCollection; +import com.kingdee.bos.service.ServiceContext; +import com.kingdee.bos.service.IServiceContext; +import com.kingdee.eas.framework.Result; +import com.kingdee.eas.framework.LineResult; +import com.kingdee.eas.framework.exception.EASMultiException; +import com.kingdee.bos.dao.ormapping.ObjectUuidPK; + +import com.kingdee.eas.common.EASBizException; +import java.lang.String; + + + +public abstract class AbstractRishengPendingMessageFacadeControllerBean extends AbstractBizControllerBean implements RishengPendingMessageFacadeController +{ + protected AbstractRishengPendingMessageFacadeControllerBean() + { + } + + protected BOSObjectType getBOSType() + { + return new BOSObjectType("4FA99C68"); + } + + public String sendPendingMsg(Context ctx, String data) throws BOSException, EASBizException + { + try { + ServiceContext svcCtx = createServiceContext(new MetaDataPK("7292ebe1-3025-4d1a-be1e-b5205d4cec73"), new Object[]{ctx, data}); + invokeServiceBefore(svcCtx); + if(!svcCtx.invokeBreak()) { + String retValue = (String)_sendPendingMsg(ctx, data); + svcCtx.setMethodReturnValue(retValue); + } + invokeServiceAfter(svcCtx); + return (String)svcCtx.getMethodReturnValue(); + } catch (BOSException ex) { + throw ex; + } catch (EASBizException ex0) { + throw ex0; + } finally { + super.cleanUpServiceState(); + } + } + protected String _sendPendingMsg(Context ctx, String data) throws BOSException, EASBizException + { + return null; + } + + public String sendDoneMsg(Context ctx, String data) throws BOSException, EASBizException + { + try { + ServiceContext svcCtx = createServiceContext(new MetaDataPK("d680b585-3ed4-43d1-985c-8e42f5869e5a"), new Object[]{ctx, data}); + invokeServiceBefore(svcCtx); + if(!svcCtx.invokeBreak()) { + String retValue = (String)_sendDoneMsg(ctx, data); + svcCtx.setMethodReturnValue(retValue); + } + invokeServiceAfter(svcCtx); + return (String)svcCtx.getMethodReturnValue(); + } catch (BOSException ex) { + throw ex; + } catch (EASBizException ex0) { + throw ex0; + } finally { + super.cleanUpServiceState(); + } + } + protected String _sendDoneMsg(Context ctx, String data) throws BOSException, EASBizException + { + return null; + } + +} \ No newline at end of file diff --git a/src/com/kingdee/eas/custom/risheng/AssignmentEventHandler.java b/src/com/kingdee/eas/custom/risheng/AssignmentEventHandler.java new file mode 100644 index 0000000..0df9a04 --- /dev/null +++ b/src/com/kingdee/eas/custom/risheng/AssignmentEventHandler.java @@ -0,0 +1,87 @@ +package com.kingdee.eas.custom.risheng; + +import java.util.Locale; + +import org.apache.log4j.Logger; + +import net.sf.json.JSONObject; + +import com.kingdee.bos.BOSException; +import com.kingdee.bos.Context; +import com.kingdee.bos.workflow.define.AssignmentEvent; +import com.kingdee.bos.workflow.enactment.IWfAssignment; +import com.kingdee.bos.workflow.enactment.WfAssignment; +import com.kingdee.bos.workflow.enactment.handler.AbstractAssignmentEventHandler; +import com.kingdee.eas.common.EASBizException; + +public class AssignmentEventHandler extends AbstractAssignmentEventHandler { + + private static Logger logger = + Logger.getLogger("com.kingdee.eas.custom.risheng.AssignmentEventHandler"); + /** + * + */ + private static final long serialVersionUID = -1965097515604467567L; + + @Override + public void execute(AssignmentEvent assignmentEvent, + IWfAssignment assignment) { + // TODO Auto-generated method stub + WfAssignment assign = (WfAssignment) assignment; + Context ctx = assign.getContext(); + String assignId = assign.getAssignmentInfo().getAssignmentId(); + logger.error("AssignmentEventHandler:"+assignmentEvent.getName()+","+assignmentEvent); + JSONObject jsonobject = new JSONObject(); + jsonobject.put("assignId", assignId); + jsonobject.put("state", assign.getAssignmentInfo().getState().getValue()); + if (AssignmentEvent.OnAssignmentAborted.equals(assignmentEvent)) { + logger.error("SendTodoMessageTaskHandler:OnAssignmentAborted"+assignId+":assign.getAssignmentInfo().getState():"+assign.getAssignmentInfo().getState().getValue()); + try { + + // TosendMessageFacadeFactory.getLocalInstance(ctx).deleteTodo(jsonobject.toString()); + RishengPendingMessageFacadeFactory.getLocalInstance(ctx).sendDoneMsg(null); + } catch (EASBizException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (BOSException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + }else if(AssignmentEvent.OnAssignmentComplete.equals(assignmentEvent)){ + + logger.error("SendTodoMessageTaskHandler:OnAssignmentComplete"+assignId+":assign.getAssignmentInfo().getState():"+assign.getAssignmentInfo().getState().getValue()); + try { + Race race = new Race(ctx,assignId); + new Thread(race,assignId).start(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + + } + class Race implements Runnable { + + private Context ctx; + private String jsonobject; + public Race(Context ctx,String jsonobject){ + this.ctx=ctx; + this.jsonobject=jsonobject; + } + @Override + public void run() { + // TODO Auto-generated method stub + + try { + RishengPendingMessageFacadeFactory.getLocalInstance(ctx).sendDoneMsg(null); + } catch (EASBizException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (BOSException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + } +} diff --git a/src/com/kingdee/eas/custom/risheng/FWOASyncHrData.java b/src/com/kingdee/eas/custom/risheng/FWOASyncHrData.java new file mode 100644 index 0000000..d2ad6fb --- /dev/null +++ b/src/com/kingdee/eas/custom/risheng/FWOASyncHrData.java @@ -0,0 +1,251 @@ +package com.kingdee.eas.custom.risheng; + +import java.io.OutputStreamWriter; +import java.io.IOException; + + +import org.apache.axis.client.Call; +import org.apache.log4j.Logger; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; + +public class FWOASyncHrData implements SyncHRDataInterface { + + private static Logger logger = + Logger.getLogger("com.kingdee.eas.custom.risheng.FWOASyncHrData"); + + /** + * OA同步组织 + */ + @Override + public String syncAdminOrg(String data,String surl) { + //进入OA组织同步接口 + logger.error("进入OA组织同步"); + OutputStreamWriter out = null; + String result = ""; + try { + JSONArray res = JSONArray.parseArray(data); + logger.error("查询数据为:"+res.toString()); + //解析数据 + //封装请求的报文,将请求参数,组合为XML格式 + StringBuffer xmlBuffer = new StringBuffer(); + xmlBuffer.append(""); + xmlBuffer.append(""); + xmlBuffer.append(" "); + for (int i = 0; i < res.size(); i++) { + JSONObject obj = res.getJSONObject(i); + logger.error("action="+obj.getString("action")); + xmlBuffer.append(" "); + xmlBuffer.append(" "+obj.getString("code")+""); + xmlBuffer.append(" "+obj.getString("shortname")+""); + xmlBuffer.append(" "+obj.getString("fullname")+""); + xmlBuffer.append(" "+obj.getString("org_code")+""); + xmlBuffer.append(" "+obj.getString("parent_code")+""); + xmlBuffer.append(" "+obj.getString("canceled")+""); + xmlBuffer.append(" 0"); + xmlBuffer.append(" "); + } + xmlBuffer.append(" "); + xmlBuffer.append(""); + //XML参数内容 + String xmlStr = xmlBuffer.toString(); + String ipStr = "121.37.207.73"; + // http://120.46.132.160:8080 + String urlStr = surl; + org.apache.axis.client.Service service = new org.apache.axis.client.Service(); + Call call = (Call) service.createCall(); + call.setOperationName("SynDepartment"); + call.setTargetEndpointAddress(urlStr); + String[] param1 = new String[2]; + param1[0] = ipStr; + param1[1] = xmlStr; + // logger.error("开始访问"); + result = (String)call.invoke(param1); + // logger.error("接口返回结果为:"+result.toString()); + + } catch (Exception e) { + e.printStackTrace(); + logger.error(e.getMessage()); + }finally { + try { + if (out != null) { + out.close(); + } + } catch (IOException e) { + e.printStackTrace(); + logger.error(e.getMessage()); + } + } + return result.toString(); + } + + /** + * 人员同步到OA + */ + @Override + public String syncPerson(String data,String surl) { + //进入OA组织同步接口 + // logger.error("进入OA人员同步"); + OutputStreamWriter out = null; + String result = ""; + try { + JSONArray res = JSONArray.parseArray(data); + // logger.error("查询数据为:"+res.toString()); + //解析数据 + //封装请求的报文,将请求参数,组合为XML格式 + StringBuffer xmlBuffer = new StringBuffer(); + xmlBuffer.append(""); + xmlBuffer.append(""); + xmlBuffer.append(" "); + for (int i = 0; i < res.size(); i++) { + JSONObject obj = res.getJSONObject(i); + logger.error("action="+obj.getString("action")); + xmlBuffer.append(" "); + xmlBuffer.append(" "+obj.getString("workcode")+""); + xmlBuffer.append(" "+obj.getString("subcompany")+""); + xmlBuffer.append(" "+obj.getString("department")+""); + xmlBuffer.append(" "+obj.getString("lastname")+""); + xmlBuffer.append(" "+obj.getString("loginid")+""); + if(obj.getString("password")=="null"||obj.getString("password")==null||obj.getString("password")==""){ + //xmlBuffer.append(" "+obj.getString("password")+""); + }else{ + xmlBuffer.append(" "+obj.getString("password")+""); + } + xmlBuffer.append(" "+obj.getString("seclevel")+""); + xmlBuffer.append(" "+obj.getString("sex")+""); + xmlBuffer.append(" "+obj.getString("jobtitle")+""); + xmlBuffer.append(" "+obj.getString("jobactivityid")+""); + xmlBuffer.append(" "+obj.getString("jobgroupid")+""); + xmlBuffer.append(" "+obj.getString("jobcall")+""); + xmlBuffer.append(" "+obj.getString("joblevel")+""); + xmlBuffer.append(" "+obj.getString("jobactivitydesc")+""); + xmlBuffer.append(" "+obj.getString("managerid")+""); + xmlBuffer.append(" "+obj.getString("assistantid")+""); + xmlBuffer.append(" "+obj.getString("status")+""); + xmlBuffer.append(" "+obj.getString("locationid")+""); + xmlBuffer.append(" "+obj.getString("workroom")+""); + xmlBuffer.append(" "+obj.getString("telephone")+""); + xmlBuffer.append(" "+obj.getString("mobile")+""); + xmlBuffer.append(" "+obj.getString("mobilecall")+""); + xmlBuffer.append(" "+obj.getString("fax")+""); + xmlBuffer.append(" "+obj.getString("email")+""); + xmlBuffer.append(" "+obj.getString("systemlanguage")+""); + xmlBuffer.append(" "+obj.getString("birthday")+""); + xmlBuffer.append(" "+obj.getString("folk")+""); + xmlBuffer.append(" "+obj.getString("nativeplace")+""); + xmlBuffer.append(" "+obj.getString("regresidentplace")+""); + xmlBuffer.append(" "+obj.getString("certificatenum")+""); + xmlBuffer.append(" "+obj.getString("maritalstatus")+""); + xmlBuffer.append(" "+obj.getString("policy")+""); + xmlBuffer.append(" "+obj.getString("bememberdate")+""); + xmlBuffer.append(" "+obj.getString("bepartydate")+""); + xmlBuffer.append(" "+obj.getString("islabouunion")+""); + xmlBuffer.append(" "+obj.getString("educationlevel")+""); + xmlBuffer.append(" "+obj.getString("degree")+""); + xmlBuffer.append(" "+obj.getString("healthinfo")+""); + xmlBuffer.append(" "+obj.getString("height")+""); + xmlBuffer.append(" "+obj.getString("weight")+""); + xmlBuffer.append(" "+obj.getString("residentplace")+""); + xmlBuffer.append(" "+obj.getString("homeaddress")+""); + xmlBuffer.append(" "+obj.getString("tempresidentnumber")+""); + xmlBuffer.append(" "); + } + xmlBuffer.append(" "); + xmlBuffer.append(""); + //XML参数内容 + String xmlStr = xmlBuffer.toString(); + logger.error("人员xml参数为"+xmlStr); + String ipStr = "121.37.207.73"; + String urlStr = surl; + org.apache.axis.client.Service service = new org.apache.axis.client.Service(); + Call call = (Call) service.createCall(); + call.setOperationName("SynHrmResource"); + call.setTargetEndpointAddress(urlStr); + String[] param1 = new String[2]; + param1[0] = ipStr; + param1[1] = xmlStr; + logger.error("开始访问"); + result = (String)call.invoke(param1); + logger.error("接口返回结果为:"+result.toString()); + + } catch (Exception e) { + e.printStackTrace(); + logger.error(e.getMessage()); + }finally { + try { + if (out != null) { + out.close(); + } + } catch (IOException e) { + e.printStackTrace(); + logger.error(e.getMessage()); + } + } + return result.toString(); + } + /** + * 岗位同步 + */ + @Override + public String syncPosition(String data,String surl) { + //进入OA组织同步接口 + logger.error("进入OA岗位同步"); + OutputStreamWriter out = null; + String result = ""; + try { + JSONArray res = JSONArray.parseArray(data); + logger.error("查询数据为:"+res.toString()); + //解析数据 + //封装请求的报文,将请求参数,组合为XML格式 + StringBuffer xmlBuffer = new StringBuffer(); + xmlBuffer.append(""); + xmlBuffer.append(""); + xmlBuffer.append(" "); + for (int i = 0; i < res.size(); i++) { + JSONObject obj = res.getJSONObject(i); + logger.error("action="+obj.getString("action")); + xmlBuffer.append(" "); + xmlBuffer.append(" "+obj.getString("jobtitlecode")+""); + xmlBuffer.append(" "+obj.getString("jobtitlename")+""); + xmlBuffer.append(" "+obj.getString("jobtitleremark")+""); + xmlBuffer.append(" "+obj.getString("jobtitledept")+""); + // jobgroupid 待确认 传不传 + xmlBuffer.append(" "+obj.getString("jobgroupid")+""); + xmlBuffer.append(" "); + } + xmlBuffer.append(" "); + xmlBuffer.append(""); + //XML参数内容 + String xmlStr = xmlBuffer.toString(); + String ipStr = "121.37.207.73"; + // http://120.46.132.160:8080 + String urlStr = surl; + org.apache.axis.client.Service service = new org.apache.axis.client.Service(); + Call call = (Call) service.createCall(); + call.setOperationName("SynJobtitle"); + call.setTargetEndpointAddress(urlStr); + String[] param1 = new String[2]; + param1[0] = ipStr; + param1[1] = xmlStr; + logger.error("开始访问"); + result = (String)call.invoke(param1); + logger.error("接口返回结果为:"+result.toString()); + + } catch (Exception e) { + e.printStackTrace(); + logger.error(e.getMessage()); + }finally { + try { + if (out != null) { + out.close(); + } + } catch (IOException e) { + e.printStackTrace(); + logger.error(e.getMessage()); + } + } + return result.toString(); + } + +} diff --git a/src/com/kingdee/eas/custom/risheng/HKSyncHrData.java b/src/com/kingdee/eas/custom/risheng/HKSyncHrData.java new file mode 100644 index 0000000..fc997c1 --- /dev/null +++ b/src/com/kingdee/eas/custom/risheng/HKSyncHrData.java @@ -0,0 +1,25 @@ +package com.kingdee.eas.custom.risheng; + +import java.util.Map; + +public class HKSyncHrData implements SyncHRDataInterface { + + @Override + public String syncAdminOrg(String data,String surl) { + // TODO 自动生成的方法存根 + return null; + } + + @Override + public String syncPerson(String data,String surl) { + // TODO 自动生成的方法存根 + return null; + } + + @Override + public String syncPosition(String data,String surl) { + // TODO 自动生成的方法存根 + return null; + } + +} diff --git a/src/com/kingdee/eas/custom/risheng/IRishengHaiKangHRFacade.java b/src/com/kingdee/eas/custom/risheng/IRishengHaiKangHRFacade.java new file mode 100644 index 0000000..7d014a7 --- /dev/null +++ b/src/com/kingdee/eas/custom/risheng/IRishengHaiKangHRFacade.java @@ -0,0 +1,22 @@ +package com.kingdee.eas.custom.risheng; + +import com.kingdee.bos.BOSException; +//import com.kingdee.bos.metadata.*; +import com.kingdee.bos.framework.*; +import com.kingdee.bos.util.*; +import com.kingdee.bos.Context; + +import com.kingdee.bos.BOSException; +import com.kingdee.bos.util.*; +import com.kingdee.eas.common.EASBizException; +import java.lang.String; +import com.kingdee.bos.Context; +import com.kingdee.bos.framework.*; + +public interface IRishengHaiKangHRFacade extends IBizCtrl +{ + public String syncAdminOrg(String data) throws BOSException, EASBizException; + public String syncPerson(String data) throws BOSException, EASBizException; + public String syncEmpLeaves(String data) throws BOSException, EASBizException; + public String syncEmpLeavesRestore(String data) throws BOSException, EASBizException; +} \ No newline at end of file diff --git a/src/com/kingdee/eas/custom/risheng/IRishengInterfaceFacade.java b/src/com/kingdee/eas/custom/risheng/IRishengInterfaceFacade.java new file mode 100644 index 0000000..fc6de40 --- /dev/null +++ b/src/com/kingdee/eas/custom/risheng/IRishengInterfaceFacade.java @@ -0,0 +1,23 @@ +package com.kingdee.eas.custom.risheng; + +import com.kingdee.bos.BOSException; +//import com.kingdee.bos.metadata.*; +import com.kingdee.bos.framework.*; +import com.kingdee.bos.util.*; +import com.kingdee.bos.Context; + +import com.kingdee.bos.BOSException; +import com.kingdee.bos.util.*; +import com.kingdee.eas.common.EASBizException; +import java.lang.String; +import com.kingdee.bos.Context; +import com.kingdee.bos.framework.*; + +public interface IRishengInterfaceFacade extends IBizCtrl +{ + public String syncAdminOrgInfo(String data) throws BOSException, EASBizException; + public String syncEmployeeInfo(String data) throws BOSException, EASBizException; + public String syncPositionInfo(String data) throws BOSException, EASBizException; + public String syncJoblevelInfo(String data) throws BOSException, EASBizException; + public String syncPersonPositionInfo(String data) throws BOSException, EASBizException; +} \ No newline at end of file diff --git a/src/com/kingdee/eas/custom/risheng/IRishengPendingMessageFacade.java b/src/com/kingdee/eas/custom/risheng/IRishengPendingMessageFacade.java new file mode 100644 index 0000000..1b8e82b --- /dev/null +++ b/src/com/kingdee/eas/custom/risheng/IRishengPendingMessageFacade.java @@ -0,0 +1,20 @@ +package com.kingdee.eas.custom.risheng; + +import com.kingdee.bos.BOSException; +//import com.kingdee.bos.metadata.*; +import com.kingdee.bos.framework.*; +import com.kingdee.bos.util.*; +import com.kingdee.bos.Context; + +import com.kingdee.bos.BOSException; +import com.kingdee.bos.util.*; +import com.kingdee.eas.common.EASBizException; +import java.lang.String; +import com.kingdee.bos.Context; +import com.kingdee.bos.framework.*; + +public interface IRishengPendingMessageFacade extends IBizCtrl +{ + public String sendPendingMsg(String data) throws BOSException, EASBizException; + public String sendDoneMsg(String data) throws BOSException, EASBizException; +} \ No newline at end of file diff --git a/src/com/kingdee/eas/custom/risheng/RishengHaiKangHRFacade.java b/src/com/kingdee/eas/custom/risheng/RishengHaiKangHRFacade.java new file mode 100644 index 0000000..33170c5 --- /dev/null +++ b/src/com/kingdee/eas/custom/risheng/RishengHaiKangHRFacade.java @@ -0,0 +1,93 @@ +package com.kingdee.eas.custom.risheng; + +import com.kingdee.bos.framework.ejb.EJBRemoteException; +import com.kingdee.bos.util.BOSObjectType; +import java.rmi.RemoteException; +import com.kingdee.bos.framework.AbstractBizCtrl; +import com.kingdee.bos.orm.template.ORMObject; + +import com.kingdee.bos.BOSException; +import com.kingdee.bos.util.*; +import com.kingdee.eas.common.EASBizException; +import com.kingdee.eas.custom.risheng.*; +import java.lang.String; +import com.kingdee.bos.Context; +import com.kingdee.bos.framework.*; + +public class RishengHaiKangHRFacade extends AbstractBizCtrl implements IRishengHaiKangHRFacade +{ + public RishengHaiKangHRFacade() + { + super(); + registerInterface(IRishengHaiKangHRFacade.class, this); + } + public RishengHaiKangHRFacade(Context ctx) + { + super(ctx); + registerInterface(IRishengHaiKangHRFacade.class, this); + } + public BOSObjectType getType() + { + return new BOSObjectType("FE79E785"); + } + private RishengHaiKangHRFacadeController getController() throws BOSException + { + return (RishengHaiKangHRFacadeController)getBizController(); + } + /** + *组织同步海康-User defined method + *@param data data + *@return + */ + public String syncAdminOrg(String data) throws BOSException, EASBizException + { + try { + return getController().syncAdminOrg(getContext(), data); + } + catch(RemoteException err) { + throw new EJBRemoteException(err); + } + } + /** + *人员同步海康-User defined method + *@param data data + *@return + */ + public String syncPerson(String data) throws BOSException, EASBizException + { + try { + return getController().syncPerson(getContext(), data); + } + catch(RemoteException err) { + throw new EJBRemoteException(err); + } + } + /** + *同步员工离职信息-User defined method + *@param data data + *@return + */ + public String syncEmpLeaves(String data) throws BOSException, EASBizException + { + try { + return getController().syncEmpLeaves(getContext(), data); + } + catch(RemoteException err) { + throw new EJBRemoteException(err); + } + } + /** + *同步员工离职恢复信息-User defined method + *@param data data + *@return + */ + public String syncEmpLeavesRestore(String data) throws BOSException, EASBizException + { + try { + return getController().syncEmpLeavesRestore(getContext(), data); + } + catch(RemoteException err) { + throw new EJBRemoteException(err); + } + } +} \ No newline at end of file diff --git a/src/com/kingdee/eas/custom/risheng/RishengHaiKangHRFacadeController.java b/src/com/kingdee/eas/custom/risheng/RishengHaiKangHRFacadeController.java new file mode 100644 index 0000000..b63d743 --- /dev/null +++ b/src/com/kingdee/eas/custom/risheng/RishengHaiKangHRFacadeController.java @@ -0,0 +1,25 @@ +package com.kingdee.eas.custom.risheng; + +import com.kingdee.bos.BOSException; +//import com.kingdee.bos.metadata.*; +import com.kingdee.bos.framework.*; +import com.kingdee.bos.util.*; +import com.kingdee.bos.Context; + +import com.kingdee.bos.BOSException; +import com.kingdee.bos.util.*; +import com.kingdee.eas.common.EASBizException; +import java.lang.String; +import com.kingdee.bos.Context; +import com.kingdee.bos.framework.*; + +import java.rmi.RemoteException; +import com.kingdee.bos.framework.ejb.BizController; + +public interface RishengHaiKangHRFacadeController extends BizController +{ + public String syncAdminOrg(Context ctx, String data) throws BOSException, EASBizException, RemoteException; + public String syncPerson(Context ctx, String data) throws BOSException, EASBizException, RemoteException; + public String syncEmpLeaves(Context ctx, String data) throws BOSException, EASBizException, RemoteException; + public String syncEmpLeavesRestore(Context ctx, String data) throws BOSException, EASBizException, RemoteException; +} \ No newline at end of file diff --git a/src/com/kingdee/eas/custom/risheng/RishengHaiKangHRFacadeControllerBean.java b/src/com/kingdee/eas/custom/risheng/RishengHaiKangHRFacadeControllerBean.java new file mode 100644 index 0000000..195073b --- /dev/null +++ b/src/com/kingdee/eas/custom/risheng/RishengHaiKangHRFacadeControllerBean.java @@ -0,0 +1,162 @@ +package com.kingdee.eas.custom.risheng; + +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.log4j.Logger; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import com.alibaba.fastjson.JSONObject; +import com.aliyun.odps.utils.StringUtils; +import com.kingdee.bos.*; + +import java.lang.String; + +import com.kingdee.eas.base.wssc.app.trd.webservice.WebServiceConfig; +import com.kingdee.eas.common.EASBizException; +import com.kingdee.eas.custom.risheng.util.HttpRequestSecUtil; +import com.kingdee.eas.util.app.DbUtil; +import com.kingdee.jdbc.rowset.IRowSet; + +public class RishengHaiKangHRFacadeControllerBean extends AbstractRishengHaiKangHRFacadeControllerBean +{ + private static Logger logger = + Logger.getLogger("com.kingdee.eas.custom.risheng.RishengHaiKangHRFacadeControllerBean"); + /** + * 组织同步 + */ + @Override + public String syncAdminOrg(Context ctx, String data) throws BOSException, EASBizException { + System.out.println("进入组织同步接口"); + JSONObject returnData = new JSONObject(); + returnData.put("success", true); + returnData.put("message", "OK"); + try { + Calendar beforeTime = Calendar.getInstance(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + beforeTime.add(Calendar.MINUTE, -5);// 5分钟之前的时间 + Date beforeD = beforeTime.getTime(); + String before5 = simpleDateFormat.format(beforeD); + String depSql = ""; + System.out.println("传入参数为"+data.toString()); + Set set = new HashSet(); + String needUpSql = ""; + if(!StringUtils.isEmpty(data)){ + needUpSql = "SELECT FID as id,FNAME_l2 AS NAME,FNUMBER AS CODE,FPARENTID AS PARENT_DEPT FROM T_ORG_ADMIN where fid = '"+data+"'"; + IRowSet depSet = DbUtil.executeQuery(ctx, needUpSql); + while(depSet.next()){ + String dep_code = depSet.getString("CODE"); + set.add(dep_code); + } + }else{ + depSql = "SELECT b.FID as id,b.FNAME_l2 AS NAME,b.FNUMBER AS CODE,b.FPARENTID AS PARENT_DEPT " + + "FROM T_ORG_BASEUNIT a " + + "left join t_org_admin b on a.fid = b.fid " + + "where to_char(a.FLASTUPDATETIME ,'yyyy-MM-dd HH24:mi:ss') >= '"+before5+"' " + + "or to_char(b.FLASTUPDATETIME ,'yyyy-MM-dd HH24:mi:ss') >= '"+before5+"' "; + IRowSet depSet = DbUtil.executeQuery(ctx, depSql); + while(depSet.next()){ + String dep_code = depSet.getString("CODE"); + set.add(dep_code); + } + } + System.out.println("set==="+set.toString()); + for(String pNumber :set){ + String upSql = "/*dialect*/ update t_org_admin Set CFToHKisNew = '1' where fnumber = '"+pNumber+"'"; + DbUtil.execute(ctx,upSql); + } + if(StringUtils.isEmpty(data)){ + needUpSql = "/*dialect*/ select fid id,fname_l2 NAME,FNUMBER CODE,FPARENTID PARENT_DEPT from t_org_admin where CFToHKisNew = '1'"; + } + System.out.println("needUpSql="+needUpSql); + IRowSet needUpSet = DbUtil.executeQuery(ctx, needUpSql); + while(needUpSet.next()){ + String timestamp = System.currentTimeMillis()/1000+""; + System.out.println("时间戳为:"+timestamp); + String depId = "";//组织ID + String depName = "";//组织名称 + String depCode = "";//组织编码 + String parent_ID = "";//上级组织ID + String invalid = "0"; //部门状态 + depId = needUpSet.getString("id"); + depName = needUpSet.getString("NAME"); + depCode = needUpSet.getString("CODE"); + parent_ID = needUpSet.getString("PARENT_DEPT"); + //是否封存 这个逻辑需要判断 + String isSealUpSql = "SELECT FIsSealUp,FIsOUSealUp FROM T_ORG_Admin WHERE FNUMBER = '"+depCode+"'"; + IRowSet isSealUpSet = DbUtil.executeQuery(ctx, isSealUpSql); + while(isSealUpSet.next()){ + if("0".equals(isSealUpSet.getString("FIsSealUp") )&& "0".equals(isSealUpSet.getString("FIsOUSealUp"))){ + invalid = "1"; + } + } + JSONObject json = new JSONObject(); + json.put("depId",depId); + json.put("depName",depName); + json.put("depCode",depCode); + json.put("parent_ID",parent_ID); + json.put("invalid",invalid); + json.put("timestamp",timestamp); + CloseableHttpClient httpClient = null; + String resultStr = ""; + httpClient = HttpClients.createDefault(); + Map headMap = new HashMap(); + headMap.put("accept", "*/*"); + headMap.put("connection", "Keep-Alive"); + headMap.put("Content-Type", "application/json"); + System.out.println("组织同步请求参数为:"+json.toJSONString()); + System.out.println("组织同步请求头参数为:"+headMap.toString()); + String TEST_BASEURL = WebServiceConfig.getPropertiesValue(ctx, "rishengBaseUrl"); + //地址待确认 + String url = TEST_BASEURL+"/xxxxxx"; + resultStr = HttpRequestSecUtil.sendPost(url, json.toString(), headMap); + JSONObject res = JSONObject.parseObject(resultStr); + String code = res.getString("code"); + String message = res.getString("message"); + if("true".equals(message)){ + String updateSQL2 = "/*dialect*/ update t_org_admin Set CFToHKisNew = '0' where fid = '"+depId+"'"; + DbUtil.execute(ctx, updateSQL2); + }else{ + returnData.put("success", false); + returnData.put("message", message); + } + } + } catch (Exception e) { + e.printStackTrace(); + System.out.println(e.getMessage()); + returnData.put("success", false); + returnData.put("message", e.getMessage()); + } + + return returnData.toJSONString(); + } + /** + * 员工离职同步 + */ + @Override + public String syncEmpLeaves(Context ctx, String data) throws BOSException, EASBizException { + // TODO 自动生成的方法存根 + return super.syncEmpLeaves(ctx, data); + } + /** + * 员工离职恢复同步 + */ + @Override + public String syncEmpLeavesRestore(Context ctx, String data) throws BOSException, EASBizException { + // TODO 自动生成的方法存根 + return super.syncEmpLeavesRestore(ctx, data); + } + /** + * 人员同步 + */ + @Override + public String syncPerson(Context ctx, String data) throws BOSException, EASBizException { + // TODO 自动生成的方法存根 + return super.syncPerson(ctx, data); + } +} \ No newline at end of file diff --git a/src/com/kingdee/eas/custom/risheng/RishengHaiKangHRFacadeFactory.java b/src/com/kingdee/eas/custom/risheng/RishengHaiKangHRFacadeFactory.java new file mode 100644 index 0000000..c715013 --- /dev/null +++ b/src/com/kingdee/eas/custom/risheng/RishengHaiKangHRFacadeFactory.java @@ -0,0 +1,30 @@ +package com.kingdee.eas.custom.risheng; + +import com.kingdee.bos.BOSException; +import com.kingdee.bos.BOSObjectFactory; +import com.kingdee.bos.util.BOSObjectType; +import com.kingdee.bos.Context; + +public class RishengHaiKangHRFacadeFactory +{ + private RishengHaiKangHRFacadeFactory() + { + } + public static com.kingdee.eas.custom.risheng.IRishengHaiKangHRFacade getRemoteInstance() throws BOSException + { + return (com.kingdee.eas.custom.risheng.IRishengHaiKangHRFacade)BOSObjectFactory.createRemoteBOSObject(new BOSObjectType("FE79E785") ,com.kingdee.eas.custom.risheng.IRishengHaiKangHRFacade.class); + } + + public static com.kingdee.eas.custom.risheng.IRishengHaiKangHRFacade getRemoteInstanceWithObjectContext(Context objectCtx) throws BOSException + { + return (com.kingdee.eas.custom.risheng.IRishengHaiKangHRFacade)BOSObjectFactory.createRemoteBOSObjectWithObjectContext(new BOSObjectType("FE79E785") ,com.kingdee.eas.custom.risheng.IRishengHaiKangHRFacade.class, objectCtx); + } + public static com.kingdee.eas.custom.risheng.IRishengHaiKangHRFacade getLocalInstance(Context ctx) throws BOSException + { + return (com.kingdee.eas.custom.risheng.IRishengHaiKangHRFacade)BOSObjectFactory.createBOSObject(ctx, new BOSObjectType("FE79E785")); + } + public static com.kingdee.eas.custom.risheng.IRishengHaiKangHRFacade getLocalInstance(String sessionID) throws BOSException + { + return (com.kingdee.eas.custom.risheng.IRishengHaiKangHRFacade)BOSObjectFactory.createBOSObject(sessionID, new BOSObjectType("FE79E785")); + } +} \ No newline at end of file diff --git a/src/com/kingdee/eas/custom/risheng/RishengInterfaceFacade.java b/src/com/kingdee/eas/custom/risheng/RishengInterfaceFacade.java new file mode 100644 index 0000000..0d8545d --- /dev/null +++ b/src/com/kingdee/eas/custom/risheng/RishengInterfaceFacade.java @@ -0,0 +1,107 @@ +package com.kingdee.eas.custom.risheng; + +import com.kingdee.bos.framework.ejb.EJBRemoteException; +import com.kingdee.bos.util.BOSObjectType; +import java.rmi.RemoteException; +import com.kingdee.bos.framework.AbstractBizCtrl; +import com.kingdee.bos.orm.template.ORMObject; + +import com.kingdee.bos.BOSException; +import com.kingdee.bos.util.*; +import com.kingdee.eas.common.EASBizException; +import com.kingdee.eas.custom.risheng.*; +import java.lang.String; +import com.kingdee.bos.Context; +import com.kingdee.bos.framework.*; + +public class RishengInterfaceFacade extends AbstractBizCtrl implements IRishengInterfaceFacade +{ + public RishengInterfaceFacade() + { + super(); + registerInterface(IRishengInterfaceFacade.class, this); + } + public RishengInterfaceFacade(Context ctx) + { + super(ctx); + registerInterface(IRishengInterfaceFacade.class, this); + } + public BOSObjectType getType() + { + return new BOSObjectType("81647F35"); + } + private RishengInterfaceFacadeController getController() throws BOSException + { + return (RishengInterfaceFacadeController)getBizController(); + } + /** + *组织同步OA-User defined method + *@param data data + *@return + */ + public String syncAdminOrgInfo(String data) throws BOSException, EASBizException + { + try { + return getController().syncAdminOrgInfo(getContext(), data); + } + catch(RemoteException err) { + throw new EJBRemoteException(err); + } + } + /** + *人员同步到OA-User defined method + *@param data data + *@return + */ + public String syncEmployeeInfo(String data) throws BOSException, EASBizException + { + try { + return getController().syncEmployeeInfo(getContext(), data); + } + catch(RemoteException err) { + throw new EJBRemoteException(err); + } + } + /** + *同步岗位信息到OA-User defined method + *@param data data + *@return + */ + public String syncPositionInfo(String data) throws BOSException, EASBizException + { + try { + return getController().syncPositionInfo(getContext(), data); + } + catch(RemoteException err) { + throw new EJBRemoteException(err); + } + } + /** + *职级信息同步到OA-User defined method + *@param data data + *@return + */ + public String syncJoblevelInfo(String data) throws BOSException, EASBizException + { + try { + return getController().syncJoblevelInfo(getContext(), data); + } + catch(RemoteException err) { + throw new EJBRemoteException(err); + } + } + /** + *员工任职信息同步到OA-User defined method + *@param data data + *@return + */ + public String syncPersonPositionInfo(String data) throws BOSException, EASBizException + { + try { + return getController().syncPersonPositionInfo(getContext(), data); + } + catch(RemoteException err) { + throw new EJBRemoteException(err); + } + } +} \ No newline at end of file diff --git a/src/com/kingdee/eas/custom/risheng/RishengInterfaceFacadeController.java b/src/com/kingdee/eas/custom/risheng/RishengInterfaceFacadeController.java new file mode 100644 index 0000000..33fdf2d --- /dev/null +++ b/src/com/kingdee/eas/custom/risheng/RishengInterfaceFacadeController.java @@ -0,0 +1,26 @@ +package com.kingdee.eas.custom.risheng; + +import com.kingdee.bos.BOSException; +//import com.kingdee.bos.metadata.*; +import com.kingdee.bos.framework.*; +import com.kingdee.bos.util.*; +import com.kingdee.bos.Context; + +import com.kingdee.bos.BOSException; +import com.kingdee.bos.util.*; +import com.kingdee.eas.common.EASBizException; +import java.lang.String; +import com.kingdee.bos.Context; +import com.kingdee.bos.framework.*; + +import java.rmi.RemoteException; +import com.kingdee.bos.framework.ejb.BizController; + +public interface RishengInterfaceFacadeController extends BizController +{ + public String syncAdminOrgInfo(Context ctx, String data) throws BOSException, EASBizException, RemoteException; + public String syncEmployeeInfo(Context ctx, String data) throws BOSException, EASBizException, RemoteException; + public String syncPositionInfo(Context ctx, String data) throws BOSException, EASBizException, RemoteException; + public String syncJoblevelInfo(Context ctx, String data) throws BOSException, EASBizException, RemoteException; + public String syncPersonPositionInfo(Context ctx, String data) throws BOSException, EASBizException, RemoteException; +} \ No newline at end of file diff --git a/src/com/kingdee/eas/custom/risheng/RishengInterfaceFacadeControllerBean.java b/src/com/kingdee/eas/custom/risheng/RishengInterfaceFacadeControllerBean.java new file mode 100644 index 0000000..e669074 --- /dev/null +++ b/src/com/kingdee/eas/custom/risheng/RishengInterfaceFacadeControllerBean.java @@ -0,0 +1,894 @@ +package com.kingdee.eas.custom.risheng; + +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.log4j.Logger; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; + +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.aliyun.odps.utils.StringUtils; +import com.kingdee.bos.*; + +import java.io.StringReader; +import java.lang.String; + +import com.kingdee.eas.base.wssc.app.trd.webservice.WebServiceConfig; +import com.kingdee.eas.common.EASBizException; +import com.kingdee.eas.custom.risheng.util.HttpRequestSecUtil; +import com.kingdee.eas.util.app.DbUtil; +import com.kingdee.jdbc.rowset.IRowSet; + +public class RishengInterfaceFacadeControllerBean extends AbstractRishengInterfaceFacadeControllerBean +{ + private static Logger logger = + Logger.getLogger("com.kingdee.eas.custom.risheng.RishengInterfaceFacadeControllerBean"); + /** + * 组织同步到OA + */ + @Override + public String syncAdminOrgInfo(Context ctx, String data) throws BOSException, EASBizException { + logger.error("进入组织同步接口"); + + try { + Calendar beforeTime = Calendar.getInstance(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + beforeTime.add(Calendar.MINUTE, -5);// 5分钟之前的时间 + Date beforeD = beforeTime.getTime(); + String before5 = simpleDateFormat.format(beforeD); + String depSql = ""; + logger.error("传入参数为"+data.toString()); + if(!StringUtils.isEmpty(data)){ + //有参数,同步指定的组织信息 + depSql = "select a.flevel level,a.fid id,a.fname_l2 NAME,a.FNUMBER CODE,b.FNUMBER PARENT_CODE,a.fissealup sup,a.fisousealup ssup,a.freservefieldfirst isnew from t_org_admin a left join t_org_admin b on a.FPARENTID = b.fid where a.fnumber = '"+data+"'"; + }else { + //没有参数,同步需要同步的组织信息 + depSql = "SELECT a.flevel level,a.FID as id,a.FNAME_l2 AS NAME,a.FNUMBER AS CODE,c.Fnumber AS PARENT_CODE,a.fissealup sup,a.fisousealup ssup,a.freservefieldfirst isnew " + + "FROM t_org_admin a " + + "left join T_ORG_BASEUNIT b on a.fid = b.fid " + + "left join t_org_admin c on c.fid = a.FPARENTID " + + "where ( to_char(a.FLASTUPDATETIME ,'yyyy-MM-dd HH24:mi:ss') >= '"+before5+"' " + + "or to_char(b.FLASTUPDATETIME ,'yyyy-MM-dd HH24:mi:ss') >= '"+before5+"' )"; + } + //加上钉钉的不同步限制 + depSql = depSql +" and not exists (SELECT forgid FROM T_DD_NOSYNCORG dd where a.FID =dd.forgid) "; + logger.error("depSql="+depSql); + IRowSet needUpSet = DbUtil.executeQuery(ctx, depSql); + JSONArray resArr = new JSONArray(); + while(needUpSet.next()){ + String level = needUpSet.getString("level"); + int levelIntVal = Integer.parseInt(level); + //部门等级大于三级部门,才进行同步 + if( levelIntVal >= 3){ + Map checkMap = new HashMap(); + String timestamp = System.currentTimeMillis()/1000+""; + logger.error("时间戳为:"+timestamp); + String depId = "";//组织ID + String depName = "";//组织名称 + String depCode = "";//组织编码 + String parent_code = "0";//上级组织编码,默认0 + String invalid = "0"; //部门状态,默认是封存(禁用)状态 + String action = "add";//操作,默认新增add,编辑为 edit + String orgCode = "2"; //分部编码,固定日盛高新 + depId = needUpSet.getString("id"); + depName = needUpSet.getString("NAME"); + depCode = needUpSet.getString("CODE"); + if(!StringUtils.isEmpty(needUpSet.getString("PARENT_CODE"))) { + if(levelIntVal == 3){ + logger.error("三级部门,上级部门默认为0"); + }else { + parent_code = needUpSet.getString("PARENT_CODE"); + } + + } + if("0".equals(needUpSet.getString("sup") )&& "0".equals(needUpSet.getString("ssup"))){ + invalid = "1"; + } + if(!StringUtils.isEmpty(needUpSet.getString("isnew"))) { + action = "edit"; + } + checkMap.put("action", action); + checkMap.put("code", depCode); + checkMap.put("shortname", depName); + checkMap.put("fullname", depName); + checkMap.put("org_code", orgCode); + checkMap.put("parent_code", parent_code); + checkMap.put("canceled", invalid); + resArr.add(checkMap); + //调用接口 + String OA_HR_BASE = WebServiceConfig.getPropertiesValue(ctx, "rishengOAHrBaseUrl"); + String urlStr = OA_HR_BASE+"/services/HrmService"; + if(resArr.size()>0) { + SyncHRDataInterface syncHRDataInterface= SyncDataFacade.SyncDataFacade("fwoa"); + String returnStr = syncHRDataInterface.syncAdminOrg(resArr.toString(),urlStr); + logger.error("组织接口返回信息为"+returnStr); + if(!StringUtils.isEmpty(returnStr)) { + logger.error("开始解析接口返回结果"); + // 创建 DOM 解析器工厂 + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + // 创建 DOM 解析器 + DocumentBuilder builder = factory.newDocumentBuilder(); + //使用解析器生成Document实例 + Document document = builder.parse(new InputSource(new StringReader(returnStr))); + //获取result元素的节点列表 + NodeList result = document.getElementsByTagName("result"); + if(result.getLength()>0) { + Node valueNode = result.item(0); + String rrr = valueNode.getTextContent(); + logger.error("rrr: " + rrr); + } + //获取属性值 + Element root = document.getDocumentElement(); + NodeList result2 = root.getChildNodes(); + if(result2 != null) { + if(result2.getLength()>0) { + Node book=result2.item(0); + if(book.getNodeType()==Node.ELEMENT_NODE) { + String value3 = book.getAttributes().getNamedItem("value").getNodeValue(); + logger.error("value3:"+value3); + if("1".equals(value3)) { + String updateSQL2 = "/*dialect*/ update t_org_admin Set freservefieldfirst = '0' where fid = '"+depId+"'"; + DbUtil.execute(ctx, updateSQL2); + } + } + } + } + } + }else { + logger.error("没有组织变更数据!"); + } + } + + } + } catch (Exception e) { + e.printStackTrace(); + logger.error(e.getMessage()); + } + return null; + } + /** + * 人员同步到OA + */ + @Override + public String syncEmployeeInfo(Context ctx, String data) throws BOSException, EASBizException { + logger.error("进入员工信息同步接口"); + Calendar beforeTime = Calendar.getInstance(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + beforeTime.add(Calendar.MINUTE, -5);// 5分钟之前的时间 + Date beforeD = beforeTime.getTime(); + String before5 = simpleDateFormat.format(beforeD); + String needUpSql = ""; + Set set = new HashSet(); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + try { + if(!StringUtils.isEmpty(data)) { + needUpSql = " SELECT * FROM t_bd_person a where a.fnumber= '"+data+"' "; + }else { + //String personSql = "/*dialect*/ SELECT FNUMBER CODE FROM t_bd_person where FLASTUPDATETIME >= '"+before5+"'"; + String personSql = "/*dialect*/ SELECT FNUMBER CODE FROM t_bd_person";//20240314 改为全量同步 + + IRowSet personSet = DbUtil.executeQuery(ctx, personSql); + while(personSet.next()){ + String pNumber = personSet.getString("CODE"); + set.add(pNumber); + } + // logger.error("set==="+set.toString()); + for(String pNumber :set){ + String upSql = "/*dialect*/ update t_bd_person Set CfIsNeedToOA = '1' where fnumber = '"+pNumber+"'"; + DbUtil.execute(ctx,upSql); + } + //选择需要更新的,并且允许同步(unSync is null)的人员 + needUpSql = " SELECT * FROM t_bd_person a where a.CfIsNeedToOA = '1' "; + } + //加上钉钉的不同步限制 + needUpSql = needUpSql +" and not exists (SELECT fpersonid FROM T_DD_NOSYNCPERSON dd where dd.fpersonid =a.fid ) "; + + IRowSet needUpSet = DbUtil.executeQuery(ctx, needUpSql); + while(needUpSet.next()){ + JSONArray resArr = new JSONArray(); + Map checkMap = new HashMap(); + String action = "add";//操作,默认新增add,编辑为 edit + String pid = "";//ID + String lastname = "";//姓名 + String workcode = "";//人员编码,唯一值 hr人员编码 + String loginid= "";//登录名 hr人员编码 + String password = "123456";//密码 默认:123456 + String subcompany = "日盛高新";// 固定“日盛高新” + String department = "";//部门名称 + String sex = "";//性别(男、女) + String mobile= "";//移动电话 + String email= "";//邮箱 + String birthday = "";//出生日期(文本) + String certificatenum= "";//身份证号码 + String jobtitle = "";//岗位名称(文本) + String jobactivityid = "ERP职务类型";//职务名称(文本) 固定 + String jobgroupid = "ERP职务类型";//职务类别名称(文本) 固定 + String jobcell = "";//职称 确定HR是否有,不是必传 + String joblevel = "1";//(数字) + String jobactivitydesc = "";//职责描述 + String status = "正式";//状态:(正式-1 正式员工、临时-2 试用员工、试用延期-3、解聘-4 解聘、离职-5、退休-6 退休、无效-7、删除-10) 确认hr会使用到哪些用工关系状态 + String folk= "";//民族(文本) 无值,默认无 + String nativeplace= "";//籍贯(文本) 默认无 + String regresidentplace= "";//户口 默认无 + String maritalstatus= "";//婚姻状况 默认无 + String policy= "";//政治面貌 默认无 + String educationlevel= "";//学历 默认无 + String degree= "";//学位 默认无 + String managerid = "";//直接上级(编号) 上级职位对应的人员编码,默认无 + String assistantid= "";//助理(编号) + String locationid = "";//办公室名称(文本) + String workroom = "";//办公地点名称(文本) 新厂,老厂 + String telephone= "";//办公电话 + String mobilecall = "";//其他电话 + String fax = "";//传真 + String systemlanguage = "简体中文";//系统语言(简体中文:7 繁体中文:9 English:8 ) 默认简体中文 + String bememberdate= "";//入团日期(文本) + String bepartydate= "";//入党日期(文本) + String islabouunion= "";//工会会员(1:是0:否) + String healthinfo= "";//健康状况 + String height= "";//身高(文本) + String weight= "";//体重(文本) + String residentplace= "";//现居住地 + String homeaddress= "";//家庭联系方式 + String tempresidentnumber= "";//暂住证号码 + String seclevel = "";//安全级别(数字) 考虑在人员入职单新增“安全级别”,10 车间普通;20 行政普通; 60 部长;70 高管;80 总经理; + String jobcall = "";//职称(文本) 确定HR是否有? + + + pid = needUpSet.getString("fid"); + workcode = needUpSet.getString("fnumber"); + lastname = needUpSet.getString("fname_l2"); + checkMap.put("workcode", workcode); + checkMap.put("subcompany", subcompany); + //所在部门 + String depCode = ""; + String persondepSQL = "SELECT b.FNAME_l2 depName,b.fnumber depCode,b.FLEVEL level FROM t_hr_personposition a left join t_org_admin b on b.fid = a.fpersondep where a.FPERSONID = '"+pid+"'"; + IRowSet personDepRows = DbUtil.executeQuery(ctx, persondepSQL); + while(personDepRows.next()){ + depCode = personDepRows.getString("depCode"); + String depLevel = personDepRows.getString("level"); + int depLevelIntVal = Integer.parseInt(depLevel); + if(depLevelIntVal == 1 || depLevelIntVal == 2 || depLevelIntVal == 3) { + department = personDepRows.getString("depName"); + }else if(depLevelIntVal == 4){ + //如果是四级部门,则找出上级部门 + String depName = personDepRows.getString("depName"); + String pDepSQL = "SELECT b.FNAME_l2 pDepName FROM t_org_admin a left join t_org_admin b on b.fid = a.FPARENTID where a.fnumber = '"+depCode+"'"; + IRowSet pDepRows = DbUtil.executeQuery(ctx, pDepSQL); + while(pDepRows.next()){ + String pDepName = pDepRows.getString("pDepName"); + department = pDepName+">"+depName; + } + }else if(depLevelIntVal == 5) { + //如果是五级部门,继续向上查找,只查到6级部门,此处暂时不重新写方法 + String depName = personDepRows.getString("depName"); + String pDepSQL = "SELECT b.FNAME_l2 pDepName,c.FNAME_l2 ppDepName " + + "FROM t_org_admin a " + + "left join t_org_admin b on b.fid = a.FPARENTID " + + "left join t_org_admin c on c.fid = b.FPARENTID " + + "where a.fnumber = '"+depCode+"'"; + IRowSet pDepRows = DbUtil.executeQuery(ctx, pDepSQL); + while(pDepRows.next()){ + String pDepName = pDepRows.getString("pDepName"); + String ppDepName = pDepRows.getString("ppDepName"); + department = ppDepName+">"+pDepName+">"+depName; + } + }else if(depLevelIntVal == 6) { + //如果是五级部门,继续向上查找,只查到6级部门,此处暂时不重新写方法 + String depName = personDepRows.getString("depName"); + String pDepSQL = "SELECT b.FNAME_l2 pDepName,c.FNAME_l2 ppDepName,d.FNAME_l2 pppDepName " + + "FROM t_org_admin a " + + "left join t_org_admin b on b.fid = a.FPARENTID " + + "left join t_org_admin c on c.fid = b.FPARENTID " + + "left join t_org_admin d on d.fid = c.FPARENTID " + + "where a.fnumber = '"+depCode+"'"; + IRowSet pDepRows = DbUtil.executeQuery(ctx, pDepSQL); + while(pDepRows.next()){ + String pDepName = pDepRows.getString("pDepName"); + String ppDepName = pDepRows.getString("ppDepName"); + String pppDepName = pDepRows.getString("pppDepName"); + department = pppDepName+">"+ppDepName+">"+pDepName+">"+depName; + } + } + + } + checkMap.put("department", department); + checkMap.put("lastname", lastname); + checkMap.put("loginid", workcode); + + //安全级别(数字) 考虑在人员入职单新增“安全级别”,10 车间普通;20 行政普通; 60 部长;70 高管;80 总经理; + seclevel = needUpSet.getString("fidcardissueorg"); + checkMap.put("seclevel", seclevel); + + String gender = needUpSet.getString("FGENDER"); + if("1".equals(gender)){ + sex = "男"; + }else if("2".equals(gender)){ + sex = "女"; + } + checkMap.put("sex", sex); + //职务和职务类型 文档上标注固定,这个后期需要确认,先传固定值 + String personPosSQL = "SELECT b.fname_l2 gwName,b.fparentid leader ,c.FNAME_l2 zwName,d.FNAME_l2 zwType,b.FPURPOSE purpose " + + "FROM t_hr_personposition a " + + "left join T_ORG_POSITION b on b.fid = a.fprimarypositionid " + + "left join T_ORG_JOB c on c.fid = b.fjobid " + + "left join T_ORG_JOBCATEGORY d on d.fid = c.fjobcategoryid " + + "where a.FPERSONID = '"+pid+"'"; + IRowSet personPosRows = DbUtil.executeQuery(ctx, personPosSQL); + String leaderId=""; + while(personPosRows.next()){ + if(!StringUtils.isEmpty(personPosRows.getString("zwName"))) { + jobactivityid = personPosRows.getString("zwName"); + } +// if(!StringUtils.isEmpty(personPosRows.getString("zwType"))) { +// jobgroupid = personPosRows.getString("zwType"); +// } + if(!StringUtils.isEmpty(personPosRows.getString("purpose"))) { + jobactivitydesc = personPosRows.getString("purpose"); + } + leaderId =personPosRows.getString("leader"); + jobtitle = personPosRows.getString("gwName"); + } + //岗位名称 + checkMap.put("jobtitle", jobtitle); + //职务名称固定 ERP职务类型,职务类别固定 ERP职务类型 这个需要联调确定 ???????? + checkMap.put("jobactivityid", jobactivityid); + + checkMap.put("jobgroupid", jobgroupid); + //jobcell 职称(文本),确定HR是否有,不是必传 + + //joblevel 传什么,当前默认为1 ??? + checkMap.put("joblevel", joblevel); + checkMap.put("jobactivitydesc", jobactivitydesc); + //直接上级(编号) 上级职位对应的人员编码 String managerid = ""; + //先找负责人职位ID + /* String depAdmPosID2 = ""; + String depPosSQL = "SELECT a.fid pid,a.FPARENTID,b.fnumber FROM t_org_position a " + + "left join T_ORG_BaseUnit b on b.fid = a.FAdminOrgUnitID " + + "where b.fnumber = '"+depCode+"' and a.FIsRespPosition = 1 "; + IRowSet depPosRows = DbUtil.executeQuery(ctx, depPosSQL); + if(depPosRows.next()) { + depAdmPosID2 = depPosRows.getString("pid"); + } + //再根据部门负责人职位 在personPostion找负责人 如果查不到,就要到兼职表中查询 + String depAdmNumSql = "SELECT a.FPERSONID,a.FPERSONDEP,a.FPRIMARYPOSITIONID,b.FNUMBER bNum " + + "FROM t_hr_personposition a " + + "left join t_bd_person b on b.fid = a.FPERSONID " + + "where a.FPrimaryPositionID = '"+depAdmPosID2+"'"; + logger.error("depAdmNumSql=="+depAdmNumSql); + IRowSet depAdmNum_Set = DbUtil.executeQuery(ctx, depAdmNumSql); + String businessLeaderID = ""; + if(depAdmNum_Set.size()>0){ + //说明有部门负责人 联合查询查到该人编码 + depAdmNum_Set.previous(); + while(depAdmNum_Set.next()){ + if(!StringUtils.isEmpty(depAdmNum_Set.getString("bNum"))) { + managerid = depAdmNum_Set.getString("bNum"); + } + } + }else{ + //该部门没有负责人,根据事业部负责人职位ID去兼职任命分录查找 T_HR_PluralityAddBizBillEntry + String leaderSql = "SELECT a.FPOSITIONID ,a.FPERSONID ,b.FNUMBER as code " + + "FROM T_HR_PluralityAddBizBillentry a left join t_bd_person b on a.FPERSONID = b.fid " + + "where a.FPOSITIONID = '"+depAdmPosID2+"'"; + logger.error("leaderSql=="+leaderSql); + IRowSet jianzhiSet = DbUtil.executeQuery(ctx, leaderSql); + while(jianzhiSet.next()){ + if(!StringUtils.isEmpty(jianzhiSet.getString("code"))) { + managerid = jianzhiSet.getString("code"); + } + } + }*/ + //20240312 wujiang 上级字段取职位上级 不取部门负责人 + if(!StringUtils.isEmpty(leaderId)){ + String leadSql ="SELECT b.FNAME_L2,b.FNUMBER FROM T_HR_PERSONPOSITION a LEFT OUTER JOIN T_BD_PERSON b ON A.FPERSONID = B.FID where a.FPRIMARYPOSITIONID ='"+leaderId+"'"; + IRowSet rs1 = DbUtil.executeQuery(ctx, leadSql); + while(rs1.next()){ + managerid = rs1.getString("FNUMBER"); + } + if(StringUtils.isEmpty(managerid)){ + // 该部门没有负责人,根据事业部负责人职位ID去兼职任命分录查找 T_HR_PluralityAddBizBillEntry + String leaderSql = "SELECT a.FPOSITIONID ,a.FPERSONID ,b.FNUMBER as code " + + "FROM T_HR_PluralityAddBizBillentry a left join t_bd_person b on a.FPERSONID = b.fid " + + "where a.FPOSITIONID = '"+leaderId+"'"; + // logger.error("leaderSql=="+leaderSql); + IRowSet jianzhiSet = DbUtil.executeQuery(ctx, leaderSql); + while(jianzhiSet.next()){ + if(!StringUtils.isEmpty(jianzhiSet.getString("code"))) { + managerid = jianzhiSet.getString("code"); + } + } + } + } + //------------------- 20240312------------------------ + + + checkMap.put("managerid", managerid); + //助理 默认传无 + checkMap.put("assistantid", assistantid); + checkMap.put("status", status); + if(!StringUtils.isEmpty(needUpSet.getString("fncell"))) { + mobile = needUpSet.getString("fncell"); + } + if(!StringUtils.isEmpty(needUpSet.getString("femail"))) { + email = needUpSet.getString("femail"); + } + if(needUpSet.getDate("fbirthday") != null) { + Date birthdayD = needUpSet.getDate("fbirthday"); + birthday = dateFormat.format(birthdayD); + } + if(!StringUtils.isEmpty(needUpSet.getString("fidcardno"))) { + certificatenum = needUpSet.getString("fidcardno"); + } + + checkMap.put("mobile", mobile); + checkMap.put("email", email); + checkMap.put("birthday", birthday); + checkMap.put("certificatenum", certificatenum); + + //民族 、籍贯、户口 + String ccKKsql = "SELECT b.FNAME_l2 mzName,a.fnativeplace_l2 jgName,c.FNAME_l2 hklx,a.fhjaddress hkAddress " + + "FROM t_bd_person a " + + "left join T_BD_HRFOLK b ON A.FFOLKID = B.FID " + + "left join T_BD_REGPERMRESIDENCE c ON A.FREGRESIDENCEID = C.FID " + + "where a.fid = '"+pid+"' "; + IRowSet ccKKRows = DbUtil.executeQuery(ctx, ccKKsql); + while(ccKKRows.next()) { + if(!StringUtils.isEmpty(ccKKRows.getString("mzName"))) { + folk = ccKKRows.getString("mzName"); + } + if(!StringUtils.isEmpty(ccKKRows.getString("jgName"))) { + nativeplace = ccKKRows.getString("jgName"); + regresidentplace = ccKKRows.getString("jgName"); + } + } + checkMap.put("folk", folk); + checkMap.put("nativeplace", nativeplace); + checkMap.put("regresidentplace", regresidentplace); + //婚姻状况,政治面貌 + String zzSQL = "SELECT b.FNAME_l2 zzmm,c.FNAME_l2 hyzk " + + "FROM t_bd_person a " + + "left join T_BD_HRPOLITICAL b on b.fid = a.fpoliticalfaceid " + + "left join T_BD_HRWED c on c.fid = a.fwedid " + + "where a.fid = '"+pid+"'"; + IRowSet zzRows = DbUtil.executeQuery(ctx, zzSQL); + while(zzRows.next()){ + if(!StringUtils.isEmpty(zzRows.getString("zzmm"))) { + policy = zzRows.getString("zzmm"); + } + if(!StringUtils.isEmpty(zzRows.getString("hyzk"))) { + maritalstatus = zzRows.getString("hyzk"); + } + } + checkMap.put("policy", policy); + checkMap.put("maritalstatus", maritalstatus); + //学历、学位 + String degSQL = "SELECT b.FNAME_l2 xlName,c.FNAME_l2 xwName " + + "FROM t_bd_person a " + + "left join T_BD_HRDIPLOMA b on b.fid = a.fhighestdegreeid " + + "left join T_BD_HRDEGREE c on c.fid = a.fhighestsubdegreeid " + + "where a.fid = '"+pid+"'"; + IRowSet degRows = DbUtil.executeQuery(ctx, degSQL); + while(degRows.next()){ + if(!StringUtils.isEmpty(degRows.getString("xlName"))) { + educationlevel = degRows.getString("xlName"); + } + if(!StringUtils.isEmpty(degRows.getString("xwName"))) { + degree = degRows.getString("xwName"); + } + } + checkMap.put("educationlevel", educationlevel); + checkMap.put("degree", degree); + + + // 助理,办公室名称,办公地点,办公电话,其他电话,传真 默认无,有值再传 s + + + //判断部门编码,去赋值新厂,旧厂 + if("3".equals(depCode) || "5".equals(depCode) ||"6".equals(depCode) ||"8".equals(depCode) ||"24".equals(depCode)){ + locationid = "老厂"; + }else { + locationid = "新厂"; + } + checkMap.put("locationid", locationid); + checkMap.put("workroom", workroom); + checkMap.put("telephone", telephone); + checkMap.put("mobilecall", mobilecall); + checkMap.put("fax", fax); + //系统语言(简体中文:7 繁体中文:9 English:8 ) 默认简体中文 + checkMap.put("systemlanguage", systemlanguage); + //入团日期、入党日期暂定无 工会会员默认否 后期有取值再定 + checkMap.put("bememberdate", bememberdate); + checkMap.put("bepartydate", bepartydate); + checkMap.put("islabouunion", islabouunion); + //身高体重健康状态默认无,赞助证号码默认无 + checkMap.put("healthinfo", healthinfo); + checkMap.put("height", height); + checkMap.put("weight", weight); + checkMap.put("homeaddress", homeaddress); + checkMap.put("tempresidentnumber", tempresidentnumber); + //现居住地址 取通信地址 + if(!StringUtils.isEmpty(needUpSet.getString("faddress_l2"))) { + residentplace = needUpSet.getString("faddress_l2"); + } + checkMap.put("residentplace", residentplace); + + //职称(文本) 确定HR是否有? 后期有值再修改 + + checkMap.put("jobcall", jobcall); + //action + if(!StringUtils.isEmpty(needUpSet.getString("CFisnew"))) { + action = "edit"; + }else{ + checkMap.put("password", password);//说明是新增 得给密码 + } + checkMap.put("action", action); + resArr.add(checkMap); + //调用接口 + String OA_HR_BASE = WebServiceConfig.getPropertiesValue(ctx, "rishengOAHrBaseUrl"); + String urlStr = OA_HR_BASE+"/services/HrmService"; + if(resArr.size()>0) { + SyncHRDataInterface syncHRDataInterface=SyncDataFacade.SyncDataFacade("fwoa"); + String returnStr = syncHRDataInterface.syncPerson(resArr.toString(),urlStr); + logger.error("人员接口返回信息为"+returnStr); + if(!StringUtils.isEmpty(returnStr)) { + // logger.error("开始解析接口返回结果"); + // 创建 DOM 解析器工厂 + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + // 创建 DOM 解析器 + DocumentBuilder builder = factory.newDocumentBuilder(); + //使用解析器生成Document实例 + Document document = builder.parse(new InputSource(new StringReader(returnStr))); + //获取result元素的节点列表 + NodeList result = document.getElementsByTagName("result"); + if(result.getLength()>0) { + Node valueNode = result.item(0); + String rrr = valueNode.getTextContent(); + // logger.error("rrr: " + rrr); + } + //获取属性值 + Element root = document.getDocumentElement(); + NodeList result2 = root.getChildNodes(); + if(result2 != null) { + if(result2.getLength()>0) { + Node book=result2.item(0); + if(book.getNodeType()==Node.ELEMENT_NODE) { + String value3 = book.getAttributes().getNamedItem("value").getNodeValue(); + logger.error("value3:"+value3); + if("1".equals(value3)) { + String updateSQL2 = "/*dialect*/ update t_bd_person Set CFisNew = '0',CfIsNeedToOA = '0' where fid = '"+pid+"'"; + DbUtil.execute(ctx, updateSQL2); + } + } + } + } + } + }else { + logger.error("没有人员变更数据!"); + } + } + } catch (Exception e) { + e.printStackTrace(); + logger.error(e.getMessage()); + } + return null; + } + /** + * 职级同步到OA + */ + @Override + public String syncJoblevelInfo(Context ctx, String data) throws BOSException, EASBizException { + logger.error("进入职级信息同步接口"); + Calendar beforeTime = Calendar.getInstance(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + beforeTime.add(Calendar.MINUTE, -5);// 5分钟之前的时间 + Date beforeD = beforeTime.getTime(); + String before5 = simpleDateFormat.format(beforeD); + Set set = new HashSet(); + String needUpSql = ""; + try { + if(!StringUtils.isEmpty(data)) { + needUpSql = "/*dialect*/ SELECT * FROM T_HR_JOBLEVEL where fnumber= '"+data+"' "; + }else { + String personSql = "/*dialect*/ SELECT FNUMBER CODE FROM T_HR_JOBLEVEL where FLASTUPDATETIME >= '"+before5+"'"; + IRowSet personSet = DbUtil.executeQuery(ctx, personSql); + while(personSet.next()){ + String pNumber = personSet.getString("CODE"); + set.add(pNumber); + } + logger.error("set==="+set.toString()); + for(String pNumber :set){ + String upSql = "/*dialect*/ update T_HR_JOBLEVEL Set CfIsNeedToOA = '1' where fnumber = '"+pNumber+"'"; + DbUtil.execute(ctx,upSql); + } + //选择需要更新的,并且允许同步(unSync is null)的人员 + needUpSql = "/*dialect*/ SELECT * FROM T_HR_JOBLEVEL where CfIsNeedToOA = '1'"; + } + IRowSet needUpSet = DbUtil.executeQuery(ctx, needUpSql); + while(needUpSet.next()){ + String timestamp = System.currentTimeMillis()/1000+""; + String name = needUpSet.getString("pname"); + String number = needUpSet.getString("CODE"); + String pid = needUpSet.getString("id"); + JSONObject json = new JSONObject(); + json.put("name",name); + json.put("number",number); + json.put("timestamp",timestamp); + CloseableHttpClient httpClient = null; + String resultStr = ""; + httpClient = HttpClients.createDefault(); + Map headMap = new HashMap(); + headMap.put("accept", "*/*"); + headMap.put("connection", "Keep-Alive"); + headMap.put("Content-Type", "application/json"); + logger.error("职级同步请求参数为:"+json.toJSONString()); + logger.error("职级同步请求头参数为:"+headMap.toString()); + String TEST_BASEURL = WebServiceConfig.getPropertiesValue(ctx, "rishengBaseUrl"); + //地址待确认 + String url = TEST_BASEURL+"/xxxxxx"; + resultStr = HttpRequestSecUtil.sendPost(url, json.toString(), headMap); + JSONObject res = JSONObject.parseObject(resultStr); + String code = res.getString("code"); + String message = res.getString("message"); + if("true".equals(message)){ + String updateSQL2 = "/*dialect*/ update T_HR_JOBLEVEL Set CFisNew = '0' where fid = '"+pid+"'"; + DbUtil.execute(ctx, updateSQL2); + } + } + } catch (Exception e) { + e.printStackTrace(); + logger.error(e.getMessage()); + } + return null; + } + /** + * 员工任职信息同步到OA + */ + @Override + public String syncPersonPositionInfo(Context ctx, String data) throws BOSException, EASBizException { + logger.error("进入员工任职信息同步接口"); + Calendar beforeTime = Calendar.getInstance(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + beforeTime.add(Calendar.MINUTE, -5);// 5分钟之前的时间 + Date beforeD = beforeTime.getTime(); + String before5 = simpleDateFormat.format(beforeD); + try { + Set set = new HashSet(); + String personSql = "/*dialect*/ SELECT FNUMBER pnumber FROM t_bd_person where FLASTUPDATETIME >= '"+before5+"'"; + String personPositionSql = "/*dialect*/ SELECT b.FNUMBER pnumber FROM T_HR_PersonPosition a LEFT OUTER JOIN t_bd_person b ON a.FPERSONID = b.FID where a.FLASTUPDATETIME >= '"+before5+"'"; + String jzSql = "/*dialect*/ SELECT b.FNUMBER pnumber FROM T_HR_PluralityAddBizBillentry a LEFT OUTER JOIN t_bd_person b ON a.FPERSONID = b.FID where a.FLASTUPDATETIME >= '"+before5+"'"; + IRowSet personSet = DbUtil.executeQuery(ctx, personSql); + while(personSet.next()){ + String pNumber = personSet.getString("pnumber"); + set.add(pNumber); + } + IRowSet personPositionSet = DbUtil.executeQuery(ctx, personPositionSql); + while(personPositionSet.next()){ + String pNumber = personPositionSet.getString("pnumber"); + set.add(pNumber); + } + + IRowSet jzSet = DbUtil.executeQuery(ctx, jzSql); + while(jzSet.next()){ + String pNumber = jzSet.getString("pnumber"); + set.add(pNumber); + } + logger.error("set==="+set.toString()); + for(String pNumber :set){ + String upSql = "/*dialect*/ update t_bd_person Set CFrzIsNew = '1' where fnumber = '"+pNumber+"'"; + DbUtil.execute(ctx,upSql); + } + //选择需要更新的人员 + String needUpSql = "/*dialect*/ SELECT fid id,FNAME_l2 pname,FNUMBER CODE,FDeletedStatus status FROM t_bd_person where CFrzIsNew = '1' "; + IRowSet needUpSet = DbUtil.executeQuery(ctx, needUpSql); + while(needUpSet.next()){ + String timestamp = System.currentTimeMillis()/1000+""; + String name = needUpSet.getString("pname"); + String number = needUpSet.getString("CODE"); + String pid = needUpSet.getString("id"); + String status = needUpSet.getString("status"); //作废状态 1 普通,2作废 + if("1".equals(status)){ + status = "普通"; + }else if("2".equals(status)){ + status = "作废"; + } + JSONObject json = new JSONObject(); + json.put("name",name); + json.put("number",number); + json.put("timestamp",timestamp); + //部门、任职、职级 + String depName = ""; + String posName = ""; + String levelName = ""; + StringBuffer positionQueryBuffer = new StringBuffer("/*dialect*/ SELECT "); + positionQueryBuffer.append(" a.FPERSONID,c.FNAME_l2 depName,b.FNAME_l2 levelName,d.FNAME_l2 posName "); + positionQueryBuffer.append(" FROM t_hr_personposition a "); + positionQueryBuffer.append(" left join T_HR_JOBLEVEL b on b.fid = a.FJobLevelID "); + positionQueryBuffer.append(" left join T_ORG_BASEUNIT c on c.fid = a.FPersonDep "); + positionQueryBuffer.append(" left join T_ORG_POSITION d on d.fid = a.FPrimaryPositionID "); + positionQueryBuffer.append(" where a.FPERSONID = '"+pid+"'"); + IRowSet queryPosRows = DbUtil.executeQuery(ctx, positionQueryBuffer.toString()); + while(queryPosRows.next()){ + depName = queryPosRows.getString("depName"); + posName = queryPosRows.getString("posName"); + levelName = queryPosRows.getString("levelName"); + } + json.put("depName",depName); + json.put("posName",posName); + json.put("levelName",levelName); + //兼职部门、兼职岗位 + String jzAdminOrgname = ""; + String jzPosName = ""; + JSONArray jzList = new JSONArray(); + StringBuffer jzQueryBuffer = new StringBuffer("/*dialect*/ SELECT "); + jzQueryBuffer.append(" b.FNAME_l2 jzAdminOrgName,c.FNAME_l2 jzPosName "); + jzQueryBuffer.append(" FROM T_HR_PluralityAddBizBillentry a "); + jzQueryBuffer.append(" left join T_ORG_BASEUNIT b on b.fid = a.FAdminOrgID "); + jzQueryBuffer.append(" left join T_ORG_POSITION c on c.fid = a.FPositionID "); + jzQueryBuffer.append(" where a.FPERSONID = '"+pid+"'"); + IRowSet queryJzRows = DbUtil.executeQuery(ctx, jzQueryBuffer.toString()); + while(queryJzRows.next()){ + JSONObject jzObj = new JSONObject(); + jzObj.put("jzAdminOrgname", queryJzRows.getString("jzAdminOrgName")); + jzObj.put("jzPosName", queryJzRows.getString("jzPosName")); + jzList.add(jzObj); + } + json.put("jzList",jzList); + CloseableHttpClient httpClient = null; + String resultStr = ""; + httpClient = HttpClients.createDefault(); + Map headMap = new HashMap(); + headMap.put("accept", "*/*"); + headMap.put("connection", "Keep-Alive"); + headMap.put("Content-Type", "application/json"); + logger.error("任职信息同步请求参数为:"+json.toJSONString()); + logger.error("任职信息同步请求头参数为:"+headMap.toString()); + String TEST_BASEURL = WebServiceConfig.getPropertiesValue(ctx, "rishengBaseUrl"); + //地址待确认 + String url = TEST_BASEURL+"/xxxxxx"; + resultStr = HttpRequestSecUtil.sendPost(url, json.toString(), headMap); + JSONObject res = JSONObject.parseObject(resultStr); + String code = res.getString("code"); + String message = res.getString("message"); + if("true".equals(message)){ + String updateSQL2 = "/*dialect*/ update t_bd_person Set CFrzIsNew = '0' where fid = '"+pid+"'"; + DbUtil.execute(ctx, updateSQL2); + } + } + } catch (Exception e) { + e.printStackTrace(); + logger.error(e.getMessage()); + } + return null; + } + /** + * 岗位信息到OA + */ + @Override + public String syncPositionInfo(Context ctx, String data) throws BOSException, EASBizException { + logger.error("进入岗位信息同步接口"); + Calendar beforeTime = Calendar.getInstance(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + beforeTime.add(Calendar.MINUTE, -5);// 5分钟之前的时间 + Date beforeD = beforeTime.getTime(); + String before5 = simpleDateFormat.format(beforeD); + String needUpSql = ""; + Set set = new HashSet(); + try { + if(!StringUtils.isEmpty(data)) { + needUpSql = "/*dialect*/ SELECT * FROM T_ORG_Position where fnumber= '"+data+"' "; + }else { + String personSql = "/*dialect*/ SELECT FNUMBER CODE FROM T_ORG_Position where FLASTUPDATETIME >= '"+before5+"'"; + IRowSet personSet = DbUtil.executeQuery(ctx, personSql); + while(personSet.next()){ + String pNumber = personSet.getString("CODE"); + set.add(pNumber); + } + logger.error("set==="+set.toString()); + for(String pNumber :set){ + String upSql = "/*dialect*/ update T_ORG_Position Set CfIsNeedToOA = '1' where fnumber = '"+pNumber+"'"; + DbUtil.execute(ctx,upSql); + } + //选择需要更新的,并且允许同步(unSync is null)的职位 + needUpSql = "/*dialect*/ SELECT * FROM T_ORG_Position where CfIsNeedToOA = '1'"; + } + IRowSet needUpSet = DbUtil.executeQuery(ctx, needUpSql); + JSONArray resArr = new JSONArray(); + while(needUpSet.next()){ + String posCode = needUpSet.getString("FNUMBER"); + //如果是高管职位,不进行同步,设置是否同步到OA为0 + if("0001".equals(posCode) || "0002".equals(posCode)|| "0003".equals(posCode)|| "0004".equals(posCode) + || "0005".equals(posCode)|| "0006".equals(posCode)|| "0007".equals(posCode)|| "0008".equals(posCode) + || "0009".equals(posCode)|| "0010".equals(posCode)|| "0011".equals(posCode)|| "0505".equals(posCode)){ + String updSql = "/*dialect*/ update T_ORG_Position Set CfIsNeedToOA = '0' where fnumber = '"+posCode+"'"; + DbUtil.execute(ctx,updSql); + }else { + Map checkMap = new HashMap(); + String action ="add";//动作,add:添加,edit:编辑,delete:删除 + String jobtitlecode="";//岗位编码,唯一值 名称 + String jobtitlename="";//岗位简称 名称 + String jobtitleremark="";//岗位全称 名称 + String jobtitledept="";//岗位所属部门编码 为空 + String jobgroupid="505";//职务编码 OA建一个统一职务 ERP职务类型 + if(!StringUtils.isEmpty(needUpSet.getString("CFisnew"))) { + action = "edit"; + } + checkMap.put("action", action); + jobtitlecode = needUpSet.getString("fname_l2"); + jobtitlename = needUpSet.getString("fname_l2"); + jobtitleremark = needUpSet.getString("fname_l2"); + checkMap.put("jobtitlecode", jobtitlecode); + checkMap.put("jobtitlename", jobtitlename); + checkMap.put("jobtitleremark", jobtitleremark); + checkMap.put("jobtitledept", jobtitledept); + //待确认 传不传 + checkMap.put("jobgroupid", jobgroupid); + resArr.add(checkMap); + //调用接口 + String OA_HR_BASE = WebServiceConfig.getPropertiesValue(ctx, "rishengOAHrBaseUrl"); + String urlStr = OA_HR_BASE+"/services/HrmService"; + if(resArr.size()>0) { + SyncHRDataInterface syncHRDataInterface=SyncDataFacade.SyncDataFacade("fwoa"); + String returnStr = syncHRDataInterface.syncPosition(resArr.toString(),urlStr); + if(!StringUtils.isEmpty(returnStr)) { + logger.error("开始解析接口返回结果"); + // 创建 DOM 解析器工厂 + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + // 创建 DOM 解析器 + DocumentBuilder builder = factory.newDocumentBuilder(); + //使用解析器生成Document实例 + Document document = builder.parse(new InputSource(new StringReader(returnStr))); + //获取result元素的节点列表 + NodeList result = document.getElementsByTagName("result"); + if(result.getLength()>0) { + Node valueNode = result.item(0); + String rrr = valueNode.getTextContent(); + logger.error("rrr: " + rrr); + } + //获取属性值 + Element root = document.getDocumentElement(); + NodeList result2 = root.getChildNodes(); + if(result2 != null) { + if(result2.getLength()>0) { + Node book=result2.item(0); + if(book.getNodeType()==Node.ELEMENT_NODE) { + String value3 = book.getAttributes().getNamedItem("value").getNodeValue(); + logger.error("value3:"+value3); + if("1".equals(value3)) { + String updateSQL2 = "/*dialect*/ update T_ORG_Position Set CFisNew = '0',CfIsNeedToOA = '0' where fnumber = '"+posCode+"'"; + DbUtil.execute(ctx, updateSQL2); + } + } + } + + } + } + }else { + logger.error("没有职位变更数据!"); + } + + } + } + } catch (Exception e) { + e.printStackTrace(); + logger.error(e.getMessage()); + } + return null; + } + +} \ No newline at end of file diff --git a/src/com/kingdee/eas/custom/risheng/RishengInterfaceFacadeFactory.java b/src/com/kingdee/eas/custom/risheng/RishengInterfaceFacadeFactory.java new file mode 100644 index 0000000..7ab49df --- /dev/null +++ b/src/com/kingdee/eas/custom/risheng/RishengInterfaceFacadeFactory.java @@ -0,0 +1,30 @@ +package com.kingdee.eas.custom.risheng; + +import com.kingdee.bos.BOSException; +import com.kingdee.bos.BOSObjectFactory; +import com.kingdee.bos.util.BOSObjectType; +import com.kingdee.bos.Context; + +public class RishengInterfaceFacadeFactory +{ + private RishengInterfaceFacadeFactory() + { + } + public static com.kingdee.eas.custom.risheng.IRishengInterfaceFacade getRemoteInstance() throws BOSException + { + return (com.kingdee.eas.custom.risheng.IRishengInterfaceFacade)BOSObjectFactory.createRemoteBOSObject(new BOSObjectType("81647F35") ,com.kingdee.eas.custom.risheng.IRishengInterfaceFacade.class); + } + + public static com.kingdee.eas.custom.risheng.IRishengInterfaceFacade getRemoteInstanceWithObjectContext(Context objectCtx) throws BOSException + { + return (com.kingdee.eas.custom.risheng.IRishengInterfaceFacade)BOSObjectFactory.createRemoteBOSObjectWithObjectContext(new BOSObjectType("81647F35") ,com.kingdee.eas.custom.risheng.IRishengInterfaceFacade.class, objectCtx); + } + public static com.kingdee.eas.custom.risheng.IRishengInterfaceFacade getLocalInstance(Context ctx) throws BOSException + { + return (com.kingdee.eas.custom.risheng.IRishengInterfaceFacade)BOSObjectFactory.createBOSObject(ctx, new BOSObjectType("81647F35")); + } + public static com.kingdee.eas.custom.risheng.IRishengInterfaceFacade getLocalInstance(String sessionID) throws BOSException + { + return (com.kingdee.eas.custom.risheng.IRishengInterfaceFacade)BOSObjectFactory.createBOSObject(sessionID, new BOSObjectType("81647F35")); + } +} \ No newline at end of file diff --git a/src/com/kingdee/eas/custom/risheng/RishengPendingMessageFacade.java b/src/com/kingdee/eas/custom/risheng/RishengPendingMessageFacade.java new file mode 100644 index 0000000..772f267 --- /dev/null +++ b/src/com/kingdee/eas/custom/risheng/RishengPendingMessageFacade.java @@ -0,0 +1,65 @@ +package com.kingdee.eas.custom.risheng; + +import com.kingdee.bos.framework.ejb.EJBRemoteException; +import com.kingdee.bos.util.BOSObjectType; +import java.rmi.RemoteException; +import com.kingdee.bos.framework.AbstractBizCtrl; +import com.kingdee.bos.orm.template.ORMObject; + +import com.kingdee.bos.BOSException; +import com.kingdee.bos.util.*; +import com.kingdee.eas.common.EASBizException; +import com.kingdee.eas.custom.risheng.*; +import java.lang.String; +import com.kingdee.bos.Context; +import com.kingdee.bos.framework.*; + +public class RishengPendingMessageFacade extends AbstractBizCtrl implements IRishengPendingMessageFacade +{ + public RishengPendingMessageFacade() + { + super(); + registerInterface(IRishengPendingMessageFacade.class, this); + } + public RishengPendingMessageFacade(Context ctx) + { + super(ctx); + registerInterface(IRishengPendingMessageFacade.class, this); + } + public BOSObjectType getType() + { + return new BOSObjectType("4FA99C68"); + } + private RishengPendingMessageFacadeController getController() throws BOSException + { + return (RishengPendingMessageFacadeController)getBizController(); + } + /** + *待办信息-User defined method + *@param data data + *@return + */ + public String sendPendingMsg(String data) throws BOSException, EASBizException + { + try { + return getController().sendPendingMsg(getContext(), data); + } + catch(RemoteException err) { + throw new EJBRemoteException(err); + } + } + /** + *已办消息-User defined method + *@param data data + *@return + */ + public String sendDoneMsg(String data) throws BOSException, EASBizException + { + try { + return getController().sendDoneMsg(getContext(), data); + } + catch(RemoteException err) { + throw new EJBRemoteException(err); + } + } +} \ No newline at end of file diff --git a/src/com/kingdee/eas/custom/risheng/RishengPendingMessageFacadeController.java b/src/com/kingdee/eas/custom/risheng/RishengPendingMessageFacadeController.java new file mode 100644 index 0000000..365b08a --- /dev/null +++ b/src/com/kingdee/eas/custom/risheng/RishengPendingMessageFacadeController.java @@ -0,0 +1,23 @@ +package com.kingdee.eas.custom.risheng; + +import com.kingdee.bos.BOSException; +//import com.kingdee.bos.metadata.*; +import com.kingdee.bos.framework.*; +import com.kingdee.bos.util.*; +import com.kingdee.bos.Context; + +import com.kingdee.bos.BOSException; +import com.kingdee.bos.util.*; +import com.kingdee.eas.common.EASBizException; +import java.lang.String; +import com.kingdee.bos.Context; +import com.kingdee.bos.framework.*; + +import java.rmi.RemoteException; +import com.kingdee.bos.framework.ejb.BizController; + +public interface RishengPendingMessageFacadeController extends BizController +{ + public String sendPendingMsg(Context ctx, String data) throws BOSException, EASBizException, RemoteException; + public String sendDoneMsg(Context ctx, String data) throws BOSException, EASBizException, RemoteException; +} \ No newline at end of file diff --git a/src/com/kingdee/eas/custom/risheng/RishengPendingMessageFacadeControllerBean.java b/src/com/kingdee/eas/custom/risheng/RishengPendingMessageFacadeControllerBean.java new file mode 100644 index 0000000..5250796 --- /dev/null +++ b/src/com/kingdee/eas/custom/risheng/RishengPendingMessageFacadeControllerBean.java @@ -0,0 +1,342 @@ +package com.kingdee.eas.custom.risheng; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +import org.apache.axis.encoding.Base64; +import org.apache.log4j.Logger; +import java.sql.SQLException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +import com.kingdee.bos.*; +import com.kingdee.bos.workflow.AssignmentInfo; +import com.kingdee.bos.workflow.service.ormrpc.EnactmentServiceFactory; +import com.kingdee.bos.workflow.service.ormrpc.IEnactmentService; + +import java.io.BufferedInputStream; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.lang.String; +import java.net.URLEncoder; + +import com.kingdee.eas.common.EASBizException; +import com.kingdee.eas.custom.risheng.util.HttpRequestUtil; +import com.kingdee.eas.util.app.DbUtil; +import com.kingdee.jdbc.rowset.IRowSet; +import com.kingdee.util.StringUtils; + +public class RishengPendingMessageFacadeControllerBean extends AbstractRishengPendingMessageFacadeControllerBean +{ + private static Logger logger = + Logger.getLogger("com.kingdee.eas.custom.risheng.RishengPendingMessageFacadeControllerBean"); + private static final String ROOT_URL = "http://120.46.132.160:8080/rest/ofs/ReceiveRequestInfoByJson"; + private static final String SHR_ROOT_URL = "https://rshr.kdeascloud.com"; + private static final String EID = "K172K145K108K99K97"; + +// private static final String TOKEN_URL = "/seeyon/rest/token"; +// private static final String AUTHEN_NAME = "0003"; +// private static final String AUTHEN_PASSWORD = "123456"; + + /** + * 待办消息推送到OA + */ + @Override + public String sendPendingMsg(Context ctx, String data) throws BOSException, EASBizException { + // TODO 自动生成的方法存根 + try{ + StringBuffer queryPendingSqlBuf = new StringBuffer( + " /*dialect*/ SELECT "); + queryPendingSqlBuf.append("b.FID"); + queryPendingSqlBuf.append(",a.FSUBJECT_l2 TITLE"); + queryPendingSqlBuf.append(",b.FSenderId SENDERID"); + queryPendingSqlBuf.append(",d.FNUMBER SENDERNUMBER"); + queryPendingSqlBuf.append(",b.FSender_l2 SENDERNAME"); + queryPendingSqlBuf.append(",a.FPERSONUSERID RECEIVERID"); + queryPendingSqlBuf.append(",e.FNUMBER RECEIVERNUMBER"); + queryPendingSqlBuf.append(",a.FPERSONUSERNAME_L2 RECEIVERNAME"); + queryPendingSqlBuf.append(",a.FCREATEDTIME SENDTIME"); + queryPendingSqlBuf.append(",a.FCREATEDTIME RECEIVETIME"); + queryPendingSqlBuf.append(",a.FPRIORITY PRIORITY"); + queryPendingSqlBuf.append(",b.FSTATUS STATUS"); + queryPendingSqlBuf.append(",a.FSTATE SOURCESTATUS"); + queryPendingSqlBuf.append(",b.FORGTYPE ORGTYPE"); + queryPendingSqlBuf.append(",b.FORGID ORGID"); + queryPendingSqlBuf.append(",a.FASSIGNID SOURCEID"); + queryPendingSqlBuf.append(",b.FIsWebSupport ISWEBSUPPORT"); + queryPendingSqlBuf.append(",a.FBODY_l2 FBODY"); + queryPendingSqlBuf.append(",a.FPROCDEFNAME_l2 PROCDEFNAME"); + queryPendingSqlBuf.append(",b.FTag_l2 TAG"); + queryPendingSqlBuf.append(",b.FSenderId SENDERID"); + queryPendingSqlBuf.append(",b.FPriorPerformerID PRIORPERFORMERID"); + queryPendingSqlBuf.append(",last.FNumber PRIORPERFORMNAME"); + queryPendingSqlBuf.append(",a.FPROCINSTID FPROCINSTID"); + queryPendingSqlBuf.append(",a.FBIZOBJID FBIZOBJID"); + queryPendingSqlBuf.append(",e.fname_l2 ename"); + queryPendingSqlBuf.append(" FROM T_WFR_Assign a"); + queryPendingSqlBuf.append(" INNER JOIN T_BAS_AssignRead b ON a.FASSIGNID = b.FASSIGNID"); + queryPendingSqlBuf.append(" JOIN T_PM_User last ON b.FPriorPerformerID = last.FID"); + queryPendingSqlBuf.append(" JOIN T_PM_User d ON b.FSenderId = d.FID"); + queryPendingSqlBuf.append(" JOIN T_PM_User e ON a.FPERSONUSERID = e.FID"); + queryPendingSqlBuf.append(" WHERE a.FIsSendMsg = 1 and a.CFISSYS is null and e.Fnumber not in ('user','administrator')"); + String queryPend = queryPendingSqlBuf.toString(); + if(null != data && !"".equals(data)){ + queryPend = queryPend + " and a.FCREATEDTIME >= '"+ data + "'"; + } + System.out.println("查询待办SQL:" + queryPend); + IRowSet queryPendingRows = DbUtil.executeQuery(ctx, queryPend); + System.out.println("待办发送条数:" + queryPendingRows.size()); + System.out.println("userQueryTime===================" + new Date()); + System.out.println("开始推送时间===================" + new Date()); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + while(queryPendingRows.next()){ + Map queryPendingMap = new HashMap(); + String taskId = queryPendingRows.getString("SOURCEID"); + queryPendingMap.put("syscode", "SHR");//异构系统标识 + queryPendingMap.put("flowid", taskId);// 流程ID + queryPendingMap.put("requestname", queryPendingRows.getString("TITLE"));// 标题 + queryPendingMap.put("workflowname", queryPendingRows.getString("PROCDEFNAME"));// 流程类型名称 + queryPendingMap.put("nodename", "1");// 步骤名称 + String url = getUrl(queryPendingRows.getString("RECEIVERNUMBER"),taskId) ; + queryPendingMap.put("pcurl",url);// pc地址 + + + String FBIZOBJID = queryPendingRows.getString("FBIZOBJID");// 业务对象内码 + //String rcvNum = queryPendingRows.getString("RECEIVERNUMBER"); //暂时设置为0003 + String rcvNum = "0003"; + String receiverNumberBase = Base64.encode(rcvNum.getBytes()); + String mbosUrl = getUrl(taskId, EID, "https://mbos.kdeascloud.com/mbos/page/loadPage?", "10036", ctx,FBIZOBJID); + mbosUrl = mbosUrl+"&token="+receiverNumberBase+"&isOtherApp=true&path=lczs2"; + + System.out.println("mbos ========"+mbosUrl); + queryPendingMap.put("appurl", mbosUrl);//app地址 + queryPendingMap.put("isremark", "0");// 状态 0:未办理;2:已办理 + queryPendingMap.put("viewtype", "0");// 流程查看状态 + //创建人,先设置为0003 + String cjrNumber = queryPendingRows.getString("SENDERNUMBER"); + String cjr = cjrNumber.substring(0, 1); + if(cjr.equals("1")||cjr.equals("2")){ + cjrNumber=cjrNumber.substring(1, cjrNumber.length()); + } + queryPendingMap.put("creator", "0003"); + //接收人,接收人先设置为0003 + String jsrNumber = queryPendingRows.getString("RECEIVERNUMBER"); + String substring = jsrNumber.substring(0, 1); + if(substring.equals("1")||substring.equals("2")){ + jsrNumber=jsrNumber.substring(1, jsrNumber.length()); + } + queryPendingMap.put("receiver", "0003");// 接收人ID + Date createTime = queryPendingRows.getDate("RECEIVETIME"); + queryPendingMap.put("createdatetime", sdf.format(createTime));// 流程创建时间 + queryPendingMap.put("receivedatetime", sdf.format(createTime));// 接受日期 + queryPendingMap.put("receivets",new Date().getTime()+"");// 时间戳 + System.out.println("待办发送数据(" + new Date().getTime() + "):"+ JSONObject.fromObject(queryPendingMap).toString()); + try{ + String resultMsgDataStr = HttpRequestUtil.sendPost(ROOT_URL ,JSONObject.fromObject(queryPendingMap).toString(), "json"); + System.out.println("待办接口返回信息(" + new Date().getTime() + ")"+ resultMsgDataStr); + JSONObject resultData = JSONObject.fromObject(resultMsgDataStr); + if(resultData.getString("operResult").equals("1")){ + //待更新表T_WFR_Assign 状态 + DbUtil.execute(ctx,"update T_WFR_Assign set CFISSYS = 0 where FASSIGNID = '"+ taskId + "'"); + }else{ + String resultDataArr = resultData.get("messgae")==null?"":resultData.get("messgae").toString(); + System.out.println("发送打回待办任务失败,失败原因为:"+ resultDataArr); + } + }catch(Exception e){ + e.printStackTrace(); + System.out.println(e.getMessage()); + } + } + System.out.println("end推送时间===================" + new Date()); + }catch(SQLException e){ + e.printStackTrace(); + System.out.println(e.getMessage()); + } + return null; + } + + private static String getUrl(String username ,String assignid) { + String url =""; + url=SHR_ROOT_URL+"/portal/index2sso.jsp?username="+username+"&billType=1&redirectTo="+URLEncoder.encode(SHR_ROOT_URL+"/easweb/webviews/workflow/transferApprove.jsp?AssignmentId="+assignid); + return url; + } + private static String getMobileUrl(String username ,String assignid,String procInId){ + return SHR_ROOT_URL+"/approve/#/ApproveApp/ApvDetail?assignId="+assignid+"&receiverId="+username+"&procInstId="+procInId; + } + public Map getValue(String fileName) { + if(!fileName.contains(".properties")){ + fileName += ".properties"; + } + Map map = new HashMap(); + Properties properties = new Properties(); + InputStream in = null; + try{ + in = new BufferedInputStream(new FileInputStream(System.getProperty("EAS_HOME")+ "/server/properties/" + fileName)); + properties.load(in); + for(Object key : properties.keySet()){ + String keyStr = key.toString(); + String value = properties.getProperty(keyStr); + map.put(keyStr, value); + } + }catch(Exception e){ + e.printStackTrace(); + System.out.println(e.getMessage()); + }finally{ + if(in != null){ + try{ + in.close(); + }catch(IOException e){ + e.printStackTrace(); + } + } + } + return map; + } + + private String getUrl(String assignid, String eid, String host, String appId,Context ctx,String billId) + throws BOSException { + String newEid =EID; + //logger.info("XT Message newEidnewEid=" + newEid); + String url = host; + IEnactmentService svc = EnactmentServiceFactory.createEnactService(ctx); + AssignmentInfo info = svc.getAssignmentById(assignid); + if(host.indexOf("?") > -1){ + String actdef = info.getActDefId(); + System.out.println("actdef==================="+actdef); + String procdef = info.getProcDefId(); + System.out.println("procdef==================="+procdef); + String mbosUrl = getMbosUrl(procdef, actdef,ctx); + System.out.println("mbosUrl=================="+mbosUrl); + if(!(StringUtils.isEmpty(mbosUrl))){ + mbosUrl = mbosUrl.replace("page/loadPage","mbosw/getWorkflowUrl"); + url = mbosUrl + "&eid=" + newEid + "&assignId=" + assignid+ "&appid=" + appId + "&billID="+URLEncoder.encode(billId); + return url; + } + } + if(host.indexOf("?") > -1) + //url = url + "&storeEid=K172K145K108K99K97&name=approveui.navui&eid=" + newEid+ "&assignId=" + assignid + "&appid=" + appId; + url = url + "storeEid=K172K145K108K99K97&name=approveui.navui&eid=" + newEid+ "&assignId=" + assignid + "&appid=" + appId; + else{ + url = url + "/dealWithNotice.html?eid=" + newEid + "&assignId="+ assignid + "&appid=" + appId; + } + return url; + } + + private String getMbosUrl(String procid, String actDefId,Context ctx) { + String url = ""; + try{ + StringBuffer sql = new StringBuffer("SELECT url FROM T_WFR_MBOS_WORKFLOW "); + if(!(StringUtils.isEmpty(actDefId))){ + sql.append(" WHERE actDefId in ('" + actDefId + "')"); + } + if(!(StringUtils.isEmpty(procid))){ + sql.append(" and procdefid in ('" + procid + "')"); + } + IRowSet rowSet = DbUtil.executeQuery(ctx, sql.toString()); + if(rowSet.next()){ + url = rowSet.getString("url"); + } + }catch(Exception e){ + //logger.error(e.getMessage(), e); + } + return url; + } + /** + * 已办消息推送到OA + */ + @Override + public String sendDoneMsg(Context ctx, String data) throws BOSException, EASBizException { + // TODO 自动生成的方法存根 + StringBuffer queryUpdatePendSqlBuf = new StringBuffer(" /*dialect*/ SELECT "); + queryUpdatePendSqlBuf.append("a.FASSIGNID"); + queryUpdatePendSqlBuf.append(",a.FPROCINSTID"); + queryUpdatePendSqlBuf.append(",a.FSTATE AFSTATE"); + queryUpdatePendSqlBuf.append(",a.FSUBJECT_l2 TITLE"); + queryUpdatePendSqlBuf.append(",e.FNUMBER RECEIVERNUMBER"); + queryUpdatePendSqlBuf.append(",a.fprocdefname_l2 PROCDEFNAME"); + queryUpdatePendSqlBuf.append(",d.fnumber SENDERNUMBER"); + queryUpdatePendSqlBuf.append(",a.fcreatedtime RECEIVETIME"); + queryUpdatePendSqlBuf.append(",b.FSTATE"); + queryUpdatePendSqlBuf.append(",c.FISPASS"); + queryUpdatePendSqlBuf.append(",a.FBIZOBJID FBIZOBJID"); + queryUpdatePendSqlBuf.append(" FROM t_wfr_AssignDetail a"); + queryUpdatePendSqlBuf.append(" JOIN T_WFR_ProcInst b ON a.FPROCINSTID = b.FPROCINSTID"); + queryUpdatePendSqlBuf.append(" LEFT JOIN T_BAS_MultiApprove c ON a.FASSIGNID = c.FASSIGNMENTID"); + queryUpdatePendSqlBuf.append(" JOIN T_PM_User e ON a.FPERSONUSERID = e.FID"); + queryUpdatePendSqlBuf.append(" JOIN T_PM_User d ON a.fpriorperformer = d.FID"); + queryUpdatePendSqlBuf.append(" WHERE (a.FSTATE = 16 OR a.FSTATE = 4) AND a.CFISSYS is null and e.Fnumber not in ('user','administrator')"); + this.sendDone(ctx, queryUpdatePendSqlBuf); + return null; + } + private int sendDone(Context ctx, StringBuffer queryUpdatePendSqlBuf)throws BOSException + { + System.out.println("查询已办SQL:" + queryUpdatePendSqlBuf.toString()); + IRowSet queryUpfatePendRows = DbUtil.executeQuery(ctx,queryUpdatePendSqlBuf.toString()); + System.out.println("已办发送条数:" + queryUpfatePendRows.size()); + try{ + System.out.println("开始推送时间===================" + new Date()); + while(queryUpfatePendRows.next()){ + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Map queryPendingMap = new HashMap(); + String taskId = queryUpfatePendRows.getString("FASSIGNID"); + queryPendingMap.put("syscode", "SHR");//异构系统标识 + queryPendingMap.put("flowid", taskId);// 流程ID + queryPendingMap.put("requestname", queryUpfatePendRows.getString("TITLE"));// 标题 + queryPendingMap.put("workflowname", queryUpfatePendRows.getString("PROCDEFNAME"));// 流程类型名称 + queryPendingMap.put("nodename", "1");// 步骤名称 + queryPendingMap.put("viewtype", "0");// 流程查看状态 + String cjrNumber = queryUpfatePendRows.getString("SENDERNUMBER"); + //queryPendingMap.put("creator", cjrNumber);// 创建人 暂时设置成0003 + queryPendingMap.put("creator", "0003"); + String jsrNumber = queryUpfatePendRows.getString("RECEIVERNUMBER"); + //queryPendingMap.put("receiver", jsrNumber);// 接收人ID 暂时设置成0003 + queryPendingMap.put("receiver", "0003"); + Date createTime = queryUpfatePendRows.getDate("RECEIVETIME"); + queryPendingMap.put("createdatetime", sdf.format(createTime));// 流程创建时间 + queryPendingMap.put("receivedatetime", sdf.format(createTime));// 接受日期 + queryPendingMap.put("isremark", "2"); + queryPendingMap.put("receivets",new Date().getTime()+"");// 时间戳 + String billType="2"; + String url = getUrl(queryUpfatePendRows.getString("RECEIVERNUMBER"),taskId) ; + queryPendingMap.put("pcurl",url);// pc地址 + String FBIZOBJID = queryUpfatePendRows.getString("FBIZOBJID");// 业务对象内码 + + //String rcvNum = queryPendingRows.getString("RECEIVERNUMBER"); //暂时设置为0003 + String rcvNum = "0003"; + String receiverNumberBase = Base64.encode(rcvNum.getBytes()); + String mbosUrl = getUrl(taskId, EID, "https://mbos.kdeascloud.com/mbos/page/loadPage?", "10036", ctx,FBIZOBJID); + mbosUrl = mbosUrl+"&token="+receiverNumberBase+"&isOtherApp=true&path=lczs2"; + System.out.println("mbos ========"+mbosUrl); + //logger.info("======mbosUrl===="+mbosUrl); + queryPendingMap.put("appurl", mbosUrl);// app地址 + System.out.println("已办发送数据("+ new Date().getTime()+ "):"+ JSONObject.fromObject(queryPendingMap).toString()); + //logger.info("已办发送数据"+ JSONObject.fromObject(queryPendingMap).toString()); + String resultDataStr = HttpRequestUtil.sendPost(ROOT_URL, JSONObject.fromObject(queryPendingMap).toString(), "json"); + System.out.println("已办接口返回信息(" + new Date().getTime()+ "):" + resultDataStr); + //logger.info("已办接口返回信息"+ resultDataStr); + JSONObject resultData = JSONObject.fromObject(resultDataStr); + if(resultData.get("operResult").equals("1")){ + DbUtil.execute(ctx,"update t_wfr_AssignDetail set CFISSYS = 0 where FASSIGNID = '"+ taskId + "'"); + System.out.println("成功发送一条已办"); + }else{ + String resultDataArr = resultData.get("messgae")==null?"":resultData.get("messgae").toString(); + System.out.println("发送打回待办任务失败,失败原因为:"+ resultDataArr); + } + } + int size = queryUpfatePendRows.size(); + return size; + }catch(SQLException e){ + e.printStackTrace(); + System.out.println(e.getMessage()); + return -1; + }catch(Exception e){ + e.printStackTrace(); + System.out.println(e.getMessage()); + return -1; + } + } +} \ No newline at end of file diff --git a/src/com/kingdee/eas/custom/risheng/RishengPendingMessageFacadeFactory.java b/src/com/kingdee/eas/custom/risheng/RishengPendingMessageFacadeFactory.java new file mode 100644 index 0000000..11d3e2d --- /dev/null +++ b/src/com/kingdee/eas/custom/risheng/RishengPendingMessageFacadeFactory.java @@ -0,0 +1,30 @@ +package com.kingdee.eas.custom.risheng; + +import com.kingdee.bos.BOSException; +import com.kingdee.bos.BOSObjectFactory; +import com.kingdee.bos.util.BOSObjectType; +import com.kingdee.bos.Context; + +public class RishengPendingMessageFacadeFactory +{ + private RishengPendingMessageFacadeFactory() + { + } + public static com.kingdee.eas.custom.risheng.IRishengPendingMessageFacade getRemoteInstance() throws BOSException + { + return (com.kingdee.eas.custom.risheng.IRishengPendingMessageFacade)BOSObjectFactory.createRemoteBOSObject(new BOSObjectType("4FA99C68") ,com.kingdee.eas.custom.risheng.IRishengPendingMessageFacade.class); + } + + public static com.kingdee.eas.custom.risheng.IRishengPendingMessageFacade getRemoteInstanceWithObjectContext(Context objectCtx) throws BOSException + { + return (com.kingdee.eas.custom.risheng.IRishengPendingMessageFacade)BOSObjectFactory.createRemoteBOSObjectWithObjectContext(new BOSObjectType("4FA99C68") ,com.kingdee.eas.custom.risheng.IRishengPendingMessageFacade.class, objectCtx); + } + public static com.kingdee.eas.custom.risheng.IRishengPendingMessageFacade getLocalInstance(Context ctx) throws BOSException + { + return (com.kingdee.eas.custom.risheng.IRishengPendingMessageFacade)BOSObjectFactory.createBOSObject(ctx, new BOSObjectType("4FA99C68")); + } + public static com.kingdee.eas.custom.risheng.IRishengPendingMessageFacade getLocalInstance(String sessionID) throws BOSException + { + return (com.kingdee.eas.custom.risheng.IRishengPendingMessageFacade)BOSObjectFactory.createBOSObject(sessionID, new BOSObjectType("4FA99C68")); + } +} \ No newline at end of file diff --git a/src/com/kingdee/eas/custom/risheng/SendTodoMessageTaskHandler.java b/src/com/kingdee/eas/custom/risheng/SendTodoMessageTaskHandler.java new file mode 100644 index 0000000..d166291 --- /dev/null +++ b/src/com/kingdee/eas/custom/risheng/SendTodoMessageTaskHandler.java @@ -0,0 +1,45 @@ +package com.kingdee.eas.custom.risheng; + +import java.util.Locale; + +import org.apache.log4j.Logger; + +import net.sf.json.JSONObject; + +import com.kingdee.bos.BOSException; +import com.kingdee.bos.Context; +import com.kingdee.bos.dao.ormapping.ObjectUuidPK; +import com.kingdee.bos.workflow.message.AssignmentCreationEvent; +import com.kingdee.eas.base.message.app.ITaskHandler; +import com.kingdee.eas.common.EASBizException; + +public class SendTodoMessageTaskHandler implements ITaskHandler { + + + private static Logger logger = + Logger.getLogger("com.kingdee.eas.custom.risheng.SendTodoMessageTaskHandler"); + @Override + public void execute(AssignmentCreationEvent e) { + // TODO Auto-generated method stub + logger.error("方法进了assignmentId:"+e.assignmentId); + JSONObject data = new JSONObject(); + + String databaseCenter = e.databaseCenter; + String solution = e.solution; + Context ctx = new Context(new ObjectUuidPK(),solution,databaseCenter,new Locale("l2")); + + data.put("data", null); + data.put("assignmentId", e.assignmentId); + logger.error("SendTodoMessageTaskHandler:"+data.toString()); + try { + RishengPendingMessageFacadeFactory.getLocalInstance(ctx).sendPendingMsg(null); + } catch (EASBizException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (BOSException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + +} diff --git a/src/com/kingdee/eas/custom/risheng/SyncDataFacade.java b/src/com/kingdee/eas/custom/risheng/SyncDataFacade.java new file mode 100644 index 0000000..731345a --- /dev/null +++ b/src/com/kingdee/eas/custom/risheng/SyncDataFacade.java @@ -0,0 +1,21 @@ +package com.kingdee.eas.custom.risheng; + +public class SyncDataFacade { + + public static SyncHRDataInterface SyncDataFacade(String type){ + SyncHRDataInterface syncHRDataInterface = null; + if(type!=null) { + switch (type) { + case "fwoa": + syncHRDataInterface = new FWOASyncHrData(); + break; + case "hk": + syncHRDataInterface = new HKSyncHrData(); + break; + default: + break; + } + } + return syncHRDataInterface; + } +} diff --git a/src/com/kingdee/eas/custom/risheng/SyncHRDataInterface.java b/src/com/kingdee/eas/custom/risheng/SyncHRDataInterface.java new file mode 100644 index 0000000..7d3154a --- /dev/null +++ b/src/com/kingdee/eas/custom/risheng/SyncHRDataInterface.java @@ -0,0 +1,9 @@ +package com.kingdee.eas.custom.risheng; + +import java.util.Map; + +public interface SyncHRDataInterface { + public String syncAdminOrg(String data,String surl); + public String syncPerson(String data,String surl); + public String syncPosition(String data,String surl); +} diff --git a/src/com/kingdee/eas/custom/risheng/util/HttpRequestSecUtil.java b/src/com/kingdee/eas/custom/risheng/util/HttpRequestSecUtil.java new file mode 100644 index 0000000..b4fffb3 --- /dev/null +++ b/src/com/kingdee/eas/custom/risheng/util/HttpRequestSecUtil.java @@ -0,0 +1,408 @@ +package com.kingdee.eas.custom.risheng.util; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.apache.commons.httpclient.HttpStatus; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.http.HttpEntity; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.protocol.BasicHttpContext; +import org.apache.http.util.EntityUtils; + +import com.alibaba.fastjson.JSONObject; + +import java.io.IOException; + +import org.apache.http.NameValuePair; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.message.BasicNameValuePair; + +public class HttpRequestSecUtil { + + private static final Log log = LogFactory.getLog(HttpRequestSecUtil.class); + + public static String sendPost(String url, String content) throws Exception { + return sendPost(url,content,"json"); + + } + public static String sendPost(String url, String content, Map headMap) throws Exception { + return sendPostAndHeader(url,content,"json",headMap); + } + + public static String sendPost(String url, String content, String contentType, Map headMap) throws Exception { + return sendPostAndHeader(url,content,contentType,headMap); + } + + public static String sendPostJson(String url, String content,String contentType) throws Exception { + log.info(url.toString()); + CloseableHttpClient httpClient = null; + HttpPost httpPost = null; + CloseableHttpResponse httpResponse = null; + try { + httpClient = HttpClients.createDefault(); + int CONNECTION_TIMEOUT = 10 * 1000; + RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(CONNECTION_TIMEOUT).setConnectTimeout(CONNECTION_TIMEOUT).setSocketTimeout(CONNECTION_TIMEOUT).build(); + httpPost = new HttpPost(url); + httpPost.setConfig(requestConfig); + if("json".equals(contentType)) + { + httpPost.addHeader("Content-Type", "application/json"); + httpPost.addHeader("Accept", "application/json"); + } + else + { + httpPost.addHeader("Content-Type", "application/x-www-form-urlencoded"); + } + StringEntity requestEntity = new StringEntity(content, "UTF-8"); + httpPost.setEntity(requestEntity); + httpResponse = httpClient.execute(httpPost, new BasicHttpContext()); + HttpEntity entity = httpResponse.getEntity(); + if(entity != null) { + String resultStr = EntityUtils.toString(entity, "UTF-8"); + return resultStr; + } + } catch(Exception e) { + log.error("", e); + throw new Exception(e); + } finally { + if(httpResponse != null) { + try { + httpResponse.close(); + } catch(Exception e) { + throw new Exception(e); + } + } + if(httpPost != null) { + try { + httpPost.releaseConnection(); + } catch(Exception e) { + log.error("", e); + throw new Exception(e); + } + } + if(httpClient != null) { + try { + httpClient.close(); + } catch(Exception e) { + log.error("", e); + throw new Exception(e); + } + } + } + return null; + } + + public static String sendPost(String url, String content,String contentType) throws Exception { + log.info(url); + CloseableHttpClient httpClient = null; + HttpPost httpPost = null; + CloseableHttpResponse httpResponse = null; + String resulrCode = ""; + try { + httpClient = HttpClients.createDefault(); + int CONNECTION_TIMEOUT = 10 * 1000; + RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(CONNECTION_TIMEOUT).setConnectTimeout(CONNECTION_TIMEOUT).setSocketTimeout(CONNECTION_TIMEOUT).build(); + httpPost = new HttpPost(url); + httpPost.setConfig(requestConfig); + if("json".equals(contentType)) + { + httpPost.addHeader("Content-Type", "application/json"); + httpPost.addHeader("Accept", "application/json"); + //httpPost.addHeader("Authorization", "Bearer "+SrmUtil.getToken()); + } + else + { + httpPost.addHeader("Content-Type", "application/x-www-form-urlencoded"); + } + StringEntity requestEntity = new StringEntity(content, "UTF-8"); + httpPost.setEntity(requestEntity); + httpResponse = httpClient.execute(httpPost, new BasicHttpContext()); + int code = httpResponse.getStatusLine().getStatusCode(); + resulrCode = String.valueOf(code); + if(code != HttpStatus.SC_OK){ + return resulrCode; + + } + HttpEntity entity = httpResponse.getEntity(); + if(entity != null) { + String resultStr = EntityUtils.toString(entity, "UTF-8"); + return resultStr; + } + } catch(Exception e) { + log.error("", e); + throw new Exception(e); + } finally { + if(httpResponse != null) { + try { + httpResponse.close(); + } catch(Exception e) { + log.error("", e); + throw new Exception(e); + } + } + if(httpPost != null) { + try { + httpPost.releaseConnection(); + } catch(Exception e) { + log.error("", e); + throw new Exception(e); + } + } + if(httpClient != null) { + try { + httpClient.close(); + } catch(Exception e) { + log.error("", e); + throw new Exception(e); + } + } + } + return resulrCode; + } + + + + public static String sendPostAndHeader(String url, String content,String contentType, Map headMap) throws Exception { + log.info(url); + CloseableHttpClient httpClient = null; + HttpPost httpPost = null; + CloseableHttpResponse httpResponse = null; + String resulrCode = ""; + try { + httpClient = HttpClients.createDefault(); + int CONNECTION_TIMEOUT = 100 * 1000; + RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(CONNECTION_TIMEOUT).setConnectTimeout(CONNECTION_TIMEOUT).setSocketTimeout(CONNECTION_TIMEOUT).build(); + httpPost = new HttpPost(url); + httpPost.setConfig(requestConfig); + if("json".equals(contentType)) + { + httpPost.addHeader("Content-Type", "application/json"); + httpPost.addHeader("Accept", "application/json"); + //httpPost.addHeader("Authorization", "Bearer "+SrmUtil.getToken()); + StringEntity requestEntity = new StringEntity(content, "UTF-8"); + httpPost.setEntity(requestEntity); + + System.out.println("json----post+headMap.toString()"); + } + else + { + httpPost.addHeader("Content-Type", "application/x-www-form-urlencoded"); + List nvps = new ArrayList(); + JSONObject object = JSONObject.parseObject(content); + for (Entry entry : object.entrySet()) { + nvps.add(new BasicNameValuePair(entry.getKey(), entry.getValue().toString())); + } + + httpPost.setEntity(new UrlEncodedFormEntity(nvps, "UTF-8")); + System.out.println(contentType+"----post+headMap.toString()"); + } + // + if(headMap!=null){ + for (String sourceKey : headMap.keySet()) { + httpPost.addHeader(sourceKey, headMap.get(sourceKey)); + } + } + + // + httpResponse = httpClient.execute(httpPost, new BasicHttpContext()); + int code = httpResponse.getStatusLine().getStatusCode(); + resulrCode = String.valueOf(code); + if(code != HttpStatus.SC_OK){ + return resulrCode; + + } + HttpEntity entity = httpResponse.getEntity(); + if(entity != null) { + String resultStr = EntityUtils.toString(entity, "UTF-8"); + return resultStr; + } + } catch(Exception e) { + log.error("", e); + throw new Exception(e); + } finally { + if(httpResponse != null) { + try { + httpResponse.close(); + } catch(Exception e) { + log.error("", e); + throw new Exception(e); + } + } + if(httpPost != null) { + try { + httpPost.releaseConnection(); + } catch(Exception e) { + log.error("", e); + throw new Exception(e); + } + } + if(httpClient != null) { + try { + httpClient.close(); + } catch(Exception e) { + log.error("", e); + throw new Exception(e); + } + } + } + return resulrCode; + } + + + public static String sendGet(String url) { + CloseableHttpClient httpClient = null; + HttpGet httpGet = null; + CloseableHttpResponse httpResponse = null; + try { + httpClient = HttpClients.createDefault(); + int CONNECTION_TIMEOUT = 10 * 1000; + RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(CONNECTION_TIMEOUT).setConnectTimeout(CONNECTION_TIMEOUT).setSocketTimeout(CONNECTION_TIMEOUT).build(); + httpGet = new HttpGet(url); + httpGet.setConfig(requestConfig); + httpGet.addHeader("Content-Type", "application/json"); + httpGet.addHeader("Accept", "application/json"); + httpResponse = httpClient.execute(httpGet, new BasicHttpContext()); + HttpEntity entity = httpResponse.getEntity(); + if(entity != null) { + String resultStr = EntityUtils.toString(entity, "UTF-8"); + //JSONObject result = JSONObject.parseObject(resultStr); + return resultStr; + } + } catch(Exception e) { + // log.error("", e); + } finally { + if(httpResponse != null) { + try { + httpResponse.close(); + } catch(Exception e) { + } + } + if(httpGet != null) { + try { + httpGet.releaseConnection(); + } catch(Exception e) { + } + } + if(httpClient != null) { + try { + httpClient.close(); + } catch(Exception e) { + } + } + } + return null; + } +// public static String sendPost(String url, String content,String contentType) throws Exception { +// log.info(url); +// CloseableHttpClient httpClient = null; +// HttpPost httpPost = null; +// CloseableHttpResponse httpResponse = null; +// String resulrCode = ""; +// try { +// httpClient = HttpClients.createDefault(); +// int CONNECTION_TIMEOUT = 10 * 1000; +// RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(CONNECTION_TIMEOUT).setConnectTimeout(CONNECTION_TIMEOUT).setSocketTimeout(CONNECTION_TIMEOUT).build(); +// httpPost = new HttpPost(url); +// httpPost.setConfig(requestConfig); +// if("json".equals(contentType)) +// { +// httpPost.addHeader("Content-Type", "application/json"); +// httpPost.addHeader("Accept", "application/json"); +// //httpPost.addHeader("Authorization", "Bearer "+SrmUtil.getToken()); +// } +// else +// { +// httpPost.addHeader("Content-Type", "application/x-www-form-urlencoded"); +// } +// StringEntity requestEntity = new StringEntity(content, "UTF-8"); +// httpPost.setEntity(requestEntity); +// httpResponse = httpClient.execute(httpPost, new BasicHttpContext()); +// int code = httpResponse.getStatusLine().getStatusCode(); +// resulrCode = String.valueOf(code); +// if(code != HttpStatus.SC_OK){ +// return resulrCode; +// +// } +// HttpEntity entity = httpResponse.getEntity(); +// if(entity != null) { +// String resultStr = EntityUtils.toString(entity, "UTF-8"); +// return resultStr; +// } +// } catch(Exception e) { +// log.error("", e); +// throw new Exception(e); +// } finally { +// if(httpResponse != null) { +// try { +// httpResponse.close(); +// } catch(Exception e) { +// log.error("", e); +// throw new Exception(e); +// } +// } +// if(httpPost != null) { +// try { +// httpPost.releaseConnection(); +// } catch(Exception e) { +// log.error("", e); +// throw new Exception(e); +// } +// } +// if(httpClient != null) { +// try { +// httpClient.close(); +// } catch(Exception e) { +// log.error("", e); +// throw new Exception(e); +// } +// } +// } +// return resulrCode; +// } + + public static String doPost(String url, Map param) { + // + CloseableHttpClient httpClient = HttpClients.createDefault(); + CloseableHttpResponse response = null; + String resultString = ""; + try { + // + HttpPost httpPost = new HttpPost(url); + // + if (param != null) { + List paramList = new ArrayList(); + for (String key : param.keySet()) { + paramList.add(new BasicNameValuePair(key, param.get(key))); + } + // + UrlEncodedFormEntity entity = new UrlEncodedFormEntity(paramList,"utf-8"); + httpPost.setEntity(entity); + } + // + response = httpClient.execute(httpPost); + resultString = EntityUtils.toString(response.getEntity(), "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + response.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + return resultString; + } + +} diff --git a/src/com/kingdee/eas/custom/risheng/util/HttpRequestUtil.java b/src/com/kingdee/eas/custom/risheng/util/HttpRequestUtil.java new file mode 100644 index 0000000..becdc1a --- /dev/null +++ b/src/com/kingdee/eas/custom/risheng/util/HttpRequestUtil.java @@ -0,0 +1,245 @@ +package com.kingdee.eas.custom.risheng.util; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.http.HttpEntity; +import org.apache.http.HttpStatus; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; + + +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.protocol.BasicHttpContext; +import org.apache.http.util.EntityUtils; + +import java.io.IOException; + +import org.apache.http.NameValuePair; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.message.BasicNameValuePair; + +public class HttpRequestUtil { + + private static final Log log = LogFactory.getLog(HttpRequestUtil.class); + + public static String sendPost(String url, String content) throws Exception { + return sendPost(url,content,"json"); + + } + + public static String sendPostJson(String url, String content,String contentType) throws Exception { + log.info(url.toString()); + CloseableHttpClient httpClient = null; + HttpPost httpPost = null; + CloseableHttpResponse httpResponse = null; + try { + httpClient = HttpClients.createDefault(); + int CONNECTION_TIMEOUT = 10 * 1000; + RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(CONNECTION_TIMEOUT).setConnectTimeout(CONNECTION_TIMEOUT).setSocketTimeout(CONNECTION_TIMEOUT).build(); + httpPost = new HttpPost(url); + httpPost.setConfig(requestConfig); + if("json".equals(contentType)) + { + httpPost.addHeader("Content-Type", "application/json"); + httpPost.addHeader("Accept", "application/json"); + } + else + { + httpPost.addHeader("Content-Type", "application/x-www-form-urlencoded"); + } + StringEntity requestEntity = new StringEntity(content, "UTF-8"); + httpPost.setEntity(requestEntity); + httpResponse = httpClient.execute(httpPost, new BasicHttpContext()); + HttpEntity entity = httpResponse.getEntity(); + if(entity != null) { + String resultStr = EntityUtils.toString(entity, "UTF-8"); + return resultStr; + } + } catch(Exception e) { + log.error("", e); + throw new Exception(e); + } finally { + if(httpResponse != null) { + try { + httpResponse.close(); + } catch(Exception e) { + throw new Exception(e); + } + } + if(httpPost != null) { + try { + httpPost.releaseConnection(); + } catch(Exception e) { + log.error("", e); + throw new Exception(e); + } + } + if(httpClient != null) { + try { + httpClient.close(); + } catch(Exception e) { + log.error("", e); + throw new Exception(e); + } + } + } + return null; + } + + public static String sendPost(String url, String content,String contentType) throws Exception { + log.info(url); + CloseableHttpClient httpClient = null; + HttpPost httpPost = null; + CloseableHttpResponse httpResponse = null; + String resulrCode = ""; + try { + httpClient = HttpClients.createDefault(); + int CONNECTION_TIMEOUT = 10 * 1000; + RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(CONNECTION_TIMEOUT).setConnectTimeout(CONNECTION_TIMEOUT).setSocketTimeout(CONNECTION_TIMEOUT).build(); + httpPost = new HttpPost(url); + httpPost.setConfig(requestConfig); + if("json".equals(contentType)) + { + httpPost.addHeader("Content-Type", "application/json"); + httpPost.addHeader("Accept", "application/json"); + //httpPost.addHeader("Authorization", "Bearer "+SrmUtil.getToken()); + } + else + { + httpPost.addHeader("Content-Type", "application/x-www-form-urlencoded"); + } + StringEntity requestEntity = new StringEntity(content, "UTF-8"); + httpPost.setEntity(requestEntity); + httpResponse = httpClient.execute(httpPost, new BasicHttpContext()); + int code = httpResponse.getStatusLine().getStatusCode(); + resulrCode = String.valueOf(code); + if(code != HttpStatus.SC_OK){ + return resulrCode; + + } + HttpEntity entity = httpResponse.getEntity(); + if(entity != null) { + String resultStr = EntityUtils.toString(entity, "UTF-8"); + return resultStr; + } + } catch(Exception e) { + log.error("", e); + throw new Exception(e); + } finally { + if(httpResponse != null) { + try { + httpResponse.close(); + } catch(Exception e) { + log.error("", e); + throw new Exception(e); + } + } + if(httpPost != null) { + try { + httpPost.releaseConnection(); + } catch(Exception e) { + log.error("", e); + throw new Exception(e); + } + } + if(httpClient != null) { + try { + httpClient.close(); + } catch(Exception e) { + log.error("", e); + throw new Exception(e); + } + } + } + return resulrCode; + } + + public static String sendGet(String url) { + CloseableHttpClient httpClient = null; + HttpGet httpGet = null; + CloseableHttpResponse httpResponse = null; + try { + httpClient = HttpClients.createDefault(); + int CONNECTION_TIMEOUT = 10 * 1000; + RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(CONNECTION_TIMEOUT).setConnectTimeout(CONNECTION_TIMEOUT).setSocketTimeout(CONNECTION_TIMEOUT).build(); + httpGet = new HttpGet(url); + httpGet.setConfig(requestConfig); + httpGet.addHeader("Content-Type", "application/json"); + httpGet.addHeader("Accept", "application/json"); + httpResponse = httpClient.execute(httpGet, new BasicHttpContext()); + HttpEntity entity = httpResponse.getEntity(); + if(entity != null) { + String resultStr = EntityUtils.toString(entity, "UTF-8"); + //JSONObject result = JSONObject.parseObject(resultStr); + return resultStr; + } + } catch(Exception e) { + // log.error("", e); + } finally { + if(httpResponse != null) { + try { + httpResponse.close(); + } catch(Exception e) { + } + } + if(httpGet != null) { + try { + httpGet.releaseConnection(); + } catch(Exception e) { + } + } + if(httpClient != null) { + try { + httpClient.close(); + } catch(Exception e) { + } + } + } + return null; + } + + + public static String doPost(String url, Map param) { + // 鍒涘缓Httpclient瀵硅薄 + CloseableHttpClient httpClient = HttpClients.createDefault(); + CloseableHttpResponse response = null; + String resultString = ""; + try { + // 鍒涘缓Http Post璇锋眰 + HttpPost httpPost = new HttpPost(url); + // 鍒涘缓鍙傛暟鍒楄〃 + if (param != null) { + List paramList = new ArrayList(); + for (String key : param.keySet()) { + paramList.add(new BasicNameValuePair(key, param.get(key))); + } + // 妯℃嫙琛ㄥ崟 + UrlEncodedFormEntity entity = new UrlEncodedFormEntity(paramList,"utf-8"); + httpPost.setEntity(entity); + } + // 鎵цhttp璇锋眰 + response = httpClient.execute(httpPost); + resultString = EntityUtils.toString(response.getEntity(), "utf-8"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + response.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + return resultString; + } + +} diff --git a/src/com/kingdee/eas/custom/risheng/webservice/WSRishengHaiKangHRFacadeSrvProxy.java b/src/com/kingdee/eas/custom/risheng/webservice/WSRishengHaiKangHRFacadeSrvProxy.java new file mode 100644 index 0000000..8bdf35f --- /dev/null +++ b/src/com/kingdee/eas/custom/risheng/webservice/WSRishengHaiKangHRFacadeSrvProxy.java @@ -0,0 +1,88 @@ +package com.kingdee.eas.custom.risheng.webservice; + +import org.apache.axis.Message; + +import org.apache.axis.MessageContext; + +import org.apache.axis.message.SOAPEnvelope; + +import org.apache.axis.message.SOAPHeaderElement; + +import com.kingdee.bos.webservice.WSConfig; + +import com.kingdee.bos.webservice.WSInvokeException; +import com.kingdee.bos.dao.IObjectPK; +import com.kingdee.bos.dao.ObjectMultiPK; +import com.kingdee.bos.dao.ormapping.ObjectUuidPK; +import com.kingdee.bos.orm.core.ORMEngine; +import com.kingdee.bos.webservice.BeanConvertHelper; +import com.kingdee.bos.webservice.BOSTypeConvertor; +import com.kingdee.bos.util.BOSUuid; +import com.kingdee.bos.webservice.WSConfig; +import com.kingdee.bos.webservice.MetaDataHelper; +import com.kingdee.bos.BOSObjectFactory; + +public class WSRishengHaiKangHRFacadeSrvProxy { + + public String syncEmpLeavesRestore( String data ) throws WSInvokeException { + try { + return getController().syncEmpLeavesRestore( + data); + } + catch( Throwable e ) { + throw new WSInvokeException( e ) ; + } + } + + public String syncEmpLeaves( String data ) throws WSInvokeException { + try { + return getController().syncEmpLeaves( + data); + } + catch( Throwable e ) { + throw new WSInvokeException( e ) ; + } + } + + public String syncAdminOrg( String data ) throws WSInvokeException { + try { + return getController().syncAdminOrg( + data); + } + catch( Throwable e ) { + throw new WSInvokeException( e ) ; + } + } + + public String syncPerson( String data ) throws WSInvokeException { + try { + return getController().syncPerson( + data); + } + catch( Throwable e ) { + throw new WSInvokeException( e ) ; + } + } + + private com.kingdee.eas.custom.risheng.IRishengHaiKangHRFacade getController() { + try { + if (WSConfig.getRomoteLocate()!=null&&WSConfig.getRomoteLocate().equals("false")){ + Message message =MessageContext.getCurrentContext().getRequestMessage(); + SOAPEnvelope soap =message.getSOAPEnvelope(); + SOAPHeaderElement headerElement=soap.getHeaderByName(WSConfig.loginQName,WSConfig.loginSessionId); + String SessionId=headerElement.getValue(); + return ( com.kingdee.eas.custom.risheng.IRishengHaiKangHRFacade )BOSObjectFactory.createBOSObject( SessionId , "com.kingdee.eas.custom.risheng.RishengHaiKangHRFacade") ; + } else { + return ( com.kingdee.eas.custom.risheng.IRishengHaiKangHRFacade )BOSObjectFactory.createRemoteBOSObject( WSConfig.getSrvURL() , "com.kingdee.eas.custom.risheng.RishengHaiKangHRFacade" , com.kingdee.eas.custom.risheng.IRishengHaiKangHRFacade.class ) ; + } + } + catch( Throwable e ) { + return ( com.kingdee.eas.custom.risheng.IRishengHaiKangHRFacade )ORMEngine.createRemoteObject( WSConfig.getSrvURL() , "com.kingdee.eas.custom.risheng.RishengHaiKangHRFacade" , com.kingdee.eas.custom.risheng.IRishengHaiKangHRFacade.class ) ; + } + } + + private BeanConvertHelper getBeanConvertor() { + return new BeanConvertHelper(); + } + +} \ No newline at end of file diff --git a/src/com/kingdee/eas/custom/risheng/webservice/WSRishengInterfaceFacadeSrvProxy.java b/src/com/kingdee/eas/custom/risheng/webservice/WSRishengInterfaceFacadeSrvProxy.java new file mode 100644 index 0000000..aa27f38 --- /dev/null +++ b/src/com/kingdee/eas/custom/risheng/webservice/WSRishengInterfaceFacadeSrvProxy.java @@ -0,0 +1,98 @@ +package com.kingdee.eas.custom.risheng.webservice; + +import org.apache.axis.Message; + +import org.apache.axis.MessageContext; + +import org.apache.axis.message.SOAPEnvelope; + +import org.apache.axis.message.SOAPHeaderElement; + +import com.kingdee.bos.webservice.WSConfig; + +import com.kingdee.bos.webservice.WSInvokeException; +import com.kingdee.bos.dao.IObjectPK; +import com.kingdee.bos.dao.ObjectMultiPK; +import com.kingdee.bos.dao.ormapping.ObjectUuidPK; +import com.kingdee.bos.orm.core.ORMEngine; +import com.kingdee.bos.webservice.BeanConvertHelper; +import com.kingdee.bos.webservice.BOSTypeConvertor; +import com.kingdee.bos.util.BOSUuid; +import com.kingdee.bos.webservice.WSConfig; +import com.kingdee.bos.webservice.MetaDataHelper; +import com.kingdee.bos.BOSObjectFactory; + +public class WSRishengInterfaceFacadeSrvProxy { + + public String syncEmployeeInfo( String data ) throws WSInvokeException { + try { + return getController().syncEmployeeInfo( + data); + } + catch( Throwable e ) { + throw new WSInvokeException( e ) ; + } + } + + public String syncJoblevelInfo( String data ) throws WSInvokeException { + try { + return getController().syncJoblevelInfo( + data); + } + catch( Throwable e ) { + throw new WSInvokeException( e ) ; + } + } + + public String syncPositionInfo( String data ) throws WSInvokeException { + try { + return getController().syncPositionInfo( + data); + } + catch( Throwable e ) { + throw new WSInvokeException( e ) ; + } + } + + public String syncPersonPositionInfo( String data ) throws WSInvokeException { + try { + return getController().syncPersonPositionInfo( + data); + } + catch( Throwable e ) { + throw new WSInvokeException( e ) ; + } + } + + public String syncAdminOrgInfo( String data ) throws WSInvokeException { + try { + return getController().syncAdminOrgInfo( + data); + } + catch( Throwable e ) { + throw new WSInvokeException( e ) ; + } + } + + private com.kingdee.eas.custom.risheng.IRishengInterfaceFacade getController() { + try { + if (WSConfig.getRomoteLocate()!=null&&WSConfig.getRomoteLocate().equals("false")){ + Message message =MessageContext.getCurrentContext().getRequestMessage(); + SOAPEnvelope soap =message.getSOAPEnvelope(); + SOAPHeaderElement headerElement=soap.getHeaderByName(WSConfig.loginQName,WSConfig.loginSessionId); + String SessionId=headerElement.getValue(); + return ( com.kingdee.eas.custom.risheng.IRishengInterfaceFacade )BOSObjectFactory.createBOSObject( SessionId , "com.kingdee.eas.custom.risheng.RishengInterfaceFacade") ; + } else { + return ( com.kingdee.eas.custom.risheng.IRishengInterfaceFacade )BOSObjectFactory.createRemoteBOSObject( WSConfig.getSrvURL() , "com.kingdee.eas.custom.risheng.RishengInterfaceFacade" , com.kingdee.eas.custom.risheng.IRishengInterfaceFacade.class ) ; + } + } + catch( Throwable e ) { + return ( com.kingdee.eas.custom.risheng.IRishengInterfaceFacade )ORMEngine.createRemoteObject( WSConfig.getSrvURL() , "com.kingdee.eas.custom.risheng.RishengInterfaceFacade" , com.kingdee.eas.custom.risheng.IRishengInterfaceFacade.class ) ; + } + } + + private BeanConvertHelper getBeanConvertor() { + return new BeanConvertHelper(); + } + +} \ No newline at end of file diff --git a/src/com/kingdee/eas/custom/risheng/webservice/WSRishengPendingMessageFacadeSrvProxy.java b/src/com/kingdee/eas/custom/risheng/webservice/WSRishengPendingMessageFacadeSrvProxy.java new file mode 100644 index 0000000..6f2e6c3 --- /dev/null +++ b/src/com/kingdee/eas/custom/risheng/webservice/WSRishengPendingMessageFacadeSrvProxy.java @@ -0,0 +1,68 @@ +package com.kingdee.eas.custom.risheng.webservice; + +import org.apache.axis.Message; + +import org.apache.axis.MessageContext; + +import org.apache.axis.message.SOAPEnvelope; + +import org.apache.axis.message.SOAPHeaderElement; + +import com.kingdee.bos.webservice.WSConfig; + +import com.kingdee.bos.webservice.WSInvokeException; +import com.kingdee.bos.dao.IObjectPK; +import com.kingdee.bos.dao.ObjectMultiPK; +import com.kingdee.bos.dao.ormapping.ObjectUuidPK; +import com.kingdee.bos.orm.core.ORMEngine; +import com.kingdee.bos.webservice.BeanConvertHelper; +import com.kingdee.bos.webservice.BOSTypeConvertor; +import com.kingdee.bos.util.BOSUuid; +import com.kingdee.bos.webservice.WSConfig; +import com.kingdee.bos.webservice.MetaDataHelper; +import com.kingdee.bos.BOSObjectFactory; + +public class WSRishengPendingMessageFacadeSrvProxy { + + public String sendDoneMsg( String data ) throws WSInvokeException { + try { + return getController().sendDoneMsg( + data); + } + catch( Throwable e ) { + throw new WSInvokeException( e ) ; + } + } + + public String sendPendingMsg( String data ) throws WSInvokeException { + try { + return getController().sendPendingMsg( + data); + } + catch( Throwable e ) { + throw new WSInvokeException( e ) ; + } + } + + private com.kingdee.eas.custom.risheng.IRishengPendingMessageFacade getController() { + try { + if (WSConfig.getRomoteLocate()!=null&&WSConfig.getRomoteLocate().equals("false")){ + Message message =MessageContext.getCurrentContext().getRequestMessage(); + SOAPEnvelope soap =message.getSOAPEnvelope(); + SOAPHeaderElement headerElement=soap.getHeaderByName(WSConfig.loginQName,WSConfig.loginSessionId); + String SessionId=headerElement.getValue(); + return ( com.kingdee.eas.custom.risheng.IRishengPendingMessageFacade )BOSObjectFactory.createBOSObject( SessionId , "com.kingdee.eas.custom.risheng.RishengPendingMessageFacade") ; + } else { + return ( com.kingdee.eas.custom.risheng.IRishengPendingMessageFacade )BOSObjectFactory.createRemoteBOSObject( WSConfig.getSrvURL() , "com.kingdee.eas.custom.risheng.RishengPendingMessageFacade" , com.kingdee.eas.custom.risheng.IRishengPendingMessageFacade.class ) ; + } + } + catch( Throwable e ) { + return ( com.kingdee.eas.custom.risheng.IRishengPendingMessageFacade )ORMEngine.createRemoteObject( WSConfig.getSrvURL() , "com.kingdee.eas.custom.risheng.RishengPendingMessageFacade" , com.kingdee.eas.custom.risheng.IRishengPendingMessageFacade.class ) ; + } + } + + private BeanConvertHelper getBeanConvertor() { + return new BeanConvertHelper(); + } + +} \ No newline at end of file