/**
   * “维修”->“电话诊断”->“明细”->维修零件添加
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   */
  public void insertRepairPartInfo(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {
    try {
      Long userId = (Long) request.getSession().getAttribute("userId");

      String repairNo = request.getParameter("repairNo");
      String stuffNo = request.getParameter("stuffNo");
      String warrantyType = request.getParameter("warrantyType");
      String applyQty = request.getParameter("applyQty");

      RepairHandleBo rhBo = RepairHandleBo.getInstance();
      List<RepairPartForm> returnFormList = null;

      // 零件添加时增加零件是否可用
      boolean chk = PartInfoBo.getInstance().chkStuffNo(stuffNo);
      if (!chk) {

        // wubin at 20110401 增加新的费用类别RR90,默认该类别是收费的
        //				if("R".equals(partFeeType)){
        //					partFeeType = "Y";
        //					isRR90PartType = "Y";
        //				}

        // add end
        List<RepairPartForm> rpfList = new ArrayList<RepairPartForm>();

        RepairPartForm rpf = new RepairPartForm();
        rpf.setRepairNo(new Long(repairNo));
        rpf.setStuffNo(stuffNo);
        rpf.setWarrantyType(warrantyType);
        rpf.setApplyQty(new Integer(applyQty));
        rpf.setRepairPartStatus("A"); // 申请中
        rpf.setRepairPartType("W"); // 维修申请
        rpf.setCreateBy(userId);
        rpf.setCreateDate(new java.util.Date());

        rpfList.add(rpf);

        returnFormList = rhBo.insertPartInfo(rpfList);
      }

      PrintWriter writer = response.getWriter();
      response.setContentType("text/xml");
      response.setHeader("Cache-Control", "no-cache");
      if (null != returnFormList && returnFormList.size() > 0) {
        writer.println("<xml>");
        writer.println("<flag>true</flag>");
        for (int i = 0; i < returnFormList.size(); i++) {
          RepairPartForm aPartForm = (RepairPartForm) returnFormList.get(i);
          writer.println("<partRow id=\"" + aPartForm.getPartsId() + "\">");
          writer.println("  <partsId>" + aPartForm.getPartsId() + "</partsId>");
          writer.println("  <stuffNo>" + aPartForm.getStuffNo() + "</stuffNo>");
          writer.println(
              "  <skuCode>" + EscapeUnescape.escape(aPartForm.getSkuCode()) + "</skuCode>");
          String standard =
              aPartForm.getStandard() == null ? "" : EscapeUnescape.escape(aPartForm.getStandard());
          writer.println("  <standard>" + (standard.equals("") ? ".." : standard) + "</standard>");
          writer.println(
              "  <skuUnit>" + EscapeUnescape.escape(aPartForm.getSkuUnit()) + "</skuUnit>");
          writer.println(
              "  <warrantyType>"
                  + EscapeUnescape.escape(
                      DicInit.getSystemName("WARRANTY_TYPE", aPartForm.getWarrantyType()))
                  + "</warrantyType>");
          writer.println("  <applyQty>" + aPartForm.getApplyQty() + "</applyQty>");

          writer.println("</partRow>");
        }
        writer.println("</xml>");
      } else {
        writer.println("<xml>");
        writer.println("<flag>false</flag>");
        if (chk) {
          writer.println("<result>part</result>");
        } else {
          writer.println("<result>error</result>");
        }

        writer.println("</xml>");
      }
      writer.flush();
      writer.close();

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Beispiel #2
0
  /**
   * 订购入库 接收 1.先将实际收到零件全部入库(临时库存X),插入StockInfoForm和StockFlowForm,各recevie条。 2.修改PO状态,以及拆分PO
   * 分析PO数量和到货recevie数量: a. PO<=recevie : 将对应PO直接修改状态(已到货/已分配待领取); b. PO>recevie :
   * 拆分PO,原来记录的num改为PO-recevie,状态不变; 新增recevie条,并修改状态(已到货/已分配待领取); 3.调用分配逻辑 a.
   * 将销售零件进行状态修改或拆分,再判断销售单状态是否需要修改; b. 将销售零件的detailId赋值给库存requestId,保留该库存零件(已分配待领取) ; c.
   * 若入库有剩余,将剩余零件再分配给其他需要该零件的单子;
   *
   * @param para 收货信息
   * @param saleNo 销售单号
   * @param userId 操作人
   * @return tag
   */
  public synchronized int orderInReceive(
      String[][] para, String saleNo, Long userId, String transportMode) throws Exception {
    int tag = -1;

    ArrayList poList = new ArrayList();
    ArrayList<StockInfoForm> stockList = new ArrayList<StockInfoForm>();
    PartPoBo ppb = PartPoBo.getInstance();
    PartInfoBo pib = PartInfoBo.getInstance();
    // SaleInfoBo sib=SaleInfoBo.getInstance();
    StockOutBo sob = StockOutBo.getInstance();
    String inStuffNo = "";
    for (int i = 0; i < para[0].length; i++) {
      PoForm pf = ppb.findById(new Long(para[0][i]));
      PartInfoForm pi = pib.find(pf.getStuffNo());
      // 零件料号非法
      if (pi == null) {
        throw new IllegalPoException(pf.getStuffNo());
      }

      int intPoNum = pf.getOrderNum();
      int intReceiveNum = Integer.parseInt(para[1][i]);

      if (intReceiveNum > 0) {
        // 插入库存信息表
        StockInfoForm sif = new StockInfoForm();

        sif.setCreateBy(userId);
        sif.setStuffNo(pf.getStuffNo());
        sif.setSkuCode(pf.getSkuCode());
        sif.setShortCode(pi.getShortCode());
        sif.setStandard(pi.getStandard());
        sif.setSkuUnit(pf.getSkuUnit());
        sif.setSkuNum(intReceiveNum);
        sif.setPerCost(
            calculatePerCost(new Float(para[2][i]), new Float(para[4][i]), new Float(para[6][i])));
        sif.setOrderDollar(new Float(para[3][i]));
        sif.setFreightTW(new Float(para[4][i]));
        sif.setInvoiceNo(para[5][i]);
        sif.setBinCode(para[7][i]);
        sif.setSkuType("A"); // 默认
        sif.setStockStatus("X"); // 临时状态,等待到货分配时修改
        sif.setRequestId(pf.getRequestId()); // 申请零件时的saleDetailId,到货分配时调用
        sif.setSkuType("S");
        sif.setCreateBy(userId);
        sif.setCreateDate(new Date());
        sif.setFlowNo(FormNumberBuilder.getStockFlowId()); // 流水号fk
        sif.setTransportMode(transportMode);
        stockList.add(sif);

        inStuffNo += "," + sif.getStuffNo();

        // 插入出入库流水表
        StockFlowForm sff = this.infoToFlow(sif);
        sff.setSkuNum(intReceiveNum);
        sff.setRestNum(sob.getRestStock(sif.getStuffNo(), intReceiveNum, "I"));

        sff.setCustomerName(pf.getCustomerName());
        sff.setFlowType("I");
        sff.setFlowItem("D"); // 订购入库
        sff.setFeeType(pf.getOrderType());
        sff.setRequestId(pf.getPoNo());
        sff.setFormNo(pf.getSaleNo());
        sff.setOrderDollar(sif.getOrderDollar());
        sff.setFreightTW(sif.getFreightTW());
        sff.setInvoiceNo(sif.getInvoiceNo());
        sff.setTransportMode(sif.getTransportMode());
        sff.setBinCode(sif.getBinCode());

        poList.add(sff);

        if (intPoNum <= intReceiveNum) { // a. PO<=recevie
          pf.setOrderStatus("C"); // 已到货
          pf.setUpdateBy(userId);
          pf.setUpdateDate(new Date());
          poList.add(pf);
        } else { // b. PO>recevie
          // 原来记录的num改为PO-recevie,仍然等待PO
          pf.setOrderNum(intPoNum - intReceiveNum);
          pf.setUpdateBy(userId);
          pf.setUpdateDate(new Date());
          poList.add(pf);

          // 拆分出recevie条,状态已到货
          PoForm newPo = new PoForm();
          BeanUtils.copyProperties(newPo, pf);
          newPo.setPoNo(null);
          newPo.setOrderNum(intReceiveNum);
          newPo.setOrderStatus("C"); // 已到货
          newPo.setCreateBy(userId);
          newPo.setCreateDate(new Date());
          poList.add(newPo);
        }
      }
    }

    if (poList.size() > 0 && this.getBatchDao().saveOrUpdateBatch(poList)) {
      if (this.getBatchDao().insertBatch(stockList)) {
        tag = new ReceiveAllocateBo().allocate(stockList);
        //			   sob.inMerge(inStuffNo.substring(1).replace(",", "','"));
      }
    }

    return tag;
  }