Compare commits

...

48 Commits
dev-wcf ... dev

Author SHA1 Message Date
Administrator a4cfa1d307 安防接口对接 1 year ago
Administrator fb8689160d Merge remote-tracking branch 'origin/dev' into dev 1 year ago
zhangming 280bd6d7fe 外出actionBUG修复 1 year ago
Administrator 8a94de0d05 责任制下月默认排班设置 1 year ago
Administrator 3727c0a5db Merge remote-tracking branch 'origin/dev' into dev 1 year ago
zhangming a5de914ee9 外出actionBUG修复 1 year ago
zhangming 2fa5df47ab Merge branch 'dev' of http://221.226.25.34:3000/chenwei/weaver-hostar into dev-zm
 Conflicts:
	src/com/engine/kq/cmd/report/ExportDailyExcelCmd.java
1 year ago
zhangming e445596114 生产代码 1 year ago
Administrator c4b72324cb 去除格式化对班代码 1 year ago
Administrator 29e8b1151f Merge remote-tracking branch 'origin/dev' into dev 1 year ago
李栋 99f62328cf 考勤报表导出bug-v1.0待验证 1 year ago
李栋 36601a10fb 外出出差action 1 year ago
Administrator 60ca792a56 Merge remote-tracking branch 'origin/dev' into dev 1 year ago
zhangming 5015d873d6 Merge branch 'dev' of http://221.226.25.34:3000/chenwei/weaver-hostar into dev-zm 1 year ago
李栋 677e414802 Revert "每日报表导出bug"
This reverts commit 04b390e0
1 year ago
李栋 52e0d2f699 Revert "每日报表导出bug"
This reverts commit 04b390e0
1 year ago
李栋 04b390e056 每日报表导出bug 1 year ago
zhangming ac4574470e 餐补报表优化 1 year ago
zhangming 7bef807a51 餐补报表优化 1 year ago
zhangming 33722523d3 餐补报表优化 1 year ago
zhangming 93a9d1f237 餐补优化 1 year ago
zhangming 9285635aee 驻点餐补BUG修复 1 year ago
Administrator 623fc926d2 打卡自动对班 1 year ago
Administrator e853bde2d5 Merge remote-tracking branch 'origin/dev' into dev 1 year ago
zhangming 30ebc44bb8 日报优化-去除不必要日志 1 year ago
zhangming dd07f9838e Merge branch 'dev' of http://221.226.25.34:3000/chenwei/weaver-hostar into dev-zm 1 year ago
zhangming bf0c6a2b46 日报优化-去除不必要日志 1 year ago
chenwei 39c8d460cb 新增打卡地址 1 year ago
Administrator 08f0477879 考勤对班 1 year ago
chenwei 435ac5bbfa 新增打卡地址 1 year ago
chenwei 43dad8ee44 新增打卡地址 1 year ago
chenwei ccfbb426ac 新增打卡地址 1 year ago
chenwei 15ab092f8b 考勤上线后问题处理 1 year ago
chenwei 2066506e17 Merge branch 'dev' into dev-chenwnj 1 year ago
chenwei 5337fba611 考勤上线后问题处理 1 year ago
Administrator 60659fe90d 考勤格式化版本代码合并 1 year ago
Administrator 2a6faf096e 自动对班 1 year ago
chenwei ae383628d5 考勤上线后问题处理 1 year ago
chenwei 7cb5afa79d 考勤上线后问题处理 1 year ago
chenwei 98b6e1847f 考勤上线后问题处理 1 year ago
chenwei 7a0a3e889c 考勤上线后问题处理 1 year ago
chenwei f581a7d9da 删除test文件 1 year ago
chenwei 24212fc10b Merge branch 'dev-chenwnj' into dev 1 year ago
chenwei c808c6d907 考勤上线后问题处理 1 year ago
fage d2cf61fbb7 加班时长根据整点、半点计算代码修改0117 1 year ago
chenwei 81ac13a7b2 实际出勤,打卡地址 1 year ago
chenwei 4faaec7639 三种餐补 1 year ago
chenwei 321a7878d2 餐补 1 year ago

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

@ -2076,7 +2076,7 @@ public class GetHrmSearchResultCmd extends AbstractCommonCommand<Map<String, Obj
else tempstr = appdetawhere; else tempstr = appdetawhere;
String backfields = "*"; String backfields = "*";
String sqlWhere = " " + tempstr; String sqlWhere = " " + tempstr + " and (t2_field0 = 0 or t2_field0 is null )";
String fromSql = ""; String fromSql = "";
String tableString = ""; String tableString = "";
String operateString = ""; String operateString = "";
@ -2198,8 +2198,7 @@ public class GetHrmSearchResultCmd extends AbstractCommonCommand<Map<String, Obj
fromSql = " from HrmResource " fromSql = " from HrmResource "
+ " left join (SELECT " + backfield[0] + " FROM cus_fielddata WHERE scope='HrmCustomFieldByInfoType' AND scopeId=-1 AND seqorder in (SELECT MAX(t.seqorder) FROM (SELECT seqorder,id FROM cus_fielddata WHERE scope = 'HrmCustomFieldByInfoType' AND scopeid=-1) t GROUP BY t.id)) t1 on hrmresource.id=t1_id " + " left join (SELECT " + backfield[0] + " FROM cus_fielddata WHERE scope='HrmCustomFieldByInfoType' AND scopeId=-1 AND seqorder in (SELECT MAX(t.seqorder) FROM (SELECT seqorder,id FROM cus_fielddata WHERE scope = 'HrmCustomFieldByInfoType' AND scopeid=-1) t GROUP BY t.id)) t1 on hrmresource.id=t1_id "
+ " left join (SELECT " + backfield[1] + " FROM cus_fielddata WHERE scope='HrmCustomFieldByInfoType' AND scopeId=1 AND seqorder in (SELECT MAX(t.seqorder) FROM (SELECT seqorder,id FROM cus_fielddata WHERE scope = 'HrmCustomFieldByInfoType' AND scopeid=1) t GROUP BY t.id)) t2 on hrmresource.id=t2_id " + " left join (SELECT " + backfield[1] + " FROM cus_fielddata WHERE scope='HrmCustomFieldByInfoType' AND scopeId=1 AND seqorder in (SELECT MAX(t.seqorder) FROM (SELECT seqorder,id FROM cus_fielddata WHERE scope = 'HrmCustomFieldByInfoType' AND scopeid=1) t GROUP BY t.id)) t2 on hrmresource.id=t2_id "
+ " left join (SELECT " + backfield[2] + " FROM cus_fielddata WHERE scope='HrmCustomFieldByInfoType' AND scopeId=3 AND seqorder in (SELECT MAX(t.seqorder) FROM (SELECT seqorder,id FROM cus_fielddata WHERE scope = 'HrmCustomFieldByInfoType' AND scopeid=3) t GROUP BY t.id)) t3 on hrmresource.id=t3_id and (field0 = 0 or field0 is null) "//二开 + " left join (SELECT " + backfield[2] + " FROM cus_fielddata WHERE scope='HrmCustomFieldByInfoType' AND scopeId=3 AND seqorder in (SELECT MAX(t.seqorder) FROM (SELECT seqorder,id FROM cus_fielddata WHERE scope = 'HrmCustomFieldByInfoType' AND scopeid=3) t GROUP BY t.id)) t3 on hrmresource.id=t3_id "
// + " left join (SELECT " + backfield[2] + " FROM cus_fielddata WHERE scope='HrmCustomFieldByInfoType' AND scopeId=3 AND seqorder in (SELECT MAX(t.seqorder) FROM (SELECT seqorder,id FROM cus_fielddata WHERE scope = 'HrmCustomFieldByInfoType' AND scopeid=3) t GROUP BY t.id)) t3 on hrmresource.id=t3_id "
+ " left join (SELECT id AS dept_id,departmentname AS deptName,showOrder AS deptShowOrder,showOrderOfTree AS showOrderOfDeptTree FROM HrmDepartment) dept on hrmresource.departmentid = dept_id " + " left join (SELECT id AS dept_id,departmentname AS deptName,showOrder AS deptShowOrder,showOrderOfTree AS showOrderOfDeptTree FROM HrmDepartment) dept on hrmresource.departmentid = dept_id "
+ " left join (SELECT id AS subcom_id,subcompanyname AS subcomName,showOrder AS subcomShowOrder,showOrderOfTree AS showOrderOfSubComTree FROM HrmSubCompany) subcom on hrmresource.subcompanyid1 = subcom_id "; + " left join (SELECT id AS subcom_id,subcompanyname AS subcomName,showOrder AS subcomShowOrder,showOrderOfTree AS showOrderOfSubComTree FROM HrmSubCompany) subcom on hrmresource.subcompanyid1 = subcom_id ";
tableString = ""; tableString = "";
@ -2320,6 +2319,7 @@ public class GetHrmSearchResultCmd extends AbstractCommonCommand<Map<String, Obj
String sql = "SELECT " + backfields + " " + fromSql + " " + sqlWhere + " ORDER BY " + orderby; String sql = "SELECT " + backfields + " " + fromSql + " " + sqlWhere + " ORDER BY " + orderby;
bb.writeLog("通讯录-sql: " + sql); bb.writeLog("通讯录-sql: " + sql);
bb.writeLog("通讯录-sqlWhere: " + sqlWhere);
tableString = " <table tabletype=\"" + tabletype + "\" pageId=\"" + pageId + "\" pageUid=\"" + pageUid + "\" exportRight=\"HrmResourceInfo:Import\" isEncryptShare=\""+encryptShareSettingEntity.getIsEnable()+"\" pagesize=\"" + PageIdConst.getPageSize(pageId, user.getUID(), PageIdConst.HRM) + "\" >" + tableString = " <table tabletype=\"" + tabletype + "\" pageId=\"" + pageId + "\" pageUid=\"" + pageUid + "\" exportRight=\"HrmResourceInfo:Import\" isEncryptShare=\""+encryptShareSettingEntity.getIsEnable()+"\" pagesize=\"" + PageIdConst.getPageSize(pageId, user.getUID(), PageIdConst.HRM) + "\" >" +
checkboxpopedompara + checkboxpopedompara +

@ -4,8 +4,6 @@ import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil; import com.engine.common.util.ServiceUtil;
import com.engine.hostar.service.KqDevService; import com.engine.hostar.service.KqDevService;
import com.engine.hostar.service.impl.KqDevServiceImpl; import com.engine.hostar.service.impl.KqDevServiceImpl;
import com.engine.sskj.service.EntryService;
import com.engine.sskj.service.impl.EntryServiceImpl;
import com.google.gson.Gson; import com.google.gson.Gson;
import weaver.hrm.HrmUserVarify; import weaver.hrm.HrmUserVarify;
import weaver.hrm.User; import weaver.hrm.User;
@ -36,12 +34,32 @@ public class KqDevController {
} }
@POST @POST
@Path("/checkApplyDate") @Path("/getEndWorkDate")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public String checkApplyDate(@Context HttpServletRequest request, @Context HttpServletResponse response) { public String getEndWorkDate(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response); User user = HrmUserVarify.getUser(request, response);
Map<String, Object> params = ParamUtil.request2Map(request); Map<String, Object> params = ParamUtil.request2Map(request);
Map<String, Object> resultDatas = getKqDevService(user).checkApplyDate(params); Map<String, Object> resultDatas = getKqDevService(user).getEndWorkDate(params);
return new Gson().toJson(resultDatas);
}
@POST
@Path("/signDelete")
@Produces(MediaType.APPLICATION_JSON)
public String signDelete(@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).signDelete(params);
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); return new Gson().toJson(resultDatas);
} }

@ -10,6 +10,10 @@ import java.util.Map;
public interface KqDevService { public interface KqDevService {
/*获取考勤日期的类型*/ /*获取考勤日期的类型*/
Map<String, Object> getKqType(Map<String, Object> params); Map<String, Object> getKqType(Map<String, Object> params);
/*检查流程发起日期是否满足指定工作日时长*/ /*根据开始日期和偏移量计算结束日期--工作日*/
Map<String, Object> checkApplyDate(Map<String, Object> params); 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,14 +3,22 @@ package com.engine.hostar.service.impl;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.engine.core.impl.Service; import com.engine.core.impl.Service;
import com.engine.hostar.service.KqDevService; import com.engine.hostar.service.KqDevService;
import com.engine.hostar.thread.HandleCBDataThread;
import com.engine.hostar.util.HostarUtil; import com.engine.hostar.util.HostarUtil;
import com.engine.kq.biz.KQHolidaySetBiz;
import com.engine.kq.biz.KQOvertimeRulesBiz; import com.engine.kq.biz.KQOvertimeRulesBiz;
import com.engine.kq.biz.KQWorkTime; import com.engine.kq.biz.KQWorkTime;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.util.CollectionUtils;
import weaver.conn.RecordSet;
import weaver.general.BaseBean; import weaver.general.BaseBean;
import weaver.general.ThreadPoolUtil;
import weaver.general.Util; import weaver.general.Util;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.concurrent.ExecutorService;
/** /**
* @author chenwnj * @author chenwnj
@ -69,7 +77,7 @@ public class KqDevServiceImpl extends Service implements KqDevService {
} }
@Override @Override
public Map<String, Object> checkApplyDate(Map<String, Object> params) { public Map<String, Object> getEndWorkDate(Map<String, Object> params) {
bb.writeLog("---checkApplyDate start---"); bb.writeLog("---checkApplyDate start---");
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
@ -99,56 +107,235 @@ public class KqDevServiceImpl extends Service implements KqDevService {
Integer offset = Util.getIntValue(offsetStr); Integer offset = Util.getIntValue(offsetStr);
bb.writeLog("offset: " + offset); bb.writeLog("offset: " + offset);
KQWorkTime kqWorkTime = new KQWorkTime(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
HostarUtil hostarUtil = new HostarUtil(); LocalDate start = LocalDate.parse(kqDate, formatter);
String today = DateUtil.format(new Date(), "yyyy-MM-dd");
bb.writeLog("today: " + today);
List<String> allDates = new ArrayList<>(); if (offset > 0 ) {
for (int i = 0 ; i < offset ; ) {
start = start.plusDays(1);
boolean holiday = KQHolidaySetBiz.isHoliday(resourceId, start.format(formatter), true);
if ( !holiday) {
i++;
}
}
} else if (offset < 0 ) {
for (int i = 0 ; i > offset ; ) {
start = start.minusDays(1);
boolean holiday = KQHolidaySetBiz.isHoliday(resourceId, start.format(formatter), true);
if ( !holiday) {
i--;
}
}
}
if (today.compareTo(kqDate) < 0 ) { String endDate = start.format(formatter);
if ( offset < 0) { result.put("code",200);
result.put("code",500); result.put("msg","请求成功");
result.put("msg","该流程只能提前"+Math.abs(offset)+"个工作日申请"); result.put("data",endDate);
return result; return result;
} }
allDates = hostarUtil.getAllDates(today, kqDate);
} else if (today.compareTo(kqDate) > 0 ){ @Override
if ( offset > 0) { public Map<String, Object> signDelete(Map<String, Object> params) {
bb.writeLog("---signDelete start---");
Map<String, Object> result = new HashMap<>();
try {
String dataid = Util.null2String(params.get("id"));//申请人
bb.writeLog("dataid: " + dataid);
if ( StringUtils.isBlank(dataid)) {
result.put("code",500); result.put("code",500);
result.put("msg","该流程只能延后"+Math.abs(offset)+"个工作日申请"); result.put("msg","先选择要删除的数据");
return result; return result;
} }
allDates = hostarUtil.getAllDates(kqDate, today);
} else if (today.compareTo(kqDate) == 0) { //将需要删除的打卡数据记录到日志表后再执行删除
if ( offset != 0) { RecordSet rs = new RecordSet();
result.put("code",500); List<String> deleteParams = new ArrayList<>();
result.put("msg","该流程只能当天申请"); List<List> logParams = new ArrayList<>();
return result; String signDelLogModeId = bb.getPropValue("project_hostar", "signDelLogModeId");
bb.writeLog("signDelLogModeId: " + signDelLogModeId);
Integer modedatacreater = user.getUID();
Integer modedatacreatertype = user.getType();
String modedatacreatedate = DateUtil.format(new Date(), "yyyy-MM-dd");
String modedatacreatetime = DateUtil.format(new Date(), "HH:mm:ss");
String acqMaxIdSql = " select max(id) as id from uf_schsigndellog";
String logSignSql = "insert into uf_schsigndellog (userid, usertype, signtype, signdate, signtime, clientaddress, isincom, " +
" signfrom, longitude, latitude, addr, isimport, suuid, timezone, belongdate, memo, deviceinfo, showaddress, " +
" formmodeid, modedatacreater, modedatacreatertype, modedatacreatedate, modedatacreatetime ) " +
" values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
String acqSchSignSql = "select userid, usertype, signtype, signdate, signtime, clientaddress, isincom," +
" signfrom, longitude, latitude, addr, isimport, suuid, timezone, belongdate, memo, " +
" deviceinfo, showaddress from hrmschedulesign where id in (" + dataid + ")";
rs.executeQuery(acqSchSignSql);
while (rs.next()) {
String userid = Util.null2String(rs.getString("userid"));
String usertype = Util.null2String(rs.getString("usertype"));
String signtype = Util.null2String(rs.getString("signtype"));
String signdate = Util.null2String(rs.getString("signdate"));
String signtime = Util.null2String(rs.getString("signtime"));
String clientaddress = Util.null2String(rs.getString("clientaddress"));
String isincom = Util.null2String(rs.getString("isincom"));
String signfrom = Util.null2String(rs.getString("signfrom"));
String longitude = Util.null2String(rs.getString("longitude"));
String latitude = Util.null2String(rs.getString("latitude"));
String addr = Util.null2String(rs.getString("addr"));
String isimport = Util.null2String(rs.getString("isimport"));
String suuid = Util.null2String(rs.getString("suuid"));
String timezone = Util.null2String(rs.getString("timezone"));
String belongdate = Util.null2String(rs.getString("belongdate"));
String memo = Util.null2String(rs.getString("memo"));
String deviceinfo = Util.null2String(rs.getString("deviceinfo"));
String showaddress = Util.null2String(rs.getString("showaddress"));
List logPa = new ArrayList<>();
logPa.add(userid);
logPa.add(usertype);
logPa.add(signtype);
logPa.add(signdate);
logPa.add(signtime);
logPa.add(clientaddress);
logPa.add(isincom);
logPa.add(signfrom);
logPa.add(longitude);
logPa.add(latitude);
logPa.add(addr);
logPa.add(isimport);
logPa.add(suuid);
logPa.add(timezone);
logPa.add(belongdate);
logPa.add(memo);
logPa.add(deviceinfo);
logPa.add(showaddress);
logPa.add(signDelLogModeId);
logPa.add(modedatacreater);
logPa.add(modedatacreatertype);
logPa.add(modedatacreatedate);
logPa.add(modedatacreatetime);
logParams.add(logPa);
} }
allDates = hostarUtil.getAllDates(kqDate, today);
int maxLogId = -1;
rs.executeQuery(acqMaxIdSql);
while (rs.next()) {
maxLogId = Util.getIntValue(Util.null2String(rs.getString("id")));
} }
bb.writeLog("allDates: " + allDates); bb.writeLog("maxLogId: " + maxLogId);
int workdays = -1; boolean addLogFlag = rs.executeBatchSql(logSignSql, logParams);
for ( String date: allDates) { bb.writeLog("addLogFlag: " + addLogFlag);
//判断是否是工作日 if (addLogFlag) {
boolean isWorkDay = kqWorkTime.isWorkDay(resourceId, date); List<Integer> billids = new ArrayList<>();
if (isWorkDay){ Map<Integer,Integer> billidCreator = new HashMap<>();
workdays ++; String acqBillidsSql = "select id from uf_schsigndellog where id > ?";
rs.executeQuery(acqBillidsSql, maxLogId);
while (rs.next()) {
Integer id = Util.getIntValue(Util.null2String(rs.getString("id")));
billids.add(id);
billidCreator.put(id, 1);
} }
bb.writeLog("billids: " + billids);
bb.writeLog("billidCreator: " + billidCreator);
if (billids != null && billids.size() > 0) {
HostarUtil hsutil = new HostarUtil();
hsutil.modePerReconBatch(billidCreator, signDelLogModeId, billids);
}
} else {
result.put("code",500);
result.put("msg","删除失败");
return result;
} }
bb.writeLog("workdays: " + workdays);
if (workdays <= Math.abs(offset)) { boolean delFlag = rs.executeUpdate("delete from hrmschedulesign where id in (" + dataid + ")");
if (delFlag) {
result.put("code",200); result.put("code",200);
result.put("msg","允许申请"); result.put("msg","删除成功");
return result; return result;
} else { } else {
result.put("code",500); result.put("code",500);
result.put("msg","超出允许申请的时间限制,允许申请的时间为:申请日期" + result.put("msg","删除失败");
(offset>= 0?(offset>0 ?"延迟"+Math.abs(offset) + "天" : "当天" ):"提前" + Math.abs(offset) + "天") ); return result;
}
}catch (Exception e ) {
bb.writeLog("signDelete Exception: " + e);
}
result.put("code",500);
result.put("msg","删除失败");
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; 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

@ -1,11 +1,14 @@
package com.engine.hostar.util; package com.engine.hostar.util;
import weaver.formmode.setup.ModeRightInfo;
import weaver.general.BaseBean; import weaver.general.BaseBean;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/** /**
* @author chenwnj * @author chenwnj
@ -60,5 +63,58 @@ public class HostarUtil {
return EARTH_RADIUS * c; return EARTH_RADIUS * c;
} }
/**
*
* @param userId
* @param modeId
* @param billid
*/
public void modePerRecon(Integer userId, String modeId, String billid) {
ModeRightInfo ModeRightInfo = new ModeRightInfo();
ModeRightInfo.setNewRight(true);
ModeRightInfo.editModeDataShare( userId, Integer.parseInt(modeId), Integer.parseInt(billid));
}
/**
*
* @param billid_creator
* @param modeId
* @param billids
*/
public void modePerReconBatch(Map<Integer,Integer> billid_creator, String modeId, List<Integer> billids) {
ModeRightInfo ModeRightInfo = new ModeRightInfo();
ModeRightInfo.setNewRight(true);
ModeRightInfo.editModeDataShare( billid_creator, Integer.parseInt(modeId), billids);
}
/**
* mapmapkey
*/
public Map<String, Object> parseMapForFilter(Map<String, Object> map, String filters) {
if (map == null) {
return null;
} else {
map = map.entrySet().stream()
.filter((e) -> checkKey(e.getKey(),filters))
.collect(Collectors.toMap(
(e) -> (String) e.getKey(),
(e) -> e.getValue()
));
}
return map;
}
/**
* indexof
*/
private boolean checkKey(String key,String filters) {
if (key.indexOf(filters)>-1){
return true;
}else {
return false;
}
}
} }

File diff suppressed because it is too large Load Diff

@ -24,6 +24,8 @@ import java.util.*;
public class KQFormatSignData extends BaseBean { public class KQFormatSignData extends BaseBean {
private KQLog kqLog = new KQLog(); private KQLog kqLog = new KQLog();
BaseBean bb = new BaseBean();
public List<Object> getSignInfo(String userId, TimeScopeEntity signTimeScope, public List<Object> getSignInfo(String userId, TimeScopeEntity signTimeScope,
TimeScopeEntity workTimeScope, String kqDate, String preDate, TimeScopeEntity workTimeScope, String kqDate, String preDate,
String nextDate, KQTimesArrayComInfo kqTimesArrayComInfo) { String nextDate, KQTimesArrayComInfo kqTimesArrayComInfo) {
@ -56,6 +58,9 @@ public class KQFormatSignData extends BaseBean {
String count4NoonStartDateTime = ""; String count4NoonStartDateTime = "";
String count4NoonEndDateTime = ""; String count4NoonEndDateTime = "";
try{ try{
bb.writeLog("getSignInfo start");
Map<String, Object> checkInfo = null; Map<String, Object> checkInfo = null;
String base_sql = ""; String base_sql = "";
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();
@ -365,126 +370,245 @@ public class KQFormatSignData extends BaseBean {
} }
/*考勤二开--出差公出流程获取外勤打卡数据start*/ /*考勤二开--出差公出流程获取外勤打卡数据start*/
BaseBean bb = new BaseBean(); // BaseBean bb = new BaseBean();
//
bb.writeLog("--出差公出流程获取外勤打卡数据start"); // bb.writeLog("+-出差公出流程获取外勤打卡数据start");
bb.writeLog("lsCheckInfo: " + lsCheckInfo); // bb.writeLog("lsCheckInfo: " + lsCheckInfo);
//获取外勤打卡的前提是已经有归档的出差、公出流程 // bb.writeLog("lsCheckInfo.size(): " + lsCheckInfo.size());
String evectionTableName = Util.null2String(bb.getPropValue("project_hostar","evectionTableName")); // //获取外勤打卡的前提是已经有归档的出差、公出流程
bb.writeLog("evectionTableName: " + evectionTableName); // String evectionTableName = Util.null2String(bb.getPropValue("project_hostar","evectionTableName"));
//// bb.writeLog("evectionTableName: " + evectionTableName);
String outTableName = Util.null2String(bb.getPropValue("project_hostar","outTableName")); //
bb.writeLog("outTableName: " + outTableName); // String outTableName = Util.null2String(bb.getPropValue("project_hostar","outTableName"));
//// bb.writeLog("outTableName: " + outTableName);
if ( StringUtils.isNotBlank(evectionTableName) && StringUtils.isNotBlank(outTableName) ) { //
RecordSet rs = new RecordSet(); // if ( StringUtils.isNotBlank(evectionTableName) && StringUtils.isNotBlank(outTableName) ) {
Integer number = -1; // RecordSet rs = new RecordSet();
String acqEvecAndOutSql = " select sum(a.number) as number " + // Integer number = -1;
" from ( " + // String acqEvecAndOutSql = " select sum(a.number) as number " +
" SELECT " + // " from ( " +
" count(*) as number " + // " SELECT " +
" FROM " + // " count(*) as number " +
" workflow_requestbase " + // " FROM " +
" WHERE " + // " workflow_requestbase " +
" requestid IN ( SELECT requestid FROM "+evectionTableName+" WHERE sqr = '"+userId+"' and ksrq <='"+kqDate+"' and yjjsrq >='"+kqDate+"' ) " + // " WHERE " +
" AND currentnodetype = 3 " + // " requestid IN ( SELECT requestid FROM "+evectionTableName+" WHERE sqr = '"+userId+"' and ksrq <='"+kqDate+"' and yjjsrq >='"+kqDate+"' ) " +
" UNION all " + // " AND currentnodetype = 3 " +
" SELECT " + // " UNION all " +
" count(*) as number " + // " SELECT " +
" FROM " + // " count(*) as number " +
" workflow_requestbase " + // " FROM " +
" WHERE " + // " workflow_requestbase " +
" requestid IN ( SELECT requestid FROM "+outTableName+" WHERE sqr = '"+userId+"' and ksrq <='"+kqDate+"' and yjjsrq >='"+kqDate+"') " + // " WHERE " +
" AND currentnodetype = 3 " + // " requestid IN ( SELECT requestid FROM "+outTableName+" WHERE sqr = '"+userId+"' and ksrq <='"+kqDate+"' and yjjsrq >='"+kqDate+"') " +
") a "; //// " AND currentnodetype = 3 " +
rs.executeQuery(acqEvecAndOutSql); // ") a ";
bb.writeLog("acqEvecAndOutSql: " + acqEvecAndOutSql); // rs.executeQuery(acqEvecAndOutSql);
//// bb.writeLog("acqEvecAndOutSql: " + acqEvecAndOutSql);
while (rs.next()) { //
number = Util.getIntValue(Util.null2String(rs.getString("number"))); // while (rs.next()) {
} // number = Util.getIntValue(Util.null2String(rs.getString("number")));
bb.writeLog("number: " + number); // }
// bb.writeLog("number: " + number);
if (lsCheckInfo.size() == 0 && number > 0) { //
List<String> legWorkInfos = new ArrayList<>(); // if (lsCheckInfo.size() < 2 && number > 0) {//只考虑每天一次上下班,原始打卡记录没有取到两次打卡记录则考虑外勤打卡
//获取允许打卡时间 // List<String> legWorkInfos = new ArrayList<>();
String signBeginTime = signTimeScope.getBeginTime(); // //获取允许打卡时间
bb.writeLog("signBeginTime: " + signBeginTime); // String signBeginTime = signTimeScope.getBeginTime();
if (StringUtils.isNotBlank(signBeginTime)) { //// bb.writeLog("signBeginTime: " + signBeginTime);
signBeginTime = signBeginTime + ":00"; // if (StringUtils.isNotBlank(signBeginTime)) {
} // signBeginTime = signBeginTime + ":00";
bb.writeLog("signBeginTime: " + signBeginTime); // }
//获取上班时间 //// bb.writeLog("signBeginTime: " + signBeginTime);
String workBeginTime = workTimeScope.getBeginTime(); // //获取上班时间
bb.writeLog("workBeginTime: " + workBeginTime); // String workBeginTime = workTimeScope.getBeginTime();
if (StringUtils.isNotBlank(workBeginTime)) { //// bb.writeLog("workBeginTime: " + workBeginTime);
workBeginTime = workBeginTime + ":00"; // if (StringUtils.isNotBlank(workBeginTime)) {
} // workBeginTime = workBeginTime + ":00";
bb.writeLog("workBeginTime: " + workBeginTime); // }
//// bb.writeLog("workBeginTime: " + workBeginTime);
String acqLegWorkSignSql = "select operate_time from mobile_sign where operater = ? and operate_date = '" + kqDate + "' and operate_time >='" + signBeginTime + "' order by operate_time asc "; //
bb.writeLog("acqLegWorkSignSql: " + acqLegWorkSignSql); // String acqLegWorkSignSql = "select operate_time from mobile_sign where operater = ? and operate_date = '" + kqDate + "' and operate_time >='" + signBeginTime + "' order by operate_time asc ";
bb.writeLog("userId: " + userId); // bb.writeLog("acqLegWorkSignSql: " + acqLegWorkSignSql);
rs.executeQuery(acqLegWorkSignSql, userId); //// bb.writeLog("userId: " + userId);
while ( rs.next()) { // rs.executeQuery(acqLegWorkSignSql, userId);
String operateTime = Util.null2String(rs.getString("operate_time")); // while ( rs.next()) {
if ( StringUtils.isNotBlank(operateTime) ) { // String operateTime = Util.null2String(rs.getString("operate_time"));
legWorkInfos.add(operateTime); // if ( StringUtils.isNotBlank(operateTime) ) {
} // legWorkInfos.add(operateTime);
} // }
bb.writeLog("legWorkInfos: " + legWorkInfos); // }
// bb.writeLog("legWorkInfos: " + legWorkInfos);
if (legWorkInfos != null && legWorkInfos.size() > 0 ) { //
String tempSignIn = ""; // if (legWorkInfos != null && legWorkInfos.size() > 0 ) {
String tempSignOut = ""; // boolean onFlag = false;//上班卡
Map<String, Object> checkInfo = new HashMap<>(); // boolean offFlag = false;//下班卡
if ( legWorkInfos.size() == 1) {//只有一笔外勤卡直接算上班 //
checkInfo.put("signType", "1"); // //判断需要获取的打卡
checkInfo.put("signDate", kqDate);//签到签退日期 // for(Object obj: lsCheckInfo) {
checkInfo.put("signTime", legWorkInfos.get(0));//签到签退时间 // if (obj != null) {
checkInfo.put("deduct_signintime", "");//流程抵扣作为打卡时间 // Map<String, Object> checkInfo = (Map<String, Object> ) obj;
checkInfo.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode()); // Integer signType = Util.getIntValue(Util.null2String(checkInfo.get("signType")));
lsCheckInfo.add(checkInfo); // if (signType == 1) {
} else { // onFlag = true;
for ( String signTime : legWorkInfos) { // }
if (signTime.compareTo(workBeginTime) < 0) {//获取上班时间点之前最早的一笔卡 // if (signType == 2) {
if (StringUtils.isBlank(tempSignIn)) { // offFlag = true;
tempSignIn = signTime; // }
} else { // }
if ( signTime.compareTo(tempSignIn) < 0 ) { // }
tempSignIn = signTime; //
} // String tempSignIn = "";
} // String tempSignOut = "";
} // Map<String, Object> checkInfo = new HashMap<>();
if ( signTime.compareTo(workBeginTime) > 0) {//下班卡取最晚的一笔 // if ( legWorkInfos.size() == 1) {//只有一笔外勤卡直接算上班
if (StringUtils.isBlank(tempSignIn)) { // if ( onFlag && !offFlag ) {
tempSignOut = signTime; // checkInfo.put("signType", "2");
} else { // checkInfo.put("signDate", kqDate);//签到签退日期
if ( signTime.compareTo(tempSignOut) > 0 ) { // checkInfo.put("signTime", legWorkInfos.get(0));//签到签退时间
tempSignOut = signTime; // checkInfo.put("deduct_signintime", "");//流程抵扣作为打卡时间
} // checkInfo.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode());
} // lsCheckInfo.add(checkInfo);
} // }
} // if ( !onFlag && offFlag ) {
checkInfo.put("signType", "1"); // checkInfo.put("signType", "1");
checkInfo.put("signDate", kqDate);//签到签退日期 // checkInfo.put("signDate", kqDate);//签到签退日期
checkInfo.put("signTime", tempSignIn);//签到签退时间 // checkInfo.put("signTime", legWorkInfos.get(0));//签到签退时间
checkInfo.put("deduct_signintime", "");//流程抵扣作为打卡时间 // checkInfo.put("deduct_signintime", "");//流程抵扣作为打卡时间
checkInfo.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode()); // checkInfo.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode());
lsCheckInfo.add(checkInfo); // lsCheckInfo.add(checkInfo);
checkInfo = new HashMap<>(); // }
checkInfo.put("signType", "2"); //
checkInfo.put("signDate", kqDate);//签到签退日期 // } else {
checkInfo.put("signTime", tempSignOut);//签到签退时间 // for ( String signTime : legWorkInfos) {
checkInfo.put("deduct_signintime", "");//流程抵扣作为打卡时间 // if (signTime.compareTo(workBeginTime) < 0) {//获取上班时间点之前最早的一笔卡
checkInfo.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode()); // if (StringUtils.isBlank(tempSignIn)) {
lsCheckInfo.add(checkInfo); // tempSignIn = signTime;
} // } else {
// if ( signTime.compareTo(tempSignIn) < 0 ) {
} // tempSignIn = signTime;
} // }
} // }
bb.writeLog("lsCheckInfo: " + lsCheckInfo); // }
// if ( signTime.compareTo(workBeginTime) > 0) {//下班卡取最晚的一笔
// if (StringUtils.isBlank(tempSignIn)) {
// tempSignOut = signTime;
// } else {
// if ( signTime.compareTo(tempSignOut) > 0 ) {
// tempSignOut = signTime;
// }
// }
// }
// }
// if (offFlag && !onFlag ) {
// checkInfo.put("signType", "1");
// checkInfo.put("signDate", kqDate);//签到签退日期
// checkInfo.put("signTime", tempSignIn);//签到签退时间
// checkInfo.put("deduct_signintime", "");//流程抵扣作为打卡时间
// checkInfo.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode());
// lsCheckInfo.add(checkInfo);
// }
// if (onFlag && !offFlag ) {
// checkInfo = new HashMap<>();
// checkInfo.put("signType", "2");
// checkInfo.put("signDate", kqDate);//签到签退日期
// checkInfo.put("signTime", tempSignOut);//签到签退时间
// checkInfo.put("deduct_signintime", "");//流程抵扣作为打卡时间
// checkInfo.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode());
// lsCheckInfo.add(checkInfo);
// }
// }
// }
// } else if ( lsCheckInfo.size() == 2) {
// List<String> legWorkInfos = new ArrayList<>();
// //获取允许打卡时间
// String signBeginTime = signTimeScope.getBeginTime();
//// bb.writeLog("signBeginTime: " + signBeginTime);
// if (StringUtils.isNotBlank(signBeginTime)) {
// signBeginTime = signBeginTime + ":00";
// }
//// bb.writeLog("signBeginTime: " + signBeginTime);
// //获取上班时间
// String workBeginTime = workTimeScope.getBeginTime();
//// bb.writeLog("workBeginTime: " + workBeginTime);
// if (StringUtils.isNotBlank(workBeginTime)) {
// workBeginTime = workBeginTime + ":00";
// }
//// bb.writeLog("workBeginTime: " + workBeginTime);
//
// String acqLegWorkSignSql = "select operate_time from mobile_sign where operater = ? and operate_date = '" + kqDate + "' and operate_time >='" + signBeginTime + "' order by operate_time asc ";
// bb.writeLog("acqLegWorkSignSql: " + acqLegWorkSignSql);
// bb.writeLog("userId: " + userId);
// rs.executeQuery(acqLegWorkSignSql, userId);
// while ( rs.next()) {
// String operateTime = Util.null2String(rs.getString("operate_time"));
// if ( StringUtils.isNotBlank(operateTime) ) {
// legWorkInfos.add(operateTime);
// }
// }
//// bb.writeLog("legWorkInfos: " + legWorkInfos);
//
// if (legWorkInfos != null && legWorkInfos.size() > 0 ) {
//
// String tempSignIn = "";
// String tempSignOut = "";
// Map<String, Object> checkInfo = new HashMap<>();
// if ( legWorkInfos.size() == 1) {//只有一笔外勤卡直接算上班
//
// checkInfo.put("signType", "1");
// checkInfo.put("signDate", kqDate);//签到签退日期
// checkInfo.put("signTime", legWorkInfos.get(0));//签到签退时间
// checkInfo.put("deduct_signintime", "");//流程抵扣作为打卡时间
// checkInfo.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode());
// lsCheckInfo.add(checkInfo);
//
//
// } else {
// for ( String signTime : legWorkInfos) {
// if (signTime.compareTo(workBeginTime) < 0) {//获取上班时间点之前最早的一笔卡
// if (StringUtils.isBlank(tempSignIn)) {
// tempSignIn = signTime;
// } else {
// if ( signTime.compareTo(tempSignIn) < 0 ) {
// tempSignIn = signTime;
// }
// }
// }
// if ( signTime.compareTo(workBeginTime) > 0) {//下班卡取最晚的一笔
// if (StringUtils.isBlank(tempSignOut)) {
// tempSignOut = signTime;
// } else {
// if ( signTime.compareTo(tempSignOut) > 0 ) {
// tempSignOut = signTime;
// }
// }
// }
// }
//
// if(StringUtils.isNotBlank(tempSignIn)) {
// checkInfo.put("signType", "1");
// checkInfo.put("signDate", kqDate);//签到签退日期
// checkInfo.put("signTime", tempSignIn);//签到签退时间
// checkInfo.put("deduct_signintime", "");//流程抵扣作为打卡时间
// checkInfo.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode());
// lsCheckInfo.add(checkInfo);
// }
//
// if(StringUtils.isNotBlank(tempSignIn)) {
// checkInfo = new HashMap<>();
// checkInfo.put("signType", "2");
// checkInfo.put("signDate", kqDate);//签到签退日期
// checkInfo.put("signTime", tempSignOut);//签到签退时间
// checkInfo.put("deduct_signintime", "");//流程抵扣作为打卡时间
// checkInfo.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode());
// lsCheckInfo.add(checkInfo);
// }
//
// }
// }
// }
// }
// bb.writeLog("lsCheckInfo: " + lsCheckInfo);
/*考勤二开--出差公出流程获取外勤打卡数据end*/ /*考勤二开--出差公出流程获取外勤打卡数据end*/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,548 @@
package com.engine.kq.biz;
import com.engine.kq.bean.KQHrmScheduleSign;
import com.engine.kq.log.KQLog;
import com.engine.kq.wfset.util.KQSignUtil;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 退
*/
public class KQScheduleSignBiz {
private KQLog kqLog = new KQLog();
private String resourceid;
private String userType;
private String signDate;
private String signTime;
private String worksection;
/**
*
*/
private String belongdate;
private String signtype;
private String signDateTimeSql;
/**
*
*/
private String signSectionTime;
/**
*
*/
private String signSectionEndTime;
/**
*
*/
private String signSectionBeginTime;
/**
*
*/
private String offSignSectionTime;
private int shiftCount;
private int shiftI;
private String count4NoonStartDateTime;
private String count4NoonEndDateTime;
private KQScheduleSignBiz(KQScheduleSignParamBuilder build){
this.resourceid = build.resourceid;
this.userType = build.userType;
this.signDate = build.signDate;
this.signTime = build.signTime;
this.belongdate = build.belongdate;
this.signtype = build.signtype;
this.worksection = build.worksection;
this.signDateTimeSql = build.signDateTimeSql;
this.signSectionTime = build.signSectionTime;
this.signSectionEndTime = build.signSectionEndTime;
this.signSectionBeginTime = build.signSectionBeginTime;
this.offSignSectionTime = build.offSignSectionTime;
this.shiftCount = build.shiftCount;
this.shiftI = build.shiftI;
this.count4NoonStartDateTime = build.count4NoonStartDateTime;
this.count4NoonEndDateTime = build.count4NoonEndDateTime;
}
/**
* 退
* @return
*/
public List<KQHrmScheduleSign> getFreeScheduleSignInfo() {
RecordSet rs = new RecordSet();
String signSql = "select * from hrmschedulesign where 1=1 and isInCom='1' ";
String sqlWhere = sqlParamWhere();
if(sqlWhere.length() > 0){
signSql += sqlWhere;
}
signSql += " order by signdate,signtime";
List<KQHrmScheduleSign> kqHrmScheduleSigns = new ArrayList<>();
try{
rs.execute(signSql);
while (rs.next()){
KQHrmScheduleSign kqHrmScheduleSign = getSignBean(rs);
kqHrmScheduleSigns.add(kqHrmScheduleSign);
}
}catch (Exception e){
e.printStackTrace();
}
return kqHrmScheduleSigns;
}
/**
*
* 退
* @return
*/
public Map<String,KQHrmScheduleSign> getScheduleSignInfoWithCardRange(){
String signSql = "";
Map<String,KQHrmScheduleSign> signMap = new HashMap<>();
RecordSet rs = new RecordSet();
String dbtype = rs.getDBType();
String baseSql = "select * from hrmschedulesign where 1=1 and isInCom='1' ";
String sqlWhere = sqlParamWhere();
if(sqlWhere.length() > 0){
baseSql += sqlWhere;
}
if(signSectionEndTime.length() == 0 && signSectionBeginTime.length() == 0){
//如果没设置上班后,下班前打卡
String signTimeSql = KQSignUtil.buildSignSql(signSectionTime,offSignSectionTime);
if(signTimeSql.length() > 0){
baseSql += " and "+signTimeSql;
}
if(baseSql.length() > 0){
signSql = baseSql;
signSql += " order by signdate,signtime";
kqLog.info("signSql:"+signSql);
try{
rs.execute(signSql);
while (rs.next()){
getScheduleSignBean(rs,signMap);
}
}catch (Exception e){
e.printStackTrace();
}
}
}else {
if(shiftCount == 4 && shiftI==2) {
String signSectionEndTime2 = count4NoonStartDateTime.substring(0, count4NoonStartDateTime.length() - 2) + "00";
String noonSignTimeSql = KQSignUtil.buildSignSql(signSectionEndTime2, count4NoonEndDateTime);
String sql = baseSql;
if (sqlWhere.length() > 0) {
sql += sqlWhere + " and " + noonSignTimeSql + " order by signdate, signtime";
}
rs.executeQuery(sql);
int count = 0;
while (rs.next()) {
if(count == 0) {
count ++;
continue;
}
// 午休时段如果有打卡的话,取第二次打卡算作下午第一次签到
KQHrmScheduleSign kqHrmScheduleSign = getSignBean(rs);
signMap.put("signin", kqHrmScheduleSign);
signMap.put("signinNoon", kqHrmScheduleSign);
if (count == 1) {
break;
}
}
}
String onSignTimeSql = "";
if(shiftCount == 4 && shiftI==2) {
onSignTimeSql = KQSignUtil.buildSignSql(count4NoonEndDateTime,signSectionEndTime);
} else {
onSignTimeSql = KQSignUtil.buildSignSql(signSectionTime,signSectionEndTime);
}
String offSignTimeSql = KQSignUtil.buildSignSql(signSectionBeginTime,offSignSectionTime);
String onSql = "";
String orderSql = "";
if(onSignTimeSql.length() > 0){
orderSql = " order by signdate asc, signtime asc ";
onSql += "select 'on' as belongtype,t.* from ("+baseSql+" and "+onSignTimeSql+") t";
if("oracle".equalsIgnoreCase(dbtype)){
onSql = "select * from ("+onSql+" "+orderSql+" ) a where rownum=1";
}else if("mysql".equalsIgnoreCase(dbtype)){
onSql = "select * from (select * from ("+onSql+" "+orderSql+" ) a limit 0,1) a ";
}
else if("postgresql".equalsIgnoreCase(dbtype)){
onSql = "select * from (select * from ("+onSql+" "+orderSql+" ) a limit 1 offset 0) a ";
}
else if("sqlserver".equalsIgnoreCase(dbtype)){
onSql = "select top 1 * from ("+onSql+" ) a "+" "+orderSql ;
}
}
String offSql = "";
if(offSignTimeSql.length() > 0){
orderSql = " order by signdate desc, signtime desc ";
offSql += "select 'off' as belongtype,t.* from ("+baseSql+" and "+offSignTimeSql+") t";
if("oracle".equalsIgnoreCase(dbtype)){
offSql = "select * from ("+offSql+" "+orderSql+" ) a where rownum=1";
}else if("mysql".equalsIgnoreCase(dbtype)){
offSql = "select * from (select * from ("+offSql+" "+orderSql+" ) a limit 0,1) a ";
}
else if("postgresql".equalsIgnoreCase(dbtype)){
offSql = "select * from (select * from ("+offSql+" "+orderSql+" ) a limit 1 offset 0) a ";
}
else if("sqlserver".equalsIgnoreCase(dbtype)){
offSql = "select top 1 * from ("+offSql+" ) a "+" "+orderSql ;
}
}
if(onSql.length() > 0 && offSql.length() > 0){
signSql = "select * from ("+onSql+" UNION ALL "+offSql+") s ";
kqLog.info("signSql:"+signSql);
try{
Map<String,KQHrmScheduleSign> checkMap = new HashMap<>();
rs.execute(signSql);
while (rs.next()){
getScheduleSignCardRangeBean(rs,signMap,checkMap);
}
}catch (Exception e){
e.printStackTrace();
}
}
if(shiftCount == 4 && shiftI==0) { // 一天4次卡的上午签退卡的统计
String signSectionEndTime2 = signSectionEndTime.substring(0, signSectionEndTime.length()-2)+"00";
String noonSignTimeSql = KQSignUtil.buildSignSql(signSectionEndTime2,offSignSectionTime);
String sql = baseSql;
if(sqlWhere.length() > 0){
sql += sqlWhere+" and "+noonSignTimeSql + " order by signdate, signtime";
}
rs.executeQuery(sql);
if (rs.next()) {
String signTime = rs.getString("signtime");
KQHrmScheduleSign kqHrmScheduleSignOut = signMap.get("signout");
String oldSignTime = kqHrmScheduleSignOut.getSigntime();
// 午休时段如果有打卡的话,取第一次打卡算作签退
if(signTime.compareTo(oldSignTime) < 0) {
kqHrmScheduleSignOut.setSigntime(signTime);
}
}
}
}
return signMap;
}
/**
* 退
* @param rs
* @param signMap
* @param checkMap
*/
public void getScheduleSignCardRangeBean(RecordSet rs, Map<String, KQHrmScheduleSign> signMap,
Map<String, KQHrmScheduleSign> checkMap){
String belongtype =Util.null2String(rs.getString("belongtype"));
if(shiftCount == 4 && shiftI==2) {
if(!signMap.isEmpty()) {
KQHrmScheduleSign kqHrmScheduleSignNoon = signMap.get("signinNoon");
KQHrmScheduleSign kqHrmScheduleSignOn = signMap.get("signin");
if(kqHrmScheduleSignNoon != null) {
if("on".equalsIgnoreCase(belongtype)) {
return;
} else {
KQHrmScheduleSign kqHrmScheduleSign = getSignBean(rs);
if(kqHrmScheduleSign != null && kqHrmScheduleSignOn.equals(kqHrmScheduleSign)) {
return;
}
signMap.put("signout",kqHrmScheduleSign);
return;
}
}
}
}
KQHrmScheduleSign kqHrmScheduleSign = getSignBean(rs);
if("on".equalsIgnoreCase(belongtype)){
if(!checkMap.containsKey("on")){
signMap.put("signin",kqHrmScheduleSign);
}
}else{
KQHrmScheduleSign kqHrmScheduleSignOn = signMap.get("signin");
if(kqHrmScheduleSignOn != null && kqHrmScheduleSign != null && kqHrmScheduleSignOn.equals(kqHrmScheduleSign)) {
return;
}
signMap.put("signout",kqHrmScheduleSign);
}
}
/**
* 退
* @param rs
* @param signMap
*/
public void getScheduleSignBean(RecordSet rs,Map<String,KQHrmScheduleSign> signMap){
KQHrmScheduleSign kqHrmScheduleSign = getSignBean(rs);
if(signMap.isEmpty()){
signMap.put("signin",kqHrmScheduleSign);
}else {
signMap.put("signout",kqHrmScheduleSign);
}
}
public KQHrmScheduleSign getSignBean(RecordSet rs){
BaseBean bb = new BaseBean();
KQHrmScheduleSign kqHrmScheduleSign = new KQHrmScheduleSign();
String id=Util.null2String(rs.getString("id"));
String userid=Util.null2String(rs.getString("userid"));
String usertype =Util.null2String(rs.getString("usertype"));
String signtype=Util.null2String(rs.getString("signtype"));
String signdate=Util.null2String(rs.getString("signdate"));
String signtime=Util.null2String(rs.getString("signtime"));
String clientaddress=Util.null2String(rs.getString("clientaddress"));
String signfrom=Util.null2String(rs.getString("signfrom"));
String longitude=Util.null2String(rs.getString("longitude"));
String latitude=Util.null2String(rs.getString("latitude"));
/*考勤二开--打卡地址改为办公地点start*/
// String addr=Util.null2String(rs.getString("addr"));
String addr=Util.null2String(rs.getString("showaddress"));
bb.writeLog("打卡地址: " + addr);
/*考勤二开--打卡地址改为办公地点end*/
String isincom=Util.null2String(rs.getString("isincom"));
String isimport=Util.null2String(rs.getString("isimport"));
String importsql=Util.null2String(rs.getString("importsql"));
String belongdate=Util.null2String(rs.getString("belongdate"));
String serialid=Util.null2String(rs.getString("serialid"));
String worksections=Util.null2String(rs.getString("worksection"));
String signstatus=Util.null2String(rs.getString("signstatus"));
kqHrmScheduleSign.setId(id);
kqHrmScheduleSign.setUserid(userid);
kqHrmScheduleSign.setUsertype(usertype);
kqHrmScheduleSign.setSigntype(signtype);
kqHrmScheduleSign.setSigndate(signdate);
kqHrmScheduleSign.setSigntime(signtime);
kqHrmScheduleSign.setClientaddress(clientaddress);
kqHrmScheduleSign.setSignfrom(signfrom);
kqHrmScheduleSign.setLongitude(longitude);
kqHrmScheduleSign.setLatitude(latitude);
kqHrmScheduleSign.setAddr(addr);
kqHrmScheduleSign.setIsincom(isincom);
kqHrmScheduleSign.setIsimport(isimport);
kqHrmScheduleSign.setImportsql(importsql);
kqHrmScheduleSign.setBelongdate(belongdate);
kqHrmScheduleSign.setSerialid(serialid);
kqHrmScheduleSign.setWorksections(worksections);
kqHrmScheduleSign.setSignstatus(signstatus);
return kqHrmScheduleSign;
}
/**
*
* @return
*/
public Map<String,KQHrmScheduleSign> getScheduleSignInfo(){
RecordSet rs = new RecordSet();
String signSql = "select * from hrmschedulesign where 1=1 and isInCom='1' ";
String sqlWhere = sqlParamWhere();
if(sqlWhere.length() > 0){
signSql += sqlWhere;
}
signSql += " order by signdate,signtime";
Map<String,KQHrmScheduleSign> signMap = new HashMap<>();
try{
kqLog.info("signSql:"+signSql);
rs.execute(signSql);
while (rs.next()){
getScheduleSignBean(rs,signMap);
}
}catch (Exception e){
e.printStackTrace();
}
return signMap;
}
/**
*
* @return
*/
private String sqlParamWhere() {
String sqlWhere = "";
if(resourceid.length() > 0){
sqlWhere += " and userid in ( "+resourceid+" )";
}
if(signDate.length() > 0){
sqlWhere += " and signDate = '"+signDate+"' ";
}
if(signTime.length() > 0){
sqlWhere += " and signTime = '"+signTime+"' ";
}
if(signDateTimeSql.length() > 0){
sqlWhere += " and "+signDateTimeSql;
}
if(belongdate.length() > 0){
sqlWhere += " and belongdate = '"+belongdate+"' ";
}
if(signtype.length() > 0){
sqlWhere += " and signtype = '"+signtype+"' ";
}
//不需要userType没啥用
// if(userType.length() > 0){
// sqlWhere += " and userType = '"+userType+"' ";
// }
if(worksection.length() > 0){
sqlWhere += " and worksection = '"+worksection+"' ";
}
return sqlWhere;
}
public static class KQScheduleSignParamBuilder{
private String resourceid;
private String userType;
private String signDate;
private String signTime;
private String belongdate;
private String signtype;
private String worksection;
private int shiftCount;
private int shiftI;
private String count4NoonStartDateTime;
private String count4NoonEndDateTime;
/**
* sql
*/
private String signDateTimeSql;
/**
*
*/
private String signSectionTime;
/**
*
*/
private String signSectionEndTime;
/**
*
*/
private String signSectionBeginTime;
/**
*
*/
private String offSignSectionTime;
public KQScheduleSignParamBuilder() {
this.resourceid = resourceid;
//初始化的时候需要把其他参数先清空下
this.userType = "";
this.signDate = "";
this.signTime = "";
this.belongdate = "";
this.signtype = "";
this.worksection = "";
this.signDateTimeSql = "";
this.signSectionTime = "";
this.signSectionEndTime = "";
this.signSectionBeginTime = "";
this.offSignSectionTime = "";
this.shiftCount = 0;
this.shiftI = 0;
this.count4NoonStartDateTime = "";
this.count4NoonEndDateTime = "";
}
//成员方法返回其自身,所以可以链式调用
public KQScheduleSignParamBuilder resourceidParam(final String resourceid) {
this.resourceid = resourceid;
return this;
}
public KQScheduleSignParamBuilder userTypeParam(final String userType) {
this.userType = userType;
return this;
}
public KQScheduleSignParamBuilder shiftCountParam(final int shiftCount) {
this.shiftCount = shiftCount;
return this;
}
public KQScheduleSignParamBuilder count4NoonStartDateTimeParam(final String count4NoonStartDateTime) {
this.count4NoonStartDateTime = count4NoonStartDateTime;
return this;
}
public KQScheduleSignParamBuilder count4NoonEndDateTimeParam(final String count4NoonEndDateTime) {
this.count4NoonEndDateTime = count4NoonEndDateTime;
return this;
}
public KQScheduleSignParamBuilder shiftIParam(final int shiftI) {
this.shiftI = shiftI;
return this;
}
public KQScheduleSignParamBuilder signDateParam(final String signDate) {
this.signDate = signDate;
return this;
}
public KQScheduleSignParamBuilder signTimeParam(final String signTime) {
this.signTime = signTime;
return this;
}
public KQScheduleSignParamBuilder belongDateParam(final String belongdate) {
this.belongdate = belongdate;
return this;
}
public KQScheduleSignParamBuilder signtypeParam(final String signtype) {
this.signtype = signtype;
return this;
}
public KQScheduleSignParamBuilder worksectionParam(final String worksection) {
this.worksection = worksection;
return this;
}
public KQScheduleSignParamBuilder signDateTimeSqlParam(final String signDateTimeSql) {
this.signDateTimeSql = signDateTimeSql;
return this;
}
public KQScheduleSignParamBuilder signSectionTimeParam(final String signSectionTime) {
this.signSectionTime = signSectionTime;
return this;
}
public KQScheduleSignParamBuilder signSectionEndTimeParam(final String signSectionEndTime) {
this.signSectionEndTime = signSectionEndTime;
return this;
}
public KQScheduleSignParamBuilder signSectionBeginTimeParam(final String signSectionBeginTime) {
this.signSectionBeginTime = signSectionBeginTime;
return this;
}
public KQScheduleSignParamBuilder offSignSectionTimeParam(final String offSignSectionTime) {
this.offSignSectionTime = offSignSectionTime;
return this;
}
//Builder的build方法返回外部类的实例
public KQScheduleSignBiz build() {
return new KQScheduleSignBiz(this);
}
}
}

@ -0,0 +1,672 @@
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;
}
}

@ -0,0 +1,501 @@
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.entity.KQGroupEntity;
import com.engine.kq.entity.WorkTimeEntity;
import com.engine.kq.log.KQLog;
import com.engine.kq.wfset.util.SplitActionUtil;
import com.google.common.collect.Maps;
import org.apache.commons.codec.digest.DigestUtils;
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;
import javax.servlet.http.HttpServletRequest;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.Map.Entry;
/**
* 退
*/
public class PunchOutButtonCmd extends AbstractCommonCommand<Map<String, Object>> {
private HttpServletRequest request;
public KQLog kqLog = new KQLog();
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;
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);
}
KQCardLogBiz.logCardInfo(user.getUID()+"", logMap, workTimeEntityLogMap, "punchOutButton");
return retmap;
}
/**
* ip
*/
private boolean checkIsInIp() {
KQGroupBiz kqGroupBiz = new KQGroupBiz();
String clientAddress = Util.getIpAddr(request);
return kqGroupBiz.getIsInScope(user.getUID()+"", clientAddress);
}
private void insertSign(Map<String, Object> retmap) {
logMap.put("lastname", user.getLastname());
logMap.put("params", params);
// signSection: 2019-03-20 08:30#2019-03-20 18:30
RecordSet rs = new RecordSet();
RecordSet rs1 = new RecordSet();
String serialid = Util.null2String(params.get("serialid"));
//应上班 工作时间点
String time = Util.null2String(params.get("time"));
//应上班 工作时间 带日期
String datetime = Util.null2String(params.get("datetime"));
//允许打卡时段 带日期
String signSectionTime = Util.null2String(params.get("signSectionTime"));
//打卡所属worksection的对应的点
String type = Util.null2String(params.get("type"));
//所属打卡日期
String belongdate = Util.null2String(params.get("belongdate"));
boolean belongdateIsNull = belongdate.length()==0;
String islastsign = Util.null2String(params.get("islastsign"));
String isPunchOpen = Util.null2String(params.get("isPunchOpen"));
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 = "";
}
String address = Util.null2String(params.get("address"));
String ismobile = Util.null2String(params.get("ismobile"));
String remark = Util.null2String(params.get("remark"));
String attachment = Util.null2String(params.get("fileids"));
//区分是来自于钉钉还是EM7
String browser = Util.null2String(params.get("browser"));
//客户
String crm = Util.null2String(params.get("crm"));
//是否开启外勤签到转考勤
String outsidesign = "";
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
KQGroupEntity kqGroupEntity = kqGroupMemberComInfo.getUserKQGroupInfo(user.getUID()+"");
String kqGroupEntityInfo = kqGroupEntity != null ? JSON.toJSONString(kqGroupEntity): "";
logMap.put("kqGroupEntityInfo", kqGroupEntityInfo);
if (kqGroupEntity != null) {
outsidesign = kqGroupEntity.getOutsidesign();
}
kqLog.info(user.getLastname()+":params:"+params+":outsidesign:"+outsidesign);
int userId = user.getUID();
String signfrom = "e9_mobile_out";
DateTimeFormatter allFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
LocalDateTime localTime = LocalDateTime.now();
String signTime =localTime.format(dateTimeFormatter);
String signDate = localTime.format(dateFormatter);
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 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);
if(zone_localTime != null && zone_localTime.length == 2){
signDate = zone_localTime[0];
signTime = zone_localTime[1];
}
}
String timeZone = Util.null2String(TimeZoneVar.getTimeZone(),"");
String signData = Util.null2String(params.get("signData"));
String groupid = workTimeEntity.getGroupId();
String text ="wea"+ userId + groupid;
kqLog.writeLog("PunchOutButtonCmd>text=" + text);
String ma5Text = DigestUtils.md5Hex(text)+"ver";
kqLog.writeLog("PunchOutButtonCmd>ma5Text=" + ma5Text+";signData=" + signData);
if(!signData.equals(ma5Text)){
retmap.put("status", "0");
retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage()));
return ;
}
String mobile_sign_sql = "insert into mobile_sign(operater,operate_type,operate_date,operate_time,longitude,latitude,address,remark,attachment,crm,timezone) "
+ " values(?,?,?,?,?,?,?,?,?,?,?) ";
rs1.executeUpdate(mobile_sign_sql, userId,signfrom,signDate,signTime,longitude,latitude,address,remark,attachment,crm,timeZone);
logMap.put("outsidesign", outsidesign);
if("1".equalsIgnoreCase(outsidesign)){
JSONObject jsonObject = null;
String deviceInfo = Util.null2String(params.get("deviceInfo"));
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();
}
}
if("DingTalk".equalsIgnoreCase(browser)){
signfrom = "DingTalk_out";
}else if("Wechat".equalsIgnoreCase(browser)){
signfrom = "Wechat_out";
String weChat_deviceid = Util.null2String(request.getSession().getAttribute(EMManager.DeviceId));
kqLog.info("EMManager.DeviceId:"+EMManager.DeviceId+":weChat_deviceid:"+weChat_deviceid);
logMap.put("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 isfree = Util.null2String(params.get("isfree"));
String userType = user.getLogintype();
String signType = "on".equalsIgnoreCase(type) ? "1" : "2";
String clientAddress = Util.getIpAddr(request);
boolean isInIp = true;
String isInCom = isInIp ? "1" : "0";
String datetime_timezone = signDate+" "+signTime;
LocalDateTime nowDateTime = LocalDateTime.parse(datetime_timezone,allFormatter);
kqLog.info("timeZone:"+timeZone+":signDate:"+signDate+":signTime:"+signTime+":nowDateTime:"+nowDateTime);
boolean isInScope = true;
if(signsection != null && signsection.length() > 0){
List<String> signsectionList = Util.TokenizerString(signsection, ",");
for(int i = 0 ; i < signsectionList.size() ; i++){
String signsections = Util.null2String(signsectionList.get(i));
String[] signsection_arr = signsections.split("#");
if(signsection_arr != null && signsection_arr.length == 2){
String canStart = signsection_arr[0];
String canEnd = signsection_arr[1];
LocalDateTime startSignDateTime = LocalDateTime.parse(canStart,allFormatter);
LocalDateTime endSignDateTime = LocalDateTime.parse(canEnd,allFormatter);
if(nowDateTime.isBefore(startSignDateTime) || nowDateTime.isAfter(endSignDateTime)){
isInScope = false;
}else{
isInScope = true;
break;
}
}
}
}
if(!isInScope){
//外勤的不在范围内也不管,全部计入考勤表
// retmap.put("status", "1");
// retmap.put("message", SystemEnv.getHtmlLabelName(503597 , user.getLanguage()));
// return ;
}
if(belongdate.length() == 0){
belongdate = signDate;
}
deviceInfo = deviceInfo.replaceAll("\\?", "");
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,address,deviceInfo);
logMap.put("punchSql", punchSql);
logMap.put("punchSql_isok", isok);
//同步更新考勤数据到考勤报表
if(belongdateIsNull){
//外勤签到没有归属日期,遇到跨天班次打卡可能归属前一天,需要格式化前一天考勤
kqLog.info("PunchOutButtonCmd:userId:"+userId+":belongdate:"+DateUtil.getYesterday());
new KQFormatBiz().formatDate(""+userId,DateUtil.getYesterday());
}
kqLog.info("PunchOutButtonCmd:userId:"+userId+":belongdate:"+(belongdate.length() == 0 ? DateUtil.getCurrentDate() : belongdate));
if(belongdate.length()==0){
//外勤签到没有归属日期,遇到跨天班次打卡可能归属前一天,需要格式化前一天考勤
new KQFormatBiz().formatDate(""+userId,DateUtil.getYesterday());
}
new KQFormatBiz().formatDate(""+userId,(belongdate.length() == 0 ? DateUtil.getCurrentDate() : belongdate));
//外勤签到转的考勤 处理加班规则
SplitActionUtil.pushOverTimeTasksAll(belongdate,belongdate,""+userId);
}
/*考勤二开--外出出差流程外勤打卡start*/
else {
bb.writeLog("外勤打卡转考勤卡start");
bb.writeLog("params: " + params);
bb.writeLog("signdate: " + signDate);
//先判断是否有外出出差流程
String evectionTableName = Util.null2String(bb.getPropValue("project_hostar","evectionTableName"));
String outTableName = Util.null2String(bb.getPropValue("project_hostar","outTableName"));
if ( StringUtils.isNotBlank(evectionTableName) && StringUtils.isNotBlank(outTableName) ) {
Integer number = -1;
String sqlDate = "";
if (StringUtils.isNotBlank(belongdate)) {
sqlDate = belongdate;
} else {
sqlDate = signDate;
}
String acqEvecAndOutSql = " select sum(a.number) as number " +
" from ( " +
" SELECT " +
" count(*) as number " +
" 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 + "'))) " +
// " AND currentnodetype = 3 " +
" UNION all " +
" SELECT " +
" count(*) as number " +
" 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 + "'))) " +
// " AND currentnodetype = 3 " +
") a ";
bb.writeLog("acqEvecAndOutSql: " + acqEvecAndOutSql);
rs.executeQuery(acqEvecAndOutSql);
while (rs.next()) {
number = Util.getIntValue(Util.null2String(rs.getString("number")));
}
bb.writeLog("number: " + number);
if (number > 0) {
boolean isInIp = true;
String userType = user.getLogintype();
String signType = "on".equalsIgnoreCase(type) ? "1" : "2";
String clientAddress = Util.getIpAddr(request);
String isInCom = isInIp ? "1" : "0";
JSONObject jsonObject = null;
String deviceInfo = Util.null2String(params.get("deviceInfo"));
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 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,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){
//外勤签到没有归属日期,遇到跨天班次打卡可能归属前一天,需要格式化前一天考勤
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){
//外勤签到没有归属日期,遇到跨天班次打卡可能归属前一天,需要格式化前一天考勤
new KQFormatBiz().formatDate(""+userId,DateUtil.getYesterday());
}
new KQFormatBiz().formatDate(""+userId,(belongdate.length() == 0 ? DateUtil.getCurrentDate() : belongdate));
//外勤签到转的考勤 处理加班规则
SplitActionUtil.pushOverTimeTasksAll(belongdate,belongdate,""+userId);
} else {
String acqSql = "select id from mobile_sign where operater = ? and operate_date = ? and operate_time = ? ";
rs.executeQuery(acqSql, userId, signDate, signTime);
while (rs.next()) {
String id = Util.null2String(rs.getString("id"));
if (StringUtils.isNotBlank(id)) {
//整理原始打卡信息
Map<String, Object> signInfo = new HashMap<>();
boolean isInIp = true;
String userType = user.getLogintype();
String signType = "on".equalsIgnoreCase(type) ? "1" : "2";
String clientAddress = Util.getIpAddr(request);
String isInCom = isInIp ? "1" : "0";
JSONObject jsonObject = null;
String deviceInfo = Util.null2String(params.get("deviceInfo"));
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();
}
}
signInfo.put("userId", userId);
signInfo.put("userType", userType);
signInfo.put("signType", signType);
signInfo.put("signDate", signDate);
signInfo.put("signTime", signTime);
signInfo.put("clientAddress", clientAddress);
signInfo.put("isInCom", isInCom);
signInfo.put("timeZone", timeZone);
signInfo.put("belongdate", belongdate);
signInfo.put("signfrom", signfrom);
signInfo.put("longitude", longitude);
signInfo.put("latitude", latitude);
signInfo.put("address", address);
signInfo.put("deviceInfo", deviceInfo);
signInfo.put("isdev", "1");
signInfo.put("belongdateIsNull", belongdateIsNull);
String signInfoString = signInfo.toString();
String outSignTypeModeId = bb.getPropValue("project_hostar", "outSignTypeModeId");
Integer modedatacreater = 1;
Integer modedatacreatertype = 0;
String modedatacreatedate = cn.hutool.core.date.DateUtil.format(new Date(), "yyyy-MM-dd");
String modedatacreatetime = cn.hutool.core.date.DateUtil.format(new Date(), "HH:mm:ss");
String abnUuid = UUID.randomUUID().toString();
String syncSql = "insert into uf_outsigntype (outsignid, signinfo, formmodeid, modedatacreater, " +
"modedatacreatertype, modedatacreatedate, modedatacreatetime, MODEUUID) values (?, ?, ?, ?, ?, ?, ?, ?)";
boolean b = rs.executeUpdate(syncSql, id, signInfoString, outSignTypeModeId, modedatacreater, modedatacreatertype, modedatacreatedate, modedatacreatetime, abnUuid);
if (b) {
String billid = "-1";
String acqModeIdSql = "select id from uf_outsigntype where MODEUUID = ?";
rs.executeQuery(acqModeIdSql, abnUuid);
while (rs.next()) {
billid = Util.null2String(rs.getString("id"));
}
bb.writeLog("billid" + billid);
new HostarUtil().modePerRecon(modedatacreater, outSignTypeModeId, billid);
}
}
}
}
}
bb.writeLog("外勤打卡转考勤卡end");
}
/*考勤二开--外出出差流程外勤打卡end*/
retmap.put("status", "1");
retmap.put("signdate", signDate);
retmap.put("signtime", signTime);
logMap.put("retmap", retmap);
}
@Override
public BizLogContext getLogContext() {
return null;
}
}

@ -5,12 +5,15 @@ import com.alibaba.fastjson.JSONObject;
import com.engine.common.biz.AbstractCommonCommand; import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext; import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext; import com.engine.core.interceptor.CommandContext;
import com.engine.hostar.util.HostarUtil;
import com.engine.kq.biz.*; import com.engine.kq.biz.*;
import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit; import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit;
import com.engine.kq.util.ExcelUtil; import com.engine.kq.util.ExcelUtil;
import com.engine.kq.util.KQDurationCalculatorUtil; import com.engine.kq.util.KQDurationCalculatorUtil;
import org.apache.commons.lang3.StringUtils;
import weaver.common.DateUtil; import weaver.common.DateUtil;
import weaver.conn.RecordSet; import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.TimeUtil; import weaver.general.TimeUtil;
import weaver.general.Util; import weaver.general.Util;
import weaver.hrm.User; import weaver.hrm.User;
@ -29,6 +32,7 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
private HttpServletRequest request; private HttpServletRequest request;
private HttpServletResponse response; private HttpServletResponse response;
private List<String> lsFieldDataKey; private List<String> lsFieldDataKey;
BaseBean bb = new BaseBean();
public ExportDailyExcelCmd(Map<String, Object> params, HttpServletRequest request, HttpServletResponse response, User user) { public ExportDailyExcelCmd(Map<String, Object> params, HttpServletRequest request, HttpServletResponse response, User user) {
this.user = user; this.user = user;
@ -44,6 +48,7 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();
String sql = ""; String sql = "";
try { try {
bb.writeLog("ExportDailyExcelCmd start.");
SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo();
DepartmentComInfo departmentComInfo = new DepartmentComInfo(); DepartmentComInfo departmentComInfo = new DepartmentComInfo();
ResourceComInfo resourceComInfo = new ResourceComInfo(); ResourceComInfo resourceComInfo = new ResourceComInfo();
@ -180,13 +185,18 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
}else { }else {
forgotBeginWorkCheck_field = " isnull(b.forgotBeginWorkCheck,0) "; forgotBeginWorkCheck_field = " isnull(b.forgotBeginWorkCheck,0) ";
} }
String backFields = " zm.cccb as mealAllowance," +
String backFields = " a.id,a.lastname,a.subcompanyid1 as subcompanyid,a.departmentid, a.workcode,b.jobtitle,a.dsporder," + " zm.zdcb as statAllowance," +
" b.kqdate, b.workdays,b.workMins,b.serialid, b.attendancedays,b.attendanceMins,b.beLate," + " 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," +
" 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.beLateMins,b.graveBeLate,b.graveBeLateMins,b.leaveEearly,b.leaveEarlyMins,b.graveLeaveEarly," +
" b.graveLeaveEarlyMins,b.absenteeism,b.signdays,b.signmins, "+ " b.graveLeaveEarlyMins,b.absenteeism,b.signdays,b.signmins, "+
" b.absenteeismMins ,(b.forgotCheck+"+forgotBeginWorkCheck_field+") forgotCheck "; " b.absenteeismMins ,(b.forgotCheck+"+forgotBeginWorkCheck_field+") forgotCheck,zeropoint ";
String sqlFrom = " from hrmresource a, kq_format_total b where a.id= b.resourceid and b.kqdate >='"+fromDate+"' and b.kqdate <='"+toDate+"'"; 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 sqlWhere = rightSql; String sqlWhere = rightSql;
if(subCompanyId.length()>0){ if(subCompanyId.length()>0){
sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") ";
@ -228,7 +238,37 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo();
String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey),"0"); String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey),"0");
long startTime = System.currentTimeMillis();
Map<String,Object> flowData = kqReportBiz.getDailyFlowData(params,user); 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);
rs.execute(sql); rs.execute(sql);
while (rs.next()) { while (rs.next()) {
data = new ArrayList<>(); data = new ArrayList<>();
@ -276,6 +316,9 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
} else if(fieldName.equals("signin1")){ } else if(fieldName.equals("signin1")){
fieldValue = Util.null2String(signDetailInfo.get("signintime1")); fieldValue = Util.null2String(signDetailInfo.get("signintime1"));
data.add(fieldValue); data.add(fieldValue);
//考勤二开
fieldValue = Util.null2String(signDetailInfo.get("signinaddress1"));
data.add(fieldValue);
fieldValue = Util.null2String(signDetailInfo.get("signinstatus1")); fieldValue = Util.null2String(signDetailInfo.get("signinstatus1"));
data.add(fieldValue); data.add(fieldValue);
continue; continue;
@ -294,6 +337,9 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
} else if(fieldName.equals("signout1")){ } else if(fieldName.equals("signout1")){
fieldValue = Util.null2String(signDetailInfo.get("signouttime1")); fieldValue = Util.null2String(signDetailInfo.get("signouttime1"));
data.add(fieldValue); data.add(fieldValue);
//考勤二开
fieldValue = Util.null2String(signDetailInfo.get("signoutaddress1"));
data.add(fieldValue);
fieldValue = Util.null2String(signDetailInfo.get("signoutstatus1")); fieldValue = Util.null2String(signDetailInfo.get("signoutstatus1"));
data.add(fieldValue); data.add(fieldValue);
continue; continue;
@ -309,13 +355,13 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
fieldValue = Util.null2String(signDetailInfo.get("signoutstatus3")); fieldValue = Util.null2String(signDetailInfo.get("signoutstatus3"));
data.add(fieldValue); data.add(fieldValue);
continue; continue;
} else if (fieldName.equals("mealAllowance")) { // } else if (fieldName.equals("mealAllowance")) {//考勤二开--出差餐补
int intValue = Util.getIntValue(Util.null2String(flowData.get("DailyMealAllow|" + resourceId + "|" + kqdate))); // int intValue = Util.getIntValue(Util.null2String(flowData.get("DailyMealAllow|" + resourceId + "|" + kqdate)));
if (intValue < 0) { // if (intValue < 0) {
intValue = 0; // intValue = 0;
} // }
data.add(intValue); // data.add(intValue);
continue; // continue;
} else if(fieldName.equals("leave")){ } else if(fieldName.equals("leave")){
//请假 //请假
List<Map<String, Object>> allLeaveRules = KQLeaveRulesBiz.getAllLeaveRules(); List<Map<String, Object>> allLeaveRules = KQLeaveRulesBiz.getAllLeaveRules();
@ -414,6 +460,81 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
}catch (Exception e){ }catch (Exception e){
} }
fieldValue = KQDurationCalculatorUtil.getDurationRound(businessLeave); 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(fieldName.equals("kqdate")){ } else if(fieldName.equals("kqdate")){
fieldValue=kqdate+" "+com.engine.portal.util.DateUtil.getDayWeekOfDate1(DateUtil.parseToDate(kqdate)); fieldValue=kqdate+" "+com.engine.portal.util.DateUtil.getDayWeekOfDate1(DateUtil.parseToDate(kqdate));
} else { } else {
@ -441,6 +562,7 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
retmap.putAll(exportMap); retmap.putAll(exportMap);
retmap.put("status", "1"); retmap.put("status", "1");
} catch (Exception e) { } catch (Exception e) {
bb.writeLog("ExportDailyExcelCmd error:" + e.getMessage());
retmap.put("status", "-1"); retmap.put("status", "-1");
retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage()));
writeLog(e); writeLog(e);
@ -530,13 +652,26 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
String sql = ""; String sql = "";
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
try{ try{
sql = " select kqdate,resourceid,serialid,serialnumber,workbegindate,workbegintime, " + // sql = " select kqdate,resourceid,serialid,serialnumber,workbegindate,workbegintime, " +
" workenddate,workendtime,workmins,signindate,signintime,signoutdate,signouttime, \n" + // " workenddate,workendtime,workmins,signindate,signintime,signoutdate,signouttime, \n" +
" attendanceMins,belatemins,graveBeLateMins,leaveearlymins,graveLeaveEarlyMins,absenteeismmins,forgotcheckMins,forgotBeginWorkCheckMins," + // " attendanceMins,belatemins,graveBeLateMins,leaveearlymins,graveLeaveEarlyMins,absenteeismmins,forgotcheckMins,forgotBeginWorkCheckMins," +
" leaveMins,leaveInfo,evectionMins,outMins,signinid,signoutid \n" + // " leaveMins,leaveInfo,evectionMins,outMins,signinid,signoutid \n" +
" from kq_format_detail b \n" + // " from kq_format_detail b \n" +
" where resourceid = " + resourceId + " and kqdate ='" + kqDate + "' \n" + // " where resourceid = " + resourceId + " and kqdate ='" + kqDate + "' \n" +
" order by serialnumber \n"; // " order by serialnumber \n";
/*考勤二开--增加打卡地址start*/
sql = " select a.kqdate,a.resourceid,a.serialid,a.serialnumber,a.workbegindate,a.workbegintime, " +
" a.workenddate,a.workendtime,a.workmins,a.signindate,a.signintime,a.signoutdate,a.signouttime, \n" +
" a.attendanceMins,a.belatemins,a.graveBeLateMins,a.leaveearlymins,a.graveLeaveEarlyMins,a.absenteeismmins,a.forgotcheckMins,a.forgotBeginWorkCheckMins," +
" a.leaveMins,a.leaveInfo,a.evectionMins,a.outMins,a.signinid,a.signoutid, b.addr as signinaddr, c.addr as signoutaddr \n" +
" from kq_format_detail a " +
" left join hrmschedulesign b on b.id = a.signinid \n" +
" left join hrmschedulesign c on c.id = a.signoutid \n" +
" where a.resourceid = " + resourceId + " and a.kqdate ='" + kqDate + "' \n" +
" order by a.serialnumber \n";
/*考勤二开--增加打卡地址end*/
rs.execute(sql); rs.execute(sql);
while (rs.next()) { while (rs.next()) {
String resourceid = Util.null2String(rs.getString("resourceid")); String resourceid = Util.null2String(rs.getString("resourceid"));
@ -564,6 +699,10 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
String leaveInfo = Util.null2String(rs.getString("leaveInfo")); String leaveInfo = Util.null2String(rs.getString("leaveInfo"));
int evectionMins = rs.getInt("evectionMins"); int evectionMins = rs.getInt("evectionMins");
int outMins = rs.getInt("outMins"); int outMins = rs.getInt("outMins");
String signInAddr = Util.null2String(rs.getString("signinaddr"));
String signOutAddr = Util.null2String(rs.getString("signoutaddr"));
bb.writeLog("signInAddr: " + signInAddr);
bb.writeLog("signOutAddr: " + signOutAddr);
if(serialid.length()>0){ if(serialid.length()>0){
@ -582,6 +721,7 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
data.put("signintime"+serialnumber, signintime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signintime); data.put("signintime"+serialnumber, signintime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signintime);
data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on")); data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on"));
data.put("signinaddress"+serialnumber, signInAddr);
} }
if (workendtime.length() > 0) { if (workendtime.length() > 0) {
@ -600,6 +740,7 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
data.put("signouttime"+serialnumber, signouttime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signouttime); data.put("signouttime"+serialnumber, signouttime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signouttime);
data.put("signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off")); data.put("signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off"));
data.put("signoutaddress"+serialnumber, signOutAddr);
} }
}else{ }else{
if(workMins>0){ if(workMins>0){
@ -614,9 +755,11 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Objec
if(signinid.length() > 0){ if(signinid.length() > 0){
data.put("signintime"+serialnumber, signintime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signintime); data.put("signintime"+serialnumber, signintime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signintime);
data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on")); data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on"));
data.put("signinaddress"+serialnumber, signInAddr);
if(signoutid.length() > 0){ if(signoutid.length() > 0){
data.put("signouttime"+serialnumber, signouttime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signouttime); data.put("signouttime"+serialnumber, signouttime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signouttime);
data.put("signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off")); data.put("signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off"));
data.put("signoutaddress"+serialnumber, signOutAddr);
} }
}else{ }else{
data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on")); data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on"));

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.engine.common.biz.AbstractCommonCommand; import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext; import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext; import com.engine.core.interceptor.CommandContext;
import com.engine.hostar.util.HostarUtil;
import com.engine.kq.biz.*; import com.engine.kq.biz.*;
import com.engine.kq.util.ExcelUtil; import com.engine.kq.util.ExcelUtil;
import com.engine.kq.util.KQDurationCalculatorUtil; import com.engine.kq.util.KQDurationCalculatorUtil;
@ -12,6 +13,7 @@ import com.engine.kq.util.UtilKQ;
import weaver.common.DateUtil; import weaver.common.DateUtil;
import weaver.common.StringUtil; import weaver.common.StringUtil;
import weaver.conn.RecordSet; import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.TimeUtil; import weaver.general.TimeUtil;
import weaver.general.Util; import weaver.general.Util;
import weaver.hrm.User; import weaver.hrm.User;
@ -32,6 +34,8 @@ public class ExportExcelCmd extends AbstractCommonCommand<Map<String, Object>> {
private HttpServletResponse response; private HttpServletResponse response;
private List<String> lsFieldDataKey; private List<String> lsFieldDataKey;
BaseBean bb = new BaseBean();
public ExportExcelCmd(Map<String, Object> params, HttpServletRequest request, HttpServletResponse response, User user) { public ExportExcelCmd(Map<String, Object> params, HttpServletRequest request, HttpServletResponse response, User user) {
this.user = user; this.user = user;
this.params = params; this.params = params;
@ -202,14 +206,19 @@ public class ExportExcelCmd extends AbstractCommonCommand<Map<String, Object>> {
Map<String,Object> definedFieldInfo = new KQFormatBiz().getDefinedField(); Map<String,Object> definedFieldInfo = new KQFormatBiz().getDefinedField();
String definedFieldSum = Util.null2String(definedFieldInfo.get("definedFieldSum")); String definedFieldSum = Util.null2String(definedFieldInfo.get("definedFieldSum"));
String backFields = " a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle," + String backFields = " (select sum(zm.cccb) from uf_cbxxjlb zm where zm.xm = a.id and zm.rq >= '" + fromDate + "' and zm.rq <= '" + toDate + "') as mealAllowance," +
" (select sum(zm.zdcb) from uf_cbxxjlb zm where zm.xm = a.id and zm.rq >= '" + fromDate + "' and zm.rq <= '" + toDate + "') as statAllowance," +
" (select sum(zm.jmybcb) from uf_cbxxjlb zm where zm.xm = a.id and zm.rq >= '" + fromDate + "' and zm.rq <= '" + toDate + "') as nightAllowance," +
" (select sum(zm.hrzdcb) from uf_cbxxjlb zm where zm.xm = a.id and zm.rq >= '" + fromDate + "' and zm.rq <= '" + toDate + "') as otherStatAllowance," +
" (select sum(zm.ybbz) from uf_cbxxjlb zm where zm.xm = a.id and zm.rq >= '" + fromDate + "' and zm.rq <= '" + toDate + "') as nightShiftSubsidy," +
" a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle," +
" sum(b.workdays) as workdays,sum(b.workMins) as workMins,sum(b.attendancedays) as attendancedays," + " sum(b.workdays) as workdays,sum(b.workMins) as workMins,sum(b.attendancedays) as attendancedays," +
" sum(b.attendanceMins) as attendanceMins,sum(b.beLate) as beLate,sum(b.beLateMins) as beLateMins, " + " sum(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," + " sum(b.graveBeLate) as graveBeLate, sum(b.graveBeLateMins) as graveBeLateMins,sum(b.leaveEearly) as leaveEearly," +
" sum(b.leaveEarlyMins) as leaveEarlyMins, sum(b.graveLeaveEarly) as graveLeaveEarly, " + " sum(b.leaveEarlyMins) as leaveEarlyMins, sum(b.graveLeaveEarly) as graveLeaveEarly, " +
" sum(b.graveLeaveEarlyMins) as graveLeaveEarlyMins,sum(b.absenteeism) as absenteeism, " + " sum(b.graveLeaveEarlyMins) as graveLeaveEarlyMins,sum(b.absenteeism) as absenteeism, " +
" sum(b.signdays) as signdays,sum(b.signmins) as signmins, "+ " sum(b.signdays) as signdays,sum(b.signmins) as signmins, "+
" sum(b.absenteeismMins) as absenteeismMins, sum(b.forgotCheck)+"+forgotBeginWorkCheck_field+" as forgotCheck "+(definedFieldSum.length()>0?","+definedFieldSum+"":""); " sum(b.absenteeismMins ) as absenteeismMins, sum(b.forgotCheck)+"+forgotBeginWorkCheck_field+" as forgotCheck,sum(b.zeropoint) as zeropoint "+(definedFieldSum.length()>0?","+definedFieldSum+"":"");
if(rs.getDBType().equals("oracle")){ if(rs.getDBType().equals("oracle")){
backFields = "/*+ index(kq_format_total IDX_KQ_FORMAT_TOTAL_KQDATE) */ "+backFields; backFields = "/*+ index(kq_format_total IDX_KQ_FORMAT_TOTAL_KQDATE) */ "+backFields;
} }
@ -269,6 +278,24 @@ public class ExportExcelCmd extends AbstractCommonCommand<Map<String, Object>> {
String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey),"0"); String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey),"0");
/*考勤二开--驻点餐补start*/
HostarUtil hostarUtil = new HostarUtil();
Map<String, Double> attendanceMap = new HashMap<>();
String acqAttendanceSql = "select a.id, b.attendanceMins, b.kqdate from hrmresource a, kq_format_total b where a.id= b.resourceid and b.kqdate >='"+fromDate+"' and b.kqdate <='"+toDate+"' "+sqlWhere;
bb.writeLog("acqAttendanceSql: " + acqAttendanceSql);
rs.executeQuery(acqAttendanceSql);
while (rs.next()) {
double attendanceMins = Util.getDoubleValue(Util.null2String(rs.getString("attendanceMins")));
String id = Util.null2String(rs.getString("id"));
String kqdate = Util.null2String(rs.getString("kqdate"));
if (attendanceMins >= 0.00) {
attendanceMap.put(id + "|DailyStatAllowance" +"|" + kqdate, attendanceMins);
}
}
bb.writeLog("attendanceMap: " + attendanceMap);
/*考勤二开--驻点餐补end*/
rs.execute(sql); rs.execute(sql);
while (rs.next()) { while (rs.next()) {
data = new ArrayList<>(); data = new ArrayList<>();
@ -411,6 +438,99 @@ public class ExportExcelCmd extends AbstractCommonCommand<Map<String, Object>> {
}catch (Exception e){ }catch (Exception e){
} }
fieldValue = KQDurationCalculatorUtil.getDurationRound(businessLeave); 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(Util.null2String(kqReportFieldComInfo.getCascadekey(fieldid)).length()>0){ } else if(Util.null2String(kqReportFieldComInfo.getCascadekey(fieldid)).length()>0){
fieldValue = Util.formatMultiLang(Util.null2String(rs.getString(fieldName)),""+user.getLanguage()); fieldValue = Util.formatMultiLang(Util.null2String(rs.getString(fieldName)),""+user.getLanguage());
data.add(fieldValue); data.add(fieldValue);

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.engine.common.biz.AbstractCommonCommand; import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext; import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext; import com.engine.core.interceptor.CommandContext;
import com.engine.hostar.util.HostarUtil;
import com.engine.kq.biz.*; import com.engine.kq.biz.*;
import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit; import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit;
import com.engine.kq.entity.WorkTimeEntity; import com.engine.kq.entity.WorkTimeEntity;
@ -12,8 +13,11 @@ import com.engine.kq.log.KQLog;
import com.engine.kq.util.KQDurationCalculatorUtil; import com.engine.kq.util.KQDurationCalculatorUtil;
import com.engine.kq.util.PageUidFactory; import com.engine.kq.util.PageUidFactory;
import java.math.BigDecimal; import java.math.BigDecimal;
import org.apache.commons.lang3.StringUtils;
import weaver.common.DateUtil; import weaver.common.DateUtil;
import weaver.conn.RecordSet; import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.TimeUtil; import weaver.general.TimeUtil;
import weaver.general.Util; import weaver.general.Util;
import weaver.hrm.HrmUserVarify; import weaver.hrm.HrmUserVarify;
@ -30,6 +34,8 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Objec
private KQLog kqLog = new KQLog(); private KQLog kqLog = new KQLog();
BaseBean bb = new BaseBean();
public GetKQDailyReportCmd(Map<String, Object> params, User user) { public GetKQDailyReportCmd(Map<String, Object> params, User user) {
this.user = user; this.user = user;
this.params = params; this.params = params;
@ -41,6 +47,7 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Objec
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();
String sql = ""; String sql = "";
try{ try{
bb.writeLog("GetKQDailyReportCmd start.");
String pageUid = PageUidFactory.getHrmPageUid("KQDailyReport"); String pageUid = PageUidFactory.getHrmPageUid("KQDailyReport");
SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo();
@ -138,11 +145,16 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Objec
forgotBeginWorkCheck_field = " isnull(b.forgotBeginWorkCheck,0) "; forgotBeginWorkCheck_field = " isnull(b.forgotBeginWorkCheck,0) ";
} }
String backFields = " a.id,a.lastname,a.subcompanyid1 as subcompanyid,a.departmentid, a.workcode,b.jobtitle,a.dsporder," + String backFields = " (select zm.cccb from uf_cbxxjlb zm where zm.xm = a.id and zm.rq = b.kqdate) as mealAllowance," +
" b.kqdate, b.workdays,b.workMins,b.serialid, b.attendancedays,b.attendanceMins," + " (select zm.zdcb from uf_cbxxjlb zm where zm.xm = a.id and zm.rq = b.kqdate) as statAllowance," +
" (select zm.jmybcb from uf_cbxxjlb zm where zm.xm = a.id and zm.rq = b.kqdate) as nightAllowance," +
" (select zm.hrzdcb from uf_cbxxjlb zm where zm.xm = a.id and zm.rq = b.kqdate) as otherStatAllowance," +
" (select zm.ybbz from uf_cbxxjlb zm where zm.xm = a.id and zm.rq = b.kqdate) as nightShiftSubsidy," +
" a.id,a.lastname,a.subcompanyid1 as subcompanyid,a.departmentid, a.workcode,b.jobtitle,a.dsporder," +
" b.kqdate, b.workdays,b.workMins,b.serialid, b.attendancedays,FLOOR( b.attendanceMins / 30 ) * 30 AS attendanceMins," +
" b.beLate,b.beLateMins,b.graveBeLate,b.graveBeLateMins,b.leaveEearly,b.leaveEarlyMins," + " b.beLate,b.beLateMins,b.graveBeLate,b.graveBeLateMins,b.leaveEearly,b.leaveEarlyMins," +
" b.signdays,b.signmins, "+ " b.signdays,b.signmins, "+
" b.graveLeaveEarly,b.graveLeaveEarlyMins,b.absenteeism ,b.absenteeismMins ,(b.forgotCheck+"+forgotBeginWorkCheck_field+") forgotCheck "; " b.graveLeaveEarly,b.graveLeaveEarlyMins,b.absenteeism , b.absenteeismMins ,(b.forgotCheck+"+forgotBeginWorkCheck_field+") forgotCheck,zeropoint ";
String sqlFrom = " from hrmresource a, kq_format_total b where a.id= b.resourceid and b.kqdate >='"+fromDate+"' and b.kqdate <='"+toDate+"'"; 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; String sqlWhere = rightSql;
if(subCompanyId.length()>0){ if(subCompanyId.length()>0){
@ -223,13 +235,47 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Objec
} else { } else {
sql = " select " + sql; sql = " select " + sql;
} }
long startTime = System.currentTimeMillis();
Map<String,Object> flowData = kqReportBiz.getDailyFlowData(params,user); 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);
// #1475814-概述:满足考勤报分部部门显示及导出时显示全路径 // #1475814-概述:满足考勤报分部部门显示及导出时显示全路径
String fullPathMainKey = "show_full_path"; String fullPathMainKey = "show_full_path";
KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo();
String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey),"0"); 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*/
bb.writeLog("每日报表sql: " + sql);
rs.execute(sql); rs.execute(sql);
while (rs.next()) { while (rs.next()) {
String id = rs.getString("id"); String id = rs.getString("id");
@ -317,12 +363,89 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Objec
if (fieldValue.length()>0) {//弹性工作制没有班次 if (fieldValue.length()>0) {//弹性工作制没有班次
data.put("serialid", shiftManagementToolKit.getShiftOnOffWorkSections(fieldValue, user.getLanguage())); data.put("serialid", shiftManagementToolKit.getShiftOnOffWorkSections(fieldValue, user.getLanguage()));
} }
} else if (fieldName.equals("mealAllowance")) { // } else if (fieldName.equals("mealAllowance")) {//考勤二开--出差餐补
int intValue = Util.getIntValue(Util.null2String(flowData.get("DailyMealAllow|" + resourceId + "|" + kqdate))); // int intValue = Util.getIntValue(Util.null2String(flowData.get("DailyMealAllow|" + resourceId + "|" + kqdate)));
if (intValue < 0) { // if (intValue < 0) {
intValue = 0; // intValue = 0;
} // }
data.put(fieldName, intValue); // 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 { } else {
fieldValue = Util.null2String(rs.getString(fieldName)); fieldValue = Util.null2String(rs.getString(fieldName));
if (kqReportFieldComInfo.getUnittype().equals("2") && fieldValue.length() > 0) { if (kqReportFieldComInfo.getUnittype().equals("2") && fieldValue.length() > 0) {
@ -331,7 +454,10 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Objec
data.put(fieldName, fieldValue); data.put(fieldName, fieldValue);
} }
} }
data.putAll(this.getSignDetailInfo(id, kqdate)); // data.putAll(this.getSignDetailInfo(id, kqdate));
Map<String, Object> signDetailInfo = this.getSignDetailInfo(id, kqdate);
bb.writeLog("signDetailInfo: " + signDetailInfo);
data.putAll(signDetailInfo);
//请假 //请假
List<Map<String, Object>> allLeaveRules = KQLeaveRulesBiz.getAllLeaveRules(); List<Map<String, Object>> allLeaveRules = KQLeaveRulesBiz.getAllLeaveRules();
@ -388,8 +514,9 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Objec
retmap.put("ishavepre", isHavePre); retmap.put("ishavepre", isHavePre);
retmap.put("ishavenext", isHaveNext); retmap.put("ishavenext", isHaveNext);
}catch (Exception e){ }catch (Exception e){
writeLog(e); bb.writeLog("GetKQDailyReportCmd error:" + e.getMessage());
} }
bb.writeLog("GetKQDailyReportCmd end.");
return retmap; return retmap;
} }
@ -506,13 +633,25 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Objec
String sql = ""; String sql = "";
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
try{ try{
sql = " select kqdate,resourceid,serialid,serialnumber,workbegindate,workbegintime, " + // sql = " select kqdate,resourceid,serialid,serialnumber,workbegindate,workbegintime, " +
" workenddate,workendtime,workmins,signindate,signintime,signoutdate,signouttime, \n" + // " workenddate,workendtime,workmins,signindate,signintime,signoutdate,signouttime, \n" +
" attendanceMins,belatemins,graveBeLateMins,leaveearlymins,graveLeaveEarlyMins,absenteeismmins,forgotcheckMins,forgotBeginWorkCheckMins," + // " attendanceMins,belatemins,graveBeLateMins,leaveearlymins,graveLeaveEarlyMins,absenteeismmins,forgotcheckMins,forgotBeginWorkCheckMins," +
" leaveMins,leaveInfo,evectionMins,outMins,signinid,signoutid \n" + // " leaveMins,leaveInfo,evectionMins,outMins,signinid,signoutid \n" +
" from kq_format_detail b \n" + // " from kq_format_detail b \n" +
" where resourceid = " + resourceId + " and kqdate ='" + kqDate + "' \n" + // " where resourceid = " + resourceId + " and kqdate ='" + kqDate + "' \n" +
" order by serialnumber \n"; // " order by serialnumber \n";
/*考勤二开--增加打卡地址start*/
sql = " select a.kqdate,a.resourceid,a.serialid,a.serialnumber,a.workbegindate,a.workbegintime, " +
" a.workenddate,a.workendtime,a.workmins,a.signindate,a.signintime,a.signoutdate,a.signouttime, \n" +
" a.attendanceMins,a.belatemins,a.graveBeLateMins,a.leaveearlymins,a.graveLeaveEarlyMins,a.absenteeismmins,a.forgotcheckMins,a.forgotBeginWorkCheckMins," +
" a.leaveMins,a.leaveInfo,a.evectionMins,a.outMins,a.signinid,a.signoutid, b.addr as signinaddr, c.addr as signoutaddr \n" +
" from kq_format_detail a " +
" left join hrmschedulesign b on b.id = a.signinid \n" +
" left join hrmschedulesign c on c.id = a.signoutid \n" +
" where a.resourceid = " + resourceId + " and a.kqdate ='" + kqDate + "' \n" +
" order by a.serialnumber \n";
/*考勤二开--增加打卡地址end*/
rs.execute(sql); rs.execute(sql);
while (rs.next()) { while (rs.next()) {
String resourceid = Util.null2String(rs.getString("resourceid")); String resourceid = Util.null2String(rs.getString("resourceid"));
@ -540,6 +679,10 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Objec
String leaveInfo = Util.null2String(rs.getString("leaveInfo")); String leaveInfo = Util.null2String(rs.getString("leaveInfo"));
int evectionMins = rs.getInt("evectionMins"); int evectionMins = rs.getInt("evectionMins");
int outMins = rs.getInt("outMins"); int outMins = rs.getInt("outMins");
String signInAddr = Util.null2String(rs.getString("signinaddr"));
String signOutAddr = Util.null2String(rs.getString("signoutaddr"));
bb.writeLog("signInAddr: " + signInAddr);
bb.writeLog("signOutAddr: " + signOutAddr);
if(serialid.length()>0){ if(serialid.length()>0){
@ -558,6 +701,7 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Objec
data.put("signintime"+serialnumber, signintime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signintime ); data.put("signintime"+serialnumber, signintime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signintime );
data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on")); data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on"));
data.put("signinaddress"+serialnumber, signInAddr);
} }
if (workendtime.length() > 0) { if (workendtime.length() > 0) {
@ -576,6 +720,7 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Objec
data.put("signouttime"+serialnumber, signouttime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signouttime ); data.put("signouttime"+serialnumber, signouttime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signouttime );
data.put("signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off")); data.put("signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off"));
data.put("signoutaddress"+serialnumber, signOutAddr);
} }
}else{ }else{
if(workMins>0){ if(workMins>0){
@ -590,9 +735,11 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Objec
if(signinid.length() > 0){ if(signinid.length() > 0){
data.put("signintime"+serialnumber, signintime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signintime ); data.put("signintime"+serialnumber, signintime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signintime );
data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on")); data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on"));
data.put("signinaddress"+serialnumber, signInAddr);
if(signoutid.length() > 0){ if(signoutid.length() > 0){
data.put("signouttime"+serialnumber, signouttime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signouttime ); data.put("signouttime"+serialnumber, signouttime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signouttime );
data.put("signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off")); data.put("signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off"));
data.put("signoutaddress"+serialnumber, signOutAddr);
} }
}else{ }else{
data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on")); data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on"));

@ -5,12 +5,13 @@ import com.alibaba.fastjson.JSONObject;
import com.engine.common.biz.AbstractCommonCommand; import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext; import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext; import com.engine.core.interceptor.CommandContext;
import com.engine.hostar.util.HostarUtil;
import com.engine.kq.biz.*; import com.engine.kq.biz.*;
import com.engine.kq.log.KQLog;
import com.engine.kq.util.KQDurationCalculatorUtil; import com.engine.kq.util.KQDurationCalculatorUtil;
import com.engine.kq.util.PageUidFactory; import com.engine.kq.util.PageUidFactory;
import weaver.common.DateUtil; import weaver.common.DateUtil;
import weaver.conn.RecordSet; import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.TimeUtil; import weaver.general.TimeUtil;
import weaver.general.Util; import weaver.general.Util;
import weaver.hrm.User; import weaver.hrm.User;
@ -25,6 +26,8 @@ import java.util.*;
public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> { public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
BaseBean bb = new BaseBean();
public GetKQReportCmd(Map<String, Object> params, User user) { public GetKQReportCmd(Map<String, Object> params, User user) {
this.user = user; this.user = user;
this.params = params; this.params = params;
@ -36,6 +39,7 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
RecordSet rs = new RecordSet(); RecordSet rs = new RecordSet();
String sql = ""; String sql = "";
try{ try{
bb.writeLog("GetKQReportCmd start.");
String pageUid = PageUidFactory.getHrmPageUid("KQReport"); String pageUid = PageUidFactory.getHrmPageUid("KQReport");
SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo();
@ -169,14 +173,19 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
Map<String,Object> definedFieldInfo = new KQFormatBiz().getDefinedField(); Map<String,Object> definedFieldInfo = new KQFormatBiz().getDefinedField();
String definedFieldSum = Util.null2String(definedFieldInfo.get("definedFieldSum")); String definedFieldSum = Util.null2String(definedFieldInfo.get("definedFieldSum"));
String backFields = " a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle," + String backFields = " (select sum(zm.cccb) from uf_cbxxjlb zm where zm.xm = a.id and zm.rq >= '" + fromDate + "' and zm.rq <= '" + toDate + "') as mealAllowance," +
" (select sum(zm.zdcb) from uf_cbxxjlb zm where zm.xm = a.id and zm.rq >= '" + fromDate + "' and zm.rq <= '" + toDate + "') as statAllowance," +
" (select sum(zm.jmybcb) from uf_cbxxjlb zm where zm.xm = a.id and zm.rq >= '" + fromDate + "' and zm.rq <= '" + toDate + "') as nightAllowance," +
" (select sum(zm.hrzdcb) from uf_cbxxjlb zm where zm.xm = a.id and zm.rq >= '" + fromDate + "' and zm.rq <= '" + toDate + "') as otherStatAllowance," +
" (select sum(zm.ybbz) from uf_cbxxjlb zm where zm.xm = a.id and zm.rq >= '" + fromDate + "' and zm.rq <= '" + toDate + "') as nightShiftSubsidy," +
" a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle," +
" sum(b.workdays) as workdays,sum(b.workMins) as workMins,sum(b.attendancedays) as attendancedays," + " sum(b.workdays) as workdays,sum(b.workMins) as workMins,sum(b.attendancedays) as attendancedays," +
" sum(b.attendanceMins) as attendanceMins,sum(b.beLate) as beLate,sum(b.beLateMins) as beLateMins, " + " sum(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," + " sum(b.graveBeLate) as graveBeLate, sum(b.graveBeLateMins) as graveBeLateMins,sum(b.leaveEearly) as leaveEearly," +
" sum(b.leaveEarlyMins) as leaveEarlyMins, sum(b.graveLeaveEarly) as graveLeaveEarly, " + " sum(b.leaveEarlyMins) as leaveEarlyMins, sum(b.graveLeaveEarly) as graveLeaveEarly, " +
" sum(b.graveLeaveEarlyMins) as graveLeaveEarlyMins,sum(b.absenteeism) as absenteeism, " + " sum(b.graveLeaveEarlyMins) as graveLeaveEarlyMins,sum(b.absenteeism) as absenteeism, " +
" sum(b.signdays) as signdays,sum(b.signmins) as signmins, "+ " sum(b.signdays) as signdays,sum(b.signmins) as signmins, "+
" sum(b.absenteeismMins) as absenteeismMins, sum(b.forgotCheck)+"+forgotBeginWorkCheck_field+" as forgotCheck "+(definedFieldSum.length()>0?","+definedFieldSum+"":""); " sum(b.absenteeismMins ) as absenteeismMins, sum(b.forgotCheck)+"+forgotBeginWorkCheck_field+" as forgotCheck, sum(b.zeropoint) as zeropoint "+(definedFieldSum.length()>0?","+definedFieldSum+"":"");
if(rs.getDBType().equals("oracle")){ if(rs.getDBType().equals("oracle")){
backFields = "/*+ index(kq_format_total IDX_KQ_FORMAT_TOTAL_KQDATE) */ "+backFields; backFields = "/*+ index(kq_format_total IDX_KQ_FORMAT_TOTAL_KQDATE) */ "+backFields;
@ -276,12 +285,10 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
} else if (rs.getDBType().equals("mysql")) { } else if (rs.getDBType().equals("mysql")) {
sql = " select * from (select " + sql+") t "+orderBy; sql = " select * from (select " + sql+") t "+orderBy;
sql = "select t1.* from (" + sql + ") t1 limit " + ((pageIndex - 1) * pageSize) + "," + pageSize; sql = "select t1.* from (" + sql + ") t1 limit " + ((pageIndex - 1) * pageSize) + "," + pageSize;
} } else if (rs.getDBType().equals("postgresql")) {
else if (rs.getDBType().equals("postgresql")) {
sql = " select * from (select " + sql+") t "+orderBy; sql = " select * from (select " + sql+") t "+orderBy;
sql = "select t1.* from (" + sql + ") t1 limit " +pageSize + " offset " + ((pageIndex - 1) * pageSize); sql = "select t1.* from (" + sql + ") t1 limit " +pageSize + " offset " + ((pageIndex - 1) * pageSize);
} } else {
else {
orderBy = " order by dsporder asc, lastname asc "; orderBy = " order by dsporder asc, lastname asc ";
descOrderBy = " order by dsporder desc, lastname desc "; descOrderBy = " order by dsporder desc, lastname desc ";
if (pageIndex > 1) { if (pageIndex > 1) {
@ -312,9 +319,30 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
double hoursToDay = kqOvertimeRulesBiz.getHoursToDay();//当前天跟小时计算关系 double hoursToDay = kqOvertimeRulesBiz.getHoursToDay();//当前天跟小时计算关系
params.put("uintType",uintType); params.put("uintType",uintType);
params.put("hoursToDay",hoursToDay); params.put("hoursToDay",hoursToDay);
long startTime = System.currentTimeMillis();
Map<String,Object> flowData = kqReportBiz.getFlowData(params,user); Map<String,Object> flowData = kqReportBiz.getFlowData(params,user);
long endTime = System.currentTimeMillis();
long elapsedTime = endTime - startTime; // 执行时间
bb.writeLog("执行时间:" + elapsedTime + "毫秒" );
// /*考勤二开--驻点餐补start*/
HostarUtil hostarUtil = new HostarUtil();
// Map<String, Double> attendanceMap = new HashMap<>();
// String acqAttendanceSql = "select a.id, b.attendanceMins, b.kqdate from hrmresource a, kq_format_total b where a.id= b.resourceid and b.kqdate >='"+fromDate+"' and b.kqdate <='"+toDate+"' "+sqlWhere;
// bb.writeLog("acqAttendanceSql: " + acqAttendanceSql);
// rs.executeQuery(acqAttendanceSql);
// while (rs.next()) {
// double attendanceMins = Util.getDoubleValue(Util.null2String(rs.getString("attendanceMins")));
// String id = Util.null2String(rs.getString("id"));
// String kqdate = Util.null2String(rs.getString("kqdate"));
// if (attendanceMins >= 0.00) {
// attendanceMap.put(id + "|DailyAllowance" +"|" + kqdate, attendanceMins);
// }
// }
// bb.writeLog("attendanceMap: " + attendanceMap);
// /*考勤二开--驻点餐补end*/
bb.writeLog("汇总报表--sql: " + sql);
rs.execute(sql); rs.execute(sql);
while (rs.next()) { while (rs.next()) {
data = new HashMap<>(); data = new HashMap<>();
@ -407,11 +435,105 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
businessLeave = "0.0"; businessLeave = "0.0";
} }
}catch (Exception e){ }catch (Exception e){
} }
fieldValue = KQDurationCalculatorUtil.getDurationRound(businessLeave); fieldValue = KQDurationCalculatorUtil.getDurationRound(businessLeave);
} else{ } else{
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id+"|"+fieldName))); 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 { } else {
fieldValue = Util.null2String(rs.getString(fieldName)); fieldValue = Util.null2String(rs.getString(fieldName));
if(Util.null2String(kqReportFieldComInfo.getUnittype()).length()>0) { if(Util.null2String(kqReportFieldComInfo.getUnittype()).length()>0) {
@ -495,6 +617,7 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
retmap.put("ishavenext", isHaveNext); retmap.put("ishavenext", isHaveNext);
}catch (Exception e){ }catch (Exception e){
writeLog(e); writeLog(e);
bb.writeLog("GetKQReportCmd Exception: " + e.getMessage());
} }
return retmap; return retmap;
} }

@ -0,0 +1,202 @@
package weaver.formmode.customjavacode.modeexpand;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.engine.kq.biz.KQFormatBiz;
import com.engine.kq.timer.KQQueue;
import com.engine.kq.timer.KQTaskBean;
import com.engine.kq.wfset.util.SplitActionUtil;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSet;
import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.soa.workflow.request.RequestInfo;
/**
*
*/
public class AddScheduleSign extends AbstractModeExpandJavaCodeNew {
/**
*
* @param param
* param()
* user
* importtype () 1 2,3(int)param.get("importtype")
* ()a=1param.get("a")
* b=2,param.get("b")
* @return
*/
public Map<String, String> doModeExpand(Map<String, Object> param) {
Map<String, String> result = new HashMap<String, String>();
try {
User user = (User)param.get("user");
int billid = -1;//数据id
int modeid = -1;//模块id
RequestInfo requestInfo = (RequestInfo)param.get("RequestInfo");
if(requestInfo!=null){
billid = Util.getIntValue(requestInfo.getRequestid());
modeid = Util.getIntValue(requestInfo.getWorkflowid());
if(billid>0&&modeid>0){
//------请在下面编写业务逻辑代码------
BaseBean bb = new BaseBean();
bb.writeLog("AddScheduleSign Start");
RecordSet rs = new RecordSet();
List<List> addParams = new ArrayList<>();
List<String> lsFormatData = new ArrayList<>();
Map<String, String> signFromMap = new HashMap<String, String>();
signFromMap.put( "0","e9pc");
signFromMap.put( "1","e9mobile");
signFromMap.put( "2","e9e");
signFromMap.put( "3","e9ewx");
signFromMap.put( "4","card");
signFromMap.put( "5","e9_mobile_out");
signFromMap.put( "6","importExcel");
signFromMap.put( "7","EMSyn");
signFromMap.put( "8","OutDataSourceSyn");
signFromMap.put( "9","DingTalk");
signFromMap.put( "10","DingTalk_out");
signFromMap.put( "11","Wechat_out");
signFromMap.put( "12","Wechat");
//获取新插入的数据
String acqSignDataSql = "select userid, usertype, signtype, signdate, signtime, clientaddress, isincom," +
" signfrom, longitude, latitude, addr, isimport, suuid, timezone, belongdate, memo, deviceinfo, showaddress " +
" from uf_schsignaddlog where id = ?";
bb.writeLog("acqSignDataSql: " + acqSignDataSql);
rs.executeQuery(acqSignDataSql, billid);
while (rs.next()) {
String userid = Util.null2String(rs.getString("userid"));
String usertype = Util.null2String(rs.getString("usertype"));
String signtype = Util.null2String(rs.getString("signtype"));
String signdate = Util.null2String(rs.getString("signdate"));
String signtime = Util.null2String(rs.getString("signtime"));
String clientaddress = Util.null2String(rs.getString("clientaddress"));
String isincom = Util.null2String(rs.getString("isincom"));
String signfrom = Util.null2String(rs.getString("signfrom"));
String longitude = Util.null2String(rs.getString("longitude"));
String latitude = Util.null2String(rs.getString("latitude"));
String addr = Util.null2String(rs.getString("addr"));
String isimport = Util.null2String(rs.getString("isimport"));
String suuid = Util.null2String(rs.getString("suuid"));
String timezone = Util.null2String(rs.getString("timezone"));
String belongdate = Util.null2String(rs.getString("belongdate"));
String memo = Util.null2String(rs.getString("memo"));
String deviceinfo = Util.null2String(rs.getString("deviceinfo"));
String showaddress = Util.null2String(rs.getString("showaddress"));
if (signtime.length() == 5) {
signtime = signtime + ":00";
}
bb.writeLog("signfrom: " + signfrom);
if (StringUtils.isNotBlank(signfrom)) {
signfrom = signFromMap.get(signfrom);
}
bb.writeLog("--signfrom: " + signfrom);
List addPa = new ArrayList<>();
addPa.add(userid);
addPa.add(usertype);
addPa.add(signtype);
addPa.add(signdate);
addPa.add(signtime);
addPa.add(clientaddress);
addPa.add(isincom);
addPa.add(signfrom);
addPa.add(longitude);
addPa.add(latitude);
addPa.add(addr);
addPa.add(isimport);
addPa.add(suuid);
addPa.add(timezone);
addPa.add(belongdate);
addPa.add(memo);
addPa.add(deviceinfo);
addPa.add(showaddress);
addParams.add(addPa);
String formatData = userid + "|" + signdate + "|" + signtime;
if (!lsFormatData.contains(formatData)) {
lsFormatData.add(formatData);
}
}
bb.writeLog("addParams: " + addParams);
String addSchSignSql = "insert into hrmschedulesign (userid, usertype, signtype, signdate, signtime, clientaddress, isincom, " +
" signfrom, longitude, latitude, addr, isimport, suuid, timezone, belongdate, memo, deviceinfo, showaddress ) values " +
" (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
bb.writeLog("addSchSignSql: " + addSchSignSql);
rs.executeBatchSql(addSchSignSql, addParams);
//触发考勤格式化计算和加班
//刷新报表数据
List<Object> formatParams = null;
List<List<Object>> lsFormatParams = new ArrayList<>();
Map<String,List<String>> overtimeMap = Maps.newHashMap();
List<String> overtimeList = Lists.newArrayList();
bb.writeLog("开始处理考勤数据生成");
for(int i=0;lsFormatData!=null&&i<lsFormatData.size();i++){
formatParams = new ArrayList<>();
String[] formatData = Util.splitString(lsFormatData.get(i),"|");
String date_1 = weaver.common.DateUtil.addDate(formatData[1], -1);
formatParams.add(formatData[0]);
formatParams.add(date_1);
lsFormatParams.add(formatParams);
formatParams = new ArrayList<>();
formatParams.add(formatData[0]);
formatParams.add(formatData[1]);
lsFormatParams.add(formatParams);
String resourceId = formatData[0];
String kqdate = formatData[1];
if(overtimeMap.containsKey(resourceId)){
List<String> tmp_overtimeList = overtimeMap.get(resourceId);
if(!tmp_overtimeList.contains(kqdate)){
tmp_overtimeList.add(kqdate);
}
}else{
if(!overtimeList.contains(kqdate)){
overtimeList.add(kqdate);
}
overtimeMap.put(resourceId, overtimeList);
}
}
new KQFormatBiz().format(lsFormatParams);
bb.writeLog("开始处理加班生成");
//处理加班生成
List<KQTaskBean> tasks = new ArrayList<>();
for(Map.Entry<String, List<String>> mme: overtimeMap.entrySet()){
String resid = mme.getKey();
List<String> overList = mme.getValue();
for(String date : overList){
SplitActionUtil.pushOverTimeTasks(date,date,resid,tasks);
}
}
if(!tasks.isEmpty()){
KQQueue.writeTasks(tasks);
}
}
}
} catch (Exception e) {
result.put("errmsg","手动添加原始打卡记录失败!");
result.put("flag", "false");
}
return result;
}
}

@ -0,0 +1,94 @@
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;
}
}

@ -0,0 +1,106 @@
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;
}
}

@ -0,0 +1,167 @@
package weaver.interfaces.hostar.action;
import com.engine.kq.biz.KQFormatBiz;
import com.engine.kq.wfset.util.SplitActionUtil;
import org.apache.commons.lang3.StringUtils;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
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;
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 {
Property[] properties = requestInfo.getMainTableInfo().getProperty();
for (Property property : properties) {
if ("ksrq".equals(property.getName())) {
startDate = Util.null2String(property.getValue());
}
if ("yjjsrq".equals(property.getName())) {
endDate = Util.null2String(property.getValue());
}
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 (?) ";
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)) {
Map<String, Object> in = mapStringToMap(inf);
String userId = Util.null2String(in.get("userId"));
String userType = Util.null2String(in.get("userType"));
String signType = Util.null2String(in.get("signType"));
String signDate = Util.null2String(in.get("signDate"));
String signTime = Util.null2String(in.get("signTime"));
String clientAddress = Util.null2String(in.get("clientAddress"));
String isInCom = Util.null2String(in.get("isInCom"));
String timeZone = Util.null2String(in.get("timeZone"));
String belongdate = Util.null2String(in.get("belongdate"));
String signfrom = Util.null2String(in.get("signfrom"));
String longitude = Util.null2String(in.get("longitude"));
String latitude = Util.null2String(in.get("latitude"));
String address = Util.null2String(in.get("address"));
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) " +
" values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
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)) {
//外勤签到没有归属日期,遇到跨天班次打卡可能归属前一天,需要格式化前一天考勤
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) {
//外勤签到没有归属日期,遇到跨天班次打卡可能归属前一天,需要格式化前一天考勤
new KQFormatBiz().formatDate("" + userId, DateUtil.getYesterday());
}
new KQFormatBiz().formatDate("" + userId, (belongdate.length() == 0 ? DateUtil.getCurrentDate() : belongdate));
//外勤签到转的考勤 处理加班规则
SplitActionUtil.pushOverTimeTasksAll(belongdate, belongdate, "" + userId);
}
}
}
} catch (Exception e) {
bb.writeLog("OutSignSyncAction Exception: " + e.getMessage());
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<>();
for (String string : strs) {
String[] splits = string.split("=");
String key = splits[0];
String value = "";
if (splits.length > 1) {
value = splits[1];
}
// 去掉头部空格
String key1 = key.trim();
String value1 = value.trim();
map.put(key1, value1);
}
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;
}
}

@ -0,0 +1,173 @@
package weaver.interfaces.hostar.job;
import com.engine.hostar.util.HostarUtil;
import com.engine.kq.biz.KQGroupMemberComInfo;
import com.engine.kq.biz.KQHolidaySetBiz;
import com.engine.kq.biz.KQOvertimeRulesBiz;
import jdk.management.resource.ResourceId;
import org.apache.commons.lang3.StringUtils;
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.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
public class AddOvertimeSignJob 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("AddOvertimeSignJob 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);
if ( StringUtils.isBlank(fromDate) || StringUtils.isBlank(toDate)) {
toDate = DateUtils.format(new Date(), "yyyy-MM-dd");
LocalDate specifiedDate = LocalDate.parse(toDate, formatter);
// 获取三天前的日期
LocalDate threeDaysAgo = specifiedDate.minusDays(3);
fromDate = threeDaysAgo.format(formatter);
}
bb.writeLog("--fromDate: " + fromDate);
bb.writeLog("--toDate: " + toDate);
RecordSet rs = new RecordSet();
String overtimeWorkflow = Util.null2String(bb.getPropValue("project_hostar", "overtimeWorkflow"));
bb.writeLog("overtimeWorkflow: " + overtimeWorkflow);
if (StringUtils.isNotBlank(overtimeWorkflow)) {
HostarUtil hostarUtil = new HostarUtil();
List<String> allDates = hostarUtil.getAllDates(fromDate, toDate);
bb.writeLog("allDates: " + allDates);
for (String date: allDates) {
List<Map<String, Object>> overtimeInfo = new ArrayList<>();
//获取加班流程
String acqOvertimeSql = "select a.resourceId, a.fromDate, a.toDate, a.fromTime, a.toTime from " + overtimeWorkflow + " a " +
" left join workflow_requestbase b" +
" on b.requestid = a.requestid and b.currentnodetype = 3" +
" where a.fromDate = '" + date + "'";
bb.writeLog("acqOvertimeSql: " + acqOvertimeSql);
rs.executeQuery(acqOvertimeSql);
while (rs.next()) {
String resourceId = Util.null2String(rs.getString("resourceId"));
String fromDate = Util.null2String(rs.getString("fromDate"));
String fromTime = Util.null2String(rs.getString("fromTime"));
String toDate = Util.null2String(rs.getString("toDate"));
String toTime = Util.null2String(rs.getString("toTime"));
if (StringUtils.isNotBlank(fromDate) && StringUtils.isNotBlank(toDate) && StringUtils.isNotBlank(resourceId)) {
if (toDate.compareTo(fromDate) > 0 ) {
KQOvertimeRulesBiz kb = new KQOvertimeRulesBiz();
int changeType = kb.getChangeType(resourceId, fromDate);
bb.writeLog("changeType: " + changeType);
if (changeType != -1) {
Map<String, Object> temp = new HashMap<>();
temp.put("resourceId", resourceId);
temp.put("fromDate", fromDate);
temp.put("fromTime", fromTime);
temp.put("toDate", toDate);
temp.put("toTime", toTime);
overtimeInfo.add(temp);
}
}
}
}
bb.writeLog("overtimeInfo: " + overtimeInfo);
//根据加班流程信息取打卡信息
for ( Map<String, Object> info: overtimeInfo) {
String resourceId = Util.null2String(info.get("resourceId"));
String fromDate = Util.null2String(info.get("fromDate"));
String fromTime = Util.null2String(info.get("fromTime"));
String toDate = Util.null2String(info.get("toDate"));
String toTime = Util.null2String(info.get("toTime"));
bb.writeLog("resourceId: " + resourceId + ", fromDate: " + fromDate + ", fromTime: " + fromTime + ", toDate: " + toDate + ", toTime: " + toTime);
// 将字符串时间转换为LocalDateTime对象
if (toTime.length() == 5) {
toTime = toTime + ":00";
}
LocalDateTime dateTime = LocalDateTime.parse(toDate + " " + toTime, formatter2);
// 获取指定时间前后三小时的时间范围
LocalDateTime startDateTimeL = dateTime.minus(3, ChronoUnit.HOURS);
LocalDateTime endDateTimeL = dateTime.plus(3, ChronoUnit.HOURS);
String startDateTime = startDateTimeL.format(formatter2);
bb.writeLog("startDateTime: " + startDateTime);
String endDateTime = endDateTimeL.format(formatter2);
bb.writeLog("endDateTime: " + endDateTime);
Integer number = -1;
String acqSignSql = "select count(*) as number from hrmschedulesign " +
" where signdate + ' '+signTime >='"+startDateTime+"' and signdate + ' '+signTime <='"+endDateTime+"' " +
" and userid = ? and signtype = 2 ";
bb.writeLog("--acqSignSql: " + acqSignSql);
rs.executeQuery(acqSignSql, resourceId);
while (rs.next()) {
number = Util.getIntValue(Util.null2String(rs.getString("number")));
}
bb.writeLog("number: " + number);
if (number > 0) {
//插入0点打卡
String addSign1Sql = "insert into hrmschedulesign (userId,userType,signType,signDate,signTime,isInCom,signfrom,timeZone,belongDate) " +
" values (?,?,?,?,?,?,?,?,?)";
boolean b1 = rs.executeUpdate(addSign1Sql, resourceId, "1", "2", fromDate, "23:59:59", "1", "e9pc", "GMT+8", date);
bb.writeLog("插入23点59分打卡: " + b1);
//插入0点打卡
String addSign2Sql = "insert into hrmschedulesign (userId,userType,signType,signDate,signTime,isInCom,signfrom,timeZone,belongDate) " +
" values (?,?,?,?,?,?,?,?,?)";
boolean b2 = rs.executeUpdate(addSign2Sql, resourceId, "1", "2", toDate, "00:00:00", "1", "e9pc", "GMT+8", date);
bb.writeLog("插入0点打卡: " + b2);
} else {
bb.writeLog("没有在指定时间范围内打下班卡无法插入0点卡");
}
}
}
} else {
bb.writeLog("没有设置加班流程");
}
}catch (Exception e) {
bb.writeLog("AddOvertimeSignJob Exception: " + e);
}
}
}

@ -0,0 +1,133 @@
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;
}
}

@ -0,0 +1,92 @@
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);
}
}
}

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