Selaa lähdekoodia

1.bug修复。

tomatozq 5 vuotta sitten
vanhempi
commit
1a7b05a636

+ 14 - 13
src/main/java/com/jpsoft/smart/modules/base/controller/EmployeeInfoController.java

@@ -345,19 +345,20 @@ public class EmployeeInfoController {
             List<Map<String,Object>> fileList = new ArrayList<>();
 
             //读取模板
-            InputStream inputStream = this.getClass().getResourceAsStream("/static/模板.csv");
+            InputStream inputStream = this.getClass().getResourceAsStream("/static/template.csv");
             byte[] bytes = new byte[inputStream.available()];
             inputStream.read(bytes);
+            inputStream.close();
 
             StringBuilder csvBuilder = new StringBuilder();
-            csvBuilder.append(new String(bytes,"UTF-8"));
+            csvBuilder.append(new String(bytes,"GBK"));
 
             List<EmployeeInfo> employeeInfos = employeeInfoService.findByArray(ids.split(","));
 
-            String tmpdir = System.getProperty("java.io.tmpdir");
-            String tmpFilePath = tmpdir + File.separator + DateTime.now().toString("yyyyMMhddHHmmssSSS") + ".csv";
+//            String tmpdir = System.getProperty("java.io.tmpdir");
+//            String tmpFilePath = tmpdir + File.separator + DateTime.now().toString("yyyyMMhddHHmmssSSS") + ".csv";
 
-            File tmpFile = new File(tmpFilePath);
+//            File tmpFile = new File(tmpFilePath);
 
             if(employeeInfos.size()>0) {
                 for (EmployeeInfo employeeInfo : employeeInfos) {
@@ -369,13 +370,13 @@ public class EmployeeInfoController {
                     csvBuilder.append(localPath + "\\照片\\" + employeeInfo.getId() + photoExt + "\r\n");
                 }
 
-                FileOutputStream fileOutput = new FileOutputStream(tmpFile);
-                byte[] data = csvBuilder.toString().getBytes("UTF-8");
-                fileOutput.write(data,0,data.length);
-                fileOutput.close();
+//                FileOutputStream fileOutput = new FileOutputStream(tmpFile);
+//                byte[] data = csvBuilder.toString().getBytes("UTF-8");
+//                fileOutput.write(data,0,data.length);
+//                fileOutput.close();
 
                 Map<String, Object> fileMap = new HashMap<>();
-                fileMap.put("localPath", tmpFilePath);
+                fileMap.put("fileData", csvBuilder.toString().getBytes("GBK"));
                 fileMap.put("fileName", "人员名单.csv");
 
                 fileList.add(fileMap);
@@ -401,9 +402,9 @@ public class EmployeeInfoController {
 
             OSSUtil.batchDownload(fileList,output);
 
-            if(tmpFile.exists()){
-                tmpFile.delete();
-            }
+//            if (tmpFile.exists()){
+//                tmpFile.delete();
+//            }
 
             output.flush();
             output.close();

+ 8 - 0
src/main/java/com/jpsoft/smart/modules/common/utils/OSSUtil.java

@@ -162,6 +162,14 @@ public class OSSUtil {
 
                         bis.close();
                     }
+                    else if(map.containsKey("fileData")){
+                        ZipEntry zipEntry = new ZipEntry(zipFile);
+                        zos.putNextEntry(zipEntry);
+
+                        byte[] data = (byte[])map.get("fileData");
+
+                        zos.write(data, 0, data.length);
+                    }
                 }
                 catch(Exception ex){
                     log.error(ex.getMessage(),ex);

+ 2 - 2
src/main/resources/application-production.yml

@@ -35,8 +35,8 @@ springfox:
 
 wx:
   pay:
-    appId: wxe598c699aa68cffe
-    appSecret: ea20d2e9a36aace26b4f7654218129af
+    appId: wx7e70eb62a8459869
+    appSecret: 909d17e353268da57c4f18cc09798049
     mchId: 1500160622
     subMchId: 1505070291
     mchKey: jpsoft11111111111111111111111111

+ 7 - 0
src/main/resources/static/template.csv

@@ -0,0 +1,7 @@
+"必填项,唯一性的标识号,如工号、学号等
+最大15个字符(大小写英文字母、数字、下划线、中划线)",必填项,最大20个字符,"可填写全路径或相对路径;
+多张图用分号分隔;
+支持无图;",证件类型:身份证、IC卡,证件号码:最大20个字符(大小写英文字母、数字),证件类型:身份证、IC卡,证件号码:最大20个字符(大小写英文字母、数字),"时间模板生效的时间段,24小时制,支持跨天、缺省;0 -  0 长期有效;
+0 - XXX:  当前时间到XXX有效;
+XXX-0:从XXX时间开始长期有效;              注意:生效时间、失效时间填充时,时间模板名称必填",,模板名,缺省为第一个时间模板。最大63个字符。,最大20个字符
+*编号,*姓名,人脸图片,证卡类型1,证卡号码1,证卡类型2,证卡号码2,生效时间,失效时间,时间模板名,备注

+ 0 - 7
src/main/resources/static/模板.csv

@@ -1,7 +0,0 @@
-"必填项,唯一性的标识号,如工号、学号等
-最大15个字符(大小写英文字母、数字、下划线、中划线)",必填项,最大20个字符,"可填写全路径或相对路径;
-多张图用分号分隔;
-支持无图;",证件类型:身份证、IC卡,证件号码:最大20个字符(大小写英文字母、数字),证件类型:身份证、IC卡,证件号码:最大20个字符(大小写英文字母、数字),"时间模板生效的时间段,24小时制,支持跨天、缺省;0 -  0 长期有效;
-0 - XXX:  当前时间到XXX有效;
-XXX-0:从XXX时间开始长期有效;              注意:生效时间、失效时间填充时,时间模板名称必填",,模板名,缺省为第一个时间模板。最大63个字符。,最大20个字符
-*编号,*姓名,人脸图片,证卡类型1,证卡号码1,证卡类型2,证卡号码2,生效时间,失效时间,时间模板名,备注

+ 1 - 1
src/test/java/com/jpsoft/smart/EmployeeTest.java

@@ -36,7 +36,7 @@ public class EmployeeTest {
             List<Map<String, Object>> fileList = new ArrayList<>();
 
             //读取模板
-            InputStream inputStream = this.getClass().getResourceAsStream("/static/模板.csv");
+            InputStream inputStream = this.getClass().getResourceAsStream("/static/template.csv");
             byte[] bytes = new byte[inputStream.available()];
             inputStream.read(bytes);