test
educoder 4 years ago
parent 216ddf8838
commit c95eb3fc6d

@ -0,0 +1,157 @@
"2015551306","李明洋","未发现附件"
"2015551317","佘思博","未发现附件"
"2015551432","周蓝","未发现附件"
"2015551407","李绍禹","未发现附件"
"2015551406","刘蕴泽","未发现附件"
"2015962037","张鋆","未发现附件"
"2015962015","邓联杰","未发现附件"
"2015962039","周铭锐","未发现附件"
"2015962133","袁凌","未发现附件"
"2015962125","王芳华","未发现附件"
"2015962131","易程","未发现附件"
"2014551331","周敏敏","未发现附件"
"2014551309","周杨萍","未发现附件"
"2015962036","张星","未发现附件"
"2015962011","曹峻源","未发现附件"
"2015962037","张鋆","未发现附件"
"2015801008","杨旭","未发现附件"
"2015962005","林慧","未发现附件"
"","p79601584","未发现附件"
"2015962033","肖巨","未发现附件"
"2015962023","廖广平","未发现附件"
"2015962039","周铭锐","未发现附件"
"2015962034","杨坤","未发现附件"
"2015962031","王耀武","未发现附件"
"2015551127","符燕群","未发现附件"
"2015962132","尹李杰","未发现附件"
"2013960815","李明烈","未发现附件"
"2015962118","刘清伟","未发现附件"
"2015962103","刘芳芳","未发现附件"
"2015551226","张斌","未发现附件"
"2015962127","吴俊杰","未发现附件"
"2015551217","陈鑫祯","未发现附件"
"2015962130","杨旭","未发现附件"
"2015962115","李德安","未发现附件"
"","p26485079","未发现附件"
"2015551220","丁弟","未发现附件"
"2015551301","殷昌健","未发现附件"
"","txuboy","未发现附件"
"2015551216","梁晶","未发现附件"
"2015551225","周杰","未发现附件"
"20159200204","阳文献","未发现附件"
"20159201014","邹子怡","未发现附件"
"","p57032168","未发现附件"
"20159201017","朱春霖","未发现附件"
"2015962102","赖慰锋","未发现附件"
"20159200205","李泽湘","未发现附件"
"2015551506","姚金城","未发现附件"
"","p45037219","未发现附件"
"","杨奇为","未发现附件"
"2015551535","ZHUxueyi","未发现附件"
"edu2015551505","李小庆","未发现附件"
"2015551619","唐昭敏","未发现附件"
"","p10928657","未发现附件"
"2015551614","戴宁","未发现附件"
"","p80674219","未发现附件"
"","p25804791","未发现附件"
"","p95284761","未发现附件"
"2015551624","白杰","未发现附件"
"2013551512","柯维隆","未发现附件"
"2015962036","张星","未发现附件"
"","m29345816","未发现附件"
"2015551625","斯海洋","未发现附件"
"20159200213","黄海兵","未发现附件"
"","p92780145","未发现附件"
"2015651103","孟世斌","未发现附件"
"2015551339","王孟轩","未发现附件"
"2015551328","肖兰建","未发现附件"
"2015551335","靳付棋","未发现附件"
"2015551326","黄趾雄","未发现附件"
"2015551302","谢伟胜","未发现附件"
"2015551313","罗钦","未发现附件"
"","陶索菲","项目文件夹不存在"
"","刘振","项目文件夹不存在"
"","杨志","项目文件夹不存在"
"","陈雅丽","检测出错"
"","周怡","项目文件夹不存在"
"","陶索菲","项目文件夹不存在"
"","刘振","项目文件夹不存在"
"","杨志","项目文件夹不存在"
"","周怡","项目文件夹不存在"
"","温豪杰","检测出错"
"","金徽","项目文件夹不存在"
"","李航","项目文件夹不存在"
"","李一鸣","项目文件夹不存在"
""," 董国超","项目文件夹不存在"
"","李超","项目文件夹不存在"
"","刘圣凯","项目文件夹不存在"
"","黄岩珍","项目文件夹不存在"
"","周为","项目文件夹不存在"
"","李邓平","项目文件夹不存在"
"","尹嘉俊","项目文件夹不存在"
"","殷昌健","项目文件夹不存在"
"","李小庆","项目文件夹不存在"
"","李鸿伟","项目文件夹不存在"
"","胡锦宇","项目文件夹不存在"
"","陈怀泽","项目文件夹不存在"
"","高宇博","项目文件夹不存在"
"","李耀","项目文件夹不存在"
"","杨帆","项目文件夹不存在"
"","周蓝","项目文件夹不存在"
"","梁晶","项目文件夹不存在"
"","刘洋","项目文件夹不存在"
"","陶索菲","项目文件夹不存在"
"","刘振","项目文件夹不存在"
"","杨志","项目文件夹不存在"
"","周怡","项目文件夹不存在"
"","金徽","项目文件夹不存在"
"","李航","项目文件夹不存在"
"","李一鸣","项目文件夹不存在"
""," 董国超","项目文件夹不存在"
"","李超","项目文件夹不存在"
"","刘圣凯","项目文件夹不存在"
"","黄岩珍","项目文件夹不存在"
"","周为","项目文件夹不存在"
"","李邓平","项目文件夹不存在"
"","尹嘉俊","项目文件夹不存在"
"","殷昌健","项目文件夹不存在"
"","李小庆","项目文件夹不存在"
"","李鸿伟","项目文件夹不存在"
"","胡锦宇","项目文件夹不存在"
"","陈怀泽","项目文件夹不存在"
"","高宇博","项目文件夹不存在"
"","李耀","项目文件夹不存在"
"","杨帆","项目文件夹不存在"
"","周蓝","项目文件夹不存在"
"","梁晶","项目文件夹不存在"
"","刘洋","项目文件夹不存在"
"","阮会姗","项目文件夹不存在"
"","毛胤灿","项目文件夹不存在"
"","张斌","项目文件夹不存在"
"","王梦媛","项目文件夹不存在"
"","陈藏宇","项目文件夹不存在"
"","曾苗","项目文件夹不存在"
"","吴嘉杰","项目文件夹不存在"
"","邹昱夫","项目文件夹不存在"
"","Claudrick","项目文件夹不存在"
"","肖瀚","项目文件夹不存在"
"","张萌","项目文件夹不存在"
"","王芳华","项目文件夹不存在"
"","赵新阳","项目文件夹不存在"
"","佘思博","项目文件夹不存在"
"","王立杰","项目文件夹不存在"
"","武张浩","项目文件夹不存在"
"","江杰","项目文件夹不存在"
"","刘卫","项目文件夹不存在"
"","唐耀辉","项目文件夹不存在"
"","李谦","项目文件夹不存在"
"","李成龙","项目文件夹不存在"
"","袁双雄","项目文件夹不存在"
"","赵新宇","项目文件夹不存在"
"","黄文","项目文件夹不存在"
"","林滨","项目文件夹不存在"
"","张铃崎","项目文件夹不存在"
"","张皓钦","项目文件夹不存在"
"","袁骏","项目文件夹不存在"
"","吴俊杰","项目文件夹不存在"
"","蒋浩","项目文件夹不存在"
1 2015551306 李明洋 未发现附件
2 2015551317 佘思博 未发现附件
3 2015551432 周蓝 未发现附件
4 2015551407 李绍禹 未发现附件
5 2015551406 刘蕴泽 未发现附件
6 2015962037 张鋆 未发现附件
7 2015962015 邓联杰 未发现附件
8 2015962039 周铭锐 未发现附件
9 2015962133 袁凌 未发现附件
10 2015962125 王芳华 未发现附件
11 2015962131 易程 未发现附件
12 2014551331 周敏敏 未发现附件
13 2014551309 周杨萍 未发现附件
14 2015962036 张星 未发现附件
15 2015962011 曹峻源 未发现附件
16 2015962037 张鋆 未发现附件
17 2015801008 杨旭 未发现附件
18 2015962005 林慧 未发现附件
19 p79601584 未发现附件
20 2015962033 肖巨 未发现附件
21 2015962023 廖广平 未发现附件
22 2015962039 周铭锐 未发现附件
23 2015962034 杨坤 未发现附件
24 2015962031 王耀武 未发现附件
25 2015551127 符燕群 未发现附件
26 2015962132 尹李杰 未发现附件
27 2013960815 李明烈 未发现附件
28 2015962118 刘清伟 未发现附件
29 2015962103 刘芳芳 未发现附件
30 2015551226 张斌 未发现附件
31 2015962127 吴俊杰 未发现附件
32 2015551217 陈鑫祯 未发现附件
33 2015962130 杨旭 未发现附件
34 2015962115 李德安 未发现附件
35 p26485079 未发现附件
36 2015551220 丁弟 未发现附件
37 2015551301 殷昌健 未发现附件
38 txuboy 未发现附件
39 2015551216 梁晶 未发现附件
40 2015551225 周杰 未发现附件
41 20159200204 阳文献 未发现附件
42 20159201014 邹子怡 未发现附件
43 p57032168 未发现附件
44 20159201017 朱春霖 未发现附件
45 2015962102 赖慰锋 未发现附件
46 20159200205 李泽湘 未发现附件
47 2015551506 姚金城 未发现附件
48 p45037219 未发现附件
49 杨奇为 未发现附件
50 2015551535 ZHUxueyi 未发现附件
51 edu2015551505 李小庆 未发现附件
52 2015551619 唐昭敏 未发现附件
53 p10928657 未发现附件
54 2015551614 戴宁 未发现附件
55 p80674219 未发现附件
56 p25804791 未发现附件
57 p95284761 未发现附件
58 2015551624 白杰 未发现附件
59 2013551512 柯维隆 未发现附件
60 2015962036 张星 未发现附件
61 m29345816 未发现附件
62 2015551625 斯海洋 未发现附件
63 20159200213 黄海兵 未发现附件
64 p92780145 未发现附件
65 2015651103 孟世斌 未发现附件
66 2015551339 王孟轩 未发现附件
67 2015551328 肖兰建 未发现附件
68 2015551335 靳付棋 未发现附件
69 2015551326 黄趾雄 未发现附件
70 2015551302 谢伟胜 未发现附件
71 2015551313 罗钦 未发现附件
72 陶索菲 项目文件夹不存在
73 刘振 项目文件夹不存在
74 杨志 项目文件夹不存在
75 陈雅丽 检测出错
76 周怡 项目文件夹不存在
77 陶索菲 项目文件夹不存在
78 刘振 项目文件夹不存在
79 杨志 项目文件夹不存在
80 周怡 项目文件夹不存在
81 温豪杰 检测出错
82 金徽 项目文件夹不存在
83 李航 项目文件夹不存在
84 李一鸣 项目文件夹不存在
85 董国超 项目文件夹不存在
86 李超 项目文件夹不存在
87 刘圣凯 项目文件夹不存在
88 黄岩珍 项目文件夹不存在
89 周为 项目文件夹不存在
90 李邓平 项目文件夹不存在
91 尹嘉俊 项目文件夹不存在
92 殷昌健 项目文件夹不存在
93 李小庆 项目文件夹不存在
94 李鸿伟 项目文件夹不存在
95 胡锦宇 项目文件夹不存在
96 陈怀泽 项目文件夹不存在
97 高宇博 项目文件夹不存在
98 李耀 项目文件夹不存在
99 杨帆 项目文件夹不存在
100 周蓝 项目文件夹不存在
101 梁晶 项目文件夹不存在
102 刘洋 项目文件夹不存在
103 陶索菲 项目文件夹不存在
104 刘振 项目文件夹不存在
105 杨志 项目文件夹不存在
106 周怡 项目文件夹不存在
107 金徽 项目文件夹不存在
108 李航 项目文件夹不存在
109 李一鸣 项目文件夹不存在
110 董国超 项目文件夹不存在
111 李超 项目文件夹不存在
112 刘圣凯 项目文件夹不存在
113 黄岩珍 项目文件夹不存在
114 周为 项目文件夹不存在
115 李邓平 项目文件夹不存在
116 尹嘉俊 项目文件夹不存在
117 殷昌健 项目文件夹不存在
118 李小庆 项目文件夹不存在
119 李鸿伟 项目文件夹不存在
120 胡锦宇 项目文件夹不存在
121 陈怀泽 项目文件夹不存在
122 高宇博 项目文件夹不存在
123 李耀 项目文件夹不存在
124 杨帆 项目文件夹不存在
125 周蓝 项目文件夹不存在
126 梁晶 项目文件夹不存在
127 刘洋 项目文件夹不存在
128 阮会姗 项目文件夹不存在
129 毛胤灿 项目文件夹不存在
130 张斌 项目文件夹不存在
131 王梦媛 项目文件夹不存在
132 陈藏宇 项目文件夹不存在
133 曾苗 项目文件夹不存在
134 吴嘉杰 项目文件夹不存在
135 邹昱夫 项目文件夹不存在
136 Claudrick 项目文件夹不存在
137 肖瀚 项目文件夹不存在
138 张萌 项目文件夹不存在
139 王芳华 项目文件夹不存在
140 赵新阳 项目文件夹不存在
141 佘思博 项目文件夹不存在
142 王立杰 项目文件夹不存在
143 武张浩 项目文件夹不存在
144 江杰 项目文件夹不存在
145 刘卫 项目文件夹不存在
146 唐耀辉 项目文件夹不存在
147 李谦 项目文件夹不存在
148 李成龙 项目文件夹不存在
149 袁双雄 项目文件夹不存在
150 赵新宇 项目文件夹不存在
151 黄文 项目文件夹不存在
152 林滨 项目文件夹不存在
153 张铃崎 项目文件夹不存在
154 张皓钦 项目文件夹不存在
155 袁骏 项目文件夹不存在
156 吴俊杰 项目文件夹不存在
157 蒋浩 项目文件夹不存在

@ -0,0 +1,157 @@
"2015551306","李明洋","未发现附件"
"2015551317","佘思博","未发现附件"
"2015551432","周蓝","未发现附件"
"2015551407","李绍禹","未发现附件"
"2015551406","刘蕴泽","未发现附件"
"2015962037","张鋆","未发现附件"
"2015962015","邓联杰","未发现附件"
"2015962039","周铭锐","未发现附件"
"2015962133","袁凌","未发现附件"
"2015962125","王芳华","未发现附件"
"2015962131","易程","未发现附件"
"2014551331","周敏敏","未发现附件"
"2014551309","周杨萍","未发现附件"
"2015962036","张星","未发现附件"
"2015962011","曹峻源","未发现附件"
"2015962037","张鋆","未发现附件"
"2015801008","杨旭","未发现附件"
"2015962005","林慧","未发现附件"
"","p79601584","未发现附件"
"2015962033","肖巨","未发现附件"
"2015962023","廖广平","未发现附件"
"2015962039","周铭锐","未发现附件"
"2015962034","杨坤","未发现附件"
"2015962031","王耀武","未发现附件"
"2015551127","符燕群","未发现附件"
"2015962132","尹李杰","未发现附件"
"2013960815","李明烈","未发现附件"
"2015962118","刘清伟","未发现附件"
"2015962103","刘芳芳","未发现附件"
"2015551226","张斌","未发现附件"
"2015962127","吴俊杰","未发现附件"
"2015551217","陈鑫祯","未发现附件"
"2015962130","杨旭","未发现附件"
"2015962115","李德安","未发现附件"
"","p26485079","未发现附件"
"2015551220","丁弟","未发现附件"
"2015551301","殷昌健","未发现附件"
"","txuboy","未发现附件"
"2015551216","梁晶","未发现附件"
"2015551225","周杰","未发现附件"
"20159200204","阳文献","未发现附件"
"20159201014","邹子怡","未发现附件"
"","p57032168","未发现附件"
"20159201017","朱春霖","未发现附件"
"2015962102","赖慰锋","未发现附件"
"20159200205","李泽湘","未发现附件"
"2015551506","姚金城","未发现附件"
"","p45037219","未发现附件"
"","杨奇为","未发现附件"
"2015551535","ZHUxueyi","未发现附件"
"edu2015551505","李小庆","未发现附件"
"2015551619","唐昭敏","未发现附件"
"","p10928657","未发现附件"
"2015551614","戴宁","未发现附件"
"","p80674219","未发现附件"
"","p25804791","未发现附件"
"","p95284761","未发现附件"
"2015551624","白杰","未发现附件"
"2013551512","柯维隆","未发现附件"
"2015962036","张星","未发现附件"
"","m29345816","未发现附件"
"2015551625","斯海洋","未发现附件"
"20159200213","黄海兵","未发现附件"
"","p92780145","未发现附件"
"2015651103","孟世斌","未发现附件"
"2015551339","王孟轩","未发现附件"
"2015551328","肖兰建","未发现附件"
"2015551335","靳付棋","未发现附件"
"2015551326","黄趾雄","未发现附件"
"2015551302","谢伟胜","未发现附件"
"2015551313","罗钦","未发现附件"
"","陶索菲","项目文件夹不存在"
"","刘振","项目文件夹不存在"
"","杨志","项目文件夹不存在"
"","陈雅丽","Mapper method itive return type (float)."
"","周怡","项目文件夹不存在"
"","陶索菲","项目文件夹不存在"
"","刘振","项目文件夹不存在"
"","杨志","项目文件夹不存在"
"","周怡","项目文件夹不存在"
"","温豪杰","连接超时 (Read failed)"
"","金徽","项目文件夹不存在"
"","李航","项目文件夹不存在"
"","李一鸣","项目文件夹不存在"
""," 董国超","项目文件夹不存在"
"","李超","项目文件夹不存在"
"","刘圣凯","项目文件夹不存在"
"","黄岩珍","项目文件夹不存在"
"","周为","项目文件夹不存在"
"","李邓平","项目文件夹不存在"
"","尹嘉俊","项目文件夹不存在"
"","殷昌健","项目文件夹不存在"
"","李小庆","项目文件夹不存在"
"","李鸿伟","项目文件夹不存在"
"","胡锦宇","项目文件夹不存在"
"","陈怀泽","项目文件夹不存在"
"","高宇博","项目文件夹不存在"
"","李耀","项目文件夹不存在"
"","杨帆","项目文件夹不存在"
"","周蓝","项目文件夹不存在"
"","梁晶","项目文件夹不存在"
"","刘洋","项目文件夹不存在"
"","陶索菲","项目文件夹不存在"
"","刘振","项目文件夹不存在"
"","杨志","项目文件夹不存在"
"","周怡","项目文件夹不存在"
"","金徽","项目文件夹不存在"
"","李航","项目文件夹不存在"
"","李一鸣","项目文件夹不存在"
""," 董国超","项目文件夹不存在"
"","李超","项目文件夹不存在"
"","刘圣凯","项目文件夹不存在"
"","黄岩珍","项目文件夹不存在"
"","周为","项目文件夹不存在"
"","李邓平","项目文件夹不存在"
"","尹嘉俊","项目文件夹不存在"
"","殷昌健","项目文件夹不存在"
"","李小庆","项目文件夹不存在"
"","李鸿伟","项目文件夹不存在"
"","胡锦宇","项目文件夹不存在"
"","陈怀泽","项目文件夹不存在"
"","高宇博","项目文件夹不存在"
"","李耀","项目文件夹不存在"
"","杨帆","项目文件夹不存在"
"","周蓝","项目文件夹不存在"
"","梁晶","项目文件夹不存在"
"","刘洋","项目文件夹不存在"
"","阮会姗","项目文件夹不存在"
"","毛胤灿","项目文件夹不存在"
"","张斌","项目文件夹不存在"
"","王梦媛","项目文件夹不存在"
"","陈藏宇","项目文件夹不存在"
"","曾苗","项目文件夹不存在"
"","吴嘉杰","项目文件夹不存在"
"","邹昱夫","项目文件夹不存在"
"","Claudrick","项目文件夹不存在"
"","肖瀚","项目文件夹不存在"
"","张萌","项目文件夹不存在"
"","王芳华","项目文件夹不存在"
"","赵新阳","项目文件夹不存在"
"","佘思博","项目文件夹不存在"
"","王立杰","项目文件夹不存在"
"","武张浩","项目文件夹不存在"
"","江杰","项目文件夹不存在"
"","刘卫","项目文件夹不存在"
"","唐耀辉","项目文件夹不存在"
"","李谦","项目文件夹不存在"
"","李成龙","项目文件夹不存在"
"","袁双雄","项目文件夹不存在"
"","赵新宇","项目文件夹不存在"
"","黄文","项目文件夹不存在"
"","林滨","项目文件夹不存在"
"","张铃崎","项目文件夹不存在"
"","张皓钦","项目文件夹不存在"
"","袁骏","项目文件夹不存在"
"","吴俊杰","项目文件夹不存在"
"","蒋浩","项目文件夹不存在"

@ -0,0 +1,104 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>net.educoder</groupId>
<artifactId>ecsonar</artifactId>
<version>0.0.1</version>
<name>ecsonar</name>
<description>educoder sonar</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.8.1</version>
</dependency>
<!-- 引入poi解析workbook视图 -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.16</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.14</version>
</dependency>
<!-- 处理excel和上面功能是一样的-->
<dependency>
<groupId>net.sourceforge.jexcelapi</groupId>
<artifactId>jxl</artifactId>
<version>2.6.10</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>maven-aliyun</id>
<name>maven-aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</repository>
</repositories>
<!-- 设定插件仓库 -->
<pluginRepositories>
<pluginRepository>
<id>maven-aliyun</id>
<name>maven-aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</pluginRepository>
</pluginRepositories>
</project>

@ -0,0 +1,4 @@
cat post1.json | curl -H "Content-Type:application/json" -X POST -d @- http://localhost:8081/api/sonar
#单个代码文件检测
cat post1.json | curl -H "Content-Type:application/json" -X POST -d @- http://localhost:8081/api/sonarSingle

@ -0,0 +1,13 @@
package net.educoder.ecsonar;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class EcsonarApplication {
public static void main(String[] args) {
SpringApplication.run(EcsonarApplication.class, args);
}
}

@ -0,0 +1,17 @@
package net.educoder.ecsonar.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@Configuration
public class ThreadPoolConfig {
@Bean
public ExecutorService getThreadPool(){
return Executors.newFixedThreadPool(10);
}
}

@ -0,0 +1,44 @@
package net.educoder.ecsonar.controller;
import net.educoder.ecsonar.model.api.SonarRequest;
import net.educoder.ecsonar.services.EcsonarService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
@RestController
@RequestMapping("/api")
public class MainController {
private Logger log = LoggerFactory.getLogger(getClass());
@Autowired
EcsonarService ecsonarService;
@RequestMapping(value = "/sonar", method = RequestMethod.POST)
@CrossOrigin
public String sonar(@RequestBody SonarRequest sonarRequest) throws IOException {
log.info("sonar: {}", sonarRequest);
ecsonarService.sonar(sonarRequest);
return "success";
}
@RequestMapping(value = "/sonarSingle", method = RequestMethod.POST)
@CrossOrigin
public String sonarSingle(@RequestBody SonarRequest sonarRequest) throws IOException {
log.info("sonarSingle: {}", sonarRequest);
ecsonarService.sonarSingle(sonarRequest);
return "success";
}
@RequestMapping(value = "/fit", method = RequestMethod.GET)
public String fit(@RequestParam String fileName,
@RequestParam String homeworkId) throws Exception {
ecsonarService.fit(fileName, homeworkId);
return "success";
}
}

@ -0,0 +1,29 @@
package net.educoder.ecsonar.dao;
import net.educoder.ecsonar.model.Project;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
@Repository
@Mapper
public interface ProjectDao {
@Select("select * from projects where name = #{name}")
Project findByName(@Param("name")String name);
@Select("select COALESCE(value,0) from project_measures where component_uuid = #{uuid} and metric_id = 19 order by id desc limit 1")
Float getComplexity(@Param("uuid") String uuid);
@Select("select COALESCE(value,0) from project_measures where component_uuid = #{uuid} and metric_id = 1 order by id desc limit 1")
Integer getLines(@Param("uuid") String uuid);
@Select("select text_value from project_measures where component_uuid = #{uuid} and metric_id = #{metric_id} order by id desc limit 1")
String getLevel(@Param("uuid") String uuid, @Param("metric_id") int metric_id);
@Select("SELECT count(*) FROM issues where project_uuid=#{uuid} and " +
"status='OPEN' and issue_type=#{issue_type} and severity=#{severity}")
int getIndicator(@Param("uuid") String uuid, @Param("issue_type") int issue_type, @Param("severity") String severity);
}

@ -0,0 +1,190 @@
package net.educoder.ecsonar.model;
public class Metrics {
private String complexity;
private int lines;
//漏洞
private int block_violations;
private int critical_violations;
private int major_violations;
private int minor_violations;
private String violations;
//缺陷
private int block_bugs;
private int critical_bugs;
private int major_bugs;
private int minor_bugs;
private String bugs;
//代码风格
private int block_code_smells;
private int critical_code_smells;
private int major_code_smells;
private int minor_code_smells;
private String code_smells;
public String getComplexity() {
return complexity;
}
public void setComplexity(String complexity) {
this.complexity = complexity;
}
public int getLines() {
return lines;
}
public void setLines(int lines) {
this.lines = lines;
}
public int getBlock_violations() {
return block_violations;
}
public void setBlock_violations(int block_violations) {
this.block_violations = block_violations;
}
public int getCritical_violations() {
return critical_violations;
}
public void setCritical_violations(int critical_violations) {
this.critical_violations = critical_violations;
}
public int getMajor_violations() {
return major_violations;
}
public void setMajor_violations(int major_violations) {
this.major_violations = major_violations;
}
public int getMinor_violations() {
return minor_violations;
}
public void setMinor_violations(int minor_violations) {
this.minor_violations = minor_violations;
}
public String getViolations() {
return violations;
}
public void setViolations(String violations) {
this.violations = violations;
}
public int getBlock_bugs() {
return block_bugs;
}
public void setBlock_bugs(int block_bugs) {
this.block_bugs = block_bugs;
}
public int getCritical_bugs() {
return critical_bugs;
}
public void setCritical_bugs(int critical_bugs) {
this.critical_bugs = critical_bugs;
}
public int getMajor_bugs() {
return major_bugs;
}
public void setMajor_bugs(int major_bugs) {
this.major_bugs = major_bugs;
}
public int getMinor_bugs() {
return minor_bugs;
}
public void setMinor_bugs(int minor_bugs) {
this.minor_bugs = minor_bugs;
}
public String getBugs() {
return bugs;
}
public void setBugs(String bugs) {
this.bugs = bugs;
}
public int getBlock_code_smells() {
return block_code_smells;
}
public void setBlock_code_smells(int block_code_smells) {
this.block_code_smells = block_code_smells;
}
public int getCritical_code_smells() {
return critical_code_smells;
}
public void setCritical_code_smells(int critical_code_smells) {
this.critical_code_smells = critical_code_smells;
}
public int getMajor_code_smells() {
return major_code_smells;
}
public void setMajor_code_smells(int major_code_smells) {
this.major_code_smells = major_code_smells;
}
public int getMinor_code_smells() {
return minor_code_smells;
}
public void setMinor_code_smells(int minor_code_smells) {
this.minor_code_smells = minor_code_smells;
}
public String getCode_smells() {
return code_smells;
}
public void setCode_smells(String code_smells) {
this.code_smells = code_smells;
}
@Override
public String toString() {
return "Metrics{" +
"complexity='" + complexity + '\'' +
", lines=" + lines +
", block_violations=" + block_violations +
", critical_violations=" + critical_violations +
", major_violations=" + major_violations +
", minor_violations=" + minor_violations +
", violations='" + violations + '\'' +
", block_bugs=" + block_bugs +
", critical_bugs=" + critical_bugs +
", major_bugs=" + major_bugs +
", minor_bugs=" + minor_bugs +
", bugs='" + bugs + '\'' +
", block_code_smells=" + block_code_smells +
", critical_code_smells=" + critical_code_smells +
", major_code_smells=" + major_code_smells +
", minor_code_smells=" + minor_code_smells +
", code_smells='" + code_smells + '\'' +
'}';
}
}

@ -0,0 +1,43 @@
package net.educoder.ecsonar.model;
public class Project {
private int id;
private boolean enabled;
private String project_uuid;
private String name;
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getProject_uuid() {
return project_uuid;
}
public void setProject_uuid(String project_uuid) {
this.project_uuid = project_uuid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

@ -0,0 +1,41 @@
package net.educoder.ecsonar.model.api;
public class Person {
private String uid;
private String name;
private String downloadUrl;
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDownloadUrl() {
return downloadUrl;
}
public void setDownloadUrl(String downloadUrl) {
this.downloadUrl = downloadUrl;
}
@Override
public String toString() {
return "Person{" +
"uid='" + uid + '\'' +
", name='" + name + '\'' +
", downloadUrl='" + downloadUrl + '\'' +
'}';
}
}

@ -0,0 +1,13 @@
package net.educoder.ecsonar.model.api;
public class ResultRequest {
private int homeworkId;
public int getHomeworkId() {
return homeworkId;
}
public void setHomeworkId(int homeworkId) {
this.homeworkId = homeworkId;
}
}

@ -0,0 +1,34 @@
package net.educoder.ecsonar.model.api;
import java.util.List;
public class SonarRequest {
private int homeworkId;
private List<Person> personList;
public List<Person> getPersonList() {
return personList;
}
public void setPersonList(List<Person> personList) {
this.personList = personList;
}
public int getHomeworkId() {
return homeworkId;
}
public void setHomeworkId(int homeworkId) {
this.homeworkId = homeworkId;
}
@Override
public String toString() {
return "SonarRequest{" +
"homeworkId=" + homeworkId +
", personList=" + personList +
'}';
}
}

@ -0,0 +1,522 @@
package net.educoder.ecsonar.services;
import net.educoder.ecsonar.dao.ProjectDao;
import net.educoder.ecsonar.model.Metrics;
import net.educoder.ecsonar.model.Project;
import net.educoder.ecsonar.model.api.Person;
import net.educoder.ecsonar.model.api.SonarRequest;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
@Service
public class EcsonarService {
Logger log = LoggerFactory.getLogger(getClass());
@Autowired
private ExecutorService executorService;
@Autowired
ProjectDao projectDao;
@Autowired
SonarService sonarService;
@Autowired
ReportService reportService;
@Value("${zip.save.path}")
String zipSavePath;
@Value("${force.parse:false}")
boolean forceParse;
public static class Row {
public int i;
public Person person;
public String key;
}
public void sonar(SonarRequest sonarRequest) {
String zipUsePath = String.format("%s%d/", zipSavePath, sonarRequest.getHomeworkId());
if (!new File(zipUsePath).exists()) {
new File(zipUsePath).mkdir();
}
String csvPath = zipUsePath + String.format("%d.csv", sonarRequest.getHomeworkId());
List<String> uids = readAllUids(csvPath);
List<Row> rows = new ArrayList<>();
executorService.execute(() -> {
int i = 0;
for (Person person : sonarRequest.getPersonList()) {
i++;
//数据库如果有就不检测了
log.info("{}/{} 开始处理: {} ", i, sonarRequest.getPersonList().size(), person);
if (person.getDownloadUrl().startsWith("http")) {
try {
//毕业设计项目完整代码
String key = String.format("%d-%s", sonarRequest.getHomeworkId(), person.getUid());
if (forceParse || (!isChecked(uids, person.getUid())) ) {
Row row = new Row();
row.i = i;
row.key = key;
row.person = person;
rows.add(row);
if (isSonared(key)){
writeResult(csvPath, row.i, row.person, row.key, Boolean.FALSE);
} else {
sonarService.scan(
zipUsePath,
person.getDownloadUrl(),
sonarRequest.getHomeworkId(),
person.getUid(), 1);
//毕业设计项目个人开发代码
sonarService.scan(
zipUsePath,
person.getDownloadUrl(),
sonarRequest.getHomeworkId(),
person.getUid(),
2);
writeResult(csvPath, row.i, row.person, row.key, Boolean.FALSE);
}
}
} catch (Exception e) {
log.error("sonar scan error: ", e);
log.error("检测出错: {}-{}, 原因: {}",
person.getName(),
person.getUid(),
e.getMessage());
writeFailResult(csvPath, i, person, e.getMessage(), Boolean.FALSE);
}
} else {
log.error("未发现附件:{}", person);
writeFailResult(csvPath, i, person, "没有上传附件", Boolean.FALSE);
}
}
});
}
public void sonarSingle(SonarRequest sonarRequest) {
String codeUsePath = String.format("%s%d/", zipSavePath, sonarRequest.getHomeworkId());
if (!new File(codeUsePath).exists()) {
new File(codeUsePath).mkdir();
}
String csvPath = codeUsePath + String.format("%d.csv", sonarRequest.getHomeworkId());
List<String> uids = readAllUids(csvPath);
executorService.execute(() -> {
int i = 0;
for (Person person : sonarRequest.getPersonList()) {
i++;
log.info("{}/{} 开始处理: {} ", i, sonarRequest.getPersonList().size(), person);
if (person.getDownloadUrl().startsWith("http")) {
try {
String key = String.format("%d-%s", sonarRequest.getHomeworkId(), person.getUid());
if (forceParse || (!isChecked(uids, person.getUid())) ) {
Row row = new Row();
row.i = i;
row.key = key;
row.person = person;
if (isSonaredSingle(key)){
//数据库如果有就不检测直接写结果
writeResult(csvPath, row.i, row.person, row.key, Boolean.TRUE);
} else {
sonarService.scanSingle(
codeUsePath,
person.getDownloadUrl(),
sonarRequest.getHomeworkId(),
person.getUid(), key);
writeResult(csvPath, row.i, row.person, row.key, Boolean.TRUE);
}
}
} catch (Exception e) {
log.error("sonar scan error: ", e);
log.error("检测出错: {}-{}, 原因: {}",
person.getName(),
person.getUid(),
e.getMessage());
writeFailResult(csvPath, i, person, e.getMessage(), Boolean.TRUE);
}
} else {
log.error("未发现附件:{}", person);
writeFailResult(csvPath, i, person, "没有上传附件", Boolean.TRUE);
}
}
});
}
/**
* sonar
* @param key
* @return
*/
private boolean isSonared(String key) {
Project project = projectDao.findByName(key+"-2");
return project!=null;
}
private boolean isSonaredSingle(String key) {
Project project = projectDao.findByName(key);
return project!=null;
}
private void writeFailResult(String filePath, int i, Person person, String message, Boolean isSingle) {
try {
StringBuffer stringBuffer = getFailString(i, person, message, isSingle);
FileWriter fileWritter = new FileWriter(filePath, true);
fileWritter.write(stringBuffer.toString());
fileWritter.close();
} catch (Exception e) {
log.error("文件写入出错: {}-{}, 原因: {}",
person.getName(),
person.getUid(),
e.getMessage());
}
}
private StringBuffer getFailString(int i, Person person, String message, Boolean isSingle) {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(i);
stringBuffer.append(",");
stringBuffer.append(person.getUid());
stringBuffer.append(",");
stringBuffer.append(person.getName());
if (isSingle) {
stringBuffer.append(",,,,,,,,,,,,,,,,,,");
} else {
stringBuffer.append(",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,");
}
stringBuffer.append(message);
stringBuffer.append("\n");
return stringBuffer;
}
private void writeResult(String filePath, int i, Person person, String key, Boolean isSingle) {
try {
StringBuffer stringBuffer;
if (isSingle) {
stringBuffer = getSinglePersonLine(i, person, key);
} else {
stringBuffer = getPersonLine(i, person, key);
}
FileWriter fileWritter = new FileWriter(filePath, true);
fileWritter.write(stringBuffer.toString());
fileWritter.close();
} catch (Exception e) {
log.error("文件写入出错: {}-{}, 原因: {}",
person.getName(),
person.getUid(),
e.getMessage());
writeFailResult(filePath, i, person, e.getMessage(), isSingle);
}
}
private StringBuffer getSinglePersonLine(int i, Person person, String key) {
Metrics metrics = reportService.getMetrics(key);
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(i);
stringBuffer.append(",");
stringBuffer.append(person.getUid());
stringBuffer.append(",");
stringBuffer.append(person.getName());
stringBuffer.append(",");
stringBuffer.append(metrics.getBlock_bugs());
stringBuffer.append(",");
stringBuffer.append(metrics.getCritical_bugs());
stringBuffer.append(",");
stringBuffer.append(metrics.getMajor_bugs());
stringBuffer.append(",");
stringBuffer.append(metrics.getMinor_bugs());
stringBuffer.append(",");
stringBuffer.append(metrics.getBugs());
stringBuffer.append(",");
stringBuffer.append(metrics.getBlock_violations());
stringBuffer.append(",");
stringBuffer.append(metrics.getCritical_violations());
stringBuffer.append(",");
stringBuffer.append(metrics.getMajor_violations());
stringBuffer.append(",");
stringBuffer.append(metrics.getMinor_violations());
stringBuffer.append(",");
stringBuffer.append(metrics.getViolations());
stringBuffer.append(",");
stringBuffer.append(metrics.getBlock_code_smells());
stringBuffer.append(",");
stringBuffer.append(metrics.getCritical_code_smells());
stringBuffer.append(",");
stringBuffer.append(metrics.getMajor_violations());
stringBuffer.append(",");
stringBuffer.append(metrics.getMinor_code_smells());
stringBuffer.append(",");
stringBuffer.append(metrics.getCode_smells());
stringBuffer.append(",");
stringBuffer.append(metrics.getComplexity());
stringBuffer.append(",");
stringBuffer.append(metrics.getLines());
stringBuffer.append("\n");
return stringBuffer;
}
private StringBuffer getPersonLine(int i, Person person, String key) {
Metrics metrics = reportService.getMetrics(key + "-1");
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(i);
stringBuffer.append(",");
stringBuffer.append(person.getUid());
stringBuffer.append(",");
stringBuffer.append(person.getName());
stringBuffer.append(",");
stringBuffer.append(metrics.getBlock_bugs());
stringBuffer.append(",");
stringBuffer.append(metrics.getCritical_bugs());
stringBuffer.append(",");
stringBuffer.append(metrics.getMajor_bugs());
stringBuffer.append(",");
stringBuffer.append(metrics.getMinor_bugs());
stringBuffer.append(",");
stringBuffer.append(metrics.getBugs());
stringBuffer.append(",");
stringBuffer.append(metrics.getBlock_violations());
stringBuffer.append(",");
stringBuffer.append(metrics.getCritical_violations());
stringBuffer.append(",");
stringBuffer.append(metrics.getMajor_violations());
stringBuffer.append(",");
stringBuffer.append(metrics.getMinor_violations());
stringBuffer.append(",");
stringBuffer.append(metrics.getViolations());
stringBuffer.append(",");
stringBuffer.append(metrics.getBlock_code_smells());
stringBuffer.append(",");
stringBuffer.append(metrics.getCritical_code_smells());
stringBuffer.append(",");
stringBuffer.append(metrics.getMajor_violations());
stringBuffer.append(",");
stringBuffer.append(metrics.getMinor_code_smells());
stringBuffer.append(",");
stringBuffer.append(metrics.getCode_smells());
stringBuffer.append(",");
stringBuffer.append(metrics.getComplexity());
stringBuffer.append(",");
stringBuffer.append(metrics.getLines());
metrics = reportService.getMetrics(key + "-2");
stringBuffer.append(",");
stringBuffer.append(metrics.getBlock_bugs());
stringBuffer.append(",");
stringBuffer.append(metrics.getCritical_bugs());
stringBuffer.append(",");
stringBuffer.append(metrics.getMajor_bugs());
stringBuffer.append(",");
stringBuffer.append(metrics.getMinor_bugs());
stringBuffer.append(",");
stringBuffer.append(metrics.getBugs());
stringBuffer.append(",");
stringBuffer.append(metrics.getBlock_violations());
stringBuffer.append(",");
stringBuffer.append(metrics.getCritical_violations());
stringBuffer.append(",");
stringBuffer.append(metrics.getMajor_violations());
stringBuffer.append(",");
stringBuffer.append(metrics.getMinor_violations());
stringBuffer.append(",");
stringBuffer.append(metrics.getViolations());
stringBuffer.append(",");
stringBuffer.append(metrics.getBlock_code_smells());
stringBuffer.append(",");
stringBuffer.append(metrics.getCritical_code_smells());
stringBuffer.append(",");
stringBuffer.append(metrics.getMajor_violations());
stringBuffer.append(",");
stringBuffer.append(metrics.getMinor_code_smells());
stringBuffer.append(",");
stringBuffer.append(metrics.getCode_smells());
stringBuffer.append(",");
stringBuffer.append(metrics.getComplexity());
stringBuffer.append(",");
stringBuffer.append(metrics.getLines());
stringBuffer.append("\n");
return stringBuffer;
}
private boolean isChecked(List<String> uids, String uid) {
for (String s : uids) {
if (StringUtils.equals(s, uid)) {
return true;
}
}
return false;
}
/**
* uid
*
* @param csvPath
* @return
*/
private List<String> readAllUids(String csvPath) {
List<String> objects = new ArrayList<>();
if (!new File(csvPath).exists()) return objects;
try {
// 使用一个字符串集合来存储文本中的路径 也可用String []数组
FileInputStream fis = new FileInputStream(csvPath);
// 防止路径乱码 如果utf-8 乱码 改GBK eclipse里创建的txt 用UTF-8在电脑上自己创建的txt 用GBK
InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
BufferedReader br = new BufferedReader(isr);
String line = "";
while ((line = br.readLine()) != null) {
String[] split = line.split(",");
if (split.length > 1) {
objects.add(split[1]);
}
}
br.close();
isr.close();
fis.close();
} catch (Exception e) {
log.error("读取uids出错", e);
}
return objects;
}
/**
*
* @param fileName
*/
public void fit(String fileName, String homeworkId) throws Exception {
String filePath = String.format("%s%s", zipSavePath, fileName);
if(!new File(filePath).exists()){
throw new Exception("找不到文件:"+filePath);
}
List<String> lines = new ArrayList<>();
try {
// 使用一个字符串集合来存储文本中的路径 也可用String []数组
FileInputStream fis = new FileInputStream(filePath);
// 防止路径乱码 如果utf-8 乱码 改GBK eclipse里创建的txt 用UTF-8在电脑上自己创建的txt 用GBK
InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
BufferedReader br = new BufferedReader(isr);
String line = "";
while ((line = br.readLine()) != null) {
String[] split = line.split(",");
if (split.length<3){
continue;
}
Person person = new Person();
person.setUid(split[1]);
person.setName(split[2]);
int i = Integer.parseInt(split[0]);
String key = String.format("%s-%s", homeworkId, split[1]);
if (StringUtils.isNoneEmpty(split[3])) { //有结果
//修正结果
log.info("开始处理: {}", key);
StringBuffer stringBuffer = getPersonLine(
i,
person,
key
);
lines.add(stringBuffer.toString());
} else {
log.info("重新找查: {}", key);
try{
StringBuffer stringBuffer = getPersonLine(
i,
person,
key
);
lines.add(stringBuffer.toString());
} catch (Exception e){
StringBuffer failString = getFailString(i, person, split[split.length - 1], Boolean.FALSE);
lines.add(failString.toString());
}
}
}
br.close();
isr.close();
fis.close();
} catch (Exception e) {
log.error("读取uids出错", e);
}
//重新写正确结果
String newFilePath = String.format("%s%s.new", zipSavePath, fileName);
try {
FileWriter fileWritter = new FileWriter(newFilePath, true);
for (String line : lines) {
fileWritter.write(line);
}
fileWritter.close();
} catch (Exception e) {
log.error("文件写入出错 原因: {}",
e.getMessage());
}
}
}

@ -0,0 +1,236 @@
package net.educoder.ecsonar.services;
import net.educoder.ecsonar.dao.ProjectDao;
import net.educoder.ecsonar.model.Metrics;
import net.educoder.ecsonar.model.Project;
import net.educoder.ecsonar.utils.ExcelUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.IOException;
@Service
public class ReportService {
Logger log = LoggerFactory.getLogger(getClass());
@Autowired
ProjectDao projectDao;
/**
*
*
* @param name
* @return
*/
public Metrics getMetrics(String name) {
Project project = projectDao.findByName(name);
if (project==null){
return null;
}
String uuid = project.getProject_uuid();
Metrics metrics = new Metrics();
metrics.setComplexity(getComplexity(uuid));
metrics.setLines(getLines(uuid));
metrics.setBlock_bugs(getBlockBugs(uuid));
metrics.setBlock_code_smells(getBlockCodeSmells(uuid));
metrics.setBlock_violations(getBlockViolations(uuid));
metrics.setCritical_bugs(getCriticalBugs(uuid));
metrics.setCritical_code_smells(getCriticalCodeSmells(uuid));
metrics.setCritical_violations(getCriticalViolations(uuid));
metrics.setMajor_bugs(getMajorBugs(uuid));
metrics.setMajor_code_smells(getMajorCodeSmells(uuid));
metrics.setMajor_violations(getMajorViolations(uuid));
metrics.setMinor_bugs(getMinorBugs(uuid));
metrics.setMinor_code_smells(getMinorCodeSmells(uuid));
metrics.setMinor_violations(getMinorViolations(uuid));
metrics.setBugs(getBugs(uuid));
metrics.setViolations(getViolations(uuid));
metrics.setCode_smells(getCodeSmells(uuid));
return metrics;
}
/**
* excel
*
* @param metrics
*/
public void writeToExcel(String stuId, String name,
Metrics metrics, String excelPath, int index) throws IOException {
// ExcelUtil.writeMetrics(metrics, stuId, name, excelPath, index);
}
/**
*
*
* @return
*/
private String getComplexity(String uuid) {
Float num = projectDao.getComplexity(uuid);
if (num == null) {
return "0";
}
return "" + projectDao.getComplexity(uuid);
}
/**
*
*
* @return
*/
private int getLines(String uuid) {
Integer num = projectDao.getLines(uuid);
if (num == null) {
return 0;
}
return projectDao.getLines(uuid);
}
/**
* -
*
* @return
*/
private int getBlockViolations(String uuid) {
return projectDao.getIndicator(uuid, 3, "BLOCKER");
}
/**
* -
*
* @return
*/
private int getCriticalViolations(String uuid) {
return projectDao.getIndicator(uuid, 3, "CRITICAL");
}
/**
* -
*
* @return
*/
private int getMajorViolations(String uuid) {
return projectDao.getIndicator(uuid, 3, "MAJOR");
}
/**
* -
*
* @return
*/
private int getMinorViolations(String uuid) {
return projectDao.getIndicator(uuid, 3, "MINOR");
}
/**
* -
*
* @return
*/
private String getViolations(String uuid) {
//93
return projectDao.getLevel(uuid, 93);
}
/**
* -
*
* @return
*/
private int getBlockBugs(String uuid) {
return projectDao.getIndicator(uuid, 2, "BLOCKER");
}
/**
* -
*
* @return
*/
private int getCriticalBugs(String uuid) {
return projectDao.getIndicator(uuid, 2, "CRITICAL");
}
/**
* -
*
* @return
*/
private int getMajorBugs(String uuid) {
return projectDao.getIndicator(uuid, 2, "MAJOR");
}
/**
* -
*
* @return
*/
private int getMinorBugs(String uuid) {
return projectDao.getIndicator(uuid, 2, "MINOR");
}
/**
* -
*
* @return
*/
private String getBugs(String uuid) {
//89
return projectDao.getLevel(uuid, 89);
}
/**
* -
*
* @return
*/
private int getBlockCodeSmells(String uuid) {
return projectDao.getIndicator(uuid, 1, "BLOCKER");
}
/**
* -
*
* @return
*/
private int getCriticalCodeSmells(String uuid) {
return projectDao.getIndicator(uuid, 1, "CRITICAL");
}
/**
* -
*
* @return
*/
private int getMajorCodeSmells(String uuid) {
return projectDao.getIndicator(uuid, 1, "MAJOR");
}
/**
* -
*
* @return
*/
private int getMinorCodeSmells(String uuid) {
return projectDao.getIndicator(uuid, 1, "MINOR");
}
/**
* -
*
* @return
*/
private String getCodeSmells(String uuid) {
//80
return projectDao.getLevel(uuid, 80);
}
}

@ -0,0 +1,155 @@
package net.educoder.ecsonar.services;
import net.educoder.ecsonar.utils.SystemUtil;
import net.educoder.ecsonar.utils.UrlUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
@Service
public class SonarService {
private Logger log = LoggerFactory.getLogger(getClass());
@Value("${sonar.url}")
String sonarUrl;
@Value("${extract.path}")
String extractProgramPath;
/**
*
*
* @param zipUrl
*/
public String scan(String zipSavePath, String zipUrl, int homeworkId, String uid, int index) throws Exception {
String key = String.format("%d-%s", homeworkId, uid);
String[] split = StringUtils.split(zipUrl, "/");
String zipFilename = UrlUtil.getURLDecoderString(split[split.length - 1]);
String savePath = zipSavePath + zipFilename;
//1. 下载文件
// if (index==1) {
// download(zipUrl, savePath);
// }
//2. 解压目录
String extractPath = zipSavePath + key;
// if (index==1) {
// extract(savePath, extractPath);
// }
//3. 执行检测
String subPath = "/" + SystemUtil.executeAndGetExitStatus("cd " + extractPath + " && ls | head -1").getOutput();
// if (index != 1) {
// subPath += "/毕业设计项目个人开发代码";
//// subPath += "/个人";
// } else {
// subPath += "/毕业设计项目完整代码";
//// subPath += "/完整";
// }
log.info("scan zipSavePath: {}, zipFilename: {}, savePath: {}, extractPath: {}, subPath: {}", zipSavePath, zipFilename, savePath, extractPath, subPath);
if (!new File(extractPath + subPath).exists()){
throw new Exception("项目文件夹不存在");
}
key = String.format("%s-%d", key, index);
sonar(extractPath + subPath, key);
return key;
}
/**
*
*/
public String scanSingle(String codeSavePath, String codeUrl, int homeworkId, String uid, String key) throws Exception {
String[] split = StringUtils.split(codeUrl, "/");
String codeFilename = UrlUtil.getURLDecoderString(split[split.length - 1]);
String savePath = codeSavePath + codeFilename;
if (!new File(savePath).exists()) {
new File(savePath).mkdir();
}
// 代码文件后缀写死
String saveFile = savePath + File.separator + codeFilename + ".cpp";
// 下载文件
download(codeUrl, saveFile);
sonar(savePath, key);
return key;
}
private void sonar(String projectPath, String key) {
SystemUtil.executeAndGetExitStatus("sonar-scanner " +
"-Dsonar.host.url=" + sonarUrl + " " +
"-Dsonar.sourceEncoding=utf-8 " +
"-Dsonar.projectKey=" + key + " " +
"-Dsonar.java.binaries=./ "+
"-Dsonar.projectBaseDir=" + projectPath);
}
/**
* zip
*
* @param zipFile
*/
private void extract(String zipFile, String extractPath) throws Exception {
File extractFile = new File(extractPath);
if (extractFile.exists()){
extractFile.delete();
}
extractFile.mkdir();
SystemUtil.ExecuteResp executeResp = SystemUtil.executeAndGetExitStatus("cd "
+ extractPath
+ " && "+extractProgramPath+" -encoding GBK " + zipFile);
}
/**
*
*
* @param zipUrl
*/
private void download(String zipUrl, String zipPath) throws IOException {
log.info("下载文件: {}-{}", zipUrl, zipPath);
String cookie = "SL_GWPT_Show_Hide_tmp=1; SL_wptGlobTipTmp=1; autologin_trustie=69dd2e4d0d8c72c7c2e4333f4dd071131f903bf8; UM_distinctid=17975a9ac5591a-0bc2d36ddb4a99-113d6055-fa000-17975a9ac56663; Hm_lvt_871c0ce6df9548f77095372950e14e56=1620798873,1621317930; _educoder_session=007087d500b90f50cc574d80ddb95c3a; Hm_lpvt_871c0ce6df9548f77095372950e14e56=1621319115";
URL url = new URL(zipUrl);
URLConnection conn = url.openConnection();
conn.setRequestProperty("Cookie", cookie);
conn.setDoInput(true);
try (BufferedInputStream in = new BufferedInputStream(conn.getInputStream());
FileOutputStream fileOutputStream = new FileOutputStream(zipPath)) {
byte dataBuffer[] = new byte[1024];
int bytesRead;
while ((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) {
fileOutputStream.write(dataBuffer, 0, bytesRead);
}
} catch (IOException e) {
log.error("文件下载失败: {}-{}", zipUrl, zipPath);
throw e;
}
}
}

@ -0,0 +1,160 @@
package net.educoder.ecsonar.utils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.ZoneId;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
/**
* mapper.stylefeng.guns.modular.lendchain.utils
*
*
* dell
* 2018/5/22 11:53
*/
public class DateUtils {
/**
*
* @param date
* @param days
* @return
*/
public static final Integer addDays(Integer date ,Integer days){
int resultDate = 0;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
try {
Date date2 = simpleDateFormat.parse(date.toString());
Calendar calendar = Calendar.getInstance();
calendar.setTime(date2);
calendar.add(Calendar.DATE,days);
resultDate = Integer.valueOf(simpleDateFormat.format(calendar.getTime().getTime()));
} catch (ParseException e) {
e.printStackTrace();
}
return resultDate;
}
public static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
//获取年月日时分(H24小时制h12小时制)
public static SimpleDateFormat dateFormat2 = new SimpleDateFormat("yyyyMMddHHmm");
//获取秒
public static SimpleDateFormat dateFormat3 = new SimpleDateFormat("ss");
/**
* @Description:
* @Method:
* @Param:
* @return:
* @throws:
* @Author:
* @Date: 2018/5/22 9:47
*/
public static Long getStartTime(){
long startTime = (System.currentTimeMillis()/86400000 )*86400000 - 8*60*60*1000;
return startTime / 1000;
}
/**
* @Description:
* @Method:
* @Param:
* @return:
* @throws:
* @Author:
* @Date: 2018/5/22 9:47
*/
public static Long getEndTime(){
long endTime = (System.currentTimeMillis()/86400000 )*86400000 - 8*60*60*1000 + 86400000;
return endTime / 1000;
}
/**
* Unix
* @param unixTimestamp
* @return
*/
public static String formatDate(Integer unixTimestamp){
return getDateByTimestamp(unixTimestamp,"yyyy-MM-dd HH:mm:ss","Asia/Shanghai");
}
public static String formatDate(Date date){
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss");
ZoneId zid = ZoneId.of("Asia/Shanghai");
sd.setTimeZone(TimeZone.getTimeZone(zid));
return sd.format(date);
}
/**
* Unix
* @param unixTimestamp
* @param format
* @return
*/
public static String formatDate(Integer unixTimestamp,String format){
return getDateByTimestamp(unixTimestamp,format,"Asia/Shanghai");
}
/**
* Unix
* @param unixTimestamp
* @param format
* @param zone
* @return
*/
public static String getDateByTimestamp(Integer unixTimestamp, String format, String zone){
SimpleDateFormat sd = new SimpleDateFormat(format);
ZoneId zid = ZoneId.of(zone);
sd.setTimeZone(TimeZone.getTimeZone(zid));
Long create_time = ((long)unixTimestamp)* 1000;
return sd.format(new Date(create_time));
}
/**
*
* @param timestamp
* @param minutes
* @return
*/
public static final String addMinutes(String timestamp ,Integer minutes){
String resultDate = "";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
try {
Date date2 = simpleDateFormat.parse(timestamp);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date2);
calendar.add(Calendar.MINUTE,minutes);
resultDate = simpleDateFormat.format(calendar.getTime().getTime());
} catch (ParseException e) {
e.printStackTrace();
}
return resultDate;
}
public static final String addMin(String timestamp ,Integer minutes){
String resultDate = "";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
try {
Date date2 = simpleDateFormat.parse(timestamp);
System.out.println("格式化后的日期为:"+date2);
resultDate = String.valueOf(date2.getTime()/1000);
} catch (ParseException e) {
e.printStackTrace();
}
return resultDate;
}
}

@ -0,0 +1,225 @@
package net.educoder.ecsonar.utils;
import net.educoder.ecsonar.model.Metrics;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.*;
import java.util.List;
import java.util.Map;
public class ExcelUtil {
private static final String EXCEL_XLS = "xls";
private static final String EXCEL_XLSX = "xlsx";
/**
*
*
* @param excelPath
* @param uid
* @return
*/
public static boolean isChecked(String excelPath, String uid) {
try {
File finalXlsxFile = new File(excelPath);
Workbook workBook = getWorkbok(finalXlsxFile);
Sheet sheet = workBook.getSheetAt(0);
int rowNumber = sheet.getLastRowNum();
for (int i = 0; i < rowNumber + 1; ++i) {
Row row = sheet.getRow(3 + i);
Cell cell = row.getCell(1);
cell.setCellType(Cell.CELL_TYPE_STRING);
if (StringUtils.equals(cell.getStringCellValue(), uid)) {
return true;
}
}
} catch (Exception e) {
return false;
}
return false;
}
public static Workbook openExcel(String excelPath) throws IOException {
// 读取Excel文档
File finalXlsxFile = new File(excelPath);
Workbook workBook = getWorkbok(finalXlsxFile);
return workBook;
}
public static void writeMetrics(Metrics metrics, String uid,
String name,
Workbook workBook, int index) throws IOException {
// sheet 对应一个工作页
Sheet sheet = workBook.getSheetAt(0);
/**
*
*/
int rowNumber = sheet.getLastRowNum(); // 第一行从0开始算
//从第三行开始
Row newRow = null;
for (int i = 0; i < rowNumber+1; ++i) {
Row row = sheet.getRow(i);
if (row != null) {
Cell cell = row.getCell(1);
cell.setCellType(Cell.CELL_TYPE_STRING);
if (StringUtils.isEmpty(cell.getStringCellValue())
|| StringUtils.equals(cell.getStringCellValue(), uid)) {
newRow = row;
break;
}
}
}
if (newRow == null) {
newRow = sheet.createRow(rowNumber+1);
}
//一直往下找,直到找到空的,或者与学号匹配的行,进行写入
//学号
Cell uidCell = newRow.createCell(1);
uidCell.setCellType(Cell.CELL_TYPE_STRING);
uidCell.setCellValue(uid);
Cell cell2 = newRow.createCell(2);
cell2.setCellType(Cell.CELL_TYPE_STRING);
cell2.setCellValue(name);
int offset = 0;
if (index == 2) {
offset = 17;
}
Cell cell3 = newRow.createCell(3 + offset);
cell3.setCellType(Cell.CELL_TYPE_NUMERIC);
cell3.setCellValue(metrics.getBlock_bugs());
Cell cell4 = newRow.createCell(4 + offset);
cell4.setCellType(Cell.CELL_TYPE_NUMERIC);
cell4.setCellValue(metrics.getCritical_bugs());
cell4 = newRow.createCell(5 + offset);
cell4.setCellType(Cell.CELL_TYPE_NUMERIC);
cell4.setCellValue(metrics.getMajor_bugs());
cell4 = newRow.createCell(6 + offset);
cell4.setCellType(Cell.CELL_TYPE_NUMERIC);
cell4.setCellValue(metrics.getMinor_bugs());
cell4 = newRow.createCell(7 + offset);
cell4.setCellType(Cell.CELL_TYPE_STRING);
cell4.setCellValue(metrics.getBugs());
cell4 = newRow.createCell(8 + offset);
cell4.setCellType(Cell.CELL_TYPE_NUMERIC);
cell4.setCellValue(metrics.getBlock_violations());
cell4 = newRow.createCell(9 + offset);
cell4.setCellType(Cell.CELL_TYPE_NUMERIC);
cell4.setCellValue(metrics.getCritical_violations());
cell4 = newRow.createCell(10 + offset);
cell4.setCellType(Cell.CELL_TYPE_NUMERIC);
cell4.setCellValue(metrics.getMajor_violations());
cell4 = newRow.createCell(11 + offset);
cell4.setCellType(Cell.CELL_TYPE_NUMERIC);
cell4.setCellValue(metrics.getMinor_violations());
cell4 = newRow.createCell(12 + offset);
cell4.setCellType(Cell.CELL_TYPE_STRING);
cell4.setCellValue(metrics.getViolations());
cell4 = newRow.createCell(13 + offset);
cell4.setCellType(Cell.CELL_TYPE_NUMERIC);
cell4.setCellValue(metrics.getBlock_code_smells());
cell4 = newRow.createCell(14 + offset);
cell4.setCellType(Cell.CELL_TYPE_NUMERIC);
cell4.setCellValue(metrics.getCritical_code_smells());
cell4 = newRow.createCell(15 + offset);
cell4.setCellType(Cell.CELL_TYPE_NUMERIC);
cell4.setCellValue(metrics.getMajor_violations());
cell4 = newRow.createCell(16 + offset);
cell4.setCellType(Cell.CELL_TYPE_NUMERIC);
cell4.setCellValue(metrics.getMinor_code_smells());
cell4 = newRow.createCell(17 + offset);
cell4.setCellType(Cell.CELL_TYPE_STRING);
cell4.setCellValue(metrics.getCode_smells());
cell4 = newRow.createCell(18 + offset);
cell4.setCellType(Cell.CELL_TYPE_NUMERIC);
cell4.setCellValue(metrics.getComplexity());
cell4 = newRow.createCell(19 + offset);
cell4.setCellType(Cell.CELL_TYPE_NUMERIC);
cell4.setCellValue(metrics.getLines());
}
public static void saveExcel(Workbook workBook, String excelPath) throws Exception {
FileOutputStream out = null;
try {
out = new FileOutputStream(excelPath);
workBook.write(out);
} finally {
try {
if (out != null) {
out.flush();
out.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* Excel,Workbook
*
* @return
* @throws IOException
*/
public static Workbook getWorkbok(File file) throws IOException {
Workbook wb = null;
FileInputStream in = new FileInputStream(file);
if (file.getName().endsWith(EXCEL_XLS)) { //Excel&nbsp;2003
wb = new HSSFWorkbook(in);
} else if (file.getName().endsWith(EXCEL_XLSX)) { // Excel 2007/2010
wb = new XSSFWorkbook(in);
}
return wb;
}
// 去读Excel的方法readExcel该方法的入口参数为一个File对象
public List readExcel(File file) {
return null;
}
}

@ -0,0 +1,33 @@
package net.educoder.ecsonar.utils;
import java.io.*;
public class FileUtil {
public static String readFile(String fileName) {
String encoding = "UTF-8";
File file = new File(fileName);
Long filelength = file.length();
byte[] filecontent = new byte[filelength.intValue()];
try {
FileInputStream in = new FileInputStream(file);
in.read(filecontent);
in.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
try {
return new String(filecontent, encoding);
} catch (UnsupportedEncodingException e) {
System.err.println("The OS does not support " + encoding);
e.printStackTrace();
return null;
}
}
}

@ -0,0 +1,76 @@
package net.educoder.ecsonar.utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.concurrent.ExecutorService;
/**
* Created by guange on 26/02/2017.
*/
public class SystemUtil {
private static final Logger logger = LoggerFactory.getLogger(SystemUtil.class);
private static ExecutorService executor;
public static class ExecuteResp{
int status;
String output;
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public String getOutput() {
return output;
}
public void setOutput(String output) {
this.output = output;
}
}
/**
* 退
*/
public static ExecuteResp executeAndGetExitStatus(String command) {
ExecuteResp resp = new ExecuteResp();
logger.debug("execute: {}", command);
StringBuffer out = new StringBuffer();
Integer exitStatus = -1;
ProcessBuilder pb = new ProcessBuilder(new String[]{"/bin/sh", "-c", command});
pb.redirectErrorStream(true);
try {
Process process = pb.start();
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
out.append(line);
out.append(System.getProperty("line.separator"));
}
exitStatus = process.waitFor();
} catch (Exception e) {
e.printStackTrace();
logger.info("executeAndGetExitStatus: {}", command);
logger.error("executeAndGetExitStatus: ",e);
}
logger.debug("out: {}", out.toString());
resp.setOutput(out.toString().trim());
resp.setStatus(exitStatus);
return resp;
}
}

@ -0,0 +1,73 @@
package net.educoder.ecsonar.utils;
import java.io.UnsupportedEncodingException;
/**
* url
*
* @author lifq
* @date 2015-3-17 04:09:35
*/
public class UrlUtil {
private final static String ENCODE = "UTF8";
/**
* URL
*
* @return String
* @author lifq
* @date 2015-3-17 04:09:51
*/
public static String getURLDecoderString(String str) {
String result = "";
if (null == str) {
return "";
}
try {
result = java.net.URLDecoder.decode(str, ENCODE);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return result;
}
/**
* URL
*
* @return String
* @author lifq
* @date 2015-3-17 04:10:28
*/
public static String getURLEncoderString(String str) {
String result = "";
if (null == str) {
return "";
}
try {
result = java.net.URLEncoder.encode(str, ENCODE);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return result;
}
/**
*
* @return void
* @author lifq
* @date 2015-3-17 04:09:16
*/
public static void main(String[] args) {
//System.out.println(getURLDecoderString("15408100208-%E8%B0%A2%E9%91%AB-%E6%9C%AC%E7%A7%91%E6%AF%95%E4%B8%9A%E8%AE%BE%E8%AE%A1%E4%BB%A3%E7%A0%81"));
long startTime = System.currentTimeMillis();
long endTime = startTime + 6000;
long index = 0;
while(true){
double x = Math.sqrt(index);
long now = System.currentTimeMillis();
if (now > endTime) {
break;
}
index++;
}
System.out.println(index+" Loops in 6 seconds");
}
}

Binary file not shown.

Binary file not shown.

@ -0,0 +1,37 @@
#spring.datasource.url=jdbc:postgresql://127.0.0.1:5432/sonar
spring.datasource.url=jdbc:postgresql://117.50.14.123:5432/sonar
spring.datasource.username=sonar
spring.datasource.password=sonar
spring.datasource.driver-class-name=org.postgresql.Driver
# Hikari will use the above plus the following to setup connection pooling
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.hikari.minimum-idle=5
spring.datasource.hikari.maximum-pool-size=15
spring.datasource.hikari.auto-commit=true
spring.datasource.hikari.idle-timeout=30000
spring.datasource.hikari.pool-name=DatebookHikariCP
spring.datasource.hikari.max-lifetime=1800000
spring.datasource.hikari.connection-timeout=30000
spring.datasource.hikari.connection-test-query=SELECT 1
logging.config=classpath:logback-spring.xml
logging.level.root=DEBUG
zip.save.path=/tmp/
#excel.template.path=/Users/guange/work/java/ecsonar/src/main/resources/template.xlsx
excel.template.path=/Users/macbookpro/IdeaProjects/p9vymrkc8/src/main/resources/template.xlsx
#sonar.url=http://127.0.0.1:9000
sonar.url=http://117.50.14.123:9000
extract.path=/usr/bin/unar
last.run.id=0
skip.checked=true
server.port=8081

@ -0,0 +1,42 @@
<?xml version="1.0"?>
<configuration>
<!-- 彩色日志 -->
<!-- 彩色日志依赖的渲染类 -->
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
<conversionRule conversionWord="wEx"
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
<!-- 彩色日志格式 -->
<property name="CONSOLE_LOG_PATTERN"
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}" />
<!-- Console 输出设置 -->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
<charset>utf8</charset>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>debug</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>NEUTRAL</onMismatch>
</filter>
</appender>
<!--输出到文件-->
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>/tmp/ecsonar.%d{yyyy-MM-dd}.log</fileNamePattern>
</rollingPolicy>
<encoder>
<pattern>%d{HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="file" />
</root>
</configuration>

Binary file not shown.

@ -0,0 +1,54 @@
package net.educoder.ecsonar;
import net.educoder.ecsonar.dao.ProjectDao;
import net.educoder.ecsonar.model.Metrics;
import net.educoder.ecsonar.model.Project;
import net.educoder.ecsonar.services.ReportService;
import net.educoder.ecsonar.services.SonarService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.io.IOException;
@RunWith(SpringRunner.class)
@SpringBootTest
public class EcsonarApplicationTests {
@Autowired
ProjectDao projectDao;
@Autowired
SonarService sonarService;
@Autowired
ReportService reportService;
@Test
public void contextLoads() {
Project demo_maven_webapp = projectDao.findByName("demo Maven Webapp");
System.out.println(demo_maven_webapp.getProject_uuid());
}
@Test
public void testScan() throws Exception {
sonarService.scan(
"",
"http://office.cn-gd.ufileos.com/2015962121-%E6%AF%9B%E8%83%A4%E7%81%BF-%E6%9C%AC%E7%A7%91%E6%AF%95%E4%B8%9A%E8%AE%BE%E8%AE%A1%E4%BB%A3%E7%A0%81.zip",
1111,
"1234",
1);
}
@Test
public void testReport() throws IOException {
Metrics hello = reportService.getMetrics("hello");
reportService.writeToExcel("111111111",
"11",
hello,
"/tmp/11.xlsx",
1);
}
}

@ -0,0 +1,18 @@
File.open('error.csv', 'a+') do |f|
File.open('out.log').each do |line|
if line.start_with? "检测出错"
m = /检测出错: (.*), 原因: (.*)/.match(line)
puts "\"\",\"#{m[1]}\",\"#{m[2]}\""
f.puts "\"\",\"#{m[1]}\",\"#{m[2]}\""
elsif line.start_with? "未发现附件"
m = /(.+?)Person{uid='(.*)', name='(.*)', downloadUrl=''}/.match(line)
puts "\"#{m[2]}\",\"#{m[3]}\",\"#{m[1]}\""
f.puts "\"#{m[2]}\",\"#{m[3]}\",\"#{m[1]}\""
end
end
end
Loading…
Cancel
Save