From 963ec1b990fc094de3234250c4888b5ca94ac5bc Mon Sep 17 00:00:00 2001 From: kongdeqiang <kongdeqiang960204@163.com> Date: 星期二, 15 四月 2025 16:46:25 +0800 Subject: [PATCH] fix:白名单新增bug --- src/main/java/com/boying/controller/EnterParkController.java | 162 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 147 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/boying/controller/EnterParkController.java b/src/main/java/com/boying/controller/EnterParkController.java index 00b0fcc..5f26b76 100644 --- a/src/main/java/com/boying/controller/EnterParkController.java +++ b/src/main/java/com/boying/controller/EnterParkController.java @@ -1,29 +1,29 @@ package com.boying.controller; import cn.hutool.core.date.DateUtil; +import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.boying.common.R; -import com.boying.entity.Barrier; -import com.boying.entity.EnterPark; -import com.boying.entity.OutPark; -import com.boying.service.BarrierService; -import com.boying.service.EnterParkService; -import com.boying.service.ParkService; +import com.boying.entity.*; +import com.boying.service.*; +import com.boying.util.DateUtilOther; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; +import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.web.bind.annotation.*; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.time.ZoneOffset; import java.util.Date; import java.util.List; +import java.util.concurrent.TimeUnit; /** * 鍏ュ満琛� @@ -35,12 +35,16 @@ @RequiredArgsConstructor @RequestMapping("ffzf/enterpark" ) @Api(value = "enterpark", tags = "鍏ュ満琛ㄧ鐞�") -@Tag(description = "ffzf/enterpark" , name = "鍏ュ満琛ㄨ褰�" ) public class EnterParkController { private final EnterParkService enterParkService; + private final OutParkService outParkService; + private final OutParkLogService outParkLogService; private final BarrierService barrierService; private final ParkService parkService; + private final CostRuleService costRuleService; + private final WhiteListService whiteListService; + private final StringRedisTemplate redisTemplate; /** * 鍒嗛〉鏌ヨ @@ -68,7 +72,6 @@ // } @PostMapping("/findPage") - @Operation(summary = "鍒嗛〉鏌ヨ" , description = "鍒嗛〉鏌ヨ" ) public Object findPage(Page page, String carNo,Integer parkId,String date) throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); if(StringUtils.isNotBlank(date)){ @@ -89,6 +92,140 @@ return R.ok(page); } + @PostMapping("/findByCar") + public Object findByCar(String carNo,Integer parkId) { + if(StringUtils.isBlank(carNo)){ + return R.failed("璇疯緭鍏ユ纭溅鐗屽彿"); + }else { + QueryWrapper<EnterPark> queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda() + .eq(EnterPark::getCarNo,carNo) + .eq(EnterPark::getParkId,parkId); + List<EnterPark> list = enterParkService.list(queryWrapper); + if(list !=null && list.size()>0){ + for (EnterPark enterPark : list) { + enterPark.setParkName(parkService.getById(enterPark.getParkId()).getName()); + } + return R.ok(list); + }else { + return R.failed("璇ヨ溅鐗屾湭鏌ヨ鍒板叆鍦鸿褰�"); + } + } + } + + @PostMapping("/getByBarrierId") + public Object getByBarrierId(Integer barrierId) throws ParseException { + Barrier byId1 = barrierService.getById(barrierId); + OutPark byId = outParkService.findByCarNoAndBarrierId(byId1.getCarNo(), barrierId); + if(byId==null){ + return R.failed("鏈煡璇㈠埌鍑哄満璁板綍"); + }else { + return R.ok(byId); + } + + } + + @PostMapping("/editOutByEnter") + public Object editOutByEnter(Integer outParkId,String carNo,Integer enterId) throws ParseException { + double money = 0.0; + OutPark outPark = outParkService.getById(outParkId); + EnterPark enterPark = enterParkService.getById(enterId); + outPark.setCarNo(enterPark.getCarNo()); + outPark.setEnterTime(enterPark.getCreateTime()); + try { + long l = outPark.getCreateTime().toInstant(ZoneOffset.of("+8")).toEpochMilli() - enterPark.getCreateTime().toInstant(ZoneOffset.of("+8")).toEpochMilli(); + outPark.setTime(l/(1000*60)); + money = costRuleService.getMoney(enterPark.getParkId(), outPark.getEnterTime(), outPark.getCreateTime(), 1); + //鍏ュ満璁板綍淇濆瓨涓�涓� + if(enterPark.getIsPay() != null && enterPark.getIsPay()==1){ + money = money - enterPark.getPrice(); + }else { + enterPark.setPrice(money); + enterPark.setIsPay(0); + enterParkService.updateById(enterPark); + } + } catch (ParseException e) { + e.printStackTrace(); + } + outPark.setPrice(money); + outPark.setStatus3(0); + outParkService.saveOrUpdate(outPark); + Barrier barrier =barrierService.getById(outPark.getBarrierId()); + barrier.setCarNo(carNo); + //鍒ゆ柇鏄惁鍦ㄧ櫧鍚嶅崟 + QueryWrapper<WhiteList> wrapper = new QueryWrapper<>(); + wrapper.lambda() + .eq(WhiteList::getCarNo,carNo); + List<WhiteList> all = whiteListService.list(wrapper); + if(all.size() >0){ + for(WhiteList w : all){ + if(w.getType()==0){ + outPark.setStatus(2); + outPark.setStatus2(1); + outParkService.saveOrUpdate(outPark); + barrierService.saveOrUpdate(barrier); + String jsonValue2 = JSON.toJSONString(barrier); + redisTemplate.opsForValue().set("barrier-"+barrier.getCode(), jsonValue2); + String jsonValue = JSON.toJSONString(outPark); + redisTemplate.opsForValue().set("outPark_dif_"+ outPark.getBarrierId(), jsonValue); + //缂撳瓨鍦╮edis閲�,蹇冭烦鎺ュ彛鍘绘姮鏉� + String jsonValue1 = JSON.toJSONString(outPark); + redisTemplate.opsForValue().set("outPark-"+outPark.getBarrierId(), jsonValue1); + redisTemplate.opsForValue().set("park_change_in_"+outPark.getParkId(),"true",1, TimeUnit.DAYS); + return R.ok(null,"鎿嶄綔鎴愬姛"); + }else{ + if(StringUtils.isNotBlank(w.getParkIds())){ + if(w.getEndTime()!=null){ + String parkIds = w.getParkIds(); + String[] split = parkIds.split(","); + for (String s : split) { + int pid = Integer.parseInt(s); + if(pid == outPark.getParkId() && System.currentTimeMillis()<w.getEndTime().getTime()){ + outPark.setStatus(2); + outPark.setStatus2(1); + outParkService.saveOrUpdate(outPark); + barrierService.saveOrUpdate(barrier); + String jsonValue2 = JSON.toJSONString(barrier); + redisTemplate.opsForValue().set("barrier-"+barrier.getCode(), jsonValue2); + String jsonValue = JSON.toJSONString(outPark); + redisTemplate.opsForValue().set("outPark_dif_"+ outPark.getBarrierId(), jsonValue); + //缂撳瓨鍦╮edis閲�,蹇冭烦鎺ュ彛鍘绘姮鏉� + String jsonValue1 = JSON.toJSONString(outPark); + redisTemplate.opsForValue().set("outPark-"+outPark.getBarrierId(), jsonValue1); + redisTemplate.opsForValue().set("park_change_in_"+outPark.getParkId(),"true",1, TimeUnit.DAYS); + return R.ok(null,"鎿嶄綔鎴愬姛"); + } + } + } + } + } + } + }else { + barrierService.saveOrUpdate(barrier); + String jsonValue2 = JSON.toJSONString(barrier); + redisTemplate.opsForValue().set("barrier-"+barrier.getCode(), jsonValue2); + if(outPark.getPrice()==0&&outPark.getStatus3()==0){ + String jsonValue = JSON.toJSONString(outPark); + redisTemplate.opsForValue().set("outPark_dif_"+ barrier.getId(), jsonValue); + String jsonValue1 = JSON.toJSONString(outPark); + redisTemplate.opsForValue().set("outPark-"+outPark.getBarrierId(), jsonValue1); + redisTemplate.opsForValue().set("park_change_in_"+outPark.getParkId(),"true",1, TimeUnit.DAYS); + return R.ok(null,"鎿嶄綔鎴愬姛"); + }else { + //闇�瑕佺即璐规垨鑰呮湁杩濈珷 + OutParkLog byOutPark = outParkLogService.getByOutPark(outPark.getCarNo(), outPark.getId()); + byOutPark.setOutTime(outPark.getCreateTime()); + byOutPark.setParkId(outPark.getParkId()); + byOutPark.setCarNo(carNo); + outParkLogService.saveOrUpdate(byOutPark); + String jsonValue = JSON.toJSONString(outPark); + redisTemplate.opsForValue().set("outPark_dif_"+ barrier.getId(), jsonValue); + return R.ok(null,"鎿嶄綔鎴愬姛,璇锋壂鐮佺即璐�"); + } + } + return R.failed("鎿嶄綔澶辫触"); + } + /** * 閫氳繃id鏌ヨ鍏ュ満琛� * @param id id @@ -96,7 +233,6 @@ */ @ApiOperation(value = "閫氳繃id鏌ヨ", notes = "閫氳繃id鏌ヨ") @GetMapping("/{id}" ) - @Operation(summary = "鏍规嵁id鏌ヨ" , description = "鏍规嵁id鏌ヨ" ) public R getById(@PathVariable("id" ) Integer id) { return R.ok(enterParkService.getById(id)); } @@ -108,7 +244,6 @@ */ @ApiOperation(value = "鏂板鍏ュ満琛�", notes = "鏂板鍏ュ満琛�") @PostMapping - @Operation(summary = "鏂板鍏ュ満" , description = "鏂板鍏ュ満" ) public R save(@RequestBody EnterPark enterPark) { return R.ok(enterParkService.save(enterPark)); } @@ -120,7 +255,6 @@ */ @ApiOperation(value = "淇敼鍏ュ満琛�", notes = "淇敼鍏ュ満琛�") @PutMapping - @Operation(summary = "淇敼鍏ュ満" , description = "淇敼鍏ュ満" ) public R updateById(@RequestBody EnterPark enterPark) { return R.ok(enterParkService.updateById(enterPark)); } @@ -132,7 +266,6 @@ */ @ApiOperation(value = "閫氳繃id鍒犻櫎鍏ュ満琛�", notes = "閫氳繃id鍒犻櫎鍏ュ満琛�") @DeleteMapping("/{id}" ) - @Operation(summary = "鍒犻櫎鍏ュ満" , description = "鍒犻櫎鍏ュ満" ) public R removeById(@PathVariable Integer id) { return R.ok(enterParkService.removeById(id)); } @@ -144,7 +277,6 @@ * @return excel 鏂囦欢娴� */ @GetMapping("/export") - @Operation(summary = "瀵煎嚭鍏ュ満" , description = "瀵煎嚭鍏ュ満" ) public List<EnterPark> export(EnterPark enterPark) { return enterParkService.list(Wrappers.query(enterPark)); } -- Gitblit v1.9.1