添加月度均价定时任务

This commit is contained in:
王文艳
2026-06-18 15:28:10 +08:00
parent 7eb3b10b56
commit 23d26b75f8
@@ -41,48 +41,48 @@ class DistrictSellStatBatch extends BaseBatch {
@Override
void process(Object args) {
// def months = DateUtils.getMonthList(202510)
// months = months[0..(months.size()-1)]
// println months
// for(def month : months){
// def curDate = DateUtils.parseFromTightByPattern(month.toString()+"01", "yyyyMMdd")
// calcMonthlyPrice(curDate)
// }
def date = new Date()
def day = date.getDate()
def hours = date.getHours()
if(day == 2 && hours<7){
calcMonthlyPrice() //正常算一期
}else{
//根据calc_type算历史
def q = new BasicDBObject("category" ,"sell_month")
def commands = COMMAND_COLL.find(q)
println "共 【"+commands.size()+"】 个小区重算 "+new Date()
for(def command : commands){
def calc_type = command.calc_type
def id = command._id
if(calc_type==1){
//找出第一次均价计算的时间
def obj = CommonDatautils.queryFirstOrLastDistrictPrice(command.city, command.region, command.name, 1)
if(obj){
def weekend = obj.weekend
def startMonth = DateUtils.formatDateByPattern(weekend, "yyyyMM").toInteger()
def months = DateUtils.getMonthList(startMonth)
if(months.size()>1){
months = months[1..(months.size()-1)]
println months
for(def month : months){
def curDate = DateUtils.parseFromTightByPattern(month.toString()+"01", "yyyyMMdd")
calcMonthlyPriceByName(curDate, command.city, command.region, command.name)
}
//删除命令
COMMAND_COLL.remove(new BasicDBObject("_id", id))
}
}
}
}
def months = DateUtils.getMonthList(202606)
months = months[0..(months.size()-1)]
println months
for(def month : months){
def curDate = DateUtils.parseFromTightByPattern(month.toString()+"01", "yyyyMMdd")
calcMonthlyPrice(curDate)
}
// def date = new Date()
// def day = date.getDate()
// def hours = date.getHours()
// if(day == 2 && hours<7){
// calcMonthlyPrice() //正常算一期
// }else{
// //根据calc_type算历史
// def q = new BasicDBObject("category" ,"sell_month")
// def commands = COMMAND_COLL.find(q)
// println "共 【"+commands.size()+"】 个小区重算 "+new Date()
// for(def command : commands){
// def calc_type = command.calc_type
// def id = command._id
// if(calc_type==1){
// //找出第一次均价计算的时间
// def obj = CommonDatautils.queryFirstOrLastDistrictPrice(command.city, command.region, command.name, 1)
// if(obj){
// def weekend = obj.weekend
// def startMonth = DateUtils.formatDateByPattern(weekend, "yyyyMM").toInteger()
// def months = DateUtils.getMonthList(startMonth)
// if(months.size()>1){
// months = months[1..(months.size()-1)]
// println months
// for(def month : months){
// def curDate = DateUtils.parseFromTightByPattern(month.toString()+"01", "yyyyMMdd")
// calcMonthlyPriceByName(curDate, command.city, command.region, command.name)
// }
// //删除命令
// COMMAND_COLL.remove(new BasicDBObject("_id", id))
// }
// }
// }
// }
// }
}