日期模拟
| import java.text.SimpleDateFormat; |
| import java.util.Calendar; |
| import java.util.Date; |
| import java.util.Random; |
| |
| public class DataUtil { |
| public static void main(String[] args) { |
| String s = getTodayDate(); |
| System.out.println(s); |
| } |
| |
| |
| public static String getTodayDate() { |
| Calendar cal = Calendar.getInstance(); |
| Date date = cal.getTime(); |
| SimpleDateFormat dfs = new SimpleDateFormat("yyyy-MM-dd"); |
| String format = dfs.format(date); |
| return format; |
| } |
| |
| |
| public static String getTodayTime() { |
| Random random = new Random(); |
| String date = getTodayDate(); |
| String hour = random.nextInt(24) + ""; |
| if (Integer.parseInt(hour) <= 9) { |
| hour = "0" + hour; |
| } |
| String min = random.nextInt(60) + ""; |
| if (Integer.parseInt(min) <= 9) { |
| min = "0" + min; |
| } |
| |
| String seconds = random.nextInt(60) + ""; |
| if (Integer.parseInt(seconds) <= 9) { |
| seconds = "0" + seconds; |
| } |
| |
| String time = date + " " + hour + ":" + min + ":" + seconds; |
| return time; |
| } |
| } |
车流量数据模拟
| import java.io.BufferedWriter; |
| import java.io.FileWriter; |
| import java.io.IOException; |
| import java.util.ArrayList; |
| import java.util.Collections; |
| import java.util.List; |
| import java.util.Random; |
| |
| public class CarFlow { |
| public static void main(String[] args) throws IOException { |
| BufferedWriter bw = new BufferedWriter( |
| new FileWriter("G:/monitor_car_flow.csv", true)); |
| |
| |
| String todayDate = DataUtil.getTodayDate(); |
| String[] chePaiPresix = |
| {"晋A", "晋A", "晋A", "晋A", "晋A", "晋A", |
| "晋A", "晋A", "晋A", "晋A", "晋A", "晋A", |
| "晋B", "晋C", "晋D", "晋E", "晋K", "晋K", |
| "晋K", "晋K", "晋K", "晋K", "晋K", "晋K", |
| "晋K", "晋K", "晋K", "晋K", "晋M", "晋L"}; |
| char[] array = |
| {'0', '1', '2', '3', '4', '5', '6', '7', |
| '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', |
| 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', |
| 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', |
| 'W', 'X', 'Y', 'Z'}; |
| Random random = new Random(); |
| |
| |
| List<String> list = new ArrayList<String>(); |
| for (int i = 0; i < 1000; i++) { |
| |
| String roadId = 1 + random.nextInt(100) + ""; |
| |
| String areaId = 1 + random.nextInt(6) + ""; |
| |
| String monitorId = areaId + "-" + roadId + "-" + random.nextInt(101); |
| |
| int camera_id = 1+random.nextInt(8); |
| |
| int num = 1 + random.nextInt(1000); |
| for (int j = 0; j < num; j++) { |
| |
| String che = chePaiPresix[random.nextInt(chePaiPresix.length)]; |
| String chepai = che + array[random.nextInt(array.length)] + |
| array[random.nextInt(array.length)] |
| + array[random.nextInt(array.length)] |
| + array[random.nextInt(array.length)] |
| + array[random.nextInt(array.length)]; |
| |
| String actionTime = DataUtil.getTodayTime(); |
| |
| String speed = random.nextInt(120) + ""; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| String data = todayDate + "," + monitorId + "," |
| + camera_id + "," + chepai + "," + actionTime + "," |
| + speed + "," + roadId + "," + areaId; |
| |
| list.add(data); |
| } |
| } |
| |
| |
| Collections.shuffle(list); |
| for (String data: list) { |
| bw.write(data); |
| bw.newLine(); |
| bw.flush(); |
| } |
| |
| System.out.println("卡口车流量数据模拟完成"); |
| } |
| } |
摄像头模拟
| import java.io.BufferedWriter; |
| import java.io.FileWriter; |
| import java.io.IOException; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| public class CameraData { |
| public static void main(String[] args) throws IOException { |
| BufferedWriter bw = new BufferedWriter(new FileWriter("G:/cameras.csv")); |
| |
| |
| |
| |
| for (int i = 1; i <= 6; i++) { |
| for (int j = 1; j <= 100; j++) { |
| for (int k = 1; k <=100 ; k++) { |
| for (int l = 1; l <= 8 ; l++) { |
| String monitor_id = i +"-"+ j +"-"+k; |
| String cameraId = l+""; |
| bw.write(monitor_id+","+cameraId); |
| bw.newLine(); |
| bw.flush(); |
| } |
| } |
| } |
| } |
| } |
| } |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?