Compare commits

..

No commits in common. 'dev' and 'dev-chenwnj' have entirely different histories.

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

@ -53,14 +53,4 @@ 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,6 +14,4 @@ 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,22 +3,18 @@ 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
@ -272,70 +268,4 @@ 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;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -380,34 +380,19 @@ 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 + "秒");
datas.putAll(getDailyMealAllowanceData(params,user));
/*考勤二开--出差公出流程餐补统计end*/
// /*考勤二开--计算驻点餐补start*/
// datas.putAll(getDailyStatAllowanceData(params,user));
// /*考勤二开--计算驻点餐补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 + "秒");
/*考勤二开--计算精密夜班餐补start*/
datas.putAll(getDailyNightShiftAllowanceData(params,user));
/*考勤二开--计算精密夜班餐补end*/
/*考勤二开--计算鸿仁驻点餐补start*/
datas.putAll(getDailyOtherStatAllowanceData(params,user));
/*考勤二开--计算鸿仁驻点餐补end*/
@ -432,7 +417,7 @@ public class KQReportBiz extends BaseBean {
/*考勤二开--出差公出流程餐补统计start*/
// datas.putAll(getDailyMealAllowanceData(params,user));
datas.putAll(getDailyMealAllowanceData(params,user));
/*考勤二开--出差公出流程餐补统计end*/
/*考勤二开--计算驻点餐补start*/
@ -444,11 +429,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*/
@ -1361,7 +1346,7 @@ public class KQReportBiz extends BaseBean {
legWorkInfos.add(temp);
}
}
// bb.writeLog("legWorkInfos: " + legWorkInfos);
bb.writeLog("legWorkInfos: " + legWorkInfos);
if (legWorkInfos != null && legWorkInfos.size() > 0 ) {
String tempSignIn = "";
@ -1441,13 +1426,13 @@ public class KQReportBiz extends BaseBean {
// bb.writeLog("radius: " + radius);
String MealAlloTableName = Util.null2String(bb.getPropValue("project_hostar", "MealAllowanceTableName"));
// bb.writeLog("MealAlloTableName: " + MealAlloTableName);
bb.writeLog("MealAlloTableName: " + MealAlloTableName);
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);
bb.writeLog("acqTimeSql: " + acqTimeSql);
rs.executeQuery(acqTimeSql);
while (rs.next()) {
String startTime = Util.null2String(rs.getString("startTime"));
@ -1457,7 +1442,7 @@ public class KQReportBiz extends BaseBean {
temp.put("endTime",endTime);
MealMap.add(temp);
}
// bb.writeLog("MealMap: " + MealMap);
bb.writeLog("MealMap: " + MealMap);
//根据外勤打卡数据计算餐补数据
for (String key: lsCheckInfo.keySet()) {
@ -1521,7 +1506,7 @@ public class KQReportBiz extends BaseBean {
writeLog(e);
}
// bb.writeLog("datas: " + datas);
bb.writeLog("datas: " + datas);
return datas;
}
@ -1584,7 +1569,7 @@ public class KQReportBiz extends BaseBean {
//获取加班时长
Map<String, Object> dailyFlowOverTimeData = getDailyFlowOverTimeDataAllowance(params, user);
// bb.writeLog("dailyFlowOverTimeData: " + dailyFlowOverTimeData);
bb.writeLog("dailyFlowOverTimeData: " + dailyFlowOverTimeData);
String otherstatsub = Util.null2String(bb.getPropValue("project_hostar", "otherstatsubcompany"));
if (StringUtils.isNotBlank(otherstatsub)) {
@ -1771,251 +1756,7 @@ public class KQReportBiz extends BaseBean {
writeLog(e);
bb.writeLog("DailyOtherStatAllowance Exception: " + e);
}
// bb.writeLog("DailyOtherStatAllowance datas: " + datas);
return datas;
}
public Map<String,Object> getDailyOtherStatAllowanceDataTemp(Map<String,Object> params, User user, Map<String, Object> dailyFlowOverTimeData){
Map<String,Object> datas = new HashMap<>();;
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try{
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
String fromDate = Util.null2String(jsonObj.get("fromDate"));
String toDate = Util.null2String(jsonObj.get("toDate"));
String typeselect =Util.null2String(jsonObj.get("typeselect"));
if(typeselect.length()==0)typeselect = "3";
if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){
if(typeselect.equals("1")){
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
}else{
fromDate = TimeUtil.getDateByOption(typeselect,"0");
toDate = TimeUtil.getDateByOption(typeselect,"1");
}
}
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
String departmentId = Util.null2String(jsonObj.get("departmentId"));
String resourceId = Util.null2String(jsonObj.get("resourceId"));
String allLevel = Util.null2String(jsonObj.get("allLevel"));
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
String viewScope = Util.null2String(jsonObj.get("viewScope"));
if(subCompanyId.length()>0){
sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") ";
}
if(departmentId.length()>0){
sqlWhere +=" and a.departmentid in("+departmentId+") ";
}
if(resourceId.length()>0){
sqlWhere +=" and a.id in("+resourceId+") ";
}
if(viewScope.equals("4")){//我的下属
if(allLevel.equals("1")){//所有下属
sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
}else{
sqlWhere+=" and a.managerid="+user.getUID();//直接下属
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
}
//获取加班时长
// Map<String, Object> dailyFlowOverTimeData = getDailyFlowOverTimeDataAllowance(params, user);
// bb.writeLog("dailyFlowOverTimeData: " + dailyFlowOverTimeData);
String otherstatsub = Util.null2String(bb.getPropValue("project_hostar", "otherstatsubcompany"));
if (StringUtils.isNotBlank(otherstatsub)) {
//查询该分部下的人员
List<String> resIds = new ArrayList<>();
sqlWhere += " and a.subcompanyid1 in (" + otherstatsub + ") ";
String acqResSql = "select a.id from hrmresource a where a.status in (0,1,2,3) " + sqlWhere;
bb.writeLog("acqResSql: " + acqResSql);
rs.executeQuery(acqResSql);
while (rs.next()) {
String id = Util.null2String(rs.getString("id"));
if (StringUtils.isNotBlank(id)) {
resIds.add(id);
}
}
bb.writeLog("resIds: " + resIds);
if (resIds != null && resIds.size() > 0 && StringUtils.isNotBlank(fromDate) && StringUtils.isNotBlank(toDate)) {
HostarUtil houtil = new HostarUtil();
List<String> allDates = houtil.getAllDates(fromDate, toDate);
bb.writeLog("allDates: " + allDates);
//先获取到出勤时长
Map<String, Double> attendanceMinsMap = new HashMap<>();
String acqAttenSql = " select resourceid, attendancemins, kqdate from kq_format_total where resourceid in (" + String.join(",", resIds) + ") and kqdate >='" + fromDate + "' and kqdate <='" + toDate + "'";
rs.executeQuery(acqAttenSql);
while (rs.next()) {
String resourceid = Util.null2String(rs.getString("resourceid"));
Double attendancemins = Util.getDoubleValue(Util.null2String(rs.getString("attendancemins")));
String kqdate = Util.null2String(rs.getString("kqdate"));
if (attendancemins >= 0.00) {
attendanceMinsMap.put(resourceid + "|" + kqdate, attendancemins);
}
}
List<String> removeRes = new ArrayList<>();
String acqNoOtherStatAllResSql = "select resourceid from uf_NoOtherStatAllRe where isdelete is null or isdelete = 0 ";
rs.executeQuery(acqNoOtherStatAllResSql);
while (rs.next()){
String resourceid = Util.null2String(rs.getString("resourceid"));
if (StringUtils.isNotBlank(resourceid) ) {
removeRes.add(resourceid);
}
}
if ( removeRes != null && removeRes.size() > 0 ) {
resIds.removeIf(removeRes::contains);
}
for (String date : allDates) {
for (String res : resIds) {
//获取考勤打卡
Map<String, Object> otherinfo = new HashMap<>();//存一些用得到的信息
String uuid = UUID.randomUUID().toString();
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
ArrayList<String> hostIps = InitServer.getRealIp();//获取IP
boolean oneSign = false;//一天一段出勤时间段
List<TimeScopeEntity> lsSignTime = new ArrayList<>();
List<TimeScopeEntity> lsWorkTime = new ArrayList<>();
// List<TimeScopeEntity> lsRestTime = new ArrayList<>();
KQWorkTime kqWorkTime = new KQWorkTime();
kqWorkTime.setIsFormat(true);
WorkTimeEntity workTime = kqWorkTime.getWorkTime(res, date);
String preDate = DateUtil.addDate(date, -1);//上一天日期
String nextDate = DateUtil.addDate(date, 1);//下一天日期
if (workTime != null) {
lsSignTime = workTime.getSignTime();//允许打卡时间
lsWorkTime = workTime.getWorkTime();//工作时间
// lsRestTime = workTime.getRestTime();//休息时段时间
oneSign = lsWorkTime != null && lsWorkTime.size() == 1;
}
int shiftCount = lsWorkTime == null ? 0 : lsWorkTime.size();
int shiftI = 0;
List<Object> lsCheckInfo = new ArrayList<>();
for (int i = 0; lsWorkTime != null && i < lsWorkTime.size(); i++) {
shiftI = i;
TimeScopeEntity signTimeScope = lsSignTime.get(i);
TimeScopeEntity workTimeScope = lsWorkTime.get(i);
Map<String, String> shifRuleMap = Maps.newHashMap();
String workBeginTime = Util.null2String(workTimeScope.getBeginTime());
int workBeginIdx = kqTimesArrayComInfo.getArrayindexByTimes(workBeginTime);
String workEndTime = Util.null2String(workTimeScope.getEndTime());
int workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(workEndTime);
boolean workEndTimeAcross = workTimeScope.getEndTimeAcross();
if (oneSign) {
//个性化设置只支持一天一次上下班
ShiftInfoBean shiftInfoBean = new ShiftInfoBean();
shiftInfoBean.setSplitDate(date);
shiftInfoBean.setShiftRuleMap(workTime.getShiftRuleInfo());
shiftInfoBean.setSignTime(lsSignTime);
shiftInfoBean.setWorkTime(lsWorkTime);
List<String> logList = Lists.newArrayList();
KQShiftRuleInfoBiz.getShiftRuleInfo(shiftInfoBean, res, shifRuleMap, logList);
if (!shifRuleMap.isEmpty()) {
if (!logList.isEmpty()) {
otherinfo.put("logList", logList);
}
otherinfo.put("shiftRule", shifRuleMap);
if (shifRuleMap.containsKey("shift_beginworktime")) {
String shift_beginworktime = Util.null2String(shifRuleMap.get("shift_beginworktime"));
if (shift_beginworktime.length() > 0) {
workBeginTime = Util.null2String(shift_beginworktime);
workBeginIdx = kqTimesArrayComInfo.getArrayindexByTimes(workBeginTime);
workTimeScope.setBeginTime(workBeginTime);
workTimeScope.setBeginTimeAcross(workBeginIdx >= 1440 ? true : false);
}
}
if (shifRuleMap.containsKey("shift_endworktime")) {
String shift_endworktime = Util.null2String(shifRuleMap.get("shift_endworktime"));
if (shift_endworktime.length() > 0) {
workEndTime = Util.null2String(shift_endworktime);
workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(workEndTime);
workTimeScope.setEndTime(workEndTime);
workTimeScope.setEndTimeAcross(workEndIdx >= 1440 ? true : false);
}
}
}
}
lsCheckInfo = new KQFormatSignData().getSignInfo(res, signTimeScope, workTimeScope, date, preDate, nextDate, kqTimesArrayComInfo, hostIps, uuid, shiftCount, shiftI);
}
List<String> signIdList = new ArrayList<>();
for (int i = 0; i < lsCheckInfo.size(); i++) {
Object o = lsCheckInfo.get(i);
if ( o != null && o != "") {
Map<String, Object> temp = (Map<String, Object>) o;
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 from hrmschedulesign where id in (" + String.join(",", signIdList) + ") ";
// bb.writeLog("acqShowAddress: " + acqShowAddress);
rs.executeQuery(acqShowAddress);
while (rs.next()) {
String showaddress = Util.null2String(rs.getString("showaddress"));
if ("鸿仕达".equals(showaddress) || "hostar".equalsIgnoreCase(showaddress)) {
signNumber = signNumber + 1;
}
}
}
if (signNumber == 0) {
double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|workingDayOvertime_4leave")));
workingDayOvertime_4leave = workingDayOvertime_4leave < 0 ? 0 : workingDayOvertime_4leave;
double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|restDayOvertime_4leave")));
restDayOvertime_4leave = restDayOvertime_4leave < 0 ? 0 : restDayOvertime_4leave;
double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|holidayOvertime_4leave")));
holidayOvertime_4leave = holidayOvertime_4leave < 0 ? 0 : holidayOvertime_4leave;
double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|workingDayOvertime_nonleave")));
workingDayOvertime_nonleave = workingDayOvertime_nonleave < 0 ? 0 : workingDayOvertime_nonleave;
double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|restDayOvertime_nonleave")));
restDayOvertime_nonleave = restDayOvertime_nonleave < 0 ? 0 : restDayOvertime_nonleave;
double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|holidayOvertime_nonleave")));
holidayOvertime_nonleave = holidayOvertime_nonleave < 0 ? 0 : holidayOvertime_nonleave;
double temp = workingDayOvertime_4leave + restDayOvertime_4leave + holidayOvertime_4leave +
workingDayOvertime_nonleave + restDayOvertime_nonleave + holidayOvertime_nonleave;
// bb.writeLog("-=-temp:" + temp);
Double attendanceMins = Util.getDoubleValue(Util.null2String(attendanceMinsMap.get(res + "|" + date)));
// bb.writeLog("-=-attendanceMins:" + attendanceMins);
double v = Math.round (((attendanceMins < 0.00) ? 0.00 : attendanceMins) + temp) / 60.00;
String value = "0";
if (v >= 4.00 && v < 9.00) {
value = "1";
} else if (v >= 9.00) {
value = "2";
}
// bb.writeLog("-=-value:" + value);
datas.put(res + "|" + "DailyOtherStatAllowance" + "|" + date, value);
}
}
}
}
}
}catch (Exception e){
writeLog(e);
bb.writeLog("DailyOtherStatAllowance Exception: " + e);
}
// bb.writeLog("DailyOtherStatAllowance datas: " + datas);
bb.writeLog("DailyOtherStatAllowance datas: " + datas);
return datas;
}
@ -2078,7 +1819,7 @@ public class KQReportBiz extends BaseBean {
//获取加班时长
Map<String, Object> dailyFlowOverTimeData = getDailyFlowOverTimeDataAllowance(params, user);
// bb.writeLog("dailyFlowOverTimeData: " + dailyFlowOverTimeData);
bb.writeLog("dailyFlowOverTimeData: " + dailyFlowOverTimeData);
//获取夜班班次
List<String> nightShiftList = new ArrayList<>();
@ -2177,163 +1918,7 @@ public class KQReportBiz extends BaseBean {
writeLog(e);
bb.writeLog("DailyNightShiftAllowanceData Exception: " + e);
}
// bb.writeLog("DailyNightShiftAllowanceData datas: " + datas);
return datas;
}
public Map<String,Object> getDailyNightShiftAllowanceDataTemp(Map<String,Object> params, User user, Map<String, Object> dailyFlowOverTimeData){
Map<String,Object> datas = new HashMap<>();;
RecordSet rs = new RecordSet();
String sql = "";
String sqlWhere = " ";
try{
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
String fromDate = Util.null2String(jsonObj.get("fromDate"));
String toDate = Util.null2String(jsonObj.get("toDate"));
String typeselect =Util.null2String(jsonObj.get("typeselect"));
if(typeselect.length()==0)typeselect = "3";
if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){
if(typeselect.equals("1")){
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
}else{
fromDate = TimeUtil.getDateByOption(typeselect,"0");
toDate = TimeUtil.getDateByOption(typeselect,"1");
}
}
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
String departmentId = Util.null2String(jsonObj.get("departmentId"));
String resourceId = Util.null2String(jsonObj.get("resourceId"));
String allLevel = Util.null2String(jsonObj.get("allLevel"));
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
String viewScope = Util.null2String(jsonObj.get("viewScope"));
if(subCompanyId.length()>0){
sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") ";
}
if(departmentId.length()>0){
sqlWhere +=" and a.departmentid in("+departmentId+") ";
}
if(resourceId.length()>0){
sqlWhere +=" and a.id in("+resourceId+") ";
}
if(viewScope.equals("4")){//我的下属
if(allLevel.equals("1")){//所有下属
sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
}else{
sqlWhere+=" and a.managerid="+user.getUID();//直接下属
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
}
//获取加班时长
// Map<String, Object> dailyFlowOverTimeData = getDailyFlowOverTimeDataAllowance(params, user);
// bb.writeLog("dailyFlowOverTimeData: " + dailyFlowOverTimeData);
//获取夜班班次
List<String> nightShiftList = new ArrayList<>();
String acqNightShiftSql = "select shift from uf_nightshiftmanage where isdelete is null or isdelete = 0";
rs.executeQuery(acqNightShiftSql);
while (rs.next()) {
String shift = Util.null2String(rs.getString("shift"));
if (StringUtils.isNotBlank(shift)) {
nightShiftList.add(shift);
}
}
if (nightShiftList != null & nightShiftList.size() > 0) {
String nightshiftsub = Util.null2String(bb.getPropValue("project_hostar", "nightshiftsubcompany"));
if (StringUtils.isNotBlank(nightshiftsub)) {
//查询该分部下的人员
List<String> resIds = new ArrayList<>();
sqlWhere += " and a.subcompanyid1 in ("+nightshiftsub+") ";
String acqResSql = "select a.id from hrmresource a where a.status in (0,1,2,3) " + sqlWhere;
bb.writeLog("acqResSql: " + acqResSql);
rs.executeQuery(acqResSql);
while (rs.next()) {
String id = Util.null2String(rs.getString("id"));
if (StringUtils.isNotBlank(id)) {
resIds.add(id);
}
}
bb.writeLog("resIds: " + resIds);
if ( resIds != null && resIds.size() > 0) {
HostarUtil houtil = new HostarUtil();
List<String> allDates = houtil.getAllDates(fromDate, toDate);
//先获取到出勤时长
Map<String, Double> attendanceMinsMap = new HashMap<>();
String acqAttenSql = " select resourceid, attendancemins, kqdate from kq_format_total where resourceid in (" + String.join(",",resIds) + ") and kqdate >='" + fromDate + "' and kqdate <='" + toDate + "'";
rs.executeQuery(acqAttenSql);
while (rs.next()) {
String resourceid = Util.null2String(rs.getString("resourceid"));
Double attendancemins = Util.getDoubleValue(Util.null2String(rs.getString("attendancemins")));
String kqdate = Util.null2String(rs.getString("kqdate"));
if (attendancemins >= 0.00 ) {
attendanceMinsMap.put(resourceid+"|"+kqdate, attendancemins);
}
}
KQWorkTime kqWorkTime = new KQWorkTime();
for (String res: resIds) {
for (String date : allDates) {
//获取当天班次
Map<String, Object> serialInfo = kqWorkTime.getSerialInfo(res, date, false);
if (serialInfo != null && serialInfo.size() > 0) {
int serialid = Util.getIntValue(Util.null2String(serialInfo.get(date)), 0);
if (serialid > 0) {
if ( !nightShiftList.contains(String.valueOf(serialid))) {
continue;
}
}
}
double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|workingDayOvertime_4leave")));
workingDayOvertime_4leave = workingDayOvertime_4leave < 0 ? 0 : workingDayOvertime_4leave;
double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|restDayOvertime_4leave")));
restDayOvertime_4leave = restDayOvertime_4leave < 0 ? 0 : restDayOvertime_4leave;
double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|holidayOvertime_4leave")));
holidayOvertime_4leave = holidayOvertime_4leave < 0 ? 0 : holidayOvertime_4leave;
double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|workingDayOvertime_nonleave")));
workingDayOvertime_nonleave = workingDayOvertime_nonleave < 0 ? 0 : workingDayOvertime_nonleave;
double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|restDayOvertime_nonleave")));
restDayOvertime_nonleave = restDayOvertime_nonleave < 0 ? 0 : restDayOvertime_nonleave;
double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(dailyFlowOverTimeData.get(res + "|" + date + "|holidayOvertime_nonleave")));
holidayOvertime_nonleave = holidayOvertime_nonleave < 0 ? 0 : holidayOvertime_nonleave;
double temp = workingDayOvertime_4leave + restDayOvertime_4leave + holidayOvertime_4leave +
workingDayOvertime_nonleave + restDayOvertime_nonleave + holidayOvertime_nonleave;
// bb.writeLog("-=-temp:" + temp);
Double attendanceMins = Util.getDoubleValue(Util.null2String(attendanceMinsMap.get(res + "|" + date)));
// bb.writeLog("-=-attendanceMins:" + attendanceMins);
String value = String.valueOf(Math.floor( ((attendanceMins < 0.00 ? 0.00 : attendanceMins) + temp) / 300));
// bb.writeLog("-=-value:" + value);
datas.put(res + "|" + "DailyNightShiftAllowanceData" + "|" + date, value);
}
}
}
} else {
bb.writeLog("夜班餐补计算失败,没有设置该餐补享受分部");
}
} else {
bb.writeLog("夜班餐补计算失败,没有设置夜班");
}
}catch (Exception e){
writeLog(e);
bb.writeLog("DailyNightShiftAllowanceData Exception: " + e);
}
// bb.writeLog("DailyNightShiftAllowanceData datas: " + datas);
bb.writeLog("DailyNightShiftAllowanceData datas: " + datas);
return datas;
}
@ -2524,7 +2109,7 @@ public class KQReportBiz extends BaseBean {
// long endTime11 = System.currentTimeMillis();
// long elapsedTime11 = endTime11 - startTime11; // 执行时间
// bb.writeLog("加班时长执行时间:" + elapsedTime11 + "毫秒" );
// bb.writeLog("dailyFlowOverTimeData: " + dailyFlowOverTimeData);
bb.writeLog("dailyFlowOverTimeData: " + dailyFlowOverTimeData);
//首先去除指定不享有的分部
// long startTime12 = System.currentTimeMillis();
@ -2540,7 +2125,7 @@ public class KQReportBiz extends BaseBean {
// long endTime12 = System.currentTimeMillis();
// long elapsedTime12 = endTime12 - startTime12; // 执行时间
// bb.writeLog("不享有的分部执行时间:" + elapsedTime12 + "毫秒" );
bb.writeLog("getDailyStatAllowanceData subComoanyList: " + subComoanyList);
bb.writeLog("subComoanyList: " + subComoanyList);
String subComoanys = "";
if ( subComoanyList != null && subComoanyList.size() > 0) {
@ -2567,7 +2152,7 @@ public class KQReportBiz extends BaseBean {
List<String> resIds = new ArrayList<>();
String acqResSql = "select a.id from hrmresource a where a.status in (0,1,2,3) " + sqlWhere;
bb.writeLog("getDailyStatAllowanceData acqResSql: " + acqResSql);
bb.writeLog("acqResSql: " + acqResSql);
rs.executeQuery(acqResSql);
while (rs.next()) {
@ -2576,7 +2161,7 @@ public class KQReportBiz extends BaseBean {
resIds.add(id);
}
}
bb.writeLog("getDailyStatAllowanceData resIds: " + resIds);
bb.writeLog("resIds: " + resIds);
if (resIds != null && resIds.size() > 0 && StringUtils.isNotBlank(fromDate) && StringUtils.isNotBlank(toDate)) {
HostarUtil houtil = new HostarUtil();
@ -2738,17 +2323,16 @@ public class KQReportBiz extends BaseBean {
}
}
}
// bb.writeLog("signIdList " + signIdList);
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) + ") ";
String acqShowAddress = "select showaddress from hrmschedulesign where id in (" + String.join(",", signIdList) + ") ";
bb.writeLog("acqShowAddress: " + acqShowAddress);
rs.executeQuery(acqShowAddress);
while (rs.next()) {
String showaddress = Util.null2String(rs.getString("showaddress"));
String addr = Util.null2String(rs.getString("addr"));
if ("鸿仕达".equals(showaddress) || "hostar".equalsIgnoreCase(showaddress) || "鸿仕达".equals(addr) || "hostar".equalsIgnoreCase(addr)) {
if ("鸿仕达".equals(showaddress) || "hostar".equalsIgnoreCase(showaddress)) {
signNumber = signNumber + 1;
}
}
@ -2789,7 +2373,7 @@ public class KQReportBiz extends BaseBean {
}
}catch (Exception e){
writeLog(e);
bb.writeLog("DailyStatAllowance Exception: " + e.getMessage());
bb.writeLog("DailyStatAllowance Exception: " + e);
}
bb.writeLog("DailyStatAllowance datas: " + datas);
@ -3082,13 +2666,12 @@ public class KQReportBiz extends BaseBean {
Integer signNumber = 0;
if (signIdList !=null && signIdList.size() > 0) {
String acqShowAddress = "select showaddress,addr from hrmschedulesign where id in (" + String.join(",", signIdList) + ") ";
String acqShowAddress = "select showaddress from hrmschedulesign where id in (" + String.join(",", signIdList) + ") ";
bb.writeLog("acqShowAddress: " + acqShowAddress);
rs.executeQuery(acqShowAddress);
while (rs.next()) {
String showaddress = Util.null2String(rs.getString("showaddress"));
String addr = Util.null2String(rs.getString("addr"));
if ("鸿仕达".equals(showaddress) || "hostar".equalsIgnoreCase(showaddress) || "鸿仕达".equals(addr) || "hostar".equalsIgnoreCase(addr)) {
if ("鸿仕达".equals(showaddress) || "hostar".equalsIgnoreCase(showaddress)) {
signNumber = signNumber + 1;
}
}

@ -1,672 +0,0 @@
package com.engine.kq.cmd.attendanceButton;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.cloudstore.dev.api.util.EMManager;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.hostar.util.HostarUtil;
import com.engine.kq.biz.*;
import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean;
import com.engine.kq.entity.KQGroupEntity;
import com.engine.kq.entity.WorkTimeEntity;
import com.engine.kq.log.KQLog;
import com.engine.kq.timer.KQQueue;
import com.engine.kq.timer.KQTaskBean;
import com.engine.kq.util.KQDurationCalculatorUtil;
import com.engine.kq.wfset.util.SplitActionUtil;
import com.google.common.collect.Maps;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.Map.Entry;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.dateformat.DateTransformer;
import weaver.dateformat.TimeZoneVar;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;
/**
* 退
*/
public class PunchButtonCmd extends AbstractCommonCommand<Map<String, Object>> {
public KQLog kqLog = new KQLog();
private HttpServletRequest request;
private Map<String,Object> logMap = Maps.newHashMap();
private Map<String,Object> workTimeEntityLogMap = Maps.newHashMap();
private final List<String> LIST = new ArrayList<>();
public PunchButtonCmd(HttpServletRequest request,Map<String, Object> params, User user) {
this.request = request;
this.user = user;
this.params = params;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> retmap = new HashMap<String, Object>();
try{
insertSign(retmap);
}catch (Exception e) {
retmap.put("status", "-1");
retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage()));
writeLog(e);
}
kqLog.info(user.getLastname()+":PunchButtonCmd:retmap:"+retmap);
KQCardLogBiz.logCardInfo(user.getUID()+"", logMap, workTimeEntityLogMap, "punchButton");
return retmap;
}
/**
* ip
* @param ismobile
*/
private boolean checkIsInIp(String ismobile) {
// if("1".equalsIgnoreCase(ismobile)){
// return true;
// }
KQGroupBiz kqGroupBiz = new KQGroupBiz();
String clientAddress = Util.getIpAddr(request);
kqLog.info("PunchButtonCmd:clientAddress:"+clientAddress);
return kqGroupBiz.getIsInScopeV4V6(user.getUID()+"", clientAddress,ismobile);
}
public void insertSign(Map<String, Object> retmap) throws Exception{
logMap.put("lastname", user.getLastname());
logMap.put("params", params);
kqLog.info(user.getLastname()+":PunchButtonCmd:params:"+params);
RecordSet rs = new RecordSet();
String deviceInfo = Util.null2String(params.get("deviceInfo"));
JSONObject jsonObject = null;
if(deviceInfo.length() > 0){
jsonObject = JSON.parseObject(deviceInfo);
JSONObject jsonObject1 = new JSONObject();
Set<Entry<String, Object>> jsonSet = jsonObject.entrySet();
for(Entry<String, Object> js : jsonSet){
String key = js.getKey();
String value = Util.null2String(js.getValue());
jsonObject1.put(key, value);
}
if(!jsonObject1.isEmpty()){
deviceInfo = jsonObject1.toJSONString();
}
}
//应上班 工作时间点
String time = Util.null2String(params.get("time"));
//应上班 工作时间 带日期
String datetime = Util.null2String(params.get("datetime"));
//允许打卡时段 带日期
String signSectionTime = Util.null2String(params.get("signSectionTime"));
//上传照片
String attachment = Util.null2String(params.get("fileids"));
//打卡所属worksection的对应的点
String type = Util.null2String(params.get("type"));
//所属打卡日期
String belongdate = Util.null2String(params.get("belongdate"));
belongdate = belongdate.length() == 0 ? DateUtil.getCurrentDate() : belongdate;
String islastsign = Util.null2String(params.get("islastsign"));
String isfirstsign = Util.null2String(params.get("isfirstsign"));
String workmins = Util.null2String(params.get("workmins"));
//针对非工作时段 签退的时候记录的签到数据 用于计算加班
String signInTime4Out = Util.null2String(params.get("signInTime4Out"));
//允许打卡的范围
String signsection = Util.null2String(params.get("signSection"));
//手机打卡部分
String longitude = Util.null2String(params.get("longitude"));
String latitude = Util.null2String(params.get("latitude"));
double d_longitude = Util.getDoubleValue(longitude);
double d_latitude = Util.getDoubleValue(latitude);
if(d_latitude <= 0){
latitude = "";
}
if(d_longitude <= 0){
longitude = "";
}
//wifi用的
String mac = Util.null2String(params.get("mac"));
String sid = Util.null2String(params.get("sid"));
String addr = Util.null2String(params.get("position"));
String ismobile = Util.null2String(params.get("ismobile"));
//区分是来自于钉钉还是EM7
String browser = Util.null2String(params.get("browser"));
//自由班制处理
String isfree = Util.null2String(Util.null2String(params.get("isfree")),"0");
//上班打卡 允许最晚打卡时间
String signSectionEndTime = Util.null2String(params.get("signSectionEndTime"));
//下班打卡 允许最早打卡时间
String signSectionBeginTime = Util.null2String(params.get("signSectionBeginTime"));
String locationshowaddress = Util.null2String(params.get("locationshowaddress"));
if(locationshowaddress.equals("1")){//记录统一地址
String locationid = Util.null2String(params.get("locationid"));//办公地点id
if(locationid.length()>0){//如果开启统一显示,就用配置的地址
KQLoactionComInfo kqLoactionComInfo = new KQLoactionComInfo();
addr = kqLoactionComInfo.getLocationname(locationid);
}
}
DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
LocalTime localTime = LocalTime.now();
String signTime =localTime.format(dateTimeFormatter);
String signDate = LocalDate.now().format(dateFormatter);
String timeZone = Util.null2String(TimeZoneVar.getTimeZone(),"");
//处理多时区
String timeZoneConversion = Util.null2String(new weaver.general.BaseBean().getPropValue("weaver_timezone_conversion","timeZoneConversion")).trim();
logMap.put("timeZoneConversion", timeZoneConversion);
if("1".equals(timeZoneConversion)) {
DateTransformer dateTransformer=new DateTransformer();
String[] zone_localTime = dateTransformer.getLocaleDateAndTime(signDate,signTime);
kqLog.info(user.getLastname()+":TimeZoneVar.getTimeZone():"+TimeZoneVar.getTimeZone()+":zone_localTime:"+JSON.toJSONString(zone_localTime));
if(zone_localTime != null && zone_localTime.length == 2){
signDate = zone_localTime[0];
signTime = zone_localTime[1];
}
}
int userId = user.getUID();
String userType = user.getLogintype();
String signType = "on".equalsIgnoreCase(type) ? "1" : "2";
String clientAddress = Util.getIpAddr(request);
boolean isInIp = checkIsInIp(ismobile);
logMap.put("clientAddress", clientAddress);
if(!isInIp){
retmap.put("message", SystemEnv.getHtmlLabelName(20157,user.getLanguage()));
retmap.put("isInIp", "0");
}
String isInCom = isInIp ? "1" : "0";
//是否是考勤例外人员
boolean isExclude = false;
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
KQWorkTime kqWorkTime = new KQWorkTime();
WorkTimeEntity workTimeEntity = kqWorkTime.getWorkTime(user.getUID()+"", signDate);
String userinfo = "#userid#"+user.getUID()+"#getUserSubCompany1#"+user.getUserSubCompany1()+"#getUserSubCompany1#"+user.getUserDepartment()
+"#getJobtitle#"+user.getJobtitle();
workTimeEntityLogMap.put("resourceid", userinfo);
workTimeEntityLogMap.put("splitDate", signDate);
workTimeEntityLogMap.put("workTimeEntity", workTimeEntity);
String groupid = workTimeEntity.getGroupId();
logMap.put("groupid", groupid);
KQGroupEntity kqGroupEntity = kqGroupMemberComInfo.getUserKQGroupInfo(user.getUID()+"");
String kqGroupEntityInfo = kqGroupEntity != null ? JSON.toJSONString(kqGroupEntity): "";
logMap.put("kqGroupEntityInfo", kqGroupEntityInfo);
if (kqGroupEntity != null && ("," + kqGroupEntity.getExcludeid() + ",").indexOf("," + user.getUID() + ",")>-1) {//排除人员无需计算考勤时间
isExclude = true;
}
String[] signsections = signsection.split("#");
if(!"1".equalsIgnoreCase(isfree)){
if(signsections != null && signsections.length == 2){
//判断是未签到直接签退
String signedMsg = signedMsg(userId+"", signType, user,signsections,signSectionBeginTime,signSectionEndTime);
if(signedMsg.length() > 0){
retmap.put("status", "1");
retmap.put("message", signedMsg);
isInCom = "0";
}
}
}
String datetime_timezone = signDate+" "+signTime;
LocalDateTime nowDateTime = LocalDateTime.parse(datetime_timezone,fullFormatter);
kqLog.info("timeZone:"+timeZone+":signDate:"+signDate+":signTime:"+signTime+":nowDateTime:"+nowDateTime);
if("1".equalsIgnoreCase(signType) && signSectionTime.length() > 0 ){
LocalDateTime startWorkDateTime = LocalDateTime.parse(signSectionTime,fullFormatter);
if(nowDateTime.isBefore(startWorkDateTime)){
Duration duration = Duration.between(nowDateTime, startWorkDateTime);
retmap.put("status", "1");
retmap.put("message", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005326,weaver.general.ThreadVarLanguage.getLang())+""+duration.toMinutes()+""+weaver.systeminfo.SystemEnv.getHtmlLabelName(15049,weaver.general.ThreadVarLanguage.getLang())+"");
isInCom = "0";
}
}else if("2".equalsIgnoreCase(signType) && signSectionTime.length() > 0 ){
LocalDateTime endWorkDateTime = LocalDateTime.parse(signSectionTime,fullFormatter);
if(nowDateTime.isAfter(endWorkDateTime)){
Duration duration = Duration.between(endWorkDateTime, nowDateTime);
retmap.put("status", "1");
retmap.put("message", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005327,weaver.general.ThreadVarLanguage.getLang())+""+duration.toMinutes()+""+weaver.systeminfo.SystemEnv.getHtmlLabelName(15049,weaver.general.ThreadVarLanguage.getLang())+"");
isInCom = "0";
}
}
//记录下是来自于E9的pc端签到
String signfrom = "e9pc";
if("1".equalsIgnoreCase(ismobile)){
signfrom = "e9mobile";
boolean needLocationRange = false;
boolean needWifiRange = false;
boolean isLocationRange = false;
boolean isWifiRange = false;
KQGroupBiz kqGroupBiz = new KQGroupBiz();
Map<String,Object> locationMap = kqGroupBiz.checkLocationScope(userId+"",longitude,latitude);
logMap.put("locationMap", locationMap);
String locationNeedCheck = Util.null2String(locationMap.get("needCheck"));
boolean locationInScope = Boolean.parseBoolean(Util.null2String(locationMap.get("inScope")));
if("1".equalsIgnoreCase(locationNeedCheck)){
needLocationRange = true;
if(locationInScope){
isLocationRange = true;
}
}
String wifiNeedCheck = "";
Map<String,Object> wifiMap = kqGroupBiz.checkWifiScope(userId+"", sid, mac);
logMap.put("wifiMap", wifiMap);
wifiNeedCheck = Util.null2String(wifiMap.get("needCheck"));
boolean wifiInScope = Boolean.parseBoolean(Util.null2String(wifiMap.get("inScope")));
if("1".equalsIgnoreCase(wifiNeedCheck)){
needWifiRange = true;
if(wifiInScope){
isWifiRange = true;
}
}
if(needLocationRange){
if(isLocationRange){
}else{
if(needWifiRange){
if(isWifiRange){
}else{
//地理位置开启而且不在范围内且开启wifi验证,不在范围内
retmap.put("message", SystemEnv.getHtmlLabelName(507524, user.getLanguage()));
isInCom = "0";
}
}else {
//地理位置开启而且不在范围内且未开启wifi验证
retmap.put("message", SystemEnv.getHtmlLabelName(500510, user.getLanguage()));
isInCom = "0";
}
}
}else{
if(needWifiRange) {
if (isWifiRange) {
} else {
//地理位置未开启且开启wifi验证,不在范围内
retmap.put("message", SystemEnv.getHtmlLabelName(507524, user.getLanguage()));
isInCom = "0";
}
}
}
if("DingTalk".equalsIgnoreCase(browser)){
signfrom = "DingTalk";
}else if("Wechat".equalsIgnoreCase(browser)){
signfrom = "Wechat";
String weChat_deviceid = Util.null2String(request.getSession().getAttribute(EMManager.DeviceId));
logMap.put("weChat_deviceid", weChat_deviceid);
kqLog.info("EMManager.DeviceId:"+EMManager.DeviceId+":weChat_deviceid:"+weChat_deviceid);
if(weChat_deviceid.length() > 0){
//微信打卡的设备号需要单独处理
if(jsonObject != null){
jsonObject.put("deviceId", weChat_deviceid);
}else{
jsonObject = new JSONObject();
jsonObject.put("deviceId", weChat_deviceid);
}
if(!jsonObject.isEmpty()){
deviceInfo = jsonObject.toJSONString();
}
}
}
}
String signStatus = "";
if(!"1".equalsIgnoreCase(isfree) && datetime.length() > 0){
signStatus = getSignStatus(signType,datetime,user.getUID()+"",belongdate,nowDateTime);
logMap.put("signStatus", signStatus);
}
if(isExclude){
signStatus = ButtonStatusEnum.NORMAL.getStatusCode();
}
String punchSql = "insert into HrmScheduleSign(userId,userType,signType,signDate,signTime,clientAddress,isInCom,timeZone,belongdate,signfrom,longitude,latitude,addr,deviceInfo) "+
" values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
boolean isOk = rs.executeUpdate(punchSql,userId,userType,signType,signDate,signTime,clientAddress,isInCom,
timeZone,belongdate,signfrom,longitude,latitude,addr,deviceInfo);
if(!isOk){
retmap.put("status", "1");
retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage()));
return ;
}
logMap.put("punchSql", punchSql);
logMap.put("punchSql_isOk", isOk);
kqLog.info(user.getLastname()+":PunchButtonCmd:punchSql:"+punchSql+":isOk:"+isOk);
//打卡提醒处理
String remindSql = "insert into hrmschedulesign_remind(userId,signType,signDate,signTime,belongdate) values(?,?,?,?,?)";
isOk = rs.executeUpdate(remindSql, userId,signType,signDate,signTime,belongdate);
kqLog.info(user.getLastname()+":PunchButtonCmd:remindSql:"+remindSql+":isOk:"+isOk);
//增加自动排班
kqLog.info("PunchButtonCmd.format in >>>>>userId" + userId + "kqDate==" + signDate+"format.groupId:"+groupid+"format.serialId:"+workTimeEntity.getSerialId());
//责任制考勤组id收集
rs.executeQuery("select kqzid from uf_zrzkqz");
while (rs.next()){
LIST.add(Util.null2String(rs.getString("kqzid")));
}
kqLog.info("PunchButtonCmd.LIST"+LIST);
if(LIST.contains(groupid)) {
RecordSet rt = new RecordSet();
BaseBean bb = new BaseBean();
//休息日或节假日给休息班次
//int changeType = KQOvertimeRulesBiz.getChangeType(Util.null2String(userId), signDate);
String fixedSerialid = Util.null2String(bb.getPropValue("project_hostar", "fixedSerialid"));
String weekendDefaultSerialid = Util.null2String(bb.getPropValue("project_hostar", "weekendDefaultSerialid"));
String holidayDefaultSerialid = Util.null2String(bb.getPropValue("project_hostar", "holidayDefaultSerialid"));
String fixedUserId = "";
//查询指定和考勤组成员
String query_sql = "select distinct typevalue from kq_groupmember where groupid = ? ";
rs.executeQuery(query_sql, fixedSerialid);
if (rs.next()) {
fixedUserId = rs.getString("typevalue");
}
boolean holiday = KQHolidaySetBiz.isHoliday(fixedUserId, signDate, true);
kqLog.info("format.holiday:" + holiday);
//String sql = "insert into kq_shiftschedule(kqdate,serialid,resourceid,groupid,isdelete)values(?,?,?,?,?)";
String sql = "update kq_shiftschedule set serialid = ? where resourceid = ? and kqdate= ? and groupid = ? and isdelete = 0 ";
//考勤当天是节假日或者休息日
if (holiday) {
//节假日休息班
boolean b = rt.executeUpdate(sql, holidayDefaultSerialid, Util.null2String(userId), signDate, groupid);
kqLog.info("PunchButtonCmd.b1:" + b);
} else {
//周末休息班
// if (DateUtil.getWeek(signDate) == 6 || DateUtil.getWeek(signDate) == 7) {
// boolean b = rt.executeUpdate(sql, weekendDefaultSerialid, Util.null2String(userId), signDate, groupid);
// kqLog.info("PunchButtonCmd.b1:" + b);
// } else {
String dybc = "";
//正常打卡,排对应打卡地点对应班次
//2.查询指定打卡地点的经纬度及范围的list
List<Map<String, String>> list2 = new ArrayList<>();
//2.1查询出打卡地点经纬度建模list
String sql2 = "select jd,wd,bj,dybc from uf_jwdbj";
rt.execute(sql2);
while (rt.next()) {
Map<String, String> map = new HashMap<>();
map.put("jd", Util.null2String(rt.getString("jd")));
map.put("wd", Util.null2String(rt.getString("wd")));
map.put("bj", Util.null2String(rt.getString("bj")));
map.put("dybc", Util.null2String(rt.getString("dybc")));
list2.add(map);
}
kqLog.info("PunchButtonCmd.list2:" + list2);
for (Map<String, String> map : list2) {
Double distance = new HostarUtil().calculateDistance(d_latitude, d_longitude, Util.getDoubleValue(map.get("wd")), Util.getDoubleValue(map.get("jd")));
if (distance <= Util.getDoubleValue(map.get("bj"))) {
dybc = map.get("dybc");
}
}
kqLog.info("PunchButtonCmd.dybc:" + dybc);
//设置考勤班次为对应班次
if (StringUtils.isNotBlank(dybc)) {
boolean b = rt.executeUpdate(sql, dybc, Util.null2String(userId), signDate, groupid);
kqLog.info("PunchButtonCmd.b2:" + b);
}
// }
}
}
//同步更新考勤数据到考勤报表
new KQFormatBiz().formatDate(""+userId,(belongdate.length() == 0 ? DateUtil.getCurrentDate() : belongdate));
//点击签退的时候,可能存在加班数据生成的情况
if("2".equalsIgnoreCase(signType)){
if("1".equalsIgnoreCase(islastsign)){
List<KQTaskBean> tasks = new ArrayList<>();
List<KQTaskBean> after_tasks = new ArrayList<>();
SplitActionUtil.pushOverTimeTasks(belongdate, belongdate, ""+userId,tasks);
if(!tasks.isEmpty()){
for(KQTaskBean kqTaskBean : tasks){
after_tasks.add(kqTaskBean);
}
}
logMap.put("after_tasks", after_tasks);
if(!after_tasks.isEmpty()){
KQQueue.writeTasks(after_tasks);
}
}
}
if("1".equalsIgnoreCase(signType)){
if("1".equalsIgnoreCase(isfirstsign)){
List<KQTaskBean> tasks = new ArrayList<>();
List<KQTaskBean> before_tasks = new ArrayList<>();
SplitActionUtil.pushOverTimeTasks(belongdate, belongdate, ""+userId,tasks);
if(!tasks.isEmpty()){
for(KQTaskBean kqTaskBean : tasks){
kqTaskBean.setTasktype("punchcard");
before_tasks.add(kqTaskBean);
}
}
logMap.put("before_tasks", before_tasks);
if(!before_tasks.isEmpty()){
KQQueue.writeTasks(before_tasks);
}
}
}
String reSignStatus = reSignStatus(user.getUID()+"",signType,nowDateTime,belongdate);
if(Util.null2String(reSignStatus,"").length() > 0){
signStatus = reSignStatus;
}
retmap.put("status", "1");
retmap.put("signdate", signDate);
retmap.put("signtime", signTime);
retmap.put("kqstatus", signStatus);
if(!"1".equalsIgnoreCase(signStatus) && !"2".equalsIgnoreCase(signStatus)){
if("".equalsIgnoreCase(Util.null2String(retmap.get("message")))){
retmap.put("success", "1");
retmap.put("message", SystemEnv.getHtmlLabelName(512596,weaver.general.Util.getIntValue(user.getLanguage())));
}
}
logMap.put("retmap", retmap);
}
public String reSignStatus(String userid, String signType, LocalDateTime nowDateTime,
String workdate) {
String signStatus = "";
String shift_begindateworktime = "";
String shift_enddateworktime = "";
ShiftInfoBean shiftInfoBean = KQDurationCalculatorUtil.getWorkTime(userid, workdate,false);
if(shiftInfoBean == null){
return signStatus;
}
Map<String,String> shifRuleMap = Maps.newHashMap();
KQShiftRuleInfoBiz.getShiftRuleInfo(shiftInfoBean,userid,shifRuleMap);
KQTimesArrayComInfo arrayComInfo = new KQTimesArrayComInfo();
if(!shifRuleMap.isEmpty()) {
DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String datetime = "";
if (shifRuleMap.containsKey("shift_beginworktime")) {
String shift_beginworktime = Util.null2String(shifRuleMap.get("shift_beginworktime"));
if (shift_beginworktime.length() > 0) {
int shift_beginworktime_index = -1;
shift_beginworktime_index = arrayComInfo.getArrayindexByTimes(shift_beginworktime);
datetime = workdate+" "+shift_beginworktime+":00";
if(shift_beginworktime_index >= 1440){
//跨天了
datetime = DateUtil.addDate(workdate, 1)+" "+arrayComInfo.turn48to24Time(shift_beginworktime)+":00";
}
}
}
if (shifRuleMap.containsKey("shift_endworktime")) {
String shift_endworktime = Util.null2String(shifRuleMap.get("shift_endworktime"));
if (shift_endworktime.length() > 0) {
int shift_endworktime_index = -1;
shift_endworktime_index = arrayComInfo.getArrayindexByTimes(shift_endworktime);
datetime = workdate+" "+shift_endworktime+":00";
if(shift_endworktime_index >= 1440) {
//跨天了
datetime = DateUtil.addDate(workdate, 1)+" "+arrayComInfo.turn48to24Time(shift_endworktime)+":00";
}
}
}
if (datetime.length() > 0) {
if("1".equalsIgnoreCase(signType)) {
LocalDateTime startWorkDateTime = LocalDateTime.parse(datetime, fullFormatter);
//打卡时间比上班时间晚,迟到了
if (nowDateTime.isAfter(startWorkDateTime)) {
signStatus = ButtonStatusEnum.BELATE.getStatusCode();
} else {
signStatus = ButtonStatusEnum.NORMAL.getStatusCode();
}
} else if ("2".equalsIgnoreCase(signType)) {
LocalDateTime endWorkDateTime = LocalDateTime.parse(datetime, fullFormatter);
//签退的话
if (nowDateTime.isBefore(endWorkDateTime)) {
signStatus = ButtonStatusEnum.LEAVEERALY.getStatusCode();
} else {
signStatus = ButtonStatusEnum.NORMAL.getStatusCode();
}
} else {
writeLog(user.getLastname() + nowDateTime + ":竟然没有传:" + signType);
return "";
}
}
}
return signStatus;
}
/**
*
* @param resourceid
* @param pre_splitDate
* @param signtime
* @param pre_bengintime
* @param signdate
*/
public void doBeforeAcrossOvertime(String resourceid,String pre_splitDate,String signtime,String pre_bengintime,String signdate) {
KQTaskBean kqTaskBean = new KQTaskBean();
kqTaskBean.setResourceId(resourceid);
kqTaskBean.setTaskDate(pre_splitDate);
kqTaskBean.setLastWorkTime(signtime);
if(pre_bengintime.length() == 5){
kqTaskBean.setTaskSignTime(pre_bengintime+":00");
}else{
kqTaskBean.setTaskSignTime(pre_bengintime);
}
kqTaskBean.setSignDate(signdate);
kqTaskBean.setSignEndDate(signdate);
kqTaskBean.setTimesource("before");
KQQueue.writeTask(kqTaskBean);
}
/**
*
* @param userid
* @param signtype
* @param curUser
* @param signsections
* @param signSectionBeginTime
* @param signSectionEndTime
* @return
*/
public String signedMsg(String userid, String signtype, User curUser, String[] signsections,
String signSectionBeginTime, String signSectionEndTime) throws Exception{
String signedMsg = "";
RecordSet rs = new RecordSet();
boolean hasSigned = false;
String onSignSectionTime = signsections[0];
String offSignSectionTime = signsections[1];
if(onSignSectionTime.length() > 0 && offSignSectionTime.length() > 0){
String hasSign = "select 1 from hrmschedulesign where 1 = 1 and isInCom = '1' and userid = ? ";
StringBuffer sql = new StringBuffer();
if(rs.getDBType().equals("oracle")||rs.getDBType().equals("postgresql")){
sql.append(" AND signDate||' '||signTime>=? ");
sql.append(" AND signDate||' '||signTime<=? ");
}else if(rs.getDBType().equals("mysql")){
sql.append(" AND concat(signDate,' ',signTime)>=? ");
sql.append(" AND concat(signDate,' ',signTime)<=? ");
}else{
sql.append(" AND signDate+' '+signTime>=? ");
sql.append(" AND signDate+' '+signTime<=? ");
}
hasSign += sql.toString();
rs.executeQuery(hasSign, userid,onSignSectionTime,offSignSectionTime);
if(rs.next()){
hasSigned = true;
}
if("1".equalsIgnoreCase(signtype)){
if(signSectionBeginTime.length() > 0 || signSectionEndTime.length() > 0){
}else{
if(hasSigned){
signedMsg = SystemEnv.getHtmlLabelName(129706, curUser.getLanguage());
}
}
}else if("2".equalsIgnoreCase(signtype)){
if(signSectionBeginTime.length() > 0 || signSectionEndTime.length() > 0){
}else{
if(!hasSigned){
signedMsg = SystemEnv.getHtmlLabelName(501301, curUser.getLanguage());
}
}
}
}
return signedMsg;
}
/**
* 退
* 退
* @return
*/
public String getSignStatus(String signType, String datetime, String userid, String workdate,
LocalDateTime nowDateTime) {
DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String signStatus = "";
//签到的话
if("1".equalsIgnoreCase(signType)){
LocalDateTime startWorkDateTime = LocalDateTime.parse(datetime,fullFormatter);
//打卡时间比上班时间晚,迟到了
if(nowDateTime.isAfter(startWorkDateTime)){
signStatus = ButtonStatusEnum.BELATE.getStatusCode();
}else{
signStatus = ButtonStatusEnum.NORMAL.getStatusCode();
}
}else if("2".equalsIgnoreCase(signType)){
LocalDateTime endWorkDateTime = LocalDateTime.parse(datetime,fullFormatter);
//签退的话
if(nowDateTime.isBefore(endWorkDateTime)){
signStatus = ButtonStatusEnum.LEAVEERALY.getStatusCode();
}else{
signStatus = ButtonStatusEnum.NORMAL.getStatusCode();
}
}else{
writeLog(user.getLastname()+nowDateTime+":竟然没有传:"+signType);
return "";
}
return signStatus;
}
@Override
public BizLogContext getLogContext() {
return null;
}
}

@ -39,7 +39,6 @@ public class PunchOutButtonCmd extends AbstractCommonCommand<Map<String, Object>
BaseBean bb = new BaseBean();
private Map<String,Object> logMap = Maps.newHashMap();
private Map<String,Object> workTimeEntityLogMap = Maps.newHashMap();
private final List<String> LIST = new ArrayList<>();
public PunchOutButtonCmd(HttpServletRequest request, Map<String, Object> params, User user) {
this.request = request;
@ -267,7 +266,6 @@ public class PunchOutButtonCmd extends AbstractCommonCommand<Map<String, Object>
logMap.put("punchSql", punchSql);
logMap.put("punchSql_isok", isok);
//同步更新考勤数据到考勤报表
if(belongdateIsNull){
//外勤签到没有归属日期,遇到跨天班次打卡可能归属前一天,需要格式化前一天考勤
@ -307,7 +305,7 @@ public class PunchOutButtonCmd extends AbstractCommonCommand<Map<String, Object>
" FROM " +
" workflow_requestbase " +
" WHERE " +
" 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 + "'))) " +
" requestid IN ( SELECT requestid FROM " + evectionTableName + " WHERE sqr = '" + userId + "' and ksrq <='" + sqlDate + "' and yjjsrq >='" + sqlDate + "' ) " +
// " AND currentnodetype = 3 " +
" UNION all " +
" SELECT " +
@ -315,11 +313,11 @@ public class PunchOutButtonCmd extends AbstractCommonCommand<Map<String, Object>
" FROM " +
" workflow_requestbase " +
" WHERE " +
" 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 + "'))) " +
" requestid IN ( SELECT requestid FROM " + outTableName + " WHERE sqr = '" + userId + "' and ksrq <='" + sqlDate + "' and yjjsrq >='" + sqlDate + "') " +
// " AND currentnodetype = 3 " +
") a ";
bb.writeLog("acqEvecAndOutSql: " + acqEvecAndOutSql);
rs.executeQuery(acqEvecAndOutSql);
bb.writeLog("acqEvecAndOutSql: " + acqEvecAndOutSql);
while (rs.next()) {
number = Util.getIntValue(Util.null2String(rs.getString("number")));
@ -353,52 +351,6 @@ public class PunchOutButtonCmd extends AbstractCommonCommand<Map<String, Object>
boolean isok = rs.executeUpdate(punchSql,userId,userType,signType,signDate,signTime,clientAddress,isInCom,
timeZone,belongdate,signfrom,longitude,latitude,address,deviceInfo,"1");
bb.writeLog("isok: " + isok);
//自动对班
kqLog.info("PunchOutButtonCmd.format in >>>>>userId" + userId + "kqDate==" + signDate+"format.groupId:"+groupid+"format.serialId:"+workTimeEntity.getSerialId());
//责任制考勤组id收集
rs.executeQuery("select kqzid from uf_zrzkqz");
while (rs.next()){
LIST.add(Util.null2String(rs.getString("kqzid")));
}
kqLog.info("PunchOutButtonCmd.LIST"+LIST);
if(LIST.contains(groupid)) {
RecordSet rt = new RecordSet();
boolean b;
BaseBean bb= new BaseBean();
//休息日或节假日给休息班次
//int changeType = KQOvertimeRulesBiz.getChangeType(Util.null2String(userId), signDate);
String fixedSerialid = Util.null2String(bb.getPropValue("project_hostar", "fixedSerialid"));
String defaultSerialid = Util.null2String(bb.getPropValue("project_hostar", "defaultSerialid"));
String weekendDefaultSerialid = Util.null2String(bb.getPropValue("project_hostar", "weekendDefaultSerialid"));
String holidayDefaultSerialid = Util.null2String(bb.getPropValue("project_hostar", "holidayDefaultSerialid"));
String fixedUserId = "";
//查询指定和考勤组成员
String query_sql = "select distinct typevalue from kq_groupmember where groupid = ? ";
rs.executeQuery(query_sql,fixedSerialid);
if (rs.next()) {
fixedUserId = rs.getString("typevalue");
}
boolean holiday = KQHolidaySetBiz.isHoliday(fixedUserId, signDate,true);
kqLog.info("format.holiday:" + holiday);
//String sql = "insert into kq_shiftschedule(kqdate,serialid,resourceid,groupid,isdelete)values(?,?,?,?,?)";
String sql = "update kq_shiftschedule set serialid = ? where resourceid = ? and kqdate= ? and groupid = ? and isdelete = 0 ";
//考勤当天是节假日或者休息日
if (holiday) {
//节假日休息班
b = rt.executeUpdate(sql, signDate, holidayDefaultSerialid, Util.null2String(userId),signDate,groupid);
kqLog.info("PunchOutButtonCmd.b1:" + b);
}else{
//周末休息班
// if(DateUtil.getWeek(signDate) == 6 || DateUtil.getWeek(signDate) == 7){
// b = rt.executeUpdate(sql,weekendDefaultSerialid, Util.null2String(userId), signDate,groupid);
// kqLog.info("PunchOutButtonCmd.b2:"+b);
// }else{
//设置考勤班次为对应班次
b = rt.executeUpdate(sql,defaultSerialid, Util.null2String(userId), signDate,groupid);
kqLog.info("PunchOutButtonCmd.b3:"+b);
//}
}
}
//同步更新考勤数据到考勤报表
if(belongdateIsNull){
//外勤签到没有归属日期,遇到跨天班次打卡可能归属前一天,需要格式化前一天考勤

@ -48,7 +48,6 @@ 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,18 +184,13 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
}else {
forgotBeginWorkCheck_field = " isnull(b.forgotBeginWorkCheck,0) ";
}
String backFields = " zm.cccb as mealAllowance," +
" zm.zdcb as statAllowance," +
" zm.jmybcb as nightAllowance," +
" zm.hrzdcb as otherStatAllowance," +
" zm.ybbz as nightShiftSubsidy, "+
" a.id,a.lastname,a.subcompanyid1 as subcompanyid,a.departmentid, a.workcode,b.jobtitle,a.dsporder," +
String backFields = " 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, "+
" b.absenteeismMins ,(b.forgotCheck+"+forgotBeginWorkCheck_field+") forgotCheck,zeropoint ";
String sqlFrom = " from hrmresource a, kq_format_total b,uf_cbxxjlb zm " +
"where a.id= b.resourceid and b.kqdate >='"+fromDate+"' and b.kqdate <='"+toDate+"' and zm.xm=a.id and zm.rq = b.kqdate ";
String sqlFrom = " from hrmresource a, kq_format_total b where a.id= b.resourceid and b.kqdate >='"+fromDate+"' and b.kqdate <='"+toDate+"'";
String sqlWhere = rightSql;
if(subCompanyId.length()>0){
sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") ";
@ -238,37 +232,34 @@ 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);
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);
/*考勤二开--驻点餐补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*/
rs.execute(sql);
while (rs.next()) {
data = new ArrayList<>();
@ -316,11 +307,11 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
} else if(fieldName.equals("signin1")){
fieldValue = Util.null2String(signDetailInfo.get("signintime1"));
data.add(fieldValue);
fieldValue = Util.null2String(signDetailInfo.get("signinstatus1"));
data.add(fieldValue);
//考勤二开
fieldValue = Util.null2String(signDetailInfo.get("signinaddress1"));
data.add(fieldValue);
fieldValue = Util.null2String(signDetailInfo.get("signinstatus1"));
data.add(fieldValue);
continue;
} else if(fieldName.equals("signin2")){
fieldValue = Util.null2String(signDetailInfo.get("signintime2"));
@ -337,11 +328,11 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
} else if(fieldName.equals("signout1")){
fieldValue = Util.null2String(signDetailInfo.get("signouttime1"));
data.add(fieldValue);
fieldValue = Util.null2String(signDetailInfo.get("signoutstatus1"));
data.add(fieldValue);
//考勤二开
fieldValue = Util.null2String(signDetailInfo.get("signoutaddress1"));
data.add(fieldValue);
fieldValue = Util.null2String(signDetailInfo.get("signoutstatus1"));
data.add(fieldValue);
continue;
} else if(fieldName.equals("signout2")){
fieldValue = Util.null2String(signDetailInfo.get("signouttime2"));
@ -355,13 +346,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();
@ -435,7 +426,7 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|"+kqdate+"|holidayOvertime_nonleave")));
holidayOvertime_nonleave = holidayOvertime_nonleave<0?0:holidayOvertime_nonleave;
fieldValue = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave+restDayOvertime_4leave+holidayOvertime_4leave+
workingDayOvertime_nonleave+restDayOvertime_nonleave+holidayOvertime_nonleave));
workingDayOvertime_nonleave+restDayOvertime_nonleave+holidayOvertime_nonleave));
data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("overtimeTotal"))));
continue;
}else if(fieldName.equals("businessLeave") || fieldName.equals("officialBusiness")){
@ -460,88 +451,88 @@ 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 {
fieldValue = Util.null2String(rs.getString(fieldName));
fieldValue = getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(fieldid));
}
if(!fieldName.equals("leave")) {
fieldValue = Util.formatMultiLang(fieldValue, "" + user.getLanguage());
data.add(fieldValue);
@ -562,7 +553,6 @@ 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,12 +206,7 @@ public class ExportExcelCmd extends AbstractCommonCommand<Map<String, Object>> {
Map<String,Object> definedFieldInfo = new KQFormatBiz().getDefinedField();
String definedFieldSum = Util.null2String(definedFieldInfo.get("definedFieldSum"));
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," +
String backFields = " a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle," +
" sum(b.workdays) as workdays,sum(b.workMins) as workMins,sum(b.attendancedays) as attendancedays," +
" sum(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," +
@ -438,99 +433,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);

@ -47,7 +47,6 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Objec
RecordSet rs = new RecordSet();
String sql = "";
try{
bb.writeLog("GetKQDailyReportCmd start.");
String pageUid = PageUidFactory.getHrmPageUid("KQDailyReport");
SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo();
@ -145,12 +144,7 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Objec
forgotBeginWorkCheck_field = " isnull(b.forgotBeginWorkCheck,0) ";
}
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," +
String backFields = " 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, "+
@ -235,44 +229,39 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Objec
} else {
sql = " select " + sql;
}
long startTime = System.currentTimeMillis();
Map<String,Object> flowData = kqReportBiz.getDailyFlowData(params,user);
long endTime = System.currentTimeMillis();
long elapsedTime = endTime - startTime; // 执行时间
bb.writeLog("flowData执行时间" + elapsedTime/1000 + "秒");
// bb.writeLog("=-=-flowData: " + flowData);
bb.writeLog("=-=-flowData: " + flowData);
// #1475814-概述:满足考勤报分部部门显示及导出时显示全路径
String fullPathMainKey = "show_full_path";
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);
@ -363,89 +352,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) {
@ -514,9 +503,8 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Objec
retmap.put("ishavepre", isHavePre);
retmap.put("ishavenext", isHaveNext);
}catch (Exception e){
bb.writeLog("GetKQDailyReportCmd error:" + e.getMessage());
writeLog(e);
}
bb.writeLog("GetKQDailyReportCmd end.");
return retmap;
}

@ -39,7 +39,6 @@ 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();
@ -173,12 +172,7 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
Map<String,Object> definedFieldInfo = new KQFormatBiz().getDefinedField();
String definedFieldSum = Util.null2String(definedFieldInfo.get("definedFieldSum"));
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," +
String backFields = " a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle," +
" sum(b.workdays) as workdays,sum(b.workMins) as workMins,sum(b.attendancedays) as attendancedays," +
" sum(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," +
@ -441,99 +435,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) {
@ -617,7 +611,7 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
retmap.put("ishavenext", isHaveNext);
}catch (Exception e){
writeLog(e);
bb.writeLog("GetKQReportCmd Exception: " + e.getMessage());
bb.writeLog("GetKQReportCmd Exception: " + e);
}
return retmap;
}

@ -1,94 +0,0 @@
package weaver.interfaces.hostar.action;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static cn.hutool.http.Method.POST;
/**
* action
*
*
* @author xuxy
* @version 1.00
* @Date 2024/4/1
*/
@Slf4j
public class EmployeeDeleteAction implements Action {
@Override
public String execute(RequestInfo requestInfo) {
BaseBean bb = new BaseBean();
//获取主表数据
Map mainInfo = getMainInfo(requestInfo);
log.info("-EmployeeDeleteAction-主表数据是:"+ JSONObject.toJSONString(mainInfo));
//此处获取主表字段信息
String gh = Util.null2String(mainInfo.get("gh"));//工号
Map<String,String> map = new HashMap<>();
String jsonParam;
String url = Util.null2String(bb.getPropValue("project_hostar", "employeeDelete"));
map.put("jobNo",gh);
jsonParam = JSONObject.toJSONString(map);
String res = callPost(url, jsonParam);
log.info("-EmployeeDeleteAction-接口返回结果res{}",res);
Map mapTypes = new HashMap<>();
if(StringUtils.isNotBlank(res)){
mapTypes = JSON.parseObject(res);
log.info("-EmployeeDeleteAction-mapTypes{}",mapTypes);
}
if(mapTypes.get("code").equals(200)){
log.info("安防接口删除人员信息接口返回成功!");
requestInfo.getRequestManager().setMessagecontent("安防接口删除人员信息接口返回成功!");
return Action.SUCCESS;
}
log.error("接口异常!");
requestInfo.getRequestManager().setMessagecontent("接口异常!");
return Action.FAILURE_AND_CONTINUE;
}
public static String callPost(String url,String jsonParam){
return HttpRequest.post(url).method(POST).header("Content-Type","application/json").body(jsonParam).execute().body();
}
/**
* requestInfo
* */
public static Map<String,Object> getMainInfo(RequestInfo requestInfo){
Map<String,Object> map = new HashMap();
Property[] property = requestInfo.getMainTableInfo().getProperty();
for (int i = 0; i < property.length; i++) {
map.put(property[i].getName().toLowerCase(), Util.null2String(property[i].getValue()));
}
return map;
}
/**
* requestInfo
* */
public static List getDetailInfo(RequestInfo requestInfo, int num){
DetailTable detailTable = requestInfo.getDetailTableInfo().getDetailTable(num);
//dtltable数组中的行数据集合
Row[] rows = detailTable.getRow();
List sublist = new ArrayList();
for (int i = 0; i < rows.length; i++) {
Row row = rows[i];
Map onerow = new HashMap();
sublist.add(onerow);
Cell[] cells = row.getCell();
for (int j = 0; j < cells.length; j++) {
Cell cell = cells[j];
onerow.put(cell.getName(), Util.null2String(cell.getValue()));
}
}
return sublist;
}
}

@ -1,106 +0,0 @@
package weaver.interfaces.hostar.action;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static cn.hutool.http.Method.POST;
/**
* action
*
*
* @author xuxy
* @version 1.00
* @Date 2024/4/1
*/
@Slf4j
public class EmployeeInsertAction implements Action {
@Override
public String execute(RequestInfo requestInfo) {
BaseBean bb = new BaseBean();
//获取主表数据
Map mainInfo = getMainInfo(requestInfo);
log.info("-EmployeeInsertAction-主表数据是:"+ JSONObject.toJSONString(mainInfo));
//此处获取主表字段信息
String xm = Util.null2String(mainInfo.get("xm"));//姓名
String xb = Util.null2String(mainInfo.get("xb"));//性别
String bm = Util.null2String(mainInfo.get("bm"));//部门
String sjhm = Util.null2String(mainInfo.get("sjhm"));//手机号
String zjhm = Util.null2String(mainInfo.get("zjhm"));//身份证号
String rybh = Util.null2String(mainInfo.get("rybh"));//人员编号
Map<String,String> map = new HashMap<>();
String jsonParam;
String url = Util.null2String(bb.getPropValue("project_hostar", "employeeInsert"));
map.put("personName",xm);
map.put("gender","0".equals(xb)?"1":"2");
map.put("orgIndexCode",bm);
map.put("phoneNo",sjhm);
map.put("certificateType","111");
map.put("certificateNo",zjhm);
map.put("jobNo",rybh);
jsonParam = JSONObject.toJSONString(map);
String res = callPost(url, jsonParam);
log.info("-EmployeeInsertAction-接口返回结果res{}",res);
Map mapTypes = new HashMap<>();
if(StringUtils.isNotBlank(res)){
mapTypes = JSON.parseObject(res);
log.info("-EmployeeInsertAction-mapTypes{}",mapTypes);
}
if(mapTypes.get("code").equals(200)){
log.info("安防接口同步人员信息接口返回成功!");
requestInfo.getRequestManager().setMessagecontent("安防接口同步人员信息接口返回成功!");
return Action.SUCCESS;
}
log.error("接口异常!");
requestInfo.getRequestManager().setMessagecontent("接口异常!");
return Action.FAILURE_AND_CONTINUE;
}
public static String callPost(String url,String jsonParam){
return HttpRequest.post(url).method(POST).header("Content-Type","application/json").body(jsonParam).execute().body();
}
/**
* requestInfo
* */
public static Map<String,Object> getMainInfo(RequestInfo requestInfo){
Map<String,Object> map = new HashMap();
Property[] property = requestInfo.getMainTableInfo().getProperty();
for (int i = 0; i < property.length; i++) {
map.put(property[i].getName().toLowerCase(), Util.null2String(property[i].getValue()));
}
return map;
}
/**
* requestInfo
* */
public static List getDetailInfo(RequestInfo requestInfo, int num){
DetailTable detailTable = requestInfo.getDetailTableInfo().getDetailTable(num);
//dtltable数组中的行数据集合
Row[] rows = detailTable.getRow();
List sublist = new ArrayList();
for (int i = 0; i < rows.length; i++) {
Row row = rows[i];
Map onerow = new HashMap();
sublist.add(onerow);
Cell[] cells = row.getCell();
for (int j = 0; j < cells.length; j++) {
Cell cell = cells[j];
onerow.put(cell.getName(), Util.null2String(cell.getValue()));
}
}
return sublist;
}
}

@ -11,23 +11,17 @@ import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.Property;
import weaver.soa.workflow.request.RequestInfo;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
public class OutSignSyncAction implements Action {
BaseBean bb = new BaseBean();
@Override
public String execute(RequestInfo requestInfo) {
bb.writeLog("OutSignSyncAction-start");
String startDate = "";
String endDate = "";
String resourceid = "";
String nbtxr = "";
String sjjsrq = "";
try {
@ -42,38 +36,24 @@ 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;
}
bb.writeLog("start to handle data.");
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 operater in (?) ";
"where operate_date > '" + startDate + "' and operate_date < '" + endDate + "' and operate = ? ";
rs.executeQuery(acqOutSignSql, resourceid);
while (rs.next()) {
String signinfo = Util.null2String(rs.getString("signinfo"));
infos.add(signinfo);
}
bb.writeLog("infos is:" + infos);
for (String inf : infos) {
if (StringUtils.isNotEmpty(inf)) {
if (inf != null ) {
Map<String, Object> in = mapStringToMap(inf);
String userId = Util.null2String(in.get("userId"));
String userType = Util.null2String(in.get("userType"));
@ -91,48 +71,44 @@ public class OutSignSyncAction implements Action {
String deviceInfo = Util.null2String(in.get("deviceInfo"));
String belongdateIsNull = Util.null2String(in.get("belongdateIsNull"));
String punchSql = "insert into HrmScheduleSign(userId,userType,signType,signDate,signTime,clientAddress,isInCom,timeZone,belongdate,signfrom,longitude,latitude,addr,deviceInfo,isdev) " +
String punchSql = "insert into HrmScheduleSign(userId,userType,signType,signDate,signTime,clientAddress,isInCom,timeZone,belongdate,signfrom,longitude,latitude,addr,deviceInfo,isdev) "+
" values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
boolean isok = rs.executeUpdate(punchSql, resourceid, userType, signType, signDate, signTime, clientAddress, isInCom,
timeZone, belongdate, signfrom, longitude, latitude, address, deviceInfo, "1");
boolean isok = rs.executeUpdate(punchSql,resourceid,userType,signType,signDate,signTime,clientAddress,isInCom,
timeZone,belongdate,signfrom,longitude,latitude,address,deviceInfo,"1");
bb.writeLog("isok: " + isok);
//同步更新考勤数据到考勤报表
if ("true".equals(belongdateIsNull)) {
if("true".equals(belongdateIsNull)){
//外勤签到没有归属日期,遇到跨天班次打卡可能归属前一天,需要格式化前一天考勤
bb.writeLog("PunchOutButtonCmd:userId:" + userId + ":belongdate:" + DateUtil.getYesterday());
new KQFormatBiz().formatDate("" + userId, DateUtil.getYesterday());
bb.writeLog("PunchOutButtonCmd:userId:"+userId+":belongdate:"+ DateUtil.getYesterday());
new KQFormatBiz().formatDate(""+userId,DateUtil.getYesterday());
}
bb.writeLog("PunchOutButtonCmd:userId:" + userId + ":belongdate:" + (belongdate.length() == 0 ? DateUtil.getCurrentDate() : belongdate));
if (belongdate.length() == 0) {
bb.writeLog("PunchOutButtonCmd:userId:"+userId+":belongdate:"+(belongdate.length() == 0 ? DateUtil.getCurrentDate() : belongdate));
if(belongdate.length()==0){
//外勤签到没有归属日期,遇到跨天班次打卡可能归属前一天,需要格式化前一天考勤
new KQFormatBiz().formatDate("" + userId, DateUtil.getYesterday());
new KQFormatBiz().formatDate(""+userId,DateUtil.getYesterday());
}
new KQFormatBiz().formatDate("" + userId, (belongdate.length() == 0 ? DateUtil.getCurrentDate() : belongdate));
new KQFormatBiz().formatDate(""+userId,(belongdate.length() == 0 ? DateUtil.getCurrentDate() : belongdate));
//外勤签到转的考勤 处理加班规则
SplitActionUtil.pushOverTimeTasksAll(belongdate, belongdate, "" + userId);
SplitActionUtil.pushOverTimeTasksAll(belongdate,belongdate,""+userId);
}
}
}
} catch (Exception e) {
bb.writeLog("OutSignSyncAction Exception: " + e.getMessage());
bb.writeLog("OutSignSyncAction Exception: " + e);
return Action.FAILURE_AND_CONTINUE;
}
return Action.SUCCESS;
}
public static Map<String, Object> mapStringToMap(String str) {
str = str.substring(1, str.length() - 1);
List<String> strs = splitString(str);
Map<String, Object> map = new HashMap<>();
public static Map<String,Object> mapStringToMap(String str){
str = str.substring(1, str.length()-1);
String[] strs = str.split(",");
Map<String,Object> map = new HashMap<>();
for (String string : strs) {
String[] splits = string.split("=");
String key = splits[0];
String value = "";
if (splits.length > 1) {
value = splits[1];
}
String key = string.split("=")[0];
String value = string.split("=")[1];
// 去掉头部空格
String key1 = key.trim();
String value1 = value.trim();
@ -140,28 +116,4 @@ public class OutSignSyncAction implements Action {
}
return map;
}
public static List<String> splitString(String input) {
List<String> result = new ArrayList<>();
int braceLevel = 0;
int startIndex = 0;
for (int i = 0; i < input.length(); i++) {
char ch = input.charAt(i);
if (ch == '{') {
braceLevel++;
} else if (ch == '}') {
braceLevel--;
} else if (ch == ',' && braceLevel == 0) {
result.add(input.substring(startIndex, i));
startIndex = i + 1;
}
}
if (startIndex < input.length()) {
result.add(input.substring(startIndex));
}
return result;
}
}

@ -1,133 +0,0 @@
package weaver.interfaces.hostar.job;
import com.engine.kq.biz.KQHolidaySetBiz;
import com.engine.kq.biz.KQWorkTime;
import com.engine.kq.entity.WorkTimeEntity;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.interfaces.schedule.BaseCronJob;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
public class AutoScheduNextMonthJob extends BaseCronJob {
private String fromDate;
private String toDate;
public String getFromDate() {
return fromDate;
}
public String getToDate() {
return toDate;
}
public void setFromDate(String fromDate) {
this.fromDate = fromDate;
}
public void setToDate(String toDate) {
this.toDate = toDate;
}
BaseBean bb= new BaseBean();
private final List<String> LIST = new ArrayList<>();
@Override
public void execute() {
bb.writeLog("AutoSchedulJob Start");
try {
//DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
//DateTimeFormatter formatter2 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
//bb.writeLog("fromDate: " + fromDate);
//bb.writeLog("toDate: " + toDate);
//当前日期
//toDate = DateUtils.format(new Date(), "yyyy-MM-dd");
RecordSet rs = new RecordSet();
boolean b = false;
String sql = "insert into kq_shiftschedule(kqdate,serialid,resourceid,groupid,isdelete)values(?,?,?,?,?)";
//责任制考勤组id收集
rs.executeQuery("select kqzid from uf_zrzkqz");
while (rs.next()) {
LIST.add(Util.null2String(rs.getString("kqzid")));
}
bb.writeLog("AutoScheduNextMonthJob.LIST" + LIST);
List<String> userList = new ArrayList<>();
//查询指定和考勤组成员
String query_sql = "select distinct typevalue from kq_groupmember where groupid in" + "('" + String.join("','", LIST) + "')";
rs.execute(query_sql);
while (rs.next()) {
userList.add(Util.null2String(rs.getString("typevalue")));
}
bb.writeLog("AutoScheduNextMonthJob.userList: " + userList);
//查询固班制人员节假日设置
String fixedSerialid = Util.null2String(bb.getPropValue("project_hostar", "fixedSerialid"));
String defaultSerialid = Util.null2String(bb.getPropValue("project_hostar", "defaultSerialid"));
String weekendDefaultSerialid = Util.null2String(bb.getPropValue("project_hostar", "weekendDefaultSerialid"));
String holidayDefaultSerialid = Util.null2String(bb.getPropValue("project_hostar", "holidayDefaultSerialid"));
bb.writeLog("AutoScheduNextMonthJob.fixedSerialid:{},defaultSerialid:{},weekendDefaultSerialid{},holidayDefaultSerialid:{} " + fixedSerialid+defaultSerialid+weekendDefaultSerialid+holidayDefaultSerialid);
String fixedUserId = "";
//查询指定和考勤组成员
String query = "select distinct typevalue from kq_groupmember where groupid = ? ";
rs.executeQuery(query,fixedSerialid);
if (rs.next()) {
fixedUserId = rs.getString("typevalue");
}
bb.writeLog("AutoScheduNextMonthJob.fixedUserId: " + fixedUserId);
//查询下个月的全部日期
List<String> nextMonthDates = getNextMonthDates();
//排默认班次
for (String userId : userList) {
for (String nextMonthDate : nextMonthDates) {
WorkTimeEntity workTimeEntity = new KQWorkTime().getWorkTime(userId, nextMonthDate);
boolean holiday = KQHolidaySetBiz.isHoliday(fixedUserId, nextMonthDate, true);
if (holiday) {
//节假日休息班
b = rs.executeUpdate(sql, nextMonthDate, holidayDefaultSerialid, userId, workTimeEntity.getGroupId(), "0");
} else {
// //周末休息班
// if(DateUtil.getWeek(nextMonthDate) == 6 || DateUtil.getWeek(nextMonthDate) == 7){
// b = rs.executeUpdate(sql, nextMonthDate, weekendDefaultSerialid, userId, workTimeEntity.getGroupId(), "0");
// }else{
b = rs.executeUpdate(sql, nextMonthDate, defaultSerialid, userId, workTimeEntity.getGroupId(), "0");
//}
}
}
}
bb.writeLog("AutoScheduNextMonthJob.b: " + b);
}catch (Exception e) {
bb.writeLog("AutoScheduNextMonthJob Exception: " + e);
}
}
/*
*/
public static List<String> getNextMonthDates() {
// 获取当前时间的Calendar实例
List<String> list = new ArrayList<>();
Calendar cal = Calendar.getInstance();
// 将Calendar实例中的月份加1得到下个月的Calendar实例
cal.add(Calendar.MONTH, 1);
// 获取下个月的天数
int daysInMonth = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
// 循环获取下个月中的每一天的日期
for (int i = 1; i <= daysInMonth; i++) {
// 将Calendar实例中的日期设置为循环变量i的值
cal.set(Calendar.DATE, i);
// 获取日期并格式化
Date date = cal.getTime();
String dateString = new SimpleDateFormat("yyyy-MM-dd").format(date);
list.add(dateString);
}
return list;
}
}

@ -1,92 +0,0 @@
package weaver.interfaces.hostar.job;
import com.engine.kq.biz.KQGroupComInfo;
import com.engine.kq.biz.KQOvertimeRulesBiz;
import com.engine.kq.biz.KQWorkTime;
import com.engine.kq.entity.WorkTimeEntity;
import org.apache.tools.ant.util.DateUtils;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.interfaces.schedule.BaseCronJob;
import java.time.format.DateTimeFormatter;
import java.util.*;
public class AutoSchedulJob extends BaseCronJob {
private String fromDate;
private String toDate;
public String getFromDate() {
return fromDate;
}
public String getToDate() {
return toDate;
}
public void setFromDate(String fromDate) {
this.fromDate = fromDate;
}
public void setToDate(String toDate) {
this.toDate = toDate;
}
BaseBean bb= new BaseBean();
@Override
public void execute() {
bb.writeLog("AutoSchedulJob Start");
try {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
DateTimeFormatter formatter2 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
bb.writeLog("fromDate: " + fromDate);
bb.writeLog("toDate: " + toDate);
//当前日期
toDate = DateUtils.format(new Date(), "yyyy-MM-dd");
RecordSet rs = new RecordSet();
boolean b = false;
//查询所有考勤人员(去除人员)
List<String> userList = new ArrayList<>();
rs.executeQuery("select id from hrmresource where 1=1");
while (rs.next()){
userList.add(Util.null2String(rs.getString("id")));
}
bb.writeLog("AutoSchedulJob.userList: " + userList);
String sql = "insert into kq_shiftschedule(kqdate,serialid,resourceid,groupid,isdelete)values(?,?,?,?,?)";
String sql3 = "select currentnodetype from workflow_requestbase where requestid in (select requestid from kq_flow_split_leave where " +
" resourceid = ? and (fromdatedb +' '+ fromtimedb) <=? and (todatedb+' '+totimedb) >=?) and currentnodetype = '3' ";
//休息日默认排休息班
for (String userId : userList) {
WorkTimeEntity workTimeEntity = new KQWorkTime().getWorkTime(userId, toDate);
/*获取考勤组的ID因为考勤组有有效期所以需要传入日期*/
//String groupId = new KQGroupMemberComInfo().getKQGroupId(userId, toDate);
int changeType = KQOvertimeRulesBiz.getChangeType(userId, toDate);
//无需考勤人员
String excludecount = Util.null2String(new KQGroupComInfo().getExcludecount(workTimeEntity.getGroupId()));//是否参与考勤报表统计
if(workTimeEntity.getIsExclude()&&!excludecount.equals("1")){
continue;
}
if(changeType!=2){
//休息班
b = rs.executeUpdate(sql, toDate, "-1", userId, workTimeEntity.getGroupId(), "0");
}else{
//查询该员工当天是否有已办结的请假流程(有:自动对班;否:不处理)
//6.2 查询这些requestid是否在当天前包含当天已批准
rs.executeQuery(sql3,userId,toDate,toDate);
if(rs.next()){
b = rs.executeUpdate(sql, toDate, "9", userId, workTimeEntity.getGroupId(), "0");
}
}
}
bb.writeLog("AutoSchedulJob.b: " + b);
}catch (Exception e) {
bb.writeLog("AutoSchedulJob Exception: " + e);
}
}
}

@ -1,98 +0,0 @@
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