Compare commits
	
		
			2 Commits
		
	
	
		
			4bcbbe8cb0
			...
			2b301aa939
		
	
	| Author | SHA1 | Date | 
|---|---|---|
| 
							
							
								 | 
						2b301aa939 | |
| 
							
							
								 | 
						e53a7fa44e | 
| 
						 | 
				
			
			@ -1,10 +1,13 @@
 | 
			
		|||
package nccloud.web.uapbd.material.action;
 | 
			
		||||
 | 
			
		||||
import nc.bs.logging.Logger;
 | 
			
		||||
import nc.bs.uapbd.util.GetPlmFileUtil;
 | 
			
		||||
import nccloud.baseapp.core.log.NCCForUAPLogger;
 | 
			
		||||
import nccloud.framework.core.io.WebFile;
 | 
			
		||||
import nccloud.framework.web.action.itf.ICommonAction;
 | 
			
		||||
import nccloud.framework.web.container.IRequest;
 | 
			
		||||
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
| 
						 | 
				
			
			@ -21,11 +24,13 @@ public class MaterialPlmDownloadAction implements ICommonAction {
 | 
			
		|||
        try {
 | 
			
		||||
            Map<String, String[]> params_1 = request.readParameters();
 | 
			
		||||
            String[] pks = params_1.get("materialCode"); // »ñÈ¡ËùÓÐ pk
 | 
			
		||||
            String materialCode = "101092250323,101092250323";
 | 
			
		||||
            NCCForUAPLogger.debug("获取所有 pk:" + Arrays.toString(pks));
 | 
			
		||||
            String materialCode = "101092250323,101092250321,101092250322";
 | 
			
		||||
            String[] materialCodeArr = materialCode.split(",", -1);
 | 
			
		||||
            GetPlmFileUtil fileUtil = new GetPlmFileUtil();
 | 
			
		||||
            files = fileUtil.getPlmFiles(materialCodeArr);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            Logger.error("MaterialPlmDownloadAction-exp:" + e.getMessage());
 | 
			
		||||
            throw new RuntimeException(e);
 | 
			
		||||
        }
 | 
			
		||||
        return files;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -88,8 +88,8 @@ public class GetPlmFileUtil {
 | 
			
		|||
            String objId = plmFileJson.getString("objId");
 | 
			
		||||
            String fname = plmFileJson.getString("fname");
 | 
			
		||||
 | 
			
		||||
            byte[] pdfBytes = this.doDownloadPlmFile(objId);
 | 
			
		||||
            InputStream ins = new ByteArrayInputStream(pdfBytes);
 | 
			
		||||
            byte[] fileBytes = this.doDownloadPlmFile(objId);
 | 
			
		||||
            InputStream ins = new ByteArrayInputStream(fileBytes);
 | 
			
		||||
 | 
			
		||||
            file = new WebFile(fname, ins);
 | 
			
		||||
        } else {
 | 
			
		||||
| 
						 | 
				
			
			@ -98,29 +98,14 @@ public class GetPlmFileUtil {
 | 
			
		|||
            ByteArrayOutputStream zipOut = new ByteArrayOutputStream();
 | 
			
		||||
            ZipOutputStream zipStream = new ZipOutputStream(zipOut);
 | 
			
		||||
            try {
 | 
			
		||||
//                int i=0;
 | 
			
		||||
                for (String materialCode : materialCodeArr) {
 | 
			
		||||
                    JSONObject plmFileJson = this.getPlmFile(materialCode);
 | 
			
		||||
                    String objId = plmFileJson.getString("objId");
 | 
			
		||||
                    String fname = plmFileJson.getString("fname");
 | 
			
		||||
                    byte[] pdfBytes =this.doDownloadPlmFile(objId);
 | 
			
		||||
                    InputStream ins = new ByteArrayInputStream(pdfBytes);
 | 
			
		||||
//                    InputStream ins = this.doDownloadPlmFile(objId);
 | 
			
		||||
                    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());
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    byte[] fileBytes = this.doDownloadPlmFile(objId);
 | 
			
		||||
                    zipStream.putNextEntry(new ZipEntry(fname));
 | 
			
		||||
                    zipStream.write(fileBytes);
 | 
			
		||||
                    zipStream.closeEntry();
 | 
			
		||||
                }
 | 
			
		||||
                zipStream.finish();
 | 
			
		||||
            } finally {
 | 
			
		||||
| 
						 | 
				
			
			@ -289,16 +274,6 @@ public class GetPlmFileUtil {
 | 
			
		|||
        byte[] responseString = httpClient.execute(get, response -> EntityUtils.toByteArray(response.getEntity()));
 | 
			
		||||
        get.releaseConnection();
 | 
			
		||||
        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,9 +39,10 @@ public class MyHelper {
 | 
			
		|||
        sqlBuilder.append(pkField, pk);
 | 
			
		||||
        Object o = dao.executeQuery(sqlBuilder.toString(), new ColumnProcessor());
 | 
			
		||||
        if (o == null) {
 | 
			
		||||
            throw new BusinessException("未查询到编码信息,sql【" + sqlBuilder + "】");
 | 
			
		||||
            Logger.info("未查询到编码信息,sql【" + sqlBuilder + "】");
 | 
			
		||||
            // throw new BusinessException("未查询到编码信息,sql【" + sqlBuilder + "】");
 | 
			
		||||
        }
 | 
			
		||||
        return o.toString();
 | 
			
		||||
        return String.valueOf(o);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue