三种餐补

dev-chenwnj
chenwei 1 year ago
parent 321a7878d2
commit 4faaec7639

@ -8,6 +8,7 @@ import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author chenwnj
@ -86,6 +87,34 @@ public class HostarUtil {
ModeRightInfo.editModeDataShare( billid_creator, Integer.parseInt(modeId), billids);
}
/**
* mapmapkey
*/
public Map<String, Object> parseMapForFilter(Map<String, Object> map, String filters) {
if (map == null) {
return null;
} else {
map = map.entrySet().stream()
.filter((e) -> checkKey(e.getKey(),filters))
.collect(Collectors.toMap(
(e) -> (String) e.getKey(),
(e) -> e.getValue()
));
}
return map;
}
/**
* indexof
*/
private boolean checkKey(String key,String filters) {
if (key.indexOf(filters)>-1){
return true;
}else {
return false;
}
}
}

@ -29,6 +29,7 @@ import weaver.general.Util;
import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;
import javax.ejb.Remove;
import java.text.DecimalFormat;
import java.util.*;
@ -386,6 +387,15 @@ public class KQReportBiz extends BaseBean {
datas.putAll(getDailyStatAllowanceData(params,user));
/*考勤二开--计算驻点餐补end*/
/*考勤二开--计算夜班餐补start*/
datas.putAll(getDailyNightShiftAllowanceData(params,user));
/*考勤二开--计算夜班餐补end*/
/*考勤二开--计算鸿仁驻点餐补start*/
datas.putAll(getDailyOtherStatAllowanceData(params,user));
/*考勤二开--计算鸿仁驻点餐补end*/
}catch (Exception e){
writeLog(e);
}
@ -404,6 +414,12 @@ public class KQReportBiz extends BaseBean {
datas.putAll(getCardMap(params,user));
datas.putAll(getOverTime(params,user));
/*考勤二开--计算驻点餐补start*/
datas.putAll(getDailyStatAllowanceData(params,user));
/*考勤二开--计算驻点餐补end*/
}catch (Exception e){
writeLog(e);
}
@ -1451,6 +1467,385 @@ public class KQReportBiz extends BaseBean {
return datas;
}
/**
* 鸿
* @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 not in (" + otherstatsub + ") ";
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 != "") {
Map<String, Object> temp = (Map<String, Object>) o;
signIdList.add(Util.null2String(temp.get("signId")));
}
}
Integer signNumber = 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) {
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);
double v = ((attendanceMins < 0.00) ? 0.00 : attendanceMins) + temp;
String value = "0";
if (v >= 4.00 && v < 9.00) {
value = "1";
} else if (v >= 9.00) {
value = "2";
}
bb.writeLog("-=-value:" + value);
datas.put(res + "|" + "DailyOtherStatAllowance" + "|" + date, value);
}
}
}
}
}
}catch (Exception e){
writeLog(e);
bb.writeLog("DailyStatAllowance Exception: " + e);
}
bb.writeLog("DailyStatAllowance datas: " + datas);
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);
String nightshiftsub = Util.null2String(bb.getPropValue("project_hostar", "nightshiftsubcompany"));
if (StringUtils.isNotBlank(nightshiftsub)) {
//查询该分部下的人员
List<String> resIds = new ArrayList<>();
sqlWhere += " and a.subcompanyid1 not in ("+nightshiftsub+") ";
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) {
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);
}
}
for (String res: resIds) {
for (String date : allDates) {
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.ceil( (attendanceMins < 0.00 ? 0.00 : attendanceMins) + temp));
bb.writeLog("-=-value:" + value);
datas.put(res + "|" + "DailyNightShiftAllowanceData" + "|" + date, value);
}
}
}
} else {
bb.writeLog("夜班餐补计算失败,没有设置该餐补享受分部");
}
}catch (Exception e){
writeLog(e);
bb.writeLog("DailyNightShiftAllowanceData Exception: " + e);
}
bb.writeLog("DailyNightShiftAllowanceData datas: " + datas);
return datas;
}
/**
*
* @param params
@ -1493,7 +1888,7 @@ public class KQReportBiz extends BaseBean {
}
if(resourceId.length()>0){
sqlWhere +=" and a.resourceid in("+resourceId+") ";
sqlWhere +=" and a.id in("+resourceId+") ";
}
if(viewScope.equals("4")){//我的下属
@ -1507,6 +1902,10 @@ public class KQReportBiz extends BaseBean {
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> subComoanyList = new ArrayList<>();
String acqNoStatAllSql = "select subcompany from uf_NoStatAllSubCom where isdelete = 0 or isdelete is null";
@ -1517,6 +1916,8 @@ public class KQReportBiz extends BaseBean {
subComoanyList.add(subcompany);
}
}
bb.writeLog("subComoanyList: " + subComoanyList);
String subComoanys = "";
if ( subComoanyList != null && subComoanyList.size() > 0) {
subComoanys = String.join(",", subComoanyList);
@ -1526,7 +1927,9 @@ public class KQReportBiz extends BaseBean {
}
List<String> resIds = new ArrayList<>();
String acqResSql = "select id from hrmresource a where a.status in (0,1,2,3) " + sqlWhere;
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"));
@ -1534,10 +1937,26 @@ public class KQReportBiz extends BaseBean {
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);
}
}
for (String date : allDates) {
for (String res: resIds) {
//获取考勤打卡
@ -1548,7 +1967,7 @@ public class KQReportBiz extends BaseBean {
boolean oneSign = false;//一天一段出勤时间段
List<TimeScopeEntity> lsSignTime = new ArrayList<>();
List<TimeScopeEntity> lsWorkTime = new ArrayList<>();
List<TimeScopeEntity> lsRestTime = new ArrayList<>();
// List<TimeScopeEntity> lsRestTime = new ArrayList<>();
KQWorkTime kqWorkTime = new KQWorkTime();
kqWorkTime.setIsFormat(true);
WorkTimeEntity workTime = kqWorkTime.getWorkTime(res, date);
@ -1557,11 +1976,12 @@ public class KQReportBiz extends BaseBean {
if (workTime != null) {
lsSignTime = workTime.getSignTime();//允许打卡时间
lsWorkTime = workTime.getWorkTime();//工作时间
lsRestTime = workTime.getRestTime();//休息时段时间
// 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);
@ -1569,17 +1989,17 @@ public class KQReportBiz extends BaseBean {
Map<String, String> shifRuleMap = Maps.newHashMap();
String workBeginTime = Util.null2String(workTimeScope.getBeginTime());
String ori_workBeginTime = workBeginTime;
// String ori_workBeginTime = workBeginTime;
int workBeginIdx = kqTimesArrayComInfo.getArrayindexByTimes(workBeginTime);
boolean workBenginTimeAcross = workTimeScope.getBeginTimeAcross();
// boolean workBenginTimeAcross = workTimeScope.getBeginTimeAcross();
String workEndTime = Util.null2String(workTimeScope.getEndTime());
String ori_workEndTime = workEndTime;
// 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;
// int workMins = workTimeScope.getWorkMins();
//
// String workBeginDate = workBenginTimeAcross ? nextDate : date;
// String workEndDate = workEndTimeAcross ? nextDate : date;
if(oneSign){
//个性化设置只支持一天一次上下班
@ -1630,20 +2050,60 @@ public class KQReportBiz extends BaseBean {
// signDate = 2023 - 12 - 22,
// signId = 7
//}]
List<Object> lsCheckInfo = new KQFormatSignData().getSignInfo(res,signTimeScope,workTimeScope,date,preDate,nextDate,kqTimesArrayComInfo,hostIps,uuid,shiftCount,shiftI);
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 != "") {
Map<String, Object> temp = (Map<String, Object>) o;
signIdList.add(Util.null2String(temp.get("signId")));
}
}
Integer signNumber = 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 ) {
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.ceil( (attendanceMins < 0.00 ? 0.00 : attendanceMins) + temp));
bb.writeLog("-=-value:" + value);
datas.put(res + "|" + "DailyStatAllowance" + "|" + date, value);
}
}
}
}
}catch (Exception e){
writeLog(e);
bb.writeLog("DailyStatAllowance Exception: " + e);
}
bb.writeLog("DailyStatAllowance datas: " + datas);
return datas;
}
@ -1959,6 +2419,111 @@ public class KQReportBiz extends BaseBean {
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

@ -9,8 +9,10 @@ import com.engine.kq.biz.*;
import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit;
import com.engine.kq.util.ExcelUtil;
import com.engine.kq.util.KQDurationCalculatorUtil;
import org.apache.commons.lang3.StringUtils;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.hrm.User;
@ -29,6 +31,7 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
private HttpServletRequest request;
private HttpServletResponse response;
private List<String> lsFieldDataKey;
BaseBean bb = new BaseBean();
public ExportDailyExcelCmd(Map<String, Object> params, HttpServletRequest request, HttpServletResponse response, User user) {
this.user = user;
@ -229,6 +232,32 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey),"0");
Map<String,Object> flowData = kqReportBiz.getDailyFlowData(params,user);
/*考勤二开--驻点餐补start*/
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);
}
}
bb.writeLog("subComoanyList: " + subComoanyList);
/*考勤二开--驻点餐补end*/
/*考勤二开--夜班餐补start*/
String nightshiftsub = Util.null2String(bb.getPropValue("project_hostar", "nightshiftsubcompany"));
List<String> nightshifts = new ArrayList<String>();
String acqSerialSql = " select serial from uf_nightshiftmanage where isdelete is null or isdelete = 0";
rs.executeQuery(acqSerialSql);
while (rs.next()) {
String serial = Util.null2String(rs.getString("serial"));
if (StringUtils.isNotBlank(serial)) {
nightshifts.add(serial);
}
}
/*考勤二开--夜班餐补end*/
rs.execute(sql);
while (rs.next()) {
data = new ArrayList<>();
@ -309,7 +338,7 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
fieldValue = Util.null2String(signDetailInfo.get("signoutstatus3"));
data.add(fieldValue);
continue;
} else if (fieldName.equals("mealAllowance")) {
} else if (fieldName.equals("mealAllowance")) {//考勤二开--出差餐补
int intValue = Util.getIntValue(Util.null2String(flowData.get("DailyMealAllow|" + resourceId + "|" + kqdate)));
if (intValue < 0) {
intValue = 0;
@ -414,6 +443,43 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
}catch (Exception e){
}
fieldValue = KQDurationCalculatorUtil.getDurationRound(businessLeave);
} else if (fieldName.equals("statAllowance")) {//考勤二开--驻点餐补
String subcompanyId = Util.null2String(rs.getString("subcompanyid"));
if ( !subComoanyList.contains(subcompanyId)) {
int temp = Util.getIntValue(Util.null2String(flowData.get(id + "|DailyStatAllowance" + "|" + kqdate )));
if (temp <= 0) {
fieldValue = "0";
} else {
fieldValue = String.valueOf(temp);
}
bb.writeLog("fieldValue: " + fieldValue);
}
data.add(fieldValue);
continue;
} else if (fieldName.equals("nightAllowance")) {//考勤二开--夜班餐补
String subcompanyId = Util.null2String(rs.getString("subcompanyid"));
String serialid = Util.null2String(rs.getString("serialid"));
if ( !subComoanyList.contains(subcompanyId) && nightshifts.contains(serialid)) {
int temp = Util.getIntValue(Util.null2String(flowData.get(id + "|DailyNightShiftAllowanceData" + "|" + kqdate )));
if (temp <= 0) {
fieldValue = "0";
} else {
fieldValue = String.valueOf(temp);
}
bb.writeLog("fieldValue: " + fieldValue);
}
data.add( fieldValue);
continue;
} else if (fieldName.equals("otherStatAllowance")) {//考勤二开--鸿仁驻点餐补
int temp = Util.getIntValue(Util.null2String(flowData.get(id + "|DailyOtherStatAllowance" + "|" + kqdate )));
if (temp <= 0) {
fieldValue = "0";
} else {
fieldValue = String.valueOf(temp);
}
bb.writeLog("fieldValue: " + fieldValue);
data.add(fieldValue);
continue;
} else if(fieldName.equals("kqdate")){
fieldValue=kqdate+" "+com.engine.portal.util.DateUtil.getDayWeekOfDate1(DateUtil.parseToDate(kqdate));
} else {

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.hostar.util.HostarUtil;
import com.engine.kq.biz.*;
import com.engine.kq.util.ExcelUtil;
import com.engine.kq.util.KQDurationCalculatorUtil;
@ -12,6 +13,7 @@ import com.engine.kq.util.UtilKQ;
import weaver.common.DateUtil;
import weaver.common.StringUtil;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.hrm.User;
@ -32,6 +34,8 @@ public class ExportExcelCmd extends AbstractCommonCommand<Map<String, Object>> {
private HttpServletResponse response;
private List<String> lsFieldDataKey;
BaseBean bb = new BaseBean();
public ExportExcelCmd(Map<String, Object> params, HttpServletRequest request, HttpServletResponse response, User user) {
this.user = user;
this.params = params;
@ -269,6 +273,24 @@ public class ExportExcelCmd extends AbstractCommonCommand<Map<String, Object>> {
String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey),"0");
/*考勤二开--驻点餐补start*/
HostarUtil hostarUtil = new HostarUtil();
Map<String, Double> attendanceMap = new HashMap<>();
String acqAttendanceSql = "select a.id, b.attendanceMins, b.kqdate from hrmresource a, kq_format_total b where a.id= b.resourceid and b.kqdate >='"+fromDate+"' and b.kqdate <='"+toDate+"' "+sqlWhere;
bb.writeLog("acqAttendanceSql: " + acqAttendanceSql);
rs.executeQuery(acqAttendanceSql);
while (rs.next()) {
double attendanceMins = Util.getDoubleValue(Util.null2String(rs.getString("attendanceMins")));
String id = Util.null2String(rs.getString("id"));
String kqdate = Util.null2String(rs.getString("kqdate"));
if (attendanceMins >= 0.00) {
attendanceMap.put(id + "|DailyStatAllowance" +"|" + kqdate, attendanceMins);
}
}
bb.writeLog("attendanceMap: " + attendanceMap);
/*考勤二开--驻点餐补end*/
rs.execute(sql);
while (rs.next()) {
data = new ArrayList<>();
@ -411,7 +433,49 @@ public class ExportExcelCmd extends AbstractCommonCommand<Map<String, Object>> {
}catch (Exception e){
}
fieldValue = KQDurationCalculatorUtil.getDurationRound(businessLeave);
} else if(Util.null2String(kqReportFieldComInfo.getCascadekey(fieldid)).length()>0){
} else if (fieldName.equals("statAllowance")) {//考勤二开--驻点餐补
bb.writeLog("flowData: " + flowData);
Map<String, Object> tempMap = hostarUtil.parseMapForFilter(flowData, id + "|DailyStatAllowance");
bb.writeLog("tempMap: " + tempMap);
if ( !tempMap.isEmpty()) {
double tempValue = 0.00;
for (String key: tempMap.keySet()) {
double doubleValue = Util.getDoubleValue(Util.null2String(tempMap.get(key)));
tempValue = tempValue + (doubleValue < 0.00 ? 0.00 : doubleValue);
}
fieldValue = String.valueOf(tempValue);
}
data.add(fieldValue);
continue;
} else if (fieldName.equals("nightAllowance")) {//考勤二开--夜班餐补
bb.writeLog("flowData: " + flowData);
Map<String, Object> tempMap = hostarUtil.parseMapForFilter(flowData, id + "|DailyNightShiftAllowanceData");
bb.writeLog("tempMap: " + tempMap);
if ( !tempMap.isEmpty()) {
double tempValue = 0.00;
for (String key: tempMap.keySet()) {
double doubleValue = Util.getDoubleValue(Util.null2String(tempMap.get(key)));
tempValue = tempValue + (doubleValue < 0.00 ? 0.00 : doubleValue);
}
fieldValue = String.valueOf(tempValue);
}
data.add(fieldValue);
continue;
} else if (fieldName.equals("otherStatAllowance")) {//考勤二开--鸿仁驻点餐补
bb.writeLog("flowData: " + flowData);
Map<String, Object> tempMap = hostarUtil.parseMapForFilter(flowData, id + "|DailyOtherStatAllowance");
bb.writeLog("tempMap: " + tempMap);
if ( !tempMap.isEmpty()) {
double tempValue = 0.00;
for (String key: tempMap.keySet()) {
double doubleValue = Util.getDoubleValue(Util.null2String(tempMap.get(key)));
tempValue = tempValue + (doubleValue < 0.00 ? 0.00 : doubleValue);
}
fieldValue = String.valueOf(tempValue);
}
data.add(fieldValue);
continue;
} else if(Util.null2String(kqReportFieldComInfo.getCascadekey(fieldid)).length()>0){
fieldValue = Util.formatMultiLang(Util.null2String(rs.getString(fieldName)),""+user.getLanguage());
data.add(fieldValue);

@ -12,8 +12,11 @@ import com.engine.kq.log.KQLog;
import com.engine.kq.util.KQDurationCalculatorUtil;
import com.engine.kq.util.PageUidFactory;
import java.math.BigDecimal;
import org.apache.commons.lang3.StringUtils;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
@ -28,7 +31,9 @@ import java.util.*;
public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Object>> {
private KQLog kqLog = new KQLog();
private KQLog kqLog = new KQLog();
BaseBean bb = new BaseBean();
public GetKQDailyReportCmd(Map<String, Object> params, User user) {
this.user = user;
@ -230,6 +235,31 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Objec
KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo();
String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey),"0");
/*考勤二开--驻点餐补start*/
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);
}
}
bb.writeLog("subComoanyList: " + subComoanyList);
/*考勤二开--驻点餐补end*/
/*考勤二开--夜班餐补start*/
String nightshiftsub = Util.null2String(bb.getPropValue("project_hostar", "nightshiftsubcompany"));
List<String> nightshifts = new ArrayList<String>();
String acqSerialSql = " select serial from uf_nightshiftmanage where isdelete is null or isdelete = 0";
rs.executeQuery(acqSerialSql);
while (rs.next()) {
String serial = Util.null2String(rs.getString("serial"));
if (StringUtils.isNotBlank(serial)) {
nightshifts.add(serial);
}
}
/*考勤二开--夜班餐补end*/
rs.execute(sql);
while (rs.next()) {
String id = rs.getString("id");
@ -317,12 +347,47 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Objec
if (fieldValue.length()>0) {//弹性工作制没有班次
data.put("serialid", shiftManagementToolKit.getShiftOnOffWorkSections(fieldValue, user.getLanguage()));
}
} else if (fieldName.equals("mealAllowance")) {
} else if (fieldName.equals("mealAllowance")) {//考勤二开--出差餐补
int intValue = Util.getIntValue(Util.null2String(flowData.get("DailyMealAllow|" + resourceId + "|" + kqdate)));
if (intValue < 0) {
intValue = 0;
}
data.put(fieldName, intValue);
} else if (fieldName.equals("statAllowance")) {//考勤二开--驻点餐补
String subcompanyId = Util.null2String(rs.getString("subcompanyid"));
if ( !subComoanyList.contains(subcompanyId)) {
int temp = Util.getIntValue(Util.null2String(flowData.get(id + "|DailyStatAllowance" + "|" + kqdate )));
if (temp <= 0) {
fieldValue = "0";
} else {
fieldValue = String.valueOf(temp);
}
bb.writeLog("fieldValue: " + fieldValue);
}
data.put(fieldName, fieldValue);
} else if (fieldName.equals("nightAllowance")) {//考勤二开--夜班餐补
String subcompanyId = Util.null2String(rs.getString("subcompanyid"));
String serialid = Util.null2String(rs.getString("serialid"));
if ( subcompanyId.equals(nightshiftsub) && nightshifts.contains(serialid)) {
int temp = Util.getIntValue(Util.null2String(flowData.get(id + "|DailyNightShiftAllowanceData" + "|" + kqdate )));
if (temp <= 0) {
fieldValue = "0";
} else {
fieldValue = String.valueOf(temp);
}
bb.writeLog("fieldValue: " + fieldValue);
}
data.put(fieldName, fieldValue);
} else if (fieldName.equals("otherStatAllowance")) {//考勤二开--鸿仁驻点餐补
int temp = Util.getIntValue(Util.null2String(flowData.get(id + "|DailyOtherStatAllowance" + "|" + kqdate )));
if (temp <= 0) {
fieldValue = "0";
} else {
fieldValue = String.valueOf(temp);
}
bb.writeLog("fieldValue: " + fieldValue);
data.put(fieldName, fieldValue);
} else {
fieldValue = Util.null2String(rs.getString(fieldName));
if (kqReportFieldComInfo.getUnittype().equals("2") && fieldValue.length() > 0) {

@ -5,12 +5,13 @@ import com.alibaba.fastjson.JSONObject;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.hostar.util.HostarUtil;
import com.engine.kq.biz.*;
import com.engine.kq.log.KQLog;
import com.engine.kq.util.KQDurationCalculatorUtil;
import com.engine.kq.util.PageUidFactory;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.hrm.User;
@ -25,6 +26,8 @@ import java.util.*;
public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
BaseBean bb = new BaseBean();
public GetKQReportCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
@ -39,7 +42,7 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
String pageUid = PageUidFactory.getHrmPageUid("KQReport");
SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo();
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
ResourceComInfo resourceComInfo = new ResourceComInfo();
JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo();
KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz();
@ -158,28 +161,28 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
String forgotBeginWorkCheck_field = " sum(b.forgotBeginWorkCheck) ";
if(rs.getDBType().equalsIgnoreCase("oracle")) {
forgotBeginWorkCheck_field = " sum(nvl(b.forgotBeginWorkCheck,0)) ";
}else if((rs.getDBType()).equalsIgnoreCase("mysql")){
forgotBeginWorkCheck_field = " sum(ifnull(b.forgotBeginWorkCheck,0)) ";
}else {
forgotBeginWorkCheck_field = " sum(isnull(b.forgotBeginWorkCheck,0)) ";
}
if(rs.getDBType().equalsIgnoreCase("oracle")) {
forgotBeginWorkCheck_field = " sum(nvl(b.forgotBeginWorkCheck,0)) ";
}else if((rs.getDBType()).equalsIgnoreCase("mysql")){
forgotBeginWorkCheck_field = " sum(ifnull(b.forgotBeginWorkCheck,0)) ";
}else {
forgotBeginWorkCheck_field = " sum(isnull(b.forgotBeginWorkCheck,0)) ";
}
Map<String,Object> definedFieldInfo = new KQFormatBiz().getDefinedField();
String definedFieldSum = Util.null2String(definedFieldInfo.get("definedFieldSum"));
String backFields = " a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle," +
" sum(b.workdays) as workdays,sum(b.workMins) as workMins,sum(b.attendancedays) as attendancedays," +
" sum(b.attendanceMins) as attendanceMins,sum(b.beLate) as beLate,sum(b.beLateMins) as beLateMins, " +
" sum(b.graveBeLate) as graveBeLate, sum(b.graveBeLateMins) as graveBeLateMins,sum(b.leaveEearly) as leaveEearly," +
" sum(b.leaveEarlyMins) as leaveEarlyMins, sum(b.graveLeaveEarly) as graveLeaveEarly, " +
" sum(b.graveLeaveEarlyMins) as graveLeaveEarlyMins,sum(b.absenteeism) as absenteeism, " +
" sum(b.signdays) as signdays,sum(b.signmins) as signmins, "+
" sum(b.absenteeismMins) as absenteeismMins, sum(b.forgotCheck)+"+forgotBeginWorkCheck_field+" as forgotCheck "+(definedFieldSum.length()>0?","+definedFieldSum+"":"");
" sum(b.workdays) as workdays,sum(b.workMins) as workMins,sum(b.attendancedays) as attendancedays," +
" sum(b.attendanceMins) as attendanceMins,sum(b.beLate) as beLate,sum(b.beLateMins) as beLateMins, " +
" sum(b.graveBeLate) as graveBeLate, sum(b.graveBeLateMins) as graveBeLateMins,sum(b.leaveEearly) as leaveEearly," +
" sum(b.leaveEarlyMins) as leaveEarlyMins, sum(b.graveLeaveEarly) as graveLeaveEarly, " +
" sum(b.graveLeaveEarlyMins) as graveLeaveEarlyMins,sum(b.absenteeism) as absenteeism, " +
" sum(b.signdays) as signdays,sum(b.signmins) as signmins, "+
" sum(b.absenteeismMins) as absenteeismMins, sum(b.forgotCheck)+"+forgotBeginWorkCheck_field+" as forgotCheck "+(definedFieldSum.length()>0?","+definedFieldSum+"":"");
if(rs.getDBType().equals("oracle")){
backFields = "/*+ index(kq_format_total IDX_KQ_FORMAT_TOTAL_KQDATE) */ "+backFields;
backFields = "/*+ index(kq_format_total IDX_KQ_FORMAT_TOTAL_KQDATE) */ "+backFields;
}
String sqlFrom = " from hrmresource a, kq_format_total b where a.id= b.resourceid and b.kqdate >='"+fromDate+"' and b.kqdate <='"+toDate+"'";
String sqlWhere = rightSql;
@ -207,13 +210,13 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
}
if(status.length()>0){
if (!status.equals("8") && !status.equals("9")) {
sqlWhere += " and a.status = "+status+ "";
}else if (status.equals("8")) {
sqlWhere += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) ";
}
}
if(status.length()>0){
if (!status.equals("8") && !status.equals("9")) {
sqlWhere += " and a.status = "+status+ "";
}else if (status.equals("8")) {
sqlWhere += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) ";
}
}
sql = " select count(*) as c from ( select 1 as c "+sqlFrom+sqlWhere+groupBy+") t";
rs.execute(sql);
@ -272,16 +275,14 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
if (rs.getDBType().equals("oracle")) {
sql = " select * from (select " + sql+") t "+orderBy;
sql = "select * from ( select row_.*, rownum rownum_ from ( " + sql + " ) row_ where rownum <= "
+ (pageIndex * pageSize) + ") where rownum_ > " + ((pageIndex - 1) * pageSize);
+ (pageIndex * pageSize) + ") where rownum_ > " + ((pageIndex - 1) * pageSize);
} else if (rs.getDBType().equals("mysql")) {
sql = " select * from (select " + sql+") t "+orderBy;
sql = "select t1.* from (" + sql + ") t1 limit " + ((pageIndex - 1) * pageSize) + "," + pageSize;
}
else if (rs.getDBType().equals("postgresql")) {
} else if (rs.getDBType().equals("postgresql")) {
sql = " select * from (select " + sql+") t "+orderBy;
sql = "select t1.* from (" + sql + ") t1 limit " +pageSize + " offset " + ((pageIndex - 1) * pageSize);
}
else {
} else {
orderBy = " order by dsporder asc, lastname asc ";
descOrderBy = " order by dsporder desc, lastname desc ";
if (pageIndex > 1) {
@ -290,7 +291,7 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
topSize = count - (pageSize * (pageIndex - 1));
}
sql = " select top " + topSize + " * from ( select top " + topSize + " * from ( select top "
+ (pageIndex * pageSize) + sql + orderBy+ " ) tbltemp1 " + descOrderBy + ") tbltemp2 " + orderBy;
+ (pageIndex * pageSize) + sql + orderBy+ " ) tbltemp1 " + descOrderBy + ") tbltemp2 " + orderBy;
} else {
sql = " select top " + pageSize + sql+orderBy;
}
@ -314,6 +315,22 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
params.put("hoursToDay",hoursToDay);
Map<String,Object> flowData = kqReportBiz.getFlowData(params,user);
/*考勤二开--驻点餐补start*/
HostarUtil hostarUtil = new HostarUtil();
Map<String, Double> attendanceMap = new HashMap<>();
String acqAttendanceSql = "select a.id, b.attendanceMins, b.kqdate from hrmresource a, kq_format_total b where a.id= b.resourceid and b.kqdate >='"+fromDate+"' and b.kqdate <='"+toDate+"' "+sqlWhere;
bb.writeLog("acqAttendanceSql: " + acqAttendanceSql);
rs.executeQuery(acqAttendanceSql);
while (rs.next()) {
double attendanceMins = Util.getDoubleValue(Util.null2String(rs.getString("attendanceMins")));
String id = Util.null2String(rs.getString("id"));
String kqdate = Util.null2String(rs.getString("kqdate"));
if (attendanceMins >= 0.00) {
attendanceMap.put(id + "|DailyAllowance" +"|" + kqdate, attendanceMins);
}
}
bb.writeLog("attendanceMap: " + attendanceMap);
/*考勤二开--驻点餐补end*/
rs.execute(sql);
while (rs.next()) {
@ -378,41 +395,81 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|holidayOvertime_4leave")));
holidayOvertime_4leave = holidayOvertime_4leave<0?0:holidayOvertime_4leave;
double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|workingDayOvertime_nonleave")));
workingDayOvertime_nonleave = workingDayOvertime_nonleave<0?0:workingDayOvertime_nonleave;
double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|restDayOvertime_nonleave")));
restDayOvertime_nonleave = restDayOvertime_nonleave<0?0:restDayOvertime_nonleave;
double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|holidayOvertime_nonleave")));
holidayOvertime_nonleave = holidayOvertime_nonleave<0?0:holidayOvertime_nonleave;
double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|workingDayOvertime_nonleave")));
workingDayOvertime_nonleave = workingDayOvertime_nonleave<0?0:workingDayOvertime_nonleave;
double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|restDayOvertime_nonleave")));
restDayOvertime_nonleave = restDayOvertime_nonleave<0?0:restDayOvertime_nonleave;
double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|holidayOvertime_nonleave")));
holidayOvertime_nonleave = holidayOvertime_nonleave<0?0:holidayOvertime_nonleave;
fieldValue = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave+restDayOvertime_4leave+holidayOvertime_4leave+
workingDayOvertime_nonleave+restDayOvertime_nonleave+holidayOvertime_nonleave));
workingDayOvertime_nonleave+restDayOvertime_nonleave+holidayOvertime_nonleave));
}else if(fieldName.equals("businessLeave") || fieldName.equals("officialBusiness")){
String businessLeaveData = Util.null2s(Util.null2String(flowData.get(id+"|"+fieldName)),"0.0");
String backType = fieldName+"_back";
String businessLeavebackData = Util.null2s(Util.null2String(flowData.get(id+"|"+backType)),"0.0");
String businessLeave = "";
try{
//以防止出现精度问题
if(businessLeaveData.length() == 0){
businessLeaveData = "0.0";
}
if(businessLeavebackData.length() == 0){
businessLeavebackData = "0.0";
}
BigDecimal b_businessLeaveData = new BigDecimal(businessLeaveData);
BigDecimal b_businessLeavebackData = new BigDecimal(businessLeavebackData);
businessLeave = b_businessLeaveData.subtract(b_businessLeavebackData).toString();
if(Util.getDoubleValue(businessLeave, -1) < 0){
businessLeave = "0.0";
}
}catch (Exception e){
}
fieldValue = KQDurationCalculatorUtil.getDurationRound(businessLeave);
}else{
String businessLeaveData = Util.null2s(Util.null2String(flowData.get(id+"|"+fieldName)),"0.0");
String backType = fieldName+"_back";
String businessLeavebackData = Util.null2s(Util.null2String(flowData.get(id+"|"+backType)),"0.0");
String businessLeave = "";
try{
//以防止出现精度问题
if(businessLeaveData.length() == 0){
businessLeaveData = "0.0";
}
if(businessLeavebackData.length() == 0){
businessLeavebackData = "0.0";
}
BigDecimal b_businessLeaveData = new BigDecimal(businessLeaveData);
BigDecimal b_businessLeavebackData = new BigDecimal(businessLeavebackData);
businessLeave = b_businessLeaveData.subtract(b_businessLeavebackData).toString();
if(Util.getDoubleValue(businessLeave, -1) < 0){
businessLeave = "0.0";
}
}catch (Exception e){
}
fieldValue = KQDurationCalculatorUtil.getDurationRound(businessLeave);
} else{
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id+"|"+fieldName)));
}
} else {
} else if (fieldName.equals("statAllowance")) {//考勤二开--驻点餐补
bb.writeLog("flowData: " + flowData);
Map<String, Object> tempMap = hostarUtil.parseMapForFilter(flowData, id + "|DailyStatAllowance");
bb.writeLog("tempMap: " + tempMap);
if ( !tempMap.isEmpty()) {
double tempValue = 0.00;
for (String key: tempMap.keySet()) {
double doubleValue = Util.getDoubleValue(Util.null2String(tempMap.get(key)));
tempValue = tempValue + (doubleValue < 0.00 ? 0.00 : doubleValue);
}
fieldValue = String.valueOf(tempValue);
}
data.put(fieldName, fieldValue);
} else if (fieldName.equals("nightAllowance")) {//考勤二开--夜班餐补
bb.writeLog("flowData: " + flowData);
Map<String, Object> tempMap = hostarUtil.parseMapForFilter(flowData, id + "|DailyNightShiftAllowanceData");
bb.writeLog("tempMap: " + tempMap);
if ( !tempMap.isEmpty()) {
double tempValue = 0.00;
for (String key: tempMap.keySet()) {
double doubleValue = Util.getDoubleValue(Util.null2String(tempMap.get(key)));
tempValue = tempValue + (doubleValue < 0.00 ? 0.00 : doubleValue);
}
fieldValue = String.valueOf(tempValue);
}
data.put(fieldName, fieldValue);
} else if (fieldName.equals("otherStatAllowance")) {//考勤二开--鸿仁驻点餐补
bb.writeLog("flowData: " + flowData);
Map<String, Object> tempMap = hostarUtil.parseMapForFilter(flowData, id + "|DailyOtherStatAllowance");
bb.writeLog("tempMap: " + tempMap);
if ( !tempMap.isEmpty()) {
double tempValue = 0.00;
for (String key: tempMap.keySet()) {
double doubleValue = Util.getDoubleValue(Util.null2String(tempMap.get(key)));
tempValue = tempValue + (doubleValue < 0.00 ? 0.00 : doubleValue);
}
fieldValue = String.valueOf(tempValue);
}
data.put(fieldName, fieldValue);
} else {
fieldValue = Util.null2String(rs.getString(fieldName));
if(Util.null2String(kqReportFieldComInfo.getUnittype()).length()>0) {
if(fieldValue.length() == 0){
@ -437,31 +494,31 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
String flowLeaveBackType = Util.null2String("leavebackType_"+leaveRule.get("id"));
String leavebackData = Util.null2s(Util.null2String(flowData.get(id+"|"+flowLeaveBackType)),"0.0");
String b_flowLeaveData = "";
String flowLeaveData = "";
String flowLeaveData = "";
try{
//以防止出现精度问题
if(leaveData.length() == 0){
leaveData = "0.0";
}
if(leavebackData.length() == 0){
leavebackData = "0.0";
}
BigDecimal b_leaveData = new BigDecimal(leaveData);
BigDecimal b_leavebackData = new BigDecimal(leavebackData);
b_flowLeaveData = b_leaveData.subtract(b_leavebackData).toString();
if(Util.getDoubleValue(b_flowLeaveData, -1) < 0){
b_flowLeaveData = "0.0";
}
}catch (Exception e){
writeLog("GetKQReportCmd:leaveData"+leaveData+":leavebackData:"+leavebackData+":"+e);
}
//以防止出现精度问题
if(leaveData.length() == 0){
leaveData = "0.0";
}
if(leavebackData.length() == 0){
leavebackData = "0.0";
}
BigDecimal b_leaveData = new BigDecimal(leaveData);
BigDecimal b_leavebackData = new BigDecimal(leavebackData);
b_flowLeaveData = b_leaveData.subtract(b_leavebackData).toString();
if(Util.getDoubleValue(b_flowLeaveData, -1) < 0){
b_flowLeaveData = "0.0";
}
}catch (Exception e){
writeLog("GetKQReportCmd:leaveData"+leaveData+":leavebackData:"+leavebackData+":"+e);
}
//考虑下冻结的数据
if(b_flowLeaveData.length() > 0){
flowLeaveData = KQDurationCalculatorUtil.getDurationRound(b_flowLeaveData);
}else{
flowLeaveData = KQDurationCalculatorUtil.getDurationRound(Util.null2String(Util.getDoubleValue(leaveData,0.0)-Util.getDoubleValue(leavebackData,0.0)));
}
//考虑下冻结的数据
if(b_flowLeaveData.length() > 0){
flowLeaveData = KQDurationCalculatorUtil.getDurationRound(b_flowLeaveData);
}else{
flowLeaveData = KQDurationCalculatorUtil.getDurationRound(Util.null2String(Util.getDoubleValue(leaveData,0.0)-Util.getDoubleValue(leavebackData,0.0)));
}
data.put(flowType,flowLeaveData);
}
@ -495,6 +552,7 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
retmap.put("ishavenext", isHaveNext);
}catch (Exception e){
writeLog(e);
bb.writeLog("GetKQReportCmd Exception: " + e);
}
return retmap;
}

Loading…
Cancel
Save