Browse Source

feature: 下载优化直接上传至oss

wuyongyi 2 years ago
parent
commit
8484d4b58a
21 changed files with 341 additions and 51 deletions
  1. 29 0
      src/main/java/com/ywt/mg/core/utils/DateUtil.java
  2. 11 0
      src/main/java/com/ywt/mg/params/checkupBooking/QueryCheckUpOrderListRequest.java
  3. 11 0
      src/main/java/com/ywt/mg/params/deposit/QueryDepositListRequest.java
  4. 9 0
      src/main/java/com/ywt/mg/params/downloadRecord/QueryDownloadRecordListRequest.java
  5. 11 0
      src/main/java/com/ywt/mg/params/mealOrder/MealOrderListRequest.java
  6. 11 0
      src/main/java/com/ywt/mg/params/outpatientOrder/QueryOutPatientOrderListRequest.java
  7. 11 0
      src/main/java/com/ywt/mg/params/registeredOrder/RegisteredOrderListRequest.java
  8. 8 8
      src/main/java/com/ywt/mg/services/AuthService.java
  9. 1 1
      src/main/java/com/ywt/mg/services/CheckUpOrderService.java
  10. 57 9
      src/main/java/com/ywt/mg/services/DownloadRecordService.java
  11. 9 9
      src/main/java/com/ywt/mg/services/OutpatientOrderService.java
  12. 31 7
      src/main/java/com/ywt/mg/web/common/ExcelDownloadSrv.java
  13. 17 10
      src/main/java/com/ywt/mg/web/common/FileSrv.java
  14. 7 0
      src/main/java/com/ywt/mg/web/controllers/CheckUpOrderController.java
  15. 12 0
      src/main/java/com/ywt/mg/web/controllers/DepositController.java
  16. 1 1
      src/main/java/com/ywt/mg/web/controllers/DownloadRecordController.java
  17. 10 2
      src/main/java/com/ywt/mg/web/controllers/MealOrderController.java
  18. 15 3
      src/main/java/com/ywt/mg/web/controllers/OutpatientOrderController.java
  19. 14 0
      src/main/java/com/ywt/mg/web/controllers/RegisteredOrderController.java
  20. 65 0
      src/main/java/com/ywt/mg/web/controllers/hospital/HospOutpatientOrderController.java
  21. 1 1
      src/main/resources/application.properties

+ 29 - 0
src/main/java/com/ywt/mg/core/utils/DateUtil.java

@@ -6,6 +6,9 @@ import java.util.Calendar;
 import java.util.Date;
 
 public class DateUtil {
+
+
+    public static final String DADE_FROMAT_YMD = "yyyy-MM-dd";
     /**
      * 将时间戳转换成日期字符串格式
      *
@@ -161,4 +164,30 @@ public class DateUtil {
             return null;
         }
     }
+
+    public static String getPastDate(int past) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - past);
+        Date today = calendar.getTime();
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+        String result = format.format(today);
+        return result;
+    }
+
+    /**
+     * 格式化日期
+     *
+     * @param date
+     * @param pattern
+     * @return
+     */
+    public static String formatDate(Date date, String pattern) {
+        if (StringHelper.isNullOrEmpty(pattern)) {
+            pattern = "yyyy-MM-dd HH:mm:ss";
+        }
+
+        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
+        return sdf.format(date);
+    }
+
 }

+ 11 - 0
src/main/java/com/ywt/mg/params/checkupBooking/QueryCheckUpOrderListRequest.java

@@ -40,6 +40,9 @@ public class QueryCheckUpOrderListRequest extends PageRequest implements Seriali
     @ApiModelProperty(value = "对账时间查询截止时间")
     private String billEndTime;
 
+    @ApiModelProperty(value = "判断医院后台还是公司后台")
+    private int hosp;
+
     public String getOrderNo() {
         return orderNo;
     }
@@ -127,4 +130,12 @@ public class QueryCheckUpOrderListRequest extends PageRequest implements Seriali
     public void setBillEndTime(String billEndTime) {
         this.billEndTime = billEndTime;
     }
+
+    public int getHosp() {
+        return hosp;
+    }
+
+    public void setHosp(int hosp) {
+        this.hosp = hosp;
+    }
 }

+ 11 - 0
src/main/java/com/ywt/mg/params/deposit/QueryDepositListRequest.java

@@ -38,6 +38,9 @@ public class QueryDepositListRequest extends PageRequest implements Serializable
     @ApiModelProperty(value = "来源")
     private String terminal;
 
+    @ApiModelProperty(value = "判断医院后台还是公司后台")
+    private int hosp;
+
     public String getOrderNo() {
         return orderNo;
     }
@@ -117,4 +120,12 @@ public class QueryDepositListRequest extends PageRequest implements Serializable
     public void setTerminal(String terminal) {
         this.terminal = terminal;
     }
+
+    public int getHosp() {
+        return hosp;
+    }
+
+    public void setHosp(int hosp) {
+        this.hosp = hosp;
+    }
 }

+ 9 - 0
src/main/java/com/ywt/mg/params/downloadRecord/QueryDownloadRecordListRequest.java

@@ -18,6 +18,7 @@ public class QueryDownloadRecordListRequest extends PageRequest implements Seria
     int hospitalId = 0;
     int pharmacyId = 0;
     int adminId = 0;
+    int status;
 
     public int getHospitalId() {
         return hospitalId;
@@ -42,4 +43,12 @@ public class QueryDownloadRecordListRequest extends PageRequest implements Seria
     public void setAdminId(int adminId) {
         this.adminId = adminId;
     }
+
+    public int getStatus() {
+        return status;
+    }
+
+    public void setStatus(int status) {
+        this.status = status;
+    }
 }

+ 11 - 0
src/main/java/com/ywt/mg/params/mealOrder/MealOrderListRequest.java

@@ -75,6 +75,9 @@ public class MealOrderListRequest implements Serializable {
     @ApiModelProperty(value = "拥有的商铺")
     private String shopIds;
 
+    @ApiModelProperty(value = "判断医院后台还是公司后台")
+    private int hosp;
+
 
     public String getOrderNo() {
         return orderNo;
@@ -259,4 +262,12 @@ public class MealOrderListRequest implements Serializable {
     public void setbIsStaff(Boolean bIsStaff) {
         this.bIsStaff = bIsStaff;
     }
+
+    public int getHosp() {
+        return hosp;
+    }
+
+    public void setHosp(int hosp) {
+        this.hosp = hosp;
+    }
 }

+ 11 - 0
src/main/java/com/ywt/mg/params/outpatientOrder/QueryOutPatientOrderListRequest.java

@@ -57,6 +57,9 @@ public class QueryOutPatientOrderListRequest implements Serializable {
     @ApiModelProperty(value = "对账时间查询截止时间")
     private String billEndTime;
 
+    @ApiModelProperty(value = "判断医院后台还是公司后台")
+    private int hosp;
+
     private boolean isAdmin = false;
 
     private String terminal;
@@ -212,4 +215,12 @@ public class QueryOutPatientOrderListRequest implements Serializable {
     public void setTerminal(String terminal) {
         this.terminal = terminal;
     }
+
+    public int getHosp() {
+        return hosp;
+    }
+
+    public void setHosp(int hosp) {
+        this.hosp = hosp;
+    }
 }

+ 11 - 0
src/main/java/com/ywt/mg/params/registeredOrder/RegisteredOrderListRequest.java

@@ -61,6 +61,9 @@ public class RegisteredOrderListRequest extends PageRequest implements Serializa
     @ApiModelProperty(value = "交易流水号")
     private String transactionId;
 
+    @ApiModelProperty(value = "判断医院后台还是公司后台")
+    private int hosp;
+
     public String getOrderno() {
         return orderno;
     }
@@ -196,4 +199,12 @@ public class RegisteredOrderListRequest extends PageRequest implements Serializa
     public void setTransactionId(String transactionId) {
         this.transactionId = transactionId;
     }
+
+    public int getHosp() {
+        return hosp;
+    }
+
+    public void setHosp(int hosp) {
+        this.hosp = hosp;
+    }
 }

+ 8 - 8
src/main/java/com/ywt/mg/services/AuthService.java

@@ -65,8 +65,8 @@ public class AuthService {
 
     public int getCurrentAdminId() {
         int adminId = WebAppContext.current().getAdminId();
-//        return adminId > 0 ? adminId : 1;
-        return adminId ;
+        return adminId > 0 ? adminId : 1;
+//        return adminId ;
     }
 
     public MGAdmins getCurrentAdmin() {
@@ -75,20 +75,20 @@ public class AuthService {
 
     public int getCurrentHospitalId() {
         int hospitalId = WebAppContext.current().getHospitalId();
-//        return hospitalId > 0 ? hospitalId : 41;
-        return hospitalId;
+        return hospitalId > 0 ? hospitalId : 41;
+//        return hospitalId;
     }
 
     public int getCurrentPharmacyId() {
         int pharmacyId = WebAppContext.current().getPharmacyId();
-//        return pharmacyId > 0 ? pharmacyId : 1;
-        return pharmacyId ;
+        return pharmacyId > 0 ? pharmacyId : 1;
+//        return pharmacyId ;
     }
 
     public int getCurrentEnterpriseId() {
         int enterpriseId = WebAppContext.current().getEnterpriseId();
-//        return enterpriseId > 0 ? enterpriseId : 1;
-        return enterpriseId ;
+        return enterpriseId > 0 ? enterpriseId : 1;
+//        return enterpriseId ;
     }
 
 

+ 1 - 1
src/main/java/com/ywt/mg/services/CheckUpOrderService.java

@@ -84,7 +84,7 @@ public class CheckUpOrderService {
         String hospitalId = request.getHospitalId();
         if (!Checker.isNone(hospitalId)) {
             int hospitalIdInt = Integer.parseInt(hospitalId);
-            if (hospitalIdInt != -1) {
+            if (hospitalIdInt != 0 ) {
                 whereSql += " and ( hospital_id = ?)";
                 paramList.add(hospitalIdInt);
             }

+ 57 - 9
src/main/java/com/ywt/mg/services/DownloadRecordService.java

@@ -6,10 +6,7 @@ import com.ywt.gapi.base.file.ReadFileResponse;
 import com.ywt.mg.configs.Constants;
 import com.ywt.mg.core.PagedList;
 import com.ywt.mg.core.SqlHelper;
-import com.ywt.mg.core.utils.Checker;
-import com.ywt.mg.core.utils.CollectionUtil;
-import com.ywt.mg.core.utils.FormatUtil;
-import com.ywt.mg.core.utils.StringHelper;
+import com.ywt.mg.core.utils.*;
 import com.ywt.mg.core.utils.serializers.JsonSerializer;
 import com.ywt.mg.domain.entities.*;
 import com.ywt.mg.domain.models.ConstantDef;
@@ -158,9 +155,13 @@ public class DownloadRecordService {
                 item.put("id", p.getId());
                 item.put("name", p.getName());
                 item.put("createTime", FormatUtil.createTimeFormatDetail(p.getCreateTime()));
-                item.put("updateTime", FormatUtil.createTimeFormatDetail(p.getUpdateTime()));
                 item.put("status", p.getStatus());
                 item.put("statusStr", DownloadRecordStatusEnum.getDisplayName(p.getStatus()));
+                if(p.getStatus() == DownloadRecordStatusEnum.Default.getValue()){
+                    item.put("updateTime", "下载中");
+                } else {
+                    item.put("updateTime", FormatUtil.createTimeFormatDetail(p.getUpdateTime()));
+                }
                 return item;
             });
             pageDataResponse.setData(datas);
@@ -188,6 +189,42 @@ public class DownloadRecordService {
             whereSql += " and ( admin_id = ?)";
             paramList.add(hospitalId);
         }
+        int status = Checker.getIntegerValue(request.getStatus());
+        if(status == 1){
+            whereSql += " and ( status = ?)";
+            paramList.add(status);
+        } else {
+            whereSql += " and ( status = 0 or status = 1)";
+        }
+        String formatDate = "yyyy-MM-dd";
+        SimpleDateFormat format = new SimpleDateFormat(formatDate);
+        String endTime = getCurrentDate();
+        if (!Checker.isNull(endTime)) {
+            whereSql += " and ( create_time < ?)";
+            Date date = format.parse(endTime);
+            //把日期往后增加一天.整数往后推,负数往前移动
+            Calendar calendar = new GregorianCalendar();
+            calendar.setTime(date);
+            calendar.add(calendar.DATE, 1);
+            date = calendar.getTime();   //这个时间就是日期往后推一天的结果
+
+            paramList.add(date);
+//            paramList.add(date);
+        }
+//        Date date = new Date();
+//        Calendar calendar = new GregorianCalendar();
+//        calendar.setTime(date);
+//        calendar.add(calendar.DATE, 1);
+
+
+        String startTime = DateUtil.getPastDate(70);
+        if (!Checker.isNull(startTime)) {
+            whereSql += " and ( create_time >= ?)";
+            Date date = format.parse(startTime);
+            paramList.add(date);
+//            paramList.add(date);
+        }
+
         int pageIndex = request.getPageIndex();
         int pageSize = request.getPageSize();
         return sqlHelper.getPagedList(pageIndex, pageSize, "*", whereSql, "create_time desc", DownloadRecord.class, paramList.toArray());
@@ -245,12 +282,12 @@ public class DownloadRecordService {
 
         // 生成本地文件
         ExcelStyleMap excelStyleMap = new ExcelStyleMap(new String[]{});
-        excelDownloadSrv.generateAndReturnExcelFileWithNoStyleAndCollectLocal(fileName, localPath, map, excelStyleMap, itemList);
+        OutputStream ba = excelDownloadSrv.generateAndReturnExcelFileWithNoStyleAndCollectLocal(fileName, localPath, map, excelStyleMap, itemList);
 
         // 本地文件上传到oss,文件名带后缀
         String ossPath = String.format(ConstantDef.BIG_DATA_EXCEL_FILE_PATH, FormatUtil.formatDate(new Date(), "yyyy-MM"));
         String ossFileName = fileName + suffixFormat;
-        DataResponse dataResponse = fileSrv.localFileUploadToOss(localPath, ossFileName, ossPath);
+        DataResponse dataResponse = fileSrv.localFileUploadToOss(localPath, ossFileName, ossPath, ba);
         if (dataResponse.getCode() == BaseResponse.SUCCEED) {
             // 上传成功,将上传状态和地址保存到数据库
             saveUrlAndStatus(downloadRecordId, dataResponse.getData().toString(), DownloadRecordStatusEnum.SUCCESS.getValue());
@@ -282,12 +319,12 @@ public class DownloadRecordService {
 
         // 生成本地文件
         ExcelStyleMap excelStyleMap = new ExcelStyleMap(new String[]{});
-        excelDownloadSrv.generateAndReturnMealExcelFileWithNoStyleAndCollectLocal(fileName, localPath, map, excelStyleMap, itemList);
+        OutputStream ba = excelDownloadSrv.generateAndReturnMealExcelFileWithNoStyleAndCollectLocal(fileName, localPath, map, excelStyleMap, itemList);
 
         // 本地文件上传到oss,文件名带后缀
         String ossPath = String.format(ConstantDef.BIG_DATA_EXCEL_FILE_PATH, FormatUtil.formatDate(new Date(), "yyyy-MM"));
         String ossFileName = fileName + suffixFormat;
-        DataResponse dataResponse = fileSrv.localFileUploadToOss(localPath, ossFileName, ossPath);
+        DataResponse dataResponse = fileSrv.localFileUploadToOss(localPath, ossFileName, ossPath, ba);
         if (dataResponse.getCode() == BaseResponse.SUCCEED) {
             // 上传成功,将上传状态和地址保存到数据库
             saveUrlAndStatus(downloadRecordId, dataResponse.getData().toString(), DownloadRecordStatusEnum.SUCCESS.getValue());
@@ -298,4 +335,15 @@ public class DownloadRecordService {
         // 删除文件
         fileSrv.deleteFile(localPath);
     }
+
+
+    private String getCurrentDate() {
+        try {
+            String value = DateUtil.formatDate(new Date(), DateUtil.DADE_FROMAT_YMD);
+            return value;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
 }

+ 9 - 9
src/main/java/com/ywt/mg/services/OutpatientOrderService.java

@@ -55,22 +55,22 @@ public class OutpatientOrderService {
     private RefundLogService refundLogService;
 
 
-    private List<OutpatientOrder> queryOutPatientOrderList(QueryOutPatientOrderListRequest request) throws Exception {
-        Map map = queryOutPatientOrderListCommonNew(request);
+    private List<OutpatientOrder> queryOutPatientOrderList(QueryOutPatientOrderListRequest request, int adminId) throws Exception {
+        Map map = queryOutPatientOrderListCommonNew(request, adminId);
 
         String whereSql = (String) map.get(ConstantDef.KEY_WHERE_SQL);
         List paramList = (List) map.get(ConstantDef.KEY_PARAM_LIST);
         return sqlHelper.getListWithNoPage("*", whereSql, " id desc ", OutpatientOrder.class, paramList.toArray());
     }
 
-    public Map<String, Object> queryOutPatientOrderListCommonNew(QueryOutPatientOrderListRequest request) throws Exception {
+    public Map<String, Object> queryOutPatientOrderListCommonNew(QueryOutPatientOrderListRequest request, int adminId) throws Exception {
         List<Object> paramList = new ArrayList<>();
         String whereSql = " ( 1=1 )";
 
         // 添加测试账号过滤
         String testAdminIds = parameterConfigurer.getTestAdminIds();
         String testDoctorCodes = parameterConfigurer.getTestDoctorCodes();
-        String adminStr = "," + authService.getCurrentAdminId() + ",";
+        String adminStr = "," + adminId + ",";
         String testAdminIdsStr = "," + testAdminIds + ",";
 
         // 不是测试账号
@@ -208,7 +208,7 @@ public class OutpatientOrderService {
             paramList.add(date);
         }
         int hospitalId = request.getHospitalId();
-        if (hospitalId > -1) {
+        if (hospitalId > 0) {
             whereSql += " and ( hospital_id = ?)";
             paramList.add(hospitalId);
         }
@@ -257,7 +257,7 @@ public class OutpatientOrderService {
         return map;
     }
 
-    public void downloadOutPatientOrderListCommon(int downloadRecordId, String fileName, QueryOutPatientOrderListRequest request) {
+    public void downloadOutPatientOrderListCommon(int downloadRecordId, String fileName, QueryOutPatientOrderListRequest request,  int adminId) {
         try {
             boolean isAdmin = request.isAdmin();
             String col0 = "订单号";
@@ -283,7 +283,7 @@ public class OutpatientOrderService {
                         col12, col13, col14, col15};
             }
 
-            List<OutpatientOrder> list = queryOutPatientOrderList(request);
+            List<OutpatientOrder> list = queryOutPatientOrderList(request, adminId);
             List<User> userList = getUserListByOutpatientOrderViewList(list, list.size());
             List<OrderPayment> orderPaymentList = orderPaymentService.getOrderPaymentListByOutPatientOrderList(list);
             int payTotal = 0;
@@ -436,7 +436,7 @@ public class OutpatientOrderService {
         return customExcelItemList;
     }
 
-    public void downloadOutPatientOrderBillListNew(int downloadRecordId, String fileName,  QueryOutPatientOrderListRequest request){
+    public void downloadOutPatientOrderBillListNew(int downloadRecordId, String fileName,  QueryOutPatientOrderListRequest request, int adminId){
         try {
                     String col0 = "交易类型*";
                     String col1 = "系统参考号*";
@@ -448,7 +448,7 @@ public class OutpatientOrderService {
             //给第二行设置背景、字体颜色、对齐方式等等;
             // 只搜索已支付的订单
             request.setPaymentstatus(PaymentStatusEnum.Success.getValue() + "");
-            List<OutpatientOrder> outpatientOrderList = queryOutPatientOrderList(request);
+            List<OutpatientOrder> outpatientOrderList = queryOutPatientOrderList(request, adminId);
             ExcelDataMap map = new ExcelDataMap(columns);
             if (!Checker.isNone(outpatientOrderList)) {
                 // 得到支付的记录日志(需要从 order_payment 获取 transaction_id 字段)

+ 31 - 7
src/main/java/com/ywt/mg/web/common/ExcelDownloadSrv.java

@@ -23,6 +23,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.OutputStream;
@@ -286,15 +287,20 @@ public class ExcelDownloadSrv {
      * @throws AppMessageException 业务层异常抛出,如传入数据为空
      * @author Walker, added on 06/27/2019.
      */
-    public void generateAndReturnExcelFileWithNoStyleAndCollectLocal(String fileName, String path, ExcelDataMap data, ExcelStyleMap excelStyleMap,
+    public OutputStream  generateAndReturnExcelFileWithNoStyleAndCollectLocal(String fileName, String path, ExcelDataMap data, ExcelStyleMap excelStyleMap,
                                                                        List<ExcelCollectPojo> collectList) throws AppMessageException {
+
+        OutputStream ba = null;
+        ba = new ByteArrayOutputStream();
+        WritableWorkbook workbook = null;
         if (data == null || data.isEmpty()) {
             throw new AppMessageException("数据为空");
         }
         try {
-            File file = new File(path);
+//            File file = new File(path);
             // 创建写工作簿对象
-            WritableWorkbook workbook = Workbook.createWorkbook(file);
+//            WritableWorkbook workbook = Workbook.createWorkbook(file);
+            workbook = Workbook.createWorkbook(ba);
             // 工作表
             WritableSheet sheet = workbook.createSheet(fileName, 0);
             //单独应用样式
@@ -340,11 +346,19 @@ public class ExcelDownloadSrv {
             workbook.write();
             //关闭流
             workbook.close();
+            if (ba != null) {
+                try {
+                    ba.close();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
         } catch (Exception e) {
             logger.error("ExcelDownloadSrv#generateAndReturnExcelFileWithNoStyleAndCollectLocal(fileName={}, path={} ):\n {}",
                     fileName, path, e.getMessage(), e);
         }
-//        return path;
+        return ba;
+
     }
 
     /**
@@ -381,15 +395,18 @@ public class ExcelDownloadSrv {
      * @throws AppMessageException 业务层异常抛出,如传入数据为空
      * @author Walker, added on 06/27/2019.
      */
-    public void generateAndReturnMealExcelFileWithNoStyleAndCollectLocal(String fileName, String path, ExcelDataMap data, ExcelStyleMap excelStyleMap,
+    public OutputStream generateAndReturnMealExcelFileWithNoStyleAndCollectLocal(String fileName, String path, ExcelDataMap data, ExcelStyleMap excelStyleMap,
                                                                      List<CustomExcelItem> collectList) throws AppMessageException {
         if (data == null || data.isEmpty()) {
             throw new AppMessageException("数据为空");
         }
+        OutputStream ba = null;
+        ba = new ByteArrayOutputStream();
+        WritableWorkbook workbook = null;
         try {
             File file = new File(path);
             // 创建写工作簿对象
-            WritableWorkbook workbook = Workbook.createWorkbook(file);
+             workbook = Workbook.createWorkbook(ba);
             // 工作表
             WritableSheet sheet = workbook.createSheet(fileName, 0);
             WritableFont font2 = new WritableFont(WritableFont.ARIAL, 14, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK);
@@ -435,10 +452,17 @@ public class ExcelDownloadSrv {
             workbook.write();
             //关闭流
             workbook.close();
+            if (ba != null) {
+                try {
+                    ba.close();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
         } catch (Exception e) {
             logger.error("ExcelDownloadSrv#generateAndReturnExcelFileWithNoStyleAndCollectLocal(fileName={}, path={} ):\n {}",
                     fileName, path, e.getMessage(), e);
         }
-//        return path;
+        return ba;
     }
 }

+ 17 - 10
src/main/java/com/ywt/mg/web/common/FileSrv.java

@@ -12,7 +12,10 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.io.OutputStream;
 import java.nio.file.Files;
 import java.util.ArrayList;
 import java.util.List;
@@ -55,16 +58,19 @@ public class FileSrv {
      * @param ossPath   oss文件路径
      * @return 文件路径
      */
-    public DataResponse localFileUploadToOss(String localPath, String filename, String ossPath) {
+    public DataResponse localFileUploadToOss(String localPath, String filename, String ossPath, OutputStream ba) {
         DataResponse response = new DataResponse();
         try {
-            File file = new File(localPath);
-            if (!file.exists()) {
-                response.parameterErrorFailed("文件不存在");
-                return response;
-            }
-            byte[] bytes = Files.readAllBytes(file.toPath());
-            String fileUrl = uploadFile(filename, ossPath, bytes);
+//            File file = new File(localPath);
+//            if (!file.exists()) {
+//                response.parameterErrorFailed("文件不存在");
+//                return response;
+//            }
+            ByteArrayInputStream bio = new ByteArrayInputStream(((ByteArrayOutputStream) ba).toByteArray());
+//            byte[] bytes  =  ByteString.readFrom(bio);
+//            byte[] bytes = Files.readAllBytes(file.toPath());
+//            String fileUrl = uploadFile(filename, ossPath, bytes);
+            String fileUrl = uploadFile(filename, ossPath, bio);
             response.setData(fileUrl);
             response.succeed();
         } catch (Exception e) {
@@ -84,12 +90,13 @@ public class FileSrv {
      * @param bytes    文件
      * @return 文件路径
      */
-    public String uploadFile(String filename, String path, byte[] bytes) {
+    public String uploadFile(String filename, String path,  ByteArrayInputStream bio) {
         try {
             UploadFileRequest rest = UploadFileRequest.newBuilder()
                     .setFilename(filename)
                     .setVpath(path)
-                    .setDatas(ByteString.copyFrom(bytes))
+//                    .setDatas(ByteString.copyFrom(bytes))
+                    .setDatas(ByteString.readFrom(bio))
                     .build();
             UploadFileResponse resp = fileServiceBlockingStub.uploadFile(rest);
             return resp.getFileUrl();

+ 7 - 0
src/main/java/com/ywt/mg/web/controllers/CheckUpOrderController.java

@@ -43,6 +43,13 @@ public class CheckUpOrderController {
         int currentAdminId = Checker.getIntegerValue(authService.getCurrentAdminId());
 //        request.setCurrentAdminId(currentAdminId);
         // 插入记录
+//        Integer hospital = 0;
+//        String hosp = "";
+//        if(request.getHosp()> 0){
+//            hospital = authService.getCurrentHospitalId();
+//            hosp = hospital.toString();
+//            request.setHospitalId(hosp);
+//        }
         int downloadRecordId = idGenerator.genDownloadRecordId();
         String name = "公司后台-订单管理-体检缴费";
         String fileName = "体检缴费列表";

+ 12 - 0
src/main/java/com/ywt/mg/web/controllers/DepositController.java

@@ -39,11 +39,18 @@ public class DepositController {
     private DepositService depositService;
 
 
+
+
     @RequestMapping({"/downloadDepositList"})
     public BaseResponse downloadDepositList(QueryDepositListRequest request) {
         int currentAdminId = Checker.getIntegerValue(authService.getCurrentAdminId());
 //        request.setCurrentAdminId(currentAdminId);
         // 插入记录
+//        int hospital = 0;
+//        if(request.getHosp() > 0){
+//            hospital = authService.getCurrentHospitalId();
+//            request.setHospitalId(hospital);
+//        }
         int downloadRecordId = idGenerator.genDownloadRecordId();
         String name = "公司后台-订单管理-住院押金";
         String fileName = "押金缴费记录";
@@ -66,6 +73,11 @@ public class DepositController {
         int currentAdminId = Checker.getIntegerValue(authService.getCurrentAdminId());
 //        request.setCurrentAdminId(currentAdminId);
         // 插入记录
+        int hospital = 0;
+        if(request.getHospitalId() > 0){
+            hospital = authService.getCurrentHospitalId();
+            request.setHospitalId(hospital);
+        }
         int downloadRecordId = idGenerator.genDownloadRecordId();
         String name = "公司后台-订单管理-住院押金对账数据";
         String fileName = "住院押金对账列表";

+ 1 - 1
src/main/java/com/ywt/mg/web/controllers/DownloadRecordController.java

@@ -40,7 +40,7 @@ public class DownloadRecordController {
     @MGRight(menuCode = {"/downloadRecord/queryDownloadRecordList"}, type = MGRightTypeDef.Menu | MGRightTypeDef.Logined)
     BaseResponse queryDownloadRecordList(@Validated @RequestBody QueryDownloadRecordListRequest request) throws Exception {
         request.setHospitalId(-1);
-        return downloadRecordService.queryDownloadRecordList(request);
+         return downloadRecordService.queryDownloadRecordList(request);
     }
 
     @ApiOperation(value = "下载文件")

+ 10 - 2
src/main/java/com/ywt/mg/web/controllers/MealOrderController.java

@@ -46,7 +46,11 @@ public class MealOrderController {
 //        int currentAdminId = Checker.getIntegerValue(authService.getCurrentAdminId());
 //        request.setCurrentAdminId(currentAdminId);
         // 插入记录
-
+//        int hospital = 0;
+//        if(request.getHosp() > 0){
+//            hospital = authService.getCurrentHospitalId();
+//            request.setHospitalId(hospital);
+//        }
         int downloadRecordId = idGenerator.genDownloadRecordId();
         String name = "公司后台-订单管理-订餐订单列表列表";
         String fileName = "订餐订单列表";
@@ -98,7 +102,11 @@ public class MealOrderController {
 //        int currentAdminId = Checker.getIntegerValue(authService.getCurrentAdminId());
 //        request.setCurrentAdminId(currentAdminId);
         // 插入记录
-
+        int hospital = 0;
+        if(request.getHospitalId() > 0){
+            hospital = authService.getCurrentHospitalId();
+            request.setHospitalId(hospital);
+        }
         int downloadRecordId = idGenerator.genDownloadRecordId();
         String name = "公司后台-订单管理-订餐订单列表列表";
         String fileName = "订餐订单列表";

+ 15 - 3
src/main/java/com/ywt/mg/web/controllers/OutpatientOrderController.java

@@ -13,6 +13,7 @@ import com.ywt.mg.web.BaseResponse;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -38,10 +39,15 @@ public class OutpatientOrderController {
 
 
     @RequestMapping({"/downloadOutPatientOrderList"})
-    public BaseResponse downloadOutPatientOrderList(QueryOutPatientOrderListRequest request) {
+    public BaseResponse downloadOutPatientOrderList(@RequestBody QueryOutPatientOrderListRequest request) {
         int currentAdminId = Checker.getIntegerValue(authService.getCurrentAdminId());
 //        request.setCurrentAdminId(currentAdminId);
         // 插入记录
+//        int hospital = 0;
+//        if(request.getHosp() > 0){
+//            hospital = authService.getCurrentHospitalId();
+//            request.setHospitalId(hospital);
+//        }
         int downloadRecordId = idGenerator.genDownloadRecordId();
         String name = "公司后台-订单管理-门诊缴费订单列表";
         String fileName = "门诊缴费记录";
@@ -52,7 +58,7 @@ public class OutpatientOrderController {
         Thread t = new Thread() {
             @Override
             public void run() {
-              outpatientOrderService.downloadOutPatientOrderListCommon(downloadRecordId, fileName, request);
+              outpatientOrderService.downloadOutPatientOrderListCommon(downloadRecordId, fileName, request, currentAdminId);
             }
         };
         t.start();
@@ -64,6 +70,12 @@ public class OutpatientOrderController {
         int currentAdminId = Checker.getIntegerValue(authService.getCurrentAdminId());
 //        request.setCurrentAdminId(currentAdminId);
         // 插入记录
+//        int hospital = 0;
+//        if(request.getHospitalId() > 0){
+//            hospital = authService.getCurrentHospitalId();
+//            request.setHospitalId(hospital);
+//        }
+
         int downloadRecordId = idGenerator.genDownloadRecordId();
         String name = "公司后台-订单管理-门诊缴费对账记录";
         String fileName = "门诊缴费对账记录";
@@ -74,7 +86,7 @@ public class OutpatientOrderController {
         Thread t = new Thread() {
             @Override
             public void run() {
-                outpatientOrderService.downloadOutPatientOrderBillListNew(downloadRecordId, fileName, request);
+                outpatientOrderService.downloadOutPatientOrderBillListNew(downloadRecordId, fileName, request, currentAdminId);
             }
         };
         t.start();

+ 14 - 0
src/main/java/com/ywt/mg/web/controllers/RegisteredOrderController.java

@@ -4,6 +4,7 @@ import com.ywt.mg.core.MGRight;
 import com.ywt.mg.core.utils.serializers.JsonSerializer;
 import com.ywt.mg.domain.models.ConstantDef;
 import com.ywt.mg.params.registeredOrder.RegisteredOrderListRequest;
+import com.ywt.mg.services.AuthService;
 import com.ywt.mg.services.DownloadRecordService;
 import com.ywt.mg.services.IdGenerator;
 import com.ywt.mg.services.RegisteredOrderService;
@@ -31,12 +32,20 @@ public class RegisteredOrderController {
     @Autowired
     private RegisteredOrderService registeredOrderService;
 
+    @Autowired
+    private AuthService authService;
+
 
     @RequestMapping({"/downloadRegisteredOrderList"})
     public BaseResponse downloadDepositList(RegisteredOrderListRequest request) {
 //        int currentAdminId = Checker.getIntegerValue(authService.getCurrentAdminId());
 //        request.setCurrentAdminId(currentAdminId);
         // 插入记录
+        int hospital = 0;
+        if(request.getHospitalId() > 0){
+            hospital = authService.getCurrentHospitalId();
+        }
+        request.setHospitalId(hospital);
         int downloadRecordId = idGenerator.genDownloadRecordId();
         String name = "公司后台-订单管理-挂号订单";
         String fileName = "挂号订单记录";
@@ -59,6 +68,11 @@ public class RegisteredOrderController {
 //        int currentAdminId = Checker.getIntegerValue(authService.getCurrentAdminId());
 //        request.setCurrentAdminId(currentAdminId);
         // 插入记录
+//        int hospital = 0;
+//        if(request.getHosp() > 0){
+//            hospital = authService.getCurrentHospitalId();
+//            request.setHospitalId(hospital);
+//        }
         int downloadRecordId = idGenerator.genDownloadRecordId();
         String name = "公司后台-订单管理-挂号订单对账数据";
         String fileName = "挂号订单对账数据";

+ 65 - 0
src/main/java/com/ywt/mg/web/controllers/hospital/HospOutpatientOrderController.java

@@ -0,0 +1,65 @@
+package com.ywt.mg.web.controllers.hospital;
+
+import com.ywt.mg.core.MGRight;
+import com.ywt.mg.core.utils.Checker;
+import com.ywt.mg.core.utils.serializers.JsonSerializer;
+import com.ywt.mg.domain.models.ConstantDef;
+import com.ywt.mg.params.outpatientOrder.QueryOutPatientOrderListRequest;
+import com.ywt.mg.services.AuthService;
+import com.ywt.mg.services.DownloadRecordService;
+import com.ywt.mg.services.IdGenerator;
+import com.ywt.mg.services.OutpatientOrderService;
+import com.ywt.mg.web.BaseResponse;
+import com.ywt.mg.web.controllers.OutpatientOrderController;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController("/hosp/outPatient")
+@RequestMapping({"/hosp/outPatient"})
+@MGRight
+public class HospOutpatientOrderController {
+
+    private static Logger logger = LoggerFactory.getLogger(HospOutpatientOrderController.class);
+
+    @Autowired
+    private IdGenerator idGenerator;
+
+    @Autowired
+    private DownloadRecordService downloadRecordService;
+
+    @Autowired
+    private AuthService authService;
+
+    @Autowired
+    private OutpatientOrderService outpatientOrderService;
+
+    @RequestMapping({"/downloadOutPatientOrderList"})
+    public BaseResponse downloadOutPatientOrderList(@RequestBody QueryOutPatientOrderListRequest request) {
+        int currentAdminId = Checker.getIntegerValue(authService.getCurrentAdminId());
+//        request.setCurrentAdminId(currentAdminId);
+        // 插入记录
+
+           int hospital = authService.getCurrentHospitalId();
+            request.setHospitalId(hospital);
+
+        int downloadRecordId = idGenerator.genDownloadRecordId();
+        String name = "医院后台-订单管理-门诊缴费订单列表";
+        String fileName = "门诊缴费记录";
+        String excelSuffixFormat = ConstantDef.EXCEL_SUFFIX_FORMAT;
+        String paramUrl = "/outpatient/downloadOutPatientOrderList";
+        String paramJson = JsonSerializer.toJson(request);
+        downloadRecordService.getOrInsertDownloadRecord(downloadRecordId, name, fileName + excelSuffixFormat, paramUrl, paramJson);
+        Thread t = new Thread() {
+            @Override
+            public void run() {
+                outpatientOrderService.downloadOutPatientOrderListCommon(downloadRecordId, fileName, request, currentAdminId);
+            }
+        };
+        t.start();
+        return new BaseResponse().succeed("后台下载中...");
+    }
+}

+ 1 - 1
src/main/resources/application.properties

@@ -1,7 +1,7 @@
 server.port=7678
 
 #前缀
-#server.contextPath=/downloadService
+server.contextPath=/downloadService
 
 spring.jpa.hibernate.ddl-auto=none