Procházet zdrojové kódy

项目人员选择功能修改

user5 před 2 roky
rodič
revize
1d67d5affd

+ 15 - 16
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/projectRecords/controller/ProjectController.java

@@ -28,6 +28,7 @@ import com.jeeplus.test.projectRecords.service.dto.ProjectDTO;
 import com.jeeplus.test.projectRecords.service.mapstruct.ProjectWrapper;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.time.DateUtils;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.usermodel.Workbook;
@@ -116,32 +117,30 @@ public class ProjectController {
         Project pro = projectService.projectDtoToDate(project,projectDTO);
         pro.setItemType(projectDTO.getItemType());
 
-        if(StrUtil.isNotEmpty(projectDTO.getProjectHead())){
-            String userId = userService.getUserIdByLogin(projectDTO.getProjectHead());
-            if(StrUtil.isNotEmpty(userId)){
-                pro.setProjectHead(userId);
-            }else{
+        if(StringUtils.isNotBlank(projectDTO.getProjectHead())){
+            UserDTO projectHead = userService.get(projectDTO.getProjectHead());
+            if(null == projectHead || StringUtils.isBlank(projectHead.getId())){
                 return ResponseEntity.badRequest().body("项目负责人不存在,请重新输入");
             }
-
+            pro.setProjectHead(projectHead.getId());
         }
 
-        if(StrUtil.isNotEmpty(projectDTO.getEvaluationPersonOne())){
-            String userId = userService.getUserIdByLogin(projectDTO.getEvaluationPersonOne());
-            if(StrUtil.isNotEmpty(userId)){
-                pro.setEvaluationPersonOne(userId);
-            }else{
+        if(StringUtils.isNotBlank(projectDTO.getEvaluationPersonOne())){
+
+            UserDTO evaluationPersonOne = userService.get(projectDTO.getEvaluationPersonOne());
+            if(null == evaluationPersonOne || StringUtils.isBlank(evaluationPersonOne.getId())){
                 return ResponseEntity.badRequest().body("签字评估师1不存在,请重新输入");
             }
+            pro.setEvaluationPersonOne(evaluationPersonOne.getId());
         }
 
-        if(StrUtil.isNotEmpty(projectDTO.getEvaluationPersonTwo())){
-            String userId = userService.getUserIdByLogin(projectDTO.getEvaluationPersonTwo());
-            if(StrUtil.isNotEmpty(userId)){
-                pro.setEvaluationPersonTwo(userId);
-            }else{
+        if(StringUtils.isNotBlank(projectDTO.getEvaluationPersonTwo())){
+
+            UserDTO evaluationPersonTwo = userService.get(projectDTO.getEvaluationPersonTwo());
+            if(null == evaluationPersonTwo || StringUtils.isBlank(evaluationPersonTwo.getId())){
                 return ResponseEntity.badRequest().body("签字评估师2不存在,请重新输入");
             }
+            pro.setEvaluationPersonTwo(evaluationPersonTwo.getId());
         }
 
         if(StrUtil.isEmpty(projectDTO.getId())){

+ 1 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/projectRecords/domain/Project.java

@@ -76,6 +76,7 @@ public class Project extends BaseEntity {
      */
     @Query
     private String projectHead;
+    private String projectHeadId;
 
     /**
      * 废旧物资评估(万元)

+ 3 - 3
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/projectRecords/mapper/xml/ProjectMapper.xml

@@ -113,9 +113,9 @@
   <select id="selectByProjectId" resultType="com.jeeplus.test.projectRecords.domain.Project">
     select
     <include refid="to_list"></include>,
-    su1.login_name as projectHead,
-    su2.login_name as evaluationPersonOne,
-    su3.login_name as evaluationPersonTwo
+    su1.id as projectHead,
+    su2.id as evaluationPersonOne,
+    su3.id as evaluationPersonTwo
     from project_records pr
     left join sys_user su1 on pr.project_head = su1.id
     left join sys_user su2 on pr.evaluation_person_one = su2.id

+ 108 - 0
jeeplus-platform/jeeplus-admin/src/main/java/com/jeeplus/sys/controller/UserController.java

@@ -21,6 +21,7 @@ import com.jeeplus.core.excel.ExportMode;
 import com.jeeplus.core.excel.utils.EasyPoiUtil;
 import com.jeeplus.core.query.QueryWrapperGenerator;
 import com.jeeplus.security.util.SecurityUtils;
+import com.jeeplus.sys.constant.CommonConstants;
 import com.jeeplus.sys.domain.User;
 import com.jeeplus.sys.service.OfficeService;
 import com.jeeplus.sys.service.RoleService;
@@ -28,6 +29,7 @@ import com.jeeplus.sys.service.UserService;
 import com.jeeplus.sys.service.dto.OfficeDTO;
 import com.jeeplus.sys.service.dto.RoleDTO;
 import com.jeeplus.sys.service.dto.UserDTO;
+import com.jeeplus.sys.service.mapstruct.OfficeWrapper;
 import com.jeeplus.sys.service.mapstruct.UserWrapper;
 import com.jeeplus.sys.utils.*;
 import io.swagger.annotations.Api;
@@ -76,6 +78,9 @@ public class UserController {
     @Autowired
     private RoleService roleService;
 
+    @Autowired
+    private OfficeWrapper officeWrapper;
+
     /**
      * 根据id查询用户
      *
@@ -422,5 +427,108 @@ public class UserController {
         return ResponseEntity.ok ( res );
     }
 
+    /**
+     * 获取机构JSON数据。
+     *
+     * @param extId 排除的ID
+     * @param type  类型(1:公司;2:部门)
+     * @param showAll 是否显示不可用数据 1 显示 0 隐藏
+     * @return
+     */
+    @ApiLog("获取部门用户数据")
+    @GetMapping("treeUserData")
+    public ResponseEntity treeUserData(@RequestParam(required = false) String extId, @RequestParam(required = false) String type, @RequestParam(required = false, defaultValue = CommonConstants.NO) String showAll) {
+        List<OfficeDTO> list = officeWrapper.toDTO (officeService.list ());
+        for (OfficeDTO info :
+                list) {
+            info.setTypeFlag(true);
+        }
+        //根据部门查询对应部门下的所有数据
+        List<OfficeDTO> officeDTOList = userService.disposeUserOffice(list,type);
+        list.addAll(officeDTOList);
+        List rootTree = officeService.getRootTree (list, extId, type, showAll);
+        return ResponseEntity.ok (rootTree);
+    }
+
+    /**
+     * 获取机构JSON数据。
+     *
+     * @param officeName 部门名称
+     * @param extId 排除的ID
+     * @param type  类型(1:公司;2:部门)
+     * @param showAll 是否显示不可用数据 1 显示 0 隐藏
+     * @return
+     */
+    @ApiLog("获取部门用户数据")
+    @GetMapping("treeUserDataAllOffice")
+    public ResponseEntity treeUserDataAllOffice(@RequestParam(required = false) String officeName,@RequestParam(required = false) String extId, @RequestParam(required = false) String type, @RequestParam(required = false, defaultValue = CommonConstants.NO) String showAll) {
+        List<OfficeDTO> list = officeService.getOfficeAllByOfficeName (officeName);
+        if(list.size()>0){
+            List<String> officeIds = Lists.newArrayList();
+            for (OfficeDTO info :
+                    list) {
+                info.setTypeFlag(true);
+                officeIds.add(info.getId());
+            }
+            //根据部门查询对应部门下的所有数据
+            List<OfficeDTO> officeDTOList = userService.getUserByOffice(officeIds,type);
+            list.addAll(officeDTOList);
+        }
+        List rootTree = officeService.getRootTree (list, extId, type, showAll);
+        return ResponseEntity.ok (rootTree);
+    }
+
+    /**
+     * 获取机构JSON数据。
+     *
+     * @param officeName 部门名称
+     * @param extId 排除的ID
+     * @param type  类型(1:公司;2:部门)
+     * @param showAll 是否显示不可用数据 1 显示 0 隐藏
+     * @return
+     */
+    @ApiLog("获取部门用户数据")
+    @GetMapping("treeUserDataByOfficeName")
+    public ResponseEntity treeUserDataByOfficeName(@RequestParam(required = false) String officeName,@RequestParam(required = false) String extId, @RequestParam(required = false) String type, @RequestParam(required = false, defaultValue = CommonConstants.NO) String showAll) {
+        List<OfficeDTO> list = officeService.getOfficeAllByOfficeName (officeName);
+        if(list.size()>0){
+            List<String> officeIds = Lists.newArrayList();
+            for (OfficeDTO info :
+                    list) {
+                info.setTypeFlag(true);
+                officeIds.add(info.getId());
+            }
+            //根据部门查询对应部门下的所有数据
+            List<OfficeDTO> officeDTOList = userService.getUserByOffice(officeIds,type);
+            list.addAll(officeDTOList);
+        }
+        List rootTree = officeService.getofficeUserTree (officeName,list, extId, type, showAll);
+        return ResponseEntity.ok (rootTree);
+    }
+
+    /**
+     * 获取机构JSON数据。
+     *
+     * @param officeName 部门名称
+     * @param extId 排除的ID
+     * @param type  类型(1:公司;2:部门)
+     * @param showAll 是否显示不可用数据 1 显示 0 隐藏
+     * @return
+     */
+    @ApiLog("获取部门信息")
+    @GetMapping("treeUserDataByOfficeList")
+    public ResponseEntity treeUserDataByOfficeList(@RequestParam(required = false) String officeName,@RequestParam(required = false) String extId, @RequestParam(required = false) String type, @RequestParam(required = false, defaultValue = CommonConstants.NO) String showAll) {
+        List<OfficeDTO> list = officeService.getOfficeAllByOfficeName (officeName);
+        if(list.size()>0){
+            List<String> officeIds = Lists.newArrayList();
+            for (OfficeDTO info :
+                    list) {
+                officeIds.add(info.getId());
+            }
+        }
+        List rootTree = officeService.getofficeUserTree (officeName,list, extId, type, showAll);
+        return ResponseEntity.ok (rootTree);
+    }
+
 
 }

+ 8 - 0
jeeplus-platform/jeeplus-admin/src/main/java/com/jeeplus/sys/mapper/OfficeMapper.java

@@ -8,6 +8,8 @@ import com.jeeplus.sys.domain.Office;
 import com.jeeplus.sys.service.dto.OfficeDTO;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 /**
  * 机构MAPPER接口
  *
@@ -17,5 +19,11 @@ import org.apache.ibatis.annotations.Param;
 public interface OfficeMapper extends TreeMapper<Office> {
 
     OfficeDTO getOfficeByName(@Param("officeName") String officeName, @Param("parentName") String parentName);
+    /**
+     * 根据部门名称 查询部门及所有子部门信息
+     * @param officeName
+     * @return
+     */
+    List<OfficeDTO> getOfficeAllByOfficeName(@Param("officeName") String officeName);
 
 }

+ 25 - 0
jeeplus-platform/jeeplus-admin/src/main/java/com/jeeplus/sys/mapper/UserMapper.java

@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Constants;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.jeeplus.sys.service.dto.OfficeDTO;
 import com.jeeplus.sys.service.dto.UserDTO;
 import com.jeeplus.sys.domain.User;
 import org.apache.ibatis.annotations.Delete;
@@ -108,4 +109,28 @@ public interface UserMapper extends BaseMapper<User> {
      */
     void insertUserPost(String userId, String postId);
 
+
+    /**
+     * 按公司获取用户列表
+     *
+     * @param companyId
+     * @return
+     */
+    List <OfficeDTO> findListByCompanyId(@Param("companyId") String companyId, @Param("type") String type);
+
+    /**
+     * 根据部门获取员工数据
+     * @param officeIds
+     * @param type
+     * @return
+     */
+    List <OfficeDTO> getUserByOffice(@Param("officeIds") List<String> officeIds,@Param("type") String type);
+
+    /**
+     * 根据部门id查询部门下所有有效用户信息
+     * @param officeIds
+     * @return
+     */
+    List<UserDTO> getUserByOfficeIds(@Param("officeIds") List<String> officeIds);
+
 }

+ 13 - 0
jeeplus-platform/jeeplus-admin/src/main/java/com/jeeplus/sys/mapper/xml/OfficeMapper.xml

@@ -41,4 +41,17 @@
             and a.del_flag = 0
         </where>
     </select>
+
+    <select id="getOfficeAllByOfficeName" resultType="com.jeeplus.sys.service.dto.OfficeDTO">
+        select
+        <include refid="officeColumns"/>
+        from sys_office a
+        <where>
+            <if test="officeName != null and officeName != ''">
+                a.id = (select id from sys_office where name = #{officeName})
+                or
+                a.parent_ids like concat('%',(select id from sys_office where name = #{officeName}),'%')
+            </if>
+        </where>
+    </select>
 </mapper>

+ 76 - 0
jeeplus-platform/jeeplus-admin/src/main/java/com/jeeplus/sys/mapper/xml/UserMapper.xml

@@ -65,6 +65,33 @@
     	o.parent_ids AS "officeDTO.parentIds"
     </sql>
 
+
+
+	<sql id="userOfficeColumns">
+    	a.id,
+    	a.login_name AS "loginName",
+		a.is_admin AS "isAdmin",
+    	a.password,
+    	a.no,
+		a.name,
+		a.email,
+		a.phone,
+		a.mobile,
+		a.login_ip AS "loginIp",
+		a.login_date AS "loginDate",
+		a.remarks,
+		a.login_flag,
+		a.photo,
+		a.qr_code,
+		a.sign,
+		a.create_by AS "createBy.id",
+		a.create_date,
+		a.update_by AS "updateBy.id",
+		a.update_date,
+    	o.id AS "parent.id",
+    	o.parent_ids AS "parentIds"
+    </sql>
+
     <sql id="userJoins">
 		LEFT JOIN sys_office c ON c.id = a.company_id
 		LEFT JOIN sys_office o ON o.id = a.office_id
@@ -157,4 +184,53 @@
 	<insert id="insertUserPost">
 		INSERT INTO sys_user_post(user_id, post_id) VALUES (#{userId}, #{postId})
 	</insert>
+
+	<!-- 查询岗位下的用户 -->
+	<select id="findListByCompanyId" resultType="com.jeeplus.sys.service.dto.OfficeDTO">
+		SELECT
+		<include refid="userOfficeColumns"/>
+		,#{type} as "type"
+		FROM sys_user a
+		<include refid="userJoins"/>
+		<where>
+			a.del_flag = 0
+		</where>
+	</select>
+
+	<!-- 查询岗位下的用户 -->
+	<select id="getUserByOffice" resultType="com.jeeplus.sys.service.dto.OfficeDTO">
+		SELECT
+		<include refid="userOfficeColumns"/>
+		,#{type} as "type"
+		FROM sys_user a
+		<include refid="userJoins"/>
+		<where>
+			a.del_flag = 0
+			<if test="officeIds != null and officeIds.size>0">
+				and a.office_id in
+				<foreach collection="officeIds" item="officeId" separator="," open="(" close=")">
+					#{officeId}
+				</foreach>
+			</if>
+			and a.is_admin IS NULL
+		</where>
+	</select>
+
+	<!-- 根据部门名称查询部门下所有有效用户信息 -->
+	<select id="getUserByOfficeIds" resultType="com.jeeplus.sys.service.dto.UserDTO">
+		SELECT
+		<include refid="userOfficeColumns"/>
+		FROM sys_user a
+		<include refid="userJoins"/>
+		<where>
+			a.del_flag = 0
+			<if test="officeIds != null and officeIds.size>0">
+				and a.office_id in
+				<foreach collection="officeIds" item="officeId" separator="," open="(" close=")">
+					#{officeId}
+				</foreach>
+			</if>
+		</where>
+	</select>
+
 </mapper>

+ 25 - 0
jeeplus-platform/jeeplus-admin/src/main/java/com/jeeplus/sys/service/OfficeService.java

@@ -142,5 +142,30 @@ public class OfficeService extends TreeService<OfficeMapper, Office> {
     }
 
 
+    /**
+     * 根据部门名称查询部门信息
+     * @param officeName
+     * @return
+     */
+    public List<OfficeDTO> getOfficeAllByOfficeName(String officeName){
+        List<OfficeDTO> officeList = officeMapper.getOfficeAllByOfficeName(officeName);
+
+        return officeList;
+    }
+
+
+    public List <OfficeDTO> getofficeUserTree(String officeName, List<OfficeDTO> list, String extId, String type, String showAll) {
+        List<OfficeDTO> offices = Lists.newArrayList ();
+        //查询总部门信息
+        OfficeDTO root = officeMapper.getOfficeByName(officeName,"");
+        if(null != root){
+            if (this.isUseAble ( extId, type,root, showAll )){
+                // 不是被排除节点的子节点
+                List<OfficeDTO> officeList = formatListToTree (root, list, extId, type, showAll);
+                offices.addAll (officeList);
+            }
+        }
+        return offices;
+    }
 
 }

+ 20 - 0
jeeplus-platform/jeeplus-admin/src/main/java/com/jeeplus/sys/service/UserService.java

@@ -16,6 +16,7 @@ import com.jeeplus.sys.constant.CacheNames;
 import com.jeeplus.sys.domain.SysConfig;
 import com.jeeplus.sys.domain.User;
 import com.jeeplus.sys.mapper.UserMapper;
+import com.jeeplus.sys.service.dto.OfficeDTO;
 import com.jeeplus.sys.service.dto.UserDTO;
 import com.jeeplus.sys.service.mapstruct.UserWrapper;
 import com.jeeplus.sys.utils.UserUtils;
@@ -234,5 +235,24 @@ public class UserService  extends ServiceImpl<UserMapper, User> {
 		super.updateById (user);
 	}
 
+	//查询所有人员信息
+	public List<OfficeDTO> disposeUserOffice(List<OfficeDTO> officeDTOList, String type){
+		return userMapper.findListByCompanyId(UserUtils.getCurrentUserDTO().getCompanyDTO().getId(),type);
+	}
+
+	//根据部门查询用户信息
+	public List<OfficeDTO> getUserByOffice(List<String> officeIds,String type){
+		return userMapper.getUserByOffice(officeIds,type);
+	}
+
+	/**
+	 * 根据部门id查询部门下所有有效用户信息
+	 * @param officeIds
+	 * @return
+	 */
+	public List<UserDTO> getUserByOfficeIds(List<String> officeIds){
+		return userMapper.getUserByOfficeIds(officeIds);
+	}
+
 
 }

+ 83 - 0
jeeplus-platform/jeeplus-admin/src/main/java/com/jeeplus/sys/service/dto/OfficeDTO.java

@@ -117,4 +117,87 @@ public class OfficeDTO extends TreeDTO <OfficeDTO> {
 	@Query
 	private String parentName;
 
+
+	/**
+	 * 登录名
+	 */
+	@Length(min = 1, max = 100)
+	@Excel (name = "登录名")
+	@Query
+	private String loginName;
+
+	/**
+	 * 密码
+	 */
+	@JsonIgnore
+	@Length(min = 1, max = 100)
+	private String password;
+
+
+	/**
+	 * 工号
+	 */
+	@Length(min = 1, max = 100)
+	@Excel (name = "工号")
+	private String no;
+
+	/**
+	 * 手机
+	 */
+	@Length(min = 0, max = 100)
+	@Excel(name = "手机")
+	private String mobile;
+
+	/**
+	 * 最后登录IP
+	 */
+	@ApiModelProperty(hidden = true)
+	private String loginIp;
+
+	/**
+	 * 最后登录日期
+	 */
+	@ApiModelProperty(hidden = true)
+	private Date loginDate;
+
+	/**
+	 * 是否允许登录
+	 */
+	private String loginFlag;
+
+	/**
+	 * 头像
+	 */
+	private String photo;
+
+	/**
+	 * 二维码
+	 */
+	private String qrCode;
+
+	/**
+	 * 原登录名
+	 */
+	private String oldLoginName;
+
+	/**
+	 * 新密码
+	 */
+	private String newPassword;
+
+	/**
+	 * 签名
+	 */
+	private String sign;
+
+	/**
+	 * 超级管理员标志
+	 */
+	private boolean isAdmin;
+
+	/**
+	 * 是否可用
+	 */
+	private boolean typeFlag = false;
+
 }