Commit c79430c4 authored by zhoumaotao's avatar zhoumaotao

代码调整2

parent bfbcf0a3
package com.gavel.kwell.service.impl; package com.gavel.kwell.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.gavel.common.base.service.impl.BaseEditServiceImpl; import com.gavel.common.base.service.impl.BaseEditServiceImpl;
import com.gavel.common.business.service.CommonService; import com.gavel.common.business.service.CommonService;
import com.gavel.common.http.HttpUtils; import com.gavel.common.utils.*;
import com.gavel.common.utils.CollectionUtils;
import com.gavel.common.utils.DateUtils;
import com.gavel.common.utils.NumberUtils;
import com.gavel.common.utils.StringUtils;
import com.gavel.kwell.dao.GpfkcxDao; import com.gavel.kwell.dao.GpfkcxDao;
import com.gavel.kwell.dao.KmesBoardDao; import com.gavel.kwell.dao.KmesBoardDao;
import com.gavel.kwell.persistent.Gpfkjg; import com.gavel.kwell.persistent.Gpfkjg;
...@@ -19,11 +16,14 @@ import com.gavel.wo.persistent.Pcjhmx; ...@@ -19,11 +16,14 @@ import com.gavel.wo.persistent.Pcjhmx;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.*;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
...@@ -44,6 +44,9 @@ public class KmesBoardServiceImpl extends BaseEditServiceImpl implements KmesBoa ...@@ -44,6 +44,9 @@ public class KmesBoardServiceImpl extends BaseEditServiceImpl implements KmesBoa
@Autowired @Autowired
private CommonService commonService; private CommonService commonService;
@Autowired
private RestTemplate restTemplate;
@Override @Override
public void initService(){ public void initService(){
} }
...@@ -316,15 +319,42 @@ public class KmesBoardServiceImpl extends BaseEditServiceImpl implements KmesBoa ...@@ -316,15 +319,42 @@ public class KmesBoardServiceImpl extends BaseEditServiceImpl implements KmesBoa
@Override @Override
public KqtjVO queryOA() { public KqtjVO queryOA() {
KqtjVO kqtjVO = new KqtjVO(); KqtjVO kqtjVO = new KqtjVO();
String time = DateUtils.formatDate(DateUtils.getDateTime(),"yyyyMMddHHmmss");
String url = "http://oa.kewell.com.cn/api/cube/restful/interface/getModeDataPageList/mes_kqtj"; String url = "http://oa.kewell.com.cn/api/cube/restful/interface/getModeDataPageList/mes_kqtj";
String param = "{\"datajson\":{\"operationinfo\":{\"operator\":\"1\"},\"mainTable\":{},\"pageInfo\":{\"pageNo\":\"1\",\"pageSize\":\"10\"}," + StringBuilder param = new StringBuilder();
"\"header\":{\"systemid\":\"CRM_System\",\"currentDateTime\":\"20200101010101\",\"Md5\":\"c4ca4238a0b923820dcc509a6f75849b\"}}}"; param.append("{\"datajson\":{\"operationinfo\":{\"operator\":\"1\"},\"mainTable\":{},\"pageInfo\":{\"pageNo\":\"1\",\"pageSize\":\"10\"},");
param.append("\"header\":{\"systemid\":\"oa\",");
param.append("\"currentDateTime\":").append("\""+time+"\"").append(",\"Md5\":").append("\""+MD5Utils.md5Hex("oa"+"123456"+time)+"\"").append("}}}");
try { try {
String response = HttpUtils.doPost(url, param);
if(StringUtils.isNotEmpty(response)){ HttpHeaders headers = new HttpHeaders();
JSONObject jsonObject = JSONObject.parseObject(response); headers.setContentType(MediaType.APPLICATION_JSON);
logger.info("返回信息:"+response); headers.set(HttpHeaders.ACCEPT_CHARSET, StandardCharsets.UTF_8.toString());
HttpEntity httpEntity = new HttpEntity<>(param, headers);
ResponseEntity<String> exchange = restTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class);
String body = exchange.getBody();
logger.info("返回信息:"+body);
if(StringUtils.isNotEmpty(body)){
JSONObject jsonObject = JSONObject.parseObject(body);
JSONArray jsonArray = jsonObject.getJSONArray("result");
for (int j= 0;j<jsonArray.size();j++){
JSONObject jsonObjectOne=jsonArray.getJSONObject(j);
int ydrs =0;
int sdrs = 0;
Integer ydrs1 = jsonObjectOne.getJSONObject("mainTable").getInteger("ydrs");
Integer sdrs1 = jsonObjectOne.getJSONObject("mainTable").getInteger("sdrs");
if(ydrs1 != null ){
ydrs = ydrs1 ;
}
if(sdrs1 != null ){
sdrs = sdrs1 ;
}
kqtjVO.setYdrs(ydrs);
kqtjVO.setSdrs(sdrs);
}
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("错误信息:",e); logger.error("错误信息:",e);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment