|
@@ -1,5 +1,6 @@
|
|
|
package com.rf.psychological.rest;
|
|
|
|
|
|
+import cn.hutool.core.lang.Validator;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.rf.psychological.base.rest.BaseController;
|
|
@@ -1015,13 +1016,17 @@ public class ServerController extends BaseController {
|
|
|
@ApiOperation(value = "用户导入")
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@PostMapping("userImport")
|
|
|
- public Result userImport(String institutionNo, MultipartFile file, HttpServletResponse response) throws Exception {
|
|
|
+ public Result userImport(String institutionNo,String structureNo, MultipartFile file, HttpServletResponse response) throws Exception {
|
|
|
if (file == null) {
|
|
|
return fail("文件为空");
|
|
|
}
|
|
|
if (institutionNo == null) {
|
|
|
return fail("机构编号为空");
|
|
|
}
|
|
|
+ InstitutionEntity institutionEntity = this.institutionService.findByInstitutionNo(institutionNo);
|
|
|
+ if (institutionEntity == null){
|
|
|
+ return fail("机构不存在");
|
|
|
+ }
|
|
|
String fileName = file.getOriginalFilename();
|
|
|
List<List<Object>> datas = ExcelUtil.getBankListByExcelForUserImport(file.getInputStream(), fileName);
|
|
|
if(CollectionUtils.isEmpty(datas)){
|
|
@@ -1035,7 +1040,7 @@ public class ServerController extends BaseController {
|
|
|
int y = 0;
|
|
|
for (int i = 0; i < datas.size(); i++) {
|
|
|
List<Object> users = datas.get(i);
|
|
|
- if (users.size()<7) {
|
|
|
+ if (users.size()<5) {
|
|
|
y = i + 1;
|
|
|
result.append("第" + y +"条数据信息不完整").append("\r\n");
|
|
|
isExist = true;
|
|
@@ -1043,18 +1048,14 @@ public class ServerController extends BaseController {
|
|
|
}
|
|
|
Object petName = users.get(0);
|
|
|
Object phone = users.get(1);
|
|
|
- Object password = users.get(2);
|
|
|
- Object gender = users.get(3);
|
|
|
- Object idCard = users.get(4);
|
|
|
- Object mobile = users.get(5);
|
|
|
- Object orgNum = users.get(6);
|
|
|
+ Object gender = users.get(2);
|
|
|
+ Object mobile = users.get(3);
|
|
|
+ Object profession = users.get(4);
|
|
|
if (petName == null || petName == "" ||
|
|
|
phone == null || phone == "" ||
|
|
|
- password == null || password == "" ||
|
|
|
gender == null || gender == "" ||
|
|
|
- idCard == null || idCard == "" ||
|
|
|
mobile == null || mobile == "" ||
|
|
|
- orgNum == null || orgNum == "") {
|
|
|
+ profession == null || profession == "") {
|
|
|
y = i + 1;
|
|
|
result.append("第" + y +"条数据信息不完整").append("\r\n");
|
|
|
isExist = true;
|
|
@@ -1066,35 +1067,34 @@ public class ServerController extends BaseController {
|
|
|
isExist = true;
|
|
|
continue;
|
|
|
}
|
|
|
- if (phone.toString().length() > 18 || phone.toString().length() < 3 || phone.toString().contains(" ")){
|
|
|
+ if (Validator.isCitizenId(phone.toString())){
|
|
|
y = i + 1;
|
|
|
- result.append("第" + y +"条数据账号长度未在3~18位之间或有空格").append("\r\n");
|
|
|
+ result.append("第" + y +"账号不符合身份证规则").append("\r\n");
|
|
|
isExist = true;
|
|
|
continue;
|
|
|
}
|
|
|
- if (password.toString().length() < 6 || password.toString().length() > 18 || password.toString().contains(" ")){
|
|
|
+ if (phone.toString().length() > 18 || phone.toString().length() < 3 || phone.toString().contains(" ")){
|
|
|
y = i + 1;
|
|
|
- result.append("第" + y +"条数据密码长度未在6~18位之间或有空格").append("\r\n");
|
|
|
+ result.append("第" + y +"条数据账号长度未在3~18位之间或有空格").append("\r\n");
|
|
|
isExist = true;
|
|
|
continue;
|
|
|
}
|
|
|
+ String idCardStr = phone.toString();
|
|
|
//插入数据库的信息
|
|
|
UserEntity tempUserDB = new UserEntity();
|
|
|
//设置组id,未分组时组id为0
|
|
|
- InstitutionEntity institutionEntity = this.institutionService.findByInstitutionNo(institutionNo);
|
|
|
+
|
|
|
tempUserDB.setInstitutionName(institutionEntity.getInstitutionName());
|
|
|
//姓名、账号、密码格式未效验
|
|
|
tempUserDB.setPetName(petName.toString());
|
|
|
tempUserDB.setPhone(phone.toString());
|
|
|
- tempUserDB.setPassword(DigestUtils.md5DigestAsHex(password.toString().getBytes(StandardCharsets.UTF_8)));
|
|
|
+ tempUserDB.setPassword(DigestUtils.md5DigestAsHex(idCardStr.substring(12).getBytes(StandardCharsets.UTF_8)));
|
|
|
tempUserDB.setGender(gender.toString());
|
|
|
tempUserDB.setInstitutionNo(institutionNo);
|
|
|
tempUserDB.setUserStatus(Constant.USER_STATUS_NORMAL);
|
|
|
- tempUserDB.setGId(orgNum.toString());
|
|
|
- tempUserDB.setStructureNo(orgNum.toString());
|
|
|
+ tempUserDB.setStructureNo(structureNo);
|
|
|
tempUserDB.setModel(mobile.toString());
|
|
|
tempUserDB.setRoleType(UserRole.COMMON.getType());
|
|
|
- String idCardStr = idCard.toString();
|
|
|
tempUserDB.setBirthday(idCardStr.substring(6,10)+"-"+idCardStr.substring(10,12)+"-"+idCardStr.substring(12,14));
|
|
|
tempUserDB.setIdCard(idCardStr);
|
|
|
//查看当前用户是否已经在数据库存在
|