自动化立体仓库 - WMS系统
#
LSH
2023-10-21 8eee61286b82a95777b809f9e72572bb367d9f9f
src/main/java/com/zy/asrs/task/kingdee/handler/LoginAuthenticationHandler.java
@@ -5,11 +5,13 @@
import com.alibaba.fastjson.JSONObject;
import com.core.common.Cools;
import com.core.exception.CoolException;
import com.zy.asrs.entity.Order;
import com.zy.asrs.service.ApiLogService;
import com.zy.asrs.task.AbstractHandler;
import com.zy.asrs.task.core.ReturnT;
import com.zy.common.utils.HttpHandler;
import com.zy.erp.kingdee.entity.param.LoginParam;
import com.zy.erp.kingdee.enums.KingDeeUtilType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -79,54 +81,64 @@
            if (Cools.isEmpty(jsonObject.getString("Message"))) {
                success = true;
            } else {
                callApiLogSaveLog(JSON.toJSONString(loginParam),false);
                log.error("请求接口失败!!!url:{};request:{};response:{}", URL+loginaddress, JSON.toJSONString(loginParam), response);
                throw new CoolException("登录金蝶失败");
//                throw new CoolException("登录金蝶失败");
            }
        } catch (Exception e) {
            log.error("fail", e);
            callApiLogSaveLog(JSON.toJSONString(loginParam),false);
            log.error("请求接口失败!!!url:{};request:{};response:{}", URL+loginaddress, JSON.toJSONString(loginParam), response);
//            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            return FAIL.setMsg(e.getMessage());
        } finally {
            try {
                // 保存接口日志
                apiLogService.save(
                        "登录金蝶",
                        URL + loginaddress,
                        null,
                        "127.0.0.1",
                        JSON.toJSONString(loginParam),
                        response,
                        success
                );
            } catch (Exception e) { log.error("", e); }
//            try {
//                // 保存接口日志
//                apiLogService.save(
//                        "登录金蝶",
//                        URL + loginaddress,
//                        null,
//                        "127.0.0.1",
//                        JSON.toJSONString(loginParam),
//                        response,
//                        success
//                );
//            } catch (Exception e) { log.error("", e); }
        }
        return SUCCESS.setContent(cookie);
    }
        public static Object findValueByKey(JSONObject json, String key) {
            Set<String> keySet = json.keySet();
            for (String k : keySet) {
                Object v = json.get(k);
                if (k.equals(key)) {
                    return v;
                } else if (v instanceof JSONArray) {
                    int size = ((JSONArray) v).size();
                    for (int i = 0; i <= size - 1; i++) {
                        Object result = findValueByKey((JSONObject) ((JSONArray) v).get(i), key);
                        if (result != null){
                            return result;
                        }
                    }
                } else if (v instanceof JSONObject){
                    Object result = findValueByKey((JSONObject) v, key);
    public static Object findValueByKey(JSONObject json, String key) {
        Set<String> keySet = json.keySet();
        for (String k : keySet) {
            Object v = json.get(k);
            if (k.equals(key)) {
                return v;
            } else if (v instanceof JSONArray) {
                int size = ((JSONArray) v).size();
                for (int i = 0; i <= size - 1; i++) {
                    Object result = findValueByKey((JSONObject) ((JSONArray) v).get(i), key);
                    if (result != null){
                        return result;
                    }
                }
            } else if (v instanceof JSONObject){
                Object result = findValueByKey((JSONObject) v, key);
                if (result != null){
                    return result;
                }
            }
            return null;
        }
        return null;
    }
    public void callApiLogSaveLog(String response, Boolean bool) {
        apiLogService.save("登录金蝶失败", URL, "null", loginaddress,
                "套账ID:"+acctID+"、账号:"+username+"、密码:"+password,
                response, bool);
    }
}