Sfoglia il codice sorgente

批量修改用户允许修改角色

anderx 2 anni fa
parent
commit
fbfdd998ef

+ 4 - 0
ruoyi-quartz/pom.xml

@@ -34,6 +34,10 @@
             <groupId>com.ruoyi</groupId>
             <artifactId>ruoyi-common</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.ruoyi</groupId>
+            <artifactId>ruoyi-system</artifactId>
+        </dependency>
 
     </dependencies>
 

+ 51 - 0
ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/YfProjectTask.java

@@ -0,0 +1,51 @@
+package com.ruoyi.quartz.task;
+
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.project.domain.ProjectTask;
+import com.ruoyi.project.mapper.ProjectTaskMapper;
+import com.ruoyi.project.service.ProjectTaskService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 定时任务调度测试
+ *
+ * @author ruoyi
+ */
+@Component("yfProjectTask")
+public class YfProjectTask
+{
+    @Autowired
+    private ProjectTaskMapper projectTaskMapper;
+    public void end(){
+        System.out.println("执行定时任务,完成项目");
+        List<ProjectTask> projectTasks = projectTaskMapper.selectAll();
+        List<Long> ids =new ArrayList<>();
+        long nowDate = System.currentTimeMillis();
+        System.out.println(projectTasks.size());
+        for (ProjectTask p : projectTasks) {
+            long taskDate = p.getEndTime().getTime();
+            System.out.println("newDate="+nowDate);
+            System.out.println("taskDate="+taskDate);
+            if (nowDate>taskDate){
+                ids.add(p.getId());
+                System.out.println(p.getId());
+            }
+        }
+        if (ids.size()>0) {
+            List<Long> idList =new ArrayList<>();
+            for (int i=0; i<ids.size(); i++) {
+                idList.add(ids.get(i));
+                if (idList.size()==50||i==ids.size()-1){
+                    if (idList.size()>0)projectTaskMapper.batchUpdateProjectStatus(ids);
+                }
+            }
+        }
+    }
+
+
+}

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

@@ -35,4 +35,8 @@ public interface ProjectTaskMapper {
     ProjectTask selectByProjectNumber(@Param("projectNumber") String projectNumber, @Param("companyId") Long companyId);
 
     void updateAdminNameByAid(SysUser user);
+
+    List<ProjectTask> selectAll();
+
+    void batchUpdateProjectStatus(@Param("ids") List<Long> ids);
 }

+ 1 - 0
ruoyi-system/src/main/java/com/ruoyi/project/service/ProjectTaskService.java

@@ -25,4 +25,5 @@ public interface ProjectTaskService {
 
     boolean checkProjectNumber(ProjectTask projectTask);
 
+
 }

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

@@ -174,6 +174,7 @@ public class ProjectTaskServiceImpl   implements ProjectTaskService {
                     if(StringUtils.isNotBlank(p.getStaffName())) {
                         addStaffAndDelete( p);
                     }
+                    p.setId(projectTask.getId());
                     if (p.getAdminName()!=null){
                         SysUser sysUser = userMapper.selectByNikeName(p.getAdminName(),company);
                         if (sysUser == null) {
@@ -250,9 +251,6 @@ public class ProjectTaskServiceImpl   implements ProjectTaskService {
         return false;
     }
 
-
-
-
     private void addStaffAndDelete(  ProjectTaskListOut p) {
         String[] split = p.getStaffName().split(",");
         List<ProjectStaff> projectStaffs = projectStaffMapper.selectByPid(p.getId());

+ 14 - 0
ruoyi-system/src/main/resources/mapper/project/ProjectTaskMapper.xml

@@ -218,6 +218,14 @@
     set admin_name = #{nickName}
     where aid= #{userId}
   </update>
+  <update id="batchUpdateProjectStatus" >
+    update project_task
+    set project_status = 1
+    where id in
+    <foreach collection="ids" item="id" open="(" close=")" separator=",">
+      #{id}
+    </foreach>
+  </update>
 
 
   <resultMap id="BaseResultOutMap" type="com.ruoyi.project.bo.ProjectTaskListOut">
@@ -300,4 +308,10 @@
       and (d.dept_id= #{companyId} or find_in_set(#{companyId},d.ancestors))
     </if>
     </select>
+  <select id="selectAll" resultMap="BaseResultMap">
+    select
+    <include refid="Base_Column_List" />
+    from project_task
+    where project_status =0
+  </select>
 </mapper>