Commit 3d433fcea07a0ea4fe0ad3cd008c8d5bf8197a70

Authored by 廖磊
2 parents 3c11b895 1d95f7c6

Merge branch 'pudong' of http://222.66.0.204:8090/panzhaov5/bsth_control

into pudong
src/main/java/com/bsth/data/schedule/late_adjust/LateAdjustHandle.java
@@ -7,7 +7,6 @@ import com.bsth.entity.realcontrol.LineConfig; @@ -7,7 +7,6 @@ import com.bsth.entity.realcontrol.LineConfig;
7 import com.bsth.entity.realcontrol.ScheduleRealInfo; 7 import com.bsth.entity.realcontrol.ScheduleRealInfo;
8 import com.bsth.util.Arith; 8 import com.bsth.util.Arith;
9 import com.bsth.websocket.handler.SendUtils; 9 import com.bsth.websocket.handler.SendUtils;
10 -import com.google.common.collect.ArrayListMultimap;  
11 import org.slf4j.Logger; 10 import org.slf4j.Logger;
12 import org.slf4j.LoggerFactory; 11 import org.slf4j.LoggerFactory;
13 import org.springframework.beans.BeansException; 12 import org.springframework.beans.BeansException;
@@ -16,7 +15,8 @@ import org.springframework.context.ApplicationContextAware; @@ -16,7 +15,8 @@ import org.springframework.context.ApplicationContextAware;
16 import org.springframework.stereotype.Component; 15 import org.springframework.stereotype.Component;
17 16
18 import java.util.Collection; 17 import java.util.Collection;
19 -import java.util.List; 18 +import java.util.HashMap;
  19 +import java.util.Map;
20 20
21 /** 21 /**
22 * 误点自动调整待发 处理程序 22 * 误点自动调整待发 处理程序
@@ -33,17 +33,11 @@ public class LateAdjustHandle implements ApplicationContextAware { @@ -33,17 +33,11 @@ public class LateAdjustHandle implements ApplicationContextAware {
33 static Logger logger = LoggerFactory.getLogger(LateAdjustHandle.class); 33 static Logger logger = LoggerFactory.getLogger(LateAdjustHandle.class);
34 34
35 /** 35 /**
36 - * 应发未到车辆 和 班次  
37 - * <p>  
38 - * 起点相同的,保留最后一个班次 36 + * 应发未到的班次 key : id
39 */ 37 */
40 - private static ArrayListMultimap lateSchMaps; 38 + private static Map<Long, ScheduleRealInfo> lateSchMap = new HashMap<>();
41 39
42 40
43 - static {  
44 - lateSchMaps = ArrayListMultimap.create();  
45 - }  
46 -  
47 /** 41 /**
48 * 新增一个误点班次 42 * 新增一个误点班次
49 * 43 *
@@ -63,15 +57,12 @@ public class LateAdjustHandle implements ApplicationContextAware { @@ -63,15 +57,12 @@ public class LateAdjustHandle implements ApplicationContextAware {
63 if (sch.getDfsj().compareTo(config.getYjtkStart()) > 0 57 if (sch.getDfsj().compareTo(config.getYjtkStart()) > 0
64 && sch.getDfsj().compareTo(config.getYjtkEnd()) <= 0) { 58 && sch.getDfsj().compareTo(config.getYjtkEnd()) <= 0) {
65 59
66 - ScheduleRealInfo old = popLateSch(sch);  
67 -  
68 - //班次被压入  
69 - if (lateSchMaps.containsEntry(sch.getClZbh(), sch)) {  
70 -  
71 - logger.info("21【应发未到 -多个(" + lateSchMaps.get(sch.getClZbh()).size() + ")】班次 " + sch.getClZbh() + " -" + sch.getDfsj() + " -id: " + sch.getId() + " -加入误点调整!"); 60 + //班次压入
  61 + if (!lateSchMap.containsKey(sch.getId())) {
  62 + logger.info("29【应发未到 班次 " + sch.getClZbh() + " -" + sch.getDfsj() + " -id: " + sch.getId() + " -加入误点调整!");
72 //通知客户端 63 //通知客户端
73 sch.setLate2(true); 64 sch.setLate2(true);
74 - sendUtils.sendAutoWdtz(sch, old); 65 + sendUtils.sendAutoWdtz(sch, null);
75 } 66 }
76 } 67 }
77 68
@@ -80,51 +71,6 @@ public class LateAdjustHandle implements ApplicationContextAware { @@ -80,51 +71,6 @@ public class LateAdjustHandle implements ApplicationContextAware {
80 } 71 }
81 } 72 }
82 73
83 - /**  
84 - * 压入新的误点班次  
85 - *  
86 - * @param sch  
87 - * @return 返回被移除的误点班次  
88 - */  
89 - private static ScheduleRealInfo popLateSch(ScheduleRealInfo sch) {  
90 - List<ScheduleRealInfo> list = lateSchMaps.get(sch.getClZbh());  
91 -  
92 - if (null == list || list.size() == 0)  
93 - lateSchMaps.put(sch.getClZbh(), sch);  
94 - else {  
95 - ScheduleRealInfo old = findExistQdz(list, sch.getQdzCode(), sch.getQdzName(), "");  
96 -  
97 - if (null == old)  
98 - lateSchMaps.put(sch.getClZbh(), sch);  
99 - else if (old.getDfsjT() < sch.getDfsjT()) {  
100 - //同一个起点,保留时间最大的班次  
101 - lateSchMaps.remove(old.getClZbh(), old);  
102 - lateSchMaps.put(sch.getClZbh(), sch);  
103 -  
104 - logger.info(sch.getClZbh() + "【应发未到】old 班次 " + old.getId() + " -被覆盖!");  
105 - return old;  
106 - }  
107 - }  
108 -  
109 - return null;  
110 - }  
111 -  
112 - /**  
113 - * 搜索同样起点的班次  
114 - *  
115 - * @param list  
116 - * @return  
117 - */  
118 - private static ScheduleRealInfo findExistQdz(List<ScheduleRealInfo> list, String qdzCode, String nam1, String name2) {  
119 - for (ScheduleRealInfo item : list) {  
120 - if (item.getQdzCode().equals(qdzCode)  
121 - || item.getQdzName().equals(nam1)  
122 - || item.getQdzName().equals(name2))  
123 - return item;  
124 - }  
125 - return null;  
126 - }  
127 -  
128 74
129 /** 75 /**
130 * 获取所有应发未到的班次 76 * 获取所有应发未到的班次
@@ -132,13 +78,13 @@ public class LateAdjustHandle implements ApplicationContextAware { @@ -132,13 +78,13 @@ public class LateAdjustHandle implements ApplicationContextAware {
132 * @return 78 * @return
133 */ 79 */
134 public static Collection<ScheduleRealInfo> allLateSch() { 80 public static Collection<ScheduleRealInfo> allLateSch() {
135 - return lateSchMaps.values(); 81 + return lateSchMap.values();
136 } 82 }
137 83
138 public static void remove(ScheduleRealInfo sch) { 84 public static void remove(ScheduleRealInfo sch) {
139 try { 85 try {
140 - if (lateSchMaps.containsEntry(sch.getClZbh(), sch)) {  
141 - lateSchMaps.remove(sch.getClZbh(), sch); 86 + if (lateSchMap.containsKey(sch.getId())) {
  87 + lateSchMap.remove(sch.getId());
142 88
143 sch.setLate2(false); 89 sch.setLate2(false);
144 sch.setLateMinute(0); 90 sch.setLateMinute(0);
@@ -161,15 +107,14 @@ public class LateAdjustHandle implements ApplicationContextAware { @@ -161,15 +107,14 @@ public class LateAdjustHandle implements ApplicationContextAware {
161 if (gps.getInstation() <= 0 || null == sch) 107 if (gps.getInstation() <= 0 || null == sch)
162 return; 108 return;
163 109
164 - List<ScheduleRealInfo> list = lateSchMaps.get(gps.getNbbm());  
165 -  
166 - if (null == list || list.size() == 0 || !list.contains(sch)) 110 + if (!lateSchMap.containsKey(sch.getId()))
167 return; 111 return;
168 112
  113 +
169 //可能是延迟信号,gps时间没有误点 114 //可能是延迟信号,gps时间没有误点
170 if (gps.getTimestamp() <= sch.getDfsjT()) { 115 if (gps.getTimestamp() <= sch.getDfsjT()) {
171 sch.setLate2(false); 116 sch.setLate2(false);
172 - lateSchMaps.remove(sch.getClZbh(), sch); 117 + lateSchMap.remove(sch.getId());
173 return; 118 return;
174 } 119 }
175 120
@@ -182,8 +127,8 @@ public class LateAdjustHandle implements ApplicationContextAware { @@ -182,8 +127,8 @@ public class LateAdjustHandle implements ApplicationContextAware {
182 //取消应发未到标记 127 //取消应发未到标记
183 sch.setLate2(false); 128 sch.setLate2(false);
184 129
185 - lateSchMaps.remove(sch.getClZbh(), sch);  
186 - logger.info("【应发未到】车辆到站 " + sch.getClZbh() + " -" + sch.getDfsj() + " -到站时间:" + gps.getTimestamp() + " -停靠时间:" + sch.getLateMinute() + " -自动设置的待发时间:" + dt); 130 + lateSchMap.remove(sch.getId());
  131 + logger.info("【应发未到】车辆到站 " + sch.getClZbh() + " -" + sch.getDfsj() + " -到站时间:" + gps.getTimestamp() + " -停靠时间:" + sch.getLateMinute() + " -自动设置的待发时间:" + dt + " -id:" + sch.getId());
187 } catch (Exception e) { 132 } catch (Exception e) {
188 e.printStackTrace(); 133 e.printStackTrace();
189 logger.error("late2 car arrive", e); 134 logger.error("late2 car arrive", e);
src/main/resources/fatso/start.js
1 /** 1 /**
2 - * @author PanZhao  
3 - * @date 2016年3月17日 下午12:44:06 2 + * @author PanZhao
  3 + * @date 2016年3月17日 下午12:44:06
4 */ 4 */
5 var fs = require('fs') 5 var fs = require('fs')
6 - ,colors = require('colors')  
7 - ,child_process = require('child_process')  
8 - ,EventProxy = require('eventproxy')  
9 - ,parse = require('./parse')  
10 - ,minifier = require('./minifier')  
11 - ,crypto = require("crypto")  
12 - ,handle_real_ctl = require('./handle_real_ctl'); 6 + , colors = require('colors')
  7 + , child_process = require('child_process')
  8 + , EventProxy = require('eventproxy')
  9 + , parse = require('./parse')
  10 + , minifier = require('./minifier')
  11 + , crypto = require("crypto")
  12 + , handle_real_ctl = require('./handle_real_ctl');
13 13
14 14
15 var platform = process.platform; 15 var platform = process.platform;
16 -var iswin = platform=='win32';  
17 -var sp = platform=='win32'?'\\':'/'; 16 +var iswin = platform == 'win32';
  17 +var sp = platform == 'win32' ? '\\' : '/';
18 //不参与的目录 18 //不参与的目录
19 -var excludes = ['scheduleApp', 'trafficManage', 'control', 'permission'+sp+'authorize_all', 'summary', 'history_sch' ,'report'+sp+'oil','base'+sp+'geo_data_edit','base'+sp+'carpark','forms','mforms', 'report', 'punctual']  
20 - ,ep = new EventProxy()  
21 - ,pName = 'bsth_control'  
22 - ,path = process.cwd()  
23 - //根目录  
24 - ,root = path.substr(0, path.indexOf(sp + 'src'+sp+'main'))  
25 - ,workspace = root.substr(0, root.lastIndexOf(sp + pName))  
26 - //临时目录  
27 - ,dest = (workspace + sp + pName+'@fatso_copy')  
28 - ,_static = sp + 'src'+sp+'main'+sp+'resources'+sp+'static'  
29 - ,_pages = dest + _static + sp + 'pages'; 19 +var excludes = ['scheduleApp', 'trafficManage', 'control', 'permission' + sp + 'authorize_all', 'summary', 'history_sch', 'report' + sp + 'oil', 'base' + sp + 'geo_data_edit', 'base' + sp + 'carpark', 'forms', 'mforms', 'report', 'punctual', 'base' + sp + 'timesmodel']
  20 + , ep = new EventProxy()
  21 + , pName = 'bsth_control'
  22 + , path = process.cwd()
  23 + //根目录
  24 + , root = path.substr(0, path.indexOf(sp + 'src' + sp + 'main'))
  25 + , workspace = root.substr(0, root.lastIndexOf(sp + pName))
  26 + //临时目录
  27 + , dest = (workspace + sp + pName + '@fatso_copy')
  28 + , _static = sp + 'src' + sp + 'main' + sp + 'resources' + sp + 'static'
  29 + , _pages = dest + _static + sp + 'pages';
30 30
31 31
32 //创建临时目录 32 //创建临时目录
33 -fs.mkdir(dest, function(e){  
34 - if(e)  
35 - logError('创建临时目录出错,请检查目录 ' + dest + '是否存在');  
36 -  
37 - setTimeout(function(){  
38 - ep.emit('mvn-clean');  
39 - }, 500); 33 +fs.mkdir(dest, function (e) {
  34 + if (e)
  35 + logError('创建临时目录出错,请检查目录 ' + dest + '是否存在');
  36 +
  37 + setTimeout(function () {
  38 + ep.emit('mvn-clean');
  39 + }, 500);
40 }); 40 });
41 //子进程 41 //子进程
42 var cProcess; 42 var cProcess;
43 43
44 -ep.tail('mvn-clean',function(){  
45 - //ep.emit('copy-project');  
46 - //清理target  
47 - logInfo('mvn clean...');  
48 - cProcess = child_process.exec("mvn clean",{cwd: workspace + sp + pName},function(error){  
49 - if(error)  
50 - logError(error);  
51 -  
52 - logSuccess('mvn clean success');  
53 -  
54 - ep.emit('copy-project');  
55 - });  
56 - output(cProcess); 44 +ep.tail('mvn-clean', function () {
  45 + //ep.emit('copy-project');
  46 + //清理target
  47 + logInfo('mvn clean...');
  48 + cProcess = child_process.exec("mvn clean", {cwd: workspace + sp + pName}, function (error) {
  49 + if (error)
  50 + logError(error);
  51 +
  52 + logSuccess('mvn clean success');
  53 +
  54 + ep.emit('copy-project');
  55 + });
  56 + output(cProcess);
57 }); 57 });
58 58
59 //复制项目副本 59 //复制项目副本
60 -ep.tail('copy-project',function(){  
61 - logInfo('copy project...');  
62 - var xcopyCom;  
63 - if(iswin)  
64 - xcopyCom = 'XCOPY '+ root.replace(/\//g,'\\') + ' ' + dest +' /e /exclude:'+path+'\\exclude.txt';  
65 - else  
66 - xcopyCom = 'cp -a ' + root + '/. ' + dest;  
67 -  
68 - cProcess = child_process.exec(xcopyCom,{cwd: workspace, maxBuffer: 5000*1024},function(error){  
69 - if(error)  
70 - logError(error);  
71 -  
72 - logSuccess('copy project success');  
73 -  
74 - ep.emit('check-js');  
75 - });  
76 - //output(cProcess); 60 +ep.tail('copy-project', function () {
  61 + logInfo('copy project...');
  62 + var xcopyCom;
  63 + if (iswin)
  64 + xcopyCom = 'XCOPY ' + root.replace(/\//g, '\\') + ' ' + dest + ' /e /exclude:' + path + '\\exclude.txt';
  65 + else
  66 + xcopyCom = 'cp -a ' + root + '/. ' + dest;
  67 +
  68 + cProcess = child_process.exec(xcopyCom, {cwd: workspace, maxBuffer: 5000 * 1024}, function (error) {
  69 + if (error)
  70 + logError(error);
  71 +
  72 + logSuccess('copy project success');
  73 +
  74 + ep.emit('check-js');
  75 + });
  76 + //output(cProcess);
77 }); 77 });
78 78
79 //检查JS 79 //检查JS
80 -ep.tail('check-js', function(){  
81 - ep.emit('minifier-js'); 80 +ep.tail('check-js', function () {
  81 + ep.emit('minifier-js');
82 }); 82 });
83 83
84 //合并压缩JS 84 //合并压缩JS
85 -ep.tail('minifier-js', function(){  
86 - logInfo('handle index.html...');  
87 -  
88 - //再处理首页  
89 - ep.emit('handle-index', function(){  
90 - //递归处理片段  
91 - walk(dest + _static + sp + 'pages', function(item){  
92 - ep.emit('handle-fragment', item);  
93 - },  
94 - function(){  
95 - //处理线调首页  
96 - handle_real_ctl.handleMain(function () {  
97 - //处理线调地图  
98 - handle_real_ctl.handleMap(function () {  
99 - //处理单屏地图页面  
100 - handle_real_ctl.handleAlonePage(function () {  
101 - //处理单屏主页  
102 - handle_real_ctl.handleAloneHomePage(function () {  
103 - ep.emit('package-jar');  
104 - });  
105 - });  
106 - });  
107 - });  
108 - });  
109 - }); 85 +ep.tail('minifier-js', function () {
  86 + logInfo('handle index.html...');
  87 +
  88 + //再处理首页
  89 + ep.emit('handle-index', function () {
  90 + //递归处理片段
  91 + walk(dest + _static + sp + 'pages', function (item) {
  92 + ep.emit('handle-fragment', item);
  93 + },
  94 + function () {
  95 + //处理线调首页
  96 + handle_real_ctl.handleMain(function () {
  97 + //处理线调地图
  98 + handle_real_ctl.handleMap(function () {
  99 + //处理单屏地图页面
  100 + handle_real_ctl.handleAlonePage(function () {
  101 + //处理单屏主页
  102 + handle_real_ctl.handleAloneHomePage(function () {
  103 + ep.emit('package-jar');
  104 + });
  105 + });
  106 + });
  107 + });
  108 + });
  109 + });
110 }); 110 });
111 111
112 //打包 112 //打包
113 -ep.tail('package-jar', function(file){  
114 - var packageCom = 'mvn clean package -DskipTests';  
115 - cProcess = child_process.exec(packageCom,{maxBuffer: 5000*1024, cwd: dest},function(error){  
116 - if(error)  
117 - logError(error);  
118 -  
119 - logSuccess('mvn package success');  
120 -  
121 - console.log(('成功打包在 ' + dest + sp + 'target 目录下').cyan);  
122 - });  
123 -  
124 - output(cProcess); 113 +ep.tail('package-jar', function (file) {
  114 + var packageCom = 'mvn clean package -DskipTests';
  115 + cProcess = child_process.exec(packageCom, {maxBuffer: 5000 * 1024, cwd: dest}, function (error) {
  116 + if (error)
  117 + logError(error);
  118 +
  119 + logSuccess('mvn package success');
  120 +
  121 + console.log(('成功打包在 ' + dest + sp + 'target 目录下').cyan);
  122 + });
  123 +
  124 + output(cProcess);
125 }); 125 });
126 126
127 //处理片段 127 //处理片段
128 -ep.tail('handle-fragment', function(file){  
129 - //要排除的文件  
130 - for(var i = 0, ex; ex = excludes[i++];){  
131 - if(file.indexOf(_pages + sp + ex) != -1)  
132 - return false;  
133 - }  
134 - handleJavascript(file, function(mini, $){  
135 - var jsMini;  
136 - if(mini.inside)  
137 - jsMini = '(function(){' + mini.inside + '\n' + mini.outside + '})();';  
138 - else  
139 - jsMini = '(function(){' + mini.outside + '})();';  
140 -  
141 - write(file, $.html() + '<script>' + jsMini + '</script>');  
142 - });  
143 - 128 +ep.tail('handle-fragment', function (file) {
  129 + //要排除的文件
  130 + for (var i = 0, ex; ex = excludes[i++];) {
  131 + if (file.indexOf(_pages + sp + ex) != -1)
  132 + return false;
  133 + }
  134 + handleJavascript(file, function (mini, $) {
  135 + var jsMini;
  136 + if (mini.inside)
  137 + jsMini = '(function(){' + mini.inside + '\n' + mini.outside + '})();';
  138 + else
  139 + jsMini = '(function(){' + mini.outside + '})();';
  140 +
  141 + write(file, $.html() + '<script>' + jsMini + '</script>');
  142 + });
  143 +
144 }); 144 });
145 145
146 //处理首页 146 //处理首页
147 -ep.tail('handle-index', function(cb){  
148 - var index = dest + _static + sp + 'index.html';  
149 - handleJavascript(index, function(mini, $){  
150 - var jsMiniText = mini.inside + mini.outside;  
151 -  
152 - var code = md5(jsMiniText);  
153 - fs.open( dest + _static + sp + 'assets'+sp+'js' + sp + code + '.js', 'a', function(err, fd){  
154 - if(err)  
155 - logError(err);  
156 -  
157 - fs.write(fd,jsMiniText, function(){  
158 - var ss = $('script');  
159 -  
160 - $(ss[ss.length - 1]).before('<script src="/assets/js/'+code+'.js"></script>\n');  
161 - for(var i = 0, s; s = ss[i++];){  
162 - $(s).removeAttr('data-exclude')  
163 - .removeAttr('flag')  
164 - .removeAttr('data-autocephaly');  
165 - }  
166 - write(index, $.html());  
167 -  
168 - cb && cb();  
169 - });  
170 - });  
171 - }); 147 +ep.tail('handle-index', function (cb) {
  148 + var index = dest + _static + sp + 'index.html';
  149 + handleJavascript(index, function (mini, $) {
  150 + var jsMiniText = mini.inside + mini.outside;
  151 +
  152 + var code = md5(jsMiniText);
  153 + fs.open(dest + _static + sp + 'assets' + sp + 'js' + sp + code + '.js', 'a', function (err, fd) {
  154 + if (err)
  155 + logError(err);
  156 +
  157 + fs.write(fd, jsMiniText, function () {
  158 + var ss = $('script');
  159 +
  160 + $(ss[ss.length - 1]).before('<script src="/assets/js/' + code + '.js"></script>\n');
  161 + for (var i = 0, s; s = ss[i++];) {
  162 + $(s).removeAttr('data-exclude')
  163 + .removeAttr('flag')
  164 + .removeAttr('data-autocephaly');
  165 + }
  166 + write(index, $.html());
  167 +
  168 + cb && cb();
  169 + });
  170 + });
  171 + });
172 }); 172 });
173 173
174 174
175 -function handleJavascript(item, cb){  
176 - //解析页面  
177 - var htmlResult = parse.html(item, dest + _static)  
178 - ,jsArray = htmlResult.jsArray  
179 - ,$ = htmlResult.$  
180 - ,scrStr = htmlResult.scriptString;  
181 -  
182 - //合并压缩  
183 - var mini = minifier.mergeAndMini(jsArray, scrStr, dest + _static, item);  
184 -  
185 - cb && cb(mini, $); 175 +function handleJavascript(item, cb) {
  176 + //解析页面
  177 + var htmlResult = parse.html(item, dest + _static)
  178 + , jsArray = htmlResult.jsArray
  179 + , $ = htmlResult.$
  180 + , scrStr = htmlResult.scriptString;
  181 +
  182 + //合并压缩
  183 + var mini = minifier.mergeAndMini(jsArray, scrStr, dest + _static, item);
  184 +
  185 + cb && cb(mini, $);
186 } 186 }
187 187
188 -function removeJsLink(s, e){  
189 - var newArray = [], flag;  
190 -  
191 - for(var i = 0, si; si = s[i++];){  
192 - flag = 0;  
193 - for(var j = 0,ei; ei = e[j++];){  
194 - if(si.indexOf(ei) != -1){  
195 - flag = -1;  
196 - break;  
197 - }  
198 - }  
199 -  
200 - if(flag == 0){  
201 - newArray.push(si);  
202 - }  
203 - }  
204 - return newArray; 188 +function removeJsLink(s, e) {
  189 + var newArray = [], flag;
  190 +
  191 + for (var i = 0, si; si = s[i++];) {
  192 + flag = 0;
  193 + for (var j = 0, ei; ei = e[j++];) {
  194 + if (si.indexOf(ei) != -1) {
  195 + flag = -1;
  196 + break;
  197 + }
  198 + }
  199 +
  200 + if (flag == 0) {
  201 + newArray.push(si);
  202 + }
  203 + }
  204 + return newArray;
205 } 205 }
206 206
207 -function write(file, text){  
208 - fs.writeFile(file, text, function (err) {  
209 - if (err){  
210 - console.log(err.toString().red);  
211 - process.exit();  
212 - }  
213 - //console.log(file.green);  
214 - }); 207 +function write(file, text) {
  208 + fs.writeFile(file, text, function (err) {
  209 + if (err) {
  210 + console.log(err.toString().red);
  211 + process.exit();
  212 + }
  213 + //console.log(file.green);
  214 + });
215 } 215 }
216 216
217 -function md5(text){  
218 - return crypto.createHash("md5").update(text).digest("hex"); 217 +function md5(text) {
  218 + return crypto.createHash("md5").update(text).digest("hex");
219 } 219 }
220 220
221 221
222 -function walk(path ,handleFile, over) {  
223 - fs.readdir(path, function(err, files) {  
224 - if (err) {  
225 - console.log('read dir error'.red);  
226 - } else {  
227 - files.forEach(function(item) { 222 +function walk(path, handleFile, over) {
  223 + fs.readdir(path, function (err, files) {
  224 + if (err) {
  225 + console.log('read dir error'.red);
  226 + } else {
  227 + files.forEach(function (item) {
228 var tmpPath = path + sp + item; 228 var tmpPath = path + sp + item;
229 - fs.stat(tmpPath, function(err1, stats) {  
230 - if (err1) {  
231 - console.log('stat error');  
232 - } else {  
233 - if (stats.isDirectory()) {  
234 - walk(tmpPath, handleFile);  
235 - } else if(item.indexOf('.html') != -1){  
236 - handleFile(tmpPath);  
237 - }  
238 - }  
239 - }) 229 + fs.stat(tmpPath, function (err1, stats) {
  230 + if (err1) {
  231 + console.log('stat error');
  232 + } else {
  233 + if (stats.isDirectory()) {
  234 + walk(tmpPath, handleFile);
  235 + } else if (item.indexOf('.html') != -1) {
  236 + handleFile(tmpPath);
  237 + }
  238 + }
  239 + })
240 }); 240 });
241 - 241 +
242 over && over(); 242 over && over();
243 - }  
244 - });  
245 -} 243 + }
  244 + });
  245 +}
246 246
247 -function logInfo(t){  
248 - console.log(t); 247 +function logInfo(t) {
  248 + console.log(t);
249 } 249 }
250 250
251 -function logSuccess(t){  
252 - console.log(t.green); 251 +function logSuccess(t) {
  252 + console.log(t.green);
253 } 253 }
254 254
255 -function logError(e){  
256 - console.log(e.toString().red);  
257 - process.exit(); 255 +function logError(e) {
  256 + console.log(e.toString().red);
  257 + process.exit();
258 } 258 }
259 259
260 -function output(cProcess){  
261 - //标准输出  
262 - cProcess.stdout.on('data', function (s) {  
263 - console.log(s);  
264 - }); 260 +function output(cProcess) {
  261 + //标准输出
  262 + cProcess.stdout.on('data', function (s) {
  263 + console.log(s);
  264 + });
265 } 265 }
266 \ No newline at end of file 266 \ No newline at end of file