public static void getSalesInfo(Long merchant_id, PhonePos shoppos) { String crmv3sql = "SELECT firm_name,staff_id,staff_city_id FROM crm_firm WHERE firm_id='" + merchant_id + "'"; Map<String, Object> queryForMap = crmv3_template.queryForMap(crmv3sql); Long user_id = (Long) queryForMap.get("staff_id"); Long city_id = (Long) queryForMap.get("staff_city_id"); String firm_name = (String) queryForMap.get("firm_name"); String ssonamesql = "SELECT NAME FROM acl_user WHERE user_id='" + user_id + "'"; String ssocitysql = "SELECT city_name FROM acl_city WHERE city_id='" + city_id + "'"; String usersql = "SELECT email FROM lbc_user WHERE id ='" + shoppos.getUserId() + "'"; Map<String, Object> userMap = tuan_lbc_template.queryForMap(usersql); String email = (String) userMap.get("email"); shoppos.setUserEmail(email); Map<String, Object> ssoMap = new HashMap<String, Object>(); Map<String, Object> ssoCityMap = new HashMap<String, Object>(); if (user_id == 0) { ssoMap.put("name", "不在私海"); ssoCityMap.put("city_name", ""); } else { try { ssoMap = sso_template.queryForMap(ssonamesql); ssoCityMap = sso_template.queryForMap(ssocitysql); } catch (Exception e) { } } String name = (String) ssoMap.get("name"); String city_name = (String) ssoCityMap.get("city_name"); shoppos.setStaffName(name); shoppos.setCity(city_name); shoppos.setPoiName(firm_name); shoppos.setStaffId(user_id); System.out.println(ToStringBuilder.reflectionToString(shoppos)); }
public static void main(String[] args) throws IOException { // getSalesInfo(1548280L); File file2 = ResourceUtils.getFile("classpath:pos_serial.csv"); List<String> sqls = FileUtils.readLines(file2); for (String s : sqls) { try { String querySql = "SELECT merchant_id,user_id FROM shop_pos WHERE SERIAL='" + s + "'"; List<Map<String, Object>> mapList = tuan_lbc_template.queryForList(querySql); for (Map<String, Object> map : mapList) { Long merchant_id = (Long) map.get("merchant_id"); Long user_id = (Long) map.get("user_id"); PhonePos shoppos = new PhonePos(); shoppos.setSerialId(s); shoppos.setMerchantId(merchant_id); shoppos.setUserId(user_id); getSalesInfo(merchant_id, shoppos); FileUtils.writeStringToFile(new File("D:\\POS.TXT"), shoppos.toString(), true); } } catch (Exception e) { System.err.println(s); e.printStackTrace(); continue; } } }