/** 流程定义列表 */ public Page<Object[]> processList(Page<Object[]> page, String category) { ProcessDefinitionQuery processDefinitionQuery = repositoryService .createProcessDefinitionQuery() .latestVersion() .orderByProcessDefinitionKey() .asc(); if (StringUtils.isNotEmpty(category)) { processDefinitionQuery.processDefinitionCategory(category); } page.setCount(processDefinitionQuery.count()); List<ProcessDefinition> processDefinitionList = processDefinitionQuery.listPage(page.getFirstResult(), page.getMaxResults()); for (ProcessDefinition processDefinition : processDefinitionList) { String deploymentId = processDefinition.getDeploymentId(); Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult(); page.getList().add(new Object[] {processDefinition, deployment}); } return page; }
@Transactional(readOnly = false) public Page<Link> find(Page<Link> page, Link link, boolean isDataScopeFilter) { // 更新过期的权重,间隔为“6”个小时 Date updateExpiredWeightDate = (Date) CacheUtils.get("updateExpiredWeightDateByLink"); if (updateExpiredWeightDate == null || (updateExpiredWeightDate != null && updateExpiredWeightDate.getTime() < new Date().getTime())) { linkDao.updateExpiredWeight(); CacheUtils.put("updateExpiredWeightDateByLink", DateUtils.addHours(new Date(), 6)); } DetachedCriteria dc = linkDao.createDetachedCriteria(); dc.createAlias("category", "category"); dc.createAlias("category.site", "category.site"); if (link.getCategory() != null && StringUtils.isNotBlank(link.getCategory().getId()) && !Category.isRoot(link.getCategory().getId())) { Category category = categoryDao.get(link.getCategory().getId()); if (category != null) { dc.add( Restrictions.or( Restrictions.eq("category.id", category.getId()), Restrictions.like("category.parentIds", "%," + category.getId() + ",%"))); dc.add(Restrictions.eq("category.site.id", category.getSite().getId())); link.setCategory(category); } else { dc.add(Restrictions.eq("category.site.id", Site.getCurrentSiteId())); } } else { dc.add(Restrictions.eq("category.site.id", Site.getCurrentSiteId())); } if (StringUtils.isNotEmpty(link.getTitle())) { dc.add(Restrictions.like("title", "%" + link.getTitle() + "%")); } if (link.getCreateBy() != null && StringUtils.isNotBlank(link.getCreateBy().getId())) { dc.add(Restrictions.eq("createBy.id", link.getCreateBy().getId())); } if (isDataScopeFilter) { dc.createAlias("category.office", "categoryOffice").createAlias("createBy", "createBy"); dc.add(dataScopeFilter(UserUtils.getUser(), "categoryOffice", "createBy")); } dc.add(Restrictions.eq(Link.FIELD_DEL_FLAG, link.getDelFlag())); dc.addOrder(Order.desc("weight")); dc.addOrder(Order.desc("updateDate")); return linkDao.find(page, dc); }
// @RequiresPermissions("funds:tradingAccounts:view") @RequestMapping(value = "form") public String form( TradingAccounts tradingAccounts, Model model, RedirectAttributes redirectAttributes) { String type = tradingAccounts.getTradeType(); if ("0".equals(type)) { // 承租合同直接处理,不跳转 tradingAccounts.setTradeStatus("1"); // 审核通过 tradingAccounts.setTradeDirection("0"); // 出账 tradingAccounts.setPayeeType("1"); // 交易人类型为“个人” String[] paymentTransIdArray = tradingAccounts.getTransIds().split(","); for (int i = 0; i < paymentTransIdArray.length; i++) { PaymentTrans paymentTrans = paymentTransService.get(paymentTransIdArray[i]); tradingAccounts.setId(null); tradingAccounts.setTradeAmount( paymentTrans.getTradeAmount() - paymentTrans.getTransAmount()); tradingAccounts.setTransIds(paymentTransIdArray[i]); tradingAccounts.setPayeeName( leaseContractService.get(paymentTrans.getTransId()).getRemittancerName()); if (tradingAccounts.getTradeAmount() > 0) { tradingAccountsService.save(tradingAccounts); } } addMessage(redirectAttributes, "保存账务交易成功"); return "redirect:" + Global.getAdminPath() + "/funds/paymentTrans/?repage"; } else { String[] paymentTransIdArray = tradingAccounts.getTransIds().split(","); double amount = 0; // 实际交易金额 String tradeType = ""; // 交易类型 String tradeObjectId = ""; // 交易对象ID Map<String, Receipt> paymentTypeMap = new HashMap<String, Receipt>(); for (int i = 0; i < paymentTransIdArray.length; i++) { PaymentTrans paymentTrans = paymentTransService.get(paymentTransIdArray[i]); if ("0".equals(paymentTrans.getTradeDirection())) { // 应出 amount -= paymentTrans.getLastAmount(); } else { // 应收 amount += paymentTrans.getLastAmount(); } tradeType = paymentTrans.getTradeType(); // 交易类型 tradeObjectId = paymentTrans.getTransId(); // 交易对象ID String paymentType = paymentTrans.getPaymentType(); // 款项类型 // 包含有出款的交易类型:0=承租合同,2=定金转违约,6=提前退租,7=正常退租,8=逾期退租,9=特殊退租 if ("0".equals(tradeType) || "2".equals(tradeType)) { // 0=承租合同,2=定金转违约不开收据 } else if ("6".equals(tradeType) || "7".equals(tradeType) || "8".equals(tradeType) || "9".equals(tradeType)) { } else { // 交易类型里的款项全是收款,不包含出款 if (!"0".equals(paymentTrans.getTradeDirection())) { // 应收款项 Receipt receipt = new Receipt(); if (paymentTypeMap.containsKey(paymentType)) { receipt = paymentTypeMap.get(paymentType); } receipt.setReceiptAmount( (null == receipt.getReceiptAmount() ? 0d : receipt.getReceiptAmount()) + paymentTrans.getLastAmount()); receipt.setPaymentType(paymentType); paymentTypeMap.put(paymentType, receipt); } } } List<Receipt> receiptList = new ArrayList<Receipt>(); /* 收据 */ if ("0".equals(tradeType) || "2".equals(tradeType)) { // 0=承租合同,2=定金转违约不开收据 } else if ("6".equals(tradeType) || "7".equals(tradeType) || "8".equals(tradeType) || "9".equals(tradeType)) { // 6=提前退租,7=正常退租,8=逾期退租,9=特殊退租 if (amount > 0) { // 总到账金额大于0 Receipt receipt = new Receipt(); receipt.setReceiptAmount( new BigDecimal(amount).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); receiptList.add(receipt); } } else { for (String key : paymentTypeMap.keySet()) { Receipt receipt = paymentTypeMap.get(key); receiptList.add(receipt); } } // 获取交易对象名称,设置交易对象名称、交易对象类型 if (StringUtils.isNotEmpty(tradeObjectId)) { DepositAgreement da = depositAgreementService.get(tradeObjectId); if (da != null) { // 定金协议承租人 List<Tenant> tenants = depositAgreementService.findTenant(da); // 定金协议的承租人列表 if (CollectionUtils.isNotEmpty(tenants)) { tradingAccounts.setPayeeName(tenants.get(0).getTenantName()); String tenantType = tenants.get(0).getTenantType(); // 租客类型 if ("0".equals(tenantType)) { // 个人租客 tradingAccounts.setPayeeType("1"); // 交易人类型为“个人” } if ("1".equals(tenantType)) { // 企业租客 tradingAccounts.setPayeeType("0"); // 交易人类型为“单位” } } } else { RentContract rc = rentContractService.get(tradeObjectId); if (rc != null) { // 出租合同承租人 List<Tenant> tenants = rentContractService.findTenant(rc); if (CollectionUtils.isNotEmpty(tenants)) { tradingAccounts.setPayeeName(tenants.get(0).getTenantName()); String tenantType = tenants.get(0).getTenantType(); // 租客类型 if ("0".equals(tenantType)) { // 个人租客 tradingAccounts.setPayeeType("1"); // 交易人类型为“个人” } if ("1".equals(tenantType)) { // 企业租客 tradingAccounts.setPayeeType("0"); // 交易人类型为“单位” } } } } } tradingAccounts.setTradeDirection(amount > 0 ? "1" : "0"); tradingAccounts.setTradeAmount( new BigDecimal(Math.abs(amount)).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); tradingAccounts.setTradeDirectionDesc( DictUtils.getDictLabel(tradingAccounts.getTradeDirection(), "trans_dirction", "")); tradingAccounts.setTradeType(tradeType); tradingAccounts.setTradeTypeDesc( DictUtils.getDictLabel(tradingAccounts.getTradeType(), "trans_type", "")); model.addAttribute("tradingAccounts", tradingAccounts); tradingAccounts.setReceiptList(receiptList); return "modules/funds/tradingAccountsForm"; } }