List of usage examples for com.mongodb DBObject put
Object put(String key, Object v);
From source file:com.cc.manage.logic.BcompanyapplyLogic.java
/** * ???/* w w w.j a v a 2 s . c o m*/ * * @param request ?? * @return * @author Ron(modify 2014.10.17) */ public JSONObject list(HttpServletRequest request) { DBObject conditionBean = new BasicDBObject(); // ? String inputname = RequestUtils.getString(request, "inputname"); String state = RequestUtils.getString(request, "state"); // ? BasicDBList values = new BasicDBList(); if (StringUtils.isNotBlank(inputname)) { Pattern pattern = Pattern.compile("^.*" + inputname + ".*$", Pattern.CASE_INSENSITIVE);// ? values.add(new BasicDBObject("name", pattern)); values.add(new BasicDBObject("contacts", pattern)); conditionBean.put("$or", values); } if (StringUtils.isNotBlank(state)) { if (StringUtils.equals(state, "exists")) { // ???? conditionBean.put("state", new BasicDBObject("$exists", false)); } else { conditionBean.put("state", state); } } // ? long count = companyapplyDao.count(TableNameConstant.T_COMPANY_APPLY, conditionBean); if (count <= 0) { return null; } // ? ?? String sortOrder = RequestUtils.getString(request, "sortOrder"); DBObject orderBy = new BasicDBObject(); if (StringUtils.isNotBlank(sortOrder)) {// StringInt orderBy.put(RequestUtils.getString(request, "sortField"), StringUtils.setOrder(sortOrder)); } else { orderBy.put("_id", StringUtils.setOrder("1")); } DBObject field = new BasicDBObject(); List<DBObject> dbList = companyapplyDao.list(TableNameConstant.T_COMPANY_APPLY, conditionBean, field, orderBy, RequestUtils.getInt(request, "pageIndex") + 1, RequestUtils.getInt(request, "pageSize")); // ?? Map<String, JSONObject> industryMap = this.ccIndustryinfoLogic.getIndustryInfoMap(); // Map<String, DBObject> areaMap = ccAreaLogic.getAreaMap(); for (int i = 0; i < dbList.size(); i++) { DBObject dbobject = dbList.get(i); // ?id?? if (CollectionUtils.isNotEmpty(industryMap)) { dbobject.put("industryName", JSONUtils.getString(industryMap.get(dbobject.get("industryuuid")), "name")); } // if (CollectionUtils.isNotEmpty(areaMap)) { dbobject.put("areaName", DBObejctUtils.getString(areaMap.get(dbobject.get("areauuid")), "name")); } } JSONObject resultBean = new JSONObject(); JSONArray json = JSONUtils.resertJSON(dbList);// _id resultBean.put("data", json.toString()); resultBean.put("total", count); return resultBean; }
From source file:com.cc.manage.logic.BcompanyapplyLogic.java
/** * ????// w w w . j a v a 2 s . c om * * @param request ??? * @return */ public String add(HttpServletRequest request) { DBObject conditionBean = new BasicDBObject(); String data = RequestUtils.getString(request, "data"); if (StringUtils.isNotBlank(data)) { JSONObject jsonBean = JSONObject.fromObject(data); // ???? String id = JSONUtils.getString(jsonBean, "id"); String remark = JSONUtils.getString(jsonBean, "remark"); // if (StringUtils.isBlank(id)) { // ? DBObject conditionBeannew = this.addBean(jsonBean); companyapplyDao.add(conditionBeannew); ObjectId objectId = (ObjectId) conditionBeannew.get("_id"); if (objectId != null) { // ? conditionBean.put("_id", objectId); HistoryUtils.saveHistory(remark, request, TableNameConstant.T_COMPANY_APPLY, conditionBean); return ResultConstant.SUCCESS; } else { return ResultConstant.FAIL; } } // else { DBObject conditionBeannew = this.addBean(jsonBean); conditionBean.put("_id", new ObjectId(id)); companyapplyDao.update(conditionBean, conditionBeannew); // ?? HistoryUtils.saveHistory(remark, request, TableNameConstant.T_COMPANY_APPLY, conditionBean); return ResultConstant.SUCCESS; } } return ResultConstant.FAIL; }
From source file:com.cc.manage.logic.BcompanyapplyLogic.java
/**** * ????DBObject//from w ww . j a va 2s . co m * * @param jsonBean * @return DBObject */ public DBObject addBean(JSONObject jsonBean) { DBObject conditionBeannew = new BasicDBObject(); conditionBeannew.put("license", JSONUtils.getString(jsonBean, "license")); conditionBeannew.put("name", JSONUtils.getString(jsonBean, "name")); conditionBeannew.put("street", JSONUtils.getString(jsonBean, "street")); conditionBeannew.put("contacts", JSONUtils.getString(jsonBean, "contacts")); conditionBeannew.put("phone", JSONUtils.getString(jsonBean, "phone")); conditionBeannew.put("email", JSONUtils.getString(jsonBean, "email")); conditionBeannew.put("industryuuid", JSONUtils.getString(jsonBean, "industryuuid")); conditionBeannew.put("areauuid", JSONUtils.getString(jsonBean, "areauuid")); conditionBeannew.put("ipAddress", JSONUtils.getString(jsonBean, "ipAddress")); conditionBeannew.put("port", JSONUtils.getString(jsonBean, "port")); conditionBeannew.put("createtime", new Date()); DBObject addressBean = new BasicDBObject(); addressBean.put("country", ""); addressBean.put("province", ""); addressBean.put("city", ""); addressBean.put("county", ""); conditionBeannew.put("address", addressBean); return conditionBeannew; }
From source file:com.cc.manage.logic.BcompanyapplyLogic.java
/** * ?id??//www . j a v a 2 s .c o m * * @param conditionBean ?id * @return */ public JSONArray query(HttpServletRequest request) { DBObject conditionBean = new BasicDBObject(); String id = RequestUtils.getString(request, "id"); String flowid = RequestUtils.getString(request, "flowid"); if (StringUtils.isNotBlank(id)) { conditionBean.put("_id", new ObjectId(id)); } if (StringUtils.isNotBlank(flowid)) { conditionBean.put("flowid", flowid); } // ?id List<DBObject> companyapply = companyapplyDao.find(TableNameConstant.T_COMPANY_APPLY, conditionBean); JSONArray json = JSONUtils.resertJSON(companyapply); return json; }
From source file:com.cc.manage.logic.BcompanyapplyLogic.java
/** * ???//from w w w . j a v a 2s. c om * * @param request * @return */ public String apply(HttpServletRequest request) { // ???id?0 String id = RequestUtils.getString(request, "id"); if (StringUtils.isNotBlank(id)) { String[] arr = id.split(AplicationKeyConstant.STRING_SPLIT_CHAR); DBObject conditionBean = new BasicDBObject(); DBObject conditionBeannew = new BasicDBObject(); for (int i = 0; i < arr.length; i++) { conditionBean.put("_id", new ObjectId(arr[i])); conditionBeannew.put("state", StateConstant.B_COMPANY_APPLY_STATE0); companyapplyDao.update(conditionBean, conditionBeannew); HistoryUtils.saveHistory("??", request, TableNameConstant.T_COMPANY_APPLY, conditionBean); } return ResultConstant.SUCCESS; } return ResultConstant.FAIL; }
From source file:com.cc.manage.logic.BcompanyapplyLogic.java
/** * superuser?//from ww w. ja v a2 s. com * * @param request */ public String supercheck(HttpServletRequest request) { // ???id?1 String id = RequestUtils.getString(request, "id"); if (StringUtils.isNotBlank(id)) { try { String arr[] = StringUtils.stringToArray(id, AplicationKeyConstant.STRING_SPLIT_CHAR); List<DBObject> dblist = new ArrayList<DBObject>(); DBObject conditionBean = new BasicDBObject(); DBObject conditionBeannew = new BasicDBObject(); for (String _id : arr) { // ?id?1 conditionBean.put("_id", new ObjectId(_id)); conditionBeannew.put("state", StateConstant.B_COMPANY_APPLY_STATE1); companyapplyDao.update(conditionBean, conditionBeannew); HistoryUtils.saveHistory("", request, TableNameConstant.T_COMPANY_APPLY, conditionBean); // ?? List<DBObject> dbobject = companyapplyDao.find(TableNameConstant.T_COMPANY_APPLY, conditionBean); DBObject object = dbobject.get(0); object.put("companyno", String.valueOf(System.nanoTime())); DBObject stateBean = new BasicDBObject(); stateBean.put("frame", StateConstant.B_COMPANY_UNALLOCAT); stateBean.put("role", StateConstant.B_COMPANY_UNALLOCAT); stateBean.put("product", StateConstant.B_COMPANY_UNALLOCAT); stateBean.put("companycc", StateConstant.B_COMPANY_UNALLOCAT); object.put("state", stateBean); object.removeField("_id"); object.removeField("history"); dblist.add(object); } companyDao.addBatch(dblist);// ??? return ResultConstant.SUCCESS; } catch (Exception e) { log.error(e.getLocalizedMessage(), e); } } return ResultConstant.FAIL; }
From source file:com.cc.manage.logic.BcompanyapplyLogic.java
/** * ?/*from w w w .j a v a 2 s.c om*/ * * @param request */ public void editHistory(HttpServletRequest request) { String data = RequestUtils.getString(request, "data"); if (StringUtils.isNotBlank(data)) { JSONObject jsonBean = JSONObject.fromObject(data); // ?id? String id = JSONUtils.getString(jsonBean, "id"); String remark = JSONUtils.getString(jsonBean, "remark"); DBObject conditionBean = new BasicDBObject(); conditionBean.put("_id", new ObjectId(id)); HistoryUtils.saveHistory(remark, request, TableNameConstant.T_COMPANY_APPLY, conditionBean); } }
From source file:com.cc.manage.logic.BcompanyapplyLogic.java
/** * ?/*from ww w . j a va2 s. c o m*/ * * @param conditionBean ???? * @param byname ? * @return */ public JSONObject history(HttpServletRequest request) { DBObject conditionBean = new BasicDBObject(); String id = RequestUtils.getString(request, "id"); if (StringUtils.isNotBlank(id)) { conditionBean.put("_id", new ObjectId(id)); } List<DBObject> List = new ArrayList<DBObject>(); List<DBObject> dblist = companyapplyDao.find(TableNameConstant.T_COMPANY_APPLY, conditionBean); for (int i = 0; i < dblist.size(); i++) { @SuppressWarnings("unchecked") List<DBObject> histroyList = (List<DBObject>) dblist.get(i).get("history"); for (int j = 0; j < histroyList.size(); j++) { DBObject history = histroyList.get(j); List.add(history); } } JSONObject jo = new JSONObject(); jo.put("data", List.toString()); jo.put("total", List.size()); return jo; }
From source file:com.cc.manage.logic.BcompanyapplyLogic.java
/** * ??// w ww . ja v a 2 s . c o m * * @return */ public String submit(HttpServletRequest request) { String id = RequestUtils.getString(request, "data"); String submitno = RequestUtils.getString(request, "usercode");// ???actno? String code = RequestUtils.getString(request, "code");// ???actno? String key = RequestUtils.getString(request, "key");// if (StringUtils.isNotBlank(id)) { // ?? JSONObject userSession = JSONObject .fromObject(request.getSession().getAttribute(SessionKey.SESSION_KEY_USER)); String uuid = JSONUtils.getString(userSession, "uuid"); JSONObject joBean = new JSONObject(); joBean.put("uuid", uuid); joBean.put("submitno", submitno); joBean.put("content", "?"); joBean.put("sub", code); joBean.put("key", key); // ?? String[] result = AuditUtils.register(joBean); DBObject conditionBean = new BasicDBObject(); if (ResultConstant.SUCCESS.equals(result[0])) { DBObject insertBean = new BasicDBObject(); insertBean.put("flowid", result[1]); if (StringUtils.isNotBlank(id)) { String[] arr = id.split(AplicationKeyConstant.STRING_SPLIT_CHAR); for (int i = 0; i < arr.length; i++) { conditionBean.put("_id", new ObjectId(arr[i])); insertBean.put("state", StateConstant.B_COMPANY_APPLY_STATE0);// companyapplyDao.update(conditionBean, insertBean); HistoryUtils.saveHistory("??", request, TableNameConstant.T_COMPANY_APPLY, conditionBean); } return ResultConstant.SUCCESS; } } } return ResultConstant.FAIL; }
From source file:com.cc.manage.logic.BcompanyapplyLogic.java
/** * ?//w w w . j a va 2s . c o m * * @param request * @return */ public JSONObject getDetailInfo(HttpServletRequest request) { DBObject conditionBean = new BasicDBObject(); String table = RequestUtils.getString(request, "table"); List<DBObject> List = new ArrayList<DBObject>(); String scheduleList = this.scheduleList(request); if (StringUtils.isNotBlank(scheduleList)) { // ? JSONArray json = JSONArray.fromObject(scheduleList); for (int i = 0; i < json.size(); i++) { JSONObject obj = json.getJSONObject(i); // ?????? conditionBean.put("flowid", JSONUtils.getString(obj, "flowno")); Object checks = commonDaoImpl.searchCommon(table, conditionBean);// b_companyapply if (checks != null) { JSONArray jsonarray = JSONArray.fromObject(checks); for (int j = 0; j < jsonarray.size(); j++) { JSONObject jo = jsonarray.getJSONObject(j); String objString = jo.toString().substring(1, jo.toString().length() - 1);// {}? // ??? String newString = obj.toString().substring(0, obj.toString().length() - 1) + AplicationKeyConstant.STRING_SPLIT_CHAR + objString + obj.toString().substring(obj.toString().length() - 1, obj.toString().length()); // StringDBobject DBObject object = (DBObject) JSON.parse(newString); List.add(object); } } } JSONObject resultBean = new JSONObject(); JSONArray jsons = JSONUtils.resertJSON(List);// _id resultBean.put("data", jsons.toString()); resultBean.put("total", jsons.size()); return resultBean; } return null; }