您的位置:首页 > 其它

工作上常用的tips

2017-09-21 14:43 211 查看
Date bDate = checkReportDto.getSearchBeginDate();
Date eDate = checkReportDto.getSearchEndDate();
if (bDate==null) {
Calendar calendar = Calendar.getInstance();//是获取一个   Calendar对象并可以进行时间的计算
Date date = new Date(); //是创建了一个date对象,默认是utc格式的
calendar.setTime(date);
calendar.add(Calendar.YEAR, -1);//把时间前推一年
bDate =calendar.getTime();//这里的bDate实际上就是获取的是去年的这个时候
}
if (eDate==null) {
eDate = new Date();
}
if(bDate!=null) {
if(eDate!=null){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); String bs = sdf.format(bDate);//时间转格式
String es = sdf.format(eDate);
hqlStr.append("and (t.check_date between to_date('"+bs+"','yyyy-MM-dd') and to_date('"+es+"','yyyy-MM-dd')) "); }
}
hqlStr.append(" order by t.check_date desc ");


String bs = sdf.format(bDate); //时间转格式

String es = sdf.format(eDate);

这里时间转格式是很重要的,不然在本地能运行,放到服务器就会报错:

调用InsReportBlh.list发生异常PreparedStatementCallback; SQL [ select count(t.id) from cohealth.t_ins_report t, cohealth.t_family_member f where t.familymember_id=f.familymember_id and t.main_idnumber=? and t.mainchild_flag=? and (t.ins_date between ? and ?) ]; ORA-01843: not a valid month

; nested exception is java.sql.SQLException: ORA-01843: not a valid month

正则写法

var reg =/^([1-9]\d{0,2})(\.\d{1,1})?$/;
if (!reg.test(weightValue)) {
if(Number(wei
95ea
ghtValue) > 999){
alertMessage01("您已超级肥胖,改减肥了!");
}else if(Number(weightValue) > 200){
alertMessage01("您已很肥胖,改减肥了!");
}else{
alertMessage01("体重填写有误,只能输入大于0的正数或带一位小数的正数");
}

return;
}


Dialog设置样式

function alertMessage01(html){
$("#messageHtml").html('<b>'+html+'</b>');
var dialog = $("#dialog-message").removeClass('hide').dialog({
resizable: false,
modal: true,
position: { using:function(pos){
console.log(pos)
var topOffset = $(this).css(pos).offset().top;
if (topOffset = 0||topOffset>0) {
$(this).css('top', 100); //设置样式 !
}
}},
title: "<div class='widget-header widget-header-small'><h4 class='smaller'><i class='ace-icon fa fa-rss orange'></i> 消息提示</h4></div>",
title_html: true,
});


关于接口对接:

1.在application.properties文件中添加接口的服务器地址



2.在后台文件中引入所需要的类文件的地址



3.新建一个vo类(要引入),放从接口传来的数据并且在dto中进行封装



4.请求接口







(如果是单独的数据或者只去某条数据,就不用这么麻烦,还写循环啥的,就直接从response里面取然后set进vo中)

5.action返回

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: