Commit f92fbfdb00520203586519ad2263c65f9c7d47cf
1 parent
7e9c61c6
1
Showing
10 changed files
with
680 additions
and
41 deletions
src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
| @@ -149,6 +149,23 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, | @@ -149,6 +149,23 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, | ||
| 149 | return scheduleRealInfoService.realOutAdjust(map); | 149 | return scheduleRealInfoService.realOutAdjust(map); |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | + | ||
| 153 | + | ||
| 154 | + /** | ||
| 155 | + * | ||
| 156 | + * @Title: realOutAdjust | ||
| 157 | + * @Description: TODO(实发调整)智能调度 | ||
| 158 | + * @param @param id 班次ID | ||
| 159 | + * @param @param fcsjActual 实际发车时间 HH:mm | ||
| 160 | + * @param @param remarks 备注 | ||
| 161 | + * @throws | ||
| 162 | + */ | ||
| 163 | + @RequestMapping(value = "/realOutAdjust_zndd", method = RequestMethod.POST) | ||
| 164 | + public Map<String, Object> realOutAdjust_zndd(@RequestParam Map<String, String> map) { | ||
| 165 | + return scheduleRealInfoService.realOutAdjust_zndd(map); | ||
| 166 | + } | ||
| 167 | + | ||
| 168 | + | ||
| 152 | /** | 169 | /** |
| 153 | * | 170 | * |
| 154 | * @Title: revokeDestroy | 171 | * @Title: revokeDestroy |
| @@ -173,6 +190,19 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, | @@ -173,6 +190,19 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, | ||
| 173 | return scheduleRealInfoService.revokeRealOutgo(id); | 190 | return scheduleRealInfoService.revokeRealOutgo(id); |
| 174 | } | 191 | } |
| 175 | 192 | ||
| 193 | + | ||
| 194 | + /** | ||
| 195 | + * | ||
| 196 | + * @Title: revokeRealOutgo | ||
| 197 | + * @Description: TODO(撤销实发) 智能调度 | ||
| 198 | + * @param @param id | ||
| 199 | + * @throws | ||
| 200 | + */ | ||
| 201 | + @RequestMapping(value = "/revokeRealOutgo_zndd", method = RequestMethod.POST) | ||
| 202 | + public Map<String, Object> revokeRealOutgo_zndd(@RequestParam Long id, @RequestParam String remarks){ | ||
| 203 | + return scheduleRealInfoService.revokeRealOutgo_zndd(id,remarks); | ||
| 204 | + } | ||
| 205 | + | ||
| 176 | /** | 206 | /** |
| 177 | * 撤销执行 | 207 | * 撤销执行 |
| 178 | * @param id | 208 | * @param id |
src/main/java/com/bsth/data/zndd/AutomaticSch.java
| @@ -148,7 +148,7 @@ public class AutomaticSch { | @@ -148,7 +148,7 @@ public class AutomaticSch { | ||
| 148 | } | 148 | } |
| 149 | //第一种 设备离线的情况下改出站 | 149 | //第一种 设备离线的情况下改出站 |
| 150 | Integer staus = 0; //状态 | 150 | Integer staus = 0; //状态 |
| 151 | - if (StringUtils.isEmpty(sr.getFcsjActual()) && sr.getRemarks() == null) { | 151 | + if (StringUtils.isEmpty(sr.getFcsjActual()) && sr.getBcType().equals("normal") && sr.getRemarks() == null) { |
| 152 | 152 | ||
| 153 | GpsEntity gps = gpsRealData.getByNbbm(sr.getClZbh()); | 153 | GpsEntity gps = gpsRealData.getByNbbm(sr.getClZbh()); |
| 154 | //当前设备离线的情况 | 154 | //当前设备离线的情况 |
| @@ -187,7 +187,7 @@ public class AutomaticSch { | @@ -187,7 +187,7 @@ public class AutomaticSch { | ||
| 187 | Collections.sort(oldSchDateList, new ScheduleComparator.FCSJ()); | 187 | Collections.sort(oldSchDateList, new ScheduleComparator.FCSJ()); |
| 188 | for (ScheduleRealInfo t : oldSchDateList){ | 188 | for (ScheduleRealInfo t : oldSchDateList){ |
| 189 | // 发车误点 | 189 | // 发车误点 |
| 190 | - if (t.getFcsj() != null && t.getFcsjActual() != null && t.getRemarks() == null){ | 190 | + if (t.getFcsj() != null && t.getFcsjActual() != null && t.getBcType().equals("normal") && t.getRemarks() == null){ |
| 191 | Long sst = ((t.getFcsjActualTime() - t.getFcsjT()) / 1000 / 60); | 191 | Long sst = ((t.getFcsjActualTime() - t.getFcsjT()) / 1000 / 60); |
| 192 | Long dfsj = t.getDfsjT() / 1000 ; | 192 | Long dfsj = t.getDfsjT() / 1000 ; |
| 193 | Long sfsj = t.getFcsjActualTime() / 1000; | 193 | Long sfsj = t.getFcsjActualTime() / 1000; |
src/main/java/com/bsth/data/zndd/ZnddThread.java
| @@ -22,7 +22,7 @@ import java.util.*; | @@ -22,7 +22,7 @@ import java.util.*; | ||
| 22 | */ | 22 | */ |
| 23 | @Component | 23 | @Component |
| 24 | public class ZnddThread extends Thread{ | 24 | public class ZnddThread extends Thread{ |
| 25 | - | 25 | + |
| 26 | Logger logger = LoggerFactory.getLogger(this.getClass()); | 26 | Logger logger = LoggerFactory.getLogger(this.getClass()); |
| 27 | /*@Autowired | 27 | /*@Autowired |
| 28 | StationPeopleLoggerRepository stationPeopleLoggerRepository;*/ | 28 | StationPeopleLoggerRepository stationPeopleLoggerRepository;*/ |
| @@ -34,53 +34,57 @@ public class ZnddThread extends Thread{ | @@ -34,53 +34,57 @@ public class ZnddThread extends Thread{ | ||
| 34 | GpsRealData gpsRealData; | 34 | GpsRealData gpsRealData; |
| 35 | @Autowired | 35 | @Autowired |
| 36 | StationRouteRepository stationRouteRepository; | 36 | StationRouteRepository stationRouteRepository; |
| 37 | -/* @Autowired | ||
| 38 | - private UserCarCountHandler userCarCountHandler;*/ | 37 | + /* @Autowired |
| 38 | + private UserCarCountHandler userCarCountHandler;*/ | ||
| 39 | @Autowired | 39 | @Autowired |
| 40 | OutEntrance outEntrance; | 40 | OutEntrance outEntrance; |
| 41 | @Autowired | 41 | @Autowired |
| 42 | AutomaticSch automaticSch; | 42 | AutomaticSch automaticSch; |
| 43 | - | 43 | + |
| 44 | @Autowired | 44 | @Autowired |
| 45 | ZnddStatusRepository znddStatusRepository; | 45 | ZnddStatusRepository znddStatusRepository; |
| 46 | - | 46 | + |
| 47 | static Map<String,List> ZNDDTYPEMAP = new HashMap<>(); //已经推送过的检测 | 47 | static Map<String,List> ZNDDTYPEMAP = new HashMap<>(); //已经推送过的检测 |
| 48 | - | ||
| 49 | - | 48 | + |
| 49 | + | ||
| 50 | String url = "https://lgapp.bsth.tech:13089/bsth_passengerflow/klbus/currentInsideNum.do"; //车内客流接口 | 50 | String url = "https://lgapp.bsth.tech:13089/bsth_passengerflow/klbus/currentInsideNum.do"; //车内客流接口 |
| 51 | - | ||
| 52 | - | 51 | + |
| 52 | + | ||
| 53 | String urldkl = "https://lgapp.bsth.tech:8005//monitor/api/getMonitorInfoByDay?key=1&solt=1111&t=1&dayStr="; //大客流接口 | 53 | String urldkl = "https://lgapp.bsth.tech:8005//monitor/api/getMonitorInfoByDay?key=1&solt=1111&t=1&dayStr="; //大客流接口 |
| 54 | - | 54 | + |
| 55 | private static SimpleDateFormat sdfHHmm = new SimpleDateFormat("HH:mm"); | 55 | private static SimpleDateFormat sdfHHmm = new SimpleDateFormat("HH:mm"); |
| 56 | private static SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"); | 56 | private static SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"); |
| 57 | private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); | 57 | private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| 58 | @Override | 58 | @Override |
| 59 | public void run() { | 59 | public void run() { |
| 60 | - List<znddStatus> znddStatusList = (List<znddStatus>) znddStatusRepository.findAll(); | ||
| 61 | - //FCJG();//发车间隔检查 报价 | ||
| 62 | - //GPSDJG();//大间隔 | ||
| 63 | - // MZ(); //满载 | ||
| 64 | - //DKL(); //大客流 以接口方式 | ||
| 65 | - //automaticSch.mz(); | ||
| 66 | - //automaticSch.dfTz();//大间隔 | ||
| 67 | - //automaticSch.drivresponse(); //设备重发 | ||
| 68 | - for (znddStatus zs : znddStatusList){ | ||
| 69 | - | ||
| 70 | - if (zs.getOpenStatus().equals("0")) { | ||
| 71 | - if (zs.getType().equals("sftz")) { | ||
| 72 | - automaticSch.sftz();//实发调整 | ||
| 73 | - logger.info("实发执行完毕"); | ||
| 74 | - } | ||
| 75 | - if (zs.getType().equals("ycsf")) { | ||
| 76 | - automaticSch.sfCX();// 异常实发 - 实发撤销 | ||
| 77 | - logger.info("异常实发执行完毕"); | 60 | + try { |
| 61 | + List<znddStatus> znddStatusList = (List<znddStatus>) znddStatusRepository.findAll(); | ||
| 62 | + //FCJG();//发车间隔检查 报价 | ||
| 63 | + //GPSDJG();//大间隔 | ||
| 64 | + // MZ(); //满载 | ||
| 65 | + //DKL(); //大客流 以接口方式 | ||
| 66 | + //automaticSch.mz(); | ||
| 67 | + //automaticSch.dfTz();//大间隔 | ||
| 68 | + //automaticSch.drivresponse(); //设备重发 | ||
| 69 | + for (znddStatus zs : znddStatusList) { | ||
| 70 | + | ||
| 71 | + if (zs.getOpenStatus().equals("0")) { | ||
| 72 | + if (zs.getType().equals("sftz")) { | ||
| 73 | + automaticSch.sftz();//实发调整 | ||
| 74 | + logger.info("实发执行完毕"); | ||
| 75 | + } | ||
| 76 | + if (zs.getType().equals("ycsf")) { | ||
| 77 | + automaticSch.sfCX();// 异常实发 - 实发撤销 | ||
| 78 | + logger.info("异常实发执行完毕"); | ||
| 79 | + } | ||
| 78 | } | 80 | } |
| 79 | } | 81 | } |
| 82 | + }catch (Exception e){ | ||
| 83 | + logger.info("智能调度线程——————",e); | ||
| 80 | } | 84 | } |
| 81 | - | ||
| 82 | - | ||
| 83 | - | 85 | + |
| 86 | + | ||
| 87 | + | ||
| 84 | } | 88 | } |
| 85 | //满载 | 89 | //满载 |
| 86 | /* public void MZ(){ | 90 | /* public void MZ(){ |
| @@ -198,8 +202,8 @@ public class ZnddThread extends Thread{ | @@ -198,8 +202,8 @@ public class ZnddThread extends Thread{ | ||
| 198 | logger.error("发车间隔检测出现出错-----------",e); | 202 | logger.error("发车间隔检测出现出错-----------",e); |
| 199 | } | 203 | } |
| 200 | }*/ | 204 | }*/ |
| 201 | - | ||
| 202 | - | 205 | + |
| 206 | + | ||
| 203 | //转换 | 207 | //转换 |
| 204 | public Map addStationPeople(ScheduleRealInfo info,String type,Long sst,String sj) throws ParseException{ | 208 | public Map addStationPeople(ScheduleRealInfo info,String type,Long sst,String sj) throws ParseException{ |
| 205 | Map sp = new HashMap(); | 209 | Map sp = new HashMap(); |
| @@ -212,9 +216,9 @@ public class ZnddThread extends Thread{ | @@ -212,9 +216,9 @@ public class ZnddThread extends Thread{ | ||
| 212 | sp.put("numType",sst); | 216 | sp.put("numType",sst); |
| 213 | return sp; | 217 | return sp; |
| 214 | } | 218 | } |
| 215 | - | ||
| 216 | 219 | ||
| 217 | - | 220 | + |
| 221 | + | ||
| 218 | //排序 | 222 | //排序 |
| 219 | public static class GpsComp implements Comparator<GpsEntity> { | 223 | public static class GpsComp implements Comparator<GpsEntity> { |
| 220 | @Override | 224 | @Override |
| @@ -222,6 +226,6 @@ public class ZnddThread extends Thread{ | @@ -222,6 +226,6 @@ public class ZnddThread extends Thread{ | ||
| 222 | return Integer.parseInt(o1.getRemark()) - Integer.parseInt(o2.getRemark()); | 226 | return Integer.parseInt(o1.getRemark()) - Integer.parseInt(o2.getRemark()); |
| 223 | } | 227 | } |
| 224 | } | 228 | } |
| 225 | - | 229 | + |
| 226 | } | 230 | } |
| 227 | 231 |
src/main/java/com/bsth/service/realcontrol/ScheduleRealInfoService.java
| @@ -80,10 +80,14 @@ public interface ScheduleRealInfoService extends BaseService<ScheduleRealInfo, L | @@ -80,10 +80,14 @@ public interface ScheduleRealInfoService extends BaseService<ScheduleRealInfo, L | ||
| 80 | 80 | ||
| 81 | Map<String, Object> realOutAdjust(Map<String, String> map); | 81 | Map<String, Object> realOutAdjust(Map<String, String> map); |
| 82 | 82 | ||
| 83 | + Map<String, Object> realOutAdjust_zndd(Map<String, String> map); | ||
| 84 | + | ||
| 83 | Map<String, Object> revokeDestroy(Long id); | 85 | Map<String, Object> revokeDestroy(Long id); |
| 84 | 86 | ||
| 85 | Map<String, Object> revokeRealOutgo(Long id); | 87 | Map<String, Object> revokeRealOutgo(Long id); |
| 86 | - | 88 | + |
| 89 | + Map<String, Object> revokeRealOutgo_zndd(Long id,String remarks); | ||
| 90 | + | ||
| 87 | Map<String, Object> spaceAdjust(Long[] ids, Integer space); | 91 | Map<String, Object> spaceAdjust(Long[] ids, Integer space); |
| 88 | 92 | ||
| 89 | Map<String, Object> schInfoFineTune(Map<String, String> map); | 93 | Map<String, Object> schInfoFineTune(Map<String, String> map); |
| @@ -203,4 +207,6 @@ public interface ScheduleRealInfoService extends BaseService<ScheduleRealInfo, L | @@ -203,4 +207,6 @@ public interface ScheduleRealInfoService extends BaseService<ScheduleRealInfo, L | ||
| 203 | List<RepairReport> repairReportList(String line,String date,String code, String type); | 207 | List<RepairReport> repairReportList(String line,String date,String code, String type); |
| 204 | 208 | ||
| 205 | Map<String, String> getLevelsByLines(List<String> lines); | 209 | Map<String, String> getLevelsByLines(List<String> lines); |
| 210 | + | ||
| 211 | + List<ScheduleRealInfo> findAllSchDate(String schDate); | ||
| 206 | } | 212 | } |
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
| @@ -29,6 +29,8 @@ import java.util.concurrent.*; | @@ -29,6 +29,8 @@ import java.util.concurrent.*; | ||
| 29 | import java.util.regex.Pattern; | 29 | import java.util.regex.Pattern; |
| 30 | 30 | ||
| 31 | import com.bsth.data.SystemParamCache; | 31 | import com.bsth.data.SystemParamCache; |
| 32 | +import com.bsth.entity.zndd.LoggerZndd; | ||
| 33 | +import com.bsth.repository.zndd.LoggerZnddRepository; | ||
| 32 | import org.apache.commons.io.IOUtils; | 34 | import org.apache.commons.io.IOUtils; |
| 33 | import org.apache.commons.lang3.StringEscapeUtils; | 35 | import org.apache.commons.lang3.StringEscapeUtils; |
| 34 | import org.apache.commons.lang3.StringUtils; | 36 | import org.apache.commons.lang3.StringUtils; |
| @@ -222,6 +224,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | @@ -222,6 +224,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | ||
| 222 | 224 | ||
| 223 | @Autowired | 225 | @Autowired |
| 224 | RepairReportRepository repairReportRepository; | 226 | RepairReportRepository repairReportRepository; |
| 227 | + | ||
| 228 | + @Autowired | ||
| 229 | + LoggerZnddRepository loggerZnddRepository; | ||
| 225 | 230 | ||
| 226 | Logger logger = LoggerFactory.getLogger(this.getClass()); | 231 | Logger logger = LoggerFactory.getLogger(this.getClass()); |
| 227 | 232 | ||
| @@ -1577,6 +1582,59 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | @@ -1577,6 +1582,59 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | ||
| 1577 | return rs; | 1582 | return rs; |
| 1578 | } | 1583 | } |
| 1579 | 1584 | ||
| 1585 | + | ||
| 1586 | + | ||
| 1587 | + @Override | ||
| 1588 | + public Map<String, Object> realOutAdjust_zndd(Map<String, String> map) { | ||
| 1589 | + Map<String, Object> rs = new HashMap<>(); | ||
| 1590 | + List<ScheduleRealInfo> ts = new ArrayList<>(); | ||
| 1591 | + try { | ||
| 1592 | + Long id = Long.parseLong(map.get("id")); | ||
| 1593 | + String remarks = map.get("remarks"), fcsjActual = map.get("fcsjActual"); | ||
| 1594 | + | ||
| 1595 | + ScheduleRealInfo sch = dayOfSchedule.get(id); | ||
| 1596 | + | ||
| 1597 | + LineConfig config = lineConfigData.get(sch.getXlBm()); | ||
| 1598 | + //小于线路开始运营时间,则默认跨过24点 | ||
| 1599 | + if (fcsjActual.compareTo(config.getStartOpt()) < 0) { | ||
| 1600 | + sch.setRealExecDate(fmtyyyyMMdd.print(sch.getScheduleDate().getTime() + DAY_TIME)); | ||
| 1601 | + } else { | ||
| 1602 | + sch.setRealExecDate(sch.getScheduleDateStr()); | ||
| 1603 | + } | ||
| 1604 | + //日志记录 | ||
| 1605 | + ScheduleModifyLogger.sftz(sch, fcsjActual, remarks); | ||
| 1606 | + sch.setFcsjActualAll(fcsjActual); | ||
| 1607 | + sch.setRemarks(remarks); | ||
| 1608 | + sch.calcStatus(); | ||
| 1609 | + //if(sch.isLate2()){ | ||
| 1610 | + //取消应发未到标记 | ||
| 1611 | + // sch.setLate2(false); | ||
| 1612 | + LateAdjustHandle.remove(sch); | ||
| 1613 | + //} | ||
| 1614 | + | ||
| 1615 | + dayOfSchedule.save(sch); | ||
| 1616 | + | ||
| 1617 | + ts.add(sch); | ||
| 1618 | + | ||
| 1619 | + rs.put("status", ResponseCode.SUCCESS); | ||
| 1620 | + rs.put("ts", ts); | ||
| 1621 | + | ||
| 1622 | + LoggerZndd lz = new LoggerZndd(); | ||
| 1623 | + String text = sch.getFcsj()+"的班次进行了实发调整"; | ||
| 1624 | + lz.setText(text); | ||
| 1625 | + lz.setCreateBy(SecurityUtils.getCurrentUser().getId()); | ||
| 1626 | + loggerZnddRepository.save(lz); | ||
| 1627 | + | ||
| 1628 | + //通知页面刷新 | ||
| 1629 | + sendUtils.refreshSch(ts); | ||
| 1630 | + } catch (Exception e) { | ||
| 1631 | + logger.error("", e); | ||
| 1632 | + rs.put("status", ResponseCode.ERROR); | ||
| 1633 | + } | ||
| 1634 | + | ||
| 1635 | + return rs; | ||
| 1636 | + } | ||
| 1637 | + | ||
| 1580 | @Override | 1638 | @Override |
| 1581 | public Map<String, Object> revokeDestroy(Long id) { | 1639 | public Map<String, Object> revokeDestroy(Long id) { |
| 1582 | Map<String, Object> rs = new HashMap<>(); | 1640 | Map<String, Object> rs = new HashMap<>(); |
| @@ -1639,6 +1697,42 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | @@ -1639,6 +1697,42 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | ||
| 1639 | } | 1697 | } |
| 1640 | 1698 | ||
| 1641 | @Override | 1699 | @Override |
| 1700 | + public Map<String, Object> revokeRealOutgo_zndd(Long id,String remarks){ | ||
| 1701 | + Map<String, Object> rs = new HashMap<>(); | ||
| 1702 | + List<ScheduleRealInfo> ts = new ArrayList<>(); | ||
| 1703 | + | ||
| 1704 | + try { | ||
| 1705 | + ScheduleRealInfo sch = dayOfSchedule.get(id); | ||
| 1706 | + if (sch.getFcsjActual() == null) { | ||
| 1707 | + rs.put("status", ResponseCode.ERROR); | ||
| 1708 | + rs.put("msg", "无实发时间,无法撤销!"); | ||
| 1709 | + } else { | ||
| 1710 | + //日志记录 | ||
| 1711 | + ScheduleModifyLogger.cxsf(sch); | ||
| 1712 | + | ||
| 1713 | + sch.clearFcsjActual(); | ||
| 1714 | + sch.setRemarks(remarks); | ||
| 1715 | + rs.put("status", ResponseCode.SUCCESS); | ||
| 1716 | + | ||
| 1717 | + ts.add(sch); | ||
| 1718 | + rs.put("ts", ts); | ||
| 1719 | + | ||
| 1720 | + dayOfSchedule.save(sch); | ||
| 1721 | + | ||
| 1722 | + LoggerZndd lz = new LoggerZndd(); | ||
| 1723 | + String text = sch.getFcsj()+"的班次进行了实发撤销调整"; | ||
| 1724 | + lz.setText(text); | ||
| 1725 | + lz.setCreateBy(SecurityUtils.getCurrentUser().getId()); | ||
| 1726 | + loggerZnddRepository.save(lz); | ||
| 1727 | + } | ||
| 1728 | + } catch (Exception e) { | ||
| 1729 | + logger.error("", e); | ||
| 1730 | + rs.put("status", ResponseCode.ERROR); | ||
| 1731 | + } | ||
| 1732 | + return rs; | ||
| 1733 | + } | ||
| 1734 | + | ||
| 1735 | + @Override | ||
| 1642 | public Map<String, Object> spaceAdjust(Long[] ids, Integer space) { | 1736 | public Map<String, Object> spaceAdjust(Long[] ids, Integer space) { |
| 1643 | 1737 | ||
| 1644 | List<ScheduleRealInfo> list = new ArrayList<>(), ts = new ArrayList<>(), tempTs = null; | 1738 | List<ScheduleRealInfo> list = new ArrayList<>(), ts = new ArrayList<>(), tempTs = null; |
| @@ -6844,7 +6938,10 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | @@ -6844,7 +6938,10 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | ||
| 6844 | // TODO Auto-generated method stub | 6938 | // TODO Auto-generated method stub |
| 6845 | exec.shutdown(); | 6939 | exec.shutdown(); |
| 6846 | } | 6940 | } |
| 6847 | - | 6941 | + @Override |
| 6942 | + public List<ScheduleRealInfo> findAllSchDate(String schDate) { | ||
| 6943 | + return scheduleRealInfoRepository.findAllSchDate(schDate); | ||
| 6944 | + } | ||
| 6848 | 6945 | ||
| 6849 | @Override | 6946 | @Override |
| 6850 | public void afterPropertiesSet() throws Exception { | 6947 | public void afterPropertiesSet() throws Exception { |
src/main/resources/static/real_control_v2/js/stationcf/imgs.html
0 → 100644
src/main/resources/static/real_control_v2/js/stationcf/stationcf.js
0 → 100644
| 1 | +/** | ||
| 2 | + * 站点催发 | ||
| 3 | + */ | ||
| 4 | +var gb_stationcf = (function () { | ||
| 5 | + var $wrap = $('.multi_plat_msg_pop_cf'); | ||
| 6 | + var max = 5; | ||
| 7 | + | ||
| 8 | + var popcf = function (data) { | ||
| 9 | + //时间格式化 | ||
| 10 | + var stm = moment(data.instructionsTime); | ||
| 11 | + data.timeStr = stm.format('HH时mm分ss秒'); | ||
| 12 | + data.type = 'cp'; | ||
| 13 | + | ||
| 14 | + debugger | ||
| 15 | + let stopNo =data.station +"_"+ data.dir; | ||
| 16 | + gb_svg_chart.people(data.lineCode,stopNo,data.num,data.image); | ||
| 17 | + | ||
| 18 | + var htmlStr = template('cf_plat_msg_template', data); | ||
| 19 | + var items = $wrap.find('.multi_plat_msg_pops'), len = items.length; | ||
| 20 | + if (len >= max) | ||
| 21 | + $wrap.find('.multi_plat_msg_pops:lt(' + (len - max) + ')').remove(); | ||
| 22 | + | ||
| 23 | + $wrap.append(htmlStr); | ||
| 24 | + }; | ||
| 25 | + | ||
| 26 | + | ||
| 27 | + $wrap.on('click', '.all', function () { | ||
| 28 | + var type = $(this).data('ip'); | ||
| 29 | + let pageUrl ="/real_control_v2/call/index.html"; | ||
| 30 | + //将片段路径写入 localStorage | ||
| 31 | + window.localStorage.setItem('real_control_form_embed_pageUrl', pageUrl); | ||
| 32 | + var index = layer.open({ | ||
| 33 | + type: 2, | ||
| 34 | + title: '语音通话', | ||
| 35 | + shadeClose: true, | ||
| 36 | + shade: false, | ||
| 37 | + area: ['450px', '740px'], | ||
| 38 | + content: pageUrl, | ||
| 39 | + zIndex: layer.zIndex, | ||
| 40 | + success: function(layero){ | ||
| 41 | + layer.setTop(layero); | ||
| 42 | + }, | ||
| 43 | + end: function () { | ||
| 44 | + | ||
| 45 | + } | ||
| 46 | + }); | ||
| 47 | + //layer.full(index);//全屏 | ||
| 48 | + | ||
| 49 | + }); | ||
| 50 | + | ||
| 51 | + | ||
| 52 | + $wrap.on('click', '.images', function () { | ||
| 53 | + debugger | ||
| 54 | + var image = $(this).data('image'); | ||
| 55 | + var imgHtml = "<img src='" + image + "' style='width: " + 600 + "px;height:" + 300 + "px'/>"; | ||
| 56 | + layer.open({ | ||
| 57 | + type: 1, | ||
| 58 | + offset: 'auto', | ||
| 59 | + area: [600 + 'px', 300 + 'px'], | ||
| 60 | + shadeClose: true,//点击外围关闭弹窗 | ||
| 61 | + scrollbar: true,//不现实滚动条 | ||
| 62 | + title: false, //不显示标题 | ||
| 63 | + content: imgHtml, //捕获的元素,注意:最好该指定的元素要存放在body最外层,否则可能被其它的相对元素所影响 | ||
| 64 | + cancel: function () { | ||
| 65 | + | ||
| 66 | + } | ||
| 67 | + }) | ||
| 68 | + | ||
| 69 | + }); | ||
| 70 | + | ||
| 71 | + return { | ||
| 72 | + popcf: popcf | ||
| 73 | + } | ||
| 74 | +})(); | ||
| 0 | \ No newline at end of file | 75 | \ No newline at end of file |
src/main/resources/static/real_control_v2/js/websocket/sch_websocket.js
| @@ -196,6 +196,16 @@ var gb_sch_websocket = (function () { | @@ -196,6 +196,16 @@ var gb_sch_websocket = (function () { | ||
| 196 | debugger | 196 | debugger |
| 197 | gb_con_plan.pop(msg.data); | 197 | gb_con_plan.pop(msg.data); |
| 198 | }; | 198 | }; |
| 199 | + //站点催发 | ||
| 200 | + var stationcf = function (msg){ | ||
| 201 | + gb_stationcf.popcf(msg.data); | ||
| 202 | + }; | ||
| 203 | + //智能调度 | ||
| 204 | + var zndd = function (msg) { | ||
| 205 | + | ||
| 206 | + gb_dataZndd.sop(msg.data); | ||
| 207 | + } | ||
| 208 | + | ||
| 199 | 209 | ||
| 200 | var msgHandle = { | 210 | var msgHandle = { |
| 201 | report80: report80, | 211 | report80: report80, |
| @@ -209,7 +219,9 @@ var gb_sch_websocket = (function () { | @@ -209,7 +219,9 @@ var gb_sch_websocket = (function () { | ||
| 209 | safeDriv: safeDriv, | 219 | safeDriv: safeDriv, |
| 210 | auto_wdtz: autoWdtz, | 220 | auto_wdtz: autoWdtz, |
| 211 | rfid: refreshRfid, | 221 | rfid: refreshRfid, |
| 212 | - contingencyPlan: contingencyPlan | 222 | + contingencyPlan: contingencyPlan, |
| 223 | + stationcf: stationcf, | ||
| 224 | + zndd : zndd | ||
| 213 | }; | 225 | }; |
| 214 | 226 | ||
| 215 | function currentSecond() { | 227 | function currentSecond() { |
src/main/resources/static/real_control_v2/js/zndd/recorder/recorder.js
0 → 100644
| 1 | +(function (window) { | ||
| 2 | + //兼容 | ||
| 3 | + window.URL = window.URL || window.webkitURL; | ||
| 4 | + navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia; | ||
| 5 | + | ||
| 6 | + | ||
| 7 | + const zzdopen="已打开无人调度"; | ||
| 8 | + const zzdclone="已关闭无人调度"; | ||
| 9 | + const error="'未匹配到对应操作,请重新下达指令!"; | ||
| 10 | + const nosche="当天没有排班"; | ||
| 11 | + | ||
| 12 | + | ||
| 13 | + var HZRecorder = function (stream, config) { | ||
| 14 | + config = config || {}; | ||
| 15 | + config.sampleBits = config.sampleBits || 16; //采样数位 8, 16 | ||
| 16 | + config.sampleRate = config.sampleRate || (16000); //采样率(1/6 44100) | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + var context = new AudioContext(); | ||
| 20 | + var audioInput = context.createMediaStreamSource(stream); | ||
| 21 | + var recorder = context.createScriptProcessor(4096, 1, 1); | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + var audioData = { | ||
| 25 | + size: 0 //录音文件长度 | ||
| 26 | + , buffer: [] //录音缓存 | ||
| 27 | + , inputSampleRate: context.sampleRate //输入采样率 | ||
| 28 | + , inputSampleBits: 16 //输入采样数位 8, 16 | ||
| 29 | + , outputSampleRate: config.sampleRate //输出采样率 | ||
| 30 | + , oututSampleBits: config.sampleBits //输出采样数位 8, 16 | ||
| 31 | + , input: function (data) { | ||
| 32 | + this.buffer.push(new Float32Array(data)); | ||
| 33 | + this.size += data.length; | ||
| 34 | + } | ||
| 35 | + , compress: function () { //合并压缩 | ||
| 36 | + //合并 | ||
| 37 | + var data = new Float32Array(this.size); | ||
| 38 | + var offset = 0; | ||
| 39 | + for (var i = 0; i < this.buffer.length; i++) { | ||
| 40 | + data.set(this.buffer[i], offset); | ||
| 41 | + offset += this.buffer[i].length; | ||
| 42 | + } | ||
| 43 | + //压缩 | ||
| 44 | + var compression = parseInt(this.inputSampleRate / this.outputSampleRate); | ||
| 45 | + var length = data.length / compression; | ||
| 46 | + var result = new Float32Array(length); | ||
| 47 | + var index = 0, j = 0; | ||
| 48 | + while (index < length) { | ||
| 49 | + result[index] = data[j]; | ||
| 50 | + j += compression; | ||
| 51 | + index++; | ||
| 52 | + } | ||
| 53 | + return result; | ||
| 54 | + } | ||
| 55 | + , encodeWAV: function () { | ||
| 56 | + var sampleRate = Math.min(this.inputSampleRate, this.outputSampleRate); | ||
| 57 | + var sampleBits = Math.min(this.inputSampleBits, this.oututSampleBits); | ||
| 58 | + var bytes = this.compress(); | ||
| 59 | + var dataLength = bytes.length * (sampleBits / 8); | ||
| 60 | + var buffer = new ArrayBuffer(44 + dataLength); | ||
| 61 | + var data = new DataView(buffer); | ||
| 62 | + | ||
| 63 | + | ||
| 64 | + var channelCount = 1;//单声道 | ||
| 65 | + var offset = 0; | ||
| 66 | + | ||
| 67 | + | ||
| 68 | + var writeString = function (str) { | ||
| 69 | + for (var i = 0; i < str.length; i++) { | ||
| 70 | + data.setUint8(offset + i, str.charCodeAt(i)); | ||
| 71 | + } | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + // 资源交换文件标识符 | ||
| 75 | + writeString('RIFF'); offset += 4; | ||
| 76 | + // 下个地址开始到文件尾总字节数,即文件大小-8 | ||
| 77 | + data.setUint32(offset, 36 + dataLength, true); offset += 4; | ||
| 78 | + // WAV文件标志 | ||
| 79 | + writeString('WAVE'); offset += 4; | ||
| 80 | + // 波形格式标志 | ||
| 81 | + writeString('fmt '); offset += 4; | ||
| 82 | + // 过滤字节,一般为 0x10 = 16 | ||
| 83 | + data.setUint32(offset, 16, true); offset += 4; | ||
| 84 | + // 格式类别 (PCM形式采样数据) | ||
| 85 | + data.setUint16(offset, 1, true); offset += 2; | ||
| 86 | + // 通道数 | ||
| 87 | + data.setUint16(offset, channelCount, true); offset += 2; | ||
| 88 | + // 采样率,每秒样本数,表示每个通道的播放速度 | ||
| 89 | + data.setUint32(offset, sampleRate, true); offset += 4; | ||
| 90 | + // 波形数据传输率 (每秒平均字节数) 单声道×每秒数据位数×每样本数据位/8 | ||
| 91 | + data.setUint32(offset, channelCount * sampleRate * (sampleBits / 8), true); offset += 4; | ||
| 92 | + // 快数据调整数 采样一次占用字节数 单声道×每样本的数据位数/8 | ||
| 93 | + data.setUint16(offset, channelCount * (sampleBits / 8), true); offset += 2; | ||
| 94 | + // 每样本数据位数 | ||
| 95 | + data.setUint16(offset, sampleBits, true); offset += 2; | ||
| 96 | + // 数据标识符 | ||
| 97 | + writeString('data'); offset += 4; | ||
| 98 | + // 采样数据总数,即数据总大小-44 | ||
| 99 | + data.setUint32(offset, dataLength, true); offset += 4; | ||
| 100 | + // 写入采样数据 | ||
| 101 | + if (sampleBits === 8) { | ||
| 102 | + for (var i = 0; i < bytes.length; i++, offset++) { | ||
| 103 | + var s = Math.max(-1, Math.min(1, bytes[i])); | ||
| 104 | + var val = s < 0 ? s * 0x8000 : s * 0x7FFF; | ||
| 105 | + val = parseInt(255 / (65535 / (val + 32768))); | ||
| 106 | + data.setInt8(offset, val, true); | ||
| 107 | + } | ||
| 108 | + } else { | ||
| 109 | + for (var i = 0; i < bytes.length; i++, offset += 2) { | ||
| 110 | + var s = Math.max(-1, Math.min(1, bytes[i])); | ||
| 111 | + data.setInt16(offset, s < 0 ? s * 0x8000 : s * 0x7FFF, true); | ||
| 112 | + } | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + | ||
| 116 | + return new Blob([data], { type: 'audio/wav' }); | ||
| 117 | + } | ||
| 118 | + }; | ||
| 119 | + | ||
| 120 | + | ||
| 121 | + //开始录音 | ||
| 122 | + this.start = function () { | ||
| 123 | + audioInput.connect(recorder); | ||
| 124 | + recorder.connect(context.destination); | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | + | ||
| 128 | + | ||
| 129 | + var Length = function() { | ||
| 130 | + recorder.onprogress = function(params) { | ||
| 131 | + var id = document.getElementById("len"); | ||
| 132 | + id.innerHTML = "录音时长:" + params.duration.toFixed(2); | ||
| 133 | + var idx = document.getElementById("loud"); | ||
| 134 | + idx.innerHTML = "音量大小:" + params.vol.toFixed(0) + "%"; | ||
| 135 | + microphone.volume("Microphone", params.vol); | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + } | ||
| 139 | + //停止 | ||
| 140 | + this.stop = function () { | ||
| 141 | + audioInput.disconnect(); | ||
| 142 | + recorder.disconnect(); | ||
| 143 | + //关闭录音图标流 | ||
| 144 | + stream.getTracks() // get all tracks from the MediaStream | ||
| 145 | + .forEach( track => track.stop() ); | ||
| 146 | + } | ||
| 147 | + | ||
| 148 | + //获取音频文件 | ||
| 149 | + this.getBlob = function () { | ||
| 150 | + this.stop(); | ||
| 151 | + return audioData.encodeWAV(); | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + | ||
| 155 | + //回放 | ||
| 156 | + this.play = function (audio) { | ||
| 157 | + audio.src = window.URL.createObjectURL(this.getBlob()); | ||
| 158 | + } | ||
| 159 | + | ||
| 160 | + | ||
| 161 | + var timeInt; | ||
| 162 | + //上传 | ||
| 163 | + this.upload = function (url, callback) { | ||
| 164 | + var fd = new FormData(); | ||
| 165 | + fd.append("audioData", this.getBlob()); | ||
| 166 | + var xhr = new XMLHttpRequest(); | ||
| 167 | + if (callback) { | ||
| 168 | + xhr.upload.addEventListener("progress", function (e) { | ||
| 169 | + callback('uploading', e); | ||
| 170 | + }, false); | ||
| 171 | + xhr.addEventListener("load", function (e) { | ||
| 172 | + callback('ok', e); | ||
| 173 | + }, false); | ||
| 174 | + xhr.addEventListener("error", function (e) { | ||
| 175 | + callback('error', e); | ||
| 176 | + }, false); | ||
| 177 | + xhr.addEventListener("abort", function (e) { | ||
| 178 | + callback('cancel', e); | ||
| 179 | + }, false); | ||
| 180 | + } | ||
| 181 | + xhr.open("POST", url); | ||
| 182 | + xhr.send(fd); | ||
| 183 | + | ||
| 184 | + xhr.onreadystatechange = function() { | ||
| 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 | + let switchs = responseText[1]; | ||
| 191 | + let storage = window.localStorage; | ||
| 192 | + if (switchs == 0){ | ||
| 193 | + storage.setItem("switchType", 1); //1开启 | ||
| 194 | + succll(responseText[0],zzdopen); | ||
| 195 | + } else if (switchs == 1){ | ||
| 196 | + storage.setItem("switchType", 0); //0关闭 | ||
| 197 | + succll(responseText[0],zzdclone); | ||
| 198 | + | ||
| 199 | + } else if (switchs == 2){ //临加班次 | ||
| 200 | + let lineCode = gb_schedule_table.TablelineCode; | ||
| 201 | + //打开临加班次 | ||
| 202 | + var folder = '/real_control_v2/fragments/line_schedule/context_menu'; | ||
| 203 | + var modal_opts = { | ||
| 204 | + center: false, | ||
| 205 | + bgclose: false | ||
| 206 | + }; | ||
| 207 | + | ||
| 208 | + debugger | ||
| 209 | + | ||
| 210 | + /*$.post('/znddLogger/schlist/'+lineCode,function(sch) { | ||
| 211 | + sch.dir = responseText[3] == null ? sch.dir : responseText[3] | ||
| 212 | + sch.fcsj = responseText[4] == null ? sch.fcsj : responseText[4] | ||
| 213 | + if (sch != null && sch != "") { | ||
| 214 | + open_modal(folder + '/temp_sch/main.html', { | ||
| 215 | + sch: sch | ||
| 216 | + }, modal_opts); | ||
| 217 | + }else { | ||
| 218 | + errll(nosche); | ||
| 219 | + } | ||
| 220 | + });*/ | ||
| 221 | + } else if (switchs == 3){ //撤销实发 | ||
| 222 | + let lineCode = gb_schedule_table.TablelineCode; | ||
| 223 | + var content = '<h3>确定要对<span>' +lineCode +'</span>'+撤销+ | ||
| 224 | + '<span style="color:red;margin: 0 5px;">'+ responseText[4]+ '</span>的实发时间?</h3>' | ||
| 225 | + alt_confirm(content, function () { | ||
| 226 | + gb_common.$post('/realSchedule/revokeRealOutgo', { | ||
| 227 | + id: that.data('id') | ||
| 228 | + }, function (rs) { | ||
| 229 | + gb_schedule_table.updateSchedule(rs.ts); | ||
| 230 | + notify_succ('撤销实发操作成功!'); | ||
| 231 | + //calc 应发未发 | ||
| 232 | + gb_schedule_table.calc_yfwf_num(sch.xlBm); | ||
| 233 | + | ||
| 234 | + cb && cb(); | ||
| 235 | + $(this).parent().remove(); | ||
| 236 | + }); | ||
| 237 | + }, '确认撤销实发'); | ||
| 238 | + } else if (switchs == 4){ //撤销班次 | ||
| 239 | + lineCode = responseText[2] == null ? lineCode : responseText[2] | ||
| 240 | + var content = '<h3>确定要对<span>' +lineCode +'</span>'+取消+ | ||
| 241 | + '<span style="color:red;margin: 0 5px;">'+ responseText[4]+ '</span>的班次?</h3>' | ||
| 242 | + alt_confirm(content, function () { | ||
| 243 | + gb_common.$post('/realSchedule/deleteRealSchedule', { | ||
| 244 | + id: that.data('id') | ||
| 245 | + }, function (rs) { | ||
| 246 | + gb_schedule_table.updateSchedule(rs.ts); | ||
| 247 | + notify_succ('撤销实发操作成功!'); | ||
| 248 | + //calc 应发未发 | ||
| 249 | + gb_schedule_table.calc_yfwf_num(sch.xlBm); | ||
| 250 | + | ||
| 251 | + cb && cb(); | ||
| 252 | + $(this).parent().remove(); | ||
| 253 | + }); | ||
| 254 | + }, '确认撤销实发'); | ||
| 255 | + }else{ | ||
| 256 | + | ||
| 257 | + errll(responseText[0],error); | ||
| 258 | + } | ||
| 259 | + | ||
| 260 | + } | ||
| 261 | + }; | ||
| 262 | + | ||
| 263 | + | ||
| 264 | + /* ti = 0; | ||
| 265 | + timeInt =setInterval(function(){leftTimer(xhr);},1000); //开始倒计时*/ | ||
| 266 | + } | ||
| 267 | + /* var ti = 0; //十次之后不管有没有识别到都取消定时器 | ||
| 268 | + function leftTimer(xhr){ | ||
| 269 | + debugger | ||
| 270 | + ti ++; | ||
| 271 | + if (ti == 10){ | ||
| 272 | + clearInterval(timeInt); | ||
| 273 | + errll(error); | ||
| 274 | + } | ||
| 275 | + | ||
| 276 | + | ||
| 277 | + var arr = headers.trim().split(/[\r\n]+/); | ||
| 278 | + var headerMap = {}; | ||
| 279 | + arr.forEach(function (line) { | ||
| 280 | + var parts = line.split(': '); | ||
| 281 | + var header = parts.shift(); | ||
| 282 | + var value = parts.join(': '); | ||
| 283 | + headerMap[header] = value; | ||
| 284 | + }); | ||
| 285 | + let switchs = headerMap['switchs']; | ||
| 286 | + if (switchs == null) | ||
| 287 | + return | ||
| 288 | + | ||
| 289 | + // //判断是否打开智能调度 加个状态是开启还是关闭**** | ||
| 290 | + let storage = window.localStorage; | ||
| 291 | + if (switchs == 0){ | ||
| 292 | + storage.setItem("switchType", 1); //1开启 | ||
| 293 | + succll(zzdopen); | ||
| 294 | + | ||
| 295 | + } else if (switchs == 1){ | ||
| 296 | + storage.setItem("switchType", 0); //0关闭 | ||
| 297 | + succll(zzdclone); | ||
| 298 | + | ||
| 299 | + } else if (switchs == 2){ | ||
| 300 | + let lineCode = gb_schedule_table.TablelineCode; | ||
| 301 | + //打开临加班次 | ||
| 302 | + var folder = '/real_control_v2/fragments/line_schedule/context_menu'; | ||
| 303 | + var modal_opts = { | ||
| 304 | + center: false, | ||
| 305 | + bgclose: false | ||
| 306 | + }; | ||
| 307 | + $.post('/znddLogger/schlist/'+lineCode,function(sch) { | ||
| 308 | + if (sch != null && sch != "") { | ||
| 309 | + open_modal(folder + '/temp_sch/main.html', { | ||
| 310 | + sch: sch | ||
| 311 | + }, modal_opts); | ||
| 312 | + }else { | ||
| 313 | + errll(nosche); | ||
| 314 | + } | ||
| 315 | + }); | ||
| 316 | + } else { | ||
| 317 | + errll(error); | ||
| 318 | + } | ||
| 319 | + clearInterval(timeInt); | ||
| 320 | + }*/ | ||
| 321 | + | ||
| 322 | + //音频采集 | ||
| 323 | + recorder.onaudioprocess = function (e) { | ||
| 324 | + audioData.input(e.inputBuffer.getChannelData(0)); | ||
| 325 | + //record(e.inputBuffer.getChannelData(0)); | ||
| 326 | + var buffer = e.inputBuffer.getChannelData(0); | ||
| 327 | + const maxvo = Math.max.apply(null, buffer); | ||
| 328 | + | ||
| 329 | + var id = document.getElementById("len"); | ||
| 330 | + id.innerHTML = "录音时长:" + e.playbackTime.toFixed(2); | ||
| 331 | + var idx = document.getElementById("loud"); | ||
| 332 | + idx.innerHTML = "音量大小:" + (maxvo *100).toFixed() + "%"; | ||
| 333 | + microphone.volume("Microphone", maxvo *100); | ||
| 334 | + | ||
| 335 | + } | ||
| 336 | + | ||
| 337 | + }; | ||
| 338 | + //成功之后语音播报 | ||
| 339 | + function succll(responseText,msg){ | ||
| 340 | + notify_succ("您说的是“"+responseText +"“"+ msg); | ||
| 341 | + gb_tts.audition(msg, 1.2); | ||
| 342 | + }; | ||
| 343 | + //失败之后语音播报 | ||
| 344 | + function errll(responseText,msg){ | ||
| 345 | + notify_err("您说的是“"+responseText +"”"+ msg); | ||
| 346 | + gb_tts.audition(msg, 1.2); | ||
| 347 | + }; | ||
| 348 | + //抛出异常 | ||
| 349 | + HZRecorder.throwError = function (message) { | ||
| 350 | + alert(message); | ||
| 351 | + throw new function () { this.toString = function () { return message; } } | ||
| 352 | + } | ||
| 353 | + //是否支持录音 | ||
| 354 | + HZRecorder.canRecording = (navigator.getUserMedia != null); | ||
| 355 | + //获取录音机 | ||
| 356 | + HZRecorder.get = function (callback, config) { | ||
| 357 | + if (callback) { | ||
| 358 | + if (navigator.getUserMedia) { | ||
| 359 | + navigator.getUserMedia( | ||
| 360 | + { audio: true } //只启用音频 | ||
| 361 | + , function (stream) { | ||
| 362 | + var rec = new HZRecorder(stream, config); | ||
| 363 | + callback(rec); | ||
| 364 | + }, | ||
| 365 | + function (error) { | ||
| 366 | + switch (error.code || error.name) { | ||
| 367 | + case 'PERMISSION_DENIED': | ||
| 368 | + case 'PermissionDeniedError': | ||
| 369 | + HZRecorder.throwError('用户拒绝提供信息。'); | ||
| 370 | + break; | ||
| 371 | + case 'NOT_SUPPORTED_ERROR': | ||
| 372 | + case 'NotSupportedError': | ||
| 373 | + HZRecorder.throwError('浏览器不支持硬件设备。'); | ||
| 374 | + break; | ||
| 375 | + case 'MANDATORY_UNSATISFIED_ERROR': | ||
| 376 | + case 'MandatoryUnsatisfiedError': | ||
| 377 | + HZRecorder.throwError('无法发现指定的硬件设备。'); | ||
| 378 | + break; | ||
| 379 | + default: | ||
| 380 | + HZRecorder.throwError('无法打开麦克风。异常信息:' + (error.code || error.name)); | ||
| 381 | + break; | ||
| 382 | + } | ||
| 383 | + }); | ||
| 384 | + } else { | ||
| 385 | + HZRecorder.throwErr('当前浏览器不支持录音功能。'); return; | ||
| 386 | + } | ||
| 387 | + } | ||
| 388 | + } | ||
| 389 | + | ||
| 390 | + | ||
| 391 | + window.HZRecorder = HZRecorder; | ||
| 392 | + | ||
| 393 | + | ||
| 394 | +})(window); | ||
| 0 | \ No newline at end of file | 395 | \ No newline at end of file |
src/main/resources/static/real_control_v2/js/zndd/recorder/recorders.js
0 → 100644
| 1 | +/*! | ||
| 2 | + * | ||
| 3 | + * js-audio-recorder - js audio recorder plugin | ||
| 4 | + * | ||
| 5 | + * @version v1.0.4 | ||
| 6 | + * @homepage https://github.com/2fps/recorder | ||
| 7 | + * @author 2fps <echoweb@126.com> (https://www.zhuyuntao.cn) | ||
| 8 | + * @license MIT | ||
| 9 | + * | ||
| 10 | + */ | ||
| 11 | +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Recorder=e():t.Recorder=e()}(this,function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(i,o,function(e){return t[e]}.bind(null,o));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([function(t,e,n){"use strict";function i(t,e,n){for(var i=0;i<n.length;i++)t.setUint8(e+i,n.charCodeAt(i))}Object.defineProperty(e,"__esModule",{value:!0}),e.compress=function(t,e,n){for(var i=e/n,o=Math.max(i,1),r=t.left,a=t.right,s=Math.floor((r.length+a.length)/i),u=new Float32Array(s),c=0,l=0;c<s;){var p=Math.floor(l);u[c]=r[p],c++,a.length&&(u[c]=a[p],c++),l+=o}return u},e.encodePCM=function(t,e,n){void 0===n&&(n=!0);var i=0,o=t.length*(e/8),r=new ArrayBuffer(o),a=new DataView(r);if(8===e)for(var s=0;s<t.length;s++,i++){var u=(c=Math.max(-1,Math.min(1,t[s])))<0?128*c:127*c;u=+u+128,a.setInt8(i,u)}else for(s=0;s<t.length;s++,i+=2){var c=Math.max(-1,Math.min(1,t[s]));a.setInt16(i,c<0?32768*c:32767*c,n)}return a},e.encodeWAV=function(t,e,n,o,r,a){void 0===a&&(a=!0);var s=n>e?e:n,u=r,c=new ArrayBuffer(44+t.byteLength),l=new DataView(c),p=o,f=0;i(l,f,"RIFF"),f+=4,l.setUint32(f,36+t.byteLength,a),i(l,f+=4,"WAVE"),i(l,f+=4,"fmt "),f+=4,l.setUint32(f,16,a),f+=4,l.setUint16(f,1,a),f+=2,l.setUint16(f,p,a),f+=2,l.setUint32(f,s,a),f+=4,l.setUint32(f,p*s*(u/8),a),f+=4,l.setUint16(f,p*(u/8),a),f+=2,l.setUint16(f,u,a),i(l,f+=2,"data"),f+=4,l.setUint32(f,t.byteLength,a),f+=4;for(var d=0;d<t.byteLength;)l.setUint8(f,t.getUint8(d)),f++,d++;return l}},function(t,e,n){"use strict";var i,o=this&&this.__extends||(i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var r=n(2),a=n(0),s=n(3),u=function(t){function e(e){void 0===e&&(e={});var n=t.call(this,e)||this;return n.isrecording=!1,n.ispause=!1,n.isplaying=!1,n}return o(e,t),e.prototype.setOption=function(t){void 0===t&&(t={}),this.setNewOption(t)},e.prototype.start=function(){return this.isrecording?Promise.reject():(this.isrecording=!0,this.startRecord())},e.prototype.pause=function(){this.isrecording&&!this.ispause&&(this.ispause=!0,this.pauseRecord())},e.prototype.resume=function(){this.isrecording&&this.ispause&&(this.ispause=!1,this.resumeRecord())},e.prototype.stop=function(){this.isrecording&&(this.isrecording=!1,this.ispause=!1,this.stopRecord())},e.prototype.play=function(){this.stop(),this.isplaying=!0,this.onplay&&this.onplay(),s.default.addPlayEnd(this.onplayend);var t=this.getWAV();t.byteLength>44&&s.default.play(t.buffer)},e.prototype.getPlayTime=function(){return s.default.getPlayTime()},e.prototype.pausePlay=function(){!this.isrecording&&this.isplaying&&(this.isplaying=!1,this.onpauseplay&&this.onpauseplay(),s.default.pausePlay())},e.prototype.resumePlay=function(){this.isrecording||this.isplaying||(this.isplaying=!0,this.onresumeplay&&this.onresumeplay(),s.default.resumePlay())},e.prototype.stopPlay=function(){this.isrecording||(this.isplaying=!1,this.onstopplay&&this.onstopplay(),s.default.stopPlay())},e.prototype.destroy=function(){return s.default.destroyPlay(),this.destroyRecord()},e.prototype.getRecordAnalyseData=function(){return this.getAnalyseData()},e.prototype.getPlayAnalyseData=function(){return s.default.getAnalyseData()},e.prototype.getPCM=function(){this.stop();var t=this.getData();return t=a.compress(t,this.inputSampleRate,this.outputSampleRate),a.encodePCM(t,this.oututSampleBits,this.littleEdian)},e.prototype.getPCMBlob=function(){return new Blob([this.getPCM()])},e.prototype.downloadPCM=function(t){void 0===t&&(t="recorder");var e=this.getPCMBlob();r.downloadPCM(e,t)},e.prototype.getWAV=function(){var t=this.getPCM();return a.encodeWAV(t,this.inputSampleRate,this.outputSampleRate,this.config.numChannels,this.oututSampleBits,this.littleEdian)},e.prototype.getWAVBlob=function(){return new Blob([this.getWAV()],{type:"audio/wav"})},e.prototype.downloadWAV=function(t){void 0===t&&(t="recorder");var e=this.getWAVBlob();r.downloadWAV(e,t)},e}(n(5).default);e.default=u},function(t,e,n){"use strict";function i(t,e,n){var i=document.createElement("a");i.href=window.URL.createObjectURL(t),i.download=e+"."+n,i.click()}Object.defineProperty(e,"__esModule",{value:!0}),e.downloadWAV=function(t,e){void 0===e&&(e="recorder"),i(t,e,"wav")},e.downloadPCM=function(t,e){void 0===e&&(e="recorder"),i(t,e,"pcm")}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(4),o=null,r=0,a=0,s=null,u=null,c=null,l=!1,p=0,f=function(){};function d(){return l=!1,s.decodeAudioData(c.slice(0),function(t){(o=s.createBufferSource()).onended=function(){l||(p=s.currentTime-a+r,f())},o.buffer=t,o.connect(u),u.connect(s.destination),o.start(0,r),a=s.currentTime},function(t){i.throwError(t)})}function h(){o&&(o.stop(),o=null)}var y=function(){function t(){}return t.play=function(t){return s||(s=new(window.AudioContext||window.webkitAudioContext),(u=s.createAnalyser()).fftSize=2048),this.stopPlay(),c=t,p=0,d()},t.pausePlay=function(){h(),r+=s.currentTime-a,l=!0},t.resumePlay=function(){return d()},t.stopPlay=function(){r=0,c=null,h()},t.destroyPlay=function(){this.stopPlay()},t.getAnalyseData=function(){var t=new Uint8Array(u.frequencyBinCount);return u.getByteTimeDomainData(t),t},t.addPlayEnd=function(t){void 0===t&&(t=function(){}),f=t},t.getPlayTime=function(){var t=l?r:s.currentTime-a+r;return p||t},t}();e.default=y},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.throwError=function(t){throw new Error(t)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(0),o=function(){function t(e){void 0===e&&(e={}),this.size=0,this.lBuffer=[],this.rBuffer=[],this.tempPCM=[],this.inputSampleBits=16,this.fileSize=0,this.duration=0,this.needRecord=!0;var n,i=new(window.AudioContext||window.webkitAudioContext);this.inputSampleRate=i.sampleRate,this.setNewOption(e),this.littleEdian=(n=new ArrayBuffer(2),new DataView(n).setInt16(0,256,!0),256===new Int16Array(n)[0]),t.initUserMedia()}return t.prototype.setNewOption=function(t){void 0===t&&(t={}),this.config={sampleBits:~[8,16].indexOf(t.sampleBits)?t.sampleBits:16,sampleRate:~[11025,16e3,22050,24e3,44100,48e3].indexOf(t.sampleRate)?t.sampleRate:this.inputSampleRate,numChannels:~[1,2].indexOf(t.numChannels)?t.numChannels:1},this.outputSampleRate=this.config.sampleRate,this.oututSampleBits=this.config.sampleBits},t.prototype.startRecord=function(){var t=this;return this.context&&this.destroyRecord(),this.initRecorder(),navigator.mediaDevices.getUserMedia({audio:!0}).then(function(e){t.audioInput=t.context.createMediaStreamSource(e),t.stream=e}).then(function(){t.audioInput.connect(t.analyser),t.analyser.connect(t.recorder),t.recorder.connect(t.context.destination)})},t.prototype.pauseRecord=function(){this.needRecord=!1},t.prototype.resumeRecord=function(){this.needRecord=!0},t.prototype.stopRecord=function(){this.audioInput&&this.audioInput.disconnect(),this.source&&this.source.stop(),this.recorder.disconnect(),this.analyser.disconnect()},t.prototype.destroyRecord=function(){return this.clearRecordStatus(),this.stopStream(),this.closeAudioContext()},t.prototype.getAnalyseData=function(){var t=new Uint8Array(this.analyser.frequencyBinCount);return this.analyser.getByteTimeDomainData(t),t},t.prototype.getData=function(){return this.flat()},t.prototype.clearRecordStatus=function(){this.lBuffer.length=0,this.rBuffer.length=0,this.size=0,this.fileSize=0,this.PCM=null,this.audioInput=null,this.duration=0},t.prototype.flat=function(){var t=null,e=new Float32Array(0);1===this.config.numChannels?t=new Float32Array(this.size):(t=new Float32Array(this.size/2),e=new Float32Array(this.size/2));for(var n=0,i=0;i<this.lBuffer.length;i++)t.set(this.lBuffer[i],n),n+=this.lBuffer[i].length;n=0;for(i=0;i<this.rBuffer.length;i++)e.set(this.rBuffer[i],n),n+=this.rBuffer[i].length;return{left:t,right:e}},t.prototype.initRecorder=function(){var t=this;this.clearRecordStatus(),this.context=new(window.AudioContext||window.webkitAudioContext),this.analyser=this.context.createAnalyser(),this.analyser.fftSize=2048;var e=this.context.createScriptProcessor||this.context.createJavaScriptNode;this.recorder=e.apply(this.context,[4096,this.config.numChannels,this.config.numChannels]),this.recorder.onaudioprocess=function(e){if(t.needRecord){var n,i=e.inputBuffer.getChannelData(0),o=null;t.lBuffer.push(new Float32Array(i)),t.size+=i.length,2===t.config.numChannels&&(o=e.inputBuffer.getChannelData(1),t.rBuffer.push(new Float32Array(o)),t.size+=o.length),t.fileSize=Math.floor(t.size/Math.max(t.inputSampleRate/t.outputSampleRate,1))*(t.oututSampleBits/8),n=100*Math.max.apply(Math,i),t.duration+=4096/t.inputSampleRate,t.onprocess&&t.onprocess(t.duration),t.onprogress&&t.onprogress({duration:t.duration,fileSize:t.fileSize,vol:n})}}},t.prototype.stopStream=function(){this.stream&&this.stream.getTracks&&(this.stream.getTracks().forEach(function(t){return t.stop()}),this.stream=null)},t.prototype.closeAudioContext=function(){return this.context&&this.context.close&&"closed"!==this.context.state?this.context.close():new Promise(function(t){t()})},t.initUserMedia=function(){void 0===navigator.mediaDevices&&(navigator.mediaDevices={}),void 0===navigator.mediaDevices.getUserMedia&&(navigator.mediaDevices.getUserMedia=function(t){var e=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia;return e?new Promise(function(n,i){e.call(navigator,t,n,i)}):Promise.reject(new Error("娴忚鍣ㄤ笉鏀寔 getUserMedia !"))})},t.prototype.transformIntoPCM=function(t,e){var n=new Float32Array(t),o=new Float32Array(e),r=i.compress({left:n,right:o},this.inputSampleRate,this.outputSampleRate);return i.encodePCM(r,this.oututSampleBits,this.littleEdian)},t.getPermission=function(){return this.initUserMedia(),navigator.mediaDevices.getUserMedia({audio:!0}).then(function(t){t.getTracks().forEach(function(t){return t.stop()})})},t}();e.default=o}]).default}); | ||
| 12 | +//# sourceMappingURL=recorder.js.map | ||
| 0 | \ No newline at end of file | 13 | \ No newline at end of file |