kongdeqiang
19 小时以前 973f7a2b420dddb06553489d72d4aa6fdea3c1c0
fix:提交
6个文件已修改
189 ■■■■ 已修改文件
src/main/java/com/boying/Application.java 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/boying/controller/BarrierController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/boying/controller/OrderRecordController.java 58 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/boying/controller/car/PlateServlet3.java 64 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/boying/controller/phone/YCPayController.java 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/boying/service/impl/OutParkServiceImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/boying/Application.java
@@ -2,7 +2,8 @@
import cn.hutool.core.io.resource.ClassPathResource;
//import net.sf.jni4net.Bridge;
import com.boying.common.SystemConfigProperties;
import net.sf.jni4net.Bridge;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
@@ -27,11 +28,11 @@
        SpringApplication.run(Application.class, args);
    }
//    @Bean
//    public static void getBean() throws IOException {
//        Bridge.setVerbose(true);
//        Bridge.init();
//        File loadDll = new File("LedShow.j4n.dll");
//        Bridge.LoadAndRegisterAssemblyFrom(loadDll);
//    }
    @Bean
    public static void getBean() throws IOException {
        Bridge.setVerbose(true);
        Bridge.init();
        File loadDll = new File("LedShow.j4n.dll");
        Bridge.LoadAndRegisterAssemblyFrom(loadDll);
    }
}
src/main/java/com/boying/controller/BarrierController.java
@@ -157,7 +157,7 @@
                   //取消计费
                   OutPark outPark = outParkService.findByCarNoAndBarrierId(b.getCarNo(), b.getId());
                   if(outPark != null){
                       outPark.setPrice(0);
                       //outPark.setPrice(0);
                       outPark.setUpdateTime(LocalDateTime.now());
                       outParkService.saveOrUpdate(outPark);
                   }
src/main/java/com/boying/controller/OrderRecordController.java
@@ -101,37 +101,39 @@
    @PostMapping("/findCountPage")
    public Object findCountPage(Integer parkId,String startTime,String endTime) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        QueryWrapper<OutPark> wrapper = new QueryWrapper<>();
        wrapper.lambda()
                .eq(parkId != null,OutPark::getParkId,parkId)
                .isNotNull(OutPark::getPayCode)
                .eq(OutPark::getStatus,1);
        if(startTime != null && endTime != null){
            wrapper.lambda().between(OutPark::getUpdateTime,DateUtil.beginOfDay(sdf.parse(startTime)), DateUtil.endOfDay(sdf.parse(endTime)));
        }
        List<OutPark> list = outParkService.list(wrapper);
        List<OutParkVo> list = outParkService.getVoList(parkId,startTime,endTime);
        List<Map<String,Object>> resultList = new ArrayList<>();
        if(list.size()>0){
            Map<Object, List<OutPark>> collect = list.stream().collect(
                    Collectors.groupingBy(b ->   b.getParkId()
            ));
            for (Map.Entry<Object, List<OutPark>> objectListEntry : collect.entrySet()) {
                Integer key = (Integer) objectListEntry.getKey();
                List<OutPark> value = objectListEntry.getValue();
                Double collect1 = value.stream().collect(Collectors.summingDouble(OutPark::getPrice));
                Map<String,Object> map  = new HashMap<>();
                Park byId = parkService.getById(key);
                if(byId != null){
                    map.put("parkName",byId.getName());
                }else {
                    map.put("parkName","未知停车场");
                }
                map.put("orderNum",value.size());
                map.put("orderMoney",collect1);
                resultList.add(map);
        for (Map.Entry<Integer, List<OutParkVo>> entry : list.stream().collect(Collectors.groupingBy(item -> item.getParkId())).entrySet()) {
            Integer pid = entry.getKey();
            List<OutParkVo> vos = entry.getValue();
            Map<String,Object> map  = new HashMap<>();
            Park byId = parkService.getById(pid);
            if(byId != null){
                map.put("parkName",byId.getName());
            }else {
                map.put("parkName","未知停车场");
            }
           int sum =  vos.stream().mapToInt(item -> item.getNum()).sum();
           double price =  vos.stream().mapToDouble(item -> item.getPrice()).sum();
            map.put("orderNum",sum);
            map.put("orderMoney",price);
            resultList.add(map);
        }
//        for (OutParkVo outParkVo : list) {
//            Map<String,Object> map  = new HashMap<>();
//            Park byId = parkService.getById(outParkVo.getParkId());
//            if(byId != null){
//                map.put("parkName",byId.getName());
//            }else {
//                map.put("parkName","未知停车场");
//            }
//            map.put("orderNum",outParkVo.getNum());
//            map.put("orderMoney",outParkVo.getPrice());
//            resultList.add(map);
//        }
        return R.ok(resultList);
    }
src/main/java/com/boying/controller/car/PlateServlet3.java
@@ -226,12 +226,19 @@
                        outPark.setStatus2(1);
                        outParkService.saveOrUpdate(outPark);
                        OutParkLog byOutPark = outParkLogService.getByOutPark(outPark.getCarNo(), outPark.getId());
                        byOutPark.setOpenTime(LocalDateTime.now());
                        outParkLogService.saveOrUpdate(byOutPark);
                        enterParkService.deleteByCarNo(outPark.getCarNo(), barrier.getParkId());
                        redisTemplate.delete("outPark-"+outPark.getBarrierId());
                        try {
                            OutParkLog byOutPark = outParkLogService.getByOutPark(outPark.getCarNo(), outPark.getId());
                            byOutPark.setOpenTime(LocalDateTime.now());
                            outParkLogService.saveOrUpdate(byOutPark);
                            enterParkService.deleteByCarNo(outPark.getCarNo(), barrier.getParkId());
                            redisTemplate.delete("outPark-"+outPark.getBarrierId());
                        }catch (Exception e){
                            String logs = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss").format(new Date())+
                                    " 车牌号为:"+outPark.getCarNo()+
                                    ",修改出场日志报错\n";
                            System.out.println(logs);
                            e.printStackTrace();
                        }
                        easyOpen(request,response);
                    }else {
@@ -890,10 +897,26 @@
                        noOpen(request,response,data1);
                    }
                }else {
                    int i = Integer.parseInt(redisnum);
                    i--;
                    if(i<0){
                        String s= "2."+carNo+",场内停车数为0\n";
                        writeTxt2(s);
                        redisTemplate.opsForValue().set("car_park_" + parkId,"0",30, TimeUnit.DAYS);
                        redisTemplate.opsForValue().set("park_up_" + parkId,"true",30, TimeUnit.DAYS);
                    }else {
                        String s= "2."+carNo+",场内停车数为"+i+"\n";
                        writeTxt2(s);
                        redisTemplate.opsForValue().set("car_park_" + parkId,Integer.toString(i),30, TimeUnit.DAYS);
                        redisTemplate.opsForValue().set("park_up_" + parkId,"true",30, TimeUnit.DAYS);
                    }
                    open(request,response,data1);
                    //缓存在redis里,心跳接口去抬杆
                    String jsonValue = JSON.toJSONString(outPark);
                    redisTemplate.opsForValue().set("outPark-"+outPark.getBarrierId(), jsonValue);
                    redisTemplate.opsForValue().set("park_change_in_"+parkId,"true",1, TimeUnit.DAYS);
//                    String jsonValue = JSON.toJSONString(outPark);
//                    redisTemplate.opsForValue().set("outPark-"+outPark.getBarrierId(), jsonValue);
//                    redisTemplate.opsForValue().set("park_change_in_"+parkId,"true",1, TimeUnit.DAYS);
                }
            }
        }else {
@@ -924,10 +947,25 @@
        String data1 = Base64.getMimeEncoder().encodeToString(dataX) + "=";
        data1 = data1.replaceAll("\r\n", "");
        if(type == 0){
            //缓存在redis里,心跳接口去抬杆
            String jsonValue = JSON.toJSONString(outPark);
            redisTemplate.opsForValue().set("outPark-"+outPark.getBarrierId(), jsonValue);
            redisTemplate.opsForValue().set("park_change_in_"+parkId,"true",1, TimeUnit.DAYS);
            int i = Integer.parseInt(redisnum);
            i--;
            if(i<=0){
                String s= "2."+carNo+"缴费完成,场内停车数为"+i+"\n";
                writeTxt2(s);
                redisTemplate.opsForValue().set("car_park_" + parkId,"0",30, TimeUnit.DAYS);
                redisTemplate.opsForValue().set("park_up_" + parkId,"true",30, TimeUnit.DAYS);
            }else {
                String s= "2."+carNo+"缴费完成,场内停车数为"+i+"\n";
                writeTxt2(s);
                redisTemplate.opsForValue().set("car_park_" + parkId,Integer.toString(i),30, TimeUnit.DAYS);
                redisTemplate.opsForValue().set("park_up_" + parkId,"true",30, TimeUnit.DAYS);
            }
            open(request,response,data1);
//            //缓存在redis里,心跳接口去抬杆
//            String jsonValue = JSON.toJSONString(outPark);
//            redisTemplate.opsForValue().set("outPark-"+outPark.getBarrierId(), jsonValue);
//            redisTemplate.opsForValue().set("park_change_in_"+parkId,"true",1, TimeUnit.DAYS);
        }else {
            noOpen(request,response,data1);
        }
src/main/java/com/boying/controller/phone/YCPayController.java
@@ -715,8 +715,48 @@
                outParkService.saveOrUpdate(outPark);
                //缓存在redis里
                String jsonValue = JSON.toJSONString(outPark);
                redisTemplate.opsForValue().set("outPark-"+outPark.getBarrierId(), jsonValue);
                redisTemplate.opsForValue().set("park_change_in_"+outPark.getParkId(),"true",1, TimeUnit.DAYS);
                String redisKey = "outPark-"+outPark.getBarrierId();
                String parkChangeKey = "park_change_in_"+outPark.getParkId();
                int retryCount = 0;
                int maxRetry = 3;
                boolean cacheSuccess = false;
                while(retryCount < maxRetry && !cacheSuccess){
                    try {
                        redisTemplate.opsForValue().set(redisKey, jsonValue);
                        redisTemplate.opsForValue().set(parkChangeKey,"true",1, TimeUnit.DAYS);
                        cacheSuccess = true;
                        String logs = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss").format(new Date())+
                                " 车牌号为:"+outPark.getCarNo()+
                                ",Redis缓存设置成功,道闸ID:"+outPark.getBarrierId()+"\n";
                        writeTxt2(logs);
                    } catch (Exception e) {
                        retryCount++;
                        String errorLogs = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss").format(new Date())+
                                " 车牌号为:"+outPark.getCarNo()+
                                ",Redis缓存设置失败,第"+retryCount+"次重试,错误信息:"+e.getMessage()+"\n";
                        writeTxt2(errorLogs);
                        e.printStackTrace();
                        if(retryCount < maxRetry){
                            try {
                                Thread.sleep(100); // 等待100ms后重试
                            } catch (InterruptedException ie) {
                                Thread.currentThread().interrupt();
                            }
                        }
                    }
                }
                if(!cacheSuccess){
                    String errorLogs = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss").format(new Date())+
                            " 车牌号为:"+outPark.getCarNo()+
                            ",Redis缓存设置失败,已重试"+maxRetry+"次,请检查Redis服务状态!\n";
                    writeTxt2(errorLogs);
                    // 虽然Redis缓存失败,但数据库已更新,心跳接口可以通过数据库查询获取数据
                }
//                redisTemplate.opsForValue().set("outPark-"+outPark.getBarrierId(), jsonValue);
//                redisTemplate.opsForValue().set("park_change_in_"+outPark.getParkId(),"true",1, TimeUnit.DAYS);
            }
        }
    }
src/main/java/com/boying/service/impl/OutParkServiceImpl.java
@@ -19,6 +19,7 @@
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
@@ -130,6 +131,9 @@
                return null;
            }
        } catch (Exception e) {
            String errorLogs = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss").format(new Date())+
                    " Redis查询失败,道闸ID:"+bId+",错误信息:"+e.getMessage()+",将查询数据库\n";
            System.out.println(errorLogs);
            e.printStackTrace();
        }
        return null;