|
@@ -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;
|
|
|
|
+ }
|
|
|
|
+}
|