Commit a3bda7e2146e8e5924fb664768d7dfaaf9116743
1 parent
3f841922
客流管理
Showing
4 changed files
with
387 additions
and
0 deletions
src/main/java/com/bsth/controller/kl/KlController.java
0 → 100644
| 1 | +package com.bsth.controller.kl; | |
| 2 | + | |
| 3 | +import com.bsth.common.ResponseCode; | |
| 4 | +import com.bsth.controller.BaseController; | |
| 5 | +import com.bsth.entity.Line; | |
| 6 | +import com.bsth.entity.LineVersions; | |
| 7 | +import com.bsth.service.Kl.KlService; | |
| 8 | +import com.bsth.service.LineService; | |
| 9 | +import com.bsth.service.LineVersionsService; | |
| 10 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 11 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 12 | +import org.springframework.web.bind.annotation.RequestMethod; | |
| 13 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 14 | +import org.springframework.web.bind.annotation.RestController; | |
| 15 | + | |
| 16 | +import java.text.ParseException; | |
| 17 | +import java.text.SimpleDateFormat; | |
| 18 | +import java.util.Date; | |
| 19 | +import java.util.HashMap; | |
| 20 | +import java.util.List; | |
| 21 | +import java.util.Map; | |
| 22 | + | |
| 23 | +/** | |
| 24 | + * | |
| 25 | + * @ClassName: LineController(线路控制器) | |
| 26 | + * | |
| 27 | + * @Extends : BaseController | |
| 28 | + * | |
| 29 | + * @Description: TODO(线路控制层) | |
| 30 | + * | |
| 31 | + * @Author bsth@lq | |
| 32 | + * | |
| 33 | + * @Date 2016年4月28日 上午9:21:17 | |
| 34 | + * | |
| 35 | + * @Version 公交调度系统BS版 0.1 | |
| 36 | + * | |
| 37 | + */ | |
| 38 | +@RestController | |
| 39 | +@RequestMapping("kl") | |
| 40 | +public class KlController extends BaseController<Line, Integer> { | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + @Autowired | |
| 45 | + private KlService klService; | |
| 46 | + | |
| 47 | + /** | |
| 48 | + * 获取线路编码与ID | |
| 49 | + * | |
| 50 | + * @return int <lineCode:线路编码> | |
| 51 | + */ | |
| 52 | + @RequestMapping(value = "findAllKl", method = RequestMethod.GET) | |
| 53 | + public Map<String, Object> findAllKl(@RequestParam Map<String,Object> params) { | |
| 54 | + return klService.query(params); | |
| 55 | + } | |
| 56 | +} | ... | ... |
src/main/java/com/bsth/service/Kl/KlService.java
0 → 100644
src/main/java/com/bsth/service/Kl/impl/KlServiceImpl.java
0 → 100644
| 1 | +package com.bsth.service.Kl.impl; | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | +import com.bsth.service.Kl.KlService; | |
| 6 | +import org.slf4j.Logger; | |
| 7 | +import org.slf4j.LoggerFactory; | |
| 8 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 9 | +import org.springframework.jdbc.core.BeanPropertyRowMapper; | |
| 10 | +import org.springframework.jdbc.core.JdbcTemplate; | |
| 11 | +import org.springframework.stereotype.Service; | |
| 12 | +import java.util.*; | |
| 13 | + | |
| 14 | +@Service | |
| 15 | +public class KlServiceImpl implements KlService { | |
| 16 | + | |
| 17 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 18 | + | |
| 19 | + @Autowired | |
| 20 | + JdbcTemplate jdbcTemplate; | |
| 21 | + | |
| 22 | + | |
| 23 | + @Override | |
| 24 | + public Map<String, Object> query(Map<String, Object> map) { | |
| 25 | + Map<String, Object> modelMap = new HashMap<>(); | |
| 26 | + StringBuffer sql=new StringBuffer("SELECT * FROM bsth_c_kl where 1=1 "); | |
| 27 | + if(map.get("line")!=null && !map.get("line").equals("")){ | |
| 28 | + sql.append(" and line_code ='"+map.get("line")+"'"); | |
| 29 | + } | |
| 30 | + if(map.get("deviceId_like")!=null && !map.get("deviceId_like").equals("")){ | |
| 31 | + sql.append(" and deviceId like '%"+map.get("deviceId_like")+"%'"); | |
| 32 | + } | |
| 33 | + List<Map<String,Object>> query = jdbcTemplate.queryForList(sql.toString()); | |
| 34 | + Integer page = Integer.valueOf(map.containsKey("page")?map.get("page").toString():"0"); | |
| 35 | + int end = (page+1)*10>query.size()?query.size():(page+1)*10; | |
| 36 | + List<Map<String,Object>> result=query.subList(page*10, end); | |
| 37 | + for (Map<String, Object> m : result) { | |
| 38 | + m.put("time",m.get("createDate").toString().substring(0,19)); | |
| 39 | + } | |
| 40 | + modelMap.put("dataList", result); | |
| 41 | + modelMap.put("totalPages", query.size()%10>0?query.size()/10+1:query.size()/10); | |
| 42 | + modelMap.put("code","00"); | |
| 43 | + return modelMap; | |
| 44 | + } | |
| 45 | + | |
| 46 | + | |
| 47 | +} | ... | ... |
src/main/resources/static/pages/kl/list.html
0 → 100644
| 1 | +<div class="page-head"> | |
| 2 | + <div class="page-title"> | |
| 3 | + <h1>客流管理</h1> | |
| 4 | + </div> | |
| 5 | +</div> | |
| 6 | +<style> | |
| 7 | + #imageModal { | |
| 8 | + position: fixed; | |
| 9 | + top: 0; | |
| 10 | + left: 0; | |
| 11 | + width: 100%; | |
| 12 | + height: 100%; | |
| 13 | + background-color: rgba(0, 0, 0, 0.5); | |
| 14 | + display: none; | |
| 15 | + justify-content: center; | |
| 16 | + align-items: center; | |
| 17 | + } | |
| 18 | + | |
| 19 | + .container { | |
| 20 | + display: flex; | |
| 21 | + justify-content: center; | |
| 22 | + align-items: center; | |
| 23 | + margin-top: 200px; | |
| 24 | + } | |
| 25 | +</style> | |
| 26 | +<!--<script src="/assets/plugins/uk3.0/uikit.min.js"></script> | |
| 27 | +<script src="/assets/plugins/uk3.0/uikit-icons.min.js"></script> | |
| 28 | +<link rel="stylesheet" href="/assets/plugins/uk3.0/uikit.min.css"/>--> | |
| 29 | +<script src="/real_control_v2/mapmonitor/js/playback.js"></script> | |
| 30 | +<ul class="page-breadcrumb breadcrumb"> | |
| 31 | + <li><a href="/pages/home.html" data-pjax>首页</a> <i class="fa fa-circle"></i></li> | |
| 32 | + <li><span class="active">客流管理</span> <i class="fa fa-circle"></i></li> | |
| 33 | + <li><span class="active">客流管理</span></li> | |
| 34 | +</ul> | |
| 35 | + | |
| 36 | +<div class="row"> | |
| 37 | + <div class="col-md-12"> | |
| 38 | + <div class="portlet light portlet-fit portlet-datatable bordered"> | |
| 39 | + <div class="portlet-title"> | |
| 40 | + <div class="caption"> | |
| 41 | + <i class="fa fa-users font-dark"></i> <span | |
| 42 | + class="caption-subject font-dark sbold uppercase">客流查询</span> | |
| 43 | + </div> | |
| 44 | + </div> | |
| 45 | + <div class="portlet-body"> | |
| 46 | + <div class="table-container" style="margin-top: 10px"> | |
| 47 | + <table | |
| 48 | + class="table table-striped table-bordered table-hover table-checkable" id="datatable_user"> | |
| 49 | + <thead> | |
| 50 | + <tr role="row" class="heading"> | |
| 51 | + <th width="3%">#</th> | |
| 52 | + <th width="15%">线路</th> | |
| 53 | + <th width="15%">设备号</th> | |
| 54 | + <th width="15%">站点</th> | |
| 55 | + <th width="12%">上下行</th> | |
| 56 | + <th width="11%">人数</th> | |
| 57 | + <th width="15%">时间</th> | |
| 58 | + <th width="26%">操作</th> | |
| 59 | + </tr> | |
| 60 | + <tr role="row" class="filter"> | |
| 61 | + <td></td> | |
| 62 | + <td> | |
| 63 | + <select name="line" class="form-control" style="width:100%" id="line"> | |
| 64 | + | |
| 65 | + </select> | |
| 66 | + <!--<input type="text" class="form-control form-filter input-sm" name="name_like">--> | |
| 67 | + </td> | |
| 68 | + <td> | |
| 69 | + <input type="text" class="form-control form-filter input-sm" name="deviceId_like"> | |
| 70 | + </td> | |
| 71 | + <td></td> | |
| 72 | + <td></td> | |
| 73 | + <td></td> | |
| 74 | + <td></td> | |
| 75 | + <td> | |
| 76 | + <button class="btn btn-sm green btn-outline filter-submit margin-bottom" ><i class="fa fa-search"></i> 搜索</button> | |
| 77 | + <button class="btn btn-sm red btn-outline filter-cancel"><i class="fa fa-times"></i> 重置</button> | |
| 78 | + </td> | |
| 79 | + </tr> | |
| 80 | + </thead> | |
| 81 | + <tbody></tbody> | |
| 82 | + </table> | |
| 83 | + <div style="text-align: right;"> | |
| 84 | + <ul id="pagination" class="pagination"></ul> | |
| 85 | + </div> | |
| 86 | + </div> | |
| 87 | + </div> | |
| 88 | + </div> | |
| 89 | + </div> | |
| 90 | +</div> | |
| 91 | + | |
| 92 | + | |
| 93 | +<div id="imageModal"> | |
| 94 | + <div class="container"> | |
| 95 | + <img id="img" style="width: 768px;height: 432px"> | |
| 96 | + </div> | |
| 97 | +</div> | |
| 98 | + | |
| 99 | +<script id="kl_list_temp" type="text/html"> | |
| 100 | +{{each list as obj i}} | |
| 101 | +<tr> | |
| 102 | + <td style="vertical-align: middle;"> | |
| 103 | + {{++i}} | |
| 104 | + </td> | |
| 105 | + <td> | |
| 106 | + {{obj.line_name}} | |
| 107 | + </td> | |
| 108 | + <td> | |
| 109 | + {{obj.deviceId}} | |
| 110 | + </td> | |
| 111 | + <td> | |
| 112 | + {{obj.station_name}} | |
| 113 | + </td> | |
| 114 | + <td> | |
| 115 | + {{if obj.upDown == 0}} | |
| 116 | + <span>上行</span> | |
| 117 | + {{else if obj.upDown == 1}} | |
| 118 | + <span>下行</span> | |
| 119 | + {{/if}} | |
| 120 | + </td> | |
| 121 | + <td> | |
| 122 | + {{obj.num}} | |
| 123 | + </td> | |
| 124 | + <td> | |
| 125 | + {{obj.time}} | |
| 126 | + </td> | |
| 127 | + <td> | |
| 128 | + <a class="btn btn-sm blue btn-outline" onclick="javascript:showPhoto('{{obj.photo}}')" data-pjax></i>查看</a> | |
| 129 | + </td> | |
| 130 | +</tr> | |
| 131 | +{{/each}} | |
| 132 | +{{if list.length == 0}} | |
| 133 | +<tr> | |
| 134 | + <td colspan=8><h6 class="muted">没有找到相关数据</h6></td> | |
| 135 | +</tr> | |
| 136 | +{{/if}} | |
| 137 | +</script> | |
| 138 | +<script> | |
| 139 | +$(function(){ | |
| 140 | + // 当弹出框背景或图片被点击时触发 | |
| 141 | + $('#imageModal, #img').click(function() { | |
| 142 | + $('#imageModal').fadeOut(); // 隐藏弹出框 | |
| 143 | + }); | |
| 144 | + var page = 0, initPagination; | |
| 145 | + var icheckOptions = { | |
| 146 | + checkboxClass: 'icheckbox_flat-blue', | |
| 147 | + increaseArea: '20%' | |
| 148 | + }; | |
| 149 | + jsDoQuery(null,true); | |
| 150 | + | |
| 151 | + //重置 | |
| 152 | + $('tr.filter .filter-cancel').on('click', function(){ | |
| 153 | + $('tr.filter input, select').val('').change(); | |
| 154 | + jsDoQuery(null, true); | |
| 155 | + }); | |
| 156 | + | |
| 157 | + | |
| 158 | + //提交 | |
| 159 | + $('tr.filter .filter-submit').on('click', function(){ | |
| 160 | + var params =getParams(); | |
| 161 | + jsDoQuery(params, true); | |
| 162 | + }); | |
| 163 | + | |
| 164 | + /* | |
| 165 | + * 获取数据 p: 要提交的参数, pagination: 是否重新分页 | |
| 166 | + */ | |
| 167 | + function jsDoQuery(p, pagination){ | |
| 168 | + var params = {}; | |
| 169 | + if(p) | |
| 170 | + params = p; | |
| 171 | + params['page'] = page; | |
| 172 | + var i = layer.load(2); | |
| 173 | + $get('/kl/findAllKl' ,params, function(data){ | |
| 174 | + var list = data.dataList; | |
| 175 | + var bodyHtm = template('kl_list_temp', {list: list}); | |
| 176 | + | |
| 177 | + $('#datatable_user tbody').html(bodyHtm) | |
| 178 | + .find('.icheck').iCheck(icheckOptions) | |
| 179 | + .on('ifChanged', iCheckChange); | |
| 180 | + if(pagination && list.length > 0){ | |
| 181 | + //重新分页 | |
| 182 | + initPagination = true; | |
| 183 | + showPagination(data); | |
| 184 | + } | |
| 185 | + layer.close(i); | |
| 186 | + | |
| 187 | + }); | |
| 188 | + } | |
| 189 | + | |
| 190 | + | |
| 191 | + function getParams() { | |
| 192 | + var cells = $('tr.filter')[0].cells | |
| 193 | + ,params = {} | |
| 194 | + ,name; | |
| 195 | + $.each(cells, function(i, cell){ | |
| 196 | + var items = $('input,select', cell); | |
| 197 | + for(var j = 0, item; item = items[j++];){ | |
| 198 | + name = $(item).attr('name'); | |
| 199 | + if(name){ | |
| 200 | + params[name] = $(item).val(); | |
| 201 | + } | |
| 202 | + } | |
| 203 | + }); | |
| 204 | + return params; | |
| 205 | + } | |
| 206 | + | |
| 207 | + | |
| 208 | + function iCheckChange() { | |
| 209 | + var tr = $(this).parents('tr'); | |
| 210 | + if (this.checked) | |
| 211 | + tr.addClass('row-active'); | |
| 212 | + else | |
| 213 | + tr.removeClass('row-active'); | |
| 214 | + } | |
| 215 | + | |
| 216 | + //分页插件 | |
| 217 | + var page = 0, initPagination; | |
| 218 | + function showPagination(data) { | |
| 219 | + //分页 | |
| 220 | + $('#pagination').jqPaginator({ | |
| 221 | + totalPages: data.totalPages, | |
| 222 | + visiblePages: 6, | |
| 223 | + currentPage: page + 1, | |
| 224 | + first: '<li class="first"><a href="javascript:void(0);">首页<\/a><\/li>', | |
| 225 | + prev: '<li class="prev"><a href="javascript:void(0);">上一页<\/a><\/li>', | |
| 226 | + next: '<li class="next"><a href="javascript:void(0);">下一页<\/a><\/li>', | |
| 227 | + last: '<li class="last"><a href="javascript:void(0);">尾页<\/a><\/li>', | |
| 228 | + page: '<li class="page"><a href="javascript:void(0);">{{page}}<\/a><\/li>', | |
| 229 | + onPageChange: function (num, type) { | |
| 230 | + if (initPagination) { | |
| 231 | + initPagination = false; | |
| 232 | + return; | |
| 233 | + } | |
| 234 | + | |
| 235 | + var params = getParams(); | |
| 236 | + | |
| 237 | + page = num - 1; | |
| 238 | + jsDoQuery(params, true); | |
| 239 | + } | |
| 240 | + }); | |
| 241 | + | |
| 242 | + } | |
| 243 | + | |
| 244 | + $.get('/report/lineList',function(xlList){ | |
| 245 | + var data = []; | |
| 246 | + $.get('/user/companyData', function(result){ | |
| 247 | + for(var i = 0; i < result.length; i++){ | |
| 248 | + var companyCode = result[i].companyCode; | |
| 249 | + var children = result[i].children; | |
| 250 | + data.push({id: '', text: ''}); | |
| 251 | + for(var j = 0; j < children.length; j++){ | |
| 252 | + var code = children[j].code; | |
| 253 | + for(var k=0;k < xlList.length;k++ ){ | |
| 254 | + if(xlList[k]["fgsbm"]==code && xlList[k]["gsbm"]==companyCode){ | |
| 255 | + data.push({id: xlList[k]["xlbm"], text: xlList[k]["xlname"]}); | |
| 256 | + } | |
| 257 | + } | |
| 258 | + } | |
| 259 | + } | |
| 260 | + initPinYinSelect2('#line',data,''); | |
| 261 | + }); | |
| 262 | + }); | |
| 263 | + | |
| 264 | +}); | |
| 265 | + | |
| 266 | + | |
| 267 | +function showPhoto(imageUrl) { | |
| 268 | + // 当按钮被点击时触发 | |
| 269 | + $('#img').attr('src', 'http://58.247.254.118:9999/images/'+imageUrl); // 设置弹出框中图片的路径 | |
| 270 | + $('#imageModal').fadeIn(); // 显示弹出框 | |
| 271 | +}; | |
| 272 | +</script> | |
| 273 | + | ... | ... |