|  |  | 
 |  |  |  | 
 |  |  | import java.text.ParseException; | 
 |  |  | import java.text.SimpleDateFormat; | 
 |  |  | import java.time.LocalDateTime; | 
 |  |  | import java.time.format.DateTimeFormatter; | 
 |  |  | import java.util.ArrayList; | 
 |  |  | import java.util.Date; | 
 |  |  | import java.util.List; | 
 |  |  | 
 |  |  |             monthZero = String.valueOf(month); | 
 |  |  |         } | 
 |  |  |         JSONArray jsonArray = new JSONArray(); | 
 |  |  |         SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); | 
 |  |  |         for (int i = 1; i <= day; i++) { | 
 |  |  |             String di; | 
 |  |  |             if(i<10){ | 
 |  |  | 
 |  |  |             Boolean planBoolean = false; | 
 |  |  |             //循环每一天 | 
 |  |  |             String ymd = year+"-"+monthZero+"-"+di; | 
 |  |  | //            Date ymdDate = dateFormat.parse(ymd); | 
 |  |  |             //匹配计划时间 | 
 |  |  |             String cycle = ardAppPatrolplan.getCycle(); | 
 |  |  |             if(cycle.equals("day")){ | 
 |  |  |                 String createTime = ardAppPatrolplan.getCreateTime(); | 
 |  |  | //                Date beginCreateDate = dateFormat.parse(createTime); | 
 |  |  |                 int d = ymd.compareTo(createTime); | 
 |  |  |                 String st = createTime.substring(0,10); | 
 |  |  |                 int d = ymd.compareTo(st); | 
 |  |  |                 if(d>=0){ | 
 |  |  |                     planBoolean = true; | 
 |  |  |                 } | 
 |  |  |             }else if(cycle.equals("once")){ | 
 |  |  |                 String onceBegin = ardAppPatrolplan.getPatroBeginTime(); | 
 |  |  | //                Date onceBeginDate = dateFormat.parse(onceBegin); | 
 |  |  |                 String onceEnd = ardAppPatrolplan.getPatroEndTime(); | 
 |  |  | //                Date onceEndDate = dateFormat.parse(onceEnd); | 
 |  |  |                 int bd = ymd.compareTo(onceBegin); | 
 |  |  |                 int ed = ymd.compareTo(onceEnd); | 
 |  |  |                 if(bd>=0 && ed<=0){ | 
 |  |  |                 String onceT = onceBegin.substring(0,10); | 
 |  |  |                 int num = ymd.compareTo(onceT); | 
 |  |  |                 if(num==0){ | 
 |  |  |                     planBoolean = true; | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  | 
 |  |  |             Boolean or = false; | 
 |  |  |             if(planBoolean){ | 
 |  |  |                 for (int j = 0; j < list.size(); j++) { | 
 |  |  |                     //打卡时间拆分 | 
 |  |  |                     String recordTime = list.get(j).getRecordTime(); | 
 |  |  |                     String[] part = recordTime.split("[-\\s:]"); | 
 |  |  |                     int recordYear = Integer.parseInt(part[0]); | 
 |  |  |                     int recordMonth = Integer.parseInt(part[1]); | 
 |  |  |                     String recordMonthZero; | 
 |  |  |                     if(recordMonth<10){ | 
 |  |  |                         recordMonthZero = String.format("%02d", recordMonth); | 
 |  |  |                     }else { | 
 |  |  |                         recordMonthZero = String.valueOf(recordMonth); | 
 |  |  |                     } | 
 |  |  |                     int recordDay = Integer.parseInt(part[2]); | 
 |  |  |                     String recordDayZero; | 
 |  |  |                     if(recordDay<10){ | 
 |  |  |                         recordDayZero = String.format("%02d", recordDay); | 
 |  |  |                     }else { | 
 |  |  |                         recordDayZero = String.valueOf(recordDay); | 
 |  |  |                     } | 
 |  |  |                     String recordDate = recordYear+"-"+recordMonthZero+"-"+recordDayZero; | 
 |  |  |                     //如果相等说明这天有打卡记录记录 | 
 |  |  |                     if(ymd.equals(recordDate)){ | 
 |  |  |                         or = true; | 
 |  |  |                         break; | 
 |  |  |                     //获取打卡时间 | 
 |  |  |                     String toDayRecord = list.get(j).getRecordTime(); | 
 |  |  |                     String dr = toDayRecord.substring(0,10); | 
 |  |  |                     //如果打开日期和这天相同 | 
 |  |  |                     if(ymd.equals(dr)){ | 
 |  |  |                         //查询该计划的所有兴趣点 | 
 |  |  |                         List<ArdAlarmpointsWell> wellList = wellMapper.wellByPlanId(planId); | 
 |  |  |                         //查询该计划的所有执行人 | 
 |  |  |                         List<SysUser> userList = sysUserMapper.userByPlanId(planId); | 
 |  |  |                         //满勤多少条打卡记录 | 
 |  |  |                         int maxNum = wellList.size()*userList.size(); | 
 |  |  |                         //对比应打卡记录相等则true | 
 |  |  |                         if(list.size()==maxNum){ | 
 |  |  |                             or = true; | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  | //                for (int j = 0; j < list.size(); j++) { | 
 |  |  | //                    //打卡时间拆分 | 
 |  |  | //                    String recordTime = list.get(j).getRecordTime(); | 
 |  |  | //                    String[] part = recordTime.split("[-\\s:]"); | 
 |  |  | //                    int recordYear = Integer.parseInt(part[0]); | 
 |  |  | //                    int recordMonth = Integer.parseInt(part[1]); | 
 |  |  | //                    String recordMonthZero; | 
 |  |  | //                    if(recordMonth<10){ | 
 |  |  | //                        recordMonthZero = String.format("%02d", recordMonth); | 
 |  |  | //                    }else { | 
 |  |  | //                        recordMonthZero = String.valueOf(recordMonth); | 
 |  |  | //                    } | 
 |  |  | //                    int recordDay = Integer.parseInt(part[2]); | 
 |  |  | //                    String recordDayZero; | 
 |  |  | //                    if(recordDay<10){ | 
 |  |  | //                        recordDayZero = String.format("%02d", recordDay); | 
 |  |  | //                    }else { | 
 |  |  | //                        recordDayZero = String.valueOf(recordDay); | 
 |  |  | //                    } | 
 |  |  | //                    String recordDate = recordYear+"-"+recordMonthZero+"-"+recordDayZero; | 
 |  |  | //                    //如果相等说明这天有打卡记录记录 | 
 |  |  | //                    if(ymd.equals(recordDate)){ | 
 |  |  | //                        or = true; | 
 |  |  | //                        break; | 
 |  |  | //                    } | 
 |  |  | //                } | 
 |  |  |             } | 
 |  |  |             jsonObject.put("toDay",ymd ); | 
 |  |  |             jsonObject.put("plan",planBoolean); | 
 |  |  | 
 |  |  |     @Override | 
 |  |  |     public Results recordDetails(RecordDetailsParam recordDetailsParam) throws ParseException { | 
 |  |  |         SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); | 
 |  |  |         SimpleDateFormat dateFormatTime = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); | 
 |  |  |         SimpleDateFormat dateFormatTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | 
 |  |  |         //获取参数 | 
 |  |  |         String planId = recordDetailsParam.getPlanId(); | 
 |  |  |         String toDay = recordDetailsParam.getToDay(); | 
 |  |  | 
 |  |  |                     //小于0是历史 | 
 |  |  |                     recordQueryWrapper.select("max(points_num) pointsNum","user_id","user_name").eq("plan_id", planId).like("record_time", toDay).groupBy("user_id","user_name"); | 
 |  |  |                 }else{ | 
 |  |  |                     String u = dateFormatTime.format(new Date()); | 
 |  |  |                     //等于0选中的日期就是今天,需要进一步判断小于当前时分秒的记录 | 
 |  |  |                     recordQueryWrapper.select("max(points_num) pointsNum","user_id","user_name").eq("plan_id", planId).le("record_time", dateFormatTime.format(new Date())).groupBy("user_id","user_name");; | 
 |  |  |                     recordQueryWrapper.select("max(points_num) pointsNum","user_id","user_name").eq("plan_id", planId).le("record_time", u).groupBy("user_id","user_name"); | 
 |  |  |                 } | 
 |  |  |                 List<ArdAppPatrolpointRecord> list = ardAppPatrolpointRecordMapper.selectList(recordQueryWrapper); | 
 |  |  |                 //选中这天该计划下没有任何打卡记录 | 
 |  |  | 
 |  |  |     @Override | 
 |  |  |     public Results executeDetailsOld(RecordDetailsParam recordDetailsParam) throws ParseException { | 
 |  |  |         SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); | 
 |  |  |         SimpleDateFormat dateFormatTime = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); | 
 |  |  |         SimpleDateFormat dateFormatTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | 
 |  |  |         String userId = SecurityUtils.getUserId(); | 
 |  |  |         //获取参数 | 
 |  |  |         String planId = recordDetailsParam.getPlanId(); | 
 |  |  | 
 |  |  |                 int planNum = dayNum+onceNum; | 
 |  |  |                 //这天总兴趣点数 | 
 |  |  |                 int wellNum = dayWell+onceWell; | 
 |  |  |                 QueryWrapper<ArdAppPatrolpointRecord> queryWrapper = new QueryWrapper<>(); | 
 |  |  |                 queryWrapper.eq("user_id",userId).like("record_time",ymd); | 
 |  |  |                 List<ArdAppPatrolpointRecord> list = ardAppPatrolpointRecordMapper.selectList(queryWrapper); | 
 |  |  |                 //已打卡总条数 | 
 |  |  |                 QueryWrapper<ArdAppPatrolpointRecord> queryWrapper = new QueryWrapper<>(); | 
 |  |  |                 queryWrapper.eq("user_id",userId).like("record_time",ymd).isNull("del"); | 
 |  |  |                 List<ArdAppPatrolpointRecord> list = ardAppPatrolpointRecordMapper.selectList(queryWrapper); | 
 |  |  |                 int num = list.size(); | 
 |  |  |                 //应打卡总条数 | 
 |  |  |                 int record = planNum*wellNum; | 
 |  |  |                 if(num==record){ | 
 |  |  |                 if(num>=record){ | 
 |  |  |                     recordBoolean = true; | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public Results son() { | 
 |  |  |  | 
 |  |  |         return null; | 
 |  |  |         DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); | 
 |  |  |         //获取用户执行人 | 
 |  |  |         String userId = SecurityUtils.getUserId(); | 
 |  |  |         // 减少 10 秒 | 
 |  |  |         LocalDateTime now = LocalDateTime.now(); // 获取当前日期时间 | 
 |  |  |         LocalDateTime earlier = now.minusSeconds(10); // 减少30秒 | 
 |  |  |         RecordSonParam recordSonParam = new RecordSonParam(); | 
 |  |  |         recordSonParam.setUserId(userId); | 
 |  |  |         String n = fmt.format(now); | 
 |  |  |         recordSonParam.setTime(n); | 
 |  |  |         String e = fmt.format(earlier); | 
 |  |  |         recordSonParam.setBeforeTime(e); | 
 |  |  |         //根据姓名ID为执行人获取所有对应的计划名称 | 
 |  |  |         List<ArdAppPatrolplan> list = patrolplanMapper.planUser(recordSonParam); | 
 |  |  |         JSONArray jsonArray = new JSONArray(); | 
 |  |  |         JSONObject jsonObject = new JSONObject(); | 
 |  |  |         if(list.size()>0){ | 
 |  |  |             jsonObject.put("plan",true); | 
 |  |  |             jsonObject.put("user",list.get(0).getNickName()); | 
 |  |  |             jsonObject.put("name",list.get(0).getPlanName()); | 
 |  |  | //            list.get(0).setSon("已通知"); | 
 |  |  | //            patrolplanMapper.updateById(list.get(0)); | 
 |  |  |         }else { | 
 |  |  |             jsonObject.put("plan",false); | 
 |  |  |             jsonObject.put("user",null); | 
 |  |  |             jsonObject.put("name",null); | 
 |  |  |         } | 
 |  |  |         jsonArray.add(jsonObject); | 
 |  |  |         return Results.succeed(jsonArray); | 
 |  |  |     } | 
 |  |  | } |