|
|
@@ -16,6 +16,7 @@ import com.tianhu.system.api.domain.SysUser;
|
|
|
import com.tianhu.system.api.model.LoginUser;
|
|
|
import com.tianhu.system.companyAuth.service.IOwnAuthService;
|
|
|
import com.tianhu.system.domain.*;
|
|
|
+import com.tianhu.system.mapper.SysRoleMapper;
|
|
|
import com.tianhu.system.service.*;
|
|
|
import com.tianhu.system.utils.FlowableService;
|
|
|
import org.json.JSONObject;
|
|
|
@@ -65,6 +66,8 @@ public class OwnAuthController extends BaseController {
|
|
|
private ISysConfigService configService;
|
|
|
@Autowired
|
|
|
private RemoteFileService remoteFileService;
|
|
|
+ @Autowired
|
|
|
+ private SysRoleMapper roleMapper;
|
|
|
/**
|
|
|
* CFCA (是否开启生产环境配置 true 开启 false 关闭)
|
|
|
*/
|
|
|
@@ -225,8 +228,14 @@ public class OwnAuthController extends BaseController {
|
|
|
List<Map<String,String>> szzssqList = (List<Map<String, String>>) map.get("szzssqList");
|
|
|
//其他附件
|
|
|
List<Map<String,String>> qtfjList = (List<Map<String, String>>) map.get("qtfjList");
|
|
|
+ String scyId = null;
|
|
|
SysCompany SysCompany = new SysCompany();
|
|
|
- String scyId = IdUtils.fastSimpleUUID();
|
|
|
+ if(use.getCompanyId() == null){
|
|
|
+ scyId = IdUtils.fastSimpleUUID();
|
|
|
+
|
|
|
+ }else{
|
|
|
+ scyId = use.getCompanyId();
|
|
|
+ }
|
|
|
SysCompany.setScyId(scyId);
|
|
|
SysCompany.setScyName(scyName);
|
|
|
SysCompany.setScySocialCode(scySocialCode);
|
|
|
@@ -293,23 +302,35 @@ public class OwnAuthController extends BaseController {
|
|
|
Date currentTime = DateUtils.getNowDate();
|
|
|
SysCompany.setCreateTime(currentTime);
|
|
|
sysCompanyService.createSysCompany(SysCompany);
|
|
|
- //创建部门
|
|
|
- String alternateNumber = IdUtils.fastSimpleUUID();
|
|
|
+ //部门id
|
|
|
SysDept dept = new SysDept();
|
|
|
dept.setCompanyId(scyId);
|
|
|
- dept.setDeptName(scyName);
|
|
|
- dept.setParentId(defaultId);
|
|
|
- dept.setAncestors(defaultAn);
|
|
|
- dept.setOrderNum(defaultOrder);
|
|
|
- dept.setCreateBy(use.getUserId()+"");
|
|
|
- dept.setAlternateNumber(alternateNumber);
|
|
|
- deptService.insertDept(dept);
|
|
|
- List<SysDept> deptList= deptService.selectDeptList(dept);
|
|
|
- //部门id
|
|
|
+ List<SysDept> deptList = deptService.selectDeptList(dept);
|
|
|
+ // 修改部门名称
|
|
|
+ if (deptList.size() > 0) {
|
|
|
+ dept.setDeptName(scyName);
|
|
|
+ dept.setDeptId(deptList.get(0).getDeptId());
|
|
|
+ deptService.updateDept(dept);
|
|
|
+ // 创建部门
|
|
|
+ } else {
|
|
|
+ String alternateNumber = IdUtils.fastSimpleUUID();
|
|
|
+ dept.setAlternateNumber(alternateNumber);
|
|
|
+ dept.setParentId(defaultId);
|
|
|
+ dept.setAncestors(defaultAn);
|
|
|
+ dept.setOrderNum(defaultOrder);
|
|
|
+ deptService.insertDept(dept);
|
|
|
+ deptList = deptService.selectDeptList(dept);
|
|
|
+ }
|
|
|
Long deptId = deptList.get(0).getDeptId();
|
|
|
+
|
|
|
//创建角色
|
|
|
SysRole sysRole = new SysRole();
|
|
|
sysRole.setCompanyId(scyId);
|
|
|
+ List<SysRole> roleList = roleService.selectRoleList(sysRole);
|
|
|
+ if (roleList.size() > 0) {
|
|
|
+ sysRole.setRoleName(scyName);
|
|
|
+ roleMapper.updateRole(sysRole);
|
|
|
+ }else{
|
|
|
sysRole.setRoleName(scyName);
|
|
|
sysRole.setRoleSort(defaultOrder);
|
|
|
sysRole.setRoleKey(scyName);
|
|
|
@@ -318,10 +339,10 @@ public class OwnAuthController extends BaseController {
|
|
|
sysRole.setDeptCheckStrictly(isCheck);
|
|
|
sysRole.setStatus(status);
|
|
|
sysRole.setStatus("0");
|
|
|
- sysRole.setCreateBy(use.getUserId()+"");
|
|
|
+ sysRole.setCreateBy(use.getUserId() + "");
|
|
|
sysRole.setIsAuto("1");
|
|
|
companyService.insertRole(sysRole);
|
|
|
- List<SysRole> roleList= roleService.selectRoleList(sysRole);
|
|
|
+ }
|
|
|
//TODO
|
|
|
//角色权限未控制
|
|
|
//角色id
|
|
|
@@ -411,7 +432,7 @@ public class OwnAuthController extends BaseController {
|
|
|
if (!"200".equals(flowableRes.get("code"))) {
|
|
|
throw new Exception("审批数据新增失败!");
|
|
|
}
|
|
|
- flowableRes = flowableService.addFlowableGroup(alternateNumber, dept.getDeptName());
|
|
|
+ flowableRes = flowableService.addFlowableGroup(deptList.get(0).getAlternateNumber(), dept.getDeptName());
|
|
|
if (!"200".equals(flowableRes.get("code"))) {
|
|
|
throw new Exception("审批数据新增失败!");
|
|
|
}
|