wangbo 4 vuotta sitten
vanhempi
commit
3cac51712b

+ 3 - 3
operation_manager/src/main/java/com/huaxu/client/UserCenterClient.java

@@ -3,9 +3,7 @@ package com.huaxu.client;
 import com.huaxu.config.FeignConfig;
 
 import org.springframework.cloud.openfeign.FeignClient;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 import java.util.Map;
@@ -19,4 +17,6 @@ public interface UserCenterClient {
     @GetMapping("/dict/selectListByPCodes")
     Map<String,String> selectListByPCodes(@RequestParam String parentDictCodes);
 
+    @PostMapping("/user/findUserIdsByUserIds")
+    Map<Long,String> findUserIdsByUserIds(Long[] ids);
 }

+ 94 - 10
operation_manager/src/main/java/com/huaxu/task/controller/PlanManageController.java

@@ -2,6 +2,7 @@ package com.huaxu.task.controller;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.huaxu.client.UserCenterClient;
 import com.huaxu.model.AjaxMessage;
 import com.huaxu.model.LoginUser;
 import com.huaxu.model.Pagination;
@@ -33,6 +34,8 @@ public class PlanManageController {
 
     @Autowired
     WorkFlowService workFlowService;
+    @Autowired
+    private UserCenterClient userCenterClient;
 
 
     /**
@@ -93,10 +96,11 @@ public class PlanManageController {
     public AjaxMessage<Pagination<PlanManageDto>> selectPlan(
             @ApiParam(value = "页数", required = true)@RequestParam Integer pageNum,
             @ApiParam(value = "条数", required = true)@RequestParam Integer pageSize,
-            @ApiParam(value = "状态", required = false) @RequestParam(required = false) Integer planStatus,
+            @ApiParam(value = "任务类型(巡检:7,侧漏:8,养护:9)", required = false) @RequestParam(required = false) Integer taskType,
+            @ApiParam(value = "状态(0:巡检计划;null:所有任务;1:执行中;2:完成)", required = false) @RequestParam(required = false) Integer planStatus,
             @ApiParam(value = "计划单号或计划名称", required = false) @RequestParam(required = false) String key,
-            @ApiParam(value = "计划安排起始日期", required = false) @RequestParam(required = false) String startDate,
-            @ApiParam(value = "计划安排截至日期", required = false) @RequestParam(required = false) String endDate){
+            @ApiParam(value = "计划起始日期(yyyy-MM-dd)", required = false) @RequestParam(required = false) String startDate,
+            @ApiParam(value = "计划截至日期(yyyy-MM-dd)", required = false) @RequestParam(required = false) String endDate){
         PlanManageDto planManageDto = new PlanManageDto();
         //根据用户编号,获取用户的权限
         LoginUser loginUser = UserUtil.getCurrentUser();
@@ -106,6 +110,7 @@ public class PlanManageController {
             planManageDto.setEndDate(endDate);
         }
         planManageDto.setPlanStatus(planStatus);
+        planManageDto.setTaskType(taskType);
         planManageDto.setTenantId(loginUser.getTenantId());
         planManageDto.setProgramItems(loginUser.getProgramItemList());
         planManageDto.setUserType(loginUser.getType());
@@ -114,15 +119,39 @@ public class PlanManageController {
         IPage<PlanManageDto> iPage = new Page<>(pageNum, pageSize);
         iPage = planManageService.selectPage(iPage, planManageDto);
         Pagination<PlanManageDto> pages = new Pagination<>(iPage);
-        for(PlanManage plan : pages.getList()){
-            //查询并更新用户名称
-            plan.setCreateByName("");
-            plan.setUpdateByName("");
-            plan.setUserName("");
-            plan.setPlanUserName("");
+        setUserName(pages);
+        return new AjaxMessage<>(ResultStatus.OK, pages);
+    }
+
+    @GetMapping("/plan/pending")
+    @ApiOperation(value = "查询待处理任务")
+    public AjaxMessage<Pagination<PlanManageDto>> selectPendingTask(
+            @ApiParam(value = "页数", required = true)@RequestParam Integer pageNum,
+            @ApiParam(value = "条数", required = true)@RequestParam Integer pageSize,
+            @ApiParam(value = "任务类型(巡检:7,侧漏:8,养护:9)", required = false) @RequestParam(required = false) Integer taskType,
+            @ApiParam(value = "计划单号或计划名称", required = false) @RequestParam(required = false) String key,
+            @ApiParam(value = "计划起始日期(yyyy-MM-dd)", required = false) @RequestParam(required = false) String startDate,
+            @ApiParam(value = "计划截至日期(yyyy-MM-dd)", required = false) @RequestParam(required = false) String endDate){
+        PlanManageDto planManageDto = new PlanManageDto();
+        //根据用户编号,获取用户的权限
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        planManageDto.setKey(key);
+        if(!StringUtils.isEmpty(startDate)&& !StringUtils.isEmpty(endDate)) {
+            planManageDto.setStartDate(startDate);
+            planManageDto.setEndDate(endDate);
+        }
+        planManageDto.setTaskType(taskType);
+        if(loginUser.getId() != null) {
+            planManageDto.setCurrentUsers(String.format("%s,", loginUser.getId()));
         }
+        IPage<PlanManageDto> iPage = new Page<>(pageNum, pageSize);
+        iPage = planManageService.selectPage(iPage, planManageDto);
+        Pagination<PlanManageDto> pages = new Pagination<>(iPage);
+        setUserName(pages);
         return new AjaxMessage<>(ResultStatus.OK, pages);
     }
+
+
     /**
      * APP查询任务详情
      * @return Response对象
@@ -155,7 +184,7 @@ public class PlanManageController {
         vars.put("assineeFormUserId",loginUser.getId());
         //巡检发送系统消息所需参数
         vars.put("任务类型",planManage.getTaskType());
-        vars.put("任务编号",planManage.getPlanId());
+        vars.put("任务编号",planManage.getId() );
         vars.put("templateId",4);
         vars.put("msgType",4);
         String startProcess = workFlowService.startProcess(processDefinition,vars);
@@ -219,4 +248,59 @@ public class PlanManageController {
     public AjaxMessage<Integer> batchDelete( @ApiParam(value = "巡检计划ids") @RequestParam List<Integer> ids){
         return new AjaxMessage<>(ResultStatus.OK, planManageService.batchDelete(ids));
     }
+
+
+    /**
+     * 获取并设置用户名称
+     * @param pages
+     */
+    private void setUserName(Pagination<PlanManageDto> pages){
+        if(pages.getTotal()>0) {
+            int total = (int) pages.getTotal();
+            List<Long> idList = new ArrayList<Long>();
+            for (PlanManage plan : pages.getList()) {
+                if(plan.getUserId() != null) {
+                    idList.add(Long.parseLong(plan.getUserId()));
+                }
+                if(plan.getPlanUserId() != null){
+                    idList.add(Long.parseLong(plan.getPlanUserId()));
+                }
+                if(plan.getCreateBy() != null){
+                    idList.add(Long.parseLong(plan.getCreateBy()));
+                }
+                if(plan.getUpdateBy() != null){
+                    idList.add(Long.parseLong(plan.getUpdateBy()));
+                }
+            }
+            Long [] ids = new Long[idList.size()];
+            for( int i =0 ;i<idList.size(); i++){
+                ids[i] = idList.get(i);
+            }
+            Map<Long, String> userMap = userCenterClient.findUserIdsByUserIds(ids);
+            for (PlanManage plan : pages.getList()) {
+                for (Map.Entry<Long, String> entry : userMap.entrySet()) {
+                    if(plan.getUserId() != null) {
+                        if(entry.getKey()== Long.parseLong(plan.getUserId())){
+                            plan.setUserName(entry.getValue());
+                        }
+                    }
+                    if(plan.getPlanUserId() != null){
+                        if(entry.getKey()== Long.parseLong(plan.getPlanUserId())){
+                            plan.setPlanUserName(entry.getValue());
+                        }
+                    }
+                    if(plan.getCreateBy() != null){
+                        if(entry.getKey()== Long.parseLong(plan.getCreateBy())){
+                            plan.setCreateByName(entry.getValue());
+                        }
+                    }
+                    if(plan.getUpdateBy() != null) {
+                        if(entry.getKey()== Long.parseLong(plan.getUpdateBy())){
+                            plan.setUpdateByName(entry.getValue());
+                        }
+                    }
+                }
+            }
+        }
+    }
 }

+ 0 - 1
operation_manager/src/main/java/com/huaxu/task/dto/PlanManageDto.java

@@ -53,7 +53,6 @@ public class PlanManageDto extends PlanManage {
      */
     @ApiModelProperty(value="截至日期")
     private String endDate;
-
     /**
      * 用户类型
      */

+ 6 - 0
operation_manager/src/main/resources/mapper/task/PlanManageMapper.xml

@@ -432,6 +432,12 @@
       <if test="plan.planStatus == null">
         and t1.plan_status != 0
       </if>
+      <if test="plan.taskType != null">
+        and t1.task_type = #{plan.taskType,jdbcType=INTEGER}
+      </if>
+      <if test="plan.currentUsers != null">
+        and  INSTR(t1.current_users,#{plan.currentUsers})
+      </if>
       <if test="plan.startDate != null and plan.endDate != null">
         and t1.date_create &gt;= date_format(#{plan.startDate,jdbcType=VARCHAR},'%Y-%c-%d')
         and t1.date_create &lt;= DATE_ADD(date_format(#{plan.endDate,jdbcType=VARCHAR},'%Y-%c-%d'),INTERVAL 1 DAY)