Merge remote-tracking branch 'origin/dev' into dev

dev
Administrator 1 year ago
commit 60ca792a56

@ -0,0 +1,2 @@
# 餐补信息记录模块ID
cbxxjl_modeid=82

@ -53,4 +53,14 @@ public class KqDevController {
return new Gson().toJson(resultDatas);
}
@POST
@Path("/updateCbInfo")
@Produces(MediaType.APPLICATION_JSON)
public String updateCbInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
Map<String, Object> params = ParamUtil.request2Map(request);
Map<String, Object> resultDatas = getKqDevService(user).updateCbInfo(params);
return new Gson().toJson(resultDatas);
}
}

@ -14,4 +14,6 @@ public interface KqDevService {
Map<String, Object> getEndWorkDate(Map<String, Object> params);
/*删除原始打卡记录*/
Map<String, Object> signDelete(Map<String, Object> params);
Map<String, Object> updateCbInfo(Map<String, Object> params);
}

@ -3,18 +3,22 @@ package com.engine.hostar.service.impl;
import cn.hutool.core.date.DateUtil;
import com.engine.core.impl.Service;
import com.engine.hostar.service.KqDevService;
import com.engine.hostar.thread.HandleCBDataThread;
import com.engine.hostar.util.HostarUtil;
import com.engine.kq.biz.KQHolidaySetBiz;
import com.engine.kq.biz.KQOvertimeRulesBiz;
import com.engine.kq.biz.KQWorkTime;
import org.apache.commons.lang.StringUtils;
import org.springframework.util.CollectionUtils;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.ThreadPoolUtil;
import weaver.general.Util;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.ExecutorService;
/**
* @author chenwnj
@ -268,4 +272,70 @@ public class KqDevServiceImpl extends Service implements KqDevService {
return result;
}
@Override
public Map<String, Object> updateCbInfo(Map<String, Object> params) {
bb.writeLog("---updateCbInfo start---");
Map<String, Object> result = new HashMap<>();
try {
String ryParam = Util.null2String(params.get("name"));
String startDate = Util.null2String(params.get("startdate"));
String endDate = Util.null2String(params.get("enddate"));
String today = DateUtil.format(new Date(), "yyyy-MM-dd");
if (org.apache.commons.lang3.StringUtils.isEmpty(endDate)) {
endDate = today;
}
if (org.apache.commons.lang3.StringUtils.isEmpty(startDate)) {
startDate = today;
}
List<String> allDates = getAllDates(startDate, endDate);
RecordSet rs = new RecordSet();
List<String> userIds = new ArrayList<>();
if (org.apache.commons.lang3.StringUtils.isEmpty(ryParam)) {
bb.writeLog("1111.");
rs.executeQuery("select id from hrmresource");
while (rs.next()) {
userIds.add(rs.getString("id"));
}
} else {
String[] ryParamTemp = ryParam.split(",");
userIds.addAll(Arrays.asList(ryParamTemp));
}
bb.writeLog("userIds:" + userIds);
if (CollectionUtils.isEmpty(userIds) || CollectionUtils.isEmpty(allDates)) {
bb.writeLog("no user or date.");
result.put("mes", "没有数据需要更新!");
result.put("code", "200");
return result;
}
ExecutorService executorService = ThreadPoolUtil.getThreadPool(null, null);
for (String userId : userIds) {
for (String kqDate : allDates) {
executorService.execute(new HandleCBDataThread(userId, kqDate));
}
}
if (executorService.isTerminated()) {
executorService.shutdown();
}
} catch (Exception e) {
bb.writeLog("updateCbInfo error:" + e.getMessage());
result.put("mes", "系统错误,请联系管理员!");
result.put("code", "400");
}
result.put("mes", "已开始计算,请稍等!");
result.put("code", "200");
return result;
}
public List<String> getAllDates(String startDate, String endDate) {
List<String> result = new ArrayList<>();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate start = LocalDate.parse(startDate, formatter);
LocalDate end = LocalDate.parse(endDate, formatter);
while (!start.isAfter(end)) {
result.add(start.format(formatter));
start = start.plusDays(1);
}
return result;
}
}

@ -0,0 +1,984 @@
package com.engine.hostar.thread;
import com.engine.hostar.util.HostarUtil;
import com.engine.kq.biz.KQFormatSignData;
import com.engine.kq.biz.KQGroupMemberComInfo;
import com.engine.kq.biz.KQLeaveRulesComInfo;
import com.engine.kq.biz.KQOvertimeRulesBiz;
import com.engine.kq.biz.KQShiftRuleInfoBiz;
import com.engine.kq.biz.KQTimesArrayComInfo;
import com.engine.kq.biz.KQWorkTime;
import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean;
import com.engine.kq.entity.TimeScopeEntity;
import com.engine.kq.entity.WorkTimeEntity;
import com.engine.kq.util.KQDurationCalculatorUtil;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSet;
import weaver.formmode.setup.ModeRightInfo;
import weaver.general.BaseBean;
import weaver.general.InitServer;
import weaver.general.Util;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
* @version 1.0
* @Title ecology-9
* @Company
* @CreateDate 2024/3/12
* @Description
* @Author AdminZm
*/
public class HandleCBDataThread extends BaseBean implements Runnable{
BaseBean baseBean = new BaseBean();
private String userId;
private String kqDate;
private static DecimalFormat df = new DecimalFormat("0.00");
private DecimalFormatSymbols symbols = new DecimalFormatSymbols();
public HandleCBDataThread(String userId, String kqDate) {
this.userId = userId;
this.kqDate = kqDate;
}
@Override
public void run() {
baseBean.writeLog("HandleCBDataThread:" + userId + "、" + kqDate);
try {
RecordSet rs = new RecordSet();
// 获取考勤二开--夜班补助
String nightShiftSubsidy = getNightShiftSubsidy(userId, kqDate);
baseBean.writeLog("nightShiftSubsidy:" + nightShiftSubsidy);
if (StringUtils.isEmpty(nightShiftSubsidy)) {
nightShiftSubsidy = "0";
}
// 获取考勤二开--鸿仁驻点餐补
String otherStatAllowance = getOtherStatAllowance(userId, kqDate);
baseBean.writeLog("otherStatAllowance:" + otherStatAllowance);
if (StringUtils.isEmpty(otherStatAllowance)) {
otherStatAllowance = "0";
}
// 考勤二开--精密夜班餐补
String nightAllowance = getNightAllowance(userId, kqDate);
baseBean.writeLog("nightAllowance:" + nightAllowance);
if (StringUtils.isEmpty(nightAllowance)) {
nightAllowance = "0";
}
// 考勤二开--驻点餐补
String statAllowance = getStatAllowance(userId, kqDate);
baseBean.writeLog("statAllowance:" + statAllowance);
if (StringUtils.isEmpty(statAllowance)) {
statAllowance = "0";
}
// 考勤二开--出差餐补
String mealAllowance = getMealAllowance(userId, kqDate);
baseBean.writeLog("mealAllowance:" + mealAllowance);
if (StringUtils.isEmpty(mealAllowance)) {
mealAllowance = "0";
}
// 考勤二开--零点补助
String zeropoint = "0";
rs.executeQuery("select zeropoint from kq_format_total where resourceid = ? and kqdate = ?", userId, kqDate);
if (rs.next()) {
zeropoint = rs.getString("zeropoint");
}
if (StringUtils.isEmpty(zeropoint)) {
zeropoint = "0";
}
rs.executeQuery("select id from uf_cbxxjlb where xm = ? and rq = ?", userId, kqDate);
RecordSet rs1 = new RecordSet();
String cbxxjlModeId = rs1.getPropValue("hostar_zm_prop", "cbxxjl_modeid");
if (rs.next()) {
int cbxxjlId = rs.getInt("id");
rs1.executeUpdate("update uf_cbxxjlb set hrzdcb = ?, jmybcb = ?, zdcb = ?, ybbz = ?, cccb = ?, ldbz = ? where id = ?",
otherStatAllowance, nightAllowance, statAllowance, nightShiftSubsidy, mealAllowance, zeropoint, cbxxjlId);
//权限重构
ModeRightInfo ModeRightInfo = new ModeRightInfo();
ModeRightInfo.setNewRight(true);
ModeRightInfo.editModeDataShare(1, Integer.parseInt(cbxxjlModeId), cbxxjlId);
} else {
String uuidT = UUID.randomUUID().toString();
SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
SimpleDateFormat sdfTime = new SimpleDateFormat("HH:mm:ss");//设置日期格式
String nowDate = sdfDate.format(new Date());
String nowTime = sdfTime.format(new Date());
String gh = null;
String bm = null;
rs1.executeQuery("SELECT workcode, departmentid from hrmresource where id = ?", userId);
if (rs1.next()) {
gh = rs1.getString("workcode");
bm = rs1.getString("departmentid");
}
rs1.executeUpdate("insert into uf_cbxxjlb (xm, rq, gh, bm, hrzdcb, jmybcb, zdcb, ybbz, cccb, ldbz, formmodeid, MODEUUID, " +
"modedatacreater, modedatacreatertype, modedatacreatedate, modedatacreatetime) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ,? ,?, ?)",
userId, kqDate, gh, bm, otherStatAllowance, nightAllowance, statAllowance, nightShiftSubsidy, mealAllowance, zeropoint, cbxxjlModeId, uuidT, "1", "0", nowDate, nowTime);
RecordSet qxcgRs = new RecordSet();
qxcgRs.execute("select id from uf_cbxxjlb where MODEUUID = '" + uuidT + "'");
Integer idT = 0;
while (qxcgRs.next()) {
idT = qxcgRs.getInt("id");
}
//权限重构
ModeRightInfo ModeRightInfo = new ModeRightInfo();
ModeRightInfo.setNewRight(true);
ModeRightInfo.editModeDataShare(1, Integer.parseInt(cbxxjlModeId), idT);
}
} catch (Exception e) {
baseBean.writeLog("HandleCBDataThread error:" + e.getMessage());
}
}
public String getNightShiftSubsidy(String userId, String kqDate) {
BaseBean bb = new BaseBean();
RecordSet rs = new RecordSet();
String value = "";
try {
//获取夜班班次
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) {
HostarUtil houtil = new HostarUtil();
//先获取到出勤时长
Map<String, Double> attendanceMinsMap = new HashMap<>();
String acqAttenSql = " select resourceid, attendancemins, kqdate from kq_format_total where resourceid in (" + userId + ") and kqdate >='" + kqDate + "' and kqdate <='" + kqDate + "'";
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();
//获取当天班次
Map<String, Object> serialInfo = kqWorkTime.getSerialInfo(userId, kqDate, false);
if (serialInfo != null && serialInfo.size() > 0) {
int serialid = Util.getIntValue(Util.null2String(serialInfo.get(kqDate)), 0);
if (serialid > 0) {
if ( !nightShiftList.contains(String.valueOf(serialid))) {
return "0";
}
}
}
Double attendanceMins = Util.getDoubleValue(Util.null2String(attendanceMinsMap.get(userId + "|" + kqDate)));
value = (( attendanceMins / 60) >= 8.00 ) ? "1" : "0";
}
} catch (Exception e) {
bb.writeLog("get NightShiftSubsidy error:" + e.getMessage());
}
return value;
}
public String getOtherStatAllowance(String userId, String kqDate) {
BaseBean bb = new BaseBean();
RecordSet rs = new RecordSet();
String value = "";
String sqlWhere = " ";
try {
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
if(userId.length()>0){
sqlWhere +=" and a.id in("+userId+") ";
}
//获取加班时长
Map<String,Object> dailyFlowOverTimeData = getDailyFlowOverTimeDataAllowance(userId, kqDate);
String otherstatsub = Util.null2String(bb.getPropValue("project_hostar", "otherstatsubcompany"));
if (StringUtils.isNotBlank(otherstatsub)) {
//查询该分部下的人员
List<String> resIds = new ArrayList<>();
sqlWhere += " and a.subcompanyid1 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(kqDate)) {
HostarUtil houtil = new HostarUtil();
//先获取到出勤时长
Map<String, Double> attendanceMinsMap = new HashMap<>();
String acqAttenSql = " select resourceid, attendancemins, kqdate from kq_format_total where resourceid in (" + String.join(",", resIds) + ") and kqdate >='" + kqDate + "' and kqdate <='" + kqDate + "'";
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 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, kqDate);
String preDate = weaver.common.DateUtil.addDate(kqDate, -1);//上一天日期
String nextDate = weaver.common.DateUtil.addDate(kqDate, 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(kqDate);
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, kqDate, 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;
String signId = Util.null2String(temp.get("signId"));
if (StringUtils.isNotBlank(signId)) {
signIdList.add(signId);
}
}
}
Integer signNumber = 0;
if (signIdList !=null && signIdList.size() > 0) {
String acqShowAddress = "select showaddress,addr 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"));
String addr = Util.null2String(rs.getString("addr"));
if ("鸿仕达".equals(showaddress) || "hostar".equalsIgnoreCase(showaddress) || "鸿仕达".equals(addr) || "hostar".equalsIgnoreCase(addr)) {
signNumber = signNumber + 1;
}
}
}
if (signNumber == 0) {
double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|workingDayOvertime_4leave")));
workingDayOvertime_4leave = workingDayOvertime_4leave < 0 ? 0 : workingDayOvertime_4leave;
double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|restDayOvertime_4leave")));
restDayOvertime_4leave = restDayOvertime_4leave < 0 ? 0 : restDayOvertime_4leave;
double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|holidayOvertime_4leave")));
holidayOvertime_4leave = holidayOvertime_4leave < 0 ? 0 : holidayOvertime_4leave;
double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|workingDayOvertime_nonleave")));
workingDayOvertime_nonleave = workingDayOvertime_nonleave < 0 ? 0 : workingDayOvertime_nonleave;
double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|restDayOvertime_nonleave")));
restDayOvertime_nonleave = restDayOvertime_nonleave < 0 ? 0 : restDayOvertime_nonleave;
double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|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 + "|" + kqDate)));
// bb.writeLog("-=-attendanceMins:" + attendanceMins);
double v = Math.round (((attendanceMins < 0.00) ? 0.00 : attendanceMins) + temp) / 60.00;
value = "0";
if (v >= 4.00 && v < 9.00) {
value = "1";
} else if (v >= 9.00) {
value = "2";
}
}
}
}
}
} catch (Exception e) {
bb.writeLog("get OtherStatAllowance error:" + e.getMessage());
}
return value;
}
public Map<String,Object> getDailyFlowOverTimeDataAllowance(String userId, String kqDate){
BaseBean bb = new BaseBean();
Map<String,Object> datas = new HashMap<>();;
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
String valueRes = "";
try{
if(userId.length()>0){
sqlWhere +=" and a.id in("+userId+") ";
}
KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz();
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 >='"+kqDate+"' and belongdate <='"+kqDate+"' " +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了
symbols.setDecimalSeparator('.');
df.setMaximumFractionDigits(5);
df.setDecimalFormatSymbols(symbols);
datas.put(resourceid+"|"+belongdate+"|"+flowType, df.format(value));
}
}catch (Exception e){
bb.writeLog("getDailyFlowOverTimeDataAllowance error:" + e.getMessage());
}
return datas;
}
public String getNightAllowance(String userId, String kqDate){
BaseBean bb = new BaseBean();
String value = "";
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try {
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
if(userId.length()>0){
sqlWhere +=" and a.id in("+userId+") ";
}
//获取加班时长
Map<String, Object> dailyFlowOverTimeData = getDailyFlowOverTimeDataAllowance(userId, kqDate);
//获取夜班班次
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);
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();
//先获取到出勤时长
Map<String, Double> attendanceMinsMap = new HashMap<>();
String acqAttenSql = " select resourceid, attendancemins, kqdate from kq_format_total where resourceid in (" + String.join(",", resIds) + ") and kqdate >='" + kqDate + "' and kqdate <='" + kqDate + "'";
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) {
//获取当天班次
Map<String, Object> serialInfo = kqWorkTime.getSerialInfo(res, kqDate, false);
if (serialInfo != null && serialInfo.size() > 0) {
int serialid = Util.getIntValue(Util.null2String(serialInfo.get(kqDate)), 0);
if (serialid > 0) {
if (!nightShiftList.contains(String.valueOf(serialid))) {
continue;
}
}
}
double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|workingDayOvertime_4leave")));
workingDayOvertime_4leave = workingDayOvertime_4leave < 0 ? 0 : workingDayOvertime_4leave;
double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|restDayOvertime_4leave")));
restDayOvertime_4leave = restDayOvertime_4leave < 0 ? 0 : restDayOvertime_4leave;
double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|holidayOvertime_4leave")));
holidayOvertime_4leave = holidayOvertime_4leave < 0 ? 0 : holidayOvertime_4leave;
double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|workingDayOvertime_nonleave")));
workingDayOvertime_nonleave = workingDayOvertime_nonleave < 0 ? 0 : workingDayOvertime_nonleave;
double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|restDayOvertime_nonleave")));
restDayOvertime_nonleave = restDayOvertime_nonleave < 0 ? 0 : restDayOvertime_nonleave;
double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|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 + "|" + kqDate)));
// bb.writeLog("-=-attendanceMins:" + attendanceMins);
value = String.valueOf(Math.floor(((attendanceMins < 0.00 ? 0.00 : attendanceMins) + temp) / 300));
}
}
}
}
} catch (Exception e) {
bb.writeLog("get NightAllowance error:" + e.getMessage());
}
return value;
}
public String getStatAllowance(String userId, String kqDate) {
BaseBean bb = new BaseBean();
String value = "0";
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try {
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
if(userId.length()>0){
sqlWhere +=" and a.id in("+userId+") ";
}
//获取加班时长
Map<String, Object> dailyFlowOverTimeData = getDailyFlowOverTimeDataAllowance(userId, kqDate);
//首先去除指定不享有的分部
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);
}
}
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(kqDate)) {
HostarUtil houtil = new HostarUtil();
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
//先获取到出勤时长
Map<String, Double> attendanceMinsMap = new HashMap<>();
String acqAttenSql = " select resourceid, attendancemins, kqdate from kq_format_total where resourceid in (" + String.join(",",resIds) + ") and kqdate >='" + kqDate + "' and kqdate <='" + kqDate + "'";
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> 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 "0";
}
for (String res: resIds) {
//判断考勤组
/*获取考勤组的ID因为考勤组有有效期所以需要传入日期*/
String groupId = kqGroupMemberComInfo.getKQGroupId(userId, kqDate);
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<>();
KQWorkTime kqWorkTime = new KQWorkTime();
kqWorkTime.setIsFormat(true);
WorkTimeEntity workTime = kqWorkTime.getWorkTime(res, kqDate);
String preDate = weaver.common.DateUtil.addDate(kqDate, -1);//上一天日期
String nextDate = weaver.common.DateUtil.addDate(kqDate, 1);//下一天日期
if (workTime != null) {
lsSignTime = workTime.getSignTime();//允许打卡时间
lsWorkTime = workTime.getWorkTime();//工作时间
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(kqDate);
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,kqDate,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;
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,addr 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"));
String addr = Util.null2String(rs.getString("addr"));
if ("鸿仕达".equals(showaddress) || "hostar".equalsIgnoreCase(showaddress) || "鸿仕达".equals(addr) || "hostar".equalsIgnoreCase(addr)) {
signNumber = signNumber + 1;
}
}
}
if (signNumber == 0 ) {
double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|workingDayOvertime_4leave")));
workingDayOvertime_4leave = workingDayOvertime_4leave < 0 ? 0 : workingDayOvertime_4leave;
double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|restDayOvertime_4leave")));
restDayOvertime_4leave = restDayOvertime_4leave < 0 ? 0 : restDayOvertime_4leave;
double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|holidayOvertime_4leave")));
holidayOvertime_4leave = holidayOvertime_4leave < 0 ? 0 : holidayOvertime_4leave;
double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|workingDayOvertime_nonleave")));
workingDayOvertime_nonleave = workingDayOvertime_nonleave < 0 ? 0 : workingDayOvertime_nonleave;
double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|restDayOvertime_nonleave")));
restDayOvertime_nonleave = restDayOvertime_nonleave < 0 ? 0 : restDayOvertime_nonleave;
double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|holidayOvertime_nonleave")));
holidayOvertime_nonleave = holidayOvertime_nonleave < 0 ? 0 : holidayOvertime_nonleave;
double temp = workingDayOvertime_4leave + restDayOvertime_4leave + holidayOvertime_4leave +
workingDayOvertime_nonleave + restDayOvertime_nonleave + holidayOvertime_nonleave;
Double attendanceMins = Util.getDoubleValue(Util.null2String(attendanceMinsMap.get(res + "|" + kqDate)));
value = String.valueOf(Math.floor( ((attendanceMins < 0.00 ? 0.00 : attendanceMins) + temp) / 300));
}
}
}
} catch (Exception e) {
bb.writeLog("get StatAllowance error:" + e.getMessage());
}
return value;
}
public String getMealAllowance(String id, String kqDateA) {
BaseBean bb = new BaseBean();
String value = "0";
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try {
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
if(id.length()>0){
sqlWhere +=" and b.id in("+id+") ";
}
// 首先获取出差公出流程信息
Map<String, Object> evectionMap = new HashMap<>();
String evectionTableName = Util.null2String(bb.getPropValue("project_hostar","evectionTableName"));
sql = " select d.resourceid, d.belongdate, d.longitude, d.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 >='"+kqDateA+"' and a.belongdate <='"+kqDateA+"' " + sqlWhere +
" ) d " +
" where 1=1 " ;
bb.writeLog("sql: " + sql);
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);
//获取外勤打卡数据
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();
if (StringUtils.isNotBlank(signBeginTime)) {
signBeginTime = signBeginTime + ":00";
}
//获取上班时间
String workBeginTime = workTimeScope.getBeginTime();
if (StringUtils.isNotBlank(workBeginTime)) {
workBeginTime = workBeginTime + ":00";
}
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 ";
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);
}
}
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();
String MealAlloTableName = Util.null2String(bb.getPropValue("project_hostar", "MealAllowanceTableName"));
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)";
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);
}
//根据外勤打卡数据计算餐补数据
for (String key: lsCheckInfo.keySet()) {
String[] split = key.split("\\|");
String userId = split[0];
String kqDate = split[1];
Map<String, Object> temp = lsCheckInfo.get(key);
String signInTime = Util.null2String(temp.get("signInTime"));
String signOutTime = Util.null2String(temp.get("signOutTime"));
if (StringUtils.isNotBlank(signInTime) && StringUtils.isNotBlank(signOutTime) ) {
for (Map<String, String> me: MealMap) {
String startTime = me.get("startTime");
String endTime = me.get("endTime");
if (StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)) {
startTime = startTime + ":00";
endTime = endTime + ":00";
}
if ( (signInTime.compareTo(startTime) <= 0) && (signOutTime.compareTo(endTime) >= 0) ) {
if (StringUtils.isEmpty(value) || StringUtils.equals(value, "0")) {
value = "1";
} else {
value = String.valueOf(Integer.parseInt(value));
}
}
}
}
}
}
} catch (Exception e) {
bb.writeLog("get MealAllowance error:" + e.getMessage());
}
return value;
}
}

@ -3,6 +3,7 @@ package com.engine.kq.biz;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.cloudstore.dev.api.util.Util_DataMap;
import com.engine.hostar.util.HostarUtil;
import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean;
import com.engine.kq.cmd.attendanceButton.ButtonStatusEnum;
import com.engine.kq.entity.KQShiftRuleEntity;
@ -11,12 +12,16 @@ import com.engine.kq.entity.TimeSignScopeEntity;
import com.engine.kq.entity.WorkTimeEntity;
import com.engine.kq.enums.FlowReportTypeEnum;
import com.engine.kq.log.KQLog;
import com.engine.kq.util.KQDurationCalculatorUtil;
import com.engine.kq.util.UtilKQ;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.googlecode.aviator.AviatorEvaluator;
import com.googlecode.aviator.Expression;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.ConcurrentHashMap;
@ -25,9 +30,13 @@ import weaver.common.DateUtil;
import weaver.conn.BatchRecordSet;
import weaver.conn.RecordSet;
import weaver.file.Prop;
import weaver.formmode.setup.ModeRightInfo;
import weaver.general.BaseBean;
import weaver.general.InitServer;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.hrm.User;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -46,6 +55,10 @@ public class KQFormatData extends BaseBean {
private final static double PI = 3.14159265358979323; // 圆周率
private final static double R = 6371229; // 地球的半径
private static DecimalFormat df = new DecimalFormat("0.00");
private DecimalFormatSymbols symbols = new DecimalFormatSymbols();
/***
*
* @param userId
@ -180,6 +193,88 @@ public class KQFormatData extends BaseBean {
rs.executeUpdate(sql, userId, kqDate);
}
}
long startTime = System.currentTimeMillis();
// 获取考勤二开--夜班补助
String nightShiftSubsidy = getNightShiftSubsidy(userId, kqDate);
bb.writeLog("nightShiftSubsidy:" + nightShiftSubsidy);
if (StringUtils.isEmpty(nightShiftSubsidy)) {
nightShiftSubsidy = "0";
}
// 获取考勤二开--鸿仁驻点餐补
String otherStatAllowance = getOtherStatAllowance(userId, kqDate);
bb.writeLog("otherStatAllowance:" + otherStatAllowance);
if (StringUtils.isEmpty(otherStatAllowance)) {
otherStatAllowance = "0";
}
// 考勤二开--精密夜班餐补
String nightAllowance = getNightAllowance(userId, kqDate);
bb.writeLog("nightAllowance:" + nightAllowance);
if (StringUtils.isEmpty(nightAllowance)) {
nightAllowance = "0";
}
// 考勤二开--驻点餐补
String statAllowance = getStatAllowance(userId, kqDate);
bb.writeLog("statAllowance:" + statAllowance);
if (StringUtils.isEmpty(statAllowance)) {
statAllowance = "0";
}
// 考勤二开--出差餐补
String mealAllowance = getMealAllowance(userId, kqDate);
bb.writeLog("mealAllowance:" + mealAllowance);
if (StringUtils.isEmpty(mealAllowance)) {
mealAllowance = "0";
}
// 考勤二开--零点补助
String zeropoint = "0";
rs.executeQuery("select zeropoint from kq_format_total where resourceid = ? and kqdate = ?", userId, kqDate);
if (rs.next()) {
zeropoint = rs.getString("zeropoint");
}
if (StringUtils.isEmpty(zeropoint)) {
zeropoint = "0";
}
rs.executeQuery("select id from uf_cbxxjlb where xm = ? and rq = ?", userId, kqDate);
RecordSet rs1 = new RecordSet();
String cbxxjlModeId = rs1.getPropValue("hostar_zm_prop","cbxxjl_modeid");
if (rs.next()) {
int cbxxjlId = rs.getInt("id");
rs1.executeUpdate("update uf_cbxxjlb set hrzdcb = ?, jmybcb = ?, zdcb = ?, ybbz = ?, cccb = ?, ldbz = ? where id = ?",
otherStatAllowance, nightAllowance, statAllowance, nightShiftSubsidy, mealAllowance, zeropoint, cbxxjlId);
//权限重构
ModeRightInfo ModeRightInfo = new ModeRightInfo();
ModeRightInfo.setNewRight(true);
ModeRightInfo.editModeDataShare(1, Integer.parseInt(cbxxjlModeId), cbxxjlId);
} else {
String uuidT = UUID.randomUUID().toString();
SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
SimpleDateFormat sdfTime = new SimpleDateFormat("HH:mm:ss");//设置日期格式
String nowDate = sdfDate.format(new Date());
String nowTime = sdfTime.format(new Date());
String gh = null;
String bm = null;
rs1.executeQuery("SELECT workcode, departmentid from hrmresource where id = ?", userId);
if (rs1.next()) {
gh = rs1.getString("workcode");
bm = rs1.getString("departmentid");
}
rs1.executeUpdate("insert into uf_cbxxjlb (xm, rq, gh, bm, hrzdcb, jmybcb, zdcb, ybbz, cccb, ldbz, formmodeid, MODEUUID, " +
"modedatacreater, modedatacreatertype, modedatacreatedate, modedatacreatetime) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ,? ,?)",
userId, kqDate, gh, bm ,otherStatAllowance, nightAllowance, statAllowance, nightShiftSubsidy, mealAllowance, zeropoint, cbxxjlModeId, uuidT, "1", "0", nowDate, nowTime);
RecordSet qxcgRs = new RecordSet();
qxcgRs.execute("select id from uf_cbxxjlb where MODEUUID = '" + uuidT + "'");
Integer idT = 0;
while (qxcgRs.next()) {
idT = qxcgRs.getInt("id");
}
//权限重构
ModeRightInfo ModeRightInfo = new ModeRightInfo();
ModeRightInfo.setNewRight(true);
ModeRightInfo.editModeDataShare(1, Integer.parseInt(cbxxjlModeId), idT);
}
long endTime = System.currentTimeMillis();
long elapsedTime = endTime - startTime; // 执行时间
bb.writeLog("getDailyMealAllowanceData执行时间" + elapsedTime/1000 + "秒");
}catch (Exception e) {
writeLog(e);
kqLog.info(e);
@ -1268,4 +1363,838 @@ public class KQFormatData extends BaseBean {
distance = Math.hypot(x, y);
return distance;
}
public String getNightShiftSubsidy(String userId, String kqDate) {
RecordSet rs = new RecordSet();
String value = "";
try {
//获取夜班班次
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) {
HostarUtil houtil = new HostarUtil();
//先获取到出勤时长
Map<String, Double> attendanceMinsMap = new HashMap<>();
String acqAttenSql = " select resourceid, attendancemins, kqdate from kq_format_total where resourceid in (" + userId + ") and kqdate >='" + kqDate + "' and kqdate <='" + kqDate + "'";
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();
//获取当天班次
Map<String, Object> serialInfo = kqWorkTime.getSerialInfo(userId, kqDate, false);
if (serialInfo != null && serialInfo.size() > 0) {
int serialid = Util.getIntValue(Util.null2String(serialInfo.get(kqDate)), 0);
if (serialid > 0) {
if ( !nightShiftList.contains(String.valueOf(serialid))) {
return "0";
}
}
}
Double attendanceMins = Util.getDoubleValue(Util.null2String(attendanceMinsMap.get(userId + "|" + kqDate)));
value = (( attendanceMins / 60) >= 8.00 ) ? "1" : "0";
}
} catch (Exception e) {
bb.writeLog("get NightShiftSubsidy error:" + e.getMessage());
}
return value;
}
public String getOtherStatAllowance(String userId, String kqDate) {
RecordSet rs = new RecordSet();
String value = "";
String sqlWhere = " ";
try {
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
if(userId.length()>0){
sqlWhere +=" and a.id in("+userId+") ";
}
//获取加班时长
Map<String,Object> dailyFlowOverTimeData = getDailyFlowOverTimeDataAllowance(userId, kqDate);
String otherstatsub = Util.null2String(bb.getPropValue("project_hostar", "otherstatsubcompany"));
if (StringUtils.isNotBlank(otherstatsub)) {
//查询该分部下的人员
List<String> resIds = new ArrayList<>();
sqlWhere += " and a.subcompanyid1 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(kqDate)) {
HostarUtil houtil = new HostarUtil();
//先获取到出勤时长
Map<String, Double> attendanceMinsMap = new HashMap<>();
String acqAttenSql = " select resourceid, attendancemins, kqdate from kq_format_total where resourceid in (" + String.join(",", resIds) + ") and kqdate >='" + kqDate + "' and kqdate <='" + kqDate + "'";
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 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, kqDate);
String preDate = DateUtil.addDate(kqDate, -1);//上一天日期
String nextDate = DateUtil.addDate(kqDate, 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(kqDate);
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, kqDate, 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;
String signId = Util.null2String(temp.get("signId"));
if (StringUtils.isNotBlank(signId)) {
signIdList.add(signId);
}
}
}
Integer signNumber = 0;
if (signIdList !=null && signIdList.size() > 0) {
String acqShowAddress = "select showaddress,addr 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"));
String addr = Util.null2String(rs.getString("addr"));
if ("鸿仕达".equals(showaddress) || "hostar".equalsIgnoreCase(showaddress) || "鸿仕达".equals(addr) || "hostar".equalsIgnoreCase(addr)) {
signNumber = signNumber + 1;
}
}
}
if (signNumber == 0) {
double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|workingDayOvertime_4leave")));
workingDayOvertime_4leave = workingDayOvertime_4leave < 0 ? 0 : workingDayOvertime_4leave;
double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|restDayOvertime_4leave")));
restDayOvertime_4leave = restDayOvertime_4leave < 0 ? 0 : restDayOvertime_4leave;
double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|holidayOvertime_4leave")));
holidayOvertime_4leave = holidayOvertime_4leave < 0 ? 0 : holidayOvertime_4leave;
double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|workingDayOvertime_nonleave")));
workingDayOvertime_nonleave = workingDayOvertime_nonleave < 0 ? 0 : workingDayOvertime_nonleave;
double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|restDayOvertime_nonleave")));
restDayOvertime_nonleave = restDayOvertime_nonleave < 0 ? 0 : restDayOvertime_nonleave;
double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|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 + "|" + kqDate)));
// bb.writeLog("-=-attendanceMins:" + attendanceMins);
double v = Math.round (((attendanceMins < 0.00) ? 0.00 : attendanceMins) + temp) / 60.00;
value = "0";
if (v >= 4.00 && v < 9.00) {
value = "1";
} else if (v >= 9.00) {
value = "2";
}
}
}
}
}
} catch (Exception e) {
bb.writeLog("get OtherStatAllowance error:" + e.getMessage());
}
return value;
}
public Map<String,Object> getDailyFlowOverTimeDataAllowance(String userId, String kqDate){
Map<String,Object> datas = new HashMap<>();;
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
String valueRes = "";
try{
if(userId.length()>0){
sqlWhere +=" and a.id in("+userId+") ";
}
KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz();
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 >='"+kqDate+"' and belongdate <='"+kqDate+"' " +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了
symbols.setDecimalSeparator('.');
df.setMaximumFractionDigits(5);
df.setDecimalFormatSymbols(symbols);
datas.put(resourceid+"|"+belongdate+"|"+flowType, df.format(value));
}
}catch (Exception e){
bb.writeLog("getDailyFlowOverTimeDataAllowance error:" + e.getMessage());
}
return datas;
}
public String getNightAllowance(String userId, String kqDate){
String value = "";
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try {
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
if(userId.length()>0){
sqlWhere +=" and a.id in("+userId+") ";
}
//获取加班时长
Map<String, Object> dailyFlowOverTimeData = getDailyFlowOverTimeDataAllowance(userId, kqDate);
//获取夜班班次
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);
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();
//先获取到出勤时长
Map<String, Double> attendanceMinsMap = new HashMap<>();
String acqAttenSql = " select resourceid, attendancemins, kqdate from kq_format_total where resourceid in (" + String.join(",", resIds) + ") and kqdate >='" + kqDate + "' and kqdate <='" + kqDate + "'";
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) {
//获取当天班次
Map<String, Object> serialInfo = kqWorkTime.getSerialInfo(res, kqDate, false);
if (serialInfo != null && serialInfo.size() > 0) {
int serialid = Util.getIntValue(Util.null2String(serialInfo.get(kqDate)), 0);
if (serialid > 0) {
if (!nightShiftList.contains(String.valueOf(serialid))) {
continue;
}
}
}
double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|workingDayOvertime_4leave")));
workingDayOvertime_4leave = workingDayOvertime_4leave < 0 ? 0 : workingDayOvertime_4leave;
double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|restDayOvertime_4leave")));
restDayOvertime_4leave = restDayOvertime_4leave < 0 ? 0 : restDayOvertime_4leave;
double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|holidayOvertime_4leave")));
holidayOvertime_4leave = holidayOvertime_4leave < 0 ? 0 : holidayOvertime_4leave;
double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|workingDayOvertime_nonleave")));
workingDayOvertime_nonleave = workingDayOvertime_nonleave < 0 ? 0 : workingDayOvertime_nonleave;
double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|restDayOvertime_nonleave")));
restDayOvertime_nonleave = restDayOvertime_nonleave < 0 ? 0 : restDayOvertime_nonleave;
double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|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 + "|" + kqDate)));
// bb.writeLog("-=-attendanceMins:" + attendanceMins);
value = String.valueOf(Math.floor(((attendanceMins < 0.00 ? 0.00 : attendanceMins) + temp) / 300));
}
}
}
}
} catch (Exception e) {
bb.writeLog("get NightAllowance error:" + e.getMessage());
}
return value;
}
public String getStatAllowance(String userId, String kqDate) {
String value = "0";
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try {
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
if(userId.length()>0){
sqlWhere +=" and a.id in("+userId+") ";
}
//获取加班时长
Map<String, Object> dailyFlowOverTimeData = getDailyFlowOverTimeDataAllowance(userId, kqDate);
//首先去除指定不享有的分部
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);
}
}
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(kqDate)) {
HostarUtil houtil = new HostarUtil();
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
//先获取到出勤时长
Map<String, Double> attendanceMinsMap = new HashMap<>();
String acqAttenSql = " select resourceid, attendancemins, kqdate from kq_format_total where resourceid in (" + String.join(",",resIds) + ") and kqdate >='" + kqDate + "' and kqdate <='" + kqDate + "'";
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> 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 "0";
}
for (String res: resIds) {
//判断考勤组
/*获取考勤组的ID因为考勤组有有效期所以需要传入日期*/
String groupId = kqGroupMemberComInfo.getKQGroupId(userId, kqDate);
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<>();
KQWorkTime kqWorkTime = new KQWorkTime();
kqWorkTime.setIsFormat(true);
WorkTimeEntity workTime = kqWorkTime.getWorkTime(res, kqDate);
String preDate = DateUtil.addDate(kqDate, -1);//上一天日期
String nextDate = DateUtil.addDate(kqDate, 1);//下一天日期
if (workTime != null) {
lsSignTime = workTime.getSignTime();//允许打卡时间
lsWorkTime = workTime.getWorkTime();//工作时间
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(kqDate);
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,kqDate,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;
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,addr 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"));
String addr = Util.null2String(rs.getString("addr"));
if ("鸿仕达".equals(showaddress) || "hostar".equalsIgnoreCase(showaddress) || "鸿仕达".equals(addr) || "hostar".equalsIgnoreCase(addr)) {
signNumber = signNumber + 1;
}
}
}
if (signNumber == 0 ) {
double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|workingDayOvertime_4leave")));
workingDayOvertime_4leave = workingDayOvertime_4leave < 0 ? 0 : workingDayOvertime_4leave;
double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|restDayOvertime_4leave")));
restDayOvertime_4leave = restDayOvertime_4leave < 0 ? 0 : restDayOvertime_4leave;
double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|holidayOvertime_4leave")));
holidayOvertime_4leave = holidayOvertime_4leave < 0 ? 0 : holidayOvertime_4leave;
double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|workingDayOvertime_nonleave")));
workingDayOvertime_nonleave = workingDayOvertime_nonleave < 0 ? 0 : workingDayOvertime_nonleave;
double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|restDayOvertime_nonleave")));
restDayOvertime_nonleave = restDayOvertime_nonleave < 0 ? 0 : restDayOvertime_nonleave;
double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + kqDate + "|holidayOvertime_nonleave")));
holidayOvertime_nonleave = holidayOvertime_nonleave < 0 ? 0 : holidayOvertime_nonleave;
double temp = workingDayOvertime_4leave + restDayOvertime_4leave + holidayOvertime_4leave +
workingDayOvertime_nonleave + restDayOvertime_nonleave + holidayOvertime_nonleave;
Double attendanceMins = Util.getDoubleValue(Util.null2String(attendanceMinsMap.get(res + "|" + kqDate)));
value = String.valueOf(Math.floor( ((attendanceMins < 0.00 ? 0.00 : attendanceMins) + temp) / 300));
}
}
}
} catch (Exception e) {
bb.writeLog("get StatAllowance error:" + e.getMessage());
}
return value;
}
public String getMealAllowance(String id, String kqDateA) {
String value = "0";
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try {
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
if(id.length()>0){
sqlWhere +=" and b.id in("+id+") ";
}
// 首先获取出差公出流程信息
Map<String, Object> evectionMap = new HashMap<>();
String evectionTableName = Util.null2String(bb.getPropValue("project_hostar","evectionTableName"));
sql = " select d.resourceid, d.belongdate, d.longitude, d.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 >='"+kqDateA+"' and a.belongdate <='"+kqDateA+"' " + sqlWhere +
" ) d " +
" where 1=1 " ;
bb.writeLog("sql: " + sql);
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);
//获取外勤打卡数据
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();
if (StringUtils.isNotBlank(signBeginTime)) {
signBeginTime = signBeginTime + ":00";
}
//获取上班时间
String workBeginTime = workTimeScope.getBeginTime();
if (StringUtils.isNotBlank(workBeginTime)) {
workBeginTime = workBeginTime + ":00";
}
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 ";
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);
}
}
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();
String MealAlloTableName = Util.null2String(bb.getPropValue("project_hostar", "MealAllowanceTableName"));
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);
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);
//根据外勤打卡数据计算餐补数据
for (String key: lsCheckInfo.keySet()) {
String[] split = key.split("\\|");
String userId = split[0];
String kqDate = split[1];
Map<String, Object> temp = lsCheckInfo.get(key);
String signInTime = Util.null2String(temp.get("signInTime"));
String signOutTime = Util.null2String(temp.get("signOutTime"));
if (StringUtils.isNotBlank(signInTime) && StringUtils.isNotBlank(signOutTime) ) {
for (Map<String, String> me: MealMap) {
String startTime = me.get("startTime");
String endTime = me.get("endTime");
if (StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)) {
startTime = startTime + ":00";
endTime = endTime + ":00";
}
if ( (signInTime.compareTo(startTime) <= 0) && (signOutTime.compareTo(endTime) >= 0) ) {
if (StringUtils.isEmpty(value) || StringUtils.equals(value, "0")) {
value = "1";
} else {
value = String.valueOf(Integer.parseInt(value));
}
}
}
}
}
}
} catch (Exception e) {
bb.writeLog("get MealAllowance error:" + e.getMessage());
}
return value;
}
}

@ -380,11 +380,11 @@ public class KQReportBiz extends BaseBean {
datas.putAll(getDailyFlowLeaveBackData(params,user));
/*考勤二开--出差公出流程餐补统计start*/
long startTime = System.currentTimeMillis();
datas.putAll(getDailyMealAllowanceData(params,user));
long endTime = System.currentTimeMillis();
long elapsedTime = endTime - startTime; // 执行时间
bb.writeLog("getDailyMealAllowanceData执行时间" + elapsedTime/1000 + "秒");
// long startTime = System.currentTimeMillis();
// datas.putAll(getDailyMealAllowanceData(params,user));
// long endTime = System.currentTimeMillis();
// long elapsedTime = endTime - startTime; // 执行时间
// bb.writeLog("getDailyMealAllowanceData执行时间" + elapsedTime/1000 + "秒");
/*考勤二开--出差公出流程餐补统计end*/
// /*考勤二开--计算驻点餐补start*/
@ -392,22 +392,22 @@ public class KQReportBiz extends BaseBean {
// /*考勤二开--计算驻点餐补end*/
//获取加班时长
Map<String, Object> dailyFlowOverTimeData = getDailyFlowOverTimeDataAllowance(params, user);
/*考勤二开--计算精密夜班餐补start*/
startTime = System.currentTimeMillis();
datas.putAll(getDailyNightShiftAllowanceDataTemp(params,user,dailyFlowOverTimeData));
endTime = System.currentTimeMillis();
elapsedTime = endTime - startTime; // 执行时间
bb.writeLog("getDailyNightShiftAllowanceData执行时间" + elapsedTime/1000 + "秒");
/*考勤二开--计算精密夜班餐补end*/
/*考勤二开--计算鸿仁驻点餐补start*/
startTime = System.currentTimeMillis();
datas.putAll(getDailyOtherStatAllowanceDataTemp(params,user,dailyFlowOverTimeData));
endTime = System.currentTimeMillis();
elapsedTime = endTime - startTime; // 执行时间
bb.writeLog("getDailyOtherStatAllowanceData执行时间" + elapsedTime/1000 + "秒");
// Map<String, Object> dailyFlowOverTimeData = getDailyFlowOverTimeDataAllowance(params, user);
//
// /*考勤二开--计算精密夜班餐补start*/
// startTime = System.currentTimeMillis();
// datas.putAll(getDailyNightShiftAllowanceDataTemp(params,user,dailyFlowOverTimeData));
// endTime = System.currentTimeMillis();
// elapsedTime = endTime - startTime; // 执行时间
// bb.writeLog("getDailyNightShiftAllowanceData执行时间" + elapsedTime/1000 + "秒");
// /*考勤二开--计算精密夜班餐补end*/
//
// /*考勤二开--计算鸿仁驻点餐补start*/
// startTime = System.currentTimeMillis();
// datas.putAll(getDailyOtherStatAllowanceDataTemp(params,user,dailyFlowOverTimeData));
// endTime = System.currentTimeMillis();
// elapsedTime = endTime - startTime; // 执行时间
// bb.writeLog("getDailyOtherStatAllowanceData执行时间" + elapsedTime/1000 + "秒");
/*考勤二开--计算鸿仁驻点餐补end*/
@ -432,7 +432,7 @@ public class KQReportBiz extends BaseBean {
/*考勤二开--出差公出流程餐补统计start*/
datas.putAll(getDailyMealAllowanceData(params,user));
// datas.putAll(getDailyMealAllowanceData(params,user));
/*考勤二开--出差公出流程餐补统计end*/
/*考勤二开--计算驻点餐补start*/
@ -444,11 +444,11 @@ public class KQReportBiz extends BaseBean {
/*考勤二开--计算驻点餐补end*/
/*考勤二开--计算精密夜班餐补start*/
datas.putAll(getDailyNightShiftAllowanceData(params,user));
// datas.putAll(getDailyNightShiftAllowanceData(params,user));
/*考勤二开--计算精密夜班餐补end*/
/*考勤二开--计算鸿仁驻点餐补start*/
datas.putAll(getDailyOtherStatAllowanceData(params,user));
// datas.putAll(getDailyOtherStatAllowanceData(params,user));
/*考勤二开--计算鸿仁驻点餐补end*/
@ -2742,12 +2742,13 @@ public class KQReportBiz extends BaseBean {
Integer signNumber = 0;
if (signIdList !=null && signIdList.size() > 0) {
String acqShowAddress = "select showaddress from hrmschedulesign where id in (" + String.join(",", signIdList) + ") ";
String acqShowAddress = "select showaddress,addr 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)) {
String addr = Util.null2String(rs.getString("addr"));
if ("鸿仕达".equals(showaddress) || "hostar".equalsIgnoreCase(showaddress) || "鸿仕达".equals(addr) || "hostar".equalsIgnoreCase(addr)) {
signNumber = signNumber + 1;
}
}
@ -3081,12 +3082,13 @@ public class KQReportBiz extends BaseBean {
Integer signNumber = 0;
if (signIdList !=null && signIdList.size() > 0) {
String acqShowAddress = "select showaddress from hrmschedulesign where id in (" + String.join(",", signIdList) + ") ";
String acqShowAddress = "select showaddress,addr 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)) {
String addr = Util.null2String(rs.getString("addr"));
if ("鸿仕达".equals(showaddress) || "hostar".equalsIgnoreCase(showaddress) || "鸿仕达".equals(addr) || "hostar".equalsIgnoreCase(addr)) {
signNumber = signNumber + 1;
}
}

@ -307,7 +307,7 @@ public class PunchOutButtonCmd extends AbstractCommonCommand<Map<String, Object>
" FROM " +
" workflow_requestbase " +
" WHERE " +
" requestid IN ( SELECT requestid FROM " + evectionTableName + " WHERE sqr = '" + userId + "' and ksrq <='" + sqlDate + "' and yjjsrq >='" + sqlDate + "' ) " +
" requestid IN ( SELECT requestid FROM " + evectionTableName + " WHERE (sqr = '" + userId + "' or ','+CAST(nbtxr AS varchar(max))+',' like '%,'+CAST("+userId+" AS varchar(10))+',%') and ksrq <='" + sqlDate + "' and (((sjjsrq is null or sjjsrq = '') and yjjsrq >= '" + sqlDate + "') or (sjjsrq is not null and sjjsrq != '' and sjjsrq >= '" + sqlDate + "'))) " +
// " AND currentnodetype = 3 " +
" UNION all " +
" SELECT " +
@ -315,11 +315,11 @@ public class PunchOutButtonCmd extends AbstractCommonCommand<Map<String, Object>
" FROM " +
" workflow_requestbase " +
" WHERE " +
" requestid IN ( SELECT requestid FROM " + outTableName + " WHERE sqr = '" + userId + "' and ksrq <='" + sqlDate + "' and yjjsrq >='" + sqlDate + "') " +
" requestid IN ( SELECT requestid FROM " + outTableName + " WHERE (sqr = '" + userId + "' or ','+CAST(nbtxr AS varchar(max))+',' like '%,'+CAST("+userId+" AS varchar(10))+',%') and ksrq <='" + sqlDate + "' and (((sjjsrq is null or sjjsrq = '') and yjjsrq >= '" + sqlDate + "') or (sjjsrq is not null and sjjsrq != '' and sjjsrq >= '" + sqlDate + "'))) " +
// " AND currentnodetype = 3 " +
") a ";
rs.executeQuery(acqEvecAndOutSql);
bb.writeLog("acqEvecAndOutSql: " + acqEvecAndOutSql);
rs.executeQuery(acqEvecAndOutSql);
while (rs.next()) {
number = Util.getIntValue(Util.null2String(rs.getString("number")));

@ -48,6 +48,7 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
RecordSet rs = new RecordSet();
String sql = "";
try {
bb.writeLog("ExportDailyExcelCmd start.");
SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo();
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
ResourceComInfo resourceComInfo = new ResourceComInfo();
@ -185,7 +186,12 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
forgotBeginWorkCheck_field = " isnull(b.forgotBeginWorkCheck,0) ";
}
String backFields = " a.id,a.lastname,a.subcompanyid1 as subcompanyid,a.departmentid, a.workcode,b.jobtitle,a.dsporder," +
String backFields = " (select zm.cccb from uf_cbxxjlb zm where zm.xm = a.id and zm.rq = b.kqdate) as mealAllowance," +
" (select zm.zdcb from uf_cbxxjlb zm where zm.xm = a.id and zm.rq = b.kqdate) as statAllowance," +
" (select zm.jmybcb from uf_cbxxjlb zm where zm.xm = a.id and zm.rq = b.kqdate) as nightAllowance," +
" (select zm.hrzdcb from uf_cbxxjlb zm where zm.xm = a.id and zm.rq = b.kqdate) as otherStatAllowance," +
" (select zm.ybbz from uf_cbxxjlb zm where zm.xm = a.id and zm.rq = b.kqdate) as nightShiftSubsidy," +
" a.id,a.lastname,a.subcompanyid1 as subcompanyid,a.departmentid, a.workcode,b.jobtitle,a.dsporder," +
" b.kqdate, b.workdays,b.workMins,b.serialid, b.attendancedays,FLOOR( b.attendanceMins / 30 ) * 30 AS attendanceMins ,b.beLate," +
" b.beLateMins,b.graveBeLate,b.graveBeLateMins,b.leaveEearly,b.leaveEarlyMins,b.graveLeaveEarly," +
" b.graveLeaveEarlyMins,b.absenteeism,b.signdays,b.signmins, "+
@ -232,34 +238,37 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo();
String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey),"0");
long startTime = System.currentTimeMillis();
Map<String,Object> flowData = kqReportBiz.getDailyFlowData(params,user);
/*考勤二开--驻点餐补start*/
HostarUtil hostarUtil = new HostarUtil();
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 shift from uf_nightshiftmanage where isdelete is null or isdelete = 0";
rs.executeQuery(acqSerialSql);
while (rs.next()) {
String serial = Util.null2String(rs.getString("shift"));
if (StringUtils.isNotBlank(serial)) {
nightshifts.add(serial);
}
}
/*考勤二开--夜班餐补end*/
long endTime = System.currentTimeMillis();
long elapsedTime = endTime - startTime; // 执行时间
bb.writeLog("getDailyMealAllowanceData执行时间" + elapsedTime/1000 + "秒");
// /*考勤二开--驻点餐补start*/
// HostarUtil hostarUtil = new HostarUtil();
// 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 shift from uf_nightshiftmanage where isdelete is null or isdelete = 0";
// rs.executeQuery(acqSerialSql);
// while (rs.next()) {
// String serial = Util.null2String(rs.getString("shift"));
// if (StringUtils.isNotBlank(serial)) {
// nightshifts.add(serial);
// }
// }
// /*考勤二开--夜班餐补end*/
bb.writeLog("ExportDailyExcelCmd sql:" + sql);
rs.execute(sql);
while (rs.next()) {
data = new ArrayList<>();
@ -346,13 +355,13 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
fieldValue = Util.null2String(signDetailInfo.get("signoutstatus3"));
data.add(fieldValue);
continue;
} else if (fieldName.equals("mealAllowance")) {//考勤二开--出差餐补
int intValue = Util.getIntValue(Util.null2String(flowData.get("DailyMealAllow|" + resourceId + "|" + kqdate)));
if (intValue < 0) {
intValue = 0;
}
data.add(intValue);
continue;
// } else if (fieldName.equals("mealAllowance")) {//考勤二开--出差餐补
// int intValue = Util.getIntValue(Util.null2String(flowData.get("DailyMealAllow|" + resourceId + "|" + kqdate)));
// if (intValue < 0) {
// intValue = 0;
// }
// data.add(intValue);
// continue;
} else if(fieldName.equals("leave")){
//请假
List<Map<String, Object>> allLeaveRules = KQLeaveRulesBiz.getAllLeaveRules();
@ -451,81 +460,81 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
}catch (Exception e){
}
fieldValue = KQDurationCalculatorUtil.getDurationRound(businessLeave);
} else if ( "mealAllowance".equals(fieldName)) {//考勤二开--出差餐补
int intValue = Util.getIntValue(Util.null2String(flowData.get("DailyMealAllow|" + resourceId + "|" + kqdate)));
if (intValue < 0) {
intValue = 0;
}
data.add(intValue);
continue;
} else if ("statAllowance".equals(fieldName)) {//考勤二开--驻点餐补
String subcompanyId = Util.null2String(rs.getString("subcompanyid"));
if ( !subComoanyList.contains(subcompanyId)) {
params.put("statUser", id);
params.put("kqdate", kqdate);
// bb.writeLog("params: " + params );
long startTime = System.currentTimeMillis();
Map<String, Object> dailyStatAllowanceData = kqReportBiz.getDailyStatAllowanceData(params, user);
long endTime = System.currentTimeMillis();
long elapsedTime = endTime - startTime; // 执行时间
bb.writeLog("执行时间:" + elapsedTime/1000 + "秒");
if (dailyStatAllowanceData == null || dailyStatAllowanceData.size() == 0) {
fieldValue = "0";
} else {
Map<String, Object> tempMap = hostarUtil.parseMapForFilter(dailyStatAllowanceData, id + "|DailyStatAllowance");
double temp = Util.getDoubleValue(Util.null2String(tempMap.get(id + "|DailyStatAllowance" + "|" + kqdate )));
if (temp <= 0) {
fieldValue = "0";
} else {
fieldValue = String.valueOf(temp);
}
}
// bb.writeLog("fieldValue: " + fieldValue);
}
data.add(fieldValue);
continue;
} else if ("nightAllowance".equals(fieldName)) {//考勤二开--夜班餐补
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 ("nightShiftSubsidy".equals(fieldName)) {//考勤二开--夜班补助
params.put("subUserId", id);
// bb.writeLog("params: " + params );
Map<String, Object> temp = kqReportBiz.getDailyNightShiftSubsidyData(params, user);
if (temp == null || temp.size() == 0) {
data.add( "0");
} else {
int intValue = Math.max(Util.getIntValue(Util.null2String(temp.get(id + "|DailyStatAllowance" + kqdate))) , 0);
data.add( intValue);
}
} else if ("otherStatAllowance".equals(fieldName)) {//考勤二开--鸿仁驻点餐补
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 ( "mealAllowance".equals(fieldName)) {//考勤二开--出差餐补
// int intValue = Util.getIntValue(Util.null2String(flowData.get("DailyMealAllow|" + resourceId + "|" + kqdate)));
// if (intValue < 0) {
// intValue = 0;
// }
// data.add(intValue);
// continue;
// } else if ("statAllowance".equals(fieldName)) {//考勤二开--驻点餐补
//
// String subcompanyId = Util.null2String(rs.getString("subcompanyid"));
// if ( !subComoanyList.contains(subcompanyId)) {
//
// params.put("statUser", id);
// params.put("kqdate", kqdate);
//// bb.writeLog("params: " + params );
//
// long startTime = System.currentTimeMillis();
// Map<String, Object> dailyStatAllowanceData = kqReportBiz.getDailyStatAllowanceData(params, user);
// long endTime = System.currentTimeMillis();
// long elapsedTime = endTime - startTime; // 执行时间
// bb.writeLog("执行时间:" + elapsedTime/1000 + "秒");
//
// if (dailyStatAllowanceData == null || dailyStatAllowanceData.size() == 0) {
// fieldValue = "0";
// } else {
// Map<String, Object> tempMap = hostarUtil.parseMapForFilter(dailyStatAllowanceData, id + "|DailyStatAllowance");
//
// double temp = Util.getDoubleValue(Util.null2String(tempMap.get(id + "|DailyStatAllowance" + "|" + kqdate )));
// if (temp <= 0) {
// fieldValue = "0";
// } else {
// fieldValue = String.valueOf(temp);
// }
// }
//
//// bb.writeLog("fieldValue: " + fieldValue);
// }
// data.add(fieldValue);
// continue;
// } else if ("nightAllowance".equals(fieldName)) {//考勤二开--夜班餐补
// 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 ("nightShiftSubsidy".equals(fieldName)) {//考勤二开--夜班补助
// params.put("subUserId", id);
//// bb.writeLog("params: " + params );
//
// Map<String, Object> temp = kqReportBiz.getDailyNightShiftSubsidyData(params, user);
// if (temp == null || temp.size() == 0) {
// data.add( "0");
// } else {
// int intValue = Math.max(Util.getIntValue(Util.null2String(temp.get(id + "|DailyStatAllowance" + kqdate))) , 0);
// data.add( intValue);
// }
//
// } else if ("otherStatAllowance".equals(fieldName)) {//考勤二开--鸿仁驻点餐补
// 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 {
@ -553,6 +562,7 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
retmap.putAll(exportMap);
retmap.put("status", "1");
} catch (Exception e) {
bb.writeLog("ExportDailyExcelCmd error:" + e.getMessage());
retmap.put("status", "-1");
retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage()));
writeLog(e);

@ -206,7 +206,12 @@ public class ExportExcelCmd extends AbstractCommonCommand<Map<String, Object>> {
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," +
String backFields = " (select sum(zm.cccb) from uf_cbxxjlb zm where zm.xm = a.id and zm.rq >= '" + fromDate + "' and zm.rq <= '" + toDate + "') as mealAllowance," +
" (select sum(zm.zdcb) from uf_cbxxjlb zm where zm.xm = a.id and zm.rq >= '" + fromDate + "' and zm.rq <= '" + toDate + "') as statAllowance," +
" (select sum(zm.jmybcb) from uf_cbxxjlb zm where zm.xm = a.id and zm.rq >= '" + fromDate + "' and zm.rq <= '" + toDate + "') as nightAllowance," +
" (select sum(zm.hrzdcb) from uf_cbxxjlb zm where zm.xm = a.id and zm.rq >= '" + fromDate + "' and zm.rq <= '" + toDate + "') as otherStatAllowance," +
" (select sum(zm.ybbz) from uf_cbxxjlb zm where zm.xm = a.id and zm.rq >= '" + fromDate + "' and zm.rq <= '" + toDate + "') as nightShiftSubsidy," +
" 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(FLOOR( b.attendanceMins / 30 ) * 30 ) 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," +
@ -433,99 +438,99 @@ public class ExportExcelCmd extends AbstractCommonCommand<Map<String, Object>> {
}catch (Exception e){
}
fieldValue = KQDurationCalculatorUtil.getDurationRound(businessLeave);
} else if ("mealAllowance".equals(fieldName)) {//考勤二开--出差餐补
// bb.writeLog("mealAllowance");
Map<String, Object> tempMap = hostarUtil.parseMapForFilter(flowData, "DailyMealAllow|" + resourceId);
// bb.writeLog("tempMap: " + tempMap);
if ( !tempMap.isEmpty()) {
int tempValue = 0;
for (String key: tempMap.keySet()) {
int intValue = Util.getIntValue(Util.null2String(tempMap.get(key)));
tempValue = tempValue + (Math.max(intValue, 0));
}
fieldValue = String.valueOf(tempValue);
}
// bb.writeLog("fieldValue: " + fieldValue);
data.add(fieldValue);
continue;
} else if ("statAllowance".equals(fieldName)) {//考勤二开--驻点餐补
// bb.writeLog("statAllowance");
// bb.writeLog("flowData: " + flowData);
params.put("statUser", id);
bb.writeLog("params: " + params );
Map<String, Object> temp = kqReportBiz.getStatAllowanceData(params, user);
if (temp == null || temp.size() == 0) {
data.add( "0");
} else {
Map<String, Object> tempMap = hostarUtil.parseMapForFilter(temp, id + "|StatAllowance");
// 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 + (Math.max(doubleValue, 0.00));
}
fieldValue = String.valueOf(tempValue);
}
// bb.writeLog("fieldValue: " + fieldValue);
data.add( fieldValue);
}
continue;
} else if ("nightAllowance".equals(fieldName)) {//考勤二开--精密夜班餐补
// bb.writeLog("nightAllowance");
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 + (Math.max(doubleValue, 0.00));
}
fieldValue = String.valueOf(tempValue);
}
// bb.writeLog("fieldValue: " + fieldValue);
data.add(fieldValue);
continue;
} else if ("nightShiftSubsidy".equals(fieldName)) {//考勤二开--夜班补助
params.put("subUserId", id);
bb.writeLog("params: " + params );
Map<String, Object> temp = kqReportBiz.getDailyNightShiftSubsidyData(params, user);
if (temp == null || temp.size() == 0) {
data.add( "0");
} else {
Map<String, Object> tempMap = hostarUtil.parseMapForFilter(temp, id + "|DailyNightShiftSubsidyData");
if ( !tempMap.isEmpty()) {
int tempValue = 0;
for (String key: tempMap.keySet()) {
int intValue = Util.getIntValue(Util.null2String(tempMap.get(key)));
tempValue = tempValue + (Math.max(intValue, 0));
}
fieldValue = String.valueOf(tempValue);
}
data.add( fieldValue);
}
continue;
} else if ("otherStatAllowance".equals(fieldName)) {//考勤二开--鸿仁驻点餐补
// bb.writeLog("otherStatAllowance");
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);
}
// bb.writeLog("fieldValue: " + fieldValue);
data.add(fieldValue);
continue;
// } else if ("mealAllowance".equals(fieldName)) {//考勤二开--出差餐补
//// bb.writeLog("mealAllowance");
// Map<String, Object> tempMap = hostarUtil.parseMapForFilter(flowData, "DailyMealAllow|" + resourceId);
//// bb.writeLog("tempMap: " + tempMap);
//
// if ( !tempMap.isEmpty()) {
// int tempValue = 0;
// for (String key: tempMap.keySet()) {
// int intValue = Util.getIntValue(Util.null2String(tempMap.get(key)));
// tempValue = tempValue + (Math.max(intValue, 0));
// }
// fieldValue = String.valueOf(tempValue);
// }
//// bb.writeLog("fieldValue: " + fieldValue);
// data.add(fieldValue);
// continue;
// } else if ("statAllowance".equals(fieldName)) {//考勤二开--驻点餐补
//// bb.writeLog("statAllowance");
//// bb.writeLog("flowData: " + flowData);
// params.put("statUser", id);
// bb.writeLog("params: " + params );
//
// Map<String, Object> temp = kqReportBiz.getStatAllowanceData(params, user);
// if (temp == null || temp.size() == 0) {
// data.add( "0");
// } else {
// Map<String, Object> tempMap = hostarUtil.parseMapForFilter(temp, id + "|StatAllowance");
//
//// 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 + (Math.max(doubleValue, 0.00));
// }
// fieldValue = String.valueOf(tempValue);
// }
//// bb.writeLog("fieldValue: " + fieldValue);
// data.add( fieldValue);
// }
// continue;
// } else if ("nightAllowance".equals(fieldName)) {//考勤二开--精密夜班餐补
//// bb.writeLog("nightAllowance");
// 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 + (Math.max(doubleValue, 0.00));
// }
// fieldValue = String.valueOf(tempValue);
// }
//// bb.writeLog("fieldValue: " + fieldValue);
// data.add(fieldValue);
// continue;
// } else if ("nightShiftSubsidy".equals(fieldName)) {//考勤二开--夜班补助
// params.put("subUserId", id);
// bb.writeLog("params: " + params );
//
// Map<String, Object> temp = kqReportBiz.getDailyNightShiftSubsidyData(params, user);
// if (temp == null || temp.size() == 0) {
// data.add( "0");
// } else {
// Map<String, Object> tempMap = hostarUtil.parseMapForFilter(temp, id + "|DailyNightShiftSubsidyData");
//
// if ( !tempMap.isEmpty()) {
// int tempValue = 0;
// for (String key: tempMap.keySet()) {
// int intValue = Util.getIntValue(Util.null2String(tempMap.get(key)));
// tempValue = tempValue + (Math.max(intValue, 0));
// }
// fieldValue = String.valueOf(tempValue);
// }
// data.add( fieldValue);
// }
// continue;
// } else if ("otherStatAllowance".equals(fieldName)) {//考勤二开--鸿仁驻点餐补
//// bb.writeLog("otherStatAllowance");
// 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);
// }
//// bb.writeLog("fieldValue: " + fieldValue);
// 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);

@ -145,7 +145,12 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Objec
forgotBeginWorkCheck_field = " isnull(b.forgotBeginWorkCheck,0) ";
}
String backFields = " a.id,a.lastname,a.subcompanyid1 as subcompanyid,a.departmentid, a.workcode,b.jobtitle,a.dsporder," +
String backFields = " (select zm.cccb from uf_cbxxjlb zm where zm.xm = a.id and zm.rq = b.kqdate) as mealAllowance," +
" (select zm.zdcb from uf_cbxxjlb zm where zm.xm = a.id and zm.rq = b.kqdate) as statAllowance," +
" (select zm.jmybcb from uf_cbxxjlb zm where zm.xm = a.id and zm.rq = b.kqdate) as nightAllowance," +
" (select zm.hrzdcb from uf_cbxxjlb zm where zm.xm = a.id and zm.rq = b.kqdate) as otherStatAllowance," +
" (select zm.ybbz from uf_cbxxjlb zm where zm.xm = a.id and zm.rq = b.kqdate) as nightShiftSubsidy," +
" a.id,a.lastname,a.subcompanyid1 as subcompanyid,a.departmentid, a.workcode,b.jobtitle,a.dsporder," +
" b.kqdate, b.workdays,b.workMins,b.serialid, b.attendancedays,FLOOR( b.attendanceMins / 30 ) * 30 AS attendanceMins," +
" b.beLate,b.beLateMins,b.graveBeLate,b.graveBeLateMins,b.leaveEearly,b.leaveEarlyMins," +
" b.signdays,b.signmins, "+
@ -243,31 +248,31 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Objec
KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo();
String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey),"0");
/*考勤二开--驻点餐补start*/
HostarUtil hostarUtil = new HostarUtil();
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 shift from uf_nightshiftmanage where isdelete is null or isdelete = 0";
rs.executeQuery(acqSerialSql);
while (rs.next()) {
String serial = Util.null2String(rs.getString("shift"));
if (StringUtils.isNotBlank(serial)) {
nightshifts.add(serial);
}
}
/*考勤二开--夜班餐补end*/
// /*考勤二开--驻点餐补start*/
// HostarUtil hostarUtil = new HostarUtil();
// 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 shift from uf_nightshiftmanage where isdelete is null or isdelete = 0";
// rs.executeQuery(acqSerialSql);
// while (rs.next()) {
// String serial = Util.null2String(rs.getString("shift"));
// if (StringUtils.isNotBlank(serial)) {
// nightshifts.add(serial);
// }
// }
// /*考勤二开--夜班餐补end*/
bb.writeLog("每日报表sql: " + sql);
@ -358,89 +363,89 @@ 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")) {//考勤二开--出差餐补
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)) {
params.put("statUser", id);
params.put("kqdate", kqdate);
bb.writeLog("params: " + params );
// long startTime = System.currentTimeMillis();
Map<String, Object> dailyStatAllowanceData = kqReportBiz.getDailyStatAllowanceData(params, user);
// long endTime = System.currentTimeMillis();
// long elapsedTime = endTime - startTime; // 执行时间
// bb.writeLog("执行时间:" + elapsedTime/1000 + "秒");
if (dailyStatAllowanceData == null || dailyStatAllowanceData.size() == 0) {
fieldValue = "0";
} else {
Map<String, Object> tempMap = hostarUtil.parseMapForFilter(dailyStatAllowanceData, id + "|DailyStatAllowance");
// bb.writeLog("-=-=tempMap: " + tempMap);
// bb.writeLog("-=-=tempMap.key: " + id + "|DailyStatAllowance" + "|" + kqdate);
double temp = Util.getDoubleValue(Util.null2String(tempMap.get(id + "|DailyStatAllowance" + "|" + kqdate )));
// bb.writeLog("-=-=temp: " + temp);
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)) {
// String key= id + "|DailyNightShiftAllowanceData" + "|" + kqdate;
// bb.writeLog("nightAllowance key: " + key );
double temp = Util.getDoubleValue(Util.null2String(flowData.get(id + "|DailyNightShiftAllowanceData" + "|" + kqdate )));
// bb.writeLog("nightAllowance temp: " + temp );
// bb.writeLog("nightAllowance kqdate: " + kqdate );
if (temp <= 0.00) {
fieldValue = "0";
} else {
fieldValue = String.valueOf(temp);
}
// bb.writeLog("fieldValue: " + fieldValue);
}
data.put(fieldName, fieldValue);
} else if ("nightShiftSubsidy".equals(fieldName)) {//考勤二开--夜班补助
params.put("subUserId", id);
bb.writeLog("params: " + params );
Map<String, Object> temp = kqReportBiz.getDailyNightShiftSubsidyData(params, user);
// bb.writeLog("nightShiftSubsidy temp: " + temp );
// bb.writeLog("nightShiftSubsidy temp.size: " + temp.size() );
// String key = id + "|DailyNightShiftSubsidyData" + kqdate;
// bb.writeLog("nightShiftSubsidy key: " + key );
if (temp == null || temp.size() == 0) {
data.put(fieldName, "0");
} else {
double doubleValue = Math.max(Util.getDoubleValue(Util.null2String(temp.get(id + "|DailyNightShiftSubsidyData|" + kqdate))) , 0.00);
// bb.writeLog("nightShiftSubsidy doubleValue: " + doubleValue );
// bb.writeLog("nightShiftSubsidy kqdate: " + kqdate );
data.put(fieldName, doubleValue);
}
} else if (fieldName.equals("otherStatAllowance")) {//考勤二开--鸿仁驻点餐补
double temp = Util.getDoubleValue(Util.null2String(flowData.get(id + "|DailyOtherStatAllowance" + "|" + kqdate )));
if (temp <= 0.00) {
fieldValue = "0";
} else {
fieldValue = String.valueOf(temp);
}
// bb.writeLog("fieldValue: " + fieldValue);
data.put(fieldName, fieldValue);
// } 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)) {
//
// params.put("statUser", id);
// params.put("kqdate", kqdate);
// bb.writeLog("params: " + params );
//
//// long startTime = System.currentTimeMillis();
// Map<String, Object> dailyStatAllowanceData = kqReportBiz.getDailyStatAllowanceData(params, user);
//// long endTime = System.currentTimeMillis();
//// long elapsedTime = endTime - startTime; // 执行时间
//// bb.writeLog("执行时间:" + elapsedTime/1000 + "秒");
//
// if (dailyStatAllowanceData == null || dailyStatAllowanceData.size() == 0) {
// fieldValue = "0";
// } else {
// Map<String, Object> tempMap = hostarUtil.parseMapForFilter(dailyStatAllowanceData, id + "|DailyStatAllowance");
//// bb.writeLog("-=-=tempMap: " + tempMap);
//// bb.writeLog("-=-=tempMap.key: " + id + "|DailyStatAllowance" + "|" + kqdate);
// double temp = Util.getDoubleValue(Util.null2String(tempMap.get(id + "|DailyStatAllowance" + "|" + kqdate )));
//// bb.writeLog("-=-=temp: " + temp);
// 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)) {
//// String key= id + "|DailyNightShiftAllowanceData" + "|" + kqdate;
//// bb.writeLog("nightAllowance key: " + key );
// double temp = Util.getDoubleValue(Util.null2String(flowData.get(id + "|DailyNightShiftAllowanceData" + "|" + kqdate )));
//// bb.writeLog("nightAllowance temp: " + temp );
//// bb.writeLog("nightAllowance kqdate: " + kqdate );
// if (temp <= 0.00) {
// fieldValue = "0";
// } else {
// fieldValue = String.valueOf(temp);
// }
//// bb.writeLog("fieldValue: " + fieldValue);
// }
// data.put(fieldName, fieldValue);
// } else if ("nightShiftSubsidy".equals(fieldName)) {//考勤二开--夜班补助
// params.put("subUserId", id);
// bb.writeLog("params: " + params );
//
// Map<String, Object> temp = kqReportBiz.getDailyNightShiftSubsidyData(params, user);
//// bb.writeLog("nightShiftSubsidy temp: " + temp );
//// bb.writeLog("nightShiftSubsidy temp.size: " + temp.size() );
//// String key = id + "|DailyNightShiftSubsidyData" + kqdate;
//// bb.writeLog("nightShiftSubsidy key: " + key );
// if (temp == null || temp.size() == 0) {
// data.put(fieldName, "0");
// } else {
// double doubleValue = Math.max(Util.getDoubleValue(Util.null2String(temp.get(id + "|DailyNightShiftSubsidyData|" + kqdate))) , 0.00);
//// bb.writeLog("nightShiftSubsidy doubleValue: " + doubleValue );
//// bb.writeLog("nightShiftSubsidy kqdate: " + kqdate );
// data.put(fieldName, doubleValue);
// }
//
// } else if (fieldName.equals("otherStatAllowance")) {//考勤二开--鸿仁驻点餐补
// double temp = Util.getDoubleValue(Util.null2String(flowData.get(id + "|DailyOtherStatAllowance" + "|" + kqdate )));
// if (temp <= 0.00) {
// 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) {
@ -509,7 +514,7 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Objec
retmap.put("ishavepre", isHavePre);
retmap.put("ishavenext", isHaveNext);
}catch (Exception e){
writeLog(e);
bb.writeLog("GetKQDailyReportCmd error:" + e.getMessage());
}
bb.writeLog("GetKQDailyReportCmd end.");
return retmap;

@ -39,6 +39,7 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
RecordSet rs = new RecordSet();
String sql = "";
try{
bb.writeLog("GetKQReportCmd start.");
String pageUid = PageUidFactory.getHrmPageUid("KQReport");
SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo();
@ -172,7 +173,12 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
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," +
String backFields = " (select sum(zm.cccb) from uf_cbxxjlb zm where zm.xm = a.id and zm.rq >= '" + fromDate + "' and zm.rq <= '" + toDate + "') as mealAllowance," +
" (select sum(zm.zdcb) from uf_cbxxjlb zm where zm.xm = a.id and zm.rq >= '" + fromDate + "' and zm.rq <= '" + toDate + "') as statAllowance," +
" (select sum(zm.jmybcb) from uf_cbxxjlb zm where zm.xm = a.id and zm.rq >= '" + fromDate + "' and zm.rq <= '" + toDate + "') as nightAllowance," +
" (select sum(zm.hrzdcb) from uf_cbxxjlb zm where zm.xm = a.id and zm.rq >= '" + fromDate + "' and zm.rq <= '" + toDate + "') as otherStatAllowance," +
" (select sum(zm.ybbz) from uf_cbxxjlb zm where zm.xm = a.id and zm.rq >= '" + fromDate + "' and zm.rq <= '" + toDate + "') as nightShiftSubsidy," +
" 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(FLOOR( b.attendanceMins / 30 ) * 30 ) 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," +
@ -435,99 +441,99 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
} else{
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id+"|"+fieldName)));
}
} else if ("mealAllowance".equals(fieldName)) {//考勤二开--出差餐补
// bb.writeLog("mealAllowance");
Map<String, Object> tempMap = hostarUtil.parseMapForFilter(flowData, "DailyMealAllow|" + resourceId);
// bb.writeLog("tempMap: " + tempMap);
if ( !tempMap.isEmpty()) {
int tempValue = 0;
for (String key: tempMap.keySet()) {
int intValue = Util.getIntValue(Util.null2String(tempMap.get(key)));
tempValue = tempValue + (Math.max(intValue, 0));
}
fieldValue = String.valueOf(tempValue);
}
// bb.writeLog("fieldValue: " + fieldValue);
data.put(fieldName, fieldValue);
} else if ("statAllowance".equals(fieldName)) {//考勤二开--驻点餐补
bb.writeLog("statAllowance");
params.put("statUser", id);
bb.writeLog("params: " + params );
Map<String, Object> temp = kqReportBiz.getStatAllowanceData(params, user);
if (temp == null || temp.size() == 0) {
data.put(fieldName, "0");
} else {
Map<String, Object> tempMap = hostarUtil.parseMapForFilter(temp, id + "|StatAllowance");
// 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 + (Math.max(doubleValue, 0.00));
}
fieldValue = String.valueOf(tempValue);
}
// bb.writeLog("fieldValue: " + fieldValue);
data.put(fieldName, fieldValue);
}
} else if ("nightAllowance".equals(fieldName)) {//考勤二开--精密夜班餐补
// bb.writeLog("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 + (Math.max(doubleValue, 0.00));
}
fieldValue = String.valueOf(tempValue);
}
// bb.writeLog("fieldValue: " + fieldValue);
data.put(fieldName, fieldValue);
} else if ("nightShiftSubsidy".equals(fieldName)) {//考勤二开--夜班补助
params.put("subUserId", id);
bb.writeLog("params: " + params );
Map<String, Object> temp = kqReportBiz.getDailyNightShiftSubsidyData(params, user);
if (temp == null || temp.size() == 0) {
data.put(fieldName, "0");
} else {
Map<String, Object> tempMap = hostarUtil.parseMapForFilter(temp, id + "|DailyNightShiftSubsidyData");
if ( !tempMap.isEmpty()) {
int tempValue = 0;
for (String key: tempMap.keySet()) {
int intValue = Util.getIntValue(Util.null2String(tempMap.get(key)));
tempValue = tempValue + (Math.max(intValue, 0));
}
fieldValue = String.valueOf(tempValue);
}
data.put(fieldName, fieldValue);
}
} else if ("otherStatAllowance".equals(fieldName)) {//考勤二开--鸿仁驻点餐补
// bb.writeLog("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 + (Math.max(doubleValue, 0.00));
}
fieldValue = String.valueOf(tempValue);
}
// bb.writeLog("fieldValue: " + fieldValue);
data.put(fieldName, fieldValue);
// } else if ("mealAllowance".equals(fieldName)) {//考勤二开--出差餐补
//// bb.writeLog("mealAllowance");
// Map<String, Object> tempMap = hostarUtil.parseMapForFilter(flowData, "DailyMealAllow|" + resourceId);
//// bb.writeLog("tempMap: " + tempMap);
//
// if ( !tempMap.isEmpty()) {
// int tempValue = 0;
// for (String key: tempMap.keySet()) {
// int intValue = Util.getIntValue(Util.null2String(tempMap.get(key)));
// tempValue = tempValue + (Math.max(intValue, 0));
// }
// fieldValue = String.valueOf(tempValue);
// }
//// bb.writeLog("fieldValue: " + fieldValue);
// data.put(fieldName, fieldValue);
// } else if ("statAllowance".equals(fieldName)) {//考勤二开--驻点餐补
// bb.writeLog("statAllowance");
//
// params.put("statUser", id);
// bb.writeLog("params: " + params );
//
// Map<String, Object> temp = kqReportBiz.getStatAllowanceData(params, user);
// if (temp == null || temp.size() == 0) {
// data.put(fieldName, "0");
// } else {
// Map<String, Object> tempMap = hostarUtil.parseMapForFilter(temp, id + "|StatAllowance");
//
//// 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 + (Math.max(doubleValue, 0.00));
// }
// fieldValue = String.valueOf(tempValue);
// }
//// bb.writeLog("fieldValue: " + fieldValue);
// data.put(fieldName, fieldValue);
// }
//
//
// } else if ("nightAllowance".equals(fieldName)) {//考勤二开--精密夜班餐补
//// bb.writeLog("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 + (Math.max(doubleValue, 0.00));
// }
// fieldValue = String.valueOf(tempValue);
// }
//// bb.writeLog("fieldValue: " + fieldValue);
// data.put(fieldName, fieldValue);
// } else if ("nightShiftSubsidy".equals(fieldName)) {//考勤二开--夜班补助
// params.put("subUserId", id);
// bb.writeLog("params: " + params );
//
// Map<String, Object> temp = kqReportBiz.getDailyNightShiftSubsidyData(params, user);
// if (temp == null || temp.size() == 0) {
// data.put(fieldName, "0");
// } else {
// Map<String, Object> tempMap = hostarUtil.parseMapForFilter(temp, id + "|DailyNightShiftSubsidyData");
//
// if ( !tempMap.isEmpty()) {
// int tempValue = 0;
// for (String key: tempMap.keySet()) {
// int intValue = Util.getIntValue(Util.null2String(tempMap.get(key)));
// tempValue = tempValue + (Math.max(intValue, 0));
// }
// fieldValue = String.valueOf(tempValue);
// }
// data.put(fieldName, fieldValue);
// }
//
// } else if ("otherStatAllowance".equals(fieldName)) {//考勤二开--鸿仁驻点餐补
//// bb.writeLog("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 + (Math.max(doubleValue, 0.00));
// }
// fieldValue = String.valueOf(tempValue);
// }
//// bb.writeLog("fieldValue: " + fieldValue);
// data.put(fieldName, fieldValue);
} else {
fieldValue = Util.null2String(rs.getString(fieldName));
if(Util.null2String(kqReportFieldComInfo.getUnittype()).length()>0) {
@ -611,7 +617,7 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
retmap.put("ishavenext", isHaveNext);
}catch (Exception e){
writeLog(e);
bb.writeLog("GetKQReportCmd Exception: " + e);
bb.writeLog("GetKQReportCmd Exception: " + e.getMessage());
}
return retmap;
}

@ -22,6 +22,8 @@ public class OutSignSyncAction implements Action {
String startDate = "";
String endDate = "";
String resourceid = "";
String nbtxr = "";
String sjjsrq = "";
try {
@ -36,16 +38,30 @@ public class OutSignSyncAction implements Action {
if ("sjccr".equals(property.getName())) {
resourceid = Util.null2String(property.getValue());
}
if ("nbtxr".equals(property.getName())) {
nbtxr = Util.null2String(property.getValue());
}
if ("sjjsrq".equals(property.getName())) {
sjjsrq = Util.null2String(property.getValue());
}
}
// 如果实际结束日期不为空,则用实际结束日期
if (StringUtils.isNotBlank(sjjsrq)) {
endDate = sjjsrq;
}
if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate) && StringUtils.isNotBlank(resourceid)) {
// 内部同行人也要考虑
if (StringUtils.isNotBlank(nbtxr)) {
resourceid = resourceid + "," + nbtxr;
}
RecordSet rs = new RecordSet();
List<String> infos = new ArrayList<>();
String acqOutSignSql = "select a.id, c.signinfo " +
"from mobile_sign a " +
"left join uf_outsigntype c " +
"on c.outsignid = a.id " +
"where operate_date > '" + startDate + "' and operate_date < '" + endDate + "' and operate = ? ";
"where operate_date > '" + startDate + "' and operate_date < '" + endDate + "' and operate in (?) ";
rs.executeQuery(acqOutSignSql, resourceid);
while (rs.next()) {
String signinfo = Util.null2String(rs.getString("signinfo"));

@ -0,0 +1,98 @@
package weaver.interfaces.hostar.job;
import cn.hutool.core.date.DateUtil;
import com.engine.hostar.thread.HandleCBDataThread;
import com.engine.hostar.util.HostarUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.ThreadPoolUtil;
import weaver.interfaces.schedule.BaseCronJob;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.ExecutorService;
/**
* @version 1.0
* @Title ecology-9
* @Company
* @CreateDate 2024/3/12
* @Description
* @Author AdminZm
*/
public class UpdateCbxxjlDataJob extends BaseCronJob {
BaseBean baseBean = new BaseBean();
private String ryParam;
private String startDate;
private String endDate;
@Override
public void execute() {
baseBean.writeLog("UpdateCbxxjlDataJob start, param is:" + ryParam + "、" + startDate + "、" + endDate);
try {
String today = DateUtil.format(new Date(), "yyyy-MM-dd");
if (StringUtils.isEmpty(endDate)) {
endDate = today;
}
if (StringUtils.isEmpty(startDate)) {
startDate = today;
}
String date1 = String.valueOf(startDate);
String date2 = String.valueOf(endDate);
List<String> allDates = getAllDates(date1, date2);
baseBean.writeLog("UpdateCbxxjlDataJob allDatas:" + allDates);
RecordSet rs = new RecordSet();
List<String> userIds = new ArrayList<>();
if (StringUtils.isEmpty(ryParam) || StringUtils.equals(ryParam, "null")) {
baseBean.writeLog("1111.");
rs.executeQuery("select id from hrmresource");
while (rs.next()) {
userIds.add(rs.getString("id"));
}
} else {
baseBean.writeLog("2222.");
rs.executeQuery("select id from hrmresource where workcode = ?", ryParam);
while (rs.next()) {
userIds.add(rs.getString("id"));
}
}
baseBean.writeLog("userIds:" + userIds);
if ((CollectionUtils.isEmpty(userIds) && userIds.isEmpty()) || (CollectionUtils.isEmpty(allDates) && allDates.isEmpty())) {
baseBean.writeLog("no user or date.");
return;
}
ExecutorService executorService = ThreadPoolUtil.getThreadPool(null, null);
for (String userId : userIds) {
for (String kqDate : allDates) {
executorService.execute(new HandleCBDataThread(userId, kqDate));
}
}
if (executorService.isTerminated()) {
executorService.shutdown();
}
} catch (Exception e) {
baseBean.writeLog("UpdateCbxxjlDataJob error:" + e.getMessage());
}
}
public List<String> getAllDates(String startDate, String endDate) {
List<String> result = new ArrayList<>();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate start = LocalDate.parse(startDate, formatter);
LocalDate end = LocalDate.parse(endDate, formatter);
while (!start.isAfter(end)) {
result.add(start.format(formatter));
start = start.plusDays(1);
}
return result;
}
}
Loading…
Cancel
Save