|
|
|
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
|
|
|
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
|
|
|
<%@ page import="weaver.conn.RecordSet" %>
|
|
|
|
<%@ page import="weaver.general.Util" %>
|
|
|
|
<%@ page import="weaver.hrm.User" %>
|
|
|
|
<%@ page import="java.time.LocalDate" %>
|
|
|
|
<%@ page import="weaver.general.TimeUtil" %>
|
|
|
|
<%@ page import="java.util.Map" %>
|
|
|
|
<%@ page import="java.util.HashMap" %>
|
|
|
|
<%@ page import="com.alibaba.fastjson.JSON" %>
|
|
|
|
<%@ page import="java.util.UUID" %>
|
|
|
|
<%@ page import="weaver.formmode.setup.ModeRightInfo" %>
|
|
|
|
<%@ page import="com.engine.kq.biz.KQReportBiz" %>
|
|
|
|
<%@ page import="com.engine.kq.util.KQDurationCalculatorUtil" %>
|
|
|
|
<%@ page import="weaver.interfaces.dfjc.entity.KqMonthDataPO" %>
|
|
|
|
|
|
|
|
|
|
|
|
<%
|
|
|
|
|
|
|
|
Map<String, Object> data = new HashMap<>();
|
|
|
|
String ids = Util.null2String(request.getParameter("ids"));
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
rs.execute(" select xm,status,bm,gw,kqy from uf_ydgs a,hrmresource b where a.xm=b.id and a.id in ("+ids+") ");
|
|
|
|
while(rs.next()){
|
|
|
|
String xm = Util.null2String(rs.getString("xm"));
|
|
|
|
String zt = Util.null2String(rs.getString("status"));
|
|
|
|
String bm = Util.null2String(rs.getString("bm"));
|
|
|
|
String gw = Util.null2String(rs.getString("gw"));
|
|
|
|
String kqy = Util.null2String(rs.getString("kqy"));
|
|
|
|
|
|
|
|
LocalDate localDate = LocalDate.parse(kqy+"-01");
|
|
|
|
String fromDate = localDate.toString();
|
|
|
|
String toDate = localDate.withDayOfMonth(localDate.lengthOfMonth()).toString();
|
|
|
|
|
|
|
|
Map<String,Object> flowData = getKqOvertimeData(fromDate,toDate,xm);
|
|
|
|
|
|
|
|
|
|
|
|
double psjbbdx = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(xm+"|workingDayOvertime_nonleave"))),0);
|
|
|
|
double xxrjbbdx = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(xm+"|restDayOvertime_nonleave"))),0);
|
|
|
|
double jjrjbbdx = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(xm+"|holidayOvertime_nonleave"))),0);
|
|
|
|
double dkzgs = Util.getDoubleValue(Util.null2String(getWorkHours(fromDate,toDate,xm)),0);
|
|
|
|
|
|
|
|
//获取出差时长
|
|
|
|
double ccxs = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(xm+"|businessLeave"))),0);
|
|
|
|
|
|
|
|
double zgs = psjbbdx+xxrjbbdx+jjrjbbdx+dkzgs+ccxs;
|
|
|
|
|
|
|
|
|
|
|
|
KqMonthDataPO kqMonthDataPO = KqMonthDataPO.builder()
|
|
|
|
.resourceId(xm)
|
|
|
|
.status(zt)
|
|
|
|
.departmentId(bm)
|
|
|
|
.jobTitle(gw)
|
|
|
|
.psjbbdx(psjbbdx)
|
|
|
|
.xxrjbbdx(xxrjbbdx)
|
|
|
|
.jjrjbbdx(jjrjbbdx)
|
|
|
|
.dkzgs(dkzgs)
|
|
|
|
.zgs(zgs)
|
|
|
|
.ccxs(ccxs)
|
|
|
|
.build();
|
|
|
|
System.out.println("KqMonthReportSynByUser==>"+JSON.toJSONString(kqMonthDataPO));
|
|
|
|
saveData(kqMonthDataPO,kqy);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
data.put("success",true);
|
|
|
|
out.println(JSON.toJSONString(data));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%>
|
|
|
|
|
|
|
|
|
|
|
|
<%!
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取加班数据
|
|
|
|
* @param fromDate
|
|
|
|
* @param toDate
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public Map<String,Object> getKqOvertimeData(String fromDate,String toDate,String resourceId){
|
|
|
|
User user = User.getUser(1,0);
|
|
|
|
Map<String,Object> params = new HashMap<>();
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
|
|
|
jsonObject.put("isNoAccount","1");
|
|
|
|
jsonObject.put("attendanceSerial","");
|
|
|
|
jsonObject.put("status","9");
|
|
|
|
jsonObject.put("viewScope","0");
|
|
|
|
jsonObject.put("typeselect","6");
|
|
|
|
jsonObject.put("fromDate",fromDate);
|
|
|
|
jsonObject.put("toDate",toDate);
|
|
|
|
jsonObject.put("resourceId",resourceId);
|
|
|
|
params.put("data",jsonObject);
|
|
|
|
|
|
|
|
|
|
|
|
KQReportBiz kqReportBiz = new KQReportBiz();
|
|
|
|
Map<String,Object> flowData = kqReportBiz.getFlowData(params,user);
|
|
|
|
return flowData;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取实际打卡时长
|
|
|
|
* @param fromDate
|
|
|
|
* @param toDate
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String getWorkHours(String fromDate,String toDate,String xm){
|
|
|
|
String workhours = "";
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
String sql = " select xm,sum(sjgssc) workhours from uf_kqgs where kqrq>=? and kqrq<=? and xm=? group by xm ";
|
|
|
|
rs.executeQuery(sql,fromDate,toDate,xm);
|
|
|
|
while (rs.next()){
|
|
|
|
workhours = Util.null2String(rs.getString("workhours"));
|
|
|
|
}
|
|
|
|
return workhours;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 同步数据到建模表
|
|
|
|
* @param kqMonthDataPO
|
|
|
|
* @param month
|
|
|
|
*/
|
|
|
|
public void saveData(KqMonthDataPO kqMonthDataPO,String month){
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
int formmodeid = getModeIdByTableName("uf_ydgs");
|
|
|
|
int modedatacreater = 1;
|
|
|
|
|
|
|
|
String xm = kqMonthDataPO.getResourceId();
|
|
|
|
String zt = kqMonthDataPO.getStatus();
|
|
|
|
String bm = kqMonthDataPO.getDepartmentId();
|
|
|
|
String gw = kqMonthDataPO.getJobTitle();
|
|
|
|
Double dkzgs = kqMonthDataPO.getDkzgs();
|
|
|
|
Double psjbbdx = kqMonthDataPO.getPsjbbdx();
|
|
|
|
Double xxrjbbdx = kqMonthDataPO.getXxrjbbdx();
|
|
|
|
Double jjrjbbdx = kqMonthDataPO.getJjrjbbdx();
|
|
|
|
Double zgs = kqMonthDataPO.getZgs();
|
|
|
|
Double ccxs = kqMonthDataPO.getCcxs();
|
|
|
|
|
|
|
|
|
|
|
|
boolean exist = isExist(month,kqMonthDataPO.getResourceId());
|
|
|
|
if(exist){
|
|
|
|
//更新
|
|
|
|
String updateSql = " update uf_ydgs set dkzgs=?, psjbbdx=?, xxrjbbdx=?, jjrjbbdx=?, zgs=?, zt=?, ccxs=? where xm=? and kqy=? ";
|
|
|
|
rs.executeUpdate(updateSql,new Object[]{dkzgs,psjbbdx,xxrjbbdx,jjrjbbdx,zgs,zt,ccxs,xm,month});
|
|
|
|
|
|
|
|
}else{
|
|
|
|
//插入
|
|
|
|
String modeuuid = UUID.randomUUID().toString();
|
|
|
|
String modedatacreatedate = TimeUtil.getCurrentDateString();
|
|
|
|
String modedatacreatetime = TimeUtil.getOnlyCurrentTimeString();
|
|
|
|
|
|
|
|
String insertSql = " insert into uf_ydgs(xm,bm,gw,kqy,dkzgs,psjbbdx,xxrjbbdx,jjrjbbdx,zgs,zt,ccxs,"+
|
|
|
|
"formmodeid,modedatacreater,modedatacreatedate,modedatacreatetime,modeuuid) " +
|
|
|
|
" values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) ";
|
|
|
|
rs.executeUpdate(insertSql,new Object[]{xm,bm,gw,month,dkzgs,psjbbdx,xxrjbbdx,jjrjbbdx,zgs,zt,ccxs,
|
|
|
|
formmodeid,modedatacreater,modedatacreatedate,modedatacreatetime,modeuuid});
|
|
|
|
|
|
|
|
rs.executeQuery("select id from uf_ydgs where modeuuid=?",modeuuid);
|
|
|
|
rs.next();
|
|
|
|
int id = rs.getInt("id");
|
|
|
|
if(id>0){
|
|
|
|
ModeRightInfo right = new ModeRightInfo();
|
|
|
|
right.editModeDataShare(1, formmodeid, id);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 判断数据是否存在
|
|
|
|
* @param month
|
|
|
|
* @param userid
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public boolean isExist(String month,String userid){
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
String sql = " select 1 from uf_ydgs where kqy=? and xm=? ";
|
|
|
|
rs.executeQuery(sql,month,userid);
|
|
|
|
return rs.next();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 根据建模表名获取建模id,建模权限同步的使用
|
|
|
|
* @param tableName 建模表名
|
|
|
|
* @return int 建模id
|
|
|
|
*/
|
|
|
|
public static int getModeIdByTableName(String tableName){
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
String sql = " select a.id from modeinfo a,workflow_bill b where a.formid=b.id and b.tablename =? ";
|
|
|
|
rs.executeQuery(sql, tableName);
|
|
|
|
if (rs.next()) {
|
|
|
|
return rs.getInt("id");
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
%>
|