汇总sql
select
sum(1) totalScmallOrder,总订单
sum(case when TO_DAYS(t.create_Time) = TO_DAYS(now()) then 1 else 0 end) todayAddScmallOrder,今天订单
sum(case when TO_DAYS(t.create_Time) = TO_DAYS(DATE_SUB(curdate(),INTERVAL 1 DAY)) then 1 else 0 end) yesterdayAddScmallOrder昨天订单
from
v_sc_order_2019 t where t.state not in ('1','6')订单表订单状态
前端jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<link rel="stylesheet" type="text/css"
href="resource/layui/css/layui.css">
<link rel="stylesheet" type="text/css" href="resource/com/css/style.css">
<link rel="stylesheet" type="text/css"
href="resource/index/css/admin_index.css">
<link rel="stylesheet" type="text/css"
href="resource/index/css/scenic.css">
<script src="resource/visual/js/visual.js"></script>
<script src="resource/echarts/js/echarts.js"></script>
<div class="container-fluid" style="padding-top : 5px;">
<!-- onsubmit="return false" action="##" -->
<div class="box color-palette-box">
<form method="post" id="formtest" onSubmit="return checkForm()" name="form" >
<span style="font-size:22px" >本月贫困户数量:</span><input type="text" name="poorHouseholds" id="poorHouseholds" οnfοcus="register(this)" /><span id="login01"></span> <br>
<span style="font-size:22px" >贫困户增收金额:</span><input type="text" name="addMoney01" id="addMoney01" οnfοcus="register(this)" /><span id="login02"></span><br>
<span style="font-size:15.5px" >扶贫主体带动增收金额:</span><input type="text" name="addMoney02" id="addMoney02" οnfοcus="register(this)" /><span id="login03"></span><br>
<!-- <button class="botton_sub" type="submit">提交</button> -->
<button class="btn btn-primary" type="submit" >
<span></span> 提交
</button>
</form>
</div>
<div class="layui-container admin-container">
<div class="blank-30"></div>
<div class="layui-col-md12 layui-col-xs12 layui-col-sm12 ">
<div class="box color-palette-box">
<div class="box-header with-border">
<label class="box-title">扶贫数据化显示</label>
</div>
<div class="box-body">
<div id="All" style="width: 100%;height:600px;"></div>
</div>
</div>
</div>
</div>
</div>
</div>
js
$(function() {
initData();
});
//验证提交
function checkForm() {
var flg = false;
if ($('#poorHouseholds').val() == "") {
$('#login01').html("本月贫困户数量不能为空").css({
"display" : "inline",
"color" : "red"
});
flg = false;
} else if ($('#addMoney01').val() == "") {
$('#login02').html("本月带动贫困户增收金额不能为空").css({
"display" : "inline",
"color" : "red"
});
flg = false;
} else if ($('#addMoney02').val() == "") {
$('#login03').html("扶贫主体带动贫困户增收金额不能为空").css({
"display" : "inline",
"color" : "red"
});
flg = false;
} else {
jQuery.ajax({
//几个参数需要注意一下
type : "POST", //方法类型
dataType : "text",
url : "visual_Home!addVisual.do",
data : $('#formtest').serialize(),
success : function(result) {
alert("提交成功,生成图表")
console.log(result);
location.reload(true);
},
error : function() {
alert("异常!");
}
});
}
return flg;
}
var isalerterror = false;
initData = function() {
allChart();
}
allChart = function() {
$.ajax({
url : 'visual_Home!getAllList.do',
type : 'post',
data : {
type : 'month'
},
//result代表visual的list集合其中包括poorHouseholds;addMoney01;addMoney02;xData
success : function(result) {
var obj = JSON.parse(JSON.stringify(result));
var xData = [];
/*var data = [];*/
var poorHouseholds = [];
var addMoney01 = [];
var addMoney02 = [];
for (var i = 0; i < obj.length; i++) {
xData.push(obj[i].month);
poorHouseholds.push(obj[i].poorHouseholds);
addMoney01.push(obj[i].addMoney01);
addMoney02.push(obj[i].addMoney02);
}
//读取jsp放置图表位置ID
var chart = echarts.init(document.getElementById('All'));
var option = {
tooltip : {
trigger : 'axis',
axisPointer : {
type : 'cross',
crossStyle : {
color : '#999'
}
}
},
//toolbox是添加项是可以自由切换柱状图折线图的
toolbox : {
feature : {
dataView : {
show : true,
readOnly : false
},
magicType : {
show : true,
type : [ 'line', 'bar' ]
},
restore : {
show : true
},
saveAsImage : {
show : true
}
}
},
legend : {
data : [ '贫困户增加金额', '扶贫主体带动贫困户增加金额', '贫困户数量' ]
},
xAxis : {
type : 'category',
data : xData,
axisPointer : {
type : 'shadow'
}
},
yAxis : [
{
type : 'value',
name : '金额',
axisLabel : {
formatter : '{value} 万元'
}
},
{
type : 'value',
name : '数量',
axisLabel : {
formatter : '{value} 户'
}
}
],
series : [ {
name : '贫困户增加金额',
type : 'bar',
data : addMoney01
},
{
name : '扶贫主体带动贫困户增加金额',
type : 'bar',
data : addMoney02
},
{
name : '贫困户数量',
type : 'line',
yAxisIndex : 1,
data : poorHouseholds
} ]
};
chart.setOption(option);
},
error : function(XMLHttpRequest, textStatus, errorThrown) {
if (!isalerterror) {
$.fn.modalAlert('请求失败', 'error');
isalerterror = true;
} else {
console.log(errorThrown);
}
}
});
}
<div class="layui-container admin-container">
<div class="blank-30"></div>
<div class="layui-col-md12 layui-col-xs12 layui-col-sm12 ">
<div class="box color-palette-box">
<div class="box-header with-border">
<label class="box-title">扶贫数据化显示</label>
</div>
<div class="box-body">
<div id="All" style="width: 100%;height:600px;"></div>
</div>
</div>
</div>
</div>
</div>
controller
package com.eastcom.visual.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.eastcom.common.bean.Message;
import com.eastcom.common.controller.BaseController;
import com.eastcom.common.util.DateUtils;
import com.eastcom.tourguide.bean.Article;
import com.eastcom.visual.bean.DateCountBean;
import com.eastcom.visual.bean.Visual;
import com.eastcom.visual.service.VisualService;
@Scope("prototype")
@Controller
public class VisualController extends BaseController
{
@Autowired
private VisualService visualService;
@ResponseBody
@RequestMapping(value = "/visual_Home!getAllList.do")
public List<Visual> getAllList(String type)
{
return visualService.getAllList( type);
}
@ResponseBody
@RequestMapping(value = "/visual_Home!addVisual.do")
public Message addVisual(Visual visual)
{
visual.setMonth(DateUtils.getNow());
return visualService.addVisual(visual);
}
}
service
package com.eastcom.visual.service;
import java.util.List;
import com.eastcom.common.bean.Message;
import com.eastcom.visual.bean.DateCountBean;
import com.eastcom.visual.bean.Visual;
public interface VisualService {
List<Visual> getAllList(String type);
Message addVisual(Visual visual);
}
serviceImpl
package com.eastcom.visual.service.impl;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import com.eastcom.common.bean.Message;
import com.eastcom.common.util.DateUtils;
import com.eastcom.common.util.ExceptionDealUtil;
import com.eastcom.idgenerate.NoGenerator;
import com.eastcom.index.bean.IndexDateCountBean;
import com.eastcom.visual.bean.DateCountBean;
import com.eastcom.visual.bean.Visual;
import com.eastcom.visual.mapper.VisualMapper;
import com.eastcom.visual.service.VisualService;
@Scope("prototype")
@Service
public class VisualServiceImpl implements VisualService {
@Autowired
private VisualMapper visualMapper;
private Logger log = Logger.getLogger(this.getClass().getName());
@Override
public Message addVisual(Visual visual) {
Message msg = new Message();
try {
if (visualMapper.isexist(visual) != null) {
msg.setSuccess(false);
msg.setMessage("保存失败:已存在于数据库中!");
} else {
visual.setId(NoGenerator.get().nextSeq());
visualMapper.addVisual(visual);
msg.setSuccess(true);
msg.setMessage("保存成功!");
}
} catch (Exception e) {
log.error(e.getMessage(), e);
msg.setSuccess(false);
msg.setMessage("保存失败:" + ExceptionDealUtil.getMessage(e));
}
return msg;
}
// 获取日期和计数x轴与y轴,和类型 返回list
@Override
public List<Visual> getAllList(String type) {
List<Visual> list = new ArrayList<Visual>();
list = visualMapper.getAllList(type);
return list;
}
}
mapper.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.eastcom.visual.mapper.VisualMapper">
<!-- 定义数据库字段与实体对象的映射关系 -->
<resultMap id="resultOfInteger" type="java.lang.Integer">
<result column="total" property="total" jdbcType="INTEGER" />
</resultMap>
<resultMap id="dateCountBean" type="com.eastcom.visual.bean.DateCountBean">
</resultMap>
<resultMap id="visual" type="com.eastcom.visual.bean.Visual">
<result property="id" column="id" javaType="STRING" jdbcType="VARCHAR" />
<result property="poorHouseholds" column="poorHouseholds" javaType="STRING" jdbcType="VARCHAR" />
<result property="addMoney01" column="addMoney01" javaType="STRING" jdbcType="VARCHAR" />
<result property="addMoney02" column="addMoney02" javaType="STRING" jdbcType="VARCHAR" />
<result property="month" column="month" javaType="STRING" jdbcType="VARCHAR" />
</resultMap>
<!-- 定义要操作的SQL语句 -->
<select id="isexist" parameterType="com.eastcom.visual.bean.Visual" resultMap="visual">
select `id`,`poorHouseholds`,`addMoney01`,`addMoney02`,`month` from visual t
<where>
id = #{id}
</where>
</select>
<insert id="addVisual" parameterType="com.eastcom.visual.bean.Visual">
insert into visual(
`id`,`poorHouseholds`,`addMoney01`,`addMoney02`,`month`)
values(
#{id},#{poorHouseholds},#{addMoney01},#{addMoney02},#{month})
</insert>
<select id="getpoorHouseholdsList" resultMap="dateCountBean">
<select id="getAllList" resultMap="visual">
select
DATE_FORMAT(t.month,'%Y-%m') month,
addMoney02 addmoney02,
addMoney01 addMoney01,
poorHouseholds poorHouseholds
from visual t
group by DATE_FORMAT(t.month,'%Y-%m')
order by DATE_FORMAT(t.month,'%Y-%m')
</select>
</mapper>
几个实体类
IndexDateCountBean
package com.eastcom.index.bean;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.eastcom.common.util.DateUtils;
public class IndexDateCountBean implements Comparable<IndexDateCountBean>
{
private String date;
private String count;
public IndexDateCountBean()
{
}
public IndexDateCountBean(String date, String count)
{
this.date = date;
this.count = count;
}
public String getDate()
{
return date;
}
public void setDate(String date)
{
this.date = date;
}
public String getCount()
{
return count;
}
public void setCount(String count)
{
this.count = count;
}
public int compareTo(IndexDateCountBean bean)
{
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Date date1 = null;
Date date2 = null;
try
{
date1 = format.parse(getDate());
date2 = format.parse(bean.getDate());
return date1.compareTo(date2);
} catch (ParseException e)
{
e.printStackTrace();
}
return -1;
}
public boolean containeDay(String checkDate)
{
String[] array = this.date.split("至");
if (array.length == 2)
{
if (DateUtils.getDifferentDay(array[0] + " 00:00:00", checkDate + " 00:00:00") >= 0 && DateUtils.getDifferentDay(array[1] + " 00:00:00", checkDate + " 00:00:00") >= 0)
{
return true;
}
}
return false;
}
}
DateUtils
package com.eastcom.common.util;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import org.apache.log4j.Logger;
public class DateUtils
{
private static Logger log = Logger.getLogger(DateUtils.class.getName());
/**
* 时间格式(yyyy-MM-dd HH:mm:ss)
*/
public final static String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
public static String format(Date date, String pattern)
{
if (date != null)
{
SimpleDateFormat df = new SimpleDateFormat(pattern);
return df.format(date);
}
return null;
}
public static String getLastYear()
{
return String.valueOf(Integer.valueOf(getThisYear()) - 1);
}
/**
* 日期转指定格式的字符串
*
*
* @param date
* @param formStr
* @return
*/
public static String dateToString(Date date, String formStr)
{
if (null == date)
{
return "";
}
if ("".equals(formStr))
{
formStr = "yyyy-MM-dd HH:mm:ss";
}
DateFormat format = new SimpleDateFormat(formStr);
return format.format(date);
}
/**
* @param fmt常用格式解析
* :具体请参照(SimpleDateFormat)API y 年 M 年中的月份 d 月份中的天数 H 一天中的小时数(0-23) m 小时中的分钟数 s 分钟中的秒数
* @return
*/
public static String getCurrentTimeStr(String fmt)
{
if (null == fmt || "".equals(fmt))
return "";
Date dd = new Date();
DateFormat sf = new SimpleDateFormat(fmt);
String dateStr = sf.format(dd);
return dateStr;
}
/**
* "yyyy"
*
* @return
*/
public static String getThisYear()
{
return getCurrentTimeStr("yyyy");
}
/**
* "yyyy-MM"
*
* @return
*/
public static String getThisMonth()
{
return getCurrentTimeStr("yyyy-MM");
}
/**
* "yyyy-MM-dd"
*
* @return
*/
public static String getToday()
{
return getCurrentTimeStr("yyyy-MM-dd");
}
/**
* "dd"
*
* @return
*/
public static String getTodayDay()
{
return getCurrentTimeStr("dd");
}
/**
* "yyyy-MM-dd"
*
* @return
*/
public static String getYesterDay()
{
return getIntervalDayTime(getNow(), -1).substring(0, 10);
}
/**
* "yyyy-MM-dd HH:mm:ss"
*
* @return
*/
public static String getNow()
{
return getCurrentTimeStr("yyyy-MM-dd HH:mm:ss");
}
/**
* "HH"
*
* @return
*/
public static String getNowHour()
{
return getCurrentTimeStr("HH");
}
/**
* "MM"
*
* @return
*/
public static String getNowMonth()
{
return getCurrentTimeStr("MM");
}
/**
* " HH:mm:ss"
*
* @return
*/
public static String getNowHHmmssSuffix()
{
return getCurrentTimeStr(" HH:mm:ss");
}
/**
* "yyyyMMddHHmmss"
*
* @return
*/
public static String getFileNameSuffix()
{
return getCurrentTimeStr("yyyyMMddHHmmss");
}
/**
* "yyyyMM"
*
* @return
*/
public static String getFolderNameSuffix()
{
return getCurrentTimeStr("yyyyMM");
}
public static Date strToDate(String str, String format) throws ParseException
{
DateFormat sf = new SimpleDateFormat(format);
return sf.parse(str);
}
/**
* oracle日期格式转java日期格式
*
* @param formatFmt
* oracle的日期格式
*
*
* @return
*/
public static String oracleToJavaDateFormat(String formatFmt)
{
formatFmt = formatFmt.toLowerCase();
formatFmt = formatFmt.replaceAll("mm", "MM");
formatFmt = formatFmt.replaceAll("hh24", "HH");
formatFmt = formatFmt.replaceAll("hh", "HH");
formatFmt = formatFmt.replaceAll("mi", "mm");
return formatFmt;
}
/**
* 获取当前日期的前几天的时间格式
*
* @param num
* @param format
* @return
*/
public static String getBeforeDayTimeStr(int num, String format)
{
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
Date currentDate = new Date();
Calendar cal = Calendar.getInstance();
cal.setTime(currentDate);
cal.add(Calendar.MONTH, -1);
sdf = new SimpleDateFormat(format);
currentDate = new Date();
cal.setTime(currentDate);
cal.add(Calendar.DATE, -num);
String befDate = sdf.format(cal.getTime());
return befDate;
}
/**
* 将java.uti..Date 对象转化成 java.sql.Date
*
* @param uDate
* @return
*/
public static java.sql.Date covertUtilDateToSqlDate(java.util.Date uDate)
{
return new java.sql.Date(uDate.getTime());
}
/**
* 将java.sql.Date转化成java.util.Date
*
* @param sDate
* @return
*/
public static java.util.Date covertSqlDateToUtilDate(java.sql.Date sDate)
{
return new java.util.Date(sDate.getTime());
}
public static String getDateForYMD(String b)
{
if (b.length() > 10)
{
return b.substring(0, 10);
}
return b;
}
public static String getMySqlDateWithoutZero(String date)
{
if (FlowBaseUtil.isEmpty(date))
{
return "";
}
if (date.endsWith(".0"))
{
return date.substring(0, date.length() - 2);
}
return date;
}
public static int differentDays(Date date1, Date date2)
{
Calendar cal1 = Calendar.getInstance();
cal1.setTime(date1);
Calendar cal2 = Calendar.getInstance();
cal2.setTime(date2);
int day1 = cal1.get(Calendar.DAY_OF_YEAR);
int day2 = cal2.get(Calendar.DAY_OF_YEAR);
int year1 = cal1.get(Calendar.YEAR);
int year2 = cal2.get(Calendar.YEAR);
if (year1 != year2) // 同一年
{
int timeDistance = 0;
for (int i = year1; i < year2; i++)
{
if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0) // 闰年
{
timeDistance += 366;
} else
// 不是闰年
{
timeDistance += 365;
}
}
return timeDistance + (day2 - day1);
} else
// 不同年
{
return day2 - day1;
}
}
public static String getNextSpecifyMinuteTime(int minute)
{
long currentTime = System.currentTimeMillis();
currentTime += minute * 60 * 1000;
Date date = new Date(currentTime);
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return dateFormat.format(date);
}
public static String getNextSpecifyMinuteTime(String date, String minute)
{
SimpleDateFormat sj = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date d;
try
{
d = sj.parse(date);
Calendar calendar = Calendar.getInstance();
calendar.setTime(d);
calendar.add(Calendar.MINUTE, Integer.valueOf(minute));
return sj.format(calendar.getTime());
} catch (ParseException e)
{
e.printStackTrace();
}
return null;
}
public static String getIntervalDayTime(String startTime, int day)
{
SimpleDateFormat sj = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date d;
try
{
d = sj.parse(startTime);
Calendar calendar = Calendar.getInstance();
calendar.setTime(d);
calendar.add(Calendar.DATE, day);
return sj.format(calendar.getTime());
} catch (ParseException e)
{
e.printStackTrace();
}
return null;
}
public static String stampToDate(String s)
{
try
{
String res;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
long lt = new Long(s + "000");
Date date = new Date(lt);
res = simpleDateFormat.format(date);
return res;
} catch (Exception e)
{
log.error(e.getMessage(), e);
return "";
}
}
/*
* 将时间转换为时间戳
*/
public static String dateToStamp(String s)
{
try
{
String res;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date;
date = simpleDateFormat.parse(s);
long ts = date.getTime();
res = String.valueOf(ts);
return res;
} catch (ParseException e)
{
log.error(e.getMessage(), e);
return s;
}
}
/**
* 获取两个日期相差天数
*
* @param day1
* @param day2
* @return
*/
public static long getDifferentDay(String day1, String day2)
{
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try
{
return (simpleDateFormat.parse(day2).getTime() - simpleDateFormat.parse(day1).getTime()) / 1000;
} catch (ParseException e)
{
log.error(e.getMessage(), e);
return 0;
}
}
public static int getMaxDayByYearMonth(String year, String month)
{
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, Integer.valueOf(year));
calendar.set(Calendar.MONTH, Integer.valueOf(month) - 1);
return calendar.getActualMaximum(Calendar.DATE);
}
/**
* 当前月的第一天是星期几 周日是0,周一是1
*
* @return
*/
public static int getMonthFirst()
{
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.DAY_OF_MONTH, 1);
return calendar.get(Calendar.DAY_OF_WEEK) - 1;
}
/**
* 获取两个日期相差分钟数
*
* @param day1
* @param day2
* @return
*/
public static long getDifferentMinute(String day1, String day2)
{
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try
{
return (simpleDateFormat.parse(day2).getTime() - simpleDateFormat.parse(day1).getTime()) / 60 / 1000;
} catch (ParseException e)
{
return 0;
}
}
public static List<String> findDates(String beginTime, String endTime)
{
try
{
List<String> allDate = new ArrayList<String>();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date dBegin = sdf.parse(beginTime);
Date dEnd = sdf.parse(endTime);
allDate.add(sdf.format(dBegin));
Calendar calBegin = Calendar.getInstance();
// 使用给定的 Date 设置此 Calendar 的时间
calBegin.setTime(dBegin);
Calendar calEnd = Calendar.getInstance();
// 使用给定的 Date 设置此 Calendar 的时间
calEnd.setTime(dEnd);
// 测试此日期是否在指定日期之后
while (dEnd.after(calBegin.getTime()))
{
// 根据日历的规则,为给定的日历字段添加或减去指定的时间量
calBegin.add(Calendar.DAY_OF_MONTH, 1);
allDate.add(sdf.format(calBegin.getTime()));
}
return allDate;
} catch (Exception e)
{
log.error(e.getMessage(), e);
}
return new ArrayList<String>();
}
/**
* 是否是周末
*
* @param bDate
* @return
* @throws ParseException
*/
public static boolean isWeekend(String bDate)
{
try
{
DateFormat format1 = new SimpleDateFormat("yyyy-MM-dd");
Date bdate = format1.parse(bDate);
Calendar cal = Calendar.getInstance();
cal.setTime(bdate);
if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)
{
return true;
} else
{
return false;
}
} catch (ParseException e)
{
log.error(e.getMessage(), e);
return false;
}
}
public static void main(String[] args) throws ParseException
{
System.out.println(getDifferentDay("2019-10-26 00:00:00", "2019-10-27 00:00:00"));
}
}
获取表的后缀
public class ShardTableUtil
{
/**
* 获取数据所在表后缀
*
* @param tableName
* 目标表
* @param startTime
* 数据开始时间
* @param endTime
* 数据结束时间
* @param userId
* 用户编号
* @param businessId
* 业务编号
* @return
*/
public static String getDestTableSuffixByCondition(String tableName, String startTime, String endTime)
{
String suffix = "_" + DateUtils.getThisYear();
if (SystemTypeConfig.isTableShard(tableName))
{
if (FlowBaseUtil.isNotEmpty(startTime))
{
String year = startTime.substring(0, 4);
if (StringUtils.isInt(year))
{
if ((Integer.valueOf(year) < Integer.valueOf(SystemTypeConfig.getMysql_shard_tables_minyear())) || (Integer.valueOf(year) > Integer.valueOf(SystemTypeConfig.getMysql_shard_tables_maxyear())))
{
return suffix;
}
} else
{
return suffix;
}
}
if (FlowBaseUtil.isNotEmpty(startTime) && FlowBaseUtil.isNotEmpty(endTime))
{
String year1 = startTime.substring(0, 4);
String year2 = endTime.substring(0, 4);
if (year1.equals(year2))
{
suffix = "_" + year1;
}
} else if (FlowBaseUtil.isNotEmpty(startTime) && FlowBaseUtil.isEmpty(endTime))
{
suffix = "_" + startTime.substring(0, 4);
} else if (FlowBaseUtil.isEmpty(startTime) && FlowBaseUtil.isNotEmpty(endTime))
{
suffix = "_" + endTime.substring(0, 4);
} else if (FlowBaseUtil.isEmpty(startTime) && FlowBaseUtil.isEmpty(endTime))
{
return "_" + DateUtils.getThisYear();
}
}
return suffix;
}
public static boolean isConditionInYearRegion(String condition)
{
if (FlowBaseUtil.isNotEmpty(condition))
{
if (condition.length() > 4)
{
String year = condition.substring(0, 4);
if ((Integer.valueOf(year) >= Integer.valueOf(SystemTypeConfig.getMysql_shard_tables_minyear())) && (Integer.valueOf(year) <= Integer.valueOf(SystemTypeConfig.getMysql_shard_tables_maxyear())))
{
return true;
}
}
}
return false;
}
}