Commit 6daca1dd authored by 赵啸非's avatar 赵啸非

添加批量导入

parent c08f11df
...@@ -40,8 +40,6 @@ import java.util.List; ...@@ -40,8 +40,6 @@ import java.util.List;
@Service("workmanService") @Service("workmanService")
public class WorkmanServiceImpl extends AbstractCRUDCacheServiceImpl<WorkmanDao, WorkmanEntity, Long> implements WorkmanService { public class WorkmanServiceImpl extends AbstractCRUDCacheServiceImpl<WorkmanDao, WorkmanEntity, Long> implements WorkmanService {
@Autowired
private UserService userService;
@Autowired @Autowired
private UploadService uploadService; private UploadService uploadService;
......
...@@ -19,7 +19,8 @@ Content-Type: application/json ...@@ -19,7 +19,8 @@ Content-Type: application/json
{ {
"page":1, "page":1,
"size":10 "size":-1,
"hallId": 11
} }
......
...@@ -24,10 +24,12 @@ public class UserEntity extends UserVo implements IUser { ...@@ -24,10 +24,12 @@ public class UserEntity extends UserVo implements IUser {
/** /**
* 登录名 * 登录名
*/ */
@Excel(name = "用户账号")
private String loginName; private String loginName;
/** /**
* 登录密码,使用md5双次加密 * 登录密码,使用md5双次加密
*/ */
@Excel(name = "初始密码")
@JSONField(serialize = false) @JSONField(serialize = false)
private String loginPwd; private String loginPwd;
/** /**
...@@ -42,6 +44,7 @@ public class UserEntity extends UserVo implements IUser { ...@@ -42,6 +44,7 @@ public class UserEntity extends UserVo implements IUser {
/** /**
* 用户手机号 * 用户手机号
*/ */
@Excel(name = "电话号码")
private String mobile; private String mobile;
/** /**
* 用户联系电话 * 用户联系电话
......
...@@ -91,7 +91,7 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity ...@@ -91,7 +91,7 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
} else { } else {
entity.setUserType(UserType.CUSTOMER.getValue()); entity.setUserType(UserType.CUSTOMER.getValue());
} }
if(StringUtils.isNotEmpty(entity.getAreaCodes())){ if (StringUtils.isNotEmpty(entity.getAreaCodes())) {
List<String> areaCodeList = Arrays.asList(entity.getAreaCodes().split(",")); List<String> areaCodeList = Arrays.asList(entity.getAreaCodes().split(","));
String resp = areaService.getFlatSitesByAreaCodes(new AreaQuery().areaCodeList(areaCodeList), null); String resp = areaService.getFlatSitesByAreaCodes(new AreaQuery().areaCodeList(areaCodeList), null);
JSONObject apiResp = JSON.parseObject(resp); JSONObject apiResp = JSON.parseObject(resp);
...@@ -107,7 +107,7 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity ...@@ -107,7 +107,7 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
@Override @Override
protected void saveBefore(UserEntity entity, Context context) throws AppException { protected void saveBefore(UserEntity entity, Context context) throws AppException {
UserEntity sysUser = this.findByLoginName(entity.getLoginName()); UserEntity sysUser = this.findByLoginName(entity.getLoginName());
if(sysUser!=null){ if (sysUser != null) {
throw new AppException("用户名重复"); throw new AppException("用户名重复");
} }
this.doHandlerUser(entity); this.doHandlerUser(entity);
...@@ -270,8 +270,8 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity ...@@ -270,8 +270,8 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
public void synchSitesAuth() throws AppException { public void synchSitesAuth() throws AppException {
UserEntity query = new UserEntity(); UserEntity query = new UserEntity();
List<UserEntity> all = this.find(query); List<UserEntity> all = this.find(query);
all.forEach(item->{ all.forEach(item -> {
if(StringUtils.isNotEmpty(item.getAreaCodes())){ if (StringUtils.isNotEmpty(item.getAreaCodes())) {
List<String> areaCodeList = Arrays.asList(item.getAreaCodes().split(",")); List<String> areaCodeList = Arrays.asList(item.getAreaCodes().split(","));
String resp = areaService.getFlatSitesByAreaCodes(new AreaQuery().areaCodeList(areaCodeList), null); String resp = areaService.getFlatSitesByAreaCodes(new AreaQuery().areaCodeList(areaCodeList), null);
JSONObject apiResp = JSON.parseObject(resp); JSONObject apiResp = JSON.parseObject(resp);
...@@ -291,10 +291,10 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity ...@@ -291,10 +291,10 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
@Override @Override
public boolean resetUserPwd(String loginName, String newPwd, Context context) throws AppException { public boolean resetUserPwd(String loginName, String newPwd, Context context) throws AppException {
if(context==null){ if (context == null) {
throw new AppException("登录过期!"); throw new AppException("登录过期!");
} }
if(context.getUser().getId()!=1){ if (context.getUser().getId() != 1) {
throw new AppException("当前用户非管理员,不能使用此功能"); throw new AppException("当前用户非管理员,不能使用此功能");
} }
UserEntity sysUser = this.findByLoginName(loginName); UserEntity sysUser = this.findByLoginName(loginName);
...@@ -319,4 +319,64 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity ...@@ -319,4 +319,64 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
authTokenService.setUser(userEntity); authTokenService.setUser(userEntity);
}); });
} }
/**
* @param list
* @param updateSupport
* @param context
* @return
*/
@Override
public String importList(List<UserEntity> list, Boolean updateSupport, Context context) {
if (ObjectUtils.isEmpty(list)) {
throw new AppException("导入数据不能为空!");
}
int successNum = 0;
int failureNum = 0;
StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder();
StringBuilder failureDetailMsg = new StringBuilder();
for (UserEntity entity : list) {
try {
//重新构建数据
entity.setLoginName(StrUtil.cleanBlank(entity.getLoginName()));
entity.setRealName(entity.getLoginName());
entity.setUserType(1);
entity.setPhone(entity.getPhone());
entity.setSiteIds("1");
entity.setAreaCodes("511500000000");
entity.setAreaNames("[{\"areaCode\":\"511500000000\",\"label\":\"宜宾市\"}]");
entity.setStatus(1);
entity.setCreateUserId(context == null ? 1L : context.getUser() == null ? 1L : context.getUser().getId());
entity.setCreateTime(new Date());
entity.setLoginPwd(SecurityUtil.md5DoubleEncoding(entity.getLoginPwd()));
int insert = this.getDao().insert(entity);
if (insert >0) {
successNum++;
RoleUserQuery roleUserQuery = new RoleUserQuery();
roleUserQuery.setUserId(entity.getId());
roleUserQuery.setRoleIdList(Arrays.asList(4L));
roleUserService.assignRoleToUser(roleUserQuery);
}
} catch (Exception e) {
log.error("导入异常", e);
failureNum++;
failureDetailMsg.append("\n");
failureDetailMsg.append(String.format("导入人员数据失败!用户名:%s", entity.getRealName()));
failureDetailMsg.append("\n");
}
}
successMsg.insert(0, "数据导入成功!共 " + successNum + " 条");
if (failureNum > 0) {
failureMsg.insert(0, "导入失败!共 " + failureNum + " 条数据格式不正确");
successMsg.append("\n");
successMsg.append(failureMsg);
successMsg.append(failureDetailMsg);
} else {
}
return successMsg.toString();
}
} }
\ No newline at end of file
...@@ -258,4 +258,16 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic ...@@ -258,4 +258,16 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic
} }
return ret.toJSONString(); return ret.toJSONString();
} }
/**
* @param list
* @param updateSupport
* @param context
* @throws AppException
*/
@Override
public void doImportDataBefore(List<UserEntity> list, boolean updateSupport, Context context) throws AppException {
super.doImportDataBefore(list, updateSupport, context);
}
} }
\ No newline at end of file
...@@ -115,6 +115,15 @@ spring: ...@@ -115,6 +115,15 @@ spring:
metadata: metadata:
response-timeout: 200000 response-timeout: 200000
connect-timeout: 200000 connect-timeout: 200000
# 证照打印
- id: smart-office-manager
#uri: http://192.168.0.98:21085
uri: lb://smart-office-manager
predicates:
- Path=/office/**
metadata:
response-timeout: 200000
connect-timeout: 200000
nacos: nacos:
# Nacos 作为注册中心的配置项,对应 NacosDiscoveryProperties 配置类 # Nacos 作为注册中心的配置项,对应 NacosDiscoveryProperties 配置类
discovery: discovery:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment