无关风月
2025-05-08 9486766c806fe1d9e082b2fd02ea1cc558f1b443
cloud-server-management/src/main/java/com/dsh/guns/modular/system/controller/system/BallController.java
@@ -231,28 +231,6 @@
        return ResultUtil.success();
    }
//    public static void main(String[] args) {
//        // 添加sutu编号
//        HashMap<String, String> map3 = new HashMap<>();
//        // 添加sutu编号
//        // 添加门禁 红蓝方
//        TSite si = siteService.getById(site);
//        TStore st = storeService.getById(store);
//        map3.put("sign", "0DB011836143EEE2C2E072967C9F4E4B");
//        map3.put("space_id", si.getId() + "");
//        map3.put("name", ToolUtil.isEmpty(sutuName) ? "" : sutuName);
//        map3.put("city_code", "");
//        String s3 = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/addDevice", map3);
//        System.out.println("---------------------------"+s3);
//        JSONObject jsonObject = new JSONObject(s3);
//        // 获取 data 字段的值
//        JSONObject dataObject = jsonObject.getJSONObject("data");
//        // 获取 sutu_id 字段的值
//        String sutuIdValue = dataObject.getString("sutu_id");
//        Integer sutuId = Integer.valueOf(sutuIdValue);
//        game.setSutuId(sutuId);
//    }
    public static MultipartFile convert(BufferedImage bufferedImage, String fileName) throws IOException {
        // 将 BufferedImage 转换为字节数组
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -272,6 +250,7 @@
        return multipartFile;
    }
    @RequestMapping("/save")
    @ResponseBody
    public ResultUtil save(Integer id, String operationId, String red, String blue, String province, String city, Integer site, Integer store
@@ -324,107 +303,111 @@
            game.setOperationId(0);
        }
        System.out.println("============"+game);
        HashMap<String, String> map5 = new HashMap<>();
        map5.put("space_id", store+"");
        map5.put("area_id", site+"");
        String s5 = HttpRequestUtil.getRequest("https://try.daowepark.com/v7/user_api/general/get_space_sutu", map5);
        System.err.println(s5);
        JSONObject jsonObject5 = new JSONObject(s5);
        // 获取 data 字段的值
        JSONArray data = jsonObject5.getJSONArray("data");
        Integer temp = null;  // 临时sutuid
        Integer temp1 = null; // 临时sutuid
        TSite si = siteService.getById(site);
        if (data.length() == 0){
            // 这个场地没有添加过sutu
            HashMap<String, String> map3 = new HashMap<>();
            HashMap<String, String> map4 = new HashMap<>();
            // 添加sutu编号
            // 调用两次 创建sutu
            map3.put("sign", "0DB011836143EEE2C2E072967C9F4E4B");
            map4.put("sign", "0DB011836143EEE2C2E072967C9F4E4B");
            map3.put("space_id", store + "");
            map3.put("area_id", si.getId() + "");
            map4.put("space_id", store + "");
            map4.put("area_id", si.getId() + "");
            map3.put("name", blue);
            map4.put("name", red);
            map3.put("city_code", city);
            map4.put("city_code", city);
            String s3 = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/addSpaceSutu", map3);
            String s4 = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/addSpaceSutu", map4);
            JSONObject jsonObject = new JSONObject(s3);
            JSONObject jsonObject1 = new JSONObject(s4);
            // 获取 data 字段的值
            JSONObject dataObject = jsonObject.getJSONObject("data");
            JSONObject dataObject1 = jsonObject1.getJSONObject("data");
            // 获取 sutu_id 字段的值
            String sutuIdValue = dataObject.getString("sutu_id");
            String sutuIdValue1 = dataObject1.getString("sutu_id");
            Integer sutuId = Integer.valueOf(sutuIdValue);
            Integer sutuId1 = Integer.valueOf(sutuIdValue1);
            game.setBlue(""+sutuId);
            game.setRed(""+sutuId1);
            // 生成红蓝sutu二维码
            HashMap<String, String> blueCode = new HashMap<>();
            blueCode.put("scan_type", "1000");
            blueCode.put("sutu_id", ""+sutuId);
            blueCode.put("space_id", si.getId() + "");
            HashMap<String, String> redCode = new HashMap<>();
            redCode.put("scan_type", "1000");
            redCode.put("sutu_id", sutuId1+"");
            redCode.put("space_id", si.getId() + "");
            String blueS= "{\"scan_type\": 1000, \"space_id\": "+si.getId()+", \"sutu_id\": "+sutuId+"}";
            String redS= "{\"scan_type\": 1000, \"space_id\": "+si.getId()+", \"sutu_id\": "+sutuId1+"}";
            MyQrCodeUtil.createCodeToFile(blueS);
            MyQrCodeUtil.createCodeToFile(redS);
            BufferedImage blueImage = QRCodeUtil.createImage(blueS);
            BufferedImage redImage = QRCodeUtil.createImage(redS);
            MultipartFile blueFile = convert(blueImage, new Date().getTime()+UUIDUtil.getRandomCode(3)+".PNG");
            MultipartFile redFile = convert(redImage, new Date().getTime()+UUIDUtil.getRandomCode(3)+".PNG");
            String s = OssUploadUtil.ossUpload("img/", blueFile);
            String s1 = OssUploadUtil.ossUpload("img/", redFile);
            game.setBlueCode(s);
            game.setRedCode(s1);
        }else{
            Integer sutuid=0;
            Integer sutuid1=0;
            JSONObject element = data.getJSONObject(0);
            if (site==27){
                sutuid=1036;
                sutuid1=1037;
                game.setBlue(sutuid.toString());
                game.setRed(sutuid1.toString());
            }else{
                sutuid = element.getInt("id");
                game.setBlue(sutuid.toString());
                JSONObject element1 = data.getJSONObject(1);
                sutuid1 = element1.getInt("id");
                game.setRed(sutuid1.toString());
        // 判断是新增还是修改 修改不会重新生成sutuId
        if (game.getId()==null) {
            HashMap<String, String> map5 = new HashMap<>();
            map5.put("space_id", store + "");
            map5.put("area_id", site + "");
            String s5 = HttpRequestUtil.getRequest("https://port.daowepark.com/v7/user_api/general/get_space_sutu", map5);
            System.err.println(s5);
            JSONObject jsonObject5 = new JSONObject(s5);
            JSONArray data = jsonObject5.getJSONArray("data");
            Integer temp = null;  // 临时sutuid
            Integer temp1 = null; // 临时sutuid
            TSite si = siteService.getById(site);
            if (data.length() == 0) {
                // 这个场地没有添加过sutu
                HashMap<String, String> map3 = new HashMap<>();
                HashMap<String, String> map4 = new HashMap<>();
                // 添加sutu编号
                // 调用两次 创建sutu
                map3.put("sign", "0DB011836143EEE2C2E072967C9F4E4B");
                map4.put("sign", "0DB011836143EEE2C2E072967C9F4E4B");
                map3.put("space_id", store + "");
                map3.put("area_id", si.getId() + "");
                map4.put("space_id", store + "");
                map4.put("area_id", si.getId() + "");
                map3.put("name", blue);
                map4.put("name", red);
                map3.put("city_code", city);
                map4.put("city_code", city);
                String s3 = HttpRequestUtil.postRequest("https://port.daowepark.com/v7/user_api/general/addSpaceSutu", map3);
                String s4 = HttpRequestUtil.postRequest("https://port.daowepark.com/v7/user_api/general/addSpaceSutu", map4);
                JSONObject jsonObject = new JSONObject(s3);
                JSONObject jsonObject1 = new JSONObject(s4);
                // 获取 data 字段的值
                JSONObject dataObject = jsonObject.getJSONObject("data");
                JSONObject dataObject1 = jsonObject1.getJSONObject("data");
                // 获取 sutu_id 字段的值
                String sutuIdValue = dataObject.getString("sutu_id");
                String sutuIdValue1 = dataObject1.getString("sutu_id");
                Integer sutuId = Integer.valueOf(sutuIdValue);
                Integer sutuId1 = Integer.valueOf(sutuIdValue1);
                game.setBlue("" + sutuId);
                game.setRed("" + sutuId1);
                // 生成红蓝sutu二维码
                HashMap<String, String> blueCode = new HashMap<>();
                blueCode.put("scan_type", "1000");
                blueCode.put("sutu_id", "" + sutuId);
                blueCode.put("space_id", si.getId() + "");
                HashMap<String, String> redCode = new HashMap<>();
                redCode.put("scan_type", "1000");
                redCode.put("sutu_id", sutuId1 + "");
                redCode.put("space_id", si.getId() + "");
                String blueS = "{\"scan_type\": 1000, \"space_id\": " + si.getId() + ", \"sutu_id\": " + sutuId + "}";
                String redS = "{\"scan_type\": 1000, \"space_id\": " + si.getId() + ", \"sutu_id\": " + sutuId1 + "}";
                MyQrCodeUtil.createCodeToFile(blueS);
                MyQrCodeUtil.createCodeToFile(redS);
                BufferedImage blueImage = QRCodeUtil.createImage(blueS);
                BufferedImage redImage = QRCodeUtil.createImage(redS);
                MultipartFile blueFile = convert(blueImage, new Date().getTime() + UUIDUtil.getRandomCode(3) + ".PNG");
                MultipartFile redFile = convert(redImage, new Date().getTime() + UUIDUtil.getRandomCode(3) + ".PNG");
                String s = OssUploadUtil.ossUpload("img/", blueFile);
                String s1 = OssUploadUtil.ossUpload("img/", redFile);
                game.setBlueCode(s);
                game.setRedCode(s1);
            } else {
                Integer sutuid = 0;
                Integer sutuid1 = 0;
                JSONObject element = data.getJSONObject(0);
                if (site == 27) {
                    sutuid = 1036;
                    sutuid1 = 1037;
                    game.setBlue(sutuid.toString());
                    game.setRed(sutuid1.toString());
                } else {
                    sutuid = element.getInt("id");
                    game.setBlue(sutuid.toString());
                    JSONObject element1 = data.getJSONObject(1);
                    sutuid1 = element1.getInt("id");
                    game.setRed(sutuid1.toString());
                }
                // 生成红蓝sutu二维码
                HashMap<String, String> blueCode = new HashMap<>();
                blueCode.put("scan_type", "1000");
                blueCode.put("sutu_id", "" + sutuid);
                blueCode.put("space_id", si.getId() + "");
                HashMap<String, String> redCode = new HashMap<>();
                redCode.put("scan_type", "1000");
                redCode.put("sutu_id", sutuid1 + "");
                redCode.put("space_id", si.getId() + "");
                String blueS = "{\"scan_type\": 1000, \"space_id\": " + si.getId() + ", \"sutu_id\": " + sutuid + "}";
                String redS = "{\"scan_type\": 1000, \"space_id\": " + si.getId() + ", \"sutu_id\": " + sutuid1 + "}";
                MyQrCodeUtil.createCodeToFile(blueS);
                MyQrCodeUtil.createCodeToFile(redS);
                BufferedImage blueImage = QRCodeUtil.createImage(blueS);
                BufferedImage redImage = QRCodeUtil.createImage(redS);
                MultipartFile blueFile = convert(blueImage, new Date().getTime() + UUIDUtil.getRandomCode(3) + ".PNG");
                MultipartFile redFile = convert(redImage, new Date().getTime() + UUIDUtil.getRandomCode(3) + ".PNG");
                String s = OssUploadUtil.ossUpload("img/", blueFile);
                String s1 = OssUploadUtil.ossUpload("img/", redFile);
                game.setBlueCode(s);
                game.setRedCode(s1);
            }
            // 生成红蓝sutu二维码
            HashMap<String, String> blueCode = new HashMap<>();
            blueCode.put("scan_type", "1000");
            blueCode.put("sutu_id", ""+sutuid);
            blueCode.put("space_id", si.getId() + "");
            HashMap<String, String> redCode = new HashMap<>();
            redCode.put("scan_type", "1000");
            redCode.put("sutu_id", sutuid1+"");
            redCode.put("space_id", si.getId() + "");
            String blueS= "{\"scan_type\": 1000, \"space_id\": "+si.getId()+", \"sutu_id\": "+sutuid+"}";
            String redS= "{\"scan_type\": 1000, \"space_id\": "+si.getId()+", \"sutu_id\": "+sutuid1+"}";
            MyQrCodeUtil.createCodeToFile(blueS);
            MyQrCodeUtil.createCodeToFile(redS);
            BufferedImage blueImage = QRCodeUtil.createImage(blueS);
            BufferedImage redImage = QRCodeUtil.createImage(redS);
            MultipartFile blueFile = convert(blueImage, new Date().getTime()+UUIDUtil.getRandomCode(3)+".PNG");
            MultipartFile redFile = convert(redImage, new Date().getTime()+UUIDUtil.getRandomCode(3)+".PNG");
            String s = OssUploadUtil.ossUpload("img/", blueFile);
            String s1 = OssUploadUtil.ossUpload("img/", redFile);
            game.setBlueCode(s);
            game.setRedCode(s1);
        }
        Integer gameId = ballClient.save(game);
        List<TGameConfig> gameConfigList = new ArrayList<>();
        //玩湃跨城赛
@@ -572,13 +555,13 @@
//        map1.put("device_id", red);
//        map1.put("region_id", st.getId() + "");
//        // 添加门禁
//        String s1 = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/addDevice", map1);
//        String s1 = HttpRequestUtil.postRequest("https://port.daowepark.com/v7/user_api/general/addDevice", map1);
//        map2.put("sign", "0DB011836143EEE2C2E072967C9F4E4B");
//        map2.put("space_id", si.getId() + "");
//        map2.put("device_id", blue);
//        map2.put("region_id", st.getId() + "");
//        // 添加门禁
//        String s2 = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/addDevice", map2);
//        String s2 = HttpRequestUtil.postRequest("https://port.daowepark.com/v7/user_api/general/addDevice", map2);
@@ -586,14 +569,8 @@
        return null;
    }
//    public static void main(String[] args) {
//        HashMap<String, String> map3 = new HashMap<>();
//        map3.put("space_id", "1001");
//        map3.put("area_id", "4352");
//        String s3 = HttpRequestUtil.getRequest("https://try.daowepark.com/v7/user_api/general/get_space_sutu", map3);
//
//        System.err.println(s3);
//    }
    @RequestMapping("/pre_add")
    public String add(Model model) {
@@ -891,6 +868,7 @@
@Autowired
private IUserService userService;
    @RequestMapping("/yueyue_info/{id}")
    public String yueyue_info(@PathVariable("id") Integer id,Model model) {
@@ -956,8 +934,7 @@
        List<OrderDto> timeRanges = new ArrayList<>();
        Site site =  siteClient.listById(book.getSiteId());
        TSite site = siteService.getById(book.getSiteId());
        System.out.println("================"+site);
        String appointmentStartTime = site.getAppointmentStartTime();
        String appointmentEndTime = site.getAppointmentEndTime();
@@ -1046,9 +1023,33 @@
                List<TCoursePackage> coursePackageByStoreId = coursePackageClient.getCoursePackageByStoreId(storeId);
                tCoursePackages.addAll(coursePackageByStoreId);
            }
            List<Integer> coursePackageByStoreIds = tCoursePackages.stream().distinct().map(TCoursePackage::getId).collect(Collectors.toList());
            if (tCoursePackages.isEmpty()){
                coursePackageByStoreIds.add(-1);
            }
            studentQeryDto.setCoursePackageIds(coursePackageByStoreIds);
        }
        // 如果当前登陆人是门店 只查询该门店下的课包的数据
        if(UserExt.getUser().getObjectType() == 3){
            // 先查询这个运营商下的所有门店ids
            List<Integer> storeIds = new ArrayList<>();
            storeIds.add(UserExt.getUser().getObjectId());
            // 根据门店ids 查询所有课包ids
            List<TCoursePackage> tCoursePackages = new ArrayList<>();
            for (Integer storeId : storeIds) {
                List<TCoursePackage> coursePackageByStoreId = coursePackageClient.getCoursePackageByStoreId(storeId);
                tCoursePackages.addAll(coursePackageByStoreId);
            }
            List<Integer> coursePackageByStoreIds = tCoursePackages.stream().distinct().map(TCoursePackage::getId).collect(Collectors.toList());
            if (tCoursePackages.isEmpty()){
                coursePackageByStoreIds.add(-1);
            }
            studentQeryDto.setCoursePackageIds(coursePackageByStoreIds);
        }
        List<Map<String, Object>>  pays = coursePackageClient.getStudentTotal(studentQeryDto);
        return pays;
    }
@@ -1153,22 +1154,22 @@
                }
            }
            if (Integer.parseInt(vo.get("status").toString())==1 ){
                String dateTimeStr = vo.get("times").toString();
                String formattedDateTimeStr = dateTimeStr.substring(0, 11) + dateTimeStr.substring(17);
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                try {
                    Date date = sdf.parse(formattedDateTimeStr);
                    if (new Date().after(date)){
                        vo.put("status",4);
                    }
                    System.out.println(date);
                } catch (ParseException e) {
                    e.printStackTrace();
                }
            }
//            if (Integer.parseInt(vo.get("status").toString())==1 ){
//                String dateTimeStr = vo.get("times").toString();
//                String formattedDateTimeStr = dateTimeStr.substring(0, 11) + dateTimeStr.substring(17);
//
//                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
//                try {
//                    Date date = sdf.parse(formattedDateTimeStr);
//                    if (new Date().after(date)){
//                        vo.put("status",4);
//                    }
//
//                    System.out.println(date);
//                } catch (ParseException e) {
//                    e.printStackTrace();
//                }
//            }
        }
        return orders;
    }