Administrator
2023-08-19 b495b133520e49f583a3e03f880d528e13d77117
ard-work/src/main/java/com/ruoyi/app/patrolplan/service/impl/ArdAppPatrolpointRecordServiceImpl.java
@@ -71,7 +71,8 @@
                .eq("user_id",ardAppPatrolpointRecord.getUserId());
        List<ArdAppPatrolpointRecord> recordList = ardAppPatrolpointRecordMapper.selectList(recordQueryWrapper);
        ardAppPatrolpointRecord.setPointsNum(recordList.size()+1);
        int num = ardAppPatrolpointRecordMapper.insert(ardAppPatrolpointRecord);
//        int num = ardAppPatrolpointRecordMapper.insert(ardAppPatrolpointRecord);
        int num = ardAppPatrolpointRecordMapper.insertArdAppPatrolpointRecord(ardAppPatrolpointRecord);
        List<String> list = ardAppPatrolpointRecord.getImg();
        for (int i = 0; i < list.size(); i++) {
            ArdAppPatrolpointRecordImg recordImg = new ArdAppPatrolpointRecordImg();
@@ -79,7 +80,7 @@
            recordImg.setId(imgId);
            recordImg.setAppPatrolponitRecordId(id);
            recordImg.setImg(list.get(i));
            recordImgMapper.insert(recordImg);
            recordImgMapper.insertArdAppPatrolpointRecordImg(recordImg);
        }
        if(num>0){
            return Results.succeed("打卡成功!");
@@ -136,14 +137,16 @@
                }
            }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;
                }
//                Date onceBeginDate = dateFormat.parse(onceBegin);
//                String onceEnd = ardAppPatrolplan.getPatroEndTime();
//                Date onceEndDate = dateFormat.parse(onceEnd);
//                int bd = ymd.compareTo(onceBegin);
//                int ed = ymd.compareTo(onceEnd);
            }
            //匹配打卡时间
            Boolean or = false;
@@ -186,7 +189,7 @@
    @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();
@@ -237,10 +240,21 @@
                    //小于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);
//                List<ArdAppPatrolpointRecord> list = new ArrayList<>();
//                RecordDetailsParam detailsParam = new RecordDetailsParam();
//                detailsParam.setPlanId(planId);
//                if(d<0){
//                    detailsParam.setToDay(toDay);
//                    list = ardAppPatrolpointRecordMapper.lt(detailsParam);
//                }else {
//                    detailsParam.setToDay(dateFormatTime.format(new Date()));
//                    list = ardAppPatrolpointRecordMapper.es(detailsParam);
//                }
                //选中这天该计划下没有任何打卡记录
                if(list.size()==0){
                    for (int i = 0; i < users.size(); i++) {
@@ -299,10 +313,20 @@
        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){
@@ -316,6 +340,7 @@
                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);
@@ -349,6 +374,7 @@
                ardAppPatrolpointRecord.setUserName(userName);
                ardAppPatrolpointRecord.setLatitude(String.valueOf(ardAlarmpointsWell.getLatitude()));
                ardAppPatrolpointRecord.setLongitude(String.valueOf(ardAlarmpointsWell.getLongitude().toString()));
                ardAppPatrolpointRecord.setPlanUserName(nikeName);
                list.add(ardAppPatrolpointRecord);
            }
        }
@@ -717,4 +743,50 @@
        }
        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);
    }
    @Override
    public Results son() {
        return null;
    }
}