no message

This commit is contained in:
Cricial
2025-12-13 12:44:15 +08:00
parent a6b06735f6
commit 0e52fcb34b
41 changed files with 42682 additions and 34029 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,198 @@
id_firm,count
214851100,453
3111603340,453
70634828,453
532328014,227
303926772,227
395736790,216
340093034,214
29223617,208
3330358736,177
25980377,177
2337727838,80
2326722141,80
331545755,80
3191869223,61
2327605629,61
2336923756,61
591350440,60
728969035,59
517675473,59
16116663,54
16210433,53
471121089,52
2349179532,52
2349705416,50
1452048,5
515770253,3
6,2
2349345463,2
5971532,2
1,2
5849940,2
2424229017,2
495782506,2
420984285,2
300186799,2
37873062,2
3392803162,2
33822284,2
3312358902,2
2728939,2
3226664625,2
79938367,2
78979697,2
14913649,2
80158773,2
8,2
11807506,2
169978927,2
4607820,1
441623911,1
367669349,1
410030851,1
395739442,1
808524154,1
38852110,1
385766513,1
8114841,1
382080545,1
466148111,1
805940123,1
675729777,1
863973253,1
35404067,1
3462551351,1
3429928077,1
3420061649,1
340603317,1
872394725,1
9032550,1
907433543,1
950849442,1
3378606529,1
3362063909,1
3358892171,1
961017,1
9620005,1
862404568,1
493002466,1
668539285,1
507827038,1
676597455,1
688155470,1
664591135,1
648145286,1
644252759,1
643954924,1
640700057,1
6333996,1
618469306,1
696450846,1
71271700,1
733657390,1
3268669333,1
5979030,1
737770776,1
742704658,1
596368303,1
59234665,1
756272716,1
758879940,1
578803019,1
562681526,1
551856519,1
543470507,1
762501019,1
771821595,1
518871190,1
778745779,1
78576577,1
598808584,1
314846874,1
3226232,1
2333843479,1
2310534839,1
2311838590,1
2314659369,1
2316150629,1
2323069589,1
2326520912,1
2326655246,1
2326903290,1
2334430421,1
225958786,1
2337952436,1
2341774429,1
23421122,1
2344471631,1
2345982379,1
2347561020,1
2348894245,1
2348987001,1
2310406050,1
205960791,1
3222821993,1
1524794108,1
1160497810,1
1171244159,1
1208566436,1
1247902451,1
1253552935,1
13854344,1
1444449910,1
1476953321,1
157087137,1
203314437,1
1605495,1
1651310523,1
16715045,1
1698501971,1
178452970,1
189427260,1
193814549,1
197362120,1
2349349655,1
2349588257,1
2349742676,1
3145389278,1
2978926070,1
2989649772,1
29954548,1
3010580773,1
3011933107,1
3031766093,1
3118140206,1
3135349256,1
3147958370,1
2349746655,1
10437056,1
3151377261,1
31732840,1
3195293647,1
3196033145,1
3203980088,1
3220049148,1
3222664794,1
2962064709,1
29452962,1
2944593082,1
290636928,1
2350443114,1
2350544061,1
2351592628,1
2352421906,1
2353389310,1
2353549582,1
2382390052,1
2448521375,1
247297633,1
25685135,1
26487185,1
265133300,1
26895145,1
27042865,1
280281699,1
286335813,1
28667694,1
9746245,1
1 id_firm count
2 214851100 453
3 3111603340 453
4 70634828 453
5 532328014 227
6 303926772 227
7 395736790 216
8 340093034 214
9 29223617 208
10 3330358736 177
11 25980377 177
12 2337727838 80
13 2326722141 80
14 331545755 80
15 3191869223 61
16 2327605629 61
17 2336923756 61
18 591350440 60
19 728969035 59
20 517675473 59
21 16116663 54
22 16210433 53
23 471121089 52
24 2349179532 52
25 2349705416 50
26 1452048 5
27 515770253 3
28 6 2
29 2349345463 2
30 5971532 2
31 1 2
32 5849940 2
33 2424229017 2
34 495782506 2
35 420984285 2
36 300186799 2
37 37873062 2
38 3392803162 2
39 33822284 2
40 3312358902 2
41 2728939 2
42 3226664625 2
43 79938367 2
44 78979697 2
45 14913649 2
46 80158773 2
47 8 2
48 11807506 2
49 169978927 2
50 4607820 1
51 441623911 1
52 367669349 1
53 410030851 1
54 395739442 1
55 808524154 1
56 38852110 1
57 385766513 1
58 8114841 1
59 382080545 1
60 466148111 1
61 805940123 1
62 675729777 1
63 863973253 1
64 35404067 1
65 3462551351 1
66 3429928077 1
67 3420061649 1
68 340603317 1
69 872394725 1
70 9032550 1
71 907433543 1
72 950849442 1
73 3378606529 1
74 3362063909 1
75 3358892171 1
76 961017 1
77 9620005 1
78 862404568 1
79 493002466 1
80 668539285 1
81 507827038 1
82 676597455 1
83 688155470 1
84 664591135 1
85 648145286 1
86 644252759 1
87 643954924 1
88 640700057 1
89 6333996 1
90 618469306 1
91 696450846 1
92 71271700 1
93 733657390 1
94 3268669333 1
95 5979030 1
96 737770776 1
97 742704658 1
98 596368303 1
99 59234665 1
100 756272716 1
101 758879940 1
102 578803019 1
103 562681526 1
104 551856519 1
105 543470507 1
106 762501019 1
107 771821595 1
108 518871190 1
109 778745779 1
110 78576577 1
111 598808584 1
112 314846874 1
113 3226232 1
114 2333843479 1
115 2310534839 1
116 2311838590 1
117 2314659369 1
118 2316150629 1
119 2323069589 1
120 2326520912 1
121 2326655246 1
122 2326903290 1
123 2334430421 1
124 225958786 1
125 2337952436 1
126 2341774429 1
127 23421122 1
128 2344471631 1
129 2345982379 1
130 2347561020 1
131 2348894245 1
132 2348987001 1
133 2310406050 1
134 205960791 1
135 3222821993 1
136 1524794108 1
137 1160497810 1
138 1171244159 1
139 1208566436 1
140 1247902451 1
141 1253552935 1
142 13854344 1
143 1444449910 1
144 1476953321 1
145 157087137 1
146 203314437 1
147 1605495 1
148 1651310523 1
149 16715045 1
150 1698501971 1
151 178452970 1
152 189427260 1
153 193814549 1
154 197362120 1
155 2349349655 1
156 2349588257 1
157 2349742676 1
158 3145389278 1
159 2978926070 1
160 2989649772 1
161 29954548 1
162 3010580773 1
163 3011933107 1
164 3031766093 1
165 3118140206 1
166 3135349256 1
167 3147958370 1
168 2349746655 1
169 10437056 1
170 3151377261 1
171 31732840 1
172 3195293647 1
173 3196033145 1
174 3203980088 1
175 3220049148 1
176 3222664794 1
177 2962064709 1
178 29452962 1
179 2944593082 1
180 290636928 1
181 2350443114 1
182 2350544061 1
183 2351592628 1
184 2352421906 1
185 2353389310 1
186 2353549582 1
187 2382390052 1
188 2448521375 1
189 247297633 1
190 25685135 1
191 26487185 1
192 265133300 1
193 26895145 1
194 27042865 1
195 280281699 1
196 286335813 1
197 28667694 1
198 9746245 1

View File

@@ -0,0 +1,259 @@
id_firm,id_product,count
303926772,99,227
532328014,99,227
395736790,95,216
340093034,95,214
29223617,95,208
2326722141,90,80
2337727838,90,80
331545755,90,80
3191869223,91,61
2327605629,94,61
2336923756,91,61
591350440,91,60
728969035,93,59
517675473,92,59
16210433,92,53
2349179532,93,52
471121089,93,52
2349705416,94,50
16116663,92,50
70634828,51,49
3111603340,51,49
214851100,51,49
214851100,53,48
214851100,52,48
3111603340,52,48
3111603340,53,48
70634828,52,48
70634828,53,48
3111603340,54,46
70634828,55,46
214851100,54,46
214851100,55,46
214851100,50,46
70634828,54,46
70634828,50,46
3111603340,50,46
3111603340,55,46
25980377,38,32
3330358736,38,32
3330358736,39,31
3330358736,43,31
25980377,43,31
25980377,39,31
25980377,40,29
3330358736,40,29
3111603340,47,29
70634828,47,29
214851100,47,29
214851100,49,28
70634828,44,28
25980377,41,28
70634828,49,28
3111603340,44,28
3111603340,45,28
3111603340,46,28
3111603340,48,28
3111603340,49,28
70634828,48,28
70634828,45,28
70634828,46,28
214851100,48,28
3330358736,41,28
214851100,46,28
214851100,45,28
214851100,44,28
25980377,42,26
3330358736,42,26
1452048,9,3
515770253,9,3
33822284,9,2
3392803162,9,2
5971532,9,2
37873062,9,2
79938367,9,2
8,37,2
420984285,16,2
495782506,19,2
80158773,69,2
6,10,2
1,10,2
14913649,9,2
16116663,11,2
2350443114,74,1
5979030,9,1
562681526,25,1
578803019,10,1
5849940,26,1
5849940,36,1
16116663,9,1
59234665,65,1
596368303,12,1
598808584,15,1
543470507,8,1
16116663,10,1
618469306,9,1
6333996,66,1
640700057,9,1
643954924,9,1
644252759,61,1
648145286,35,1
664591135,9,1
551856519,33,1
1651310523,9,1
675729777,10,1
518871190,9,1
35404067,9,1
367669349,31,1
193814549,33,1
382080545,9,1
385766513,24,1
38852110,10,1
189427260,9,1
395739442,9,1
410030851,27,1
178452970,25,1
441623911,79,1
4607820,9,1
466148111,9,1
169978927,9,1
493002466,9,1
169978927,66,1
507827038,10,1
1698501971,9,1
16715045,10,1
668539285,17,1
676597455,68,1
2350544061,9,1
808524154,9,1
778745779,9,1
78576577,9,1
78979697,61,1
78979697,74,1
11807506,36,1
1171244159,32,1
1160497810,12,1
805940123,72,1
8114841,9,1
762501019,9,1
862404568,11,1
863973253,9,1
872394725,70,1
9032550,34,1
907433543,10,1
950849442,9,1
961017,23,1
9620005,9,1
771821595,31,1
758879940,65,1
688155470,30,1
13854344,9,1
696450846,9,1
1605495,9,1
157087137,73,1
1524794108,9,1
1476953321,10,1
1452048,30,1
1452048,11,1
1444449910,20,1
1253552935,9,1
756272716,32,1
1247902451,9,1
1208566436,62,1
70634828,7,1
71271700,27,1
11807506,9,1
733657390,10,1
737770776,34,1
742704658,9,1
3462551351,13,1
3429928077,9,1
3420061649,9,1
340603317,9,1
280281699,60,1
286335813,72,1
28667694,10,1
290636928,9,1
2348987001,9,1
2944593082,9,1
29452962,9,1
2962064709,9,1
2978926070,8,1
2989649772,71,1
29954548,18,1
300186799,10,1
300186799,11,1
3010580773,9,1
3011933107,9,1
3031766093,9,1
2348894245,11,1
2347561020,9,1
2345982379,67,1
2728939,71,1
2728939,63,1
27042865,9,1
247297633,18,1
2351592628,10,1
2352421906,17,1
2353389310,15,1
2353549582,23,1
2382390052,9,1
2424229017,26,1
2424229017,9,1
2448521375,25,1
25685135,11,1
26895145,9,1
2349746655,10,1
2349742676,33,1
2349588257,10,1
2349349655,9,1
2349345463,59,1
2349345463,35,1
26487185,62,1
265133300,9,1
2344471631,9,1
23421122,9,1
2341774429,9,1
2310534839,64,1
3226664625,13,1
3226664625,28,1
3268669333,67,1
3312358902,59,1
3312358902,79,1
2316150629,10,1
2314659369,20,1
2311838590,97,1
2310406050,60,1
3222821993,9,1
225958786,11,1
214851100,7,1
3358892171,64,1
3362063909,10,1
3378606529,9,1
205960791,63,1
203314437,22,1
197362120,15,1
3226232,10,1
3222664794,9,1
2337952436,24,1
3135349256,9,1
2334430421,73,1
2333843479,70,1
10437056,9,1
2326903290,9,1
2326655246,9,1
2326520912,10,1
3111603340,7,1
3118140206,68,1
3145389278,9,1
3220049148,9,1
3147958370,12,1
314846874,11,1
3151377261,29,1
31732840,29,1
2323069589,9,1
3195293647,28,1
3196033145,9,1
3203980088,10,1
9746245,97,1
1 id_firm id_product count
2 303926772 99 227
3 532328014 99 227
4 395736790 95 216
5 340093034 95 214
6 29223617 95 208
7 2326722141 90 80
8 2337727838 90 80
9 331545755 90 80
10 3191869223 91 61
11 2327605629 94 61
12 2336923756 91 61
13 591350440 91 60
14 728969035 93 59
15 517675473 92 59
16 16210433 92 53
17 2349179532 93 52
18 471121089 93 52
19 2349705416 94 50
20 16116663 92 50
21 70634828 51 49
22 3111603340 51 49
23 214851100 51 49
24 214851100 53 48
25 214851100 52 48
26 3111603340 52 48
27 3111603340 53 48
28 70634828 52 48
29 70634828 53 48
30 3111603340 54 46
31 70634828 55 46
32 214851100 54 46
33 214851100 55 46
34 214851100 50 46
35 70634828 54 46
36 70634828 50 46
37 3111603340 50 46
38 3111603340 55 46
39 25980377 38 32
40 3330358736 38 32
41 3330358736 39 31
42 3330358736 43 31
43 25980377 43 31
44 25980377 39 31
45 25980377 40 29
46 3330358736 40 29
47 3111603340 47 29
48 70634828 47 29
49 214851100 47 29
50 214851100 49 28
51 70634828 44 28
52 25980377 41 28
53 70634828 49 28
54 3111603340 44 28
55 3111603340 45 28
56 3111603340 46 28
57 3111603340 48 28
58 3111603340 49 28
59 70634828 48 28
60 70634828 45 28
61 70634828 46 28
62 214851100 48 28
63 3330358736 41 28
64 214851100 46 28
65 214851100 45 28
66 214851100 44 28
67 25980377 42 26
68 3330358736 42 26
69 1452048 9 3
70 515770253 9 3
71 33822284 9 2
72 3392803162 9 2
73 5971532 9 2
74 37873062 9 2
75 79938367 9 2
76 8 37 2
77 420984285 16 2
78 495782506 19 2
79 80158773 69 2
80 6 10 2
81 1 10 2
82 14913649 9 2
83 16116663 11 2
84 2350443114 74 1
85 5979030 9 1
86 562681526 25 1
87 578803019 10 1
88 5849940 26 1
89 5849940 36 1
90 16116663 9 1
91 59234665 65 1
92 596368303 12 1
93 598808584 15 1
94 543470507 8 1
95 16116663 10 1
96 618469306 9 1
97 6333996 66 1
98 640700057 9 1
99 643954924 9 1
100 644252759 61 1
101 648145286 35 1
102 664591135 9 1
103 551856519 33 1
104 1651310523 9 1
105 675729777 10 1
106 518871190 9 1
107 35404067 9 1
108 367669349 31 1
109 193814549 33 1
110 382080545 9 1
111 385766513 24 1
112 38852110 10 1
113 189427260 9 1
114 395739442 9 1
115 410030851 27 1
116 178452970 25 1
117 441623911 79 1
118 4607820 9 1
119 466148111 9 1
120 169978927 9 1
121 493002466 9 1
122 169978927 66 1
123 507827038 10 1
124 1698501971 9 1
125 16715045 10 1
126 668539285 17 1
127 676597455 68 1
128 2350544061 9 1
129 808524154 9 1
130 778745779 9 1
131 78576577 9 1
132 78979697 61 1
133 78979697 74 1
134 11807506 36 1
135 1171244159 32 1
136 1160497810 12 1
137 805940123 72 1
138 8114841 9 1
139 762501019 9 1
140 862404568 11 1
141 863973253 9 1
142 872394725 70 1
143 9032550 34 1
144 907433543 10 1
145 950849442 9 1
146 961017 23 1
147 9620005 9 1
148 771821595 31 1
149 758879940 65 1
150 688155470 30 1
151 13854344 9 1
152 696450846 9 1
153 1605495 9 1
154 157087137 73 1
155 1524794108 9 1
156 1476953321 10 1
157 1452048 30 1
158 1452048 11 1
159 1444449910 20 1
160 1253552935 9 1
161 756272716 32 1
162 1247902451 9 1
163 1208566436 62 1
164 70634828 7 1
165 71271700 27 1
166 11807506 9 1
167 733657390 10 1
168 737770776 34 1
169 742704658 9 1
170 3462551351 13 1
171 3429928077 9 1
172 3420061649 9 1
173 340603317 9 1
174 280281699 60 1
175 286335813 72 1
176 28667694 10 1
177 290636928 9 1
178 2348987001 9 1
179 2944593082 9 1
180 29452962 9 1
181 2962064709 9 1
182 2978926070 8 1
183 2989649772 71 1
184 29954548 18 1
185 300186799 10 1
186 300186799 11 1
187 3010580773 9 1
188 3011933107 9 1
189 3031766093 9 1
190 2348894245 11 1
191 2347561020 9 1
192 2345982379 67 1
193 2728939 71 1
194 2728939 63 1
195 27042865 9 1
196 247297633 18 1
197 2351592628 10 1
198 2352421906 17 1
199 2353389310 15 1
200 2353549582 23 1
201 2382390052 9 1
202 2424229017 26 1
203 2424229017 9 1
204 2448521375 25 1
205 25685135 11 1
206 26895145 9 1
207 2349746655 10 1
208 2349742676 33 1
209 2349588257 10 1
210 2349349655 9 1
211 2349345463 59 1
212 2349345463 35 1
213 26487185 62 1
214 265133300 9 1
215 2344471631 9 1
216 23421122 9 1
217 2341774429 9 1
218 2310534839 64 1
219 3226664625 13 1
220 3226664625 28 1
221 3268669333 67 1
222 3312358902 59 1
223 3312358902 79 1
224 2316150629 10 1
225 2314659369 20 1
226 2311838590 97 1
227 2310406050 60 1
228 3222821993 9 1
229 225958786 11 1
230 214851100 7 1
231 3358892171 64 1
232 3362063909 10 1
233 3378606529 9 1
234 205960791 63 1
235 203314437 22 1
236 197362120 15 1
237 3226232 10 1
238 3222664794 9 1
239 2337952436 24 1
240 3135349256 9 1
241 2334430421 73 1
242 2333843479 70 1
243 10437056 9 1
244 2326903290 9 1
245 2326655246 9 1
246 2326520912 10 1
247 3111603340 7 1
248 3118140206 68 1
249 3145389278 9 1
250 3220049148 9 1
251 3147958370 12 1
252 314846874 11 1
253 3151377261 29 1
254 31732840 29 1
255 2323069589 9 1
256 3195293647 28 1
257 3196033145 9 1
258 3203980088 10 1
259 9746245 97 1

View File

@@ -0,0 +1,73 @@
id_product,count
95,638
99,454
90,240
91,182
93,163
92,162
51,147
53,144
52,144
50,138
55,138
54,138
94,111
47,87
44,84
9,84
49,84
46,84
45,84
48,84
38,64
43,62
39,62
40,58
41,56
42,52
10,23
11,9
15,3
12,3
33,3
7,3
25,3
69,2
74,2
68,2
70,2
71,2
72,2
73,2
19,2
79,2
8,2
66,2
18,2
17,2
16,2
13,2
97,2
67,2
32,2
65,2
27,2
34,2
35,2
36,2
37,2
31,2
30,2
29,2
28,2
26,2
64,2
24,2
23,2
20,2
59,2
60,2
62,2
63,2
61,2
22,1
1 id_product count
2 95 638
3 99 454
4 90 240
5 91 182
6 93 163
7 92 162
8 51 147
9 53 144
10 52 144
11 50 138
12 55 138
13 54 138
14 94 111
15 47 87
16 44 84
17 9 84
18 49 84
19 46 84
20 45 84
21 48 84
22 38 64
23 43 62
24 39 62
25 40 58
26 41 56
27 42 52
28 10 23
29 11 9
30 15 3
31 12 3
32 33 3
33 7 3
34 25 3
35 69 2
36 74 2
37 68 2
38 70 2
39 71 2
40 72 2
41 73 2
42 19 2
43 79 2
44 8 2
45 66 2
46 18 2
47 17 2
48 16 2
49 13 2
50 97 2
51 67 2
52 32 2
53 65 2
54 27 2
55 34 2
56 35 2
57 36 2
58 37 2
59 31 2
60 30 2
61 29 2
62 28 2
63 26 2
64 64 2
65 24 2
66 23 2
67 20 2
68 59 2
69 60 2
70 62 2
71 63 2
72 61 2
73 22 1

View File

@@ -0,0 +1,80 @@
import pickle
from sqlalchemy import text
from orm import engine, connection
import pandas as pd
import networkx as nx
import json
import matplotlib.pyplot as plt
# Prepare data
Firm = pd.read_csv("../../input_data/input_firm_data/firm_amended.csv")
Firm['Code'] = Firm['Code'].astype('string')
Firm.fillna(0, inplace=True)
BomNodes = pd.read_csv('../../input_data/input_product_data/BomNodes.csv', index_col=0)
# SQL query
with open('../../SQL_analysis_risk.sql', 'r') as f:
str_sql = text(f.read())
result = pd.read_sql(sql=str_sql, con=connection)
result.to_csv('count.csv', index=False, encoding='utf-8-sig')
print(result)
# Count firm product
count_firm_prod = result.value_counts(subset=['id_firm', 'id_product'])
count_firm_prod.name = 'count'
count_firm_prod = count_firm_prod.to_frame().reset_index()
count_firm_prod.to_csv('count_firm_prod.csv', index=False, encoding='utf-8-sig')
print(count_firm_prod)
# Count firm
count_firm = count_firm_prod.groupby('id_firm')['count'].sum()
count_firm = count_firm.to_frame().reset_index()
count_firm.sort_values('count', inplace=True, ascending=False)
count_firm.to_csv('count_firm.csv', index=False, encoding='utf-8-sig')
print(count_firm)
# Count product
count_prod = count_firm_prod.groupby('id_product')['count'].sum()
count_prod = count_prod.to_frame().reset_index()
count_prod.sort_values('count', inplace=True, ascending=False)
count_prod.to_csv('count_prod.csv', index=False, encoding='utf-8-sig')
print(count_prod)
# DCP disruption causing probability
result_disrupt_ts_above_0 = result[result['ts'] > 0]
print(result_disrupt_ts_above_0)
result_dcp = pd.DataFrame(columns=[
's_id', 'up_id_firm', 'up_id_product', 'down_id_firm', 'down_id_product'
])
result_dcp_list = [] # 用列表收集数据避免DataFrame逐行增长的问题
for sid, group in result.groupby('s_id'):
ts_start = max(group['ts'])
while ts_start >= 1:
ts_end = ts_start - 1
while ts_end >= 0:
up = group.loc[group['ts'] == ts_end, ['id_firm', 'id_product']]
down = group.loc[group['ts'] == ts_start, ['id_firm', 'id_product']]
for _, up_row in up.iterrows():
for _, down_row in down.iterrows():
result_dcp_list.append([sid] + up_row.tolist() + down_row.tolist())
ts_end -= 1
ts_start -= 1
# 转换为DataFrame
result_dcp = pd.DataFrame(result_dcp_list, columns=[
's_id', 'up_id_firm', 'up_id_product', 'down_id_firm', 'down_id_product'
])
# 统计
count_dcp = result_dcp.value_counts(
subset=['up_id_firm', 'up_id_product', 'down_id_firm', 'down_id_product']
).reset_index(name='count')
# 保存文件
count_dcp.to_csv('count_dcp.csv', index=False, encoding='utf-8-sig')
# 输出结果
print(count_dcp)