Commit 5b922d6c304a2682a8433aaa3ee3d75824825efa
1 parent
a9f3aed7
给电科手机端的线路指标接口2
Showing
2 changed files
with
231 additions
and
2 deletions
src/main/java/com/bsth/repository/ScheduleRealInfoRepository.java
| @@ -18,7 +18,7 @@ public interface ScheduleRealInfoRepository extends PagingAndSortingRepository<S | @@ -18,7 +18,7 @@ public interface ScheduleRealInfoRepository extends PagingAndSortingRepository<S | ||
| 18 | * @return | 18 | * @return |
| 19 | */ | 19 | */ |
| 20 | @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) | 20 | @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) |
| 21 | - @Query("select DISTINCT s from ScheduleRealInfo s where s.scheduleDateStr=?1") | 21 | + @Query("select DISTINCT s from ScheduleRealInfo s where s.scheduleDateStr=?1 order by s.gsBm, s.fgsBm, s.xlName") |
| 22 | List<ScheduleRealInfo> findAll(String schDate); | 22 | List<ScheduleRealInfo> findAll(String schDate); |
| 23 | 23 | ||
| 24 | /** | 24 | /** |
src/main/java/com/bsth/server_rs/bigdata/BigscreenService.java
| @@ -1526,7 +1526,7 @@ public class BigscreenService { | @@ -1526,7 +1526,7 @@ public class BigscreenService { | ||
| 1526 | return JSON.parseObject(JSON.toJSONString(resMap)); | 1526 | return JSON.parseObject(JSON.toJSONString(resMap)); |
| 1527 | } | 1527 | } |
| 1528 | 1528 | ||
| 1529 | - /**给电科手机端查线路指标(发车准点率) | 1529 | + /**给电科手机端查线路指标(起讫站发车准点率) |
| 1530 | * | 1530 | * |
| 1531 | */ | 1531 | */ |
| 1532 | @GET | 1532 | @GET |
| @@ -1632,6 +1632,235 @@ public class BigscreenService { | @@ -1632,6 +1632,235 @@ public class BigscreenService { | ||
| 1632 | return JSON.parseObject(JSON.toJSONString(resMap)); | 1632 | return JSON.parseObject(JSON.toJSONString(resMap)); |
| 1633 | } | 1633 | } |
| 1634 | 1634 | ||
| 1635 | + /**给电科手机端查线路指标(挂牌线路发车准点率) | ||
| 1636 | + * | ||
| 1637 | + */ | ||
| 1638 | + @GET | ||
| 1639 | + @Path("/selectData/getPlateLineBus/{company}/{branchCompany}") | ||
| 1640 | + public JSONObject getPlateLineBus(@PathParam("company") String company, | ||
| 1641 | + @PathParam("branchCompany") String branchCompany){ | ||
| 1642 | + Map<String, Object> resMap = new HashMap<String, Object>(); | ||
| 1643 | + | ||
| 1644 | + String gpLineSql = "select * from bsth_c_line_plate"; | ||
| 1645 | + List<Map<String, Object>> gpLineList=jdbcTemplate.query(gpLineSql, | ||
| 1646 | + new RowMapper<Map<String, Object>>(){ | ||
| 1647 | + @Override | ||
| 1648 | + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 1649 | + Map<String, Object> m=new HashMap<String,Object>(); | ||
| 1650 | + m.put("lineName", rs.getString("line_name")); | ||
| 1651 | + m.put("lineCode", rs.getString("line_code")); | ||
| 1652 | + return m; | ||
| 1653 | + } | ||
| 1654 | + }); | ||
| 1655 | + | ||
| 1656 | + Set<String> gpSet = new HashSet<String>(); | ||
| 1657 | + for(Map<String, Object> t : gpLineList){ | ||
| 1658 | + if(t.get("lineCode") != null && t.get("lineCode").toString().trim().length() > 0){ | ||
| 1659 | + gpSet.add(t.get("lineCode").toString().trim()); | ||
| 1660 | + } | ||
| 1661 | + } | ||
| 1662 | + | ||
| 1663 | + String date = sd.format(new Date()); | ||
| 1664 | + String gs = "", fgs = ""; | ||
| 1665 | + if(company.trim().length() > 0 && !("all".equals(company.trim()))){ | ||
| 1666 | + gs = company.trim(); | ||
| 1667 | + } | ||
| 1668 | + if(branchCompany.trim().length() > 0 && !("all".equals(branchCompany.trim()))){ | ||
| 1669 | + fgs = branchCompany.trim(); | ||
| 1670 | + } | ||
| 1671 | + | ||
| 1672 | + String yyxlSql="SELECT line_code from bsth_c_line " | ||
| 1673 | + + " where nature in ('yxl','cgxl','gjxl','csbs','cctxl')"; | ||
| 1674 | + List<Map<String, Object>> yyxlList=jdbcTemplate.query(yyxlSql, | ||
| 1675 | + new RowMapper<Map<String, Object>>(){ | ||
| 1676 | + @Override | ||
| 1677 | + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 1678 | + Map<String, Object> m=new HashMap<String,Object>(); | ||
| 1679 | + m.put("lineCode", rs.getString("line_code")); | ||
| 1680 | + return m; | ||
| 1681 | + } | ||
| 1682 | + }); | ||
| 1683 | + Set<String> yyLine = new HashSet<String>(); | ||
| 1684 | + for(Map<String, Object> t : yyxlList){ | ||
| 1685 | + if(t.get("lineCode") != null){ | ||
| 1686 | + yyLine.add(t.get("lineCode").toString()); | ||
| 1687 | + } | ||
| 1688 | + } | ||
| 1689 | + | ||
| 1690 | + List<String> objList = new ArrayList<String>(); | ||
| 1691 | + String sql="select xl,xl_name,date,jhbc,bczxl,jhbcz,sjbc,jhcc,sjcc,ccl,jhccz," | ||
| 1692 | + + " jhyylc,sjyylc,jhyylcz,jhkslc,sjkslc,jhkslcz," | ||
| 1693 | + + " jhssgfbcs,sjgfbcs,jhgfbcsz,jhssdgbcs,sjdgbcs,jhdgbcsz," | ||
| 1694 | + + " jhsmbcs,sjsmbczds,smbczdl,jhsmbcsz,sjsmbczdsz,smbczdlz," | ||
| 1695 | + + " jhszfcs,sjszfczds,szfczdl,create_date" | ||
| 1696 | + + " from bsth_c_calc_count " | ||
| 1697 | + + " where date = ? and gsdm != '77'"; | ||
| 1698 | + objList.add(date); | ||
| 1699 | + if(fgs.length() > 0){ | ||
| 1700 | + sql +=" and gsdm = ? and fgsdm = ?"; | ||
| 1701 | + objList.add(gs); | ||
| 1702 | + objList.add(fgs); | ||
| 1703 | + } else if(gs.length() > 0){ | ||
| 1704 | + sql +=" and gsdm = ?"; | ||
| 1705 | + objList.add(gs); | ||
| 1706 | + } | ||
| 1707 | + | ||
| 1708 | + List<Map<String, Object>> list=jdbcTemplate.query(sql, | ||
| 1709 | + objList.toArray(), | ||
| 1710 | + new RowMapper<Map<String, Object>>(){ | ||
| 1711 | + @Override | ||
| 1712 | + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 1713 | + Map<String, Object> m=new HashMap<String,Object>(); | ||
| 1714 | + m.put("lineCode",rs.getString("xl")); | ||
| 1715 | + m.put("lineName", rs.getString("xl_name")); | ||
| 1716 | + m.put("date", rs.getString("date")); | ||
| 1717 | + | ||
| 1718 | + m.put("jhszfcs", rs.getString("jhszfcs")); | ||
| 1719 | + m.put("sjszfczds", rs.getString("sjszfczds")); | ||
| 1720 | + | ||
| 1721 | + Date date = new Date(); | ||
| 1722 | + date.setTime(rs.getTimestamp("create_date").getTime()); | ||
| 1723 | + m.put("createDate", sdf.format(date)); | ||
| 1724 | + return m; | ||
| 1725 | + } | ||
| 1726 | + }); | ||
| 1727 | + | ||
| 1728 | + List<Map<String, Object>> detailsList = new ArrayList<Map<String, Object>>(); | ||
| 1729 | + | ||
| 1730 | + long jh = 0, sj = 0; | ||
| 1731 | + | ||
| 1732 | + for(Map<String, Object> t : list){ | ||
| 1733 | + if(yyLine.contains(t.get("lineCode").toString())){ | ||
| 1734 | + | ||
| 1735 | + if(gpSet.contains(t.get("lineCode").toString())){ | ||
| 1736 | + | ||
| 1737 | + Long plan = Long.valueOf(t.get("jhszfcs").toString()); | ||
| 1738 | + Long real = Long.valueOf(t.get("sjszfczds").toString()); | ||
| 1739 | + | ||
| 1740 | + jh += plan; | ||
| 1741 | + sj += real; | ||
| 1742 | + | ||
| 1743 | + Map<String, Object> detail = new HashMap<String, Object>(); | ||
| 1744 | + detail.put("lineName", t.get("lineName").toString()); | ||
| 1745 | + detail.put("plan", plan); | ||
| 1746 | + detail.put("real", real); | ||
| 1747 | + detail.put("ratio", plan>0?new BigDecimal(real*100l).divide( | ||
| 1748 | + new BigDecimal(plan), 2, BigDecimal.ROUND_HALF_UP).doubleValue():"0"); | ||
| 1749 | + detailsList.add(detail); | ||
| 1750 | + } | ||
| 1751 | + } | ||
| 1752 | + } | ||
| 1753 | + | ||
| 1754 | + resMap.put("plan", jh); | ||
| 1755 | + resMap.put("real", sj); | ||
| 1756 | + resMap.put("ratio", jh>0?new BigDecimal(sj*100l).divide( | ||
| 1757 | + new BigDecimal(jh), 2, BigDecimal.ROUND_HALF_UP).doubleValue():"0"); | ||
| 1758 | + | ||
| 1759 | + resMap.put("detailsList", detailsList); | ||
| 1760 | + | ||
| 1761 | + return JSON.parseObject(JSON.toJSONString(resMap)); | ||
| 1762 | + } | ||
| 1763 | + | ||
| 1764 | + /**给电科手机端查线路指标(签卡率) | ||
| 1765 | + * | ||
| 1766 | + */ | ||
| 1767 | + @GET | ||
| 1768 | + @Path("/selectData/getCardSigning/{company}/{branchCompany}") | ||
| 1769 | + public JSONObject getCardSigning(@PathParam("company") String company, | ||
| 1770 | + @PathParam("branchCompany") String branchCompany){ | ||
| 1771 | + Map<String, Object> resMap = new HashMap<String, Object>(); | ||
| 1772 | + String date = sd.format(new Date()); | ||
| 1773 | + String gs = "", fgs = ""; | ||
| 1774 | + if(company.trim().length() > 0 && !("all".equals(company.trim()))){ | ||
| 1775 | + gs = company.trim(); | ||
| 1776 | + } | ||
| 1777 | + if(branchCompany.trim().length() > 0 && !("all".equals(branchCompany.trim()))){ | ||
| 1778 | + fgs = branchCompany.trim(); | ||
| 1779 | + } | ||
| 1780 | + | ||
| 1781 | + String yyxlSql="SELECT line_code from bsth_c_line " | ||
| 1782 | + + " where nature in ('yxl','cgxl','gjxl','csbs','cctxl')"; | ||
| 1783 | + List<Map<String, Object>> yyxlList=jdbcTemplate.query(yyxlSql, | ||
| 1784 | + new RowMapper<Map<String, Object>>(){ | ||
| 1785 | + @Override | ||
| 1786 | + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 1787 | + Map<String, Object> m=new HashMap<String,Object>(); | ||
| 1788 | + m.put("lineCode", rs.getString("line_code")); | ||
| 1789 | + return m; | ||
| 1790 | + } | ||
| 1791 | + }); | ||
| 1792 | + Set<String> yyLine = new HashSet<String>(); | ||
| 1793 | + for(Map<String, Object> t : yyxlList){ | ||
| 1794 | + if(t.get("lineCode") != null){ | ||
| 1795 | + yyLine.add(t.get("lineCode").toString()); | ||
| 1796 | + } | ||
| 1797 | + } | ||
| 1798 | + | ||
| 1799 | + List<Map<String, Object>> detailsList = new ArrayList<Map<String, Object>>(); | ||
| 1800 | + Map<String, Map<String, Object>> keyMap = new HashMap<String, Map<String, Object>>(); | ||
| 1801 | + | ||
| 1802 | + long jh = 0, sj = 0; | ||
| 1803 | + | ||
| 1804 | + List<ScheduleRealInfo> findAll = scheduleRealInfoRepository.findAll(date); | ||
| 1805 | + for(ScheduleRealInfo s : findAll){ | ||
| 1806 | + if(s.getGsBm() != null && s.getFgsBm() != null){ | ||
| 1807 | + if("77".equals(s.getGsBm())){ | ||
| 1808 | + continue; | ||
| 1809 | + } | ||
| 1810 | + if(fgs.length() > 0){ | ||
| 1811 | + if(!(s.getGsBm().equals(gs)) || !(s.getFgsBm().equals(gs))){ | ||
| 1812 | + continue; | ||
| 1813 | + } | ||
| 1814 | + } else if(gs.length() > 0){ | ||
| 1815 | + if(!(s.getGsBm().equals(gs))){ | ||
| 1816 | + continue; | ||
| 1817 | + } | ||
| 1818 | + } | ||
| 1819 | + if(s.getXlBm() != null && yyLine.contains(s.getXlBm())){//营运线路 | ||
| 1820 | + if(!isInOut(s) && !s.isCcService() && s.getStatus() != -1 && s.getStatus() != 0){ | ||
| 1821 | + long plan = 0, real = 0; | ||
| 1822 | + ++plan; | ||
| 1823 | + ++jh; | ||
| 1824 | + String sty = decimalToBinary(s.getRfidState()); | ||
| 1825 | + Integer state = Integer.parseInt(sty); | ||
| 1826 | + if ((state & 4) == 4) { | ||
| 1827 | + ++real; | ||
| 1828 | + ++sj; | ||
| 1829 | + } | ||
| 1830 | + if(!(keyMap.containsKey(s.getXlBm()))){ | ||
| 1831 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 1832 | + m = new HashMap<String, Object>(); | ||
| 1833 | + m.put("lineName", s.getXlName()); | ||
| 1834 | + m.put("plan", "0"); | ||
| 1835 | + m.put("real", "0"); | ||
| 1836 | + keyMap.put(s.getXlBm(), m); | ||
| 1837 | + detailsList.add(m); | ||
| 1838 | + } | ||
| 1839 | + Map<String, Object> m = keyMap.get(s.getXlBm()); | ||
| 1840 | + m.put("plan", Long.valueOf(m.get("plan").toString()) + plan); | ||
| 1841 | + m.put("real", Long.valueOf(m.get("real").toString()) + real); | ||
| 1842 | + } | ||
| 1843 | + } | ||
| 1844 | + } | ||
| 1845 | + } | ||
| 1846 | + | ||
| 1847 | + for(Map<String, Object> m : detailsList){ | ||
| 1848 | + long plan = Long.valueOf(m.get("plan").toString()); | ||
| 1849 | + long real = Long.valueOf(m.get("real").toString()); | ||
| 1850 | + resMap.put("ratio", plan>0?new BigDecimal(real*100l).divide( | ||
| 1851 | + new BigDecimal(plan), 2, BigDecimal.ROUND_HALF_UP).doubleValue():"0"); | ||
| 1852 | + } | ||
| 1853 | + | ||
| 1854 | + resMap.put("plan", jh); | ||
| 1855 | + resMap.put("real", sj); | ||
| 1856 | + resMap.put("ratio", jh>0?new BigDecimal(sj*100l).divide( | ||
| 1857 | + new BigDecimal(jh), 2, BigDecimal.ROUND_HALF_UP).doubleValue():"0"); | ||
| 1858 | + | ||
| 1859 | + resMap.put("detailsList", detailsList); | ||
| 1860 | + | ||
| 1861 | + return JSON.parseObject(JSON.toJSONString(resMap)); | ||
| 1862 | + } | ||
| 1863 | + | ||
| 1635 | @GET | 1864 | @GET |
| 1636 | @Path("/selectData/attendance") | 1865 | @Path("/selectData/attendance") |
| 1637 | public JSONObject attendance(){ | 1866 | public JSONObject attendance(){ |