Browse Source

注释流程测试类

wangbo 4 years ago
parent
commit
4c49eca02b

+ 57 - 13
operation_manager/src/main/java/com/huaxu/task/controller/PlanManageController.java

@@ -6,6 +6,8 @@ import com.huaxu.model.AjaxMessage;
 import com.huaxu.model.LoginUser;
 import com.huaxu.model.Pagination;
 import com.huaxu.model.ResultStatus;
+import com.huaxu.process.entity.ProcessDefinition;
+import com.huaxu.process.service.WorkFlowService;
 import com.huaxu.task.dto.PlanManageDto;
 import com.huaxu.task.entity.PlanManage;
 import com.huaxu.task.service.PlanManageService;
@@ -14,9 +16,14 @@ import com.huaxu.util.UserUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
+import org.activiti.engine.task.Task;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.*;
 import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
 
 @RestController
 @RequestMapping("/workflow/task/")
@@ -26,6 +33,10 @@ public class PlanManageController {
     @Autowired
     PlanManageService planManageService;
 
+    @Autowired
+    WorkFlowService workFlowService;
+
+
     /**
      * 新增巡检计划
      * @param planName 任务名称
@@ -84,18 +95,14 @@ public class PlanManageController {
             @ApiParam(value = "计划单号或计划名称", required = true) @RequestParam(required = false) String key,
             @ApiParam(value = "计划安排起始日期", required = true) @RequestParam(required = false) String startDate,
             @ApiParam(value = "计划安排截至日期", required = true) @RequestParam(required = false) String endDate){
-
         PlanManageDto planManageDto = new PlanManageDto();
         //根据用户编号,获取用户的权限
         LoginUser loginUser = UserUtil.getCurrentUser();
-//        Map<String,Object> map =new HashMap<String,Object>();
-//        map.put("tenantId",loginUser.getTenantId());
-//        map.put("key",key);
-//        map.put("startDate",startDate);
-//        map.put("endDate",endDate);
-//        map.put("permissonType",loginUser.getPermissonType());
-//        map.put("programItem",loginUser.getProgramItemList());
-//        IPage<PlanManage> iPage = new Page<>(pageNum, pageSize);
+        planManageDto.setKey(key);
+        if(!StringUtils.isEmpty(startDate)&& !StringUtils.isEmpty(endDate)) {
+            planManageDto.setStartDate(startDate);
+            planManageDto.setEndDate(endDate);
+        }
         planManageDto.setTenantId(loginUser.getTenantId());
         planManageDto.setProgramItems(loginUser.getProgramItemList());
         planManageDto.setUserType(loginUser.getType());
@@ -104,15 +111,52 @@ public class PlanManageController {
         IPage<PlanManageDto> iPage = new Page<>(pageNum, pageSize);
         iPage = planManageService.selectPage(iPage, planManageDto);
         Pagination<PlanManageDto> pages = new Pagination<>(iPage);
-        for(PlanManageDto plan : pages.getList()){
+        for(PlanManage plan : pages.getList()){
             //plan.setCompanyOrgName(orgInfoUtil.getOrgName(plan.getCompanyOrgId()));
             //plan.setDeptOrgName(orgInfoUtil.getOrgName(plan.getDeptOrgId()));
         }
         return new AjaxMessage<>(ResultStatus.OK, pages);
-
     }
 
 
-
-
+    @PostMapping("/plan/submit")
+    @ApiOperation(value = "提交巡检计划")
+    public AjaxMessage submitPlan(
+            @ApiParam(value = "计划单号", required = true) @RequestParam(required = false) String planId){
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        PlanManage planManage = planManageService.selectByPlanId(planId);
+        //测试数据 test1 1 1
+//        ProcessDefinition processDefinition = workFlowService.findProcessDefinition(
+//                loginUser.getTenantId(),
+//                loginUser.getCompanyId(),
+//                planManage.getTaskType());
+        ProcessDefinition processDefinition = workFlowService.findProcessDefinition(
+                "test1",
+                1,
+                1);
+        Map<String,Object> vars = new HashMap<>();
+        vars.put("assineeFormUserId",planManage.getUserId());
+        //巡检发送系统消息所需参数
+        vars.put("任务类型",planManage.getTaskType());
+        vars.put("任务编号",planManage.getPlanId());
+        vars.put("templateId",4);
+        vars.put("msgType",4);
+        String startProcess = workFlowService.startProcess(processDefinition,vars);
+        Task task = workFlowService.getProcessRuntimeTask(startProcess).get(0);
+        Set<String> taskParticipator = workFlowService.getTaskParticipator(task.getId(),false,null);
+        //更新计划表的流程相关字段值。
+        planManage.setPlanStatus(1);//已执行
+        planManage.setUpdateBy(loginUser.getId().toString());
+        planManage.setDateUpdate(new Date());
+        planManage.setProcessInstanceId("");
+        planManage.setProcessDefId("");
+        planManage.setCurrentTaskId("");
+        planManage.setCurrentUsers("");
+        planManage.setCurrentTaskName("");
+        int rows = planManageService.updateByPrimaryKeySelective(planManage);
+        if(rows > 0) {
+            return new AjaxMessage<>(ResultStatus.OK);
+        }
+        return new AjaxMessage<>(ResultStatus.ERROR);
+    }
 }

+ 2 - 0
operation_manager/src/main/java/com/huaxu/task/dao/PlanManageMapper.java

@@ -16,6 +16,8 @@ public interface PlanManageMapper {
 
     PlanManage selectByPrimaryKey(Integer id);
 
+    PlanManage selectByPlanId(String planId);
+
     int updateByPrimaryKeySelective(PlanManage record);
 
     Page<PlanManageDto> findPage(IPage<PlanManageDto> page, @Param("plan") PlanManageDto planManageDto);

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

@@ -1,5 +1,6 @@
 package com.huaxu.task.dto;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.huaxu.model.ProgramItem;
 import com.huaxu.task.entity.PlanManage;
@@ -7,6 +8,7 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.util.Date;
 import java.util.List;
 
 @Data
@@ -34,6 +36,18 @@ public class PlanManageDto extends PlanManage {
     @ApiModelProperty(value="用户权限类型",hidden = true)
     @JsonIgnore
     private Integer permissonType;
+    /**
+     *
+     */
+    @ApiModelProperty(value = "关键字")
+    private String key;
+
+    @ApiModelProperty(value="起始日期")
+    private String startDate;
+
+    @ApiModelProperty(value="截至日期")
+    private String endDate;
+
     /**
      * 用户类型
      */

+ 12 - 0
operation_manager/src/main/java/com/huaxu/task/entity/PlanManage.java

@@ -24,9 +24,15 @@ public class PlanManage implements Serializable {
     @ApiModelProperty(value = "计划安排人")
     private String planUserId;
 
+    @ApiModelProperty(value = "计划安排人姓名")
+    private String planUserName;
+
     @ApiModelProperty(value = "计划巡检人员")
     private String userId;
 
+    @ApiModelProperty(value = "计划巡检人员姓名")
+    private String userName;
+
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
     @ApiModelProperty(value = "计划安排时间")
     private Date planDate;
@@ -75,6 +81,9 @@ public class PlanManage implements Serializable {
     @ApiModelProperty(value = "创建者")
     private String createBy;
 
+    @ApiModelProperty(value = "创建者姓名")
+    private String createByName;
+
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
     @ApiModelProperty(value = "创建时间")
     private Date dateCreate;
@@ -82,6 +91,9 @@ public class PlanManage implements Serializable {
     @ApiModelProperty(value = "更新人")
     private String updateBy;
 
+    @ApiModelProperty(value = "更新人姓名")
+    private String updateByName;
+
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
     @ApiModelProperty(value = "更新时间")
     private Date dateUpdate;

+ 6 - 0
operation_manager/src/main/java/com/huaxu/task/service/PlanManageService.java

@@ -20,4 +20,10 @@ public interface PlanManageService {
      */
     IPage<PlanManageDto> selectPage(IPage<PlanManageDto> page, PlanManageDto planManageDto);
 
+
+    /**
+     * 按单号查询
+     */
+    PlanManage selectByPlanId(String planId);
+
 }

+ 5 - 0
operation_manager/src/main/java/com/huaxu/task/service/impl/PlanManageServiceImpl.java

@@ -29,4 +29,9 @@ public class PlanManageServiceImpl implements PlanManageService {
         return planManageMapper.findPage(page,planManageDto);
     }
 
+    @Override
+    public PlanManage selectByPlanId(String planId) {
+        return planManageMapper.selectByPlanId(planId);
+    }
+
 }