bug修复
This commit is contained in:
parent
df60ff3880
commit
be99b64aa7
@ -2,121 +2,43 @@ package com.zhgd.jeecg.common.util.pass;
|
||||
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.gexin.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* http 工具类 获取请求中的参数
|
||||
* http 工具类,打印日志
|
||||
*
|
||||
* @author show
|
||||
* @date 14:23 2019/5/29
|
||||
*/
|
||||
@Slf4j
|
||||
public class HttpUtils {
|
||||
/**
|
||||
* 将URL的参数和body参数合并
|
||||
*
|
||||
* @param request
|
||||
* @author show
|
||||
* @date 14:24 2019/5/29
|
||||
*/
|
||||
public static SortedMap<String, Object> getAllParams(HttpServletRequest request) throws IOException {
|
||||
|
||||
SortedMap<String, Object> result = new TreeMap<>();
|
||||
//获取URL上的参数
|
||||
Map<String, Object> urlParams = getUrlParams(request);
|
||||
for (Map.Entry entry : urlParams.entrySet()) {
|
||||
result.put((String) entry.getKey(), entry.getValue());
|
||||
}
|
||||
Map<String, String> allRequestParam = new HashMap<>(16);
|
||||
// get请求不需要拿body参数
|
||||
if (!HttpMethod.GET.name().equals(request.getMethod())) {
|
||||
allRequestParam = getAllRequestParam(request);
|
||||
}
|
||||
//将URL的参数和body参数进行合并
|
||||
if (allRequestParam != null) {
|
||||
for (Map.Entry entry : allRequestParam.entrySet()) {
|
||||
result.put((String) entry.getKey(), (String) entry.getValue());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 Body 参数
|
||||
*
|
||||
* @param request
|
||||
* @author show
|
||||
* @date 15:04 2019/5/30
|
||||
*/
|
||||
public static Map<String, String> getAllRequestParam(final HttpServletRequest request) throws IOException {
|
||||
InputStreamReader inputStreamReader = null;
|
||||
StringBuilder wholeStr = new StringBuilder();
|
||||
BufferedReader reader = null;
|
||||
try {
|
||||
inputStreamReader = new InputStreamReader(request.getInputStream());
|
||||
//BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream()));
|
||||
reader = new BufferedReader(inputStreamReader);
|
||||
String str = "";
|
||||
//一行一行的读取body体里面的内容;
|
||||
while ((str = reader.readLine()) != null) {
|
||||
wholeStr.append(str);
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
inputStreamReader.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
reader.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
//转化成json对象
|
||||
return JSONObject.parseObject(StringUtils.isNotEmpty(wholeStr.toString()) ? wholeStr.toString() : "{}", Map.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将URL请求参数转换成Map
|
||||
*
|
||||
* @param request
|
||||
* @author show
|
||||
*/
|
||||
public static Map<String, Object> getUrlParams(HttpServletRequest request) {
|
||||
|
||||
Enumeration enu = request.getParameterNames();
|
||||
Map<String, Object> result = new HashMap<>(16);
|
||||
while (enu.hasMoreElements()) {
|
||||
String paraName = (String) enu.nextElement();
|
||||
log.info(paraName + ": " + request.getParameter(paraName));
|
||||
result.put(paraName, request.getParameter(paraName));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送http请求,json格式
|
||||
* 发送post,http请求,json格式
|
||||
*
|
||||
* @param url
|
||||
* @param body
|
||||
*/
|
||||
public static String post(String url, Object body) {
|
||||
public static String postJson(String url, Object body) {
|
||||
String b = JSON.toJSONString(body);
|
||||
log.info("post(rq):url:{},body:{}", url, b);
|
||||
log.info("postJson(rq):url:{},body:{}", url, b);
|
||||
String rs = HttpUtil.post(url, b);
|
||||
log.info("post(rs):url:{},rs:{}", url, rs);
|
||||
log.info("postJson(rs):url:{},rs:{}", url, rs);
|
||||
return rs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送get,http请求,json格式
|
||||
*
|
||||
* @param url
|
||||
*/
|
||||
public static String get(String url) {
|
||||
log.info("get(rq):url:{}", url);
|
||||
String rs = HttpUtil.get(url);
|
||||
log.info("get(rs):url:{},rs:{}", url, rs);
|
||||
return rs;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ public class weixinUtils {
|
||||
// json.put("form_id",formId);
|
||||
// json.put("data",data);
|
||||
// log.info(json.toJSONString());
|
||||
// String result= HttpUtil.post(weixinUrl+"/cgi-bin/message/wxopen/template/send?access_token="+token,json.toJSONString());
|
||||
// String result= HttpUtil.postJson(weixinUrl+"/cgi-bin/message/wxopen/template/send?access_token="+token,json.toJSONString());
|
||||
// log.info(result);
|
||||
// if(result!=null&&result.length()>0){
|
||||
// Map<String,Object> map=JSONUtil.readValueToMap(result);
|
||||
|
||||
@ -34,7 +34,7 @@ public class JiLianDaCall {
|
||||
if (!ifSend()) {
|
||||
return;
|
||||
}
|
||||
thirdPartRequestUtil.post(jldPushUrl + "/saveEnterpriseInfo", enterpriseInfo);
|
||||
thirdPartRequestUtil.postJson(jldPushUrl + "/saveEnterpriseInfo", enterpriseInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -46,48 +46,48 @@ public class JiLianDaCall {
|
||||
if (!ifSend()) {
|
||||
return;
|
||||
}
|
||||
thirdPartRequestUtil.post(jldPushUrl + "/removeEnterpriseInfo", projectEnterprise);
|
||||
thirdPartRequestUtil.postJson(jldPushUrl + "/removeEnterpriseInfo", projectEnterprise);
|
||||
}
|
||||
|
||||
public void saveTeamInfo(TeamInfo teamInfo) {
|
||||
if (!ifSend()) {
|
||||
return;
|
||||
}
|
||||
thirdPartRequestUtil.post(jldPushUrl + "/saveTeamInfo", teamInfo);
|
||||
thirdPartRequestUtil.postJson(jldPushUrl + "/saveTeamInfo", teamInfo);
|
||||
}
|
||||
|
||||
public void removeTeamInfo(TeamInfo teamInfo) {
|
||||
if (!ifSend()) {
|
||||
return;
|
||||
}
|
||||
thirdPartRequestUtil.post(jldPushUrl + "/removeTeamInfo", teamInfo);
|
||||
thirdPartRequestUtil.postJson(jldPushUrl + "/removeTeamInfo", teamInfo);
|
||||
}
|
||||
|
||||
public void saveWorkerInfo(WorkerInfo workerInfo) {
|
||||
if (!ifSend()) {
|
||||
return;
|
||||
}
|
||||
thirdPartRequestUtil.post(jldPushUrl + "/saveWorkerInfo", workerInfo);
|
||||
thirdPartRequestUtil.postJson(jldPushUrl + "/saveWorkerInfo", workerInfo);
|
||||
}
|
||||
|
||||
public void removeWorkerInfo(WorkerInfo workerInfo) {
|
||||
if (!ifSend()) {
|
||||
return;
|
||||
}
|
||||
thirdPartRequestUtil.post(jldPushUrl + "/removeWorkerInfo", workerInfo);
|
||||
thirdPartRequestUtil.postJson(jldPushUrl + "/removeWorkerInfo", workerInfo);
|
||||
}
|
||||
|
||||
public void saveDepartmentInfo(DepartmentInfo departmentInfo) {
|
||||
if (!ifSend()) {
|
||||
return;
|
||||
}
|
||||
thirdPartRequestUtil.post(jldPushUrl + "/saveDepartmentInfo", departmentInfo);
|
||||
thirdPartRequestUtil.postJson(jldPushUrl + "/saveDepartmentInfo", departmentInfo);
|
||||
}
|
||||
|
||||
public void removeDepartmentInfo(DepartmentInfo departmentInfo) {
|
||||
if (!ifSend()) {
|
||||
return;
|
||||
}
|
||||
thirdPartRequestUtil.post(jldPushUrl + "/removeDepartmentInfo", departmentInfo);
|
||||
thirdPartRequestUtil.postJson(jldPushUrl + "/removeDepartmentInfo", departmentInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@ -742,7 +742,7 @@ public class EnvironmentAlarmServiceImpl extends ServiceImpl<EnvironmentAlarmMap
|
||||
object.put("dataId",alarmIdList);
|
||||
object.put("type",1);
|
||||
log.info(JSONUtil.toJsonStr(object));
|
||||
String result=HttpUtil.post("http://127.0.0.1:6500/api/analysisVideo", JSONUtil.toJsonStr(object));
|
||||
String result=HttpUtil.postJson("http://127.0.0.1:6500/api/analysisVideo", JSONUtil.toJsonStr(object));
|
||||
log.info(result);
|
||||
}*/
|
||||
|
||||
|
||||
@ -81,6 +81,7 @@ public class StableWaterMixStationDataController {
|
||||
@ApiOperation(value = "添加水稳拌合站数据信息", notes = "添加水稳拌合站数据信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<StableWaterMixStationData> add(@RequestBody StableWaterMixStationData stableWaterMixStationData) {
|
||||
log.info("添加水稳拌合站数据信息:{}", JSON.toJSONString(stableWaterMixStationData));
|
||||
stableWaterMixStationDataService.add(stableWaterMixStationData);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ -2,8 +2,10 @@ package com.zhgd.xmgl.modules.stablewater.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
@ -172,9 +174,9 @@ public class StableWaterMixStationData implements Serializable {
|
||||
/**
|
||||
* 时间戳
|
||||
*/
|
||||
@Excel(name = "时间戳", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "时间戳", width = 20, format = "yyyy-MM-dd HH:mm:ss.SSS")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss.SSS")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
|
||||
@ApiModelProperty(value = "时间戳")
|
||||
private java.util.Date timestamp;
|
||||
/**
|
||||
@ -192,9 +194,9 @@ public class StableWaterMixStationData implements Serializable {
|
||||
/**
|
||||
* 生产时间 / 发料时间
|
||||
*/
|
||||
@Excel(name = "生产时间 / 发料时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "生产时间 / 发料时间", width = 20, format = "yyyy-MM-dd HH:mm:ss.SSS")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss.SSS")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
|
||||
@ApiModelProperty(value = "生产时间 / 发料时间")
|
||||
private java.util.Date scsj;
|
||||
/**
|
||||
@ -225,4 +227,9 @@ public class StableWaterMixStationData implements Serializable {
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "更新时间 yyyy-MM-dd HH:mm:ss")
|
||||
private java.util.Date updateDate;
|
||||
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "水稳拌合站盘次数据列表")
|
||||
private List<StableWaterMixStationSetData> setDataList;
|
||||
|
||||
}
|
||||
|
||||
@ -36,6 +36,9 @@ public class StableWaterMixStationDev implements Serializable {
|
||||
@Excel(name = "设备sn", width = 15)
|
||||
@ApiModelProperty(value = "设备sn")
|
||||
private java.lang.String devSn;
|
||||
@ApiModelProperty(value = "站点编码")
|
||||
private java.lang.String siteEncoding;
|
||||
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
|
||||
@ -1,17 +1,18 @@
|
||||
package com.zhgd.xmgl.modules.stablewater.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 水稳拌合站盘次数据
|
||||
@ -99,4 +100,8 @@ public class StableWaterMixStationSetData implements Serializable {
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "更新时间 yyyy-MM-dd HH:mm:ss")
|
||||
private java.util.Date updateDate;
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "水稳拌合站原材数据列表")
|
||||
private List<StableWaterMixStationRawMaterialData> rawMaterialDataList;
|
||||
|
||||
}
|
||||
|
||||
@ -1,23 +1,31 @@
|
||||
package com.zhgd.xmgl.modules.stablewater.service.impl;
|
||||
|
||||
import com.zhgd.xmgl.modules.stablewater.entity.StableWaterMixStationData;
|
||||
import com.zhgd.xmgl.modules.stablewater.mapper.StableWaterMixStationDataMapper;
|
||||
import com.zhgd.xmgl.modules.stablewater.service.IStableWaterMixStationDataService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
||||
import com.zhgd.xmgl.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
||||
import com.zhgd.xmgl.modules.stablewater.entity.StableWaterMixStationData;
|
||||
import com.zhgd.xmgl.modules.stablewater.entity.StableWaterMixStationDev;
|
||||
import com.zhgd.xmgl.modules.stablewater.entity.StableWaterMixStationRawMaterialData;
|
||||
import com.zhgd.xmgl.modules.stablewater.entity.StableWaterMixStationSetData;
|
||||
import com.zhgd.xmgl.modules.stablewater.mapper.StableWaterMixStationDataMapper;
|
||||
import com.zhgd.xmgl.modules.stablewater.mapper.StableWaterMixStationDevMapper;
|
||||
import com.zhgd.xmgl.modules.stablewater.mapper.StableWaterMixStationRawMaterialDataMapper;
|
||||
import com.zhgd.xmgl.modules.stablewater.mapper.StableWaterMixStationSetDataMapper;
|
||||
import com.zhgd.xmgl.modules.stablewater.service.IStableWaterMixStationDataService;
|
||||
import com.zhgd.xmgl.util.PageUtil;
|
||||
import com.zhgd.xmgl.util.RefUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.zhgd.xmgl.util.RefUtil;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* @Description: 水稳拌合站数据
|
||||
* @author: pds
|
||||
@ -29,6 +37,12 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
public class StableWaterMixStationDataServiceImpl extends ServiceImpl<StableWaterMixStationDataMapper, StableWaterMixStationData> implements IStableWaterMixStationDataService {
|
||||
@Autowired
|
||||
private StableWaterMixStationDataMapper stableWaterMixStationDataMapper;
|
||||
@Autowired
|
||||
private StableWaterMixStationRawMaterialDataMapper stableWaterMixStationRawMaterialDataMapper;
|
||||
@Autowired
|
||||
private StableWaterMixStationSetDataMapper stableWaterMixStationSetDataMapper;
|
||||
@Autowired
|
||||
private StableWaterMixStationDevMapper stableWaterMixStationDevMapper;
|
||||
|
||||
@Override
|
||||
public IPage<StableWaterMixStationData> queryPageList(HashMap<String, Object> paramMap) {
|
||||
@ -57,9 +71,35 @@ public class StableWaterMixStationDataServiceImpl extends ServiceImpl<StableWate
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(StableWaterMixStationData stableWaterMixStationData) {
|
||||
stableWaterMixStationData.setId(null);
|
||||
baseMapper.insert(stableWaterMixStationData);
|
||||
public void add(StableWaterMixStationData data) {
|
||||
String devSn = data.getDevSn();
|
||||
StableWaterMixStationDev dev = stableWaterMixStationDevMapper.selectOne(new LambdaQueryWrapper<StableWaterMixStationDev>()
|
||||
.eq(StableWaterMixStationDev::getDevSn, devSn));
|
||||
if (dev == null) {
|
||||
throw new OpenAlertException("设备编号不正确");
|
||||
}
|
||||
String projectSn = dev.getProjectSn();
|
||||
data.setId(null);
|
||||
data.setProjectSn(projectSn);
|
||||
baseMapper.insert(data);
|
||||
List<StableWaterMixStationSetData> setDataList = data.getSetDataList();
|
||||
if (CollUtil.isNotEmpty(setDataList)) {
|
||||
for (StableWaterMixStationSetData setData : setDataList) {
|
||||
setData.setStableWaterMixStationDataId(data.getId());
|
||||
setData.setDevSn(devSn);
|
||||
setData.setProjectSn(projectSn);
|
||||
stableWaterMixStationSetDataMapper.insert(setData);
|
||||
List<StableWaterMixStationRawMaterialData> rawMaterialDataList = setData.getRawMaterialDataList();
|
||||
if (CollUtil.isNotEmpty(rawMaterialDataList)) {
|
||||
for (StableWaterMixStationRawMaterialData rawMaterialData : rawMaterialDataList) {
|
||||
rawMaterialData.setStableWaterMixStationSetDataId(setData.getId());
|
||||
rawMaterialData.setDevSn(devSn);
|
||||
rawMaterialData.setProjectSn(projectSn);
|
||||
stableWaterMixStationRawMaterialDataMapper.insert(rawMaterialData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -253,6 +253,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.antMatchers("/xmgl/smartTensionData/add").permitAll()
|
||||
.antMatchers("/xmgl/smartGroutData/add").permitAll()
|
||||
.antMatchers("/xmgl/bimface/getDetailsByFileIdAndProjectSn").permitAll()
|
||||
.antMatchers("/xmgl/stableWaterMixStationData/add").permitAll()
|
||||
.antMatchers(HttpMethod.OPTIONS, "/**").anonymous()
|
||||
.anyRequest().authenticated() // 剩下所有的验证都需要验证
|
||||
.and()
|
||||
|
||||
@ -0,0 +1,38 @@
|
||||
package com.zhgd.xmgl.task;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.zhgd.xmgl.util.ThirdPartRequestUtil;
|
||||
import lombok.extern.log4j.Log4j;
|
||||
import net.javacrumbs.shedlock.core.SchedulerLock;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 水稳拌合站任务
|
||||
*/
|
||||
@Log4j
|
||||
@Component
|
||||
public class StableWaterMixStationTask {
|
||||
@Autowired
|
||||
ThirdPartRequestUtil thirdPartRequestUtil;
|
||||
|
||||
/**
|
||||
* 定时拉取广联达的搅拌站数据,https://xmgl.glodon.com/wl/docs/third_help/part2/openapi/pull/mixTotal.html
|
||||
*/
|
||||
@Scheduled(cron = "0 2 0 * * ?")
|
||||
@SchedulerLock(name = "executeStableWaterMixStationTask", lockAtMostFor = 1000 * 60 * 2, lockAtLeastFor = 1000 * 60 * 1)
|
||||
public void executeTask() {
|
||||
log.info("定时拉取广联达的搅拌站数据任务开始");
|
||||
//String url = "/api/mix/v1.0/mix/product/getMachineProductList?projectId=1460369&beginTimestamp=20170710101010000";
|
||||
//String rs = thirdPartRequestUtil.get(url);
|
||||
//JSONObject jo = JSON.parseObject(rs);
|
||||
//if (Objects.equals(jo.getBoolean("success"), true)) {
|
||||
// BeanUtil.copyProperties();
|
||||
//}
|
||||
}
|
||||
}
|
||||
@ -72,12 +72,12 @@ public class IdCardUtils {
|
||||
public static String getIdCardInfo(String imageurl, boolean side) {
|
||||
if (enable) {
|
||||
// String JSONSTR = "{ \n \"auth\": { \n \"identity\": { \n \"methods\": [ \n \"password\" \n ], \n \"password\": { \n \"user\": { \n\"name\": \"" + username + "\", \n \"password\": \"" + password + "\", \n \"domain\": { \n \"name\": \"" + domainname + "\" \n } \n } \n} \n}, \n\"scope\": { \n \"project\": { \n\"name\": \"cn-east-3\" \n} \n} \n} \n}";
|
||||
// String token = HttpRequest.post(tokenurl).body(String.valueOf(JSONUtil.parse(JSONSTR))).execute().header("X-Subject-Token");
|
||||
// String token = HttpRequest.postJson(tokenurl).body(String.valueOf(JSONUtil.parse(JSONSTR))).execute().header("X-Subject-Token");
|
||||
// String url = "https://ocr.cn-east-3.myhuaweicloud.com/v2/" + projectid + "/ocr/id-card";
|
||||
// Map<String, Object> param = new HashMap<>();
|
||||
// param.put("url", imageurl);
|
||||
// param.put("side", side ? "front" : "back");
|
||||
// String result = HttpRequest.post(url).header("X-Auth-Token", token).body(String.valueOf(JSONUtil.parse(param))).execute().body();
|
||||
// String result = HttpRequest.postJson(url).header("X-Auth-Token", token).body(String.valueOf(JSONUtil.parse(param))).execute().body();
|
||||
// log.info(result);
|
||||
// return result;
|
||||
|
||||
@ -209,7 +209,7 @@ public class IdCardUtils {
|
||||
String imageurl="http://119.29.110.58:9000/itbgp/file/3b097a48-7e46-407c-9e32-fc725204c485.jpg";
|
||||
String JSONSTR=getTokenStr(domain,username,password,"cn-north-4");
|
||||
|
||||
String token = HttpRequest.post("https://iam.cn-north-4.myhuaweicloud.com/v3/auth/tokens").body(JSONUtil.toJsonStr(JSONSTR)).execute().header("x-subject-token");
|
||||
String token = HttpRequest.postJson("https://iam.cn-north-4.myhuaweicloud.com/v3/auth/tokens").body(JSONUtil.toJsonStr(JSONSTR)).execute().header("x-subject-token");
|
||||
log.info(token);
|
||||
}*/
|
||||
}
|
||||
|
||||
@ -7,6 +7,9 @@ import com.zhgd.xmgl.modules.basicdata.mapper.ThirdPartRequestLogMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 请求第三方请求记录工具,记录日志到数据库
|
||||
*/
|
||||
@Component
|
||||
public class ThirdPartRequestUtil {
|
||||
@Autowired
|
||||
@ -18,17 +21,35 @@ public class ThirdPartRequestUtil {
|
||||
* @param url
|
||||
* @param body
|
||||
*/
|
||||
public String post(String url, Object body) {
|
||||
public String postJson(String url, Object body) {
|
||||
ThirdPartRequestLog log = new ThirdPartRequestLog();
|
||||
log.setUrl(url);
|
||||
log.setMethod(2);
|
||||
log.setParam(JSON.toJSONString(body));
|
||||
thirdPartRequestLogMapper.insert(log);
|
||||
String rs = HttpUtils.post(url, body);
|
||||
String rs = HttpUtils.postJson(url, body);
|
||||
log.setResult(rs);
|
||||
log.setStatus(1);
|
||||
thirdPartRequestLogMapper.updateById(log);
|
||||
return rs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送get,http请求
|
||||
*
|
||||
* @param url
|
||||
*/
|
||||
public String get(String url) {
|
||||
ThirdPartRequestLog log = new ThirdPartRequestLog();
|
||||
log.setUrl(url);
|
||||
log.setMethod(1);
|
||||
thirdPartRequestLogMapper.insert(log);
|
||||
String rs = HttpUtils.get(url);
|
||||
log.setResult(rs);
|
||||
log.setStatus(1);
|
||||
thirdPartRequestLogMapper.updateById(log);
|
||||
return rs;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user