todayTime

@Resource
NurLearningTimeMapper nurLearningTimeMapper;
@Resource
NurStudentMapper nurStudentMapper;
@Resource
NurScoreDetailMapper nurScoreDetailMapper;

private static final long nh = 1000 * 60 * 60;
private static final long nm = 1000 * 60;



@Override
public Result todayTime(StuIdStatusDTO stuIdStatusDTO) throws ParseException {

    //获取当前日期
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Calendar c = Calendar.getInstance();
    c.add(Calendar.DATE, 1);//-1.昨天时间 0.当前时间 1.明天时间 *以此类推
    String tomorrow = sdf.format(c.getTime());
    String today = new SimpleDateFormat("yyyy-MM-dd").format(new Date());

    stuIdStatusDTO.setDate(today);
    stuIdStatusDTO.setTomorrow(tomorrow);

    List<NurLearningTime> nurStuLearnTimeVOSOne = nurLearningTimeMapper.selectTodayTimeOne(stuIdStatusDTO);

    NurLearningTime nurStuLearnTimeVOSTwo = nurLearningTimeMapper.selectTodayTimeTwo(stuIdStatusDTO);


    NurStudent nurStudent = nurStudentMapper.selectOne(Wrappers.lambdaQuery(NurStudent.class)
            .eq(NurStudent::getStuId, stuIdStatusDTO.getStuId()));


    if(nurStuLearnTimeVOSTwo==null){
        long duration = 0;
        for (NurLearningTime nurLearningTime : nurStuLearnTimeVOSOne) {
            long startTime = nurLearningTime.getStartTime().getTime();
            long stopTime = nurLearningTime.getStopTime().getTime();
            long time = stopTime - startTime;
            duration += time;
        }
        long min = duration / nm;

        Double stuStudyTime = nurStudent.getStuStudyTime();
        Double stuStudyAllTime = stuStudyTime +min;

        nurStudentMapper.update(nurStudent,Wrappers.lambdaUpdate(NurStudent.class)
                .set(NurStudent::getStuStudyTime,stuStudyAllTime)
                .eq(NurStudent::getStuId,stuIdStatusDTO.getStuId()));


        return Result.ok().data("min",min);

    }else {
        long duration = 0;
        for (NurLearningTime nurLearningTime : nurStuLearnTimeVOSOne) {
            long startTime = nurLearningTime.getStartTime().getTime();
            long stopTime = nurLearningTime.getStopTime().getTime();
            long time = stopTime - startTime;
            duration += time;

        }

        long minOne = duration / nm;

        long stopTime = nurStuLearnTimeVOSTwo.getStopTime().getTime();
        SimpleDateFormat sdfOne = new SimpleDateFormat("yyyy-MM-dd ");
        long overTime = (stopTime - (sdfOne.parse(sdfOne.format(stopTime)).getTime()));
        long min1 = overTime/nm;

        Double stuStudyAllTimeTwo = Double.valueOf(minOne + min1);

        nurStudentMapper.update(nurStudent,Wrappers.lambdaUpdate(NurStudent.class)
                .set(NurStudent::getStuStudyTime,stuStudyAllTimeTwo)
                .eq(NurStudent::getStuId,stuIdStatusDTO.getStuId()));

        return Result.ok().data("min1",min1);
    }

}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值