|
@@ -13,10 +13,7 @@ import com.ydtech.exception.SystemException;
|
|
|
import com.ydtech.modules.admin.model.*;
|
|
import com.ydtech.modules.admin.model.*;
|
|
|
import com.ydtech.modules.admin.model.dto.AgentUserDto;
|
|
import com.ydtech.modules.admin.model.dto.AgentUserDto;
|
|
|
import com.ydtech.modules.admin.model.dto.SysUserDto;
|
|
import com.ydtech.modules.admin.model.dto.SysUserDto;
|
|
|
-import com.ydtech.modules.admin.service.SysDeptService;
|
|
|
|
|
-import com.ydtech.modules.admin.service.SysUserInfoService;
|
|
|
|
|
-import com.ydtech.modules.admin.service.SysUserRoleService;
|
|
|
|
|
-import com.ydtech.modules.admin.service.SysUserService;
|
|
|
|
|
|
|
+import com.ydtech.modules.admin.service.*;
|
|
|
import com.ydtech.modules.admin.model.vo.SysUserBaseVO;
|
|
import com.ydtech.modules.admin.model.vo.SysUserBaseVO;
|
|
|
import com.ydtech.modules.admin.model.vo.SysUserVO;
|
|
import com.ydtech.modules.admin.model.vo.SysUserVO;
|
|
|
import com.ydtech.modules.base.controller.BaseController;
|
|
import com.ydtech.modules.base.controller.BaseController;
|
|
@@ -26,18 +23,23 @@ import com.ydtech.modules.esm.model.EsmUserReferrer;
|
|
|
import com.ydtech.modules.esm.model.vo.UserRegistVO;
|
|
import com.ydtech.modules.esm.model.vo.UserRegistVO;
|
|
|
import com.ydtech.modules.esm.service.EsmUserInternalService;
|
|
import com.ydtech.modules.esm.service.EsmUserInternalService;
|
|
|
import com.ydtech.modules.esm.service.EsmUserReferrerService;
|
|
import com.ydtech.modules.esm.service.EsmUserReferrerService;
|
|
|
|
|
+import com.ydtech.modules.inv.model.dto.InvInsChinaCoalExcelDto;
|
|
|
import com.ydtech.security.utils.PasswordUtils;
|
|
import com.ydtech.security.utils.PasswordUtils;
|
|
|
import com.ydtech.utils.StringUtils;
|
|
import com.ydtech.utils.StringUtils;
|
|
|
|
|
+import com.ydtech.utils.excel.ExcelUtils2;
|
|
|
import com.ydtech.utils.idgen.IdGenerate;
|
|
import com.ydtech.utils.idgen.IdGenerate;
|
|
|
import io.swagger.annotations.*;
|
|
import io.swagger.annotations.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
import static com.ydtech.constants.RedisConstant.PHONE_VERIFICATION_CODE_KEY;
|
|
import static com.ydtech.constants.RedisConstant.PHONE_VERIFICATION_CODE_KEY;
|
|
|
|
|
|
|
@@ -68,6 +70,8 @@ public class SysUserController extends BaseController {
|
|
|
private StringRedisTemplate stringRedisTemplate;
|
|
private StringRedisTemplate stringRedisTemplate;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private EsmUserReferrerService esmUserReferrerService;
|
|
private EsmUserReferrerService esmUserReferrerService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SysRoleService sysRoleService;
|
|
|
|
|
|
|
|
|
|
|
|
|
// @PreAuthorize("hasAuthority('sys:user:delete')")
|
|
// @PreAuthorize("hasAuthority('sys:user:delete')")
|
|
@@ -595,6 +599,83 @@ public class SysUserController extends BaseController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping(value = "/newUserImport")
|
|
|
|
|
+ @ApiOperation(value = "新用户导入")
|
|
|
|
|
+ @ApiImplicitParams({
|
|
|
|
|
+ @ApiImplicitParam(name = "file", value = "excel文件", required = true, dataType = "__file"),
|
|
|
|
|
+ @ApiImplicitParam(name = "deptId", value = "机构部门ID", required = true, dataType = "String",paramType = "formData")
|
|
|
|
|
+ })
|
|
|
|
|
+ @Transactional
|
|
|
|
|
+ public HttpResult newUserImport(@RequestPart MultipartFile file, @RequestParam String deptId) {
|
|
|
|
|
+
|
|
|
|
|
+ SysDept sd = sysDeptService.getById(deptId);
|
|
|
|
|
+ if(null == sd) return HttpResult.error("机构部门不存在");
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ List<SysUser> userList = ExcelUtils2.importExcel(file, SysUser.class, 0, 1, 1);
|
|
|
|
|
+ userList = userList.stream().filter(l -> StringUtils.isNotEmpty(l.getMobile())).collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ userList.stream().forEach(a ->{
|
|
|
|
|
+
|
|
|
|
|
+ if (StringUtils.isNullOrEmpty(a.getMobile())) throw new SystemException("手机不能为空");
|
|
|
|
|
+ //处理密码
|
|
|
|
|
+ if (StringUtils.isNotEmpty(a.getPassword())) {
|
|
|
|
|
+ String salt = PasswordUtils.getSalt();
|
|
|
|
|
+ String pwd = PasswordUtils.encode(a.getPassword(), salt);
|
|
|
|
|
+ a.setPassword(pwd);
|
|
|
|
|
+ a.setSalt(salt);
|
|
|
|
|
+ }
|
|
|
|
|
+ a.setDeptId(sd.getId());
|
|
|
|
|
+ a.setDeptName(sd.getName());
|
|
|
|
|
+
|
|
|
|
|
+ //获取角色
|
|
|
|
|
+ LambdaQueryWrapper<SysRole> lqwRole = new LambdaQueryWrapper<>();
|
|
|
|
|
+ lqwRole.like(SysRole::getName,a.getRoleName());
|
|
|
|
|
+ SysRole sr = sysRoleService.getOne(lqwRole);
|
|
|
|
|
+ a.setRoleId(sr.getId().toString());
|
|
|
|
|
+ a.setRoleName(sr.getName());
|
|
|
|
|
+
|
|
|
|
|
+ //状态
|
|
|
|
|
+ if(a.getExcelStatus().equals("正常")){
|
|
|
|
|
+ a.setStatus(1);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(a.getExcelStatus().equals("新注册")){
|
|
|
|
|
+ a.setStatus(2);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //性别
|
|
|
|
|
+ if(a.getSex().equals("未知")){
|
|
|
|
|
+ a.setSex("U");
|
|
|
|
|
+ }
|
|
|
|
|
+ if(a.getSex().equals("男")){
|
|
|
|
|
+ a.setSex("M");
|
|
|
|
|
+ }
|
|
|
|
|
+ if(a.getSex().equals("女")){
|
|
|
|
|
+ a.setSex("W");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if (StringUtils.isNullOrEmpty(a.getDeptId())) throw new SystemException("机构ID不能为空");
|
|
|
|
|
+
|
|
|
|
|
+ sysUserService.saveUser(a);
|
|
|
|
|
+
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
|
+ throw new SystemException(e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ return HttpResult.ok("导入成功");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* ==================用户详情=================
|
|
* ==================用户详情=================
|
|
|
*/
|
|
*/
|