com.xnx3.exception.NotReturnValueException Java Examples

The following examples show how to use com.xnx3.exception.NotReturnValueException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DateUtil.java    From xnx3 with Apache License 2.0 6 votes vote down vote up
/**
 * 将Linux时间戳变为文字描述的时间
 * @param linuxTime Linux时间戳,10位或者13位
 * @param format 转换格式 ,若不填,默认为yyyy-MM-dd hh:mm:ss {@link #FORMAT_DEFAULT}
 * @return 转换后的日期。如 2016-01-18 11:11:11
 * @throws NotReturnValueException
 */
public static String dateFormat(long linuxTime,String format) throws NotReturnValueException{
	int linuxTimeLength=(linuxTime+"").length();
	if(linuxTime==0||!(linuxTimeLength==10||linuxTimeLength==13)){
		throw new NotReturnValueException("传入的linux时间戳长度错误!当前传入的时间戳:"+linuxTime+",请传入10或者13位的时间戳");
	}else{
		if(format==null||format.length()==0){
			format=FORMAT_DEFAULT;
		}
		
		if(linuxTimeLength==10){
			linuxTime=linuxTime*1000;
		}
		return new SimpleDateFormat(format).format(new java.util.Date(linuxTime));
	}
}
 
Example #2
Source File: Action.java    From templatespider with Apache License 2.0 5 votes vote down vote up
/**
 * 获取当前操作的模版,保存路径的模版名,将要保存到文件夹的名称
 * @return
 */
public static String getTemplatePathName(){
	String uiTN = Global.mainUI.getTextField_templateName().getText();
	if(uiTN == null || uiTN.length() == 0){
		try {
			uiTN = "template_"+DateUtil.dateFormat(DateUtil.timeForUnix10(), "yyyy_MM_dd__hh_mm");
		} catch (NotReturnValueException e) {
			e.printStackTrace();
		}
	}
	return uiTN;
}
 
Example #3
Source File: AdminRequestLogController.java    From wangmarket with Apache License 2.0 5 votes vote down vote up
/**
 * 折线图,当月(最近30天),每天的访问情况
 */
@RequiresPermissions("adminRequestLogFangWen")
@RequestMapping("dayLineForCurrentMonth${url.suffix}")
@ResponseBody
public RequestLogDayLineVO dayLineForCurrentMonth(HttpServletRequest request) throws LogException{
	RequestLogDayLineVO vo = new RequestLogDayLineVO();
	
	//当前10位时间戳
	int currentTime = DateUtil.timeForUnix10();
	String query = "Mozilla | timeslice 24h | count as c";
	
	//当月访问量统计
	ArrayList<QueriedLog> jinriQlList = Log.aliyunLogUtil.queryList(query, "", DateUtil.getDateZeroTime(currentTime - 2592000), currentTime, 0, 100, true);
	
	JSONArray jsonArrayDate = new JSONArray();	//天数
	JSONArray jsonArrayFangWen = new JSONArray();	//某天访问量,pv
	for (int i = 0; i < jinriQlList.size(); i++) {
		LogItem li = jinriQlList.get(i).GetLogItem();
		JSONObject json = JSONObject.fromObject(li.ToJsonString());
		try {
			jsonArrayDate.add(DateUtil.dateFormat(json.getInt("logtime"), "MM-dd"));
		} catch (NotReturnValueException e) {
			e.printStackTrace();
		}
		jsonArrayFangWen.add(json.getInt("c"));
	}
	vo.setJsonArrayFangWen(jsonArrayFangWen);
	vo.setJsonArrayDate(jsonArrayDate);
	
	AliyunLog.addActionLog(0, "总管理后台,获取最近30天的访问数据统计记录");
	
	return vo;
}
 
Example #4
Source File: LogAdminController_.java    From wangmarket with Apache License 2.0 5 votes vote down vote up
/**
 * 折线图,当月(最近30天),每天的访问情况
 */
@RequiresPermissions("adminLogCartogram")
@RequestMapping("dayLineForCurrentMonth${url.suffix}")
@ResponseBody
public LogLineGraphVO dayLineForCurrentMonth(HttpServletRequest request) throws LogException{
	LogLineGraphVO vo = new LogLineGraphVO();
	
	//当前10位时间戳
	int currentTime = DateUtil.timeForUnix10();
	String query = "Mozilla | timeslice 24h | count as c";
	
	//当月访问量统计
	ArrayList<QueriedLog> jinriQlList = ActionLogCache.aliyunLogUtil.queryList(query, "", DateUtil.getDateZeroTime(currentTime - 2592000), currentTime, 0, 100, true);
	
	JSONArray jsonArrayDate = new JSONArray();	//天数
	JSONArray jsonArrayFangWen = new JSONArray();	//某天访问量,pv
	for (int i = 0; i < jinriQlList.size(); i++) {
		LogItem li = jinriQlList.get(i).GetLogItem();
		JSONObject json = JSONObject.fromObject(li.ToJsonString());
		try {
			jsonArrayDate.add(DateUtil.dateFormat(json.getInt("logtime"), "MM-dd"));
		} catch (NotReturnValueException e) {
			e.printStackTrace();
		}
		jsonArrayFangWen.add(json.getInt("c"));
	}
	vo.setDataArray(jsonArrayFangWen);
	vo.setNameArray(jsonArrayDate);
	
	return vo;
}
 
Example #5
Source File: AliyunLogUtil.java    From xnx3 with Apache License 2.0 5 votes vote down vote up
public static void main(String args[]) throws LogException, InterruptedException, NotReturnValueException {
    AliyunLogUtil aliyunLogUtil = new AliyunLogUtil("cn-hongkong.log.aliyuncs.com", "121212", "121212", "requestlog", "fangwen");
		
    ArrayList<QueriedLog> qlList = aliyunLogUtil.queryList("*", "leiwen.wang.market", DateUtil.timeForUnix10()-10000000, DateUtil.timeForUnix10(), 0, 100, true);
   	for (int i = 0; i < qlList.size(); i++) {
   		System.out.println(i);
   		QueriedLog ll = qlList.get(i);
   		LogItem li = ll.GetLogItem();
   		System.out.println(li.GetLogContents().toString());
   	} 
   	System.out.println("qlList  :  "+qlList.size());
}
 
Example #6
Source File: DateUtil.java    From xnx3 with Apache License 2.0 5 votes vote down vote up
/**
 * 将Linux时间戳变为文字描述的时间
 * @param linuxTime Linux时间戳,10位
 * @param format 转换格式 ,若不填,默认为yyyy-MM-dd hh:mm:ss {@link #FORMAT_DEFAULT}
 * @return 转换后的日期。如 2016-01-18 11:11:11
 */
public static String intToString(int linuxTime,String format){
	try {
		return dateFormat(linuxTime, format);
	} catch (NotReturnValueException e) {
		e.printStackTrace();
		return linuxTime+"";
	}
}
 
Example #7
Source File: DateUtil.java    From xnx3 with Apache License 2.0 5 votes vote down vote up
/**
 * 传入一个10位的时间戳,返回当前时间戳所在的当天0点的10位时间戳
 * @param time 10位的时间戳
 * @return 当天0点的时间戳。若失败,返回0
 */
public static int getDateZeroTime(int time){
	String ls;
	try {
		ls = DateUtil.dateFormat(time, "yyyy-MM-dd");
	} catch (NotReturnValueException e) {
		e.printStackTrace();
		return 0;
	}
	return DateUtil.StringToInt(ls+" 00:00:00", "yyyy-MM-dd hh:mm:ss");
}
 
Example #8
Source File: AgencyUserController.java    From wangmarket with Apache License 2.0 4 votes vote down vote up
/**
	 * 给某个代理延长使用期限
	 * @param agencyId 要续费的代理id,agency.id
	 * @param year 要续费的年数,支持1~10,最大续费10年
	 */
	@RequiresPermissions("agencyYanQi")
	@RequestMapping("agencyYanQi${url.suffix}")
	@ResponseBody
	public BaseVO agencyYanQi(HttpServletRequest request, Model model,
			@RequestParam(value = "agencyId", required = true) int agencyId,
			@RequestParam(value = "year", required = false, defaultValue = "0") int year){
		if(year < 1){
			return error("请输入要续费的年数,1~10");
		}
		if(year > 10){
			return error("请输入要续费的年数,1~10,最大可往后续费10年");
		}
		
		//我的代理信息
		Agency myAgency = sqlService.findById(Agency.class, getMyAgency().getId());
		
		//续费所需的站币
		int xufeiZhanBi = year * 20;
		
		if(myAgency.getSiteSize() - xufeiZhanBi <= 0){
			return error("您当前只拥有"+myAgency.getSiteSize()+"站币!续费花费的金额超出,续费失败!");
		}
		
		//我的下级的代理信息,要给他延期的,代理的信息
		Agency subAgency = sqlService.findById(Agency.class, agencyId);
		//我的下级代理,所属人的信息
		User subUser = sqlService.findById(User.class, subAgency.getUserid());
		if(subUser.getReferrerid() - myAgency.getUserid() != 0){
			return error("要延期的代理不是您的直属下级,为其延期失败");
		}
		
		//判断延期后的代理使用期限是否超过了10年 ,当前时间 + 3660天
		if((subAgency.getExpiretime() + (year * 31622400)) > (DateUtil.timeForUnix10() + 316224000)){
			return error("代理资格往后延期的最大期限为10年!");
		}
		
		//当前我的IP地址
		String ip = IpUtil.getIpAddress(request);
		
		
		/**** 进行数据保存 ****/
		
		//我的代理信息里,减去续费花费的站币
		myAgency.setSiteSize(myAgency.getSiteSize() - xufeiZhanBi);
		sqlService.save(myAgency);
		//数据库保存我的消费记录
		SiteSizeChange ssc = new SiteSizeChange();
		ssc.setAddtime(DateUtil.timeForUnix10());
		ssc.setAgencyId(myAgency.getId());
		ssc.setChangeAfter(myAgency.getSiteSize());
		ssc.setChangeBefore(myAgency.getSiteSize() + xufeiZhanBi);
		ssc.setGoalid(subAgency.getId());
		ssc.setSiteSizeChange(0-xufeiZhanBi);
		ssc.setUserid(myAgency.getUserid());
		sqlService.save(ssc);
		//记录我的资金消费记录
		SiteSizeChangeLog.xiaofei(myAgency.getName(), "给代理"+subAgency.getName()+"延长使用期限"+year+"年", ssc.getSiteSizeChange(), ssc.getChangeBefore(), ssc.getChangeAfter(), ssc.getGoalid(), ip);
		
		//对方代理平台延长使用过期时间
		subAgency.setExpiretime(subAgency.getExpiretime() + (year * 31622400));
		sqlService.save(subAgency);
		
		//到期时间
		String daoqishijian = "";
		try {
			daoqishijian = DateUtil.dateFormat(subAgency.getExpiretime(), "yyyy年MM月dd日");
		} catch (NotReturnValueException e) {
			e.printStackTrace();
		}
		
		//记录操作日志
		AliyunLog.addActionLog(ssc.getId(), "给代理"+subAgency.getName()+"延长使用期限"+year+"年。代理资格延期后,日期到"+daoqishijian);
		
		//发送短信通知对方
		//这里等转为公司模式后,用公司资格申请短信发送资格
//		G.aliyunSMSUtil.send(G.AliyunSMS_SignName, G.AliyunSMS_siteYanQi_templateCode, "{\"siteName\":\""+site.getName()+"\", \"year\":\""+year+"\", \"time\":\""+daoqishijian+"\"}", site.getPhone());
		
		//刷新Session中我的代理信息缓存
		Func.getUserBeanForShiroSession().setMyAgency(myAgency);
		
		return success();
	}
 
Example #9
Source File: TransactionalServiceImpl.java    From wangmarket with Apache License 2.0 4 votes vote down vote up
public BaseVO siteXuFei(HttpServletRequest request, int siteid, int year) {
		BaseVO vo = new BaseVO();
		
		if(year < 1){
			vo.setBaseVO(BaseVO.FAILURE, "请输入要续费的年数,1~10");
			return vo;
		}
		if(year > 10){
			vo.setBaseVO(BaseVO.FAILURE, "请输入要续费的年数,1~10,最大可往后续费10年");
			return vo;
		}
		
		Agency shiroMyAgency = com.xnx3.wangmarket.superadmin.Func.getMyAgency();
		
		//我的代理信息
		Agency myAgency = sqlDAO.findById(Agency.class, shiroMyAgency.getId());
		
		if(myAgency.getSiteSize() - year <= 0){
			vo.setBaseVO(BaseVO.FAILURE, "您当前只拥有"+myAgency.getSiteSize()+"站币!续费花费的金额超出,续费失败!");
			return vo;
		}
		
		//我的下级的网站信息,要给他续费的网站信息
		Site site = sqlDAO.findById(Site.class, siteid);
		//我的下级的网站所属人的信息
		User user = sqlDAO.findById(User.class, site.getUserid());
		if(user.getReferrerid() - myAgency.getUserid() != 0){
			vo.setBaseVO(BaseVO.FAILURE, "要续费的网站不是您的直属下级,无法续费");
			AliyunLog.insert(request, myAgency.getId(), "warn", "给我开通的站点续费:"+vo.getInfo());
			return vo;
		}
		
		//避免int溢出
		long expiretime = site.getExpiretime();
		expiretime = expiretime + (year * 31622400);
		System.out.println(expiretime);
		if(expiretime > 2147483647){
			vo.setBaseVO(BaseVO.FAILURE, "网站往后续费最大可续费到2038年!此年份后将开启全新建站时代。");
			return vo;
		}
		
		//判断续费后的网站是否超过了10年 ,当前时间 + 3660天
		if(expiretime > (DateUtil.timeForUnix10() + 316224000)){
			vo.setBaseVO(BaseVO.FAILURE, "网站往后续费最大为10年!");
			return vo;
		}
		
		
		//当前我的IP地址
		String ip = IpUtil.getIpAddress(request);
		
		/**** 进行数据保存 ****/
		
		//我的代理信息里,减去续费花费的站币
		myAgency.setSiteSize(myAgency.getSiteSize() - year);
		sqlDAO.save(myAgency);
		//数据库保存我的消费记录
		SiteSizeChange ssc = new SiteSizeChange();
		ssc.setAddtime(DateUtil.timeForUnix10());
		ssc.setAgencyId(myAgency.getId());
		ssc.setChangeAfter(myAgency.getSiteSize());
		ssc.setChangeBefore(myAgency.getSiteSize() + year);
		ssc.setGoalid(site.getId());
		ssc.setSiteSizeChange(0-year);
		ssc.setUserid(myAgency.getUserid());
		sqlDAO.save(ssc);
		//记录我的资金消费记录
		SiteSizeChangeLog.xiaofei(myAgency.getName(), "给网站"+site.getName()+"续费"+year+"年", year, myAgency.getSiteSize()+year, myAgency.getSiteSize(), site.getId(), ip);
		
		//网站增加过期时间
		site.setExpiretime(site.getExpiretime() + (year * 31622400));
		sqlDAO.save(site);
		
		//到期时间
		String daoqishijian = "";
		try {
			daoqishijian = DateUtil.dateFormat(site.getExpiretime(), "yyyy年MM月dd日");
		} catch (NotReturnValueException e) {
			e.printStackTrace();
		}
		
		//记录操作日志
		AliyunLog.addActionLog(site.getId(), "给网站"+site.getName()+"续费"+year+"年。网站续费后,日期到"+daoqishijian);
		
		//发送短信通知对方
//		G.aliyunSMSUtil.send(G.AliyunSMS_SignName, G.AliyunSMS_siteYanQi_templateCode, "{\"siteName\":\""+site.getName()+"\", \"year\":\""+year+"\", \"time\":\""+daoqishijian+"\"}", site.getPhone());
		
		//刷新Session中我的代理信息缓存
		Func.getUserBeanForShiroSession().setMyAgency(myAgency);
		return vo;
	}
 
Example #10
Source File: DateUtil.java    From xnx3 with Apache License 2.0 2 votes vote down vote up
/**
 * 将Linux时间戳变为文字描述的时间
 * {@link #dateFormat(long, String)}
 * @param linuxTime Linux时间戳,10位或者13位
 * @return 转换后的日期。如 2016-01-18 11:11:11
 * @throws NotReturnValueException
 */
public String dateFormat(long linuxTime) throws NotReturnValueException{
	return dateFormat(linuxTime, FORMAT_DEFAULT);
}