|
|
@@ -1,18 +1,14 @@
|
|
|
package com.malk.jiuyousimu.service.Impl;
|
|
|
+import com.malk.jiuyousimu.entity.FNumber;
|
|
|
|
|
|
-import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.google.gson.Gson;
|
|
|
-import com.kingdee.bos.webapi.entity.IdentifyInfo;
|
|
|
import com.kingdee.bos.webapi.entity.RepoRet;
|
|
|
import com.kingdee.bos.webapi.sdk.K3CloudApi;
|
|
|
-import com.malk.jiuyousimu.config.KDWebApiConf;
|
|
|
import com.malk.jiuyousimu.entity.*;
|
|
|
-import com.malk.jiuyousimu.service.DingTalkService;
|
|
|
import com.malk.jiuyousimu.service.DeptService;
|
|
|
+import com.malk.jiuyousimu.service.KingDeeService;
|
|
|
import com.malk.server.common.McR;
|
|
|
-import com.malk.service.aliwork.YDClient;
|
|
|
-import com.malk.service.aliwork.YDService;
|
|
|
import com.malk.service.dingtalk.*;
|
|
|
import com.malk.utils.UtilMap;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -21,10 +17,8 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
-import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
-import java.util.concurrent.ConcurrentHashMap;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static org.aspectj.bridge.MessageUtil.fail;
|
|
|
@@ -51,80 +45,12 @@ public class DeptServiceImpl implements DeptService {
|
|
|
private Long agentId;
|
|
|
|
|
|
@Autowired
|
|
|
- DingTalkService dingTalkService;
|
|
|
+ KingDeeService kingDeeService;
|
|
|
@Autowired
|
|
|
DDService ddService;
|
|
|
- @Autowired
|
|
|
- private YDClient ydClient;
|
|
|
- @Autowired
|
|
|
- private YDService ydService;
|
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
|
- private static final String API_TOKEN = "/corpAccessToken/get/V2";
|
|
|
- private static final String POST_GET_USER = "/user/getByMobile";
|
|
|
- private static final String POST_DATA_UPDATE = "/crm/custom/v2/data/update";
|
|
|
- private static final String TABLE_PRODUCT_FIELID = "TableField_BEUZFS0B8R40";
|
|
|
- private static final String TABLE_CELLLINES_FIELID = "TableField_M04O3XGALA80";
|
|
|
- private static String CROPID = "";
|
|
|
- private ConcurrentHashMap<String, LocalDateTime> formInstanceIdStore = new ConcurrentHashMap<>();
|
|
|
-
|
|
|
- //所有的人员控件枚举
|
|
|
- private static final Map<String, String> EMPLOYEE_ENUM = new HashMap<>();
|
|
|
-
|
|
|
- static {
|
|
|
- EMPLOYEE_ENUM.put("下属公司","employeeField_mji9tann");
|
|
|
- EMPLOYEE_ENUM.put("一线部门","employeeField_mji9tany");
|
|
|
- EMPLOYEE_ENUM.put("室","employeeField_mji9tao9");
|
|
|
- EMPLOYEE_ENUM.put("班组","employeeField_mjiac7gr");
|
|
|
- }
|
|
|
- //运行控制子表枚举
|
|
|
- private static final Map<String, String> OPERATION_CONTROL = new HashMap<>();
|
|
|
-
|
|
|
- static {
|
|
|
- OPERATION_CONTROL.put("投资公司","tableField_mjavj2r6");
|
|
|
- OPERATION_CONTROL.put("下属公司","tableField_mji9tanq");
|
|
|
- OPERATION_CONTROL.put("一线部门","tableField_mji9tao1");
|
|
|
- OPERATION_CONTROL.put("室","tableField_mji9taoc");
|
|
|
- }
|
|
|
- //安全生产子表枚举
|
|
|
- private static final Map<String, String> WORK_SAFETY = new HashMap<>();
|
|
|
-
|
|
|
- static {
|
|
|
- WORK_SAFETY.put("投资公司","tableField_mjgiipn0");
|
|
|
-// WORK_SAFETY.put("下属公司","tableField_mji9tant");
|
|
|
-// WORK_SAFETY.put("一线部门","tableField_mji9tao4");
|
|
|
-// WORK_SAFETY.put("室","tableField_mji9taof");
|
|
|
- }
|
|
|
- //质量控制子表枚举
|
|
|
- private static final Map<String, String> QUALITY_CONTROL = new HashMap<>();
|
|
|
-
|
|
|
- static {
|
|
|
- QUALITY_CONTROL.put("投资公司","tableField_mjgiipn4");
|
|
|
-// QUALITY_CONTROL.put("下属公司","tableField_mji9tanw");
|
|
|
-// QUALITY_CONTROL.put("一线部门","tableField_mji9tao7");
|
|
|
-// QUALITY_CONTROL.put("室","tableField_mji9taoi");
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void testToken() {
|
|
|
-// approveUpdateCRM(processInstanceId,"DXCPXS","审批拒绝", isAgree);
|
|
|
- }
|
|
|
- public String getNumberByUserId(String workingEmployeeIds) {
|
|
|
-// log.info("根据钉钉人员id获取员工工号:{}",workingEmployeeIds);
|
|
|
- List<String> filterList = new ArrayList<>();
|
|
|
- filterList.add("sys00-jobNumber");
|
|
|
- List<Map> employeeInfos = ddClientPersonnel.getEmployeeInfos(ddClient.getAccessToken(), Arrays.asList(workingEmployeeIds), agentId, filterList);
|
|
|
- final String[] value = {""};
|
|
|
- employeeInfos.forEach(e -> {
|
|
|
- List<Map> mapList = (List<Map>) e.get("field_data_list");
|
|
|
- mapList.forEach(m -> {
|
|
|
- List<Map> valueList = (List<Map>) m.get("field_value_list");
|
|
|
- value[0] = ObjectUtil.isNotNull(valueList.get(0).get("value")) ? valueList.get(0).get("value").toString() : null;
|
|
|
- });
|
|
|
- });
|
|
|
- return value[0];
|
|
|
- }
|
|
|
@Override
|
|
|
public McR deptCreate(Map deptInfo) {
|
|
|
log.info("开始创建金蝶部门,参数:{}",deptInfo);
|
|
|
@@ -143,7 +69,7 @@ public class DeptServiceImpl implements DeptService {
|
|
|
save.setModel(dept);
|
|
|
|
|
|
try{
|
|
|
- K3CloudApi client = new K3CloudApi(initIden());
|
|
|
+ K3CloudApi client = new K3CloudApi(kingDeeService.initIden());
|
|
|
//业务对象标识
|
|
|
String formId = "BD_Department";
|
|
|
//调用接口
|
|
|
@@ -153,7 +79,7 @@ public class DeptServiceImpl implements DeptService {
|
|
|
//对返回结果进行解析和校验
|
|
|
RepoRet repoRet = gson.fromJson(resultJson, RepoRet.class);
|
|
|
|
|
|
- if (isTrue(repoRet)){
|
|
|
+ if (kingDeeService.isTrue(repoRet)){
|
|
|
String id = repoRet.getResult().getId();
|
|
|
|
|
|
Submit submit = new Submit();
|
|
|
@@ -161,7 +87,7 @@ public class DeptServiceImpl implements DeptService {
|
|
|
//提交
|
|
|
String resultJson2 = client.submit(formId, JSONObject.toJSONString(submit));
|
|
|
RepoRet repoRet2 = gson.fromJson(resultJson2, RepoRet.class);
|
|
|
- isTrue(repoRet2);
|
|
|
+ kingDeeService.isTrue(repoRet2);
|
|
|
|
|
|
// String orderCode = repoRet2.getResult().getResponseStatus().getSuccessEntitys().get(0).getNumber();
|
|
|
|
|
|
@@ -170,13 +96,15 @@ public class DeptServiceImpl implements DeptService {
|
|
|
// .updateFormDataJson(JSONObject.toJSONString(UtilMap.map("textField_m6yntxmz",orderCode)))
|
|
|
// .build(), YDConf.FORM_OPERATION.update);
|
|
|
|
|
|
- if (isTrue(repoRet2)){
|
|
|
+ if (kingDeeService.isTrue(repoRet2)){
|
|
|
Audit audit = new Audit();
|
|
|
audit.setIds(id);
|
|
|
//审核
|
|
|
String resultJson3 = client.audit(formId,JSONObject.toJSONString(audit));
|
|
|
RepoRet repoRet3 = gson.fromJson(resultJson3, RepoRet.class);
|
|
|
- isTrue(repoRet3);
|
|
|
+ if (kingDeeService.isTrue(repoRet3)){
|
|
|
+ positionCreate(UtilMap.getString(deptInfo,"dept_id"));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
@@ -205,14 +133,14 @@ public class DeptServiceImpl implements DeptService {
|
|
|
|
|
|
|
|
|
try{
|
|
|
- K3CloudApi client = new K3CloudApi(initIden());
|
|
|
+ K3CloudApi client = new K3CloudApi(kingDeeService.initIden());
|
|
|
//业务对象标识
|
|
|
String formId = "BD_Department";
|
|
|
//调用接口
|
|
|
Gson gson = new Gson();
|
|
|
String resultUnAuditJson = client.unAudit(formId,JSONObject.toJSONString(dept));
|
|
|
RepoRet repoRetAudit = gson.fromJson(resultUnAuditJson, RepoRet.class);
|
|
|
- if (isTrue(repoRetAudit)){
|
|
|
+ if (kingDeeService.isTrue(repoRetAudit)){
|
|
|
log.info("本次反审核成功部门id:{}",numberIds);
|
|
|
}else {
|
|
|
log.info("本次反审核出错部门id:{}",numberIds);
|
|
|
@@ -222,7 +150,7 @@ public class DeptServiceImpl implements DeptService {
|
|
|
//对返回结果进行解析和校验
|
|
|
RepoRet repoRetDelete = gson.fromJson(resultDeleteJson, RepoRet.class);
|
|
|
|
|
|
- if (isTrue(repoRetDelete)){
|
|
|
+ if (kingDeeService.isTrue(repoRetDelete)){
|
|
|
log.info("本次删除成功部门id:{}",numberIds);
|
|
|
}else {
|
|
|
log.info("本次删除出错部门id:{}",numberIds);
|
|
|
@@ -234,31 +162,64 @@ public class DeptServiceImpl implements DeptService {
|
|
|
return McR.success();
|
|
|
}
|
|
|
|
|
|
- private boolean isTrue(RepoRet repoRet){
|
|
|
- Gson gson = new Gson();
|
|
|
+ @Override
|
|
|
+ public McR positionCreate(String deptId) {
|
|
|
+ log.info("开始创建金蝶部门下默认岗位信息,参数:{}",deptId);
|
|
|
+ LocalDate today = LocalDate.now();
|
|
|
+ String dateStr = today.format(formatter);
|
|
|
+ Save save = new Save();
|
|
|
+
|
|
|
+ Position position = new Position();
|
|
|
+ position.setFName("默认");
|
|
|
+ position.setFNumber(deptId+"01");
|
|
|
+ position.setFDept(deptId);
|
|
|
+ position.setFCreateOrgId(new FNumber("100"));
|
|
|
+ position.setFUseOrgId(new FNumber("100"));
|
|
|
+ position.setFEffectDate(dateStr);
|
|
|
+ position.setFEffectDate("2226-03-12");
|
|
|
+ save.setModel(position);
|
|
|
+
|
|
|
+ try{
|
|
|
+ K3CloudApi client = new K3CloudApi(kingDeeService.initIden());
|
|
|
+ //业务对象标识
|
|
|
+ String formId = "BD_Department";
|
|
|
+ //调用接口
|
|
|
+ String resultJson = client.save(formId,JSONObject.toJSONString(save));
|
|
|
+ //用于记录结果
|
|
|
+ Gson gson = new Gson();
|
|
|
+ //对返回结果进行解析和校验
|
|
|
+ RepoRet repoRet = gson.fromJson(resultJson, RepoRet.class);
|
|
|
+
|
|
|
+ if (kingDeeService.isTrue(repoRet)){
|
|
|
+ String id = repoRet.getResult().getId();
|
|
|
|
|
|
- if (repoRet.getResult().getResponseStatus().isIsSuccess()) {
|
|
|
- System.out.printf("接口返回结果: %s%n", gson.toJson(repoRet.getResult()));
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- fail("接口返回结果: " + gson.toJson(repoRet.getResult().getResponseStatus()));
|
|
|
- return false;
|
|
|
+ Submit submit = new Submit();
|
|
|
+ submit.setIds(id);
|
|
|
+ //提交
|
|
|
+ String resultJson2 = client.submit(formId, JSONObject.toJSONString(submit));
|
|
|
+ RepoRet repoRet2 = gson.fromJson(resultJson2, RepoRet.class);
|
|
|
+ kingDeeService.isTrue(repoRet2);
|
|
|
+
|
|
|
+// String orderCode = repoRet2.getResult().getResponseStatus().getSuccessEntitys().get(0).getNumber();
|
|
|
+
|
|
|
+// ydClient.operateData(YDParam.builder()
|
|
|
+//// .formInstId(formInstId)
|
|
|
+// .updateFormDataJson(JSONObject.toJSONString(UtilMap.map("textField_m6yntxmz",orderCode)))
|
|
|
+// .build(), YDConf.FORM_OPERATION.update);
|
|
|
+
|
|
|
+ if (kingDeeService.isTrue(repoRet2)){
|
|
|
+ Audit audit = new Audit();
|
|
|
+ audit.setIds(id);
|
|
|
+ //审核
|
|
|
+ String resultJson3 = client.audit(formId,JSONObject.toJSONString(audit));
|
|
|
+ RepoRet repoRet3 = gson.fromJson(resultJson3, RepoRet.class);
|
|
|
+ kingDeeService.isTrue(repoRet3);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ McR.errorUnknown(e.getMessage());
|
|
|
}
|
|
|
- }
|
|
|
- @Autowired
|
|
|
- private KDWebApiConf kdWebApiConf;
|
|
|
-
|
|
|
- private IdentifyInfo initIden(){
|
|
|
- //注意 1:此处不再使用参数形式传入用户名及密码等敏感信息,改为在登录配置文件中设置。
|
|
|
- //注意 2:必须先配置第三方系统登录授权信息后,再进行业务操作,详情参考各语言版本SDK介绍中的登录配置文件说明。
|
|
|
- //读取配置,初始化SDK
|
|
|
- IdentifyInfo iden = new IdentifyInfo();
|
|
|
- iden.setUserName(kdWebApiConf.getXKDApiUserName());
|
|
|
- iden.setAppId(kdWebApiConf.getXKDApiAppID());
|
|
|
- iden.setdCID(kdWebApiConf.getXKDApiAcctID());
|
|
|
- iden.setAppSecret(kdWebApiConf.getXKDApiAppSec());
|
|
|
- iden.setServerUrl(kdWebApiConf.getXKDApiServerUrl());
|
|
|
-
|
|
|
- return iden;
|
|
|
+
|
|
|
+ return McR.success();
|
|
|
}
|
|
|
}
|