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; }
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; }