|
@ -24,11 +24,13 @@ import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
|
|
import com.yihu.jw.restmodel.base.wx.WxGraphicMessageVO;
|
|
import com.yihu.jw.restmodel.base.wx.WxGraphicMessageVO;
|
|
import com.yihu.jw.restmodel.base.wx.WxReplySceneVO;
|
|
import com.yihu.jw.restmodel.base.wx.WxReplySceneVO;
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
|
import com.yihu.jw.utils.EntityUtils;
|
|
import com.yihu.jw.utils.hibernate.HibenateUtils;
|
|
import com.yihu.jw.utils.hibernate.HibenateUtils;
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
import com.yihu.utils.security.MD5;
|
|
import com.yihu.utils.security.MD5;
|
|
import org.apache.axis.utils.Admin;
|
|
import org.apache.axis.utils.Admin;
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
@ -37,8 +39,8 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
import javax.swing.text.html.parser.Entity;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.sql.PreparedStatement;
|
|
import java.sql.PreparedStatement;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@ -93,12 +95,12 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
|
|
|
|
|
|
public UserDO registerWithIdcard(UserDO userDO) {
|
|
public UserDO registerWithIdcard(UserDO userDO) {
|
|
userDO.setSalt(randomString(5));
|
|
userDO.setSalt(randomString(5));
|
|
if (StringUtils.isEmpty(userDO.getEnabled())){
|
|
|
|
userDO.setEnabled(true);
|
|
|
|
|
|
if (org.springframework.util.StringUtils.isEmpty(userDO.getEnabled())){
|
|
|
|
userDO.setEnabled(1);
|
|
}else {
|
|
}else {
|
|
userDO.setEnabled(userDO.getEnabled());
|
|
userDO.setEnabled(userDO.getEnabled());
|
|
}
|
|
}
|
|
userDO.setLocked(false);
|
|
|
|
|
|
userDO.setLocked(0);
|
|
userDO.setLoginFailureCount(0);
|
|
userDO.setLoginFailureCount(0);
|
|
String password = userDO.getPassword();
|
|
String password = userDO.getPassword();
|
|
if (StringUtils.isEmpty(password)) {
|
|
if (StringUtils.isEmpty(password)) {
|
|
@ -116,8 +118,8 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
|
|
*/
|
|
*/
|
|
public UserDO registerWithMobile(UserDO userDO) {
|
|
public UserDO registerWithMobile(UserDO userDO) {
|
|
userDO.setSalt(randomString(5));
|
|
userDO.setSalt(randomString(5));
|
|
userDO.setEnabled(true);
|
|
|
|
userDO.setLocked(false);
|
|
|
|
|
|
userDO.setEnabled(1);
|
|
|
|
userDO.setLocked(0);
|
|
userDO.setLoginFailureCount(0);
|
|
userDO.setLoginFailureCount(0);
|
|
String password = userDO.getPassword();
|
|
String password = userDO.getPassword();
|
|
if (StringUtils.isEmpty(password)) {
|
|
if (StringUtils.isEmpty(password)) {
|
|
@ -193,7 +195,7 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
|
|
UserDO user = userDao.findOne(id);
|
|
UserDO user = userDao.findOne(id);
|
|
RoleDO role = null;
|
|
RoleDO role = null;
|
|
if (user != null ) {
|
|
if (user != null ) {
|
|
if(!user.getEnabled()){
|
|
|
|
|
|
if(user.getEnabled()==0){
|
|
throw new Exception("用户已失效!");
|
|
throw new Exception("用户已失效!");
|
|
}
|
|
}
|
|
userinfo.put("id", user.getId());
|
|
userinfo.put("id", user.getId());
|
|
@ -316,7 +318,7 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public JSONObject createUser(String jsonData) {
|
|
|
|
|
|
public JSONObject createUser(String jsonData) throws Exception {
|
|
JSONObject result = new JSONObject();
|
|
JSONObject result = new JSONObject();
|
|
if (StringUtils.isEmpty(jsonData)) {
|
|
if (StringUtils.isEmpty(jsonData)) {
|
|
result.put("msg", "parameter jsonData is null");
|
|
result.put("msg", "parameter jsonData is null");
|
|
@ -325,44 +327,49 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
|
|
}
|
|
}
|
|
JSONObject jsonObject = JSONObject.parseObject(jsonData);
|
|
JSONObject jsonObject = JSONObject.parseObject(jsonData);
|
|
JSONObject user = jsonObject.getJSONObject("user");
|
|
JSONObject user = jsonObject.getJSONObject("user");
|
|
JSONArray org = jsonObject.getJSONArray("org");
|
|
|
|
JSONArray area = jsonObject.getJSONArray("area");
|
|
|
|
JSONArray equipment = jsonObject.getJSONArray("equipment");
|
|
|
|
|
|
// JSONArray org = jsonObject.getJSONArray("org");
|
|
|
|
JSONArray area = user.getJSONArray("area");
|
|
|
|
JSONArray equipment = user.getJSONArray("equipment");
|
|
|
|
|
|
//归属租户为默认租户,表示用户为超级管理员,不需要机构
|
|
|
|
|
|
/* //归属租户为默认租户,表示用户为超级管理员,不需要机构
|
|
if (null == user || CollectionUtils.isEmpty(org) && !user.getString("saasId").equalsIgnoreCase(defaultSaasId)) {
|
|
if (null == user || CollectionUtils.isEmpty(org) && !user.getString("saasId").equalsIgnoreCase(defaultSaasId)) {
|
|
result.put("msg", "请点击机构管理选择所在机构");
|
|
result.put("msg", "请点击机构管理选择所在机构");
|
|
result.put("response", ConstantUtils.FAIL);
|
|
result.put("response", ConstantUtils.FAIL);
|
|
return result;
|
|
return result;
|
|
}
|
|
|
|
|
|
}*/
|
|
//组装用户信息
|
|
//组装用户信息
|
|
UserDO userDO = null;
|
|
|
|
|
|
UserDO userDO = new UserDO();
|
|
try {
|
|
try {
|
|
userDO = objectMapper.readValue(user.toJSONString(), UserDO.class);
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
// userDO = objectMapper.readValue(user.toJSONString(), UserDO.class);
|
|
|
|
userDO = EntityUtils.jsonToEntity(user.toString(),UserDO.class);
|
|
|
|
} catch (Exception e) {
|
|
result.put("msg", "convert user jsonObject to UserDO failed," + e.getCause());
|
|
result.put("msg", "convert user jsonObject to UserDO failed," + e.getCause());
|
|
result.put("response", ConstantUtils.FAIL);
|
|
result.put("response", ConstantUtils.FAIL);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
registerWithIdcard(userDO);
|
|
|
|
|
|
if (!StringUtils.isNoneBlank(userDO.getIdcard())){
|
|
|
|
registerWithMobile(userDO);
|
|
|
|
}else {
|
|
|
|
registerWithIdcard(userDO);
|
|
|
|
}
|
|
|
|
|
|
//组装用户与机构的关联关系
|
|
//组装用户与机构的关联关系
|
|
List<BaseOrgUserDO> orgList = new ArrayList<>();
|
|
|
|
BaseOrgUserDO orgUserDO = null;
|
|
|
|
if(!CollectionUtils.isEmpty(org)){
|
|
|
|
for (Object obj : org) {
|
|
|
|
try {
|
|
|
|
orgUserDO = objectMapper.readValue(obj.toString(), BaseOrgUserDO.class);
|
|
|
|
orgUserDO.setUserId(userDO.getId());
|
|
|
|
orgList.add(orgUserDO);
|
|
|
|
} catch (IOException e) {
|
|
|
|
result.put("msg", "convert org jsonObject to BaseOrgUserDO failed," + e.getCause());
|
|
|
|
result.put("response", ConstantUtils.FAIL);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
baseOrgUserService.batchInsert(orgList);
|
|
|
|
}
|
|
|
|
|
|
// List<BaseOrgUserDO> orgList = new ArrayList<>();
|
|
|
|
// BaseOrgUserDO orgUserDO = null;
|
|
|
|
// if(!CollectionUtils.isEmpty(org)){
|
|
|
|
// for (Object obj : org) {
|
|
|
|
// try {
|
|
|
|
// orgUserDO = objectMapper.readValue(obj.toString(), BaseOrgUserDO.class);
|
|
|
|
// orgUserDO.setUserId(userDO.getId());
|
|
|
|
// orgList.add(orgUserDO);
|
|
|
|
// } catch (IOException e) {
|
|
|
|
// result.put("msg", "convert org jsonObject to BaseOrgUserDO failed," + e.getCause());
|
|
|
|
// result.put("response", ConstantUtils.FAIL);
|
|
|
|
// return result;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// baseOrgUserService.batchInsert(orgList);
|
|
|
|
// }
|
|
//area:[{"city":"","cityName":"","town":"","townName":"","hospital":"","hospitalName":""}]
|
|
//area:[{"city":"","cityName":"","town":"","townName":"","hospital":"","hospitalName":""}]
|
|
//用户所属区域添加
|
|
//用户所属区域添加
|
|
if (area!=null&&area.size()!=0){
|
|
if (area!=null&&area.size()!=0){
|
|
@ -411,7 +418,11 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
|
|
}
|
|
}
|
|
JSONObject returnMsg = new JSONObject();
|
|
JSONObject returnMsg = new JSONObject();
|
|
returnMsg.put("username",userDO.getUsername());
|
|
returnMsg.put("username",userDO.getUsername());
|
|
returnMsg.put("password",userDO.getIdcard().substring(userDO.getIdcard().length()-6,userDO.getIdcard().length()));
|
|
|
|
|
|
if (!StringUtils.isNoneBlank(userDO.getIdcard())){
|
|
|
|
returnMsg.put("password",userDO.getMobile().substring(userDO.getMobile().length()-6,userDO.getMobile().length()));
|
|
|
|
}else {
|
|
|
|
returnMsg.put("password", userDO.getIdcard().substring(userDO.getIdcard().length() - 6, userDO.getIdcard().length()));
|
|
|
|
}
|
|
result.put("response", ConstantUtils.SUCCESS);
|
|
result.put("response", ConstantUtils.SUCCESS);
|
|
result.put("msg", returnMsg);
|
|
result.put("msg", returnMsg);
|
|
return result;
|
|
return result;
|
|
@ -694,8 +705,8 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
|
|
}
|
|
}
|
|
|
|
|
|
user.setSalt(randomString(5));
|
|
user.setSalt(randomString(5));
|
|
user.setEnabled(true);
|
|
|
|
user.setLocked(false);
|
|
|
|
|
|
user.setEnabled(1);
|
|
|
|
user.setLocked(0);
|
|
user.setLoginFailureCount(0);
|
|
user.setLoginFailureCount(0);
|
|
user.setPassword(MD5.md5Hex(pwd + "{" + user.getSalt() + "}"));
|
|
user.setPassword(MD5.md5Hex(pwd + "{" + user.getSalt() + "}"));
|
|
userDao.save(user);
|
|
userDao.save(user);
|
|
@ -749,8 +760,8 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
|
|
}
|
|
}
|
|
|
|
|
|
user.setSalt(randomString(5));
|
|
user.setSalt(randomString(5));
|
|
user.setEnabled(true);
|
|
|
|
user.setLocked(false);
|
|
|
|
|
|
user.setEnabled(1);
|
|
|
|
user.setLocked(0);
|
|
user.setLoginFailureCount(0);
|
|
user.setLoginFailureCount(0);
|
|
user.setPassword(MD5.md5Hex(password + "{" + user.getSalt() + "}"));
|
|
user.setPassword(MD5.md5Hex(password + "{" + user.getSalt() + "}"));
|
|
userDao.save(user);
|
|
userDao.save(user);
|
|
@ -782,7 +793,7 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
|
|
*/
|
|
*/
|
|
public JSONObject lockOrUnlocakUser(String userId,boolean lock){
|
|
public JSONObject lockOrUnlocakUser(String userId,boolean lock){
|
|
JSONObject result = new JSONObject();
|
|
JSONObject result = new JSONObject();
|
|
if(StringUtils.isEmpty(userId) || StringUtils.isEmpty(lock)){
|
|
|
|
|
|
if(org.springframework.util.StringUtils.isEmpty(userId) || org.springframework.util.StringUtils.isEmpty(lock)){
|
|
result.put("msg","parameter id or del is null");
|
|
result.put("msg","parameter id or del is null");
|
|
result.put("response",ConstantUtils.FAIL);
|
|
result.put("response",ConstantUtils.FAIL);
|
|
return result;
|
|
return result;
|
|
@ -793,7 +804,11 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
|
|
result.put("response",ConstantUtils.FAIL);
|
|
result.put("response",ConstantUtils.FAIL);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
user.setLocked(lock);
|
|
|
|
|
|
if (lock){
|
|
|
|
user.setLocked(0);
|
|
|
|
}else {
|
|
|
|
user.setLocked(1);
|
|
|
|
}
|
|
user.setLockedDate(new Date());
|
|
user.setLockedDate(new Date());
|
|
this.save(user);
|
|
this.save(user);
|
|
result.put("response",ConstantUtils.SUCCESS);
|
|
result.put("response",ConstantUtils.SUCCESS);
|
|
@ -809,7 +824,7 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
|
|
*/
|
|
*/
|
|
public JSONObject enableOrDisable(String userId,boolean lock){
|
|
public JSONObject enableOrDisable(String userId,boolean lock){
|
|
JSONObject result = new JSONObject();
|
|
JSONObject result = new JSONObject();
|
|
if(StringUtils.isEmpty(userId) || StringUtils.isEmpty(lock)){
|
|
|
|
|
|
if(org.springframework.util.StringUtils.isEmpty(userId) || org.springframework.util.StringUtils.isEmpty(lock)){
|
|
result.put("msg","parameter id or del is null");
|
|
result.put("msg","parameter id or del is null");
|
|
result.put("response",ConstantUtils.FAIL);
|
|
result.put("response",ConstantUtils.FAIL);
|
|
return result;
|
|
return result;
|
|
@ -820,7 +835,11 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
|
|
result.put("response",ConstantUtils.FAIL);
|
|
result.put("response",ConstantUtils.FAIL);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
user.setEnabled(lock);
|
|
|
|
|
|
if (lock){
|
|
|
|
user.setEnabled(1);
|
|
|
|
}else {
|
|
|
|
user.setEnabled(0);
|
|
|
|
}
|
|
this.save(user);
|
|
this.save(user);
|
|
result.put("response",ConstantUtils.SUCCESS);
|
|
result.put("response",ConstantUtils.SUCCESS);
|
|
return result;
|
|
return result;
|