Commit bc6158299e15f11dd7293ef042c3a8cb85c26a94
1 parent
ceaa88f8c1
Exists in
master
and in
3 other branches
add data import :机构、部门、用户(医生)
Showing 7 changed files with 284 additions and 163 deletions
- platform-biz-service/src/main/java/com/lyms/platform/permission/model/UserRoleMaps.java
- platform-biz-service/src/main/java/com/lyms/platform/permission/model/Users.java
- platform-biz-service/src/main/resources/mainOrm/Roles.xml
- platform-common/src/main/java/com/lyms/platform/common/utils/LoginUtil.java
- platform-data-api/src/main/java/com/lyms/platform/data/controller/TaskController.java
- platform-data-api/src/main/java/com/lyms/platform/data/service/impl/DataImportTaskServiceImpl.java
- platform-data-api/src/main/resources/database.properties
platform-biz-service/src/main/java/com/lyms/platform/permission/model/UserRoleMaps.java
View file @
bc61582
| ... | ... | @@ -2,56 +2,56 @@ |
| 2 | 2 | |
| 3 | 3 | import java.util.Date; |
| 4 | 4 | |
| 5 | -public class UserRoleMaps {private Integer id;private Integer userId;private Integer roleId;private Integer yn;private Date expirTime; | |
| 5 | +public class UserRoleMaps { | |
| 6 | + private Integer id; | |
| 7 | + private Integer userId; | |
| 8 | + private Integer roleId; | |
| 9 | + private Integer yn; | |
| 10 | + private Date expirTime; | |
| 6 | 11 | |
| 7 | -public Integer getId() { | |
| 12 | + public Integer getId() { | |
| 8 | 13 | return id; |
| 9 | 14 | } |
| 10 | 15 | |
| 11 | 16 | |
| 12 | - | |
| 13 | 17 | public void setId(Integer id) { |
| 14 | 18 | this.id = id; |
| 15 | 19 | |
| 16 | 20 | } |
| 17 | 21 | |
| 18 | -public Integer getUserId() { | |
| 22 | + public Integer getUserId() { | |
| 19 | 23 | return userId; |
| 20 | 24 | } |
| 21 | 25 | |
| 22 | 26 | |
| 23 | - | |
| 24 | 27 | public void setUserId(Integer userId) { |
| 25 | 28 | this.userId = userId; |
| 26 | 29 | |
| 27 | 30 | } |
| 28 | 31 | |
| 29 | -public Integer getRoleId() { | |
| 32 | + public Integer getRoleId() { | |
| 30 | 33 | return roleId; |
| 31 | 34 | } |
| 32 | 35 | |
| 33 | 36 | |
| 34 | - | |
| 35 | 37 | public void setRoleId(Integer roleId) { |
| 36 | 38 | this.roleId = roleId; |
| 37 | 39 | |
| 38 | 40 | } |
| 39 | 41 | |
| 40 | -public Integer getYn() { | |
| 42 | + public Integer getYn() { | |
| 41 | 43 | return yn; |
| 42 | 44 | } |
| 43 | 45 | |
| 44 | 46 | |
| 45 | - | |
| 46 | 47 | public void setYn(Integer yn) { |
| 47 | 48 | this.yn = yn; |
| 48 | 49 | |
| 49 | 50 | } |
| 50 | 51 | |
| 51 | -public Date getExpirtime() { | |
| 52 | + public Date getExpirtime() { | |
| 52 | 53 | return expirTime; |
| 53 | 54 | } |
| 54 | - | |
| 55 | 55 | |
| 56 | 56 | |
| 57 | 57 | public void setExpirtime(Date expirTime) { |
platform-biz-service/src/main/java/com/lyms/platform/permission/model/Users.java
View file @
bc61582
| ... | ... | @@ -29,6 +29,16 @@ |
| 29 | 29 | private Organization organization; |
| 30 | 30 | private String foreignId; |
| 31 | 31 | |
| 32 | + private String roleStr; | |
| 33 | + | |
| 34 | + public String getRoleStr() { | |
| 35 | + return roleStr; | |
| 36 | + } | |
| 37 | + | |
| 38 | + public void setRoleStr(String roleStr) { | |
| 39 | + this.roleStr = roleStr; | |
| 40 | + } | |
| 41 | + | |
| 32 | 42 | public String getForeignId() { |
| 33 | 43 | return foreignId; |
| 34 | 44 | } |
platform-biz-service/src/main/resources/mainOrm/Roles.xml
View file @
bc61582
| ... | ... | @@ -2,148 +2,144 @@ |
| 2 | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
| 3 | 3 | <mapper namespace="com.lyms.platform.permission.dao.RolesMapper"> |
| 4 | 4 | |
| 5 | -<resultMap id="RolesResultMap" type="com.lyms.platform.permission.model.Roles"> | |
| 6 | -<id column="id" property="id" jdbcType="INTEGER" /> | |
| 7 | -<result column="type" property="type" jdbcType="INTEGER" /> | |
| 8 | -<result column="name" property="name" jdbcType="VARCHAR" /> | |
| 9 | -<result column="publish_id" property="publishId" jdbcType="INTEGER" /> | |
| 10 | -<result column="publish_name" property="publishName" jdbcType="VARCHAR" /> | |
| 11 | -<result column="yn" property="yn" jdbcType="INTEGER" /> | |
| 12 | -<result column="enable" property="enable" jdbcType="INTEGER" /> | |
| 13 | -<result column="modified" property="modified" jdbcType="TIMESTAMP" /> | |
| 14 | -<result column="created" property="created" jdbcType="TIMESTAMP" /> | |
| 15 | -<result column="remarks" property="remarks" jdbcType="VARCHAR" /> | |
| 16 | -<result column="shortCode" property="shortCode" jdbcType="VARCHAR" /> | |
| 17 | -</resultMap> | |
| 5 | + <resultMap id="RolesResultMap" type="com.lyms.platform.permission.model.Roles"> | |
| 6 | + <id column="id" property="id" jdbcType="INTEGER"/> | |
| 7 | + <result column="type" property="type" jdbcType="INTEGER"/> | |
| 8 | + <result column="name" property="name" jdbcType="VARCHAR"/> | |
| 9 | + <result column="publish_id" property="publishId" jdbcType="INTEGER"/> | |
| 10 | + <result column="publish_name" property="publishName" jdbcType="VARCHAR"/> | |
| 11 | + <result column="yn" property="yn" jdbcType="INTEGER"/> | |
| 12 | + <result column="enable" property="enable" jdbcType="INTEGER"/> | |
| 13 | + <result column="modified" property="modified" jdbcType="TIMESTAMP"/> | |
| 14 | + <result column="created" property="created" jdbcType="TIMESTAMP"/> | |
| 15 | + <result column="remarks" property="remarks" jdbcType="VARCHAR"/> | |
| 16 | + <result column="shortCode" property="shortCode" jdbcType="VARCHAR"/> | |
| 17 | + </resultMap> | |
| 18 | 18 | |
| 19 | 19 | |
| 20 | - | |
| 21 | -<insert id="addRoles" parameterType="com.lyms.platform.permission.model.Roles"> | |
| 20 | + <insert id="addRoles" parameterType="com.lyms.platform.permission.model.Roles"> | |
| 21 | + <selectKey order="AFTER" keyProperty="id" resultType="java.lang.Integer"> SELECT LAST_INSERT_ID() </selectKey> | |
| 22 | 22 | insert into roles (type,name,publish_id,publish_name,yn,enable,modified,created,remarks,shortCode) values (#{type},#{name},#{publishId},#{publishName},#{yn},#{enable},#{modified},#{created},#{remarks},#{shortCode}) |
| 23 | 23 | </insert> |
| 24 | 24 | |
| 25 | 25 | |
| 26 | + <update id="updateRoles" parameterType="com.lyms.platform.permission.model.Roles"> | |
| 27 | + update roles | |
| 28 | + <set> | |
| 29 | + <if test="type != null and type >= 0"> | |
| 30 | + type = #{type,jdbcType=INTEGER}, | |
| 31 | + </if> | |
| 32 | + <if test="name != null and name != ''"> | |
| 33 | + name = #{name,jdbcType=VARCHAR}, | |
| 34 | + </if> | |
| 35 | + <if test="publishId != null and publishId >= 0"> | |
| 36 | + publish_id = #{publishId,jdbcType=INTEGER}, | |
| 37 | + </if> | |
| 38 | + <if test="permissiontype != null and permissiontype >= 0"> | |
| 39 | + permissiontype = #{permissiontype,jdbcType=INTEGER}, | |
| 40 | + </if> | |
| 41 | + <if test="publishName != null and publishName != ''"> | |
| 42 | + publish_name = #{publishName,jdbcType=VARCHAR}, | |
| 43 | + </if> | |
| 44 | + <if test="yn != null and yn >= 0"> | |
| 45 | + yn = #{yn,jdbcType=INTEGER}, | |
| 46 | + </if> | |
| 47 | + <if test="enable != null and enable >= 0"> | |
| 48 | + enable = #{enable,jdbcType=INTEGER}, | |
| 49 | + </if> | |
| 50 | + <if test="modified != null"> | |
| 51 | + modified = #{modified,jdbcType=TIMESTAMP}, | |
| 52 | + </if> | |
| 53 | + <if test="created != null"> | |
| 54 | + created = #{created,jdbcType=TIMESTAMP}, | |
| 55 | + </if> | |
| 56 | + <if test="remarks != null and remarks != ''"> | |
| 57 | + remarks = #{remarks,jdbcType=VARCHAR}, | |
| 58 | + </if> | |
| 59 | + <if test="shortCode != null and shortCode != ''"> | |
| 60 | + shortCode = #{shortCode,jdbcType=VARCHAR}, | |
| 61 | + </if> | |
| 62 | + </set> | |
| 63 | + where id = #{id,jdbcType=INTEGER} | |
| 64 | + </update> | |
| 26 | 65 | |
| 27 | -<update id="updateRoles" parameterType="com.lyms.platform.permission.model.Roles"> | |
| 28 | -update roles <set><if test="type != null and type >= 0"> | |
| 29 | -type = #{type,jdbcType=INTEGER}, | |
| 30 | -</if> | |
| 31 | -<if test="name != null and name != ''"> | |
| 32 | -name = #{name,jdbcType=VARCHAR}, | |
| 33 | -</if> | |
| 34 | -<if test="publishId != null and publishId >= 0"> | |
| 35 | -publish_id = #{publishId,jdbcType=INTEGER}, | |
| 36 | -</if> | |
| 37 | -<if test="permissiontype != null and permissiontype >= 0"> | |
| 38 | - permissiontype = #{permissiontype,jdbcType=INTEGER}, | |
| 39 | -</if> | |
| 40 | -<if test="publishName != null and publishName != ''"> | |
| 41 | -publish_name = #{publishName,jdbcType=VARCHAR}, | |
| 42 | -</if> | |
| 43 | -<if test="yn != null and yn >= 0"> | |
| 44 | -yn = #{yn,jdbcType=INTEGER}, | |
| 45 | -</if> | |
| 46 | -<if test="enable != null and enable >= 0"> | |
| 47 | -enable = #{enable,jdbcType=INTEGER}, | |
| 48 | -</if> | |
| 49 | -<if test="modified != null"> | |
| 50 | -modified = #{modified,jdbcType=TIMESTAMP}, | |
| 51 | -</if> | |
| 52 | -<if test="created != null"> | |
| 53 | -created = #{created,jdbcType=TIMESTAMP}, | |
| 54 | -</if> | |
| 55 | -<if test="remarks != null and remarks != ''"> | |
| 56 | -remarks = #{remarks,jdbcType=VARCHAR}, | |
| 57 | -</if> | |
| 58 | -<if test="shortCode != null and shortCode != ''"> | |
| 59 | -shortCode = #{shortCode,jdbcType=VARCHAR}, | |
| 60 | -</if> | |
| 61 | -</set> | |
| 62 | -where id = #{id,jdbcType=INTEGER} | |
| 63 | -</update> | |
| 64 | 66 | |
| 65 | - | |
| 66 | -<delete id="deleteRoles" parameterType="java.lang.Integer"> | |
| 67 | + <delete id="deleteRoles" parameterType="java.lang.Integer"> | |
| 67 | 68 | delete from roles where id = #{id,jdbcType=INTEGER} |
| 68 | 69 | </delete> |
| 69 | 70 | |
| 70 | 71 | |
| 71 | - | |
| 72 | -<select id="getRoles" resultMap="RolesResultMap" parameterType="java.lang.Integer"> | |
| 72 | + <select id="getRoles" resultMap="RolesResultMap" parameterType="java.lang.Integer"> | |
| 73 | 73 | select id,type,name,publish_id,publish_name,yn,enable,modified,created,remarks,shortCode |
| 74 | 74 | from roles where id = #{id,jdbcType=INTEGER} |
| 75 | 75 | </select> |
| 76 | 76 | |
| 77 | 77 | |
| 78 | -<sql id="orderAndLimit"> | |
| 79 | -<if test="sort != null and sort != '' "> | |
| 80 | -order by ${sort} | |
| 81 | -<if test="need != null"> | |
| 82 | -limit #{offset, jdbcType=INTEGER} , #{limit, jdbcType=INTEGER} | |
| 83 | -</if> | |
| 84 | -</if> | |
| 85 | -</sql> | |
| 78 | + <sql id="orderAndLimit"> | |
| 79 | + <if test="sort != null and sort != '' "> | |
| 80 | + order by ${sort} | |
| 81 | + <if test="need != null"> | |
| 82 | + limit #{offset, jdbcType=INTEGER} , #{limit, jdbcType=INTEGER} | |
| 83 | + </if> | |
| 84 | + </if> | |
| 85 | + </sql> | |
| 86 | 86 | |
| 87 | 87 | |
| 88 | + <sql id="RolesCondition"> | |
| 89 | + <where> | |
| 90 | + 1 = 1 | |
| 91 | + <if test="id != null and id >= 0"> | |
| 92 | + and id = #{id,jdbcType=INTEGER} | |
| 93 | + </if> | |
| 94 | + <if test="type != null and type >= 0"> | |
| 95 | + and type = #{type,jdbcType=INTEGER} | |
| 96 | + </if> | |
| 97 | + <if test="name != null and name != ''"> | |
| 98 | + and name = #{name,jdbcType=VARCHAR} | |
| 99 | + </if> | |
| 100 | + <if test="publishId != null and publishId >= 0"> | |
| 101 | + and publish_id = #{publishId,jdbcType=INTEGER} | |
| 102 | + </if> | |
| 103 | + <if test="publishName != null and publishName != ''"> | |
| 104 | + and publish_name = #{publishName,jdbcType=VARCHAR} | |
| 105 | + </if> | |
| 106 | + <if test="yn != null and yn >= 0"> | |
| 107 | + and yn = #{yn,jdbcType=INTEGER} | |
| 108 | + </if> | |
| 109 | + <if test="enable != null and enable >= 0"> | |
| 110 | + and enable = #{enable,jdbcType=INTEGER} | |
| 111 | + </if> | |
| 112 | + <if test="modified != null"> | |
| 113 | + and modified = #{modified,jdbcType=TIMESTAMP} | |
| 114 | + </if> | |
| 115 | + <if test="created != null"> | |
| 116 | + and created = #{created,jdbcType=TIMESTAMP} | |
| 117 | + </if> | |
| 118 | + <if test="remarks != null and remarks != ''"> | |
| 119 | + and remarks = #{remarks,jdbcType=VARCHAR} | |
| 120 | + </if> | |
| 121 | + <if test="shortCode != null and shortCode != ''"> | |
| 122 | + and shortCode = #{shortCode,jdbcType=VARCHAR} | |
| 123 | + </if> | |
| 124 | + <if test="keyword != null and keyword != ''"> | |
| 125 | + and name like CONCAT(#{keyword}, '%') | |
| 126 | + </if> | |
| 127 | + </where> | |
| 128 | + </sql> | |
| 88 | 129 | |
| 89 | -<sql id="RolesCondition"> | |
| 90 | -<where> | |
| 91 | - 1 = 1 | |
| 92 | -<if test="id != null and id >= 0"> | |
| 93 | -and id = #{id,jdbcType=INTEGER} | |
| 94 | -</if> | |
| 95 | -<if test="type != null and type >= 0"> | |
| 96 | -and type = #{type,jdbcType=INTEGER} | |
| 97 | -</if> | |
| 98 | -<if test="name != null and name != ''"> | |
| 99 | -and name = #{name,jdbcType=VARCHAR} | |
| 100 | -</if> | |
| 101 | -<if test="publishId != null and publishId >= 0"> | |
| 102 | -and publish_id = #{publishId,jdbcType=INTEGER} | |
| 103 | -</if> | |
| 104 | -<if test="publishName != null and publishName != ''"> | |
| 105 | -and publish_name = #{publishName,jdbcType=VARCHAR} | |
| 106 | -</if> | |
| 107 | -<if test="yn != null and yn >= 0"> | |
| 108 | -and yn = #{yn,jdbcType=INTEGER} | |
| 109 | -</if> | |
| 110 | -<if test="enable != null and enable >= 0"> | |
| 111 | -and enable = #{enable,jdbcType=INTEGER} | |
| 112 | -</if> | |
| 113 | -<if test="modified != null"> | |
| 114 | -and modified = #{modified,jdbcType=TIMESTAMP} | |
| 115 | -</if> | |
| 116 | -<if test="created != null"> | |
| 117 | -and created = #{created,jdbcType=TIMESTAMP} | |
| 118 | -</if> | |
| 119 | -<if test="remarks != null and remarks != ''"> | |
| 120 | -and remarks = #{remarks,jdbcType=VARCHAR} | |
| 121 | -</if> | |
| 122 | -<if test="shortCode != null and shortCode != ''"> | |
| 123 | -and shortCode = #{shortCode,jdbcType=VARCHAR} | |
| 124 | -</if> | |
| 125 | - <if test="keyword != null and keyword != ''"> | |
| 126 | - and name like CONCAT(#{keyword}, '%') | |
| 127 | - </if> | |
| 128 | -</where> | |
| 129 | -</sql> | |
| 130 | 130 | |
| 131 | + <select id="queryRoles" resultMap="RolesResultMap" parameterType="com.lyms.platform.permission.model.RolesQuery"> | |
| 132 | + select id,type,name,publish_id,publish_name,yn,enable,modified,created,remarks,shortCode,permissiontype | |
| 133 | + from roles | |
| 134 | + <include refid="RolesCondition"/> | |
| 135 | + <include refid="orderAndLimit"/> | |
| 136 | + </select> | |
| 131 | 137 | |
| 132 | 138 | |
| 133 | -<select id="queryRoles" resultMap="RolesResultMap" parameterType="com.lyms.platform.permission.model.RolesQuery"> | |
| 134 | -select id,type,name,publish_id,publish_name,yn,enable,modified,created,remarks,shortCode,permissiontype | |
| 135 | - from roles | |
| 136 | -<include refid="RolesCondition" /> | |
| 137 | -<include refid="orderAndLimit" /> | |
| 138 | -</select> | |
| 139 | - | |
| 140 | - | |
| 141 | - | |
| 142 | -<select id="queryRolesCount" resultType="int" parameterType="com.lyms.platform.permission.model.RolesQuery"> | |
| 143 | -select count(1) from roles | |
| 144 | -<include refid="RolesCondition" /> | |
| 145 | -</select> | |
| 146 | - | |
| 139 | + <select id="queryRolesCount" resultType="int" parameterType="com.lyms.platform.permission.model.RolesQuery"> | |
| 140 | + select count(1) from roles | |
| 141 | + <include refid="RolesCondition"/> | |
| 142 | + </select> | |
| 147 | 143 | |
| 148 | 144 | |
| 149 | 145 | </mapper> |
platform-common/src/main/java/com/lyms/platform/common/utils/LoginUtil.java
View file @
bc61582
| ... | ... | @@ -35,6 +35,61 @@ |
| 35 | 35 | return null; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | + public static Integer aouHospitalUser(String account, String pwd, String typeId, String token) { | |
| 39 | + HttpClient client = new HttpClient(); | |
| 40 | + PostMethod post = new MessageUtil.UTF8PostMethod("http://passport.healthbaby.com.cn/v1/checkUser.action"); | |
| 41 | + NameValuePair[] data = { | |
| 42 | + new NameValuePair("account", account), | |
| 43 | + new NameValuePair("pwd", pwd), | |
| 44 | + new NameValuePair("typeId", typeId) | |
| 45 | + }; | |
| 46 | + post.setRequestBody(data); | |
| 47 | + post.setRequestHeader("Authorization", token); | |
| 48 | + try { | |
| 49 | + client.executeMethod(post); | |
| 50 | + int statusCode = post.getStatusCode(); | |
| 51 | + String result = new String(post.getResponseBodyAsString()); | |
| 52 | + | |
| 53 | + post.releaseConnection(); | |
| 54 | + if(200 == statusCode) { | |
| 55 | + LoginContext loginState = JsonUtil.str2Obj(result, LoginContext.class); | |
| 56 | + if(0 == loginState.getErrorcode()) { | |
| 57 | + return loginState.getId(); | |
| 58 | + } | |
| 59 | + } | |
| 60 | + } catch (Exception e) { | |
| 61 | + e.printStackTrace(); | |
| 62 | + } | |
| 63 | + return null; | |
| 64 | + } | |
| 65 | + | |
| 66 | + public static String loginHospitalUser(String phone, String pwd, String typeId, String token) { | |
| 67 | + HttpClient client = new HttpClient(); | |
| 68 | + PostMethod post = new MessageUtil.UTF8PostMethod("http://passport.healthbaby.com.cn/v1/userLogin.action"); | |
| 69 | + NameValuePair[] data = { | |
| 70 | + new NameValuePair("phone", phone), | |
| 71 | + new NameValuePair("typeId", typeId), | |
| 72 | + new NameValuePair("password", pwd) | |
| 73 | + }; | |
| 74 | + post.setRequestBody(data); | |
| 75 | + post.setRequestHeader("Authorization", token); | |
| 76 | + try { | |
| 77 | + client.executeMethod(post); | |
| 78 | + int statusCode = post.getStatusCode(); | |
| 79 | + String result = new String(post.getResponseBodyAsString()); | |
| 80 | + | |
| 81 | + post.releaseConnection(); | |
| 82 | + if(200 == statusCode) { | |
| 83 | + LoginContext loginState = JsonUtil.str2Obj(result, LoginContext.class); | |
| 84 | + if(0 == loginState.getErrorcode()) { | |
| 85 | + return loginState.getToken(); | |
| 86 | + } | |
| 87 | + } | |
| 88 | + } catch (Exception e) { | |
| 89 | + e.printStackTrace(); | |
| 90 | + } | |
| 91 | + return null; | |
| 92 | + } | |
| 38 | 93 | |
| 39 | 94 | public static String login(String phone, String varCode, String typeId, String token) { |
| 40 | 95 | HttpClient client = new HttpClient(); |
platform-data-api/src/main/java/com/lyms/platform/data/controller/TaskController.java
View file @
bc61582
| ... | ... | @@ -59,7 +59,7 @@ |
| 59 | 59 | } else if ("fullUpdateUsers".equals(sid)) { |
| 60 | 60 | dataImportTaskService.fullUpdateUsers(); |
| 61 | 61 | writeString(response, "success"); |
| 62 | - } else if ("codeinit".equals(sid)) { | |
| 62 | + } else if ("codeinit111".equals(sid)) { | |
| 63 | 63 | try { |
| 64 | 64 | List<String> list = FileUtils.readLines(new File("d:/streets.csv")); |
| 65 | 65 | Map<String, String> codeMap = new HashMap<>(); |
platform-data-api/src/main/java/com/lyms/platform/data/service/impl/DataImportTaskServiceImpl.java
View file @
bc61582
| 1 | 1 | package com.lyms.platform.data.service.impl; |
| 2 | 2 | |
| 3 | 3 | import com.lyms.platform.biz.service.BasicConfigService; |
| 4 | +import com.lyms.platform.common.enums.PermissionTypeEnums; | |
| 4 | 5 | import com.lyms.platform.common.enums.YnEnums; |
| 5 | 6 | import com.lyms.platform.common.utils.JsonUtil; |
| 6 | 7 | import com.lyms.platform.common.utils.LogUtil; |
| 8 | +import com.lyms.platform.common.utils.LoginUtil; | |
| 7 | 9 | import com.lyms.platform.data.service.DataImportTaskService; |
| 8 | 10 | import com.lyms.platform.permission.model.*; |
| 9 | -import com.lyms.platform.permission.service.DepartmentsService; | |
| 10 | -import com.lyms.platform.permission.service.OrganizationService; | |
| 11 | -import com.lyms.platform.permission.service.UsersService; | |
| 11 | +import com.lyms.platform.permission.service.*; | |
| 12 | 12 | import com.lyms.platform.pojo.BasicConfig; |
| 13 | 13 | import com.lymsh.mommybaby.earlydata.dao.PlatMapper; |
| 14 | 14 | import com.lymsh.mommybaby.earlydata.model.PlatDataContent; |
| 15 | 15 | import org.apache.commons.lang.StringUtils; |
| 16 | 16 | import org.joda.time.DateTime; |
| 17 | 17 | import org.springframework.beans.factory.annotation.Autowired; |
| 18 | +import org.springframework.beans.factory.annotation.Value; | |
| 18 | 19 | import org.springframework.stereotype.Service; |
| 19 | 20 | |
| 20 | 21 | import java.math.BigDecimal; |
| 21 | -import java.util.Date; | |
| 22 | -import java.util.HashMap; | |
| 23 | -import java.util.List; | |
| 24 | -import java.util.Map; | |
| 22 | +import java.util.*; | |
| 25 | 23 | |
| 26 | 24 | /** |
| 27 | 25 | * Created by Administrator on 2016/4/30 0030. |
| 28 | 26 | |
| ... | ... | @@ -42,8 +40,20 @@ |
| 42 | 40 | private BasicConfigService basicConfigService; |
| 43 | 41 | |
| 44 | 42 | @Autowired |
| 43 | + private RolesService rolesService; | |
| 44 | + | |
| 45 | + @Autowired | |
| 46 | + private UserRoleMapsService userRoleMapsService; | |
| 47 | + | |
| 48 | + @Autowired | |
| 45 | 49 | private PlatMapper platMapper; |
| 46 | 50 | |
| 51 | + | |
| 52 | + @Value("#{configProperties['login.token']}") | |
| 53 | + private String token; | |
| 54 | + @Value("#{configProperties['login.typeId']}") | |
| 55 | + private String typeId; | |
| 56 | + | |
| 47 | 57 | public Integer getInteger(Object obj) { |
| 48 | 58 | if (obj == null) { |
| 49 | 59 | return null; |
| ... | ... | @@ -70,7 +80,7 @@ |
| 70 | 80 | |
| 71 | 81 | @Override |
| 72 | 82 | public void fullUpdateUsers() { |
| 73 | - updateUsersByHospital(null,null,null); | |
| 83 | + updateUsersByHospital(null, null, null); | |
| 74 | 84 | } |
| 75 | 85 | |
| 76 | 86 | @Override |
| 77 | 87 | |
| 78 | 88 | |
| ... | ... | @@ -78,18 +88,24 @@ |
| 78 | 88 | try { |
| 79 | 89 | List<Map> list = platMapper.selectAllUserByHospitalId(hospitalForeignId, startTime); |
| 80 | 90 | if (list != null && list.size() > 0) { |
| 91 | + Map<String, Roles> rolesMap = new HashMap<>(); | |
| 92 | + List<Roles> rolesList = rolesService.queryRoles(new RolesQuery()); | |
| 93 | + for (Roles roles : rolesList) { | |
| 94 | + rolesMap.put(roles.getName(), roles); | |
| 95 | + } | |
| 96 | + | |
| 81 | 97 | Map<String, Organization> organizationMap = new HashMap<>(); |
| 82 | 98 | Organization organization = new Organization(); |
| 83 | 99 | Departments departments = new Departments(); |
| 84 | 100 | Users users = new Users(); |
| 85 | - for (Map map:list) { | |
| 101 | + for (Map map : list) { | |
| 86 | 102 | try { |
| 87 | 103 | // organization |
| 88 | 104 | if (StringUtils.isBlank(organization.getForeignId()) || !map.get("H_ID").equals(organization.getForeignId())) { |
| 89 | 105 | if (!organizationMap.containsKey(map.get("H_ID").toString())) { |
| 90 | 106 | organization = new Organization(); |
| 91 | 107 | organization.setForeignId(map.get("H_ID").toString()); |
| 92 | - organizationMap.put(organization.getForeignId(),organization); | |
| 108 | + organizationMap.put(organization.getForeignId(), organization); | |
| 93 | 109 | } |
| 94 | 110 | organization.setYn(YnEnums.YES.getId()); |
| 95 | 111 | organization.setName(map.get("H_NAME").toString()); |
| 96 | 112 | |
| ... | ... | @@ -140,10 +156,10 @@ |
| 140 | 156 | users.setEnable(2); |
| 141 | 157 | } |
| 142 | 158 | users.setKsId(departments.getId()); |
| 143 | - | |
| 159 | + users.setRoleStr(map.get("UR_ROLEIDS") == null ? null : map.get("UR_ROLEIDS").toString()); | |
| 160 | + users.setPwd(map.get("U_USERPWD") == null ? null : map.get("U_USERPWD").toString()); | |
| 144 | 161 | //TODO 手机号,权限 对应中间表 |
| 145 | 162 | // users.setPhone(""); |
| 146 | -// String roles = map.get("UR_ROLEIDS")==null?null:map.get("UR_ROLEIDS").toString(); | |
| 147 | 163 | } |
| 148 | 164 | |
| 149 | 165 | |
| 150 | 166 | |
| 151 | 167 | |
| ... | ... | @@ -153,15 +169,19 @@ |
| 153 | 169 | } |
| 154 | 170 | |
| 155 | 171 | // save |
| 172 | + UserRoleMapsQuery userRoleMapsQuery = new UserRoleMapsQuery(); | |
| 173 | + userRoleMapsQuery.setYn(YnEnums.YES.getId()); | |
| 174 | + UserRoleMaps userRoleMaps = new UserRoleMaps(); | |
| 175 | + userRoleMaps.setYn(YnEnums.YES.getId()); | |
| 156 | 176 | OrganizationQuery organizationQuery = new OrganizationQuery(); |
| 157 | 177 | DepartmentsQuery departmentsQuery = new DepartmentsQuery(); |
| 158 | 178 | UsersQuery usersQuery = new UsersQuery(); |
| 159 | - for (Organization o:organizationMap.values()) { | |
| 179 | + for (Organization o : organizationMap.values()) { | |
| 160 | 180 | try { |
| 161 | 181 | organizationQuery.setForeignId(o.getForeignId()); |
| 162 | 182 | List<Organization> organizationList = organizationService.queryOrganization(organizationQuery); |
| 163 | 183 | if (organizationList != null && organizationList.size() > 0) { |
| 164 | - for (Organization odb:organizationList) { | |
| 184 | + for (Organization odb : organizationList) { | |
| 165 | 185 | o.setId(odb.getId()); |
| 166 | 186 | organizationService.updateOrganization(o); |
| 167 | 187 | } |
| 168 | 188 | |
| ... | ... | @@ -169,12 +189,12 @@ |
| 169 | 189 | o.setCreated(o.getModified()); |
| 170 | 190 | organizationService.addOrganization(o); |
| 171 | 191 | } |
| 172 | - for (Departments d:o.getDepartmentsMap().values()) { | |
| 192 | + for (Departments d : o.getDepartmentsMap().values()) { | |
| 173 | 193 | d.setOrgId(o.getId()); |
| 174 | 194 | departmentsQuery.setForeignId(d.getForeignId()); |
| 175 | 195 | List<Departments> departmentsList = departmentsService.queryDepartments(departmentsQuery); |
| 176 | 196 | if (departmentsList != null && departmentsList.size() > 0) { |
| 177 | - for (Departments dd:departmentsList) { | |
| 197 | + for (Departments dd : departmentsList) { | |
| 178 | 198 | d.setId(dd.getId()); |
| 179 | 199 | departmentsService.updateDepartments(d); |
| 180 | 200 | } |
| 181 | 201 | |
| 182 | 202 | |
| ... | ... | @@ -182,14 +202,15 @@ |
| 182 | 202 | d.setCreated(d.getModified()); |
| 183 | 203 | departmentsService.addDepartments(d); |
| 184 | 204 | } |
| 185 | - for (Users u:d.getUsersMap().values()) { | |
| 205 | + for (Users u : d.getUsersMap().values()) { | |
| 186 | 206 | u.setOrgId(o.getId()); |
| 187 | 207 | u.setDeptId(d.getId()); |
| 188 | 208 | u.setKsId(d.getId()); |
| 209 | + u.setLogincenterId(LoginUtil.aouHospitalUser(u.getAccount(), u.getPwd(), typeId, token)); | |
| 189 | 210 | usersQuery.setForeignId(u.getForeignId()); |
| 190 | 211 | List<Users> usersList = usersService.queryUsers(usersQuery); |
| 191 | 212 | if (usersList != null && usersList.size() > 0) { |
| 192 | - for (Users du:usersList) { | |
| 213 | + for (Users du : usersList) { | |
| 193 | 214 | u.setId(du.getId()); |
| 194 | 215 | usersService.updateUsers(u); |
| 195 | 216 | } |
| ... | ... | @@ -197,6 +218,42 @@ |
| 197 | 218 | u.setCreated(u.getModified()); |
| 198 | 219 | usersService.addUsers(u); |
| 199 | 220 | } |
| 221 | + if (StringUtils.isNotBlank(u.getRoleStr())) { | |
| 222 | + String[] array = u.getRoleStr().split(","); | |
| 223 | + for (String a : array) { | |
| 224 | + Integer roleId = null; | |
| 225 | + if (rolesMap.containsKey(a)) { | |
| 226 | + roleId = rolesMap.get(a).getId(); | |
| 227 | + } else { | |
| 228 | + Roles roles = new Roles(); | |
| 229 | + roles.setYn(YnEnums.YES.getId()); | |
| 230 | + roles.setEnable(YnEnums.YES.getId()); | |
| 231 | + roles.setCreated(new Date()); | |
| 232 | + roles.setModified(roles.getCreated()); | |
| 233 | + roles.setName(a); | |
| 234 | + roles.setPublishId(0); | |
| 235 | + roles.setPublishName("system"); | |
| 236 | + roles.setType(2); | |
| 237 | + if (a.contains("管理员") || a.contains("管理") || a.contains("院长") || a.contains("客服") || a.contains("财务")) { | |
| 238 | + roles.setPermissiontype(PermissionTypeEnums.ALL_HOSPITAL.getId()); | |
| 239 | + } else if (a.contains("主任") || a.contains("护士长")) { | |
| 240 | + roles.setPermissiontype(PermissionTypeEnums.ALL_DEPARTMENT.getId()); | |
| 241 | + } else { | |
| 242 | + roles.setPermissiontype(PermissionTypeEnums.ONLY_SELF.getId()); | |
| 243 | + } | |
| 244 | + rolesService.addRoles(roles); | |
| 245 | + rolesMap.put(roles.getName(), roles); | |
| 246 | + roleId = roles.getId(); | |
| 247 | + } | |
| 248 | + userRoleMapsQuery.setRoleId(roleId); | |
| 249 | + userRoleMapsQuery.setUserId(u.getId()); | |
| 250 | + if (userRoleMapsService.queryUserRoleMapsCount(userRoleMapsQuery) == 0) { | |
| 251 | + userRoleMaps.setRoleId(userRoleMapsQuery.getRoleId()); | |
| 252 | + userRoleMaps.setUserId(u.getId()); | |
| 253 | + userRoleMapsService.addUserRoleMaps(userRoleMaps); | |
| 254 | + } | |
| 255 | + } | |
| 256 | + } | |
| 200 | 257 | } |
| 201 | 258 | } |
| 202 | 259 | |
| ... | ... | @@ -205,7 +262,7 @@ |
| 205 | 262 | } |
| 206 | 263 | } |
| 207 | 264 | } else { |
| 208 | - LogUtil.taskInfo("hospitalId:"+hospitalForeignId+" has no data!"); | |
| 265 | + LogUtil.taskInfo("hospitalId:" + hospitalForeignId + " has no data!"); | |
| 209 | 266 | } |
| 210 | 267 | } catch (Exception e) { |
| 211 | 268 | e.printStackTrace(); |
| ... | ... | @@ -218,7 +275,7 @@ |
| 218 | 275 | public void updateBasicConfig() { |
| 219 | 276 | try { |
| 220 | 277 | List<PlatDataContent> list = platMapper.selectPlatDataContent(); |
| 221 | - for (PlatDataContent data:list) { | |
| 278 | + for (PlatDataContent data : list) { | |
| 222 | 279 | try { |
| 223 | 280 | if (StringUtils.isBlank(data.getDcId())) { |
| 224 | 281 | continue; |