parent
3503b1a504
commit
58b6768ad1
@ -0,0 +1,233 @@ |
||||
package com.keyware.htey.controller.project; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.HashSet; |
||||
import java.util.Iterator; |
||||
import java.util.List; |
||||
import java.util.Objects; |
||||
import java.util.stream.Collectors; |
||||
|
||||
import javax.annotation.Resource; |
||||
|
||||
import com.keyware.htey.entity.department.Department; |
||||
import com.keyware.htey.entity.organizeassets.OFourColum; |
||||
import com.keyware.htey.entity.user.User; |
||||
import com.keyware.htey.service.itf.DepartmentService; |
||||
import com.keyware.htey.service.itf.OFourColumService; |
||||
import com.keyware.htey.service.itf.UserService; |
||||
import com.keyware.htey.utli.Constant; |
||||
import com.keyware.htey.utli.JsonUtils; |
||||
import io.swagger.v3.oas.annotations.Operation; |
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse; |
||||
import io.swagger.v3.oas.annotations.tags.Tag; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.util.StringUtils; |
||||
import org.springframework.web.bind.annotation.RequestBody; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestMethod; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.ResponseBody; |
||||
|
||||
/** |
||||
* @author daijiajun |
||||
* @version V1.0 |
||||
* @description 对与项目管理模块业务的处理 |
||||
* @Package com.keyware.htey.controller.project |
||||
* @date 2025/1/15 15:43 |
||||
*/ |
||||
@Controller |
||||
@RequestMapping("/projectKt") |
||||
@Tag(name = "项目管理模块 API", description = "部门表数据接口") |
||||
@Slf4j |
||||
public class ProjectKtController { |
||||
@Autowired |
||||
private OFourColumService fourColumService; |
||||
@Resource |
||||
private DepartmentService departmentService; |
||||
@Autowired |
||||
private UserService userService; |
||||
@Autowired |
||||
private OFourColumService oFourColumService; |
||||
|
||||
@RequestMapping( |
||||
value = {"/selectDepartUser"}, |
||||
method = {RequestMethod.POST}, |
||||
produces = {"application/json; charset=utf-8"} |
||||
) |
||||
@ResponseBody |
||||
@Operation(summary = "查询部门负责人", description = "返回部门负责人信息") |
||||
@ApiResponse(responseCode = "200", description = "部门负责人返回成功") |
||||
public String selectDepartUser(@RequestBody User user, @RequestParam(required = false) String setDocumentDepartId, |
||||
@RequestParam(required = false) String headId) { |
||||
List<User> list = new ArrayList(); |
||||
String departId = user.getDepartId() == null ? "" : user.getDepartId(); |
||||
String set_document_departId = setDocumentDepartId == null ? "" : setDocumentDepartId; |
||||
String source = user.getSecret() == null ? "" : user.getSecret(); |
||||
String userName = user.getUserNameForSerch(); |
||||
if (user.getSystemLevel() != "" && user.getSystemLevel() != null) { |
||||
user.setSystemLevel(getSeq(user.getSystemLevel()).toString()); |
||||
} |
||||
log.info("查询条件=" + userName); |
||||
String projectClassIficationName = user.getUesrRankName() == null ? "" : user.getUesrRankName(); |
||||
String projectClassIfication = user.getUesrRankId() == null ? "" : user.getUesrRankId(); |
||||
String customer = Constant.customer; |
||||
if ("sysadmin".equals(Constant.userId)) { |
||||
user.setIsSys("sysadmin"); |
||||
} |
||||
user.setFlag("1"); |
||||
List users; |
||||
Iterator userIterator; |
||||
if (!"".equals(set_document_departId)) { |
||||
Department department = this.departmentService.selectByPrimaryKey(set_document_departId); |
||||
if (department != null) { |
||||
users = null; |
||||
if (customer != null && customer.equals("siyuan17suo")) { |
||||
if (userName != null && !"搜索您想寻找的...".equals(userName)) { |
||||
user.setUserNameForSerch(userName); |
||||
user.setDepartId(department.getParentId()); |
||||
user.setProjectSource(Constant.projectName); |
||||
users = this.userService.selectByUserInfo17suo(user); |
||||
} else { |
||||
users = this.userService.selectDepartUser17suo(department.getParentId()); |
||||
} |
||||
|
||||
userIterator = users.iterator(); |
||||
|
||||
while (userIterator.hasNext()) { |
||||
User u = (User)userIterator.next(); |
||||
if (("内部".equals(projectClassIficationName) || "秘密".equals(projectClassIficationName)) |
||||
&& !"10".equals(u.getSecret()) && !"20".equals(u.getSecret()) && !"30".equals( |
||||
u.getSecret())) { |
||||
userIterator.remove(); |
||||
} |
||||
|
||||
if ("机密".equals(projectClassIficationName) && !"20".equals(u.getSecret()) && !"30".equals( |
||||
u.getSecret())) { |
||||
userIterator.remove(); |
||||
} |
||||
} |
||||
} |
||||
return JsonUtils.arrayListToJsonString(users); |
||||
} |
||||
} else { |
||||
HashSet selectByparentId; |
||||
String deptId; |
||||
if (customer == null || !customer.equals("siyuan17suo") && !customer.equals("guiyangshiyuan")) { |
||||
if (StringUtils.hasText(userName)) { |
||||
if (!"搜索您想寻找的...".equals(userName)) { |
||||
user.setUserNameForSerch(userName); |
||||
} |
||||
|
||||
users = this.userService.selectByUserInfo(user); |
||||
list.addAll(users); |
||||
} else if (!"".equals(source)) { |
||||
user.setDepartId(departId); |
||||
users = this.userService.selectByUserInfo(user); |
||||
list.addAll(users); |
||||
} else { |
||||
selectByparentId = this.departmentService.selectByparentId(departId); |
||||
user.setDepartId(departId); |
||||
users = this.userService.selectByUserInfo(user); |
||||
list.addAll(users); |
||||
userIterator = selectByparentId.iterator(); |
||||
|
||||
while (userIterator.hasNext()) { |
||||
deptId = (String)userIterator.next(); |
||||
user.setDepartId(deptId); |
||||
users = this.userService.selectByUserInfo(user); |
||||
list.addAll(users); |
||||
} |
||||
} |
||||
} else { |
||||
if (StringUtils.hasText(userName)) { |
||||
if (!"搜索您想寻找的...".equals(userName)) { |
||||
user.setUserNameForSerch(userName); |
||||
} |
||||
|
||||
users = this.userService.selectByUserInfo17suo(user); |
||||
list.addAll(users); |
||||
} else if (!"".equals(source)) { |
||||
user.setDepartId(departId); |
||||
// users = this.userService.selectByUserInfo17suo(user);
|
||||
users = userService.selectByUser(user); |
||||
list.addAll(users); |
||||
} else { |
||||
selectByparentId = this.departmentService.selectByparentId(departId); |
||||
user.setDepartId(departId); |
||||
// users = this.userService.selectByUserInfo17suo(user);
|
||||
users = userService.selectByUser(user); |
||||
list.addAll(users); |
||||
userIterator = selectByparentId.iterator(); |
||||
|
||||
while (userIterator.hasNext()) { |
||||
deptId = (String)userIterator.next(); |
||||
if (deptId != "" && deptId != null) { |
||||
user.setDepartId(deptId); |
||||
users = userService.selectByUser(user); |
||||
list.addAll(users); |
||||
} |
||||
} |
||||
} |
||||
|
||||
Iterator<User> iterator = list.iterator(); |
||||
|
||||
while (iterator.hasNext()) { |
||||
User u = (User)iterator.next(); |
||||
if (("内部".equals(projectClassIficationName) || "秘密".equals(projectClassIficationName)) |
||||
&& !"10".equals(u.getSecret()) && !"20".equals(u.getSecret()) && !"30".equals(u.getSecret())) { |
||||
iterator.remove(); |
||||
} |
||||
|
||||
if ("机密".equals(projectClassIficationName) && !"20".equals(u.getSecret()) && !"30".equals( |
||||
u.getSecret())) { |
||||
iterator.remove(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
List listnew = new ArrayList(); |
||||
Iterator var21 = list.iterator(); |
||||
|
||||
while (var21.hasNext()) { |
||||
User user1 = (User)var21.next(); |
||||
if (!listnew.contains(user1)) { |
||||
listnew.add(user1); |
||||
} |
||||
} |
||||
if (!StringUtils.isEmpty(projectClassIfication)) { |
||||
OFourColum oFourColum = oFourColumService.selectByPrimaryKey(projectClassIfication); |
||||
if (oFourColum != null) { |
||||
Iterator iterator = listnew.iterator(); |
||||
while (iterator.hasNext()) { |
||||
User next = (User)iterator.next(); |
||||
if (!StringUtils.isEmpty(next.getSecret())) { |
||||
OFourColum oFourColum1 = oFourColumService.selectByPrimaryKey(next.getSecret()); |
||||
if (oFourColum1 != null && oFourColum.getSeq() > oFourColum1.getSeq() || oFourColum1 == null) { |
||||
iterator.remove(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
if (!StringUtils.isEmpty(headId)) { |
||||
listnew = (List)listnew.stream().filter(o -> !((User)o).getId().equals(headId)).collect( |
||||
Collectors.toList()); |
||||
} |
||||
|
||||
return JsonUtils.toJson(listnew); |
||||
} |
||||
|
||||
public Integer getSeq(String id) { |
||||
OFourColum OFourColum = null; |
||||
if (!StringUtils.isEmpty(id)) { |
||||
OFourColum = fourColumService.selectByPrimaryKey(id); |
||||
} |
||||
if (Objects.isNull(OFourColum)) { |
||||
return null; |
||||
} |
||||
return OFourColum.getSeq(); |
||||
} |
||||
|
||||
} |
@ -1,12 +1,14 @@ |
||||
<?xml version="1.0" encoding="UTF-8" ?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
||||
<mapper namespace="com.keyware.htey.mybatis.itf.UserRoleMapper" > |
||||
<resultMap id="BaseResultMap" type="com.keyware.htey.entity.user.UserRole" > |
||||
<result column="USER_ID" property="userId" jdbcType="VARCHAR" /> |
||||
<result column="ROLE_ID" property="roleId" jdbcType="VARCHAR" /> |
||||
<mapper namespace="com.keyware.htey.mybatis.itf.UserRoleMapper"> |
||||
<resultMap id="BaseResultMap" type="com.keyware.htey.entity.user.UserRole"> |
||||
<result column="USER_ID" property="userId" jdbcType="VARCHAR"/> |
||||
<result column="ROLE_ID" property="roleId" jdbcType="VARCHAR"/> |
||||
</resultMap> |
||||
|
||||
<delete id="deleteByUserId" parameterType="java.lang.String"> |
||||
delete from USER_ROLE where USER_ID = #{userId,jdbcType=VARCHAR} |
||||
delete |
||||
from USER_ROLE |
||||
where USER_ID = #{userId,jdbcType=VARCHAR} |
||||
</delete> |
||||
</mapper> |
||||
|
Loading…
Reference in new issue