|
|
@@ -0,0 +1,416 @@
|
|
|
+package com.malk.minglei.service.impl.yida;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.malk.minglei.config.YidaApplicationsProperties;
|
|
|
+import com.malk.minglei.dto.ErpYidaPushMainData;
|
|
|
+import com.malk.minglei.dto.ErpYidaPushRequest;
|
|
|
+import com.malk.minglei.service.yida.YidaFormPushHandler;
|
|
|
+import com.malk.minglei.service.yida.YidaProcessOpenApiClient;
|
|
|
+import com.malk.server.common.McException;
|
|
|
+import com.malk.server.dingtalk.DDR_New;
|
|
|
+import com.malk.server.dingtalk.DDConf;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.ZoneId;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class MiscReceiptIssueFormPushHandler implements YidaFormPushHandler {
|
|
|
+
|
|
|
+ private static final Logger LOGGER = LoggerFactory.getLogger(MiscReceiptIssueFormPushHandler.class);
|
|
|
+ private static final String START_PROCESS_ENDPOINT = "/v1.0/yida/processes/instances/start";
|
|
|
+ public static final String TYPE = "cint301";
|
|
|
+ private static final String FORM_NAME = "miscReceiptIssue";
|
|
|
+ private static final String FORM_UUID = "FORM-4B08ADABCDAA45788C043729A855E03ED76G";
|
|
|
+ private static final String PROCESS_CODE = "TPROC--MQD66371C1N84FPSJZO4W79IN4BW2AE7I08TM0";
|
|
|
+ private static final String DEFAULT_ORIGINATOR_USER_ID = "41603502201288023";
|
|
|
+
|
|
|
+ private static final String TITLE_FIELD_ID = "textField_msh27unu";
|
|
|
+ private static final String APPLICANT_FIELD_ID = "employeeField_msh186rr";
|
|
|
+ private static final String COMPANY_FIELD_ID = "selectField_mso1em48";
|
|
|
+ private static final String DEPARTMENT_FIELD_ID = "departmentSelectField_msh186ry";
|
|
|
+ private static final String APPLY_DATE_FIELD_ID = "dateField_msh186rs";
|
|
|
+ private static final String FORM_TITLE_FIELD_ID = "textField_mspcpz92";
|
|
|
+ private static final String DATA_SOURCE_FIELD_ID = "textField_mt7zi4fy";
|
|
|
+ private static final String APPLICANT_NO_FIELD_ID = "textField_mt7zi4g0";
|
|
|
+ private static final String DEPARTMENT_NO_FIELD_ID = "textField_mt80nq6s";
|
|
|
+ private static final String REASON_CODE_FIELD_ID = "textField_mt80nq6t";
|
|
|
+ private static final String REASON_DESC_FIELD_ID = "textField_mt80nq6v";
|
|
|
+ private static final String REMARK_FIELD_ID = "textField_mt7zi4fz";
|
|
|
+
|
|
|
+ private static final String DETAIL_TABLE_FIELD_ID = "tableField_msh186sv";
|
|
|
+ private static final String DETAIL_SEQ_FIELD_ID = "textField_mt7zi4g1";
|
|
|
+ private static final String DETAIL_ORDER_NO_FIELD_ID = "textField_mt80nq6y";
|
|
|
+ private static final String DETAIL_ORDER_SEQ_FIELD_ID = "textField_mt80nq6z";
|
|
|
+ private static final String DETAIL_ITEM_CODE_FIELD_ID = "textField_mt80nq70";
|
|
|
+ private static final String DETAIL_ITEM_NAME_FIELD_ID = "textField_mt80nq71";
|
|
|
+ private static final String DETAIL_SPEC_FIELD_ID = "textField_mt80nq72";
|
|
|
+ private static final String DETAIL_PRODUCT_FEATURE_FIELD_ID = "textField_mt80nq73";
|
|
|
+ private static final String DETAIL_WAREHOUSE_FIELD_ID = "textField_mt80nq74";
|
|
|
+ private static final String DETAIL_LOCATION_FIELD_ID = "textField_mt80nq75";
|
|
|
+ private static final String DETAIL_LOT_NO_FIELD_ID = "textField_mt7zi4g2";
|
|
|
+ private static final String DETAIL_STOCK_FEATURE_FIELD_ID = "textField_mt80nq76";
|
|
|
+ private static final String DETAIL_QUANTITY_FIELD_ID = "numberField_mt80nq77";
|
|
|
+ private static final String DETAIL_UNIT_FIELD_ID = "textField_mt6ur4w1";
|
|
|
+ private static final String DETAIL_REASON_CODE_FIELD_ID = "textField_mt7zi4g4";
|
|
|
+ private static final String DETAIL_REASON_DESC_FIELD_ID = "textField_mt80nq79";
|
|
|
+ private static final String DETAIL_PROJECT_NO_FIELD_ID = "textField_mt6ur4w8";
|
|
|
+ private static final String DETAIL_PROJECT_DESC_FIELD_ID = "textField_mt80nq7a";
|
|
|
+ private static final String DETAIL_SOURCE_DOC_NO_FIELD_ID = "textField_mt80nq7b";
|
|
|
+
|
|
|
+ private final YidaProcessOpenApiClient yidaProcessOpenApiClient;
|
|
|
+ private final DDConf dingTalkConfiguration;
|
|
|
+ private final YidaApplicationsProperties applications;
|
|
|
+
|
|
|
+ public MiscReceiptIssueFormPushHandler(YidaProcessOpenApiClient yidaProcessOpenApiClient,
|
|
|
+ DDConf dingTalkConfiguration,
|
|
|
+ YidaApplicationsProperties applications) {
|
|
|
+ this.yidaProcessOpenApiClient = yidaProcessOpenApiClient;
|
|
|
+ this.dingTalkConfiguration = dingTalkConfiguration;
|
|
|
+ this.applications = applications;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<String> getTypes() {
|
|
|
+ return Collections.singletonList(TYPE);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String push(ErpYidaPushRequest request) {
|
|
|
+ validateConfiguration();
|
|
|
+
|
|
|
+ String operatorUserId = resolveOperatorUserId(request);
|
|
|
+ String appType = requireText(applications.getCoordinationOffice().getAppType(), "YIDA_COORDINATION_OFFICE_APP_TYPE is not configured");
|
|
|
+ String systemToken = requireText(applications.getCoordinationOffice().getSystemToken(), "YIDA_COORDINATION_OFFICE_SYSTEM_TOKEN is not configured");
|
|
|
+ Map<String, Object> formData = toYidaFormData(request, operatorUserId);
|
|
|
+ String title = requireText(toText(formData.get(TITLE_FIELD_ID)), "Yida process title is not configured");
|
|
|
+ Map<String, Object> body = new LinkedHashMap<String, Object>();
|
|
|
+ body.put("appType", appType);
|
|
|
+ body.put("systemToken", systemToken);
|
|
|
+ body.put("userId", operatorUserId);
|
|
|
+ body.put("processCode", PROCESS_CODE);
|
|
|
+ body.put("formUuid", FORM_UUID);
|
|
|
+ body.put("formDataJson", JSON.toJSONString(formData));
|
|
|
+ body.put("executeExpression", true);
|
|
|
+ body.put("noExecuteExpression", false);
|
|
|
+ body.put("title", title);
|
|
|
+ body.put("dataTitle", title);
|
|
|
+ LOGGER.info("Yida process start request endpoint={} formName={} body={}",
|
|
|
+ START_PROCESS_ENDPOINT, FORM_NAME, JSON.toJSONString(maskSensitive(body)));
|
|
|
+
|
|
|
+ DDR_New response;
|
|
|
+ try {
|
|
|
+ response = yidaProcessOpenApiClient.startProcess(body);
|
|
|
+ } catch (McException exception) {
|
|
|
+ throw exception;
|
|
|
+ } catch (Exception exception) {
|
|
|
+ LOGGER.error("Yida process start failed formName={} body={}",
|
|
|
+ FORM_NAME, JSON.toJSONString(maskSensitive(body)), exception);
|
|
|
+ throw new McException("DINGTALK_YIDA_ERROR", "Yida process start failed: " + rootMessage(exception));
|
|
|
+ }
|
|
|
+ return extractProcessInstanceId(response);
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, Object> toYidaFormData(ErpYidaPushRequest request, String operatorUserId) {
|
|
|
+ Map<String, Object> main = objectToMap(request.getMainData());
|
|
|
+ putIfNotBlank(main, "bm", request.getBm());
|
|
|
+ putIfNotBlank(main, "gs", request.getGs());
|
|
|
+ putIfNotBlank(main, "tjr", request.getTjr());
|
|
|
+ Map<String, Object> detailWrapper = objectToMap(request.getDetailData());
|
|
|
+ List<Map<String, Object>> detailRows = toMapRows(detailWrapper.get("detailData1"));
|
|
|
+ String docNo = toText(value(main, "inbadocno"));
|
|
|
+ String title = toText(firstNonBlank(value(main, "title", "dataTitle"), docNo == null ? null : "miscReceiptIssue-" + docNo));
|
|
|
+
|
|
|
+ Map<String, Object> formData = new LinkedHashMap<String, Object>();
|
|
|
+ putIfNotBlank(formData, TITLE_FIELD_ID, title);
|
|
|
+ putIfNotBlank(formData, APPLICANT_FIELD_ID, toStringList(operatorUserId, null));
|
|
|
+ putIfNotBlank(formData, COMPANY_FIELD_ID, firstNonBlank(value(main, "gs", "applyCompany", "company"), value(main, "inbaent")));
|
|
|
+ putIfNotBlank(formData, DEPARTMENT_FIELD_ID, toStringList(value(main, "bm", "applyDepartment", "department", "deptId"), null));
|
|
|
+ putIfNotBlank(formData, APPLY_DATE_FIELD_ID, toDateMillis(firstNonBlank(value(main, "rq", "applyDate"), value(main, "inbadocdt"))));
|
|
|
+ putIfNotBlank(formData, FORM_TITLE_FIELD_ID, title);
|
|
|
+ putIfNotBlank(formData, DATA_SOURCE_FIELD_ID, value(main, "inba006"));
|
|
|
+ putIfNotBlank(formData, APPLICANT_NO_FIELD_ID, value(main, "inba003"));
|
|
|
+ putIfNotBlank(formData, DEPARTMENT_NO_FIELD_ID, value(main, "inba004"));
|
|
|
+ putIfNotBlank(formData, REASON_CODE_FIELD_ID, value(main, "inba007"));
|
|
|
+ putIfNotBlank(formData, REASON_DESC_FIELD_ID, value(main, "oocql004"));
|
|
|
+ putIfNotBlank(formData, REMARK_FIELD_ID, value(main, "inba008"));
|
|
|
+
|
|
|
+ List<Map<String, Object>> rows = toDetailRows(detailRows);
|
|
|
+ if (!rows.isEmpty()) {
|
|
|
+ formData.put(DETAIL_TABLE_FIELD_ID, rows);
|
|
|
+ }
|
|
|
+ copyYidaFieldValues(main, formData);
|
|
|
+ return formData;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<Map<String, Object>> toDetailRows(List<Map<String, Object>> sourceRows) {
|
|
|
+ List<Map<String, Object>> rows = new ArrayList<Map<String, Object>>();
|
|
|
+ for (Map<String, Object> source : sourceRows) {
|
|
|
+ Map<String, Object> row = new LinkedHashMap<String, Object>();
|
|
|
+ putIfNotBlank(row, DETAIL_SEQ_FIELD_ID, value(source, "inbbseq"));
|
|
|
+ putIfNotBlank(row, DETAIL_ORDER_NO_FIELD_ID, value(source, "inbbua001"));
|
|
|
+ putIfNotBlank(row, DETAIL_ORDER_SEQ_FIELD_ID, value(source, "inbbua002"));
|
|
|
+ putIfNotBlank(row, DETAIL_ITEM_CODE_FIELD_ID, value(source, "inbb001"));
|
|
|
+ putIfNotBlank(row, DETAIL_ITEM_NAME_FIELD_ID, value(source, "imaal003"));
|
|
|
+ putIfNotBlank(row, DETAIL_SPEC_FIELD_ID, value(source, "imaal004"));
|
|
|
+ putIfNotBlank(row, DETAIL_PRODUCT_FEATURE_FIELD_ID, value(source, "inbb002"));
|
|
|
+ putIfNotBlank(row, DETAIL_WAREHOUSE_FIELD_ID, value(source, "inbb007"));
|
|
|
+ putIfNotBlank(row, DETAIL_LOCATION_FIELD_ID, value(source, "inbb008"));
|
|
|
+ putIfNotBlank(row, DETAIL_LOT_NO_FIELD_ID, value(source, "inbb009"));
|
|
|
+ putIfNotBlank(row, DETAIL_STOCK_FEATURE_FIELD_ID, value(source, "inbb003"));
|
|
|
+ putIfNotBlank(row, DETAIL_QUANTITY_FIELD_ID, toDecimal(value(source, "inbb011")));
|
|
|
+ putIfNotBlank(row, DETAIL_UNIT_FIELD_ID, value(source, "inbb010"));
|
|
|
+ putIfNotBlank(row, DETAIL_REASON_CODE_FIELD_ID, value(source, "inbb016"));
|
|
|
+ putIfNotBlank(row, DETAIL_REASON_DESC_FIELD_ID, value(source, "oocql004"));
|
|
|
+ putIfNotBlank(row, DETAIL_PROJECT_NO_FIELD_ID, value(source, "inbb023"));
|
|
|
+ putIfNotBlank(row, DETAIL_PROJECT_DESC_FIELD_ID, value(source, "pjbal003"));
|
|
|
+ putIfNotBlank(row, DETAIL_SOURCE_DOC_NO_FIELD_ID, value(source, "inbb017"));
|
|
|
+ copyYidaFieldValues(source, row);
|
|
|
+ if (!row.isEmpty()) {
|
|
|
+ rows.add(row);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return rows;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<Map<String, Object>> toMapRows(Object value) {
|
|
|
+ List<Map<String, Object>> rows = new ArrayList<Map<String, Object>>();
|
|
|
+ for (Object item : toList(value)) {
|
|
|
+ Map<String, Object> row = objectToMap(item);
|
|
|
+ if (!row.isEmpty()) {
|
|
|
+ rows.add(row);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return rows;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<?> toList(Object value) {
|
|
|
+ if (value instanceof List) {
|
|
|
+ return (List<?>) value;
|
|
|
+ }
|
|
|
+ if (value instanceof Iterable) {
|
|
|
+ List<Object> result = new ArrayList<Object>();
|
|
|
+ for (Object item : (Iterable<?>) value) {
|
|
|
+ result.add(item);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ return value == null ? Collections.emptyList() : Collections.singletonList(value);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<String> toStringList(Object value, String fallback) {
|
|
|
+ Object actualValue = isBlank(value) ? fallback : value;
|
|
|
+ if (actualValue == null) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ if (actualValue instanceof Iterable) {
|
|
|
+ List<String> result = new ArrayList<String>();
|
|
|
+ for (Object item : (Iterable<?>) actualValue) {
|
|
|
+ if (!isBlank(item)) {
|
|
|
+ result.add(String.valueOf(item).trim());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ return Collections.singletonList(String.valueOf(actualValue).trim());
|
|
|
+ }
|
|
|
+
|
|
|
+ private BigDecimal toDecimal(Object value) {
|
|
|
+ if (isBlank(value)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (value instanceof BigDecimal) {
|
|
|
+ return (BigDecimal) value;
|
|
|
+ }
|
|
|
+ if (value instanceof Number) {
|
|
|
+ return new BigDecimal(String.valueOf(value));
|
|
|
+ }
|
|
|
+ return new BigDecimal(String.valueOf(value).trim());
|
|
|
+ }
|
|
|
+
|
|
|
+ private Long toDateMillis(Object value) {
|
|
|
+ if (isBlank(value)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ String text = String.valueOf(value).trim();
|
|
|
+ if (text.matches("\\d+")) {
|
|
|
+ return Long.valueOf(text);
|
|
|
+ }
|
|
|
+ return LocalDate.parse(text).atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
|
|
+ }
|
|
|
+
|
|
|
+ private Object value(Map<String, Object> source, String firstKey, String... otherKeys) {
|
|
|
+ Object value = source.get(firstKey);
|
|
|
+ if (!isBlank(value)) {
|
|
|
+ return value;
|
|
|
+ }
|
|
|
+ for (String key : otherKeys) {
|
|
|
+ value = source.get(key);
|
|
|
+ if (!isBlank(value)) {
|
|
|
+ return value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Object firstNonBlank(Object first, Object second) {
|
|
|
+ return isBlank(first) ? second : first;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void putIfNotBlank(Map<String, Object> target, String fieldId, Object value) {
|
|
|
+ if (!isBlank(value)) {
|
|
|
+ target.put(fieldId, value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void copyYidaFieldValues(Map<String, Object> source, Map<String, Object> target) {
|
|
|
+ for (Map.Entry<String, Object> entry : source.entrySet()) {
|
|
|
+ if (entry.getKey() != null && entry.getKey().contains("Field_") && !isBlank(entry.getValue())) {
|
|
|
+ target.put(entry.getKey(), entry.getValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, Object> objectToMap(Object value) {
|
|
|
+ if (value == null) {
|
|
|
+ return Collections.emptyMap();
|
|
|
+ }
|
|
|
+ if (value instanceof Map) {
|
|
|
+ return copyMap((Map<?, ?>) value);
|
|
|
+ }
|
|
|
+ if (value instanceof ErpYidaPushMainData) {
|
|
|
+ ErpYidaPushMainData mainData = (ErpYidaPushMainData) value;
|
|
|
+ Map<String, Object> result = new LinkedHashMap<String, Object>();
|
|
|
+ putIfNotBlank(result, "rq", mainData.getRq());
|
|
|
+ putIfNotBlank(result, "bm", mainData.getBm());
|
|
|
+ putIfNotBlank(result, "tjr", mainData.getTjr());
|
|
|
+ putIfNotBlank(result, "gs", mainData.getGs());
|
|
|
+ putIfNotBlank(result, "t100id", mainData.getT100id());
|
|
|
+ putIfNotBlank(result, "ent", mainData.getEnt());
|
|
|
+ putIfNotBlank(result, "t100bm", mainData.getT100bm());
|
|
|
+ result.putAll(mainData.getExtraFields());
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ return JSON.parseObject(JSON.toJSONString(value));
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, Object> copyMap(Map<?, ?> source) {
|
|
|
+ Map<String, Object> result = new LinkedHashMap<String, Object>();
|
|
|
+ for (Map.Entry<?, ?> entry : source.entrySet()) {
|
|
|
+ if (entry.getKey() != null) {
|
|
|
+ result.put(String.valueOf(entry.getKey()), entry.getValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean isBlank(Object value) {
|
|
|
+ if (value == null) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (value instanceof Iterable) {
|
|
|
+ return !((Iterable<?>) value).iterator().hasNext();
|
|
|
+ }
|
|
|
+ if (value instanceof Map) {
|
|
|
+ return ((Map<?, ?>) value).isEmpty();
|
|
|
+ }
|
|
|
+ return String.valueOf(value).trim().isEmpty();
|
|
|
+ }
|
|
|
+
|
|
|
+ private String resolveOperatorUserId(ErpYidaPushRequest request) {
|
|
|
+ if (!isBlank(request.getOriginatorUserId())) {
|
|
|
+ return request.getOriginatorUserId().trim();
|
|
|
+ }
|
|
|
+ Map<String, Object> main = objectToMap(request.getMainData());
|
|
|
+ Object operator = firstNonBlank(value(main, "originatorUserId", "userId"), value(main, "applicant"));
|
|
|
+ return String.valueOf(isBlank(operator) ? DEFAULT_ORIGINATOR_USER_ID : firstItem(operator)).trim();
|
|
|
+ }
|
|
|
+
|
|
|
+ private Object firstItem(Object value) {
|
|
|
+ if (value instanceof Iterable) {
|
|
|
+ for (Object item : (Iterable<?>) value) {
|
|
|
+ if (!isBlank(item)) {
|
|
|
+ return item;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return value;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String toText(Object value) {
|
|
|
+ return isBlank(value) ? null : String.valueOf(value);
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, Object> maskSensitive(Map<String, Object> source) {
|
|
|
+ Map<String, Object> body = new LinkedHashMap<String, Object>(source);
|
|
|
+ if (body.containsKey("systemToken")) {
|
|
|
+ body.put("systemToken", "******");
|
|
|
+ }
|
|
|
+ return body;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String extractProcessInstanceId(DDR_New response) {
|
|
|
+ if (response == null) {
|
|
|
+ throw new McException("YIDA_NULL_RESPONSE", "Yida process start failed: empty response");
|
|
|
+ }
|
|
|
+ LOGGER.info("Yida process start response formName={} success={} code={} result={} instanceId={} formInstId={}",
|
|
|
+ FORM_NAME, response.isSuccess(), response.getCode(), response.getResult(), response.getInstanceId(), response.getFormInstId());
|
|
|
+
|
|
|
+ Object result = firstNonBlank(firstNonBlank(response.getResult(), response.getInstanceId()), response.getFormInstId());
|
|
|
+ if (!isBlank(result)) {
|
|
|
+ return String.valueOf(result);
|
|
|
+ }
|
|
|
+ if (response.isSuccess()) {
|
|
|
+ return "SUCCESS";
|
|
|
+ }
|
|
|
+ String code = defaultText(response.getCode(), "YIDA_ERROR");
|
|
|
+ String message = defaultText(response.getMessage(), "Yida process start failed: no process instance id");
|
|
|
+ throw new McException(code, "Yida API [startProcess] failed: " + message);
|
|
|
+ }
|
|
|
+
|
|
|
+ private String defaultText(String value, String fallback) {
|
|
|
+ return value == null || value.trim().isEmpty() ? fallback : value.trim();
|
|
|
+ }
|
|
|
+
|
|
|
+ private String rootMessage(Throwable exception) {
|
|
|
+ Throwable current = exception;
|
|
|
+ while (current.getCause() != null && current.getCause() != current) {
|
|
|
+ current = current.getCause();
|
|
|
+ }
|
|
|
+ String message = current.getMessage();
|
|
|
+ if (message == null || message.trim().isEmpty()) {
|
|
|
+ message = exception.getMessage();
|
|
|
+ }
|
|
|
+ if (message == null || message.trim().isEmpty()) {
|
|
|
+ message = current.getClass().getSimpleName();
|
|
|
+ }
|
|
|
+ return message.trim();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void validateConfiguration() {
|
|
|
+ require(dingTalkConfiguration.getAppKey(), "DINGTALK_APP_KEY is not configured");
|
|
|
+ require(dingTalkConfiguration.getAppSecret(), "DINGTALK_APP_SECRET is not configured");
|
|
|
+ require(applications.getCoordinationOffice().getAppType(), "YIDA_COORDINATION_OFFICE_APP_TYPE is not configured");
|
|
|
+ require(applications.getCoordinationOffice().getSystemToken(), "YIDA_COORDINATION_OFFICE_SYSTEM_TOKEN is not configured");
|
|
|
+ }
|
|
|
+
|
|
|
+ private String requireText(String value, String message) {
|
|
|
+ require(value, message);
|
|
|
+ return value.trim();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void require(String value, String message) {
|
|
|
+ if (value == null || value.trim().isEmpty()) {
|
|
|
+ throw new IllegalStateException(message);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|