From e1e4b243e273373a6572879cfc06f93bda09a98b Mon Sep 17 00:00:00 2001 From: fangcheng Date: Wed, 29 Mar 2017 18:07:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=97=85=E5=8F=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hospital/constants/HistoryPatientType.java | 25 +++++++++++++ .../hospital/dao/history/HistorySourceMapper.java | 2 +- .../hospital/dao/history/HistorySourceMapper.xml | 3 +- .../hospital/entity/history/HistorySource.java | 41 ++++++++++++++++++---- .../service/history/HistorySourceService.java | 25 +++++++++++++ .../history/impl/HistorySourceServiceImpl.java | 37 +++++++++++++++++++ .../lyms/hospital/controller/LoginController.java | 6 ++-- .../controller/conf/HighriskVersionController.java | 4 +-- .../java/test/hospital/history/HistoryTest.java | 27 ++++++++++++++ .../mybatisplus/test/generator/MysqlGenerator.java | 8 ++--- 10 files changed, 161 insertions(+), 17 deletions(-) create mode 100644 parent/hospital.mac/src/main/java/com/lyms/hospital/constants/HistoryPatientType.java create mode 100644 parent/hospital.web/src/test/java/test/hospital/history/HistoryTest.java diff --git a/parent/hospital.mac/src/main/java/com/lyms/hospital/constants/HistoryPatientType.java b/parent/hospital.mac/src/main/java/com/lyms/hospital/constants/HistoryPatientType.java new file mode 100644 index 0000000..17e1548 --- /dev/null +++ b/parent/hospital.mac/src/main/java/com/lyms/hospital/constants/HistoryPatientType.java @@ -0,0 +1,25 @@ +package com.lyms.hospital.constants; + +/** + *
  • @ClassName: 病史分类 + *
  • @Description: TODO(类描述) + *
  • @author 方承 + *
  • @date 2017年3月29日 + *
  • + */ +public enum HistoryPatientType { + + JWS("JWS"), + JZS("JZS"); + + private String code; + + private HistoryPatientType(String code) { + this.code = code; + } + + public String getCode() { + return code; + } + +} diff --git a/parent/hospital.mac/src/main/java/com/lyms/hospital/dao/history/HistorySourceMapper.java b/parent/hospital.mac/src/main/java/com/lyms/hospital/dao/history/HistorySourceMapper.java index 92fe2de..b45962c 100644 --- a/parent/hospital.mac/src/main/java/com/lyms/hospital/dao/history/HistorySourceMapper.java +++ b/parent/hospital.mac/src/main/java/com/lyms/hospital/dao/history/HistorySourceMapper.java @@ -10,7 +10,7 @@ import java.io.Serializable; *

    * * @author fangcheng - * @since 2017-03-28 + * @since 2017-03-29 */ @Repository public interface HistorySourceMapper extends BaseMapper { diff --git a/parent/hospital.mac/src/main/java/com/lyms/hospital/dao/history/HistorySourceMapper.xml b/parent/hospital.mac/src/main/java/com/lyms/hospital/dao/history/HistorySourceMapper.xml index 7f0e4ae..e4e4c2e 100644 --- a/parent/hospital.mac/src/main/java/com/lyms/hospital/dao/history/HistorySourceMapper.xml +++ b/parent/hospital.mac/src/main/java/com/lyms/hospital/dao/history/HistorySourceMapper.xml @@ -8,12 +8,13 @@ + - ID AS id, PID AS pid, NAME AS name, TYPE AS type, LEVEL AS level, ENABLE AS enable + ID AS id, PID AS pid, NAME AS name, TYPE AS type, ITEMORDER AS itemorder, LEVEL AS level, ENABLE AS enable diff --git a/parent/hospital.mac/src/main/java/com/lyms/hospital/entity/history/HistorySource.java b/parent/hospital.mac/src/main/java/com/lyms/hospital/entity/history/HistorySource.java index 261a87e..51840a0 100644 --- a/parent/hospital.mac/src/main/java/com/lyms/hospital/entity/history/HistorySource.java +++ b/parent/hospital.mac/src/main/java/com/lyms/hospital/entity/history/HistorySource.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotations.TableId; import com.baomidou.mybatisplus.annotations.TableField; import com.baomidou.mybatisplus.annotations.TableName; import java.io.Serializable; +import java.util.List; /** *

    @@ -11,7 +12,7 @@ import java.io.Serializable; *

    * * @author fangcheng - * @since 2017-03-28 + * @since 2017-03-29 */ @TableName("HISTORY_SOURCE") public class HistorySource implements Serializable { @@ -39,6 +40,11 @@ public class HistorySource implements Serializable { @TableField(value="TYPE") private String type; /** + * + */ + @TableField(value="ITEMORDER") + private String itemorder; + /** * 本记录层级,1,2,3 */ @TableField(value="LEVEL") @@ -47,9 +53,14 @@ public class HistorySource implements Serializable { * 是否启用,默认1启用 */ @TableField(value="ENABLE") - private String enable; - - + private Integer enable; + + /** + * 子级别元素 + */ + @TableField(exist=false) + private List children; + public String getId() { return id; } @@ -82,6 +93,14 @@ public class HistorySource implements Serializable { this.type = type; } + public String getItemorder() { + return itemorder; + } + + public void setItemorder(String itemorder) { + this.itemorder = itemorder; + } + public String getLevel() { return level; } @@ -90,12 +109,22 @@ public class HistorySource implements Serializable { this.level = level; } - public String getEnable() { + public Integer getEnable() { return enable; } - public void setEnable(String enable) { + public void setEnable(Integer enable) { this.enable = enable; } + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } + + + } diff --git a/parent/hospital.mac/src/main/java/com/lyms/hospital/service/history/HistorySourceService.java b/parent/hospital.mac/src/main/java/com/lyms/hospital/service/history/HistorySourceService.java index 730c9ad..54bdbdb 100644 --- a/parent/hospital.mac/src/main/java/com/lyms/hospital/service/history/HistorySourceService.java +++ b/parent/hospital.mac/src/main/java/com/lyms/hospital/service/history/HistorySourceService.java @@ -3,6 +3,7 @@ package com.lyms.hospital.service.history; import com.lyms.hospital.entity.history.HistorySource; import com.lyms.web.service.BaseService; import java.io.Serializable; +import java.util.List; /** *

    @@ -20,5 +21,29 @@ public interface HistorySourceService extends BaseService { *

  • @return 大于0修改成功,否则为失败 */ public Integer deleteLogicById(Serializable id); + + + /** + *
  • @Description:根据参数类型获取所有病史基础数据,不传入参数获取所有 + *
  • @param types HistoryPatientType + *
  • @return + *
  • 创建人:方承 + *
  • 创建时间:2017年3月29日 + *
  • 修改人: + *
  • 修改时间: + */ +public List selectByType(String ...HistoryPatientType); + + +/** + *
  • @Description:根据参数类型获取所有病史的结构型数据(有层次结构的数据),不传入参数获取所有 + *
  • @param HistoryPatientType + *
  • @return + *
  • 创建人:方承 + *
  • 创建时间:2017年3月29日 + *
  • 修改人: + *
  • 修改时间: + */ +public List selectStructureByType(String ...HistoryPatientType); } diff --git a/parent/hospital.mac/src/main/java/com/lyms/hospital/service/history/impl/HistorySourceServiceImpl.java b/parent/hospital.mac/src/main/java/com/lyms/hospital/service/history/impl/HistorySourceServiceImpl.java index ebe346b..b89e03d 100644 --- a/parent/hospital.mac/src/main/java/com/lyms/hospital/service/history/impl/HistorySourceServiceImpl.java +++ b/parent/hospital.mac/src/main/java/com/lyms/hospital/service/history/impl/HistorySourceServiceImpl.java @@ -3,9 +3,13 @@ package com.lyms.hospital.service.history.impl; import com.lyms.hospital.entity.history.HistorySource; import com.lyms.hospital.dao.history.HistorySourceMapper; import com.lyms.hospital.service.history.HistorySourceService; +import com.lyms.util.InstanceUtils; +import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.service.impl.ServiceImpl; import org.springframework.stereotype.Service; import java.io.Serializable; +import java.util.List; +import java.util.Map; /** *

    @@ -21,4 +25,37 @@ public class HistorySourceServiceImpl extends ServiceImpl selectByType(String... historyPatientType) { + List dataList = null; + EntityWrapper ew = new EntityWrapper(); + ew.where("enable=1"); + if(null != historyPatientType){ + ew.and("type={}", "'"+historyPatientType+"'"); + } + dataList = selectList(ew); + return dataList; + } + + @Override + public List selectStructureByType(String... HistoryPatientType) { + List dbdataList = selectByType(HistoryPatientType); + List firstdataList = InstanceUtils.newArrayList(); + Map firstLevelData = InstanceUtils.newHashMap(); + for(HistorySource historySource : dbdataList){ + if("1".equals(historySource.getLevel())){ + firstdataList.add(historySource); + firstLevelData.put(historySource.getId(), historySource); + dbdataList.remove(historySource); + } + } + for(HistorySource historySource : dbdataList){ + if("2".equals(historySource.getLevel())){ + firstLevelData.get(historySource.getPid()).getChildren().add(historySource); + dbdataList.remove(historySource); + } + } + return firstdataList; + } } diff --git a/parent/hospital.web/src/main/java/com/lyms/hospital/controller/LoginController.java b/parent/hospital.web/src/main/java/com/lyms/hospital/controller/LoginController.java index 77ecb40..470df00 100644 --- a/parent/hospital.web/src/main/java/com/lyms/hospital/controller/LoginController.java +++ b/parent/hospital.web/src/main/java/com/lyms/hospital/controller/LoginController.java @@ -43,7 +43,7 @@ public class LoginController extends BaseController { */ @RequestMapping(value = "/testPostJson", method = RequestMethod.POST) @ResponseBody - public String testPostJson(@RequestBody JSONObject reqJson){ + public String testPostJson(@RequestBody String reqJson){ Users u = getRequestUsersEntity(reqJson); System.out.println(JSON.toJSONString(u)); return "1"; @@ -58,8 +58,8 @@ public class LoginController extends BaseController { *

  • 修改人: *
  • 修改时间: */ - private Users getRequestUsersEntity(JSONObject reqJson){ + private Users getRequestUsersEntity(String reqJson){ //users.setId(reqJson.getString("id")); - return JSON.parseObject(reqJson.toJSONString(), Users.class); + return JSON.parseObject(reqJson, Users.class); } } diff --git a/parent/hospital.web/src/main/java/com/lyms/hospital/controller/conf/HighriskVersionController.java b/parent/hospital.web/src/main/java/com/lyms/hospital/controller/conf/HighriskVersionController.java index 2c0d072..6e5d7dc 100644 --- a/parent/hospital.web/src/main/java/com/lyms/hospital/controller/conf/HighriskVersionController.java +++ b/parent/hospital.web/src/main/java/com/lyms/hospital/controller/conf/HighriskVersionController.java @@ -17,7 +17,7 @@ import com.lyms.web.controller.BaseController; @RequestMapping(value = "/highrisk/version") public class HighriskVersionController extends BaseController { - @Autowired - private HighriskVersionService highriskVersionService; +// @Autowired +// private HighriskVersionService highriskVersionService; } diff --git a/parent/hospital.web/src/test/java/test/hospital/history/HistoryTest.java b/parent/hospital.web/src/test/java/test/hospital/history/HistoryTest.java new file mode 100644 index 0000000..68bd29b --- /dev/null +++ b/parent/hospital.web/src/test/java/test/hospital/history/HistoryTest.java @@ -0,0 +1,27 @@ +package test.hospital.history; + +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; + +import com.lyms.hospital.service.history.HistorySourceService; + +import test.hospital.BaseTest; + +public class HistoryTest extends BaseTest{ + + @Autowired + private HistorySourceService historySourceService; + + /** + *
  • @Description:测试病史基础数据 + *
  • + *
  • 创建人:方承 + *
  • 创建时间:2017年3月29日 + *
  • 修改人: + *
  • 修改时间: + */ + @Test + public void testHistorySource(){ + outJson(historySourceService.selectStructureByType()); + } +} diff --git a/parent/mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/generator/MysqlGenerator.java b/parent/mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/generator/MysqlGenerator.java index 70da4b8..a48c5a6 100644 --- a/parent/mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/generator/MysqlGenerator.java +++ b/parent/mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/generator/MysqlGenerator.java @@ -44,15 +44,15 @@ public class MysqlGenerator { private static void customSet(GlobalConfig gc, StrategyConfig strategy, PackageConfig pc) { gc.setOutputDir("E://mybatis-plus-generate"); - gc.setAuthor("maliang"); + gc.setAuthor("fangcheng"); // strategy.setInclude(new String[] { // "SYS_USERS","SYS_USER_ROLE_MAPS","SYS_ROLES" }); // 需要生成的表 - strategy.setInclude(new String[] { "HIGHRISK_VERSION" }); // 需要生成的表 + strategy.setInclude(new String[] { "HISTORY_SOURCE"}); // 需要生成的表 // pc.setParent("com.lyms.hospital"); - pc.setParent("com.lyms.base.common"); + pc.setParent("com.lyms.hospital"); - pc.setFunctionName("conf"); // com.lyms.hospital.web.controller.sys + pc.setFunctionName("history"); // com.lyms.hospital.web.controller.sys // 加在controller后面 // pc.setModuleName("sys"); //com.lyms.hospital.sys.controller // 加在controller前面 -- 1.8.3.1