Przeglądaj źródła

项目模块修改

anderx 2 lat temu
rodzic
commit
17fdb42876

+ 12 - 2
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDept.java

@@ -12,7 +12,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
 
 /**
  * 部门表 sys_dept
- * 
+ *
  * @author ruoyi
  */
 public class SysDept extends BaseEntity
@@ -51,10 +51,20 @@ public class SysDept extends BaseEntity
 
     /** 父部门名称 */
     private String parentName;
-    
+    /** 最大时长 */
+    private Integer maxDuration;
+
     /** 子部门 */
     private List<SysDept> children = new ArrayList<SysDept>();
 
+    public Integer getMaxDuration() {
+        return maxDuration;
+    }
+
+    public void setMaxDuration(Integer maxDuration) {
+        this.maxDuration = maxDuration;
+    }
+
     public Long getDeptId()
     {
         return deptId;

+ 9 - 0
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java

@@ -122,6 +122,15 @@ public class SysUser extends BaseEntity
     /**公司id*/
     private Long companyId;
     private Long postId;
+    private Double duration;
+
+    public Double getDuration() {
+        return duration;
+    }
+
+    public void setDuration(Double duration) {
+        this.duration = duration;
+    }
 
     public SysUser()
     {

+ 2 - 1
ruoyi-common/src/main/java/com/ruoyi/common/enums/UserRolesType.java

@@ -8,7 +8,8 @@ public enum UserRolesType {
     ADMIN(1l,"admin"),
     COMMON(2l,"common"),
     MANAGE(3l,"manage"),
-    CEO(4l,"ceo");
+    CEO(4l,"ceo"),
+    INSPECTORS(5l,"inspectors");
 
     private final String desc;
     private final Long code;

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

@@ -9,6 +9,7 @@ import com.ruoyi.common.core.domain.model.LoginUser;
 import com.ruoyi.common.exception.ServiceException;
 
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 /**
@@ -91,6 +92,8 @@ public class SecurityUtils
         }
     }
 
+
+
     public static boolean hashRoles(Long roleId){
         List<SysRole> userRoles = getUserRoles();
         AtomicBoolean flag= new AtomicBoolean(false);

+ 9 - 1
ruoyi-system/src/main/java/com/ruoyi/project/bo/ProjectListInput.java

@@ -14,10 +14,18 @@ public class ProjectListInput {
     private Integer projectStatus;
 
     /**
-     * 0=我的项目
+     * 0=我的项目 1=All
      */
     private Integer roleType;
 
+    public Integer getRoleType() {
+        return roleType;
+    }
+
+    public void setRoleType(Integer roleType) {
+        this.roleType = roleType;
+    }
+
     public Long getCompanyId() {
         return companyId;
     }

+ 3 - 0
ruoyi-system/src/main/java/com/ruoyi/project/mapper/ProjectTaskMapper.java

@@ -3,6 +3,7 @@ package com.ruoyi.project.mapper;
 import com.ruoyi.project.bo.ProjectListInput;
 import com.ruoyi.project.bo.ProjectTaskListOut;
 import com.ruoyi.project.domain.ProjectTask;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -22,4 +23,6 @@ public interface ProjectTaskMapper {
     void updateStaffName(Long pid);
 
     List<ProjectTaskListOut> selectList(ProjectListInput in);
+
+    void projectAddDuration(@Param("pid") Long pid, @Param("duration") Double duration);
 }

+ 13 - 3
ruoyi-system/src/main/java/com/ruoyi/project/service/impl/ProjectStaffRecordServiceImpl.java

@@ -1,6 +1,7 @@
 package com.ruoyi.project.service.impl;
 
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.enums.UserRolesType;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.project.bo.ProjectStaffRecordInput;
@@ -9,7 +10,9 @@ import com.ruoyi.project.domain.ProjectStaffRecord;
 import com.ruoyi.project.domain.ProjectStaffRecordLog;
 import com.ruoyi.project.mapper.ProjectStaffRecordLogMapper;
 import com.ruoyi.project.mapper.ProjectStaffRecordMapper;
+import com.ruoyi.project.mapper.ProjectTaskMapper;
 import com.ruoyi.project.service.ProjectStaffRecordService;
+import com.ruoyi.system.mapper.SysUserMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -21,6 +24,10 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
     private ProjectStaffRecordMapper projectStaffRecordMapper;
     @Autowired
     private ProjectStaffRecordLogMapper projectStaffRecordLogMapper;
+    @Autowired
+    private SysUserMapper sysUserMapper;
+    @Autowired
+    private ProjectTaskMapper projectTaskMapper;
 
     @Override
     public AjaxResult add(ProjectStaffRecord in) {
@@ -29,8 +36,13 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
         in.setAid(userId);
         in.setName(username);
         if(in.getProcessStatus()>1)in.setProcessStatus(1);
-        projectStaffRecordMapper.insertSelective(in);
+        if (SecurityUtils.hashRoles(UserRolesType.INSPECTORS.getCode())){
+            in.setProcessStatus(2);
+            sysUserMapper.userAddDuration(userId,in.getDuration());
+            projectTaskMapper.projectAddDuration(in.getPid(),in.getDuration());
+        }
         addRecordLog(in);
+        projectStaffRecordMapper.insertSelective(in);
         return AjaxResult.success();
     }
 
@@ -47,8 +59,6 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
             log.setName(SecurityUtils.getLoginUser().getUser().getNickName());
             log.setContent(getContent(in.getProcessStatus())+in.getContent());
         }
-
-
         projectStaffRecordLogMapper.insertSelective(log);
     }
 

+ 1 - 5
ruoyi-system/src/main/java/com/ruoyi/project/service/impl/ProjectTaskServiceImpl.java

@@ -71,12 +71,8 @@ public class ProjectTaskServiceImpl   implements ProjectTaskService {
 
     @Override
     public List<ProjectTaskListOut> list(ProjectListInput in) {
+        if (in.getRoleType()==null)in.setRoleType(0);
         in.setUid(SecurityUtils.getUserId());
-        if (SecurityUtils.hashRoles(UserRolesType.MANAGE.getCode())){
-            in.setRolesId(UserRolesType.MANAGE.getCode());
-        }else if(SecurityUtils.hashRoles(UserRolesType.COMMON.getCode())){
-            in.setRolesId(UserRolesType.COMMON.getCode());
-        }
         Long companyId = deptService.selectCompanyByDeptId();
         if (companyId!=null)in.setCompanyId(companyId);
         if (in.getEndTime()!=null)in.setEndTime(in.getEndTime()+" 23:59:59");

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java

@@ -126,4 +126,6 @@ public interface SysUserMapper
     public SysUser checkEmailUnique(String email);
 
     List<SysUser> selectName(String name);
+
+    void userAddDuration(@Param("userId") Long userId, @Param("duration") Double duration);
 }

+ 8 - 7
ruoyi-system/src/main/resources/mapper/project/ProjectTaskMapper.xml

@@ -193,18 +193,14 @@
     a.id, a.aid, a.`name`, a.project_status , a.create_time, a.remark, a.admin_name, a.staff_name, a.project_number,
     a.project_year, a.create_year, a.cross_year
     from project_task a
-    <if test="rolesId ==2">
-      left join (select pid from project_staff where aid= #{uid}) b on a.id=b.pid
-    </if>
     <if test="companyId !=null">
       left join sys_user c on a.aid=c.user_id
       left join sys_dept d on c.dept_id=d.dept_id
     </if>
     where 1=1
-      <if test="rolesId ==3">
-        and a.aid = #{uid}
-      </if>
-
+    <if test="roleType ==0">
+      and (a.aid =#{uid} or  a.id in (select pid from project_staff where aid= #{uid}) b on a.id=b.pid)
+    </if>
     <if test="headId !=null">
       and a.aid= #{headId}
     </if>
@@ -233,4 +229,9 @@
      and (d.dept_id= #{companyId} or find_in_set(#{companyId},d.ancestors))
     </if>
   </select>
+  <select id="projectAddDuration">
+    update project_task
+    set duration=duration+#{duration}
+    where id =#{pid}
+  </select>
 </mapper>

+ 3 - 0
ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml

@@ -102,6 +102,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="email != null and email != ''">email,</if>
  			<if test="status != null">status,</if>
  			<if test="createBy != null and createBy != ''">create_by,</if>
+			<if test="maxDuration != null ">max_duration,</if>
  			create_time
  		)values(
  			<if test="deptId != null and deptId != 0">#{deptId},</if>
@@ -114,6 +115,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="email != null and email != ''">#{email},</if>
  			<if test="status != null">#{status},</if>
  			<if test="createBy != null and createBy != ''">#{createBy},</if>
+			<if test="maxDuration != null ">#{maxDuration},</if>
  			sysdate()
  		)
 	</insert>
@@ -130,6 +132,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			<if test="email != null">email = #{email},</if>
  			<if test="status != null and status != ''">status = #{status},</if>
  			<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
+ 			<if test="maxDuration != null ">max_duration = #{maxDuration},</if>
  			update_time = sysdate()
  		</set>
  		where dept_id = #{deptId}

+ 16 - 15
ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml

@@ -16,12 +16,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		<result property="updateTime"    column="update_time"   />
 		<result property="remark"        column="remark"        />
 	</resultMap>
-	
+
 	<sql id="selectPostVo">
-        select post_id, post_code, post_name, post_sort, status, create_by, create_time, remark 
+        select post_id, post_code, post_name, post_sort, status, create_by, create_time, remark
 		from sys_post
     </sql>
-	
+
 	<select id="selectPostList" parameterType="SysPost" resultMap="SysPostResult">
 	    <include refid="selectPostVo"/>
 		<where>
@@ -35,17 +35,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 				AND post_name like concat('%', #{postName}, '%')
 			</if>
 		</where>
+		order by post_sort
 	</select>
-	
+
 	<select id="selectPostAll" resultMap="SysPostResult">
 		<include refid="selectPostVo"/>
 	</select>
-	
+
 	<select id="selectPostById" parameterType="Long" resultMap="SysPostResult">
 		<include refid="selectPostVo"/>
 		where post_id = #{postId}
 	</select>
-	
+
 	<select id="selectPostListByUserId" parameterType="Long" resultType="Long">
 		select p.post_id
         from sys_post p
@@ -53,7 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	        left join sys_user u on u.user_id = up.user_id
 	    where u.user_id = #{userId}
 	</select>
-	
+
 	<select id="selectPostsByUserName" parameterType="String" resultMap="SysPostResult">
 		select p.post_id, p.post_name, p.post_code
 		from sys_post p
@@ -61,17 +62,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 			 left join sys_user u on u.user_id = up.user_id
 		where u.user_name = #{userName}
 	</select>
-	
+
 	<select id="checkPostNameUnique" parameterType="String" resultMap="SysPostResult">
 		<include refid="selectPostVo"/>
 		 where post_name=#{postName} limit 1
 	</select>
-	
+
 	<select id="checkPostCodeUnique" parameterType="String" resultMap="SysPostResult">
 		<include refid="selectPostVo"/>
 		 where post_code=#{postCode} limit 1
 	</select>
-	
+
 	<update id="updatePost" parameterType="SysPost">
  		update sys_post
  		<set>
@@ -85,7 +86,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  		</set>
  		where post_id = #{postId}
 	</update>
- 	
+
  	<insert id="insertPost" parameterType="SysPost" useGeneratedKeys="true" keyProperty="postId">
  		insert into sys_post(
  			<if test="postId != null and postId != 0">post_id,</if>
@@ -107,16 +108,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  			sysdate()
  		)
 	</insert>
-	
+
 	<delete id="deletePostById" parameterType="Long">
 		delete from sys_post where post_id = #{postId}
 	</delete>
-	
+
 	<delete id="deletePostByIds" parameterType="Long">
  		delete from sys_post where post_id in
  		<foreach collection="array" item="postId" open="(" separator="," close=")">
  			#{postId}
-        </foreach> 
+        </foreach>
  	</delete>
 
-</mapper> 
+</mapper>

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

@@ -259,6 +259,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  		update sys_user set password = #{password} where user_name = #{userName}
 	</update>
 
+
 	<delete id="deleteUserById" parameterType="Long">
  		update sys_user set del_flag = '2' where user_id = #{userId}
  	</delete>
@@ -274,4 +275,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		select user_id userId, user_name userName,nick_name nickName
 		from sys_user where user_id >1 and nick_name like concat('%',#{name},'%')
 	</select>
+
+	<update id="userAddDuration">
+		update sys_user set duration = duration+#{duration}
+		where user_id = #{userId}
+	</update>
 </mapper>