|
@@ -5,11 +5,15 @@ import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.fouram.core.base.service.BaseService;
|
|
|
import org.fouram.core.plugin.weixin.cp.util.WXCpOaUtil;
|
|
|
import org.fouram.core.util.BeanUtils;
|
|
|
import org.fouram.core.util.DateUtil;
|
|
|
+import org.fouram.core.util.Tools;
|
|
|
import org.fouram.entity.SapCheck;
|
|
|
+import org.fouram.entity.SapCheckOption;
|
|
|
+import org.fouram.entity.SapCheckReport;
|
|
|
import org.fouram.entity.SapUser;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -17,6 +21,8 @@ import org.springframework.stereotype.Service;
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
|
import me.chanjar.weixin.cp.bean.WxCpCheckinData;
|
|
|
+import me.chanjar.weixin.cp.bean.WxCpCheckinOption;
|
|
|
+import me.chanjar.weixin.cp.bean.WxCpCheckinOption.CheckinTime;
|
|
|
|
|
|
@Service
|
|
|
public class SapCheckService extends BaseService {
|
|
@@ -77,6 +83,38 @@ public class SapCheckService extends BaseService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void saveAllUserCheckOption() throws Exception {
|
|
|
+ List<SapUser> users = userService.selectSuccessList();
|
|
|
+ Map<String, List<String>> map = groupList(users);
|
|
|
+ int count = 0;
|
|
|
+ List<Date> datetimes = Lists.newArrayList();
|
|
|
+ datetimes.add(DateUtil.sdfTime.parse("2020-04-09 00:00:00"));
|
|
|
+ for (String key : map.keySet()) {
|
|
|
+ count = count + 1;
|
|
|
+ List<WxCpCheckinOption> options = WXCpOaUtil.getCheckinOption(datetimes, map.get(key));
|
|
|
+ System.out.println(options.size());
|
|
|
+ int subCount = 0;
|
|
|
+ for (WxCpCheckinOption option : options) {
|
|
|
+ subCount = subCount + 1;
|
|
|
+ if (option.getGroup() != null && !option.getGroup().getCheckinDate().isEmpty()) {
|
|
|
+ SapCheckOption check = new SapCheckOption();
|
|
|
+ CheckinTime checkinTime = option.getGroup().getCheckinDate().get(0).getCheckinTime()[0];
|
|
|
+ check.setUserId(option.getUserId());
|
|
|
+ check.setWorkSec(checkinTime.getWorkSec());
|
|
|
+ check.setOffWorkSec(checkinTime.getOffWorkSec());
|
|
|
+ saveCheckinOption(check);
|
|
|
+ }
|
|
|
+ System.out.println(subCount);
|
|
|
+ }
|
|
|
+ System.out.println(count);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ System.out.println(34200 / 60 / 60.0);
|
|
|
+ System.out.println(66600 / 60 / 60.0);
|
|
|
+ }
|
|
|
+
|
|
|
public void saveCheckin(SapCheck check) throws Exception {
|
|
|
save("SapCheckMapper.saveCheckin", check);
|
|
|
}
|
|
@@ -88,4 +126,81 @@ public class SapCheckService extends BaseService {
|
|
|
public void saveCheckout(SapCheck check) throws Exception {
|
|
|
save("SapCheckMapper.saveCheckout", check);
|
|
|
}
|
|
|
+
|
|
|
+ public void saveCheckinOption(SapCheckOption check) throws Exception {
|
|
|
+ save("SapCheckMapper.saveCheckinOption", check);
|
|
|
+ }
|
|
|
+
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ public void updateReportData() throws Exception {
|
|
|
+ // 更新所有异常事件的数据为异常数据
|
|
|
+ update("SapCheckMapper.updateAllExceptionResult", null);
|
|
|
+ // 查询有请假情况的数据
|
|
|
+ List<SapCheckReport> checkReports = (List<SapCheckReport>) findList("SapCheckMapper.selectLeaveDayList", null);
|
|
|
+ for (SapCheckReport checkReport : checkReports) {
|
|
|
+ if (Tools.isInteger(checkReport.getLeaveDay())) {
|
|
|
+ update("SapCheckMapper.updateResultOk", checkReport.getId());
|
|
|
+ } else {
|
|
|
+ // 0.5
|
|
|
+ if (isOkWorkTime(checkReport) || isOkOffWorkTime(checkReport)) {
|
|
|
+ update("SapCheckMapper.updateResultOk", checkReport.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ checkReports = (List<SapCheckReport>) findList("SapCheckMapper.selectCheckoutList", null);
|
|
|
+ for (SapCheckReport checkReport : checkReports) {
|
|
|
+ if (isOkWorkTime(checkReport) && isOkOffWorkTime(checkReport)) {
|
|
|
+ update("SapCheckMapper.updateResultOk", checkReport.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 是不是正确的上班时间
|
|
|
+ private boolean isOkWorkTime(SapCheckReport checkReport) throws Exception {
|
|
|
+ if (StringUtils.isBlank(checkReport.getCheckinException())
|
|
|
+ && StringUtils.isNotBlank(checkReport.getCheckinDate())) {
|
|
|
+ if (DateUtil.sdfTime.parse(checkReport.getCheckinDate()).getTime() <= DateUtil.sdfsTime
|
|
|
+ .parse(checkReport.getCheckinDay() + " " + checkReport.getWorkTime()).getTime()) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(checkReport.getCheckoutDate1())) {
|
|
|
+ if (DateUtil.sdfTime.parse(checkReport.getCheckoutDate1()).getTime() <= DateUtil.sdfsTime
|
|
|
+ .parse(checkReport.getCheckinDay() + " " + checkReport.getWorkTime()).getTime()) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(checkReport.getCheckoutDate2())) {
|
|
|
+ if (DateUtil.sdfTime.parse(checkReport.getCheckoutDate2()).getTime() <= DateUtil.sdfsTime
|
|
|
+ .parse(checkReport.getCheckinDay() + " " + checkReport.getWorkTime()).getTime()) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 是不是正确的下班时间
|
|
|
+ private boolean isOkOffWorkTime(SapCheckReport checkReport) throws Exception {
|
|
|
+ if (StringUtils.isBlank(checkReport.getCheckoffException())
|
|
|
+ && StringUtils.isNotBlank(checkReport.getCheckoffDate())) {
|
|
|
+ if (DateUtil.sdfTime.parse(checkReport.getCheckoffDate()).getTime() >= DateUtil.sdfsTime
|
|
|
+ .parse(checkReport.getCheckinDay() + " " + checkReport.getOffWorkTime()).getTime()) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(checkReport.getCheckoutDate1())) {
|
|
|
+ if (DateUtil.sdfTime.parse(checkReport.getCheckoutDate1()).getTime() >= DateUtil.sdfsTime
|
|
|
+ .parse(checkReport.getCheckinDay() + " " + checkReport.getWorkTime()).getTime()) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(checkReport.getCheckoutDate2())) {
|
|
|
+ if (DateUtil.sdfTime.parse(checkReport.getCheckoutDate2()).getTime() >= DateUtil.sdfsTime
|
|
|
+ .parse(checkReport.getCheckinDay() + " " + checkReport.getOffWorkTime()).getTime()) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|