Exemplo n.º 1
0
  /**
   * File stream download,include file path,file name
   *
   * @param mapping ActionMapping
   * @param form ActionForm
   * @param request HttpServletRequest
   * @param response HttpServletResponse
   */
  public void fileResponse(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {

    try {

      String path = (String) request.getAttribute("filePath"); // 下载的文件路径
      String fileName = (String) request.getAttribute("fileName");
      if (path == null) path = request.getParameter("filePath");
      if (fileName == null) fileName = request.getParameter("fileName");

      // 需要限制下载的路径
      // downLoadPath
      // reportPath[1] = PropsUtil.get("downLoadPath");
      // attachePath
      // reportPath[4] = PropsUtil.get("attachePath");
      String downLoadPath = Operate.getReportPath()[1];
      String attachePath = Operate.getReportPath()[4];

      if (((!path.startsWith(attachePath)) && (!path.startsWith(downLoadPath)))
          || (path.indexOf("/../") >= 0)) {
        //				System.out.println("-------access no auth file:"+path);
        response.getWriter().println("You haven't right to access file:" + path);
        response.flushBuffer();
        return;
      }

      java.io.File downloadFile = new java.io.File(path);
      java.io.FileInputStream SourceFile = new java.io.FileInputStream(downloadFile);
      OutputStream outputStream = response.getOutputStream();
      try {
        response.setHeader(
            "Content-disposition",
            "attachment; filename=" + java.net.URLEncoder.encode(fileName, "utf-8"));

        byte readFromFile[] = new byte[1024 * 5];
        int len;
        while ((len = SourceFile.read(readFromFile)) > 0) {
          outputStream.write(readFromFile, 0, len);
        }

      } catch (IOException ie) {
        ie.printStackTrace();
      } catch (Exception e) {
        e.printStackTrace();
      } finally {
        outputStream.flush();
        outputStream.close();
        SourceFile.close();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 2
0
public class ReportFilePathImpl implements com.dne.export.execution.ReportFilePath {

  private static final String[] reportPath = Operate.getReportPath();
  public String strWeek = Operate.getWeek2();

  public String getWritePath() {
    String writePath = reportPath[0] + strWeek + "/";
    return writePath;
  }

  public String getDownLoadPath() {
    String downLoadPath = reportPath[1] + strWeek + "/";
    return downLoadPath;
  }
}
Exemplo n.º 3
0
 @SuppressWarnings("unchecked")
 public Double getCustomerTax(Long customerId, Double totalAmt) throws Exception {
   Double taxAmt = 0D;
   List<TsServiceTax> taxList =
       this.getDao()
           .list(
               "from TsServiceTax t where t.deletFlag = 0 "
                   + "and exists(from TdCustomerInfoForm c where c.customGrpId = t.customgrpId and c.customerId = ?) "
                   + "and t.feeType='X'",
               customerId);
   if (taxList.isEmpty()) {
     taxList =
         this.getDao()
             .listAll(
                 "from TsServiceTax t where t.deletFlag = 0 and t.customgrpId is null and t.feeType='X'");
   }
   for (TsServiceTax tax : taxList) {
     List<TsTaxCode> taxCodeList =
         this.getDao().listAll("from TsTaxCode c where c.taxCode = '" + tax.getTaxCode() + "'");
     for (TsTaxCode code : taxCodeList) {
       if ("E".equals(code.getTaxType())) {
         taxAmt -= totalAmt * (code.getTaxRate() / 100);
       } else {
         taxAmt += totalAmt * (code.getTaxRate() / 100);
       }
     }
   }
   return Operate.formatDouble(taxAmt);
 }
Exemplo n.º 4
0
  /**
   * Inquire running statistics of some background report in one ASC
   *
   * @param reportCode
   * @param orgCode
   * @return
   * @throws Exception
   */
  public ArrayList<String[]> bgReportQuery(Long reportCode, Long orgCode) throws Exception {
    ArrayList<String[]> bgList = new ArrayList<String[]>();
    String strHql =
        "from BackgrounderReportForm as bgr where bgr.createDate>=sysdate-7 "
            + "and bgr.reportCode= :reportCode and bgr.organizationCode= :organizationCode order by bgr.bgId desc";

    ArrayList<QueryParameter> paramList = new ArrayList<QueryParameter>();
    QueryParameter param = new QueryParameter();
    param.setName("reportCode");
    param.setValue(reportCode);
    param.setHbType(Hibernate.LONG);
    paramList.add(param);

    param = new QueryParameter();
    param.setName("organizationCode");
    param.setValue(orgCode);
    param.setHbType(Hibernate.LONG);
    paramList.add(param);
    ArrayList<BackgrounderReportForm> al =
        (ArrayList<BackgrounderReportForm>) this.getDao().parameterQuery(strHql, paramList);
    String[] path = Operate.getReportPath();
    String strWeek = Operate.getWeek2();
    for (int i = 0; i < al.size(); i++) {
      BackgrounderReportForm bgrf = al.get(i);
      String[] temp = new String[7];
      temp[0] = bgrf.getBgId().toString();
      temp[1] = bgrf.getReportUserName();
      if (bgrf.getReportFile() != null) {
        // temp[2]=bgrf.getReportFile().substring(bgrf.getReportFile().lastIndexOf("/")+1);
        temp[2] = bgrf.getReportFile();
      }
      temp[3] = bgrf.getReportStatus();
      temp[4] = bgrf.getBeginTime().toString();
      temp[5] = bgrf.getExceptionMessage();
      if (temp[2] != null) {
        temp[6] = path[1] + temp[2];
      }
      bgList.add(temp);
    }

    return bgList;
  }
Exemplo n.º 5
0
  /**
   * Hub packing list
   *
   * @param doNo String Packing ID
   * @param orgCode Long ASC code
   * @return ArrayList Packing Info and part Info
   */
  public ArrayList hubReturnPartPrint(String doNo, Long orgCode) {
    ArrayList alDate = new ArrayList();
    CommonSearch cs = ((CommonSearch) SpringContextUtil.getBean("commonSearch"));
    String location = "";
    try {
      if (doNo != null && !doNo.equals("")) {
        List tempList = new ArrayList();
        tempList =
            this.getDao()
                .list("from DoListForm df where df.doNo='" + doNo.trim() + "' and rownum=1");

        List brokenList =
            (ArrayList)
                this.getDao()
                    .list(
                        " select rf.returnCode,rf.serviceSheetNo,rf.modelCode,rf.serialNo,rf.partCode,rf.snNo,rf.partDesc,rf.bpNum,rf.irisCodeName,rf.irisCodeDesc,rf.returnLocation from BrokenPartsHubForm rf where rf.hubId in(select df.bpId from DoListForm df where df.returnType='C' and df.doNo='"
                            + doNo.trim()
                            + "')");
        Iterator bt = brokenList.iterator();
        while (bt.hasNext()) {
          String[] data = new String[10];
          Object[] obj = (Object[]) bt.next();
          data[0] = obj[0] == null ? "" : obj[0].toString();
          data[1] = obj[1] == null ? "" : obj[1].toString();
          data[2] = obj[2] == null ? "" : obj[2].toString();
          data[3] = obj[3] == null ? "" : obj[3].toString();
          data[4] = obj[4] == null ? "" : obj[4].toString();
          data[5] = obj[5] == null ? "" : obj[5].toString();
          data[6] = obj[6] == null ? "" : obj[6].toString();
          data[7] = obj[7] == null ? "" : obj[7].toString();
          data[8] = obj[8] == null ? "" : obj[8].toString();
          data[9] = obj[9] == null ? "" : obj[9].toString();
          location = obj[10].toString();
          alDate.add(data);
        }
        DoListForm doListForm = (DoListForm) tempList.get(0);
        String temp[] = new String[5];
        temp[0] = cs.findOrgNameByOrgCode(orgCode);
        temp[1] = doListForm.getDoCode() == null ? "" : doListForm.getDoCode();
        temp[2] = cs.findOrgNameByOrgCode(doListForm.getDoTarget());
        temp[3] = Operate.toSqlDate().toString();
        temp[4] = location;
        alDate.add(0, temp);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    return alDate;
  }
Exemplo n.º 6
0
 public void updateCreditNoteWfStatus(String billId, String status, Long userId)
     throws ComException, Exception {
   CreditNoteForm fm = new CreditNoteForm();
   CreditNoteMain fmmain = new CreditNoteMain();
   fmmain.setId(new Long(billId));
   fm.setCnm(fmmain);
   CreditNoteBo cnBo = (CreditNoteBo) SpringContextUtil.getBean("cnBo");
   CreditNoteMain cnm = cnBo.queryCreditNoteMain(fm);
   if (null != cnm) {
     List<Object> updateList = new ArrayList<Object>();
     Date currentDate = Operate.toUtilDate();
     cnm.setStatus(status);
     cnm.setUpdateBy(userId);
     cnm.setUpdateDate(currentDate);
     updateList.add(cnm);
     Set<CreditNoteDetail> detailSets = cnm.getCreditNoteDetails();
     for (CreditNoteDetail detail : detailSets) {
       if (SysConstants.CN_FLAG_Y.equals(detail.getCnFlag())) {
         detail.setStatus(status);
         detail.setUpdateBy(userId);
         detail.setUpdateDate(currentDate);
         updateList.add(detail);
       }
     }
     CreditNoteMainTemp cnmt =
         (CreditNoteMainTemp)
             this.getDao()
                 .uniqueResult("from CreditNoteMainTemp cnmt where cnmt.id=?", cnm.getRefTid());
     if (null != cnmt) {
       if (SysConstants.CN_STATUS_APPROVAL.equals(status)) {
         cnmt.setStatus(status);
       } else { // 如果审批不通过,Credit Note Temp主表置为关闭状态
         cnmt.setStatus(SysConstants.CN_TEMP_STATUS_CLOSED);
       }
       cnmt.setUpdateBy(cnm.getUpdateBy());
       cnmt.setUpdateDate(currentDate);
       updateList.add(cnmt);
     }
     this.getBatchDao().saveOrUpdateBatch(updateList);
   }
 }
Exemplo n.º 7
0
  /**
   * Query Hub packing
   *
   * @param doPackPartReturnMappingForm DoPackPartReturnMappingForm
   * @param orgCode Long ASC code
   * @return ArrayList Packing list
   */
  public ArrayList list(BrokenPartsHubForm form) {
    List dataList = new ArrayList();
    ArrayList alData = new ArrayList();
    ReturnPartHubQuery uq = new ReturnPartHubQuery(form); // 实例化queryBean
    int count = 0;
    try {
      dataList = uq.doListQuery(form.getFromPage(), form.getToPage()); // 查询坏件信息
      count = uq.doCountQuery();
      BrokenPartsHubForm uf = new BrokenPartsHubForm();
      for (int i = 0; i < dataList.size(); i++) {
        String[] data = new String[14];

        uf = (BrokenPartsHubForm) dataList.get(i);

        data[0] = uf.getReturnCode();
        data[1] = uf.getServiceSheetNo() == null ? "" : uf.getServiceSheetNo().toString(); // BO_ID
        data[2] = uf.getModelCode() == null ? "" : uf.getModelCode(); // 机型
        data[3] = uf.getSerialNo() == null ? "" : uf.getSerialNo(); // 机身号
        data[4] = uf.getPartCode() == null ? "" : uf.getPartCode(); // 零件编号
        data[5] = uf.getSnNo() == null ? "" : uf.getSnNo().toString(); // 零件序列号
        data[6] = uf.getPartName() == null ? "" : uf.getPartName(); // 零件中文描述
        data[7] = uf.getPartDesc() == null ? "" : uf.getPartDesc(); // 零件英文描述
        data[8] = uf.getBpNum() == null ? "" : uf.getBpNum().toString(); // 零件数量
        data[9] = uf.getReturnLocation() == null ? "" : uf.getReturnLocation(); // ReturnLocation
        data[10] =
            uf.getHubId().toString() + CommonSearch.split1 + uf.getVersion(); // 返回的BoId+版本号 						
        data[11] =
            uf.getReceiveDate() == null ? "" : Operate.formatYMDDate(uf.getReceiveDate()); // 回库日期
        alData.add(data);
      }
      alData.add(0, count + "");
    } catch (Exception e) {
      e.printStackTrace();
    } finally {

    }
    return alData;
  }
Exemplo n.º 8
0
  /**
   * Update database after generation reports
   *
   * @param reportCode
   * @param reportFile
   * @throws Exception
   */
  public static void updateBgTable(
      Long bgId, String reportFile, String errInfo, double timeZone, String countryCode)
      throws Exception {
    Date date = new Date(System.currentTimeMillis() + (int) (timeZone * 60 * 60 * 1000));

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String endDate = "to_date('" + sdf.format(date) + "','yyyy-mm-dd hh24:mi:ss')";

    String elapsedTime = "(" + endDate + "-r.BEGIN_TIME)*24*3600";
    String status = "complete";
    if (errInfo != null) status = "exception";

    String[] batchSql = new String[2];
    String fileName = "";
    String sqlCondition = "";
    String writePath = Operate.getReportPath()[0];

    if (!"".equals(reportFile)) {
      try {
        fileName = reportFile.split(String.valueOf(CommonSearch.split1))[0];
        fileName = fileName.split("reports/")[1];
        sqlCondition = reportFile.split(String.valueOf(CommonSearch.split1))[1];
        sqlCondition = sqlCondition.replace("'", "’");
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    String updBgReport =
        "update td_backgrounder_report r set r.REPORT_FILE='"
            + fileName
            + "',r.END_TIME="
            + endDate
            + ",r.REPORT_STATUS='"
            + status
            + "'";
    if (errInfo != null) {
      updBgReport += ",r.EXCEPTION_MESSAGE='" + errInfo + "' ";
    }
    File file = new File(writePath + fileName);
    String FileSize = String.valueOf(Double.parseDouble(file.length() + "") / 1024);
    updBgReport += ",r.ELAPSED_TIME= " + elapsedTime + " where r.BG_ID=" + bgId;
    batchSql[0] = updBgReport;

    String insBgFlow =
        "insert into td_backgrounder_report_flow"
            + "  (select seq_background_flow_id.nextval,"
            + "          r.bg_id,"
            + "          r.organization_code,"
            + "          r.report_user_name,"
            + "          r.begin_time,"
            + endDate
            + ","
            + elapsedTime
            + ","
            + "          r.report_code,"
            + "'"
            + sqlCondition
            + "',"
            + "'"
            + fileName
            + "',"
            + "'"
            + status
            + "',"
            + "          r.exception_message,"
            + "          r.create_by,"
            + "          sysdate,"
            + "'"
            + FileSize
            + "'"
            + "     from td_backgrounder_report r"
            + "    where r.bg_id = "
            + bgId
            + ")";

    batchSql[1] = insBgFlow;
    //		ReportExecutor re = (ReportExecutor)SpringContextUtil.getBean("reportExecutor");
    // Add multi-country by XT
    ReportExecutor re = (ReportExecutor) SpringContextUtil.getBean("reportExecutor" + countryCode);

    re.updateBgTable(batchSql);

    //		ArrayList al = new ArrayList();
    //		BackgrounderReportForm bgrf =
    // (BackgrounderReportForm)this.getDao().findById(BackgrounderReportForm.class, bgId);
    //		bgrf.setReportFile(reportFile);
    //		bgrf.setExceptionMessage(errInfo);
    //		bgrf.setEndTime(endDate);
    //		long elapsedTime=((endDate.getTime()-bgrf.getBeginTime().getTime())/1000);
    //		bgrf.setElapsedTime(elapsedTime);
    //		al.add(bgrf);
    //
    //		BackgrounderReportFlowForm bgrlf = new BackgrounderReportFlowForm();
    //		bgrlf.setBgId(bgrf.getBgId());
    //		bgrlf.setOrganizationCode(bgrf.getOrganizationCode());
    //		bgrlf.setReportUserName(bgrf.getReportUserName());
    //		bgrlf.setBeginTime(bgrf.getBeginTime());
    //		bgrlf.setEndTime(bgrf.getEndTime());
    //		bgrlf.setElapsedTime(bgrf.getElapsedTime());
    //		bgrlf.setReportCode(bgrf.getReportCode());
    //		bgrlf.setSqlCondition(bgrf.getSqlCondition());
    //		bgrlf.setReportFile(bgrf.getReportFile());
    //		bgrlf.setReportStatus(bgrf.getReportStatus());
    //		bgrlf.setExceptionMessage(bgrf.getExceptionMessage());
    //		bgrlf.setCreateBy(bgrf.getCreateBy());
    //		al.add(bgrlf);
    //
    //		this.getBatchDao().saveOrUpdateBatch(al);

  }
  // 预销售单查询
  public void getSaleDetailList(NpcSalesDetailForm npcSalesDetailForm) throws Exception {
    // Get part status list from cache
    List<LabelValueBean> partStatusList =
        this.getBaseTableCacheQueryService()
            .getLabellingSystemCodeList(SysConstants.SALES_DETAIL_STATUS_PREKEY);
    npcSalesDetailForm.setPartStatusList(partStatusList);
    // Get reason list from cache
    List<LabelValueBean> reasonList =
        this.getBaseTableCacheQueryService()
            .getLabellingSystemCodeList(SysConstants.HOLD_REASON_KEY);
    npcSalesDetailForm.setReasonList(reasonList);

    HQLQueryBean page =
        (HQLQueryBean) PageUtils.getPageBean(npcSalesDetailForm, PageConstants.QUERY_TYPE_HQL);
    page.addAlias("NpcSalesDetailInfo", "nsd");
    page.addAlias("NpcSalesInfo", "nsi");
    if (null != npcSalesDetailForm.getSaleNo() && !"".equals(npcSalesDetailForm.getSaleNo())) {
      page.addEqualSearch("nsd.saleNo", npcSalesDetailForm.getSaleNo());
    }
    if (null != npcSalesDetailForm.getPartStatus()
        && !"".equals(npcSalesDetailForm.getPartStatus())) {
      page.addEqualSearch("nsd.partStatus", npcSalesDetailForm.getPartStatus());
    }
    if (null != npcSalesDetailForm.getPartCode() && !"".equals(npcSalesDetailForm.getPartCode())) {
      page.addEqualSearch("nsd.partCode", npcSalesDetailForm.getPartCode());
    }
    if (null != npcSalesDetailForm.getCustomerName()
        && !"".equals(npcSalesDetailForm.getCustomerName())) {
      page.addEqualSearch("nsi.customerName", npcSalesDetailForm.getCustomerName());
    }
    //		if(null!=npcSalesDetailForm.getPhone()&&!"".equals(npcSalesDetailForm.getPhone())){
    //			page.addEqualSearch("nsi.phone", npcSalesDetailForm.getPhone());
    //		}
    // 两个框合成一个框
    if (null != npcSalesDetailForm.getMobile() && !"".equals(npcSalesDetailForm.getMobile())) {
      page.setWhere(
          " and (nsi.mobile='"
              + npcSalesDetailForm.getMobile()
              + "' or nsi.phone='"
              + npcSalesDetailForm.getMobile()
              + "')");
    }
    if (null != npcSalesDetailForm.getCreateDateStart()
        && !"".equals(npcSalesDetailForm.getCreateDateStart())) {
      page.addGreatEqualSearch(
          "nsd.createDate", Operate.toDate(npcSalesDetailForm.getCreateDateStart()));
    }
    if (null != npcSalesDetailForm.getCreateDateEnd()
        && !"".equals(npcSalesDetailForm.getCreateDateEnd())) {
      page.addLessSearch(
          "nsd.createDate", Operate.getNextDate(npcSalesDetailForm.getCreateDateEnd()));
    }
    if (null != npcSalesDetailForm.getReasonCode()
        && !"".equals(npcSalesDetailForm.getReasonCode())) {
      page.addEqualSearch("nsd.reasonCode", npcSalesDetailForm.getReasonCode());
    }
    if (null != npcSalesDetailForm.getOrganizationCode()
        && !"".equals(npcSalesDetailForm.getOrganizationCode())) {
      page.addEqualSearch("nsd.organizationCode", npcSalesDetailForm.getOrganizationCode());
    }
    page.addEqualPropertySearch("nsd.saleNo", "nsi.saleNo");
    page.addEqualSearch("nsd.isPre", String.valueOf(SysConstants.SALES_ISPRE));
    page.setSelectHql(
        "select "
            + "nsd.saleNo,"
            + "nsi.customerName,"
            + "nsd.ascPoNo,"
            + "nsd.partCode,"
            + "nsd.partDescCn,"
            + "nsd.partNum,"
            + "nsd.unitPrice,"
            + "nsd.totalPrice,"
            + "nsd.partStatus,"
            + "nsd.reasonCode,"
            + "nsd.createDate,"
            + "nsd.soId,"
            + "nsd.createBy");
    List<Object[]> saleDetailList = npcQuotationSaleQueryDao.list(page);
    List<NpcSalesDetailForm> npcSalesDetailFormList = new ArrayList<NpcSalesDetailForm>();
    for (Object[] obj : saleDetailList) {
      NpcSalesDetailForm saleDetailForm = new NpcSalesDetailForm();
      saleDetailForm.setSaleNo(String.valueOf(obj[0]));
      saleDetailForm.setCustomerName(
          String.valueOf(obj[1]) == "null" ? "" : String.valueOf(obj[1]));
      if (null != String.valueOf(obj[2])
          && !"".equals(String.valueOf(obj[2]))
          && !"null".equals(String.valueOf(obj[2]))) {
        saleDetailForm.setSource(SysConstants.NPC_SALE_SOURCE_AUTO);
      } else {
        saleDetailForm.setSource(SysConstants.NPC_SALE_SOURCE_MANUAL);
      }
      saleDetailForm.setAscPoNo(String.valueOf(obj[2]) == "null" ? "" : String.valueOf(obj[2]));
      saleDetailForm.setPartCode(String.valueOf(obj[3]));
      saleDetailForm.setPartDescCn(String.valueOf(obj[4]));
      saleDetailForm.setPartNum((Integer) obj[5]);
      saleDetailForm.setUnitPrice((Double) obj[6]);
      saleDetailForm.setTotalPrice((Double) obj[7]);
      saleDetailForm.setPartStatus(String.valueOf(obj[8]));
      saleDetailForm.setPartStatusDesc(
          this.getBaseTableCacheQueryService()
              .getSystemNameByCode(
                  String.valueOf(obj[8]), SysConstants.SALES_DETAIL_STATUS_PREKEY));
      saleDetailForm.setReasonCode(String.valueOf(obj[9]));
      saleDetailForm.setCreateDate((Date) obj[10]);
      saleDetailForm.setSoId(Long.valueOf(obj[11].toString()));
      if (Long.parseLong(obj[12] + "") != -1)
        saleDetailForm.setCreateByDesc(
            this.getBaseTableCacheQueryService().getUserNameByUserId(Long.parseLong(obj[12] + "")));
      else saleDetailForm.setCreateByDesc(SysConstants.SYSTEM_ADMIN_NAME);
      npcSalesDetailFormList.add(saleDetailForm);
    }
    npcSalesDetailForm.setNpcSalesDetailFormList(npcSalesDetailFormList);
  }
Exemplo n.º 10
0
  /**
   * Call method after controled part application approved
   *
   * @param ralpf Application details
   * @param approveFlag true:Approve passed,false:Approve failed
   */
  public void wbiBack(boolean approveFlag, RepairApplicationPRForm raprf, long userId) {
    try {
      RepairPartForm rpform =
          (RepairPartForm) this.getDao().findById(RepairPartForm.class, raprf.getPartsId());
      rpform.setPartRequestNo(raprf.getWorkflowId());
      this.getDao().update(rpform);
      // 将TD_UNREPAIR_STATUS置为完成
      try {
        List unRepairStatusForms =
            this.getDao()
                .list(
                    " from RepairUnRepairStatusInfoForm rursif where rursif.unRepairStatus='E' and rursif.repairNo="
                        + raprf.getRepairNo()
                        + " and rursif.workFlowNo="
                        + raprf.getWorkflowId());
        for (int i = 0; i < unRepairStatusForms.size(); i++) {
          RepairUnRepairStatusInfoForm rursif =
              (RepairUnRepairStatusInfoForm) unRepairStatusForms.get(i);
          rursif.setDbEndDate(((MultiDate) SpringContextUtil.getBean("multiDate")).getMultiDate());
          rursif.setContinuanceDays(
              new Long(Operate.calculateDiffDays(rursif.getDbBeginDate(), rursif.getDbEndDate())));
          rursif.setContinuanceHours(
              new Long(Operate.calculateDiffHours(rursif.getDbBeginDate(), rursif.getDbEndDate())));

          rursif.setUpdateDate(
              new java.sql.Date(
                  ((MultiDate) SpringContextUtil.getBean("multiDate")).getMultiDate().getTime()));
          unRepairStatusForms.set(i, rursif);
        }
        this.getBatchDao().updateBatch(unRepairStatusForms);
      } catch (Exception e) {
        e.printStackTrace();
      }
      UserForm uf = (UserForm) this.getDao().findById(UserForm.class, userId);
      if (approveFlag) {

        // 取出此零件对应的维修单
        RepairServiceForm rsf =
            (RepairServiceForm)
                this.getDao().findById(RepairServiceForm.class, raprf.getRepairNo());
        // 取出此零件的基本信息

        // 根据PARTCODE查询RETURN PART 看是否RMA审批零件
        List returnPart =
            this.getDao()
                .list("from ReturnPartForm r where r.partCode='" + raprf.getPartCode() + "'");

        CommonSearch cs = ((CommonSearch) SpringContextUtil.getBean("commonSearch"));
        String pcType = cs.findPcTypeByOrgCode(rsf.getOrganizationCode());
        LimitPartApprove lpa = new LimitPartApprove();
        String[] approveRoles =
            lpa.getApproveRoles(
                "Y".equals(rpform.getPartFeeType()) ? "O" : "I",
                rsf.getManufacture(),
                rsf.getModelCode(),
                rpform.getPartCode(),
                pcType);

        if (!returnPart.isEmpty()) { // 如果符合RMA零件申请则自动启动RMA流程申请
          //			System.out.println("维修零件申请审批结束---系统自动启动RMA零件申请");
          RepairListBo rlb = new RepairListBo();
          RepairPartForm rpf = rlb.getRepairPartInfo(raprf.getPartsId());
          rpf.setRepairPartStatus("E");
          rpf.setRmaApply("Y");
          this.getDao().update(rpf);

          RepairApplicationRMAForm rmaForm = new RepairApplicationRMAForm();
          rmaForm.setRepairNo(rsf.getRepairNo());
          rmaForm.setServiceSheetNo(rsf.getServiceSheetNo());
          rmaForm.setModelCode(rsf.getModelCode());
          rmaForm.setSerialNo(rsf.getSerialNo());
          rmaForm.setPartsId(rpf.getPartsId());
          rmaForm.setPartCode(rpf.getPartCode());
          rmaForm.setOrganizationCode(rsf.getOrganizationCode());
          rmaForm.setModelName(rsf.getModelName());
          rmaForm.setCreateDate(
              ((MultiDate) SpringContextUtil.getBean("multiDate")).getMultiDate());
          rmaForm.setCreateBy(rpf.getUpdateBy());
          rmaForm.setApplyMan(rpf.getUpdateBy());
          repairApplicationRMABo.startRMA(rmaForm, uf);
        } else if (approveRoles != null) { // 如果符合受控零件申请则自动启动受控流程申请
          //			System.out.println("维修零件申请审批结束---系统自动启动受控零件申请");
          RepairListBo rlb = new RepairListBo();
          RepairPartForm rpf = rlb.getRepairPartInfo(raprf.getPartsId());
          rpf.setRepairPartStatus("E");
          rpf.setLimitApply("Y"); // 如果是受控零件,先更改零件申请类型
          this.getDao().update(rpf); // 更新维修零件表
          RepairApplicationLPForm ralpf = new RepairApplicationLPForm();
          ralpf.setRepairNo(rsf.getRepairNo());
          ralpf.setServiceSheetNo(rsf.getServiceSheetNo());
          ralpf.setModelCode(rsf.getModelCode());
          ralpf.setModelName(rsf.getModelName());
          ralpf.setSerialNo(rsf.getSerialNo());
          ralpf.setPartsId(rpf.getPartsId());
          ralpf.setPartCode(rpf.getPartCode());
          ralpf.setOrganizationCode(rsf.getOrganizationCode());
          ralpf.setCreateDate(((MultiDate) SpringContextUtil.getBean("multiDate")).getMultiDate());
          ralpf.setCreateBy(rpf.getUpdateBy());
          ralpf.setApplyMan(rpf.getUpdateBy());
          ralpf.setFactory(rsf.getManufacture());
          ralpf.setFee(rpf.getFee1());
          ralpf.setPartFeeType(rpf.getPartFeeType());

          repairApplicationLPBo.pageSave(ralpf, approveRoles, uf);
        } else {
          PartInfoForm pif =
              (PartInfoForm) this.getDao().findById(PartInfoForm.class, rpform.getPartCode());
          repairHandleBo.repairApproveAllocate(
              raprf.getWorkflowId(), raprf.getCreateBy(), rsf, rpform, pif);
        }
      } else {
        // 审批拒绝repair_part_info & partrequest update
        //			rpform.setRepairPartStatus("X");
        //			rpform.setCancelQty(new Long(1));
        //
        //	rpform.setUpdateDate(((MultiDate)SpringContextUtil.getBean("multiDate")).getMultiDate());
        //			this.getDao().update(rpform);
        repairHandleBo.processReject(rpform, raprf.getWorkflowId(), raprf.getCreateBy());
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
Exemplo n.º 11
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.º 12
0
  /**
   * 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;
  }
Exemplo n.º 13
0
 /**
  * @param userId 审批人
  * @param wfid 流程id
  * @param comment
  * @param orgCodeRR
  * @param string
  * @param tkiid
  * @param approveAgree
  * @return
  * @throws Exception
  */
 @SuppressWarnings("rawtypes")
 public ProcessInfo approveCreditNote(
     Long userId,
     String wfid,
     String processId,
     String comment,
     Long orgCode,
     boolean approveAgree) {
   ProcessInfo pf = null;
   Map<String, Object> businessMap = new HashMap<String, Object>();
   businessMap.put("businessCode", wfid); // throw new Exception();
   businessMap.put("varorganizationCode", orgCode.toString());
   String stType =
       ((CommonSearch) SpringContextUtil.getBean("commonSearch")).findStTypeByOrgCode(orgCode);
   businessMap.put("varStType", stType);
   WorkFlowDao workFlowDao = (WorkFlowDao) BeanUtil.getBean("workFlowDao");
   try {
     WorkFlowNextRoles wfnr =
         workFlowDao.findWorkFlowNextRolesByProcessId(Integer.parseInt(processId));
     WBIDBOperateBo wbidbbo = new WBIDBOperateBo();
     TdWorkFlowForm wff = wbidbbo.getWorkFlowFormByWorkflowNoAndSheetType(processId, "D");
     String currentRole = "";
     if (null != wfnr) {
       log.info("CreditNote->审批----ROLES:" + wfnr.getProcessNextRoles());
       if (wfnr.getProcessNextRoles().indexOf(",") != -1) {
         String[] configRoles = wfnr.getProcessNextRoles().split(",");
         currentRole = configRoles[0];
       } else {
         currentRole = wfnr.getProcessNextRoles();
       }
     }
     TdWorkFlowInfoForm wfif = new TdWorkFlowInfoForm();
     // 审批单据号码
     wfif.setWorkflowNo(wff.getWorkflowNo());
     wfif.setSheetType("D"); // 审批单据类型
     wfif.setApproveUser(userId); // 审批人
     wfif.setRoleCode(wff.getNextRole());
     // 审批时角色
     wfif.setApproveDate(Operate.getCurrentDate());
     // 审批日期
     wfif.setWorkFlowStatus("R"); // 流程状态为等待审批
     if (approveAgree) {
       wff.setCurrentStatus(cn.com.sony.npc.common.SysConstants.NPC_WORKFLOW_STATUS_O);
       wfif.setApproveResult("Y"); // 审批同意
       wff.setApproveResult("Y");
     } else {
       wfif.setApproveResult("N"); // 审批不同意
       wff.setApproveResult("N");
     }
     wfif.setApproveNote(comment); // 审批内容
     wfif.setCreateBy(Long.valueOf(userId));
     if (!"".equals(currentRole)) {
       wff.setNextRole(Long.valueOf(currentRole)); // 设置下一个审批角色
     } else {
       wff.setNextRole(null); // 设置下一个审批角色
     }
     wff.setUpdateDate(Operate.getCurrentDate());
     wfif.setWff(wff);
     if (!wbidbbo.isClosedAlready(new Long(processId))) {
       wbidbbo.insert(wfif);
       // 工作流参数(MAP)准备工作
       Map params = workFlowInit.initApproveMap(businessMap, approveAgree + "", wfid, comment);
       // 启动BPE工作流
       IWorkFlowService workFlowService = (IWorkFlowService) BeanUtil.getBean("workFlowService");
       MockUser user = new MockUser();
       user.setUserId(userId + "");
       user.setUserName(CommonSearch.getInstance().findUserNameByUserId(userId));
       user.setCurrentRole(currentRole);
       pf = workFlowService.doApproveProcess(params, user);
       // 工作流审批结束TODO
       log.info("CreditNote->当前审批结束,下个审批节点是:" + pf.getNextStateId());
       log.info("CreditNote->............流程审批结束.............");
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
   return pf;
 }
Exemplo n.º 14
0
  /**
   * Part accessory sale index save
   *
   * @param request HttpServletRequest
   * @param form ActionForm form data
   * @param mapping ActionMapping
   * @param response HttpServletResponse
   */
  public void validate(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {
    try {
      MultiEntity multiEntity = (MultiEntity) SpringContextUtil.getBean("multiEntity");
      HttpSession session = request.getSession();
      PrintWriter writer = response.getWriter();
      response.setContentType("text/xml");
      response.setHeader("Cache-Control", "no-cache");
      writer.println("<xml>");

      Long orgCode = (Long) session.getAttribute("orgCode");
      Boolean isSSC = (Boolean) session.getAttribute("isSSC");
      String stType = (String) session.getAttribute("stType");
      String pcType =
          ((CommonSearch) SpringContextUtil.getBean("commonSearch")).findPcTypeByOrgCode(orgCode);
      String partCode = request.getParameter("skuCode");
      String customerId = request.getParameter("customerId");
      int quantity = new Integer(request.getParameter("quantity")).intValue();
      // 得到 part info
      PartInfoForm partInfoForm = partInfoBo.find(partCode);
      PartsPriceLogic priceLogic = new PartsPriceLogic();
      //
      if (partInfoForm != null) {

        String clientType = "";
        Double partStdCost = null;
        FactorMarkUp priceGroupRelation = null;
        boolean hasPriceGroupFee = true;
        if (customerId != null && !customerId.equals("") && NumberUtils.isDigits(customerId)) {
          // 得到customer group id
          Long cusGrpid =
              ((CommonSearch) SpringContextUtil.getBean("commonSearch")).getCustomGrpId(customerId);
          if (cusGrpid != null) {
            clientType = cusGrpid.toString();
            priceGroupRelation =
                priceGroupBo.findGroupRelation(Long.parseLong(customerId), orgCode);
            TdCustomerInfoForm cus =
                (TdCustomerInfoForm)
                    priceGroupBo
                        .getDao()
                        .findById(TdCustomerInfoForm.class, Long.parseLong(customerId));
            if (priceGroupRelation == null) {
              priceLogic = new PartsPriceLogic();
            } else {
              priceLogic =
                  new PartsPriceLogic(priceGroupRelation.getPriceGroupId(), cus.getForSsc());
            }
            partStdCost = priceLogic.getPartPrice(partCode, "SS", orgCode, pcType, clientType);
            String enableMU6 =
                CommonSearch.getSystemCode("ENABLE_MU6", "MU6", multiEntity.getCountryCode());
            if ("P".equals(stType)
                && isSSC
                && (null != enableMU6 && "Y".equals(enableMU6.toUpperCase()))) {
              if (null != priceGroupRelation) {
                hasPriceGroupFee = partStdCost != 0d;
              } else {
                hasPriceGroupFee = false;
              }
            }
          }
        }

        boolean flag = partInfoBo.isCanUsePart(partCode, "S");

        /** *****新的计价逻辑****** */
        CommonSearch cs = ((CommonSearch) SpringContextUtil.getBean("commonSearch"));
        ArrayList<PartsSalesInfo> partList = new ArrayList<PartsSalesInfo>();
        SearchOptionListSetting extOptionList = null;

        String productSubCategory = partInfoForm.getProduct_Subcategory();
        String cityCode = cs.getCityCode(orgCode);
        String stateCode = cs.getStateCode(orgCode);
        String unitCode = cs.findUnitCodeByOrgCode(orgCode);
        String ascLevel = cs.getAscLevelByOrgCode(orgCode);
        RepairBasicInfo repairBasicInfo =
            new RepairBasicInfo(
                null,
                stateCode,
                cityCode,
                "",
                productSubCategory,
                "",
                "",
                orgCode,
                new Long(customerId),
                unitCode,
                ascLevel,
                "");
        repairBasicInfo.setOrgType(pcType);
        repairBasicInfo.setClientType(clientType);
        repairBasicInfo.setAbandonFlag(true);

        PartsSalesInfo partsSalesInfo = new PartsSalesInfo();
        partsSalesInfo.setPartCode(partInfoForm.getPartCode());
        partsSalesInfo.setChargableFlag("N");
        partsSalesInfo.setQuantity(quantity);

        partList.add(partsSalesInfo);

        PartFeeInterface partFeeInterface =
            (PartFeeInterface)
                SpringContextUtil.getBean("partFeeInterface" + multiEntity.getCountryCode());
        partFeeInterface.initSales(repairBasicInfo);
        PartFeeListBean partFeeListBean = partFeeInterface.getSalesPartFee(extOptionList, partList);
        ArrayList<PartFeeBean> partFeeBeanList = partFeeListBean.listFee();
        PartFeeBean partFeeBean = partFeeBeanList.get(0);

        PartTaxListBean partTaxListBean = partFeeBean.getTaxList();

        ArrayList<PartTaxBean> partTaxBeanList = partTaxListBean.listTax();

        writer.println("<partFlag>true</partFlag>");
        writer.println(
            "<partName>" + EscapeUnescape.escape(partInfoForm.getPartName()) + "</partName>");
        writer.println(
            "<partDesc>" + EscapeUnescape.escape(partInfoForm.getPartDesc()) + "</partDesc>");
        writer.println(
            "<partPrice>" + Operate.DoubleTransfer(partFeeBean.getPartPrice()) + "</partPrice>");
        //				System.out.println("<partPrice>" + Operate.DoubleTransfer(partFeeBean.getPartPrice())
        // + "</partPrice>");
        writer.println(
            "<stdCost>" + Operate.DoubleTransfer(partInfoForm.getStdCost()) + "</stdCost>");
        writer.println("<isHasSn>" + partInfoForm.getIsHasSn() + "</isHasSn>");
        writer.println("<isCanUsePart>" + flag + "</isCanUsePart>");
        writer.println("<perCost>" + Operate.DoubleTransfer(partStdCost) + "</perCost>");
        //				System.out.println("<perCost>"+Operate.DoubleTransfer(partStdCost)+"</perCost>");
        StringBuffer taxBuffer = new StringBuffer();
        int count = 0;
        Double totalTax = 0.0;
        for (PartTaxBean partTaxBean : partTaxBeanList) {

          writer.println("<taxRow id=\"" + count + "\">");
          writer.println(
              "<taxCode>" + EscapeUnescape.escape(partTaxBean.getTaxCode()) + "</taxCode>");
          writer.println(
              "<taxName>"
                  + EscapeUnescape.escape(popupSaleInfoBo.findTaxName(partTaxBean.getTaxCode()))
                  + "</taxName>");
          writer.println(
              "<taxRate>"
                  + EscapeUnescape.escape(
                      String.valueOf(Operate.formatPrice(partTaxBean.getTaxRate() * 100)))
                  + "</taxRate>");
          writer.println(
              "<taxAmt>"
                  + EscapeUnescape.escape(Operate.DoubleTransfer(partTaxBean.getTaxAmt()))
                  + "</taxAmt>");
          writer.println(
              "<convertedTaxRate>"
                  + EscapeUnescape.escape(
                      String.valueOf(Operate.formatPrice(partTaxBean.getActualTaxRate() * 100)))
                  + "</convertedTaxRate>");
          writer.println(
              "<taxType>" + EscapeUnescape.escape(partTaxBean.getTaxType()) + "</taxType>");
          writer.println("</taxRow>");
          Double tax = partTaxBean.getTaxAmt();
          String taxType = partTaxBean.getTaxType();
          totalTax = PriceLogicCommonHelper.calculateTaxByTaxType(totalTax, tax, taxType);

          String taxString =
              partTaxBean.getTaxCode()
                  + SPLITER1_STR
                  + popupSaleInfoBo.findTaxName(partTaxBean.getTaxCode())
                  + SPLITER1_STR
                  + partTaxBean.getTaxRate()
                  + SPLITER1_STR
                  + Operate.DoubleTransfer(partTaxBean.getTaxAmt())
                  + SPLITER1_STR
                  + partTaxBean.getActualTaxRate();

          taxBuffer.append(taxString);
          taxBuffer.append(SPLITER2_STR);
          count += 1;
        }
        writer.println(
            "<totalTax>" + EscapeUnescape.escape(Operate.DoubleTransfer(totalTax)) + "</totalTax>");
        writer.println(
            "<taxBuffer>" + EscapeUnescape.escape(taxBuffer.toString()) + "</taxBuffer>");
        writer.println("<hasPriceGroup>" + hasPriceGroupFee + "</hasPriceGroup>");
      } else {
        writer.println("<partFlag>false</partFlag>");
      }

      writer.println("</xml>");
      writer.flush();
      writer.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 15
0
  /**
   * Method of submiting controled part applicaiton
   *
   * @param ralpf Controled part application
   * @param approveRoles Approve role list
   * @return 1:Successful,-1:Unsuccessful
   */
  public int pageSave(RepairApplicationPRForm ralpf, UserForm uf) {
    int returnFlag = -1;
    AllDefaultDaoImp daoImp = (AllDefaultDaoImp) SpringContextUtil.getBean("dao");
    String stType =
        ((CommonSearch) SpringContextUtil.getBean("commonSearch"))
            .findStTypeByOrgCode(ralpf.getOrganizationCode());
    WorkFlowConfigRole wfcr = null;
    try {

      ralpf.setWorkflowId(Long.valueOf(workFlowService.getBusinessId()));
      /* *******************************************************************/
      /*@Added/Modified by        : Deepak
      /*@Date                     : 14/10/2012
      /*@Reason                   : Part request application workflow
      /**********************************************************************/
      MultiEntity multiEntity = (MultiEntity) SpringContextUtil.getBean("multiEntity");
      String[] roleConfig = null;
      if (!multiEntity.getCountryCode().equalsIgnoreCase("IN")) {
        roleConfig =
            workFlowInit.getAllRole(BPEProcessConstants.PARTREQUEST, stType); // need to change
        ralpf.setAllApproveRoles(roleConfig[0]);
        logger.info("if ===from getallrole pagesave method==Deepak==" + roleConfig[0]);
      } else {
        if (ralpf.getWarrantyType().equals("O") && ralpf.getPartFeeType().equals("N")) {
          wfcr = daoImp.findByTempNameAndStep(BPEProcessConstants.PARTREQUEST, "STEP2", stType);
          logger.info("if part wfcr.getConfigRole()" + wfcr.getConfigRole());
          ralpf.setAllApproveRoles(wfcr.getConfigRole());

        } else {
          wfcr = daoImp.findByTempNameAndStep(BPEProcessConstants.PARTREQUEST, "STEP1", stType);
          //                  System.out.println("else part
          // wfcr.getConfigRole()"+wfcr.getConfigRole());
          ralpf.setAllApproveRoles(wfcr.getConfigRole());
          logger.info("else ===from getallrole pagesave method==Deepak==" + wfcr.getConfigRole());
        }
      }
      logger.info("===Pagesave method of Repair applicationPRBo.java file ");
      /** ******************************************************************* */
      returnFlag = this.getDao().insert(ralpf) ? 1 : -1;

      String tmplateId = "13";

      Map businessMap = new HashMap();
      businessMap.put("businessCode", ralpf.getServiceSheetNo());
      businessMap.put("varStType", stType);
      businessMap.put("varOrganizationCode", String.valueOf(ralpf.getOrganizationCode()));
      Map params =
          workFlowInit.initapplyMap(businessMap, uf, ralpf.getWorkflowId().toString(), tmplateId);
      NewsisUser nu = new NewsisUser();

      nu.setUserId(String.valueOf(uf.getId()));
      nu.setUserName(uf.getUserName());

      //			/***/
      WBIDBOperateBo wbido = new WBIDBOperateBo();
      String[] strs = ralpf.getAllApproveRoles().split(",");
      Long[] longs = new Long[strs.length + 2];
      longs[0] = null;
      longs[1] = null;
      for (int i = 0; i < strs.length; i++) {
        longs[i + 2] = new Long(strs[i]);
      }
      wbido.insertStartInfo(
          ralpf.getWorkflowId(),
          "P",
          ralpf.getApplyMan(),
          ralpf.getRepairNo(),
          ralpf.getServiceSheetNo(),
          new Long(strs[0]),
          longs);

      //			    System.out.println("写入到RepairUnRepairStatusInfoForm-----");
      List batchInsertList = new ArrayList();
      RepairUnRepairStatusInfoForm rursif = new RepairUnRepairStatusInfoForm();
      rursif.setRepairNo(ralpf.getRepairNo());
      rursif.setUnRepairStatus("E"); // Waiting for internal approve
      rursif.setDbBeginDate(((MultiDate) SpringContextUtil.getBean("multiDate")).getMultiDate());
      rursif.setOrganizationCode(ralpf.getOrganizationCode().toString());
      rursif.setUnrepairGenType("A");
      rursif.setWorkFlowNo(ralpf.getWorkflowId().toString());
      rursif.setCreateBy(ralpf.getCreateBy());
      rursif.setCreateDate(Operate.toUtilDate());
      batchInsertList.add(rursif);

      returnFlag = this.getBatchDao().insertBatch(batchInsertList) ? 1 : -1;
      //			///启动BPE申请工作流
      ProcessInfo pinfo = workFlowService.doStartProcess(params, nu);

    } catch (Exception e) {
      e.printStackTrace();
    }
    return returnFlag;
  }
Exemplo n.º 16
0
  /**
   * RC add warranty claim fee
   *
   * @param request HttpServletRequest
   * @param form ActionForm
   * @return String Return results page
   */
  public String addBalanceFee(HttpServletRequest request, ActionForm form) {
    String forward = "resultMessage";
    ArrayList al = new ArrayList();
    int ftag = -1;
    int ptag = -1;
    try {

      /**
       * ******************************************************************** /*@Added/Modified by :
       * Veena /*@Date : 4/09/2012 /*@Reason : INC000000441294, CR 19 - Tax calculation by system
       * /*********************************************************************
       */
      String stateCode = null;
      String cityCode = null;
      String unitCode = null;
      Long organizationCode = null;
      String customerGroupId = null;
      ArrayList<String> feeTypeList = new ArrayList<String>();
      TreeMap<String, ServiceTaxListBean> serviceTaxMap = null;
      /** **********************Ends here********************************************* */
      Set balanceIdSet = new HashSet();
      HttpSession session = request.getSession();
      Long chargeStaffId = (Long) session.getAttribute("userId");
      String chks = (String) request.getParameter("chksBalanceId");
      BalanceFeeForm2 bf = (BalanceFeeForm2) form;
      String status = "";
      if ("bcApprove".equals(bf.getSheetType())) {
        status = "1";
      } else {
        status = "27";
      }
      //			System.out.println("sheetType---------------"+bf.getSheetType());
      //			System.out.println("status---------------"+status);
      //			BCBalanceApproveBo rbo=new BCBalanceApproveBo();
      List tempList = bcBalanceApproveBo.listVersion(chks);
      for (int i = 0; i < tempList.size(); i++) {
        BalanceFeeForm2 balanceFeeForm = (BalanceFeeForm2) tempList.get(i);
        balanceIdSet.add(balanceFeeForm.getBalanceId()); // 取不重复的balanceId
      }
      Iterator it = balanceIdSet.iterator();
      while (it.hasNext()) {
        BalanceFeeForm2 addFeeForm = new BalanceFeeForm2();
        Long tempBalanceId = (Long) it.next();
        addFeeForm.setBalanceId(tempBalanceId);
        addFeeForm.setBalanceFeeType(bf.getBalanceFeeType());
        addFeeForm.setBalanceSponsor(new Long(request.getParameter("hiddenFactoryInfo")));
        addFeeForm.setBalanceFee(bf.getBalanceFee());
        /**
         * ******************************************************************** /*@Added/Modified by
         * : Veena /*@Date : 4/09/2012 /*@Reason : INC000000441294, CR 19 - Tax calculation by
         * system /*********************************************************************
         */
        feeTypeList.add(bf.getBalanceFeeType());

        Long repairNo =
            Long.valueOf(bcBalanceApproveBo.findRepairNoByBalanceId(tempBalanceId.toString()));
        RepairServiceForm rsf = getRepairInfo(repairNo);
        organizationCode = rsf.getOrganizationCode();
        cityCode = cs.getCityCode(organizationCode);
        stateCode = cs.getStateCode(organizationCode);
        unitCode = cs.findUnitCodeByOrgCode(organizationCode);
        /* *******************************************************************/
        /*@Added/Modified by        : Manohar
        /*@Date                     : 17/04/2013
        /*@Reason                   : INC000000518392 - NeWSIS :: System issue :: Fee modification for jobs
        /**********************************************************************/

        if (null != rsf.getCustomerId() && rsf.getCustomerId().equals("")) {
          customerGroupId = cs.getCustomGrpId(rsf.getCustomerId().toString()).toString();
        }
        /* ************************ENDS HERE****************************************  */
        SearchOptionListSetting taxOptionList = new SearchOptionListSetting();

        taxOptionList.createServiceTaxDefaultInstance(
            stateCode, cityCode, unitCode, feeTypeList, customerGroupId);

        MultiEntity multiEntity = (MultiEntity) SpringContextUtil.getBean("multiEntity");
        String countryCode = multiEntity.getCountryCode();
        CommonSearchService commonSearchService =
            (CommonSearchService) SpringContextUtil.getBean("commonSearchService" + countryCode);

        serviceTaxMap = commonSearchService.getTaxList(taxOptionList);

        ServiceTaxListBean taxList =
            (serviceTaxMap == null) ? null : serviceTaxMap.get(bf.getBalanceFeeType());

        if (taxList != null) {
          taxList.calculate(bf.getBalanceFee());

          /* *******************************************************************/
          /*@Added/Modified by        : Sanjay
          /*@Date                     : 25/09/2012
          /*@Reason                   : INC000000456989 - IW Module Add fee Issue - Operation failed
          /**********************************************************************/

          if (null != taxList.getTotalTaxAmt().toString()) {
            addFeeForm.setTaxTotal(taxList.getTotalTaxAmt().toString());
          }
          /* ************************ENDS HERE********************************** */
        }

        addFeeForm.setBalanceFeeStatus(
            status); // 设置状��此页�结算�状�为BC暂�
        addFeeForm.setCreateBy(chargeStaffId);
        addFeeForm.setCreateDate(Operate.toUtilDate());
        addFeeForm.setIsSysGen("N"); // 代表是 BC手工添加的这笔费用
        addFeeForm.setRepairCode(
            bcBalanceApproveBo.findRepairCodeByBalanceId(tempBalanceId.toString())); // 方法代码
        if (bf.getBcRemark() != null && !"".equals(bf.getBcRemark())) {
          addFeeForm.setBcRemark("BC Manul Create:" + bf.getBcRemark());
        }
        ftag = bcBalanceApproveBo.add(addFeeForm);
        if (ftag == 1) {

          // 插入结算费用变化过程表
          SettlementFeeChangeProcdureForm sfcpf = new SettlementFeeChangeProcdureForm();
          sfcpf.setBalanceId(tempBalanceId);
          sfcpf.setBalanceFeeId(addFeeForm.getBalanceFeeId());
          sfcpf.setBalanceFee(bf.getBalanceFee());
          // wubin at 20100527 增加taxTotal
          Double tempTaxTotal =
              bf.getTaxTotal() == null || "".equals(bf.getTaxTotal().trim())
                  ? 0
                  : Double.parseDouble(bf.getTaxTotal());
          sfcpf.setTaxTotal(tempTaxTotal);
          sfcpf.setBalanceStatus(status);
          sfcpf.setChangeBy(chargeStaffId);
          sfcpf.setRemark(bf.getBcRemark());
          sfcpf.setCreateBy(chargeStaffId);
          sfcpf.setCreateDate(Operate.toUtilDate());
          ptag = bcBalanceApproveBo.add(sfcpf);
          if (ptag == -1) {
            bcBalanceApproveBo.delete(addFeeForm);
          }
        }
      }

      request.setAttribute("tag", ptag + "");
      if ("bcApprove".equals(bf.getSheetType())) {
        request.setAttribute("businessFlag", "RcApprove");
      } else {
        request.setAttribute("businessFlag", "BCWait");
      }
    } catch (VersionException ve) {
      forward = "versionErr";
    } catch (Exception e) {
      e.printStackTrace();
    }
    return forward;
  }
Exemplo n.º 17
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;
  }