groovy parttion and sql example
def partition(array, size) {
def partitions = []
int partitionCount = array.size() / size
partitionCount.times { partitionNumber ->
def start = partitionNumber * size
def end = start + size - 1
partitions << array[start..end]
}
if (array.size() % size) partitions << array[partitionCount * size..-1]
return partitions
}
import groovy.sql.Sql
def dataSource=__ac.getBean("dataSource")
def popDataSource=__ac.getBean('popDataSource')
def mysql=new Sql(dataSource)
def mysql2=new Sql(popDataSource)
println mysql.firstRow("select count(*) as cnt from target_url where website_id=1 and status=0 or status=-2").cnt
def skus=[]
mysql.eachRow("select sku from target_url where website_id=1 and status=0 or status=-2")
{
skus <<it.sku
}
println skus.size()
partition(skus,1000).each{k->
//println k
def s= k.join(",")
def update_sql= "update opponent_product set available=0 where sku in ('${s}')"
//println update_sql
println mysql2.execute(update_sql)
}相关阅读:
禁止用户打开HTML页面调试
Git 忽略提交 .gitignore
PHP日期时间处理
HTML页面中JavaScript能获取到的各种屏幕大小信息
移动浏览器H5页面通过scheme打开本地应用
Python爬虫利器:Beautiful Soup
MySQL分页查询优化
JavaScrpit中异步请求Ajax实现
PHP反射机制
CentOS下nginx php mysql 环境搭建原文地址:https://www.cnblogs.com/lexus/p/2621932.html
最新文章
20191017_datatable.select() 数据源中没有dataRow
20191012_WMI中可以看到有打印机, 设备管理器中没有
20190904_ 警告 发现同一依赖程序集的不同版本间存在冲突。
20190814_tomcat配置项目的错误页
20190713_(转)IIS上部署MVC网站,打开后ExtensionlessUrlHandler-Integrated-4.0解决办法 (转)
20190713_发布网站的时候报错:无法完成向远程代理 URL 发送请求 基础连接已经关闭 发送时发生错误
20190713_windows 2008 R2在启动网站时报错_另一个程序正在使用此文件,进程无法访问
20190712_mysql执行sql脚本语句_Failed to open file_error
20190705_关于winform程序修改程序名后, 报未将对象引用设置到对象的实例
20190703_创建 unity 的配置节处理程序时出错: The type name or alias Microsoft.Practices.Unity.InterceptionExtension.Configuration.InterceptionConfigurationExtension
热门文章
http和https 握手过程
shell 函数
Ubuntu16.04 install hadoop-2.8.1.tar.gz Cluster Setup
JavaSE
入门: 在Windows上搭建Flutter开发环境
Linux命令的详解
对linux下日志文件error监控
Fiddler抓包工具(捕获Android数据包)
使用unittest测试(基础一)
ADB命令使用详解