Commit 0da9175754984cbe6da11890f1887d6bdbc1e198
Exists in
master
and in
6 other branches
Merge remote-tracking branch 'origin/master'
Showing 9 changed files
- platform-biz-service/src/main/java/com/lyms/platform/permission/model/Organization.java
- platform-biz-service/src/main/resources/mainOrm/master/MasterOrganization.xml
- platform-operate-api/pom.xml
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyBuildController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/OrganizationController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/WordTest.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyBookbuildingFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/WordUtil.java
- platform-operate-api/src/main/resources/jlb.docx
platform-biz-service/src/main/java/com/lyms/platform/permission/model/Organization.java
View file @
0da9175
... | ... | @@ -37,7 +37,17 @@ |
37 | 37 | private String foreignId; |
38 | 38 | private Integer orgType; //-1 未设置 0 公司 1 医院 |
39 | 39 | private Integer status; |
40 | + //乡镇卫生院ID | |
41 | + private String townOrgId; | |
40 | 42 | |
43 | + public String getTownOrgId() { | |
44 | + return townOrgId; | |
45 | + } | |
46 | + | |
47 | + public void setTownOrgId(String townOrgId) { | |
48 | + this.townOrgId = townOrgId; | |
49 | + } | |
50 | + | |
41 | 51 | public Integer getbStatus() { |
42 | 52 | return bStatus; |
43 | 53 | } |
... | ... | @@ -139,7 +149,6 @@ |
139 | 149 | public String getShortCode() { |
140 | 150 | return shortCode; |
141 | 151 | } |
142 | - | |
143 | 152 | |
144 | 153 | |
145 | 154 | public void setShortCode(String shortCode) { |
platform-biz-service/src/main/resources/mainOrm/master/MasterOrganization.xml
View file @
0da9175
... | ... | @@ -22,20 +22,20 @@ |
22 | 22 | <result column="shortCode" property="shortCode" jdbcType="VARCHAR"/> |
23 | 23 | <result column="foreign_id" property="foreignId" jdbcType="VARCHAR"/> |
24 | 24 | <result column="bStatus" property="bStatus" jdbcType="INTEGER"/> |
25 | - | |
25 | + <result column="townOrgId" property="townOrgId" jdbcType="VARCHAR"/> | |
26 | 26 | </resultMap> |
27 | 27 | |
28 | 28 | |
29 | 29 | <insert id="addOrganization" parameterType="com.lyms.platform.permission.model.Organization"> |
30 | 30 | <selectKey order="AFTER" keyProperty="id" resultType="java.lang.Integer">SELECT LAST_INSERT_ID()</selectKey> |
31 | 31 | insert into organization |
32 | - (foreign_id,name,type,level,province_id,city_id,area_id,address,description,publish_id,publish_name,yn,modified,created,shortCode,street_id,bStatus | |
32 | + (foreign_id,name,type,level,province_id,city_id,area_id,address,description,publish_id,publish_name,yn,modified,created,shortCode,street_id,bStatus,townOrgId | |
33 | 33 | <if test="id != null and id >= 0"> |
34 | 34 | ,id |
35 | 35 | </if> |
36 | 36 | ) |
37 | 37 | values |
38 | - (#{foreignId},#{name},#{type},#{level},#{provinceId},#{cityId},#{areaId},#{address},#{description},#{publishId},#{publishName},#{yn},#{modified},#{created},#{shortCode},#{streetId},#{bStatus} | |
38 | + (#{foreignId},#{name},#{type},#{level},#{provinceId},#{cityId},#{areaId},#{address},#{description},#{publishId},#{publishName},#{yn},#{modified},#{created},#{shortCode},#{streetId},#{bStatus},#{townOrgId} | |
39 | 39 | <if test="id != null and id >= 0"> |
40 | 40 | ,#{id} |
41 | 41 | </if> |
... | ... | @@ -103,6 +103,9 @@ |
103 | 103 | <if test="status != null"> |
104 | 104 | status = #{status,jdbcType=INTEGER}, |
105 | 105 | </if> |
106 | + <if test="townOrgId !=null"> | |
107 | + townOrgId=#{townOrgId,jdbcType=VARCHAR}, | |
108 | + </if> | |
106 | 109 | </set> |
107 | 110 | where id = #{id,jdbcType=INTEGER} |
108 | 111 | </update> |
... | ... | @@ -114,7 +117,7 @@ |
114 | 117 | |
115 | 118 | |
116 | 119 | <select id="getOrganization" resultMap="OrganizationResultMap" parameterType="java.lang.Integer"> |
117 | -select id,name,type,level,area_manage,province_id,city_id,area_id,address,description,publish_id,publish_name,yn,modified,created,shortCode,foreign_id,street_id,status,bStatus | |
120 | +select id,name,type,level,area_manage,province_id,city_id,area_id,address,description,publish_id,publish_name,yn,modified,created,shortCode,foreign_id,street_id,status,bStatus,townOrgId | |
118 | 121 | from organization where id = #{id,jdbcType=INTEGER} |
119 | 122 | </select> |
120 | 123 | |
... | ... | @@ -218,7 +221,7 @@ |
218 | 221 | <select id="queryOrganization" resultMap="OrganizationResultMap" |
219 | 222 | parameterType="com.lyms.platform.permission.model.OrganizationQuery"> |
220 | 223 | select |
221 | - id,name,type,level,area_manage,province_id,city_id,area_id,address,description,publish_id,publish_name,yn,modified,created,shortCode,foreign_id,street_id,status,bStatus | |
224 | + id,name,type,level,area_manage,province_id,city_id,area_id,address,description,publish_id,publish_name,yn,modified,created,shortCode,foreign_id,street_id,status,bStatus,townOrgId | |
222 | 225 | from organization |
223 | 226 | <include refid="OrganizationCondition"/> |
224 | 227 | <include refid="orderAndLimit"/> |
... | ... | @@ -261,7 +264,7 @@ |
261 | 264 | </select> |
262 | 265 | |
263 | 266 | <select id="getOrganizationByAreaId" parameterType="string" resultType="map"> |
264 | - SELECT id, name FROM `organization` where yn = 1 and area_id = #{areaId} | |
267 | + SELECT id, name,townOrgId FROM `organization` where yn = 1 and area_id = #{areaId} | |
265 | 268 | </select> |
266 | 269 | |
267 | 270 | <select id="getOrganizationName" parameterType="java.lang.String" resultType="java.lang.String"> |
platform-operate-api/pom.xml
View file @
0da9175
... | ... | @@ -12,14 +12,14 @@ |
12 | 12 | |
13 | 13 | <dependencies> |
14 | 14 | <!--<dependency>--> |
15 | - <!--<groupId>org.apache.httpcomponents</groupId>--> | |
16 | - <!--<artifactId>httpclient</artifactId>--> | |
17 | - <!--<version>4.5.2</version>--> | |
15 | + <!--<groupId>org.apache.httpcomponents</groupId>--> | |
16 | + <!--<artifactId>httpclient</artifactId>--> | |
17 | + <!--<version>4.5.2</version>--> | |
18 | 18 | <!--</dependency>--> |
19 | 19 | |
20 | 20 | <!--<dependency>--> |
21 | - <!--<groupId>commons-httpclient</groupId>--> | |
22 | - <!--<artifactId>commons-httpclient</artifactId>--> | |
21 | + <!--<groupId>commons-httpclient</groupId>--> | |
22 | + <!--<artifactId>commons-httpclient</artifactId>--> | |
23 | 23 | <!--</dependency>--> |
24 | 24 | <dependency> |
25 | 25 | <groupId>com.aspose</groupId> |
... | ... | @@ -97,6 +97,21 @@ |
97 | 97 | <artifactId>jxl</artifactId> |
98 | 98 | <version>2.6.12</version> |
99 | 99 | </dependency> |
100 | + | |
101 | + <!-- https://mvnrepository.com/artifact/freemarker/freemarker --> | |
102 | + <!-- <dependency> | |
103 | + <groupId>freemarker</groupId> | |
104 | + <artifactId>freemarker</artifactId> | |
105 | + <version>2.3.9</version> | |
106 | + </dependency>--> | |
107 | + | |
108 | + | |
109 | + <!-- https://mvnrepository.com/artifact/ro.pippo/pippo-freemarker --> | |
110 | + <!-- <dependency> | |
111 | + <groupId>ro.pippo</groupId> | |
112 | + <artifactId>pippo-freemarker</artifactId> | |
113 | + <version>1.12.0</version> | |
114 | + </dependency>--> | |
100 | 115 | |
101 | 116 | </dependencies> |
102 | 117 | <build> |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyBuildController.java
View file @
0da9175
1 | 1 | package com.lyms.platform.operate.web.controller; |
2 | 2 | |
3 | 3 | |
4 | +import com.aspose.words.*; | |
4 | 5 | import com.lyms.platform.common.annotation.TokenRequired; |
5 | 6 | import com.lyms.platform.common.base.BaseController; |
6 | 7 | import com.lyms.platform.common.base.LoginContext; |
7 | 8 | |
... | ... | @@ -28,8 +29,11 @@ |
28 | 29 | import javax.servlet.http.HttpServletRequest; |
29 | 30 | import javax.servlet.http.HttpServletResponse; |
30 | 31 | import javax.validation.Valid; |
32 | +import java.io.IOException; | |
33 | +import java.io.InputStream; | |
31 | 34 | import java.io.UnsupportedEncodingException; |
32 | 35 | import java.util.List; |
36 | +import java.util.Map; | |
33 | 37 | |
34 | 38 | |
35 | 39 | /* |
... | ... | @@ -558,6 +562,91 @@ |
558 | 562 | ) { |
559 | 563 | LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); |
560 | 564 | babyBookbuildingFacade.exportWcBabyReportExcl(loginState.getId(), time, hospitalId, response); |
565 | + } | |
566 | + | |
567 | + //导出管理记录表 | |
568 | + @RequestMapping(value = "/recordSheetWord", method = RequestMethod.GET) | |
569 | + @TokenRequired | |
570 | + public void exportManagementRecords(HttpServletRequest request, HttpServletResponse response, | |
571 | + @RequestParam(required = false) String id) { | |
572 | + Map<String, Object> map = babyBookbuildingFacade.getData(id); | |
573 | + try { | |
574 | + // 验证License | |
575 | + if (!getLicense()) { | |
576 | + return; | |
577 | + } | |
578 | + Document doc = null;// 原始word路径 | |
579 | + try { | |
580 | + doc = new Document(ViewController.class.getClassLoader().getResourceAsStream("jlb.docx")); | |
581 | + markData(doc, map);//普通数据 | |
582 | + sendToBrowser(doc, "导出", "doc", true, response); | |
583 | + } catch (Exception e) { | |
584 | + e.printStackTrace(); | |
585 | + } | |
586 | + response.flushBuffer(); | |
587 | + } catch (IOException e) { | |
588 | + e.printStackTrace(); | |
589 | + } | |
590 | + | |
591 | + } | |
592 | + | |
593 | + public static boolean getLicense() { | |
594 | + boolean result = false; | |
595 | + try { | |
596 | + InputStream is = ViewController.class.getClassLoader().getResourceAsStream("license.xml"); | |
597 | + License aposeLic = new License(); | |
598 | + aposeLic.setLicense(is); | |
599 | + result = true; | |
600 | + } catch (Exception e) { | |
601 | + e.printStackTrace(); | |
602 | + } | |
603 | + return result; | |
604 | + } | |
605 | + | |
606 | + public void markData(Document doc, Map<String, Object> data) { | |
607 | + try { | |
608 | + for (Map.Entry<String, Object> m : data.entrySet()) { | |
609 | + if (m.getValue() == null || "null".equals(m.getValue())) { | |
610 | + continue; | |
611 | + } | |
612 | + BookmarkCollection books = doc.getRange().getBookmarks(); | |
613 | + Bookmark bookmark = books.get(m.getKey()); | |
614 | + if (bookmark != null) { | |
615 | + bookmark.setText(String.valueOf(m.getValue())); | |
616 | + } | |
617 | + } | |
618 | + } catch (Exception e) { | |
619 | + e.printStackTrace(); | |
620 | + } | |
621 | + } | |
622 | + | |
623 | + private void sendToBrowser(Document doc, String docName, String formatType, | |
624 | + boolean openNewWindow, HttpServletResponse response) | |
625 | + throws Exception { | |
626 | + String extension = formatType; | |
627 | + | |
628 | + if (formatType.equals("WML") || formatType.equals("FOPC")) | |
629 | + extension = "XML"; | |
630 | + | |
631 | + String fileName = docName + "." + extension; | |
632 | + | |
633 | + if (openNewWindow) | |
634 | + response.setHeader("content-disposition", "attachment; filename=" | |
635 | + + fileName); | |
636 | + else | |
637 | + response.addHeader("content-disposition", "inline; filename=" | |
638 | + + fileName); | |
639 | + | |
640 | + if ("doc".equals(formatType)) { | |
641 | + response.setContentType("application/msword"); | |
642 | + doc.save(response.getOutputStream(), SaveFormat.DOC); | |
643 | + } else if ("docx".equals(formatType)) { | |
644 | + response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document"); | |
645 | + doc.save(response.getOutputStream(), SaveFormat.DOCX); | |
646 | + } else if ("pdf".equals(formatType)) { | |
647 | + response.setContentType("application/pdf"); | |
648 | + doc.save(response.getOutputStream(), SaveFormat.PDF); | |
649 | + } | |
561 | 650 | } |
562 | 651 | |
563 | 652 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/OrganizationController.java
View file @
0da9175
... | ... | @@ -59,7 +59,7 @@ |
59 | 59 | */ |
60 | 60 | @RequestMapping(value = "/organization/{id}", method = RequestMethod.DELETE) |
61 | 61 | @TokenRequired |
62 | - public void updateOrganization(HttpServletResponse response, @PathVariable(value = "id") Integer id,HttpServletRequest request) { | |
62 | + public void updateOrganization(HttpServletResponse response, @PathVariable(value = "id") Integer id, HttpServletRequest request) { | |
63 | 63 | if (id == null) { |
64 | 64 | ResultUtils.buildParameterErrorResultAndWrite(response); |
65 | 65 | return; |
... | ... | @@ -133,7 +133,7 @@ |
133 | 133 | return; |
134 | 134 | } |
135 | 135 | |
136 | - if(!organization.getName().equals(name)) { | |
136 | + if (!organization.getName().equals(name)) { | |
137 | 137 | OrganizationQuery organizationQuery = new OrganizationQuery(); |
138 | 138 | organizationQuery.setYn(YnEnums.YES.getId()); |
139 | 139 | organizationQuery.setName(name); |
... | ... | @@ -184,7 +184,8 @@ |
184 | 184 | @RequestParam(value = "streetId", required = false) String streetId, |
185 | 185 | @RequestParam(value = "address") String address, |
186 | 186 | @RequestParam(value = "description", required = false) String description, |
187 | - @RequestParam(value = "shortCode", required = false) String shortCode) { | |
187 | + @RequestParam(value = "shortCode", required = false) String shortCode, | |
188 | + @RequestParam(value = "townOrgId", required = false) String townOrgId) { | |
188 | 189 | |
189 | 190 | //获取登录用户 |
190 | 191 | LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); |
191 | 192 | |
192 | 193 | |
193 | 194 | |
... | ... | @@ -220,17 +221,19 @@ |
220 | 221 | organization.setModified(new Date()); |
221 | 222 | organization.setPublishName(users.getName()); |
222 | 223 | organization.setPublishId(users.getId()); |
224 | + //乡镇卫生院ID | |
225 | + organization.setTownOrgId(townOrgId); | |
223 | 226 | //默认为建档医院 |
224 | 227 | organization.setbStatus(1); |
225 | - Integer id= organizationService.addOrganization(organization); | |
228 | + Integer id = organizationService.addOrganization(organization); | |
226 | 229 | |
227 | 230 | |
228 | 231 | operateLogFacade.addAddOptLog(getUserId(request), id, organization, OptActionEnums.ADD.getId(), "添加机构"); |
229 | 232 | |
230 | - AccessPermissionAddRequest accessPermissionAddRequest = new AccessPermissionAddRequest(); | |
231 | - accessPermissionAddRequest.setUserId(loginState.getId()+""); | |
233 | + AccessPermissionAddRequest accessPermissionAddRequest = new AccessPermissionAddRequest(); | |
234 | + accessPermissionAddRequest.setUserId(loginState.getId() + ""); | |
232 | 235 | accessPermissionAddRequest.setBizId(id + ""); |
233 | - accessPermissionAddRequest.setType(PermissionTypeEnums.Type.ADMIN.getId()+""); | |
236 | + accessPermissionAddRequest.setType(PermissionTypeEnums.Type.ADMIN.getId() + ""); | |
234 | 237 | accessPermissionFacade.addAccessPermission(accessPermissionAddRequest); |
235 | 238 | ResultUtils.buildSuccessResultAndWrite(response); |
236 | 239 | } |
237 | 240 | |
238 | 241 | |
239 | 242 | |
... | ... | @@ -242,25 +245,25 @@ |
242 | 245 | @ResponseBody |
243 | 246 | @TokenRequired |
244 | 247 | public Map getOrganization(HttpServletRequest request, @RequestParam(value = "page", required = false) Integer page, |
245 | - @RequestParam(value = "limit", required = false) Integer limit, | |
246 | - @RequestParam(value = "keyword", required = false) String keyword, | |
247 | - @RequestParam(value = "areaId", required = false) String aId) { | |
248 | + @RequestParam(value = "limit", required = false) Integer limit, | |
249 | + @RequestParam(value = "keyword", required = false) String keyword, | |
250 | + @RequestParam(value = "areaId", required = false) String aId) { | |
248 | 251 | LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); |
249 | 252 | Users users = usersService.getUsers(loginState.getId()); |
250 | 253 | |
251 | 254 | List<Integer> areaId = autoMatchFacade.matchAreaOrgId(loginState.getId()); |
252 | 255 | List<Object> data = new ArrayList<>(); |
253 | 256 | List<Organization> organizations = new ArrayList<>(); |
254 | - PageInfo pageInfo = new PageInfo(0,0,0,1); | |
257 | + PageInfo pageInfo = new PageInfo(0, 0, 0, 1); | |
255 | 258 | if (areaId != null) { |
256 | 259 | // 一定要加上自己的机构权限 |
257 | 260 | areaId.add(users.getOrgId()); |
258 | 261 | OrganizationQuery organizationQuery = new OrganizationQuery(); |
259 | - if(null != page && null!=limit) { | |
262 | + if (null != page && null != limit) { | |
260 | 263 | organizationQuery.setNeed("true"); |
261 | 264 | organizationQuery.setPage(page); |
262 | 265 | organizationQuery.setLimit(limit); |
263 | - if(80 < limit) { //一次请求大于80 则按树排序 | |
266 | + if (80 < limit) { //一次请求大于80 则按树排序 | |
264 | 267 | organizationQuery.setSort("province_id desc,city_id desc,area_id desc"); |
265 | 268 | } else { |
266 | 269 | organizationQuery.setSort("modified desc"); |
... | ... | @@ -268,7 +271,7 @@ |
268 | 271 | } |
269 | 272 | |
270 | 273 | BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(aId); |
271 | - if(null != basicConfig) { | |
274 | + if (null != basicConfig) { | |
272 | 275 | if (SystemConfig.CHINA_BASIC_ID.equals(basicConfig.getParentId())) { |
273 | 276 | organizationQuery.setProvinceId(aId); |
274 | 277 | } else { |
275 | 278 | |
... | ... | @@ -299,9 +302,9 @@ |
299 | 302 | // organizationQuery.setYn(YnEnums.YES.getId()); |
300 | 303 | // organizationQuery.setTypeList(list); |
301 | 304 | organizations = organizationService.queryOrganization(organizationQuery); |
302 | - pageInfo=organizationQuery.getPageInfo(); | |
305 | + pageInfo = organizationQuery.getPageInfo(); | |
303 | 306 | |
304 | - } else if(null == areaId && UserTypeEnum.SUPPER_ADMIN.getId().equals(users.getType())){ | |
307 | + } else if (null == areaId && UserTypeEnum.SUPPER_ADMIN.getId().equals(users.getType())) { | |
305 | 308 | // UserOrganizationMapsQuery userOrganizationMapsQuery = new UserOrganizationMapsQuery(); |
306 | 309 | // userOrganizationMapsQuery.setYn(YnEnums.YES.getId()); |
307 | 310 | // userOrganizationMapsQuery.setUserId(loginState.getId()); |
308 | 311 | |
... | ... | @@ -311,11 +314,11 @@ |
311 | 314 | |
312 | 315 | OrganizationQuery organizationQuery = new OrganizationQuery(); |
313 | 316 | organizationQuery.setKeyword(keyword); |
314 | - if(null != page &&null!= limit ) { | |
317 | + if (null != page && null != limit) { | |
315 | 318 | organizationQuery.setNeed("true"); |
316 | 319 | organizationQuery.setPage(page); |
317 | 320 | organizationQuery.setLimit(limit); |
318 | - if(80 < limit) { //一次请求大于80 则按树排序 | |
321 | + if (80 < limit) { //一次请求大于80 则按树排序 | |
319 | 322 | organizationQuery.setSort("province_id desc,city_id desc,area_id desc"); |
320 | 323 | } else { |
321 | 324 | organizationQuery.setSort("modified desc"); |
... | ... | @@ -324,7 +327,7 @@ |
324 | 327 | |
325 | 328 | |
326 | 329 | BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(aId); |
327 | - if(null != basicConfig) { | |
330 | + if (null != basicConfig) { | |
328 | 331 | if (SystemConfig.CHINA_BASIC_ID.equals(basicConfig.getParentId())) { |
329 | 332 | organizationQuery.setProvinceId(aId); |
330 | 333 | } else { |
331 | 334 | |
... | ... | @@ -369,14 +372,14 @@ |
369 | 372 | data.add(organization); |
370 | 373 | } |
371 | 374 | } |
372 | - Map<String,Object> map = new HashMap<>(); | |
373 | - map.put("data",data); | |
374 | - map.put("errormsg","成功"); | |
375 | - map.put("errorcode",ErrorCodeConstants.SUCCESS); | |
376 | - map.put("pageInfo",pageInfo); | |
375 | + Map<String, Object> map = new HashMap<>(); | |
376 | + map.put("data", data); | |
377 | + map.put("errormsg", "成功"); | |
378 | + map.put("errorcode", ErrorCodeConstants.SUCCESS); | |
379 | + map.put("pageInfo", pageInfo); | |
377 | 380 | List<DataPermissionsModel> dataPermissionsModelList = accessPermissionFacade.findAccessPerminssionByUserId(loginState.getId()); |
378 | 381 | if (dataPermissionsModelList != null && dataPermissionsModelList.size() > 0) { |
379 | - map.put("areaPermission",dataPermissionsModelList.get(0).getAreaPermission()); | |
382 | + map.put("areaPermission", dataPermissionsModelList.get(0).getAreaPermission()); | |
380 | 383 | } |
381 | 384 | return map; |
382 | 385 | } |
... | ... | @@ -436,8 +439,8 @@ |
436 | 439 | List<Integer> list = autoMatchFacade.matchOrgId(loginState.getId()); |
437 | 440 | List<String> a = new ArrayList<>(); |
438 | 441 | |
439 | - if(CollectionUtils.isNotEmpty(list)){ | |
440 | - a = organizationService.queryProvinceIdByOrgId(list); | |
442 | + if (CollectionUtils.isNotEmpty(list)) { | |
443 | + a = organizationService.queryProvinceIdByOrgId(list); | |
441 | 444 | } |
442 | 445 | /* for (Integer integer : list) { |
443 | 446 | Organization organization = organizationService.getOrganization(integer); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/WordTest.java
View file @
0da9175
1 | +/* | |
2 | +package com.lyms.platform.operate.web.controller; | |
3 | + | |
4 | + | |
5 | +import freemarker.cache.FileTemplateLoader; | |
6 | +import freemarker.cache.TemplateLoader; | |
7 | +import freemarker.template.Configuration; | |
8 | +import freemarker.template.Template; | |
9 | +import freemarker.template.TemplateException; | |
10 | + | |
11 | +import java.io.*; | |
12 | +import java.util.ArrayList; | |
13 | +import java.util.HashMap; | |
14 | +import java.util.List; | |
15 | +import java.util.Map; | |
16 | + | |
17 | + | |
18 | +public class WordTest { | |
19 | + | |
20 | + private Configuration configuration = null; | |
21 | + | |
22 | + public static void main(String[] args) { | |
23 | + com.lyms.platform.operate.web.controller.WordTest test = new com.lyms.platform.operate.web.controller.WordTest(); | |
24 | + test.createWord(); | |
25 | + } | |
26 | + | |
27 | + | |
28 | + public void createWord() { | |
29 | + Configuration cfg = new Configuration(); | |
30 | + TemplateLoader templateLoader = null; | |
31 | + String path = ""; | |
32 | + Map<String, Object> dataMap = new HashMap<String, Object>(); | |
33 | + getData(dataMap); | |
34 | + //使用FileTemplateLoader | |
35 | + Template t = null; | |
36 | + try { | |
37 | + path = this.getClass().getResource("/").getPath(); | |
38 | + templateLoader = new FileTemplateLoader(new File(path)); | |
39 | + cfg.setTemplateLoader(templateLoader); | |
40 | + t = cfg.getTemplate("jlb.ftl", "UTF-8"); | |
41 | + } catch (IOException e) { | |
42 | + e.printStackTrace(); | |
43 | + } | |
44 | + File outFile = new File("D:/outFile" + Math.random() * 10000 + ".doc"); //导出文件 | |
45 | + Writer out = null; | |
46 | + try { | |
47 | + out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile))); | |
48 | + } catch (FileNotFoundException e1) { | |
49 | + e1.printStackTrace(); | |
50 | + } | |
51 | + | |
52 | + try { | |
53 | + t.process(dataMap, out); //将填充数据填入模板文件并输出到目标文件 | |
54 | + } catch (TemplateException e) { | |
55 | + e.printStackTrace(); | |
56 | + } catch (IOException e) { | |
57 | + e.printStackTrace(); | |
58 | + } | |
59 | + } | |
60 | + | |
61 | + private void getData(Map<String, Object> dataMap) { | |
62 | + dataMap.put("title", "标题"); | |
63 | + dataMap.put("nian", "2016"); | |
64 | + dataMap.put("yue", "3"); | |
65 | + dataMap.put("ri", "6"); | |
66 | + //dataMap.put("shenheren", "lc"); | |
67 | + List<Map<String, Object>> cheshi = new ArrayList<Map<String, Object>>(); | |
68 | + for (int i = 0; i < 10; i++) { | |
69 | + Map<String, Object> map = new HashMap<String, Object>(); | |
70 | + map.put("xuhao", "傻得"); | |
71 | + map.put("neirong", "内容" + i); | |
72 | + cheshi.add(map); | |
73 | + } | |
74 | + | |
75 | + dataMap.put("cheshi", cheshi); | |
76 | + } | |
77 | +}*/ |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyBookbuildingFacade.java
View file @
0da9175
... | ... | @@ -16,12 +16,14 @@ |
16 | 16 | import com.lyms.platform.common.result.BaseObjectResponse; |
17 | 17 | import com.lyms.platform.common.result.BaseResponse; |
18 | 18 | import com.lyms.platform.common.utils.*; |
19 | -import com.lyms.platform.common.utils.ArrayUtils; | |
20 | -import com.lyms.platform.common.utils.StringUtils; | |
21 | -import com.lyms.platform.operate.web.request.*; | |
19 | +import com.lyms.platform.operate.web.request.BabyBookbuildingAddRequest; | |
20 | +import com.lyms.platform.operate.web.request.BabyGuideSmsequest; | |
21 | +import com.lyms.platform.operate.web.request.BabyManageRequest; | |
22 | +import com.lyms.platform.operate.web.request.BookbuildingQueryRequest; | |
22 | 23 | import com.lyms.platform.operate.web.result.*; |
23 | 24 | import com.lyms.platform.operate.web.service.ITrackDownService; |
24 | 25 | import com.lyms.platform.operate.web.utils.BabyListTask; |
26 | +import com.lyms.platform.operate.web.utils.CommonsHelper; | |
25 | 27 | import com.lyms.platform.operate.web.utils.GrowthCountTask; |
26 | 28 | import com.lyms.platform.operate.web.utils.MongoUtil; |
27 | 29 | import com.lyms.platform.permission.model.*; |
28 | 30 | |
... | ... | @@ -32,12 +34,13 @@ |
32 | 34 | import com.lyms.platform.pojo.*; |
33 | 35 | import com.lyms.platform.query.*; |
34 | 36 | import org.apache.commons.collections.CollectionUtils; |
35 | -import org.apache.commons.lang.*; | |
36 | 37 | import org.apache.commons.lang.math.NumberUtils; |
37 | 38 | import org.springframework.beans.factory.annotation.Autowired; |
38 | 39 | import org.springframework.beans.factory.annotation.Qualifier; |
39 | 40 | import org.springframework.data.domain.Sort; |
40 | 41 | import org.springframework.data.mongodb.core.MongoTemplate; |
42 | +import org.springframework.data.mongodb.core.query.Criteria; | |
43 | +import org.springframework.data.mongodb.core.query.Query; | |
41 | 44 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
42 | 45 | import org.springframework.stereotype.Component; |
43 | 46 | |
... | ... | @@ -64,6 +67,9 @@ |
64 | 67 | private HisService hisServiceV2; |
65 | 68 | |
66 | 69 | @Autowired |
70 | + private ViewFacade viewFacade; | |
71 | + | |
72 | + @Autowired | |
67 | 73 | private QingLongXianHisService qingLongXianHisService; |
68 | 74 | |
69 | 75 | @Autowired |
70 | 76 | |
... | ... | @@ -3853,6 +3859,121 @@ |
3853 | 3859 | return parentIds; |
3854 | 3860 | } |
3855 | 3861 | |
3862 | + /* public void exportManagementRecords(String id) { | |
3856 | 3863 | |
3864 | + } | |
3865 | + | |
3866 | + public void createWord(String id) { | |
3867 | + Configuration cfg = new Configuration(); | |
3868 | + TemplateLoader templateLoader = null; | |
3869 | + String path = ""; | |
3870 | + //Map<String, Object> dataMap = new HashMap<String, Object>(); | |
3871 | + Map<String, Object> dataMap = getData(id); | |
3872 | + //使用FileTemplateLoader | |
3873 | + Template t = null; | |
3874 | + try { | |
3875 | + path = this.getClass().getResource("/").getPath(); | |
3876 | + templateLoader = new FileTemplateLoader(new File(path)); | |
3877 | + cfg.setTemplateLoader(templateLoader); | |
3878 | + t = cfg.getTemplate("jlb.ftl", "UTF-8"); | |
3879 | + } catch (IOException e) { | |
3880 | + e.printStackTrace(); | |
3881 | + } | |
3882 | + File outFile = new File("D:/outFile" + Math.random() * 10000 + ".doc"); //导出文件 | |
3883 | + Writer out = null; | |
3884 | + try { | |
3885 | + out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile))); | |
3886 | + } catch (FileNotFoundException e1) { | |
3887 | + e1.printStackTrace(); | |
3888 | + } | |
3889 | + | |
3890 | + try { | |
3891 | + t.process(dataMap, out); //将填充数据填入模板文件并输出到目标文件 | |
3892 | + } catch (TemplateException e) { | |
3893 | + e.printStackTrace(); | |
3894 | + } catch (IOException e) { | |
3895 | + e.printStackTrace(); | |
3896 | + } | |
3897 | + }*/ | |
3898 | + | |
3899 | + public Map<String, Object> getData(String id) { | |
3900 | + Map<String, Object> dataMap = new HashMap<>(); | |
3901 | + if (StringUtils.isNotEmpty(id)) { | |
3902 | + BabyModel babyModel = mongoTemplate.findOne(Query.query(Criteria.where("_id").is(id)), BabyModel.class); | |
3903 | + dataMap.put("babyName", babyModel.getName()); | |
3904 | + dataMap.put("sex", babyModel.getSex() != 0 ? "男" : "女"); | |
3905 | + String[] times = DateUtil.getyyyy_MM_dd(babyModel.getBirth()).split("-"); | |
3906 | + dataMap.put("nian", times[0]); | |
3907 | + dataMap.put("yue", times[1]); | |
3908 | + dataMap.put("ri", times[2]); | |
3909 | + String[] created = DateUtil.getyyyy_MM_dd(babyModel.getCreated()).split("-"); | |
3910 | + dataMap.put("createdYear", created[0]); | |
3911 | + dataMap.put("createdMnth", created[1]); | |
3912 | + dataMap.put("createdDay", created[2]); | |
3913 | + if (null != babyModel.getEndCaseTime()) { | |
3914 | + String[] endTime = DateUtil.getyyyy_MM_dd(babyModel.getEndCaseTime()).split("-"); | |
3915 | + dataMap.put("ednYear", endTime[0]); | |
3916 | + dataMap.put("endMnth", endTime[1]); | |
3917 | + dataMap.put("endDay", endTime[2]); | |
3918 | + } | |
3919 | + if (babyModel.getHighRisk() != 0 && CollectionUtils.isNotEmpty(babyModel.getHighRiskInfo())) { | |
3920 | + dataMap.put("hig", "高危儿因素"); | |
3921 | + String highRiskInfos = basicConfigFacade.queryBaseInfoByStr(babyModel.getHighRiskInfo()); | |
3922 | + dataMap.put("higHrisk", highRiskInfos); | |
3923 | + } | |
3924 | + if (babyModel.getWeakSon() != 0 && CollectionUtils.isNotEmpty(babyModel.getWeakSonInfo())) { | |
3925 | + dataMap.put("wask", "体弱儿因素"); | |
3926 | + String weakSonsInfo = basicConfigFacade.queryBaseInfoByStr(babyModel.getWeakSonInfo()); | |
3927 | + dataMap.put("weakSone", weakSonsInfo); | |
3928 | + } | |
3929 | + dataMap.put("phone", babyModel.getFphone()); | |
3930 | + dataMap.put("parentName", babyModel.getMname()); | |
3931 | + List<BabyCheckModel> babyCheckModel = mongoTemplate.find(Query.query(Criteria.where("buildId").is(id)), BabyCheckModel.class); | |
3932 | + if (CollectionUtils.isNotEmpty(babyCheckModel)) { | |
3933 | + List<Map> listMap = new ArrayList<>(); | |
3934 | + for (BabyCheckModel babyCheck : babyCheckModel) { | |
3935 | + Map<String, Object> map = new HashMap<>(); | |
3936 | + dataMap.put("mainFoster", babyCheck.getMainFoster()); | |
3937 | + /* map.put("checkTime", DateUtil.getyyyy_MM_dd(babyCheck.getCheckDate())); | |
3938 | + map.put("age", DateUtil.getBabyMonthAge(babyModel.getBirth(), babyCheck.getCheckDate()));*/ | |
3939 | + | |
3940 | + } | |
3941 | + System.out.println(dataMap.get("mainFoster")); | |
3942 | + if ("0".equals(dataMap.get("mainFoster"))) { | |
3943 | + dataMap.put("filiation", "父子"); | |
3944 | + } else if ("1".equals(dataMap.get("mainFoster"))) { | |
3945 | + dataMap.put("filiation", "母子"); | |
3946 | + } else if ("2".equals(dataMap.get("mainFoster")) || "3".equals(dataMap.get("mainFoster"))) { | |
3947 | + dataMap.put("filiation", "祖孙"); | |
3948 | + } else if ("4".equals(dataMap.get("mainFoster")) || "5".equals(dataMap.get("mainFoster"))) { | |
3949 | + dataMap.put("filiation", "外祖孙"); | |
3950 | + } else if ("6".equals(dataMap.get("mainFoster"))) { | |
3951 | + dataMap.put("filiation", "其他"); | |
3952 | + } | |
3953 | + } | |
3954 | + Patients patients = mongoTemplate.findOne(Query.query(Criteria.where("_id").is(babyModel.getParentId())), Patients.class); | |
3955 | + //市区 | |
3956 | + dataMap.put("city", CommonsHelper.getName1(patients.getCityRegisterId(), basicConfigService)); | |
3957 | + //县 | |
3958 | + dataMap.put("county", CommonsHelper.getName1(patients.getAreaRegisterId(), basicConfigService)); | |
3959 | + //乡镇 | |
3960 | + dataMap.put("township", CommonsHelper.getName1(patients.getStreetRegisterId(), basicConfigService)); | |
3961 | + //村 | |
3962 | + dataMap.put("village", patients.getAddressRegister()); | |
3963 | + dataMap.put("education", getBasicConfig(babyModel.getmLevelId())); | |
3964 | + } | |
3965 | + return dataMap; | |
3966 | + } | |
3967 | + | |
3968 | + private String getBasicConfig(String id) { | |
3969 | + if (com.lyms.platform.common.utils.StringUtils.isEmpty(id)) { | |
3970 | + return ""; | |
3971 | + } | |
3972 | + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(id); | |
3973 | + if (null != basicConfig) { | |
3974 | + return basicConfig.getName(); | |
3975 | + } | |
3976 | + return ""; | |
3977 | + } | |
3857 | 3978 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/WordUtil.java
View file @
0da9175
1 | +/* | |
2 | +package com.lyms.platform.operate.web.facade; | |
3 | + | |
4 | +import freemarker.cache.FileTemplateLoader; | |
5 | +import freemarker.cache.TemplateLoader; | |
6 | +import freemarker.template.Configuration; | |
7 | +import freemarker.template.Template; | |
8 | +import freemarker.template.TemplateException; | |
9 | + | |
10 | +import java.io.*; | |
11 | +import java.util.ArrayList; | |
12 | +import java.util.HashMap; | |
13 | +import java.util.List; | |
14 | +import java.util.Map; | |
15 | + | |
16 | +public class WordUtil { | |
17 | + private Configuration configuration = null; | |
18 | + | |
19 | + public WordUtil() { | |
20 | + configuration = new Configuration(); | |
21 | + configuration.setDefaultEncoding("UTF-8"); | |
22 | + } | |
23 | + public void createWord() { | |
24 | + Configuration cfg = new Configuration(); | |
25 | + TemplateLoader templateLoader = null; | |
26 | + String path = ""; | |
27 | + Map<String, Object> dataMap = new HashMap<String, Object>(); | |
28 | + getData(dataMap); | |
29 | + //使用FileTemplateLoader | |
30 | + Template t = null; | |
31 | + try { | |
32 | + path = this.getClass().getResource("/").getPath(); | |
33 | + templateLoader = new FileTemplateLoader(new File(path)); | |
34 | + cfg.setTemplateLoader(templateLoader); | |
35 | + t = cfg.getTemplate("jlb.ftl", "UTF-8"); | |
36 | + } catch (IOException e) { | |
37 | + e.printStackTrace(); | |
38 | + } | |
39 | + File outFile = new File("D:/outFile" + Math.random() * 10000 + ".doc"); //导出文件 | |
40 | + Writer out = null; | |
41 | + try { | |
42 | + out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile))); | |
43 | + } catch (FileNotFoundException e1) { | |
44 | + e1.printStackTrace(); | |
45 | + } | |
46 | + | |
47 | + try { | |
48 | + t.process(dataMap, out); //将填充数据填入模板文件并输出到目标文件 | |
49 | + } catch (TemplateException e) { | |
50 | + e.printStackTrace(); | |
51 | + } catch (IOException e) { | |
52 | + e.printStackTrace(); | |
53 | + } | |
54 | + } | |
55 | + | |
56 | + private void getData(Map<String, Object> dataMap) { | |
57 | + dataMap.put("title", "标题"); | |
58 | + dataMap.put("nian", "2016"); | |
59 | + dataMap.put("yue", "3"); | |
60 | + dataMap.put("ri", "6"); | |
61 | + //dataMap.put("shenheren", "lc"); | |
62 | + List<Map<String, Object>> cheshi = new ArrayList<Map<String, Object>>(); | |
63 | + for (int i = 0; i < 10; i++) { | |
64 | + Map<String, Object> map = new HashMap<String, Object>(); | |
65 | + map.put("xuhao", "傻得"); | |
66 | + map.put("neirong", "内容" + i); | |
67 | + cheshi.add(map); | |
68 | + } | |
69 | + | |
70 | + dataMap.put("cheshi", cheshi); | |
71 | + } | |
72 | +} | |
73 | +*/ |
platform-operate-api/src/main/resources/jlb.docx
View file @
0da9175