|
@@ -1,9 +1,12 @@
|
|
package com.ywt.mg.web.controllers.pharmacy;
|
|
package com.ywt.mg.web.controllers.pharmacy;
|
|
|
|
|
|
|
|
|
|
|
|
+import com.fasterxml.jackson.databind.JsonNode;
|
|
|
|
+import com.ywt.mg.configs.DomainConfigurer;
|
|
import com.ywt.mg.core.MGRight;
|
|
import com.ywt.mg.core.MGRight;
|
|
import com.ywt.mg.core.MGRightTypeDef;
|
|
import com.ywt.mg.core.MGRightTypeDef;
|
|
import com.ywt.mg.core.utils.Checker;
|
|
import com.ywt.mg.core.utils.Checker;
|
|
|
|
+import com.ywt.mg.core.utils.RandomUtil;
|
|
import com.ywt.mg.core.utils.serializers.JsonSerializer;
|
|
import com.ywt.mg.core.utils.serializers.JsonSerializer;
|
|
import com.ywt.mg.domain.models.ConstantDef;
|
|
import com.ywt.mg.domain.models.ConstantDef;
|
|
import com.ywt.mg.params.downloadRecord.DownloadFileRequest;
|
|
import com.ywt.mg.params.downloadRecord.DownloadFileRequest;
|
|
@@ -15,18 +18,19 @@ import com.ywt.mg.services.DownloadRecordService;
|
|
import com.ywt.mg.services.IdGenerator;
|
|
import com.ywt.mg.services.IdGenerator;
|
|
import com.ywt.mg.services.PharmacyService;
|
|
import com.ywt.mg.services.PharmacyService;
|
|
import com.ywt.mg.web.BaseResponse;
|
|
import com.ywt.mg.web.BaseResponse;
|
|
|
|
+import com.ywt.mg.web.DataResponse;
|
|
import com.ywt.mg.web.controllers.hospital.HospNatOrderController;
|
|
import com.ywt.mg.web.controllers.hospital.HospNatOrderController;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
+import org.eclipse.jetty.util.UrlEncoded;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.validation.annotation.Validated;
|
|
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 org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import java.util.Base64;
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@RestController("/pharmacy")
|
|
@RestController("/pharmacy")
|
|
@RequestMapping({"/pharmacy"})
|
|
@RequestMapping({"/pharmacy"})
|
|
@@ -47,6 +51,9 @@ public class PharmacyController {
|
|
@Autowired
|
|
@Autowired
|
|
private PharmacyService pharmacyService;
|
|
private PharmacyService pharmacyService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private DomainConfigurer domainConfigurer;
|
|
|
|
+
|
|
|
|
|
|
@ApiOperation(value = "按条件查询下载记录列表")
|
|
@ApiOperation(value = "按条件查询下载记录列表")
|
|
@RequestMapping(value = {"/downloadRecordList"}, method = RequestMethod.POST)
|
|
@RequestMapping(value = {"/downloadRecordList"}, method = RequestMethod.POST)
|
|
@@ -59,10 +66,41 @@ public class PharmacyController {
|
|
return downloadRecordService.queryPharDownloadRecordList(request);
|
|
return downloadRecordService.queryPharDownloadRecordList(request);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @MGRight(rightCode = {"/pharmacy/downloadPrescriptionFile"}, type = MGRightTypeDef.Right)
|
|
|
|
+ @RequestMapping({"/downloadPrescriptionFile"})
|
|
|
|
+ BaseResponse downloadPrescriptionlist(@RequestBody Map<String, Object> map) {
|
|
|
|
+ DataResponse<Object> dataResponse = new DataResponse<>();
|
|
|
|
+ try {
|
|
|
|
+// map.put("pharmacyId", userService.getPharmacyId());
|
|
|
|
+// map.put("adminId", userService.getAdminId());
|
|
|
|
+
|
|
|
|
+ String uData = Base64.getEncoder().encodeToString(JsonSerializer.toJson(map).getBytes());
|
|
|
|
+ String randomValue = RandomUtil.getRandomCode(8, 3);
|
|
|
|
+ String url = domainConfigurer.getYwtHttpsMgapiDomain() + "/downloadService/pharmacy/downloadFile?k=" + UrlEncoded.encodeString(uData) + "&randomValue=" + randomValue;
|
|
|
|
+ dataResponse.setData(url);
|
|
|
|
+ return dataResponse.succeed();
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ logger.error("/pharmacyPrescription/downloadPrescriptionList:{},{}", JsonSerializer.toJson(map), e.getMessage(), e);
|
|
|
|
+ return dataResponse.failed(BaseResponse.PARAMETER_ERROR, "处理失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private String getStrFromJsonNode(JsonNode node, String def) {
|
|
|
|
+ if (node == null) return def;
|
|
|
|
+ return node.asText(def);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
@ApiOperation(value = "下载文件")
|
|
@ApiOperation(value = "下载文件")
|
|
- @RequestMapping(value = {"/downloadFile"}, method = RequestMethod.GET)
|
|
|
|
|
|
+ @RequestMapping(value = {"/downloadFile"})
|
|
@MGRight(menuCode = {"/pharmacy/downloadFile"}, type = MGRightTypeDef.Menu | MGRightTypeDef.Logined)
|
|
@MGRight(menuCode = {"/pharmacy/downloadFile"}, type = MGRightTypeDef.Menu | MGRightTypeDef.Logined)
|
|
- public void downloadFile(@Validated DownloadFileRequest request, HttpServletResponse httpServletResponse) {
|
|
|
|
|
|
+ public void downloadFile(@RequestParam(value = "k") String k, HttpServletResponse httpServletResponse) {
|
|
|
|
+ String key = new String(Base64.getDecoder().decode(k));
|
|
|
|
+ JsonNode jsonNode = JsonSerializer.readToNode(key);
|
|
|
|
+ String downloadId = getStrFromJsonNode(jsonNode.get("id"), "0");
|
|
|
|
+ int downId = Integer.parseInt(downloadId);
|
|
|
|
+ DownloadFileRequest request = new DownloadFileRequest();
|
|
|
|
+ request.setDownloadRecordId(downId);
|
|
downloadRecordService.downloadFile(request, httpServletResponse);
|
|
downloadRecordService.downloadFile(request, httpServletResponse);
|
|
}
|
|
}
|
|
|
|
|