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-hostar/src/com/engine/kq/biz/KQReportBiz.java

4031 lines
180 KiB
Java

package com.engine.kq.biz;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
1 year ago
import com.engine.hostar.util.HostarUtil;
1 year ago
import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean;
import com.engine.kq.cmd.attendanceButton.ButtonStatusEnum;
1 year ago
import com.engine.kq.entity.TimeScopeEntity;
import com.engine.kq.entity.WorkTimeEntity;
import com.engine.kq.enums.KqSplitFlowTypeEnum;
import com.engine.kq.log.KQLog;
import com.engine.kq.util.KQDurationCalculatorUtil;
import java.text.DecimalFormatSymbols;
import java.util.Map.Entry;
import com.engine.kq.util.KQTransMethod;
1 year ago
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
1 year ago
import com.weaver.integration.ldap.sync.formart.OaFormart;
import org.apache.commons.lang3.StringUtils;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.file.Prop;
import weaver.general.BaseBean;
1 year ago
import weaver.general.InitServer;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;
1 year ago
import javax.ejb.Remove;
import java.text.DecimalFormat;
import java.util.*;
public class KQReportBiz extends BaseBean {
private static DecimalFormat df = new DecimalFormat("0.00");
private DecimalFormatSymbols symbols = new DecimalFormatSymbols();
public String format(double value) {
// DecimalFormatSymbols symbols = new DecimalFormatSymbols();
symbols.setDecimalSeparator('.');
df.setMaximumFractionDigits(5);
df.setDecimalFormatSymbols(symbols);
return df.format(value);
}
private KQLog kqLog = new KQLog();
1 year ago
BaseBean bb = new BaseBean();
/**
*
*/
public void initKQReportData(){
String date = DateUtil.getCurrentDate();
RecordSet rs = new RecordSet();
String sql = "";
try{
boolean hasInit = false;
sql = "select 1 from kq_report_check where check_date = ? ";
rs.executeQuery(sql,date);
if(rs.next()) {
hasInit = true;
}
String beforeyesterday = DateUtil.addDate(date,-2);
String yesterday = DateUtil.addDate(date,-1);
if(!hasInit){
//这里做过功能是每天都刷下考勤缓存 因为这个缓存也是异步的,一点都不稳定
kqLog.info("begin do KQOneStopUp refreshCominfo invoke ...");
new KQOneStopUp().refreshCominfo();
kqLog.info("end do KQOneStopUp refreshCominfo invoke ...");
KQFormatBiz kqFormatBiz = new KQFormatBiz();
kqFormatBiz.clearFormatPool();
//格式化上上天数据
kqFormatBiz.formatDateByKQDate(beforeyesterday);
//格式化上一天数据
kqFormatBiz.formatDateByKQDate(yesterday);
//初始化今天数据
kqFormatBiz.formatDateByKQDate(date);
sql = " insert into kq_report_check(check_date) values (?)";
rs.executeUpdate(sql,date);
writeLog(date+"执行考勤报表数据格式化成功!");
}
}catch (Exception e){
writeLog(e);
}
}
public Map<String, String> getModel_ShiftRule(String i,String serialId) {
RecordSet rs = new RecordSet();
HashMap<String,String> sectionMap = new HashMap<>();
String getStartWorkSections = "select * from kq_ShiftOnOffWorkSections where SERIALID=? and record=? ";
rs.executeQuery(getStartWorkSections,serialId,i);
while (rs.next()) {
String onoffworktype = Util.null2String(rs.getString("onoffworktype"));
String clockinnot = Util.null2s(Util.null2String(rs.getString("clockinnot")), "0");
sectionMap.put(onoffworktype, clockinnot);
}
return sectionMap;
}
/***
*
* @param resourceId
* @param fromdate
* @param todate
* @param isAll
* @return
*/
public List<Object> getKqDateInfo(String resourceId, String fromdate, String todate, boolean isAll) {
List<Object> kqdates = new ArrayList<>();
RecordSet rs = new RecordSet();
String sql = "";
try {
Map<String, Object> kqdate = null;
List<Object> datas = null;
Map<String,Object> data = null;
sql = " select kqdate,serialid, workbegindate, workbegintime,workenddate, workendtime," +
" signintime,signouttime,beLateMins,graveBeLateMins,leaveEarlyMins,graveLeaveEarlyMins," +
" absenteeismMins, forgotCheckMins,forgotBeginWorkCheckMins,otherinfo,serialnumber "+
" from kq_format_detail " +
" where resourceid=? and kqdate>=? and kqdate<=? ";
if(!isAll){
if(rs.getDBType().equalsIgnoreCase("oracle") || Util.null2String(rs.getOrgindbtype()).equals("dm") || Util.null2String(rs.getOrgindbtype()).equals("st")) {
sql += " and nvl(beLateMins,0)+nvl(graveBeLateMins,0)+nvl(leaveEarlyMins,0)+nvl(graveLeaveEarlyMins,0)+nvl(absenteeismMins,0)+nvl(forgotCheckMins,0)+nvl(forgotBeginWorkCheckMins,0)>0 ";
}else if((rs.getDBType()).equalsIgnoreCase("mysql")){
sql += " and ifnull(beLateMins,0)+ifnull(graveBeLateMins,0)+ifnull(leaveEarlyMins,0)+ifnull(graveLeaveEarlyMins,0)+ifnull(absenteeismMins,0)+ifnull(forgotCheckMins,0)+ifnull(forgotBeginWorkCheckMins,0)>0 ";
}else {
sql += " and isnull(beLateMins,0)+isnull(graveBeLateMins,0)+isnull(leaveEarlyMins,0)+isnull(graveLeaveEarlyMins,0)+isnull(absenteeismMins,0)+isnull(forgotCheckMins,0)+isnull(forgotBeginWorkCheckMins,0)>0 ";
}
}
sql += " order by kqdate ";
rs.executeQuery(sql,resourceId,fromdate, todate);
while(rs.next()){
String serialnumber = Util.null2String(rs.getString("serialnumber"));
1 year ago
String serialid = Util.null2String(rs.getString("serialid"));
String workbegindate = Util.null2String(rs.getString("workbegindate"));
String workbegintime = Util.null2String(rs.getString("workbegintime"));
String workenddate = Util.null2String(rs.getString("workenddate"));
String workendtime = Util.null2String(rs.getString("workendtime"));
String signintime = Util.null2String(rs.getString("signintime"));
String signouttime = Util.null2String(rs.getString("signouttime"));
int beLateMins = rs.getInt("beLateMins");
int graveBeLateMins = rs.getInt("graveBeLateMins");
int leaveEarlyMins = rs.getInt("leaveEarlyMins");
int graveLeaveEarlyMins = rs.getInt("graveLeaveEarlyMins");
int absenteeismMins = rs.getInt("absenteeismMins");
int forgotCheckMins = rs.getInt("forgotCheckMins");
int forgotBeginWorkCheckMins = rs.getInt("forgotBeginWorkCheckMins");
String otherinfo = Util.null2String(rs.getString("otherinfo"));
String shift_begindate = "";
String shift_beginworktime = "";
String shift_enddate = "";
String shift_endworktime = "";
if(otherinfo.length() > 0){
JSONObject otherinfo_object = JSONObject.parseObject(otherinfo);
if(otherinfo_object != null && !otherinfo_object.isEmpty()){
JSONObject shiftRule = (JSONObject) otherinfo_object.get("shiftRule");
if(shiftRule != null && !shiftRule.isEmpty()){
shift_begindate = Util.null2String(shiftRule.get("shift_begindate"));
shift_beginworktime = Util.null2String(shiftRule.get("shift_beginworktime"));
shift_enddate = Util.null2String(shiftRule.get("shift_enddate"));
shift_endworktime = Util.null2String(shiftRule.get("shift_endworktime"));
if(shift_begindate.length() > 0){
workbegindate = shift_begindate;
}
if(shift_beginworktime.length() > 0){
workbegintime = shift_beginworktime;
}
if(shift_enddate.length() > 0){
workenddate = shift_enddate;
}
if(shift_endworktime.length() > 0){
workendtime = shift_endworktime;
}
}
}
}
kqdate = new HashMap<>();
datas = new ArrayList<>();
kqdate.put("kqdate",Util.null2String(rs.getString("kqdate")));
if(workbegindate.length()>0){
data = new HashMap<>();
data.put("workbegindate",workbegindate);
data.put("workbegintime",workbegintime);
data.put("signintime",signintime);
data.put("workenddate",workenddate);
data.put("workendtime",workendtime);
data.put("signouttime",signouttime);
String status = "";
if(beLateMins>0||graveBeLateMins>0){
status = ButtonStatusEnum.BELATE.getStatusCode();
}
if(forgotBeginWorkCheckMins>0){
if(status.length()>0)status+=",";
status += ButtonStatusEnum.NOSIGN_ON.getStatusCode();
}
if(leaveEarlyMins>0||graveLeaveEarlyMins>0){
if(status.length()>0)status+=",";
status += ButtonStatusEnum.LEAVEERALY.getStatusCode();
}
if(absenteeismMins>0){
int isondutyfreecheck =0;
int isoffdutyfreecheck =0;
Map<String, String> model_ShiftRule = getModel_ShiftRule(serialnumber, serialid);
Iterator iter = model_ShiftRule.entrySet().iterator();
while (iter.hasNext()) {
Entry entry = (Entry) iter.next();
String key = Util.null2String(entry.getKey());
String value = Util.null2String(entry.getValue());
if(key.equals("start")&&value.equals("1")){
isondutyfreecheck = 1;
}
if(key.equals("end")&&value.equals("1")){
isoffdutyfreecheck = 1;
}
}
data.put("start",isondutyfreecheck);
1 year ago
data.put("end",isoffdutyfreecheck);
if(status.length()>0)status+=",";
status += ButtonStatusEnum.ABSENT.getStatusCode();
}
if(forgotCheckMins>0){
if(status.length()>0)status+=",";
status += ButtonStatusEnum.NOSIGN.getStatusCode();
}
data.put("status",status);
datas.add(data);
}
kqdate.put("checkInfo",datas);
kqdates.add(kqdate);
}
} catch (Exception e) {
writeLog(e);
}
return kqdates;
}
/**
*
* @param reportType
* @param userId id
* @param tableExt
* @return
*/
public String getReportRight(String reportType, String userId, String tableExt){
String rightSql = "";
String sql = "";
RecordSet rs = new RecordSet();
try{
List<String> userAllUserIds = new ArrayList<>();
List<String> userAllDeptIds = new ArrayList<>();
List<String> userAllSubCompanyIds = new ArrayList<>();
List<String> userAllJobtitleIds = new ArrayList<>();
boolean forAllUser = false;
sql = " select sharelevel,subcomid, deptid,userid,jobtitleid,foralluser from kq_reportshare where resourceid=? ";
if(reportType.length()>0 ){
sql += " and (reportname =0 or reportname =" + reportType+")";
}
rs.executeQuery(sql,userId);
while(rs.next()){
int sharelevel = rs.getInt("sharelevel");
if(sharelevel==0){//分部
if(Util.null2String(rs.getString("subcomid")).length()>0){
userAllSubCompanyIds.add(rs.getString("subcomid"));
}
}else if(sharelevel==1){//部门
if(Util.null2String(rs.getString("deptid")).length()>0) {
userAllDeptIds.add(rs.getString("deptid"));
}
}else if(sharelevel==2){//人员
if(Util.null2String(rs.getString("userid")).length()>0) {
userAllUserIds.add(rs.getString("userid"));
}
}else if(sharelevel==3){//岗位
if(Util.null2String(rs.getString("jobtitleid")).length()>0) {
userAllJobtitleIds.add(rs.getString("jobtitleid"));
}
}else if(sharelevel==4){//所有人
forAllUser = true;
userAllUserIds.clear();
userAllDeptIds.clear();
userAllSubCompanyIds.clear();
userAllJobtitleIds.clear();
break;
}
}
if(!forAllUser) {
for (int sharelevel = 0; sharelevel < 4; sharelevel++) {
if (sharelevel == 0) {//分部
if (userAllSubCompanyIds.size() > 0) {
if(rightSql.length()>0)rightSql+= " or ";
rightSql += tableExt+".subcompanyid1 in(" + String.join(",", userAllSubCompanyIds) + ")";
}
} else if (sharelevel == 1) {//部门
if (userAllDeptIds.size() > 0) {
if(rightSql.length()>0)rightSql+= " or ";
rightSql += tableExt+".departmentid in(" + String.join(",", userAllDeptIds) + ")";
}
} else if (sharelevel == 2) {//人员
if (userAllUserIds.size() > 0) {
if(rightSql.length()>0)rightSql+= " or ";
rightSql += tableExt+".id in(" + String.join(",", userAllUserIds) + ")";
}
} else if (sharelevel == 3) {//岗位
if (userAllJobtitleIds.size() > 0) {
if(rightSql.length()>0)rightSql+= " or ";
rightSql += tableExt+".jobtitle in(" + String.join(",", userAllJobtitleIds) + ")";
}
}
}
//可以看自己和下属的考勤
String selfSql = " ("+tableExt+".id = "+userId+" or "+tableExt+".managerstr like '%,"+userId+",%')";
if(rightSql.length()>0){
rightSql = " and ((" +rightSql+") or "+selfSql+" ) ";
}else{
rightSql = " and "+selfSql;
}
}
}catch (Exception e){
writeLog(e);
}
return rightSql;
}
public static String getUnitType(KQReportFieldComInfo kqReportFieldComInfo, User user){
String unitTypeName = "";
String unitType = Util.null2String(kqReportFieldComInfo.getUnittype());
String parentid = Util.null2String( kqReportFieldComInfo.getParentid());
String fieldName = Util.null2String(kqReportFieldComInfo.getFieldname());
if(kqReportFieldComInfo.getIsLeaveType().equals("1")){
if(fieldName.equals("businessLeave")){
unitType = KQTravelRulesBiz.getMinimumUnit().equals("3")?"2":"1";//单位类型
}else if(fieldName.equals("officialBusiness")){
unitType = KQExitRulesBiz.getMinimumUnit().equals("3")?"2":"1";//单位类型
}else if(parentid.equals("overtime") || parentid.equals("overtime_nonleave") || parentid.equals("overtime_4leave")){
unitType = (KQOvertimeRulesBiz.getMinimumUnit()==3 || KQOvertimeRulesBiz.getMinimumUnit()==5 ||KQOvertimeRulesBiz.getMinimumUnit()==6)?"2":"1";//单位类型
}
}
if(Util.null2String(unitType).length()>0){
if(unitType.equals("1")){
unitTypeName=SystemEnv.getHtmlLabelName(1925, user.getLanguage());
}else if(unitType.equals("2")){
unitTypeName=SystemEnv.getHtmlLabelName(391, user.getLanguage());
}else if(unitType.equals("3")){
unitTypeName=SystemEnv.getHtmlLabelName(18083, user.getLanguage());
}
}
return unitTypeName;
}
/**
*
* @param params
* @param user
* @return
*/
public Map<String,Object> getDailyFlowData(Map<String,Object> params, User user){
Map<String,Object> datas = new HashMap<>();;
try{
datas.putAll(getDailyFlowLeaveData(params,user));
datas.putAll(getDailyFlowEvectionOutData(params,user));
datas.putAll(getDailyFlowOverTimeData(params,user));
datas.putAll(getDailyFlowLeaveBackData(params,user));
1 year ago
/*考勤二开--出差公出流程餐补统计start*/
datas.putAll(getDailyMealAllowanceData(params,user));
/*考勤二开--出差公出流程餐补统计end*/
1 year ago
// /*考勤二开--计算驻点餐补start*/
// datas.putAll(getDailyStatAllowanceData(params,user));
// /*考勤二开--计算驻点餐补end*/
1 year ago
/*考勤二开--计算精密夜班餐补start*/
1 year ago
datas.putAll(getDailyNightShiftAllowanceData(params,user));
/*考勤二开--计算精密夜班餐补end*/
1 year ago
/*考勤二开--计算鸿仁驻点餐补start*/
datas.putAll(getDailyOtherStatAllowanceData(params,user));
/*考勤二开--计算鸿仁驻点餐补end*/
}catch (Exception e){
writeLog(e);
}
return datas;
}
public Map<String,Object> getFlowData(Map<String,Object> params, User user){
Map<String,Object> datas = new HashMap<>();;
try{
datas.putAll(getFlowLeaveData(params,user));
datas.putAll(getFlowEvectionOutData(params,user));
datas.putAll(getFlowOverTimeDataNew(params,user));
datas.putAll(getFlowOtherData(params,user));
datas.putAll(getFlowLeaveBackData(params,user));
datas.putAll(getFlowProcessChangeData(params,user));
datas.putAll(getCardMap(params,user));
datas.putAll(getOverTime(params,user));
1 year ago
/*考勤二开--出差公出流程餐补统计start*/
datas.putAll(getDailyMealAllowanceData(params,user));
/*考勤二开--出差公出流程餐补统计end*/
1 year ago
/*考勤二开--计算驻点餐补start*/
// long startTime2 = System.currentTimeMillis();
// datas.putAll(getDailyStatAllowanceData(params,user));
// long endTime2 = System.currentTimeMillis();
// long elapsedTime2 = endTime2 - startTime2; // 执行时间
// bb.writeLog("计算驻点餐补执行时间:" + elapsedTime2 + "毫秒" );
1 year ago
/*考勤二开--计算驻点餐补end*/
/*考勤二开--计算精密夜班餐补start*/
datas.putAll(getDailyNightShiftAllowanceData(params,user));
/*考勤二开--计算精密夜班餐补end*/
/*考勤二开--计算鸿仁驻点餐补start*/
datas.putAll(getDailyOtherStatAllowanceData(params,user));
/*考勤二开--计算鸿仁驻点餐补end*/
1 year ago
}catch (Exception e){
writeLog(e);
}
return datas;
}
/**
*
* @param params
* @param user
* @return
*/
public Map<String,Object> getFlowEvectionOutData(Map<String,Object> params, User user){
Map<String,Object> datas = new HashMap<>();;
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try{
String[] tables = new String[]{KqSplitFlowTypeEnum.EVECTION.getTablename(),//出差
KqSplitFlowTypeEnum.OUT.getTablename()};//公出
String minimumUnit = "";//单位类型
double proportion = 0.00;//换算关系
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
String fromDate = Util.null2String(jsonObj.get("fromDate"));
String toDate = Util.null2String(jsonObj.get("toDate"));
String typeselect =Util.null2String(jsonObj.get("typeselect"));
if(typeselect.length()==0)typeselect = "3";
if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){
if(typeselect.equals("1")){
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
}else{
fromDate = TimeUtil.getDateByOption(typeselect,"0");
toDate = TimeUtil.getDateByOption(typeselect,"1");
}
}
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
String departmentId = Util.null2String(jsonObj.get("departmentId"));
String resourceId = Util.null2String(jsonObj.get("resourceId"));
String allLevel = Util.null2String(jsonObj.get("allLevel"));
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
String viewScope = Util.null2String(jsonObj.get("viewScope"));
if(subCompanyId.length()>0){
sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") ";
}
if(departmentId.length()>0){
sqlWhere +=" and a.departmentid in("+departmentId+") ";
}
if(resourceId.length()>0){
sqlWhere +=" and b.resourceid in("+resourceId+") ";
}
if(viewScope.equals("4")){//我的下属
if(allLevel.equals("1")){//所有下属
sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
}else{
sqlWhere+=" and a.managerid="+user.getUID();//直接下属
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
}
for(String table : tables){
sql = " select resourceid, durationrule, sum(duration) as val from hrmresource a, "+table+" b "+
" where a.id = b.resourceid and (b.status is null or b.status<>1) and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' "+sqlWhere+
" group by resourceid, durationrule ";
rs.execute(sql);
while (rs.next()) {
String resourceid = rs.getString("resourceid");
double value = rs.getDouble("val");
String durationrule = rs.getString("durationrule");
String flowType = "";
if(KqSplitFlowTypeEnum.EVECTION.getTablename().equals(table)){
flowType = "businessLeave";
minimumUnit = KQTravelRulesBiz.getMinimumUnit();//单位类型
proportion = Util.getDoubleValue(KQTravelRulesBiz.getHoursToDay());//换算关系
}else if(KqSplitFlowTypeEnum.OUT.getTablename().equals(table)){
flowType = "officialBusiness";
minimumUnit = KQExitRulesBiz.getMinimumUnit();//单位类型
proportion = Util.getDoubleValue(KQExitRulesBiz.getHoursToDay());//换算关系
}
if(KQUnitBiz.isLeaveHour(minimumUnit)){//按小时
if(!KQUnitBiz.isLeaveHour(durationrule)){
if(proportion>0) value = value*proportion;
}
}else{//按天
if(KQUnitBiz.isLeaveHour(durationrule)){
if(proportion>0) value = value/proportion;
}
}
String key = resourceid+"|"+flowType;
if(datas.containsKey(key)){
value += Util.getDoubleValue(Util.null2String(datas.get(key)));
}
//df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了
df.setMaximumFractionDigits(5);
datas.put(key, format(value));
}
}
}catch (Exception e){
writeLog(e);
}
return datas;
}
/**
*
* @param params
* @param user
* @return
*/
public Map<String,Object> getDailyFlowEvectionOutData(Map<String,Object> params, User user){
Map<String,Object> datas = new HashMap<>();;
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try{
String[] tables = new String[]{KqSplitFlowTypeEnum.EVECTION.getTablename(),//出差
KqSplitFlowTypeEnum.OUT.getTablename()};//公出
String minimumUnit = "";//单位类型
double proportion = 0.00;//换算关系
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
String fromDate = Util.null2String(jsonObj.get("fromDate"));
String toDate = Util.null2String(jsonObj.get("toDate"));
String typeselect =Util.null2String(jsonObj.get("typeselect"));
if(typeselect.length()==0)typeselect = "3";
if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){
if(typeselect.equals("1")){
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
}else{
fromDate = TimeUtil.getDateByOption(typeselect,"0");
toDate = TimeUtil.getDateByOption(typeselect,"1");
}
}
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
String departmentId = Util.null2String(jsonObj.get("departmentId"));
String resourceId = Util.null2String(jsonObj.get("resourceId"));
String allLevel = Util.null2String(jsonObj.get("allLevel"));
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
String viewScope = Util.null2String(jsonObj.get("viewScope"));
if(subCompanyId.length()>0){
sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") ";
}
if(departmentId.length()>0){
sqlWhere +=" and a.departmentid in("+departmentId+") ";
}
if(resourceId.length()>0){
sqlWhere +=" and b.resourceid in("+resourceId+") ";
}
if(viewScope.equals("4")){//我的下属
if(allLevel.equals("1")){//所有下属
sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
}else{
sqlWhere+=" and a.managerid="+user.getUID();//直接下属
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
}
for(String table : tables){
sql = " select resourceid, durationrule, sum(duration) as val,belongdate from hrmresource a, "+table+" b "+
" where a.id = b.resourceid and (b.status is null or b.status<>1) and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' "+sqlWhere+
" group by resourceid, durationrule,belongdate ";
rs.execute(sql);
while (rs.next()) {
String resourceid = rs.getString("resourceid");
String belongdate = rs.getString("belongdate");
double value = rs.getDouble("val");
String durationrule = rs.getString("durationrule");
String flowType = "";
if(KqSplitFlowTypeEnum.EVECTION.getTablename().equals(table)){
flowType = "businessLeave";
minimumUnit = KQTravelRulesBiz.getMinimumUnit();//单位类型
proportion = Util.getDoubleValue(KQTravelRulesBiz.getHoursToDay());//换算关系
}else if(KqSplitFlowTypeEnum.OUT.getTablename().equals(table)){
flowType = "officialBusiness";
minimumUnit = KQExitRulesBiz.getMinimumUnit();//单位类型
proportion = Util.getDoubleValue(KQExitRulesBiz.getHoursToDay());//换算关系
}
if(KQUnitBiz.isLeaveHour(minimumUnit)){//按小时
if(!KQUnitBiz.isLeaveHour(durationrule)){
if(proportion>0) value = value*proportion;
}
}else{//按天
if(KQUnitBiz.isLeaveHour(durationrule)){
if(proportion>0) value = value/proportion;
}
}
String key = resourceid+"|"+belongdate+"|"+flowType;
if(datas.containsKey(key)){
value += Util.getDoubleValue(Util.null2String(datas.get(key)));
}
//df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了
df.setMaximumFractionDigits(5);
datas.put(key, format(value));
}
}
}catch (Exception e){
writeLog(e);
}
return datas;
}
/**
*
* @param params
* @param user
* @return
*/
public Map<String,Object> getFlowLeaveData(Map<String,Object> params, User user){
Map<String,Object> datas = new HashMap<>();;
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try{
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
String fromDate = Util.null2String(jsonObj.get("fromDate"));
String toDate = Util.null2String(jsonObj.get("toDate"));
String typeselect =Util.null2String(jsonObj.get("typeselect"));
if(typeselect.length()==0)typeselect = "3";
if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){
if(typeselect.equals("1")){
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
}else{
fromDate = TimeUtil.getDateByOption(typeselect,"0");
toDate = TimeUtil.getDateByOption(typeselect,"1");
}
}
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
String departmentId = Util.null2String(jsonObj.get("departmentId"));
String resourceId = Util.null2String(jsonObj.get("resourceId"));
String allLevel = Util.null2String(jsonObj.get("allLevel"));
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
String viewScope = Util.null2String(jsonObj.get("viewScope"));
if(subCompanyId.length()>0){
sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") ";
}
if(departmentId.length()>0){
sqlWhere +=" and a.departmentid in("+departmentId+") ";
}
if(resourceId.length()>0){
sqlWhere +=" and b.resourceid in("+resourceId+") ";
}
if(viewScope.equals("4")){//我的下属
if(allLevel.equals("1")){//所有下属
sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
}else{
sqlWhere+=" and a.managerid="+user.getUID();//直接下属
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
}
sql = " select resourceid, newleavetype, durationrule, sum(duration) as val from hrmresource a, "+KqSplitFlowTypeEnum.LEAVE.getTablename()+" b "+
1 year ago
" where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere +
" group by resourceid, newleavetype, durationrule ";
rs.execute(sql);
while (rs.next()) {
String resourceid = rs.getString("resourceid");
String newleavetype = rs.getString("newleavetype");
String durationrule = rs.getString("durationrule");
double value = rs.getDouble("val")<0?0:rs.getDouble("val");
double proportion = Util.getDoubleValue(kqLeaveRulesComInfo.getProportion(newleavetype));
if(KQUnitBiz.isLeaveHour(newleavetype, kqLeaveRulesComInfo)){//按小时
if(!KQUnitBiz.isLeaveHour(durationrule)){
if(proportion>0) value = value*proportion;
}
}else{//按天
if(KQUnitBiz.isLeaveHour(durationrule)){
if(proportion>0) value = value/proportion;
}
}
String key = resourceid+"|leaveType_"+newleavetype;
if(datas.containsKey(key)){
value += Util.getDoubleValue(Util.null2String(datas.get(key)));
}
//df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了
df.setMaximumFractionDigits(5);
datas.put(key,format(value));
}
}catch (Exception e){
writeLog(e);
}
return datas;
}
//获取打卡数据用于判断外勤,补卡等信息===============================
public Map<String,Object> getCardMap(Map<String,Object> params, User user){
Map<String,Object> datas = new HashMap<>();;
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
//rs.writeLog("getCardMap="+ JSONObject.toJSONString(params));
try{
String show_card_source = Util.null2String(params.get("show_card_source"));
if(!"1".equals(show_card_source)){//下面的日历都是实时拼接,这里还是控制下数据库的交互次数,虽然用起来没啥用-.-
return datas;
}
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
KQTransMethod kqTransMethod = new KQTransMethod();
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
rs.writeLog("jsonObj="+ jsonObj.toJSONString());
String fromDate = Util.null2String(jsonObj.get("fromDate"));
String toDate = Util.null2String(jsonObj.get("toDate"));
String typeselect =Util.null2String(jsonObj.get("typeselect"));
if(typeselect.length()==0)typeselect = "3";
if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){
if(typeselect.equals("1")){
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
}else{
fromDate = TimeUtil.getDateByOption(typeselect,"0");
toDate = TimeUtil.getDateByOption(typeselect,"1");
}
}
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
String departmentId = Util.null2String(jsonObj.get("departmentId"));
String resourceId = Util.null2String(jsonObj.get("resourceId"));
String allLevel = Util.null2String(jsonObj.get("allLevel"));
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
String viewScope = Util.null2String(jsonObj.get("viewScope"));
if(subCompanyId.length()>0){
sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") ";
}
if(departmentId.length()>0){
sqlWhere +=" and a.departmentid in("+departmentId+") ";
}
if(resourceId.length()>0){
sqlWhere +=" and a.id in("+resourceId+") ";
}
if(viewScope.equals("4")){//我的下属
if(allLevel.equals("1")){//所有下属
sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
}else{
sqlWhere+=" and a.managerid="+user.getUID();//直接下属
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
}
//em7外勤、云桥外勤数据同步、钉钉外勤打卡、微信外勤转考勤补卡先留一个口子以防客户要
// sqlWhere += " and (signfrom like 'card%' or signfrom='e9_mobile_out' or signfrom='EMSyn_out' or signfrom='DingTalk_out' or signfrom='Wechat_out') ";
sql = " select a.id,b.signdate,b.id as signid,b.signfrom from hrmresource a, hrmschedulesign b "+
1 year ago
" where a.id = b.userid and b.signdate >='"+fromDate+"' and b.signdate <='"+toDate+"' " +sqlWhere +
" order by a.id,b.signdate ";
rs.execute(sql);
// kqLog.info("card.sql="+sql);
while (rs.next()) {
String resourceid = Util.null2String(rs.getString("id"));
String signdate = Util.null2String(rs.getString("signdate"));
String signid = Util.null2String(rs.getString("signid"));
String signfrom = Util.null2String(rs.getString("signfrom"));
String signFromShow = kqTransMethod.getSignFromShow(signfrom, ""+user.getLanguage());
String key = resourceid+"|"+signdate;
datas.put(signid,signFromShow);
}
}catch (Exception e){
writeLog(e);
}
return datas;
}
//获取打卡数据用于判断外勤,补卡等信息===============================
/**
*
* @param params
* @param user
* @return
*/
public Map<String,Object> getFlowLeaveBackData(Map<String,Object> params, User user){
Map<String,Object> datas = new HashMap<>();;
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try{
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
String fromDate = Util.null2String(jsonObj.get("fromDate"));
String toDate = Util.null2String(jsonObj.get("toDate"));
String typeselect =Util.null2String(jsonObj.get("typeselect"));
if(typeselect.length()==0)typeselect = "3";
if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){
if(typeselect.equals("1")){
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
}else{
fromDate = TimeUtil.getDateByOption(typeselect,"0");
toDate = TimeUtil.getDateByOption(typeselect,"1");
}
}
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
String departmentId = Util.null2String(jsonObj.get("departmentId"));
String resourceId = Util.null2String(jsonObj.get("resourceId"));
String allLevel = Util.null2String(jsonObj.get("allLevel"));
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
String viewScope = Util.null2String(jsonObj.get("viewScope"));
if(subCompanyId.length()>0){
sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") ";
}
if(departmentId.length()>0){
sqlWhere +=" and a.departmentid in("+departmentId+") ";
}
if(resourceId.length()>0){
sqlWhere +=" and b.resourceid in("+resourceId+") ";
}
if(viewScope.equals("4")){//我的下属
if(allLevel.equals("1")){//所有下属
sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
}else{
sqlWhere+=" and a.managerid="+user.getUID();//直接下属
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
}
sql = " select resourceid, newleavetype, durationrule, sum(duration) as val from hrmresource a, "+KqSplitFlowTypeEnum.LEAVEBACK.getTablename()+" b "+
1 year ago
" where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere +
" group by resourceid, newleavetype, durationrule ";
rs.execute(sql);
while (rs.next()) {
String resourceid = rs.getString("resourceid");
String newleavetype = rs.getString("newleavetype");
String durationrule = rs.getString("durationrule");
double value = rs.getDouble("val")<0?0:rs.getDouble("val");
double proportion = Util.getDoubleValue(kqLeaveRulesComInfo.getProportion(newleavetype));
if(KQUnitBiz.isLeaveHour(newleavetype,kqLeaveRulesComInfo)){//按小时
if(!KQUnitBiz.isLeaveHour(durationrule)){
if(proportion>0) value = value*proportion;
}
}else{//按天
if(KQUnitBiz.isLeaveHour(durationrule)){
if(proportion>0) value = value/proportion;
}
}
String key = resourceid+"|leavebackType_"+newleavetype;
if(datas.containsKey(key)){
value += Util.getDoubleValue(Util.null2String(datas.get(key)));
}
//df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了
df.setMaximumFractionDigits(5);
datas.put(key,format(value));
}
}catch (Exception e){
writeLog(e);
}
return datas;
}
/**
*
* @param params
* @param user
* @return
*/
public Map<String,Object> getFlowProcessChangeData(Map<String,Object> params, User user){
Map<String,Object> datas = new HashMap<>();;
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try{
String minimumUnit = "";//单位类型
double proportion = 0.00;//换算关系
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
String fromDate = Util.null2String(jsonObj.get("fromDate"));
String toDate = Util.null2String(jsonObj.get("toDate"));
String typeselect =Util.null2String(jsonObj.get("typeselect"));
if(typeselect.length()==0)typeselect = "3";
if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){
if(typeselect.equals("1")){
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
}else{
fromDate = TimeUtil.getDateByOption(typeselect,"0");
toDate = TimeUtil.getDateByOption(typeselect,"1");
}
}
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
String departmentId = Util.null2String(jsonObj.get("departmentId"));
String resourceId = Util.null2String(jsonObj.get("resourceId"));
String allLevel = Util.null2String(jsonObj.get("allLevel"));
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
String viewScope = Util.null2String(jsonObj.get("viewScope"));
if(subCompanyId.length()>0){
sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") ";
}
if(departmentId.length()>0){
sqlWhere +=" and a.departmentid in("+departmentId+") ";
}
if(resourceId.length()>0){
sqlWhere +=" and b.resourceid in("+resourceId+") ";
}
if(viewScope.equals("4")){//我的下属
if(allLevel.equals("1")){//所有下属
sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
}else{
sqlWhere+=" and a.managerid="+user.getUID();//直接下属
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
}
sql = " select resourceid, durationrule, changetype,sum(duration) as val from hrmresource a, "+KqSplitFlowTypeEnum.PROCESSCHANGE.getTablename()+" b "+
" where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' "+sqlWhere+
" group by resourceid, durationrule,changetype ";
rs.execute(sql);
while (rs.next()) {
String resourceid = rs.getString("resourceid");
int changetype = Util.getIntValue(rs.getString("changetype"));
String flowType = "";
if(KqSplitFlowTypeEnum.EVECTION.getFlowtype() == changetype){
flowType = "businessLeave_back";
proportion = Util.getDoubleValue(KQTravelRulesBiz.getHoursToDay());//换算关系
minimumUnit = KQTravelRulesBiz.getMinimumUnit();
}else if(KqSplitFlowTypeEnum.OUT.getFlowtype() == changetype){
flowType = "officialBusiness_back";
minimumUnit = KQExitRulesBiz.getMinimumUnit();
proportion = Util.getDoubleValue(KQExitRulesBiz.getHoursToDay());//换算关系
}
double value = rs.getDouble("val")<0?0:rs.getDouble("val");
String durationrule = rs.getString("durationrule");
if(KQUnitBiz.isLeaveHour(minimumUnit)){//按小时
if(!KQUnitBiz.isLeaveHour(durationrule)){
if(proportion>0) value = value*proportion;
}
}else{//按天
if(KQUnitBiz.isLeaveHour(durationrule)){
if(proportion>0) value = value/proportion;
}
}
String key = resourceid+"|"+flowType;
if(datas.containsKey(key)){
value += Util.getDoubleValue(Util.null2String(datas.get(key)));
}
//df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了
df.setMaximumFractionDigits(5);
datas.put(key, format(value));
}
}catch (Exception e){
writeLog(e);
}
return datas;
}
/**
*
* @param params
* @param user
* @return
*/
public Map<String,Object> getDailyFlowLeaveData(Map<String,Object> params, User user){
Map<String,Object> datas = new HashMap<>();;
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try{
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
String fromDate = Util.null2String(jsonObj.get("fromDate"));
String toDate = Util.null2String(jsonObj.get("toDate"));
String typeselect =Util.null2String(jsonObj.get("typeselect"));
if(typeselect.length()==0)typeselect = "3";
if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){
if(typeselect.equals("1")){
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
}else{
fromDate = TimeUtil.getDateByOption(typeselect,"0");
toDate = TimeUtil.getDateByOption(typeselect,"1");
}
}
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
String departmentId = Util.null2String(jsonObj.get("departmentId"));
String resourceId = Util.null2String(jsonObj.get("resourceId"));
String allLevel = Util.null2String(jsonObj.get("allLevel"));
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
String viewScope = Util.null2String(jsonObj.get("viewScope"));
if(subCompanyId.length()>0){
sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") ";
}
if(departmentId.length()>0){
sqlWhere +=" and a.departmentid in("+departmentId+") ";
}
if(resourceId.length()>0){
sqlWhere +=" and b.resourceid in("+resourceId+") ";
}
if(viewScope.equals("4")){//我的下属
if(allLevel.equals("1")){//所有下属
sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
}else{
sqlWhere+=" and a.managerid="+user.getUID();//直接下属
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
}
sql = " select resourceid, newleavetype, durationrule, sum(duration) as val,belongdate from hrmresource a, "+KqSplitFlowTypeEnum.LEAVE.getTablename()+" b "+
1 year ago
" where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere +
" group by resourceid, newleavetype, durationrule,belongdate ";
rs.execute(sql);
while (rs.next()) {
String resourceid = rs.getString("resourceid");
String belongdate = rs.getString("belongdate");
String newleavetype = rs.getString("newleavetype");
String durationrule = rs.getString("durationrule");
double value = rs.getDouble("val")<0?0:rs.getDouble("val");
double proportion = Util.getDoubleValue(kqLeaveRulesComInfo.getProportion(newleavetype));
if(KQUnitBiz.isLeaveHour(newleavetype,kqLeaveRulesComInfo)){//按小时
if(!KQUnitBiz.isLeaveHour(durationrule)){
if(proportion>0) value = value*proportion;
}
}else{//按天
if(KQUnitBiz.isLeaveHour(durationrule)){
if(proportion>0) value = value/proportion;
}
}
String key = resourceid+"|"+belongdate+"|leaveType_"+newleavetype;
if(datas.containsKey(key)){
value += Util.getDoubleValue(Util.null2String(datas.get(key)));
}
//df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了
df.setMaximumFractionDigits(5);
datas.put(key,format(value));
}
}catch (Exception e){
writeLog(e);
}
return datas;
}
/**
*
* @param params
* @param user
* @return
*/
public Map<String,Object> getDailyFlowLeaveBackData(Map<String,Object> params, User user){
Map<String,Object> datas = new HashMap<>();;
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try{
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
String fromDate = Util.null2String(jsonObj.get("fromDate"));
String toDate = Util.null2String(jsonObj.get("toDate"));
String typeselect =Util.null2String(jsonObj.get("typeselect"));
if(typeselect.length()==0)typeselect = "3";
if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){
if(typeselect.equals("1")){
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
}else{
fromDate = TimeUtil.getDateByOption(typeselect,"0");
toDate = TimeUtil.getDateByOption(typeselect,"1");
}
}
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
String departmentId = Util.null2String(jsonObj.get("departmentId"));
String resourceId = Util.null2String(jsonObj.get("resourceId"));
String allLevel = Util.null2String(jsonObj.get("allLevel"));
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
String viewScope = Util.null2String(jsonObj.get("viewScope"));
if(subCompanyId.length()>0){
sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") ";
}
if(departmentId.length()>0){
sqlWhere +=" and a.departmentid in("+departmentId+") ";
}
if(resourceId.length()>0){
sqlWhere +=" and b.resourceid in("+resourceId+") ";
}
if(viewScope.equals("4")){//我的下属
if(allLevel.equals("1")){//所有下属
sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
}else{
sqlWhere+=" and a.managerid="+user.getUID();//直接下属
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
}
sql = " select resourceid, newleavetype, durationrule, sum(duration) as val,belongdate from hrmresource a, "+KqSplitFlowTypeEnum.LEAVEBACK.getTablename()+" b "+
1 year ago
" where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere +
" group by resourceid, newleavetype, durationrule,belongdate ";
rs.execute(sql);
while (rs.next()) {
String resourceid = rs.getString("resourceid");
String belongdate = rs.getString("belongdate");
String newleavetype = rs.getString("newleavetype");
String durationrule = rs.getString("durationrule");
double value = rs.getDouble("val")<0?0:rs.getDouble("val");
double proportion = Util.getDoubleValue(kqLeaveRulesComInfo.getProportion(newleavetype));
if(KQUnitBiz.isLeaveHour(newleavetype,kqLeaveRulesComInfo)){//按小时
if(!KQUnitBiz.isLeaveHour(durationrule)){
if(proportion>0) value = value*proportion;
}
}else{//按天
if(KQUnitBiz.isLeaveHour(durationrule)){
if(proportion>0) value = value/proportion;
}
}
String key = resourceid+"|"+belongdate+"|leavebackType_"+newleavetype;
if(datas.containsKey(key)){
value += Util.getDoubleValue(Util.null2String(datas.get(key)));
}
//df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了
df.setMaximumFractionDigits(5);
datas.put(key,format(value));
}
}catch (Exception e){
writeLog(e);
}
return datas;
}
1 year ago
/**
*
* @param params
* @param user
* @return
*/
public Map<String,Object> getDailyMealAllowanceData(Map<String,Object> params, User user){
Map<String,Object> datas = new HashMap<>();;
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try{
bb.writeLog("getDailyMealAllowanceData start");
1 year ago
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
String fromDate = Util.null2String(jsonObj.get("fromDate"));
String toDate = Util.null2String(jsonObj.get("toDate"));
String typeselect =Util.null2String(jsonObj.get("typeselect"));
if(typeselect.length()==0)typeselect = "3";
if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){
if(typeselect.equals("1")){
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
}else{
fromDate = TimeUtil.getDateByOption(typeselect,"0");
toDate = TimeUtil.getDateByOption(typeselect,"1");
}
}
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
String departmentId = Util.null2String(jsonObj.get("departmentId"));
String resourceId = Util.null2String(jsonObj.get("resourceId"));
String allLevel = Util.null2String(jsonObj.get("allLevel"));
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
String viewScope = Util.null2String(jsonObj.get("viewScope"));
if(subCompanyId.length()>0){
sqlWhere +=" and b.subcompanyid1 in("+subCompanyId+") ";
1 year ago
}
if(departmentId.length()>0){
sqlWhere +=" and b.departmentid in("+departmentId+") ";
1 year ago
}
if(resourceId.length()>0){
sqlWhere +=" and b.id in("+resourceId+") ";
1 year ago
}
if(viewScope.equals("4")){//我的下属
if(allLevel.equals("1")){//所有下属
sqlWhere+=" and b.managerstr like '%,"+user.getUID()+",%'";
1 year ago
}else{
sqlWhere+=" and b.managerid="+user.getUID();//直接下属
1 year ago
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and b.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and b.loginid<>'' ");
1 year ago
}
//首先获取出差公出流程信息
Map<String, Object> evectionMap = new HashMap<>();
String evectionTableName = Util.null2String(bb.getPropValue("project_hostar","evectionTableName"));
sql = " select c.resourceid, c.belongdate, c.longitude, c.latitude from ( " +
" select a.belongdate, b.id as resourceid, b.subcompanyid1, b.departmentid, b.managerstr, b.managerid, b.loginid, c.jd as longitude, c.wd as latitude from kq_flow_split_evection a " +
" left join hrmresource b " +
" on b.id = a.resourceid " +
" left join " + evectionTableName + " c " +
" on c.requestid = a.requestid " +
" where a.belongdate >='"+fromDate+"' and a.belongdate <='"+toDate+"' " + sqlWhere +
1 year ago
" ) c " +
" where 1=1 " ;
bb.writeLog("sql: " + sql);
1 year ago
rs.execute(sql);
while (rs.next()) {
String resourceid = Util.null2String(rs.getString("resourceid"));
String belongdate = Util.null2String(rs.getString("belongdate"));
String longitude = Util.null2String(rs.getString("longitude"));
String latitude = Util.null2String(rs.getString("latitude"));
evectionMap.put( belongdate + "|" + resourceid, longitude + "|" + latitude );
}
bb.writeLog("evectionMap: " + evectionMap);
1 year ago
//获取外勤打卡数据
KQWorkTime kqWorkTime = new KQWorkTime();
kqWorkTime.setIsFormat(true);
Map< String, Map<String, Object>> lsCheckInfo = new HashMap<>();
for ( String key: evectionMap.keySet()) {
String[] split = key.split("\\|");
String kqDate = split[0];
String userId = split[1];
WorkTimeEntity workTime = kqWorkTime.getWorkTime(userId, kqDate);
List<TimeScopeEntity> lsSignTime = new ArrayList<>();
List<TimeScopeEntity> lsWorkTime = new ArrayList<>();
if (workTime != null) {
lsSignTime = workTime.getSignTime();//允许打卡时间
lsWorkTime = workTime.getWorkTime();//工作时间
}
//只支持一天一次上下班
if (lsWorkTime != null && lsWorkTime.size()==1 ) {
TimeScopeEntity signTimeScope = lsSignTime.get(0);
TimeScopeEntity workTimeScope = lsWorkTime.get(0);
List<Map<String, Object>> legWorkInfos = new ArrayList<>();
//获取允许打卡时间
String signBeginTime = signTimeScope.getBeginTime();
// bb.writeLog("signBeginTime: " + signBeginTime);
1 year ago
if (StringUtils.isNotBlank(signBeginTime)) {
signBeginTime = signBeginTime + ":00";
}
// bb.writeLog("signBeginTime: " + signBeginTime);
1 year ago
//获取上班时间
String workBeginTime = workTimeScope.getBeginTime();
// bb.writeLog("workBeginTime: " + workBeginTime);
1 year ago
if (StringUtils.isNotBlank(workBeginTime)) {
workBeginTime = workBeginTime + ":00";
}
// bb.writeLog("workBeginTime: " + workBeginTime);
1 year ago
String acqLegWorkSignSql = "select operate_time, longitude, latitude from mobile_sign where operater = ? and operate_date = '" + kqDate + "' and operate_time >='" + signBeginTime + "' order by operate_time asc ";
// bb.writeLog("acqLegWorkSignSql: " + acqLegWorkSignSql);
// bb.writeLog("userId: " + userId);
1 year ago
rs.executeQuery(acqLegWorkSignSql, userId);
while ( rs.next()) {
String operateTime = Util.null2String(rs.getString("operate_time"));
String longitude = Util.null2String(rs.getString("longitude"));
String latitude = Util.null2String(rs.getString("latitude"));
if ( StringUtils.isNotBlank(operateTime) && StringUtils.isNotBlank(longitude) && StringUtils.isNotBlank(latitude) ) {
Map<String, Object> temp = new HashMap<>();
temp.put("operateTime", operateTime);
temp.put("longitude", longitude);
temp.put("latitude", latitude);
legWorkInfos.add(temp);
}
}
bb.writeLog("legWorkInfos: " + legWorkInfos);
if (legWorkInfos != null && legWorkInfos.size() > 0 ) {
String tempSignIn = "";
String tempSignInLatitude = "";
String tempSignInLongitude = "";
String tempSignOutLatitude = "";
String tempSignOutLongitude = "";
String tempSignOut = "";
Map<String, Object> checkInfo = new HashMap<>();
if ( legWorkInfos.size() == 1) {//只有一笔外勤卡直接算上班
Map<String, Object> temp = legWorkInfos.get(0);
String operateTime = Util.null2String(temp.get("operateTime"));
String longitude = Util.null2String(temp.get("longitude"));
String latitude = Util.null2String(temp.get("latitude"));
checkInfo.put("signDate", kqDate);//签到签退日期
checkInfo.put("signInTime", operateTime);//签到时间
checkInfo.put("signInLatitude", latitude);//签到纬度
checkInfo.put("signInLongitude", longitude);//签到经度
lsCheckInfo.put(userId + "|" + kqDate, checkInfo);
} else {
for ( Map<String, Object> temp : legWorkInfos) {
String operateTime = Util.null2String(temp.get("operateTime"));
String longitude = Util.null2String(temp.get("longitude"));
String latitude = Util.null2String(temp.get("latitude"));
if (operateTime.compareTo(workBeginTime) < 0) {//获取上班时间点之前最早的一笔卡
if (StringUtils.isBlank(tempSignIn)) {
tempSignIn = operateTime;
tempSignInLatitude = latitude;
tempSignInLongitude = longitude;
} else {
if ( operateTime.compareTo(tempSignIn) < 0 ) {
tempSignIn = operateTime;
tempSignInLatitude = latitude;
tempSignInLongitude = longitude;
}
}
}
if ( operateTime.compareTo(workBeginTime) > 0) {//下班卡取最晚的一笔
if (StringUtils.isBlank(tempSignIn)) {
tempSignOut = operateTime;
tempSignOutLatitude = latitude;
tempSignOutLongitude = longitude;
} else {
if ( operateTime.compareTo(tempSignOut) > 0 ) {
tempSignOut = operateTime;
tempSignOutLatitude = latitude;
tempSignOutLongitude = longitude;
}
}
}
}
checkInfo.put("signDate", kqDate);//签到签退日期
checkInfo.put("signInTime", tempSignIn);//签到时间
checkInfo.put("signInLatitude", tempSignInLatitude);//签到纬度
checkInfo.put("signInLongitude", tempSignInLongitude);//签到经度
checkInfo.put("signOutTime", tempSignOut);//签退时间
checkInfo.put("signOutLatitude", tempSignOutLatitude);//签退纬度
checkInfo.put("signOutLongitude", tempSignOutLongitude);//签退经度
lsCheckInfo.put(userId + "|" + kqDate, checkInfo);
}
}
}
}
HostarUtil hostarUtil = new HostarUtil();
//获取经纬度半径
Double radius = 0.00;
String acqRadiusSql = "select radius from uf_leWorkRadius where (isDelete is null or isDelete = 0 )";
bb.writeLog("acqRadiusSql: " + acqRadiusSql);
1 year ago
rs.executeQuery(acqRadiusSql);
while (rs.next()) {
radius = Util.getDoubleValue(Util.null2String(rs.getString("radius")));
}
bb.writeLog("radius: " + radius);
String MealAlloTableName = Util.null2String(bb.getPropValue("project_hostar", "MealAllowanceTableName"));
bb.writeLog("MealAlloTableName: " + MealAlloTableName);
1 year ago
if (StringUtils.isNotBlank(MealAlloTableName)) {
//获取餐补判断时间
List<Map<String, String>> MealMap = new ArrayList<>();
String acqTimeSql = "select startTime, endTime from " + MealAlloTableName + " where (isDelete is null or isDelete = 0)";
bb.writeLog("acqTimeSql: " + acqTimeSql);
1 year ago
rs.executeQuery(acqTimeSql);
while (rs.next()) {
String startTime = Util.null2String(rs.getString("startTime"));
String endTime = Util.null2String(rs.getString("endTime"));
Map<String, String> temp = new HashMap<>();
temp.put("startTime",startTime);
temp.put("endTime",endTime);
MealMap.add(temp);
}
bb.writeLog("MealMap: " + MealMap);
1 year ago
//根据外勤打卡数据计算餐补数据
for (String key: lsCheckInfo.keySet()) {
// bb.writeLog("key: " + key);
1 year ago
String[] split = key.split("\\|");
// bb.writeLog("split: " + split);
1 year ago
String userId = split[0];
// bb.writeLog("userId: " + userId);
1 year ago
String kqDate = split[1];
// bb.writeLog("kqDate: " + kqDate);
1 year ago
Map<String, Object> temp = lsCheckInfo.get(key);
String signInTime = Util.null2String(temp.get("signInTime"));
String signOutTime = Util.null2String(temp.get("signOutTime"));
Double signInLatitude = Util.getDoubleValue(Util.null2String(temp.get("signInLatitude")));
Double signInLongitude = Util.getDoubleValue(Util.null2String(temp.get("signInLongitude")));
Double signOutLatitude = Util.getDoubleValue(Util.null2String(temp.get("signOutLatitude")));
Double signOutLongitude = Util.getDoubleValue(Util.null2String(temp.get("signOutLongitude")));
if (StringUtils.isNotBlank(signInTime) && StringUtils.isNotBlank(signOutTime) ) {
String lonAndLat = Util.null2String(evectionMap.get(kqDate + "|" + userId));
// bb.writeLog("lonAndLat: " + lonAndLat);
1 year ago
String[] split1 = lonAndLat.split("\\|");
Double longitude = Util.getDoubleValue(Util.null2String(split1[0]));
Double latitude = Util.getDoubleValue(Util.null2String(split1[1]));
//判断经纬度是否符合标准
Double distanceIn = hostarUtil.calculateDistance(latitude, longitude, signInLatitude, signInLongitude);//上班
// bb.writeLog("distanceIn: " + distanceIn);
1 year ago
Double distanceOut = hostarUtil.calculateDistance(latitude, longitude, signOutLatitude, signOutLongitude);//下班
// bb.writeLog("distanceOut: " + distanceOut);
1 year ago
if ( distanceIn<=radius && distanceOut<=radius) {
for (Map<String, String> me: MealMap) {
String startTime = me.get("startTime");
// bb.writeLog("startTime: " + startTime);
1 year ago
String endTime = me.get("endTime");
// bb.writeLog("endTime: " + endTime);
1 year ago
if (StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)) {
startTime = startTime + ":00";
endTime = endTime + ":00";
}
// bb.writeLog("signInTime: " + signInTime);
// bb.writeLog("signOutTime: " + signOutTime);
1 year ago
if ( (signInTime.compareTo(startTime) <= 0) && (signOutTime.compareTo(endTime) >= 0) ) {
int t = Util.getIntValue(Util.null2String(datas.get("DailyMealAllow|" + resourceId + "|" + kqDate)));
if (t <= 0) {
datas.put("DailyMealAllow|" + resourceId + "|" + kqDate, 1);
} else {
t = t + 1;
datas.put("DailyMealAllow|" + resourceId + "|" + kqDate, t);
}
}
}
}
}
}
}
}catch (Exception e){
writeLog(e);
}
bb.writeLog("datas: " + datas);
1 year ago
return datas;
}
1 year ago
/**
* 鸿
* @param params
* @param user
* @return
*/
public Map<String,Object> getDailyOtherStatAllowanceData(Map<String,Object> params, User user){
Map<String,Object> datas = new HashMap<>();;
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try{
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
String fromDate = Util.null2String(jsonObj.get("fromDate"));
String toDate = Util.null2String(jsonObj.get("toDate"));
String typeselect =Util.null2String(jsonObj.get("typeselect"));
if(typeselect.length()==0)typeselect = "3";
if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){
if(typeselect.equals("1")){
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
}else{
fromDate = TimeUtil.getDateByOption(typeselect,"0");
toDate = TimeUtil.getDateByOption(typeselect,"1");
}
}
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
String departmentId = Util.null2String(jsonObj.get("departmentId"));
String resourceId = Util.null2String(jsonObj.get("resourceId"));
String allLevel = Util.null2String(jsonObj.get("allLevel"));
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
String viewScope = Util.null2String(jsonObj.get("viewScope"));
if(subCompanyId.length()>0){
sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") ";
}
if(departmentId.length()>0){
sqlWhere +=" and a.departmentid in("+departmentId+") ";
}
if(resourceId.length()>0){
sqlWhere +=" and a.id in("+resourceId+") ";
}
if(viewScope.equals("4")){//我的下属
if(allLevel.equals("1")){//所有下属
sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
}else{
sqlWhere+=" and a.managerid="+user.getUID();//直接下属
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
}
//获取加班时长
Map<String, Object> dailyFlowOverTimeData = getDailyFlowOverTimeDataAllowance(params, user);
bb.writeLog("dailyFlowOverTimeData: " + dailyFlowOverTimeData);
String otherstatsub = Util.null2String(bb.getPropValue("project_hostar", "otherstatsubcompany"));
if (StringUtils.isNotBlank(otherstatsub)) {
//查询该分部下的人员
List<String> resIds = new ArrayList<>();
sqlWhere += " and a.subcompanyid1 in (" + otherstatsub + ") ";
1 year ago
String acqResSql = "select a.id from hrmresource a where a.status in (0,1,2,3) " + sqlWhere;
bb.writeLog("acqResSql: " + acqResSql);
rs.executeQuery(acqResSql);
while (rs.next()) {
String id = Util.null2String(rs.getString("id"));
if (StringUtils.isNotBlank(id)) {
resIds.add(id);
}
}
bb.writeLog("resIds: " + resIds);
if (resIds != null && resIds.size() > 0 && StringUtils.isNotBlank(fromDate) && StringUtils.isNotBlank(toDate)) {
HostarUtil houtil = new HostarUtil();
List<String> allDates = houtil.getAllDates(fromDate, toDate);
bb.writeLog("allDates: " + allDates);
//先获取到出勤时长
Map<String, Double> attendanceMinsMap = new HashMap<>();
String acqAttenSql = " select resourceid, attendancemins, kqdate from kq_format_total where resourceid in (" + String.join(",", resIds) + ") and kqdate >='" + fromDate + "' and kqdate <='" + toDate + "'";
rs.executeQuery(acqAttenSql);
while (rs.next()) {
String resourceid = Util.null2String(rs.getString("resourceid"));
Double attendancemins = Util.getDoubleValue(Util.null2String(rs.getString("attendancemins")));
String kqdate = Util.null2String(rs.getString("kqdate"));
if (attendancemins >= 0.00) {
attendanceMinsMap.put(resourceid + "|" + kqdate, attendancemins);
}
}
List<String> removeRes = new ArrayList<>();
String acqNoOtherStatAllResSql = "select resourceid from uf_NoOtherStatAllRe where isdelete is null or isdelete = 0 ";
rs.executeQuery(acqNoOtherStatAllResSql);
while (rs.next()){
String resourceid = Util.null2String(rs.getString("resourceid"));
if (StringUtils.isNotBlank(resourceid) ) {
removeRes.add(resourceid);
}
}
if ( removeRes != null && removeRes.size() > 0 ) {
resIds.removeIf(removeRes::contains);
}
for (String date : allDates) {
for (String res : resIds) {
//获取考勤打卡
Map<String, Object> otherinfo = new HashMap<>();//存一些用得到的信息
String uuid = UUID.randomUUID().toString();
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
ArrayList<String> hostIps = InitServer.getRealIp();//获取IP
boolean oneSign = false;//一天一段出勤时间段
List<TimeScopeEntity> lsSignTime = new ArrayList<>();
List<TimeScopeEntity> lsWorkTime = new ArrayList<>();
// List<TimeScopeEntity> lsRestTime = new ArrayList<>();
KQWorkTime kqWorkTime = new KQWorkTime();
kqWorkTime.setIsFormat(true);
WorkTimeEntity workTime = kqWorkTime.getWorkTime(res, date);
String preDate = DateUtil.addDate(date, -1);//上一天日期
String nextDate = DateUtil.addDate(date, 1);//下一天日期
if (workTime != null) {
lsSignTime = workTime.getSignTime();//允许打卡时间
lsWorkTime = workTime.getWorkTime();//工作时间
// lsRestTime = workTime.getRestTime();//休息时段时间
oneSign = lsWorkTime != null && lsWorkTime.size() == 1;
}
int shiftCount = lsWorkTime == null ? 0 : lsWorkTime.size();
int shiftI = 0;
List<Object> lsCheckInfo = new ArrayList<>();
for (int i = 0; lsWorkTime != null && i < lsWorkTime.size(); i++) {
shiftI = i;
TimeScopeEntity signTimeScope = lsSignTime.get(i);
TimeScopeEntity workTimeScope = lsWorkTime.get(i);
Map<String, String> shifRuleMap = Maps.newHashMap();
String workBeginTime = Util.null2String(workTimeScope.getBeginTime());
int workBeginIdx = kqTimesArrayComInfo.getArrayindexByTimes(workBeginTime);
String workEndTime = Util.null2String(workTimeScope.getEndTime());
int workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(workEndTime);
boolean workEndTimeAcross = workTimeScope.getEndTimeAcross();
if (oneSign) {
//个性化设置只支持一天一次上下班
ShiftInfoBean shiftInfoBean = new ShiftInfoBean();
shiftInfoBean.setSplitDate(date);
shiftInfoBean.setShiftRuleMap(workTime.getShiftRuleInfo());
shiftInfoBean.setSignTime(lsSignTime);
shiftInfoBean.setWorkTime(lsWorkTime);
List<String> logList = Lists.newArrayList();
KQShiftRuleInfoBiz.getShiftRuleInfo(shiftInfoBean, res, shifRuleMap, logList);
if (!shifRuleMap.isEmpty()) {
if (!logList.isEmpty()) {
otherinfo.put("logList", logList);
}
otherinfo.put("shiftRule", shifRuleMap);
if (shifRuleMap.containsKey("shift_beginworktime")) {
String shift_beginworktime = Util.null2String(shifRuleMap.get("shift_beginworktime"));
if (shift_beginworktime.length() > 0) {
workBeginTime = Util.null2String(shift_beginworktime);
workBeginIdx = kqTimesArrayComInfo.getArrayindexByTimes(workBeginTime);
workTimeScope.setBeginTime(workBeginTime);
workTimeScope.setBeginTimeAcross(workBeginIdx >= 1440 ? true : false);
}
}
if (shifRuleMap.containsKey("shift_endworktime")) {
String shift_endworktime = Util.null2String(shifRuleMap.get("shift_endworktime"));
if (shift_endworktime.length() > 0) {
workEndTime = Util.null2String(shift_endworktime);
workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(workEndTime);
workTimeScope.setEndTime(workEndTime);
workTimeScope.setEndTimeAcross(workEndIdx >= 1440 ? true : false);
}
}
}
}
lsCheckInfo = new KQFormatSignData().getSignInfo(res, signTimeScope, workTimeScope, date, preDate, nextDate, kqTimesArrayComInfo, hostIps, uuid, shiftCount, shiftI);
}
List<String> signIdList = new ArrayList<>();
for (int i = 0; i < lsCheckInfo.size(); i++) {
Object o = lsCheckInfo.get(i);
if ( o != null && o != "") {
1 year ago
Map<String, Object> temp = (Map<String, Object>) o;
String signId = Util.null2String(temp.get("signId"));
if (StringUtils.isNotBlank(signId)) {
signIdList.add(signId);
}
1 year ago
}
}
Integer signNumber = 0;
if (signIdList !=null && signIdList.size() > 0) {
String acqShowAddress = "select showaddress from hrmschedulesign where id in (" + String.join(",", signIdList) + ") ";
// bb.writeLog("acqShowAddress: " + acqShowAddress);
rs.executeQuery(acqShowAddress);
while (rs.next()) {
String showaddress = Util.null2String(rs.getString("showaddress"));
if ("鸿仕达".equals(showaddress) || "hostar".equalsIgnoreCase(showaddress)) {
signNumber = signNumber + 1;
}
1 year ago
}
}
if (signNumber == 0) {
double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|workingDayOvertime_4leave")));
workingDayOvertime_4leave = workingDayOvertime_4leave < 0 ? 0 : workingDayOvertime_4leave;
double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|restDayOvertime_4leave")));
restDayOvertime_4leave = restDayOvertime_4leave < 0 ? 0 : restDayOvertime_4leave;
double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|holidayOvertime_4leave")));
holidayOvertime_4leave = holidayOvertime_4leave < 0 ? 0 : holidayOvertime_4leave;
double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|workingDayOvertime_nonleave")));
workingDayOvertime_nonleave = workingDayOvertime_nonleave < 0 ? 0 : workingDayOvertime_nonleave;
double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|restDayOvertime_nonleave")));
restDayOvertime_nonleave = restDayOvertime_nonleave < 0 ? 0 : restDayOvertime_nonleave;
double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|holidayOvertime_nonleave")));
holidayOvertime_nonleave = holidayOvertime_nonleave < 0 ? 0 : holidayOvertime_nonleave;
double temp = workingDayOvertime_4leave + restDayOvertime_4leave + holidayOvertime_4leave +
workingDayOvertime_nonleave + restDayOvertime_nonleave + holidayOvertime_nonleave;
// bb.writeLog("-=-temp:" + temp);
1 year ago
Double attendanceMins = Util.getDoubleValue(Util.null2String(attendanceMinsMap.get(res + "|" + date)));
// bb.writeLog("-=-attendanceMins:" + attendanceMins);
double v = Math.round (((attendanceMins < 0.00) ? 0.00 : attendanceMins) + temp) / 60.00;
1 year ago
String value = "0";
if (v >= 4.00 && v < 9.00) {
value = "1";
} else if (v >= 9.00) {
value = "2";
}
// bb.writeLog("-=-value:" + value);
1 year ago
datas.put(res + "|" + "DailyOtherStatAllowance" + "|" + date, value);
}
}
}
}
}
}catch (Exception e){
writeLog(e);
bb.writeLog("DailyOtherStatAllowance Exception: " + e);
1 year ago
}
bb.writeLog("DailyOtherStatAllowance datas: " + datas);
1 year ago
return datas;
}
/**
*
* @param params
* @param user
* @return
*/
public Map<String,Object> getDailyNightShiftAllowanceData(Map<String,Object> params, User user){
Map<String,Object> datas = new HashMap<>();;
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try{
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
String fromDate = Util.null2String(jsonObj.get("fromDate"));
String toDate = Util.null2String(jsonObj.get("toDate"));
String typeselect =Util.null2String(jsonObj.get("typeselect"));
if(typeselect.length()==0)typeselect = "3";
if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){
if(typeselect.equals("1")){
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
}else{
fromDate = TimeUtil.getDateByOption(typeselect,"0");
toDate = TimeUtil.getDateByOption(typeselect,"1");
}
}
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
String departmentId = Util.null2String(jsonObj.get("departmentId"));
String resourceId = Util.null2String(jsonObj.get("resourceId"));
String allLevel = Util.null2String(jsonObj.get("allLevel"));
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
String viewScope = Util.null2String(jsonObj.get("viewScope"));
if(subCompanyId.length()>0){
sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") ";
}
if(departmentId.length()>0){
sqlWhere +=" and a.departmentid in("+departmentId+") ";
}
if(resourceId.length()>0){
sqlWhere +=" and a.id in("+resourceId+") ";
}
if(viewScope.equals("4")){//我的下属
if(allLevel.equals("1")){//所有下属
sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
}else{
sqlWhere+=" and a.managerid="+user.getUID();//直接下属
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
}
//获取加班时长
Map<String, Object> dailyFlowOverTimeData = getDailyFlowOverTimeDataAllowance(params, user);
bb.writeLog("dailyFlowOverTimeData: " + dailyFlowOverTimeData);
//获取夜班班次
List<String> nightShiftList = new ArrayList<>();
String acqNightShiftSql = "select shift from uf_nightshiftmanage where isdelete is null or isdelete = 0";
rs.executeQuery(acqNightShiftSql);
while (rs.next()) {
String shift = Util.null2String(rs.getString("shift"));
if (StringUtils.isNotBlank(shift)) {
nightShiftList.add(shift);
}
}
if (nightShiftList != null & nightShiftList.size() > 0) {
String nightshiftsub = Util.null2String(bb.getPropValue("project_hostar", "nightshiftsubcompany"));
if (StringUtils.isNotBlank(nightshiftsub)) {
//查询该分部下的人员
List<String> resIds = new ArrayList<>();
sqlWhere += " and a.subcompanyid1 in ("+nightshiftsub+") ";
String acqResSql = "select a.id from hrmresource a where a.status in (0,1,2,3) " + sqlWhere;
bb.writeLog("acqResSql: " + acqResSql);
1 year ago
rs.executeQuery(acqResSql);
while (rs.next()) {
String id = Util.null2String(rs.getString("id"));
if (StringUtils.isNotBlank(id)) {
resIds.add(id);
}
1 year ago
}
bb.writeLog("resIds: " + resIds);
if ( resIds != null && resIds.size() > 0) {
HostarUtil houtil = new HostarUtil();
List<String> allDates = houtil.getAllDates(fromDate, toDate);
//先获取到出勤时长
Map<String, Double> attendanceMinsMap = new HashMap<>();
String acqAttenSql = " select resourceid, attendancemins, kqdate from kq_format_total where resourceid in (" + String.join(",",resIds) + ") and kqdate >='" + fromDate + "' and kqdate <='" + toDate + "'";
rs.executeQuery(acqAttenSql);
while (rs.next()) {
String resourceid = Util.null2String(rs.getString("resourceid"));
Double attendancemins = Util.getDoubleValue(Util.null2String(rs.getString("attendancemins")));
String kqdate = Util.null2String(rs.getString("kqdate"));
if (attendancemins >= 0.00 ) {
attendanceMinsMap.put(resourceid+"|"+kqdate, attendancemins);
}
}
KQWorkTime kqWorkTime = new KQWorkTime();
for (String res: resIds) {
for (String date : allDates) {
//获取当天班次
Map<String, Object> serialInfo = kqWorkTime.getSerialInfo(res, date, false);
if (serialInfo != null && serialInfo.size() > 0) {
int serialid = Util.getIntValue(Util.null2String(serialInfo.get(date)), 0);
if (serialid > 0) {
if ( !nightShiftList.contains(String.valueOf(serialid))) {
continue;
}
}
}
double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|workingDayOvertime_4leave")));
workingDayOvertime_4leave = workingDayOvertime_4leave < 0 ? 0 : workingDayOvertime_4leave;
double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|restDayOvertime_4leave")));
restDayOvertime_4leave = restDayOvertime_4leave < 0 ? 0 : restDayOvertime_4leave;
double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|holidayOvertime_4leave")));
holidayOvertime_4leave = holidayOvertime_4leave < 0 ? 0 : holidayOvertime_4leave;
double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|workingDayOvertime_nonleave")));
workingDayOvertime_nonleave = workingDayOvertime_nonleave < 0 ? 0 : workingDayOvertime_nonleave;
double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|restDayOvertime_nonleave")));
restDayOvertime_nonleave = restDayOvertime_nonleave < 0 ? 0 : restDayOvertime_nonleave;
double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|holidayOvertime_nonleave")));
holidayOvertime_nonleave = holidayOvertime_nonleave < 0 ? 0 : holidayOvertime_nonleave;
double temp = workingDayOvertime_4leave + restDayOvertime_4leave + holidayOvertime_4leave +
workingDayOvertime_nonleave + restDayOvertime_nonleave + holidayOvertime_nonleave;
// bb.writeLog("-=-temp:" + temp);
Double attendanceMins = Util.getDoubleValue(Util.null2String(attendanceMinsMap.get(res + "|" + date)));
// bb.writeLog("-=-attendanceMins:" + attendanceMins);
String value = String.valueOf(Math.floor( ((attendanceMins < 0.00 ? 0.00 : attendanceMins) + temp) / 300));
// bb.writeLog("-=-value:" + value);
datas.put(res + "|" + "DailyNightShiftAllowanceData" + "|" + date, value);
}
}
}
} else {
bb.writeLog("夜班餐补计算失败,没有设置该餐补享受分部");
1 year ago
}
} else {
bb.writeLog("夜班餐补计算失败,没有设置夜班");
}
}catch (Exception e){
writeLog(e);
bb.writeLog("DailyNightShiftAllowanceData Exception: " + e);
}
bb.writeLog("DailyNightShiftAllowanceData datas: " + datas);
return datas;
}
/**
*
* @param params
* @param user
* @return
*/
public Map<String,Object> getDailyNightShiftSubsidyData(Map<String,Object> params, User user){
Map<String,Object> datas = new HashMap<>();;
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try{
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
String fromDate = Util.null2String(jsonObj.get("fromDate"));
String toDate = Util.null2String(jsonObj.get("toDate"));
String typeselect =Util.null2String(jsonObj.get("typeselect"));
if(typeselect.length()==0)typeselect = "3";
if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){
if(typeselect.equals("1")){
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
}else{
fromDate = TimeUtil.getDateByOption(typeselect,"0");
toDate = TimeUtil.getDateByOption(typeselect,"1");
}
}
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
String departmentId = Util.null2String(jsonObj.get("departmentId"));
String resourceId = Util.null2String(jsonObj.get("resourceId"));
String allLevel = Util.null2String(jsonObj.get("allLevel"));
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
String viewScope = Util.null2String(jsonObj.get("viewScope"));
String subUserId = Util.null2String(params.get("subUserId"));
// if(subCompanyId.length()>0){
// sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") ";
// }
//
// if(departmentId.length()>0){
// sqlWhere +=" and a.departmentid in("+departmentId+") ";
// }
//
// if(resourceId.length()>0){
// sqlWhere +=" and a.id in("+resourceId+") ";
// }
//
// if(viewScope.equals("4")){//我的下属
// if(allLevel.equals("1")){//所有下属
// sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
// }else{
// sqlWhere+=" and a.managerid="+user.getUID();//直接下属
// }
// }
// if (!"1".equals(isNoAccount)) {
// sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
// }
//获取夜班班次
List<String> nightShiftList = new ArrayList<>();
String acqNightShiftSql = "select shift from uf_nightshiftmanage where isdelete is null or isdelete = 0";
rs.executeQuery(acqNightShiftSql);
while (rs.next()) {
String shift = Util.null2String(rs.getString("shift"));
if (StringUtils.isNotBlank(shift)) {
nightShiftList.add(shift);
}
}
if (nightShiftList != null & nightShiftList.size() > 0) {
1 year ago
HostarUtil houtil = new HostarUtil();
List<String> allDates = houtil.getAllDates(fromDate, toDate);
//先获取到出勤时长
Map<String, Double> attendanceMinsMap = new HashMap<>();
String acqAttenSql = " select resourceid, attendancemins, kqdate from kq_format_total where resourceid in (" + subUserId + ") and kqdate >='" + fromDate + "' and kqdate <='" + toDate + "'";
1 year ago
rs.executeQuery(acqAttenSql);
while (rs.next()) {
String resourceid = Util.null2String(rs.getString("resourceid"));
Double attendancemins = Util.getDoubleValue(Util.null2String(rs.getString("attendancemins")));
String kqdate = Util.null2String(rs.getString("kqdate"));
if (attendancemins >= 0.00 ) {
attendanceMinsMap.put(resourceid+"|"+kqdate, attendancemins);
}
}
KQWorkTime kqWorkTime = new KQWorkTime();
for (String date : allDates) {
//获取当天班次
Map<String, Object> serialInfo = kqWorkTime.getSerialInfo(subUserId, date, false);
if (serialInfo != null && serialInfo.size() > 0) {
int serialid = Util.getIntValue(Util.null2String(serialInfo.get(date)), 0);
if (serialid > 0) {
if ( !nightShiftList.contains(String.valueOf(serialid))) {
continue;
}
}
}
Double attendanceMins = Util.getDoubleValue(Util.null2String(attendanceMinsMap.get(subUserId + "|" + date)));
String value = (( attendanceMins / 60) >= 8.00 ) ? "1" : "0";
datas.put(subUserId + "|" + "DailyNightShiftSubsidyData" + "|" + date, value);
}
}
}catch (Exception e){
writeLog(e);
bb.writeLog("DailyNightShiftSubsidyData Exception: " + e);
}
bb.writeLog("DailyNightShiftSubsidyData datas: " + datas);
return datas;
}
/**
*
* @param params
* @param user
* @return
*/
public Map<String,Object> getDailyStatAllowanceData(Map<String,Object> params, User user){
Map<String,Object> datas = new HashMap<>();;
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try{
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
String fromDate = Util.null2String(jsonObj.get("fromDate"));
String toDate = Util.null2String(jsonObj.get("toDate"));
String typeselect =Util.null2String(jsonObj.get("typeselect"));
if(typeselect.length()==0)typeselect = "3";
if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){
if(typeselect.equals("1")){
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
}else{
fromDate = TimeUtil.getDateByOption(typeselect,"0");
toDate = TimeUtil.getDateByOption(typeselect,"1");
}
}
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
String departmentId = Util.null2String(jsonObj.get("departmentId"));
String resourceId = Util.null2String(jsonObj.get("resourceId"));
String allLevel = Util.null2String(jsonObj.get("allLevel"));
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
String viewScope = Util.null2String(jsonObj.get("viewScope"));
String statUser = Util.null2String(Util.null2String(params.get("statUser")));
String kqDate = Util.null2String(Util.null2String(params.get("kqdate")));
if(statUser.length()>0){
sqlWhere +=" and a.id in("+statUser+") ";
}
// if(kqdate.length()>0){
// sqlWhere +=" and a.id in("+statUser+") ";
// }
// if(subCompanyId.length()>0){
// sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") ";
// }
//
// if(departmentId.length()>0){
// sqlWhere +=" and a.departmentid in("+departmentId+") ";
// }
//
// if(resourceId.length()>0){
// sqlWhere +=" and a.id in("+resourceId+") ";
// }
//
// if(viewScope.equals("4")){//我的下属
// if(allLevel.equals("1")){//所有下属
// sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
// }else{
// sqlWhere+=" and a.managerid="+user.getUID();//直接下属
// }
// }
// if (!"1".equals(isNoAccount)) {
// sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
// }
//获取加班时长
// long startTime11 = System.currentTimeMillis();
Map<String, Object> dailyFlowOverTimeData = getDailyFlowOverTimeDataAllowance(params, user);
// long endTime11 = System.currentTimeMillis();
// long elapsedTime11 = endTime11 - startTime11; // 执行时间
// bb.writeLog("加班时长执行时间:" + elapsedTime11 + "毫秒" );
// bb.writeLog("dailyFlowOverTimeData: " + dailyFlowOverTimeData);
//首先去除指定不享有的分部
// long startTime12 = System.currentTimeMillis();
List<String> subComoanyList = new ArrayList<>();
String acqNoStatAllSql = "select subcompany from uf_NoStatAllSubCom where isdelete = 0 or isdelete is null";
rs.executeQuery(acqNoStatAllSql);
while (rs.next()) {
String subcompany = Util.null2String(rs.getString("subcompany"));
if (StringUtils.isNotBlank(subcompany)) {
subComoanyList.add(subcompany);
}
}
// long endTime12 = System.currentTimeMillis();
// long elapsedTime12 = endTime12 - startTime12; // 执行时间
// bb.writeLog("不享有的分部执行时间:" + elapsedTime12 + "毫秒" );
// bb.writeLog("subComoanyList: " + subComoanyList);
String subComoanys = "";
if ( subComoanyList != null && subComoanyList.size() > 0) {
subComoanys = String.join(",", subComoanyList);
}
if (StringUtils.isNotBlank(subComoanys)) {
sqlWhere += " and a.subcompanyid1 not in ("+subComoanys+") ";
}
//指定人员不享受
List<String> noRes = new ArrayList<>();
String acqNoResSql = "select resourceid from uf_NoStatAllRes where isdelete = 0 or isdelete is null";
rs.executeQuery(acqNoResSql);
while (rs.next()) {
String resourceid = Util.null2String(rs.getString("resourceid"));
if (StringUtils.isNotBlank(resourceid)) {
noRes.add(resourceid);
}
}
if ( noRes !=null && noRes.size()>0) {
sqlWhere += " and a.id not in ("+String.join(",", noRes)+") ";
}
List<String> resIds = new ArrayList<>();
String acqResSql = "select a.id from hrmresource a where a.status in (0,1,2,3) " + sqlWhere;
bb.writeLog("acqResSql: " + acqResSql);
rs.executeQuery(acqResSql);
while (rs.next()) {
String id = Util.null2String(rs.getString("id"));
if (StringUtils.isNotBlank(id)) {
resIds.add(id);
}
}
bb.writeLog("resIds: " + resIds);
if (resIds != null && resIds.size() > 0 && StringUtils.isNotBlank(fromDate) && StringUtils.isNotBlank(toDate)) {
HostarUtil houtil = new HostarUtil();
// List<String> allDates = houtil.getAllDates(fromDate, toDate);
List<String> allDates = new ArrayList<>();
allDates.add(kqDate);
bb.writeLog("allDates: " + allDates);
bb.writeLog("allDates.size(): " + allDates.size());
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
//先获取到出勤时长
// long startTime13 = System.currentTimeMillis();
Map<String, Double> attendanceMinsMap = new HashMap<>();
String acqAttenSql = " select resourceid, attendancemins, kqdate from kq_format_total where resourceid in (" + String.join(",",resIds) + ") and kqdate >='" + fromDate + "' and kqdate <='" + toDate + "'";
rs.executeQuery(acqAttenSql);
while (rs.next()) {
String resourceid = Util.null2String(rs.getString("resourceid"));
Double attendancemins = Util.getDoubleValue(Util.null2String(rs.getString("attendancemins")));
String kqdate = Util.null2String(rs.getString("kqdate"));
if (attendancemins >= 0.00 ) {
attendanceMinsMap.put(resourceid+"|"+kqdate, attendancemins);
}
}
// long endTime13 = System.currentTimeMillis();
// long elapsedTime13 = endTime13 - startTime13; // 执行时间
// bb.writeLog("出勤时长执行时间:" + elapsedTime13 + "毫秒" );
//获取享受的考勤组
List<String> grouplist = new ArrayList<String>();
String acqGroupSql = "select kqgroup from uf_StatAlloKqGroup where isdelete is null or isdelete = 0 " ;
rs.executeQuery(acqGroupSql);
while (rs.next()) {
String kqgroup = Util.null2String(rs.getString("kqgroup"));
if (StringUtils.isNotBlank(kqgroup)) {
grouplist.add(kqgroup);
}
}
if ( grouplist != null && grouplist.size() == 0) {
return datas;
}
// int x = 1;
for (String date : allDates) {
// long startTime14 = System.currentTimeMillis();
1 year ago
for (String res: resIds) {
// long startTime15 = System.currentTimeMillis();
//判断考勤组
/*获取考勤组的ID因为考勤组有有效期所以需要传入日期*/
String groupId = kqGroupMemberComInfo.getKQGroupId(resourceId, date);
if ( !grouplist.contains(groupId)) {
continue;
}
//获取考勤打卡
Map<String,Object> otherinfo = new HashMap<>();//存一些用得到的信息
String uuid = UUID.randomUUID().toString();
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
ArrayList<String> hostIps = InitServer.getRealIp();//获取IP
boolean oneSign = false;//一天一段出勤时间段
List<TimeScopeEntity> lsSignTime = new ArrayList<>();
List<TimeScopeEntity> lsWorkTime = new ArrayList<>();
// List<TimeScopeEntity> lsRestTime = new ArrayList<>();
KQWorkTime kqWorkTime = new KQWorkTime();
kqWorkTime.setIsFormat(true);
WorkTimeEntity workTime = kqWorkTime.getWorkTime(res, date);
String preDate = DateUtil.addDate(date, -1);//上一天日期
String nextDate = DateUtil.addDate(date, 1);//下一天日期
if (workTime != null) {
lsSignTime = workTime.getSignTime();//允许打卡时间
lsWorkTime = workTime.getWorkTime();//工作时间
// lsRestTime = workTime.getRestTime();//休息时段时间
oneSign = lsWorkTime!=null&&lsWorkTime.size()==1;
}
int shiftCount = lsWorkTime == null ? 0 : lsWorkTime.size();
int shiftI = 0;
List<Object> lsCheckInfo = new ArrayList<>();
for (int i = 0; lsWorkTime != null && i < lsWorkTime.size(); i++) {
shiftI = i;
TimeScopeEntity signTimeScope = lsSignTime.get(i);
TimeScopeEntity workTimeScope = lsWorkTime.get(i);
Map<String, String> shifRuleMap = Maps.newHashMap();
String workBeginTime = Util.null2String(workTimeScope.getBeginTime());
// String ori_workBeginTime = workBeginTime;
int workBeginIdx = kqTimesArrayComInfo.getArrayindexByTimes(workBeginTime);
// boolean workBenginTimeAcross = workTimeScope.getBeginTimeAcross();
String workEndTime = Util.null2String(workTimeScope.getEndTime());
// String ori_workEndTime = workEndTime;
int workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(workEndTime);
boolean workEndTimeAcross = workTimeScope.getEndTimeAcross();
// int workMins = workTimeScope.getWorkMins();
//
// String workBeginDate = workBenginTimeAcross ? nextDate : date;
// String workEndDate = workEndTimeAcross ? nextDate : date;
if(oneSign){
//个性化设置只支持一天一次上下班
ShiftInfoBean shiftInfoBean = new ShiftInfoBean();
shiftInfoBean.setSplitDate(date);
shiftInfoBean.setShiftRuleMap(workTime.getShiftRuleInfo());
shiftInfoBean.setSignTime(lsSignTime);
shiftInfoBean.setWorkTime(lsWorkTime);
List<String> logList = Lists.newArrayList();
KQShiftRuleInfoBiz.getShiftRuleInfo(shiftInfoBean, res, shifRuleMap,logList);
if(!shifRuleMap.isEmpty()){
if(!logList.isEmpty()){
otherinfo.put("logList", logList);
}
otherinfo.put("shiftRule", shifRuleMap);
if(shifRuleMap.containsKey("shift_beginworktime")){
String shift_beginworktime = Util.null2String(shifRuleMap.get("shift_beginworktime"));
if(shift_beginworktime.length() > 0){
workBeginTime = Util.null2String(shift_beginworktime);
workBeginIdx = kqTimesArrayComInfo.getArrayindexByTimes(workBeginTime);
workTimeScope.setBeginTime(workBeginTime);
workTimeScope.setBeginTimeAcross(workBeginIdx>=1440?true:false);
}
}
if(shifRuleMap.containsKey("shift_endworktime")){
String shift_endworktime = Util.null2String(shifRuleMap.get("shift_endworktime"));
if(shift_endworktime.length() > 0){
workEndTime = Util.null2String(shift_endworktime);
workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(workEndTime);
workTimeScope.setEndTime(workEndTime);
workTimeScope.setEndTimeAcross(workEndIdx>=1440?true:false);
}
}
}
}
//lsCheckInfo的内容格式
//[{
// signTime = 08: 49: 00,
// signStatus = 0,
// signType = 1,
// signDate = 2023 - 12 - 22,
// signId = 6
//}, {
// signTime = 18: 49: 00,
// signStatus = 0,
// signType = 2,
// signDate = 2023 - 12 - 22,
// signId = 7
//}]
lsCheckInfo = new KQFormatSignData().getSignInfo(res,signTimeScope,workTimeScope,date,preDate,nextDate,kqTimesArrayComInfo,hostIps,uuid,shiftCount,shiftI);
}
// long endTime15 = System.currentTimeMillis();
// long elapsedTime15 = endTime15 - startTime15; // 执行时间
// bb.writeLog("获取打卡数据执行时间:" + elapsedTime15 + "毫秒" );
// long startTime16 = System.currentTimeMillis();
List<String> signIdList = new ArrayList<>();
for (int i = 0; i < lsCheckInfo.size(); i++) {
Object o = lsCheckInfo.get(i);
if ( o != null && o != "") {
Map<String, Object> temp = (Map<String, Object>) o;
String signId = Util.null2String(temp.get("signId"));
if (StringUtils.isNotBlank(signId)) {
signIdList.add(signId);
}
}
}
bb.writeLog("signIdList " + signIdList);
Integer signNumber = 0;
if (signIdList !=null && signIdList.size() > 0) {
String acqShowAddress = "select showaddress from hrmschedulesign where id in (" + String.join(",", signIdList) + ") ";
bb.writeLog("acqShowAddress: " + acqShowAddress);
rs.executeQuery(acqShowAddress);
while (rs.next()) {
String showaddress = Util.null2String(rs.getString("showaddress"));
if ("鸿仕达".equals(showaddress) || "hostar".equalsIgnoreCase(showaddress)) {
signNumber = signNumber + 1;
}
}
}
if (signNumber == 0 ) {
1 year ago
double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|workingDayOvertime_4leave")));
workingDayOvertime_4leave = workingDayOvertime_4leave < 0 ? 0 : workingDayOvertime_4leave;
double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|restDayOvertime_4leave")));
restDayOvertime_4leave = restDayOvertime_4leave < 0 ? 0 : restDayOvertime_4leave;
double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|holidayOvertime_4leave")));
holidayOvertime_4leave = holidayOvertime_4leave < 0 ? 0 : holidayOvertime_4leave;
double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|workingDayOvertime_nonleave")));
workingDayOvertime_nonleave = workingDayOvertime_nonleave < 0 ? 0 : workingDayOvertime_nonleave;
double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|restDayOvertime_nonleave")));
restDayOvertime_nonleave = restDayOvertime_nonleave < 0 ? 0 : restDayOvertime_nonleave;
double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|holidayOvertime_nonleave")));
holidayOvertime_nonleave = holidayOvertime_nonleave < 0 ? 0 : holidayOvertime_nonleave;
double temp = workingDayOvertime_4leave + restDayOvertime_4leave + holidayOvertime_4leave +
workingDayOvertime_nonleave + restDayOvertime_nonleave + holidayOvertime_nonleave;
// bb.writeLog("-=-temp:" + temp);
1 year ago
Double attendanceMins = Util.getDoubleValue(Util.null2String(attendanceMinsMap.get(res + "|" + date)));
// bb.writeLog("-=-attendanceMins:" + attendanceMins);
String value = String.valueOf(Math.floor( ((attendanceMins < 0.00 ? 0.00 : attendanceMins) + temp) / 300));
// bb.writeLog("-=-value:" + value);
datas.put(res + "|" + "DailyStatAllowance" + "|" + date, value);
1 year ago
}
// long endTime16 = System.currentTimeMillis();
// long elapsedTime16 = endTime16 - startTime16; // 执行时间
// bb.writeLog("计算餐补执行时间:" + elapsedTime16 + "毫秒" );
1 year ago
}
// long endTime14 = System.currentTimeMillis();
// long elapsedTime14 = endTime14 - startTime14; // 执行时间
// bb.writeLog("第" + x + "循环执行时间:" + elapsedTime14 + "毫秒" );
// x++;
1 year ago
}
}
}catch (Exception e){
writeLog(e);
bb.writeLog("DailyStatAllowance Exception: " + e);
1 year ago
}
bb.writeLog("DailyStatAllowance datas: " + datas);
1 year ago
return datas;
}
1 year ago
/**
*
* @param params
* @param user
* @return
*/
public Map<String,Object> getStatAllowanceData(Map<String,Object> params, User user){
1 year ago
Map<String,Object> datas = new HashMap<>();;
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try{
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
String fromDate = Util.null2String(jsonObj.get("fromDate"));
String toDate = Util.null2String(jsonObj.get("toDate"));
String typeselect =Util.null2String(jsonObj.get("typeselect"));
if(typeselect.length()==0)typeselect = "3";
if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){
if(typeselect.equals("1")){
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
}else{
fromDate = TimeUtil.getDateByOption(typeselect,"0");
toDate = TimeUtil.getDateByOption(typeselect,"1");
}
}
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
String departmentId = Util.null2String(jsonObj.get("departmentId"));
String resourceId = Util.null2String(jsonObj.get("resourceId"));
String allLevel = Util.null2String(jsonObj.get("allLevel"));
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
String viewScope = Util.null2String(jsonObj.get("viewScope"));
String statUser = Util.null2String(Util.null2String(params.get("statUser")));
// String kqdate = Util.null2String(Util.null2String(params.get("kqdate")));
if(statUser.length()>0){
sqlWhere +=" and a.id in("+statUser+") ";
}
// if(kqdate.length()>0){
// sqlWhere +=" and a.id in("+statUser+") ";
// }
// if(subCompanyId.length()>0){
// sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") ";
// }
//
// if(departmentId.length()>0){
// sqlWhere +=" and a.departmentid in("+departmentId+") ";
// }
//
// if(resourceId.length()>0){
// sqlWhere +=" and a.id in("+resourceId+") ";
// }
//
// if(viewScope.equals("4")){//我的下属
// if(allLevel.equals("1")){//所有下属
// sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
// }else{
// sqlWhere+=" and a.managerid="+user.getUID();//直接下属
// }
// }
// if (!"1".equals(isNoAccount)) {
// sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
// }
1 year ago
1 year ago
//获取加班时长
// long startTime11 = System.currentTimeMillis();
1 year ago
Map<String, Object> dailyFlowOverTimeData = getDailyFlowOverTimeDataAllowance(params, user);
// long endTime11 = System.currentTimeMillis();
// long elapsedTime11 = endTime11 - startTime11; // 执行时间
// bb.writeLog("加班时长执行时间:" + elapsedTime11 + "毫秒" );
// bb.writeLog("dailyFlowOverTimeData: " + dailyFlowOverTimeData);
1 year ago
1 year ago
//首先去除指定不享有的分部
// long startTime12 = System.currentTimeMillis();
1 year ago
List<String> subComoanyList = new ArrayList<>();
String acqNoStatAllSql = "select subcompany from uf_NoStatAllSubCom where isdelete = 0 or isdelete is null";
rs.executeQuery(acqNoStatAllSql);
while (rs.next()) {
String subcompany = Util.null2String(rs.getString("subcompany"));
if (StringUtils.isNotBlank(subcompany)) {
subComoanyList.add(subcompany);
}
}
// long endTime12 = System.currentTimeMillis();
// long elapsedTime12 = endTime12 - startTime12; // 执行时间
// bb.writeLog("不享有的分部执行时间:" + elapsedTime12 + "毫秒" );
// bb.writeLog("subComoanyList: " + subComoanyList);
1 year ago
1 year ago
String subComoanys = "";
if ( subComoanyList != null && subComoanyList.size() > 0) {
subComoanys = String.join(",", subComoanyList);
}
if (StringUtils.isNotBlank(subComoanys)) {
sqlWhere += " and a.subcompanyid1 not in ("+subComoanys+") ";
}
//指定人员不享受
List<String> noRes = new ArrayList<>();
String acqNoResSql = "select resourceid from uf_NoStatAllRes where isdelete = 0 or isdelete is null";
rs.executeQuery(acqNoResSql);
while (rs.next()) {
String resourceid = Util.null2String(rs.getString("resourceid"));
if (StringUtils.isNotBlank(resourceid)) {
noRes.add(resourceid);
}
}
if ( noRes !=null && noRes.size()>0) {
sqlWhere += " and a.id not in ("+String.join(",", noRes)+") ";
}
1 year ago
List<String> resIds = new ArrayList<>();
1 year ago
String acqResSql = "select a.id from hrmresource a where a.status in (0,1,2,3) " + sqlWhere;
bb.writeLog("acqResSql: " + acqResSql);
1 year ago
rs.executeQuery(acqResSql);
while (rs.next()) {
String id = Util.null2String(rs.getString("id"));
if (StringUtils.isNotBlank(id)) {
resIds.add(id);
}
}
1 year ago
bb.writeLog("resIds: " + resIds);
1 year ago
if (resIds != null && resIds.size() > 0 && StringUtils.isNotBlank(fromDate) && StringUtils.isNotBlank(toDate)) {
HostarUtil houtil = new HostarUtil();
List<String> allDates = houtil.getAllDates(fromDate, toDate);
1 year ago
bb.writeLog("allDates: " + allDates);
bb.writeLog("allDates.size(): " + allDates.size());
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
1 year ago
//先获取到出勤时长
// long startTime13 = System.currentTimeMillis();
1 year ago
Map<String, Double> attendanceMinsMap = new HashMap<>();
String acqAttenSql = " select resourceid, attendancemins, kqdate from kq_format_total where resourceid in (" + String.join(",",resIds) + ") and kqdate >='" + fromDate + "' and kqdate <='" + toDate + "'";
rs.executeQuery(acqAttenSql);
while (rs.next()) {
String resourceid = Util.null2String(rs.getString("resourceid"));
Double attendancemins = Util.getDoubleValue(Util.null2String(rs.getString("attendancemins")));
String kqdate = Util.null2String(rs.getString("kqdate"));
if (attendancemins >= 0.00 ) {
attendanceMinsMap.put(resourceid+"|"+kqdate, attendancemins);
}
}
// long endTime13 = System.currentTimeMillis();
// long elapsedTime13 = endTime13 - startTime13; // 执行时间
// bb.writeLog("出勤时长执行时间:" + elapsedTime13 + "毫秒" );
//获取享受的考勤组
List<String> grouplist = new ArrayList<String>();
String acqGroupSql = "select kqgroup from uf_StatAlloKqGroup where isdelete is null or isdelete = 0 " ;
rs.executeQuery(acqGroupSql);
while (rs.next()) {
String kqgroup = Util.null2String(rs.getString("kqgroup"));
if (StringUtils.isNotBlank(kqgroup)) {
grouplist.add(kqgroup);
}
}
if ( grouplist != null && grouplist.size() == 0) {
return datas;
}
1 year ago
// int x = 1;
1 year ago
for (String date : allDates) {
// long startTime14 = System.currentTimeMillis();
1 year ago
for (String res: resIds) {
// long startTime15 = System.currentTimeMillis();
//判断考勤组
/*获取考勤组的ID因为考勤组有有效期所以需要传入日期*/
String groupId = kqGroupMemberComInfo.getKQGroupId(resourceId, date);
if ( !grouplist.contains(groupId)) {
continue;
}
1 year ago
//获取考勤打卡
Map<String,Object> otherinfo = new HashMap<>();//存一些用得到的信息
String uuid = UUID.randomUUID().toString();
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
ArrayList<String> hostIps = InitServer.getRealIp();//获取IP
boolean oneSign = false;//一天一段出勤时间段
List<TimeScopeEntity> lsSignTime = new ArrayList<>();
List<TimeScopeEntity> lsWorkTime = new ArrayList<>();
1 year ago
// List<TimeScopeEntity> lsRestTime = new ArrayList<>();
1 year ago
KQWorkTime kqWorkTime = new KQWorkTime();
kqWorkTime.setIsFormat(true);
WorkTimeEntity workTime = kqWorkTime.getWorkTime(res, date);
String preDate = DateUtil.addDate(date, -1);//上一天日期
String nextDate = DateUtil.addDate(date, 1);//下一天日期
if (workTime != null) {
lsSignTime = workTime.getSignTime();//允许打卡时间
lsWorkTime = workTime.getWorkTime();//工作时间
1 year ago
// lsRestTime = workTime.getRestTime();//休息时段时间
1 year ago
oneSign = lsWorkTime!=null&&lsWorkTime.size()==1;
}
int shiftCount = lsWorkTime == null ? 0 : lsWorkTime.size();
int shiftI = 0;
1 year ago
List<Object> lsCheckInfo = new ArrayList<>();
1 year ago
for (int i = 0; lsWorkTime != null && i < lsWorkTime.size(); i++) {
shiftI = i;
TimeScopeEntity signTimeScope = lsSignTime.get(i);
TimeScopeEntity workTimeScope = lsWorkTime.get(i);
Map<String, String> shifRuleMap = Maps.newHashMap();
String workBeginTime = Util.null2String(workTimeScope.getBeginTime());
1 year ago
// String ori_workBeginTime = workBeginTime;
1 year ago
int workBeginIdx = kqTimesArrayComInfo.getArrayindexByTimes(workBeginTime);
1 year ago
// boolean workBenginTimeAcross = workTimeScope.getBeginTimeAcross();
1 year ago
String workEndTime = Util.null2String(workTimeScope.getEndTime());
1 year ago
// String ori_workEndTime = workEndTime;
1 year ago
int workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(workEndTime);
boolean workEndTimeAcross = workTimeScope.getEndTimeAcross();
1 year ago
// int workMins = workTimeScope.getWorkMins();
//
// String workBeginDate = workBenginTimeAcross ? nextDate : date;
// String workEndDate = workEndTimeAcross ? nextDate : date;
1 year ago
if(oneSign){
//个性化设置只支持一天一次上下班
ShiftInfoBean shiftInfoBean = new ShiftInfoBean();
shiftInfoBean.setSplitDate(date);
shiftInfoBean.setShiftRuleMap(workTime.getShiftRuleInfo());
shiftInfoBean.setSignTime(lsSignTime);
shiftInfoBean.setWorkTime(lsWorkTime);
List<String> logList = Lists.newArrayList();
KQShiftRuleInfoBiz.getShiftRuleInfo(shiftInfoBean, res, shifRuleMap,logList);
if(!shifRuleMap.isEmpty()){
if(!logList.isEmpty()){
otherinfo.put("logList", logList);
}
otherinfo.put("shiftRule", shifRuleMap);
if(shifRuleMap.containsKey("shift_beginworktime")){
String shift_beginworktime = Util.null2String(shifRuleMap.get("shift_beginworktime"));
if(shift_beginworktime.length() > 0){
workBeginTime = Util.null2String(shift_beginworktime);
workBeginIdx = kqTimesArrayComInfo.getArrayindexByTimes(workBeginTime);
workTimeScope.setBeginTime(workBeginTime);
workTimeScope.setBeginTimeAcross(workBeginIdx>=1440?true:false);
}
}
if(shifRuleMap.containsKey("shift_endworktime")){
String shift_endworktime = Util.null2String(shifRuleMap.get("shift_endworktime"));
if(shift_endworktime.length() > 0){
workEndTime = Util.null2String(shift_endworktime);
workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(workEndTime);
workTimeScope.setEndTime(workEndTime);
workTimeScope.setEndTimeAcross(workEndIdx>=1440?true:false);
}
}
}
}
//lsCheckInfo的内容格式
//[{
// signTime = 08: 49: 00,
// signStatus = 0,
// signType = 1,
// signDate = 2023 - 12 - 22,
// signId = 6
//}, {
// signTime = 18: 49: 00,
// signStatus = 0,
// signType = 2,
// signDate = 2023 - 12 - 22,
// signId = 7
//}]
1 year ago
lsCheckInfo = new KQFormatSignData().getSignInfo(res,signTimeScope,workTimeScope,date,preDate,nextDate,kqTimesArrayComInfo,hostIps,uuid,shiftCount,shiftI);
}
// long endTime15 = System.currentTimeMillis();
// long elapsedTime15 = endTime15 - startTime15; // 执行时间
// bb.writeLog("获取打卡数据执行时间:" + elapsedTime15 + "毫秒" );
// long startTime16 = System.currentTimeMillis();
1 year ago
List<String> signIdList = new ArrayList<>();
for (int i = 0; i < lsCheckInfo.size(); i++) {
Object o = lsCheckInfo.get(i);
if ( o != null && o != "") {
Map<String, Object> temp = (Map<String, Object>) o;
String signId = Util.null2String(temp.get("signId"));
if (StringUtils.isNotBlank(signId)) {
signIdList.add(signId);
}
1 year ago
}
}
bb.writeLog("signIdList " + signIdList);
1 year ago
Integer signNumber = 0;
if (signIdList !=null && signIdList.size() > 0) {
String acqShowAddress = "select showaddress from hrmschedulesign where id in (" + String.join(",", signIdList) + ") ";
bb.writeLog("acqShowAddress: " + acqShowAddress);
rs.executeQuery(acqShowAddress);
while (rs.next()) {
String showaddress = Util.null2String(rs.getString("showaddress"));
if ("鸿仕达".equals(showaddress) || "hostar".equalsIgnoreCase(showaddress)) {
signNumber = signNumber + 1;
}
1 year ago
}
}
if (signNumber == 0 ) {
double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|workingDayOvertime_4leave")));
workingDayOvertime_4leave = workingDayOvertime_4leave < 0 ? 0 : workingDayOvertime_4leave;
double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|restDayOvertime_4leave")));
restDayOvertime_4leave = restDayOvertime_4leave < 0 ? 0 : restDayOvertime_4leave;
double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|holidayOvertime_4leave")));
holidayOvertime_4leave = holidayOvertime_4leave < 0 ? 0 : holidayOvertime_4leave;
double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|workingDayOvertime_nonleave")));
workingDayOvertime_nonleave = workingDayOvertime_nonleave < 0 ? 0 : workingDayOvertime_nonleave;
double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|restDayOvertime_nonleave")));
restDayOvertime_nonleave = restDayOvertime_nonleave < 0 ? 0 : restDayOvertime_nonleave;
double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|holidayOvertime_nonleave")));
holidayOvertime_nonleave = holidayOvertime_nonleave < 0 ? 0 : holidayOvertime_nonleave;
double temp = workingDayOvertime_4leave + restDayOvertime_4leave + holidayOvertime_4leave +
workingDayOvertime_nonleave + restDayOvertime_nonleave + holidayOvertime_nonleave;
// bb.writeLog("-=-temp:" + temp);
1 year ago
Double attendanceMins = Util.getDoubleValue(Util.null2String(attendanceMinsMap.get(res + "|" + date)));
// bb.writeLog("-=-attendanceMins:" + attendanceMins);
String value = String.valueOf(Math.floor( ((attendanceMins < 0.00 ? 0.00 : attendanceMins) + temp) / 300));
// bb.writeLog("-=-value:" + value);
datas.put(res + "|" + "StatAllowance" + "|" + date, value);
1 year ago
}
// long endTime16 = System.currentTimeMillis();
// long elapsedTime16 = endTime16 - startTime16; // 执行时间
// bb.writeLog("计算餐补执行时间:" + elapsedTime16 + "毫秒" );
1 year ago
}
// long endTime14 = System.currentTimeMillis();
// long elapsedTime14 = endTime14 - startTime14; // 执行时间
// bb.writeLog("第" + x + "循环执行时间:" + elapsedTime14 + "毫秒" );
// x++;
1 year ago
}
}
}catch (Exception e){
writeLog(e);
bb.writeLog("StatAllowance Exception: " + e);
1 year ago
}
bb.writeLog("StatAllowance datas: " + datas);
1 year ago
1 year ago
return datas;
}
1 year ago
/**
*
* @return
*/
public Map<String,Object> getFlowOverTimeDataNew(Map<String,Object> params, User user){
Map<String,Object> datas = new HashMap<>();;
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try{
KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz();
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
String fromDate = Util.null2String(jsonObj.get("fromDate"));
String toDate = Util.null2String(jsonObj.get("toDate"));
String typeselect =Util.null2String(jsonObj.get("typeselect"));
if(typeselect.length()==0)typeselect = "3";
if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){
if(typeselect.equals("1")){
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
}else{
fromDate = TimeUtil.getDateByOption(typeselect,"0");
toDate = TimeUtil.getDateByOption(typeselect,"1");
}
}
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
String departmentId = Util.null2String(jsonObj.get("departmentId"));
String resourceId = Util.null2String(jsonObj.get("resourceId"));
String allLevel = Util.null2String(jsonObj.get("allLevel"));
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
String viewScope = Util.null2String(jsonObj.get("viewScope"));
if(subCompanyId.length()>0){
sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") ";
}
if(departmentId.length()>0){
sqlWhere +=" and a.departmentid in("+departmentId+") ";
}
if(resourceId.length()>0){
sqlWhere +=" and a.id in("+resourceId+") ";
}
if(viewScope.equals("4")){//我的下属
if(allLevel.equals("1")){//所有下属
sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
}else{
sqlWhere+=" and a.managerid="+user.getUID();//直接下属
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
}
int uintType = kqOvertimeRulesBiz.getMinimumUnit();//当前加班单位
double hoursToDay = kqOvertimeRulesBiz.getHoursToDay();//当前天跟小时计算关系
String valueField = "";
sql = " select resourceid,changeType, sum(cast(duration_min as decimal(18,4))) as val,paidLeaveEnable "+
" from hrmresource a, kq_flow_overtime b "+
" where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere+
" group by resourceid,changeType,paidLeaveEnable ";
rs.execute(sql);
kqLog.info("getFlowOverTimeDataNew:sql:"+sql);
while (rs.next()) {
String resourceid = rs.getString("resourceid");
String paidLeaveEnable = rs.getString("paidLeaveEnable");
int changeType =rs.getInt("changeType");//1-节假日、2-工作日、3-休息日
double value = rs.getDouble("val")<0?0:rs.getDouble("val");
if(uintType==3 || uintType== 5 || uintType== 6){//按小时计算
value = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(value/(60.0)+""));
}else{//按天计算
value = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(value/(60.0*hoursToDay)+""));
}
String flowType = "";
if(changeType==1){
flowType = "holidayOvertime";
}else if(changeType==2){
flowType = "workingDayOvertime";
}else if(changeType==3){
flowType = "restDayOvertime";
}
if("1".equalsIgnoreCase(paidLeaveEnable)){
//1表示关联调休
flowType += "_4leave";
}else{
//0表示不关联调休
flowType += "_nonleave";
}
String key = resourceid+"|"+flowType;
//df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了
df.setMaximumFractionDigits(5);
if(datas.containsKey(key)){
double tmpVal = Util.getDoubleValue(Util.null2String(datas.get(key)),0.0);
tmpVal += value;
datas.put(key,format(tmpVal));
}else{
datas.put(key,format(value));
}
}
}catch (Exception e){
writeLog(e);
}
return datas;
}
/**
*
* @return
*/
public Map<String,Object> getFlowOverTimeData(Map<String,Object> params, User user){
Map<String,Object> datas = new HashMap<>();;
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try{
KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz();
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
String fromDate = Util.null2String(jsonObj.get("fromDate"));
String toDate = Util.null2String(jsonObj.get("toDate"));
String typeselect =Util.null2String(jsonObj.get("typeselect"));
if(typeselect.length()==0)typeselect = "3";
if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){
if(typeselect.equals("1")){
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
}else{
fromDate = TimeUtil.getDateByOption(typeselect,"0");
toDate = TimeUtil.getDateByOption(typeselect,"1");
}
}
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
String departmentId = Util.null2String(jsonObj.get("departmentId"));
String resourceId = Util.null2String(jsonObj.get("resourceId"));
String allLevel = Util.null2String(jsonObj.get("allLevel"));
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
String viewScope = Util.null2String(jsonObj.get("viewScope"));
if(subCompanyId.length()>0){
sqlWhere +=" and b.subcompanyid in("+subCompanyId+") ";
}
if(departmentId.length()>0){
sqlWhere +=" and b.departmentid in("+departmentId+") ";
}
if(resourceId.length()>0){
sqlWhere +=" and b.resourceid in("+resourceId+") ";
}
if(viewScope.equals("4")){//我的下属
if(allLevel.equals("1")){//所有下属
sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
}else{
sqlWhere+=" and a.managerid="+user.getUID();//直接下属
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
}
int uintType = kqOvertimeRulesBiz.getMinimumUnit();//当前加班单位
double hoursToDay = kqOvertimeRulesBiz.getHoursToDay();//当前天跟小时计算关系
String valueField = "";
if(uintType==3 || uintType== 5 || uintType== 6){//按小时计算
valueField = "sum( case when durationrule='3' then duration else duration*"+hoursToDay+" end) as val";
}else{//按天计算
valueField = "sum( case when durationrule='3' then duration/"+hoursToDay+" else duration end) as val";
}
sql = " select resourceid,changeType, " +valueField+
" from hrmresource a, "+KqSplitFlowTypeEnum.OVERTIME.getTablename()+" b "+
" where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere+
" group by resourceid,changeType,durationrule ";
rs.execute(sql);
while (rs.next()) {
String resourceid = rs.getString("resourceid");
int changeType =rs.getInt("changeType");//1-节假日、2-工作日、3-休息日
double value = rs.getDouble("val")<0?0:rs.getDouble("val");
String flowType = "";
if(changeType==1){
flowType = "holidayOvertime";
}else if(changeType==2){
flowType = "workingDayOvertime";
}else if(changeType==3){
flowType = "restDayOvertime";
}
String key = resourceid+"|"+flowType;
//df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了
df.setMaximumFractionDigits(5);
if(datas.containsKey(key)){
double tmpVal = Util.getDoubleValue(Util.null2String(datas.get(key)),0.0);
tmpVal += value;
datas.put(key,format(tmpVal));
}else{
datas.put(key,format(value));
}
}
}catch (Exception e){
writeLog(e);
}
return datas;
}
/**
*
* @return
*/
public Map<String,Object> getDailyFlowOverTimeData(Map<String,Object> params, User user){
Map<String,Object> datas = new HashMap<>();;
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try{
KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz();
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
String fromDate = Util.null2String(jsonObj.get("fromDate"));
String toDate = Util.null2String(jsonObj.get("toDate"));
String typeselect =Util.null2String(jsonObj.get("typeselect"));
if(typeselect.length()==0)typeselect = "3";
if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){
if(typeselect.equals("1")){
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
}else{
fromDate = TimeUtil.getDateByOption(typeselect,"0");
toDate = TimeUtil.getDateByOption(typeselect,"1");
}
}
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
String departmentId = Util.null2String(jsonObj.get("departmentId"));
String resourceId = Util.null2String(jsonObj.get("resourceId"));
String allLevel = Util.null2String(jsonObj.get("allLevel"));
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
String viewScope = Util.null2String(jsonObj.get("viewScope"));
if(subCompanyId.length()>0){
sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") ";
}
if(departmentId.length()>0){
sqlWhere +=" and a.departmentid in("+departmentId+") ";
}
if(resourceId.length()>0){
sqlWhere +=" and a.id in("+resourceId+") ";
}
if(viewScope.equals("4")){//我的下属
if(allLevel.equals("1")){//所有下属
sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
}else{
sqlWhere+=" and a.managerid="+user.getUID();//直接下属
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
}
int uintType = kqOvertimeRulesBiz.getMinimumUnit();//当前加班单位
double hoursToDay = kqOvertimeRulesBiz.getHoursToDay();//当前天跟小时计算关系
String valueField = "";
if(uintType==3 || uintType== 5 || uintType== 6){//按小时计算
valueField = "sum( case when durationrule='3' then duration else duration*"+hoursToDay+" end) as val";
}else{//按天计算
valueField = "sum( case when durationrule='3' then duration/"+hoursToDay+" else duration end) as val";
}
sql = " select resourceid,changeType,belongdate,paidLeaveEnable, sum(cast(duration_min as decimal(18,4))) as val "+
" from hrmresource a, kq_flow_overtime b "+
" where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere+
" group by resourceid,changeType,paidLeaveEnable,belongdate ";
rs.execute(sql);
while (rs.next()) {
String resourceid = rs.getString("resourceid");
String belongdate = rs.getString("belongdate");
String paidLeaveEnable = rs.getString("paidLeaveEnable");
int changeType =rs.getInt("changeType");//1-节假日、2-工作日、3-休息日
double value = rs.getDouble("val")<0?0:rs.getDouble("val");
if(uintType==3 || uintType== 5 || uintType== 6){//按小时计算
value = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(value/(60.0)+""));
}else{//按天计算
value = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(value/(60.0*hoursToDay)+""));
}
String flowType = "";
if(changeType==1){
flowType = "holidayOvertime";
}else if(changeType==2){
flowType = "workingDayOvertime";
}else if(changeType==3){
flowType = "restDayOvertime";
}
if("1".equalsIgnoreCase(paidLeaveEnable)){
//1表示关联调休
flowType += "_4leave";
}else{
//0表示不关联调休
flowType += "_nonleave";
}
//df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了
df.setMaximumFractionDigits(5);
datas.put(resourceid+"|"+belongdate+"|"+flowType,format(value));
1 year ago
}
}catch (Exception e){
writeLog(e);
}
return datas;
}
/**
* (使)
* @return
*/
public Map<String,Object> getDailyFlowOverTimeDataAllowance(Map<String,Object> params, User user){
Map<String,Object> datas = new HashMap<>();;
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try{
KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz();
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
String fromDate = Util.null2String(jsonObj.get("fromDate"));
String toDate = Util.null2String(jsonObj.get("toDate"));
String typeselect =Util.null2String(jsonObj.get("typeselect"));
if(typeselect.length()==0)typeselect = "3";
if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){
if(typeselect.equals("1")){
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
}else{
fromDate = TimeUtil.getDateByOption(typeselect,"0");
toDate = TimeUtil.getDateByOption(typeselect,"1");
}
}
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
String departmentId = Util.null2String(jsonObj.get("departmentId"));
String resourceId = Util.null2String(jsonObj.get("resourceId"));
String allLevel = Util.null2String(jsonObj.get("allLevel"));
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
String viewScope = Util.null2String(jsonObj.get("viewScope"));
if(subCompanyId.length()>0){
sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") ";
}
if(departmentId.length()>0){
sqlWhere +=" and a.departmentid in("+departmentId+") ";
}
if(resourceId.length()>0){
sqlWhere +=" and a.id in("+resourceId+") ";
}
if(viewScope.equals("4")){//我的下属
if(allLevel.equals("1")){//所有下属
sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
}else{
sqlWhere+=" and a.managerid="+user.getUID();//直接下属
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
}
int uintType = kqOvertimeRulesBiz.getMinimumUnit();//当前加班单位
double hoursToDay = kqOvertimeRulesBiz.getHoursToDay();//当前天跟小时计算关系
String valueField = "";
if(uintType==3 || uintType== 5 || uintType== 6){//按小时计算
valueField = "sum( case when durationrule='3' then duration else duration*"+hoursToDay+" end) as val";
}else{//按天计算
valueField = "sum( case when durationrule='3' then duration/"+hoursToDay+" else duration end) as val";
}
sql = " select resourceid,changeType,belongdate,paidLeaveEnable, sum(cast(duration_min as decimal(18,4))) as val "+
" from hrmresource a, kq_flow_overtime b "+
" where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere+
" group by resourceid,changeType,paidLeaveEnable,belongdate ";
rs.execute(sql);
while (rs.next()) {
String resourceid = rs.getString("resourceid");
String belongdate = rs.getString("belongdate");
String paidLeaveEnable = rs.getString("paidLeaveEnable");
int changeType =rs.getInt("changeType");//1-节假日、2-工作日、3-休息日
double value = rs.getDouble("val")<0?0:rs.getDouble("val");
if(uintType==3 || uintType== 5 || uintType== 6){//按小时计算
value = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(value+""));
}else{//按天计算
value = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(value+""));
}
String flowType = "";
if(changeType==1){
flowType = "holidayOvertime";
}else if(changeType==2){
flowType = "workingDayOvertime";
}else if(changeType==3){
flowType = "restDayOvertime";
}
if("1".equalsIgnoreCase(paidLeaveEnable)){
//1表示关联调休
flowType += "_4leave";
}else{
//0表示不关联调休
flowType += "_nonleave";
}
//df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了
df.setMaximumFractionDigits(5);
datas.put(resourceid+"|"+belongdate+"|"+flowType,format(value));
}
}catch (Exception e){
writeLog(e);
}
return datas;
}
/**
*
* @return
*/
public Map<String,Object> getFlowOtherData(Map<String,Object> params, User user){
Map<String,Object> datas = new HashMap<>();;
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try{
String minimumUnit = "";//单位类型
double proportion = 0.00;//换算关系
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
String fromDate = Util.null2String(jsonObj.get("fromDate"));
String toDate = Util.null2String(jsonObj.get("toDate"));
String typeselect =Util.null2String(jsonObj.get("typeselect"));
if(typeselect.length()==0)typeselect = "3";
if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){
if(typeselect.equals("1")){
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
}else{
fromDate = TimeUtil.getDateByOption(typeselect,"0");
toDate = TimeUtil.getDateByOption(typeselect,"1");
}
}
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
String departmentId = Util.null2String(jsonObj.get("departmentId"));
String resourceId = Util.null2String(jsonObj.get("resourceId"));
String allLevel = Util.null2String(jsonObj.get("allLevel"));
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
String viewScope = Util.null2String(jsonObj.get("viewScope"));
if(subCompanyId.length()>0){
sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") ";
}
if(departmentId.length()>0){
sqlWhere +=" and a.departmentid in("+departmentId+") ";
}
if(resourceId.length()>0){
sqlWhere +=" and b.resourceid in("+resourceId+") ";
}
if(viewScope.equals("4")){//我的下属
if(allLevel.equals("1")){//所有下属
sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
}else{
sqlWhere+=" and a.managerid="+user.getUID();//直接下属
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
}
sql = " select resourceid, durationrule, sum(duration) as val from hrmresource a, "+KqSplitFlowTypeEnum.OTHER.getTablename()+" b "+
" where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' "+sqlWhere+
" group by resourceid, durationrule ";
rs.execute(sql);
while (rs.next()) {
String resourceid = rs.getString("resourceid");
double value = rs.getDouble("val")<0?0:rs.getDouble("val");
String durationrule = rs.getString("durationrule");
if(KQUnitBiz.isLeaveHour(minimumUnit)){//按小时
if(!KQUnitBiz.isLeaveHour(durationrule)){
if(proportion>0) value = value*proportion;
}
}else{//按天
if(KQUnitBiz.isLeaveHour(durationrule)){
if(proportion>0) value = value/proportion;
}
}
String key = resourceid+"|leaveDeduction";
if(datas.containsKey(key)){
value += Util.getDoubleValue(Util.null2String(datas.get(key)));
}
//df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了
df.setMaximumFractionDigits(5);
datas.put(key, format(value));
}
}catch (Exception e){
writeLog(e);
}
return datas;
}
/**
*
* @param resourceId
* @param fromDate
* @param toDate
* @return
*/
public Map<String,Object> getDetialDatas(String resourceId,String fromDate, String toDate, User user){
return getDetialDatas(resourceId,fromDate,toDate,user,new HashMap<String,Object>(),false,0,"0");
}
public Map<String,Object> getDetialDatas(String resourceId,String fromDate, String toDate, User user,
Map<String,Object> flowData,boolean isWrap,int uintType,String show_card_source){
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
Map<String,Object> datas = new HashMap<>();
Map<String,Object> data = null;
Map<String,Object> tmpdatas = new HashMap<>();
Map<String,Object> tmpdata = null;
Map<String,Object> tmpmap = null;
Map<String,String> tmpstatusdata = new HashMap<>();
Map<String,String> tmpstatus = null;
RecordSet rs = new RecordSet();
String sql = "";
//add
String unit = "小时";
if(uintType==1 || uintType== 2 || uintType== 4){//按天计算
unit = "天";
}
//kqLog.info("detail.flowdata="+JSONObject.toJSONString(flowData));
try {
sql = " select resourceid, kqdate, workMins,attendanceMins,signindate,signintime,signoutdate,signouttime,signinid,signoutid, belatemins, graveBeLateMins, leaveearlymins, graveLeaveEarlyMins, absenteeismmins, forgotcheckMins, forgotBeginWorkCheckMins, "+
" leaveMins,leaveInfo,evectionMins,outMins " +
" from kq_format_detail " +
" where resourceid = ? and kqdate>=? and kqdate<=? "+
" order by resourceid, kqdate, serialnumber ";
rs.executeQuery(sql,resourceId, fromDate,toDate);
while (rs.next()) {
String key = rs.getString("resourceid") + "|" + rs.getString("kqdate");
int workMins = rs.getInt("workMins");
String attendanceMins = rs.getString("attendanceMins");
// String chuqin = "出勤:"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(attendanceMins) / 60.0)))+"小时";
String overtimekey = key+"|overtime";
String overtime = Util.null2String(flowData.get(overtimekey));
boolean hasovertime = Util.getDoubleValue(overtime)>0;
overtime = hasovertime?(SystemEnv.getHtmlLabelName(6151, user.getLanguage())+""+overtime+unit):"";//显示加班
String signinid = "";
String signoutid = "";
String signintime = "";
String signouttime = "";
if("1".equals(show_card_source)){
String nosign = SystemEnv.getHtmlLabelName(25994, user.getLanguage());//未打卡
signinid = Util.null2String(rs.getString("signinid")).trim();
signintime = Util.null2String(rs.getString("signintime")).trim();
String tmpin = SystemEnv.getHtmlLabelName(21974, user.getLanguage())+"";
if(signinid.length()>0){
String signinfrom = Util.null2String(flowData.get(signinid));
signintime = tmpin+signintime+" "+signinfrom;
}else{
signintime = tmpin+nosign;
}
// signintime = isWrap?"\r\n"+signintime:"<br/>"+signintime;
signoutid = Util.null2String(rs.getString("signoutid")).trim();
signouttime = Util.null2String(rs.getString("signouttime")).trim();
String tmpout = SystemEnv.getHtmlLabelName(21975, user.getLanguage())+"";
if(signoutid.length()>0){
String signoutfrom = Util.null2String(flowData.get(signoutid));
signouttime = tmpout+signouttime+" "+signoutfrom;
}else{
signouttime = tmpout+nosign;
}
signouttime = isWrap?"\r\n"+signouttime:"<br/>"+signouttime;
}
int beLateMins = rs.getInt("beLateMins");
int leaveEarlyMins = rs.getInt("leaveEarlyMins");
int graveBeLateMins = rs.getInt("graveBeLateMins");
int absenteeismMins = rs.getInt("absenteeismMins");
int graveLeaveEarlyMins = rs.getInt("graveLeaveEarlyMins");
int forgotCheckMins = rs.getInt("forgotCheckMins");
int forgotBeginWorkCheckMins = rs.getInt("forgotBeginWorkCheckMins");
int leaveMins = rs.getInt("leaveMins");
String leaveInfo = rs.getString("leaveInfo");
int evectionMins = rs.getInt("evectionMins");
int outMins = rs.getInt("outMins");
String text = "";
String tmptext ="";
String flag ="true";
if(datas.get(key)==null){
data = new HashMap<>();
}else{
data = (Map<String,Object>)datas.get(key);
tmptext = Util.null2String(data.get("text"));
}
tmpdata = new HashMap<>();
if(tmpdatas.get(key)!=null){
tmpmap = (Map<String,Object>)tmpdatas.get(key);
flag = Util.null2String(tmpmap.get("text"));
}
String yichang ="";
if(tmpstatusdata.get(key)!=null){
yichang = Util.null2String(tmpstatusdata.get(key));
}
String sign ="";
String signkey = key+"|text";
if(tmpstatusdata.get(signkey)!=null){
sign = Util.null2String(tmpstatusdata.get(signkey));
}
if (workMins<=0) {
if(text.length()>0) text +=" ";
text += SystemEnv.getHtmlLabelName(26593, user.getLanguage());
//休息日处理
if(signinid.length()>0){
text += (isWrap?"\r\n":"<br/>")+signintime;
}
if(signoutid.length()>0){
text += signouttime;
}
if(sign.length()>0) sign += isWrap?"\r\n":"<br/>";
sign += text;
} else {
//处理打卡数据==================
if(text.length()>0) text+= isWrap?"\r\n":"<br/>";
text += signintime;
text += signouttime;
if(sign.length()>0) sign+= isWrap?"\r\n":"<br/>";
sign += text;
//处理打卡数据==================
if (absenteeismMins > 0) {//旷工
if(text.length()>0) text+=" ";
text += SystemEnv.getHtmlLabelName(20085, user.getLanguage());
// text += ""+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+absenteeismMins) / 60.0)))+"小时";
if(yichang.indexOf(SystemEnv.getHtmlLabelName(20085, user.getLanguage()))==-1){
if(yichang.length()>0) yichang+= isWrap?"\r\n":"<br/>";
yichang += SystemEnv.getHtmlLabelName(20085, user.getLanguage());
}
}else {
if (beLateMins > 0) {//迟到
if (text.length() > 0) text += " ";
text += SystemEnv.getHtmlLabelName(20081, user.getLanguage());
// text += ""+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+beLateMins) / 60.0)))+"小时";
if(yichang.indexOf(SystemEnv.getHtmlLabelName(20081, user.getLanguage()))==-1) {
if (yichang.length() > 0) yichang += isWrap?"\r\n":"<br/>";
yichang += SystemEnv.getHtmlLabelName(20081, user.getLanguage());
}
}
if (graveBeLateMins > 0) {//严重迟到
if (text.length() > 0) text += " ";
text += SystemEnv.getHtmlLabelName(500546, user.getLanguage());
// text += ""+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+graveBeLateMins) / 60.0)))+"小时";
if(yichang.indexOf(SystemEnv.getHtmlLabelName(500546, user.getLanguage()))==-1) {
if (yichang.length() > 0) yichang += isWrap?"\r\n":"<br/>";
yichang += SystemEnv.getHtmlLabelName(500546, user.getLanguage());
}
}
if (leaveEarlyMins > 0) {//早退
if (text.length() > 0) text += " ";
text += SystemEnv.getHtmlLabelName(20082, user.getLanguage());
// text += ""+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+leaveEarlyMins) / 60.0)))+"小时";
if(yichang.indexOf(SystemEnv.getHtmlLabelName(20082, user.getLanguage()))==-1) {
if (yichang.length() > 0) yichang += isWrap?"\r\n":"<br/>";
yichang += SystemEnv.getHtmlLabelName(20082, user.getLanguage());
}
}
if (graveLeaveEarlyMins > 0) {//严重早退
if (text.length() > 0) text += " ";
text += SystemEnv.getHtmlLabelName(500547, user.getLanguage());
// text += ""+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+graveLeaveEarlyMins) / 60.0)))+"小时";
if(yichang.indexOf(SystemEnv.getHtmlLabelName(500547, user.getLanguage()))==-1) {
if (yichang.length() > 0) yichang += isWrap?"\r\n":"<br/>";
yichang += SystemEnv.getHtmlLabelName(500547, user.getLanguage());
}
}
if (forgotCheckMins > 0) {//漏签
if (text.length() > 0) text += " ";
text += SystemEnv.getHtmlLabelName(20086, user.getLanguage());
if(yichang.indexOf(SystemEnv.getHtmlLabelName(20086, user.getLanguage()))==-1) {
if (yichang.length() > 0) yichang += isWrap?"\r\n":"<br/>";
yichang += SystemEnv.getHtmlLabelName(20086, user.getLanguage());
}
}
if (forgotBeginWorkCheckMins > 0) {//漏签
if (text.length() > 0) text += " ";
text += SystemEnv.getHtmlLabelName(20086, user.getLanguage());
if(yichang.indexOf(SystemEnv.getHtmlLabelName(20086, user.getLanguage()))==-1) {
if (yichang.length() > 0) yichang += isWrap?"\r\n":"<br/>";
yichang += SystemEnv.getHtmlLabelName(20086, user.getLanguage());
}
}
}
}
if (leaveMins > 0) {//请假
Map<String,Object> jsonObject = null;
if(leaveInfo.length()>0){
jsonObject = JSON.parseObject(leaveInfo);
for (Entry<String,Object> entry : jsonObject.entrySet()) {
String newLeaveType = entry.getKey();
String tmpLeaveMins = Util.null2String(entry.getValue());
if(text.indexOf(kqLeaveRulesComInfo.getLeaveName(newLeaveType))==-1){
if (text.length() > 0) text += " ";
//text += kqLeaveRulesComInfo.getLeaveName(newLeaveType)+tmpLeaveMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage());
text += Util.formatMultiLang( kqLeaveRulesComInfo.getLeaveName(newLeaveType),""+user.getLanguage());
// text += ""+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+leaveMins) / 60.0)))+"小时";
if(yichang.length()>0) yichang+= isWrap?"\r\n":"<br/>";
yichang += Util.formatMultiLang( kqLeaveRulesComInfo.getLeaveName(newLeaveType),""+user.getLanguage());
}
}
}else{
if(text.indexOf(SystemEnv.getHtmlLabelName(670, user.getLanguage()))==-1) {
if (text.length() > 0) text += " ";
text += SystemEnv.getHtmlLabelName(670, user.getLanguage());
}
}
}
if (evectionMins > 0) {//出差
if(text.indexOf(SystemEnv.getHtmlLabelName(20084, user.getLanguage()))==-1) {
if (text.length() > 0) text += " ";
text += SystemEnv.getHtmlLabelName(20084, user.getLanguage());
// text += ""+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+evectionMins) / 60.0)))+"小时";
if(yichang.length()>0) yichang+= isWrap?"\r\n":"<br/>";
yichang += SystemEnv.getHtmlLabelName(20084, user.getLanguage());
}
}
if (outMins > 0) {//公出
if(text.indexOf(SystemEnv.getHtmlLabelName(24058, user.getLanguage()))==-1) {
if (text.length() > 0) text += " ";
text += SystemEnv.getHtmlLabelName(24058, user.getLanguage());
// text += ""+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+outMins) / 60.0)))+"小时";
if(yichang.length()>0) yichang+= isWrap?"\r\n":"<br/>";
yichang += SystemEnv.getHtmlLabelName(24058, user.getLanguage());
}
}
if(text.length()==0) {
text = "√";
}else{
flag = "false";//有其他的异常状态,则表示为false不需要处理直接全部显示即可
}
text += overtime;
//需要处理下打卡时间和异常状态显示的顺序--start
tmpstatusdata.put(key, yichang);
tmpstatusdata.put(signkey, sign);
boolean hasyichang = tmpstatusdata.get(key).length()>0;
if(tmptext.length()>0){
// text = tmpstatusdata.get(signkey)+(isWrap?"\r\n":"<br/>")+tmpstatusdata.get(key)+(isWrap?"\r\n":"<br/>"+overtime);
text = tmpstatusdata.get(signkey);
if(hasyichang){
text += (isWrap?"\r\n":"<br/>")+tmpstatusdata.get(key);
}
if(hasovertime){
text += (isWrap?"\r\n":"<br/>")+overtime;
}
}else{
text = tmpstatusdata.get(signkey);
if(hasyichang){
text += (isWrap?"\r\n":"<br/>")+tmpstatusdata.get(key);
}
if(hasovertime){
text += (isWrap?"\r\n":"<br/>")+overtime;
}
}
//需要处理下打卡时间和异常状态显示的顺序--end
// text = tmptext.length()>0?tmptext+" "+text:text;//显示所有的状态
data.put("text", text);
datas.put(key, data);
//add
tmpdata.put("text", flag);
tmpdatas.put(key, tmpdata);
//end
}
//全部搞一遍
if(tmpdatas != null){
// writeLog(n+">>>tmpdatas="+JSONObject.toJSONString(tmpdatas));
Map<String,Object> data1 = null;
for(Entry<String,Object> entry : tmpdatas.entrySet()){
String mapKey = Util.null2String(entry.getKey());
Map<String,Object> mapValue = (Map<String,Object>)entry.getValue();
String flag = Util.null2String(mapValue.get("text"));
if("true".equals(flag)){//需要加工的数据
data1 = new HashMap<>();
data1.put("text", "√");
datas.put(mapKey, data1);
}
}
// writeLog("datas="+JSONObject.toJSONString(datas));
}
}catch (Exception e){
writeLog(e);
}
// 最后针对数据再处理一遍不然出现2023-01-02: "休息" 形式的错误导致页面记载报错应该是2023-01-01: {text: "休息"}格式
boolean isEnd = false;
for(String currentDate = fromDate; !isEnd;) {
if (currentDate.equals(toDate)) isEnd = true;
String dailyValue = Util.null2String(datas.get(currentDate));
if(!"".equals(dailyValue) && !dailyValue.contains("text")) {
Map<String,Object> innerMap2 = new HashMap<>();
innerMap2.put("text", dailyValue);
datas.put(currentDate, innerMap2);
}
currentDate = DateUtil.addDate(currentDate, 1);
}
return datas;
}
// public String getSignStatus(Map<String,Object> data, User user){
// String result = "";
// String signtype = Util.null2String(data.get("signtype"));//上班 下班
// String worktime = Util.null2String(data.get("worktime"));//工作时间
// String signtime = Util.null2String(data.get("signtime"));//签到时间
// String abnormalMins = Util.null2String(data.get("abnormalMins"));//异常分钟数
// String forgotCheck = Util.null2String(data.get("forgotCheck"));//漏签
// if(worktime.length()>0){
// if(signtime.length()>0){
// if(Util.getDoubleValue(abnormalMins)>0){
// result =SystemEnv.getHtmlLabelName(signtype.equals("1")?20081:20082, user.getLanguage())+abnormalMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage());//迟到 早退
// }else{
// result =SystemEnv.getHtmlLabelName(225, user.getLanguage());//正常
// }
// }else if(forgotCheck.equals("1")){
// result =SystemEnv.getHtmlLabelName(20086, user.getLanguage());//漏签
// }
// }else{
// result = "";
// }
//
// return result;
// }
public int getSerialCount(String resourceId, String fromDate, String toDate, String serialId){
RecordSet rs = new RecordSet();
String sql = "";
int serialCount = 0;
try{
sql = "select count(1) from hrmresource a, kq_format_total b where a.id= b.resourceid and b.resourceid = ? and b.kqdate >=? and b.kqdate <=? and b.serialId = ? ";
rs.executeQuery(sql,resourceId,fromDate,toDate, serialId);
if(rs.next()){
serialCount = rs.getInt(1);
}
}catch (Exception e){
writeLog(e);
}
return serialCount;
}
public static String getSignStatus(Map<String,Object> signInfo, User user){
return getSignStatus(signInfo,user,"");
}
public static String getSignStatus(Map<String,Object> signInfo, User user,String onOrOff){
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
String text = "";
String workdate = Util.null2String(signInfo.get("workdate"));
String worktime = Util.null2String(signInfo.get("worktime"));
if(!new KQFormatBiz().needCal(workdate,worktime)) {//还未到时间无需计算
return text;
}
int absenteeismMins = Util.getIntValue(Util.null2String(signInfo.get("absenteeismMins")));
int beLateMins = Util.getIntValue(Util.null2String(signInfo.get("beLateMins")));
int graveBeLateMins = Util.getIntValue(Util.null2String(signInfo.get("graveBeLateMins")));
int leaveEarlyMins = Util.getIntValue(Util.null2String(signInfo.get("leaveEarlyMins")));
int graveLeaveEarlyMins = Util.getIntValue(Util.null2String(signInfo.get("graveLeaveEarlyMins")));
int forgotCheckMins = Util.getIntValue(Util.null2String(signInfo.get("forgotCheckMins")));
int forgotBeginWorkCheckMins = Util.getIntValue(Util.null2String(signInfo.get("forgotBeginWorkCheckMins")));
int leaveMins = Util.getIntValue(Util.null2String(signInfo.get("leaveMins")));
String leaveInfo = Util.null2String(signInfo.get("leaveInfo"));
int evectionMins = Util.getIntValue(Util.null2String(signInfo.get("evectionMins")));
int outMins = Util.getIntValue(Util.null2String(signInfo.get("outMins")));
if(worktime.length()>0){
if (absenteeismMins > 0) {//旷工
text = SystemEnv.getHtmlLabelName(20085, user.getLanguage())+absenteeismMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage());
}else {
if (beLateMins > 0) {//迟到
text = SystemEnv.getHtmlLabelName(20081, user.getLanguage())+beLateMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage());
}
if (graveBeLateMins > 0) {//严重迟到
1 year ago
text = SystemEnv.getHtmlLabelName(500546, user.getLanguage())+graveBeLateMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage());
}
if (leaveEarlyMins > 0) {//早退
text = SystemEnv.getHtmlLabelName(20082, user.getLanguage())+leaveEarlyMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage());
}
if (graveLeaveEarlyMins > 0) {//严重早退
text = SystemEnv.getHtmlLabelName(500547, user.getLanguage())+graveLeaveEarlyMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage());
}
if (forgotCheckMins > 0) {//漏签
text = SystemEnv.getHtmlLabelName(20086, user.getLanguage());
}
if(onOrOff.length() > 0 && "on".equalsIgnoreCase(onOrOff)){
if (forgotBeginWorkCheckMins > 0) {//漏签
text = SystemEnv.getHtmlLabelName(20086, user.getLanguage());
}
}
}
if (leaveMins > 0) {//请假
Map<String,Object> jsonObject = null;
if(leaveInfo.length()>0){
jsonObject = JSON.parseObject(leaveInfo);
for (Entry<String,Object> entry : jsonObject.entrySet()) {
String newLeaveType = entry.getKey();
String tmpLeaveMins = Util.null2String(entry.getValue());
if(text.indexOf(kqLeaveRulesComInfo.getLeaveName(newLeaveType))==-1){
if (text.length() > 0) text += " ";
//text += kqLeaveRulesComInfo.getLeaveName(newLeaveType)+tmpLeaveMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage());
text += Util.formatMultiLang(kqLeaveRulesComInfo.getLeaveName(newLeaveType),""+user.getLanguage());
}
}
}else{
if(text.indexOf(SystemEnv.getHtmlLabelName(670, user.getLanguage()))==-1) {
if (text.length() > 0) text += " ";
text += SystemEnv.getHtmlLabelName(670, user.getLanguage());
}
}
}
if (evectionMins > 0) {//出差
if(text.indexOf(SystemEnv.getHtmlLabelName(20084, user.getLanguage()))==-1) {
if (text.length() > 0) text += " ";
text += SystemEnv.getHtmlLabelName(20084, user.getLanguage());
}
}
if (outMins > 0) {//公出
if(text.indexOf(SystemEnv.getHtmlLabelName(24058, user.getLanguage()))==-1) {
if (text.length() > 0) text += " ";
text += SystemEnv.getHtmlLabelName(24058, user.getLanguage());
}
}
if(text.equals("")){
boolean needCal = new KQFormatBiz().needCal(workdate,worktime);
text = needCal?SystemEnv.getHtmlLabelName(225, user.getLanguage()):"";
}
}else{
if (leaveMins > 0) {//请假
Map<String,Object> jsonObject = null;
if(leaveInfo.length()>0){
jsonObject = JSON.parseObject(leaveInfo);
for (Entry<String,Object> entry : jsonObject.entrySet()) {
String newLeaveType = entry.getKey();
String tmpLeaveMins = Util.null2String(entry.getValue());
if(text.indexOf(kqLeaveRulesComInfo.getLeaveName(newLeaveType))==-1){
if (text.length() > 0) text += " ";
//text += kqLeaveRulesComInfo.getLeaveName(newLeaveType)+tmpLeaveMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage());
text += Util.formatMultiLang(kqLeaveRulesComInfo.getLeaveName(newLeaveType));
}
}
}else{
if(text.indexOf(SystemEnv.getHtmlLabelName(670, user.getLanguage()))==-1) {
if (text.length() > 0) text += " ";
text += SystemEnv.getHtmlLabelName(670, user.getLanguage());
}
}
}
if (evectionMins > 0) {//出差
if(text.indexOf(SystemEnv.getHtmlLabelName(20084, user.getLanguage()))==-1) {
if (text.length() > 0) text += " ";
text += SystemEnv.getHtmlLabelName(20084, user.getLanguage());
}
}
if (outMins > 0) {//公出
if(text.indexOf(SystemEnv.getHtmlLabelName(24058, user.getLanguage()))==-1) {
if (text.length() > 0) text += " ";
text += SystemEnv.getHtmlLabelName(24058, user.getLanguage());
}
}
}
return text;
}
/**
* ()
* @param signInfo
* @param user
* @param onOrOff
* @return
*/
public static String getSignStatus2(Map<String, Object> signInfo, User user, String onOrOff) {
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
String text = "";
String worktime = Util.null2String(signInfo.get("worktime"));
int absenteeismMins = Util.getIntValue(Util.null2String(signInfo.get("absenteeismMins")));
int beLateMins = Util.getIntValue(Util.null2String(signInfo.get("beLateMins")));
int graveBeLateMins = Util.getIntValue(Util.null2String(signInfo.get("graveBeLateMins")));
int leaveEarlyMins = Util.getIntValue(Util.null2String(signInfo.get("leaveEarlyMins")));
int graveLeaveEarlyMins = Util.getIntValue(Util.null2String(signInfo.get("graveLeaveEarlyMins")));
int forgotCheckMins = Util.getIntValue(Util.null2String(signInfo.get("forgotCheckMins")));
int forgotBeginWorkCheckMins = Util.getIntValue(Util.null2String(signInfo.get("forgotBeginWorkCheckMins")));
int leaveMins = Util.getIntValue(Util.null2String(signInfo.get("leaveMins")));
String leaveInfo = Util.null2String(signInfo.get("leaveInfo"));
int evectionMins = Util.getIntValue(Util.null2String(signInfo.get("evectionMins")));
int outMins = Util.getIntValue(Util.null2String(signInfo.get("outMins")));
if (worktime.length() > 0) {
if (absenteeismMins > 0) {//旷工
text = SystemEnv.getHtmlLabelName(20085, user.getLanguage());
} else {
if (beLateMins > 0) {//迟到
text = SystemEnv.getHtmlLabelName(20081, user.getLanguage());
}
if (graveBeLateMins > 0) {//严重迟到
text = SystemEnv.getHtmlLabelName(500546, user.getLanguage());
}
if (leaveEarlyMins > 0) {//早退
text = SystemEnv.getHtmlLabelName(20082, user.getLanguage());
}
if (graveLeaveEarlyMins > 0) {//严重早退
text = SystemEnv.getHtmlLabelName(500547, user.getLanguage());
}
if (forgotCheckMins > 0) {//漏签
text = SystemEnv.getHtmlLabelName(20086, user.getLanguage());
}
if (onOrOff.length() > 0 && "on".equalsIgnoreCase(onOrOff)) {
if (forgotBeginWorkCheckMins > 0) {//漏签
text = SystemEnv.getHtmlLabelName(20086, user.getLanguage());
}
}
}
if (text.equals("") && leaveMins <= 0 && evectionMins <= 0 && outMins <= 0) {
text = SystemEnv.getHtmlLabelName(225, user.getLanguage());
}
}
return text;
}
public static boolean getShowFlowText(String leaveInfo,String onOrOff){
Map<String,Object> jsonObject = null;
jsonObject = JSON.parseObject(leaveInfo);
String flow_signtype = "";
for (Entry<String,Object> entry : jsonObject.entrySet()) {
String tmpSignType = Util.null2String(entry.getValue());
flow_signtype += ","+tmpSignType;
}
if(flow_signtype.length() == 0){
return true;
}
return isShowFlowText(flow_signtype,onOrOff);
}
public static boolean isShowFlowText(String flow_signtype,String onOrOff){
boolean showFlowText = true;
if(flow_signtype.length() > 0){
flow_signtype = flow_signtype.substring(1);
if("on".equalsIgnoreCase(onOrOff)){
if((","+flow_signtype+",").indexOf(",1,") > -1){
//抵扣了上班卡
}else{
//上班状态,但是没有上班抵扣流程
showFlowText = false;
}
}
if("off".equalsIgnoreCase(onOrOff)){
if((","+flow_signtype+",").indexOf(",2,") > -1){
//抵扣了下班卡
}else{
//下班状态,但是没有下班抵扣流程
showFlowText = false;
}
}
}
return showFlowText;
}
public static int getPageSize(String pageSize, String pageUid, int userid){
String sql = "";
RecordSet rs = new RecordSet();
int iPageSize= Util.getIntValue(pageSize,10);
if(iPageSize<10)iPageSize=10;
try{
if(pageSize.length()>0){
boolean flag = false;
sql = "select count(1) from ecology_pagesize where pageid = '"+pageUid+"' and userid ="+userid;
rs.executeQuery(sql);
if(rs.next()){
if(rs.getInt(1)>0){
flag = true;
}
}
if(flag){
sql = "update ecology_pagesize set pagesize ="+pageSize+" where pageid = '"+pageUid+"' and userid ="+userid;
rs.executeUpdate(sql);
}else{
sql = "insert into ecology_pagesize (pageid,pagesize,userid) values ('"+pageUid+"',"+pageSize+","+userid+")";
rs.executeUpdate(sql);
}
}else{
sql = "select pageSize from ecology_pagesize where pageid = '"+pageUid+"' and userid ="+userid;
rs.executeQuery(sql);
if(rs.next()){
iPageSize = rs.getInt("pageSize");
}
}
}catch (Exception e){
new BaseBean().writeLog("KQReportBiz.getPageSize"+e);
}
return iPageSize;
}
//经常遇到申请变更流程或销假流程提示未归档,不胜其烦,所以搞一下
public void reflow(String requestid){
try {
requestid = Util.null2String(requestid);
String workflowid = "";
String currentnodetype = "";
if(requestid.length() == 0){
return;
}
RecordSet rs2 = new RecordSet();
String sql = "select requestid,workflowid,currentnodetype from workflow_requestbase where requestid = '"+requestid+"'";
rs2.executeQuery(sql);
if(rs2.next()){
workflowid = Util.null2String(rs2.getString("workflowid"));
currentnodetype = Util.null2String(rs2.getString("currentnodetype"));
}
boolean isForce1 = false;
boolean isUpgrade1 = false;
if(requestid.length() == 0){
return ;
}
if(workflowid.length() == 0){
return ;
}
if(!"3".equals(currentnodetype)){
return ;
}
long start = System.currentTimeMillis();
KQFlowActiontBiz kqFlowActiontBiz = new KQFlowActiontBiz();
RecordSet rs = new RecordSet();
RecordSet rs1 = new RecordSet();
String proc_set_sql = "select * from kq_att_proc_set where field001 = ? ";
rs.executeQuery(proc_set_sql, workflowid);
if(rs.next()){
String proc_set_id = rs.getString("id");
//得到这个考勤流程设置是否使用明细
String usedetails = rs.getString("usedetail");
int kqtype = Util.getIntValue(rs.getString("field006"));
Map<String, String> map = new HashMap<String, String>();
if(Util.getIntValue(requestid) > 0){
map.put("requestId", "and t.requestId = " + requestid);
}
String tablename = "";
if(kqtype == KqSplitFlowTypeEnum.LEAVE.getFlowtype()){
tablename = KqSplitFlowTypeEnum.LEAVE.getTablename();
}else if(kqtype == KqSplitFlowTypeEnum.EVECTION.getFlowtype()){
tablename = KqSplitFlowTypeEnum.EVECTION.getTablename();
}else if(kqtype == KqSplitFlowTypeEnum.OUT.getFlowtype()){
tablename = KqSplitFlowTypeEnum.OUT.getTablename();;
}else if(kqtype == KqSplitFlowTypeEnum.OVERTIME.getFlowtype()){
tablename = KqSplitFlowTypeEnum.OVERTIME.getTablename();;
}else if(kqtype == KqSplitFlowTypeEnum.SHIFT.getFlowtype()){
tablename = KqSplitFlowTypeEnum.SHIFT.getTablename();;
}else if(kqtype == KqSplitFlowTypeEnum.OTHER.getFlowtype()){
tablename = KqSplitFlowTypeEnum.OTHER.getTablename();;
}else if(kqtype == KqSplitFlowTypeEnum.CARD.getFlowtype()){
tablename = KqSplitFlowTypeEnum.CARD.getTablename();;
return;
}else if(kqtype == KqSplitFlowTypeEnum.LEAVEBACK.getFlowtype()){
tablename = KqSplitFlowTypeEnum.LEAVEBACK.getTablename();;
}else{
return;
}
if(null != tablename && tablename.length() > 0){
String tmpsql = "select * from "+tablename+" where requestId="+requestid;
rs1.executeQuery(tmpsql);
if(rs1.next()){
return;//表示已经产生了拆分数据
}
}
//先根据requestid删除中间表里的数据再做啥插入操作
String delSql = "delete from "+tablename+" where requestid = "+requestid;
rs1.executeUpdate(delSql);
if(kqtype == KqSplitFlowTypeEnum.OVERTIME.getFlowtype()) {
delSql = "delete from kq_flow_overtime where requestid = "+requestid;
rs1.executeUpdate(delSql);
}
Map<String,String> result = kqFlowActiontBiz.handleKQFlowAction(proc_set_id, usedetails, Util.getIntValue(requestid), kqtype, Util.getIntValue(workflowid), isForce1,isUpgrade1,map);
if(!result.isEmpty()){
}
}
long end = System.currentTimeMillis();
}catch (Exception e){
e.printStackTrace();;
}
}
//add
public Map<String,Object> getOverTime(Map<String,Object> params, User user){
Map<String,Object> datas = new HashMap<>();;
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try{
KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz();
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
String fromDate = Util.null2String(jsonObj.get("fromDate"));
String toDate = Util.null2String(jsonObj.get("toDate"));
String typeselect =Util.null2String(jsonObj.get("typeselect"));
if(typeselect.length()==0)typeselect = "3";
if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){
if(typeselect.equals("1")){
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
}else{
fromDate = TimeUtil.getDateByOption(typeselect,"0");
toDate = TimeUtil.getDateByOption(typeselect,"1");
}
}
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
String departmentId = Util.null2String(jsonObj.get("departmentId"));
String resourceId = Util.null2String(jsonObj.get("resourceId"));
String allLevel = Util.null2String(jsonObj.get("allLevel"));
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
String viewScope = Util.null2String(jsonObj.get("viewScope"));
if(subCompanyId.length()>0){
sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") ";
}
if(departmentId.length()>0){
sqlWhere +=" and a.departmentid in("+departmentId+") ";
}
if(resourceId.length()>0){
sqlWhere +=" and a.id in("+resourceId+") ";
}
if(viewScope.equals("4")){//我的下属
if(allLevel.equals("1")){//所有下属
sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
}else{
sqlWhere+=" and a.managerid="+user.getUID();//直接下属
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
}
int uintType = Util.getIntValue(Util.null2String(params.get("uintType")));//当前加班单位
double hoursToDay = Util.getDoubleValue(Util.null2String(params.get("hoursToDay")));//当前天跟小时计算关系
String valueField = "";
sql = " select resourceid,belongdate,paidLeaveEnable,duration_min "+
" from hrmresource a, kq_flow_overtime b "+
" where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere+
" order by resourceid,belongdate ";
rs.execute(sql);
// kqLog.info("getOverTime:sql:"+sql);
while (rs.next()) {
String resourceid = rs.getString("resourceid");
String belongdate = rs.getString("belongdate");
String paidLeaveEnable = rs.getString("paidLeaveEnable");
// int changeType =rs.getInt("changeType");//1-节假日、2-工作日、3-休息日
double value = rs.getDouble("duration_min")<0?0:rs.getDouble("duration_min");
if(uintType==3 || uintType== 5 || uintType== 6){//按小时计算
value = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(value/(60.0)+""));
}else{//按天计算
value = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(value/(60.0*hoursToDay)+""));
}
String key = resourceid+"|"+belongdate+"|overtime";
if(value>0){
df.setMaximumFractionDigits(5);
if(datas.containsKey(key)){
double tmpVal = Util.getDoubleValue(Util.null2String(datas.get(key)),0.0);
tmpVal += value;
datas.put(key,format(tmpVal));
}else{
datas.put(key,format(value));
}
// if(datas.containsKey(key)){
// datas.put(key,"加班");
//// datas.put(key,SystemEnv.getHtmlLabelName(6151, user.getLanguage()));
// }else{
// datas.put(key,"加班");
// }
}
}
}catch (Exception e){
writeLog(e);
}
return datas;
}
}