From eb5679217f094451bf027d564ecbacd9585fddd8 Mon Sep 17 00:00:00 2001 From: zhizhi wu <2377881365@qq.com> Date: Thu, 11 Mar 2021 14:24:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=99=BA=E6=85=A7=E5=B9=B3=E8=BD=A6=E7=A7=B0?= =?UTF-8?q?=E9=87=8D=E5=92=8Crfid=E8=AE=B0=E5=BD=95=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ccsens/wisdomcar/api/RecordController.java | 6 ++++++ .../com/ccsens/wisdomcar/service/RecordService.java | 13 ++++++++++++- .../resources/mapper_dao/WisdomCarRecordDao.xml | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/wisdomcar/src/main/java/com/ccsens/wisdomcar/api/RecordController.java b/wisdomcar/src/main/java/com/ccsens/wisdomcar/api/RecordController.java index 824df9af..2bcf8f63 100644 --- a/wisdomcar/src/main/java/com/ccsens/wisdomcar/api/RecordController.java +++ b/wisdomcar/src/main/java/com/ccsens/wisdomcar/api/RecordController.java @@ -40,6 +40,9 @@ public class RecordController { @RequestMapping(value = "/weightList", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) public JsonResponse timeList(@ApiParam @Validated @RequestBody QueryDto params){ log.info("查询智慧平车称重和rfid记录:{}", params); + if (params.getParam().getEndTime() != null) { + params.getParam().setEndTime(params.getParam().getEndTime() + 24 * 3600 *1000); + } List list = recordService.queryWeightAndRfid(params.getParam(), params.getUserId()); log.info("查询智慧平车称重和rfid记录结果:{}",list); return JsonResponse.newInstance().ok(list); @@ -49,6 +52,9 @@ public class RecordController { @RequestMapping(value = "/weightExport", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) public void weightExport(@ApiParam @Validated RecordDto.WeightAndRfidExport param, HttpServletResponse response) throws IOException { log.info("导出智慧平车称重和rfid记录:{}", param); + if (param.getEndTime() != null) { + param.setEndTime(param.getEndTime() + 24 * 3600 *1000); + } Workbook workbook = recordService.exportWeightAndRfid(param); log.info("导出智慧平车称重和rfid记录结果结束"); Date start = new Date(); diff --git a/wisdomcar/src/main/java/com/ccsens/wisdomcar/service/RecordService.java b/wisdomcar/src/main/java/com/ccsens/wisdomcar/service/RecordService.java index efdcc554..52ddfa1e 100644 --- a/wisdomcar/src/main/java/com/ccsens/wisdomcar/service/RecordService.java +++ b/wisdomcar/src/main/java/com/ccsens/wisdomcar/service/RecordService.java @@ -169,15 +169,25 @@ public class RecordService implements IRecordService{ Iterator iterator = list.iterator(); while (iterator.hasNext()) { RecordVo.WeightAndRfid next = iterator.next(); + log.info("next:{}", next); if (next.getType() == Constant.CAR_RECORD_WEIGHT) { // 称重 if (weight == null) { weight = next; + if (rfid != null) { + for (RecordVo.WeightAndRfid vo : list) { + if (vo == next) { + break; + } + vo.setValue(next.getValue()); + } + } continue; } // 体重变化和上一条体重相似且间隔时间较短,删除 if (Integer.parseInt(next.getValue()) - Integer.parseInt(weight.getValue()) <= weightMinus && next.getTime() - weight.getTime() <= timeMinus) { + log.info("删除体重,当前:{}, 上一个:{}", next, weight); iterator.remove(); } else { weight = next; @@ -193,7 +203,8 @@ public class RecordService implements IRecordService{ } // rfid和上一个一样且间隔时间较短,删除 - if (next.getValue().equals(rfid.getValue()) && next.getTime() - rfid.getTime() <= timeMinus) { + if (next.getName().equals(rfid.getName()) && next.getTime() - rfid.getTime() <= timeMinus) { + log.info("删除rfid,当前rfid:{}, 上一个rfid:{}", next, rfid); iterator.remove(); } else { rfid = next; diff --git a/wisdomcar/src/main/resources/mapper_dao/WisdomCarRecordDao.xml b/wisdomcar/src/main/resources/mapper_dao/WisdomCarRecordDao.xml index b09c5510..a292f581 100644 --- a/wisdomcar/src/main/resources/mapper_dao/WisdomCarRecordDao.xml +++ b/wisdomcar/src/main/resources/mapper_dao/WisdomCarRecordDao.xml @@ -7,7 +7,7 @@ select * from ( select r.time, r.type, r.value, '称重' as name from t_wisdom_car_record r where r.car_id = #{carId} and r.type = 1 and r.time >= #{startTime} and r.time < #{endTime} and r.value <= 200000 and r.rec_status = 0 union - select r.time, r.type, r.value, s.name from t_wisdom_car_record r, t_rfid rfid, t_step s where r.car_id = #{carId} and r.value = rfid.id and rfid.step_id = s.id and r.type = 2 and r.time >= #{startTime} and r.time < #{endTime} and r.rec_status = 0 + select r.time, r.type, r.value, s.name from t_wisdom_car_record r, t_rfid rfid, t_step s where r.car_id = #{carId} and r.value = rfid.rfid and rfid.step_id = s.id and r.type = 2 and r.time >= #{startTime} and r.time < #{endTime} and r.rec_status = 0 ) t order by time