zoukankan      html  css  js  c++  java
  • 遍历数据批量导入部分代码

    直奔主题:

    前台页面代码:

            //定义变量存id值
    	var ids = " ";
    	//遍历数据获取id数组元素
    	for(var i = 0; i < rowId.length; i++){
    		if(i == 0){
    			ids = rowId[i]; 
    		}else{
    			ids = ids+ ","+rowId[i]; 
    		}
    	}         
    

    webController层:

    @RequiresPermissions("customer:customer:edit")
    	@RequestMapping(value = "write")
    	@ResponseBody
    	public String write(String ids) {
    		//切割字符串
    		String[] list = ids.split(",");
    		//创建空对象
    		Customer customer = null;
    		//遍历对象
    		for(int i=0; i<list.length; i++) {
    			customer = new Customer();
    			//set整型id
    			customer.setIid(Integer.valueOf(list[i]));
    			//调用接口把id传给对象
    			customer = customerService.get(customer);
    			//需要try cash抛异常
    			try {
    				customerService.write(customer);
    			} catch (RemoteException | ServiceException e) {
    				e.printStackTrace();
    				return renderResult(Global.FALSE, text("客户写入EAS失败!"));
    			}
    		}
    		return renderResult(Global.TRUE, text("客户写入EAS成功!"));
    	}
    

      service层:

    @Transactional(readOnly=false, rollbackFor = Exception.class)
    	public void write(Customer customer) throws RemoteException, ServiceException {
    		//调用对象里面的数据传给接口
    		Result sendCustomerInfo = easService.sendCustomerInfo(customer.getCcuscode(), customer.getCcusname(),
    				customer.getCcusenname(), customer.getCcusabbname(), customer.getCcusaddress(),
    				customer.getCcuslperson());
    		//判断它是否成功
    		if(sendCustomerInfo.isFlag()) {
    			//成功则更改它的状态为Y             主要是更改这部分东西
    			customer.setIsup(CustomerConstant.ISUP_Y);
    			this.update(customer);
    		}else {
    			//抛出异常并且提示错误信息
    			throw new BaseException(sendCustomerInfo.getMessage());
    		}
    	}
    

      

  • 相关阅读:
    基于Windows Mobile 5.0的GPS应用程序开发
    iis6应用程序池被自动禁用问题 应用程序池'DefaultAppPool' 被自动禁用
    Axapta物流模块深度历险(八)
    AX的报表服务器(一)
    AX的企业门户(一)
    SQL Server2005 Reporting Services 管理站点
    SQL Server2005 Reporting Services的卸载
    耐心的解决问题
    危险操作符
    慢慢的坚持啊
  • 原文地址:https://www.cnblogs.com/qijiang123/p/14005704.html
Copyright © 2011-2022 走看看