| | |
| | | import com.java110.core.context.ICmdDataFlowContext; |
| | | import com.java110.core.event.cmd.Cmd; |
| | | import com.java110.core.event.cmd.CmdEvent; |
| | | import com.java110.dto.itemRelease.ItemReleaseDto; |
| | | import com.java110.dto.oaWorkflow.OaWorkflowDto; |
| | | import com.java110.dto.oaWorkflow.WorkflowDto; |
| | | import com.java110.dto.purchase.PurchaseApplyDto; |
| | | import com.java110.dto.audit.AuditUser; |
| | | import com.java110.intf.common.IOaWorkflowActivitiInnerServiceSMO; |
| | | import com.java110.intf.common.IResourceEntryStoreInnerServiceSMO; |
| | | import com.java110.intf.oa.IOaWorkflowInnerServiceSMO; |
| | | import com.java110.intf.store.IPurchaseApplyInnerServiceSMO; |
| | | import com.java110.utils.exception.CmdException; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.utils.util.BeanConvertUtil; |
| | | import com.java110.vo.ResultVo; |
| | | import com.java110.vo.api.resourceOrder.ApiResourceOrderDataVo; |
| | | import com.java110.vo.api.resourceOrder.ApiResourceOrderVo; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | @Autowired |
| | | private IResourceEntryStoreInnerServiceSMO resourceEntryStoreInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IOaWorkflowActivitiInnerServiceSMO oaWorkflowUserInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IOaWorkflowInnerServiceSMO oaWorkflowInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IPurchaseApplyInnerServiceSMO purchaseApplyInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IOaWorkflowActivitiInnerServiceSMO oaWorkflowActivitiInnerServiceSMOImpl; |
| | | |
| | | @Override |
| | | public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException { |
| | | Assert.hasKeyAndValue(reqJson, "storeId", "必填,请填写商户ID"); |
| | | Assert.hasKeyAndValue(reqJson, "userId", "必填,请填写用户ID"); |
| | | Assert.hasKeyAndValue(reqJson, "row", "必填,请填写每页显示数"); |
| | | Assert.hasKeyAndValue(reqJson, "page", "必填,请填写页数"); |
| | | |
| | |
| | | |
| | | @Override |
| | | public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException { |
| | | 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 = resourceEntryStoreInnerServiceSMOImpl.getUserTaskCount(auditUser); |
| | | |
| | | List<ApiResourceOrderDataVo> auditOrders = null; |
| | | String userId = context.getReqHeaders().get("user-id"); |
| | | String storeId = context.getReqHeaders().get("store-id"); |
| | | |
| | | if (count > 0) { |
| | | List<PurchaseApplyDto> purchaseApplyDtos = resourceEntryStoreInnerServiceSMOImpl.getUserTasks(auditUser); |
| | | auditOrders = BeanConvertUtil.covertBeanList(purchaseApplyDtos, ApiResourceOrderDataVo.class); |
| | | for( ApiResourceOrderDataVo apiResourceOrderDataVo : auditOrders){ |
| | | switch (apiResourceOrderDataVo.getState()){ |
| | | case "1000": apiResourceOrderDataVo.setStateName("待审核");break; |
| | | case "1001": apiResourceOrderDataVo.setStateName("审核中");break; |
| | | case "1002": apiResourceOrderDataVo.setStateName("已审核");break; |
| | | } |
| | | if(apiResourceOrderDataVo.getResOrderType().equals("10000")){ |
| | | apiResourceOrderDataVo.setResOrderTypeName("采购申请"); |
| | | }else{ |
| | | apiResourceOrderDataVo.setResOrderTypeName("出库申请"); |
| | | } |
| | | OaWorkflowDto oaWorkflowDto = new OaWorkflowDto(); |
| | | oaWorkflowDto.setState(OaWorkflowDto.STATE_COMPLAINT); |
| | | oaWorkflowDto.setFlowType(OaWorkflowDto.FLOW_TYPE_PURCHASE_APPLY); |
| | | List<OaWorkflowDto> oaWorkflowDtos = oaWorkflowInnerServiceSMOImpl.queryOaWorkflows(oaWorkflowDto); |
| | | |
| | | } |
| | | } else { |
| | | auditOrders = new ArrayList<>(); |
| | | if (oaWorkflowDtos == null || oaWorkflowDtos.size() < 1) { |
| | | return; |
| | | } |
| | | List<String> flowIds = new ArrayList<>(); |
| | | for (OaWorkflowDto tmpOaWorkflowDto : oaWorkflowDtos) { |
| | | flowIds.add(WorkflowDto.DEFAULT_PROCESS + tmpOaWorkflowDto.getFlowId()); |
| | | } |
| | | |
| | | ApiResourceOrderVo apiResourceOrderVo = new ApiResourceOrderVo(); |
| | | AuditUser auditUser = new AuditUser(); |
| | | auditUser.setProcessDefinitionKeys(flowIds); |
| | | auditUser.setUserId(userId); |
| | | auditUser.setStoreId(storeId); |
| | | auditUser.setPage(reqJson.getInteger("page")); |
| | | auditUser.setRow(reqJson.getInteger("row")); |
| | | |
| | | apiResourceOrderVo.setTotal((int) count); |
| | | apiResourceOrderVo.setRecords((int) Math.ceil((double) count / (double) reqJson.getInteger("row"))); |
| | | apiResourceOrderVo.setResourceOrders(auditOrders); |
| | | long count = oaWorkflowUserInnerServiceSMOImpl.getDefinitionKeysUserTaskCount(auditUser); |
| | | |
| | | ResponseEntity<String> responseEntity = new ResponseEntity<String>(JSONObject.toJSONString(apiResourceOrderVo), HttpStatus.OK); |
| | | List<JSONObject> datas = null; |
| | | |
| | | if (count > 0) { |
| | | datas = oaWorkflowUserInnerServiceSMOImpl.getDefinitionKeysUserTasks(auditUser); |
| | | //刷新 表单数据 |
| | | refreshFormData(datas, reqJson, storeId); |
| | | } else { |
| | | datas = new ArrayList<>(); |
| | | } |
| | | |
| | | ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reqJson.getInteger("row")), count, datas); |
| | | |
| | | ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK); |
| | | context.setResponseEntity(responseEntity); |
| | | } |
| | | |
| | | private void refreshFormData(List<JSONObject> datas, JSONObject paramIn, String storeId) { |
| | | |
| | | List<String> ids = new ArrayList<>(); |
| | | for (JSONObject data : datas) { |
| | | ids.add(data.getString("id")); |
| | | } |
| | | if (ids.size() < 1) { |
| | | return; |
| | | } |
| | | |
| | | //查询 投诉信息 |
| | | PurchaseApplyDto purchaseApplyDto = new PurchaseApplyDto(); |
| | | purchaseApplyDto.setStoreId(storeId); |
| | | purchaseApplyDto.setApplyOrderIds(ids.toArray(new String[ids.size()])); |
| | | List<PurchaseApplyDto> tmpPurchaseApplyDtos = purchaseApplyInnerServiceSMOImpl.queryPurchaseApplyAndDetails(purchaseApplyDto); |
| | | |
| | | if (tmpPurchaseApplyDtos == null || tmpPurchaseApplyDtos.size() < 1) { |
| | | return; |
| | | } |
| | | |
| | | for (PurchaseApplyDto tmpPurchaseApplyDto : tmpPurchaseApplyDtos) { |
| | | switch (tmpPurchaseApplyDto.getState()) { |
| | | case "1000": |
| | | tmpPurchaseApplyDto.setStateName("待审核"); |
| | | break; |
| | | case "1001": |
| | | tmpPurchaseApplyDto.setStateName("审核中"); |
| | | break; |
| | | case "1002": |
| | | tmpPurchaseApplyDto.setStateName("已审核"); |
| | | break; |
| | | } |
| | | if (tmpPurchaseApplyDto.getResOrderType().equals("10000")) { |
| | | tmpPurchaseApplyDto.setResOrderTypeName("采购申请"); |
| | | } else { |
| | | tmpPurchaseApplyDto.setResOrderTypeName("出库申请"); |
| | | } |
| | | |
| | | |
| | | } |
| | | JSONObject curTaskNode = null; |
| | | for (JSONObject data : datas) { |
| | | |
| | | //todo 计算 当前节点名称 |
| | | curTaskNode = new JSONObject(); |
| | | curTaskNode.put("taskId", data.getString("taskId")); |
| | | curTaskNode = oaWorkflowActivitiInnerServiceSMOImpl.getCurrentNodeTask(curTaskNode); |
| | | data.put("curTaskName", curTaskNode.getString("curTaskName")); |
| | | |
| | | for (PurchaseApplyDto form : tmpPurchaseApplyDtos) { |
| | | if (data.getString("id").equals(form.getApplyOrderId())) { |
| | | data.putAll(BeanConvertUtil.beanCovertJson(form)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |