// region Get e Set Values private void SetValues(Negocio item) { TextView cliente = (TextView) findViewById(R.id.negocioDetailCliente); TextView nome = (TextView) findViewById(R.id.negocioDetailNome); TextView endereco = (TextView) findViewById(R.id.negocioDetailEndereco); TextView criacao = (TextView) findViewById(R.id.negocioDetalhesDataCriacao); TextView termino = (TextView) findViewById(R.id.negocioDetalhesTxtDataTermino); nome.setText(item.getNeg_vnome()); cliente.setText(item.getNeg_vcliente()); endereco.setText(item.getNeg_vendereco()); criacao.setText(DateUtil.dateToString(negocio.getNeg_dcadastro())); termino.setText(DateUtil.dateToString(negocio.getNeg_dtermino())); if (item.getNeg_ctipo() == NegocioTipo.Orcamento) { setTitle(R.string.Orcamento); TextView header = (TextView) findViewById(R.id.negocioDetalhesTxtHeader); header.setText(R.string.Orcamento); if (item.getNeg_cstatus() == NegocioStatus.ABERTO) { Button btnCriarNegocio = (Button) findViewById(R.id.negocioDetalhesBtnCriarNegocio); btnCriarNegocio.setVisibility(View.VISIBLE); termino.setVisibility(View.GONE); TextView terminoLabel = (TextView) findViewById(R.id.negocioDetalhestxtDataTerminoLabel); terminoLabel.setVisibility(View.GONE); } } else { setTitle(R.string.Negocio); if (item.getNeg_parent() != null && item.getNeg_parent().getNeg_codigo() != 0) { // /tem orçamento new PegaValorTotalOrcamento().execute(item.getNeg_parent()); LinearLayout layout = (LinearLayout) findViewById(R.id.negocioDetalhesLayoutComparacao); layout.setVisibility(View.VISIBLE); } } }
@RequestMapping("updateMessage") public String updateProduct( String ctime_es, String utime_es, String btime_es, String etime_es, Message message, HttpServletRequest request) { message.setCtime(DateUtil.getDateFromStr(ctime_es, "yyyy-MM-dd hh:mm:ss")); message.setUtime(DateUtil.getDateFromStr(utime_es, "yyyy-MM-dd hh:mm:ss")); message.setBtime(DateUtil.getDateFromStr(btime_es, "yyyy-MM-dd hh:mm:ss")); message.setEtime(DateUtil.getDateFromStr(etime_es, "yyyy-MM-dd hh:mm:ss")); messageService.update(message); return "redirect:message.html"; }
private Vector<String> toVector(IncomeVO vo) { Vector<String> str = new Vector<String>(); str.add(vo.kdyID); str.add(vo.income + ""); str.add(DateUtil.dateToString(vo.date)); return str; }
@Override public void run() { logger.info("begin to consume tweets"); controller.running(); while (true) { susSem.acquireUninterruptibly(); try { for (Entry<String, List<Status>> topicData : consumer.nextStatus().entrySet()) { try { // 在高速转发的情况下,这样可以减轻写入到kafka中的状态数据 Map<String, TimeSeriesUpdateState> states = new HashMap<String, TimeSeriesUpdateState>(); List<TimeSeriesUpdateState> segSignal = new ArrayList<TimeSeriesUpdateState>(); for (Status cur : topicData.getValue()) { tweetDao.putTweet(cur); if (cur.getRetweetedStatus() != null) { // rand.nextFloat() < 0.01 && if (tweetDao.getStatusByMid(cur.getRetweetedStatus().getMid()) == null) { tweetDao.putTweet(cur.getRetweetedStatus()); } tweetDao.putRtweet(cur); for (TimeSeriesUpdateState state : tweetDao.updateRtTimeSeries(cur)) { states.put(state.getMid(), state); } } else { // maybe it is the first tweet or an indication // for end of monitoring if (cur.getMid() != null) { SegState state = segDao.getSegState(cur.getMid()); if (state != null) { long updateDate = DateUtil.roundByHour(System.currentTimeMillis()); segSignal.add(new TimeSeriesUpdateState(state.mid, updateDate, true)); List<String> mids = tweetDao.getRtMids(state.mid); for (String rtMid : mids) { segSignal.add(new TimeSeriesUpdateState(rtMid, updateDate, true)); } } } } } for (TimeSeriesUpdateState state : segSignal) { states.put(state.mid, state); } for (TimeSeriesUpdateState state : states.values()) { logger.info("update time series " + state); producer.storeTsUpdateState(state); } } catch (Exception ex) { ex.printStackTrace(); } } } finally { susSem.release(); } } }
@RequestMapping("updateUser") public String updateProduct( String ctime_es, String utime_es, String btime_es, String etime_es, String logtime_es, String birthday_es, User user, HttpServletRequest request) { user.setCtime(DateUtil.getDateFromStr(ctime_es, "yyyy-MM-dd hh:mm:ss")); user.setUtime(DateUtil.getDateFromStr(utime_es, "yyyy-MM-dd hh:mm:ss")); user.setBtime(new Date()); user.setEtime(new Date()); user.setLogtime(DateUtil.getDateFromStr(logtime_es, "yyyy-MM-dd hh:mm:ss")); user.setBirthday(DateUtil.getDateFromStr(birthday_es, "yyyy-MM-dd")); baseService.update(user); return "redirect:user.html"; }
@RequestMapping("saveMessage") public String saveMessage( String ctime_as, String utime_as, String btime_as, String etime_as, Message message, HttpServletRequest request) { message.setCtime(DateUtil.getDateFromStr(ctime_as, "yyyy-MM-dd hh:mm:ss")); message.setUtime(DateUtil.getDateFromStr(utime_as, "yyyy-MM-dd hh:mm:ss")); message.setBtime(DateUtil.getDateFromStr(btime_as, "yyyy-MM-dd hh:mm:ss")); message.setEtime(DateUtil.getDateFromStr(etime_as, "yyyy-MM-dd hh:mm:ss")); if (message.getSsid() == null || message.getSsid() == 0) message.setSsid(messageService.getMaxSsid("Message") + 1); messageService.save(message); return "redirect:message.html"; }
@RequestMapping("saveUser") public String saveUser( String ctime_as, String utime_as, String btime_as, String etime_as, String logtime_as, String birthday_as, User user, HttpServletRequest request) { user.setCtime(DateUtil.getDateFromStr(ctime_as, "yyyy-MM-dd hh:mm:ss")); user.setUtime(DateUtil.getDateFromStr(utime_as, "yyyy-MM-dd hh:mm:ss")); user.setBtime(new Date()); user.setEtime(new Date()); user.setLogtime(DateUtil.getDateFromStr(logtime_as, "yyyy-MM-dd hh:mm:ss")); user.setBirthday(DateUtil.getDateFromStr(birthday_as, "yyyy-MM-dd")); if (user.getSsid() == null || user.getSsid() == 0) user.setSsid(userService.getMaxSsid("User") + 1); baseService.save(user); return "redirect:user.html"; }
@Override protected void onPostExecute(String valor) { super.onPostExecute(valor); Dialog.CancelProgressDialog(); if (valor.equals("0")) // deu erro Dialog.ShowAlertError(NegocioActivityDetalhes.this); else { Negocio ng = new Negocio(); ng.setNeg_cstatus(NegocioStatus.CONCLUIDO); ng.setNeg_codigo(negocio.getNeg_codigo()); negocio.setNeg_parent(ng); negocio.setNeg_codigo(Integer.parseInt(valor)); negocio.setNeg_ctipo(NegocioTipo.Negocio); negocio.setNeg_dcadastro(DateUtil.GetDate()); Intent i = new Intent(NegocioActivityDetalhes.this, NegocioActivityDetalhes.class); i.putExtra("NEGOCIO", negocio); i.putExtra("NOVO_NEGOCIO", true); startActivity(i); finish(); } }
public void cadastrarVoo() { System.out.println("Selecione o Avião para realizar esse Vôo: "); new UIaviao(avioes).mostrarAvioes(); int codigo = Console.scanInt("Digite o CODIGO do avião que voará:"); if (avioes.aviaoExiste(codigo)) { Aviao aviao = avioes.buscaAviao(codigo); Date horaDoVoo = null; boolean dataValida; do { try { String dataHora = Console.scanString("Digite a data e o horário do Vôo (dd/mm/aaaa hh:mm):"); horaDoVoo = DateUtil.stringToDateHour(dataHora); dataValida = true; } catch (ParseException ex) { System.out.println("Data ou hora no formato inválido!"); dataValida = false; } } while (!dataValida); mostrarPontes(); // Pontes_Aereas ponteSelecionada = null; se for o caso colocar um while pra obrigar a seleção // de uma ponte válida int opPonte = Console.scanInt("Selecione o código da rota q deseja cadastrar:"); if (ExistePonte(opPonte)) { Pontes_Aereas ponteSelecionada = devolvePonte(opPonte); String origem = ponteSelecionada.getOrigem(); String destino = ponteSelecionada.getDestino(); voo.addVoos(new Voo(origem, destino, horaDoVoo, aviao)); System.out.println("Vôo cadastrado com sucesso!!!"); } else { System.out.println("Não Existe uma rota com esse código!!!\n Ponte Aérea não cadastrada."); } } else { System.out.println("Não existe esse avião"); } }
/** * Checks the String whether it is a valid date. * * @param dateString * @return true if the String is a valid date */ public static boolean validDate(String dateString) { // Try to parse the String. return DateUtil.parse(dateString) != null; }
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods. * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); HttpSession session = request.getSession(); ServletContext app = getServletContext(); ; try { String url = ""; String login = (String) session.getAttribute("username"); if (login == null || login.isEmpty()) { // request.setAttribute("Message","Please login to access system !"); response.sendRedirect("../login.html"); } else { if (session.getAttribute("Role").equals("Seller")) { String lang = (String) app.getAttribute("MALL_LA"); String btn = request.getParameter("btnSearch"); User user = (User) UserBUS.getUser((String) session.getAttribute("username"), lang); List<Products> lst = null; if (null == btn || btn.isEmpty()) { lst = ProductBUS.lstProduct(user, lang); } else { SimpleDateFormat dayFormat = new SimpleDateFormat("yyyy-MM-dd"); String child = request.getParameter("selectCate"); String sub = request.getParameter("selectSub"); String search = request.getParameter("txtSearch"); String fromDate = request.getParameter("fromDate"); String toDate = request.getParameter("toDate"); // System.out.println(fromDate); // System.out.println(DateUtil.convertStringToDate(fromDate, // "yyyy-MM-dd")); lst = ProductBUS.advancedSearchProduct( (String) session.getAttribute("username"), child, sub, search, DateUtil.convertStringToDate(fromDate, "yyyy-MM-dd"), DateUtil.convertStringToDate(toDate, "yyyy-MM-dd"), lang); } request.setAttribute("ProductPOJOs", lst); url = "/sale/upload.jsp"; } else { request.setAttribute("Message", "Accounts are not allowed to access!"); url = "/login.html"; } } ServletContext sc = getServletContext(); RequestDispatcher rd = sc.getRequestDispatcher(url); rd.forward(request, response); } catch (Exception ex) { out.println(ex.getMessage()); } finally { out.close(); } }
/** * 查询用户消息列表接口 消息列表:同步返回每个用户的已读回执 公告列表:只需要返回公告标题和内容,不需要返回已读回执,已读回执在详情页展示 CustomDocinfo.java * * @param id * @param user_type 0:发送用户;1:接收用户;其他:全部 * @param notice_type 0:公告;1:消息;公告获取全部, 消息只能获取自己发送或接受到的消息 * @param if_read 是否已读;0:未读;1:已读 2015年6月15日 */ public static ResultInfo getNoticeList( Integer user_id, Integer notice_type, Integer if_read, String keywords, Integer p, Integer ps, Request request) { ResultInfo info = new ResultInfo(); AndroidUserInfo androidUserInfo = AndroidUserInfo.findById(user_id); if (androidUserInfo == null) { info.setCodeAndMsg(400); info.setRequest(request.path); return info; } if (keywords != null && keywords.length() > 0) { // 首先将keyword去空格 keywords = keywords.replaceAll(" ", ""); // 半角空格 if (keywords != null && keywords.length() > 0) { keywords = keywords.replaceAll(" ", ""); // 全角空格 } } List<AndroidNoticeInfo> androidNoticeInfoList = new ArrayList<AndroidNoticeInfo>(); // if (notice_type == 0) {//公告 List<AndroidReceiveNoticeUser> androidReceiveNoticeUserList = null; String notice_ids = ""; if (if_read == null || if_read > 1) { // 获取全部公告 // androidNoticeInfoList = AndroidNoticeInfo.find(" notice_type = ? order by id desc", // notice_type).fetch(p, ps); // 查询本人接收的所有公告 androidReceiveNoticeUserList = AndroidReceiveNoticeUser.findByNoticeTypeAndUser( notice_type, user_id /*, p, ps,keywords*/); } else { // 查询本人接收的所有公告 androidReceiveNoticeUserList = AndroidReceiveNoticeUser.findByNoticeTypeAndUserAndIfRead( notice_type, user_id, if_read /*, p, ps,keywords*/); } if (androidReceiveNoticeUserList != null && androidReceiveNoticeUserList.size() > 0) { for (AndroidReceiveNoticeUser androidReceiveNoticeUser : androidReceiveNoticeUserList) { if (androidReceiveNoticeUser != null) { notice_ids += androidReceiveNoticeUser.notice_id; notice_ids += ","; } } } if (notice_ids.endsWith(",")) { notice_ids = notice_ids.substring(0, notice_ids.length() - 1); } if (keywords != null && keywords.length() > 0) { if (notice_ids.length() > 0) { androidNoticeInfoList = AndroidNoticeInfo.find( " title LIKE '%" + keywords + "%' AND (id IN (" + notice_ids + ") or (notice_type = ? and push_user_id = ? )) " + " group by id order by id desc", notice_type, user_id) .fetch(p, ps); } else { androidNoticeInfoList = AndroidNoticeInfo.find( " title LIKE '%" + keywords + "%' AND (notice_type = ? and push_user_id = ?) " + " group by id order by id desc", notice_type, user_id) .fetch(p, ps); } } else { if (notice_ids.length() > 0) { androidNoticeInfoList = AndroidNoticeInfo.find( " id IN (" + notice_ids + ") or (notice_type = ? and push_user_id = ? ) " + " group by id order by id desc", notice_type, user_id) .fetch(p, ps); } else { androidNoticeInfoList = AndroidNoticeInfo.find( " notice_type = ? and push_user_id = ? " + " group by id order by id desc", notice_type, user_id) .fetch(p, ps); } } // }else {// 消息只能获取自己发送或接受到的消息 // // if (if_read == null || if_read > 0) {//全部消息 // List<AndroidReceiveNoticeUser> androidReceiveNoticeUserList = AndroidReceiveNoticeUser // .find("notice_type = ? AND (receive_user_id = ? OR push_user_id = ? OR " // + "(receive_user_id = 0 AND receive_user_type = 1) OR " // + "(receive_user_id = 0 AND receive_user_type = 2 AND department_id = ?))" // + "group by notice_id order by id desc",notice_type, user_id, // user_id,androidUserInfo.department_id).fetch(p,ps); // // //获取消息编号列表 // String noticeIds = ""; // if (androidReceiveNoticeUserList != null && androidReceiveNoticeUserList.size() > 0) { // for (AndroidReceiveNoticeUser androidReceiveNoticeUser : androidReceiveNoticeUserList) // { // if (androidReceiveNoticeUser != null) { // noticeIds += androidReceiveNoticeUser.notice_id; // noticeIds += ","; // } // } // } // if (noticeIds.endsWith(",")) { // noticeIds = noticeIds.substring(0, noticeIds.length() - 1); // } // if (noticeIds.length() > 0) { // androidNoticeInfoList = AndroidNoticeInfo.find("id IN (" + noticeIds + ") order by // create_time desc").fetch(); // } // }else { // List<AndroidReceiveNoticeUser> androidReceiveNoticeUserList = AndroidReceiveNoticeUser // .find("notice_type = ? AND if_read = ? AND (receive_user_id = ? OR push_user_id = ? OR " // + "(receive_user_id = 0 AND receive_user_type = 1) OR " // + "(receive_user_id = 0 AND receive_user_type = 2 AND department_id = ?))" // + "group by notice_id order by id desc",notice_type,if_read, user_id, // user_id,androidUserInfo.department_id).fetch(p,ps); // // //获取消息编号列表 // String noticeIds = ""; // if (androidReceiveNoticeUserList != null && androidReceiveNoticeUserList.size() > 0) { // for (AndroidReceiveNoticeUser androidReceiveNoticeUser : androidReceiveNoticeUserList) // { // if (androidReceiveNoticeUser != null) { // noticeIds += androidReceiveNoticeUser.notice_id; // noticeIds += ","; // } // } // } // if (noticeIds.endsWith(",")) { // noticeIds = noticeIds.substring(0, noticeIds.length() - 1); // } // if (noticeIds.length() > 0) { // androidNoticeInfoList = AndroidNoticeInfo.find("id IN (" + noticeIds + ") order by // create_time desc").fetch(); // } // } // // // } // 取消息已读未读状态 if (androidNoticeInfoList != null && androidNoticeInfoList.size() > 0) { // String receive_user_names = ""; // receive_user_names += androidReceiveNoticeUser.receive_user_name; // receive_user_names += ","; // // if (receive_user_names.endsWith(",")) { // receive_user_names = receive_user_names.substring(0, news_ids.length() - 1); // } // for (AndroidNoticeInfo androidNoticeInfo : androidNoticeInfoList) { // String create_time_string = DateUtil.date2String(androidNoticeInfo.create_time, // "yyyy-MM-dd HH:mm:ss"); // // try { // androidNoticeInfo.create_time = DateUtil.string2UtilDate(create_time_string, "yyyy-MM-dd // HH:mm:ss"); // } catch (Exception e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } // // } for (AndroidNoticeInfo androidNoticeInfo : androidNoticeInfoList) { if (androidNoticeInfo != null) { if (androidNoticeInfo.push_user_id != user_id) { // 如果本人是接收人,取已读未读状态 AndroidReceiveNoticeUser androidReceiveNoticeUser = AndroidReceiveNoticeUser.findByNoticeAndUser(androidNoticeInfo.id, user_id); if (androidReceiveNoticeUser != null) { androidNoticeInfo.if_read = androidReceiveNoticeUser.if_read; } else { androidNoticeInfo.if_read = 1; } } else { // 本人发送的公告消息默认为已读 androidNoticeInfo.if_read = 1; } androidNoticeInfo.create_time_string = DateUtil.date2String(androidNoticeInfo.create_time, "yyyy-MM-dd HH:mm:ss"); String create_time_string = DateUtil.date2String(androidNoticeInfo.create_time, "yyyy-MM-dd HH:mm:ss"); try { androidNoticeInfo.create_time = DateUtil.string2UtilDate(create_time_string, "yyyy-MM-dd HH:mm:ss"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } } info.setCodeAndMsg(200); info.setInfo(androidNoticeInfoList); info.setCount(androidNoticeInfoList.size()); info.setRequest(request.path); } else { info.setCodeAndMsg(200); info.setInfo(androidNoticeInfoList); info.setRequest(request.path); } return info; }
/** * 查询用户消息详情, 公告:对于发布人查看公告消息,同步返回已读和未读用户列表; 对于接收人查看公告消息,不返回已读和未读用户列表; CustomDocinfoService.java * * @param id * @param user_id 阅读人 * @param request * @return 2015年6月15日 */ public static ResultInfo getNoticeInfo(Integer id, Integer user_id, Request request) { ResultInfo info = new ResultInfo(); AndroidNoticeInfo androidNoticeInfo = AndroidNoticeInfo.findById(id); if (androidNoticeInfo == null) { info.setCodeAndMsg(12001); info.setRequest(request.path); return info; } // 修改已读标志 AndroidReceiveNoticeUser receiveNoticeUser = AndroidReceiveNoticeUser.findByNoticeAndUser(id, user_id); if (receiveNoticeUser != null) { receiveNoticeUser.if_read = 1; receiveNoticeUser.read_time = new Date(); receiveNoticeUser.save(); } if ( /*androidNoticeInfo.notice_type == 0 && */ androidNoticeInfo.push_user_id.equals( user_id)) { // 对于发布人查看公告消息,同步返回已读和未读用户列表; // 取公告已读接收人记录 List<AndroidReceiveNoticeUser> androidReceiveNoticeUserList = AndroidReceiveNoticeUser.find( "notice_id = ? and receive_user_id != ? and if_read = 1", id, androidNoticeInfo.push_user_id) .fetch(); String receive_user_ids = ""; String receive_user_names = ""; if (androidReceiveNoticeUserList != null && androidReceiveNoticeUserList.size() > 0) { for (AndroidReceiveNoticeUser androidReceiveNoticeUser : androidReceiveNoticeUserList) { if (androidReceiveNoticeUser != null) { receive_user_ids += androidReceiveNoticeUser.receive_user_id; receive_user_ids += ","; receive_user_names += androidReceiveNoticeUser.receive_user_name; receive_user_names += ","; } } } if (receive_user_ids.endsWith(",")) { receive_user_ids = receive_user_ids.substring(0, receive_user_ids.length() - 1); } if (receive_user_names.endsWith(",")) { receive_user_names = receive_user_names.substring(0, receive_user_names.length() - 1); } androidNoticeInfo.receive_user_ids = receive_user_ids; androidNoticeInfo.receive_user_names = receive_user_names; // 取公告未读接收人记录 List<AndroidReceiveNoticeUser> unReadAndroidReceiveNoticeUserList = AndroidReceiveNoticeUser.find( "notice_id = ? and receive_user_id != ? and if_read = 0", id, androidNoticeInfo.push_user_id) .fetch(); String unreceive_user_ids = ""; String unreceive_user_names = ""; if (unReadAndroidReceiveNoticeUserList != null && unReadAndroidReceiveNoticeUserList.size() > 0) { for (AndroidReceiveNoticeUser androidReceiveNoticeUser : unReadAndroidReceiveNoticeUserList) { if (androidReceiveNoticeUser != null) { unreceive_user_ids += androidReceiveNoticeUser.receive_user_id; unreceive_user_ids += ","; unreceive_user_names += androidReceiveNoticeUser.receive_user_name; unreceive_user_names += ","; } } } if (unreceive_user_ids.endsWith(",")) { unreceive_user_ids = unreceive_user_ids.substring(0, unreceive_user_ids.length() - 1); } if (unreceive_user_names.endsWith(",")) { unreceive_user_names = unreceive_user_names.substring(0, unreceive_user_names.length() - 1); } // if(receive_user_ids.equals("null")){ // receive_user_ids = ""; // } androidNoticeInfo.unreceive_user_ids = unreceive_user_ids; androidNoticeInfo.unreceive_user_names = unreceive_user_names; } androidNoticeInfo.create_time_string = DateUtil.date2String(androidNoticeInfo.create_time, "yyyy-MM-dd HH:mm:ss"); String create_time_string = DateUtil.date2String(androidNoticeInfo.create_time, "yyyy-MM-dd HH:mm:ss"); try { androidNoticeInfo.create_time = DateUtil.string2UtilDate(create_time_string, "yyyy-MM-dd HH:mm:ss"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } info.setCodeAndMsg(200); info.setInfo(androidNoticeInfo); info.setRequest(request.path); return info; }