| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | 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; |
| | |
| | | |
| | | /** |
| | | * 45分钟登录一次金蝶系统 |
| | | * |
| | | * @return |
| | | */ |
| | | @Transactional |
| | | public synchronized ReturnT<String> start() { |
| | | |
| | | LoginParam loginParam =new LoginParam(); |
| | | LoginParam loginParam = new LoginParam(); |
| | | loginParam.setAcctID(acctID); |
| | | loginParam.setUsername(username); |
| | | loginParam.setPassword(password); |
| | |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | Object sessionId = findValueByKey(JSON.parseObject(response), "SessionId"); |
| | | cookie="ASP.NET_SessionId="+sessionId+";"+"kdservice-sessionid="+jsonObject.getString("KDSVCSessionId"); |
| | | cookie = "ASP.NET_SessionId=" + sessionId + ";" + "kdservice-sessionid=" + jsonObject.getString("KDSVCSessionId"); |
| | | 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); |
| | | callApiLogSaveLog(JSON.toJSONString(loginParam), false); |
| | | log.error("请求接口失败!!!url:{};request:{};response:{}", URL + loginaddress, JSON.toJSONString(loginParam), response); |
| | | // 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); |
| | | 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 { |
| | |
| | | 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){ |
| | | if (result != null) { |
| | | return result; |
| | | } |
| | | } |
| | | } else if (v instanceof JSONObject){ |
| | | } else if (v instanceof JSONObject) { |
| | | Object result = findValueByKey((JSONObject) v, key); |
| | | if (result != null){ |
| | | if (result != null) { |
| | | return result; |
| | | } |
| | | } |
| | |
| | | |
| | | public void callApiLogSaveLog(String response, Boolean bool) { |
| | | apiLogService.save("登录金蝶失败", URL, "null", loginaddress, |
| | | "套账ID:"+acctID+"、账号:"+username+"、密码:"+password, |
| | | "套账ID:" + acctID + "、账号:" + username + "、密码:" + password, |
| | | response, bool); |
| | | } |
| | | |