終端關聯專案

ZHOU_VIP發表於2018-10-11
/**
 * 關聯終端(csv檔案)手動輸入
 * 
 * @param request
 * @param response
 * @return
 */
@RequestMapping("devProjectWithInput")
@ResponseBody
public ClaaAjaxResult devProjectWithInput(HttpServletRequest request, HttpServletResponse response) throws Exception 
{
	ClaaAjaxResult ret = new ClaaAjaxResult();
	String randomStr = Long.toUnsignedString(UUID.randomUUID().getLeastSignificantBits());
	try{		
		String deveuis = request.getParameter("dev_project_gweuis"); // 逗號分隔.
		String projectid = request.getParameter("projectid"); 
		// 在gweui輸入框中批量設定了gwEUI!.
		this.setProgress(randomStr, 1, true, "開始處理關聯終端...");
		List<String> deveuiList = new ArrayList<String>();
		if(deveuis != null && !deveuis.trim().equals("")){
			String[] gwEuiArr = deveuis.trim().split(",");
			for(String gweui : gwEuiArr){
				if(gweui == null || gweui.trim().equals("")){
					continue;
				}
				if(deveuiList.contains(gweui.trim())){
					continue;
				}
				deveuiList.add(gweui.trim());
			}
		} 
		if(deveuiList.size() == 0){
			this.setProgress(randomStr, 100, true, "沒有待關聯的終端!");
			ret.setRetCode(ClaaAjaxResult.RET_CODE_OK);
			ret.setRetRemark("沒有待關聯的終端!");
			return ret;
		}
		
		OsmDev osmDev = new OsmDev();
		osmDev.setProjectid(projectid);
		this.modifyOsmDevs(osmDev, randomStr, deveuiList);	
		
		ret.setRetCode(ClaaAjaxResult.RET_CODE_OK);
		// 將隨機數返回,用於後續批量匯入進度查詢。
		ret.setRetRemark(randomStr);
	}catch(Exception ex){
		ret.setRetCode(ClaaAjaxResult.RET_CODE_ERR);
		ret.setRetRemark(ex.getMessage());
		this.setProgress(randomStr, 100, false, ex.getMessage());
	}
	this.addOpLog(ret, MODULE_NAME, "批量遷移閘道器", "遷移請求提交", "請求批次編號:"+randomStr);
	return ret;
}

 

相關文章