コード例 #1
0
 @Override
 public List<MedicineStorehouse> queryNotExpired(MedicineStorehouse vo, PageResult page) {
   List<Object> objList = dao.queryNotExpired(vo, page);
   List<MedicineStorehouse> list = new ArrayList<MedicineStorehouse>();
   MedicineStorehouse m = null;
   for (Object obj : objList) {
     m = new MedicineStorehouse();
     Object[] o = (Object[]) obj;
     Long id = MathUtil.valueToLong(o[0]);
     Long medicineId = MathUtil.valueToLong(o[1]);
     String medicineName = (String) o[2];
     Date mfg = (Date) o[3];
     Date exp = (Date) o[4];
     int number = (int) o[5];
     double price = (double) o[6];
     Long purchaseId = MathUtil.valueToLong(o[7]);
     double costPrice = (double) o[8];
     m.setId(id);
     m.setMedicineId(medicineId);
     m.setMfg(mfg);
     m.setExp(exp);
     m.setNumber(number);
     m.setPrice(price);
     m.setPurchaseId(purchaseId);
     m.setMedicineName(medicineName);
     m.setCostPrice(costPrice);
     list.add(m);
   }
   return list;
 }
コード例 #2
0
 @Override
 public String JSONQuery(MedicineStorehouse vo, PageResult page) {
   List<Object> objList = dao.query(vo, page);
   SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
   JSONArray ja = new JSONArray();
   JSONObject jo = null;
   for (Object obj : objList) {
     jo = new JSONObject();
     Object[] o = (Object[]) obj;
     Long id = MathUtil.valueToLong(o[0]);
     Long medicineId = MathUtil.valueToLong(o[1]);
     String medicineName = (String) o[2];
     Date mfg = (Date) o[3];
     Date exp = (Date) o[4];
     int number = (int) o[5];
     double price = (double) o[6];
     Long purchaseId = MathUtil.valueToLong(o[7]);
     double costPrice = (double) o[8];
     jo.put("id", id);
     jo.put("medicineId", medicineId);
     jo.put("mfg", sdf.format(mfg));
     jo.put("exp", sdf.format(exp));
     jo.put("number", number);
     jo.put("price", price);
     jo.put("purchaseId", purchaseId);
     jo.put("medicineName", medicineName);
     jo.put("costPrice", costPrice);
     if (exp.getTime() < new Date().getTime()) {
       jo.put("status", "已过期");
     } else if (price > 0) {
       jo.put("status", "已上架");
     } else {
       jo.put("status", "未上架");
     }
     ja.add(jo);
   }
   return ja.toJSONString();
 }