Browse Source

定时任务修改

seyason 1 year ago
parent
commit
28d5df8609

+ 13 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ReportController.java

@@ -339,6 +339,19 @@ public class ReportController {
         User user = userService.getById(token);
         Company company = companyService.getById(user.getCompanyId());
         TimeType comTimeType = timeTypeMapper.selectById(user.getCompanyId());
+        if (company.getId() == 1336) {
+            //针对三友反馈的填写的日报内容,但是没有显示出来的问题,打印日志进行追踪
+            System.out.println("user: "+user.getId()+", 填写内容是:");
+            if (content != null) {
+                for (int i=0;i<projectId.length; i++) {
+                    if (i < content.length) {
+                        System.out.println("项目:"+i+", "+projectId[i]+", "+content[i]);
+                    } else {
+                        System.out.println("项目:"+i+", "+projectId[i]+", 内容为空");
+                    }
+                }
+            }
+        }
         if (comTimeType.getStopReport() == 1) {
             HttpRespMsg msg = new HttpRespMsg();
             msg.setError("系统已关闭日报填写功能,请联系管理员");

+ 12 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/WeiXinCorpController.java

@@ -1714,7 +1714,8 @@ public class WeiXinCorpController {
 
     //获取部门详情
     private JSONObject getDeptDetail(String accessToken, int deptId) {
-        String url = GET_DEPARTMENT_DETAIL_URL.replace("ACCESS_TOKEN", accessToken).replace("ID", ""+deptId);
+        log.info("传参数accessToken="+accessToken+", deptId=="+deptId);
+        String url = GET_DEPARTMENT_DETAIL_URL.replace("ACCESS_TOKEN", accessToken).replace("id=ID", "id="+deptId);
         String result = restTemplate.getForObject(url, String.class);
         log.info("部门详情:"+result);
         JSONObject obj = JSONObject.parseObject(result);
@@ -2664,9 +2665,19 @@ public class WeiXinCorpController {
             } else {
                 //比较是否有更新
                 Department oldDept = first.get();
+                boolean hasUpdate = false;
                 if (oldDept.getCorpwxDeptpid() == null || !oldDept.getCorpwxDeptpid().equals(department.getCorpwxDeptpid())) {
                     //有父部门需要更新
                     oldDept.setCorpwxDeptpid(parentId);
+                    hasUpdate = true;
+                }
+                if ((StringUtils.isEmpty(oldDept.getDepartmentName()) && !StringUtils.isEmpty(department.getDepartmentName()))
+                    ||(!StringUtils.isEmpty(oldDept.getDepartmentName()) && !StringUtils.isEmpty(department.getDepartmentName()) && !oldDept.getDepartmentName().equals(department.getDepartmentName()))) {
+                    //有名称需要更新
+                    oldDept.setDepartmentName(department.getDepartmentName());
+                    hasUpdate = true;
+                }
+                if (hasUpdate) {
                     departmentMapper.updateById(oldDept);
                 }
                 department = oldDept;

+ 11 - 7
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -5566,13 +5566,17 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                     map.put("daysTxt", date.format(DateTimeFormatter.ofPattern("MM/dd")));
                     if (!noReportDataList.stream().anyMatch(noItem->noItem.get("corpwxUserid").equals(curUser.getCorpwxUserid()))) {
                         noReportDataList.add(map);
-                    }
-                } else {
-                    Map<String, Object> findUser = noReportDataList.stream().filter(data -> data.get("corpwxUserid").equals(curUser.getCorpwxUserid())).findFirst().get();
-                    Object days = findUser.get("days");
-                    findUser.put("days", (Integer)days + 1);
-                    if ((Integer)days + 1 < 4) {
-                        findUser.put("daysTxt", findUser.get("daysTxt") + "," + date.format(DateTimeFormatter.ofPattern("MM/dd")));
+                    } else {
+                        //已经添加过了,需要更新天数
+                        Optional<Map<String, Object>> optional = noReportDataList.stream().filter(data -> data.get("corpwxUserid").equals(curUser.getCorpwxUserid())).findFirst();
+                        if (optional.isPresent()) {
+                            Map<String, Object> findUser = optional.get();
+                            Object days = findUser.get("days");
+                            findUser.put("days", (Integer)days + 1);
+                            if ((Integer)days + 1 < 4) {
+                                findUser.put("daysTxt", findUser.get("daysTxt") + "," + date.format(DateTimeFormatter.ofPattern("MM/dd")));
+                            }
+                        }
                     }
                 }
             }

+ 19 - 19
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/task/TimingTask.java

@@ -1278,9 +1278,8 @@ public class TimingTask {
                 }
                 //开通了OA功能,有请假模块的,需要把当前请假的排除掉
                 List<Map<String, Object>> userList = new ArrayList<>();
-                boolean recentlyNotFill;
+                boolean lastWeekNotFill = false;
                 if (t.getAlertType() == 0 || t.getAlertType() == 1) {
-                    recentlyNotFill = false;
                     if (company.getPackageOa() == 1) {
                         userList = userMapper.getPushUserList(t.getCompanyId(),t.getAlertType(), date);
                     } else {
@@ -1305,16 +1304,21 @@ public class TimingTask {
                         }
                         transfDay = transfDay.plusDays(1);
                     }
-                    //如果今天就是最后一个工作日
-                    if (lastWorkDay.isEqual(localDate)) {
-                        recentlyNotFill = false;
+                    //如果今天就是最后一个工作日;或者周六周日,需要提醒本周
+                    if (lastWorkDay.isEqual(localDate) || localDate.getDayOfWeek().getValue() == 6 || localDate.getDayOfWeek().getValue() == 7) {
                         LocalDate startDate = localDate.with(DayOfWeek.MONDAY);
                         userList = reportService.getNotFullReportUserList(company.getId(), startDate, lastDay);
                     } else {
-                        //检查之前10天是否存在未填的
-                        LocalDate startDate = localDate.minusDays(10);
-                        userList = reportService.getNotFullReportUserList(company.getId(), startDate, localDate.minusDays(1));
-                        recentlyNotFill = true;
+                        LocalDate startDate = localDate.minusDays(7);
+                        //从2023-11-10号以后开始算
+                        if (startDate.isAfter(LocalDate.parse("2023-11-05"))) {
+                            //检查上周日报是否漏填
+                            LocalDate lastSunday = localDate.with(DayOfWeek.SUNDAY).minusWeeks(1);
+                            LocalDate lastMonday = lastSunday.minusDays(6);
+                            userList = reportService.getNotFullReportUserList(company.getId(), lastMonday, lastSunday);
+//                            System.out.println("上周未填人员数量="+userList.size());
+                            lastWeekNotFill = true;
+                        }
                     }
                 } else if (t.getAlertType() == 3) {
                     //3--每月固定日期提醒上个月的
@@ -1328,19 +1332,16 @@ public class TimingTask {
                         LocalDate endDate = localDate.minusMonths(1).with(TemporalAdjusters.lastDayOfMonth());
                         userList = reportService.getNotFullReportUserList(company.getId(), startDate, endDate);
                     }
-                    recentlyNotFill = false;
-                } else {
-                    recentlyNotFill = false;
                 }
-
                 List<WxCorpInfo> cpList = wxCorpInfoMapper.selectList(new QueryWrapper<WxCorpInfo>().eq("company_id", t.getCompanyId()));
+                final boolean finalLastWeekNotFill = lastWeekNotFill;
                 userList.forEach(u->{
                     if (u.get("corpwxUserid") != null){
                         //推送到企业微信
                         String corpUid = (String) u.get("corpwxUserid");
                         JSONObject json=new JSONObject();
-                        JSONArray dataJson=new JSONArray();
-                        JSONObject jsonObj=new JSONObject();
+                        JSONArray dataJson = new JSONArray();
+                        JSONObject jsonObj = new JSONObject();
                         jsonObj.put("key", "提示");
                         if (t.getAlertType() == 3) {
                             //每月提醒上个月的
@@ -1350,14 +1351,12 @@ public class TimingTask {
                                 jsonObj.put("value", "您上个月有"+u.get("daysTxt")+"共"+(Integer)u.get("days")+"天未填写工时报告,请尽快填写");
                             }
                         } else {
-                            if (recentlyNotFill) {
-                                jsonObj.put("value", "您近期有"+(Integer)u.get("days")+"天未填写工时报告,请尽快填写");
+                            if (finalLastWeekNotFill) {
+                                jsonObj.put("value", "您上周有"+(Integer)u.get("days")+"天未填写工时报告,请尽快填写");
                             } else {
                                 jsonObj.put("value", StringUtils.isEmpty(t.getAlertMsg())?"":t.getAlertMsg());
                             }
                         }
-
-
                         dataJson.add(jsonObj);
                         if(isPrivateDeploy){
                             json.put("content",StringUtils.isEmpty(t.getAlertMsg())?"":t.getAlertMsg()+"\\n<a href=\\\"https://open.weixin.qq.com/connect/oauth2/authorize?appid="+suitId+"&redirect_uri="+pcUrl+"/api/corpInsideWXAuth&response_type=code&scope=snsapi_base&state=0#wechat_redirect\\\">去填写</a>");
@@ -1367,6 +1366,7 @@ public class TimingTask {
                             json.put("content_item",dataJson);
                         }
                         if (cpList.size() > 0) {
+//                            System.out.println("发送企业微信漏填提醒:" + LocalDateTime.now().toString() + ", corpUid=" + corpUid + ", json=" + json.toJSONString());
                             wxCorpInfoService.sendWXCorpTemplateMsg(cpList.get(0), corpUid, json);
                         }
                     } else if (u.get("wxOpenid") != null) {

+ 5 - 10
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/DateTimeUtil.java

@@ -70,15 +70,10 @@ public class DateTimeUtil {
     }
 
     public static void main(String[] args) {
-        double d = getHalfHoursFromDouble(0.26);
-        System.out.println(d);
-        d = getHalfHoursFromDouble(1.2);
-        System.out.println(d);
-        d = getHalfHoursFromDouble(1.24);
-        System.out.println(d);
-        d = getHalfHoursFromDouble(1.25);
-        System.out.println(d);
-        d = getHalfHoursFromDouble(1.26);
-        System.out.println(d);
+        LocalDate localDate = LocalDate.now();
+        System.out.println(localDate);
+        System.out.println(localDate.getDayOfWeek().getValue());
+        localDate = localDate.with(DayOfWeek.SUNDAY);
+        System.out.println(localDate);
     }
 }