Prechádzať zdrojové kódy

feature:下载hispatientId

wuyongyi 1 rok pred
rodič
commit
953e9623fd

+ 3 - 0
src/main/java/com/ywt/mg/domain/entities/MedicalCardRepository.java

@@ -10,4 +10,7 @@ public interface MedicalCardRepository extends JpaRepository<MedicalCard, Intege
 
     @Query(value = "select * from medical_card where mobile = ? ;", nativeQuery = true)
     List<MedicalCard> getCardByMobile(String patientmobile);
+
+    @Query(value = "select * from medical_card where hospital_id = ? and status = 1;", nativeQuery = true)
+    List<MedicalCard> getListByHospitalId(int hospitalId);
 }

+ 10 - 0
src/main/java/com/ywt/mg/domain/models/pojo/ConstantRightDisplayDef.java

@@ -0,0 +1,10 @@
+package com.ywt.mg.domain.models.pojo;
+
+public class ConstantRightDisplayDef {
+
+    /**
+     * 医院后台--门诊通知--"下载患者ID"控制显示
+     * todo: 没勾选“下载患者ID”权限,则不显示该信息
+     */
+    public static final String COMMON_WX_PUSH_DISPLAY_DOWNLOAD_HISPATIENTID = "/hosp/commonWxPush/downloadHisPatientid";
+}

+ 77 - 0
src/main/java/com/ywt/mg/services/CommonWxPushService.java

@@ -0,0 +1,77 @@
+package com.ywt.mg.services;
+
+import com.ywt.mg.core.SqlHelper;
+import com.ywt.mg.core.utils.Checker;
+import com.ywt.mg.domain.entities.MedicalCard;
+import com.ywt.mg.domain.entities.MedicalCardRepository;
+import com.ywt.mg.domain.models.ExcelDataMap;
+import com.ywt.mg.domain.models.ExcelStyleMap;
+import com.ywt.mg.domain.models.pojo.ConstantRightDisplayDef;
+import com.ywt.mg.domain.models.pojo.ExcelCollectPojo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class CommonWxPushService {
+    private static Logger logger = LoggerFactory.getLogger(CommonWxPushService.class);
+
+    @Autowired
+    private SqlHelper sqlHelper;
+
+    @Autowired
+    private MedicalCardRepository medicalCardRepository;
+
+    @Autowired
+    private AuthService authService;
+
+    @Autowired
+    private DownloadRecordService downloadRecordService;
+
+
+    public List<MedicalCard> getListByHospitalId(int hospitalId) {
+        return medicalCardRepository.getListByHospitalId(hospitalId);
+    }
+
+
+    public void downloadHisPatientId(int downloadRecordId, String fileName, Integer hospitalId) {
+        try {
+            String downloadHisPatientidRightCode = ConstantRightDisplayDef.COMMON_WX_PUSH_DISPLAY_DOWNLOAD_HISPATIENTID;
+            boolean downloadHisPatientidRight = authService.checkCacheRight(downloadHisPatientidRightCode);
+            if (!downloadHisPatientidRight) {
+                logger.error("CommonWxPushService#downloadHisPatientId>>没有权限,请先设置权限,userId:{}", authService.getCurrentAdmin());
+            }
+            List<MedicalCard> infoList = getListByHospitalId(hospitalId);
+
+            String col1 = "患者ID";
+            String col2 = "患者姓名";
+            String col3 = "身份证号";
+            String col4 = "手机号";
+
+            String[] columns = new String[]{col1, col2, col3, col4};
+            ExcelDataMap map = new ExcelDataMap(columns);
+            String filename = "患者ID";
+            if (Checker.isNone(infoList)) {
+                return;
+            }
+            for (MedicalCard item : infoList) {
+                map.getStringListSafely(col1).add(item.getHisPatientId());
+                map.getStringListSafely(col2).add(item.getPatientName());
+                map.getStringListSafely(col3).add(item.getIdNo());
+                map.getStringListSafely(col4).add(item.getMobile());
+            }
+            // 得到统计
+            int size = infoList.size();
+            List<ExcelCollectPojo> itemList = null;
+            ExcelStyleMap excelStyleMap = new ExcelStyleMap(new String[]{});
+            int bill = 0;
+            downloadRecordService.createFileAndUploadOssAndSaveToDataBase(fileName, downloadRecordId, map, itemList, size, bill);
+        } catch (Exception e) {
+            logger.error("/CommonWxPushService/downloadHisPatientId(): {}", e.getMessage(), e);
+            e.printStackTrace();
+        }
+    }
+}

+ 67 - 0
src/main/java/com/ywt/mg/web/controllers/hospital/HospCommonWxPushController.java

@@ -0,0 +1,67 @@
+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.checkupBooking.QueryCheckUpOrderListRequest;
+import com.ywt.mg.services.AuthService;
+import com.ywt.mg.services.CommonWxPushService;
+import com.ywt.mg.services.DownloadRecordService;
+import com.ywt.mg.services.IdGenerator;
+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;
+
+@RestController("/hosp/commonWxPush")
+@RequestMapping({"/hosp/commonWxPush"})
+@MGRight
+public class HospCommonWxPushController {
+
+    private static Logger logger = LoggerFactory.getLogger(HospCommonWxPushController.class);
+
+    @Autowired
+    private IdGenerator idGenerator;
+
+    @Autowired
+    private DownloadRecordService downloadRecordService;
+
+    @Autowired
+    private AuthService authService;
+
+    @Autowired
+    private CommonWxPushService commonWxPushService;
+
+    @RequestMapping({"/downloadHisPatientId"})
+    public BaseResponse downloadHisPatientId() {
+        int currentAdminId = Checker.getIntegerValue(authService.getCurrentAdminId());
+//        request.setCurrentAdminId(currentAdminId);
+        // 插入记录
+
+        String hosp = "";
+//        if(request.getHosp()> 0){
+        Integer hospital = authService.getCurrentHospitalId();
+        hosp = hospital.toString();
+
+//        }
+        int downloadRecordId = idGenerator.genDownloadRecordId();
+        String name = "下载患者ID";
+        String fileName = "下载患者ID";
+        String excelSuffixFormat = ConstantDef.EXCEL_SUFFIX_FORMAT;
+        String paramUrl = "/hosp/commonWxPush/downloadHisPatientId";
+        String paramJson = JsonSerializer.toJson(hospital);
+        downloadRecordService.getOrInsertDownloadRecordByHosp(downloadRecordId, name, fileName + excelSuffixFormat, paramUrl, paramJson);
+        Thread t = new Thread() {
+            @Override
+            public void run() {
+             commonWxPushService.downloadHisPatientId(downloadRecordId, fileName, hospital);
+            }
+        };
+        t.start();
+        return new BaseResponse().succeed("后台下载中...");
+    }
+}