コード例 #1
0
ファイル: ReturnPartHubBo.java プロジェクト: a4m/newsisAP
  /**
   * HUB defective part packing
   *
   * @param doPackPartReturnMappingForm DoPackPartReturnMappingForm
   * @param bpIds String bpId and version
   * @param userId Long User Id
   * @param doNo String Packing No
   * @return int 1:Successful,-1:Unsuccessful
   */
  public int hubReturnPartPack(
      String idList, Long userId, BrokenPartsHubForm form, String doNo, String doCode)
      throws VersionException {
    int tag = -1;
    boolean flag = false;
    ArrayList alData = new ArrayList();
    AllDefaultDaoImp adi = new AllDefaultDaoImp();
    try {

      Long doTarget =
          this.findReturnAddressByLocCode(form.getReturnLocation(), form.getOrganizationCode());
      //			System.out.println("doTarget"+doTarget);

      String versionId = Operate.toVersionData(idList);
      List tempList =
          this.listVersion(
              "from BrokenPartsHubForm as saf where (saf.hubId,saf.version) in (" + versionId + ")",
              idList.split(",").length);
      Iterator it = tempList.iterator();
      while (it.hasNext()) {
        BrokenPartsHubForm bph = (BrokenPartsHubForm) it.next();
        // 把要包装的数据添加到DoList表中

        DoListForm df = new DoListForm();

        df.setDoNo(doNo); // Do号

        df.setBpId(bph.getHubId()); // BrokenPartsHubForm 的hubId
        df.setSkuCode(bph.getPartCode());
        df.setRepairN(bph.getRepairNo());
        df.setSkuDesc(bph.getPartDesc()); // 零件描述
        df.setPackDate(Operate.toSqlDate()); // 打包时间
        df.setSkuType(bph.getPartTypeCode()); // 零件类型
        df.setReturnType("C");
        df.setOrganizationCode(bph.getOrganizationCode()); // 发货单位

        df.setSkuNum(bph.getBpNum()); // 零件数量
        df.setSnNo(bph.getSnNo()); // sn号
        df.setDoCode(doCode); // 箱号	
        df.setDoType("R"); // 包装类型
        df.setDoTarget(doTarget); // 创建人
        df.setCreateBy(userId);
        df.setCreateDate(Operate.toUtilDate()); // added by jackyu 2011-03-15  add time zone

        // 修改BrokenPartsHub表中的数据,将其"返还状态"改为"已包装"

        bph.setUpdateBy(userId);
        bph.setUpdateDate(Operate.toUtilDate());
        bph.setReturnStatus("D");
        bph.setDoCode(doCode);
        bph.setDoNo(doNo);

        Object[] objdf = {df, "i"};
        Object[] objbform = {bph, "u"};

        alData.add(objdf);
        alData.add(objbform);
      }
      flag = adi.allDMLBatch(alData);
      tag = flag == true ? 1 : -1;
    } catch (VersionException ve) {
      throw ve;
    } catch (Exception e) {
      e.printStackTrace();
    }
    return tag;
  }