临时访问地址&工具类

This commit is contained in:
李贵强 2025-10-30 10:31:50 +08:00
parent 5caf4c7eea
commit a4cbcb2a55
2 changed files with 51 additions and 0 deletions

View File

@ -14,6 +14,7 @@ import kd.bos.logging.LogFactory;
import kd.bos.orm.query.QCP; import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter; import kd.bos.orm.query.QFilter;
import kd.bos.schedule.executor.AbstractTask; import kd.bos.schedule.executor.AbstractTask;
import kd.bos.servicehelper.AttachmentServiceHelper;
import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.PrintServiceHelper; import kd.bos.servicehelper.PrintServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper; import kd.bos.servicehelper.operation.SaveServiceHelper;
@ -24,6 +25,7 @@ import kd.sdk.plugin.Plugin;
import kd.tmc.bei.common.helper.BeiHelper; import kd.tmc.bei.common.helper.BeiHelper;
import kd.tmc.bei.common.helper.ReceiptPrintHelper; import kd.tmc.bei.common.helper.ReceiptPrintHelper;
import kd.tmc.fbp.common.ofd.OfdConvertUtil; import kd.tmc.fbp.common.ofd.OfdConvertUtil;
import shjh.jhzj7.fi.fi.utils.UrlUtils;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
@ -72,6 +74,10 @@ public class ElecStatementUrlSaveTask extends AbstractTask implements Plugin {
if (!EmptyUtil.isEmpty(urlEntry)) { if (!EmptyUtil.isEmpty(urlEntry)) {
for (DynamicObject urlInfo : urlEntry) { for (DynamicObject urlInfo : urlEntry) {
String downloadUrl = getRealUploadUrl(urlInfo); // 需要实现这个方法 String downloadUrl = getRealUploadUrl(urlInfo); // 需要实现这个方法
// String remUrl = UrlUtils.removeParameter(downloadUrl, "kdedcba");
// String encreptURL = AttachmentServiceHelper.getEncreptURL(remUrl);
// bill.set("shjh_url", encreptURL);
// bill.set("shjh_url_tag", encreptURL);
bill.set("shjh_url", downloadUrl); bill.set("shjh_url", downloadUrl);
bill.set("shjh_url_tag", downloadUrl); bill.set("shjh_url_tag", downloadUrl);
SaveServiceHelper.update(bill); SaveServiceHelper.update(bill);

View File

@ -0,0 +1,45 @@
package shjh.jhzj7.fi.fi.utils;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
public class UrlUtils {
public static String removeParameter(String url, String paramToRemove) {
try {
URI uri = new URI(url);
String query = uri.getQuery();
if (query == null) {
return url;
}
String[] params = query.split("&");
List<String> filteredParams = new ArrayList<>();
for (String param : params) {
String[] keyValuePair = param.split("=", 2);
String key = keyValuePair[0];
if (!key.equals(paramToRemove)) {
filteredParams.add(param);
}
}
String newQuery = filteredParams.isEmpty() ? null : String.join("&", filteredParams);
URI newUri = new URI(
uri.getScheme(),
uri.getAuthority(),
uri.getPath(),
newQuery,
uri.getFragment()
);
return newUri.toString();
} catch (URISyntaxException e) {
throw new IllegalArgumentException("Invalid URL: " + url, e);
}
}
}