You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
weaver-develop/interface.kr/updateJbHours.jsp

73 lines
2.0 KiB
Plaintext

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="weaver.general.Util" %>
<jsp:useBean id="bb" class="weaver.general.BaseBean"/>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="com.alibaba.fastjson.JSONArray" %>
<%@ page import="java.util.Date" %>
<%@ page import="com.time.util.DateUtil" %>
<%--
User: wangj
Design Ideas
康瑞-加班申请【制造中心】流程
需要:批量修改计算 加班时长 记录
测试环境表名formtable_main_24
生产环境表名formtable_main_20
--%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%
JSONObject res = new JSONObject();
RecordSet rs = new RecordSet();
int count = 0;
String sql = "select id,ksrq,kssj,jsrq,jssj from formtable_main_20_dt1 where jbsc is null";
rs.execute(sql);
while (rs.next()){
String id = Util.null2String(rs.getString("id"));
String ksrq = Util.null2String(rs.getString("ksrq"));
String kssj = Util.null2String(rs.getString("kssj"));
String jsrq = Util.null2String(rs.getString("jsrq"));
String jssj = Util.null2String(rs.getString("jssj"));
if("".equals(ksrq)||"".equals(kssj)||"".equals(jsrq)||"".equals(jssj)){
continue;
}
double jbsc = getHours(ksrq,kssj,jsrq,jssj);
updateJbsc(id,jbsc);
count ++;
}
res.put("count", count);
out.print(res.toJSONString());
%>
<%!
private double getHours(String ksrq,String kssj,String jsrq,String jssj){
double hour = 0.00;
Date sdate = DateUtil.parseDate(ksrq+" "+kssj, "yyyy-MM-dd HH:mm");
Date edate = DateUtil.parseDate(jsrq+" "+jssj, "yyyy-MM-dd HH:mm");
hour = (Math.abs(sdate.getTime() - edate.getTime())/1800000);
hour = hour/2;
return hour;
}
%>
<%!
private void updateJbsc(String id, double jbsc){
RecordSet rs = new RecordSet();
rs.executeUpdate("update formtable_main_20_dt1 set jbsc = ? where id = ?",jbsc,id);
}
%>