/**

  • 获得扫码记录列表中当日所扫码的次数统计
  • @param goodsName
  • @param businessName
  • @param timeHorizon1
  • @param timeHorizon2 */ @Override public int getScanRecordCountToday(Long goodsName, Long businessName, String timeHorizon1, String timeHorizon2) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(ScanRecordDO::getBelongBusinessId, businessName); wrapper.eq(ScanRecordDO::getGoodsId, goodsName); // //时间转换 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { Date date1 = sdf.parse(timeHorizon1); Date date2 = sdf.parse(timeHorizon2); wrapper.between(ScanRecordDO::getScanTime, date1, date2); } catch (ParseException e) { e.printStackTrace(); } // 获取当日时间段 Date today = new Date(); Calendar calendar = Calendar.getInstance(); calendar.setTime(today); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); Date startDate = calendar.getTime(); calendar.set(Calendar.HOUR_OF_DAY, 23); calendar.set(Calendar.MINUTE, 59); calendar.set(Calendar.SECOND, 59); Date endDate = calendar.getTime(); // 添加当日时间段的查询条件 wrapper.between(ScanRecordDO::getScanTime, startDate, endDate); List scanRecordDOS = scanRecordMapper.selectList(wrapper); return scanRecordDOS.size(); }

这段代码实现了从扫码记录列表中查询出当日所扫码的次数统计,思路如下:

  1. 在原有代码基础上,获取当日时间段的起始时间和结束时间;
  2. 添加当日时间段的查询条件;
  3. 查询出符合条件的扫码记录列表;
  4. 返回扫码记录列表的大小,即为当日所扫码的次数统计。
获得扫码记录列表 param goodsName param businessName param timeHorizon1 param timeHorizon2 Override public ListScanRecordDO getScanRecordListTistLong goodsName Long business

原文地址: https://www.cveoy.top/t/topic/5Zc 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录