Commit f460356fdbb3350ae771903a853f1308b0195a90

Authored by liquanyu
1 parent 2c1e86132f
Exists in master and in 1 other branch dev

重点孕妇登记随访本

Showing 2 changed files with 221 additions and 4 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PuerperaManageController.java View file @ f460356
1 1 package com.lyms.platform.operate.web.controller;
2 2  
  3 +import com.aspose.words.*;
3 4 import com.lyms.platform.common.annotation.TokenRequired;
4 5 import com.lyms.platform.common.base.BaseController;
5 6 import com.lyms.platform.common.base.LoginContext;
6 7  
... ... @@ -32,7 +33,11 @@
32 33 import javax.servlet.http.HttpServletRequest;
33 34 import javax.servlet.http.HttpServletResponse;
34 35 import javax.validation.Valid;
  36 +import java.awt.*;
  37 +import java.io.IOException;
  38 +import java.io.InputStream;
35 39 import java.util.*;
  40 +import java.util.List;
36 41  
37 42 /**
38 43 * 孕产妇管理接口
... ... @@ -131,7 +136,7 @@
131 136 @TokenRequired
132 137 public BaseResponse queryAllPuerpera(@Valid RiskPatientsQueryRequest patientsQueryRequest,HttpServletRequest request) {
133 138 LoginContext loginState = (LoginContext) request.getAttribute("loginContext");
134   - return patientFacade.queryHighRisk(patientsQueryRequest,null,1,loginState.getId(),"true",Boolean.FALSE);
  139 + return patientFacade.queryHighRisk(patientsQueryRequest, null, 1, loginState.getId(), "true", Boolean.FALSE);
135 140 }
136 141  
137 142  
... ... @@ -338,7 +343,7 @@
338 343 patientsQueryRequest.setStartAge(null);
339 344 patientsQueryRequest.setEndAge(null);
340 345  
341   - return patientFacade.queryHighRisk(patientsQueryRequest, null, 3,loginState.getId(),"true",Boolean.TRUE);
  346 + return patientFacade.queryHighRisk(patientsQueryRequest, null, 3, loginState.getId(), "true", Boolean.TRUE);
342 347 }
343 348  
344 349 /**
... ... @@ -352,7 +357,7 @@
352 357 public BaseResponse queryPuerpera(@Valid RiskPatientsQueryRequest patientsQueryRequest,HttpServletRequest request){
353 358 patientsQueryRequest.setFmHospital(patientsQueryRequest.gethId());
354 359 patientsQueryRequest.setNotEnable("2");
355   - return patientFacade.queryHighRisk(patientsQueryRequest, null, 3,0,"true",Boolean.FALSE);
  360 + return patientFacade.queryHighRisk(patientsQueryRequest, null, 3, 0, "true", Boolean.FALSE);
356 361 }
357 362  
358 363  
... ... @@ -367,7 +372,7 @@
367 372 @TokenRequired
368 373 public BaseResponse queryRegionAllPuerpera(@Valid RiskPatientsQueryRequest patientsQueryRequest,HttpServletRequest request) {
369 374 LoginContext loginState = (LoginContext) request.getAttribute("loginContext");
370   - return patientFacade.queryHighRisk(patientsQueryRequest,null,1,loginState.getId(),"true",Boolean.TRUE);
  375 + return patientFacade.queryHighRisk(patientsQueryRequest, null, 1, loginState.getId(), "true", Boolean.TRUE);
371 376 }
372 377  
373 378 /**
... ... @@ -491,6 +496,145 @@
491 496 ExcelUtil.toExcel(httpServletResponse.getOutputStream(), list, header);
492 497 } catch (Exception e) {
493 498 ExceptionUtils.catchException(e, "childbirthManagerExcel异常");
  499 + }
  500 + }
  501 +
  502 +
  503 + //孕妇随访本
  504 + @TokenRequired
  505 + @RequestMapping(value = "/gravidaFollowWord", method = RequestMethod.GET)
  506 + public void gravidaFollowWord(@RequestParam("pid") String pid, HttpServletResponse response) {
  507 +
  508 + Map<String, Object> map = patientFacade.gravidaFollowWord(pid, response);
  509 + try {
  510 + // 验证License
  511 + if (!getLicense()) {
  512 + return;
  513 + }
  514 + Document doc = null;// 原始word路径
  515 + try {
  516 + doc = new Document(ViewController.class.getClassLoader().getResourceAsStream("sfdjb.docx"));
  517 +
  518 + /* DocumentBuilder builder = new DocumentBuilder(doc);
  519 + if (map.containsKey("red")) {
  520 + builder.moveToBookmark("red");
  521 + markFrameText(builder, (String) map.get("red"));
  522 + map.remove("red");
  523 + }
  524 + if (map.containsKey("orange")) {
  525 + builder.moveToBookmark("orange");
  526 + markFrameText(builder, (String) map.get("orange"));
  527 + map.remove("orange");
  528 + }*/
  529 +
  530 + markData(doc, map);//普通数据
  531 + sendToBrowser(doc, "导出", "doc", true, response);
  532 + } catch (Exception e) {
  533 + e.printStackTrace();
  534 + }
  535 + response.flushBuffer();
  536 +
  537 +
  538 +
  539 + } catch (IOException e) {
  540 + e.printStackTrace();
  541 + }
  542 + }
  543 +
  544 + /**
  545 + * 获取license
  546 + *
  547 + * @return
  548 + */
  549 + public static boolean getLicense() {
  550 + boolean result = false;
  551 + try {
  552 + InputStream is = ViewController.class.getClassLoader().getResourceAsStream("license.xml");
  553 + License aposeLic = new License();
  554 + aposeLic.setLicense(is);
  555 + result = true;
  556 + } catch (Exception e) {
  557 + e.printStackTrace();
  558 + }
  559 + return result;
  560 + }
  561 +
  562 + /**
  563 + * 向客户端发送数据
  564 + *
  565 + * @param doc com.aspose.words.Document
  566 + * @param docName 返回客户端的word文件名
  567 + * @param formatType DOC 或者 DOCX
  568 + * @param openNewWindow 在线打开或者下载
  569 + * @param response
  570 + * @throws Exception
  571 + */
  572 + private void sendToBrowser(Document doc, String docName, String formatType,
  573 + boolean openNewWindow, HttpServletResponse response)
  574 + throws Exception {
  575 + String extension = formatType;
  576 +
  577 + if (formatType.equals("WML") || formatType.equals("FOPC"))
  578 + extension = "XML";
  579 +
  580 + String fileName = docName + "." + extension;
  581 +
  582 + if (openNewWindow)
  583 + response.setHeader("content-disposition", "attachment; filename="
  584 + + fileName);
  585 + else
  586 + response.addHeader("content-disposition", "inline; filename="
  587 + + fileName);
  588 +
  589 + if ("doc".equals(formatType)) {
  590 + response.setContentType("application/msword");
  591 + doc.save(response.getOutputStream(), SaveFormat.DOC);
  592 + } else if ("docx".equals(formatType)) {
  593 + response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
  594 + doc.save(response.getOutputStream(), SaveFormat.DOCX);
  595 + } else if ("pdf".equals(formatType)) {
  596 + response.setContentType("application/pdf");
  597 + doc.save(response.getOutputStream(), SaveFormat.PDF);
  598 + }
  599 + }
  600 +
  601 + /**
  602 + * 添加特殊字
  603 + *
  604 + * @param builder
  605 + * @param text
  606 + */
  607 + public void markFrameText(DocumentBuilder builder, String text) {
  608 + try {
  609 + if (com.lyms.platform.common.utils.StringUtils.isEmpty(text) || "null".equals(text)) {
  610 + return;
  611 + }
  612 + builder.getFont().getBorder().clearFormatting();
  613 + builder.getFont().getBorder().setColor(Color.black);
  614 + builder.getFont().getBorder().setLineWidth(1);
  615 + builder.getFont().getBorder().setLineStyle(LineStyle.SINGLE);
  616 + builder.getFont().getBorder().setDistanceFromText(2);
  617 + // builder.getFont().getBorder().setShadow(true);
  618 + builder.write(text);
  619 + } catch (Exception e) {
  620 + e.printStackTrace();
  621 + }
  622 + }
  623 +
  624 + public void markData(Document doc, Map<String, Object> data) {
  625 + try {
  626 + for (Map.Entry<String, Object> m : data.entrySet()) {
  627 + if (m.getValue() == null || "null".equals(m.getValue())) {
  628 + continue;
  629 + }
  630 + BookmarkCollection books = doc.getRange().getBookmarks();
  631 + Bookmark bookmark = books.get(m.getKey());
  632 + if (bookmark != null) {
  633 + bookmark.setText(String.valueOf(m.getValue()));
  634 + }
  635 + }
  636 + } catch (Exception e) {
  637 + e.printStackTrace();
494 638 }
495 639 }
496 640 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java View file @ f460356
... ... @@ -1694,5 +1694,78 @@
1694 1694 return new BaseObjectResponse().setData(patientBaseResult).setErrormsg("成功").setErrorcode(ErrorCodeConstants.SUCCESS);
1695 1695 }
1696 1696  
  1697 +
  1698 + /***
  1699 + *重点孕妇登记随访本
  1700 + *
  1701 + */
  1702 + public Map gravidaFollowWord(String pid, HttpServletResponse response) {
  1703 + Map<String, Object> dataMap = new HashMap<>();
  1704 + if (StringUtils.isNotEmpty(pid)) {
  1705 + Patients patients = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(pid)), Patients.class);
  1706 + dataMap.put("name", patients.getUsername());
  1707 + dataMap.put("age", DateUtil.getAge(patients.getBirth()));
  1708 + //孕次
  1709 + AntExChuModel antExChuModel = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(pid)), AntExChuModel.class);
  1710 + if (null != antExChuModel) {
  1711 + dataMap.put("pregnancySecond", antExChuModel.getPregnancyTimes());
  1712 + //产次
  1713 + dataMap.put("parity", antExChuModel.getProdTime());
  1714 + }
  1715 + //预产期
  1716 + dataMap.put("dueDate", DateUtil.getyyyy_MM_dd(patients.getDueDate()));
  1717 + //身份证号
  1718 + if (StringUtils.isNotEmpty(patients.getPcerteTypeId()) && "70ae1d93-2964-46bc-83fa-bec9ff605b1c".equals(patients.getPcerteTypeId())) {
  1719 + dataMap.put("cardNo", patients.getCardNo());
  1720 + }
  1721 + //孕妇电话
  1722 + dataMap.put("gravidaPhone", patients.getPhone());
  1723 + //丈夫电话
  1724 + dataMap.put("husbandPhone", patients.getHusbandPhone() != null ? patients.getHusbandPhone() : null);
  1725 + //住址
  1726 + dataMap.put("address", CommonsHelper.getResidence(patients.getProvinceRegisterId(), patients.getCityRegisterId(),
  1727 + patients.getAreaRegisterId(), patients.getStreetRegisterId(), patients.getAddressRegister(), basicConfigService));
  1728 + dataMap.put("weeks", DateUtil.getWeek(patients.getLastMenses()));
  1729 + //确诊单位
  1730 + dataMap.put("diagnosis", "诸城人民医院");
  1731 + dataMap.put("created", DateUtil.getyyyy_MM_dd(patients.getCreated()));
  1732 + //户籍
  1733 + if (StringUtils.isNotEmpty(patients.getPliveTypeId())) {
  1734 + if ("57624c440cf23d4631523ea1".equals(patients.getPliveTypeId())) {
  1735 + dataMap.put("cz", "√");
  1736 + } else if ("5a371bce0cf2ab082ac30433".equals(patients.getPliveTypeId())) {
  1737 + dataMap.put("zz", "√");
  1738 + } else if ("57624c5e0cf23d4631523ea2".equals(patients.getPliveTypeId())) {
  1739 + dataMap.put("ld", "√");
  1740 + }
  1741 + }
  1742 + if (CollectionUtils.isNotEmpty(patients.getRiskFactorId())) {
  1743 + List<String> riskFactor = patients.getRiskFactorId();
  1744 + StringBuffer riskStr = new StringBuffer();
  1745 + for (String risk : riskFactor) {
  1746 + riskStr.append(getBasicConfig(risk) + " ");
  1747 + }
  1748 + dataMap.put("highRisk", riskStr);
  1749 + }
  1750 + //判断风险等级
  1751 + if (StringUtils.isNotEmpty(patients.getRiskLevelId())) {
  1752 + String str = patients.getRiskLevelId();
  1753 + String substr = str.substring(1, str.length() - 1);
  1754 + String[] strings = substr.split(",");
  1755 + for (String strs : strings) {
  1756 + if ("\"49a36aea-c5b6-4162-87d2-9eb3c6ec00c2\"".equals(strs)) {
  1757 + dataMap.put("orange", "√");
  1758 + } else if ("\"eb146c03-b19f-4e28-b85f-fda574b2283b\"".equals(strs)) {
  1759 + dataMap.put("red", "√");
  1760 + } else if ("\"224b2329-cb82-4da3-a071-8527f8283aab\"".equals(strs)) {
  1761 + dataMap.put("purple", "√");
  1762 + } else if ("\"315107bd-91fe-42a1-9237-752f3c046a40\"".equals(strs)) {
  1763 + dataMap.put("yellow", "√");
  1764 + }
  1765 + }
  1766 + }
  1767 + }
  1768 + return dataMap;
  1769 + }
1697 1770 }