Kaynağa Gözat

加入调拨待办

java110 5 yıl önce
ebeveyn
işleme
2efaaa9ac8

+ 84 - 0
java110-bean/src/main/java/com/java110/dto/allocationStorehouse/AllocationStorehouseDto.java

@@ -19,6 +19,7 @@ public class AllocationStorehouseDto extends PageDto implements Serializable {
     public static final String STATE_SUCCESS = "1202";//状态,1201 调拨审核 1202 调拨完成 1202 调拨失败
     public static final String STATE_FAIL = "1203";//状态,1201 调拨审核 1202 调拨完成 1202 调拨失败
     private String asId;
+    private String[] asIds;
     private String storeId;
     private String resId;
     private String shIdz;
@@ -39,6 +40,16 @@ public class AllocationStorehouseDto extends PageDto implements Serializable {
     private String statusCd = "0";
 
 
+    private String currentUserId;
+    private String processInstanceId;
+    private String taskId;
+    private String auditCode;
+    private String auditMessage;
+    private String staffId;
+    private String staffName;
+    private String staffTel;
+
+
     public String getAsId() {
         return asId;
     }
@@ -167,4 +178,77 @@ public class AllocationStorehouseDto extends PageDto implements Serializable {
     public void setShzName(String shzName) {
         this.shzName = shzName;
     }
+
+
+    public String getCurrentUserId() {
+        return currentUserId;
+    }
+
+    public void setCurrentUserId(String currentUserId) {
+        this.currentUserId = currentUserId;
+    }
+
+    public String getProcessInstanceId() {
+        return processInstanceId;
+    }
+
+    public void setProcessInstanceId(String processInstanceId) {
+        this.processInstanceId = processInstanceId;
+    }
+
+    public String getTaskId() {
+        return taskId;
+    }
+
+    public void setTaskId(String taskId) {
+        this.taskId = taskId;
+    }
+
+    public String getAuditCode() {
+        return auditCode;
+    }
+
+    public void setAuditCode(String auditCode) {
+        this.auditCode = auditCode;
+    }
+
+    public String getAuditMessage() {
+        return auditMessage;
+    }
+
+    public void setAuditMessage(String auditMessage) {
+        this.auditMessage = auditMessage;
+    }
+
+    public String getStaffId() {
+        return staffId;
+    }
+
+    public void setStaffId(String staffId) {
+        this.staffId = staffId;
+    }
+
+    public String getStaffName() {
+        return staffName;
+    }
+
+    public void setStaffName(String staffName) {
+        this.staffName = staffName;
+    }
+
+    public String getStaffTel() {
+        return staffTel;
+    }
+
+    public void setStaffTel(String staffTel) {
+        this.staffTel = staffTel;
+    }
+
+    public String[] getAsIds() {
+        return asIds;
+    }
+
+    public void setAsIds(String[] asIds) {
+        this.asIds = asIds;
+    }
 }

+ 4 - 0
java110-bean/src/main/java/com/java110/dto/workflow/WorkflowDto.java

@@ -32,6 +32,10 @@ public class WorkflowDto extends PageDto implements Serializable {
     public static final String FLOW_TYPE_CONTRACT_CHANGE = "60006";//合同变更审核
 
 
+    //物品调拨
+    public static final String FLOW_TYPE_ALLOCATION_STOREHOUSE = "70007";//合同变更审核
+
+
 
     public static final String DEFAULT_SKIP_LEVEL = "1";
 

+ 97 - 0
java110-interface/src/main/java/com/java110/intf/common/IAllocationStorehouseUserInnerServiceSMO.java

@@ -0,0 +1,97 @@
+package com.java110.intf.common;
+
+import com.java110.config.feign.FeignConfiguration;
+import com.java110.dto.allocationStorehouse.AllocationStorehouseDto;
+import com.java110.entity.audit.AuditUser;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import java.util.List;
+
+@FeignClient(name = "common-service", configuration = {FeignConfiguration.class})
+@RequestMapping("/allocationStorehouseUserApi")
+public interface IAllocationStorehouseUserInnerServiceSMO {
+
+
+    /**
+     * <p>启动流程</p>
+     *
+     * @return CommunityDto 对象数据
+     */
+    @RequestMapping(value = "/startProcess", method = RequestMethod.POST)
+    public AllocationStorehouseDto startProcess(@RequestBody AllocationStorehouseDto allocationStorehouseDto);
+
+
+    /**
+     * 查询用户任务数
+     *
+     * @param user
+     * @return
+     */
+    @RequestMapping(value = "/getUserTaskCount", method = RequestMethod.POST)
+    public long getUserTaskCount(@RequestBody AuditUser user);
+
+    /**
+     * 获取用户任务
+     *
+     * @param user 用户信息
+     */
+    @RequestMapping(value = "/getUserTasks", method = RequestMethod.POST)
+    public List<AllocationStorehouseDto> getUserTasks(@RequestBody AuditUser user);
+
+    /**
+     * 同意
+     *
+     * @param
+     * @return
+     */
+    @RequestMapping(value = "/agreeCompleteTask", method = RequestMethod.POST)
+    public boolean agreeCompleteTask(@RequestBody AllocationStorehouseDto allocationStorehouseDto);
+
+
+    /**
+     * 反驳
+     *
+     * @param
+     * @return
+     */
+    @RequestMapping(value = "/refuteCompleteTask", method = RequestMethod.POST)
+    public boolean refuteCompleteTask(@RequestBody AllocationStorehouseDto allocationStorehouseDto);
+
+    /**
+     * 完成任务
+     *
+     * @param
+     */
+    @RequestMapping(value = "/complete", method = RequestMethod.GET)
+    public boolean complete(@RequestBody AllocationStorehouseDto allocationStorehouseDto);
+
+    /**
+     * 查询用户任务数
+     *
+     * @param user
+     * @return
+     */
+    @RequestMapping(value = "/getUserHistoryTaskCount", method = RequestMethod.POST)
+    public long getUserHistoryTaskCount(@RequestBody AuditUser user);
+
+    /**
+     * 获取用户审批的任务
+     *
+     * @param user 用户信息
+     */
+    @RequestMapping(value = "/getUserHistoryTasks", method = RequestMethod.POST)
+    public List<AllocationStorehouseDto> getUserHistoryTasks(@RequestBody AuditUser user);
+
+    /**
+     * 处理任务
+     *
+     * @return true 为流程结束 false 为流程没有结束
+     */
+    @RequestMapping(value = "/completeTask", method = RequestMethod.POST)
+    public boolean completeTask(@RequestBody AllocationStorehouseDto allocationStorehouseDto);
+
+
+}

+ 6 - 0
java110-utils/src/main/java/com/java110/utils/constant/ServiceCodeAuditUserConstant.java

@@ -54,4 +54,10 @@ public class ServiceCodeAuditUserConstant {
     public static final String LIST_AUDIT_HISTORY_COMPLAINTS = "auditUser.listAuditHistoryComplaints";
 
 
+    /**
+     * 查询 审核订单
+     */
+    public static final String LIST_ALLOCATION_STORE_AUDITORDERS = "resourceStore.listAllocationStoreAuditOrders";
+
+
 }

+ 8 - 0
service-api/src/main/java/com/java110/api/bmo/store/IStoreBMO.java

@@ -77,4 +77,12 @@ public interface IStoreBMO extends IApiBaseBMO {
      */
      JSONObject contractChange(JSONObject paramInJson);
 
+    /**
+     * 调拨审核
+     *
+     * @param paramInJson
+     * @return
+     */
+    JSONObject allocationStorehouse(JSONObject paramInJson);
+
 }

+ 26 - 0
service-api/src/main/java/com/java110/api/bmo/store/impl/StoreBMOImpl.java

@@ -353,5 +353,31 @@ public class StoreBMOImpl extends ApiBaseBMO implements IStoreBMO {
         return business;
     }
 
+    /**
+     * 调拨审核
+     *
+     * @param paramInJson
+     * @return
+     */
+    public JSONObject allocationStorehouse(JSONObject paramInJson) {
+
+        JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
+        business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_WORKFLOW);
+        business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ + 11);
+        business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
+        JSONArray businessOrgStaffRels = new JSONArray();
+        WorkflowPo workflowPo = new WorkflowPo();
+        workflowPo.setCommunityId("9999"); //所有小区
+        workflowPo.setFlowId("-5");
+        workflowPo.setFlowName("物品调拨");
+        workflowPo.setFlowType(WorkflowDto.FLOW_TYPE_ALLOCATION_STOREHOUSE);
+        workflowPo.setSkipLevel(WorkflowDto.DEFAULT_SKIP_LEVEL);
+        workflowPo.setStoreId(paramInJson.getString("storeId"));
+        businessOrgStaffRels.add(JSONObject.parseObject(JSONObject.toJSONString(workflowPo)));
+        business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put(WorkflowPo.class.getSimpleName(), businessOrgStaffRels);
+        return business;
+    }
+
+
 
 }

+ 83 - 0
service-api/src/main/java/com/java110/api/listener/resourceStore/ListAllocationStoreAuditOrdersListener.java

@@ -0,0 +1,83 @@
+package com.java110.api.listener.resourceStore;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.api.listener.AbstractServiceApiListener;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.core.event.service.api.ServiceDataFlowEvent;
+import com.java110.dto.allocationStorehouse.AllocationStorehouseDto;
+import com.java110.entity.audit.AuditUser;
+import com.java110.intf.common.IAllocationStorehouseUserInnerServiceSMO;
+import com.java110.utils.constant.ServiceCodeAuditUserConstant;
+import com.java110.utils.util.Assert;
+import com.java110.vo.ResultVo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * 查询待审核调拨单
+ */
+@Java110Listener("listAllocationStoreAuditOrdersListener")
+public class ListAllocationStoreAuditOrdersListener extends AbstractServiceApiListener {
+
+    @Autowired
+    private IAllocationStorehouseUserInnerServiceSMO allocationStorehouseUserInnerServiceSMOImpl;
+
+    @Override
+    public String getServiceCode() {
+        return ServiceCodeAuditUserConstant.LIST_ALLOCATION_STORE_AUDITORDERS;
+    }
+
+    @Override
+    public HttpMethod getHttpMethod() {
+        return HttpMethod.GET;
+    }
+
+
+    @Override
+    public int getOrder() {
+        return DEFAULT_ORDER;
+    }
+
+
+    @Override
+    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
+        Assert.hasKeyAndValue(reqJson, "storeId", "必填,请填写商户ID");
+        Assert.hasKeyAndValue(reqJson, "userId", "必填,请填写用户ID");
+        Assert.hasKeyAndValue(reqJson, "row", "必填,请填写每页显示数");
+        Assert.hasKeyAndValue(reqJson, "page", "必填,请填写页数");
+
+        super.validatePageInfo(reqJson);
+    }
+
+    @Override
+    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
+
+        AuditUser auditUser = new AuditUser();
+        auditUser.setUserId(reqJson.getString("userId"));
+        auditUser.setPage(reqJson.getInteger("page"));
+        auditUser.setRow(reqJson.getInteger("row"));
+        auditUser.setStoreId(reqJson.getString("storeId"));
+
+        long count = allocationStorehouseUserInnerServiceSMOImpl.getUserTaskCount(auditUser);
+
+        List<AllocationStorehouseDto> purchaseApplyDtos = null;
+
+        if (count > 0) {
+            purchaseApplyDtos = allocationStorehouseUserInnerServiceSMOImpl.getUserTasks(auditUser);
+        } else {
+            purchaseApplyDtos = new ArrayList<>();
+        }
+
+        ResponseEntity responseEntity
+                = ResultVo.createResponseEntity((int) Math.ceil((double) count / (double) reqJson.getInteger("row")),
+                (int) count,
+                purchaseApplyDtos);
+        context.setResponseEntity(responseEntity);
+    }
+}

+ 3 - 5
service-api/src/main/java/com/java110/api/listener/store/SaveStoreServiceListener.java

@@ -14,11 +14,7 @@ import com.java110.utils.constant.CommonConstant;
 import com.java110.utils.constant.ServiceCodeConstant;
 import com.java110.utils.util.Assert;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
+import org.springframework.http.*;
 
 /**
  * 保存商户信息
@@ -81,6 +77,8 @@ public class SaveStoreServiceListener extends AbstractServiceApiListener {
         businesses.add(storeBMOImpl.addCollection(paramObj));
         businesses.add(storeBMOImpl.contractApply(paramObj));
         businesses.add(storeBMOImpl.contractChange(paramObj));
+        //物品调拨流程
+        businesses.add(storeBMOImpl.allocationStorehouse(paramObj));
 
         //super.doResponse(dataFlowContext);
         ResponseEntity<String> responseEntity = storeBMOImpl.callService(dataFlowContext, service.getServiceCode(), businesses);

+ 287 - 0
service-common/src/main/java/com/java110/common/smo/impl/AllocationStorehouseUserInnerServiceSMOImpl.java

@@ -0,0 +1,287 @@
+package com.java110.common.smo.impl;
+
+
+import com.java110.core.base.smo.BaseServiceSMO;
+import com.java110.dto.PageDto;
+import com.java110.dto.allocationStorehouse.AllocationStorehouseDto;
+import com.java110.dto.workflow.WorkflowDto;
+import com.java110.entity.audit.AuditUser;
+import com.java110.intf.common.IAllocationStorehouseUserInnerServiceSMO;
+import com.java110.intf.common.IWorkflowInnerServiceSMO;
+import com.java110.intf.store.IAllocationStorehouseInnerServiceSMO;
+import com.java110.intf.store.IContractInnerServiceSMO;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.StringUtil;
+import org.activiti.engine.HistoryService;
+import org.activiti.engine.ProcessEngine;
+import org.activiti.engine.RuntimeService;
+import org.activiti.engine.TaskService;
+import org.activiti.engine.history.HistoricProcessInstance;
+import org.activiti.engine.history.HistoricTaskInstance;
+import org.activiti.engine.history.HistoricTaskInstanceQuery;
+import org.activiti.engine.impl.identity.Authentication;
+import org.activiti.engine.query.Query;
+import org.activiti.engine.runtime.ProcessInstance;
+import org.activiti.engine.task.Task;
+import org.activiti.engine.task.TaskQuery;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+//@Service("resourceEntryStoreSMOImpl")
+@RestController
+public class AllocationStorehouseUserInnerServiceSMOImpl extends BaseServiceSMO implements IAllocationStorehouseUserInnerServiceSMO {
+
+    @Autowired
+    private ProcessEngine processEngine;
+
+    @Autowired
+    private RuntimeService runtimeService;
+
+    @Autowired
+    private TaskService taskService;
+
+    @Autowired
+    private IAllocationStorehouseInnerServiceSMO allocationStorehouseInnerServiceSMOImpl;
+
+    @Autowired
+    private IWorkflowInnerServiceSMO workflowInnerServiceSMOImpl;
+
+
+    /**
+     * 启动流程
+     *
+     * @return
+     */
+    public AllocationStorehouseDto startProcess(@RequestBody AllocationStorehouseDto allocationStorehouseDto) {
+        //将信息加入map,以便传入流程中
+        Map<String, Object> variables = new HashMap<String, Object>();
+        variables.put("allocationStorehouseDto", allocationStorehouseDto);
+        variables.put("userId", allocationStorehouseDto.getCurrentUserId());
+        variables.put("startUserId", allocationStorehouseDto.getCurrentUserId());
+        //开启流程
+        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(getWorkflowDto(allocationStorehouseDto.getStoreId()), allocationStorehouseDto.getAsId(), variables);
+        //将得到的实例流程id值赋给之前设置的变量
+        String processInstanceId = processInstance.getId();
+        // System.out.println("流程开启成功.......实例流程id:" + processInstanceId);
+
+        allocationStorehouseDto.setProcessInstanceId(processInstanceId);
+
+        return allocationStorehouseDto;
+
+    }
+
+    /**
+     * 查询用户任务数
+     *
+     * @param user
+     * @return
+     */
+    public long getUserTaskCount(@RequestBody AuditUser user) {
+        TaskService taskService = processEngine.getTaskService();
+        TaskQuery query = taskService.createTaskQuery().processDefinitionKey(getWorkflowDto(user.getStoreId()));
+        query.taskAssignee(user.getUserId());
+        return query.count();
+    }
+
+    /**
+     * 获取用户任务
+     *
+     * @param user 用户信息
+     */
+    public List<AllocationStorehouseDto> getUserTasks(@RequestBody AuditUser user) {
+        TaskService taskService = processEngine.getTaskService();
+        TaskQuery query = taskService.createTaskQuery().processDefinitionKey(getWorkflowDto(user.getStoreId()));
+        query.taskAssignee(user.getUserId());
+        query.orderByTaskCreateTime().desc();
+        List<Task> list = null;
+        if (user.getPage() >= 1) {
+            user.setPage(user.getPage() - 1);
+        }
+        if (user.getPage() != PageDto.DEFAULT_PAGE) {
+            list = query.listPage(user.getPage(), user.getRow());
+        } else {
+            list = query.list();
+        }
+
+        List<String> asIds = new ArrayList<>();
+        Map<String, String> taskBusinessKeyMap = new HashMap<>();
+        for (Task task : list) {
+            String processInstanceId = task.getProcessInstanceId();
+            //3.使用流程实例,查询
+            ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
+            //4.使用流程实例对象获取BusinessKey
+            String business_key = pi.getBusinessKey();
+            asIds.add(business_key);
+            taskBusinessKeyMap.put(business_key, task.getId());
+        }
+
+        if (asIds == null || asIds.size() == 0) {
+            return new ArrayList<>();
+        }
+
+        //查询 投诉信息
+        AllocationStorehouseDto allocationStorehouseDto = new AllocationStorehouseDto();
+        allocationStorehouseDto.setStoreId(user.getStoreId());
+        allocationStorehouseDto.setAsIds(asIds.toArray(new String[asIds.size()]));
+        List<AllocationStorehouseDto> tmpAllocationStorehouseDtos = allocationStorehouseInnerServiceSMOImpl.queryAllocationStorehouses(allocationStorehouseDto);
+
+        for (AllocationStorehouseDto tmpAllocationStorehouseDto : tmpAllocationStorehouseDtos) {
+            tmpAllocationStorehouseDto.setTaskId(taskBusinessKeyMap.get(tmpAllocationStorehouseDto.getAsId()));
+        }
+        return tmpAllocationStorehouseDtos;
+    }
+
+    public boolean agreeCompleteTask(@RequestBody AllocationStorehouseDto allocationStorehouseDto) {
+        TaskService taskService = processEngine.getTaskService();
+        Map<String, Object> variables = new HashMap<String, Object>();
+        variables.put("auditCode", allocationStorehouseDto.getAuditCode());
+        taskService.complete(allocationStorehouseDto.getTaskId(), variables);
+        return true;
+    }
+
+    public boolean refuteCompleteTask(@RequestBody AllocationStorehouseDto allocationStorehouseDto) {
+        TaskService taskService = processEngine.getTaskService();
+        Map<String, Object> variables = new HashMap<String, Object>();
+        variables.put("auditCode", allocationStorehouseDto.getAuditCode());
+        taskService.complete(allocationStorehouseDto.getTaskId(), variables);
+        return true;
+    }
+
+    /**
+     * 审核 当前任务
+     *
+     * @param allocationStorehouseDto 资源订单
+     * @return
+     */
+    public boolean complete(@RequestBody AllocationStorehouseDto allocationStorehouseDto) {
+        TaskService taskService = processEngine.getTaskService();
+
+        taskService.complete(allocationStorehouseDto.getTaskId());
+
+
+        return true;
+    }
+
+
+    private String getWorkflowDto(String storeId) {
+        //开启流程
+        //WorkflowDto.DEFAULT_PROCESS + workflowDto.getFlowId()
+        WorkflowDto workflowDto = new WorkflowDto();
+        workflowDto.setFlowType(WorkflowDto.FLOW_TYPE_CONTRACT_APPLY);
+        workflowDto.setStoreId(storeId);
+        List<WorkflowDto> workflowDtos = workflowInnerServiceSMOImpl.queryWorkflows(workflowDto);
+        Assert.listOnlyOne(workflowDtos, "未找到 投诉建议流程或找到多条,请在物业账号系统管理下流程管理中配置流程");
+
+        WorkflowDto tmpWorkflowDto = workflowDtos.get(0);
+        if (StringUtil.isEmpty(tmpWorkflowDto.getProcessDefinitionKey())) {
+            throw new IllegalArgumentException("合同起草续签流程还未部署");
+        }
+        return WorkflowDto.DEFAULT_PROCESS + tmpWorkflowDto.getFlowId();
+    }
+
+    /**
+     * 查询用户任务数
+     *
+     * @param user
+     * @return
+     */
+    public long getUserHistoryTaskCount(@RequestBody AuditUser user) {
+        HistoryService historyService = processEngine.getHistoryService();
+//        Query query = historyService.createHistoricTaskInstanceQuery()
+//                .processDefinitionKey("complaint")
+//                .taskAssignee(user.getUserId());
+
+        HistoricTaskInstanceQuery historicTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery()
+                .processDefinitionKey(getWorkflowDto(user.getStoreId()))
+                .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())) {
+            historicTaskInstanceQuery.taskName("complaitDealUser");
+        }
+
+        Query query = historicTaskInstanceQuery;
+        return query.count();
+    }
+
+    /**
+     * 获取用户审批的任务
+     *
+     * @param user 用户信息
+     */
+    public List<AllocationStorehouseDto> getUserHistoryTasks(@RequestBody AuditUser user) {
+        HistoryService historyService = processEngine.getHistoryService();
+
+        HistoricTaskInstanceQuery historicTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery()
+                .processDefinitionKey(getWorkflowDto(user.getStoreId()))
+                .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())) {
+//            historicTaskInstanceQuery.taskName("complaitDealUser");
+//        }
+
+        Query query = historicTaskInstanceQuery.orderByHistoricTaskInstanceStartTime().desc();
+
+        List<HistoricTaskInstance> list = null;
+        if (user.getPage() != PageDto.DEFAULT_PAGE) {
+            list = query.listPage((user.getPage() - 1) * user.getRow(), user.getRow());
+        } else {
+            list = query.list();
+        }
+
+        List<String> asIds = new ArrayList<>();
+        Map<String, String> taskBusinessKeyMap = new HashMap<>();
+
+        for (HistoricTaskInstance task : list) {
+            String processInstanceId = task.getProcessInstanceId();
+            //3.使用流程实例,查询
+            HistoricProcessInstance pi = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
+            //4.使用流程实例对象获取BusinessKey
+            String business_key = pi.getBusinessKey();
+            asIds.add(business_key);
+            taskBusinessKeyMap.put(business_key, task.getId());
+        }
+
+        //查询 投诉信息
+        AllocationStorehouseDto allocationStorehouseDto = new AllocationStorehouseDto();
+        allocationStorehouseDto.setStoreId(user.getStoreId());
+        allocationStorehouseDto.setAsIds(asIds.toArray(new String[asIds.size()]));
+        List<AllocationStorehouseDto> tmpAllocationStorehouseDtos = allocationStorehouseInnerServiceSMOImpl.queryAllocationStorehouses(allocationStorehouseDto);
+
+        for (AllocationStorehouseDto tmpAllocationStorehouseDto : tmpAllocationStorehouseDtos) {
+            tmpAllocationStorehouseDto.setTaskId(taskBusinessKeyMap.get(tmpAllocationStorehouseDto.getAsId()));
+        }
+        return tmpAllocationStorehouseDtos;
+    }
+
+
+    public boolean completeTask(@RequestBody AllocationStorehouseDto allocationStorehouseDto) {
+        TaskService taskService = processEngine.getTaskService();
+        Task task = taskService.createTaskQuery().taskId(allocationStorehouseDto.getTaskId()).singleResult();
+        String processInstanceId = task.getProcessInstanceId();
+        Authentication.setAuthenticatedUserId(allocationStorehouseDto.getCurrentUserId());
+        taskService.addComment(allocationStorehouseDto.getTaskId(), processInstanceId, allocationStorehouseDto.getAuditMessage());
+        Map<String, Object> variables = new HashMap<String, Object>();
+        variables.put("auditCode", allocationStorehouseDto.getAuditCode());
+        variables.put("currentUserId", allocationStorehouseDto.getCurrentUserId());
+        variables.put("flag", "1200".equals(allocationStorehouseDto.getAuditCode()) ? "false" : "true");
+        variables.put("startUserId", allocationStorehouseDto.getStartUserId());
+        taskService.complete(allocationStorehouseDto.getTaskId(), variables);
+
+        ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
+        if (pi == null) {
+            return true;
+        }
+        return false;
+    }
+
+}