| | |
| | | import com.ruoyi.app.patrolplan.domain.ArdAppPatrolplan; |
| | | import com.ruoyi.app.patrolplan.domain.ArdAppPatrolpointRecordImg; |
| | | import com.ruoyi.app.patrolplan.domain.ArdAppPatroluser; |
| | | import com.ruoyi.app.patrolplan.domain.param.ArdAppPatrolpointRecordParam; |
| | | import com.ruoyi.app.patrolplan.domain.param.*; |
| | | import com.ruoyi.app.patrolplan.mapper.ArdAppPatrolplanMapper; |
| | | import com.ruoyi.app.patrolplan.mapper.ArdAppPatrolpointRecordImgMapper; |
| | | import com.ruoyi.app.patrolplan.mapper.ArdAppPatroluserMapper; |
| | |
| | | @Resource |
| | | private ArdAlarmpointsWellMapper wellMapper; |
| | | |
| | | /** |
| | | * 查询app巡检计划记录 |
| | | * |
| | | * @param id app巡检计划记录主键 |
| | | * @return app巡检计划记录 |
| | | */ |
| | | @Override |
| | | public ArdAppPatrolpointRecord selectArdAppPatrolpointRecordById(String id) { |
| | | return ardAppPatrolpointRecordMapper.selectArdAppPatrolpointRecordById(id); |
| | | } |
| | | |
| | | /** |
| | | * 查询app巡检计划记录列表 |
| | | * |
| | | * @param ardAppPatrolpointRecord app巡检计划记录 |
| | | * @return app巡检计划记录 |
| | | */ |
| | | @Override |
| | | public List<ArdAppPatrolpointRecord> selectArdAppPatrolpointRecordList(ArdAppPatrolpointRecord ardAppPatrolpointRecord) { |
| | | return ardAppPatrolpointRecordMapper.selectArdAppPatrolpointRecordList(ardAppPatrolpointRecord); |
| | | } |
| | | |
| | | /** |
| | | * 新增app巡检计划记录 |
| | | * |
| | | * @param ardAppPatrolpointRecord app巡检计划记录 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int insertArdAppPatrolpointRecord(ArdAppPatrolpointRecord ardAppPatrolpointRecord) { |
| | | ardAppPatrolpointRecord.setUserId(SecurityUtils.getUserId()); |
| | | return ardAppPatrolpointRecordMapper.insertArdAppPatrolpointRecord(ardAppPatrolpointRecord); |
| | | } |
| | | |
| | | /** |
| | | * 修改app巡检计划记录 |
| | | * |
| | | * @param ardAppPatrolpointRecord app巡检计划记录 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int updateArdAppPatrolpointRecord(ArdAppPatrolpointRecord ardAppPatrolpointRecord) { |
| | | return ardAppPatrolpointRecordMapper.updateArdAppPatrolpointRecord(ardAppPatrolpointRecord); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除app巡检计划记录 |
| | | * |
| | | * @param ids 需要删除的app巡检计划记录主键 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteArdAppPatrolpointRecordByIds(String[] ids) { |
| | | return ardAppPatrolpointRecordMapper.deleteArdAppPatrolpointRecordByIds(ids); |
| | | } |
| | | |
| | | /** |
| | | * 删除app巡检计划记录信息 |
| | | * |
| | | * @param id app巡检计划记录主键 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteArdAppPatrolpointRecordById(String id) { |
| | | return ardAppPatrolpointRecordMapper.deleteArdAppPatrolpointRecordById(id); |
| | | } |
| | | |
| | | @Override |
| | | public Results record(ArdAppPatrolpointRecord ardAppPatrolpointRecord) { |
| | | String id = IdUtils.simpleUUID(); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Results recordMonth(ArdAppPatrolpointRecordParam ardAppPatrolpointRecordParam) throws ParseException { |
| | | public Results recordMonth(RecordMonthParam recordMonthParam) throws ParseException { |
| | | //获取前端参数 |
| | | String begin = ardAppPatrolpointRecordParam.getBegin(); |
| | | String end = ardAppPatrolpointRecordParam.getEnd(); |
| | | String planId = ardAppPatrolpointRecordParam.getPlanId(); |
| | | String begin = recordMonthParam.getBegin(); |
| | | String end = recordMonthParam.getEnd(); |
| | | String planId = recordMonthParam.getPlanId(); |
| | | //查询计划表 |
| | | ArdAppPatrolplan ardAppPatrolplan = patrolplanMapper.selectById(planId); |
| | | //查询出有效打卡数据 |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Results recordDetails(ArdAppPatrolpointRecordParam ardAppPatrolpointRecordParam) throws ParseException { |
| | | public Results recordDetails(RecordDetailsParam recordDetailsParam) throws ParseException { |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | | SimpleDateFormat dateFormatTime = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); |
| | | //获取参数 |
| | | String planId = ardAppPatrolpointRecordParam.getPlanId(); |
| | | String toDay = ardAppPatrolpointRecordParam.getToDay(); |
| | | String planId = recordDetailsParam.getPlanId(); |
| | | String toDay = recordDetailsParam.getToDay(); |
| | | //查询计划表 |
| | | ArdAppPatrolplan ardAppPatrolplan = patrolplanMapper.selectById(planId); |
| | | String cycle = ardAppPatrolplan.getCycle(); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Results recordSolo(ArdAppPatrolpointRecordParam ardAppPatrolpointRecordParam) { |
| | | String toDay = ardAppPatrolpointRecordParam.getToDay(); |
| | | String planId = ardAppPatrolpointRecordParam.getPlanId(); |
| | | String userId = ardAppPatrolpointRecordParam.getUserId(); |
| | | public Results recordSolo(RecordSoloParam recordSoloParam) { |
| | | String toDay = recordSoloParam.getToDay(); |
| | | String planId = recordSoloParam.getPlanId(); |
| | | String userId = recordSoloParam.getUserId(); |
| | | String planName = recordSoloParam.getPlanName(); |
| | | String userName = recordSoloParam.getUserName(); |
| | | //根据计划ID获取制定人ID |
| | | ArdAppPatrolplan ardAppPatrolplan = patrolplanMapper.selectById(planId); |
| | | //根据姓名ID查询计划制定人的姓名 |
| | | String planUserId = ardAppPatrolplan.getUserId(); |
| | | SysUser sysUser = sysUserMapper.selectById(planUserId); |
| | | String nikeName = sysUser.getNickName(); |
| | | QueryWrapper<ArdAppPatrolpointRecord> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("plan_id", planId).eq("user_id",userId).like("record_time", toDay); |
| | | //当前计划选中时间里此用户的打卡记录 |
| | | List<ArdAppPatrolpointRecord> list = ardAppPatrolpointRecordMapper.selectList(queryWrapper); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | ArdAppPatrolpointRecord ardAppPatrolpointRecord = list.get(i); |
| | | ardAppPatrolpointRecord.setPlanUserName(nikeName); |
| | | } |
| | | //查询该计划的所有兴趣点 |
| | | List<ArdAlarmpointsWell> wellList = wellMapper.wellByPlanId(planId); |
| | | if(list.size()==0){ |
| | | for (ArdAlarmpointsWell ardAlarmpointsWell : wellList) { |
| | | ArdAppPatrolpointRecord ardAppPatrolpointRecord = new ArdAppPatrolpointRecord(); |
| | | ardAppPatrolpointRecord.setAppPatrolpointsId(ardAlarmpointsWell.getId()); |
| | | ardAppPatrolpointRecord.setAppPatrolpointsName(ardAlarmpointsWell.getWellId()); |
| | | ardAppPatrolpointRecord.setPlanId(planId); |
| | | ardAppPatrolpointRecord.setPlanName(planName); |
| | | ardAppPatrolpointRecord.setUserId(userId); |
| | | ardAppPatrolpointRecord.setUserName(userName); |
| | | ardAppPatrolpointRecord.setLatitude(String.valueOf(ardAlarmpointsWell.getLatitude())); |
| | | ardAppPatrolpointRecord.setLongitude(String.valueOf(ardAlarmpointsWell.getLongitude().toString())); |
| | | ardAppPatrolpointRecord.setPlanUserName(nikeName); |
| | | list.add(ardAppPatrolpointRecord); |
| | | } |
| | | return Results.succeed(list); |
| | | } |
| | | for (ArdAppPatrolpointRecord appPatrolpointRecord : list) { |
| | | QueryWrapper<ArdAppPatrolpointRecordImg> queryWrapper1 = new QueryWrapper<>(); |
| | | queryWrapper1.eq("app_patrolponit_record_id", appPatrolpointRecord.getId()); |
| | |
| | | for (ArdAppPatrolpointRecord appPatrolpointRecord : list) { |
| | | pointList.add(appPatrolpointRecord.getAppPatrolpointsId()); |
| | | } |
| | | //查询该计划的所有兴趣点 |
| | | List<ArdAlarmpointsWell> wellList = wellMapper.wellByPlanId(planId); |
| | | for (ArdAlarmpointsWell ardAlarmpointsWell : wellList) { |
| | | //所有应该打卡的地点ID |
| | | String well = ardAlarmpointsWell.getId(); |
| | | //如果打开地点不包含应打卡地点,那说名这块儿没打卡 |
| | | //如果打卡地点不包含应打卡地点,那说名这块儿没打卡 |
| | | if (!pointList.contains(well)) { |
| | | ArdAppPatrolpointRecord ardAppPatrolpointRecord = new ArdAppPatrolpointRecord(); |
| | | ardAppPatrolpointRecord.setAppPatrolpointsId(well); |
| | | ardAppPatrolpointRecord.setAppPatrolpointsName(ardAlarmpointsWell.getWellId()); |
| | | ardAppPatrolpointRecord.setPlanId(planId); |
| | | ardAppPatrolpointRecord.setPlanName(list.get(0).getPlanName()); |
| | | ardAppPatrolpointRecord.setPlanName(planName); |
| | | ardAppPatrolpointRecord.setUserId(userId); |
| | | ardAppPatrolpointRecord.setUserName(list.get(0).getUserName()); |
| | | ardAppPatrolpointRecord.setLatitude(ardAlarmpointsWell.getLatitude().toString()); |
| | | ardAppPatrolpointRecord.setLongitude(ardAlarmpointsWell.getLongitude().toString()); |
| | | ardAppPatrolpointRecord.setUserName(userName); |
| | | ardAppPatrolpointRecord.setLatitude(String.valueOf(ardAlarmpointsWell.getLatitude())); |
| | | ardAppPatrolpointRecord.setLongitude(String.valueOf(ardAlarmpointsWell.getLongitude().toString())); |
| | | ardAppPatrolpointRecord.setPlanUserName(nikeName); |
| | | list.add(ardAppPatrolpointRecord); |
| | | } |
| | | } |
| | | return Results.succeed(list); |
| | | } |
| | | |
| | | @Override |
| | | public Results executeMonthOld(RecordMonthParam RecordMonthParam) throws ParseException { |
| | | //获取前端参数 |
| | | String begin = RecordMonthParam.getBegin(); |
| | | String end = RecordMonthParam.getEnd(); |
| | | String planId = RecordMonthParam.getPlanId(); |
| | | //查询计划表 |
| | | ArdAppPatrolplan ardAppPatrolplan = patrolplanMapper.selectById(planId); |
| | | //查询出有效打卡数据 |
| | | String userId = SecurityUtils.getUserId(); |
| | | QueryWrapper<ArdAppPatrolpointRecord> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.between("record_time",begin,end).eq("plan_id",planId).eq("user_id",userId); |
| | | List<ArdAppPatrolpointRecord> list = ardAppPatrolpointRecordMapper.selectList(queryWrapper); |
| | | //时间拆分 |
| | | String[] parts = end.split("[-\\s:]"); |
| | | int year = Integer.parseInt(parts[0]); |
| | | int month = Integer.parseInt(parts[1]); |
| | | int day = Integer.parseInt(parts[2]); |
| | | String monthZero; |
| | | if(month<10){ |
| | | monthZero = String.format("%02d", month); |
| | | }else { |
| | | 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){ |
| | | di = String.format("%02d", i); |
| | | }else { |
| | | di = String.valueOf(i); |
| | | } |
| | | JSONObject jsonObject = new JSONObject(); |
| | | Boolean planBoolean = false; |
| | | //循环每一天 |
| | | String ymd = year+"-"+monthZero+"-"+di; |
| | | //匹配计划时间 |
| | | String cycle = ardAppPatrolplan.getCycle(); |
| | | if(cycle.equals("day")){ |
| | | String createTime = ardAppPatrolplan.getCreateTime(); |
| | | int d = ymd.compareTo(createTime); |
| | | if(d>=0){ |
| | | planBoolean = true; |
| | | } |
| | | }else if(cycle.equals("once")){ |
| | | String onceBegin = ardAppPatrolplan.getPatroBeginTime(); |
| | | String onceEnd = ardAppPatrolplan.getPatroEndTime(); |
| | | int bd = ymd.compareTo(onceBegin); |
| | | int ed = ymd.compareTo(onceEnd); |
| | | if(bd>=0 && ed<=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; |
| | | } |
| | | } |
| | | } |
| | | jsonObject.put("toDay",ymd ); |
| | | jsonObject.put("plan",planBoolean); |
| | | jsonObject.put("record",or); |
| | | jsonArray.add(jsonObject); |
| | | } |
| | | return Results.succeed(jsonArray); |
| | | } |
| | | |
| | | @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"); |
| | | String userId = SecurityUtils.getUserId(); |
| | | //获取参数 |
| | | String planId = recordDetailsParam.getPlanId(); |
| | | String toDay = recordDetailsParam.getToDay(); |
| | | //查询计划表 |
| | | ArdAppPatrolplan ardAppPatrolplan = patrolplanMapper.selectById(planId); |
| | | String cycle = ardAppPatrolplan.getCycle(); |
| | | String begin = ardAppPatrolplan.getPatroBeginTime(); |
| | | String end = ardAppPatrolplan.getPatroEndTime(); |
| | | String create = ardAppPatrolplan.getCreateTime(); |
| | | JSONArray jsonArray = new JSONArray(); |
| | | int c = 0; |
| | | if(cycle.equals("day")){ |
| | | //每天计划取创建时间 |
| | | c = toDay.compareTo(create.substring(0,10)); |
| | | }else if(cycle.equals("once")){ |
| | | //单次计划取开始时间 |
| | | c = toDay.compareTo(begin.substring(0,10)); |
| | | } |
| | | if(cycle.equals("once") && c>0){ |
| | | //单次计划大于开始时间==跨天,在计划时间外 |
| | | return Results.succeed("[]"); |
| | | } |
| | | if(c<0){ |
| | | //每日计划小于创建时间或单次计划小于开始时间,在计划时间外 |
| | | return Results.succeed("[]"); |
| | | }else{ |
| | | //在每日计划的时间范围内 |
| | | String date = dateFormat.format(new Date()); |
| | | //比较选中的日期和今天日期 |
| | | int d = toDay.compareTo(date); |
| | | //查询该计划的所有人员 |
| | | List<SysUser> users = sysUserMapper.userByPlanId(planId); |
| | | //查询该计划的所有兴趣点 |
| | | List<ArdAlarmpointsWell> wellList = wellMapper.wellByPlanId(planId); |
| | | //大于0代表查询以后的记录 |
| | | if(d>0){ |
| | | //查询计划内的每日未来数据 |
| | | for (int i = 0; i < users.size(); i++) { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("wellId",wellList.get(i).getId()); |
| | | jsonObject.put("wellName",wellList.get(i).getWellId()); |
| | | jsonObject.put("type",false); |
| | | jsonArray.add(jsonObject); |
| | | } |
| | | return Results.succeed(jsonArray); |
| | | }else{ |
| | | //查询计划内的实际历史打卡数据 |
| | | QueryWrapper<ArdAppPatrolpointRecord> recordQueryWrapper = new QueryWrapper<>(); |
| | | if(d<0){ |
| | | //小于0是历史 |
| | | recordQueryWrapper.select("app_patrolpoints_id","app_patrolpoints_name").eq("plan_id", planId).eq("user_id",userId).like("record_time", toDay); |
| | | }else{ |
| | | //等于0选中的日期就是今天,需要进一步判断小于当前时分秒的记录 |
| | | recordQueryWrapper.select("app_patrolpoints_id","app_patrolpoints_name").eq("plan_id", planId).eq("user_id",userId).le("record_time", dateFormatTime.format(new Date())); |
| | | } |
| | | List<ArdAppPatrolpointRecord> list = ardAppPatrolpointRecordMapper.selectList(recordQueryWrapper); |
| | | //循环打卡地点 |
| | | for (int i = 0; i < wellList.size(); i++) { |
| | | String id = wellList.get(i).getId(); |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("wellId",wellList.get(i).getId()); |
| | | jsonObject.put("wellName",wellList.get(i).getWellId()); |
| | | if(list.size()>0){ |
| | | for (int j = 0; j < list.size(); j++) { |
| | | if(id.equals(list.get(j).getAppPatrolpointsId())){ |
| | | jsonObject.put("type",true); |
| | | break; |
| | | } |
| | | if(j==list.size()-1){ |
| | | jsonObject.put("type",false); |
| | | } |
| | | } |
| | | }else { |
| | | jsonObject.put("type",false); |
| | | } |
| | | jsonArray.add(jsonObject); |
| | | } |
| | | return Results.succeed(jsonArray); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Results executeSolo(RecordSoloExParam recordSoloExParam) { |
| | | QueryWrapper<ArdAppPatrolpointRecord> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("plan_id",recordSoloExParam.getPlanId()) |
| | | .eq("app_patrolpoints_id",recordSoloExParam.getWellId()) |
| | | .eq("user_id",recordSoloExParam.getUserId()) |
| | | .like("record_time",recordSoloExParam.getToDay()); |
| | | List<ArdAppPatrolpointRecord> list = ardAppPatrolpointRecordMapper.selectList(queryWrapper); |
| | | for (ArdAppPatrolpointRecord appPatrolpointRecord : list) { |
| | | QueryWrapper<ArdAppPatrolpointRecordImg> queryWrapper1 = new QueryWrapper<>(); |
| | | queryWrapper1.eq("app_patrolponit_record_id", appPatrolpointRecord.getId()); |
| | | List<ArdAppPatrolpointRecordImg> list1 = recordImgMapper.selectList(queryWrapper1); |
| | | List<String> strings = new ArrayList<>(); |
| | | for (ArdAppPatrolpointRecordImg ardAppPatrolpointRecordImg : list1) { |
| | | strings.add(ardAppPatrolpointRecordImg.getImg()); |
| | | } |
| | | appPatrolpointRecord.setImg(strings); |
| | | } |
| | | return Results.succeed(list); |
| | | } |
| | | |
| | | @Override |
| | | public Results executeMonth(RecordMonthExParam recordMonthExParam) throws ParseException { |
| | | //获取前端参数 |
| | | String begin = recordMonthExParam.getBegin(); |
| | | String end = recordMonthExParam.getEnd(); |
| | | //返回这个 |
| | | JSONArray jsonArray = new JSONArray(); |
| | | //时间拆分 |
| | | String[] parts = end.split("[-\\s:]"); |
| | | int year = Integer.parseInt(parts[0]); |
| | | int month = Integer.parseInt(parts[1]); |
| | | int day = Integer.parseInt(parts[2]); |
| | | String monthZero; |
| | | if(month<10){ |
| | | monthZero = String.format("%02d", month); |
| | | }else { |
| | | monthZero = String.valueOf(month); |
| | | } |
| | | String userId = SecurityUtils.getUserId(); |
| | | recordMonthExParam.setUserId(userId); |
| | | //查询该用户下需要执行的单次计划 |
| | | List<ArdAppPatrolplan> onceList = patrolplanMapper.oncePlan(recordMonthExParam); |
| | | //查询该用户下需要执行的每日计划 |
| | | List<ArdAppPatrolplan> dayList = patrolplanMapper.dayPlan(recordMonthExParam); |
| | | //循环一个月中的每一天 |
| | | for (int i = 1; i <= day; i++) { |
| | | String di; |
| | | Boolean planBoolean = false; |
| | | Boolean recordBoolean = false; |
| | | //记录这天计划条数 |
| | | int dayNum = 0; |
| | | int onceNum = 0; |
| | | //记录这天的打开地点数 |
| | | int dayWell = 0; |
| | | int onceWell = 0; |
| | | if (i < 10) { |
| | | di = String.format("%02d", i); |
| | | } else { |
| | | di = String.valueOf(i); |
| | | } |
| | | //每一天 |
| | | String ymd = year + "-" + monthZero + "-" + di; |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("toDay",ymd ); |
| | | //如果每日计划有数据 |
| | | if (dayList.size() > 0) { |
| | | for (int j = 0; j < dayList.size(); j++) { |
| | | String dayTime = dayList.get(j).getCreateTime(); |
| | | String dt = dayTime.substring(0,10); |
| | | //如果每日计划日期等于这一天,那从这一天之后的每一天都是有计划的 |
| | | if(dt.compareTo(ymd)<=0){ |
| | | planBoolean =true; |
| | | dayNum+=1; |
| | | String id = dayList.get(j).getId(); |
| | | List<ArdAlarmpointsWell> dayWells = wellMapper.wellByPlanId(id); |
| | | dayWell = dayWells.size(); |
| | | } |
| | | } |
| | | } |
| | | //如果单次计划有数据 |
| | | if(onceList.size()>0){ |
| | | for (int j = 0; j < onceList.size(); j++) { |
| | | String beginTime = onceList.get(j).getPatroBeginTime(); |
| | | String bt = beginTime.substring(0,10); |
| | | if(bt.equals(ymd)){ |
| | | planBoolean = true; |
| | | onceNum+=1; |
| | | List<ArdAlarmpointsWell> onceWells = wellMapper.wellByPlanId(onceList.get(j).getId()); |
| | | onceWell = onceWells.size(); |
| | | } |
| | | } |
| | | } |
| | | if(planBoolean){ |
| | | //这天总任务条数 |
| | | 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); |
| | | //已打卡总条数 |
| | | int num = list.size(); |
| | | //应打卡总条数 |
| | | int record = planNum*wellNum; |
| | | if(num==record){ |
| | | recordBoolean = true; |
| | | } |
| | | } |
| | | jsonObject.put("toDay",ymd ); |
| | | jsonObject.put("plan",planBoolean); |
| | | jsonObject.put("record",recordBoolean); |
| | | jsonArray.add(jsonObject); |
| | | } |
| | | return Results.succeed(jsonArray); |
| | | } |
| | | |
| | | @Override |
| | | public Results executeDetails(RecordDetailsExParam recordDetailsExParam) throws ParseException { |
| | | String userId = SecurityUtils.getUserId(); |
| | | //获取参数 |
| | | Boolean plan = recordDetailsExParam.getPlan(); |
| | | String toDay = recordDetailsExParam.getToDay(); |
| | | JSONArray jsonArray = new JSONArray(); |
| | | if(plan){ |
| | | //查询这个用户下为执行人的所有巡检计划 |
| | | ArdAppPatrolplan ardAppPatrolplan = new ArdAppPatrolplan(); |
| | | ardAppPatrolplan.setUserId(SecurityUtils.getUserId()); |
| | | List<ArdAppPatrolplan> list = patrolplanMapper.executeList(ardAppPatrolplan); |
| | | //找出今天的单次和每日计划 |
| | | List<ArdAppPatrolplan> patrolplanList = new ArrayList<>(); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | String cycle = list.get(i).getCycle(); |
| | | //如果是单次任务 |
| | | if(cycle.equals("once")){ |
| | | String begin = list.get(i).getPatroBeginTime(); |
| | | String b = begin.substring(0,10); |
| | | if(b.equals(toDay)){ |
| | | //是今天的计划 |
| | | patrolplanList.add(list.get(i)); |
| | | } |
| | | } |
| | | //如果是每日任务 |
| | | else if(cycle.equals("day")){ |
| | | String create = list.get(i).getCreateTime(); |
| | | String c = create.substring(0,10); |
| | | if(c.compareTo(toDay)<=0){ |
| | | //有今天的计划 |
| | | patrolplanList.add(list.get(i)); |
| | | } |
| | | } |
| | | } |
| | | if(patrolplanList.size()>0){ |
| | | //遍历今天的计划 |
| | | for (int i = 0; i < patrolplanList.size(); i++) { |
| | | String planId = patrolplanList.get(i).getId(); |
| | | String planName = patrolplanList.get(i).getPlanName(); |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("planId",planId); |
| | | jsonObject.put("planName",planName); |
| | | //查询这天有多少点 |
| | | List<ArdAlarmpointsWell> dayWells = wellMapper.wellByPlanId(planId); |
| | | int dayWellNum = dayWells.size(); |
| | | //查询这个用户的这个计划在今天打卡的条数 |
| | | QueryWrapper<ArdAppPatrolpointRecord> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("user_id",userId).eq("plan_id",planId).like("record_time",toDay); |
| | | List<ArdAppPatrolpointRecord> recordList = ardAppPatrolpointRecordMapper.selectList(queryWrapper); |
| | | int recordNum = recordList.size(); |
| | | //如果相等那这条今天的计划就是全部完成了 |
| | | if(recordNum==dayWellNum){ |
| | | jsonObject.put("type",true); |
| | | }else { |
| | | jsonObject.put("type",false); |
| | | } |
| | | jsonArray.add(jsonObject); |
| | | } |
| | | } |
| | | }else { |
| | | //没有计划 |
| | | return Results.succeed("[]"); |
| | | } |
| | | return Results.succeed(jsonArray); |
| | | } |
| | | |
| | | @Override |
| | | public Results recordBefore(RecordBeforeParam recordBeforeParam) { |
| | | String planId = recordBeforeParam.getPlanId(); |
| | | String wellId = recordBeforeParam.getWellId(); |
| | | String toDay = recordBeforeParam.getToDay(); |
| | | String userId = SecurityUtils.getUserId(); |
| | | JSONArray jsonArray = new JSONArray(); |
| | | ArdAppPatrolplan plan = patrolplanMapper.selectById(planId); |
| | | jsonArray.add(plan); |
| | | QueryWrapper<ArdAppPatrolpointRecord> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("plan_id",planId).eq("app_patrolpoints_id",wellId).eq("user_id",userId).like("record_time",toDay); |
| | | ArdAppPatrolpointRecord record = ardAppPatrolpointRecordMapper.selectOne(queryWrapper); |
| | | //根据姓名ID查询计划制定人的姓名 |
| | | String planUserId = plan.getUserId(); |
| | | SysUser sysUser = sysUserMapper.selectById(planUserId); |
| | | String nikeName = sysUser.getNickName(); |
| | | if(record==null){ |
| | | //根据姓名ID查询执行人姓名 |
| | | SysUser user = sysUserMapper.selectById(userId); |
| | | String userName = user.getNickName(); |
| | | //查询该计划的所有兴趣点 |
| | | ArdAlarmpointsWell ardAlarmpointsWell = wellMapper.selectById(wellId); |
| | | //没打卡的数据 |
| | | ArdAppPatrolpointRecord record1 = new ArdAppPatrolpointRecord(); |
| | | record1.setAppPatrolpointsId(ardAlarmpointsWell.getId()); |
| | | record1.setAppPatrolpointsName(ardAlarmpointsWell.getWellId()); |
| | | record1.setPlanId(planId); |
| | | record1.setPlanName(plan.getPlanName()); |
| | | record1.setUserId(userId); |
| | | record1.setUserName(userName); |
| | | record1.setLatitude(String.valueOf(ardAlarmpointsWell.getLatitude())); |
| | | record1.setLongitude(String.valueOf(ardAlarmpointsWell.getLongitude().toString())); |
| | | record1.setPlanUserName(nikeName); |
| | | jsonArray.add(record1); |
| | | }else { |
| | | jsonArray.add(record); |
| | | } |
| | | return Results.succeed(jsonArray); |
| | | } |
| | | } |