|
@@ -1,5 +1,6 @@
|
|
package com.malk.kabeiyi.service.impl;
|
|
package com.malk.kabeiyi.service.impl;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.malk.core.McProject;
|
|
import com.malk.core.McProject;
|
|
@@ -21,6 +22,7 @@ import com.malk.utils.UtilHttp;
|
|
import com.malk.utils.UtilToken;
|
|
import com.malk.utils.UtilToken;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.apache.commons.lang3.time.DateUtils;
|
|
import org.apache.logging.log4j.util.Strings;
|
|
import org.apache.logging.log4j.util.Strings;
|
|
import org.slf4j.MDC;
|
|
import org.slf4j.MDC;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -28,10 +30,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
-import java.util.Objects;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@Service
|
|
@Service
|
|
@@ -76,7 +75,10 @@ public class KabeiyiServiceImpl implements KabeiyiService {
|
|
private static final String QUESTION = "FORM-89F515967FF94C62A9031F28EF6000B1YV5Q";
|
|
private static final String QUESTION = "FORM-89F515967FF94C62A9031F28EF6000B1YV5Q";
|
|
//问题整改表流程code
|
|
//问题整改表流程code
|
|
private static final String QUESTION_PROC_CODE = "TPROC--DP5660A1LEXNP1S37P7KU9GCHD5U3HB6C360M5";
|
|
private static final String QUESTION_PROC_CODE = "TPROC--DP5660A1LEXNP1S37P7KU9GCHD5U3HB6C360M5";
|
|
-
|
|
|
|
|
|
+ //审核表
|
|
|
|
+ private static final String CHECK = "FORM-F4ED246EADD8427381BC13C4F0FEF7FDYMKJ";
|
|
|
|
+ //审核表流程code
|
|
|
|
+ private static final String CHECK_PROC_CODE = "TPROC--4XC66Y61XWWNZNJKBZD4VAB5BQAJ2YANX160M5";
|
|
//关联表单(卡倍亿)
|
|
//关联表单(卡倍亿)
|
|
private static final Map<String,String> SCHEMA_MAP = new HashMap<>();
|
|
private static final Map<String,String> SCHEMA_MAP = new HashMap<>();
|
|
static{
|
|
static{
|
|
@@ -316,24 +318,48 @@ public class KabeiyiServiceImpl implements KabeiyiService {
|
|
.formInstId(formInstId)
|
|
.formInstId(formInstId)
|
|
.build(), YDConf.FORM_QUERY.retrieve_id);
|
|
.build(), YDConf.FORM_QUERY.retrieve_id);
|
|
Map formData = ddrNew.getFormData();
|
|
Map formData = ddrNew.getFormData();
|
|
|
|
+ //审核人
|
|
List<String> reviewerUserIds = (List<String>) formData.get("employeeField_m061zye5_id");
|
|
List<String> reviewerUserIds = (List<String>) formData.get("employeeField_m061zye5_id");
|
|
- List<String> rectificationUserIds = (List<String>) formData.get("employeeField_m061zyeq_id");
|
|
|
|
- List<String> deptIds = (List<String>) formData.get("departmentSelectField_m0c3qbjn_id");
|
|
|
|
- formData.put("departmentSelectField_m0c3qbjn",deptIds);
|
|
|
|
- formData.put("employeeField_m061zye5",rectificationUserIds);
|
|
|
|
- formData.put("employeeField_m061zyeq",reviewerUserIds);
|
|
|
|
- //发起审批
|
|
|
|
- String[] yida = McProject.getYida("1009");
|
|
|
|
- Map<String,Object> body = new HashMap<>();
|
|
|
|
|
|
|
|
- body.put("appType",yida[0]);
|
|
|
|
- body.put("systemToken",yida[1]);
|
|
|
|
- body.put("userId",reviewerUserIds.get(0));
|
|
|
|
- body.put("formUuid",QUESTION);
|
|
|
|
- body.put("processCode",QUESTION_PROC_CODE);
|
|
|
|
- body.put("formDataJson", JSONObject.toJSONString(formData));
|
|
|
|
|
|
+ List<Map> details = (List<Map>) formData.get("tableField_m0kqtqoy");
|
|
|
|
+ String[] yida = McProject.getYida("1009");
|
|
|
|
+ for (Map detail : details) {
|
|
|
|
+ String result = detail.get("radioField_m0nm3des").toString();
|
|
|
|
+ if ("NG".equals(result)){
|
|
|
|
+ //发起问题整改审批
|
|
|
|
+ Map question = new HashMap();
|
|
|
|
+ question.put("textField_m061zye8",detail.get("textField_m0on13ob"));//审核项目
|
|
|
|
+ question.put("textareaField_m061zye9",detail.get("textField_m0kqtqoz"));//审核方法和标准
|
|
|
|
+ question.put("attachmentField_m061zyep",detail.get("attachmentField_m061zyep"));//问题证据
|
|
|
|
+ question.put("textareaField_m063drgz",detail.get("textareaField_m063drgz"));//问题描述
|
|
|
|
+ question.put("dateField_m061zyev",detail.get("dateField_m061zyev"));//整改截止时间
|
|
|
|
+
|
|
|
|
+ //根据userId获取部门id
|
|
|
|
+ List<String> rectificationUserIds = (List<String>) detail.get("employeeField_m061zyeq_id");
|
|
|
|
+ question.put("employeeField_m061zyeq",rectificationUserIds);//责任整改人
|
|
|
|
+
|
|
|
|
+ Map body2 = new HashMap<>();
|
|
|
|
+ body2.put("userid", rectificationUserIds.get(0));
|
|
|
|
+
|
|
|
|
+ DDR_New ddrNew1 = (DDR_New) UtilHttp.doPost("https://oapi.dingtalk.com/topapi/v2/department/listparentbyuser", null, ddClient.initTokenParams(), body2, DDR_New.class);
|
|
|
|
+ Map result2 = (Map) ddrNew1.getResult();
|
|
|
|
+ List<Map> parentList = (List<Map>) result2.get("parent_list");
|
|
|
|
+ List<Long> parentDeptIdList = (List<Long>) parentList.get(0).get("parent_dept_id_list");
|
|
|
|
+ String deptId = parentDeptIdList.get(0) + "";
|
|
|
|
+ question.put("departmentSelectField_m0p0tbyo",new String[]{deptId});//部门
|
|
|
|
+
|
|
|
|
+ Map<String,Object> body = new HashMap<>();
|
|
|
|
+ body.put("appType",yida[0]);
|
|
|
|
+ body.put("systemToken",yida[1]);
|
|
|
|
+ body.put("userId",reviewerUserIds.get(0));
|
|
|
|
+ body.put("formUuid",QUESTION);
|
|
|
|
+ body.put("processCode",QUESTION_PROC_CODE);
|
|
|
|
+ body.put("formDataJson", JSONObject.toJSONString(question));
|
|
|
|
+
|
|
|
|
+ UtilHttp.doPost("https://api.dingtalk.com/v1.0/yida/processes/instances/start", ddClient.initTokenHeader(), null, body, DDR_New.class);
|
|
|
|
|
|
- UtilHttp.doPost("https://api.dingtalk.com/v1.0/yida/processes/instances/start", ddClient.initTokenHeader(), null, body, DDR_New.class);
|
|
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return McR.success();
|
|
return McR.success();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -349,6 +375,98 @@ public class KabeiyiServiceImpl implements KabeiyiService {
|
|
return McR.errorUnknown("识别失败!");
|
|
return McR.errorUnknown("识别失败!");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public McR addPlanApproval(Map map) {
|
|
|
|
+ MDC.put("MDC_KEY_PID","1009");
|
|
|
|
+
|
|
|
|
+ if (Objects.isNull(map.get("formInstId"))){
|
|
|
|
+ return McR.errorParam("formInstId不能为空!");
|
|
|
|
+ }
|
|
|
|
+ String formInstId = map.get("formInstId").toString();
|
|
|
|
+
|
|
|
|
+ DDR_New ddrNew = ydClient.queryData(YDParam.builder()
|
|
|
|
+ .formInstId(formInstId)
|
|
|
|
+ .build(), YDConf.FORM_QUERY.retrieve_id);
|
|
|
|
+ //计划制定人
|
|
|
|
+ Map originator = ddrNew.getOriginator();
|
|
|
|
+ String planUserId = originator.get("userId").toString();
|
|
|
|
+
|
|
|
|
+ Map formData = ddrNew.getFormData();
|
|
|
|
+ //审核人
|
|
|
|
+ List<String> reviewerUserIds = (List<String>) formData.get("employeeField_m061zye5_id");
|
|
|
|
+ //频次
|
|
|
|
+ String frequency = formData.get("selectField_m0koxj7g").toString();
|
|
|
|
+ //下次自动发起审核日期
|
|
|
|
+ long nextTime = (long) formData.get("dateField_m0nbpasq");
|
|
|
|
+ Date nextDate = new Date(nextTime);
|
|
|
|
+
|
|
|
|
+ //上次自动发起审核日期
|
|
|
|
+ Date lastTime = nextDate;
|
|
|
|
+ //审核截至日期
|
|
|
|
+ Date endDate = new Date();
|
|
|
|
+ switch (frequency){
|
|
|
|
+ case "每周":
|
|
|
|
+ endDate = DateUtils.addDays(nextDate, 6);
|
|
|
|
+ nextDate = DateUtils.addDays(nextDate, 7);
|
|
|
|
+ break;
|
|
|
|
+ case "每两周":
|
|
|
|
+ endDate = DateUtils.addDays(nextDate, 13);
|
|
|
|
+ nextDate = DateUtils.addDays(nextDate, 14);
|
|
|
|
+ break;
|
|
|
|
+ case "每月":
|
|
|
|
+ endDate = DateUtils.addDays(DateUtils.addMonths(nextDate, 1), -1);
|
|
|
|
+ nextDate = DateUtils.addMonths(nextDate, 1);
|
|
|
|
+ break;
|
|
|
|
+ case "每季度":
|
|
|
|
+ endDate = DateUtils.addDays(DateUtils.addMonths(nextDate, 3),-1);
|
|
|
|
+ nextDate = DateUtils.addMonths(nextDate, 3);
|
|
|
|
+ break;
|
|
|
|
+ case "一次":
|
|
|
|
+ endDate = new Date((long)formData.get("dateField_m0oqbh48"));
|
|
|
|
+ nextDate = null;
|
|
|
|
+ break;
|
|
|
|
+ default:break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //每个审批人发起审批
|
|
|
|
+ for (String reviewerUserId : reviewerUserIds) {
|
|
|
|
+ //根据userId获取部门id
|
|
|
|
+ Map body = new HashMap<>();
|
|
|
|
+ body.put("userid", reviewerUserId);
|
|
|
|
+
|
|
|
|
+ DDR_New ddrNew1 = (DDR_New) UtilHttp.doPost("https://oapi.dingtalk.com/topapi/v2/department/listparentbyuser", null, ddClient.initTokenParams(), body, DDR_New.class);
|
|
|
|
+ Map result = (Map) ddrNew1.getResult();
|
|
|
|
+ List<Map> parentList = (List<Map>) result.get("parent_list");
|
|
|
|
+ List<Long> parentDeptIdList = (List<Long>) parentList.get(0).get("parent_dept_id_list");
|
|
|
|
+ String deptId = parentDeptIdList.get(0) + "";
|
|
|
|
+ formData.put("departmentSelectField_m0c3qbjn", new String[]{deptId});
|
|
|
|
+ formData.put("dateField_m061zye7", endDate.getTime());
|
|
|
|
+ formData.put("employeeField_m061zye5",new String[]{reviewerUserId});
|
|
|
|
+ //发起审批
|
|
|
|
+ String[] yida = McProject.getYida("1009");
|
|
|
|
+ Map<String,Object> body2 = new HashMap<>();
|
|
|
|
+
|
|
|
|
+ body2.put("appType",yida[0]);
|
|
|
|
+ body2.put("systemToken",yida[1]);
|
|
|
|
+ body2.put("userId",planUserId);
|
|
|
|
+ body2.put("formUuid",CHECK);
|
|
|
|
+ body2.put("processCode",CHECK_PROC_CODE);
|
|
|
|
+ body2.put("formDataJson", JSONObject.toJSONString(formData));
|
|
|
|
+
|
|
|
|
+ UtilHttp.doPost("https://api.dingtalk.com/v1.0/yida/processes/instances/start", ddClient.initTokenHeader(), null, body2, DDR_New.class);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //更新审核计划下次发起审批时间及上次发起审批时间
|
|
|
|
+ formData.put("dateField_m0nbpasw", lastTime);
|
|
|
|
+ formData.put("dateField_m0nbpasq", nextDate);
|
|
|
|
+ ydClient.operateData(YDParam.builder()
|
|
|
|
+ .formInstId(formInstId)
|
|
|
|
+ .updateFormDataJson(JSON.toJSONString(formData))
|
|
|
|
+ .build(), YDConf.FORM_OPERATION.update);
|
|
|
|
+
|
|
|
|
+ return McR.success();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
private String getString(Object obj){
|
|
private String getString(Object obj){
|
|
return obj == null ? "" : obj.toString();
|
|
return obj == null ? "" : obj.toString();
|