|
@@ -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);
|
|
|
+ }
|
|
|
}
|