Commit 15836e19b814c69e4a1cf2c1b2560a165c3502eb
1 parent
ec1404c6
AI语音
Showing
5 changed files
with
473 additions
and
84 deletions
src/main/java/com/bsth/data/zndd/voice/GJC.java
0 → 100644
| 1 | +package com.bsth.data.zndd.voice; | ||
| 2 | + | ||
| 3 | +import java.util.*; | ||
| 4 | + | ||
| 5 | +public enum GJC { | ||
| 6 | + CX(1, "撤销"), | ||
| 7 | + QX(1, "取消"), | ||
| 8 | + XZ(2, "新增"), | ||
| 9 | + TJ(2, "添加"), | ||
| 10 | + LJ(2, "临加"), | ||
| 11 | + TZ(3, "调整"), | ||
| 12 | + BC(4, "班次"), | ||
| 13 | + PB(4, "排班"), | ||
| 14 | + DF(5, "待发"), | ||
| 15 | + SF(6, "实发"), | ||
| 16 | + CC(7, "出场"), | ||
| 17 | + KQ(8, "开启"), | ||
| 18 | + GB(9, "关闭"), | ||
| 19 | + ge(10, "个"), | ||
| 20 | + dao(11, "到"), | ||
| 21 | + de(12, "的"); | ||
| 22 | + | ||
| 23 | + private int code; | ||
| 24 | + private String description; | ||
| 25 | + | ||
| 26 | + GJC(int code, String description) { | ||
| 27 | + this.code = code; | ||
| 28 | + this.description = description; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + public int getCode() { | ||
| 32 | + return code; | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + public void setCode(int code) { | ||
| 36 | + this.code = code; | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + public String getDescription() { | ||
| 40 | + return description; | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + public void setDescription(String description) { | ||
| 44 | + this.description = description; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + public static int getNumber(String description){ | ||
| 48 | + int number = 999; | ||
| 49 | + for (GJC gjc : GJC.values()) { | ||
| 50 | + if(gjc.description.equals(description)){ | ||
| 51 | + number = gjc.code; | ||
| 52 | + } | ||
| 53 | + } | ||
| 54 | + return number; | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + public static Set<String> getDescription(int number){ | ||
| 58 | + Set<String> description = new HashSet<>(); | ||
| 59 | + for (GJC gjc : GJC.values()) { | ||
| 60 | + if(gjc.code==number){ | ||
| 61 | + description.add(gjc.description); | ||
| 62 | + } | ||
| 63 | + } | ||
| 64 | + return description; | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + public static Set<Integer> getGJC(String yy){ | ||
| 68 | + Set<Integer> set=new HashSet<>(); | ||
| 69 | + for (GJC gjc : GJC.values()) { | ||
| 70 | + char[] arr=gjc.description.toCharArray(); | ||
| 71 | + for (char c : arr) { | ||
| 72 | + if(UploadVideoServlet.getPinyin(yy).contains(UploadVideoServlet.getPinyin(String.valueOf(c)))){ | ||
| 73 | + set.add(gjc.code); | ||
| 74 | + } | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + } | ||
| 78 | + return set; | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + public static int getCount(int i){ | ||
| 82 | + int count=0; | ||
| 83 | + for (GJC gjc : GJC.values()) { | ||
| 84 | + if(gjc.code==i){ | ||
| 85 | + count++; | ||
| 86 | + } | ||
| 87 | + } | ||
| 88 | + return count; | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + public static void main(String[] args) { | ||
| 92 | + List<Integer> list=new ArrayList<>(); | ||
| 93 | + list.add(1); | ||
| 94 | + list.add(2); | ||
| 95 | + list.add(4); | ||
| 96 | + Set<String> ml=new HashSet<>(); | ||
| 97 | + nestedLoop(list,"",ml); | ||
| 98 | + System.out.println(ml); | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + public static void nestedLoop(List<Integer> arr,String str,Set<String> ml) { | ||
| 102 | + if(arr.size()>0){ | ||
| 103 | + Set<String> set=getDescription(arr.get(0)); | ||
| 104 | + for (String s : set) { | ||
| 105 | + List list2=new ArrayList(); | ||
| 106 | + list2.addAll(arr); | ||
| 107 | + list2.remove(0); | ||
| 108 | + nestedLoop(list2,str+s,ml); | ||
| 109 | + } | ||
| 110 | + }else { | ||
| 111 | + ml.add(str); | ||
| 112 | + } | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + | ||
| 116 | +} |
src/main/java/com/bsth/data/zndd/voice/UploadVideoServlet.java
| @@ -121,44 +121,84 @@ public class UploadVideoServlet extends HttpServlet { | @@ -121,44 +121,84 @@ public class UploadVideoServlet extends HttpServlet { | ||
| 121 | //定义输出类型 | 121 | //定义输出类型 |
| 122 | response.setHeader("Content-type", "text/html;charset=UTF-8"); | 122 | response.setHeader("Content-type", "text/html;charset=UTF-8"); |
| 123 | PrintWriter writer = response.getWriter(); | 123 | PrintWriter writer = response.getWriter(); |
| 124 | - List<retun> list1 = new ArrayList<>(); | ||
| 125 | String text = textList.get(0).toString(); | 124 | String text = textList.get(0).toString(); |
| 126 | - | ||
| 127 | - | ||
| 128 | - //帮我添加一个夏硕路林兰路到鸿音路云端路的班次 | ||
| 129 | - String fcsj = null;//线路名,上下行,发车时间 | ||
| 130 | - String[] ks = text.replace(",","").split("到"); | ||
| 131 | - String Station1= ks[0].split("个")[1]; | ||
| 132 | - String Station2= ks[1].split("的")[0]; | ||
| 133 | - //发车时间 | ||
| 134 | - fcsj = extractTimes(text); | ||
| 135 | - //线路名称 - 线路编码和名称对照 | ||
| 136 | - | ||
| 137 | - Map<String, Object> param = new HashMap<>(); | ||
| 138 | - param.put("lineCode_eq", line); | ||
| 139 | - param.put("directions_eq", 0); | ||
| 140 | - param.put("destroy_eq", 0); | ||
| 141 | - List<StationRoute> stationup = ((List<StationRoute>) stationRouteService.list(param)); | ||
| 142 | - //上行匹配 | ||
| 143 | - Map m = pyPp(stationup,Station1,Station2); | ||
| 144 | - if (m.get("stationcode1") == null || m.get("stationcode2") == null){ | ||
| 145 | - param.put("directions_eq",1); | ||
| 146 | - List<StationRoute> stationdown = ((List<StationRoute>) stationRouteService.list(param)); | ||
| 147 | - //下行匹配 | ||
| 148 | - Map smap = pyPp(stationdown,Station1,Station2); | ||
| 149 | - if (smap.get("stationcode1") == null || smap.get("stationcode2") == null){ | ||
| 150 | - writer.write(text +","+"99999"); | 125 | + //text="新增出厂班次"; |
| 126 | + //text="帮我添加一个鸿音路南芦公路到临港大道枢纽站的班次"; | ||
| 127 | + if(isSimilarity(ZL.zdzdbc,text,null)){//帮我添加一个xx到xx站的班次(帮我添加一个鸿音路南芦公路到临港大道枢纽站的班次) | ||
| 128 | + String[] ks = text.replace(",","").split("到"); | ||
| 129 | + if(ks[0].split("个").length==1){ | ||
| 130 | + writer.write(text+"_识别失败"+",999"); | ||
| 151 | return; | 131 | return; |
| 152 | } | 132 | } |
| 153 | - | ||
| 154 | - writer.write(text +","+smap.get("stationcode1")+","+smap.get("stationcode2")+","+1); | 133 | + if(ks[1].split("的").length==1){ |
| 134 | + writer.write(text+"_识别失败"+",999"); | ||
| 135 | + return; | ||
| 136 | + } | ||
| 137 | + String Station1= ks[0].split("个")[1]; | ||
| 138 | + String Station2= ks[1].split("的")[0]; | ||
| 139 | + | ||
| 140 | + /* String fcsj = null;//线路名,上下行,发车时间 | ||
| 141 | + //发车时间 | ||
| 142 | + fcsj = extractTimes(text);*/ | ||
| 143 | + //线路名称 - 线路编码和名称对照 | ||
| 144 | + | ||
| 145 | + Map<String, Object> param = new HashMap<>(); | ||
| 146 | + param.put("lineCode_eq", line); | ||
| 147 | + param.put("directions_eq", 0); | ||
| 148 | + param.put("destroy_eq", 0); | ||
| 149 | + List<StationRoute> stationup = ((List<StationRoute>) stationRouteService.list(param)); | ||
| 150 | + //上行匹配 | ||
| 151 | + Map m = pyPp(stationup,Station1,Station2); | ||
| 152 | + if (m.get("stationcode1") == null || m.get("stationcode2") == null){ | ||
| 153 | + param.put("directions_eq",1); | ||
| 154 | + List<StationRoute> stationdown = ((List<StationRoute>) stationRouteService.list(param)); | ||
| 155 | + //下行匹配 | ||
| 156 | + Map smap = pyPp(stationdown,Station1,Station2); | ||
| 157 | + if (smap.get("stationcode1") == null || smap.get("stationcode2") == null){ | ||
| 158 | + writer.write(text +","+"999"); | ||
| 159 | + return; | ||
| 160 | + } | ||
| 161 | + writer.write(text +",1,"+smap.get("stationcode1")+","+smap.get("stationcode2")+","+1); | ||
| 162 | + return; | ||
| 163 | + } | ||
| 164 | + writer.write(text +",1,"+m.get("stationcode1")+","+m.get("stationcode2")+","+0); | ||
| 155 | return; | 165 | return; |
| 156 | } | 166 | } |
| 157 | - | ||
| 158 | - writer.write(text +","+m.get("stationcode1")+","+m.get("stationcode2")+","+0); | ||
| 159 | - return; | ||
| 160 | - | ||
| 161 | - //打开0 关闭1 临加2 999异常 | 167 | + if(isSimilarity(ZL.LJCCBC,text,null)){//添加出厂班次 |
| 168 | + writer.write(text+"_"+ZL.LJCCBC.getDescription()+",2"); | ||
| 169 | + return; | ||
| 170 | + } | ||
| 171 | + if(isSimilarity(ZL.LJBC,text,null)){//添加班次 | ||
| 172 | + writer.write(text+"_"+ZL.LJBC.getDescription()+",3"); | ||
| 173 | + return; | ||
| 174 | + } | ||
| 175 | + if(isSimilarity(ZL.QXBC,text,null)){//取消班次 | ||
| 176 | + writer.write(text+"_"+ZL.QXBC.getDescription()+",11"); | ||
| 177 | + return; | ||
| 178 | + } | ||
| 179 | + if(isSimilarity(ZL.QXSF,text,null)){//取消实发 | ||
| 180 | + writer.write(text+"_"+ZL.QXSF.getDescription()+",12"); | ||
| 181 | + return; | ||
| 182 | + } | ||
| 183 | + if(isSimilarity(ZL.TZDF,text,"待")){//调整待发 | ||
| 184 | + writer.write(text+"_"+ZL.TZDF.getDescription()+",21"); | ||
| 185 | + return; | ||
| 186 | + } | ||
| 187 | + if(isSimilarity(ZL.TZSF,text,"实")){//调整实发 | ||
| 188 | + writer.write(text+"_"+ZL.TZSF.getDescription()+",22"); | ||
| 189 | + return; | ||
| 190 | + } | ||
| 191 | + if(isSimilarity(ZL.KQ,text,null)){//启动 | ||
| 192 | + writer.write(text+"_"+ZL.KQ.getDescription()+",31"); | ||
| 193 | + return; | ||
| 194 | + } | ||
| 195 | + if(isSimilarity(ZL.GB,text,null)){//关闭 | ||
| 196 | + writer.write(text+"_"+ZL.GB.getDescription()+",41"); | ||
| 197 | + return; | ||
| 198 | + } | ||
| 199 | + else { | ||
| 200 | + writer.write(text+"_识别失败"+",999"); | ||
| 201 | + } | ||
| 162 | } | 202 | } |
| 163 | 203 | ||
| 164 | } catch (Exception e) { | 204 | } catch (Exception e) { |
| @@ -232,30 +272,45 @@ public class UploadVideoServlet extends HttpServlet { | @@ -232,30 +272,45 @@ public class UploadVideoServlet extends HttpServlet { | ||
| 232 | } | 272 | } |
| 233 | 273 | ||
| 234 | 274 | ||
| 235 | - | ||
| 236 | public static String getPinyin(String chinese) { | 275 | public static String getPinyin(String chinese) { |
| 237 | HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat(); | 276 | HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat(); |
| 238 | format.setCaseType(HanyuPinyinCaseType.LOWERCASE); | 277 | format.setCaseType(HanyuPinyinCaseType.LOWERCASE); |
| 239 | format.setToneType(HanyuPinyinToneType.WITHOUT_TONE); | 278 | format.setToneType(HanyuPinyinToneType.WITHOUT_TONE); |
| 240 | 279 | ||
| 241 | - StringBuilder pinyinBuilder = new StringBuilder(); | ||
| 242 | - char[] charArray = chinese.toCharArray(); | ||
| 243 | - for (char c : charArray) { | ||
| 244 | - String[] pinyinArray = null; | ||
| 245 | - try { | ||
| 246 | - pinyinArray = PinyinHelper.toHanyuPinyinStringArray(c, format); | ||
| 247 | - } catch (BadHanyuPinyinOutputFormatCombination e) { | ||
| 248 | - e.printStackTrace(); | 280 | + StringBuilder sb = new StringBuilder(); |
| 281 | + char[] chars = chinese.toCharArray(); | ||
| 282 | + for (char c : chars) { | ||
| 283 | + if (Character.isWhitespace(c)) { | ||
| 284 | + continue; | ||
| 249 | } | 285 | } |
| 250 | - if (pinyinArray != null) { | ||
| 251 | - pinyinBuilder.append(pinyinArray[0]); | 286 | + if (c >= '\u4e00' && c <= '\u9fa5') { |
| 287 | + try { | ||
| 288 | + String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(c, format); | ||
| 289 | + sb.append(pinyinArray[0]); | ||
| 290 | + } catch (BadHanyuPinyinOutputFormatCombination e) { | ||
| 291 | + e.printStackTrace(); | ||
| 292 | + } | ||
| 252 | } else { | 293 | } else { |
| 253 | - pinyinBuilder.append(c); | 294 | + sb.append(c); |
| 254 | } | 295 | } |
| 255 | } | 296 | } |
| 256 | - return pinyinBuilder.toString(); | 297 | + return sb.toString(); |
| 257 | } | 298 | } |
| 258 | 299 | ||
| 300 | + | ||
| 301 | + //去除标点符号 | ||
| 302 | + public static String removePunctuation(String input) { | ||
| 303 | + String punctuationRegex = "[\\p{Punct}]"; | ||
| 304 | + input=input.replaceAll(punctuationRegex, ""); | ||
| 305 | + String regEx = "[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]"; | ||
| 306 | + Pattern p = Pattern.compile(regEx); | ||
| 307 | + Matcher m = p.matcher(input); | ||
| 308 | + return input.replaceAll(punctuationRegex, "").replaceAll(regEx, ""); | ||
| 309 | + } | ||
| 310 | + | ||
| 311 | + public static void main(String[] args) { | ||
| 312 | + System.out.println(calculateSimilarity("临加班次", "撤销班次")); | ||
| 313 | + } | ||
| 259 | public static Double calculateSimilarity(String str1, String str2) { | 314 | public static Double calculateSimilarity(String str1, String str2) { |
| 260 | String pinyinStr1 = getPinyin(str1); | 315 | String pinyinStr1 = getPinyin(str1); |
| 261 | String pinyinStr2 = getPinyin(str2); | 316 | String pinyinStr2 = getPinyin(str2); |
| @@ -285,7 +340,40 @@ public class UploadVideoServlet extends HttpServlet { | @@ -285,7 +340,40 @@ public class UploadVideoServlet extends HttpServlet { | ||
| 285 | 340 | ||
| 286 | 341 | ||
| 287 | 342 | ||
| 288 | - | ||
| 289 | - | 343 | + /* public static boolean isSimilarity(Integer[] gjc,String str,String gjz){ |
| 344 | + Set<String> ml=new HashSet<>(); | ||
| 345 | + GJC.nestedLoop(Arrays.asList(gjc),"",ml); | ||
| 346 | + for (String s : ml) { | ||
| 347 | + if(calculateSimilarity(s,str)>= 0.75){//相似度 | ||
| 348 | + if(gjz==null){//不含关键字 | ||
| 349 | + return true; | ||
| 350 | + }else { | ||
| 351 | + if(UploadVideoServlet.getPinyin(str).contains(UploadVideoServlet.getPinyin(gjz))){ | ||
| 352 | + return true; | ||
| 353 | + } | ||
| 354 | + } | ||
| 355 | + } | ||
| 356 | + } | ||
| 357 | + return false; | ||
| 358 | + }*/ | ||
| 359 | + | ||
| 360 | + public static boolean isSimilarity(ZL zl,String str,String gjz){ | ||
| 361 | + Integer[] ints=zl.getCodes(); | ||
| 362 | + Set<String> ml=new HashSet<>(); | ||
| 363 | + GJC.nestedLoop(Arrays.asList(ints),"",ml); | ||
| 364 | + for (String s : ml) { | ||
| 365 | + double d=calculateSimilarity(s,str); | ||
| 366 | + if(d>= 0.75){//相似度 | ||
| 367 | + if(gjz==null){//不含关键字 | ||
| 368 | + return true; | ||
| 369 | + }else { | ||
| 370 | + if(UploadVideoServlet.getPinyin(str).contains(UploadVideoServlet.getPinyin(gjz))){ | ||
| 371 | + return true; | ||
| 372 | + } | ||
| 373 | + } | ||
| 374 | + } | ||
| 375 | + } | ||
| 376 | + return false; | ||
| 377 | + } | ||
| 290 | 378 | ||
| 291 | } | 379 | } |
| 292 | \ No newline at end of file | 380 | \ No newline at end of file |
src/main/java/com/bsth/data/zndd/voice/ZL.java
0 → 100644
| 1 | +package com.bsth.data.zndd.voice; | ||
| 2 | + | ||
| 3 | + | ||
| 4 | +import java.util.Arrays; | ||
| 5 | +import java.util.HashSet; | ||
| 6 | +import java.util.List; | ||
| 7 | +import java.util.Set; | ||
| 8 | + | ||
| 9 | +public enum ZL { | ||
| 10 | + LJBC(new Integer[]{2,4}, "临加班次"), | ||
| 11 | + LJCCBC(new Integer[]{2,4,7}, "临加出场班次"), | ||
| 12 | + TZDF(new Integer[]{3,5}, "调整待发"), | ||
| 13 | + TZSF(new Integer[]{3,6}, "调整实发"), | ||
| 14 | + QXBC(new Integer[]{1,4}, "取消班次"), | ||
| 15 | + QXSF(new Integer[]{1,6}, "取消实发"), | ||
| 16 | + KQ(new Integer[]{8}, "开启智能调度"), | ||
| 17 | + GB(new Integer[]{9}, "关闭智能调度"), | ||
| 18 | + zdzdbc(new Integer[]{10,11,12}, "添加一个xx到xx的班次"); | ||
| 19 | + | ||
| 20 | + private Integer[] codes; | ||
| 21 | + private String description; | ||
| 22 | + | ||
| 23 | + ZL(Integer[] codes, String description) { | ||
| 24 | + this.codes = codes; | ||
| 25 | + this.description = description; | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + public Integer[] getCodes() { | ||
| 29 | + return codes; | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + public void setCodes(Integer[] codes) { | ||
| 33 | + this.codes = codes; | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + public String getDescription() { | ||
| 37 | + return description; | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + public void setDescription(String description) { | ||
| 41 | + this.description = description; | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + public static boolean match(ZL zl,String str){ | ||
| 45 | + Integer[] ints=zl.codes; | ||
| 46 | + List<Integer> list= Arrays.asList(ints); | ||
| 47 | + Set<String> ml=new HashSet<>(); | ||
| 48 | + GJC.nestedLoop(list,str,ml); | ||
| 49 | + return false; | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + | ||
| 53 | +} |
src/main/resources/static/real_control_v2/js/line_schedule/sch_table.js
| @@ -28,6 +28,7 @@ var gb_schedule_table = (function () { | @@ -28,6 +28,7 @@ var gb_schedule_table = (function () { | ||
| 28 | }; | 28 | }; |
| 29 | 29 | ||
| 30 | var show = function (cb) { | 30 | var show = function (cb) { |
| 31 | + document.cookie = "checkedSch="; | ||
| 31 | //从服务器获取班次数据 | 32 | //从服务器获取班次数据 |
| 32 | $.get('/realSchedule/lines', { | 33 | $.get('/realSchedule/lines', { |
| 33 | lines: gb_data_basic.line_idx | 34 | lines: gb_data_basic.line_idx |
| @@ -499,6 +500,7 @@ var gb_schedule_table = (function () { | @@ -499,6 +500,7 @@ var gb_schedule_table = (function () { | ||
| 499 | nextSch, tempDL; | 500 | nextSch, tempDL; |
| 500 | 501 | ||
| 501 | getDl(sch).addClass('intimity'); | 502 | getDl(sch).addClass('intimity'); |
| 503 | + document.cookie = "checkedSch="+sch.id; | ||
| 502 | $.each(schArr, function (i) { | 504 | $.each(schArr, function (i) { |
| 503 | tempDL = $('dl[data-id=' + this.id + ']', contWrap); | 505 | tempDL = $('dl[data-id=' + this.id + ']', contWrap); |
| 504 | tempDL.addClass('relevance-active'); | 506 | tempDL.addClass('relevance-active'); |
src/main/resources/static/real_control_v2/js/zndd/recorder/recorder.js
| @@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
| 8 | const zzdclone="已关闭无人调度"; | 8 | const zzdclone="已关闭无人调度"; |
| 9 | const error="'未匹配到对应操作,请重新下达指令!"; | 9 | const error="'未匹配到对应操作,请重新下达指令!"; |
| 10 | const nosche="当天没有排班"; | 10 | const nosche="当天没有排班"; |
| 11 | - | 11 | + |
| 12 | 12 | ||
| 13 | var HZRecorder = function (stream, config) { | 13 | var HZRecorder = function (stream, config) { |
| 14 | config = config || {}; | 14 | config = config || {}; |
| @@ -183,48 +183,178 @@ | @@ -183,48 +183,178 @@ | ||
| 183 | 183 | ||
| 184 | xhr.onreadystatechange = function() { | 184 | xhr.onreadystatechange = function() { |
| 185 | if (xhr.readyState == 3 && xhr.status == 200) { | 185 | if (xhr.readyState == 3 && xhr.status == 200) { |
| 186 | - var responseText = xhr.responseText.split(","); | ||
| 187 | - //notify_succ("您说的是:"+responseText[0]); | ||
| 188 | - | ||
| 189 | - console.log(responseText); // 这里会输出 "Hello, World!" | ||
| 190 | - | ||
| 191 | - debugger | ||
| 192 | let lineCode = gb_schedule_table.TablelineCode; | 186 | let lineCode = gb_schedule_table.TablelineCode; |
| 193 | - //打开临加班次 | ||
| 194 | - var folder = '/real_control_v2/fragments/line_schedule/context_menu'; | ||
| 195 | - var modal_opts = { | ||
| 196 | - center: false, | ||
| 197 | - bgclose: false | ||
| 198 | - }; | ||
| 199 | - /*var sch ={ | ||
| 200 | - xlBm : lineCode, | ||
| 201 | - qdzCode : responseText[1], | ||
| 202 | - zdzCode : responseText[2], | ||
| 203 | - dir : responseText[3], | ||
| 204 | - yuyin:111, | ||
| 205 | - };*/ | ||
| 206 | - let date = { | ||
| 207 | - lineCode :lineCode, | ||
| 208 | - dir:responseText[3], | 187 | + const schId = getCookie('checkedSch'); |
| 188 | + var responseText = xhr.responseText.split(","); | ||
| 189 | + if(responseText[1]=="1"){ | ||
| 190 | + //notify_succ("您说的是:"+responseText[0]); | ||
| 191 | + //console.log(responseText); // 这里会输出 "Hello, World!" | ||
| 192 | + //打开临加班次 | ||
| 193 | + var folder = '/real_control_v2/fragments/line_schedule/context_menu'; | ||
| 194 | + var modal_opts = { | ||
| 195 | + center: false, | ||
| 196 | + bgclose: false | ||
| 197 | + }; | ||
| 198 | + let date = { | ||
| 199 | + lineCode :lineCode, | ||
| 200 | + dir:responseText[4], | ||
| 201 | + } | ||
| 202 | + $.post('/logZndd/schlist',date,function(sch) { | ||
| 203 | + debugger | ||
| 204 | + sch.qdzCode = responseText[2]; | ||
| 205 | + sch.zdzCode = responseText[3]; | ||
| 206 | + sch.xlDir = responseText[4]; | ||
| 207 | + sch.zdsjActual = moment(new Date()).format("HH:mm") | ||
| 208 | + open_modal(folder + '/temp_sch/main.html', { | ||
| 209 | + sch: sch | ||
| 210 | + }, modal_opts); | ||
| 211 | + }); | ||
| 212 | + } | ||
| 213 | + else if(responseText[1]=="2"){//新增出场班次 | ||
| 214 | + if(schId==''){ | ||
| 215 | + notify_err("请选择班次"); | ||
| 216 | + return; | ||
| 217 | + } | ||
| 218 | + var sch = gb_schedule_table.findScheduleByLine(lineCode)[schId]; | ||
| 219 | + sch = Object.assign({}, sch); | ||
| 220 | + var confirmBtn = $(this).parent().find('.uk-button-primary'); | ||
| 221 | + var fun =gb_schedule_context_menu.add_temp_sch; | ||
| 222 | + sch.bcType='out'; | ||
| 223 | + sch.qdzCode=getCarPark(sch)[0].code; | ||
| 224 | + sch.qdzName=getCarPark(sch)[0].name; | ||
| 225 | + fun(sch, function () { | ||
| 226 | + confirmBtn.trigger('click'); | ||
| 227 | + }); | ||
| 228 | + return; | ||
| 229 | + } | ||
| 230 | + else if(responseText[1]=="3"){//新增班次 | ||
| 231 | + if(schId==''){ | ||
| 232 | + notify_err("请选择班次"); | ||
| 233 | + return; | ||
| 234 | + } | ||
| 235 | + var sch = gb_schedule_table.findScheduleByLine(lineCode)[schId]; | ||
| 236 | + var confirmBtn = $(this).parent().find('.uk-button-primary'); | ||
| 237 | + var fun =gb_schedule_context_menu.add_temp_sch; | ||
| 238 | + fun(sch, function () { | ||
| 239 | + confirmBtn.trigger('click'); | ||
| 240 | + }); | ||
| 241 | + return; | ||
| 242 | + } | ||
| 243 | + if(responseText[1]=="11"){//取消班次 | ||
| 244 | + if(schId==''){ | ||
| 245 | + notify_err("请选择班次"); | ||
| 246 | + return; | ||
| 247 | + } | ||
| 248 | + var sch = gb_schedule_table.findScheduleByLine(lineCode)[schId]; | ||
| 249 | + var confirmBtn = $(this).parent().find('.uk-button-primary'); | ||
| 250 | + var fun =gb_schedule_context_menu.jhlb; | ||
| 251 | + fun(sch, function () { | ||
| 252 | + confirmBtn.trigger('click'); | ||
| 253 | + }); | ||
| 254 | + return; | ||
| 255 | + } | ||
| 256 | + else if(responseText[1]=="12"){//取消实发 | ||
| 257 | + if(schId==''){ | ||
| 258 | + notify_err("请选择班次"); | ||
| 259 | + return; | ||
| 260 | + } | ||
| 261 | + var sch = gb_schedule_table.findScheduleByLine(lineCode)[schId]; | ||
| 262 | + var confirmBtn = $(this).parent().find('.uk-button-primary'); | ||
| 263 | + var fun =gb_schedule_context_menu.cxsf; | ||
| 264 | + fun(sch, function () { | ||
| 265 | + confirmBtn.trigger('click'); | ||
| 266 | + }); | ||
| 267 | + return; | ||
| 268 | + } | ||
| 269 | + else if(responseText[1]=="21"){//调整待发 | ||
| 270 | + if(schId==''){ | ||
| 271 | + notify_err("请选择班次"); | ||
| 272 | + return; | ||
| 273 | + } | ||
| 274 | + var sch = gb_schedule_table.findScheduleByLine(lineCode)[schId]; | ||
| 275 | + var confirmBtn = $(this).parent().find('.uk-button-primary'); | ||
| 276 | + var fun =gb_schedule_context_menu.dftz; | ||
| 277 | + fun(sch, function () { | ||
| 278 | + confirmBtn.trigger('click'); | ||
| 279 | + }); | ||
| 280 | + return; | ||
| 281 | + } | ||
| 282 | + else if(responseText[1]=="22"){//调整实发 | ||
| 283 | + if(schId==''){ | ||
| 284 | + notify_err("请选择班次"); | ||
| 285 | + return; | ||
| 286 | + } | ||
| 287 | + var sch = gb_schedule_table.findScheduleByLine(lineCode)[schId]; | ||
| 288 | + var confirmBtn = $(this).parent().find('.uk-button-primary'); | ||
| 289 | + var fun =gb_schedule_context_menu.sftz; | ||
| 290 | + fun(sch, function () { | ||
| 291 | + confirmBtn.trigger('click'); | ||
| 292 | + }); | ||
| 293 | + return; | ||
| 294 | + } | ||
| 295 | + else if(responseText[1]=="31"){ | ||
| 296 | + notify_succ("开启智能调度"); | ||
| 297 | + }else if(responseText[1]=="41"){ | ||
| 298 | + notify_succ("关闭智能调度"); | ||
| 299 | + }else if(responseText[1]=="999"){ | ||
| 300 | + console.log(responseText[0]); | ||
| 301 | + notify_err(error); | ||
| 209 | } | 302 | } |
| 210 | - $.post('/logZndd/schlist',date,function(sch) { | ||
| 211 | - debugger | ||
| 212 | - sch.qdzCode = responseText[1]; | ||
| 213 | - sch.zdzCode = responseText[2]; | ||
| 214 | - sch.xlDir = responseText[3]; | ||
| 215 | - sch.zdsjActual = moment(new Date()).format("HH:mm") | ||
| 216 | - | ||
| 217 | - open_modal(folder + '/temp_sch/main.html', { | ||
| 218 | - sch: sch | ||
| 219 | - }, modal_opts); | ||
| 220 | - }); | ||
| 221 | - | ||
| 222 | - | ||
| 223 | 303 | ||
| 224 | } | 304 | } |
| 225 | }; | 305 | }; |
| 226 | 306 | ||
| 307 | + function getCarPark(sch){ | ||
| 308 | + var st_park_data = gb_data_basic.get_stat_park_data()[sch.xlBm]; | ||
| 309 | + //停车场 | ||
| 310 | + var parks = gb_data_basic.simpleParksArray(); | ||
| 311 | + //线路标准 | ||
| 312 | + var information = gb_data_basic.getLineInformation(sch.xlBm); | ||
| 313 | + //停车场排序,常用的放前面 | ||
| 314 | + return sort_parks(parks, information, st_park_data); | ||
| 315 | + } | ||
| 316 | + /** | ||
| 317 | + * 停车场排序 | ||
| 318 | + * @param parks 停车场 code 2 name | ||
| 319 | + * @param information 线路标准 | ||
| 320 | + * @param st_park_data 站到场 | ||
| 321 | + */ | ||
| 322 | + function sort_parks(parks, information, st_park_data) { | ||
| 323 | + var array = [], names=[]; | ||
| 324 | + for(var code in parks){ | ||
| 325 | + array.push({code: code, name: parks[code]}); | ||
| 326 | + } | ||
| 327 | + | ||
| 328 | + if(st_park_data && st_park_data.length > 0){ | ||
| 329 | + $.each(st_park_data, function () { | ||
| 330 | + names.push(this.parkName); | ||
| 331 | + }); | ||
| 332 | + } | ||
| 227 | 333 | ||
| 334 | + //debugger | ||
| 335 | + array.sort(function (a, b) { | ||
| 336 | + if(a.code==information.carPark) | ||
| 337 | + return -1; | ||
| 338 | + if(b.code==information.carPark) | ||
| 339 | + return 1; | ||
| 340 | + | ||
| 341 | + var ai = names.indexOf(a.name), | ||
| 342 | + bi = names.indexOf(b.name); | ||
| 343 | + | ||
| 344 | + if(ai!=-1 && bi==-1) | ||
| 345 | + return -1; | ||
| 346 | + else if(ai==-1 && bi!=-1) | ||
| 347 | + return 1; | ||
| 348 | + else | ||
| 349 | + return $.trim(a.name).localeCompare($.trim(b.name), 'zh-CN'); | ||
| 350 | + }); | ||
| 351 | + return array; | ||
| 352 | + } | ||
| 353 | + const getCookie = (name) => { | ||
| 354 | + const value = `; ${document.cookie}`; | ||
| 355 | + const parts = value.split(`; ${name}=`); | ||
| 356 | + if (parts.length === 2) return parts.pop().split(';').shift(); | ||
| 357 | + } | ||
| 228 | /* ti = 0; | 358 | /* ti = 0; |
| 229 | timeInt =setInterval(function(){leftTimer(xhr);},1000); //开始倒计时*/ | 359 | timeInt =setInterval(function(){leftTimer(xhr);},1000); //开始倒计时*/ |
| 230 | } | 360 | } |