考勤功能优化:减少钉钉API调用次数
This commit is contained in:
@@ -270,7 +270,7 @@ public class DingdingService {
|
||||
List<Map<String,Object>> members = dingdingDao.getDingdingOaMember();
|
||||
|
||||
// 一次封装12人的考勤数据
|
||||
int groupSize = 5; // 每组的大小
|
||||
int groupSize = 10; // 每组的大小
|
||||
List<List<Map<String,Object>>> memberLists = new ArrayList<List<Map<String,Object>>>();
|
||||
for (int i = 0; i < members.size(); i += groupSize) {
|
||||
int endIndex = Math.min(i + groupSize, members.size());
|
||||
@@ -292,13 +292,15 @@ public class DingdingService {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.add(Calendar.DAY_OF_MONTH, -1);
|
||||
Date result = calendar.getTime();
|
||||
|
||||
int offset=0;
|
||||
boolean ishasmore;
|
||||
do {
|
||||
param.put("workDateFrom", sdf.format(result)+" 00:00:00");
|
||||
param.put("workDateTo", sdf.format(result)+" 23:59:59");
|
||||
// param.put("workDateFrom", "2024-01-15 00:00:00");
|
||||
// param.put("workDateTo", "2024-01-15 23:59:59");
|
||||
param.put("userIdList", dingdingmemberids);
|
||||
param.put("offset", 0);
|
||||
param.put("offset", offset);
|
||||
param.put("limit", 50);
|
||||
DingtalkUtil dingtalkUtil = new DingtalkUtil();
|
||||
// 根据人员ID获取考勤打卡信息
|
||||
@@ -308,6 +310,12 @@ public class DingdingService {
|
||||
log.info("考勤记录获取失败:"+ret);
|
||||
return null;
|
||||
}
|
||||
|
||||
ishasmore = ret.getBooleanValue("hasMore");
|
||||
if(ishasmore) {
|
||||
offset = offset+50;
|
||||
}
|
||||
|
||||
FormExportUtil formExportUtil = new FormExportUtil();
|
||||
// 调用转换方法
|
||||
List<Map<String, Object>> transformedData = formExportUtil.transformData(recordresult);
|
||||
@@ -447,6 +455,7 @@ public class DingdingService {
|
||||
getFormFactory().importBusinessFormData("hr", "CLOCKIN",
|
||||
formExport, new String[] {});
|
||||
}
|
||||
}while(ishasmore);
|
||||
}
|
||||
System.out.println("钉钉考勤原始数据创建完成");
|
||||
return null;
|
||||
@@ -457,7 +466,7 @@ public class DingdingService {
|
||||
List<Map<String,Object>> members = dingdingDao.getDingdingOaMember();
|
||||
|
||||
// 一次封装12人的考勤数据
|
||||
int groupSize = 5; // 每组的大小
|
||||
int groupSize = 10; // 每组的大小
|
||||
List<List<Map<String,Object>>> memberLists = new ArrayList<List<Map<String,Object>>>();
|
||||
for (int i = 0; i < members.size(); i += groupSize) {
|
||||
int endIndex = Math.min(i + groupSize, members.size());
|
||||
@@ -479,11 +488,13 @@ public class DingdingService {
|
||||
// Calendar calendar = Calendar.getInstance();
|
||||
// calendar.add(Calendar.DAY_OF_MONTH, -1);
|
||||
// Date result = calendar.getTime();
|
||||
|
||||
int offset=0;
|
||||
boolean ishasmore;
|
||||
do {
|
||||
param.put("workDateFrom", datestr+" 00:00:00");
|
||||
param.put("workDateTo", datestr+" 23:59:59");
|
||||
param.put("userIdList", dingdingmemberids);
|
||||
param.put("offset", 0);
|
||||
param.put("offset", offset);
|
||||
param.put("limit", 50);
|
||||
DingtalkUtil dingtalkUtil = new DingtalkUtil();
|
||||
// 根据人员ID获取考勤打卡信息
|
||||
@@ -493,6 +504,12 @@ public class DingdingService {
|
||||
log.info("考勤记录获取失败:"+ret);
|
||||
return "考勤记录获取失败:"+ret;
|
||||
}
|
||||
|
||||
ishasmore = ret.getBooleanValue("hasMore");
|
||||
if(ishasmore) {
|
||||
offset = offset+50;
|
||||
}
|
||||
|
||||
FormExportUtil formExportUtil = new FormExportUtil();
|
||||
// 调用转换方法
|
||||
List<Map<String, Object>> transformedData = formExportUtil.transformData(recordresult);
|
||||
@@ -632,6 +649,7 @@ public class DingdingService {
|
||||
getFormFactory().importBusinessFormData("hr", "CLOCKIN",
|
||||
formExport, new String[] {});
|
||||
}
|
||||
}while(ishasmore);
|
||||
}
|
||||
System.out.println(datestr+"钉钉考勤原始数据创建完成");
|
||||
return datestr+"钉钉考勤原始数据创建完成";
|
||||
|
||||
@@ -56,7 +56,7 @@ public class FormExportUtil {
|
||||
}
|
||||
subordinateFormExport.setValues(recordExports);
|
||||
subordinateFormExports.add(subordinateFormExport);
|
||||
|
||||
|
||||
return subordinateFormExports;
|
||||
}
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ public class FVService {
|
||||
Map mainmap12 = new HashMap();
|
||||
mainmap12.put("fieldName","balx");
|
||||
String type = formDataVo.getFieldData("备案类型").getStringValue();
|
||||
if("全国".equals(type)){
|
||||
if("全区域".equals(type)){
|
||||
mainmap12.put("fieldValue","3");
|
||||
}else if ("区域".equals(type)){
|
||||
mainmap12.put("fieldValue","1");
|
||||
@@ -224,7 +224,7 @@ public class FVService {
|
||||
Map mainmap11 = new HashMap();
|
||||
mainmap11.put("fieldName","balx");
|
||||
String type = formDataVo.getFieldData("备案类型").getStringValue();
|
||||
if("全国".equals(type)){
|
||||
if("全区域".equals(type)){
|
||||
mainmap11.put("fieldValue","3");
|
||||
}else if ("区域".equals(type)){
|
||||
mainmap11.put("fieldValue","2");
|
||||
|
||||
148
src/com/seeyon/apps/src_qyba/vo/FVTongyongbeianNode.java
Normal file
148
src/com/seeyon/apps/src_qyba/vo/FVTongyongbeianNode.java
Normal file
@@ -0,0 +1,148 @@
|
||||
package com.seeyon.apps.src_qyba.vo;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.seeyon.apps.common.config.ICstConfigApi;
|
||||
import com.seeyon.apps.common.plugin.vo.ConfigVo;
|
||||
import com.seeyon.apps.common.workflow.constants.WorkFlowType;
|
||||
import com.seeyon.apps.common.workflow.node.ACommonSuperNode;
|
||||
import com.seeyon.apps.ext.workflow.vo.FieldDataVo;
|
||||
import com.seeyon.apps.ext.workflow.vo.FormDataVo;
|
||||
import com.seeyon.apps.ext.workflow.vo.SuperNodeContext;
|
||||
import com.seeyon.apps.src_qyba.constants.FVConstants;
|
||||
import com.seeyon.apps.src_qyba.service.FVService;
|
||||
import com.seeyon.apps.src_qyba.util.FanWeiUtil;
|
||||
import com.seeyon.cap4.form.bean.FormDataMasterBean;
|
||||
import com.seeyon.ctp.common.AppContext;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import www.seeyon.com.utils.StringUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 功能描述:<br>
|
||||
* <pre>
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @Author: HuangZhengguo
|
||||
* @Date: 2024/2/27
|
||||
*/
|
||||
public abstract class FVTongyongbeianNode extends ACommonSuperNode {
|
||||
private final static Log log = LogFactory.getLog(FVTongyongbeianNode.class);
|
||||
protected ICstConfigApi cstConfigApi = (ICstConfigApi) AppContext.getBean("cstConfigApi");
|
||||
|
||||
@Autowired
|
||||
FVService fvService;
|
||||
|
||||
@Override
|
||||
public String getPluginId() {
|
||||
return FVConstants.getPluginId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFormParse() {
|
||||
return "json";
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorkFlowType[] getTypes() {
|
||||
return new WorkFlowType[] {WorkFlowType.superNode};
|
||||
}
|
||||
|
||||
public ConfigVo getFVConfig() {
|
||||
return cstConfigApi.getConfig(getPluginId());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SuperNodeContext proceed(String request, FormDataVo formDataVo, FormDataMasterBean formDataMasterBean) throws Exception {
|
||||
SuperNodeContext context = new SuperNodeContext();
|
||||
log.info("进入区域备案处理超级节点中");
|
||||
try {
|
||||
FieldDataVo fhjg = formDataVo.getFieldData("返回结果");
|
||||
String value = fhjg.getStringValue();
|
||||
if(value.startsWith("推送经销商平台成功")) {
|
||||
return context.success("跳过:" + value);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
context.setErrMsg("调用失败:"+e);
|
||||
context.setException(true);
|
||||
context.back("调用失败:"+e);
|
||||
}
|
||||
ConfigVo configVo = getFVConfig();
|
||||
context.setNeedSave(true);
|
||||
String url = "";
|
||||
// 进行新老接口分发
|
||||
FieldDataVo xttb = formDataVo.getFieldData("系统同步");
|
||||
String xttbvalue = xttb.getStringValue();
|
||||
String s = "";
|
||||
Map parm = new HashMap();
|
||||
if("CRM".equals(xttbvalue) || StringUtil.isEmpty(xttbvalue)){
|
||||
url = configVo.getParamVal(FVConstants.fvOldUrl.name());
|
||||
// 设置附件路径
|
||||
JSONArray filePath = fvService.getFilePath(formDataVo,configVo);
|
||||
// 参数封装
|
||||
parm = FVService.createWF(filePath,formDataVo,configVo);
|
||||
//调用新建接口
|
||||
String userid = formDataVo.getFieldData("经办人").getStringValue();
|
||||
s = FanWeiUtil.PostRestful(parm, userid,configVo);
|
||||
} if ("NCRM".equals(xttbvalue) || StringUtil.isEmpty(xttbvalue)){
|
||||
url = configVo.getParamVal(FVConstants.fvNewUrl.name());
|
||||
// 设置附件路径
|
||||
JSONArray filePath = fvService.getFilePath(formDataVo,configVo);
|
||||
//封装参数
|
||||
parm = FVService.createNewWF(filePath,formDataVo,configVo);
|
||||
//调用新建接口
|
||||
String userid = formDataVo.getFieldData("经办人").getStringValue();
|
||||
s = FanWeiUtil.NewPostRestful(parm, userid,configVo);
|
||||
}
|
||||
JSONObject returnMsg = JSONObject.parseObject(s);
|
||||
Object code = returnMsg.get("code");
|
||||
log.info("新建code:" + code);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
if ("SUCCESS".equals(code.toString())) {
|
||||
//调用提交接口
|
||||
map.put("code", "200");
|
||||
map.put("msg", "推送成功");
|
||||
map.put("request", parm.toString());
|
||||
map.put("response", s);
|
||||
} else {
|
||||
// Map data = (Map) returnMsg.get("errMsg");
|
||||
map.put("code", "300");
|
||||
map.put("msg", "新建流程失败!"+returnMsg.getString("msg"));
|
||||
map.put("request", parm.toString());
|
||||
map.put("response", s);
|
||||
}
|
||||
try{
|
||||
context.setRequest(map.get("request").toString());
|
||||
context.setResponse(map.get("response").toString());
|
||||
Object jsoncode = map.get("code");
|
||||
if ("200".equals(jsoncode.toString())) {
|
||||
context.success(map.get("msg").toString(), false);
|
||||
formDataVo.getNewFieldDataMap().put("返回结果",map.get("msg").toString());
|
||||
} else {
|
||||
context.setErrMsg(map.get("msg").toString());
|
||||
context.setException(true);
|
||||
context.back("推送失败:" +map.get("msg").toString());
|
||||
formDataVo.getNewFieldDataMap().put("返回结果","推送失败:"+map.get("msg").toString());
|
||||
}
|
||||
}catch (Exception e){
|
||||
context.setException(true);
|
||||
context.back("推送失败:OA处理异常:" + e.getMessage());
|
||||
formDataVo.getNewFieldDataMap().put("返回结果","推送失败:OA处理异常:"+map.get("msg").toString());
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
public abstract String getMethod();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user