Beispiel #1
0
  /**
   * start CreditNote WorkFlow [serviceSheetNo] equals [CreditNoteNo]
   *
   * @param cnForm
   * @param cnm
   * @return
   * @throws Exception
   */
  @SuppressWarnings("rawtypes")
  public String startCreditNoteWorkFlow(CreditNoteForm cnForm, CreditNoteMain cnm)
      throws Exception {
    if (cnm.getId() == null) {
      throw new IllegalArgumentException("CreditNoteMain-->id can not be null!!!");
    }
    String wfid = workflowService.getBusinessId();
    UserForm uf = new UserForm();
    uf.setId(cnForm.getCurrentUserId());
    uf.setUserName(cnForm.getCurrentUserName());
    uf.setPosition("");
    log.info("CreditNote->启动工作流开始...............");
    String[] roleConfig = workFlowInit.getAllRole2(tmplateName, "C", cnForm.getStType());
    String[] nextRole =
        workFlowInit.getNextRole(
            roleConfig,
            Integer.parseInt(wfid),
            BPEProcessConstants.NOTQUERY,
            BPEProcessConstants.NOUPDATENEXTROLETABLE);
    Map<String, Object> businessMap = new HashMap<String, Object>();
    businessMap.put("varOrganizationCode", cnForm.getOrgCode());
    businessMap.put("varPcType", "C");
    businessMap.put("varStType", cnForm.getStType());
    businessMap.put(ParameterConstants.PARAM_BUSINESS_CODE, cnm.getId() + "");

    // 准备申请流程参数
    Map params = workFlowInit.initapplyMap(businessMap, uf, wfid.toString(), tmplateId);
    // 当前用户对象封装
    NewsisUser nu = new NewsisUser();
    nu.setUserId(String.valueOf(uf.getId()));
    nu.setUserName(uf.getUserName());
    String[] strs = new String[] {nextRole[0]};
    Long[] longs = new Long[strs.length + 2];
    longs[0] = null;
    longs[1] = null;
    for (int i = 0; i < strs.length; i++) {
      longs[i + 2] = new Long(strs[i]);
    }
    String roleConfigStr = roleConfig[0];
    if (roleConfigStr.indexOf(",") != -1) {
      roleConfigStr = roleConfigStr.substring(0, roleConfigStr.indexOf(","));
    }
    WBIDBOperateBo wbido = new WBIDBOperateBo();
    wbido.insertStartInfo(
        Long.parseLong(wfid),
        "D",
        uf.getId(),
        cnm.getId(),
        cnForm.getCnNo(),
        new Long(roleConfigStr),
        longs);
    // /启动BPE申请工作流
    IWorkFlowService workFlowService = (IWorkFlowService) workflowService;
    workFlowService.doStartProcess(params, nu);
    return wfid;
  }
  /**
   * Method of submiting controled part applicaiton
   *
   * @param ralpf Controled part application
   * @param approveRoles Approve role list
   * @return 1:Successful,-1:Unsuccessful
   */
  public int pageSave(RepairApplicationPRForm ralpf, UserForm uf) {
    int returnFlag = -1;
    AllDefaultDaoImp daoImp = (AllDefaultDaoImp) SpringContextUtil.getBean("dao");
    String stType =
        ((CommonSearch) SpringContextUtil.getBean("commonSearch"))
            .findStTypeByOrgCode(ralpf.getOrganizationCode());
    WorkFlowConfigRole wfcr = null;
    try {

      ralpf.setWorkflowId(Long.valueOf(workFlowService.getBusinessId()));
      /* *******************************************************************/
      /*@Added/Modified by        : Deepak
      /*@Date                     : 14/10/2012
      /*@Reason                   : Part request application workflow
      /**********************************************************************/
      MultiEntity multiEntity = (MultiEntity) SpringContextUtil.getBean("multiEntity");
      String[] roleConfig = null;
      if (!multiEntity.getCountryCode().equalsIgnoreCase("IN")) {
        roleConfig =
            workFlowInit.getAllRole(BPEProcessConstants.PARTREQUEST, stType); // need to change
        ralpf.setAllApproveRoles(roleConfig[0]);
        logger.info("if ===from getallrole pagesave method==Deepak==" + roleConfig[0]);
      } else {
        if (ralpf.getWarrantyType().equals("O") && ralpf.getPartFeeType().equals("N")) {
          wfcr = daoImp.findByTempNameAndStep(BPEProcessConstants.PARTREQUEST, "STEP2", stType);
          logger.info("if part wfcr.getConfigRole()" + wfcr.getConfigRole());
          ralpf.setAllApproveRoles(wfcr.getConfigRole());

        } else {
          wfcr = daoImp.findByTempNameAndStep(BPEProcessConstants.PARTREQUEST, "STEP1", stType);
          //                  System.out.println("else part
          // wfcr.getConfigRole()"+wfcr.getConfigRole());
          ralpf.setAllApproveRoles(wfcr.getConfigRole());
          logger.info("else ===from getallrole pagesave method==Deepak==" + wfcr.getConfigRole());
        }
      }
      logger.info("===Pagesave method of Repair applicationPRBo.java file ");
      /** ******************************************************************* */
      returnFlag = this.getDao().insert(ralpf) ? 1 : -1;

      String tmplateId = "13";

      Map businessMap = new HashMap();
      businessMap.put("businessCode", ralpf.getServiceSheetNo());
      businessMap.put("varStType", stType);
      businessMap.put("varOrganizationCode", String.valueOf(ralpf.getOrganizationCode()));
      Map params =
          workFlowInit.initapplyMap(businessMap, uf, ralpf.getWorkflowId().toString(), tmplateId);
      NewsisUser nu = new NewsisUser();

      nu.setUserId(String.valueOf(uf.getId()));
      nu.setUserName(uf.getUserName());

      //			/***/
      WBIDBOperateBo wbido = new WBIDBOperateBo();
      String[] strs = ralpf.getAllApproveRoles().split(",");
      Long[] longs = new Long[strs.length + 2];
      longs[0] = null;
      longs[1] = null;
      for (int i = 0; i < strs.length; i++) {
        longs[i + 2] = new Long(strs[i]);
      }
      wbido.insertStartInfo(
          ralpf.getWorkflowId(),
          "P",
          ralpf.getApplyMan(),
          ralpf.getRepairNo(),
          ralpf.getServiceSheetNo(),
          new Long(strs[0]),
          longs);

      //			    System.out.println("写入到RepairUnRepairStatusInfoForm-----");
      List batchInsertList = new ArrayList();
      RepairUnRepairStatusInfoForm rursif = new RepairUnRepairStatusInfoForm();
      rursif.setRepairNo(ralpf.getRepairNo());
      rursif.setUnRepairStatus("E"); // Waiting for internal approve
      rursif.setDbBeginDate(((MultiDate) SpringContextUtil.getBean("multiDate")).getMultiDate());
      rursif.setOrganizationCode(ralpf.getOrganizationCode().toString());
      rursif.setUnrepairGenType("A");
      rursif.setWorkFlowNo(ralpf.getWorkflowId().toString());
      rursif.setCreateBy(ralpf.getCreateBy());
      rursif.setCreateDate(Operate.toUtilDate());
      batchInsertList.add(rursif);

      returnFlag = this.getBatchDao().insertBatch(batchInsertList) ? 1 : -1;
      //			///启动BPE申请工作流
      ProcessInfo pinfo = workFlowService.doStartProcess(params, nu);

    } catch (Exception e) {
      e.printStackTrace();
    }
    return returnFlag;
  }
Beispiel #3
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;
 }