Merge remote-tracking branch 'origin/test' into test

pull/163/head
shuliYao 1 year ago
commit 96e58dd8a3

@ -4,6 +4,9 @@
<meta charset="utf-8"/> <meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>数据拉取日志</title> <title>数据拉取日志</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>
<#include "/head/headlist.html" /> <#include "/head/headlist.html" />
</head> </head>
<body class="gray-bg"> <body class="gray-bg">
@ -138,7 +141,21 @@
}, },
{width: 80, valign: "middle", field: 'responseParam', title: '响应参数', sortable: true}, {width: 80, valign: "middle", field: 'responseParam', title: '响应参数', sortable: true},
{width: 80, valign: "middle", field: 'requestParam', title: '请求参数', sortable: true}, {width: 80, valign: "middle", field: 'requestParam', title: '请求参数', sortable: true},
{
width:200,
field: 'id',
title: '操作',
formatter:function(value,oData,index) {
var listOperation = "";
$(jspOperation).each(function (i, toolbar) {
console.log(toolbar);
if (toolbar.text === '修改' && oData.status !== 100) {
listOperation = listOperation + "<a href=\"javascript:" + toolbar.actionmethod + "('${resourceid}','" + encodeURIComponent(oData.requestParam) + "');\" class=\"btn " + toolbar.img + " btn-xs\")><i class=\"fa " + "fa-refresh" + "\"></i> " + "重试" + " </a>&nbsp;&nbsp;";
}
});
return listOperation;
}
}
] ]
}); });
} }
@ -149,5 +166,26 @@
function refreshTable(sourceid){ function refreshTable(sourceid){
_tableListPost.bootstrapTable('refreshOptions',{pageNumber:1}); _tableListPost.bootstrapTable('refreshOptions',{pageNumber:1});
} }
function updateData(jframeid,str){
$(document).ready(function() {
// Encode the parameter string to be URL-safe
// Make an AJAX GET request
$.ajax({
url: '${ctx}/test/api/pullPictureByParameter', // Replace with your server endpoint
type: 'GET',
headers: {"logintoken": parent.getLoginToken()},
data: { parameterString: str },
success: function(response) {
console.log(response);
toastr.success('Request was successful!');
},
error: function(xhr, status, error) {
console.log(error);
toastr.error('Request was failed!');
}
});
});
}
</script> </script>

@ -16,6 +16,7 @@ import cn.jyjz.xiaoyao.ocr.api.utils.ApiPage;
import cn.jyjz.xiaoyao.ocr.service.OcrPictureService; import cn.jyjz.xiaoyao.ocr.service.OcrPictureService;
import cn.jyjz.xiaoyao.ocr.service.OcrPrevailCloudLogService; import cn.jyjz.xiaoyao.ocr.service.OcrPrevailCloudLogService;
import cn.jyjz.xiaoyao.ocr.thread.TaskQueue; import cn.jyjz.xiaoyao.ocr.thread.TaskQueue;
import cn.jyjz.xiaoyao.ocr.util.RequestParameterFormat;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import lombok.extern.flogger.Flogger; import lombok.extern.flogger.Flogger;
@ -24,6 +25,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.compress.utils.Lists; import org.apache.commons.compress.utils.Lists;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import sun.nio.ch.ThreadPool; import sun.nio.ch.ThreadPool;
@ -276,6 +278,32 @@ public class PrevailCloudApiController {
return "处理成功"; return "处理成功";
} }
@GetMapping("/pullPictureByParameter")
public Boolean pullPictureByParameter(String parameterString) {
PictureSourceParameter pictureSourceParameter = RequestParameterFormat.fromString(parameterString);
List<PictureSourceResult> resultList = prevailCloudApi.getPictureSourceResultApiPage(pictureSourceParameter);
if (CollectionUtils.isEmpty(resultList)) {
return false;
}
for (PictureSourceResult pictureSourceResult : resultList) {
//1.如果不存在图片默认一个默认图片,方便走测试。
if (pictureSourceResult.getLivePhoto() == null) {
List<Map<String, Object>> livePhoto = new ArrayList<>();
Map<String, Object> map = new HashMap<>();
map.put("imgUrl", StringUtils.isEmpty(apiConfig.getDefaultPictureImg()) ? "http://47.93.59.251/api/image/default.png" : apiConfig.getDefaultPictureImg());
map.put("imgName", "default.png");
livePhoto.add(map);
pictureSourceResult.setLivePhoto(livePhoto);
}
//赋值默认参数
pictureSourceResult.setRequestParam(pictureSourceParameter);
//将可以处理数据放入处理队列中
TaskQueue.pictureDisposePushData(pictureSourceResult, ocrPictureService, ocrPrevailCloudLogService);
}
return true;
}
@GetMapping("pullAccountInfo") @GetMapping("pullAccountInfo")
public String pullAccountInfo(HttpServletRequest request) { public String pullAccountInfo(HttpServletRequest request) {

@ -0,0 +1,91 @@
package cn.jyjz.xiaoyao.ocr.util;
import cn.jyjz.xiaoyao.ocr.api.entity.PictureSourceParameter;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.TimeZone;
import java.util.Locale;
public class RequestParameterFormat {
public static PictureSourceParameter fromString(String inputString) {
if (isJsonString(inputString)) {
return fromJsonString(inputString);
} else if (isCustomString(inputString)) {
try {
return fromCustomString(inputString);
} catch (ParseException e) {
throw new RuntimeException("Failed to parse custom string", e);
}
} else {
throw new IllegalArgumentException("Input string does not match known formats");
}
}
private static boolean isJsonString(String str) {
return str.trim().startsWith("{") && str.trim().endsWith("}");
}
private static boolean isCustomString(String str) {
return str.startsWith("PictureSourceParameter(") && str.endsWith(")");
}
public static PictureSourceParameter fromJsonString(String jsonString) {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
try {
return objectMapper.readValue(jsonString, PictureSourceParameter.class);
} catch (Exception e) {
throw new RuntimeException("Failed to parse JSON string", e);
}
}
public static PictureSourceParameter fromCustomString(String customString) throws ParseException {
Pattern pattern = Pattern.compile(
"PictureSourceParameter\\(startTime=(.*?), endTime=(.*?), pageSize=(.*?), pageNo=(.*?), projectNo=(.*?), planId=(.*?), accountNo=(.*?), tenantNo=(.*?)\\)");
Matcher matcher = pattern.matcher(customString);
if (!matcher.matches()) {
throw new IllegalArgumentException("String does not match the expected format");
}
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.ENGLISH);
dateFormat.setTimeZone(TimeZone.getTimeZone("CST"));
PictureSourceParameter param = new PictureSourceParameter();
param.setStartTime(parseDate(matcher.group(1).trim(), dateFormat));
param.setEndTime(parseDate(matcher.group(2).trim(), dateFormat));
param.setPageSize(Integer.parseInt(matcher.group(3).trim()));
param.setPageNo(Integer.parseInt(matcher.group(4).trim()));
param.setProjectNo(parseLong(matcher.group(5).trim()));
param.setPlanId(parseLong(matcher.group(6).trim()));
param.setAccountNo(parseLong(matcher.group(7).trim()));
param.setTenantNo(parseLong(matcher.group(8).trim()));
return param;
}
private static Date parseDate(String dateString, SimpleDateFormat dateFormat) throws ParseException {
try {
return dateFormat.parse(dateString);
} catch (ParseException e) {
// Try parsing with alternative formats if necessary
throw e;
}
}
private static Long parseLong(String value) {
if ("null".equals(value)) {
return null;
}
return Long.parseLong(value);
}
}
Loading…
Cancel
Save