Pro-Java search_read接口
POST #{papi_url}/ersoft-core-hr/spi/integration/search
var reqBody = {
"model": "x_builder_xxx",
"domain": [["code", "=", "code"]],
"fields": [
"id",
"name",
"write_date"
],
"pager": 1,
"size": 10,
"order": "",
"context": {"lang": "zh_CN"}
}
var respJson = httpPost(getProperty("post_url"), reqBody)
var isSuccess = respJson.code == 0 && respJson.data && respJson.data.data && respJson.data.data.length
if (isSuccess) {
// 其他操作
}
isSuccess
? putToRel("SuccessRel", respJson)
: putToRel("failure", {"msg": context.getName() + "失败", "data": {"reqBody": reqBody, "respJson": respJson}})
Pro-Python search_read接口
POST #{papi_url}/papi/nal/integration/model/search_read
var reqBody = {
"model": "x_builder_xxx",
"domain": [["code", "=", "code"]],
"fields": [
"id",
"name",
"write_date"
],
"offset": 0,
"limit": 1,
"order": "",
"context": {
"lang": "zh_CN"
}
}
var respJson = httpPost(getProperty("post_url"), reqBody)
var isSuccess = respJson.code == 0 && respJson.data && respJson.data.data && respJson.data.data.length
if (isSuccess) {
// 其他操作
}
isSuccess
? putToRel("SuccessRel", respJson)
: putToRel("failure", {"msg": context.getName() + "失败", "data": {"reqBody": reqBody, "respJson": respJson}})
Pro-Java upsert接口
POST #{papi_url}/ersoft-core-hr/spi/integration/upsert
var reqBody = {
"model": "x_builder_xxx",
"values": [{
"id": getAttr("x_id"),
"x_status": "1"
}],
"uniqueField": "id",
"mode": "standard",
"context": {"lang": "zh_CN"}
}
var respJson = httpPost(getProperty("post_url"), reqBody)
var isSuccess = respJson.code == 0
isSuccess
? putToRel("SuccessRel", event)
: putToRel("failure", {"msg": context.getName() + "失败", "data": {"reqBody": reqBody, "respJson": respJson}})
Pro-Python upsert接口
POST #{papi_url}/papi/nal/integration/model/upsert
var reqBody = {
"model": "x_builder_xxx",
"values": [{
"id": getAttr("x_id"),
"x_status": "1"
}],
"unique_field": "id",
"standard_mode": true,
"context": {"lang": "zh_CN"}
}
var respJson = httpPost(getProperty("post_url"), reqBody)
isSuccess = respJson.code == 0
isSuccess
? putToRel("SuccessRel", event)
: putToRel("failure", {"msg": context.getName() + "失败", "data": {"reqBody": reqBody, "respJson": respJson}})
Pro-Python-批量打卡接口
var post_url = '#{papi_url}/papi/nal/attendance/data/batch_clock'
var reqBody = {
"vals": event.datas.map(function(item) {
return {
"employee_id": item.employee_id, // 员工id
"name": item.eventTime // 打卡时间,格式:yyyy-MM-dd hh:mm:ss
}
}).filter(function(item) {
return item.employee_id
}),
"context": {"lang": "zh_CN"}
}
Pro-Java-批量打卡接口
#{ersoft_kratos_url}/ersoft-kratos/spi/attendance/punchSource/batchPunch
var reqBody = event.data.map(function(item) {
return {
"employeeNumber": item.employee_number, // 员工工号
"punchDatetime": item.punchdatetime,// 打卡时间,格式:yyyy-MM-dd hh:mm:ss
"userDevice": item.userdevice, // 设备标识
"deviceCode": item.devicecode, // 设备编码,规则设置/高级设置/设备管理
//"punchCategoryCode": "" // 打卡类型编码,实施助手/系统配置/打卡类型,不填存默认设备编码(PPCD000001),但是不能传空
}
})
var respJson = httpPost(getProperty("post_url"), reqBody)
var isSuccess = respJson.code == 0 && respJson.data.total == respJson.data.success
if (isSuccess) {
// 其他操作
}
isSuccess
? putToRel("SuccessRel", respJson)
: putToRel("failure", {"msg": context.getName() + "失败", "data": {"reqBody": reqBody, "respJson": respJson}})
Java-报表查询接口
POST #{ersoft_basic_url}/report/api/dataByWidget
var reqBody = {
"lang": "zh_CN",
"paging": { "pageNo": 1, "pageSize": 3000 },
"filters": [{
"columnName": "X_BATCH_CODE",
"filterType": "=",
"values": [getAttr("x_batch_code")]
}, {
"columnName": "X_PAYROLL_PERIOD",
"filterType": "=",
"values": [getAttr("x_payroll_period")]
}],
"widgetId": getProperty("widgetId")
}
var fieldsMapping = {
"employee_no": "employee_number",
"plan_name": "plan_name",
"部门名称": "department_name",
"状态": "state"
}
var respJson = httpPost(getProperty("post_url"), reqBody, {"header": {"user-id": 1}})
var isSuccess = respJson.data && respJson.data.length
if (isSuccess) {
respJson.data = respJson.data.map(function(item) {
var newItem = {}
for(index in item) {
var field = respJson.columnIndexList[index].name.toLowerCase()
if (fieldsMapping[field] === undefined) continue // 可以去掉此行,原样输出
newItem[field] = item[index] === "null" ? null : item[index]
}
return newItem
})
}