// 派发 @RequestMapping(value = "/groupRuleUpload") public void GroupRuleUpload(@RequestParam("file") CommonsMultipartFile file, HttpServletRequest request, HttpServletResponse response) { try { if (file == null) { Helper.StatusResponse(response, "failure", "-1", "派发规则文件不存在"); return; } String provinces = request.getParameter("province"); List<String> listProvinces = new ArrayList<String>(); Helper.Spliter (Provinces, "," , listProvinces); IF (listProvinces.size () 0 == ) { logger.error ( "RulesUpload file upload failed: province cities parameter is null" ); Helper.StatusResponse (Response, "failure", "-1", "Province cities parameter is null" ); return ; } logger.info ( "Upload fileName:" + file.getOriginalFilename ()); // Get the input stream may CommonsMultipartFile directly from the file stream HashMap <String, List <String >> DeployHistory = new new HashMap <String, List <String>>(); Obj the JSONObject = new new the JSONObject (); the Map <String, DeployManagerInfo> Results = sysService.QueryDeployManager (listProvinces); for (String A: listProvinces) { DeployManagerInfo DMI = results.get (A); IF (DMI == null ) { obj .put (A, "the rules of distribution fails, incoming province name mismatch" ); // logger.error ( "RulesUpload" + A + "failure to distribute incoming province name mismatch"); the Continue ; } IF (! dmi.getStatus (). the equals ( ". 1" )) { obj.put (A, "distribution rule fails, the province undeployed" ); // logger.error ( "RulesUpload" + A + "distribution fails, the province undeployed"); Continue ; } FtpUtil FTP = new new FtpUtil ( dmi.getFtp_ip (), Helper.StringToInt (dmi.getFtp_port ()), dmi.getFtp_user (), dmi.getFtp_password (), dmi.getFtp_direct ()); IF ! (ftp.CreateFTPConnect () = 0 ) { // logger.error ( "RulesUpload" + a + " distribution fails, the region ftp configuration is not up to: \ the n-" + dmi.toString ()); obj.put (A, "the rules of distribution fails, the region ftp configuration unreachable" ); the Continue ; } String res = ""; InputStream is = file.getInputStream(); boolean b = ftp.FtpUpload(/*a + "_" + */file.getOriginalFilename(), is); if (b == false) { res += file.getOriginalFilename() + "派发失败;"; } else { res += file.getOriginalFilename() + "派发成功;"; List<String> filelist = DeployHistory.get(a); if (filelist == null) { filelist = new ArrayList<String>(); DeployHistory.put(a, filelist); } filelist.add(file.getOriginalFilename()); } obj.put(a, res); ftp.CloseFtp(); } Helper.JsonResponser(response, obj); logger.info("RulesUpload 规则派发结果:\n" + obj.toString()); for (Entry<String, List<String>> entry : DeployHistory.entrySet()) { for (String filename : entry.getValue()) { HistoryRuleDeployInfo hdInfo = new HistoryRuleDeployInfo(); hdInfo.setProvince(entry.getKey()); hdInfo.setCreate_time(Helper.getDateByFormat(new Date(), "yyyy-MM-dd HH:mm:ss")); hdInfo.setRule_name(filename.replace(".csv", "").replace(".dat", "")); hdInfo.setFile_name(filename); int ret = sysService.InsertHistoryDeployInfo(hdInfo); if (ret != 1) { logger.error("规则派发结果历史入库失败,province=" + entry.getKey() + " filename=" + filename); } } } Logger.info ( "dispatch rule GroupRuleUpload result history storage completion" ); } the catch (Exception E) { logger.error ( "GroupRuleUpload:" + e.getMessage ()); } }