Exemplo n.º 1
0
  /**
   * Part accessory sale index save
   *
   * @param request HttpServletRequest
   * @param form form data
   * @return String Return to forward page resultMessage Succeed to save page of part accessory sale
   */
  public String sellPrepareSalesList(HttpServletRequest request, ActionForm form) {
    // String forward="sellRegisterList";
    String forward = "resultMessage";
    int tag = -1;

    try {
      SellRegisterForm srf = (SellRegisterForm) form;
      HttpSession session = request.getSession();
      Long userId = (Long) session.getAttribute("userId");
      Long orgCode = (Long) session.getAttribute("orgCode");
      String orgCode2 = request.getParameter("stationCode");
      if (orgCode2 != null && Operate.isPositiveInteger(orgCode2)) {
        orgCode = new Long(orgCode2);
        srf.setOrgName(
            ((CommonSearch) SpringContextUtil.getBean("commonSearch"))
                .findOrgNameByOrgCode(orgCode));
      }

      // 接收表单提交数据

      String[] skuCode1 = request.getParameterValues("skuCode1"); // SKU编号
      String[] skuQuanty1 = request.getParameterValues("skuQuanty1");
      // 数量
      String[] bkbs = request.getParameterValues("bkbs"); // 订购选项
      String[] marks = request.getParameterValues("marks"); // 备注
      String[] stdCost1 = request.getParameterValues("stdCost1"); // 建议价格
      String[] count1 = request.getParameterValues("count1"); // 实际价格
      String[] partDesc1 = request.getParameterValues("partDesc1");
      // SKU描述-英
      String[] partName1 = request.getParameterValues("partName1");
      // SKU描述-中
      String[] stdCost0 = request.getParameterValues("stdCost0"); // 建议单价
      String[] wcNo = request.getParameterValues("wcNo"); // 保卡号
      String[] sn1 = request.getParameterValues("sn1"); // SN号
      String[] lot1 = request.getParameterValues("lot1"); // LOT号
      String[] discount1 = request.getParameterValues("discount1");
      String[] totalTax = request.getParameterValues("totalTax");
      String taxBuffer[] = request.getParameterValues("taxBuffer");
      String totoalDiscount = request.getParameter("totalDiscount");
      // 销售来源
      String fromSales =
          request.getParameter("fromSales") == null ? "0" : request.getParameter("fromSales");
      //			PopupSaleInfoBo sibo = new PopupSaleInfoBo();
      // 销售信息表 TD_SALES_INFO
      TdCustomerInfoForm tdCustomer = customerInfoBo.findByID(srf.getCustomerId());
      SalesInfoForm sif = new SalesInfoForm();
      String saleNo = FormNumberBuilder.getNewSaleOrderNumber(orgCode.toString());
      // 销售单编号
      sif.setSaleNo(saleNo);
      sif.setCustomerId(srf.getCustomerId());
      sif.setCustomerName(srf.getCustomerN());
      sif.setPhone(srf.getCustomerTele());
      sif.setFormCreaDate(Operate.toUtilDate());
      sif.setTotalPrice(srf.getTotalPrice());
      sif.setSalesBy(userId);
      sif.setSaleStatus("N"); // 未确认预销售
      sif.setStationCode(orgCode);
      sif.setFromSales(new Long(fromSales));
      sif.setContractNo(srf.getContractNo());
      sif.setCreateDate(Operate.toUtilDate()); // added by jackyu 2011-03-16  add time zone
      srf.setSaleNo(saleNo);
      srf.setSaleDate(sif.getFormCreaDate());
      srf.setSuggestPrice(srf.getTotalPrice());
      sif.setTotalDiscount(totoalDiscount);
      // 生成预销售单是的创建人 add by hanxn
      sif.setCreateBy(userId);
      if (tdCustomer != null) {
        sif.setMobile(tdCustomer.getMobile());
      }
      ArrayList psfList = new ArrayList();

      // 销售/预定明细 TD_SALES_DETAIL
      if (skuCode1 != null && skuCode1.length > 0)
        for (int i = 0; i < skuCode1.length; i++) {
          Integer partNum =
              Operate.isPositiveInteger(skuQuanty1[i]) ? new Integer(skuQuanty1[i]) : null;
          Double perCost = Operate.isNumeric(stdCost0[i]) ? new Double(stdCost0[i]) : null;
          Double perPrice = Operate.isNumeric(count1[i]) ? new Double(count1[i]) : null;

          PartSaleForm psf = new PartSaleForm();
          psf.setSaleNo(saleNo);
          psf.setPartCode(skuCode1[i]);
          psf.setPartStatus("P"); // 等待分配
          psf.setPartNum(partNum);
          psf.setPerCost(perCost);
          psf.setPerPrice(perPrice);
          psf.setRemark(marks[i]);
          psf.setCreateBy(userId);
          psf.setCreateDate(Operate.toUtilDate()); // added by jackyu 2011-03-16  add time zone
          psf.setIsBackToBack(bkbs[i]);
          psf.setWarrantyCardNo(wcNo[i]);
          psf.setSnNo(sn1[i]);
          psf.setLotNo(lot1[i]);
          psf.setDiscount(discount1[i]);

          // 存储税begin
          String taxString = taxBuffer[i];

          if (null != taxString && !"".equals(taxString)) {
            String[] taxCount = taxString.split(SPLITER2_STR);
            if (null != taxCount && taxCount.length > 0) {
              for (int c = 0; c < taxCount.length; c++) {
                String[] taxDetial = taxCount[c].split(SPLITER1_STR);
                TdPartSalesTaxDetail sd = new TdPartSalesTaxDetail();
                sd.setSoId(new Long(1));
                sd.setTaxCode(taxDetial[0] == null ? "" : taxDetial[0]);
                sd.setTaxRate(taxDetial[2] == null ? null : new Double(taxDetial[2]));
                sd.setConvertedTaxRate(taxDetial[4] == null ? null : new Double(taxDetial[4]));
                sd.setTaxAmt(taxDetial[3] == null ? null : new Double(taxDetial[3]));
                sd.setDeletFlag(0);
                sd.setCreatedDate(Operate.getCurrentDate());
                sd.setCreateBy(0L);
                sd.setSaleNo(saleNo);
                psf.getTaxDetails().add(sd);
              }
            }
          }

          psfList.add(psf);
          // 存储税 end

          sif.getSalesDetails().add(psf);
        }
      tag = popupSaleInfoBo.add(sif);

      /*
      ArrayList tempList=new ArrayList();\
      if(tag==1){
      	ArrayList saleList=new ArrayList(sif.getSalesDetails());
      	//System.out.println("--------------saleList="+saleList.size());
      	for(int i=0;i<saleList.size();i++){
      		PartSaleForm psf2=(PartSaleForm)saleList.get(i);

      		String temp[]=new String[9];
      		temp[0]=psf2.getSoId().toString();
      		temp[1]=skuCode1[i];
      		temp[2]=partDesc1[i];
      		temp[3]=partName1[i];
      		temp[4]=wcNo[i];
      		temp[5]=sn1[i];
      		temp[6]=lot1[i];
      		temp[7]=skuQuanty1[i];
      		temp[8]=stdCost1[i];

      		tempList.add(temp);
      	}

      	request.setAttribute("tempList",tempList);
      	request.setAttribute("sellRegisterForm",srf);
      }
      request.setAttribute("flag","Y");
      */

      request.setAttribute("templetName", fromSales);
      request.setAttribute("tempData", sif.getSaleNo());

      request.setAttribute("tag", tag + "");
      request.setAttribute("businessFlag", "sellPrepareList");

    } catch (Exception e) {
      e.printStackTrace();
    }
    return forward;
  }
Exemplo n.º 2
0
  /**
   * Part accessory sale index save
   *
   * @param request HttpServletRequest
   * @param form ActionForm form data
   * @return String Return to forward page resultMessage Succeed to save page of part accessory sale
   */
  public String sellRegisterSalesList(HttpServletRequest request, ActionForm form) {
    // String forward="sellRegisterList";
    String forward = "resultMessage";
    int tag = -1;

    try {
      HttpSession session = request.getSession();
      Long userId = (Long) session.getAttribute("userId");
      Long orgCode = (Long) session.getAttribute("orgCode");

      // 接收表单提交数据
      SellRegisterForm srf = (SellRegisterForm) form;
      String[] skuCode1 = request.getParameterValues("skuCode1"); // SKU编号
      String[] skuQuanty1 = request.getParameterValues("skuQuanty1");
      // 数量
      String[] bkbs = request.getParameterValues("bkbs"); // 订购选项
      String[] marks = request.getParameterValues("marks"); // 备注
      String[] stdCost1 = request.getParameterValues("stdCost1"); // 建议价格
      String[] count1 = request.getParameterValues("count1"); // 实际价格
      String[] discount1 = request.getParameterValues("discount1");
      // Discount
      String[] partDesc1 = request.getParameterValues("partDesc1");
      // SKU描述-英
      String[] partName1 = request.getParameterValues("partName1");
      // SKU描述-中
      String[] stdCost0 = request.getParameterValues("stdCost0"); // 建议单价 价格逻辑后的价格
      String[] stdCost = request.getParameterValues("stdCost"); // 成本单价

      String[] wcNo = request.getParameterValues("wcNo"); // 保卡号
      String[] sn1 = request.getParameterValues("sn1"); // SN号
      String[] lot1 = request.getParameterValues("lot1"); // LOT号

      String[] totalTax = request.getParameterValues("totalTax");
      String totalPrice = request.getParameter("totalPrice");

      String taxBuffer[] = request.getParameterValues("taxBuffer");

      String totoalDiscount = request.getParameter("totalDiscount");

      //			System.out.println("totoalDiscount -=-=-=-=-=-=-=-"+totoalDiscount);
      ArrayList partSalesTaxList = new ArrayList();
      // add by sr 后台计算实际价格总和
      // String[] partSn=request.getParameterValues("partSnNo1");//零件序列号
      //			double total=0;
      //			if(count1!=null&&count1.length>0)
      //			for(int j=0;j<count1.length;j++){
      //				//Double d=Double.valueOf(count1[j]);
      //
      //				BigDecimal b1 = new BigDecimal(count1[j]);//update by sr 防止double运算精度问题
      //				BigDecimal b2 = new BigDecimal(Double.toString(total));
      //				BigDecimal b3 = new BigDecimal(totalTax[j]);
      //				total=b1.add(b2).doubleValue();
      //
      //
      //				//total+=d.doubleValue();
      //			}

      // add by sr end

      PopupSaleInfoBo sibo = new PopupSaleInfoBo();
      // 销售信息表 TD_SALES_INFO
      SalesInfoForm sif = new SalesInfoForm();
      String saleNo = FormNumberBuilder.getNewSaleOrderNumber(orgCode.toString());

      TdCustomerInfoForm tdCustomer = customerInfoBo.findByID(srf.getCustomerId());
      sif.setSaleNo(saleNo);
      sif.setCustomerId(srf.getCustomerId());
      sif.setCustomerName(srf.getCustomerN());
      sif.setPhone(srf.getCustomerTele());
      sif.setFormCreaDate(Operate.toUtilDate());
      sif.setTotalPrice(new Double(totalPrice)); // update by sr
      sif.setSalesBy(userId);
      sif.setSaleStatus("P");
      sif.setStationCode(orgCode);
      sif.setFromSales(new Long(0));
      sif.setContractNo(srf.getContractNo());
      sif.setPartNum(srf.getQuantityAll());
      sif.setCreateDate(Operate.toUtilDate()); // added by jackyu 2011-03-16  add time zone
      if (tdCustomer != null) {
        sif.setMobile(tdCustomer.getMobile()); // 用户的电话号码
      }
      // 生成预销售单是的创建人 add by hanxn
      sif.setCreateBy(userId);

      srf.setSaleNo(saleNo);
      srf.setSaleDate(sif.getFormCreaDate());

      srf.setTotalDiscount(totoalDiscount);

      sif.setTotalDiscount(totoalDiscount);
      //			System.out.println("totoaldiscount-=-=-=-=-=-=-=-=-=-=-=-222222"+sif.getTotalDiscount());
      ArrayList dataList = new ArrayList();
      ArrayList psfList = new ArrayList();

      // 销售/预售明细 TD_SALES_DETAIL
      if (skuCode1 != null && skuCode1.length > 0)
        for (int i = 0; i < skuCode1.length; i++) {
          Integer partNum =
              Operate.isPositiveInteger(skuQuanty1[i]) ? new Integer(skuQuanty1[i]) : null;
          Double perCost =
              Operate.isNumeric(stdCost0[i]) ? new Double(stdCost0[i]) : null; // 价格逻辑后的单价
          Double perPrice =
              Operate.isNumeric(count1[i]) ? new Double(count1[i]) : null; // 调用价格逻辑后算出的这个零件价格*数量总和
          Double standCost = Operate.isNumeric(stdCost[i]) ? new Double(stdCost[i]) : null; // 零件基价

          PartSaleForm psf = new PartSaleForm();
          psf.setSaleNo(saleNo);
          psf.setPartCode(skuCode1[i]);
          psf.setPartStatus("P");
          psf.setPartNum(partNum);
          psf.setPerCost(perCost);
          psf.setPerPrice(perPrice);
          psf.setRemark(marks[i]);
          psf.setCreateBy(userId);
          psf.setIsBackToBack(bkbs[i]);
          psf.setWarrantyCardNo(wcNo[i]);
          psf.setSnNo(sn1[i]);
          psf.setLotNo(lot1[i]);
          psf.setAppPartCode(skuCode1[i]); // 保存第一次申请的零件号 add by sr
          psf.setCreateDate(Operate.toUtilDate()); // added by jackyu 2011-03-16  add time zone
          psf.setDiscount(discount1[i]);

          String taxString = taxBuffer[i];

          if (null != taxString && !"".equals(taxString)) {
            String[] taxCount = taxString.split(SPLITER2_STR);
            if (null != taxCount && taxCount.length > 0) {
              for (int c = 0; c < taxCount.length; c++) {
                String[] taxDetial = taxCount[c].split(SPLITER1_STR);
                TdPartSalesTaxDetail sd = new TdPartSalesTaxDetail();
                sd.setSoId(new Long(1));
                sd.setTaxCode(taxDetial[0] == null ? "" : taxDetial[0]);
                sd.setTaxRate(taxDetial[2] == null ? null : new Double(taxDetial[2]));
                sd.setConvertedTaxRate(taxDetial[4] == null ? null : new Double(taxDetial[4]));
                sd.setTaxAmt(taxDetial[3] == null ? null : new Double(taxDetial[3]));
                sd.setDeletFlag(0);
                sd.setCreatedDate(Operate.getCurrentDate());
                sd.setCreateBy(0L);
                sd.setSaleNo(saleNo);
                psf.getTaxDetails().add(sd);
              }
            }
          }

          psfList.add(psf);

          // 零件申请表 TD_PARTS_REQUEST
          PartsRequestForm prf = new PartsRequestForm();
          prf.setFormId(saleNo); // 销售单号
          if ("Y".equals(bkbs[i])) {
            prf.setReqType("T"); // 申请类型(Back To Back)
          } else if ("Q".equals(bkbs[i])) {
            prf.setReqType("Q"); // 申请类型(特殊)
          } else {
            prf.setReqType("S"); // 申请类型(普通)
          }
          prf.setReqStat("P"); // 零件申请状态
          prf.setPartsCode(skuCode1[i]); // 零件编号
          prf.setReqNum(partNum); // 零件数量
          prf.setPerCost(standCost); // 成本  (stand cost)
          prf.setOrganizationCode(orgCode); // 维修站代码
          prf.setReqDate(sif.getFormCreaDate()); // 申请日期
          prf.setRequestBy(userId); // 申请人
          prf.setPartType(
              ((CommonSearch) SpringContextUtil.getBean("commonSearch")).getPartType(skuCode1[i]));
          // SKU类型
          prf.setCreateBy(userId);
          prf.setRemark(marks[i]);
          prf.setRequestPartCode(skuCode1[i]); // add by sr 2009-03-31 保存原始申请零件
          prf.setCreateDate(Operate.toUtilDate()); // added by jackyu 2011-03-21  add time zone
          dataList.add(prf);
        }
      // 先插入request表
      tag = popupSaleInfoBo.sellRegisterAdd(dataList);
      if (tag == 1) {
        // 将requestId存入PartsRequestForm
        for (int i = 0; i < psfList.size(); i++) {
          PartSaleForm psf2 = (PartSaleForm) psfList.get(i);
          PartsRequestForm prf2 = (PartsRequestForm) dataList.get(i);
          psf2.setRequestId(prf2.getId());
          sif.getSalesDetails().add(psf2);
        }
        // 再插入销售业务表
        tag = popupSaleInfoBo.add(sif);
        if (tag == 1) {
          // 调用分配逻辑 U-U货不可以出库
          popupSaleInfoBo.saleAllocate(saleNo);

          // CCC用户
          if (orgCode.intValue() == 421) {
            request.setAttribute("templetName", "1");
          } else {
            request.setAttribute("templetName", "0");
          }
          request.setAttribute("tempData", sif.getSaleNo());
        }
        request.setAttribute("tag", tag + "");
        request.setAttribute("businessFlag", "sellRegisterList");
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
    return forward;
  }