diff --git a/platform-biz-service/src/main/java/com/lyms/platform/permission/model/Departments.java b/platform-biz-service/src/main/java/com/lyms/platform/permission/model/Departments.java index d7abdfd..816bc2e 100644 --- a/platform-biz-service/src/main/java/com/lyms/platform/permission/model/Departments.java +++ b/platform-biz-service/src/main/java/com/lyms/platform/permission/model/Departments.java @@ -1,6 +1,9 @@ package com.lyms.platform.permission.model; import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; public class Departments { private Integer id; @@ -15,6 +18,25 @@ public class Departments { private Date created; private Integer type; private String shortCode; + private String foreignId; + + Map usersMap = new HashMap<>(); + + public Map getUsersMap() { + return usersMap; + } + + public void setUsersMap(Map usersMap) { + this.usersMap = usersMap; + } + + public String getForeignId() { + return foreignId; + } + + public void setForeignId(String foreignId) { + this.foreignId = foreignId; + } private Organization organization; diff --git a/platform-biz-service/src/main/java/com/lyms/platform/permission/model/DepartmentsQuery.java b/platform-biz-service/src/main/java/com/lyms/platform/permission/model/DepartmentsQuery.java index 0a0f2d3..5d03428 100644 --- a/platform-biz-service/src/main/java/com/lyms/platform/permission/model/DepartmentsQuery.java +++ b/platform-biz-service/src/main/java/com/lyms/platform/permission/model/DepartmentsQuery.java @@ -20,6 +20,15 @@ public class DepartmentsQuery extends BaseQuery { private Integer type; private String shortCode; private String keyword; + private String foreignId; + + public String getForeignId() { + return foreignId; + } + + public void setForeignId(String foreignId) { + this.foreignId = foreignId; + } public String getShortCode() { return shortCode; diff --git a/platform-biz-service/src/main/java/com/lyms/platform/permission/model/Organization.java b/platform-biz-service/src/main/java/com/lyms/platform/permission/model/Organization.java index fe49230..db08175 100644 --- a/platform-biz-service/src/main/java/com/lyms/platform/permission/model/Organization.java +++ b/platform-biz-service/src/main/java/com/lyms/platform/permission/model/Organization.java @@ -4,6 +4,9 @@ import com.lyms.platform.common.result.IdTextModel; import com.lyms.platform.pojo.BasicConfig; import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; public class Organization { private Integer id; @@ -30,6 +33,16 @@ public class Organization { private BasicConfig area; private String foreignId; + Map departmentsMap = new HashMap<>(); + + public Map getDepartmentsMap() { + return departmentsMap; + } + + public void setDepartmentsMap(Map departmentsMap) { + this.departmentsMap = departmentsMap; + } + public String getForeignId() { return foreignId; } diff --git a/platform-biz-service/src/main/java/com/lyms/platform/permission/model/OrganizationQuery.java b/platform-biz-service/src/main/java/com/lyms/platform/permission/model/OrganizationQuery.java index ccc914b..2e03740 100644 --- a/platform-biz-service/src/main/java/com/lyms/platform/permission/model/OrganizationQuery.java +++ b/platform-biz-service/src/main/java/com/lyms/platform/permission/model/OrganizationQuery.java @@ -24,6 +24,15 @@ public class OrganizationQuery extends BaseQuery { private Date created; private String shortCode; private String keyword; + private String foreignId; + + public String getForeignId() { + return foreignId; + } + + public void setForeignId(String foreignId) { + this.foreignId = foreignId; + } public String getShortCode() { return shortCode; diff --git a/platform-biz-service/src/main/java/com/lyms/platform/permission/model/Users.java b/platform-biz-service/src/main/java/com/lyms/platform/permission/model/Users.java index 960145a..59b05b2 100644 --- a/platform-biz-service/src/main/java/com/lyms/platform/permission/model/Users.java +++ b/platform-biz-service/src/main/java/com/lyms/platform/permission/model/Users.java @@ -27,6 +27,15 @@ public class Users { private List roles; private Departments departmentses; private Organization organization; + private String foreignId; + + public String getForeignId() { + return foreignId; + } + + public void setForeignId(String foreignId) { + this.foreignId = foreignId; + } public Integer getKsId() { diff --git a/platform-biz-service/src/main/java/com/lyms/platform/permission/model/UsersQuery.java b/platform-biz-service/src/main/java/com/lyms/platform/permission/model/UsersQuery.java index 5e7f115..f631836 100644 --- a/platform-biz-service/src/main/java/com/lyms/platform/permission/model/UsersQuery.java +++ b/platform-biz-service/src/main/java/com/lyms/platform/permission/model/UsersQuery.java @@ -28,6 +28,15 @@ public class UsersQuery extends BaseQuery { private String keyword; private Integer roleId; + private String foreignId; + + public String getForeignId() { + return foreignId; + } + + public void setForeignId(String foreignId) { + this.foreignId = foreignId; + } public Integer getRoleId() { return roleId; diff --git a/platform-biz-service/src/main/resources/mainOrm/Departments.xml b/platform-biz-service/src/main/resources/mainOrm/Departments.xml index 62f7219..d1d2abb 100644 --- a/platform-biz-service/src/main/resources/mainOrm/Departments.xml +++ b/platform-biz-service/src/main/resources/mainOrm/Departments.xml @@ -2,152 +2,157 @@ - - - - - - - - - - - - - - - - - - -insert into departments (parent_id,name,org_id,description,publish_id,publish_name,yn,modified,created,type,shortCode) values (#{parentId},#{name},#{orgId},#{description},#{publishId},#{publishName},#{yn},#{modified},#{created},#{type},#{shortCode}) + + + + + + + + + + + + + + + + + + + SELECT LAST_INSERT_ID() +insert into departments (foreign_id,parent_id,name,org_id,description,publish_id,publish_name,yn,modified,created,type,shortCode) values (#{foreignId},#{parentId},#{name},#{orgId},#{description},#{publishId},#{publishName},#{yn},#{modified},#{created},#{type},#{shortCode}) - - -update departments -parent_id = #{parentId,jdbcType=INTEGER}, - - -name = #{name,jdbcType=VARCHAR}, - - -org_id = #{orgId,jdbcType=INTEGER}, - - -description = #{description,jdbcType=VARCHAR}, - - -publish_id = #{publishId,jdbcType=INTEGER}, - - -publish_name = #{publishName,jdbcType=VARCHAR}, - - -yn = #{yn,jdbcType=INTEGER}, - - -modified = #{modified,jdbcType=TIMESTAMP}, - - -created = #{created,jdbcType=TIMESTAMP}, - - -type = #{type,jdbcType=INTEGER}, - - -shortCode = #{shortCode,jdbcType=VARCHAR}, - - -where id = #{id,jdbcType=INTEGER} - - - - + + update departments + + + parent_id = #{parentId,jdbcType=INTEGER}, + + + name = #{name,jdbcType=VARCHAR}, + + + org_id = #{orgId,jdbcType=INTEGER}, + + + foreign_id = #{foreignId,jdbcType=INTEGER}, + + + description = #{description,jdbcType=VARCHAR}, + + + publish_id = #{publishId,jdbcType=INTEGER}, + + + publish_name = #{publishName,jdbcType=VARCHAR}, + + + yn = #{yn,jdbcType=INTEGER}, + + + modified = #{modified,jdbcType=TIMESTAMP}, + + + created = #{created,jdbcType=TIMESTAMP}, + + + type = #{type,jdbcType=INTEGER}, + + + shortCode = #{shortCode,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=INTEGER} + + + + delete from departments where id = #{id,jdbcType=INTEGER} - - +select id,parent_id,name,org_id,description,publish_id,publish_name,yn,modified,created,type,shortCode,foreign_id from departments where id = #{id,jdbcType=INTEGER} - - -order by ${sort} - -limit #{offset, jdbcType=INTEGER} , #{limit, jdbcType=INTEGER} - - - - - - - - - 1 = 1 - -and id = #{id,jdbcType=INTEGER} - - -and parent_id = #{parentId,jdbcType=INTEGER} - - -and name = #{name,jdbcType=VARCHAR} - - -and org_id = #{orgId,jdbcType=INTEGER} - - -and description = #{description,jdbcType=VARCHAR} - - -and publish_id = #{publishId,jdbcType=INTEGER} - - -and publish_name = #{publishName,jdbcType=VARCHAR} - - -and yn = #{yn,jdbcType=INTEGER} - - -and modified = #{modified,jdbcType=TIMESTAMP} - - -and created = #{created,jdbcType=TIMESTAMP} - - -and type = #{type,jdbcType=INTEGER} - - -and shortCode = #{shortCode,jdbcType=VARCHAR} - - - and name like CONCAT(#{keyword}, '%') - - - - - - - - - - - - + + + order by ${sort} + + limit #{offset, jdbcType=INTEGER} , #{limit, jdbcType=INTEGER} + + + + + + + + 1 = 1 + + and id = #{id,jdbcType=INTEGER} + + + and parent_id = #{parentId,jdbcType=INTEGER} + + + and foreign_id = #{foreignId,jdbcType=VARCHAR} + + + and name = #{name,jdbcType=VARCHAR} + + + and org_id = #{orgId,jdbcType=INTEGER} + + + and description = #{description,jdbcType=VARCHAR} + + + and publish_id = #{publishId,jdbcType=INTEGER} + + + and publish_name = #{publishName,jdbcType=VARCHAR} + + + and yn = #{yn,jdbcType=INTEGER} + + + and modified = #{modified,jdbcType=TIMESTAMP} + + + and created = #{created,jdbcType=TIMESTAMP} + + + and type = #{type,jdbcType=INTEGER} + + + and shortCode = #{shortCode,jdbcType=VARCHAR} + + + and name like CONCAT(#{keyword}, '%') + + + + + + + + + \ No newline at end of file diff --git a/platform-biz-service/src/main/resources/mainOrm/Organization.xml b/platform-biz-service/src/main/resources/mainOrm/Organization.xml index 282c4d3..91476c5 100644 --- a/platform-biz-service/src/main/resources/mainOrm/Organization.xml +++ b/platform-biz-service/src/main/resources/mainOrm/Organization.xml @@ -2,180 +2,187 @@ - - - - - - - - - - - - - - - - - - - - - - -insert into organization (name,type,level,area_manage,province_id,city_id,area_id,address,description,publish_id,publish_name,yn,modified,created,shortCode) values (#{name},#{type},#{level},#{areaManage},#{provinceId},#{cityId},#{areaId},#{address},#{description},#{publishId},#{publishName},#{yn},#{modified},#{created},#{shortCode}) + + + + + + + + + + + + + + + + + + + + + + + SELECT LAST_INSERT_ID() +insert into organization (foreign_id,name,type,level,area_manage,province_id,city_id,area_id,address,description,publish_id,publish_name,yn,modified,created,shortCode) +values (#{foreignId},#{name},#{type},#{level},#{areaManage},#{provinceId},#{cityId},#{areaId},#{address},#{description},#{publishId},#{publishName},#{yn},#{modified},#{created},#{shortCode}) - - -update organization -name = #{name,jdbcType=VARCHAR}, - - -type = #{type,jdbcType=INTEGER}, - - -level = #{level,jdbcType=INTEGER}, - - -area_manage = #{areaManage,jdbcType=INTEGER}, - - -province_id = #{provinceId,jdbcType=INTEGER}, - - -city_id = #{cityId,jdbcType=INTEGER}, - - -area_id = #{areaId,jdbcType=INTEGER}, - - -address = #{address,jdbcType=VARCHAR}, - - -description = #{description,jdbcType=VARCHAR}, - - -publish_id = #{publishId,jdbcType=INTEGER}, - - -publish_name = #{publishName,jdbcType=VARCHAR}, - - -yn = #{yn,jdbcType=INTEGER}, - - -modified = #{modified,jdbcType=TIMESTAMP}, - - -created = #{created,jdbcType=TIMESTAMP}, - - -shortCode = #{shortCode,jdbcType=VARCHAR}, - - -where id = #{id,jdbcType=INTEGER} - - - - + + update organization + + + foreign_id = #{foreignId,jdbcType=VARCHAR}, + + + name = #{name,jdbcType=VARCHAR}, + + + type = #{type,jdbcType=INTEGER}, + + + level = #{level,jdbcType=INTEGER}, + + + area_manage = #{areaManage,jdbcType=INTEGER}, + + + province_id = #{provinceId,jdbcType=INTEGER}, + + + city_id = #{cityId,jdbcType=INTEGER}, + + + area_id = #{areaId,jdbcType=INTEGER}, + + + address = #{address,jdbcType=VARCHAR}, + + + description = #{description,jdbcType=VARCHAR}, + + + publish_id = #{publishId,jdbcType=INTEGER}, + + + publish_name = #{publishName,jdbcType=VARCHAR}, + + + yn = #{yn,jdbcType=INTEGER}, + + + modified = #{modified,jdbcType=TIMESTAMP}, + + + created = #{created,jdbcType=TIMESTAMP}, + + + shortCode = #{shortCode,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=INTEGER} + + + + delete from organization where id = #{id,jdbcType=INTEGER} - - +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 from organization where id = #{id,jdbcType=INTEGER} - - -order by ${sort} - -limit #{offset, jdbcType=INTEGER} , #{limit, jdbcType=INTEGER} - - - - - - - - - 1 = 1 - -and id = #{id,jdbcType=INTEGER} - - -and name = #{name,jdbcType=VARCHAR} - - -and type = #{type,jdbcType=INTEGER} - - -and level = #{level,jdbcType=INTEGER} - - -and area_manage = #{areaManage,jdbcType=INTEGER} - - -and province_id = #{provinceId,jdbcType=INTEGER} - - -and city_id = #{cityId,jdbcType=INTEGER} - - -and area_id = #{areaId,jdbcType=INTEGER} - - -and address = #{address,jdbcType=VARCHAR} - - -and description = #{description,jdbcType=VARCHAR} - - -and publish_id = #{publishId,jdbcType=INTEGER} - - -and publish_name = #{publishName,jdbcType=VARCHAR} - - -and yn = #{yn,jdbcType=INTEGER} - - -and modified = #{modified,jdbcType=TIMESTAMP} - - -and created = #{created,jdbcType=TIMESTAMP} - - -and shortCode = #{shortCode,jdbcType=VARCHAR} - - - and name like CONCAT(#{keyword}, '%') - - - - - - - - - - - - + + + order by ${sort} + + limit #{offset, jdbcType=INTEGER} , #{limit, jdbcType=INTEGER} + + + + + + + + 1 = 1 + + and id = #{id,jdbcType=INTEGER} + + + and foreign_id = #{foreignId,jdbcType=VARCHAR} + + + and name = #{name,jdbcType=VARCHAR} + + + and type = #{type,jdbcType=INTEGER} + + + and level = #{level,jdbcType=INTEGER} + + + and area_manage = #{areaManage,jdbcType=INTEGER} + + + and province_id = #{provinceId,jdbcType=INTEGER} + + + and city_id = #{cityId,jdbcType=INTEGER} + + + and area_id = #{areaId,jdbcType=INTEGER} + + + and address = #{address,jdbcType=VARCHAR} + + + and description = #{description,jdbcType=VARCHAR} + + + and publish_id = #{publishId,jdbcType=INTEGER} + + + and publish_name = #{publishName,jdbcType=VARCHAR} + + + and yn = #{yn,jdbcType=INTEGER} + + + and modified = #{modified,jdbcType=TIMESTAMP} + + + and created = #{created,jdbcType=TIMESTAMP} + + + and shortCode = #{shortCode,jdbcType=VARCHAR} + + + and name like CONCAT(#{keyword}, '%') + + + + + + + + + \ No newline at end of file diff --git a/platform-biz-service/src/main/resources/mainOrm/Users.xml b/platform-biz-service/src/main/resources/mainOrm/Users.xml index bcf7cca..dccc38b 100644 --- a/platform-biz-service/src/main/resources/mainOrm/Users.xml +++ b/platform-biz-service/src/main/resources/mainOrm/Users.xml @@ -2,257 +2,265 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - -insert into users (logincenter_id,type,org_id,dept_id,name,account,pwd,phone,publish_id,publish_name,yn,enable,modified,created,remarks,last_login_time,ks_id) values (#{logincenterId},#{type},#{orgId},#{deptId},#{name},#{account},#{pwd},#{phone},#{publishId},#{publishName},#{yn},#{enable},#{modified},#{created},#{remarks},#{lastLoginTime},#{ksId}) + + SELECT LAST_INSERT_ID() +insert into users (foreign_id,logincenter_id,type,org_id,dept_id,name,account,pwd,phone,publish_id,publish_name,yn,enable,modified,created,remarks,last_login_time,ks_id) +values (#{foreignId},#{logincenterId},#{type},#{orgId},#{deptId},#{name},#{account},#{pwd},#{phone},#{publishId},#{publishName},#{yn},#{enable},#{modified},#{created},#{remarks},#{lastLoginTime},#{ksId}) - - -update users -logincenter_id = #{logincenterId,jdbcType=INTEGER}, - - -type = #{type,jdbcType=INTEGER}, - - -org_id = #{orgId,jdbcType=INTEGER}, - - -dept_id = #{deptId,jdbcType=INTEGER}, - - - ks_id = #{ksId,jdbcType=INTEGER}, - - -name = #{name,jdbcType=VARCHAR}, - - -account = #{account,jdbcType=VARCHAR}, - - -pwd = #{pwd,jdbcType=VARCHAR}, - - -phone = #{phone,jdbcType=VARCHAR}, - - -publish_id = #{publishId,jdbcType=INTEGER}, - - -publish_name = #{publishName,jdbcType=VARCHAR}, - - -yn = #{yn,jdbcType=INTEGER}, - - -enable = #{enable,jdbcType=INTEGER}, - - -modified = #{modified,jdbcType=TIMESTAMP}, - - -created = #{created,jdbcType=TIMESTAMP}, - - -remarks = #{remarks,jdbcType=VARCHAR}, - - -last_login_time = #{lastLoginTime,jdbcType=TIMESTAMP}, - - -where id = #{id,jdbcType=INTEGER} - + + update users + + + logincenter_id = #{logincenterId,jdbcType=INTEGER}, + + + type = #{type,jdbcType=INTEGER}, + + + org_id = #{orgId,jdbcType=INTEGER}, + + + dept_id = #{deptId,jdbcType=INTEGER}, + + + ks_id = #{ksId,jdbcType=INTEGER}, + + + name = #{name,jdbcType=VARCHAR}, + + + foreign_id = #{foreignId,jdbcType=VARCHAR}, + + + account = #{account,jdbcType=VARCHAR}, + + + pwd = #{pwd,jdbcType=VARCHAR}, + + + phone = #{phone,jdbcType=VARCHAR}, + + + publish_id = #{publishId,jdbcType=INTEGER}, + + + publish_name = #{publishName,jdbcType=VARCHAR}, + + + yn = #{yn,jdbcType=INTEGER}, + + + enable = #{enable,jdbcType=INTEGER}, + + + modified = #{modified,jdbcType=TIMESTAMP}, + + + created = #{created,jdbcType=TIMESTAMP}, + + + remarks = #{remarks,jdbcType=VARCHAR}, + + + last_login_time = #{lastLoginTime,jdbcType=TIMESTAMP}, + + + where id = #{id,jdbcType=INTEGER} + - + delete from users where id = #{id,jdbcType=INTEGER} - - +select id,logincenter_id,type,org_id,dept_id,name,account,pwd,phone,publish_id,publish_name,yn,enable,modified,created,remarks,last_login_time, ks_id,foreign_id from users where id = #{id,jdbcType=INTEGER} - + select id,logincenter_id,type,org_id,dept_id,name,account,pwd,phone,publish_id,publish_name,yn,enable,modified,created,remarks,last_login_time, ks_id,foreign_id from users where logincenter_id = #{id,jdbcType=INTEGER} - - -order by ${sort} - -limit #{offset, jdbcType=INTEGER} , #{limit, jdbcType=INTEGER} - - - + + + order by ${sort} + + limit #{offset, jdbcType=INTEGER} , #{limit, jdbcType=INTEGER} + + + + + + 1 = 1 + + and id = #{id,jdbcType=INTEGER} + + + and logincenter_id = #{logincenterId,jdbcType=INTEGER} + + + and type = #{type,jdbcType=INTEGER} + + + and org_id = #{orgId,jdbcType=INTEGER} + + + and dept_id = #{deptId,jdbcType=INTEGER} + + + and ks_id = #{ksId,jdbcType=INTEGER} + + + and name = #{name,jdbcType=VARCHAR} + + + and foreign_id = #{foreignId,jdbcType=VARCHAR} + + + and account = #{account,jdbcType=VARCHAR} + + + and pwd = #{pwd,jdbcType=VARCHAR} + + + and phone = #{phone,jdbcType=VARCHAR} + + + and publish_id = #{publishId,jdbcType=INTEGER} + + + and publish_name = #{publishName,jdbcType=VARCHAR} + + + and yn = #{yn,jdbcType=INTEGER} + + + and enable = #{enable,jdbcType=INTEGER} + + + and modified = #{modified,jdbcType=TIMESTAMP} + + + and created = #{created,jdbcType=TIMESTAMP} + + + and remarks = #{remarks,jdbcType=VARCHAR} + + + and last_login_time = #{lastLoginTime,jdbcType=TIMESTAMP} + + + - - - 1 = 1 - -and id = #{id,jdbcType=INTEGER} - - -and logincenter_id = #{logincenterId,jdbcType=INTEGER} - - -and type = #{type,jdbcType=INTEGER} - - -and org_id = #{orgId,jdbcType=INTEGER} - - - and dept_id = #{deptId,jdbcType=INTEGER} - - - and ks_id = #{ksId,jdbcType=INTEGER} - - -and name = #{name,jdbcType=VARCHAR} - - -and account = #{account,jdbcType=VARCHAR} - - -and pwd = #{pwd,jdbcType=VARCHAR} - - -and phone = #{phone,jdbcType=VARCHAR} - - -and publish_id = #{publishId,jdbcType=INTEGER} - - -and publish_name = #{publishName,jdbcType=VARCHAR} - - -and yn = #{yn,jdbcType=INTEGER} - - -and enable = #{enable,jdbcType=INTEGER} - - -and modified = #{modified,jdbcType=TIMESTAMP} - - -and created = #{created,jdbcType=TIMESTAMP} - - -and remarks = #{remarks,jdbcType=VARCHAR} - - -and last_login_time = #{lastLoginTime,jdbcType=TIMESTAMP} - - - + - - + - + - - - - - + \ No newline at end of file diff --git a/platform-data-api/src/main/java/com/lyms/platform/data/controller/TaskController.java b/platform-data-api/src/main/java/com/lyms/platform/data/controller/TaskController.java index 802f9ec..482bbcf 100644 --- a/platform-data-api/src/main/java/com/lyms/platform/data/controller/TaskController.java +++ b/platform-data-api/src/main/java/com/lyms/platform/data/controller/TaskController.java @@ -42,7 +42,12 @@ public class TaskController extends BaseController { if ("basicConfig".equals(sid)) { dataImportTaskService.updateBasicConfig(); writeString(response, "success"); - } else { + } else if ("fullUpdateUsers".equals(sid)) { + dataImportTaskService.fullUpdateUsers(); + writeString(response, "success"); + } + + else { writeString(response, "nomethod"); } diff --git a/platform-data-api/src/main/java/com/lyms/platform/data/service/impl/DataImportTaskServiceImpl.java b/platform-data-api/src/main/java/com/lyms/platform/data/service/impl/DataImportTaskServiceImpl.java index de80241..10819b3 100644 --- a/platform-data-api/src/main/java/com/lyms/platform/data/service/impl/DataImportTaskServiceImpl.java +++ b/platform-data-api/src/main/java/com/lyms/platform/data/service/impl/DataImportTaskServiceImpl.java @@ -4,9 +4,10 @@ import com.lyms.platform.biz.service.BasicConfigService; import com.lyms.platform.common.enums.YnEnums; import com.lyms.platform.common.utils.LogUtil; import com.lyms.platform.data.service.DataImportTaskService; -import com.lyms.platform.permission.model.Organization; -import com.lyms.platform.permission.model.OrganizationQuery; +import com.lyms.platform.permission.model.*; +import com.lyms.platform.permission.service.DepartmentsService; import com.lyms.platform.permission.service.OrganizationService; +import com.lyms.platform.permission.service.UsersService; import com.lyms.platform.pojo.BasicConfig; import com.lymsh.mommybaby.earlydata.dao.PlatMapper; import com.lymsh.mommybaby.earlydata.model.PlatDataContent; @@ -15,7 +16,9 @@ import org.joda.time.DateTime; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.math.BigDecimal; import java.util.Date; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -29,11 +32,28 @@ public class DataImportTaskServiceImpl implements DataImportTaskService { private OrganizationService organizationService; @Autowired + private DepartmentsService departmentsService; + + @Autowired + private UsersService usersService; + + @Autowired private BasicConfigService basicConfigService; @Autowired private PlatMapper platMapper; + public Integer getInteger(Object obj) { + if (obj == null) { + return null; + } + try { + return ((BigDecimal) obj).intValue(); + } catch (Exception e) { + return null; + } + } + @Override public void updateUsers() { Date startTime = new DateTime().minusMinutes(7).toDate(); @@ -57,18 +77,127 @@ public class DataImportTaskServiceImpl implements DataImportTaskService { try { List list = platMapper.selectAllUserByHospitalId(hospitalForeignId, startTime); if (list != null && list.size() > 0) { + Map organizationMap = new HashMap<>(); Organization organization = new Organization(); + Departments departments = new Departments(); + Users users = new Users(); for (Map map:list) { try { // organization - if (StringUtils.isBlank(organization.getForeignId()) || organization.getForeignId().equals(map.get("H_ID"))) { + if (StringUtils.isBlank(organization.getForeignId()) || !organization.getForeignId().equals(map.get("H_ID"))) { organization.setForeignId(map.get("H_ID").toString()); organization.setYn(YnEnums.YES.getId()); + organization.setName(map.get("H_NAME").toString()); + organization.setAreaId(map.get("H_COUNTYNO") == null ? null : map.get("H_COUNTYNO").toString()); + organization.setCityId(map.get("H_CITYNO") == null ? null : map.get("H_CITYNO").toString()); + organization.setLevel(getInteger(map.get("H_LEVEL"))); + organization.setProvinceId(map.get("H_PROVINCENO") == null ? null : map.get("H_PROVINCENO").toString()); + organization.setShortCode(map.get("H_HELPCODE") == null ? null : map.get("H_HELPCODE").toString()); + organization.setType(getInteger(map.get("H_TYPE"))); + organization.setAreaManage(getInteger(map.get("H_ISLEADER"))); + organization.setPublishId(0); + organization.setPublishName("system"); + organization.setModified(new Date()); + if (!organizationMap.containsKey(organization.getForeignId())) { + organizationMap.put(organization.getForeignId(),organization); + } + } + + // Departments + if (StringUtils.isBlank(departments.getForeignId()) || !departments.getForeignId().equals(map.get("D_ID"))) { + departments.setPublishName("system"); + departments.setType(2); + departments.setPublishId(0); + departments.setShortCode(map.get("D_HELPCODE") == null ? null : map.get("D_HELPCODE").toString()); + departments.setYn(YnEnums.YES.getId()); + departments.setForeignId(map.get("D_ID").toString()); + departments.setModified(new Date()); + departments.setName(map.get("D_NAME") == null ? null : map.get("D_NAME").toString()); + if (!organization.getDepartmentsMap().containsKey(departments.getForeignId())) { + organization.getDepartmentsMap().put(departments.getForeignId(), departments); + } + } + + // users + if (StringUtils.isBlank(users.getForeignId()) || !users.getForeignId().equals(map.get("U_ID"))) { + users.setPublishId(0); + users.setPublishName("system"); + users.setOrgId(organization.getId()); + users.setName(map.get("E_NAME") == null ? null : map.get("E_NAME").toString()); + users.setAccount(map.get("U_USERNAME") == null ? null : map.get("U_USERNAME").toString()); + users.setForeignId(map.get("U_ID").toString()); + users.setYn(YnEnums.YES.getId()); + users.setModified(new Date()); + users.setDeptId(departments.getId()); + Integer enable = getInteger(map.get("U_ISVALID")); + if (enable != null && enable == 1) { + users.setEnable(1); + } else { + users.setEnable(2); + } + users.setKsId(departments.getId()); + if (!departments.getUsersMap().containsKey(users.getForeignId())) { + departments.getUsersMap().put(users.getForeignId(), users); + } + + //TODO 手机号,权限 对应中间表 +// users.setPhone(""); +// String roles = map.get("UR_ROLEIDS")==null?null:map.get("UR_ROLEIDS").toString(); } } catch (Exception ee) { + LogUtil.taskError(ee.getMessage(), ee); + } + } + // save + OrganizationQuery organizationQuery = new OrganizationQuery(); + DepartmentsQuery departmentsQuery = new DepartmentsQuery(); + UsersQuery usersQuery = new UsersQuery(); + for (Organization o:organizationMap.values()) { + try { + organizationQuery.setForeignId(organization.getForeignId()); + List organizationList = organizationService.queryOrganization(organizationQuery); + if (organizationList != null && organizationList.size() > 0) { + for (Organization odb:organizationList) { + organization.setId(odb.getId()); + organizationService.updateOrganization(organization); + } + } else { + organization.setCreated(organization.getModified()); + organizationService.addOrganization(organization); + } + for (Departments d:organization.getDepartmentsMap().values()) { + departments.setOrgId(organization.getId()); + departmentsQuery.setForeignId(departments.getForeignId()); + List departmentsList = departmentsService.queryDepartments(departmentsQuery); + if (departmentsList != null && departmentsList.size() > 0) { + for (Departments dd:departmentsList) { + departments.setId(dd.getId()); + departmentsService.updateDepartments(departments); + } + } else { + departments.setCreated(departments.getModified()); + departmentsService.addDepartments(departments); + } + for (Users u:departments.getUsersMap().values()) { + usersQuery.setForeignId(users.getForeignId()); + List usersList = usersService.queryUsers(usersQuery); + if (usersList != null && usersList.size() > 0) { + for (Users du:usersList) { + users.setId(du.getId()); + usersService.updateUsers(users); + } + } else { + users.setCreated(users.getModified()); + usersService.addUsers(users); + } + } + } + + } catch (Exception ee) { + LogUtil.taskError(ee.getMessage(), ee); } } } else { diff --git a/platform-data-api/src/main/webapp/WEB-INF/vm/task/index.vm b/platform-data-api/src/main/webapp/WEB-INF/vm/task/index.vm index d4333f2..60a95ae 100644 --- a/platform-data-api/src/main/webapp/WEB-INF/vm/task/index.vm +++ b/platform-data-api/src/main/webapp/WEB-INF/vm/task/index.vm @@ -25,11 +25,19 @@ + + 机构、部门、用户(医生) + + 无 + + + +