public void updateCreditNoteWfStatus(String billId, String status, Long userId) throws ComException, Exception { CreditNoteForm fm = new CreditNoteForm(); CreditNoteMain fmmain = new CreditNoteMain(); fmmain.setId(new Long(billId)); fm.setCnm(fmmain); CreditNoteBo cnBo = (CreditNoteBo) SpringContextUtil.getBean("cnBo"); CreditNoteMain cnm = cnBo.queryCreditNoteMain(fm); if (null != cnm) { List<Object> updateList = new ArrayList<Object>(); Date currentDate = Operate.toUtilDate(); cnm.setStatus(status); cnm.setUpdateBy(userId); cnm.setUpdateDate(currentDate); updateList.add(cnm); Set<CreditNoteDetail> detailSets = cnm.getCreditNoteDetails(); for (CreditNoteDetail detail : detailSets) { if (SysConstants.CN_FLAG_Y.equals(detail.getCnFlag())) { detail.setStatus(status); detail.setUpdateBy(userId); detail.setUpdateDate(currentDate); updateList.add(detail); } } CreditNoteMainTemp cnmt = (CreditNoteMainTemp) this.getDao() .uniqueResult("from CreditNoteMainTemp cnmt where cnmt.id=?", cnm.getRefTid()); if (null != cnmt) { if (SysConstants.CN_STATUS_APPROVAL.equals(status)) { cnmt.setStatus(status); } else { // 如果审批不通过,Credit Note Temp主表置为关闭状态 cnmt.setStatus(SysConstants.CN_TEMP_STATUS_CLOSED); } cnmt.setUpdateBy(cnm.getUpdateBy()); cnmt.setUpdateDate(currentDate); updateList.add(cnmt); } this.getBatchDao().saveOrUpdateBatch(updateList); } }
/** * 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; }