ThridPrescriptionEndPoint.java 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package com.yihu.ehr.profile.controller.prescription;
  2. import com.yihu.ehr.constants.ApiVersion;
  3. import com.yihu.ehr.controller.BaseRestEndPoint;
  4. import com.yihu.ehr.profile.service.old.ThridPrescriptionService;
  5. import io.swagger.annotations.Api;
  6. import io.swagger.annotations.ApiOperation;
  7. import io.swagger.annotations.ApiParam;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.web.bind.annotation.*;
  10. import springfox.documentation.annotations.ApiIgnore;
  11. import java.io.File;
  12. import java.io.FileInputStream;
  13. /**
  14. * Created by cwd on 2016/6/14.
  15. */
  16. /*@RestController
  17. @RequestMapping(ApiVersion.Version1_0+"/thridPrescription")
  18. @Api(value = "第三方处方调阅服务", description = "第三方处方调阅服务")
  19. @ApiIgnore*/
  20. public class ThridPrescriptionEndPoint extends BaseRestEndPoint {
  21. @Autowired
  22. private ThridPrescriptionService thridPrescriptionService;
  23. @ApiOperation(value = "处方模板转图片")
  24. @RequestMapping(value = "/prescriptioToImage", method = RequestMethod.GET)
  25. public String prescriptioToImage(@ApiParam(value = "eventNo" ) @RequestParam String eventNo,
  26. @ApiParam(value = "orgId") @RequestParam(required=false) String orgId,
  27. @ApiParam(value = "cdaType") @RequestParam(required=false) String cdaType,
  28. @ApiParam(value = "version") @RequestParam(required=false) String version,
  29. @ApiParam(value = "height(默认600)") @RequestParam(required=false,defaultValue = "600") int height,
  30. @ApiParam(value = "width(默认400)") @RequestParam(required=false,defaultValue = "400") int width) {
  31. String filePath="";
  32. try{
  33. filePath= thridPrescriptionService.prescriptioToImage(eventNo,orgId,cdaType,version,height,width);
  34. }catch (Exception e){
  35. e.printStackTrace();
  36. }
  37. return filePath;
  38. }
  39. @ApiOperation(value = "imagetest")
  40. @RequestMapping(value = "/imagetest", method = RequestMethod.GET)
  41. public boolean test() throws Exception
  42. {
  43. File file=new File("E:/1.html");
  44. FileInputStream fis=new FileInputStream(file);
  45. byte[] buf = new byte[1024];
  46. StringBuffer sb=new StringBuffer();
  47. while((fis.read(buf))!=-1) {
  48. sb.append(new String(buf));
  49. buf = new byte[1024];//重新生成,避免和上次读取的数据重复
  50. }
  51. thridPrescriptionService.htmlToImage(sb.toString(),800,600);
  52. return true;
  53. }
  54. }