コード例 #1
0
 public Map checkMachine(String machineNo, UserLogin ul) {
   Map result = new HashMap();
   List<Object[]> ml =
       this.getHibernateTemplate()
           .find(
               "from Machine m,MachineType mt where m.MachineTypeId = mt.id and m.MachineNo = ?",
               machineNo);
   if (WebUtil.isNullForList(ml)) {
     result.put("Flag", "ERROR");
     result.put("Message", "无理光公司出货信息");
     return result;
   }
   Object[] obj = ml.get(0);
   Machine m = (Machine) obj[0];
   MachineType mt = (MachineType) obj[1];
   int companyId = ul.getCompanyId();
   List<CompanyMachineTypeRef> cl =
       this.getHibernateTemplate()
           .find(
               "from CompanyMachineTypeRef where id.CompanyId = ? and id.MachineTypeId = ?",
               new Object[] {companyId, m.getMachineTypeId()});
   if (WebUtil.isNullForList(cl)) {
     result.put("Flag", "ERROR");
     result.put("Message", "贵公司没有该机型维护能力");
     return result;
   }
   if (WebUtil.isNotNull(m.getStatus()) && m.getStatus().equals("REPAIRING")) {
     result.put("Flag", "ERROR");
     result.put("Message", "该机器正在维修中...");
     return result;
   }
   if (WebUtil.isNotNull(m.getStatus()) && m.getStatus().equals("CHANGE")) {
     result.put("Flag", "ERROR");
     result.put("Message", "该机器已换货");
     return result;
   }
   result.put("Flag", "SUCCESS");
   Map mm = new HashMap();
   mm.put("MachineId", m.getId());
   mm.put("MachineNo", m.getMachineNo());
   mm.put("MachineTypeId", mt.getId());
   mm.put("MachineTypeName", mt.getMachineType());
   mm.put("MachineCat", mt.getMachineCat());
   mm.put("MachineCd", mt.getMachineCd());
   mm.put("PpsNo", m.getPpsNo());
   mm.put("PaymentStatus", m.getPaymentStatus());
   mm.put("PaymentCompany", m.getPaymentCompany());
   mm.put("PaymentCompanyCd", m.getPaymentCompanyCd());
   mm.put("ServiceFromDate", m.getServiceFromDate());
   mm.put("ServiceEndDate", m.getServiceEndDate());
   mm.put("InvoiceDate", m.getInvoiceDate());
   mm.put("OutDate", m.getOutDate());
   mm.put("LastTime", m.getLastTime());
   result.put("Machine", mm);
   return result;
 }
コード例 #2
0
 public Map getMachineInfo(String machineId) {
   if (!WebUtil.isNumeric(machineId)) {
     return null;
   }
   List<Machine> l =
       this.getHibernateTemplate().find("from Machine m where m.id = ?", new Integer(machineId));
   if (WebUtil.isNullForList(l)) return null;
   Map<String, String> status = getMachineStatus();
   Machine m = l.get(0);
   Map<String, String> result = new HashMap();
   result.put("MachineId", m.getId().toString());
   result.put("MachineNo", m.getMachineNo());
   result.put("PpsNo", m.getPpsNo());
   result.put("ServiceFromDate", WebUtil.formatDateString(m.getServiceFromDate(), "yyyy-MM-dd"));
   result.put("ServiceEndDate", WebUtil.formatDateString(m.getServiceEndDate(), "yyyy-MM-dd"));
   result.put("OutDate", WebUtil.formatDateString(m.getOutDate(), "yyyy-MM-dd"));
   result.put("InvoiceDate", WebUtil.formatDateString(m.getInvoiceDate(), "yyyy-MM-dd"));
   result.put("PaymentStatus", m.getPaymentStatus());
   result.put("PaymentCompany", m.getPaymentCompany());
   result.put("PaymentCompanyCd", m.getPaymentCompanyCd());
   result.put("PaymentDate", WebUtil.formatDateString(m.getPaymentDate(), "yyyy-MM-dd"));
   if (WebUtil.isNotNull(m.getPaymentAmt()))
     result.put("PaymentAmt", m.getPaymentAmt().toString());
   result.put("LastTime", WebUtil.formatDateString(m.getLastTime(), "yyyy-MM-dd"));
   if (WebUtil.isNotNull(m.getLastCompanyId())) {
     List<Company> cl =
         this.getHibernateTemplate()
             .find("from Company where Status = 'NORMAL' and id = " + m.getLastCompanyId());
     if (!WebUtil.isNullForList(cl)) {
       Company c = cl.get(0);
       result.put("LastCompanyName", c.getCompanyName());
       result.put("LastCompanyId", m.getLastCompanyId().toString());
     }
   }
   result.put("MachineStatus", m.getStatus());
   result.put("MachineStatusName", status.get(m.getStatus()));
   if (m.getMachineTypeId() != null) {
     List<MachineType> mtList =
         this.getHibernateTemplate()
             .find("from MachineType where Status = 'NORMAL' and id = " + m.getMachineTypeId());
     if (!WebUtil.isNullForList(mtList)) {
       MachineType mt = mtList.get(0);
       result.put("MachineTypeId", m.getMachineTypeId().toString());
       result.put("MachineType", mt.getMachineType());
       result.put("MachineCd", mt.getMachineCd());
     }
   }
   result.put("Origin", m.getOrigin());
   result.put("CustomerNo", m.getCustomerNo());
   result.put("CustomerName", m.getCustomerName());
   return result;
 }
コード例 #3
0
  public Map searchMachine(Map param, int currentPage, int pageRow) {
    StringBuffer hql = new StringBuffer();
    hql.append("from Machine m ,MachineType mt where m.MachineTypeId = mt.id ");
    StringBuffer con = new StringBuffer();
    List conList = new ArrayList();
    if (!WebUtil.isNull(param.get("MachineNo"))) {
      if (con.length() > 0) con.append(" and ");
      con.append(" m.MachineNo = :Condition" + conList.size());
      conList.add(param.get("MachineNo").toString());
    }
    if (!WebUtil.isNull(param.get("PpsNo"))) {
      if (con.length() > 0) con.append(" and ");
      con.append(" m.PpsNo like :Condition" + conList.size());
      conList.add("%" + param.get("PpsNo") + "%");
    }

    if (!WebUtil.isNull(param.get("CustomerName"))) {
      if (con.length() > 0) con.append(" and ");
      con.append(" m.CustomerName like :Condition" + conList.size());
      conList.add("%" + param.get("CustomerName") + "%");
    }
    if (!WebUtil.isNull(param.get("MachineTypeId"))) {
      if (con.length() > 0) con.append(" and ");
      con.append(" m.MachineTypeId = :Condition" + conList.size());
      conList.add(new Integer(param.get("MachineTypeId").toString()));
    }
    if (!WebUtil.isNull(param.get("MachineCd"))) {
      if (con.length() > 0) con.append(" and ");
      con.append(" mt.MachineCd = :Condition" + conList.size());
      conList.add(param.get("MachineCd"));
    }
    if (!WebUtil.isNull(param.get("FromOutDate"))) {
      if (con.length() > 0) con.append(" and ");
      con.append(" m.OutDate >= :Condition" + conList.size());
      conList.add(WebUtil.toDateForString(param.get("FromOutDate").toString(), "yyyy-MM-dd"));
    }
    if (!WebUtil.isNull(param.get("EndOutDate"))) {
      if (con.length() > 0) con.append(" and ");
      con.append(" m.OutDate < :Condition" + conList.size());
      conList.add(WebUtil.toDateForString(param.get("EndOutDate").toString(), "yyyy-MM-dd"));
    }
    if (con.length() > 0) hql.append(" and " + con.toString());

    Session session = this.getSession();
    Map result = null;
    try {
      Query q1 = session.createQuery("select count(*) " + hql.toString());
      // 查询条件
      for (int i = 0; i < conList.size(); i++) {
        q1.setParameter("Condition" + i, conList.get(i));
      }
      List<Long> countList = q1.list();
      int count = countList.get(0).intValue();
      Query q = session.createQuery(hql.toString());
      // 查询条件
      for (int i = 0; i < conList.size(); i++) {
        q.setParameter("Condition" + i, conList.get(i));
      }
      if (pageRow > 0) {
        q.setFirstResult((currentPage - 1) * pageRow);
        q.setMaxResults(pageRow);
      }
      result = new HashMap();
      List<Object[]> l = q.list();
      List<Map> r = new ArrayList();
      for (Object[] obj : l) {
        Machine mm = (Machine) obj[0];
        MachineType mt = (MachineType) obj[1];
        Map m = new HashMap();
        m.put("MachineId", mm.getId().toString());
        m.put("MachineNo", mm.getMachineNo());
        m.put("PpsNo", mm.getPpsNo());
        m.put("MachineTypeId", mm.getMachineTypeId());
        m.put("MachineType", mt.getMachineType());
        m.put("MachineCd", mt.getMachineCd());
        m.put("CustomerName", mm.getCustomerName());
        m.put("CustomerNo", mm.getCustomerNo());
        m.put("OuterDate", WebUtil.formatDateString(mm.getOutDate(), "yyyy-MM-dd"));
        m.put("ServiceFromDate", WebUtil.formatDateString(mm.getServiceFromDate(), "yyyy-MM-dd"));
        m.put("ServiceEndDate", WebUtil.formatDateString(mm.getServiceEndDate(), "yyyy-MM-dd"));
        m.put("PaymentStatus", mm.getPaymentStatus());
        r.add(m);
      }
      result.put("RESULT", r);
      result.put("COUNT_ROW", count);
    } catch (HibernateException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (RuntimeException e) {
      result.put("Flag", "ERROR");
      result.put("Message", e.getMessage());
      logger.error(e.getMessage());
    } finally {
      if (session != null && session.isOpen()) session.close();
    }
    return result;
  }
コード例 #4
0
  public Integer saveMachine(Map param) {
    String machineId = (String) param.get("MachineId");
    Machine mt = null;
    if (WebUtil.isNotNull(machineId)) {
      List<Machine> l =
          this.getHibernateTemplate().find("from Machine where id = ?", new Integer(machineId));
      if (!WebUtil.isNullForList(l)) {
        mt = l.get(0);
      }
    }
    Date date = new Date();
    if (mt == null) {
      mt = new Machine();
      mt.setCtime(date);
      mt.setCuser((String) param.get("UserName"));
      mt.setStatus("NORMAL");
      mt.setOrigin("NEW");
    } else {
      mt.setMtime(date);
      mt.setMuser((String) param.get("UserName"));
    }
    if (WebUtil.isNotNull(param.get("MachineCd"))) mt.setMachineCd((String) param.get("MachineCd"));
    if (WebUtil.isNotNull(param.get("MachineTypeId")))
      mt.setMachineTypeId(new Integer(param.get("MachineTypeId").toString()));
    if (WebUtil.isNotNull(param.get("MachineNo"))) mt.setMachineNo((String) param.get("MachineNo"));
    if (WebUtil.isNotNull(param.get("PpsNo"))) mt.setPpsNo((String) param.get("PpsNo"));
    if (WebUtil.isNotNull(param.get("ServiceFromDate")))
      mt.setServiceFromDate(
          WebUtil.toDateForString(param.get("ServiceFromDate").toString(), "yyyy-MM-dd"));
    if (WebUtil.isNotNull(param.get("ServiceEndDate")))
      mt.setServiceEndDate(
          WebUtil.toDateForString(param.get("ServiceEndDate").toString(), "yyyy-MM-dd"));
    if (WebUtil.isNotNull(param.get("OutDate")))
      mt.setOutDate(WebUtil.toDateForString(param.get("OutDate").toString(), "yyyy-MM-dd"));
    if (WebUtil.isNotNull(param.get("InvoiceDate")))
      mt.setInvoiceDate(WebUtil.toDateForString(param.get("InvoiceDate").toString(), "yyyy-MM-dd"));
    if (WebUtil.isNotNull(param.get("PaymentStatus")))
      mt.setPaymentStatus((String) param.get("PaymentStatus"));
    if (WebUtil.isNotNull(param.get("PaymentCompany")))
      mt.setPaymentCompany((String) param.get("PaymentCompany"));
    if (WebUtil.isNotNull(param.get("PaymentCompanyCd")))
      mt.setPaymentCompanyCd((String) param.get("PaymentCompanyCd"));
    if (WebUtil.isNotNull(param.get("PaymentDate")))
      mt.setPaymentDate(WebUtil.toDateForString(param.get("PaymentDate").toString(), "yyyy-MM-dd"));
    if (WebUtil.isNotNull(param.get("PaymentAmt")))
      mt.setPaymentAmt(new BigDecimal(param.get("PaymentAmt").toString()));
    if (WebUtil.isNotNull(param.get("CustomerNo")))
      mt.setCustomerNo(param.get("CustomerNo").toString());
    if (WebUtil.isNotNull(param.get("CustomerName")))
      mt.setCustomerName(param.get("CustomerName").toString());

    if (mt.getId() == null) this.getHibernateTemplate().save(mt);
    else this.getHibernateTemplate().update(mt);
    return mt.getId();
  }