Commit 99e42dcd91423eed4057d587486a6d2fdc3b8480

Authored by yiming
1 parent ba9b2765

处理打包和jdk冲突

@@ -190,6 +190,10 @@ @@ -190,6 +190,10 @@
190 <groupId>org.apache.xmlgraphics</groupId> 190 <groupId>org.apache.xmlgraphics</groupId>
191 <artifactId>batik-js</artifactId> 191 <artifactId>batik-js</artifactId>
192 </exclusion> 192 </exclusion>
  193 + <exclusion>
  194 + <groupId>javassist</groupId>
  195 + <artifactId>javassist</artifactId>
  196 + </exclusion>
193 </exclusions> 197 </exclusions>
194 </dependency> 198 </dependency>
195 <dependency> 199 <dependency>
src/main/java/com/bsth/data/commonData/SyncData.java
@@ -91,7 +91,7 @@ public class SyncData extends Thread{ @@ -91,7 +91,7 @@ public class SyncData extends Thread{
91 @Autowired 91 @Autowired
92 BasicData.BasicDataLoader basicDataLoader; 92 BasicData.BasicDataLoader basicDataLoader;
93 93
94 - @Scheduled(cron = "0 0/1 * * * ?") 94 + @Scheduled(cron = "0 1 * * * ?")
95 @Transactional() 95 @Transactional()
96 public void SyncData(){ 96 public void SyncData(){
97 syncBusiness(); 97 syncBusiness();
src/main/java/com/bsth/data/jddzx/JDInterface.java
@@ -103,7 +103,6 @@ public class JDInterface { @@ -103,7 +103,6 @@ public class JDInterface {
103 //人员投入 103 //人员投入
104 int jhrytl=culateService.culateJhry(schList,""); 104 int jhrytl=culateService.culateJhry(schList,"");
105 int sjrytl=culateService.culateSjry(schList,""); 105 int sjrytl=culateService.culateSjry(schList,"");
106 -<<<<<<< HEAD  
107 BigDecimal rytlbfb=BigDecimal.valueOf(100); 106 BigDecimal rytlbfb=BigDecimal.valueOf(100);
108 if(jhrytl>0){ 107 if(jhrytl>0){
109 rytlbfb=BigDecimal.valueOf((double)sjrytl/jhrytl*100); 108 rytlbfb=BigDecimal.valueOf((double)sjrytl/jhrytl*100);
@@ -113,13 +112,6 @@ public class JDInterface { @@ -113,13 +112,6 @@ public class JDInterface {
113 rytl.put("sjrytl",sjrytl); 112 rytl.put("sjrytl",sjrytl);
114 rytl.put("rytl",rytlbfb.setScale(2,BigDecimal.ROUND_HALF_UP)); 113 rytl.put("rytl",rytlbfb.setScale(2,BigDecimal.ROUND_HALF_UP));
115 data.put("rytl",rytl); 114 data.put("rytl",rytl);
116 -=======  
117 - BigDecimal rytl=BigDecimal.valueOf(100);  
118 - if(jhrytl>0){  
119 - rytl=BigDecimal.valueOf((double)sjrytl/jhrytl*100);  
120 - }  
121 - data.put("rytl",rytl.setScale(2,BigDecimal.ROUND_HALF_UP));  
122 ->>>>>>> origin/jdsfx  
123 115
124 //车辆投入 116 //车辆投入
125 Map<String,Object> cltl=new HashMap<>(); 117 Map<String,Object> cltl=new HashMap<>();
@@ -129,11 +121,8 @@ public class JDInterface { @@ -129,11 +121,8 @@ public class JDInterface {
129 if(jh_z>0){ 121 if(jh_z>0){
130 cltl_z=BigDecimal.valueOf((double)sj_z/jh_z*100); 122 cltl_z=BigDecimal.valueOf((double)sj_z/jh_z*100);
131 } 123 }
132 -<<<<<<< HEAD  
133 cltl.put("jh_z",jh_z); 124 cltl.put("jh_z",jh_z);
134 cltl.put("sj_z",sj_z); 125 cltl.put("sj_z",sj_z);
135 -=======  
136 ->>>>>>> origin/jdsfx  
137 cltl.put("cltl_z",cltl_z.setScale(2,BigDecimal.ROUND_HALF_UP)); 126 cltl.put("cltl_z",cltl_z.setScale(2,BigDecimal.ROUND_HALF_UP));
138 127
139 int jh_w=culateService.culateJhcl(schList,"wgf"); 128 int jh_w=culateService.culateJhcl(schList,"wgf");
@@ -142,11 +131,8 @@ public class JDInterface { @@ -142,11 +131,8 @@ public class JDInterface {
142 if(jh_w>0){ 131 if(jh_w>0){
143 cltl_w=BigDecimal.valueOf((double)sj_w/jh_w*100); 132 cltl_w=BigDecimal.valueOf((double)sj_w/jh_w*100);
144 } 133 }
145 -<<<<<<< HEAD  
146 cltl.put("jh_w",jh_w); 134 cltl.put("jh_w",jh_w);
147 cltl.put("sj_w",sj_w); 135 cltl.put("sj_w",sj_w);
148 -=======  
149 ->>>>>>> origin/jdsfx  
150 cltl.put("cltl_w",cltl_w.setScale(2,BigDecimal.ROUND_HALF_UP)); 136 cltl.put("cltl_w",cltl_w.setScale(2,BigDecimal.ROUND_HALF_UP));
151 137
152 int jh_q=culateService.culateJhcl(schList,""); 138 int jh_q=culateService.culateJhcl(schList,"");
@@ -155,11 +141,8 @@ public class JDInterface { @@ -155,11 +141,8 @@ public class JDInterface {
155 if(jh_q>0){ 141 if(jh_q>0){
156 cltl_q=BigDecimal.valueOf((double)sj_q/jh_q*100); 142 cltl_q=BigDecimal.valueOf((double)sj_q/jh_q*100);
157 } 143 }
158 -<<<<<<< HEAD  
159 cltl.put("jh_q",jh_q); 144 cltl.put("jh_q",jh_q);
160 cltl.put("sj_q",sj_q); 145 cltl.put("sj_q",sj_q);
161 -=======  
162 ->>>>>>> origin/jdsfx  
163 cltl.put("cltl_q",cltl_q.setScale(2,BigDecimal.ROUND_HALF_UP)); 146 cltl.put("cltl_q",cltl_q.setScale(2,BigDecimal.ROUND_HALF_UP));
164 147
165 data.put("cltl",cltl); 148 data.put("cltl",cltl);
@@ -172,11 +155,8 @@ public class JDInterface { @@ -172,11 +155,8 @@ public class JDInterface {
172 if(jhbctl_z>0){ 155 if(jhbctl_z>0){
173 bctl_z=BigDecimal.valueOf((double)sjbctl_z/jhbctl_z*100); 156 bctl_z=BigDecimal.valueOf((double)sjbctl_z/jhbctl_z*100);
174 } 157 }
175 -<<<<<<< HEAD  
176 bctl.put("jhbctl_z",jhbctl_z); 158 bctl.put("jhbctl_z",jhbctl_z);
177 bctl.put("sjbctl_z",sjbctl_z); 159 bctl.put("sjbctl_z",sjbctl_z);
178 -=======  
179 ->>>>>>> origin/jdsfx  
180 bctl.put("bctl_z",bctl_z.setScale(2,BigDecimal.ROUND_HALF_UP)); 160 bctl.put("bctl_z",bctl_z.setScale(2,BigDecimal.ROUND_HALF_UP));
181 161
182 int jhbctl_w=culateService.culateJhbc(schList,"wgf"); 162 int jhbctl_w=culateService.culateJhbc(schList,"wgf");
@@ -185,11 +165,8 @@ public class JDInterface { @@ -185,11 +165,8 @@ public class JDInterface {
185 if(jhbctl_w>0){ 165 if(jhbctl_w>0){
186 bctl_w=BigDecimal.valueOf((double)sjbctl_w/jhbctl_w*100); 166 bctl_w=BigDecimal.valueOf((double)sjbctl_w/jhbctl_w*100);
187 } 167 }
188 -<<<<<<< HEAD  
189 bctl.put("jhbctl_w",jhbctl_w); 168 bctl.put("jhbctl_w",jhbctl_w);
190 bctl.put("sjbctl_w",sjbctl_w); 169 bctl.put("sjbctl_w",sjbctl_w);
191 -=======  
192 ->>>>>>> origin/jdsfx  
193 bctl.put("bctl_w",bctl_w.setScale(2,BigDecimal.ROUND_HALF_UP)); 170 bctl.put("bctl_w",bctl_w.setScale(2,BigDecimal.ROUND_HALF_UP));
194 171
195 int jhbctl_q=culateService.culateJhbc(schList,""); 172 int jhbctl_q=culateService.culateJhbc(schList,"");
@@ -198,11 +175,8 @@ public class JDInterface { @@ -198,11 +175,8 @@ public class JDInterface {
198 if(jhbctl_q>0){ 175 if(jhbctl_q>0){
199 bctl_q=BigDecimal.valueOf((double)sjbctl_q/jhbctl_q*100); 176 bctl_q=BigDecimal.valueOf((double)sjbctl_q/jhbctl_q*100);
200 } 177 }
201 -<<<<<<< HEAD  
202 bctl.put("jhbctl_q",jhbctl_q); 178 bctl.put("jhbctl_q",jhbctl_q);
203 bctl.put("sjbctl_q",sjbctl_q); 179 bctl.put("sjbctl_q",sjbctl_q);
204 -=======  
205 ->>>>>>> origin/jdsfx  
206 bctl.put("bctl_q",bctl_q.setScale(2,BigDecimal.ROUND_HALF_UP)); 180 bctl.put("bctl_q",bctl_q.setScale(2,BigDecimal.ROUND_HALF_UP));
207 181
208 data.put("bctl",bctl); 182 data.put("bctl",bctl);
src/main/resources/fatso/handle_real_ctl.js
@@ -5,8 +5,7 @@ var fs = require(&#39;fs&#39;) @@ -5,8 +5,7 @@ var fs = require(&#39;fs&#39;)
5 , cheerio = require('cheerio') 5 , cheerio = require('cheerio')
6 , minifier = require('./minifier') 6 , minifier = require('./minifier')
7 , crypto = require("crypto") 7 , crypto = require("crypto")
8 - , CleanCSS = require('clean-css')  
9 - , UglifyJS = require("uglify-js"); 8 + , CleanCSS = require('clean-css');
10 ; 9 ;
11 10
12 var platform = process.platform; 11 var platform = process.platform;
@@ -152,7 +151,7 @@ var handleJs = function ($, file, cb) { @@ -152,7 +151,7 @@ var handleJs = function ($, file, cb) {
152 (function () { 151 (function () {
153 if (index >= ks.length) { 152 if (index >= ks.length) {
154 write(file, $.html()); 153 write(file, $.html());
155 - console.log(file + ' 结束'.green); 154 + console.log(file + ' 结束'); // 移除.green调用
156 cb && cb(); 155 cb && cb();
157 return; 156 return;
158 } 157 }
@@ -160,25 +159,38 @@ var handleJs = function ($, file, cb) { @@ -160,25 +159,38 @@ var handleJs = function ($, file, cb) {
160 index++; 159 index++;
161 var f = arguments.callee; 160 var f = arguments.callee;
162 //合并压缩js 161 //合并压缩js
163 - var result = UglifyJS.minify(jsMap[k]);  
164 - var data = result.code;  
165 - var fName = (k + '_' + md5(data)) + '.js';  
166 - //写入 assets js 目录下  
167 - var descFile = dest + _static + sp + 'real_control_v2'+sp+'assets'+sp+'js' + sp + fName;  
168 - fs.open(descFile, 'a', function (err, fd) {  
169 -  
170 - fs.write(fd, data, function () {  
171 - var tag = '<script src="/real_control_v2/assets/js/' + fName + '"></script>';  
172 - if ($('body').length > 0)  
173 - $('body').append(tag);  
174 - else {  
175 - //没有body 就写在尾部  
176 - $('*').last().after(tag);  
177 - }  
178 - console.log(k + ' js', '结束,下一个');  
179 - f(); 162 + try {
  163 + // 先合并文件内容
  164 + let code = '';
  165 + for(let j = 0; j < jsMap[k].length; j++) {
  166 + code += fs.readFileSync(jsMap[k][j], 'utf8') + '\n';
  167 + }
  168 + // 使用Terser压缩
  169 + var data = minifier.mini(code);
  170 + if (code !== '' && data === '') {
  171 + console.error('压缩出错')
  172 + process.exit();
  173 + }
  174 + var fName = (k + '_' + md5(data)) + '.js';
  175 + //写入 assets js 目录下
  176 + var descFile = dest + _static + sp + 'real_control_v2'+sp+'assets'+sp+'js' + sp + fName;
  177 + fs.open(descFile, 'a', function (err, fd) {
  178 + fs.write(fd, data, function () {
  179 + var tag = '<script src="/real_control_v2/assets/js/' + fName + '"></script>';
  180 + if ($('body').length > 0)
  181 + $('body').append(tag);
  182 + else {
  183 + //没有body 就写在尾部
  184 + $('*').last().after(tag);
  185 + }
  186 + console.log(k + ' js', '结束,下一个');
  187 + f();
  188 + });
180 }); 189 });
181 - }); 190 + } catch (e) {
  191 + console.error('合并压缩错误:', e);
  192 + process.exit();
  193 + }
182 })(); 194 })();
183 }; 195 };
184 196
@@ -197,10 +209,10 @@ function md5(text) { @@ -197,10 +209,10 @@ function md5(text) {
197 function write(file, text) { 209 function write(file, text) {
198 fs.writeFile(file, text, function (err) { 210 fs.writeFile(file, text, function (err) {
199 if (err) { 211 if (err) {
200 - console.log(err.toString().red); 212 + console.log(err.toString()); // 移除.red调用
201 process.exit(); 213 process.exit();
202 } 214 }
203 - console.log(file.green); 215 + console.log(file); // 移除.green调用
204 }); 216 });
205 } 217 }
206 218
src/main/resources/fatso/minifier.js
1 -/**  
2 - * @author PanZhao  
3 - * @date 2016年3月17日 下午12:44:06  
4 - */  
5 var fs = require('fs'); 1 var fs = require('fs');
6 -var UglifyJS = require("uglify-js"); 2 +var Terser = require('terser');
7 3
8 var platform = process.platform; 4 var platform = process.platform;
9 var iswin = platform=='win32'; 5 var iswin = platform=='win32';
10 var separator = platform=='win32'?'\\':'/'; 6 var separator = platform=='win32'?'\\':'/';
11 var minifier = { 7 var minifier = {
12 -  
13 - mergeAndMini: function(fileArray,scriptString, root, file){ 8 +
  9 + mergeAndMini: function(fileArray, scriptString, root, file) {
14 var len = fileArray.length; 10 var len = fileArray.length;
15 for(var i = 0; i < len; i ++){ 11 for(var i = 0; i < len; i ++){
16 - fileArray[i] = root + fileArray[i].split('/').join(separator); 12 + fileArray[i] = root + fileArray[i].split('/').join(separator);
17 } 13 }
18 - 14 +
19 var result, indoorRs; 15 var result, indoorRs;
20 - 16 +
21 try { 17 try {
22 - if(fileArray && len > 0)  
23 - result = UglifyJS.minify(fileArray);  
24 -  
25 - if(scriptString)  
26 - indoorRs = UglifyJS.minify(scriptString, {fromString: true}); 18 + if(fileArray && len > 0) {
  19 + // Terser可以直接接受文件路径数组
  20 + result = Terser.minify_sync(fs.readFileSync(fileArray[0], 'utf8'));
  21 + // 如果有多个文件,需要先合并内容
  22 + if(len > 1) {
  23 + let code = '';
  24 + for(let j = 0; j < len; j++) {
  25 + code += fs.readFileSync(fileArray[j], 'utf8') + '\n';
  26 + }
  27 + result = Terser.minify_sync(code);
  28 + }
  29 + }
  30 +
  31 + if(scriptString) {
  32 + // Terser不需要fromString选项,直接传递代码字符串
  33 + indoorRs = Terser.minify_sync(scriptString);
  34 + }
27 } catch (e) { 35 } catch (e) {
28 console.log(e); 36 console.log(e);
29 - console.log(file.red); 37 + console.log(file); // 移除.red调用,除非有chalk等库
30 process.exit(); 38 process.exit();
31 } 39 }
32 -  
33 - return {outside: result?result.code:'', inside: indoorRs?indoorRs.code:''}; 40 +
  41 + return {outside: result && !result.error ? result.code : '', inside: indoorRs && !indoorRs.error ? indoorRs.code : ''};
34 }, 42 },
35 - mini: function(file){  
36 - return UglifyJS.minify(file).code; 43 +
  44 + mini: function(file) {
  45 + try {
  46 + // 检查file是文件路径还是代码字符串
  47 + if(typeof file === 'string' && fs.existsSync(file)) {
  48 + const code = fs.readFileSync(file, 'utf8');
  49 + const result = Terser.minify_sync(code);
  50 + return result && !result.error ? result.code : '';
  51 + } else {
  52 + // 假设是代码字符串
  53 + const result = Terser.minify_sync(file);
  54 + return result && !result.error ? result.code : '';
  55 + }
  56 + } catch (e) {
  57 + console.log(e);
  58 + return '';
  59 + }
37 } 60 }
38 -} 61 +};
39 62
40 module.exports = minifier; 63 module.exports = minifier;
41 \ No newline at end of file 64 \ No newline at end of file
src/main/resources/fatso/package.json
@@ -12,7 +12,8 @@ @@ -12,7 +12,8 @@
12 "cheerio": "^0.20.0", 12 "cheerio": "^0.20.0",
13 "clean-css": "^4.0.12", 13 "clean-css": "^4.0.12",
14 "colors": "^1.3.3", 14 "colors": "^1.3.3",
15 - "eventproxy": "^0.3.5", 15 + "eventproxy": "^0.3.4",
  16 + "terser": "^5.44.0",
16 "uglify-js": "^2.6.2" 17 "uglify-js": "^2.6.2"
17 } 18 }
18 } 19 }
src/main/resources/fatso/start.js
@@ -16,7 +16,7 @@ var platform = process.platform; @@ -16,7 +16,7 @@ var platform = process.platform;
16 var iswin = platform == 'win32'; 16 var iswin = platform == 'win32';
17 var sp = platform == 'win32' ? '\\' : '/'; 17 var sp = platform == 'win32' ? '\\' : '/';
18 //不参与的目录 18 //不参与的目录
19 -var excludes = ['scheduleApp', 'trafficManage', 'control', 'permission' + sp + 'authorize_all','permission' + sp + 'user', 'summary', 'history_sch', 'report' + sp + 'oil', 'base' + sp + 'geo_data_edit', 'base' + sp + 'carpark', 'forms', 'mforms', 'report', 'punctual', 'base' + sp + 'timesmodel', 'base' + sp + 'stationroute','zndd_yuan','call','base' + sp + 'region',] 19 +var excludes = ['scheduleApp', 'trafficManage', 'control', 'permission' + sp + 'authorize_all','permission' + sp + 'user', 'summary', 'history_sch', 'report' + sp + 'oil', 'base' + sp + 'geo_data_edit', 'base' + sp + 'carpark', 'forms', 'mforms', 'report', 'punctual', 'base' + sp + 'timesmodel', 'base' + sp + 'stationroute']
20 , ep = new EventProxy() 20 , ep = new EventProxy()
21 , pName = 'bsth_control' 21 , pName = 'bsth_control'
22 , path = process.cwd() 22 , path = process.cwd()