Commit 986be3be7e672ad2d7fa55b2584f9e157c8971fe
1 parent
856424e519
Exists in
master
编写高危信息代码
Showing 18 changed files with 288 additions and 52 deletions
- parent/base.common/pom.xml
- parent/base.common/src/main/java/com/lyms/base/common/dao/conf/HighriskConfMapper.java
- parent/base.common/src/main/java/com/lyms/base/common/dao/conf/HighriskConfMapper.xml
- parent/base.common/src/main/java/com/lyms/base/common/dao/conf/HighriskVersionMapper.xml
- parent/base.common/src/main/java/com/lyms/base/common/entity/conf/HighriskConf.java
- parent/base.common/src/main/java/com/lyms/base/common/entity/conf/HighriskSource.java
- parent/base.common/src/main/java/com/lyms/base/common/service/conf/HighriskConfService.java
- parent/base.common/src/main/java/com/lyms/base/common/service/conf/HighriskVersionService.java
- parent/base.common/src/main/java/com/lyms/base/common/service/conf/impl/HighriskConfServiceImpl.java
- parent/base.common/src/main/java/com/lyms/base/common/service/conf/impl/HighriskSourceServiceImpl.java
- parent/base.common/src/main/java/com/lyms/base/common/service/conf/impl/HighriskVersionServiceImpl.java
- parent/hospital.web/src/main/java/com/lyms/hospital/controller/conf/HighriskVersionController.java
- parent/hospital.web/src/main/resources/app-context.xml
- parent/hospital.web/src/main/resources/xml/app-datasource.xml
- parent/hospital.web/src/test/java/test/hospital/BaseServiceTest.java
- parent/hospital.web/src/test/java/test/hospital/BaseTest.java
- parent/hospital.web/src/test/java/test/hospital/service/HighriskVersionTest.java
- parent/hospital.web/src/test/java/test/hospital/service/package-info.java
parent/base.common/pom.xml
View file @
986be3b
parent/base.common/src/main/java/com/lyms/base/common/dao/conf/HighriskConfMapper.java
View file @
986be3b
| ... | ... | @@ -32,5 +32,16 @@ |
| 32 | 32 | */ |
| 33 | 33 | public List<HighriskConf> selectByVersion(String versionId); |
| 34 | 34 | |
| 35 | + /** | |
| 36 | + * <li>@Description:根据资源ID获取对应的配置信息 | |
| 37 | + * <li>@param sourceId | |
| 38 | + * <li>@return | |
| 39 | + * <li>创建人:maliang | |
| 40 | + * <li>创建时间:2017年3月29日 | |
| 41 | + * <li>修改人: | |
| 42 | + * <li>修改时间: | |
| 43 | + */ | |
| 44 | + public List<HighriskConf> selectBySource(String sourceId); | |
| 45 | + | |
| 35 | 46 | } |
parent/base.common/src/main/java/com/lyms/base/common/dao/conf/HighriskConfMapper.xml
View file @
986be3b
| ... | ... | @@ -21,9 +21,16 @@ |
| 21 | 21 | ID AS id, SOURCE_ID AS sourceId, VERSION_ID AS versionId, NAME AS name, COLORCODE AS colorcode, COLORTEXT AS colortext, GROUPORDER AS grouporder, ITEMORDER AS itemorder, GRADE AS grade, ENABLE AS enable |
| 22 | 22 | </sql> |
| 23 | 23 | |
| 24 | + <!-- 根据版本号获取高危区域配置和信息 --> | |
| 24 | 25 | <select id="selectByVersion" resultMap="BaseResultMap"> |
| 25 | - select <include refid="Base_Column_List" /> from HIGHRISK_CONF where versionId=#{versionId} | |
| 26 | + select <include refid="Base_Column_List" /> from HIGHRISK_CONF where VERSION_ID=#{versionId} | |
| 26 | 27 | </select> |
| 28 | + | |
| 29 | + <!-- 根据资源ID获取区域高危配置信息 --> | |
| 30 | + <select id="selectBySource" resultMap="BaseResultMap"> | |
| 31 | + select <include refid="Base_Column_List" /> from HIGHRISK_CONF where SOURCE_ID=#{sourceId} | |
| 32 | + </select> | |
| 33 | + | |
| 27 | 34 | |
| 28 | 35 | </mapper> |
parent/base.common/src/main/java/com/lyms/base/common/dao/conf/HighriskVersionMapper.xml
View file @
986be3b
| ... | ... | @@ -20,7 +20,7 @@ |
| 20 | 20 | </sql> |
| 21 | 21 | |
| 22 | 22 | <!-- id & enable --> |
| 23 | - <select id="selectBy" resultType="HighriskVersion" > | |
| 23 | + <select id="selectBy" resultMap="BaseResultMap" > | |
| 24 | 24 | select <include refid="Base_Column_List" /> from <include refid="Base_Table" /> |
| 25 | 25 | <where> |
| 26 | 26 | id=#{id} and enable=#{status} |
parent/base.common/src/main/java/com/lyms/base/common/entity/conf/HighriskConf.java
View file @
986be3b
| ... | ... | @@ -55,17 +55,17 @@ |
| 55 | 55 | * 高危组排序 |
| 56 | 56 | */ |
| 57 | 57 | @TableField(value = "GROUPORDER") |
| 58 | - private String grouporder; | |
| 58 | + private Integer grouporder; | |
| 59 | 59 | /** |
| 60 | 60 | * 高危项排序 |
| 61 | 61 | */ |
| 62 | 62 | @TableField(value = "ITEMORDER") |
| 63 | - private String itemorder; | |
| 63 | + private Integer itemorder; | |
| 64 | 64 | /** |
| 65 | 65 | * 自定义评分 |
| 66 | 66 | */ |
| 67 | 67 | @TableField(value = "GRADE") |
| 68 | - private String grade; | |
| 68 | + private Double grade; | |
| 69 | 69 | /** |
| 70 | 70 | * 是否启用,默认1启用 |
| 71 | 71 | */ |
| 72 | 72 | |
| 73 | 73 | |
| 74 | 74 | |
| 75 | 75 | |
| 76 | 76 | |
| ... | ... | @@ -120,27 +120,27 @@ |
| 120 | 120 | this.colortext = colortext; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - public String getGrouporder() { | |
| 123 | + public Integer getGrouporder() { | |
| 124 | 124 | return grouporder; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - public void setGrouporder(String grouporder) { | |
| 127 | + public void setGrouporder(Integer grouporder) { | |
| 128 | 128 | this.grouporder = grouporder; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - public String getItemorder() { | |
| 131 | + public Integer getItemorder() { | |
| 132 | 132 | return itemorder; |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - public void setItemorder(String itemorder) { | |
| 135 | + public void setItemorder(Integer itemorder) { | |
| 136 | 136 | this.itemorder = itemorder; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - public String getGrade() { | |
| 139 | + public Double getGrade() { | |
| 140 | 140 | return grade; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - public void setGrade(String grade) { | |
| 143 | + public void setGrade(Double grade) { | |
| 144 | 144 | this.grade = grade; |
| 145 | 145 | } |
| 146 | 146 |
parent/base.common/src/main/java/com/lyms/base/common/entity/conf/HighriskSource.java
View file @
986be3b
| ... | ... | @@ -4,6 +4,7 @@ |
| 4 | 4 | |
| 5 | 5 | import com.baomidou.mybatisplus.annotations.TableField; |
| 6 | 6 | import com.baomidou.mybatisplus.annotations.TableName; |
| 7 | +import com.lyms.base.common.enums.StatusEnum; | |
| 7 | 8 | |
| 8 | 9 | /** |
| 9 | 10 | * <p> |
| ... | ... | @@ -37,7 +38,7 @@ |
| 37 | 38 | * 是否启用,默认1启用 |
| 38 | 39 | */ |
| 39 | 40 | @TableField(value = "ENABLE") |
| 40 | - private Integer enable; | |
| 41 | + private Integer enable = StatusEnum.ENABLED.getStatus(); | |
| 41 | 42 | |
| 42 | 43 | public String getId() { |
| 43 | 44 | return id; |
parent/base.common/src/main/java/com/lyms/base/common/service/conf/HighriskConfService.java
View file @
986be3b
| ... | ... | @@ -48,14 +48,25 @@ |
| 48 | 48 | public boolean updateHighriskConf(HighriskConf highriskConf) throws SystemException; |
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | - * <li>@Description:根据版本号获取高危配置信息 | |
| 51 | + * <li>@Description:根据版本号获取区域高危配置信息 | |
| 52 | 52 | * <li>@return |
| 53 | 53 | * <li>创建人:maliang |
| 54 | 54 | * <li>创建时间:2017年3月28日 |
| 55 | 55 | * <li>修改人: |
| 56 | 56 | * <li>修改时间: |
| 57 | 57 | */ |
| 58 | - public List<HighriskConf> getHighriskConf(String versionId); | |
| 58 | + public List<HighriskConf> getHighriskConfByVersionId(String versionId); | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * <li>@Description:根据资源ID 获取区域版本配置信息 | |
| 62 | + * <li>@param sourceId | |
| 63 | + * <li>@return | |
| 64 | + * <li>创建人:maliang | |
| 65 | + * <li>创建时间:2017年3月29日 | |
| 66 | + * <li>修改人: | |
| 67 | + * <li>修改时间: | |
| 68 | + */ | |
| 69 | + public List<HighriskConf> getHighriskConfBySourceId(String sourceId); | |
| 59 | 70 | |
| 60 | 71 | } |
parent/base.common/src/main/java/com/lyms/base/common/service/conf/HighriskVersionService.java
View file @
986be3b
| 1 | 1 | package com.lyms.base.common.service.conf; |
| 2 | 2 | |
| 3 | 3 | import java.io.Serializable; |
| 4 | +import java.util.List; | |
| 4 | 5 | |
| 5 | 6 | import com.lyms.base.common.entity.conf.HighriskVersion; |
| 6 | 7 | import com.lyms.exception.SystemException; |
| ... | ... | @@ -44,7 +45,7 @@ |
| 44 | 45 | * <li>修改人: |
| 45 | 46 | * <li>修改时间: |
| 46 | 47 | */ |
| 47 | - public HighriskVersion getEnableHighriskVersionBy(Serializable id) throws SystemException; | |
| 48 | + public List<HighriskVersion> getEnableHighriskVersionBy(Serializable id) throws SystemException; | |
| 48 | 49 | |
| 49 | 50 | /** |
| 50 | 51 | * <li>@Description:添加版本号 |
parent/base.common/src/main/java/com/lyms/base/common/service/conf/impl/HighriskConfServiceImpl.java
View file @
986be3b
| ... | ... | @@ -5,6 +5,7 @@ |
| 5 | 5 | |
| 6 | 6 | import org.apache.commons.lang3.StringUtils; |
| 7 | 7 | import org.springframework.beans.factory.annotation.Autowired; |
| 8 | +import org.springframework.stereotype.Service; | |
| 8 | 9 | import org.springframework.transaction.annotation.Transactional; |
| 9 | 10 | |
| 10 | 11 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| ... | ... | @@ -23,6 +24,7 @@ |
| 23 | 24 | * @author maliang |
| 24 | 25 | * @since 2017-03-28 |
| 25 | 26 | */ |
| 27 | +@Service | |
| 26 | 28 | public class HighriskConfServiceImpl extends ServiceImpl<HighriskConfMapper, HighriskConf> |
| 27 | 29 | implements HighriskConfService { |
| 28 | 30 | |
| ... | ... | @@ -54,7 +56,8 @@ |
| 54 | 56 | if (enable == null) { |
| 55 | 57 | highriskConf.setEnable(StatusEnum.ENABLED.getStatus()); |
| 56 | 58 | } |
| 57 | - return id; | |
| 59 | + Integer tag = confMapper.insert(highriskConf); | |
| 60 | + return tag != null && tag >= 1 ? id : null; | |
| 58 | 61 | } |
| 59 | 62 | |
| 60 | 63 | @Override |
| 61 | 64 | |
| ... | ... | @@ -73,10 +76,17 @@ |
| 73 | 76 | } |
| 74 | 77 | |
| 75 | 78 | @Override |
| 76 | - public List<HighriskConf> getHighriskConf(String versionId) { | |
| 79 | + public List<HighriskConf> getHighriskConfByVersionId(String versionId) { | |
| 77 | 80 | if (StringUtils.isBlank(versionId)) |
| 78 | 81 | return null; |
| 79 | 82 | return confMapper.selectByVersion(versionId); |
| 83 | + } | |
| 84 | + | |
| 85 | + @Override | |
| 86 | + public List<HighriskConf> getHighriskConfBySourceId(String sourceId) { | |
| 87 | + if (StringUtils.isBlank(sourceId)) | |
| 88 | + return null; | |
| 89 | + return confMapper.selectBySource(sourceId); | |
| 80 | 90 | } |
| 81 | 91 | |
| 82 | 92 | } |
parent/base.common/src/main/java/com/lyms/base/common/service/conf/impl/HighriskSourceServiceImpl.java
View file @
986be3b
| ... | ... | @@ -3,9 +3,14 @@ |
| 3 | 3 | import java.io.Serializable; |
| 4 | 4 | import java.util.List; |
| 5 | 5 | |
| 6 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 7 | +import org.springframework.stereotype.Service; | |
| 8 | + | |
| 9 | +import com.baomidou.mybatisplus.mapper.EntityWrapper; | |
| 6 | 10 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| 7 | 11 | import com.lyms.base.common.dao.conf.HighriskSourceMapper; |
| 8 | 12 | import com.lyms.base.common.entity.conf.HighriskSource; |
| 13 | +import com.lyms.base.common.enums.StatusEnum; | |
| 9 | 14 | import com.lyms.base.common.service.conf.HighriskSourceService; |
| 10 | 15 | import com.lyms.exception.SystemException; |
| 11 | 16 | import com.lyms.util.StrUtils; |
| 12 | 17 | |
| ... | ... | @@ -18,9 +23,13 @@ |
| 18 | 23 | * @author maliang |
| 19 | 24 | * @since 2017-03-28 |
| 20 | 25 | */ |
| 26 | +@Service | |
| 21 | 27 | public class HighriskSourceServiceImpl extends ServiceImpl<HighriskSourceMapper, HighriskSource> |
| 22 | 28 | implements HighriskSourceService { |
| 23 | 29 | |
| 30 | + @Autowired | |
| 31 | + private HighriskSourceMapper sourceMapper; | |
| 32 | + | |
| 24 | 33 | @Override |
| 25 | 34 | public Integer deleteLogicById(Serializable id) { |
| 26 | 35 | return null; |
| 27 | 36 | |
| 28 | 37 | |
| 29 | 38 | |
| 30 | 39 | |
| ... | ... | @@ -36,21 +45,40 @@ |
| 36 | 45 | public String createHighriskSource(HighriskSource highriskSource) throws SystemException { |
| 37 | 46 | |
| 38 | 47 | throwCheckException(highriskSource); |
| 39 | - | |
| 40 | 48 | String id = StrUtils.uuid(); |
| 41 | 49 | highriskSource.setId(id); |
| 50 | + Integer tag = sourceMapper.insert(highriskSource); | |
| 51 | + return tag != null && tag >= 1 ? id : null; | |
| 42 | 52 | |
| 43 | - return null; | |
| 44 | 53 | } |
| 45 | 54 | |
| 46 | 55 | @Override |
| 47 | 56 | public boolean enable(Serializable id) throws SystemException { |
| 48 | - return false; | |
| 57 | + | |
| 58 | + if (id == null) | |
| 59 | + return false; | |
| 60 | + | |
| 61 | + HighriskSource highriskSource = sourceMapper.selectById(id); | |
| 62 | + if (highriskSource == null) | |
| 63 | + return false; | |
| 64 | + | |
| 65 | + Integer status = highriskSource.getEnable(); | |
| 66 | + | |
| 67 | + if (status == null || StatusEnum.isDisEnabled(status)) { | |
| 68 | + highriskSource.setEnable(StatusEnum.ENABLED.getStatus()); | |
| 69 | + } else { | |
| 70 | + highriskSource.setEnable(StatusEnum.DISENABLED.getStatus()); | |
| 71 | + } | |
| 72 | + Integer tag = sourceMapper.updateById(highriskSource); | |
| 73 | + | |
| 74 | + return tag != null && tag >= 1; | |
| 49 | 75 | } |
| 50 | 76 | |
| 51 | 77 | @Override |
| 52 | 78 | public List<HighriskSource> getHighriskSource() throws SystemException { |
| 53 | - return null; | |
| 79 | + EntityWrapper<HighriskSource> wrapper = new EntityWrapper<HighriskSource>(); | |
| 80 | + wrapper.where("enable={0}", StatusEnum.ENABLED.getStatus()); | |
| 81 | + return sourceMapper.selectList(wrapper); | |
| 54 | 82 | } |
| 55 | 83 | |
| 56 | 84 | } |
parent/base.common/src/main/java/com/lyms/base/common/service/conf/impl/HighriskVersionServiceImpl.java
View file @
986be3b
| 1 | 1 | package com.lyms.base.common.service.conf.impl; |
| 2 | 2 | |
| 3 | 3 | import java.io.Serializable; |
| 4 | +import java.util.List; | |
| 4 | 5 | |
| 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; |
| 7 | +import org.springframework.stereotype.Service; | |
| 6 | 8 | import org.springframework.transaction.annotation.Transactional; |
| 7 | 9 | |
| 10 | +import com.baomidou.mybatisplus.mapper.EntityWrapper; | |
| 8 | 11 | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| 9 | 12 | import com.lyms.base.common.dao.conf.HighriskVersionMapper; |
| 10 | 13 | import com.lyms.base.common.entity.conf.HighriskVersion; |
| ... | ... | @@ -21,6 +24,7 @@ |
| 21 | 24 | * @author maliang |
| 22 | 25 | * @since 2017-03-28 |
| 23 | 26 | */ |
| 27 | +@Service | |
| 24 | 28 | public class HighriskVersionServiceImpl extends ServiceImpl<HighriskVersionMapper, HighriskVersion> |
| 25 | 29 | implements HighriskVersionService { |
| 26 | 30 | |
| 27 | 31 | |
| 28 | 32 | |
| ... | ... | @@ -53,27 +57,22 @@ |
| 53 | 57 | } |
| 54 | 58 | |
| 55 | 59 | @Override |
| 56 | - public HighriskVersion getEnableHighriskVersionBy(Serializable id) throws SystemException { | |
| 60 | + public List<HighriskVersion> getEnableHighriskVersionBy(Serializable id) throws SystemException { | |
| 57 | 61 | |
| 58 | - boolean tag = false; | |
| 59 | - HighriskVersion version = null; | |
| 60 | - if (id == null) { | |
| 61 | - tag = true; | |
| 62 | - } else { | |
| 63 | - version = versionMapper.selectBy(id, StatusEnum.ENABLED.getStatus()); | |
| 64 | - if (version == null) { | |
| 65 | - tag = true; | |
| 66 | - } | |
| 67 | - } | |
| 68 | - // 获取默认版本信息 | |
| 69 | - if (tag) { | |
| 70 | - // version = versionMapper.selectById(id); | |
| 71 | - // TODO 获取默认版本 | |
| 72 | - } | |
| 73 | - return version; | |
| 62 | + /* | |
| 63 | + * boolean tag = false; HighriskVersion version = null; if (id == null) | |
| 64 | + * { tag = true; } else { version = versionMapper.selectBy(id, | |
| 65 | + * StatusEnum.ENABLED.getStatus()); if (version == null) { tag = true; } | |
| 66 | + * } // 获取默认版本信息 if (tag) { // version = versionMapper.selectById(id); | |
| 67 | + * // TODO 获取默认版本 } | |
| 68 | + */ | |
| 69 | + EntityWrapper<HighriskVersion> wrapper = new EntityWrapper<HighriskVersion>(); | |
| 70 | + wrapper.where("enable={0}", StatusEnum.ENABLED.getStatus()); | |
| 71 | + return versionMapper.selectList(wrapper); | |
| 74 | 72 | } |
| 75 | 73 | |
| 76 | 74 | @Override |
| 75 | + @Transactional | |
| 77 | 76 | public String createVersion(HighriskVersion version) throws SystemException { |
| 78 | 77 | |
| 79 | 78 | if (version == null) { |
parent/hospital.web/src/main/java/com/lyms/hospital/controller/conf/HighriskVersionController.java
View file @
986be3b
| ... | ... | @@ -17,8 +17,8 @@ |
| 17 | 17 | @RequestMapping(value = "/highrisk/version") |
| 18 | 18 | public class HighriskVersionController extends BaseController { |
| 19 | 19 | |
| 20 | - @Autowired | |
| 21 | - private HighriskVersionService highriskVersionService; | |
| 20 | + //@Autowired | |
| 21 | + //private HighriskVersionService highriskVersionService; | |
| 22 | 22 | |
| 23 | 23 | } |
parent/hospital.web/src/main/resources/app-context.xml
View file @
986be3b
| ... | ... | @@ -22,8 +22,7 @@ |
| 22 | 22 | </property> |
| 23 | 23 | </bean> |
| 24 | 24 | |
| 25 | - <context:component-scan base-package="com.lyms.hospital"></context:component-scan> | |
| 26 | - <context:component-scan base-package="com.lyms.spring" /> | |
| 25 | + <context:component-scan base-package="com.lyms" /> | |
| 27 | 26 | <!-- <mvc:default-servlet-handler /> --> |
| 28 | 27 | |
| 29 | 28 | <!-- 配置静态资源,直接映射到对应的文件夹,DispatcherServlet 不处理 --> |
parent/hospital.web/src/main/resources/xml/app-datasource.xml
View file @
986be3b
| ... | ... | @@ -78,9 +78,11 @@ |
| 78 | 78 | <list> |
| 79 | 79 | <value>classpath*:com/lyms/hospital/dao/*Mapper.xml</value> |
| 80 | 80 | <value>classpath*:com/lyms/hospital/dao/*/*Mapper.xml</value> |
| 81 | + <value>classpath*:com/lyms/base/common/dao/*/*Mapper.xml</value> | |
| 81 | 82 | </list> |
| 82 | 83 | </property> |
| 83 | - <property name="typeAliasesPackage" value="com.lyms.hospital.entity" /> | |
| 84 | + <!-- <property name="typeAliasesPackage" value="com.lyms.base.common.entity" /> --> | |
| 85 | + <property name="typeAliasesPackage" value="com.lyms.base.common.entity" /> | |
| 84 | 86 | |
| 85 | 87 | <!-- MP 全局配置注入 --> |
| 86 | 88 | <property name="globalConfig" ref="globalConfig" /> |
| ... | ... | @@ -100,7 +102,7 @@ |
| 100 | 102 | |
| 101 | 103 | <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> |
| 102 | 104 | <!-- 可以指定多个包名 以逗号或分号分隔 --> |
| 103 | - <property name="basePackage" value="com.lyms.hospital.dao" /> | |
| 105 | + <property name="basePackage" value="com.lyms.hospital.dao,com.lyms.base.common.dao" /> | |
| 104 | 106 | <property name="annotationClass" value="org.springframework.stereotype.Repository" /> |
| 105 | 107 | </bean> |
| 106 | 108 | </beans> |
parent/hospital.web/src/test/java/test/hospital/BaseServiceTest.java
View file @
986be3b
| 1 | +package test.hospital; | |
| 2 | + | |
| 3 | +import org.junit.runner.RunWith; | |
| 4 | +import org.springframework.test.context.ContextConfiguration; | |
| 5 | +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | |
| 6 | +import org.springframework.test.context.web.WebAppConfiguration; | |
| 7 | + | |
| 8 | +@RunWith(SpringJUnit4ClassRunner.class) | |
| 9 | +@WebAppConfiguration | |
| 10 | +@ContextConfiguration(locations = { "classpath:app-context.xml" }) | |
| 11 | +public class BaseServiceTest { | |
| 12 | + | |
| 13 | +} |
parent/hospital.web/src/test/java/test/hospital/BaseTest.java
View file @
986be3b
| ... | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | |
| 19 | 19 | @RunWith(SpringJUnit4ClassRunner.class) |
| 20 | 20 | @WebAppConfiguration |
| 21 | -@ContextConfiguration(locations = { "classpath:app-context.xml", "classpath:xml/app-*.xml" | |
| 21 | +@ContextConfiguration(locations = { "classpath:app-context.xml", "classpath:dev/xml/app-*.xml" | |
| 22 | 22 | |
| 23 | 23 | // , |
| 24 | 24 | // "classpath:app-datasource.xml", |
| 25 | 25 | |
| 26 | 26 | |
| ... | ... | @@ -41,15 +41,14 @@ |
| 41 | 41 | session = new MockHttpSession(); |
| 42 | 42 | mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build(); |
| 43 | 43 | } |
| 44 | - | |
| 45 | - protected void outPrint(Object obj){ | |
| 44 | + | |
| 45 | + protected void outPrint(Object obj) { | |
| 46 | 46 | System.err.println(obj); |
| 47 | 47 | } |
| 48 | - | |
| 49 | - protected void outJson(Object obj){ | |
| 48 | + | |
| 49 | + protected void outJson(Object obj) { | |
| 50 | 50 | System.err.println(JSONObject.toJSONString(obj)); |
| 51 | 51 | } |
| 52 | - | |
| 53 | - | |
| 52 | + | |
| 54 | 53 | } |
parent/hospital.web/src/test/java/test/hospital/service/HighriskVersionTest.java
View file @
986be3b
| 1 | +package test.hospital.service; | |
| 2 | + | |
| 3 | +import java.util.List; | |
| 4 | + | |
| 5 | +import org.apache.commons.collections.CollectionUtils; | |
| 6 | +import org.apache.commons.lang3.builder.ToStringBuilder; | |
| 7 | +import org.junit.Assert; | |
| 8 | +import org.junit.Before; | |
| 9 | +import org.junit.Test; | |
| 10 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 11 | + | |
| 12 | +import com.lyms.base.common.entity.conf.HighriskConf; | |
| 13 | +import com.lyms.base.common.entity.conf.HighriskSource; | |
| 14 | +import com.lyms.base.common.entity.conf.HighriskVersion; | |
| 15 | +import com.lyms.base.common.service.conf.HighriskConfService; | |
| 16 | +import com.lyms.base.common.service.conf.HighriskSourceService; | |
| 17 | +import com.lyms.base.common.service.conf.HighriskVersionService; | |
| 18 | + | |
| 19 | +import test.hospital.BaseServiceTest; | |
| 20 | + | |
| 21 | +public class HighriskVersionTest extends BaseServiceTest { | |
| 22 | + | |
| 23 | + @Autowired | |
| 24 | + private HighriskVersionService highriskVersionService; | |
| 25 | + | |
| 26 | + @Autowired | |
| 27 | + private HighriskSourceService highriskSourceService; | |
| 28 | + | |
| 29 | + @Autowired | |
| 30 | + private HighriskConfService highriskConfService; | |
| 31 | + | |
| 32 | + private HighriskVersion version = null; | |
| 33 | + | |
| 34 | + @Before | |
| 35 | + public void init() { | |
| 36 | + version = new HighriskVersion(); | |
| 37 | + version.setName("center-1.0"); | |
| 38 | + } | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * <li>@Description: 启用 / 禁用版本号 | |
| 42 | + * <li> | |
| 43 | + * <li>创建人:maliang | |
| 44 | + * <li>创建时间:2017年3月29日 | |
| 45 | + * <li>修改人: | |
| 46 | + * <li>修改时间: | |
| 47 | + */ | |
| 48 | + @Test | |
| 49 | + public void enable() { | |
| 50 | + String id = "0EDDB06729CE48FF84CC6188231A6ECE"; | |
| 51 | + boolean tag = highriskVersionService.enable(id); | |
| 52 | + Assert.assertTrue(tag); | |
| 53 | + } | |
| 54 | + | |
| 55 | + /** | |
| 56 | + * | |
| 57 | + * <li>@Description:创建资源 | |
| 58 | + * <li>@return | |
| 59 | + * <li>创建人:maliang | |
| 60 | + * <li>创建时间:2017年3月29日 | |
| 61 | + * <li>修改人: | |
| 62 | + * <li>修改时间: | |
| 63 | + */ | |
| 64 | + public String createSource() { | |
| 65 | + HighriskSource source = new HighriskSource(); | |
| 66 | + source.setName("高危资源"); | |
| 67 | + source.setType("1"); | |
| 68 | + return highriskSourceService.createHighriskSource(source); | |
| 69 | + } | |
| 70 | + | |
| 71 | + /** | |
| 72 | + * <li>@Description:创建版本测试 | |
| 73 | + * <li> | |
| 74 | + * <li>创建人:maliang | |
| 75 | + * <li>创建时间:2017年3月29日 | |
| 76 | + * <li>修改人: | |
| 77 | + * <li>修改时间: | |
| 78 | + */ | |
| 79 | + public String createVersion() { | |
| 80 | + String id = highriskVersionService.createVersion(version); | |
| 81 | + return id; | |
| 82 | + } | |
| 83 | + | |
| 84 | + // @Transactional | |
| 85 | + @Test | |
| 86 | + public void createConfig() { | |
| 87 | + HighriskConf highriskConf = new HighriskConf(); | |
| 88 | + highriskConf.setSourceId(createSource()); | |
| 89 | + highriskConf.setVersionId(createVersion()); | |
| 90 | + highriskConf.setColorcode("ys001"); | |
| 91 | + highriskConf.setColortext("颜色编码1"); | |
| 92 | + highriskConf.setGrade(5D); | |
| 93 | + highriskConf.setGrouporder(1); | |
| 94 | + highriskConf.setName("颜色"); | |
| 95 | + highriskConf.setItemorder(1); | |
| 96 | + | |
| 97 | + highriskConfService.createHighriskConf(highriskConf); | |
| 98 | + } | |
| 99 | + | |
| 100 | + /** | |
| 101 | + * <li>@Description:根据source ID获取高危信息 | |
| 102 | + * <li> | |
| 103 | + * <li>创建人:maliang | |
| 104 | + * <li>创建时间:2017年3月29日 | |
| 105 | + * <li>修改人: | |
| 106 | + * <li>修改时间: | |
| 107 | + */ | |
| 108 | + @Test | |
| 109 | + public void getConfigBySourceId() { | |
| 110 | + String id = "0CFB58C5748247008D5C3421DDB753ED"; | |
| 111 | + List<HighriskConf> configs = highriskConfService.getHighriskConfBySourceId(id); | |
| 112 | + System.out.println(ToStringBuilder.reflectionToString(configs)); | |
| 113 | + this.print(configs); | |
| 114 | + } | |
| 115 | + | |
| 116 | + /** | |
| 117 | + * <li>@Description:根据version ID获取高危信息 | |
| 118 | + * <li> | |
| 119 | + * <li>创建人:maliang | |
| 120 | + * <li>创建时间:2017年3月29日 | |
| 121 | + * <li>修改人: | |
| 122 | + * <li>修改时间: | |
| 123 | + */ | |
| 124 | + @Test | |
| 125 | + public void getConfigByVersionId() { | |
| 126 | + String id = "71839AE8C94B4ACA9A694DD93338CD00"; | |
| 127 | + List<HighriskConf> configs = highriskConfService.getHighriskConfByVersionId(id); | |
| 128 | + this.print(configs); | |
| 129 | + } | |
| 130 | + | |
| 131 | + private void print(List<HighriskConf> configs) { | |
| 132 | + if (CollectionUtils.isEmpty(configs)) | |
| 133 | + return; | |
| 134 | + for (HighriskConf conf : configs) { | |
| 135 | + System.out.println(conf.getName()); | |
| 136 | + } | |
| 137 | + } | |
| 138 | + | |
| 139 | +} |
parent/hospital.web/src/test/java/test/hospital/service/package-info.java
View file @
986be3b
| 1 | +/** | |
| 2 | + * <li>@Title: package-info.java | |
| 3 | + * <li>@Package test.hospital.service | |
| 4 | + * <li>@Description: TODO(文件描述) | |
| 5 | + * <li>@author maliang | |
| 6 | + * <li>@date 2017年3月29日 | |
| 7 | + */ | |
| 8 | +/** | |
| 9 | + * <li>@ClassName: package-info | |
| 10 | + * <li>@Description: TODO(类描述) | |
| 11 | + * <li>@author maliang | |
| 12 | + * <li>@date 2017年3月29日 | |
| 13 | + * <li> | |
| 14 | + */ | |
| 15 | +package test.hospital.service; |