public String doDelete() { ActionContext ctx = ActionContext.getContext(); HttpServletRequest req = Struts2Util.getRequest(); String[] invoiceIds = req.getParameter("invoiceIds").split(","); // System.out.println("SessionUtil.getUserId():"+SessionUtil.getUserId()); // System.out.println("statusUpReason:"+req.getParameter("statusUpReason")); List<ApInvoice> list = new ArrayList(); for (int i = 0; i < invoiceIds.length; i++) { ApInvoice entity = (ApInvoice) apInvoiceDao .getSession() .get( ApInvoice.class, new Integer(invoiceIds[i])); // apInvoiceDao.get(new Integer(invoiceIds[i])); entity.setOldStatus(entity.getStatus()); // 原始状态 entity.setStatus(Constant.STATUS_VOID); // 修改后的状态 entity.setModifiedBy(SessionUtil.getUserId()); entity.setModifyDate(new Date()); entity.setStatusUpdReason(req.getParameter("statusUpReason")); list.add(entity); } boolean bres = apInvoiceService.delete(list); Struts2Util.getRequest().setAttribute("operate_result", bres); return "delete_invoice_page"; // return input(); }
public String saveServicePriceToSession() throws Exception { Map<String, Object> rt = new HashMap<String, Object>(); String returnType = ServletActionContext.getRequest().getParameter("returnType"); String serviceIdDetail = ServletActionContext.getRequest().getParameter("serviceIdDetail"); String catalogNo = ServletActionContext.getRequest().getParameter("catalogNo"); String key = null; if ("serviceId".equals(returnType)) { servicePrice.setServiceId(Integer.valueOf(serviceIdDetail)); key = servicePrice.getCatalogId() + "_" + servicePrice.getServiceId(); } else { List<com.genscript.gsscm.serv.entity.Service> serv = this.servService.getServiceByCatalogNo(catalogNo); servicePrice.setServiceId(serv.get(0).getServiceId()); key = servicePrice.getCatalogId() + "_" + catalogNo; } ServicePrice sp = this.servService.getServicePriceByServiceIdAndCatalogId( servicePrice.getCatalogId(), servicePrice.getServiceId()); if (sp == null) { sp = servicePrice; } else { sp.setLimitPrice(servicePrice.getLimitPrice()); sp.setStandardPrice(servicePrice.getStandardPrice()); sp.setPriceRuleGroup(servicePrice.getPriceRuleGroup()); sp.setCategoryId(servicePrice.getCategoryId()); } SessionUtil.updateOneRow(SessionPdtServ.ServicePricing.value(), sessionServiceId, key, sp); rt.put("key", key); rt.put("message", SUCCESS); Struts2Util.renderJson(rt); return null; }
public String priceApprovedSaveSession() { Map<String, Object> rt = new HashMap<String, Object>(); String key = Struts2Util.getParameter("priceId"); String approved = Struts2Util.getParameter("approved"); String groupApproved = Struts2Util.getParameter("groupApproved"); String approvedReason = Struts2Util.getParameter("approvedReason"); String oldVal = Struts2Util.getParameter("oldPriceApproved"); ServicePriceDTO dto = new ServicePriceDTO(); if (key == null) { key = Struts2Util.getParameter("subPriceId"); if (key != null) { dto.setPriceId(Integer.valueOf(key)); dto.setServiceSubPriceApprove(Double.valueOf(approved)); dto.setServicePriceReason(approvedReason); dto.setServicePriceOldVal(Double.valueOf(oldVal)); SessionUtil.updateOneRow( SessionPdtServ.ServiceSubPriceApproved.value(), sessionServiceId, key, dto); rt.put("key", key); } } else { dto.setPriceId(Integer.valueOf(key)); if (groupApproved != null && !groupApproved.equals("")) { dto.setServiceRuleGroupPriceApprove(Integer.valueOf(groupApproved)); } if (approved != null && !approved.equals("")) { dto.setServicePriceApprove(Double.valueOf(approved)); } dto.setServicePriceReason(approvedReason); if (oldVal != null && !oldVal.equals("")) { dto.setServicePriceOldVal(Double.valueOf(oldVal)); } else { dto.setServicePriceOldVal(Double.valueOf(0)); } SessionUtil.updateOneRow( SessionPdtServ.ServicePriceApproved.value(), sessionServiceId, key, dto); rt.put("key", key); } rt.put("message", SUCCESS); Struts2Util.renderJson(rt); return null; }
/** @return */ public String afteredit_invoiceline() { ActionContext ctx = ActionContext.getContext(); String dispatch = Struts2Util.getRequest().getParameter("dispatch").trim(); if (null != ctx.getSession().get("apInvoice")) { apInvoice = (ApInvoice) ctx.getSession().get("apInvoice"); param = (Map) ctx.getSession().get("param"); // ctx.getSession().remove("apInvoice"); } String LineNo = "" + apInvoiceLine.getLineNo(); String[] itemNos = param.get("itemNo") == null ? null : (String[]) param.get("itemNo"); String[] catalogNo = param.get("catalogNo") == null ? null : (String[]) param.get("catalogNo"); String[] names = param.get("name") == null ? null : (String[]) param.get("name"); String[] qtys = param.get("qty") == null ? null : (String[]) param.get("qty"); String[] qtyUoms = param.get("qtyUom") == null ? null : (String[]) param.get("qtyUom"); String[] unitPrices = param.get("unitPrice") == null ? null : (String[]) param.get("unitPrice"); String[] amounts = param.get("amount") == null ? null : (String[]) param.get("amount"); String[] taxs = param.get("tax") == null ? null : (String[]) param.get("tax"); String[] sizes = param.get("size") == null ? null : (String[]) param.get("size"); String[] lineNo = param.get("lineNo") == null ? null : (String[]) param.get("lineNo"); String[] creationDate = param.get("creationDate") == null ? null : (String[]) param.get("creationDate"); String[] creationBy = param.get("createdBy") == null ? null : (String[]) param.get("createdBy"); // String[] modify_dates = param.get("modifyDate")== null ? null : // (String[])param.get("modifyDate"); // String[] modified_by = param.get("modifiedBy")== null ? null : // (String[])param.get("modifiedBy"); // ctx.getSession().remove("param"); int i = 0; for (i = 0; i < lineNo.length; i++) { if (LineNo.equals(lineNo[i])) { break; } } amounts[i] = "" + apInvoiceLine.getAmount(); catalogNo[i] = apInvoiceLine.getCatalogNo(); itemNos[i] = "" + apInvoiceLine.getItemNo(); names[i] = apInvoiceLine.getName(); qtys[i] = "" + apInvoiceLine.getQty(); qtyUoms[i] = "" + apInvoiceLine.getQtyUom(); unitPrices[i] = "" + apInvoiceLine.getUnitPrice(); taxs[i] = "" + apInvoiceLine.getTax(); sizes[i] = "" + apInvoiceLine.getSize(); lineNo[i] = "" + apInvoiceLine.getLineNo(); creationDate[i] = Tools.getCurrentTime("yyyy-MM-dd"); creationBy[i] = "" + SessionUtil.getUserId(); // modify_dates[i]=Tools.getCurrentTime("yyyy-MM-dd"); // modified_by[i]=""+SessionUtil.getUserId(); Struts2Util.getRequest().setAttribute("paramEL", param); return dispatch; }
public String searchServicePriceByCategoryIdServiceId() { Map<String, Object> rt = new HashMap<String, Object>(); String catalogId = ServletActionContext.getRequest().getParameter("catalogId"); String catalogNo = ServletActionContext.getRequest().getParameter("catalogNo"); String returnType = ServletActionContext.getRequest().getParameter("returnType"); String serviceIdDetail = ServletActionContext.getRequest().getParameter("serviceIdDetail"); String key = null; if ("serviceId".equals(returnType)) { key = catalogId + "_" + serviceIdDetail; } else { key = catalogId + "_" + catalogNo; } Object obj = SessionUtil.getOneRow(SessionPdtServ.ServicePricing.value(), sessionServiceId, key); if (obj != null) { this.servicePrice = (ServicePrice) obj; } else { if ("serviceId".equals(returnType)) { this.servicePrice = this.servService.getServicePriceByServiceIdAndCatalogId( catalogId, Integer.valueOf(serviceIdDetail)); } else { List<com.genscript.gsscm.serv.entity.Service> serv = this.servService.getServiceByCatalogNo(catalogNo); if (serv.isEmpty()) { this.servicePrice = new ServicePrice(); this.group = new ArrayList<PriceRuleGroups>(); } else { this.servicePrice = this.servService.getServicePriceByServiceIdAndCatalogId( catalogId, serv.get(0).getServiceId()); this.group = this.priceRuleService.searchPriceRuleGroupListByClsId(serv.get(0).getServiceClsId()); } } } Catalog catg = this.productService.getCatalogByCatalogId(catalogId); rt.put("priceAppr", this.getPriceAppr()); rt.put("group", group); rt.put("currencyCode", catg.getCurrencyCode()); rt.put("id", catg.getId()); rt.put("message", SUCCESS); rt.put("servicePrice", servicePrice); Struts2Util.renderJson(rt); return null; }
public String saveServiceSubStepPriceToSession() throws Exception { Map<String, Object> rt = new HashMap<String, Object>(); String key = subStepPrice.getCatalogId() + "_" + subStepPrice.getStepId(); ServiceSubStepPrice sssp = this.servService.getSubStepPrice(subStepPrice.getCatalogId(), subStepPrice.getStepId()); if (sssp == null) { sssp = subStepPrice; } else { sssp.setLimitPrice(subStepPrice.getLimitPrice()); sssp.setRetailPrice(subStepPrice.getRetailPrice()); sssp.setCatalogId(subStepPrice.getCatalogId()); } SessionUtil.updateOneRow( SessionPdtServ.ServiceSubStepPricing.value(), sessionServiceId, key, sssp); rt.put("key", key); rt.put("message", SUCCESS); Struts2Util.renderJson(rt); return null; }
public String searchSubStepPrice() { Map<String, Object> rt = new HashMap<String, Object>(); String catalogId = ServletActionContext.getRequest().getParameter("catalogId"); String stepId = ServletActionContext.getRequest().getParameter("stepId"); String key = catalogId + "_" + stepId; Object obj = SessionUtil.getOneRow(SessionPdtServ.ServiceSubStepPricing.value(), sessionServiceId, key); if (obj != null) { this.subStepPrice = (ServiceSubStepPrice) obj; } else { this.subStepPrice = this.servService.getSubStepPrice(catalogId, Integer.valueOf(stepId)); } Catalog catg = this.productService.getCatalogByCatalogId(catalogId); rt.put("priceAppr", this.getPriceAppr()); rt.put("currencyCode", catg.getCurrencyCode()); rt.put("id", catg.getId()); rt.put("message", SUCCESS); rt.put("subStepPrice", subStepPrice); Struts2Util.renderJson(rt); return null; }
public String searchServicePriceByCatalogId() { Map<String, Object> rt = new HashMap<String, Object>(); String catalogId = ServletActionContext.getRequest().getParameter("catalogId"); String catalogNo = ServletActionContext.getRequest().getParameter("catalogNo"); String returnType = ServletActionContext.getRequest().getParameter("returnType"); String serviceIdDetail = ServletActionContext.getRequest().getParameter("serviceIdDetail"); this.serviceBCategoryOfPriceList = this.servService.getServiceCategoryByCatalogId(catalogId, null, 1); if (serviceBCategoryOfPriceList != null && !serviceBCategoryOfPriceList.isEmpty()) { this.serviceCCategoryOfPriceList = this.servService.getServiceCategoryByCatalogId( catalogId, serviceBCategoryOfPriceList.get(0).getCategoryId(), 2); if (serviceCCategoryOfPriceList != null && !serviceCCategoryOfPriceList.isEmpty()) { this.serviceCategoryOfPriceList = this.servService.getServiceCategoryByCatalogId( catalogId, serviceCCategoryOfPriceList.get(0).getCategoryId(), 3); } else { this.serviceCategoryOfPriceList = new ArrayList<ServiceCategory>(); } } else { this.serviceCCategoryOfPriceList = new ArrayList<ServiceCategory>(); this.serviceCategoryOfPriceList = new ArrayList<ServiceCategory>(); } if (serviceCategoryOfPriceList == null || serviceCategoryOfPriceList.isEmpty()) { this.servicePrice = new ServicePrice(); } else { String key = null; if ("serviceId".equals(returnType)) { key = catalogId + "_" + serviceIdDetail; } else { key = catalogId + "_" + catalogNo; } Object obj = SessionUtil.getOneRow(SessionPdtServ.ServicePricing.value(), sessionServiceId, key); if (obj != null) { this.servicePrice = (ServicePrice) obj; if (servicePrice != null && servicePrice.getCategoryId() != null) { ServiceCategory pcategory = this.servService.getServiceCategoryDetail(servicePrice.getCategoryId()); if (pcategory != null && pcategory.getParentCatId() != null) { ServiceCategory ccategory = this.servService.getServiceCategoryDetail(pcategory.getParentCatId()); if (ccategory != null) { this.ccategoryId = ccategory.getCategoryId(); if (ccategory.getParentCatId() != null) { ServiceCategory bcategory = this.servService.getServiceCategoryDetail(ccategory.getParentCatId()); if (bcategory != null) { this.bcategoryId = bcategory.getCategoryId(); } } } } } } else { if ("serviceId".equals(returnType)) { this.servicePrice = this.servService.getServicePriceByServiceIdAndCatalogId( catalogId, Integer.valueOf(serviceIdDetail)); if (servicePrice != null && servicePrice.getCategoryId() != null) { ServiceCategory pcategory = this.servService.getServiceCategoryDetail(servicePrice.getCategoryId()); if (pcategory != null && pcategory.getParentCatId() != null) { ServiceCategory ccategory = this.servService.getServiceCategoryDetail(pcategory.getParentCatId()); if (ccategory != null) { this.ccategoryId = ccategory.getCategoryId(); if (ccategory.getParentCatId() != null) { ServiceCategory bcategory = this.servService.getServiceCategoryDetail(ccategory.getParentCatId()); if (bcategory != null) { this.bcategoryId = bcategory.getCategoryId(); } } } } } } else { List<com.genscript.gsscm.serv.entity.Service> serv = this.servService.getServiceByCatalogNo(catalogNo); if (serv.isEmpty()) { this.servicePrice = new ServicePrice(); } else { this.servicePrice = this.servService.getServicePriceByServiceIdAndCatalogId( catalogId, serv.get(0).getServiceId()); } } } } Catalog catg = this.productService.getCatalogByCatalogId(catalogId); rt.put("priceAppr", this.getPriceAppr()); rt.put("serviceCategoryOfPriceList", serviceCategoryOfPriceList); rt.put("serviceBCategoryOfPriceList", serviceBCategoryOfPriceList); rt.put("serviceCCategoryOfPriceList", serviceCCategoryOfPriceList); rt.put("ccategoryId", this.ccategoryId); rt.put("bcategoryId", this.bcategoryId); rt.put("currencyCode", catg.getCurrencyCode()); rt.put("id", catg.getId()); rt.put("message", SUCCESS); rt.put("servicePrice", servicePrice); Struts2Util.renderJson(rt); return null; }
/** 保存修改invoiceLine后的发票 */ public String saveEdit() { ActionContext ctx = ActionContext.getContext(); try { ApInvoice oldApInvoice = apInvoiceDao.getById(apInvoice.getInvoiceId()); apInvoice.setModifiedBy(SessionUtil.getUserId()); apInvoice.setModifyDate(new Date()); // 如果原来状态既非 new 也非 inprocess 则不能 修改内容,只能修改状态 if ((!Constant.STATUS_INPROCESS.equals(oldApInvoice.getStatus())) && (!Constant.STATUS_NEW.equals(oldApInvoice.getStatus()))) { String status = oldApInvoice.getStatus(); // 以手动更改为Invalid 手动改为Void if (Constant.STATUS_VOID.equals(status) || Constant.STATUS_INVALID.equals(status)) { oldApInvoice.setStatus(apInvoice.getStatus()); status = apInvoice.getStatus(); if (Constant.STATUS_INPROCESS.equals(status) || Constant.STATUS_NEW.equals(status)) { apInvoiceDao.getSession().clear(); apInvoiceService.edit(oldApInvoice); } } ctx.getSession().remove("apInvoice"); ctx.getSession().remove("param"); return input(); } // boolean flag = this.apInvoiceDao.isAllocation(apInvoice.getInvoiceId()); // 没对过账,对过账的不能修改 boolean changeStatus = false; String status = apInvoice.getStatus(); // 手动更改为Invalid 手动改为Void if (Constant.STATUS_VOID.equals(status) || Constant.STATUS_INVALID.equals(status) && (!flag)) { oldApInvoice.setStatus(status); changeStatus = true; if (Constant.STATUS_INPROCESS.equals(oldApInvoice.getStatus())) { this.changeOderItem(oldApInvoice); apInvoiceDao.getSession().clear(); apInvoiceService.edit(oldApInvoice); ctx.getSession().remove("apInvoice"); ctx.getSession().remove("param"); return input(); } } if ((!oldApInvoice.getCurrency().equals(apInvoice.getCurrency())) && (!flag) && (!changeStatus)) // 没对过账 Currency更改 没手动更改为Invalid 、Void { if (Constant.STATUS_INPROCESS.equals(oldApInvoice.getStatus())) // 原本就是inprocess { apInvoiceService.copyNewInvoice(apInvoice); apInvoice.setCurrency(oldApInvoice.getCurrency()); apInvoice.setStatus(Constant.STATUS_VOID); apInvoiceDao.getSession().clear(); apInvoiceService.edit(apInvoice); ctx.getSession().remove("apInvoice"); ctx.getSession().remove("param"); return input(); } // 原来状态是new的不需要 } apInvoiceDao.getSession().clear(); apInvoiceService.edit(apInvoice); if (!Constant.STATUS_NEW.equals(oldApInvoice.getStatus())) { ctx.getSession().remove("apInvoice"); ctx.getSession().remove("param"); return input(); } int InvoiceId = apInvoice.getInvoiceId(); if (0 != param.size()) { String[] invoiceLineIds = param.get("invoiceLineIds") == null ? null : (String[]) param.get("invoiceLineIds"); String[] invoiceIds = param.get("invoiceIds") == null ? null : (String[]) param.get("invoiceIds"); String[] itemNos = param.get("itemNo") == null ? null : (String[]) param.get("itemNo"); String[] catalogNo = param.get("catalogNo") == null ? null : (String[]) param.get("catalogNo"); String[] names = param.get("name") == null ? null : (String[]) param.get("name"); String[] qtys = param.get("qty") == null ? null : (String[]) param.get("qty"); String[] qtyUoms = param.get("qtyUom") == null ? null : (String[]) param.get("qtyUom"); String[] unitPrices = param.get("unitPrice") == null ? null : (String[]) param.get("unitPrice"); String[] amounts = param.get("amount") == null ? null : (String[]) param.get("amount"); String[] taxs = param.get("tax") == null ? null : (String[]) param.get("tax"); String[] sizes = param.get("size") == null ? null : (String[]) param.get("size"); String[] lineNo = param.get("lineNo") == null ? null : (String[]) param.get("lineNo"); String[] discounts = param.get("discount") == null ? null : (String[]) param.get("discount"); String[] creation_dates = param.get("creationDate") == null ? null : (String[]) param.get("creationDate"); String[] created_by = param.get("createdBy") == null ? null : (String[]) param.get("createdBy"); String[] modify_dates = param.get("modifyDate") == null ? null : (String[]) param.get("modifyDate"); String[] modified_by = param.get("modifiedBy") == null ? null : (String[]) param.get("modifiedBy"); /** 对从invoice 状态从new 变为 inprocess的 invoice line的审核 对invoice line 进行check 开始 */ if (Constant.STATUS_INPROCESS.equals(apInvoice.getStatus()) && (null != itemNos)) { for (int i = 0; i < itemNos.length; i++) { int itemNo = 0; int quantity = 0; double size = 0; itemNo = Tools.String2Integer(itemNos[i]); quantity = Tools.String2Integer(qtys[i]); size = Tools.String2Float(sizes[i]); // // OrderItemOverSizeDTO = this.apInvoiceService.checkOderItem( // apInvoice.getInvoiceId(), // apInvoice.getOrderNo(),itemNo,quantity, size,false ); // // if(null!=OrderItemOverSizeDTO) // { // apInvoiceService.edit(oldApInvoice);// 将 主表的数据 退回 原值 // return "edit_invoice"; // } } // for 循环结束 } /** 对invoice line 进行check 结束 */ ////////////// 在状态为New时。InvoiceLine 执行删除//////////////// // if(Constant.STATUS_NEW.equals(apInvoice.getStatus())) // { String InvoiceLineIds = "0"; String invoiceId = "" + InvoiceId; for (int i = 0; i < invoiceLineIds.length; i++) { InvoiceLineIds = InvoiceLineIds + "," + invoiceLineIds[i]; } try { apInvoiceLineDao.DeleteBatch(invoiceId, InvoiceLineIds); } catch (Exception e) { e.printStackTrace(); } // } //////////////////////////////// ApInvoiceLine insertLine = null; for (int i = 0; i < itemNos.length; i++) { insertLine = apInvoiceLineDao.queryInvoiceLine(Tools.String2Integer(invoiceLineIds[i]).intValue()); if (null == insertLine) { insertLine = new ApInvoiceLine(); } else { insertLine.setInvoiceLineId(Tools.String2Integer(invoiceLineIds[i])); } insertLine.setAmount(Tools.String2Float(amounts[i])); insertLine.setCatalogNo(catalogNo[i]); insertLine.setDiscount(Tools.String2Float(discounts[i])); ; insertLine.setInvoiceId(InvoiceId); insertLine.setItemNo(Tools.String2Integer(itemNos[i])); int linno = Tools.String2Integer(lineNo[i]); // insertLine.setLineNo(linno); insertLine.setLineNo(i + 1); insertLine.setModifiedBy(SessionUtil.getUserId()); insertLine.setModifyDate(new Date()); insertLine.setCreatedBy(Tools.String2Integer(created_by[i])); insertLine.setCreationDate(Tools.getFormatDate(creation_dates[i])); insertLine.setName(names[i]); insertLine.setOrderNo(apInvoice.getOrderNo()); insertLine.setQty(Tools.String2Integer(qtys[i])); insertLine.setQtyUom(qtyUoms[i]); insertLine.setSize(Tools.String2Float(sizes[i])); insertLine.setSizeUom(""); insertLine.setTax(Tools.String2Float(taxs[i])); insertLine.setUnitPrice(Tools.String2Float(unitPrices[i])); insertLine.setStatus(apInvoice.getStatus()); apInvoiceLineDao.save(insertLine); } } } catch (Exception e) { e.printStackTrace(); } ctx.getSession().remove("apInvoice"); ctx.getSession().remove("param"); return input(); }
/** * 新增一个发票点击save后,但是数据还没有保存到数据库 * * @return */ public String afteradd_invoiceline() { ActionContext ctx = ActionContext.getContext(); String dispatch = Struts2Util.getRequest().getParameter("dispatch").trim(); if (null != ctx.getSession().get("apInvoice")) { apInvoice = (ApInvoice) ctx.getSession().get("apInvoice"); // ctx.getSession().remove("apInvoice"); } if (null != ctx.getSession().get("param")) { param = (Map) ctx.getSession().get("param"); String[] invoiceLineIds = param.get("invoiceLineIds") == null ? null : (String[]) param.get("invoiceLineIds"); String[] invoiceIds = param.get("invoiceIds") == null ? null : (String[]) param.get("invoiceIds"); String[] itemNos = param.get("itemNo") == null ? null : (String[]) param.get("itemNo"); String[] catalogNo = param.get("catalogNo") == null ? null : (String[]) param.get("catalogNo"); String[] names = param.get("name") == null ? null : (String[]) param.get("name"); String[] qtys = param.get("qty") == null ? null : (String[]) param.get("qty"); String[] qtyUoms = param.get("qtyUom") == null ? null : (String[]) param.get("qtyUom"); String[] unitPrices = param.get("unitPrice") == null ? null : (String[]) param.get("unitPrice"); String[] amounts = param.get("amount") == null ? null : (String[]) param.get("amount"); String[] taxs = param.get("tax") == null ? null : (String[]) param.get("tax"); String[] sizes = param.get("size") == null ? null : (String[]) param.get("size"); String[] lineNo = param.get("lineNo") == null ? null : (String[]) param.get("lineNo"); String[] discounts = param.get("discount") == null ? null : (String[]) param.get("discount"); String[] creation_dates = param.get("creationDate") == null ? null : (String[]) param.get("creationDate"); String[] created_by = param.get("createdBy") == null ? null : (String[]) param.get("createdBy"); String[] modify_dates = param.get("modifyDate") == null ? null : (String[]) param.get("modifyDate"); String[] modified_by = param.get("modifiedBy") == null ? null : (String[]) param.get("modifiedBy"); // ctx.getSession().remove("param"); String[] invoiceLineIds1 = Tools.add(invoiceLineIds, "0"); String[] invoiceIds1 = Tools.add(invoiceIds, "0"); String itemNo1[] = Tools.add(itemNos, this.apInvoiceLine.getItemNo() + ""); String catalogNo1[] = Tools.add(catalogNo, this.apInvoiceLine.getCatalogNo()); String names1[] = Tools.add(names, this.apInvoiceLine.getName()); // name 未填 String qtys1[] = Tools.add(qtys, this.apInvoiceLine.getQty() + ""); String qtyUoms1[] = Tools.add(qtyUoms, this.apInvoiceLine.getQtyUom()); String unitPrices1[] = Tools.add(unitPrices, this.apInvoiceLine.getUnitPrice() + ""); String amounts1[] = Tools.add(amounts, this.apInvoiceLine.getAmount() + ""); String taxs1[] = Tools.add(taxs, this.apInvoiceLine.getTax() + ""); String[] sizes1 = Tools.add(sizes, this.apInvoiceLine.getSize() + ""); String[] lineNo1 = Tools.add(lineNo, this.apInvoiceLine.getLineNo() + ""); String[] discounts1 = Tools.add(discounts, this.apInvoiceLine.getDiscount() + ""); String[] creation_dates1 = Tools.add(creation_dates, Tools.getCurrentTime("yyyy-MM-dd")); String[] created_by1 = Tools.add(created_by, SessionUtil.getUserId() + ""); String[] modify_dates1 = Tools.add(modify_dates, Tools.getCurrentTime("yyyy-MM-dd") + ""); String[] modified_by1 = Tools.add(modified_by, SessionUtil.getUserId() + ""); param.put("invoiceLineIds", invoiceLineIds1); param.put("invoiceIds", invoiceIds1); param.put("itemNo", itemNo1); param.put("catalogNo", catalogNo1); param.put("name", names1); param.put("qty", qtys1); param.put("qtyUom", qtyUoms1); param.put("amount", amounts1); param.put("tax", taxs1); param.put("unitPrice", unitPrices1); param.put("size", sizes1); param.put("lineNo", lineNo1); param.put("discount", discounts1); param.put("creationDate", creation_dates1); param.put("createdBy", created_by1); param.put("modifyDate", modify_dates1); param.put("modifiedBy", modified_by1); // ctx.getSession().put("param", param); } else { String[] invoiceLineIds = new String[1]; invoiceLineIds[0] = "0"; String[] invoiceIds = new String[1]; invoiceIds[0] = "0"; String itemNo[] = new String[1]; itemNo[0] = this.apInvoiceLine.getItemNo() + ""; String catalogNo[] = new String[1]; catalogNo[0] = apInvoiceLine.getCatalogNo(); String names[] = new String[1]; names[0] = apInvoiceLine.getName(); // 还未给值 String qtys[] = new String[1]; qtys[0] = apInvoiceLine.getQty() + ""; String qtyUoms[] = new String[1]; qtyUoms[0] = apInvoiceLine.getQtyUom(); String unitPrices[] = new String[1]; unitPrices[0] = this.apInvoiceLine.getUnitPrice() + ""; String amounts[] = new String[1]; amounts[0] = this.apInvoiceLine.getAmount() + ""; String taxs[] = new String[1]; taxs[0] = this.apInvoiceLine.getTax() + ""; String[] sizes = new String[1]; sizes[0] = this.apInvoiceLine.getSize() + ""; String[] lineNo = new String[1]; lineNo[0] = this.apInvoiceLine.getLineNo() + ""; String[] discount = new String[1]; discount[0] = this.apInvoiceLine.getDiscount() + ""; String[] creation_dates = Tools.add(null, Tools.getCurrentTime("yyyy-MM-dd") + ""); String[] created_by = Tools.add(null, SessionUtil.getUserId() + ""); String[] modify_dates = Tools.add(null, Tools.getCurrentTime("yyyy-MM-dd") + ""); String[] modified_by = Tools.add(null, SessionUtil.getUserId() + ""); param.put("invoiceLineIds", invoiceLineIds); param.put("invoiceIds", invoiceIds); param.put("itemNo", itemNo); param.put("catalogNo", catalogNo); param.put("name", names); param.put("qty", qtys); param.put("qtyUom", qtyUoms); param.put("amount", amounts); param.put("tax", taxs); param.put("unitPrice", unitPrices); param.put("size", sizes); param.put("lineNo", lineNo); param.put("discount", discount); param.put("creationDate", creation_dates); param.put("createdBy", created_by); param.put("modifyDate", modify_dates); param.put("modifiedBy", modified_by); // ctx.getSession().put("param", param); } Struts2Util.getRequest().setAttribute("paramEL", param); return dispatch; }
/** * 添加invoice,跳转到页面 * * @return * @throws Exception */ public String save() throws Exception { try { apInvoice.setCreatedBy(SessionUtil.getUserId()); apInvoice.setCreationDate(new Date()); apInvoice.setModifiedBy(SessionUtil.getUserId()); apInvoice.setModifyDate(new Date()); apInvoice.setPrintedFlag("N"); int companyId = this.apInvoiceDao.getCompanyId(apInvoice.getOrderNo()); apInvoice.setCompanyId(companyId); // 测试 int InvoiceId = apInvoiceService.add(apInvoice); if (0 != param.size()) { String[] itemNos = param.get("itemNo") == null ? null : (String[]) param.get("itemNo"); String[] catalogNo = param.get("catalogNo") == null ? null : (String[]) param.get("catalogNo"); String[] names = param.get("name") == null ? null : (String[]) param.get("name"); String[] qtys = param.get("qty") == null ? null : (String[]) param.get("qty"); String[] qtyUoms = param.get("qtyUom") == null ? null : (String[]) param.get("qtyUom"); String[] unitPrices = param.get("unitPrice") == null ? null : (String[]) param.get("unitPrice"); String[] amounts = param.get("amount") == null ? null : (String[]) param.get("amount"); String[] taxs = param.get("tax") == null ? null : (String[]) param.get("tax"); String[] sizes = param.get("size") == null ? null : (String[]) param.get("size"); String[] lineNo = param.get("lineNo") == null ? null : (String[]) param.get("lineNo"); String[] discounts = param.get("discount") == null ? null : (String[]) param.get("discount"); ApInvoiceLine insertLine = null; for (int i = 0; i < itemNos.length; i++) { insertLine = new ApInvoiceLine(); insertLine.setAmount(Tools.String2Float(amounts[i])); insertLine.setCatalogNo(catalogNo[i]); insertLine.setCreatedBy(SessionUtil.getUserId()); insertLine.setCreationDate(new Date()); insertLine.setDiscount(Tools.String2Float(discounts[i])); insertLine.setInvoiceId(InvoiceId); insertLine.setItemNo(Tools.String2Integer(itemNos[i])); int linno = Tools.String2Integer(lineNo[i]); // insertLine.setLineNo(linno); insertLine.setLineNo(i + 1); insertLine.setModifiedBy(SessionUtil.getUserId()); insertLine.setModifyDate(new Date()); insertLine.setName(names[i]); insertLine.setOrderNo(apInvoice.getOrderNo()); insertLine.setQty(Tools.String2Integer(qtys[i])); insertLine.setQtyUom(qtyUoms[i]); insertLine.setSize(Tools.String2Float(sizes[i])); insertLine.setSizeUom(""); insertLine.setTax(Tools.String2Float(taxs[i])); insertLine.setUnitPrice(Tools.String2Float(unitPrices[i])); insertLine.setStatus(Constant.STATUS_NEW); apInvoiceLineDao.save(insertLine); } } } catch (Exception e) { e.printStackTrace(); } ActionContext ctx = ActionContext.getContext(); ctx.getSession().remove("apInvoice"); ctx.getSession().remove("param"); return input(); }