|
@ -10,6 +10,8 @@ import com.yihu.jw.base.dao.role.BaseRoleMenuDao;
|
|
|
import com.yihu.jw.base.dao.role.RoleDao;
|
|
|
import com.yihu.jw.base.dao.saas.SaasDao;
|
|
|
import com.yihu.jw.base.dao.user.UserDao;
|
|
|
import com.yihu.jw.base.service.equipment.WlyyUserAreaService;
|
|
|
import com.yihu.jw.base.service.equipment.WlyyUserEquipmentService;
|
|
|
import com.yihu.jw.base.service.org.*;
|
|
|
import com.yihu.jw.base.util.ConstantUtils;
|
|
|
import com.yihu.jw.base.util.JavaBeanUtils;
|
|
@ -77,6 +79,10 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
|
|
|
@Autowired
|
|
|
private WlyyUserAreaDao userAreaDao;
|
|
|
@Autowired
|
|
|
private WlyyUserAreaService userAreaService;
|
|
|
@Autowired
|
|
|
private WlyyUserEquipmentService equipmentService;
|
|
|
@Autowired
|
|
|
private WlyyUserEquipmentDao userEquipmentDao;
|
|
|
|
|
|
@Autowired
|
|
@ -1170,4 +1176,149 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
public String addUserByIjk(JSONObject doctorJson) {
|
|
|
String idcard = doctorJson.getString("idcard");
|
|
|
String mobile = doctorJson.getString("mobile");
|
|
|
|
|
|
if (StringUtils.isBlank(idcard)) {
|
|
|
return "I健康账户信息不完整,添加失败";
|
|
|
}
|
|
|
|
|
|
UserDO userDO = userDao.findByMobile(mobile);
|
|
|
if (userDO != null) {
|
|
|
userDO.setSaasId("808080eb7bc87123017bf16ba0ad0046");
|
|
|
userDO.setName(doctorJson.getString("name"));
|
|
|
userDO.setIdcard(doctorJson.getString("idcard"));
|
|
|
userDO.setUsername(doctorJson.getString("mobile"));
|
|
|
userDO.setMobile(doctorJson.getString("mobile"));
|
|
|
if (doctorJson.getInteger("sex") == 1) {
|
|
|
userDO.setGender(UserDO.Gender.male);
|
|
|
} else if (doctorJson.getInteger("sex") == 2) {
|
|
|
userDO.setGender(UserDO.Gender.female);
|
|
|
}
|
|
|
//认证信息设置
|
|
|
String salt = randomString(5);
|
|
|
String pw = idcard.substring(idcard.length() - 6);
|
|
|
userDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
|
|
|
userDO.setSalt(salt);
|
|
|
userDO.setEnabled(1);
|
|
|
userDO.setLocked(0);
|
|
|
userDO.setCreateTime(new Date());
|
|
|
userDO.setUpdateTime(new Date());
|
|
|
userDO = userDao.save(userDO);
|
|
|
//18补货员19社区药柜管理员20药柜区域管理员21药柜超级管理员
|
|
|
String expandLevel = doctorJson.getString("expandLevel");
|
|
|
RoleDO roleDO = roleDao.findOne(expandLevel);
|
|
|
userDO.setRoleId(roleDO.getId());
|
|
|
userDO = userDao.save(userDO);
|
|
|
List<WlyyUserAreaDO> userAreaDOList = userAreaDao.findAllByUserId(userDO.getId());
|
|
|
//先删除
|
|
|
userAreaService.delete(userAreaDOList);
|
|
|
WlyyUserAreaDO userAreaDO = new WlyyUserAreaDO();
|
|
|
userAreaDO.setUserId(userDO.getId());
|
|
|
userAreaDO.setCity(doctorJson.getString("city"));
|
|
|
userAreaDO.setCityName(doctorJson.getString("cityName"));
|
|
|
userAreaDO.setTown(doctorJson.getString("town"));
|
|
|
userAreaDO.setTownName(doctorJson.getString("townName"));
|
|
|
userAreaDO.setHospital(doctorJson.getString("hospital"));
|
|
|
userAreaDO.setHospitalName(doctorJson.getString("hospitalName"));
|
|
|
userAreaDO.setUpdateTime(new Date());
|
|
|
userAreaDO.setCreateTime(new Date());
|
|
|
userAreaDO.setDel(1);
|
|
|
userAreaDao.save(userAreaDO);
|
|
|
if (roleDO.getCode().equalsIgnoreCase("replenisher")) {
|
|
|
String sql = "select d.id as id,d.equ_name as name from t_mediicine_device d where d.belong_community ='" + doctorJson.getString("hospital") + "' ";
|
|
|
List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql);
|
|
|
List<WlyyUserEquipmentDO> equipmentDOList = userEquipmentDao.findAllByUserId(userDO.getId());
|
|
|
equipmentService.delete(equipmentDOList);
|
|
|
for (Map<String, Object> map : mapList) {
|
|
|
WlyyUserEquipmentDO equipmentDO = new WlyyUserEquipmentDO();
|
|
|
String id = map.get("id").toString();
|
|
|
String name = map.get("name") == null ? "" : map.get("name").toString();
|
|
|
equipmentDO.setEquipmentId(id);
|
|
|
equipmentDO.setEquipmentName(name);
|
|
|
equipmentDO.setUserId(userDO.getId());
|
|
|
equipmentDO.setDel(1);
|
|
|
equipmentDO.setCityName(doctorJson.getString("cityName"));
|
|
|
equipmentDO.setCity(doctorJson.getString("city"));
|
|
|
equipmentDO.setTown(doctorJson.getString("town"));
|
|
|
equipmentDO.setTownName(doctorJson.getString("townName"));
|
|
|
equipmentDO.setHospital(doctorJson.getString("hospital"));
|
|
|
equipmentDO.setHospitalName(doctorJson.getString("hospitalName"));
|
|
|
equipmentDO.setCreateTime(new Date());
|
|
|
equipmentDO.setUpdateTime(new Date());
|
|
|
userEquipmentDao.save(equipmentDO);
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
//存储医生全科医生信息
|
|
|
userDO = new UserDO();
|
|
|
userDO.setSaasId("808080eb7bc87123017bf16ba0ad0046");
|
|
|
userDO.setName(doctorJson.getString("name"));
|
|
|
userDO.setIdcard(doctorJson.getString("idcard"));
|
|
|
userDO.setUsername(doctorJson.getString("mobile"));
|
|
|
userDO.setMobile(doctorJson.getString("mobile"));
|
|
|
if (doctorJson.getInteger("sex") == 1) {
|
|
|
userDO.setGender(UserDO.Gender.male);
|
|
|
} else if (doctorJson.getInteger("sex") == 2) {
|
|
|
userDO.setGender(UserDO.Gender.female);
|
|
|
}
|
|
|
//认证信息设置
|
|
|
String salt = randomString(5);
|
|
|
String pw = idcard.substring(idcard.length() - 6);
|
|
|
userDO.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
|
|
|
userDO.setSalt(salt);
|
|
|
userDO.setEnabled(1);
|
|
|
userDO.setLocked(0);
|
|
|
userDO.setCreateTime(new Date());
|
|
|
userDO.setUpdateTime(new Date());
|
|
|
userDO = userDao.save(userDO);
|
|
|
//18补货员19社区药柜管理员20药柜区域管理员21药柜超级管理员
|
|
|
String expandLevel = doctorJson.getString("expandLevel");
|
|
|
RoleDO roleDO = roleDao.findOne(expandLevel);
|
|
|
userDO.setRoleId(roleDO.getId());
|
|
|
userDO = userDao.save(userDO);
|
|
|
List<WlyyUserAreaDO> userAreaDOList = userAreaDao.findAllByUserId(userDO.getId());
|
|
|
//先删除
|
|
|
userAreaService.delete(userAreaDOList);
|
|
|
WlyyUserAreaDO userAreaDO = new WlyyUserAreaDO();
|
|
|
userAreaDO.setUserId(userDO.getId());
|
|
|
userAreaDO.setCity(doctorJson.getString("city"));
|
|
|
userAreaDO.setCityName(doctorJson.getString("cityName"));
|
|
|
userAreaDO.setTown(doctorJson.getString("town"));
|
|
|
userAreaDO.setTownName(doctorJson.getString("townName"));
|
|
|
userAreaDO.setHospital(doctorJson.getString("hospital"));
|
|
|
userAreaDO.setHospitalName(doctorJson.getString("hospitalName"));
|
|
|
userAreaDO.setUpdateTime(new Date());
|
|
|
userAreaDO.setCreateTime(new Date());
|
|
|
userAreaDO.setDel(1);
|
|
|
userAreaDao.save(userAreaDO);
|
|
|
if (roleDO.getCode().equalsIgnoreCase("replenisher")) {
|
|
|
String sql = "select d.id as id,d.equ_name as name from t_mediicine_device d where d.belong_community ='" + doctorJson.getString("hospital") + "' ";
|
|
|
List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql);
|
|
|
List<WlyyUserEquipmentDO> equipmentDOList = userEquipmentDao.findAllByUserId(userDO.getId());
|
|
|
equipmentService.delete(equipmentDOList);
|
|
|
for (Map<String, Object> map : mapList) {
|
|
|
WlyyUserEquipmentDO equipmentDO = new WlyyUserEquipmentDO();
|
|
|
String id = map.get("id").toString();
|
|
|
String name = map.get("name") == null ? "" : map.get("name").toString();
|
|
|
equipmentDO.setEquipmentId(id);
|
|
|
equipmentDO.setEquipmentName(name);
|
|
|
equipmentDO.setUserId(userDO.getId());
|
|
|
equipmentDO.setDel(1);
|
|
|
equipmentDO.setCityName(doctorJson.getString("cityName"));
|
|
|
equipmentDO.setCity(doctorJson.getString("city"));
|
|
|
equipmentDO.setTown(doctorJson.getString("town"));
|
|
|
equipmentDO.setTownName(doctorJson.getString("townName"));
|
|
|
equipmentDO.setHospital(doctorJson.getString("hospital"));
|
|
|
equipmentDO.setHospitalName(doctorJson.getString("hospitalName"));
|
|
|
equipmentDO.setCreateTime(new Date());
|
|
|
equipmentDO.setUpdateTime(new Date());
|
|
|
userEquipmentDao.save(equipmentDO);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return "添加成功";
|
|
|
}
|
|
|
}
|