标签:created int 查询 condition ids line isp convert obj
MongoTemplate mongoTemplate = mongodbClient.getMongoTemplate(); DBCollection cursor = mongoTemplate.getCollection("vip_batchsend_message"); BasicDBObject query = new BasicDBObject(); query.put("sms_code", sms_code); query.put("open_id", open_id); JSONObject message = new JSONObject(); DBCursor cursor1 = cursor.find(query); LOGGER.info("-------------sms_code:" + sms_code + "----open_id:" + open_id + "--" + cursor1.size()); if (cursor1.size() > 0) { DBObject dBObject = cursor1.next(); String corp_code = dBObject.get("corp_code").toString(); .....
BasicDBObject query = new BasicDBObject(); query.put("sms_code", sms_code); query.put("open_id", open_id); MongoTemplate mongoTemplate = mongodbClient.getMongoTemplate(); JSONObject message = new JSONObject(); DBCollection cursor = mongoTemplate.getCollection("vip_batchsend_message"); DBObject dbObject = cursor.findOne(query); if (dbObject.isPartialObject()) { LOGGER.info("-------------sms_code:" + sms_code + "----open_id:" + open_id + "--" + 1); String corp_code = dbObject.get("corp_code").toString(); String vip_id = dbObject.get("vip_id").toString(); Data data_corp_code = new Data("corp_code", corp_code, ValueType.PARAM); Data data_vip_id = new Data("vip_ids", vip_id, ValueType.PARAM); ......
public DBCursor selectRelation(String app_user_name, String open_id) throws SQLException { MongoTemplate mongoTemplate = mongodbClient.getMongoTemplate(); DBCollection cursor = mongoTemplate.getCollection(WxConst.table_vip_emp_relation); Map keyMap = new HashMap(); keyMap.put("_id", app_user_name + open_id); BasicDBObject queryCondition = new BasicDBObject(); queryCondition.putAll(keyMap); DBCursor dbCursor = cursor.find(queryCondition); return dbCursor; }
简单阐述
建议修改
public DBObject selectRelation(String app_user_name, String open_id) throws SQLException { Map keyMap = new HashMap(); keyMap.put("_id", app_user_name + open_id); BasicDBObject queryCondition = new BasicDBObject(); queryCondition.putAll(keyMap); MongoTemplate mongoTemplate = mongodbClient.getMongoTemplate(); DBCollection cursor = mongoTemplate.getCollection(WxConst.table_vip_emp_relation); DBObject dbCursor = cursor.findOne(queryCondition); return dbCursor; }
BasicDBObject basicDBObject=new BasicDBObject(); basicDBObject.put("activity_code",activity_code); basicDBObject.put("open_id",open_id); basicDBObject.put("status","1"); int count=cursor.find(basicDBObject).count(); basicDBObject.put("sign_status","Y"); int sign_count=cursor.find(basicDBObject).count(); if(sign_count>0){ result="您已签到成功,请勿重复签到"; }else { if (count > 0) { BasicDBObject query=new BasicDBObject(); query.put("activity_code",activity_code); query.put("open_id",open_id); ......
简单阐述
建议修改
BasicDBObject basicDBObject=new BasicDBObject(); basicDBObject.put("activity_code",activity_code); basicDBObject.put("open_id",open_id); basicDBObject.put("status","1"); Long count=cursor.count(basicDBObject); basicDBObject.put("sign_status","Y"); Long sign_count=cursor.count(basicDBObject); if(sign_count>0){ result="您已签到成功,请勿重复签到"; }else { if (count > 0) { BasicDBObject query=new BasicDBObject(); query.put("activity_code",activity_code); query.put("open_id",open_id); ......
if (cursor.find(basicDBObject).count() > 0){ BasicDBObject basicDBObject1=new BasicDBObject(); basicDBObject1.put("sign_status","Y"); basicDBObject1.put("sign_date",Common.DATETIME_FORMAT.format(new Date())); BasicDBObject update=new BasicDBObject(); update.put("$set",basicDBObject1); cursor.update(basicDBObj,update,true,false); }else { BasicDBObject dbObject = new BasicDBObject(); dbObject.put("_id", app_id + "_" + activity_code + "_" + open_id); dbObject.put("corp_code", corp_code); dbObject.put("sign_status","Y"); dbObject.put("sign_date",Common.DATETIME_FORMAT.format(new Date())); dbObject.put("app_id", app_id); dbObject.put("activity_code", activity_code); dbObject.put("status", "0"); dbObject.put("open_id", open_id); dbObject.put("vip", vip_array.getJSONObject(0)); dbObject.put("modified_date", Common.DATETIME_FORMAT.format(new Date())); dbObject.put("created_date", Common.DATETIME_FORMAT.format(new Date())); cursor.save(dbObject); } ......
简单阐述
建议修改
if (cursor.find(basicDBObject).count() > 0){ BasicDBObject basicDBObject1=new BasicDBObject(); basicDBObject1.put("sign_status","Y"); basicDBObject1.put("sign_date",Common.DATETIME_FORMAT.format(new Date())); BasicDBObject update=new BasicDBObject(); update.put("$set",basicDBObject1); cursor.update(basicDBObj,update,true,false); }else { BasicDBObject dbObject = new BasicDBObject(); dbObject.put("_id", app_id + "_" + activity_code + "_" + open_id); dbObject.put("corp_code", corp_code); dbObject.put("sign_status","Y"); dbObject.put("sign_date",Common.DATETIME_FORMAT.format(new Date())); dbObject.put("app_id", app_id); dbObject.put("activity_code", activity_code); dbObject.put("status", "0"); dbObject.put("open_id", open_id); dbObject.put("vip", vip_array.getJSONObject(0)); dbObject.put("modified_date", Common.DATETIME_FORMAT.format(new Date())); dbObject.put("created_date", Common.DATETIME_FORMAT.format(new Date())); cursor.insert(dbObject); } ......
标签:created int 查询 condition ids line isp convert obj
原文地址:https://www.cnblogs.com/lzh-boy/p/9037053.html