// 型号 , 状态 public static Map<String, List<SNInventory>> getMapBranchType( User user, String startTime, int branchid) { // startTime = "2015-05-03"; // List<Inventory> list = new ArrayList<Inventory>(); Branch branch = BranchService.getMap().get(branchid); String bnum = ""; if (null != branch) { bnum = branch.getEncoded(); } // logger.info() Map<String, Product> mapp = ProductService.gettypeNUmmap(); // logger.info(mapp); Map<String, List<SNInventory>> map = new HashMap<String, List<SNInventory>>(); if (null != branch && branch.getBranchtype().getSaletype() == SaleModel.Model.苏宁.getValue()) { try { String tempPath = PathUtill.getXMLpath(); tempPath += "data" + File.separator + "DownloadInventory" + File.separator + startTime + File.separator + "SuNing"; logger.info(tempPath); File file = new File(tempPath); if (!file.exists()) { file.mkdirs(); } File file2 = new File(tempPath + File.separator + "model.csv"); // file2.createNewFile(); CsvReader reader = new CsvReader(file2.getPath(), ',', Charset.forName("GBK")); // 一般用这编码读就可以了 reader.readHeaders(); while (reader.readRecord()) { // 逐行读入除表头的数据 String[] strs = reader.getValues(); if (null != strs) { SNInventory in = new SNInventory(); for (int i = 0; i < strs.length; i++) { // logger.info(i); String str = strs[i]; // logger.info(str); if (i == 0) { // logger.info(str); in.setGoodType("样机"); } else if (i == 2) { in.setBranchName(str); } else if (i == 3) { in.setBranchNum(str); } else if (i == 6) { in.setGoodGroupName(str); } else if (i == 7) { in.setGoodGroupNum(str); } else if (i == 10) { in.setGoodpName(str); } else if (i == 11) { in.setGoodNum(str); } else if (i == 12) { double realnum = Double.valueOf(str); int re = (int) realnum; in.setNum(re); } else if (i == 13) { in.setSerialNumber(str); } } // logger.info(in.getBranchNum()); String bnu = in.getBranchNum(); // logger.info(bnu); // logger.info(in.getBranchNum()); if (bnum.equals(bnu)) { String key = in.getGoodNum(); // logger.info(key); Product p = mapp.get(key); // logger.info(p); if (null != p) { String pname = mapp.get(key).getType(); List<SNInventory> inmap = map.get(pname); if (inmap == null) { inmap = new ArrayList<SNInventory>(); map.put(pname, inmap); } inmap.add(in); } } } } logger.info(map.size()); reader.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } // 跳过表头 如果需要表头的话,不要写这句。 } return map; }
public static List<SNInventory> getMap() { // startTime = "2015-05-03"; List<SNInventory> list = new ArrayList<SNInventory>(); Map<Integer, Map<String, Map<Integer, InventoryBranch>>> mapin = InventoryBranchManager.getInventoryMap(); try { String tempPath = PathUtill.getXMLpath(); tempPath += "data" + File.separator + "DownloadInventory" + File.separator + TimeUtill.getdateString() + File.separator + "SuNing"; logger.info(tempPath); File file = new File(tempPath); if (!file.exists()) { file.mkdirs(); } File file2 = new File(tempPath + File.separator + "model.csv"); // file2.createNewFile(); CsvReader reader = new CsvReader(file2.getPath(), ',', Charset.forName("GBK")); // 一般用这编码读就可以了 reader.readHeaders(); int count = 0; while (reader.readRecord()) { // 逐行读入除表头的数据 String[] strs = reader.getValues(); if (null != strs) { SNInventory in = new SNInventory(); for (int i = 0; i < strs.length; i++) { // logger.info(i); String str = strs[i]; // logger.info(str); if (i == 0) { // logger.info(str); in.setGoodType("样机"); } else if (i == 2) { in.setBranchName(str); } else if (i == 3) { in.setBranchNum(str); } else if (i == 6) { in.setGoodGroupName(str); } else if (i == 7) { in.setGoodGroupNum(str); } else if (i == 10) { in.setGoodpName(str); } else if (i == 11) { in.setGoodNum(str); } else if (i == 12) { double realnum = Double.valueOf(str); int re = (int) realnum; in.setNum(re); } else if (i == 13) { in.setSerialNumber(str); } } count++; int branchid = -1; int type = -1; try { branchid = BranchService.getNumMap(Model.苏宁.getValue()).get(in.getBranchNum()).getId(); // logger.info(in.getBranchNum()); } catch (Exception e) { logger.info("转化门店出错"); } try { type = ProductService.gettypeNUmmap().get(in.getGoodNum()).getId(); // logger.info(in.getGoodNum()); } catch (Exception e) { logger.info("转化型号出错"); } if (branchid != -1 && type != -1) { in.setBid(branchid); in.setTid(type); Map<String, Map<Integer, InventoryBranch>> mapb = mapin.get(branchid); if (null == mapb) { list.add(in); } else { Map<Integer, InventoryBranch> mapt = mapb.get(type + ""); if (null == mapt) { list.add(in); } else { InventoryBranch inb = mapt.get(OrderGoods.prototype); if (null == inb) { list.add(in); } } } } } } logger.info("count" + count); reader.close(); } catch (IOException e) { // TODO Auto-generated catch block logger.info(e); } // 跳过表头 如果需要表头的话,不要写这句。 logger.info("list" + list.size()); return list; }