Kaynağa Gözat

优化代码

wuxw 3 yıl önce
ebeveyn
işleme
9f4b2d09e6

+ 7 - 1
java110-core/src/main/java/com/java110/core/client/FileUploadTemplate.java

@@ -11,6 +11,8 @@ import java.io.InputStream;
 @Component
 public class FileUploadTemplate {
 
+    private static final String ROOT_PATH = "hc/";
+
 
     @Autowired
     private FtpUploadTemplate ftpUploadTemplate;
@@ -27,6 +29,8 @@ public class FileUploadTemplate {
 
     public String saveFile(InputStream inputStream,String fileName){
 
+        fileName = ROOT_PATH+ fileName;
+
         String ossSwitch = MappingCache.getValue(OSSUtil.DOMAIN, OSSUtil.OSS_SWITCH);
 
         if (OSSUtil.OSS_SWITCH_OSS.equals(ossSwitch)) {
@@ -43,6 +47,8 @@ public class FileUploadTemplate {
                     ftpPort, ftpUserName,
                     ftpUserPassword, fileName);
         }
-        return fileName;
+
+        String imgUrl = MappingCache.getValue("IMG_PATH");
+        return imgUrl+fileName;
     }
 }

+ 1 - 2
java110-core/src/main/java/com/java110/core/client/OssUploadTemplate.java

@@ -112,7 +112,6 @@ public class OssUploadTemplate {
     }
 
     public String upload(InputStream inputStream,  String ftpPath) {
-        String fileName = "";
         OSSClient ossClient = null;
         try {
             ossClient = OSSUtil.getOSSClient();
@@ -122,7 +121,7 @@ public class OssUploadTemplate {
             throw new IllegalArgumentException("上传文件失败");
         } finally {
         }
-        return fileName;
+        return ftpPath;
     }
 
     /*

+ 1 - 1
java110-db/src/main/resources/mapper/job/UserDownloadFileV1ServiceDaoImplMapper.xml

@@ -20,7 +20,7 @@
         select t.name,t.download_id,t.download_id downloadId,t.download_user_id,t.download_user_id
         downloadUserId,t.status_cd,t.status_cd statusCd,t.state,t.temp_url,t.temp_url
         tempUrl,t.community_id,t.community_id communityId,t.download_user_name,t.download_user_name
-        downloadUserName,t.file_type,t.file_type fileType,td.name stateName,td1.name fileTypeName,t.create_time createTime
+        downloadUserName,t.file_type,t.file_type fileType,td.name stateName,td1.name fileTypeName,t.create_time,t.remark
         from user_download_file t
         left join t_dict td on t.state = td.status_cd and td.table_name = 'user_download_file' and td.table_columns = 'state'
         left join t_dict td1 on t.file_type = td1.status_cd and td1.table_name = 'user_download_file' and td1.table_columns = 'file_type'

+ 6 - 4
service-common/src/main/java/com/java110/common/smo/impl/FileInnerServiceSMOImpl.java

@@ -23,6 +23,8 @@ import java.util.List;
 @RestController
 public class FileInnerServiceSMOImpl extends BaseServiceSMO implements IFileInnerServiceSMO {
 
+    private static final String ROOT_PATH = "hc/";
+
     @Autowired
     private IFileServiceDao fileServiceDaoImpl;
 
@@ -51,21 +53,21 @@ public class FileInnerServiceSMOImpl extends BaseServiceSMO implements IFileInne
         if (OSSUtil.OSS_SWITCH_OSS.equals(ossSwitch)) {
             fileName = ossUploadTemplate.upload(fileDto.getContext(), java110Properties.getFtpServer(),
                     java110Properties.getFtpPort(), java110Properties.getFtpUserName(),
-                    java110Properties.getFtpUserPassword(), java110Properties.getFtpPath());
+                    java110Properties.getFtpUserPassword(), ROOT_PATH);
         } else if (COSUtil.COS_SWITCH_COS.equals(ossSwitch)) {
             fileName = cosUploadTemplate.upload(fileDto.getContext(), java110Properties.getFtpServer(),
                     java110Properties.getFtpPort(), java110Properties.getFtpUserName(),
-                    java110Properties.getFtpUserPassword(), java110Properties.getFtpPath());
+                    java110Properties.getFtpUserPassword(), ROOT_PATH);
         } else {
             String ftpServer = MappingCache.getValue(FtpUploadTemplate.FTP_DOMAIN, FtpUploadTemplate.FTP_SERVER);
             int ftpPort = Integer.parseInt(MappingCache.getValue(FtpUploadTemplate.FTP_DOMAIN, FtpUploadTemplate.FTP_PORT));
             String ftpUserName = MappingCache.getValue(FtpUploadTemplate.FTP_DOMAIN, FtpUploadTemplate.FTP_USERNAME);
             String ftpUserPassword = MappingCache.getValue(FtpUploadTemplate.FTP_DOMAIN, FtpUploadTemplate.FTP_USERPASSWORD);
-            String ftpPath = java110Properties.getFtpPath();
+            //String ftpPath = java110Properties.getFtpPath();
 
             fileName = ftpUploadTemplate.upload(fileDto.getContext(), ftpServer,
                         ftpPort, ftpUserName,
-                        ftpUserPassword, ftpPath);
+                        ftpUserPassword, ROOT_PATH);
         }
         return fileName;
     }

+ 2 - 2
service-job/src/main/java/com/java110/job/cmd/export/ExportDataCmd.java

@@ -27,7 +27,7 @@ import java.util.List;
 @Java110Cmd(serviceCode = "export.exportData")
 public class ExportDataCmd extends Cmd {
 
-    private static final String EXPORT_DATA_PRE = "hc/temp/export/data/";
+    private static final String EXPORT_DATA_PRE = "temp/export/data/";
 
     public static final String CODE_PREFIX_ID = "10";
 
@@ -60,7 +60,7 @@ public class ExportDataCmd extends Cmd {
         exportDataDto.setReqJson(reqJson);
         String fileName = DateUtil.getyyyyMMddhhmmssDateString()
                 + ".xlsx";
-        exportDataDto.setFileName(exportDataDto
+        exportDataDto.setFileName(EXPORT_DATA_PRE
                 + reqJson.getString("pagePath")
                 + "/"
                 + DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_B)

+ 3 - 1
service-job/src/main/java/com/java110/job/export/ExportDataExecutor.java

@@ -52,7 +52,7 @@ public class ExportDataExecutor implements Runnable {
                 log.error("处理消息异常", e);
                 e.printStackTrace();
             }
-            log.debug("导出数据线程开始完成");
+            log.debug("导出数据线程处理完成");
 
         }
 
@@ -87,6 +87,8 @@ public class ExportDataExecutor implements Runnable {
             inputStream = new ByteArrayInputStream(os.toByteArray());
 
             fileName = fileUploadTemplate.saveFile(inputStream, exportDataDto.getFileName());
+
+
             updateUserDownloadFile(exportDataDto, UserDownloadFileDto.STATE_FINISH,fileName, "下载完成");
 
         } catch (Exception e) {