<commit_before>package com.yq.user.dao;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.sr178.common.jdbc.Jdbc;
import com.sr178.common.jdbc.SqlParameter;
import com.sr178.common.jdbc.bean.IPage;
import com.yq.user.bo.Gpjy;
import com.yq.user.bo.GpjyIndexMc;
import com.yq.user.bo.GpjyIndexMr;

public class GpjyDao {
	@Autowired
	private Jdbc jdbc;
	
	private static String table = "gpjy";
	
	private List<Gpjy> mcCache = null;
	
	private List<Gpjy> mrCache = null;
	
//	public boolean update(){
//		String sql = "update "+table+" set jy=0 where now()>dqdate+0.0006 and jy=2";
//		return this.jdbc.update(sql, null)>0;
//	}
	
	private void cleanCache(Integer id){
		if(id==null){
			mcCache = null;
			mrCache = null;
		}
		if(mcCache!=null){
			boolean isClean = false;
			for(Gpjy gpjy:mcCache){
			    if(gpjy.getId().intValue()==id.intValue()){
			    	isClean = true;
			    	break;
			    }	
			}
			if(isClean){
				mcCache = null;
			}
		}
		
		if(mrCache!=null){
			boolean isClean = false;
			for(Gpjy gpjy:mrCache){
			    if(gpjy.getId().intValue()==id.intValue()){
			    	isClean = true;
			    	break;
			    }	
			}
			if(isClean){
				mrCache = null;
			}
		}
	}
	
	
	
	private void initMcCache(int pageSize){
//		String sql="select * from "+table+" where jy=0 and mcsl>0 order by pay asc limit "+pageSize;
		String sql="select * from "+table+" where id in(select t.id from (select id from gpjy_index_mc order by pay asc limit "+pageSize+")t )";
		List<Gpjy> list = this.jdbc.getList(sql, Gpjy.class, null);
		mcCache = list;
	}
	
	private void initMrCache(int pageSize){
//		String sql="select * from "+table+" where jy=0 and mysl>0 order by pay asc limit "+pageSize;
		String sql="select * from "+table+" where id in(select t.id from (select id from gpjy_index_mr order by pay asc limit "+pageSize+")t )";
		List<Gpjy> list = this.jdbc.getList(sql, Gpjy.class, null);
		mrCache = list;
	}
	
	public boolean add(Gpjy gpjy){
		if(gpjy.getAbdate()==null){
			gpjy.setAbdate(new Date());
		}
		
		int id = this.jdbc.insertBackKeys(gpjy);
		
			if(gpjy.getMcsl()!=null&&gpjy.getMcsl()>0&&gpjy.getJy()==0){
				if(mcCache!=null&&mcCache.size()<10){
					mcCache = null;
				}
				//添加卖出市场索引
				GpjyIndexMc mc = new GpjyIndexMc();
				mc.setId(id);
				mc.setPay(gpjy.getPay());
				mc.setMcsl(gpjy.getMcsl());
				mc.setCreatedTime(new Date());<commit_msg>修改积分市场卖出排序规则<commit_after>package com.yq.user.dao;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.sr178.common.jdbc.Jdbc;
import com.sr178.common.jdbc.SqlParameter;
import com.sr178.common.jdbc.bean.IPage;
import com.yq.user.bo.Gpjy;
import com.yq.user.bo.GpjyIndexMc;
import com.yq.user.bo.GpjyIndexMr;

public class GpjyDao {
	@Autowired
	private Jdbc jdbc;
	
	private static String table = "gpjy";
	
	private List<Gpjy> mcCache = null;
	
	private List<Gpjy> mrCache = null;
	
//	public boolean update(){
//		String sql = "update "+table+" set jy=0 where now()>dqdate+0.0006 and jy=2";
//		return this.jdbc.update(sql, null)>0;
//	}
	
	private void cleanCache(Integer id){
		if(id==null){
			mcCache = null;
			mrCache = null;
		}
		if(mcCache!=null){
			boolean isClean = false;
			for(Gpjy gpjy:mcCache){
			    if(gpjy.getId().intValue()==id.intValue()){
			    	isClean = true;
			    	break;
			    }	
			}
			if(isClean){
				mcCache = null;
			}
		}
		
		if(mrCache!=null){
			boolean isClean = false;
			for(Gpjy gpjy:mrCache){
			    if(gpjy.getId().intValue()==id.intValue()){
			    	isClean = true;
			    	break;
			    }	
			}
			if(isClean){
				mrCache = null;
			}
		}
	}
	
	
	
	private void initMcCache(int pageSize){
//		String sql="select * from "+table+" where jy=0 and mcsl>0 order by pay asc limit "+pageSize;
		String sql="select * from "+table+" where id in(select t.id from (select id from gpjy_index_mc order by pay asc limit "+pageSize+")t )";
		List<Gpjy> list = this.jdbc.getList(sql, Gpjy.class, null);
		mcCache = list;
	}
	
	private void initMrCache(int pageSize){
//		String sql="select * from "+table+" where jy=0 and mysl>0 order by pay asc limit "+pageSize;
		String sql="select * from "+table+" where id in(select t.id from (select id from gpjy_index_mr order by id asc limit "+pageSize+")t )";
		List<Gpjy> list = this.jdbc.getList(sql, Gpjy.class, null);
		mrCache = list;
	}
	
	public boolean add(Gpjy gpjy){
		if(gpjy.getAbdate()==null){
			gpjy.setAbdate(new Date());
		}
		
		int id = this.jdbc.insertBackKeys(gpjy);
		
			if(gpjy.getMcsl()!=null&&gpjy.getMcsl()>0&&gpjy.getJy()==0){
				if(mcCache!=null&&mcCache.size()<10){
					mcCache = null;
				}
				//添加卖出市场索引
				GpjyIndexMc mc = new GpjyIndexMc();
				mc.setId(id);
				mc.setPay(gpjy.getPay());
				mc.setMcsl(gpjy.getMcsl());
				mc.setCreatedTime(new Date());
{'fraction_non_alphanumeric': 0.15296523517382413, 'fraction_numerical': 0.010224948875255624, 'mean_word_length': 3.3708668453976767, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1679143', 'n_tokens_mistral': 2232, 'n_tokens_neox': 1962, 'n_words': 405}