Beispiel #1
0
 /**
  * @param userId 审批人
  * @param wfid 流程id
  * @param comment
  * @param orgCodeRR
  * @param string
  * @param tkiid
  * @param approveAgree
  * @return
  * @throws Exception
  */
 @SuppressWarnings("rawtypes")
 public ProcessInfo approveCreditNote(
     Long userId,
     String wfid,
     String processId,
     String comment,
     Long orgCode,
     boolean approveAgree) {
   ProcessInfo pf = null;
   Map<String, Object> businessMap = new HashMap<String, Object>();
   businessMap.put("businessCode", wfid); // throw new Exception();
   businessMap.put("varorganizationCode", orgCode.toString());
   String stType =
       ((CommonSearch) SpringContextUtil.getBean("commonSearch")).findStTypeByOrgCode(orgCode);
   businessMap.put("varStType", stType);
   WorkFlowDao workFlowDao = (WorkFlowDao) BeanUtil.getBean("workFlowDao");
   try {
     WorkFlowNextRoles wfnr =
         workFlowDao.findWorkFlowNextRolesByProcessId(Integer.parseInt(processId));
     WBIDBOperateBo wbidbbo = new WBIDBOperateBo();
     TdWorkFlowForm wff = wbidbbo.getWorkFlowFormByWorkflowNoAndSheetType(processId, "D");
     String currentRole = "";
     if (null != wfnr) {
       log.info("CreditNote->审批----ROLES:" + wfnr.getProcessNextRoles());
       if (wfnr.getProcessNextRoles().indexOf(",") != -1) {
         String[] configRoles = wfnr.getProcessNextRoles().split(",");
         currentRole = configRoles[0];
       } else {
         currentRole = wfnr.getProcessNextRoles();
       }
     }
     TdWorkFlowInfoForm wfif = new TdWorkFlowInfoForm();
     // 审批单据号码
     wfif.setWorkflowNo(wff.getWorkflowNo());
     wfif.setSheetType("D"); // 审批单据类型
     wfif.setApproveUser(userId); // 审批人
     wfif.setRoleCode(wff.getNextRole());
     // 审批时角色
     wfif.setApproveDate(Operate.getCurrentDate());
     // 审批日期
     wfif.setWorkFlowStatus("R"); // 流程状态为等待审批
     if (approveAgree) {
       wff.setCurrentStatus(cn.com.sony.npc.common.SysConstants.NPC_WORKFLOW_STATUS_O);
       wfif.setApproveResult("Y"); // 审批同意
       wff.setApproveResult("Y");
     } else {
       wfif.setApproveResult("N"); // 审批不同意
       wff.setApproveResult("N");
     }
     wfif.setApproveNote(comment); // 审批内容
     wfif.setCreateBy(Long.valueOf(userId));
     if (!"".equals(currentRole)) {
       wff.setNextRole(Long.valueOf(currentRole)); // 设置下一个审批角色
     } else {
       wff.setNextRole(null); // 设置下一个审批角色
     }
     wff.setUpdateDate(Operate.getCurrentDate());
     wfif.setWff(wff);
     if (!wbidbbo.isClosedAlready(new Long(processId))) {
       wbidbbo.insert(wfif);
       // 工作流参数(MAP)准备工作
       Map params = workFlowInit.initApproveMap(businessMap, approveAgree + "", wfid, comment);
       // 启动BPE工作流
       IWorkFlowService workFlowService = (IWorkFlowService) BeanUtil.getBean("workFlowService");
       MockUser user = new MockUser();
       user.setUserId(userId + "");
       user.setUserName(CommonSearch.getInstance().findUserNameByUserId(userId));
       user.setCurrentRole(currentRole);
       pf = workFlowService.doApproveProcess(params, user);
       // 工作流审批结束TODO
       log.info("CreditNote->当前审批结束,下个审批节点是:" + pf.getNextStateId());
       log.info("CreditNote->............流程审批结束.............");
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
   return pf;
 }