public String checkWorkLog(String data,HttpServletRequest request){
JSONObject result = new JSONObject() ;
JSONObject dataJsonObject = JSONObject.fromObject(data);
String date = dataJsonObject.getString("date") ;
String userId = CommonUtils.getSessionUserId(request).toString() ;
Calendar cal = Calendar.getInstance() ;
String preDate = "" ,currentDate = "",isRepeate="0",flag = "0";
currentDate = DateUtils.convertDateToString("yyyy-MM-dd",cal.getTime()) ;
String currenttime = DateUtils.convertDateToString("HH:mm",cal.getTime()) ;
cal.add(Calendar.HOUR,-24) ;
preDate = DateUtils.convertDateToString("yyyy-MM-dd",cal.getTime()) ;
DbOpt dbopt = new DbOpt() ;
try{
//判断日志是否重复填写
String isRepeat = dbopt.executeQueryToStr("select count(whir$rz_id) from whir$rz where whir$rz_owner=? and whir$rz_rq=?"
, new Object[]{userId,date}) ;
if(!"0".equals(isRepeat)){//日志重复填写
isRepeate = "1";
}else{
if(date.compareTo(currentDate)>0){//提交日期大于当前日期
flag = "1" ;
}else if(date.compareTo(preDate)<0){//提交日期小于前一天
flag = "2" ;
}else if(date.equals(preDate) && currenttime.compareTo("12:00")>0){
flag = "3" ;
}
}
}catch(Exception e){
}finally{
if(dbopt != null){
try {
dbopt.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
result.put("isRepeate",isRepeate) ;
result.put("flag",flag) ;
return result.toString() ;
}
JSONObject result = new JSONObject() ;
JSONObject dataJsonObject = JSONObject.fromObject(data);
String date = dataJsonObject.getString("date") ;
String userId = CommonUtils.getSessionUserId(request).toString() ;
Calendar cal = Calendar.getInstance() ;
String preDate = "" ,currentDate = "",isRepeate="0",flag = "0";
currentDate = DateUtils.convertDateToString("yyyy-MM-dd",cal.getTime()) ;
String currenttime = DateUtils.convertDateToString("HH:mm",cal.getTime()) ;
cal.add(Calendar.HOUR,-24) ;
preDate = DateUtils.convertDateToString("yyyy-MM-dd",cal.getTime()) ;
DbOpt dbopt = new DbOpt() ;
try{
//判断日志是否重复填写
String isRepeat = dbopt.executeQueryToStr("select count(whir$rz_id) from whir$rz where whir$rz_owner=? and whir$rz_rq=?"
, new Object[]{userId,date}) ;
if(!"0".equals(isRepeat)){//日志重复填写
isRepeate = "1";
}else{
if(date.compareTo(currentDate)>0){//提交日期大于当前日期
flag = "1" ;
}else if(date.compareTo(preDate)<0){//提交日期小于前一天
flag = "2" ;
}else if(date.equals(preDate) && currenttime.compareTo("12:00")>0){
flag = "3" ;
}
}
}catch(Exception e){
}finally{
if(dbopt != null){
try {
dbopt.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
result.put("isRepeate",isRepeate) ;
result.put("flag",flag) ;
return result.toString() ;
}
解决方案 »
- JSP—input fileSelected问题
- Linxu下验证码无法显示
- 刷新后取不到值
- 急,请大家帮下忙!
- 新手求救
- 我要做个博客,可不知道怎么写,请好心的你帮帮我(javaweb -struts-hibernate-spring)
- 一个N简单的问题!!!!!
- 请教。
- 高手请进!!请问在jdk1.3.1中有没有JdbcOdbcDriver?是不是没有象jdk1.4那样的java plug in?
- 大家看看这段 javamail发送邮件的代码那里错了阿??????谢谢,一定给分!!!!!!!!!
- 系统首页的导航在iframe框架中,点击之后怎么实现各个页面的重定向
- javaWeb项目写好了,Godaddy买了域名和虚拟主机,要怎么部署?
(oracle/sql)
with tab1 as (
select 1 user_id, to_date('2019030813', 'yyyymmddhh24') dt from dual union all
select 2 user_id, to_date('2019030713', 'yyyymmddhh24') dt from dual
)
select decode(count(1), 0, '不可补写', '可以') "flag"
from tab1 t1
where t1.user_id = 1
and (trunc(t1.dt) = trunc(sysdate, 'd') - 2
and to_char(sysdate, 'd') = 2
and to_number(to_char(sysdate, 'hh24')) < 12)
;