2025-09-29
120次
東寶HR系統
一、背景描述:
在企業日常運營中,HR系統是員工信息、考勤、人事變動等核心數據的管理平臺;而泛微OA是企業內部流程審批、公文流轉、協同辦公的核心工具。
目前,OA已對接多套系統使用審批流程,例如費用采購流程、報銷、財務、金蝶等,而當前需上HR系統進行考勤異常、請假、加班、調休等審批時,存在以下痛點:
1、系統割裂:HR 系統中產生的考勤審批數據需在 OA 中重新提交,導致重復操作。
2、效率低下:員工或 HR 需要跨系統手動發起審批,流程繁瑣,易出錯。
3、審批不統一:部分審批走 HR 系統,部分走 OA,缺乏統一標準和歸檔。
4、數據不同步:HR 系統審批通過后,OA 無記錄,影響審計、合規與流程追溯。
5、領導審批負擔重:審批待辦分散在多個系統,難以集中處理。
為提升審批效率、實現流程統一、保障數據一致性,亟需將 HR 系統中的考勤審批業務數據自動同步推送至 OA 系統,并觸發 OA 的標準審批流程。
二、解決方案:
2.1分析思路
實現思路:實現 HR 系統與 OA 系統的深度集成,使 HR 系統中產生的考勤類審批單據自動推送至 OA并自動提交,并由 OA 完成后續審批流程,審批結果回寫 HR 系統。
流程集成方式:單向觸發
1、HR 系統作為數據源,生成審批單后,通過接口自動推送至 OA。
2、OA 系統接收后,自動生成審批流程,進入待辦。
3、審批完成后,OA 將審批結果(通過/駁回)回調 HR 系統,更新審核狀態。
2.2配置OA流程關系表
首先要建立DHG系統表單發起,需調用OA的哪個流程ID,在DHG系統上維護對應關系,并支持設置人員范圍,用于控制不同人員發起時,調用不同的OA流程進行審批。
這里需要建立自定義模塊來進行配置。


2.3字段數據確認
1、根據OA的審批表單,確認DHG中的相關字段的取值、數據類型等。

對應的OA中,為了能實現DHG系統發起表單后自動觸發OA流程提交,需要在DHG員工資料中維護OA員工ID、OA部門ID、OA公司ID。

2.4頁面二開
OA提交按鈕,不影響標準功能前提下,新增按鈕進行配置。

表單代碼二開
function submitOA(type) {
//OA用戶id:creatorId、OA流程id:workflowId、hr表名:tableCode
if (this.mainForm.emp_origin_id) {
if (this.$refs.empIdSelect.empList[0].c_OAuserid && this.$refs.empIdSelect.empList[0].c_OAorgid) {
this.mainForm.creatorId = Number(this.$refs.empIdSelect.empList[0].c_OAuserid);
this.mainForm.orgOAId = Number(this.$refs.empIdSelect.empList[0].c_OAorgid);
//this.mainForm.org_name = this.$refs.empIdSelect.empList[0].org_name;
} else {
JsUlits.showWarning("請到員工檔案維護該員工的OA員工id和OA部門id后重試!");
return;
}
}
//主表代碼:att_business_trip_order
var res = this.syncRunCode("empHaveOaFlowInfo", { curTemplateCode: this.curTemplateCode, empOriginId: this.mainForm.c_emp_origin_id });
if (res.length > 1) {
JsUlits.showWarning("該員工未查詢到OA流程信息,或者存在多筆匹配OA流程信息!");
return;
}
this.mainForm.begin_date_ymd = JsUlits.dateFormat(this.mainForm.begin_date, "yyyy-MM-dd");
this.mainForm.end_date_ymd = JsUlits.dateFormat(this.mainForm.end_date, "yyyy-MM-dd");
this.mainForm.emp_info = this.$refs.empChoose.empList[0];
this.mainForm.curTemplateCode = this.curTemplateCode;
this.mainForm.is_submit = true;
var value = this.mainForm.total_day;
var num = typeof value === 'number' ? value : parseFloat(value);
this.mainForm.total_day_fix = isNaN(num) ? "0.0" : num.toFixed(1);
this.mainForm.tableCode = this.tableCode;
this.mainForm.workflowId = res[0].c_oaflow_id;
if (!this.mainForm.audit_status || this.mainForm.audit_status == '0') {
this.mainForm.audit_status = '2';
}
this.saveLeaveOrderSelf(type);
}
function changeemphrdailiren(val) {
if (val && val.length > 0) {
this.mainForm.c_hrdailiren_name = val[0].name;
} else {
this.mainForm.c_hrdailiren_name = "";
}
}
/**
* 點擊[保存]或[提交]
*
* @param type {1|2|3} 1-保存新增;2-保存退出;3-提交
*/
function saveLeaveOrderSelf(type) {
var _that = this;
// 通用校驗數據
if (!_that.checkValid()) return;
// 判斷請假日期范圍是否存在未排班的日期
if (this.isNotSchedule) {
return _that.errMsgHandler(this.notScheduleMessage);
}
// 校驗:開始日期大于結束日期, 則提示錯誤
_that.checkDateComparePromise()
// 保存前處理數據
.then(this.handleDataBeforeSavePromise)
// 執行保存
.then(function () {
_that.execSaveReqPromiseSelf(type)
})
.catch(_that.errMsgHandler)
}
/**
* 執行保存
*/
function execSaveReqPromiseSelf(type) {
var _that = this
// huanglb 2021/07/26 新增保存或提交; 退回提交, 都需要進行單據檢查。
_that.reqCheckComplianceLeaveOrderPromise()
.then(
// handle resolve
function () {
_that.mainForm.audit_status = "2";
_that.saveQuit();
},
// handle reject
function (resultData) {
if (type) {
_that.mainForm.audit_status = "2";
_that.saveQuit();
return;
}
_that.handleExForm(_that, resultData, resultData.showConfirmButton);
}
)
}
function syncRunCode(code, param) {
var postData = {
codeType: 1,
templateId: this.curTemplateId,
code: code,
runParam: param
}
var result = null;
var url = window.ctxPath + '/sysObjectTool/runCode?curdate=' + new Date().getTime();
JsUlits.postSync(url, postData, function (res) {
result = res.data;
})
return result;
}
后臺代碼二開

var log = @org.slf4j.LoggerFactory.getLogger("");
var now = @com.dongbao.core.util.DateUtil.getDate();
var nowStr = @com.dongbao.core.util.DateUtil.format(now, "yyyy-MM-dd");
var tempFormData = formData.mainForm[0];
var isSuccess = "1";
var errorMsg = "";
var showParam = {};
if( tempFormData.is_self == '1'){
tempFormData = formData.mainForm[0].oa_main_form;
}
if(isEmpty(tempFormData.is_submit) && isEmpty(tempFormData.is_self) ){
return ;
}
if(isEmpty(tempFormData.code)){
//執行查詢返回列表
var codeInfoList = tool.selectSql("select code from " + tempFormData.tableCode + " where id = #{id}",{id:tempFormData.id},null,null);
if(codeInfoList.~size > 0){
tempFormData.code = codeInfoList[0].code;
}
}
if (tempFormData.audit_status + "" == '2' || tempFormData.audit_status + "" == '7')
{
//判斷必傳參數:
if (isEmpty(tempFormData.creatorId) || isEmpty(tempFormData.workflowId) || isEmpty(tempFormData.tableCode))
{
isSuccess = "0";
errorMsg = "檢查必填參數,OA用戶id:creatorId、OA流程id:workflowId、hr表名:tableCode,不能為空!";
}
var urlInfo = tool.selectSql("select url from third_platform_data_source where name = 'OA代辦推送服務地址'",
{}, null, null);
if (urlInfo.~size == 0 ) {
isSuccess = "0";
errorMsg = "數據源中未找到名稱為‘OA代辦推送服務地址’ 的數據源,請配置!";
}
if (isEmpty(tempFormData.total_day)) {
tempFormData.total_day = '0.0';
}
var hjts = tempFormData.total_day_fix + "";
if (tempFormData.end_time == "" || tempFormData.end_time == null) {
tempFormData.end_time = "23:59";
}
if (tempFormData.begin_time == "" || tempFormData.begin_time == null) {
tempFormData.begin_time = "00:00";
}
//開始附件操作
var thirdPlatformForeignControllerFile = @com.dongbao.core.util.SpringContextUtil.getBean('thirdPlatformForeignController');
var param11 = {
mainForm : tempFormData
};
var paramJson1 = @com.alibaba.fastjson.JSONObject.toJSONString(param11);
var info1 = @thirdPlatformForeignControllerFile.execBlockCode("getFileUrlCode", paramJson1);
//開始封裝附件:
var fileObj = {
key : "fujian", value : "", filedType : ""
};
if (info1.~size > 0)
{
for (var ii = 0 ; ii < info1.~size ; ii++ )
{
var item = info1[ii];
if (ii != 0)
{
fileObj.value = fileObj.value + "|" + info1[ii].fileUrl;
fileObj.filedType = fileObj.filedType + "|http:" + info1[ii].fileName;
}else {
fileObj.value = info1[ii].fileUrl;
fileObj.filedType = "http:" + info1[ii].fileName;
}
}
}
var param =
{
// 基本流程信息
"creatorId" : tempFormData.creatorId, // OA的用戶id (number類型)
"workflowId" : tempFormData.workflowId, // OA的流程id (string類型)
"isNextflow" : "0", // 是否自動提交下一流程 (string類型)
"requestName" : "請假申請單-" + tempFormData.code + "-" + tempFormData.emp_info.name + "-" + nowStr , // 流程標題 (string類型)
"endpointUrl" : urlInfo[0].url, // WebService地址
"tableCode" : tempFormData.tableCode, "requestId" : "", "type" : "submit", "submitRemark" : " ",
"id" : tempFormData.id, // 主表數據
"mainTableData" :
{
"title" : "請假申請單-" + tempFormData.code + "-" + tempFormData.emp_info.name + "-" + nowStr , // 流程標題
"sqr" : tempFormData.creatorId + "", // 申請人,用戶id
"sqbm": tempFormData.orgOAId + "", // 申請部門,不用傳值
"sqsj" : nowStr, // 申請日期,格式 YYYY-MM-DD
"hrdailiren" : tempFormData.c_hrdailiren_name,
// "lcbh": "", // 流程編號,不用傳值
// --- 業務單據字段 (屬于主表) ---
"hrgh" : tempFormData.emp_info.emp_no, // 請假人工號
"hrxm" : tempFormData.emp_info.name, // 請假人姓名
"lianluofangshi" : tempFormData.e