Compare commits
No commits in common. "2b301aa939705568be1140c712970ec43f8c7a3c" and "4bcbbe8cb03b0acb74ea24187af4457648cfe8cc" have entirely different histories.
2b301aa939
...
4bcbbe8cb0
|
@ -1,13 +1,10 @@
|
||||||
package nccloud.web.uapbd.material.action;
|
package nccloud.web.uapbd.material.action;
|
||||||
|
|
||||||
import nc.bs.logging.Logger;
|
|
||||||
import nc.bs.uapbd.util.GetPlmFileUtil;
|
import nc.bs.uapbd.util.GetPlmFileUtil;
|
||||||
import nccloud.baseapp.core.log.NCCForUAPLogger;
|
|
||||||
import nccloud.framework.core.io.WebFile;
|
import nccloud.framework.core.io.WebFile;
|
||||||
import nccloud.framework.web.action.itf.ICommonAction;
|
import nccloud.framework.web.action.itf.ICommonAction;
|
||||||
import nccloud.framework.web.container.IRequest;
|
import nccloud.framework.web.container.IRequest;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,13 +21,11 @@ public class MaterialPlmDownloadAction implements ICommonAction {
|
||||||
try {
|
try {
|
||||||
Map<String, String[]> params_1 = request.readParameters();
|
Map<String, String[]> params_1 = request.readParameters();
|
||||||
String[] pks = params_1.get("materialCode"); // »ñÈ¡ËùÓÐ pk
|
String[] pks = params_1.get("materialCode"); // »ñÈ¡ËùÓÐ pk
|
||||||
NCCForUAPLogger.debug("获取所有 pk:" + Arrays.toString(pks));
|
String materialCode = "101092250323,101092250323";
|
||||||
String materialCode = "101092250323,101092250321,101092250322";
|
|
||||||
String[] materialCodeArr = materialCode.split(",", -1);
|
String[] materialCodeArr = materialCode.split(",", -1);
|
||||||
GetPlmFileUtil fileUtil = new GetPlmFileUtil();
|
GetPlmFileUtil fileUtil = new GetPlmFileUtil();
|
||||||
files = fileUtil.getPlmFiles(materialCodeArr);
|
files = fileUtil.getPlmFiles(materialCodeArr);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.error("MaterialPlmDownloadAction-exp:" + e.getMessage());
|
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
return files;
|
return files;
|
||||||
|
|
|
@ -88,8 +88,8 @@ public class GetPlmFileUtil {
|
||||||
String objId = plmFileJson.getString("objId");
|
String objId = plmFileJson.getString("objId");
|
||||||
String fname = plmFileJson.getString("fname");
|
String fname = plmFileJson.getString("fname");
|
||||||
|
|
||||||
byte[] fileBytes = this.doDownloadPlmFile(objId);
|
byte[] pdfBytes = this.doDownloadPlmFile(objId);
|
||||||
InputStream ins = new ByteArrayInputStream(fileBytes);
|
InputStream ins = new ByteArrayInputStream(pdfBytes);
|
||||||
|
|
||||||
file = new WebFile(fname, ins);
|
file = new WebFile(fname, ins);
|
||||||
} else {
|
} else {
|
||||||
|
@ -98,14 +98,29 @@ public class GetPlmFileUtil {
|
||||||
ByteArrayOutputStream zipOut = new ByteArrayOutputStream();
|
ByteArrayOutputStream zipOut = new ByteArrayOutputStream();
|
||||||
ZipOutputStream zipStream = new ZipOutputStream(zipOut);
|
ZipOutputStream zipStream = new ZipOutputStream(zipOut);
|
||||||
try {
|
try {
|
||||||
|
// int i=0;
|
||||||
for (String materialCode : materialCodeArr) {
|
for (String materialCode : materialCodeArr) {
|
||||||
JSONObject plmFileJson = this.getPlmFile(materialCode);
|
JSONObject plmFileJson = this.getPlmFile(materialCode);
|
||||||
String objId = plmFileJson.getString("objId");
|
String objId = plmFileJson.getString("objId");
|
||||||
String fname = plmFileJson.getString("fname");
|
String fname = plmFileJson.getString("fname");
|
||||||
byte[] fileBytes = this.doDownloadPlmFile(objId);
|
byte[] pdfBytes =this.doDownloadPlmFile(objId);
|
||||||
zipStream.putNextEntry(new ZipEntry(fname));
|
InputStream ins = new ByteArrayInputStream(pdfBytes);
|
||||||
zipStream.write(fileBytes);
|
// InputStream ins = this.doDownloadPlmFile(objId);
|
||||||
zipStream.closeEntry();
|
try {
|
||||||
|
byte[] bytes = parseFileStream(ins);
|
||||||
|
zipStream.putNextEntry(new ZipEntry(fname+""));
|
||||||
|
// i++;
|
||||||
|
zipStream.write(bytes);
|
||||||
|
zipStream.closeEntry();
|
||||||
|
} finally {
|
||||||
|
if (ins != null) {
|
||||||
|
try {
|
||||||
|
ins.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error("Failed to close input stream: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
zipStream.finish();
|
zipStream.finish();
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -274,6 +289,16 @@ public class GetPlmFileUtil {
|
||||||
byte[] responseString = httpClient.execute(get, response -> EntityUtils.toByteArray(response.getEntity()));
|
byte[] responseString = httpClient.execute(get, response -> EntityUtils.toByteArray(response.getEntity()));
|
||||||
get.releaseConnection();
|
get.releaseConnection();
|
||||||
return responseString;
|
return responseString;
|
||||||
|
// // 执行请求并返回文件流
|
||||||
|
// return httpClient.execute(httpGet, response -> {
|
||||||
|
// // 检查响应状态
|
||||||
|
// int statusCode = response.getStatusLine().getStatusCode();
|
||||||
|
// if (statusCode >= 200 && statusCode < 300) {
|
||||||
|
// return response.getEntity().getContent();
|
||||||
|
// } else {
|
||||||
|
// throw new IOException("HTTP request failed with status code: " + statusCode);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -39,10 +39,9 @@ public class MyHelper {
|
||||||
sqlBuilder.append(pkField, pk);
|
sqlBuilder.append(pkField, pk);
|
||||||
Object o = dao.executeQuery(sqlBuilder.toString(), new ColumnProcessor());
|
Object o = dao.executeQuery(sqlBuilder.toString(), new ColumnProcessor());
|
||||||
if (o == null) {
|
if (o == null) {
|
||||||
Logger.info("未查询到编码信息,sql【" + sqlBuilder + "】");
|
throw new BusinessException("未查询到编码信息,sql【" + sqlBuilder + "】");
|
||||||
// throw new BusinessException("未查询到编码信息,sql【" + sqlBuilder + "】");
|
|
||||||
}
|
}
|
||||||
return String.valueOf(o);
|
return o.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue