浏览代码

Merge remote-tracking branch 'origin/master'

yuejiaying 4 年之前
父节点
当前提交
7c5f46e435

+ 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)

+ 18 - 5
user_center/src/main/java/com/huaxu/controller/UserController.java

@@ -25,10 +25,9 @@ import org.springframework.stereotype.Controller;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.ui.ModelMap;
 
-import java.util.List;
+import java.util.*;
 import java.io.IOException;
-import java.util.Map;
-import java.util.Date;
+
 import org.springframework.web.bind.annotation.*;
 import com.huaxu.entity.UserEntity;
 import com.huaxu.service.UserService;
@@ -98,6 +97,7 @@ public class UserController {
         return new AjaxMessage<>(ResultStatus.OK, userEntity);
     }
 
+
     /**
      * 按用户查询一级菜单信息(入口菜单)
      */
@@ -267,9 +267,22 @@ public class UserController {
 
     @RequestMapping(value = "/findUserIdsByOrgId", method = RequestMethod.POST)
     @ResponseBody
-    public AjaxMessage<List<UserEntity>> findUserIdsByOrgId(String ids) {
-        List list = JSONObject.parseObject(ids, List.class);
+    public AjaxMessage<List<UserEntity>> findUserIdsByOrgId(Long[] ids) {
+        List list = Arrays.asList(ids.clone());
         List<UserEntity> result = userService.findUserIdsByOrgId(list);
         return new AjaxMessage<>(ResultStatus.OK,result);
     }
+
+    @RequestMapping(value = "/findUserIdsByUserIds", method = RequestMethod.POST)
+    @ResponseBody
+    public Map<Long,String> findUserIdsByUserIds(Long[] ids) {
+        List list = Arrays.asList(ids.clone());
+        List<UserEntity> result = userService.findUserIdsByUserIds(list);
+        Map<Long,String> userInfos = new HashMap<>();
+        for(UserEntity item : result)
+        {
+            userInfos.put(item.getId(),item.getUsername());
+        }
+        return  userInfos;
+    }
 }

+ 2 - 0
user_center/src/main/java/com/huaxu/dao/UserMapper.java

@@ -34,5 +34,7 @@ public interface UserMapper extends BaseMapper<UserEntity> {
 
     List<UserEntity> findUserIdsByOrgId(List<Integer> orgIds);
 
+    List<UserEntity> findUserIdsByUserIds(List<Integer> userIds);
+
     /**删除相关方法  使用mybatis-plus集成的 **/
 }

+ 8 - 0
user_center/src/main/java/com/huaxu/service/UserService.java

@@ -268,4 +268,12 @@ public class UserService extends ServiceImpl<UserMapper,UserEntity> {
 		}
 		return userEntities;
 	}
+
+	public List<UserEntity> findUserIdsByUserIds(List<Integer> userIds) {
+		List<UserEntity> userEntities = new ArrayList<>();
+		if(userIds.size()>0){
+			userEntities=userMapper.findUserIdsByUserIds(userIds);
+		}
+		return userEntities;
+	}
 }

+ 11 - 0
user_center/src/main/resources/mapper/UserMapper.xml

@@ -157,4 +157,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </foreach>
         )
     </select>
+    <select id="findUserIdsByUserIds"  resultType="com.huaxu.entity.UserEntity">
+        SELECT
+        <include refid="userColumns"/>
+        FROM uims_user a
+        <include refid="sysAreaJoins"/>
+        where a.status=1 and
+        a.id in
+        <foreach collection="list" item="item" open="(" close=")" separator=",">
+            #{item}
+        </foreach>
+    </select>
 </mapper>