|
@@ -1,12 +1,15 @@
|
|
|
package com.muzhi.shennongshi.service.impl;
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceResponse;
|
|
|
import com.aliyun.tea.TeaException;
|
|
|
import com.aliyun.teautil.models.RuntimeOptions;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.dingtalk.api.DefaultDingTalkClient;
|
|
|
import com.dingtalk.api.DingTalkClient;
|
|
|
import com.dingtalk.api.request.OapiSmartworkHrmEmployeeV2ListRequest;
|
|
@@ -15,6 +18,8 @@ import com.dingtalk.api.response.OapiSmartworkHrmEmployeeV2ListResponse;
|
|
|
import com.dingtalk.api.response.OapiSmartworkHrmEmployeeV2UpdateResponse;
|
|
|
import com.google.gson.JsonObject;
|
|
|
import com.muzhi.shennongshi.common.R;
|
|
|
+import com.muzhi.shennongshi.entity.DateShennongshi;
|
|
|
+import com.muzhi.shennongshi.mapper.DateShennongshiMapper;
|
|
|
import com.muzhi.shennongshi.service.AccessTokenService;
|
|
|
import com.muzhi.shennongshi.service.DingOaService;
|
|
|
import com.taobao.api.ApiException;
|
|
@@ -34,11 +39,15 @@ public class DingOaServiceImpl implements DingOaService {
|
|
|
@Autowired
|
|
|
private AccessTokenService accessTokenService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private DateShennongshiMapper dateShennongshiMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 表单打开时加载(原所属主体)
|
|
|
*/
|
|
|
@Override
|
|
|
public Map getSuoshuzhuti(String userid){
|
|
|
+// userid = "011033176057775267";
|
|
|
log.info("获取当前表单传参人员userid:" + userid);
|
|
|
|
|
|
//智能人事获取员工花名册信息,抓取【人员主体】字段信息
|
|
@@ -64,8 +73,8 @@ public class DingOaServiceImpl implements DingOaService {
|
|
|
String field_code = field_data_list.getJSONObject(i).getString("field_code");
|
|
|
// log.info("当前花名册字段field_code:" + field_code);
|
|
|
switch (field_code) {
|
|
|
- //人员主体
|
|
|
- case "3ee15b1a-3fda-46d5-ac4b-c11ea01e0c5c":
|
|
|
+ //人员主体:改为合同公司
|
|
|
+ case "sys05-contractCompanyName":
|
|
|
JSONArray field_value_list = field_data_list.getJSONObject(i).getJSONArray("field_value_list");
|
|
|
//人员主体内容
|
|
|
label = field_value_list.getJSONObject(0).getString("label");
|
|
@@ -93,74 +102,132 @@ public class DingOaServiceImpl implements DingOaService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 表单提交审批通过后反写智能人事花名册更新(所属主体)
|
|
|
+ * 提交审批单后将生效日期等信息写入数据库
|
|
|
*/
|
|
|
@Override
|
|
|
- public R updateSuoshuzhuti(String userid,String sszt){
|
|
|
+ public String dateToMySQL(String userid,String htgsid,String sxrq) throws Exception{
|
|
|
log.info("获取当前表单传参待更新人员userid:" + userid);
|
|
|
- log.info("获取当前表单传参待更新人员所属主体:" + sszt);
|
|
|
-
|
|
|
- String ssztid = null;
|
|
|
- if (sszt.equals("餐饮")){
|
|
|
- ssztid = "10001";
|
|
|
- }else if (sszt.equals("管理")){
|
|
|
- ssztid = "10002";
|
|
|
- }else if (sszt.equals("神唐")){
|
|
|
- ssztid = "10003";
|
|
|
- }else if (sszt.equals("五斗米")){
|
|
|
- ssztid = "10004";
|
|
|
- }
|
|
|
+ log.info("获取当前表单传参待更新人员合同公司id:" + htgsid);
|
|
|
+ log.info("获取当前表单传参待更新生效日期:" + sxrq);
|
|
|
+
|
|
|
+ Date date = new SimpleDateFormat("yyyy-MM-dd").parse(sxrq);
|
|
|
+
|
|
|
+ DateShennongshi dateShennongshi = new DateShennongshi();
|
|
|
+ dateShennongshi.setUserid(userid);
|
|
|
+ dateShennongshi.setHtgsid(htgsid);
|
|
|
+ dateShennongshi.setDate(date);
|
|
|
+ dateShennongshiMapper.insert(dateShennongshi);
|
|
|
+
|
|
|
+ return "生效日期同步数据库结束!";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 表单提交审批通过后反写智能人事花名册更新(所属主体)
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public R updateSuoshuzhuti() throws Exception{
|
|
|
+// log.info("获取当前表单传参待更新人员userid:" + userid);
|
|
|
+// log.info("获取当前表单传参待更新人员所属主体:" + sszt);
|
|
|
+
|
|
|
+// String ssztid = null;
|
|
|
+// if (sszt.equals("餐饮")){
|
|
|
+// ssztid = "10001";
|
|
|
+// }else if (sszt.equals("管理")){
|
|
|
+// ssztid = "10002";
|
|
|
+// }else if (sszt.equals("神唐")){
|
|
|
+// ssztid = "10003";
|
|
|
+// }else if (sszt.equals("五斗米")){
|
|
|
+// ssztid = "10004";
|
|
|
+// }
|
|
|
+
|
|
|
+ Date dateNow = new Date();
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(dateNow);
|
|
|
+ //当天
|
|
|
+ calendar.add(Calendar.DAY_OF_MONTH,0);
|
|
|
+ calendar.set(Calendar.HOUR_OF_DAY,0);
|
|
|
+ calendar.set(Calendar.MINUTE,0);
|
|
|
+ calendar.set(Calendar.SECOND,0);
|
|
|
+ calendar.set(Calendar.MILLISECOND,0);
|
|
|
+ String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime());
|
|
|
+ System.out.println("当天零点文本型:" + time);
|
|
|
+
|
|
|
+ Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(time);
|
|
|
+ System.out.println("当天零点时间型:" + date);
|
|
|
+
|
|
|
+ QueryWrapper<DateShennongshi> queryWrapper = new QueryWrapper<>();
|
|
|
+ List<DateShennongshi> dateShennongshiList = null;
|
|
|
|
|
|
- //更新智能人事员工花名册【人员主体】字段信息
|
|
|
- String body = null;
|
|
|
- String success = null;
|
|
|
- String errmsg = null;
|
|
|
try {
|
|
|
- DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/smartwork/hrm/employee/v2/update");
|
|
|
- OapiSmartworkHrmEmployeeV2UpdateRequest req = new OapiSmartworkHrmEmployeeV2UpdateRequest();
|
|
|
- req.setAgentid(2358039528L);
|
|
|
- OapiSmartworkHrmEmployeeV2UpdateRequest.EmpUpdateByCustomParam obj1 = new OapiSmartworkHrmEmployeeV2UpdateRequest.EmpUpdateByCustomParam();
|
|
|
- List<OapiSmartworkHrmEmployeeV2UpdateRequest.EmpGroupFieldVo> list3 = new ArrayList<OapiSmartworkHrmEmployeeV2UpdateRequest.EmpGroupFieldVo>();
|
|
|
- OapiSmartworkHrmEmployeeV2UpdateRequest.EmpGroupFieldVo obj4 = new OapiSmartworkHrmEmployeeV2UpdateRequest.EmpGroupFieldVo();
|
|
|
- list3.add(obj4);
|
|
|
- List<OapiSmartworkHrmEmployeeV2UpdateRequest.EmpListFieldVo> list7 = new ArrayList<OapiSmartworkHrmEmployeeV2UpdateRequest.EmpListFieldVo>();
|
|
|
- OapiSmartworkHrmEmployeeV2UpdateRequest.EmpListFieldVo obj8 = new OapiSmartworkHrmEmployeeV2UpdateRequest.EmpListFieldVo();
|
|
|
- list7.add(obj8);
|
|
|
- List<OapiSmartworkHrmEmployeeV2UpdateRequest.EmpFieldVo> list11 = new ArrayList<OapiSmartworkHrmEmployeeV2UpdateRequest.EmpFieldVo>();
|
|
|
- OapiSmartworkHrmEmployeeV2UpdateRequest.EmpFieldVo obj12 = new OapiSmartworkHrmEmployeeV2UpdateRequest.EmpFieldVo();
|
|
|
- list11.add(obj12);
|
|
|
- //智能人事花名册中【人员主体】字段编号
|
|
|
- obj12.setFieldCode("3ee15b1a-3fda-46d5-ac4b-c11ea01e0c5c");
|
|
|
- //更新内容编号
|
|
|
- obj12.setValue(ssztid);
|
|
|
- obj8.setSection(list11);
|
|
|
- //TODO 智能人事花名册中【人员主体】数组下标
|
|
|
- obj8.setOldIndex(30L);
|
|
|
- obj4.setSections(list7);
|
|
|
- //字段分组编号
|
|
|
- obj4.setGroupId("sys01");
|
|
|
- obj1.setGroups(list3);
|
|
|
- //更新人员的userid
|
|
|
- obj1.setUserid(userid);
|
|
|
- req.setParam(obj1);
|
|
|
- OapiSmartworkHrmEmployeeV2UpdateResponse rsp = client.execute(req, accessTokenService.getAccessToken());
|
|
|
- body = rsp.getBody();
|
|
|
- System.out.println(body);
|
|
|
- JSONObject jsonObject = JSON.parseObject(body);
|
|
|
- success = jsonObject.getString("success");
|
|
|
- log.info("钉钉智能人事更新员工花名册字段返回结果标识:" + success);
|
|
|
- errmsg = jsonObject.getString("errmsg");
|
|
|
- log.info("钉钉智能人事更新员工花名册字段返回结果信息:" + errmsg);
|
|
|
- } catch (ApiException e) {
|
|
|
+ queryWrapper.eq("date", date);
|
|
|
+
|
|
|
+ dateShennongshiList = dateShennongshiMapper.selectList(queryWrapper);
|
|
|
+ }catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
+ System.out.println("同步记录数据表【生效时间=当前日期】总数:" + dateShennongshiList.size());
|
|
|
+ System.out.println("同步记录数据表【生效时间=当前日期】:" + dateShennongshiList);
|
|
|
+
|
|
|
+ if (dateShennongshiList != null) {
|
|
|
+ for (int i = 0; i < dateShennongshiList.size(); i++) {
|
|
|
+ //更新智能人事员工花名册【人员主体:改为合同公司】字段信息
|
|
|
+ String ssztid = dateShennongshiList.get(i).getHtgsid();
|
|
|
+ System.out.println("循环获取数据库符合条件的合同公司id值:" + ssztid);
|
|
|
+ String userid = dateShennongshiList.get(i).getUserid();
|
|
|
+ System.out.println("循环获取数据库符合条件的人员userid值:" + userid);
|
|
|
+
|
|
|
+ String success = null;
|
|
|
+ String errmsg = null;
|
|
|
+
|
|
|
+ try {
|
|
|
+ DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/smartwork/hrm/employee/v2/update");
|
|
|
+ OapiSmartworkHrmEmployeeV2UpdateRequest req = new OapiSmartworkHrmEmployeeV2UpdateRequest();
|
|
|
+ req.setAgentid(2358039528L);
|
|
|
+ OapiSmartworkHrmEmployeeV2UpdateRequest.EmpUpdateByCustomParam obj1 = new OapiSmartworkHrmEmployeeV2UpdateRequest.EmpUpdateByCustomParam();
|
|
|
+ List<OapiSmartworkHrmEmployeeV2UpdateRequest.EmpGroupFieldVo> list3 = new ArrayList<OapiSmartworkHrmEmployeeV2UpdateRequest.EmpGroupFieldVo>();
|
|
|
+ OapiSmartworkHrmEmployeeV2UpdateRequest.EmpGroupFieldVo obj4 = new OapiSmartworkHrmEmployeeV2UpdateRequest.EmpGroupFieldVo();
|
|
|
+ list3.add(obj4);
|
|
|
+ List<OapiSmartworkHrmEmployeeV2UpdateRequest.EmpListFieldVo> list7 = new ArrayList<OapiSmartworkHrmEmployeeV2UpdateRequest.EmpListFieldVo>();
|
|
|
+ OapiSmartworkHrmEmployeeV2UpdateRequest.EmpListFieldVo obj8 = new OapiSmartworkHrmEmployeeV2UpdateRequest.EmpListFieldVo();
|
|
|
+ list7.add(obj8);
|
|
|
+ List<OapiSmartworkHrmEmployeeV2UpdateRequest.EmpFieldVo> list11 = new ArrayList<OapiSmartworkHrmEmployeeV2UpdateRequest.EmpFieldVo>();
|
|
|
+ OapiSmartworkHrmEmployeeV2UpdateRequest.EmpFieldVo obj12 = new OapiSmartworkHrmEmployeeV2UpdateRequest.EmpFieldVo();
|
|
|
+ list11.add(obj12);
|
|
|
+ //智能人事花名册中【人员主体:改为合同公司】字段编号
|
|
|
+ obj12.setFieldCode("sys05-contractCompanyName");
|
|
|
+ //更新内容编号
|
|
|
+ obj12.setValue(ssztid);
|
|
|
+ obj8.setSection(list11);
|
|
|
+ //TODO 智能人事花名册中【人员主体:改为合同公司】数组下标,不能随意更改花名册该字段!!!
|
|
|
+ obj8.setOldIndex(25L);
|
|
|
+ obj4.setSections(list7);
|
|
|
+ //字段分组编号
|
|
|
+ obj4.setGroupId("sys05");
|
|
|
+ obj1.setGroups(list3);
|
|
|
+ //更新人员的userid
|
|
|
+ obj1.setUserid(userid);
|
|
|
+ req.setParam(obj1);
|
|
|
+ OapiSmartworkHrmEmployeeV2UpdateResponse rsp = client.execute(req, accessTokenService.getAccessToken());
|
|
|
+ String body = rsp.getBody();
|
|
|
+ System.out.println(body);
|
|
|
+ JSONObject jsonObject = JSON.parseObject(body);
|
|
|
+ success = jsonObject.getString("success");
|
|
|
+ log.info("钉钉智能人事更新员工花名册字段返回结果标识:" + success);
|
|
|
+ errmsg = jsonObject.getString("errmsg");
|
|
|
+ log.info("钉钉智能人事更新员工花名册字段返回结果信息:" + errmsg);
|
|
|
+ } catch (ApiException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
//封装返回信息
|
|
|
- if (success.equals("true")){
|
|
|
- return R.ok().message(errmsg);
|
|
|
- }else {
|
|
|
- return R.error().message(errmsg);
|
|
|
- }
|
|
|
+// if (success.equals("true")){
|
|
|
+// return R.ok().message(errmsg);
|
|
|
+// }else {
|
|
|
+// return R.error().message(errmsg);
|
|
|
+// }
|
|
|
+ return R.ok().message("本次定时刷新生效日期,任务执行结束!");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -212,7 +279,7 @@ public class DingOaServiceImpl implements DingOaService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 表单提交时校验
|
|
|
+ * 表单提交时校验(加班)
|
|
|
* @param rylx(连接器传参人员类型)
|
|
|
* @param jbbcfs(连接器传参加班补偿方式)
|
|
|
* @return
|
|
@@ -310,7 +377,7 @@ public class DingOaServiceImpl implements DingOaService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 请假审批表单提交后反校验是否提交单据内容是否符合规则,不符合执行撤销审批实例
|
|
|
+ * 请假审批表单提交后会校验提交单据内容是否符合规则,不符合执行撤销审批实例
|
|
|
*/
|
|
|
@Async
|
|
|
@Override
|
|
@@ -444,9 +511,42 @@ public class DingOaServiceImpl implements DingOaService {
|
|
|
}
|
|
|
}
|
|
|
return R.error().message("当前人员属于【退休返聘】,不能提交年假,将发起审批撤回!");
|
|
|
- }else {
|
|
|
+ }else {//else if TODO【继续写其他条件判断】
|
|
|
return R.ok().message("正常通过提交...");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ /**l
|
|
|
+ * 表单提交时校验(部门)
|
|
|
+ * @param bmid(连接器传参部门id)
|
|
|
+// * @param jbbcfs(连接器传参加班补偿方式)
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+
|
|
|
+// @Override
|
|
|
+// public Map getBMJY(String bmid){
|
|
|
+// System.out.println("连接器传参部门id:" + bmid);
|
|
|
+//// System.out.println("连接器传参加班补偿方式:" + jbbcfs);
|
|
|
+//
|
|
|
+// Boolean zhi = null;
|
|
|
+//
|
|
|
+// if (rylx.equals("领导")){
|
|
|
+// if (jbbcfs.equals("转调休")){
|
|
|
+// zhi = true;
|
|
|
+// }else {
|
|
|
+// zhi = false;
|
|
|
+// }
|
|
|
+// }else {
|
|
|
+// zhi = true;
|
|
|
+// }
|
|
|
+//
|
|
|
+// System.out.println("校验结果:" + zhi);
|
|
|
+//
|
|
|
+// Map map = new HashMap();
|
|
|
+// map.put("jiaoyanjieguo", zhi);
|
|
|
+// map.put("jiaoyanxinxi","【领导】人员,不允许选择加班费,请重新选择!");
|
|
|
+//
|
|
|
+// return map;
|
|
|
+// }
|
|
|
}
|