xubh 5 år sedan
förälder
incheckning
090ce95422

+ 1 - 0
src/main/java/com/minpay/common/service/impl/PublicServiceImpl.java

@@ -347,6 +347,7 @@ public class PublicServiceImpl implements IPublicService {
 		// 获取根路径(nginx文件服务器路径)
 		String basePath = Service.lookup(IPublicService.class)
 				.getSysParValue(channel+"_FILE_SERVER_BASE_PATH");// 为nginx根路径
+		basePath ="D:\\woker\\shouhuoji\\ccc\\";
 		savePath = basePath.concat(fileTypePath).concat(nowDate).concat("/");
 
 		// 获取web服务器访问路径

+ 74 - 16
src/main/java/com/minpay/mt/machine/action/MachineManageAction.java

@@ -31,6 +31,9 @@ import com.startup.minpay.frame.session.MINSession;
 import com.startup.minpay.frame.target.MINAction;
 import com.startup.minpay.frame.target.MINComponent;
 import com.startup.minpay.frame.target.MINParam;
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.FileItemFactory;
+import org.apache.commons.fileupload.disk.DiskFileItemFactory;
 
 import java.io.*;
 import java.util.HashMap;
@@ -290,8 +293,19 @@ public class MachineManageAction implements IMINAction {
         outputStream.close();
         // 上传图片到服务器
         InputStream inputSteam = new FileInputStream(file);
-        String url = UpLoadFile.uploadImg(inputSteam,"jpg",channel,"00");
 
+        String ambient = Service.lookup(IPublicService.class)
+                .getSysParValue("AMBIENT");//当前环境
+        FileItem  fileItem = createFileItem(file ,"itemFileName");
+        Map<String, Object> map = null;
+        if("00".equals(ambient)){//测试
+            map =Service.lookup(IPublicService.class).uploadFile(fileItem, "00", 0, true,"V01");
+        }
+        if("01".equals(ambient)){//生产
+            map =Service.lookup(IPublicService.class).uploadFileBD(fileItem, "00", 0, true,"V01");
+        }
+        //String url = UpLoadFile.uploadImg(inputSteam,"jpg",channel,"00");
+        String url  = String.valueOf(map.get("url"));
         inputSteam.close();
         // 删除本地图片
         file.delete();
@@ -324,9 +338,19 @@ public class MachineManageAction implements IMINAction {
                 e.printStackTrace();
             }
             outputStreams.close();
-            // 上传图片到服务器
             InputStream inputSteams = new FileInputStream(file);
-            url = UpLoadFile.uploadImg(inputSteams,"jpg",channel,"00");
+            FileItem  fileItemb = createFileItem(file ,"itemFileName");
+            Map<String, Object> mapb = null;
+            if("00".equals(ambient)){//测试
+                map =Service.lookup(IPublicService.class).uploadFile(fileItemb, "00", 0, true,"V01");
+            }
+            if("01".equals(ambient)){//生产
+                map =Service.lookup(IPublicService.class).uploadFileBD(fileItemb, "00", 0, true,"V01");
+            }
+            //String url = UpLoadFile.uploadImg(inputSteam,"jpg",channel,"00");
+             url  = String.valueOf(map.get("url"));
+
+            //url = UpLoadFile.uploadImg(inputSteams,"jpg",channel,"00");
 
             inputSteams.close();
             // 删除本地图片
@@ -1335,7 +1359,7 @@ public class MachineManageAction implements IMINAction {
      * @param flash 是否刷新
      */
     @MINAction(value = CREATE_QRCODE, transaction = IMINTransactionEnum.CMT)
-    public static MINActionResult createQrCode(
+    public  MINActionResult createQrCode(
             @MINParam(key = "flash") String flash,
             @MINParam(key = "equId") String equId,
             @MINParam(key = "equType") String equType,
@@ -1383,7 +1407,20 @@ public class MachineManageAction implements IMINAction {
         outputStream.close();
         // 上传图片到服务器
         InputStream inputSteam = new FileInputStream(file);
-        String url = UpLoadFile.uploadImg(inputSteam,"jpg",channel,"00");
+        //String url = UpLoadFile.uploadImg(inputSteam,"jpg",channel,"00");
+        String ambient = Service.lookup(IPublicService.class)
+                .getSysParValue("AMBIENT");//当前环境
+        InputStream inputSteams = new FileInputStream(file);
+        FileItem  fileItemb = createFileItem(file ,"itemFileName");
+        Map<String, Object> map = null;
+       /* if("00".equals(ambient)){//测试
+            map =Service.lookup(IPublicService.class).uploadFile(fileItemb, "00", 0, true,"V01");
+        }*/
+        if("00".equals(ambient)){//生产
+            map =Service.lookup(IPublicService.class).uploadFileBD(fileItemb, "00", 0, true,"V01");
+        }
+        //String url = UpLoadFile.uploadImg(inputSteam,"jpg",channel,"00");
+        String url  = String.valueOf(map.get("url"));
 
         inputSteam.close();
         // 删除本地图片
@@ -1647,12 +1684,12 @@ public class MachineManageAction implements IMINAction {
      */
     @MINAction(value = TENCENTMANAGE_QUERY)
     public MINActionResult businessNumManageQuery(MINSession session,
-          @MINParam(key = "branchId") String branchId,
-          @MINParam(key = "accountName") String accountName,
-          @MINParam(key = "accountId") String accountId,
-          @MINParam(key = "type") String type,
-          @MINParam(key = "page", defaultValue = "1") int page,
-          @MINParam(key = "limit", defaultValue = "10") int limit) throws MINBusinessException {
+                                                  @MINParam(key = "branchId") String branchId,
+                                                  @MINParam(key = "accountName") String accountName,
+                                                  @MINParam(key = "accountId") String accountId,
+                                                  @MINParam(key = "type") String type,
+                                                  @MINParam(key = "page", defaultValue = "1") int page,
+                                                  @MINParam(key = "limit", defaultValue = "10") int limit) throws MINBusinessException {
         MINActionResult res = new MINActionResult();
         // 查询当前角色编号
         User u = session.getUser();
@@ -1697,11 +1734,11 @@ public class MachineManageAction implements IMINAction {
      */
     @MINAction(value = QUERY_BRANCH)
     public MINActionResult queryBranch(MINSession session,
-      @MINParam(key = "accountName") String accountName,
-      @MINParam(key = "accountId") String accountId,
-      @MINParam(key = "type") String type,
-      @MINParam(key = "page", defaultValue = "1") int page,
-      @MINParam(key = "limit", defaultValue = "10") int limit) throws MINBusinessException {
+                                       @MINParam(key = "accountName") String accountName,
+                                       @MINParam(key = "accountId") String accountId,
+                                       @MINParam(key = "type") String type,
+                                       @MINParam(key = "page", defaultValue = "1") int page,
+                                       @MINParam(key = "limit", defaultValue = "10") int limit) throws MINBusinessException {
         MINActionResult res = new MINActionResult();
         // 查询当前角色编号
         User u = session.getUser();
@@ -1758,4 +1795,25 @@ public class MachineManageAction implements IMINAction {
 		Service.lookup(ILogService.class).logging(session, logInfo);*/
         return res;
     }
+    /*
+    创建FileItem
+     */
+    private FileItem createFileItem(File file, String fieldName) {
+        FileItemFactory factory = new DiskFileItemFactory(16, null);
+        FileItem item = factory.createItem(fieldName, "text/plain", true, file.getName());
+        int bytesRead = 0;
+        byte[] buffer = new byte[8192];
+        try {
+            FileInputStream fis = new FileInputStream(file);
+            OutputStream os = item.getOutputStream();
+            while ((bytesRead = fis.read(buffer, 0, 8192)) != -1) {
+                os.write(buffer, 0, bytesRead);
+            }
+            os.close();
+            fis.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return item;
+    }
 }