Esempio n. 1
0
/**
 * Controled part application hangdle Bo
 *
 * @author HaoShuang
 */
public class RepairApplicationPRBo extends CommBo {
  IWorkFlowService workFlowService = (IWorkFlowService) BeanUtil.getBean("workFlowService");
  private RepairHandleBo repairHandleBo;

  public RepairHandleBo getRepairHandleBo() {
    return repairHandleBo;
  }

  public void setRepairHandleBo(RepairHandleBo repairHandleBo) {
    this.repairHandleBo = repairHandleBo;
  }

  public RepairApplicationRMABo getRepairApplicationRMABo() {
    return repairApplicationRMABo;
  }

  public void setRepairApplicationRMABo(RepairApplicationRMABo repairApplicationRMABo) {
    this.repairApplicationRMABo = repairApplicationRMABo;
  }

  WorkFlowInit workFlowInit = (WorkFlowInit) BeanUtil.getBean("workFlowInit");
  private RepairApplicationRMABo repairApplicationRMABo;
  private PartInfoBo partInfoBo;

  public PartInfoBo getPartInfoBo() {
    return partInfoBo;
  }

  //	private WorkFlowInit workFlowInit;

  public RepairApplicationLPBo getRepairApplicationLPBo() {
    return repairApplicationLPBo;
  }

  public void setRepairApplicationLPBo(RepairApplicationLPBo repairApplicationLPBo) {
    this.repairApplicationLPBo = repairApplicationLPBo;
  }

  private RepairApplicationLPBo repairApplicationLPBo;

  //	public WorkFlowInit getWorkFlowInit() {
  //		return workFlowInit;
  //	}
  //	public void setWorkFlowInit(WorkFlowInit workFlowInit) {
  //		this.workFlowInit = workFlowInit;
  //	}

  public void setPartInfoBo(PartInfoBo partInfoBo) {
    this.partInfoBo = partInfoBo;
  }

  private static Logger logger = Logger.getLogger(RepairListBo.class);

  /**
   * 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;
  }

  /**
   * Call method after controled part application approved
   *
   * @param ralpf Application details
   * @param approveFlag true:Approve passed,false:Approve failed
   */
  public void wbiBack(boolean approveFlag, RepairApplicationPRForm raprf, long userId) {
    try {
      RepairPartForm rpform =
          (RepairPartForm) this.getDao().findById(RepairPartForm.class, raprf.getPartsId());
      rpform.setPartRequestNo(raprf.getWorkflowId());
      this.getDao().update(rpform);
      // 将TD_UNREPAIR_STATUS置为完成
      try {
        List unRepairStatusForms =
            this.getDao()
                .list(
                    " from RepairUnRepairStatusInfoForm rursif where rursif.unRepairStatus='E' and rursif.repairNo="
                        + raprf.getRepairNo()
                        + " and rursif.workFlowNo="
                        + raprf.getWorkflowId());
        for (int i = 0; i < unRepairStatusForms.size(); i++) {
          RepairUnRepairStatusInfoForm rursif =
              (RepairUnRepairStatusInfoForm) unRepairStatusForms.get(i);
          rursif.setDbEndDate(((MultiDate) SpringContextUtil.getBean("multiDate")).getMultiDate());
          rursif.setContinuanceDays(
              new Long(Operate.calculateDiffDays(rursif.getDbBeginDate(), rursif.getDbEndDate())));
          rursif.setContinuanceHours(
              new Long(Operate.calculateDiffHours(rursif.getDbBeginDate(), rursif.getDbEndDate())));

          rursif.setUpdateDate(
              new java.sql.Date(
                  ((MultiDate) SpringContextUtil.getBean("multiDate")).getMultiDate().getTime()));
          unRepairStatusForms.set(i, rursif);
        }
        this.getBatchDao().updateBatch(unRepairStatusForms);
      } catch (Exception e) {
        e.printStackTrace();
      }
      UserForm uf = (UserForm) this.getDao().findById(UserForm.class, userId);
      if (approveFlag) {

        // 取出此零件对应的维修单
        RepairServiceForm rsf =
            (RepairServiceForm)
                this.getDao().findById(RepairServiceForm.class, raprf.getRepairNo());
        // 取出此零件的基本信息

        // 根据PARTCODE查询RETURN PART 看是否RMA审批零件
        List returnPart =
            this.getDao()
                .list("from ReturnPartForm r where r.partCode='" + raprf.getPartCode() + "'");

        CommonSearch cs = ((CommonSearch) SpringContextUtil.getBean("commonSearch"));
        String pcType = cs.findPcTypeByOrgCode(rsf.getOrganizationCode());
        LimitPartApprove lpa = new LimitPartApprove();
        String[] approveRoles =
            lpa.getApproveRoles(
                "Y".equals(rpform.getPartFeeType()) ? "O" : "I",
                rsf.getManufacture(),
                rsf.getModelCode(),
                rpform.getPartCode(),
                pcType);

        if (!returnPart.isEmpty()) { // 如果符合RMA零件申请则自动启动RMA流程申请
          //			System.out.println("维修零件申请审批结束---系统自动启动RMA零件申请");
          RepairListBo rlb = new RepairListBo();
          RepairPartForm rpf = rlb.getRepairPartInfo(raprf.getPartsId());
          rpf.setRepairPartStatus("E");
          rpf.setRmaApply("Y");
          this.getDao().update(rpf);

          RepairApplicationRMAForm rmaForm = new RepairApplicationRMAForm();
          rmaForm.setRepairNo(rsf.getRepairNo());
          rmaForm.setServiceSheetNo(rsf.getServiceSheetNo());
          rmaForm.setModelCode(rsf.getModelCode());
          rmaForm.setSerialNo(rsf.getSerialNo());
          rmaForm.setPartsId(rpf.getPartsId());
          rmaForm.setPartCode(rpf.getPartCode());
          rmaForm.setOrganizationCode(rsf.getOrganizationCode());
          rmaForm.setModelName(rsf.getModelName());
          rmaForm.setCreateDate(
              ((MultiDate) SpringContextUtil.getBean("multiDate")).getMultiDate());
          rmaForm.setCreateBy(rpf.getUpdateBy());
          rmaForm.setApplyMan(rpf.getUpdateBy());
          repairApplicationRMABo.startRMA(rmaForm, uf);
        } else if (approveRoles != null) { // 如果符合受控零件申请则自动启动受控流程申请
          //			System.out.println("维修零件申请审批结束---系统自动启动受控零件申请");
          RepairListBo rlb = new RepairListBo();
          RepairPartForm rpf = rlb.getRepairPartInfo(raprf.getPartsId());
          rpf.setRepairPartStatus("E");
          rpf.setLimitApply("Y"); // 如果是受控零件,先更改零件申请类型
          this.getDao().update(rpf); // 更新维修零件表
          RepairApplicationLPForm ralpf = new RepairApplicationLPForm();
          ralpf.setRepairNo(rsf.getRepairNo());
          ralpf.setServiceSheetNo(rsf.getServiceSheetNo());
          ralpf.setModelCode(rsf.getModelCode());
          ralpf.setModelName(rsf.getModelName());
          ralpf.setSerialNo(rsf.getSerialNo());
          ralpf.setPartsId(rpf.getPartsId());
          ralpf.setPartCode(rpf.getPartCode());
          ralpf.setOrganizationCode(rsf.getOrganizationCode());
          ralpf.setCreateDate(((MultiDate) SpringContextUtil.getBean("multiDate")).getMultiDate());
          ralpf.setCreateBy(rpf.getUpdateBy());
          ralpf.setApplyMan(rpf.getUpdateBy());
          ralpf.setFactory(rsf.getManufacture());
          ralpf.setFee(rpf.getFee1());
          ralpf.setPartFeeType(rpf.getPartFeeType());

          repairApplicationLPBo.pageSave(ralpf, approveRoles, uf);
        } else {
          PartInfoForm pif =
              (PartInfoForm) this.getDao().findById(PartInfoForm.class, rpform.getPartCode());
          repairHandleBo.repairApproveAllocate(
              raprf.getWorkflowId(), raprf.getCreateBy(), rsf, rpform, pif);
        }
      } else {
        // 审批拒绝repair_part_info & partrequest update
        //			rpform.setRepairPartStatus("X");
        //			rpform.setCancelQty(new Long(1));
        //
        //	rpform.setUpdateDate(((MultiDate)SpringContextUtil.getBean("multiDate")).getMultiDate());
        //			this.getDao().update(rpform);
        repairHandleBo.processReject(rpform, raprf.getWorkflowId(), raprf.getCreateBy());
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
}
Esempio n. 2
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;
 }