old mode 100644
new mode 100755
| | |
| | | |
| | | |
| | | import com.java110.core.base.smo.BaseServiceSMO; |
| | | import com.java110.core.smo.store.IComplaintInnerServiceSMO; |
| | | import com.java110.core.smo.common.IComplaintUserInnerServiceSMO; |
| | | import com.java110.core.smo.user.IUserInnerServiceSMO; |
| | | import com.java110.intf.common.IComplaintUserInnerServiceSMO; |
| | | import com.java110.intf.common.IWorkflowInnerServiceSMO; |
| | | import com.java110.intf.store.IComplaintInnerServiceSMO; |
| | | import com.java110.intf.user.IUserInnerServiceSMO; |
| | | import com.java110.dto.PageDto; |
| | | import com.java110.dto.auditMessage.AuditMessageDto; |
| | | import com.java110.dto.complaint.ComplaintDto; |
| | | import com.java110.dto.user.UserDto; |
| | | import com.java110.dto.workflow.WorkflowDto; |
| | | import com.java110.entity.audit.AuditUser; |
| | | import com.java110.utils.cache.MappingCache; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.utils.util.StringUtil; |
| | | import org.activiti.engine.HistoryService; |
| | |
| | | import org.activiti.engine.task.Comment; |
| | | import org.activiti.engine.task.Task; |
| | | import org.activiti.engine.task.TaskQuery; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | |
| | | @RestController |
| | | public class ComplaintUserInnerServiceSMOImpl extends BaseServiceSMO implements IComplaintUserInnerServiceSMO { |
| | | |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(ComplaintUserInnerServiceSMOImpl.class); |
| | | |
| | | @Autowired |
| | | private ProcessEngine processEngine; |
| | | |
| | |
| | | private TaskService taskService; |
| | | |
| | | @Autowired |
| | | private HistoryService historyService; |
| | | |
| | | @Autowired |
| | | private IComplaintInnerServiceSMO complaintInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IUserInnerServiceSMO userInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IWorkflowInnerServiceSMO workflowInnerServiceSMOImpl; |
| | | |
| | | |
| | | /** |
| | |
| | | public ComplaintDto startProcess(@RequestBody ComplaintDto complaintDto) { |
| | | //将信息加入map,以便传入流程中 |
| | | Map<String, Object> variables = new HashMap<String, Object>(); |
| | | variables.put("complaintDto", complaintDto); |
| | | variables.put("userId", complaintDto.getCurrentUserId()); |
| | | //开启流程 |
| | | ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("complaint", complaintDto.getComplaintId(), variables); |
| | | //variables.put("complaintDto", complaintDto); |
| | | variables.put("startUserId", complaintDto.getCurrentUserId()); |
| | | String key = getWorkflowDto(complaintDto.getCommunityId()); |
| | | |
| | | if(StringUtil.isEmpty(key)){ |
| | | return null; |
| | | } |
| | | |
| | | ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(key, complaintDto.getComplaintId(), variables); |
| | | //将得到的实例流程id值赋给之前设置的变量 |
| | | String processInstanceId = processInstance.getId(); |
| | | // System.out.println("流程开启成功.......实例流程id:" + processInstanceId); |
| | | |
| | | complaintDto.setProcessInstanceId(processInstanceId); |
| | | //第一个节点自动提交 |
| | | autoFinishFirstTask(complaintDto); |
| | | //autoFinishFirstTask(complaintDto); |
| | | return complaintDto; |
| | | } |
| | | |
| | | private String getWorkflowDto(String communityId) { |
| | | //开启流程 |
| | | //WorkflowDto.DEFAULT_PROCESS + workflowDto.getFlowId() |
| | | WorkflowDto workflowDto = new WorkflowDto(); |
| | | workflowDto.setFlowType(WorkflowDto.FLOW_TYPE_COMPLAINT); |
| | | workflowDto.setCommunityId(communityId); |
| | | List<WorkflowDto> workflowDtos = workflowInnerServiceSMOImpl.queryWorkflows(workflowDto); |
| | | |
| | | if(workflowDtos == null || workflowDtos.size() < 1){ |
| | | return ""; |
| | | } |
| | | |
| | | WorkflowDto tmpWorkflowDto = workflowDtos.get(0); |
| | | if (StringUtil.isEmpty(tmpWorkflowDto.getProcessDefinitionKey())) { |
| | | return ""; |
| | | } |
| | | return WorkflowDto.DEFAULT_PROCESS + tmpWorkflowDto.getFlowId(); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public long getUserTaskCount(@RequestBody AuditUser user) { |
| | | TaskService taskService = processEngine.getTaskService(); |
| | | TaskQuery query = taskService.createTaskQuery().processDefinitionKey("complaint"); |
| | | TaskQuery query = taskService.createTaskQuery().processDefinitionKey(getWorkflowDto(user.getCommunityId())); |
| | | query.taskAssignee(user.getUserId()); |
| | | return query.count(); |
| | | } |
| | |
| | | */ |
| | | public List<ComplaintDto> getUserTasks(@RequestBody AuditUser user) { |
| | | TaskService taskService = processEngine.getTaskService(); |
| | | TaskQuery query = taskService.createTaskQuery().processDefinitionKey("complaint"); |
| | | TaskQuery query = taskService.createTaskQuery().processDefinitionKey(getWorkflowDto(user.getCommunityId())); |
| | | ; |
| | | query.taskAssignee(user.getUserId()); |
| | | query.orderByTaskCreateTime().desc(); |
| | |
| | | // .taskAssignee(user.getUserId()); |
| | | |
| | | HistoricTaskInstanceQuery historicTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery() |
| | | .processDefinitionKey("complaint") |
| | | .taskAssignee(user.getUserId()); |
| | | .processDefinitionKey(getWorkflowDto(user.getCommunityId())) |
| | | .taskAssignee(user.getUserId()) |
| | | .finished(); |
| | | if (!StringUtil.isEmpty(user.getAuditLink()) && "START".equals(user.getAuditLink())) { |
| | | historicTaskInstanceQuery.taskName("complaint"); |
| | | } else if (!StringUtil.isEmpty(user.getAuditLink()) && "AUDIT".equals(user.getAuditLink())) { |
| | |
| | | } |
| | | |
| | | Query query = historicTaskInstanceQuery; |
| | | |
| | | return query.count(); |
| | | } |
| | | |
| | |
| | | HistoryService historyService = processEngine.getHistoryService(); |
| | | |
| | | HistoricTaskInstanceQuery historicTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery() |
| | | .processDefinitionKey("complaint") |
| | | .taskAssignee(user.getUserId()); |
| | | .processDefinitionKey(getWorkflowDto(user.getCommunityId())) |
| | | .taskAssignee(user.getUserId()) |
| | | .finished(); |
| | | if (!StringUtil.isEmpty(user.getAuditLink()) && "START".equals(user.getAuditLink())) { |
| | | historicTaskInstanceQuery.taskName("complaint"); |
| | | } else if (!StringUtil.isEmpty(user.getAuditLink()) && "AUDIT".equals(user.getAuditLink())) { |
| | |
| | | Map<String, Object> variables = new HashMap<String, Object>(); |
| | | variables.put("auditCode", complaintDto.getAuditCode()); |
| | | variables.put("currentUserId", complaintDto.getCurrentUserId()); |
| | | variables.put("flag", "1200".equals(complaintDto.getAuditCode()) ? "false" : "true"); |
| | | variables.put("startUserId", complaintDto.getStartUserId()); |
| | | //taskService.setAssignee(complaintDto.getTaskId(),complaintDto.getCurrentUserId()); |
| | | //taskService.addCandidateUser(complaintDto.getTaskId(), complaintDto.getCurrentUserId()); |
| | | //taskService.claim(complaintDto.getTaskId(), complaintDto.getCurrentUserId()); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 删除指定任务 |
| | | */ |
| | | public boolean deleteTask(@RequestBody ComplaintDto complaintDto){ |
| | | String taskId = complaintDto.getTaskId(); |
| | | |
| | | Task task = taskService.createTaskQuery().taskId(complaintDto.getTaskId()).singleResult(); |
| | | String processInstanceId = task.getProcessInstanceId(); |
| | | ProcessInstance pi = runtimeService.createProcessInstanceQuery() |
| | | .processInstanceId(processInstanceId) |
| | | .singleResult(); |
| | | logger.info("删除id为:{},投诉建议任务"); |
| | | if (null != pi) { |
| | | //该流程实例未结束的 |
| | | runtimeService.deleteProcessInstance(processInstanceId, "删除任务"); |
| | | } |
| | | historyService.deleteHistoricProcessInstance(processInstanceId); |
| | | return true; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取任务当前处理人 |
| | | * |
| | | * @param complaintDto |
| | |
| | | public ComplaintDto getTaskCurrentUser(@RequestBody ComplaintDto complaintDto) { |
| | | |
| | | TaskService taskService = processEngine.getTaskService(); |
| | | Task task = taskService.createTaskQuery().processInstanceBusinessKey(complaintDto.getComplaintId()).singleResult(); |
| | | List<Task> tasks = taskService.createTaskQuery().processInstanceBusinessKey(complaintDto.getComplaintId()).list(); |
| | | |
| | | if (task == null) { |
| | | if (tasks == null || tasks.size() == 0) { |
| | | complaintDto.setCurrentUserId(""); |
| | | complaintDto.setCurrentUserName(""); |
| | | complaintDto.setCurrentUserTel(""); |
| | | return complaintDto; |
| | | } |
| | | |
| | | String userId = task.getAssignee(); |
| | | List<UserDto> users = userInnerServiceSMOImpl.getUserInfo(new String[]{userId}); |
| | | |
| | | if (users == null || users.size() == 0) { |
| | | complaintDto.setCurrentUserId(""); |
| | | complaintDto.setCurrentUserName(""); |
| | | complaintDto.setCurrentUserTel(""); |
| | | return complaintDto; |
| | | String userIds = ""; |
| | | String userNames = ""; |
| | | String userTels = ""; |
| | | String taskIds = ""; |
| | | for (Task task : tasks) { |
| | | String userId = task.getAssignee(); |
| | | taskIds += (task.getId() + "/"); |
| | | List<UserDto> users = userInnerServiceSMOImpl.getUserInfo(new String[]{userId}); |
| | | if (users == null || users.size() == 0) { |
| | | continue; |
| | | } |
| | | userIds += (userId + "/"); |
| | | userNames += (users.get(0).getName() + "/"); |
| | | userTels += (users.get(0).getTel() + "/"); |
| | | } |
| | | |
| | | complaintDto.setCurrentUserId(userId); |
| | | complaintDto.setCurrentUserName(users.get(0).getName()); |
| | | complaintDto.setCurrentUserTel(users.get(0).getTel()); |
| | | userIds = userIds.endsWith("/") ? userIds.substring(0, userIds.length() - 1) : userIds; |
| | | userNames = userNames.endsWith("/") ? userNames.substring(0, userNames.length() - 1) : userNames; |
| | | userTels = userTels.endsWith("/") ? userTels.substring(0, userTels.length() - 1) : userTels; |
| | | taskIds = taskIds.endsWith("/") ? taskIds.substring(0, taskIds.length() - 1) : taskIds; |
| | | complaintDto.setCurrentUserId(userIds); |
| | | complaintDto.setCurrentUserName(userNames); |
| | | complaintDto.setCurrentUserTel(userTels); |
| | | complaintDto.setTaskId(taskIds); |
| | | return complaintDto; |
| | | |
| | | } |