Kaynağa Gözat

研发打卡修改

anderx 2 yıl önce
ebeveyn
işleme
9a361f5fd3

+ 11 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java

@@ -24,7 +24,7 @@ import com.ruoyi.system.service.ISysDeptService;
 
 /**
  * 部门信息
- * 
+ *
  * @author ruoyi
  */
 @RestController
@@ -129,4 +129,14 @@ public class SysDeptController extends BaseController
         deptService.checkDeptDataScope(deptId);
         return toAjax(deptService.deleteDeptById(deptId));
     }
+
+    /**
+     * 获取公司
+     * @return
+     */
+    @GetMapping("/getCompany")
+    public AjaxResult getCompany(){
+
+        return AjaxResult.success(deptService.getCompany());
+    }
 }

+ 81 - 37
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java

@@ -5,6 +5,7 @@ import java.util.List;
 import javax.validation.constraints.*;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.common.core.domain.BaseEntity;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 import com.ruoyi.common.annotation.Excel;
@@ -24,31 +25,65 @@ public class SysUser extends BaseEntity
     private static final long serialVersionUID = 1L;
 
     /** 用户ID */
-    @Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号")
+    @Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号",width = 8)
     private Long userId;
-
-    /** 部门ID */
-    @Excel(name = "部门编号", type = Type.IMPORT)
-    private Long deptId;
-
+    /**
+     * 工号
+     */
+    @Excel(name ="工号",width = 8)
+    private String jobNumber;
     /** 用户账号 */
-    @Excel(name = "登录名称")
+    @Excel(name = "账号")
     private String userName;
 
     /** 用户昵称 */
     @Excel(name = "用户名称")
     private String nickName;
+    @Excel(name = "职位",width = 8)
+    private String postName;
+    /**
+     *  0=兼职,1=全职
+     */
+    @Excel(name = "全职/兼职",readConverterExp = "0=兼职,1=全职",width = 8)
+    private Integer fullJob;
+    @Excels({
+            @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),
+//        @Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT)
+    })
+    private SysDept dept;
+
+    /**
+     * 项目数量
+     */
+    @Excel(name = "参与项目数",width = 8)
+    private Integer projectQuantity;
+    @Excel(name = "上级负责人")
+    private String superiorName;
+    @Excel(name = "累计工时",width = 8)
+    private Double duration;
+    /** 帐号状态(0正常 1停用) */
+    @Excel(name = "状态", readConverterExp = "0=正常,1=停用",width = 8)
+    private String status;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "创建时间", dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
+    private Date createTime;
+
+    /** 最后登录时间 */
+    @Excel(name = "最后登录时间",  dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
+    private Date loginDate;
+
+    /** 部门ID */
+    private Long deptId;
+
+
 
     /** 用户邮箱 */
-    @Excel(name = "用户邮箱")
     private String email;
 
     /** 手机号码 */
-    @Excel(name = "手机号码")
     private String phonenumber;
 
     /** 用户性别 */
-    @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
     private String sex;
 
     /** 用户头像 */
@@ -57,28 +92,19 @@ public class SysUser extends BaseEntity
     /** 密码 */
     private String password;
 
-    /** 帐号状态(0正常 1停用) */
-    @Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
-    private String status;
+
 
     /** 删除标志(0代表存在 2代表删除) */
     private String delFlag;
 
     /** 最后登录IP */
-    @Excel(name = "最后登录IP", type = Type.EXPORT)
+//    @Excel(name = "最后登录IP", type = Type.EXPORT)
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private String loginIp;
 
-    /** 最后登录时间 */
-    @Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
-    private Date loginDate;
 
     /** 部门对象 */
-    @Excels({
-        @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),
-        @Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT)
-    })
-    private SysDept dept;
+
 
     /**
      * 微信公共编号
@@ -92,20 +118,9 @@ public class SysUser extends BaseEntity
      */
     private Long superiorId;
 
-    /**
-     * 项目数量
-     */
-    private Integer projectQuantity;
 
-    /**
-     * 工号
-     */
-    private String jobNumber;
 
-    /**
-     *  0=兼职,1=全职
-     */
-    private Integer fullJob;
+
 
     /** 角色对象 */
     private List<SysRole> roles;
@@ -122,9 +137,38 @@ public class SysUser extends BaseEntity
     /**公司id*/
     private Long companyId;
     private Long postId;
-    private Double duration;
-    private String postName;
-    private String superiorName;
+
+
+
+
+    private Integer projectQuantitySort;
+    private Integer durationSort;
+
+    @Override
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    @Override
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Integer getProjectQuantitySort() {
+        return projectQuantitySort;
+    }
+
+    public void setProjectQuantitySort(Integer projectQuantitySort) {
+        this.projectQuantitySort = projectQuantitySort;
+    }
+
+    public Integer getDurationSort() {
+        return durationSort;
+    }
+
+    public void setDurationSort(Integer durationSort) {
+        this.durationSort = durationSort;
+    }
 
     public String getSuperiorName() {
         return superiorName;

+ 8 - 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java

@@ -148,4 +148,12 @@ public class SecurityUtils
     {
         return userId != null && 1L == userId;
     }
+
+    public static boolean isSuperAdmin()
+    {
+        if (getUserId()==1l){
+            return true;
+        }
+        return false;
+    }
 }

+ 16 - 14
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java

@@ -6,14 +6,14 @@ import com.ruoyi.common.core.domain.entity.SysDept;
 
 /**
  * 部门管理 数据层
- * 
+ *
  * @author ruoyi
  */
 public interface SysDeptMapper
 {
     /**
      * 查询部门管理数据
-     * 
+     *
      * @param dept 部门信息
      * @return 部门信息集合
      */
@@ -21,7 +21,7 @@ public interface SysDeptMapper
 
     /**
      * 根据角色ID查询部门树信息
-     * 
+     *
      * @param roleId 角色ID
      * @param deptCheckStrictly 部门树选择项是否关联显示
      * @return 选中部门列表
@@ -30,7 +30,7 @@ public interface SysDeptMapper
 
     /**
      * 根据部门ID查询信息
-     * 
+     *
      * @param deptId 部门ID
      * @return 部门信息
      */
@@ -38,7 +38,7 @@ public interface SysDeptMapper
 
     /**
      * 根据ID查询所有子部门
-     * 
+     *
      * @param deptId 部门ID
      * @return 部门列表
      */
@@ -46,7 +46,7 @@ public interface SysDeptMapper
 
     /**
      * 根据ID查询所有子部门(正常状态)
-     * 
+     *
      * @param deptId 部门ID
      * @return 子部门数
      */
@@ -54,7 +54,7 @@ public interface SysDeptMapper
 
     /**
      * 是否存在子节点
-     * 
+     *
      * @param deptId 部门ID
      * @return 结果
      */
@@ -62,7 +62,7 @@ public interface SysDeptMapper
 
     /**
      * 查询部门是否存在用户
-     * 
+     *
      * @param deptId 部门ID
      * @return 结果
      */
@@ -70,7 +70,7 @@ public interface SysDeptMapper
 
     /**
      * 校验部门名称是否唯一
-     * 
+     *
      * @param deptName 部门名称
      * @param parentId 父部门ID
      * @return 结果
@@ -79,7 +79,7 @@ public interface SysDeptMapper
 
     /**
      * 新增部门信息
-     * 
+     *
      * @param dept 部门信息
      * @return 结果
      */
@@ -87,7 +87,7 @@ public interface SysDeptMapper
 
     /**
      * 修改部门信息
-     * 
+     *
      * @param dept 部门信息
      * @return 结果
      */
@@ -95,14 +95,14 @@ public interface SysDeptMapper
 
     /**
      * 修改所在部门正常状态
-     * 
+     *
      * @param deptIds 部门ID组
      */
     public void updateDeptStatusNormal(Long[] deptIds);
 
     /**
      * 修改子元素关系
-     * 
+     *
      * @param depts 子元素
      * @return 结果
      */
@@ -110,9 +110,11 @@ public interface SysDeptMapper
 
     /**
      * 删除部门管理信息
-     * 
+     *
      * @param deptId 部门ID
      * @return 结果
      */
     public int deleteDeptById(Long deptId);
+
+    List<SysDept> getCompany();
 }

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java

@@ -123,4 +123,6 @@ public interface ISysDeptService
     public int deleteDeptById(Long deptId);
 
     public Long selectCompanyByDeptId();
+
+    List<SysDept> getCompany();
 }

+ 16 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java

@@ -324,6 +324,22 @@ public class SysDeptServiceImpl implements ISysDeptService
         return null;
     }
 
+    @Override
+    public List<SysDept> getCompany() {
+        boolean flag = SecurityUtils.isSuperAdmin();
+        if (flag){
+            return deptMapper.getCompany();
+        }
+        SysDept dep=new SysDept();
+        SysDept dept = SecurityUtils.getLoginUser().getUser().getDept();
+        if (dept.getCompanyId()!=null){
+            dep.setDeptId(dept.getCompanyId());
+        }else {
+            dep.setDeptId(dept.getDeptId());
+        }
+        return deptMapper.selectDeptList(dep);
+    }
+
     /**
      * 递归列表
      */

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java

@@ -501,7 +501,7 @@ public class SysUserServiceImpl implements ISysUserService
             try
             {
                 // 验证是否存在这个用户
-                SysUser u = userMapper.selectUserByUserName(user.getUserName());
+                SysUser u = userMapper.selectUserById(user.getUserId());
                 if (StringUtils.isNull(u))
                 {
                     BeanValidators.validateWithException(validator, user);

+ 5 - 1
ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml

@@ -100,8 +100,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	    <include refid="selectDeptVo"/>
 		where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1
 	</select>
+	<select id="getCompany" resultMap="SysDeptResult">
+		<include refid="selectDeptVo"/>
+		 where parent_id = 100
+	</select>
 
-    <insert id="insertDept" parameterType="SysDept">
+	<insert id="insertDept" parameterType="SysDept">
  		insert into sys_dept(
  			<if test="deptId != null and deptId != 0">dept_id,</if>
  			<if test="parentId != null and parentId != 0">parent_id,</if>

+ 33 - 6
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -46,6 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<result property="ancestors"    column="ancestors"      />
         <result property="status"    column="dept_status" />
         <result property="maxDuration"    column="max_duration" />
+        <result property="companyId"    column="company_id" />
     </resultMap>
 
     <resultMap id="RoleResult" type="SysRole">
@@ -59,7 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
 	<sql id="selectUserVo">
         select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
-        d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,d.ancestors,d.max_duration,u.open_id,
+        d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,d.ancestors,d.max_duration,u.open_id,d.company_id,
         r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status
         from sys_user u
 		    left join sys_dept d on u.dept_id = d.dept_id
@@ -83,13 +84,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<if test="userName != null and userName != ''">
 			AND u.user_name like concat('%', #{userName}, '%')
 		</if>
+		<if test="nickName != null and nickName != ''">
+			AND u.nick_name like concat('%', #{nickName}, '%')
+		</if>
 		<if test="jobNumber != null and jobNumber != ''">
 			AND u.job_number like concat('%', #{jobNumber}, '%')
 		</if>
-		<if test="fullJob != null and fullJob != ''">
-			AND u.full_job = #{fullJob}
-		</if>
-		<if test="fullJob != null and fullJob != ''">
+		<if test="fullJob != null ">
 			AND u.full_job = #{fullJob}
 		</if>
 		<if test="postId != null and postId != ''">
@@ -113,9 +114,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<if test="companyId !=null and companyId != 0">
 			AND (u.dept_id = #{companyId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{companyId}, ancestors) ))
 		</if>
-
 		<!-- 数据范围过滤 -->
 		${params.dataScope}
+		<if test="projectQuantitySort !=null and durationSort !=null">
+			order by u.project_quantity
+			<if test="projectQuantitySort==1">
+				desc
+			</if>
+			,u.duration
+			<if test="durationSort==1">
+				desc
+			</if>
+		</if>
+		<if test="projectQuantitySort !=null and durationSort ==null">
+			order by u.project_quantity
+			<if test="projectQuantitySort==1">
+				desc
+			</if>
+
+		</if>
+		<if test="projectQuantitySort ==null and durationSort !=null">
+			order by
+			u.duration
+			<if test="durationSort==1">
+				desc
+			</if>
+		</if>
 	</select>
 
 	<select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
@@ -199,6 +223,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="projectQuantity != null and projectQuantity != ''">project_quantity,</if>
  			<if test="jobNumber != null and jobNumber != ''">job_number,</if>
  			<if test="fullJob != null and fullJob != ''">full_job,</if>
+ 			<if test="duration != null and duration != ''">duration,</if>
  			create_time
  		)values(
  			<if test="userId != null and userId != ''">#{userId},</if>
@@ -218,6 +243,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 			<if test="projectQuantity != null and projectQuantity != ''">#{projectQuantity},</if>
 			<if test="jobNumber != null and jobNumber != ''">#{jobNumber},</if>
 			<if test="fullJob != null and fullJob != ''">#{fullJob},</if>
+			<if test="duration != null and duration != ''">#{duration},</if>
  			sysdate()
  		)
 	</insert>
@@ -253,6 +279,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 			<if test="fullJob != null">
 				full_job = #{fullJob,jdbcType=INTEGER},
 			</if>
+			<if test="duration != null and duration != ''">duration=#{duration},</if>
  			update_time = sysdate()
  		</set>
  		where user_id = #{userId}