Quellcode durchsuchen

feature: 药房客户端下载

wuyongyi vor 2 Jahren
Ursprung
Commit
f6b343dbd9

+ 40 - 0
src/main/java/com/ywt/mg/domain/models/enums/PharmacyPaymentChannelEnum.java

@@ -0,0 +1,40 @@
+package com.ywt.mg.domain.models.enums;
+
+public enum PharmacyPaymentChannelEnum {
+
+    WeChat("微信", 1),
+    AliPay("支付宝", 2),
+    Cash("现金", 3),          //现场支付
+    MedicalCard("诊疗卡", 4),
+    POS("pos机", 5),
+    FREE("无须支付", 6),
+    MedicalInsurance("医保", 7),
+    ICBC("工行", 8),
+    UNKNOWN("", 0);
+
+    private final String displayName;
+
+    private final int value;
+
+    PharmacyPaymentChannelEnum(String displayName, int value) {
+        this.displayName = displayName;
+        this.value = value;
+    }
+
+    public String getDisplayName() {
+        return displayName;
+    }
+
+    public int getValue() {
+        return value;
+    }
+
+    public static PharmacyPaymentChannelEnum valueOf(int value) {
+        for (PharmacyPaymentChannelEnum item : PharmacyPaymentChannelEnum.values()) {
+            if (item.getValue() == value) {
+                return item;
+            }
+        }
+        return UNKNOWN;
+    }
+}

+ 25 - 0
src/main/java/com/ywt/mg/services/CommonServices.java

@@ -272,4 +272,29 @@ public class CommonServices {
 //        return "待支付";
 //    }
 
+    /**
+     * 广三药房客户端:获取广三的处方状态
+     * <p>
+     * 广三his处方_广三生殖药房:状态:待支付、待取药、已退费、已完成、已过期
+     * his处方+广三生殖药房+如意坊大药房:状态:待支付、待取药、已退费、已完成、已过期、退费中
+     *
+     * @param p 处方记录
+     * @return 处方状态
+     */
+    public String getPrescriptionInfoStatusStrForGS(PrescriptionInfo p) {
+        if (Checker.isNone(p)) {
+            return "";
+        }
+        // 处理退费中的状态
+        if (!Checker.isNone(p.getRefundStatus()) && p.getRefundStatus().equals(RefundStatusEnum.PENDING.getValue())) {
+            return "退费中";
+        }
+        String statusStr = PrescriptionInfoStatusEnum.valueOf(p.getStatus()).getDisplayName();
+        if (Checker.getIntegerValue(p.getStatus()) == PrescriptionInfoStatusEnum.Dispatching.getValue()) {
+            statusStr = "待取药";
+        }
+        return statusStr;
+    }
+
+
 }

+ 141 - 0
src/main/java/com/ywt/mg/services/DownloadRecordService.java

@@ -401,4 +401,145 @@ public class DownloadRecordService {
         }
         return null;
     }
+
+
+    public BaseResponse queryPharDownloadRecordList(QueryDownloadRecordListRequest request) throws Exception {
+        PageDataResponse<Object> pageDataResponse = new PageDataResponse<>();
+        PagedList<DownloadRecord> downloadRecordPagedList = queryPharDownloadRecordListCommon(request);
+        //做转换处理
+        if (!Checker.isNone(downloadRecordPagedList.getItems())) {
+            List<Map<String, Object>> datas = CollectionUtil.toList(downloadRecordPagedList.getItems(), p -> {
+                Map<String, Object> item = new HashMap<>(16);
+
+                item.put("id", p.getId());
+                item.put("name", p.getName());
+                item.put("createTime", FormatUtil.createTimeFormatDetail(p.getCreateTime()));
+                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);
+        } else {
+            pageDataResponse.setData(downloadRecordPagedList.getItems());
+        }
+        int count = downloadRecordPagedList.getTotal();
+        pageDataResponse.setPageIndex(request.getPageIndex());
+        pageDataResponse.setPageSize(request.getPageSize());
+        pageDataResponse.setTotalCount(count);
+        return pageDataResponse.succeed("处理成功");
+    }
+
+
+    private PagedList<DownloadRecord> queryPharDownloadRecordListCommon(QueryDownloadRecordListRequest request) throws ParseException {
+        List<Object> paramList = new ArrayList<>();
+        String whereSql = " ( 1=1 ) ";
+        whereSql += "and (deleted = 0)";
+        whereSql += "and (hospital_id = -1)";
+
+//        int hospitalId = request.getHospitalId();
+//        if (hospitalId >= 0) {
+//            whereSql += " and ( hospital_id = ?)";
+//            paramList.add(hospitalId);
+//        }
+        int adminId = request.getAdminId();
+        if (adminId > 0) {
+            whereSql += " and ( admin_id = ?)";
+            paramList.add(adminId);
+        }
+        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(7);
+        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());
+    }
+
+    public DownloadRecord getOrInsertPharDownloadRecord(int id, String name, String fileName, String paramUrl, String paramJson) {
+        int pharmacyId = 0, hospitalId = -1, currentAdminId = 0;
+        String pharmacyName = "", hospitalName = "", currentAdminName = "";
+        MGAdmins currentAdmin = authService.getCurrentAdmin();
+        if (!Checker.isNone(currentAdmin)) {
+            currentAdminId = currentAdmin.getId();
+            currentAdminName = currentAdmin.getAccount();
+        }
+        Pharmacy pharmacy = authService.getCurrentPharmacy();
+        if (!Checker.isNone(pharmacy)) {
+            pharmacyId = pharmacy.getId();
+            pharmacyName = pharmacy.getName();
+        }
+//        Hospital hospital = authService.getCurrentHospitalByCache();
+//        if (!Checker.isNone(hospital)) {
+////            hospitalId = hospital.getId();
+//            hospitalName = hospital.getName();
+//        }
+        Map map = new HashMap();
+        map.put("param", paramJson);
+        map.put("adminId", currentAdminId);
+        map.put("hospitalId", hospitalId);
+        map.put("pharmacyId", pharmacyId);
+        String paramMd5 = StringHelper.md5(JsonSerializer.toJson(map));
+        // todo: 判断是否有同样的下载
+//        DownloadRecord record = downloadRecordRepository.findCreatingLeastOne(currentAdminId, paramMd5, paramUrl);
+//        if (!Checker.isNone(record)) {
+//            return record;
+//        }
+        DownloadRecord record;
+        record = new DownloadRecord();
+        record.setId(id);
+        record.setName(name);
+        record.setFileName(fileName);
+        record.setPharmacyId(pharmacyId);
+        record.setPharmacyName(pharmacyName);
+        record.setHospitalId(hospitalId);
+        record.setHospitalName(hospitalName);
+        record.setAdminId(currentAdminId);
+        record.setAdminName(currentAdminName);
+        record.setCreateTime(new Date());
+        record.setDeleted(false);
+        record.setParamMd5(paramMd5);
+        record.setParamJson(paramJson);
+        record.setParamUrl(paramUrl);
+        record.setStatus(DownloadRecordStatusEnum.Default.getValue());
+        record.setUpdateTime(new Date());
+        downloadRecordRepository.saveAndFlush(record);
+        return record;
+    }
 }

+ 0 - 305
src/main/java/com/ywt/mg/services/PharamacyService.java

@@ -1,305 +0,0 @@
-package com.ywt.mg.services;
-
-import com.ywt.mg.configs.ParameterConfigurer;
-import com.ywt.mg.core.utils.Checker;
-import com.ywt.mg.domain.models.ConstantDef;
-import com.ywt.mg.domain.models.enums.PrescriptionInfoStatusEnum;
-import com.ywt.mg.domain.models.enums.RefundStatusEnum;
-import com.ywt.mg.domain.models.enums.SinopharmEnum;
-import com.ywt.mg.domain.ywtDrugEntities.Pharmacy;
-import com.ywt.mg.domain.ywtDrugEntities.PrescriptionInfo;
-import com.ywt.mg.params.pharamcy.PharamcyDownloadPresRequest;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.jdbc.core.BeanPropertyRowMapper;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.stereotype.Service;
-
-import java.text.SimpleDateFormat;
-import java.util.*;
-
-@Service
-public class PharamacyService {
-
-    private static final Logger logger = LoggerFactory.getLogger(PharamacyService.class);
-
-    @Autowired
-    private AuthService authService;
-
-    @Autowired
-    private PharmacyCacheService pharmacyCacheService;
-
-    @Autowired
-    private JdbcTemplate ywtDrugJdbcTemplate;
-
-    @Autowired
-    private ParameterConfigurer parameterConfigurer;
-
-
-    private static final String KEY_WHERE_SQL = "whereSql";
-
-    private static final String KEY_PARAM_LIST = "paramList";
-    private static final String INJECTIONS_MAP = "injectionsMap";
-
-
-
-
-    public List<PrescriptionInfo> downloadPrescriptionlist(PharamcyDownloadPresRequest request) {
-        Map<String, Object> map = buildQueryPrescriptionListSQLParam(request);
-        String whereSql = (String) map.get(KEY_WHERE_SQL);
-        List<Object> paramList = (List<Object>) map.get(KEY_PARAM_LIST);
-        // 分页查找
-        // 拼凑sql语句
-        String sqlBuilder = "select *,biz_no_3th as bizNo3th from prescription_info where " + whereSql + " order by create_on desc";
-        return ywtDrugJdbcTemplate.query(sqlBuilder, paramList.toArray(), new BeanPropertyRowMapper<>(PrescriptionInfo.class));
-    }
-
-    private Map<String, Object> buildQueryPrescriptionListSQLParam(PharamcyDownloadPresRequest request) {
-        List<Object> paramList = new ArrayList<>();
-        String whereSql = " ( 1=1 )";
-
-        String doctorname = request.getDoctorName();
-        if (!Checker.isNull(doctorname)) {
-            whereSql += " and ( doctor_name like ?)";
-            paramList.add("%" + doctorname + "%");
-        }
-
-        String patientname = request.getPatientName();
-        if (!Checker.isNull(patientname)) {
-            whereSql += " and ( patient_name like ?)";
-            paramList.add("%" + patientname + "%");
-        }
-        String deptname = request.getDeptName();
-        if (!Checker.isNull(deptname)) {
-            whereSql += " and ( dept like ?)";
-            paramList.add("%" + deptname + "%");
-        }
-
-        whereSql += " and (deleted = 0 or deleted is null) ";
-
-        List<Pharmacy> pharmacyList = pharmacyCacheService.getPharmacyList();
-
-        String selectPharmacyId = Checker.getStringValue(request.getSelectPharmacyId());
-        if (!Checker.isNull(selectPharmacyId)) {
-            whereSql += " and pharmacy_id = ? ";
-            paramList.add(Integer.parseInt(selectPharmacyId));
-        } else {
-
-            // todo: 多药房数据查询
-            whereSql += " and (pharmacy_id = ?";
-            paramList.add(request.getPharmacyId());
-            for (Pharmacy pharmacy : pharmacyList) {
-                if (!Checker.isNone(pharmacy) && pharmacy.getTreeCode().startsWith(request.getPharmacyId() + "|")) {
-                    whereSql += " or pharmacy_id = ?";
-                    paramList.add(pharmacy.getId());
-                }
-            }
-            whereSql += "  ) ";
-        }
-
-        // todo: v4.3.6 广三生殖药房可以看到所有的订单,而其他子药房看不到'待支付'的订单 (所以这里需要针对不是"生殖药房"的子药房进行过滤), parentId != -1 表示是子药房, leader = 0,表示除"生殖药房"的子药房
-        Pharmacy pharmacy = pharmacyList.stream().filter(p -> Checker.getIntegerValue(p.getId()) == request.getPharmacyId()).findFirst().orElse(null);
-        if (!Checker.isNone(pharmacy) && Checker.getIntegerValue(pharmacy.getParentId()) != -1 && Checker.getIntegerValue(pharmacy.getLeader()) == 0) {
-            whereSql += " and ( status != ? ) ";
-            paramList.add(PrescriptionInfoStatusEnum.WaitForPayment.getValue());
-        }
-
-        // 添加测试账号过滤
-        String testAdminIds = parameterConfigurer.getTestAdminIds();
-        String testDoctorIds = parameterConfigurer.getTestDoctorIds();
-        String adminStr = "," + request.getAdminId() + ",";
-        String testAdminIdsStr = "," + testAdminIds + ",";
-
-        // 不是测试账号
-        if (!(testAdminIdsStr.contains(adminStr))) {
-            String[] testDoctorIdsArr = testDoctorIds.split(",");
-            if (!Checker.isNone(testDoctorIdsArr)) {
-                StringBuilder sqlSub = new StringBuilder();
-                for (String doctorId : testDoctorIdsArr) {
-                    sqlSub.append("doctor_id != ").append(doctorId).append(" and ");
-                }
-                String sqlSubStr = sqlSub.substring(0, sqlSub.lastIndexOf("and"));
-                whereSql += String.format(" and ((%s) or doctor_id is null)", sqlSubStr);
-            }
-        }
-
-        /**
-         * 1-待支付; 2-配送中/待取药; 3-已完成
-         * 4-已退费; 5-已过期; 10-退费中
-         */
-        if (!Checker.isNone(request.getStatus())) {
-            int statusInt = Integer.parseInt(request.getStatus());
-            int pharmacyIdInt = authService.getCurrentPharmacyId();
-            int selectPharmacyIdInt = Checker.isNone(selectPharmacyId) ? 0 : Integer.parseInt(selectPharmacyId);
-            // todo: 这是暂时的做法,后续需要优化
-            boolean bl = pharmacyIdInt == ConstantDef.GS_PHARMACY_ID || pharmacyIdInt == ConstantDef.GUANGSAN_ID || pharmacyIdInt == 1 || pharmacyIdInt == 4 || pharmacyIdInt == 5 || pharmacyIdInt == 12 || pharmacyIdInt == 13 || pharmacyIdInt == 14
-                    || request.getPharmacyId() == ConstantDef.GS_PHARMACY_ID || request.getPharmacyId() == ConstantDef.GUANGSAN_ID ||request.getPharmacyId() == 1 || request.getPharmacyId() == 4 || request.getPharmacyId() == 5 || request.getPharmacyId() == 12 || request.getPharmacyId() == 13 || request.getPharmacyId() == 14
-                    || selectPharmacyIdInt == ConstantDef.GS_PHARMACY_ID || selectPharmacyIdInt == ConstantDef.GUANGSAN_ID || selectPharmacyIdInt == 1 || selectPharmacyIdInt == 4 || selectPharmacyIdInt == 5 || selectPharmacyIdInt == 12 || selectPharmacyIdInt == 13 || selectPharmacyIdInt == 14;
-            if (bl) {
-                // 退费中
-                if (statusInt == 10) {
-                    whereSql += " and ( refund_status = ?  ) ";
-                    paramList.add(RefundStatusEnum.PENDING.getValue());
-                } else {
-                    whereSql += " and ( status = ? and (refund_status != ? or refund_status is null) ) ";
-                    paramList.add(Integer.parseInt(request.getStatus()));
-                    paramList.add(RefundStatusEnum.PENDING.getValue());
-                }
-            } else if (authService.getCurrentPharmacyId() == ConstantDef.GK_PHARMACY_ID) {
-                // 国控大药房状态:1-待支付、2-待取药、3-已退费、4-已过期
-                switch (statusInt) {
-                    case 2:
-                        whereSql += " and ( status = 2 or status = 3) ";
-                        break;
-                    case 3:
-                        whereSql += " and ( status = 4) ";
-                        break;
-                    case 4:
-                        whereSql += " and ( status = 5) ";
-                        break;
-                    default:
-                        whereSql += " and ( status = ?) ";
-                        paramList.add(statusInt);
-                        break;
-                }
-            }
-        }
-
-        if (!Checker.isNone(request.getPaymentStatus())) {
-            whereSql += " and ( payment_status = ? ) ";
-            paramList.add(Integer.parseInt(request.getPaymentStatus()));
-        }
-
-        if (!Checker.isNone(request.getPreBizNo())) {
-            whereSql += " and ( pre_biz_no like ? ) ";
-            paramList.add("%" + request.getPreBizNo().trim() + "%");
-        }
-        if (!Checker.isNone(request.getBizNo3th())) {
-            whereSql += " and ( biz_no_3th like ? ) ";
-            paramList.add("%" + request.getBizNo3th().trim() + "%");
-        }
-        if (!Checker.isNone(request.getOrderNo())) {
-            whereSql += " and ( order_no like ? ) ";
-            paramList.add("%" + request.getOrderNo().trim() + "%");
-        }
-
-        if (!Checker.isNone(request.getPaymentChannel())) {
-            whereSql += " and ( payment_channel = ? ) ";
-            paramList.add(Integer.parseInt(request.getPaymentChannel()));
-        }
-
-        String Format_Date = "yyyy-MM-dd";
-        SimpleDateFormat format = new SimpleDateFormat(Format_Date);
-        String createTimeEnd = request.getCreateTimeEnd();
-        String createTimeStart = request.getCreateTimeStart();
-        String payTimeEnd = request.getPayTimeEnd();
-        String payTimeStart = request.getPayTimeStart();
-        String refundTimeEnd = request.getRefundTimeEnd();
-        String refundTimeStart = request.getRefundTimeStart();
-
-        try {
-            // 创建时间
-            if (!Checker.isNull(createTimeEnd)) {
-                whereSql += " and ( create_on < ?)";
-                Date date = format.parse(createTimeEnd);
-                //把日期往后增加一天.整数往后推,负数往前移动
-                Calendar calendar = new GregorianCalendar();
-                calendar.setTime(date);
-                calendar.add(Calendar.DATE, 1);
-                //这个时间就是日期往后推一天的结果
-                date = calendar.getTime();
-
-                paramList.add(date);
-            }
-
-
-
-            if (!Checker.isNull(createTimeStart)) {
-                whereSql += " and ( create_on >= ?)";
-                Date date = format.parse(createTimeStart);
-                paramList.add(date);
-            }
-
-            // 支付时间
-            if (!Checker.isNull(payTimeEnd)) {
-                whereSql += " and ( pay_time < ?)";
-                Date date = format.parse(payTimeEnd);
-                //把日期往后增加一天.整数往后推,负数往前移动
-                Calendar calendar = new GregorianCalendar();
-                calendar.setTime(date);
-                calendar.add(Calendar.DATE, 1);
-                //这个时间就是日期往后推一天的结果
-                date = calendar.getTime();
-
-                paramList.add(date);
-            }
-
-            if (!Checker.isNull(payTimeStart)) {
-                whereSql += " and ( pay_time >= ?)";
-                Date date = format.parse(payTimeStart);
-                paramList.add(date);
-            }
-
-
-            // 退费时间搜索
-            if (!Checker.isNull(refundTimeEnd)) {
-                whereSql += " and (refund_time < ?)";
-                Date date = format.parse(refundTimeEnd);
-                //把日期往后增加一天.整数往后推,负数往前移动
-                Calendar calendar = new GregorianCalendar();
-                calendar.setTime(date);
-                calendar.add(Calendar.DATE, 1);
-                //这个时间就是日期往后推一天的结果
-                date = calendar.getTime();
-
-                paramList.add(date);
-            }
-
-            if (!Checker.isNull(refundTimeStart)) {
-                whereSql += " and ( refund_time >= ?)";
-                Date date = format.parse(refundTimeStart);
-                paramList.add(date);
-            }
-
-            if (!Checker.isNull(request.getSource())) {
-                whereSql += " and ( source = ?)";
-                paramList.add(Integer.parseInt(request.getSource()));
-            }
-            if (!Checker.isNull(request.getReceiveStatus())) {
-                int receiveStatusInt = Integer.parseInt(request.getReceiveStatus());
-                // receiveStatus: 1-成功,2-失败
-                if (receiveStatusInt == 1) {
-                    whereSql += " and ( sinopharm & ? = ?)";
-                    paramList.add(SinopharmEnum.CONFIRM_ORDER.getValue());
-                    paramList.add(SinopharmEnum.CONFIRM_ORDER.getValue());
-                } else {
-                    whereSql += " and ( sinopharm & ? = ?)";
-                    paramList.add(SinopharmEnum.Failure.getValue());
-                    paramList.add(SinopharmEnum.Failure.getValue());
-                }
-            }
-
-            if (!Checker.isNull(selectPharmacyId)) {
-                whereSql += " and pharmacy_id = ? ";
-                paramList.add(Integer.parseInt(selectPharmacyId));
-            }
-
-
-            if (!Checker.isNull(request.getPatientNo())) {
-                whereSql += " and patient_no = ? ";
-                paramList.add(request.getPatientNo().trim());
-            }
-
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
-        // logger.info("buildQueryPrescriptionListSQLParam(): whereSql = " + whereSql);
-
-        Map<String, Object> map = new HashMap<>();
-        map.put("whereSql", whereSql);
-        map.put("paramList", paramList);
-        return map;
-    }
-}

+ 554 - 0
src/main/java/com/ywt/mg/services/PharmacyService.java

@@ -0,0 +1,554 @@
+package com.ywt.mg.services;
+
+import com.ywt.mg.configs.ParameterConfigurer;
+import com.ywt.mg.core.utils.Checker;
+import com.ywt.mg.core.utils.FormatUtil;
+import com.ywt.mg.domain.models.ConstantDef;
+import com.ywt.mg.domain.models.ExcelDataMap;
+import com.ywt.mg.domain.models.enums.*;
+import com.ywt.mg.domain.models.pojo.ExcelCollectPojo;
+import com.ywt.mg.domain.ywtDrugEntities.Pharmacy;
+import com.ywt.mg.domain.ywtDrugEntities.PrescriptionInfo;
+import com.ywt.mg.params.outpatientOrder.QueryOutPatientOrderListRequest;
+import com.ywt.mg.params.pharamcy.PharamcyDownloadPresRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.stereotype.Service;
+
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+@Service
+public class PharmacyService {
+
+    private static final Logger logger = LoggerFactory.getLogger(PharmacyService.class);
+
+    @Autowired
+    private AuthService authService;
+
+    @Autowired
+    private PharmacyCacheService pharmacyCacheService;
+
+    @Autowired
+    private JdbcTemplate ywtDrugJdbcTemplate;
+
+    @Autowired
+    private ParameterConfigurer parameterConfigurer;
+
+    @Autowired
+    private CommonServices commonServices;
+
+    @Autowired
+    private DownloadRecordService downloadRecordService;
+
+
+    private static final String KEY_WHERE_SQL = "whereSql";
+
+    private static final String KEY_PARAM_LIST = "paramList";
+    private static final String INJECTIONS_MAP = "injectionsMap";
+
+
+    public List<PrescriptionInfo> downloadPrescriptionlist(PharamcyDownloadPresRequest request) {
+        Map<String, Object> map = buildQueryPrescriptionListSQLParam(request);
+        String whereSql = (String) map.get(KEY_WHERE_SQL);
+        List<Object> paramList = (List<Object>) map.get(KEY_PARAM_LIST);
+        // 分页查找
+        // 拼凑sql语句
+        String sqlBuilder = "select *,biz_no_3th as bizNo3th from prescription_info where " + whereSql + " order by create_on desc";
+        return ywtDrugJdbcTemplate.query(sqlBuilder, paramList.toArray(), new BeanPropertyRowMapper<>(PrescriptionInfo.class));
+    }
+
+    private Map<String, Object> buildQueryPrescriptionListSQLParam(PharamcyDownloadPresRequest request) {
+        List<Object> paramList = new ArrayList<>();
+        String whereSql = " ( 1=1 )";
+
+        String doctorname = request.getDoctorName();
+        if (!Checker.isNull(doctorname)) {
+            whereSql += " and ( doctor_name like ?)";
+            paramList.add("%" + doctorname + "%");
+        }
+
+        String patientname = request.getPatientName();
+        if (!Checker.isNull(patientname)) {
+            whereSql += " and ( patient_name like ?)";
+            paramList.add("%" + patientname + "%");
+        }
+        String deptname = request.getDeptName();
+        if (!Checker.isNull(deptname)) {
+            whereSql += " and ( dept like ?)";
+            paramList.add("%" + deptname + "%");
+        }
+
+        whereSql += " and (deleted = 0 or deleted is null) ";
+
+        List<Pharmacy> pharmacyList = pharmacyCacheService.getPharmacyList();
+
+        String selectPharmacyId = Checker.getStringValue(request.getSelectPharmacyId());
+        if (!Checker.isNull(selectPharmacyId)) {
+            whereSql += " and pharmacy_id = ? ";
+            paramList.add(Integer.parseInt(selectPharmacyId));
+        } else {
+
+            // todo: 多药房数据查询
+            whereSql += " and (pharmacy_id = ?";
+            paramList.add(request.getPharmacyId());
+            for (Pharmacy pharmacy : pharmacyList) {
+                if (!Checker.isNone(pharmacy) && pharmacy.getTreeCode().startsWith(request.getPharmacyId() + "|")) {
+                    whereSql += " or pharmacy_id = ?";
+                    paramList.add(pharmacy.getId());
+                }
+            }
+            whereSql += "  ) ";
+        }
+
+        // todo: v4.3.6 广三生殖药房可以看到所有的订单,而其他子药房看不到'待支付'的订单 (所以这里需要针对不是"生殖药房"的子药房进行过滤), parentId != -1 表示是子药房, leader = 0,表示除"生殖药房"的子药房
+        Pharmacy pharmacy = pharmacyList.stream().filter(p -> Checker.getIntegerValue(p.getId()) == request.getPharmacyId()).findFirst().orElse(null);
+        if (!Checker.isNone(pharmacy) && Checker.getIntegerValue(pharmacy.getParentId()) != -1 && Checker.getIntegerValue(pharmacy.getLeader()) == 0) {
+            whereSql += " and ( status != ? ) ";
+            paramList.add(PrescriptionInfoStatusEnum.WaitForPayment.getValue());
+        }
+
+        // 添加测试账号过滤
+        String testAdminIds = parameterConfigurer.getTestAdminIds();
+        String testDoctorIds = parameterConfigurer.getTestDoctorIds();
+        String adminStr = "," + request.getAdminId() + ",";
+        String testAdminIdsStr = "," + testAdminIds + ",";
+
+        // 不是测试账号
+        if (!(testAdminIdsStr.contains(adminStr))) {
+            String[] testDoctorIdsArr = testDoctorIds.split(",");
+            if (!Checker.isNone(testDoctorIdsArr)) {
+                StringBuilder sqlSub = new StringBuilder();
+                for (String doctorId : testDoctorIdsArr) {
+                    sqlSub.append("doctor_id != ").append(doctorId).append(" and ");
+                }
+                String sqlSubStr = sqlSub.substring(0, sqlSub.lastIndexOf("and"));
+                whereSql += String.format(" and ((%s) or doctor_id is null)", sqlSubStr);
+            }
+        }
+
+        /**
+         * 1-待支付; 2-配送中/待取药; 3-已完成
+         * 4-已退费; 5-已过期; 10-退费中
+         */
+        if (!Checker.isNone(request.getStatus())) {
+            int statusInt = Integer.parseInt(request.getStatus());
+            int pharmacyIdInt = authService.getCurrentPharmacyId();
+            int selectPharmacyIdInt = Checker.isNone(selectPharmacyId) ? 0 : Integer.parseInt(selectPharmacyId);
+            // todo: 这是暂时的做法,后续需要优化
+            boolean bl = pharmacyIdInt == ConstantDef.GS_PHARMACY_ID || pharmacyIdInt == ConstantDef.GUANGSAN_ID || pharmacyIdInt == 1 || pharmacyIdInt == 4 || pharmacyIdInt == 5 || pharmacyIdInt == 12 || pharmacyIdInt == 13 || pharmacyIdInt == 14
+                    || request.getPharmacyId() == ConstantDef.GS_PHARMACY_ID || request.getPharmacyId() == ConstantDef.GUANGSAN_ID || request.getPharmacyId() == 1 || request.getPharmacyId() == 4 || request.getPharmacyId() == 5 || request.getPharmacyId() == 12 || request.getPharmacyId() == 13 || request.getPharmacyId() == 14
+                    || selectPharmacyIdInt == ConstantDef.GS_PHARMACY_ID || selectPharmacyIdInt == ConstantDef.GUANGSAN_ID || selectPharmacyIdInt == 1 || selectPharmacyIdInt == 4 || selectPharmacyIdInt == 5 || selectPharmacyIdInt == 12 || selectPharmacyIdInt == 13 || selectPharmacyIdInt == 14;
+            if (bl) {
+                // 退费中
+                if (statusInt == 10) {
+                    whereSql += " and ( refund_status = ?  ) ";
+                    paramList.add(RefundStatusEnum.PENDING.getValue());
+                } else {
+                    whereSql += " and ( status = ? and (refund_status != ? or refund_status is null) ) ";
+                    paramList.add(Integer.parseInt(request.getStatus()));
+                    paramList.add(RefundStatusEnum.PENDING.getValue());
+                }
+            } else if (authService.getCurrentPharmacyId() == ConstantDef.GK_PHARMACY_ID) {
+                // 国控大药房状态:1-待支付、2-待取药、3-已退费、4-已过期
+                switch (statusInt) {
+                    case 2:
+                        whereSql += " and ( status = 2 or status = 3) ";
+                        break;
+                    case 3:
+                        whereSql += " and ( status = 4) ";
+                        break;
+                    case 4:
+                        whereSql += " and ( status = 5) ";
+                        break;
+                    default:
+                        whereSql += " and ( status = ?) ";
+                        paramList.add(statusInt);
+                        break;
+                }
+            }
+        }
+
+        if (!Checker.isNone(request.getPaymentStatus())) {
+            whereSql += " and ( payment_status = ? ) ";
+            paramList.add(Integer.parseInt(request.getPaymentStatus()));
+        }
+
+        if (!Checker.isNone(request.getPreBizNo())) {
+            whereSql += " and ( pre_biz_no like ? ) ";
+            paramList.add("%" + request.getPreBizNo().trim() + "%");
+        }
+        if (!Checker.isNone(request.getBizNo3th())) {
+            whereSql += " and ( biz_no_3th like ? ) ";
+            paramList.add("%" + request.getBizNo3th().trim() + "%");
+        }
+        if (!Checker.isNone(request.getOrderNo())) {
+            whereSql += " and ( order_no like ? ) ";
+            paramList.add("%" + request.getOrderNo().trim() + "%");
+        }
+
+        if (!Checker.isNone(request.getPaymentChannel())) {
+            whereSql += " and ( payment_channel = ? ) ";
+            paramList.add(Integer.parseInt(request.getPaymentChannel()));
+        }
+
+        String Format_Date = "yyyy-MM-dd";
+        SimpleDateFormat format = new SimpleDateFormat(Format_Date);
+        String createTimeEnd = request.getCreateTimeEnd();
+        String createTimeStart = request.getCreateTimeStart();
+        String payTimeEnd = request.getPayTimeEnd();
+        String payTimeStart = request.getPayTimeStart();
+        String refundTimeEnd = request.getRefundTimeEnd();
+        String refundTimeStart = request.getRefundTimeStart();
+
+        try {
+            // 创建时间
+            if (!Checker.isNull(createTimeEnd)) {
+                whereSql += " and ( create_on < ?)";
+                Date date = format.parse(createTimeEnd);
+                //把日期往后增加一天.整数往后推,负数往前移动
+                Calendar calendar = new GregorianCalendar();
+                calendar.setTime(date);
+                calendar.add(Calendar.DATE, 1);
+                //这个时间就是日期往后推一天的结果
+                date = calendar.getTime();
+
+                paramList.add(date);
+            }
+
+
+            if (!Checker.isNull(createTimeStart)) {
+                whereSql += " and ( create_on >= ?)";
+                Date date = format.parse(createTimeStart);
+                paramList.add(date);
+            }
+
+            // 支付时间
+            if (!Checker.isNull(payTimeEnd)) {
+                whereSql += " and ( pay_time < ?)";
+                Date date = format.parse(payTimeEnd);
+                //把日期往后增加一天.整数往后推,负数往前移动
+                Calendar calendar = new GregorianCalendar();
+                calendar.setTime(date);
+                calendar.add(Calendar.DATE, 1);
+                //这个时间就是日期往后推一天的结果
+                date = calendar.getTime();
+
+                paramList.add(date);
+            }
+
+            if (!Checker.isNull(payTimeStart)) {
+                whereSql += " and ( pay_time >= ?)";
+                Date date = format.parse(payTimeStart);
+                paramList.add(date);
+            }
+
+
+            // 退费时间搜索
+            if (!Checker.isNull(refundTimeEnd)) {
+                whereSql += " and (refund_time < ?)";
+                Date date = format.parse(refundTimeEnd);
+                //把日期往后增加一天.整数往后推,负数往前移动
+                Calendar calendar = new GregorianCalendar();
+                calendar.setTime(date);
+                calendar.add(Calendar.DATE, 1);
+                //这个时间就是日期往后推一天的结果
+                date = calendar.getTime();
+
+                paramList.add(date);
+            }
+
+            if (!Checker.isNull(refundTimeStart)) {
+                whereSql += " and ( refund_time >= ?)";
+                Date date = format.parse(refundTimeStart);
+                paramList.add(date);
+            }
+
+            if (!Checker.isNull(request.getSource())) {
+                whereSql += " and ( source = ?)";
+                paramList.add(Integer.parseInt(request.getSource()));
+            }
+            if (!Checker.isNull(request.getReceiveStatus())) {
+                int receiveStatusInt = Integer.parseInt(request.getReceiveStatus());
+                // receiveStatus: 1-成功,2-失败
+                if (receiveStatusInt == 1) {
+                    whereSql += " and ( sinopharm & ? = ?)";
+                    paramList.add(SinopharmEnum.CONFIRM_ORDER.getValue());
+                    paramList.add(SinopharmEnum.CONFIRM_ORDER.getValue());
+                } else {
+                    whereSql += " and ( sinopharm & ? = ?)";
+                    paramList.add(SinopharmEnum.Failure.getValue());
+                    paramList.add(SinopharmEnum.Failure.getValue());
+                }
+            }
+
+            if (!Checker.isNull(selectPharmacyId)) {
+                whereSql += " and pharmacy_id = ? ";
+                paramList.add(Integer.parseInt(selectPharmacyId));
+            }
+
+
+            if (!Checker.isNull(request.getPatientNo())) {
+                whereSql += " and patient_no = ? ";
+                paramList.add(request.getPatientNo().trim());
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        // logger.info("buildQueryPrescriptionListSQLParam(): whereSql = " + whereSql);
+
+        Map<String, Object> map = new HashMap<>();
+        map.put("whereSql", whereSql);
+        map.put("paramList", paramList);
+        return map;
+    }
+
+
+    public void downloadPharPrescriptionlist(int downloadRecordId, String fileName, PharamcyDownloadPresRequest request) {
+        try {
+//               "订单号", "处方号", "医生姓名", "患者姓名", "药房", "来源", "状态", "支付状态", "支付渠道",
+//                       "总金额", "创建时间", "支付时间", "退费时间", "备注", "药店系统接收"
+            String col0 = "订单号";
+            String col1 = "处方号";
+            String col2 = "医生姓名";
+            String col3 = "患者姓名";
+            String col4 = "药房";
+            String col5 = "来源";
+            String col6 = "状态";
+            String col7 = "支付状态";
+            String col8 = "支付渠道";
+            String col9 = "总金额";
+            String col10 = "创建时间";
+            String col11 = "支付时间";
+            String col12 = "退费时间";
+            String col13 = "备注";
+            String col14 = "药店系统接收";
+            String col15 = "诊疗卡号或ID号";
+
+            String[] columns = new String[]{col0, col1, col2, col3, col4, col5, col6, col7, col8, col9, col10,
+                    col11, col12, col13, col14};
+            if (Checker.getIntegerValue(request.getPharmacyId()) == ConstantDef.GK_PHARMACY_ID) {
+                columns = new String[]{col0, col1, col15, col3, col5, col4, col6, col7, col8, col9, col10,
+                        col11, col12};
+            }
+            int payTotal = 0, refundTotal = 0, realTotal = 0,
+                    weChatPay = 0, weChatRefundTotal = 0, weChatRealTotal = 0,
+                    aliPay = 0, aliRefundTotal = 0, aliRealTotal = 0,
+                    cashPay = 0, cashRefundTotal = 0, cashRealTotal = 0,
+                    medicalCardPay = 0, medicalCardRefundTotal = 0, medicalCardRealTotal = 0,
+                    posPay = 0, posRefundTotal = 0, posRealTotal = 0,
+                    medicalInsurancePay = 0, medicalInsuranceRefundTotal = 0, medicalInsuranceRealTotal = 0,
+                    icbcPay = 0, icbcRefundTotal = 0, icbcRealTotal = 0;
+            List<PrescriptionInfo> list = downloadPrescriptionlist(request);
+            ExcelDataMap map = new ExcelDataMap(columns);
+            if (!Checker.isNone(list)) {
+                Map<Integer, Pharmacy> pharmacyMap = pharmacyCacheService.getPharmacyMap();
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+
+                for (PrescriptionInfo p : list) {
+
+                    String orderNoValue = Checker.getStringValue(p.getOrderNo());
+                    String bizNo3thValue = Checker.getStringValue(p.getBizNo3th());
+                    String doctorNameValue = Checker.getStringValue(p.getDoctorName());
+                    String patientNameValue = Checker.getStringValue(p.getPatientName());
+                    // 合并之后,列数一样,合并的列在中间,行数一样
+                    // 药房
+                    Pharmacy pharmacy = pharmacyMap.get(Checker.getIntegerValue(p.getPharmacyId()));
+                    String pharmacyName = !Checker.isNone(pharmacy) ? pharmacy.getName() : "";
+                    // 来源
+                    String sourceStr = PrescriptionInfoSourceEnum.getSource(p.getSource()).getDisplayName();
+                    // 状态
+                    String statusStr = commonServices.getPrescriptionInfoStatusStrForGS(p);
+                    // 支付状态
+                    String paymentStr = PaymentStatusEnum.getPaymentStatus(Checker.getIntegerValue(p.getPaymentStatus())).getDisplayName();
+                    // 总金额
+                    String totalStr = String.format("%.2f", (Checker.getIntegerValue(p.getTotalPrice()) / 100d));
+                    // 创建时间
+                    String createTimeStr = !Checker.isNone(p.getCreateOn()) ? sdf.format(p.getCreateOn()) : "";
+                    // 支付渠道
+                    String paymentChannel = PharmacyPaymentChannelEnum.valueOf(Checker.getIntegerValue(p.getPaymentChannel())).getDisplayName();
+                    // 创建时间
+                    String createTime = FormatUtil.createTimeFormatList(p.getCreateOn());
+                    // 支付时间
+                    String payTime = !Checker.isNone(p.getPayTime()) ? sdf.format(p.getPayTime()) : "";
+                    // 退费时间
+                    String refundTime = !Checker.isNone(p.getRefundTime()) ? sdf.format(p.getRefundTime()) : "";
+                    //备注
+                    String remark = Checker.getStringValue(p.getRemarks());
+                    // 药店系统接收状态
+                    int sinopharm = Checker.getIntegerValue(p.getSinopharm());
+                    String sinopharmStr = getSinopharmStr(sinopharm);
+
+                    if(request.getPharmacyId() == ConstantDef.GK_PHARMACY_ID){
+                        String patientNoStr = Checker.getStringValue(p.getPatientNo());
+                        map.getStringListSafely(col0).add(orderNoValue);
+                        map.getStringListSafely(col1).add(bizNo3thValue);
+                        map.getStringListSafely(col15).add(patientNameValue);
+                        map.getStringListSafely(col3).add(patientNameValue);
+                        map.getStringListSafely(col5).add(sourceStr);
+                        map.getStringListSafely(col4).add(pharmacyName);
+                        map.getStringListSafely(col6).add(statusStr);
+                        map.getStringListSafely(col7).add(paymentStr);
+                        map.getStringListSafely(col8).add(paymentChannel);
+                        map.getStringListSafely(col9).add(totalStr);
+                        map.getStringListSafely(col10).add( createTimeStr);
+                        map.getStringListSafely(col11).add(payTime);
+                        map.getStringListSafely(col12).add(refundTime);
+
+                    } else {
+                        map.getStringListSafely(col0).add(orderNoValue);
+                        map.getStringListSafely(col1).add(bizNo3thValue);
+                        map.getStringListSafely(col2).add(doctorNameValue);
+                        map.getStringListSafely(col3).add(patientNameValue);
+                        map.getStringListSafely(col4).add(pharmacyName);
+                        map.getStringListSafely(col5).add(sourceStr);
+                        map.getStringListSafely(col6).add(statusStr);
+                        map.getStringListSafely(col7).add(paymentStr);
+                        map.getStringListSafely(col8).add(paymentChannel);
+                        map.getStringListSafely(col9).add(totalStr);
+                        map.getStringListSafely(col10).add( createTimeStr);
+                        map.getStringListSafely(col11).add(payTime);
+                        map.getStringListSafely(col12).add(refundTime);
+                        map.getStringListSafely(col13).add(remark);
+                        map.getStringListSafely(col14).add(sinopharmStr);
+
+                    }
+
+
+                    //统计支付总额和退费总额
+                    int paymentStatusInt = Checker.getIntegerValue(p.getPaymentStatus());
+                    int presStatus = Checker.getIntegerValue(p.getStatus());
+                    int payChanelInt = Checker.getIntegerValue(p.getPaymentChannel());
+
+                    if (presStatus == PrescriptionInfoStatusEnum.HaveARefund.getValue()) {
+                        refundTotal += Checker.getIntegerValue(p.getTotalPrice());
+
+                        if (payChanelInt == PresPaymentChannelEnum.WeChat.getValue()) {
+                            weChatRefundTotal += Checker.getIntegerValue(p.getTotalPrice());
+                        } else if (payChanelInt == PresPaymentChannelEnum.AliPay.getValue()) {
+                            aliRefundTotal += Checker.getIntegerValue(p.getTotalPrice());
+                        } else if (payChanelInt == PresPaymentChannelEnum.Cash.getValue()) {
+                            cashRefundTotal += Checker.getIntegerValue(p.getTotalPrice());
+                        } else if (payChanelInt == PresPaymentChannelEnum.MedicalCard.getValue()) {
+                            medicalCardRefundTotal += Checker.getIntegerValue(p.getTotalPrice());
+                        } else if (payChanelInt == PresPaymentChannelEnum.POS.getValue()) {
+                            posRefundTotal += Checker.getIntegerValue(p.getTotalPrice());
+                        } else if (payChanelInt == PresPaymentChannelEnum.MedicalInsurance.getValue()) {
+                            medicalInsuranceRefundTotal += Checker.getIntegerValue(p.getTotalPrice());
+                        } else if (payChanelInt == PresPaymentChannelEnum.ICBC.getValue()) {
+                            icbcRefundTotal += Checker.getIntegerValue(p.getTotalPrice());
+                        }
+                    }
+                    if (paymentStatusInt == PaymentStatusEnum.Success.getValue()) {
+                        payTotal += Checker.getIntegerValue(p.getTotalPrice());
+
+                        if (payChanelInt == PresPaymentChannelEnum.WeChat.getValue()) {
+                            weChatPay += Checker.getIntegerValue(p.getTotalPrice());
+                        } else if (payChanelInt == PresPaymentChannelEnum.AliPay.getValue()) {
+                            aliPay += Checker.getIntegerValue(p.getTotalPrice());
+                        } else if (payChanelInt == PresPaymentChannelEnum.Cash.getValue()) {
+                            cashPay += Checker.getIntegerValue(p.getTotalPrice());
+                        } else if (payChanelInt == PresPaymentChannelEnum.MedicalCard.getValue()) {
+                            medicalCardPay += Checker.getIntegerValue(p.getTotalPrice());
+                        } else if (payChanelInt == PresPaymentChannelEnum.POS.getValue()) {
+                            posPay += Checker.getIntegerValue(p.getTotalPrice());
+                        } else if (payChanelInt == PresPaymentChannelEnum.MedicalInsurance.getValue()) {
+                            medicalInsurancePay += Checker.getIntegerValue(p.getTotalPrice());
+                        } else if (payChanelInt == PresPaymentChannelEnum.ICBC.getValue()) {
+                            icbcPay += Checker.getIntegerValue(p.getTotalPrice());
+                        }
+                    }
+                }
+
+            }
+            int size = list.size();
+            List<ExcelCollectPojo> itemList = getStatisticsData(size, payTotal, refundTotal, weChatPay, weChatRefundTotal,
+                    aliPay, aliRefundTotal,
+                    cashPay, cashRefundTotal,
+                    medicalCardPay, medicalCardRefundTotal,
+                    posPay, posRefundTotal,
+                    medicalInsurancePay, medicalInsuranceRefundTotal,
+                    icbcPay, icbcRefundTotal);
+            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList);
+
+        } catch (Exception e) {
+            logger.error("/pharmacy/downloadPrescriptionlist(): {}", e.getMessage(), e);
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 药店系统接收状态(文字)
+     *
+     * @param sinopharm 国控推送状态,参考{@link SinopharmEnum}
+     * @return 状态(文字)
+     */
+    public String getSinopharmStr(Integer sinopharm) {
+        if ((sinopharm & SinopharmEnum.CONFIRM_ORDER.getValue()) == SinopharmEnum.CONFIRM_ORDER.getValue()) {
+            return "成功";
+        }
+        if ((sinopharm & SinopharmEnum.Failure.getValue()) == SinopharmEnum.Failure.getValue()) {
+            return "失败";
+        }
+        return "";
+    }
+
+    private List<ExcelCollectPojo> getStatisticsData(int size, int payTotal, int refundTotal, int weChatPay, int weChatRefundTotal,
+                                                     int aliPay, int aliRefundTotal,
+                                                     int cashPay, int cashRefundTotal,
+                                                     int medicalCardPay, int medicalCardRefundTotal,
+                                                     int posPay, int posRefundTotal,
+                                                     int medicalInsurancePay, int medicalInsuranceRefundTotal,
+                                                     int icbcPay, int icbcRefundTotal) {
+        int startRows = size + 3;
+        int startColumn = 3;
+
+        List<ExcelCollectPojo> customExcelItemList = new ArrayList<>();
+        customExcelItemList.add(new ExcelCollectPojo(startColumn + 1, startRows, new String[]{"支付总额", FormatUtil.intShrink100ToStr(payTotal)}));
+        customExcelItemList.add(new ExcelCollectPojo(startColumn + 3, startRows, new String[]{"退款总额", FormatUtil.intShrink100ToStr(refundTotal)}));
+        customExcelItemList.add(new ExcelCollectPojo(startColumn + 5, startRows, new String[]{"实际支付金额", FormatUtil.intShrink100ToStr(payTotal - refundTotal)}));
+        startRows += 1;
+
+        customExcelItemList.add(new ExcelCollectPojo(startColumn + 1, startRows, new String[]{"微信支付总额", FormatUtil.intShrink100ToStr(weChatPay)}));
+        customExcelItemList.add(new ExcelCollectPojo(startColumn + 3, startRows, new String[]{"微信退费总额", FormatUtil.intShrink100ToStr(weChatRefundTotal)}));
+        customExcelItemList.add(new ExcelCollectPojo(startColumn + 5, startRows, new String[]{"微信实际支付金额", FormatUtil.intShrink100ToStr(weChatPay - weChatRefundTotal)}));
+        startRows += 1;
+
+        customExcelItemList.add(new ExcelCollectPojo(startColumn + 1, startRows, new String[]{"支付宝支付", FormatUtil.intShrink100ToStr(aliPay)}));
+        customExcelItemList.add(new ExcelCollectPojo(startColumn + 3, startRows, new String[]{"支付宝退费总额", FormatUtil.intShrink100ToStr(refundTotal)}));
+        customExcelItemList.add(new ExcelCollectPojo(startColumn + 5, startRows, new String[]{"支付宝实际金额", FormatUtil.intShrink100ToStr(aliPay - aliRefundTotal)}));
+        startRows += 1;
+
+        customExcelItemList.add(new ExcelCollectPojo(startColumn + 1, startRows, new String[]{"现金支付", FormatUtil.intShrink100ToStr(cashPay)}));
+        customExcelItemList.add(new ExcelCollectPojo(startColumn + 3, startRows, new String[]{"现金退费总额", FormatUtil.intShrink100ToStr(cashRefundTotal)}));
+        customExcelItemList.add(new ExcelCollectPojo(startColumn + 5, startRows, new String[]{"现金实际金额", FormatUtil.intShrink100ToStr(cashPay - cashRefundTotal)}));
+        startRows += 1;
+
+        customExcelItemList.add(new ExcelCollectPojo(startColumn + 1, startRows, new String[]{"诊疗卡支付", FormatUtil.intShrink100ToStr(medicalCardPay)}));
+        customExcelItemList.add(new ExcelCollectPojo(startColumn + 3, startRows, new String[]{"诊疗卡退款总额", FormatUtil.intShrink100ToStr(medicalCardRefundTotal)}));
+        customExcelItemList.add(new ExcelCollectPojo(startColumn + 5, startRows, new String[]{"诊疗卡实际支付金额", FormatUtil.intShrink100ToStr(medicalCardPay - medicalCardRefundTotal)}));
+        startRows += 1;
+
+        customExcelItemList.add(new ExcelCollectPojo(startColumn + 1, startRows, new String[]{"POS支付", FormatUtil.intShrink100ToStr(posPay)}));
+        customExcelItemList.add(new ExcelCollectPojo(startColumn + 3, startRows, new String[]{"POS退款总额", FormatUtil.intShrink100ToStr(posRefundTotal)}));
+        customExcelItemList.add(new ExcelCollectPojo(startColumn + 5, startRows, new String[]{"POS实际支付金额", FormatUtil.intShrink100ToStr(posPay - posRefundTotal)}));
+        startRows += 1;
+
+        customExcelItemList.add(new ExcelCollectPojo(startColumn + 1, startRows, new String[]{"医保支付", FormatUtil.intShrink100ToStr(medicalInsurancePay)}));
+        customExcelItemList.add(new ExcelCollectPojo(startColumn + 3, startRows, new String[]{"医保退款总额", FormatUtil.intShrink100ToStr(medicalInsuranceRefundTotal)}));
+        customExcelItemList.add(new ExcelCollectPojo(startColumn + 5, startRows, new String[]{"医保实际支付金额", FormatUtil.intShrink100ToStr(medicalInsurancePay - medicalInsuranceRefundTotal)}));
+        startRows += 1;
+
+        customExcelItemList.add(new ExcelCollectPojo(startColumn + 1, startRows, new String[]{"工行支付", FormatUtil.intShrink100ToStr(icbcPay)}));
+        customExcelItemList.add(new ExcelCollectPojo(startColumn + 3, startRows, new String[]{"工行退款总额", FormatUtil.intShrink100ToStr(refundTotal)}));
+        customExcelItemList.add(new ExcelCollectPojo(startColumn + 5, startRows, new String[]{"工行实际支付金额", FormatUtil.intShrink100ToStr(icbcPay - icbcRefundTotal)}));
+
+
+        return customExcelItemList;
+    }
+}

+ 98 - 0
src/main/java/com/ywt/mg/web/controllers/pharmacy/PharmacyController.java

@@ -0,0 +1,98 @@
+package com.ywt.mg.web.controllers.pharmacy;
+
+
+import com.ywt.mg.core.MGRight;
+import com.ywt.mg.core.MGRightTypeDef;
+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.downloadRecord.DownloadFileRequest;
+import com.ywt.mg.params.downloadRecord.QueryDownloadRecordListRequest;
+import com.ywt.mg.params.pharamcy.PharamcyDownloadPresRequest;
+import com.ywt.mg.params.prescription.QueryPrescriptionListRequest;
+import com.ywt.mg.services.AuthService;
+import com.ywt.mg.services.DownloadRecordService;
+import com.ywt.mg.services.IdGenerator;
+import com.ywt.mg.services.PharmacyService;
+import com.ywt.mg.web.BaseResponse;
+import com.ywt.mg.web.controllers.hospital.HospNatOrderController;
+import io.swagger.annotations.ApiOperation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletResponse;
+
+@RestController("/pharmacy")
+@RequestMapping({"/pharmacy"})
+@MGRight
+public class PharmacyController {
+
+    private static Logger logger = LoggerFactory.getLogger(HospNatOrderController.class);
+
+    @Autowired
+    private IdGenerator idGenerator;
+
+    @Autowired
+    private DownloadRecordService downloadRecordService;
+
+    @Autowired
+    private AuthService authService;
+
+    @Autowired
+    private PharmacyService pharmacyService;
+
+
+    @ApiOperation(value = "按条件查询下载记录列表")
+    @RequestMapping(value = {"/downloadRecordList"}, method = RequestMethod.POST)
+    @MGRight(menuCode = {"/pharmacy/downloadRecord/queryDownloadRecordList"}, type = MGRightTypeDef.Menu | MGRightTypeDef.Logined)
+    BaseResponse queryDownloadRecordList(@Validated @RequestBody QueryDownloadRecordListRequest request) throws Exception {
+        //药房客户端
+        request.setHospitalId(-1);
+        int adminId = authService.getCurrentAdminId();
+        request.setAdminId(adminId);
+        return downloadRecordService.queryPharDownloadRecordList(request);
+    }
+
+    @ApiOperation(value = "下载文件")
+    @RequestMapping(value = {"/downloadFile"}, method = RequestMethod.GET)
+    @MGRight(menuCode = {"/pharmacy/downloadRecord/downloadFile"}, type = MGRightTypeDef.Menu | MGRightTypeDef.Logined)
+    public void downloadFile(@Validated DownloadFileRequest request, HttpServletResponse httpServletResponse) {
+        downloadRecordService.downloadFile(request, httpServletResponse);
+    }
+
+    @RequestMapping({"/downloadPrescriptionlist"})
+    public BaseResponse downloadNatOrderList(@RequestBody PharamcyDownloadPresRequest request) {
+        int currentAdminId = Checker.getIntegerValue(authService.getCurrentAdminId());
+//        request.setCurrentAdminId(currentAdminId);
+        // 插入记录
+//        int  hospital = authService.getCurrentHospitalId();
+//        request.setHospitalId(hospital);
+//        if(request.getHosp() > 0){
+//            hospital = authService.getCurrentHospitalId();
+//            request.setHospitalId(hospital);
+//        }
+        int downloadRecordId = idGenerator.genDownloadRecordId();
+        String name = "处方列表";
+        String fileName = "处方列表";
+        String excelSuffixFormat = ConstantDef.EXCEL_SUFFIX_FORMAT;
+        String paramUrl = "/pharmacy/downloadPrescriptionlist";
+        String paramJson = JsonSerializer.toJson(request);
+        downloadRecordService.getOrInsertPharDownloadRecord(downloadRecordId, name, fileName + excelSuffixFormat, paramUrl, paramJson);
+        Thread t = new Thread() {
+            @Override
+            public void run() {
+               pharmacyService.downloadPharPrescriptionlist(downloadRecordId, fileName, request);
+//
+            }
+        };
+        t.start();
+        return new BaseResponse().succeed("后台下载中...");
+    }
+
+}