更新站间数据

This commit is contained in:
DU 2021-01-25 14:47:57 +08:00
parent 04eb086254
commit 36b509ff40
3 changed files with 21 additions and 16 deletions

View File

@ -14,10 +14,10 @@ import springfox.documentation.annotations.ApiIgnore;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import java.util.List; import java.util.List;
@Api(tags = {"单位成员管理接口"}) @Api(tags = {"组织成员管理接口"})
@RestController @RestController
@RequestMapping("/api/company") @RequestMapping("/api/company")
public class CompanyController { public class OrgController {
@Autowired @Autowired
private IOrgUserService iOrgUserService; private IOrgUserService iOrgUserService;

View File

@ -38,7 +38,7 @@ public class OrgUserService implements IOrgUserService {
private ISysUserService iSysUserService; private ISysUserService iSysUserService;
@Autowired @Autowired
private OrgUserDAO departmentUserDAO; private OrgUserDAO orgUserDAO;
@Autowired @Autowired
private OrgLessonDAO orgLessonDAO; private OrgLessonDAO orgLessonDAO;
@ -143,7 +143,7 @@ public class OrgUserService implements IOrgUserService {
public boolean isCompanyUser(Long userId) { public boolean isCompanyUser(Long userId) {
OrgUserExample e = new OrgUserExample(); OrgUserExample e = new OrgUserExample();
e.createCriteria().andUserIdEqualTo(userId); e.createCriteria().andUserIdEqualTo(userId);
return departmentUserDAO.countByExample(e) > 0; return orgUserDAO.countByExample(e) > 0;
} }
//************************************部门管理********************************************** //************************************部门管理**********************************************
@ -257,7 +257,7 @@ public class OrgUserService implements IOrgUserService {
example.createCriteria() example.createCriteria()
.andUserIdEqualTo(userId) .andUserIdEqualTo(userId)
.andOrgIdEqualTo(departId); .andOrgIdEqualTo(departId);
List<OrgUser> ucrs = departmentUserDAO.selectByExample(example); List<OrgUser> ucrs = orgUserDAO.selectByExample(example);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(ucrs, "非部门" + departId + "内部用户"); BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(ucrs, "非部门" + departId + "内部用户");
return ucrs.get(0); return ucrs.get(0);
} }
@ -266,7 +266,7 @@ public class OrgUserService implements IOrgUserService {
public List<UserDepartRelVO> getDepartRefByUserId(Long userId) { public List<UserDepartRelVO> getDepartRefByUserId(Long userId) {
OrgUserExample e = new OrgUserExample(); OrgUserExample e = new OrgUserExample();
e.createCriteria().andUserIdEqualTo(userId).andRoleNotEqualTo(BusinessConsts.OrgRole.Admin.name()); e.createCriteria().andUserIdEqualTo(userId).andRoleNotEqualTo(BusinessConsts.OrgRole.Admin.name());
List<OrgUser> departmentUserRefs = this.departmentUserDAO.selectByExample(e); List<OrgUser> departmentUserRefs = this.orgUserDAO.selectByExample(e);
return UserDepartRelVO.convert2VOList(departmentUserRefs); return UserDepartRelVO.convert2VOList(departmentUserRefs);
} }
@ -278,7 +278,7 @@ public class OrgUserService implements IOrgUserService {
BusinessExceptionAssertEnum.INVALID_OPERATION.assertTrue(StringUtils.hasText(userRel.getRole()) && !Objects.equals(userRel.getRole(),BusinessConsts.OrgRole.Student), "非部门管理员无法操作"); BusinessExceptionAssertEnum.INVALID_OPERATION.assertTrue(StringUtils.hasText(userRel.getRole()) && !Objects.equals(userRel.getRole(),BusinessConsts.OrgRole.Student), "非部门管理员无法操作");
var departmentUser = getDepartUseRelEntity(userDepartRelVO.getUserId(), userDepartRelVO.getDepartmentId()); var departmentUser = getDepartUseRelEntity(userDepartRelVO.getUserId(), userDepartRelVO.getDepartmentId());
BusinessExceptionAssertEnum.INVALID_OPERATION.assertNull(departmentUser, "已存在的部门成员"); BusinessExceptionAssertEnum.INVALID_OPERATION.assertNull(departmentUser, "已存在的部门成员");
departmentUserDAO.insertSelective(userDepartRelVO.toDB()); orgUserDAO.insertSelective(userDepartRelVO.toDB());
} }
/**更新部门-职位-用户关系*/ /**更新部门-职位-用户关系*/
@ -300,13 +300,13 @@ public class OrgUserService implements IOrgUserService {
BusinessExceptionAssertEnum.INVALID_OPERATION.assertTrue(StringUtils.hasText(userRel.getRole()) && !Objects.equals(userRel.getRole(),BusinessConsts.OrgRole.Student), "非部门管理员无法操作"); BusinessExceptionAssertEnum.INVALID_OPERATION.assertTrue(StringUtils.hasText(userRel.getRole()) && !Objects.equals(userRel.getRole(),BusinessConsts.OrgRole.Student), "非部门管理员无法操作");
OrgUserExample example = new OrgUserExample(); OrgUserExample example = new OrgUserExample();
example.createCriteria().andOrgIdEqualTo(userDepartRelVO.getDepartmentId()).andUserIdEqualTo(userDepartRelVO.getUserId()); example.createCriteria().andOrgIdEqualTo(userDepartRelVO.getDepartmentId()).andUserIdEqualTo(userDepartRelVO.getUserId());
departmentUserDAO.deleteByExample(example); orgUserDAO.deleteByExample(example);
} }
@Override @Override
public List<CompanyDepartUserVO> getUserCompanyDeparts(UserVO user, Integer companyId) { public List<CompanyDepartUserVO> getUserCompanyDeparts(UserVO user, Integer companyId) {
//根据公司id和用户id查询用户企业详细信息 //根据公司id和用户id查询用户企业详细信息
return departmentUserDAO.getUserCompanyDeparts(companyId,user.getId()); return orgUserDAO.getUserCompanyDeparts(companyId,user.getId());
} }
@Override @Override
@ -316,7 +316,7 @@ public class OrgUserService implements IOrgUserService {
companyUserQueryVO.setDepartmentId(departId); companyUserQueryVO.setDepartmentId(departId);
companyUserQueryVO.setOrgRole(BusinessConsts.OrgRole.Student); companyUserQueryVO.setOrgRole(BusinessConsts.OrgRole.Student);
PageHelper.startPage(companyUserQueryVO.getPageNum(), companyUserQueryVO.getPageSize()); PageHelper.startPage(companyUserQueryVO.getPageNum(), companyUserQueryVO.getPageSize());
Page<CompanyDepartUserVO> page = (Page<CompanyDepartUserVO>) departmentUserDAO.getCompanyDepartUsers(companyUserQueryVO); Page<CompanyDepartUserVO> page = (Page<CompanyDepartUserVO>) orgUserDAO.getCompanyDepartUsers(companyUserQueryVO);
return PageVO.convert(page); return PageVO.convert(page);
} }
@ -330,7 +330,7 @@ public class OrgUserService implements IOrgUserService {
BusinessExceptionAssertEnum.INVALID_OPERATION.assertEquals(user.getCompanyId(), companyId, "非同单位成员无法操作"); BusinessExceptionAssertEnum.INVALID_OPERATION.assertEquals(user.getCompanyId(), companyId, "非同单位成员无法操作");
OrgUserExample oue = new OrgUserExample(); OrgUserExample oue = new OrgUserExample();
oue.createCriteria().andOrgIdEqualTo(companyId).andRoleEqualTo(BusinessConsts.OrgRole.Admin.name()); oue.createCriteria().andOrgIdEqualTo(companyId).andRoleEqualTo(BusinessConsts.OrgRole.Admin.name());
BusinessExceptionAssertEnum.INVALID_OPERATION.assertTrue(departmentUserDAO.countByExample(oue)> 0,"非本单位管理员"); BusinessExceptionAssertEnum.INVALID_OPERATION.assertTrue(orgUserDAO.countByExample(oue)> 0,"非本单位管理员");
//验证是否存在并导入新的年级和班级 //验证是否存在并导入新的年级和班级
var departmentExample = new OrgExample(); var departmentExample = new OrgExample();
departmentExample.createCriteria() departmentExample.createCriteria()
@ -346,7 +346,7 @@ public class OrgUserService implements IOrgUserService {
childDepart = new DepartmentVO(importCompanyUserVO.getDepart(), parentDepart.getId(),companyId); childDepart = new DepartmentVO(importCompanyUserVO.getDepart(), parentDepart.getId(),companyId);
createDepart(childDepart); createDepart(childDepart);
UserDepartRelVO userDepartRelVO = new UserDepartRelVO(user.getId(), childDepart.getId(), BusinessConsts.OrgRole.Teacher.name()); UserDepartRelVO userDepartRelVO = new UserDepartRelVO(user.getId(), childDepart.getId(), BusinessConsts.OrgRole.Teacher.name());
departmentUserDAO.insertSelective(userDepartRelVO.toDB()); orgUserDAO.insertSelective(userDepartRelVO.toDB());
} else { } else {
parentDepart = new DepartmentVO(importParentDepart.get(0)); parentDepart = new DepartmentVO(importParentDepart.get(0));
departmentExample.clear(); departmentExample.clear();
@ -363,7 +363,7 @@ public class OrgUserService implements IOrgUserService {
childDepart = new DepartmentVO(importCompanyUserVO.getDepart(), parentDepart.getId(), companyId); childDepart = new DepartmentVO(importCompanyUserVO.getDepart(), parentDepart.getId(), companyId);
createDepart(childDepart); createDepart(childDepart);
UserDepartRelVO userDepartRelVO = new UserDepartRelVO(user.getId(), childDepart.getId(), BusinessConsts.OrgRole.Teacher.name()); UserDepartRelVO userDepartRelVO = new UserDepartRelVO(user.getId(), childDepart.getId(), BusinessConsts.OrgRole.Teacher.name());
departmentUserDAO.insertSelective(userDepartRelVO.toDB()); orgUserDAO.insertSelective(userDepartRelVO.toDB());
} }
//构建系统用户对象 //构建系统用户对象
@ -374,11 +374,11 @@ public class OrgUserService implements IOrgUserService {
iSysUserService.createUser(sysUser); iSysUserService.createUser(sysUser);
userVO = new UserVO(sysUser); userVO = new UserVO(sysUser);
UserDepartRelVO userDepartRelVO = new UserDepartRelVO(userVO.getId(), childDepart.getId(), BusinessConsts.OrgRole.Student.name()); UserDepartRelVO userDepartRelVO = new UserDepartRelVO(userVO.getId(), childDepart.getId(), BusinessConsts.OrgRole.Student.name());
departmentUserDAO.insertSelective(userDepartRelVO.toDB()); orgUserDAO.insertSelective(userDepartRelVO.toDB());
} else { } else {
OrgUserExample e = new OrgUserExample(); OrgUserExample e = new OrgUserExample();
e.createCriteria().andUserIdEqualTo(sysUser.getId()); e.createCriteria().andUserIdEqualTo(sysUser.getId());
List<OrgUser> orgUsers = departmentUserDAO.selectByExample(e); List<OrgUser> orgUsers = orgUserDAO.selectByExample(e);
BusinessExceptionAssertEnum.INVALID_OPERATION.assertCollectionNotEmpty(orgUsers, sysUser.getAccount() + "账号重复"); BusinessExceptionAssertEnum.INVALID_OPERATION.assertCollectionNotEmpty(orgUsers, sysUser.getAccount() + "账号重复");
OrgExample oe = new OrgExample(); OrgExample oe = new OrgExample();
oe.createCriteria().andRootIdEqualTo(companyId); oe.createCriteria().andRootIdEqualTo(companyId);
@ -386,7 +386,7 @@ public class OrgUserService implements IOrgUserService {
BusinessExceptionAssertEnum.INVALID_OPERATION.assertTrue(orgUsers.stream().allMatch(orgUser -> orgIds.contains(orgUser.getOrgId())), sysUser.getAccount() + "账号重复"); BusinessExceptionAssertEnum.INVALID_OPERATION.assertTrue(orgUsers.stream().allMatch(orgUser -> orgIds.contains(orgUser.getOrgId())), sysUser.getAccount() + "账号重复");
if (orgUsers.stream().anyMatch(orgUser -> Objects.equals(orgUser.getOrgId(), childDepart.getId()))) return; if (orgUsers.stream().anyMatch(orgUser -> Objects.equals(orgUser.getOrgId(), childDepart.getId()))) return;
UserDepartRelVO userDepartRelVO = new UserDepartRelVO(userVO.getId(), childDepart.getId(), BusinessConsts.OrgRole.Student.name()); UserDepartRelVO userDepartRelVO = new UserDepartRelVO(userVO.getId(), childDepart.getId(), BusinessConsts.OrgRole.Student.name());
departmentUserDAO.insertSelective(userDepartRelVO.toDB()); orgUserDAO.insertSelective(userDepartRelVO.toDB());
} }
}); });
} }

View File

@ -16,6 +16,8 @@ import com.github.pagehelper.PageHelper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.List; import java.util.List;
@ -28,6 +30,7 @@ public class RunPlanRunlevelService implements IRunPlanRunlevelService {
private RunPlanRunlevelDAO runPlanRunlevelDAO; private RunPlanRunlevelDAO runPlanRunlevelDAO;
@Override @Override
@Transactional
public void createUserRunlevel(RunPlanRunlevelVO runLevelVO) { public void createUserRunlevel(RunPlanRunlevelVO runLevelVO) {
BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNotTrue(isExisted(runLevelVO)); BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNotTrue(isExisted(runLevelVO));
RunPlanRunlevel runLevel = runLevelVO.convert2Entity(); RunPlanRunlevel runLevel = runLevelVO.convert2Entity();
@ -42,7 +45,9 @@ public class RunPlanRunlevelService implements IRunPlanRunlevelService {
} }
@Override @Override
@Transactional
public void updateRefLevels(Long userId, Long mapId, List<RunPlanRunlevelVO> list) { public void updateRefLevels(Long userId, Long mapId, List<RunPlanRunlevelVO> list) {
BusinessExceptionAssertEnum.INVALID_OPERATION.assertNotTrue(CollectionUtils.isEmpty(list),"操作失败,数据为空");
list.forEach(runLevelVO -> { list.forEach(runLevelVO -> {
RunPlanRunlevel runLevel = this.getEntityById(runLevelVO.getId()); RunPlanRunlevel runLevel = this.getEntityById(runLevelVO.getId());
if (runLevel.getMapId().equals(mapId) && runLevel.getUserId().equals(userId)) { if (runLevel.getMapId().equals(mapId) && runLevel.getUserId().equals(userId)) {