|
@@ -405,79 +405,7 @@ public class UserController {
|
|
|
|
|
|
@RequestMapping("/initSystemForAd")
|
|
|
public HttpRespMsg initSystemForAd(String companyName) throws Exception {
|
|
|
-<<<<<<< HEAD
|
|
|
return userService.initSystemForAd(companyName);
|
|
|
-=======
|
|
|
- HttpRespMsg msg = new HttpRespMsg();
|
|
|
- Company company = new Company().setCompanyName(companyName)
|
|
|
- .setExpirationDate(LocalDateTime.now().plusDays(36500));
|
|
|
- company.setPackageWorktime(1);
|
|
|
- companyMapper.insert(company);
|
|
|
- //生成工作时长
|
|
|
- TimeType timeType = new TimeType();
|
|
|
- timeType.setCompanyId(company.getId());
|
|
|
- timeTypeMapper.insert(timeType);
|
|
|
- SysRole smanager = sysRoleService.generateDefaultRoles(company.getId());
|
|
|
- //生成项目的成本基线默认条目
|
|
|
- String[] array = Constant.DEFAULT_BASE_COST_ITEMS;
|
|
|
- for (String baseItem : array) {
|
|
|
- ProjectBasecostSetting setting = new ProjectBasecostSetting();
|
|
|
- setting.setName(baseItem);
|
|
|
- setting.setCompanyId(company.getId());
|
|
|
- projectBasecostSettingMapper.insert(setting);
|
|
|
- }
|
|
|
- //todo: 生成项目报表服务默认条目
|
|
|
- Integer[] arrayInteger = new Integer[]{1, 2, 3, 4, 7};
|
|
|
- for (Integer integerItem : arrayInteger) {
|
|
|
- CompanyReport companyReport = new CompanyReport();
|
|
|
- companyReport.setCompanyId(company.getId());
|
|
|
- companyReport.setReportFormId(integerItem);
|
|
|
- companyReportMapper.insert(companyReport);
|
|
|
- }
|
|
|
- SysRole role = sysRoleMapper.selectOne(new QueryWrapper<SysRole>().eq("company_id", company.getId()).eq("rolename","普通员工"));
|
|
|
- List<JSONObject> deptArrays = userService.ldapGetOU();
|
|
|
- for (JSONObject dept : deptArrays) {
|
|
|
- Department department=new Department();
|
|
|
- department.setDepartmentName(dept.getString("name"))
|
|
|
- .setCompanyId(company.getId());
|
|
|
- String canonicalName = dept.getString("canonicalName");
|
|
|
- String[] split = canonicalName.split("/");
|
|
|
- if(split.length>2){
|
|
|
- String s = split[split.length - 2];
|
|
|
- Department one = departmentMapper.selectOne(new QueryWrapper<Department>().eq("department_name", s).eq("company_id", company.getId()));
|
|
|
- if(Optional.of(one).isPresent()){
|
|
|
- department.setSuperiorId(one.getDepartmentId());
|
|
|
- }
|
|
|
- }
|
|
|
- departmentMapper.insert(department);
|
|
|
- }
|
|
|
- List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", company.getId()));
|
|
|
- List<JSONObject> userArrays = userService.getUser();
|
|
|
- for (JSONObject user : userArrays) {
|
|
|
- User u=new User();
|
|
|
- u.setId(SnowFlake.nextId()+"")
|
|
|
- .setName(user.getString("name"))
|
|
|
- .setPhone(user.getString("userPrincipalName"))
|
|
|
- .setId(SnowFlake.nextId()+"")
|
|
|
- .setRoleId(role.getId())//默认普通员工
|
|
|
- .setRoleName(role.getRolename())
|
|
|
- .setCompanyId(company.getId())
|
|
|
- .setColor(ColorUtil.randomColor())
|
|
|
- .setPassword(MD5Util.getPassword("000000"));
|
|
|
- String distinguishedName = user.getString("distinguishedName");
|
|
|
- String[] split = distinguishedName.split(",");
|
|
|
- List<String> list = Arrays.asList(split);
|
|
|
- List<String> collect = list.stream().filter(l -> l.contains("OU=")).collect(Collectors.toList());
|
|
|
- if(collect.size()>0){
|
|
|
- String s = collect.get(0).replaceAll("OU=", "");
|
|
|
- Department one = departmentMapper.selectOne(new QueryWrapper<Department>().eq("department_name", s).eq("company_id", company.getId()));
|
|
|
- if(one!=null){
|
|
|
- u.setDepartmentId(one.getDepartmentId()).setDepartmentName(one.getDepartmentName()).setDepartmentCascade(convertDepartmentIdToCascade(one.getDepartmentId(),departmentList));
|
|
|
- }
|
|
|
- userService.save(u);
|
|
|
- }
|
|
|
- }
|
|
|
- return msg;
|
|
|
}
|
|
|
|
|
|
@RequestMapping("/updateUserDeptHierarchy")
|
|
@@ -512,7 +440,6 @@ public class UserController {
|
|
|
}
|
|
|
}
|
|
|
return cascade.toString();
|
|
|
->>>>>>> e5e8ccbc655cdfebeb0ce3a15115545fe8aacc24
|
|
|
}
|
|
|
|
|
|
private Department findById(int id, List<Department> allList) {
|