Commit 03466fc6513945487c91d0395f3375d235fa6d9b
1 parent
cd10c3cd
LGF 导出
Showing
6 changed files
with
126 additions
and
24 deletions
src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
| ... | ... | @@ -310,8 +310,8 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, |
| 310 | 310 | |
| 311 | 311 | @RequestMapping(value = "/historyMessage") |
| 312 | 312 | public List<Object[]> historyMessage(@RequestParam String line, @RequestParam String date, |
| 313 | - @RequestParam String code) { | |
| 314 | - return scheduleRealInfoService.historyMessage(line, date, code); | |
| 313 | + @RequestParam String code, @RequestParam String type) { | |
| 314 | + return scheduleRealInfoService.historyMessage(line, date, code, type); | |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | @RequestMapping(value="/findLine") |
| ... | ... | @@ -332,8 +332,8 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, |
| 332 | 332 | |
| 333 | 333 | @RequestMapping(value = "/account") |
| 334 | 334 | public List<Map<String,Object>> account(@RequestParam String line, @RequestParam String date, |
| 335 | - @RequestParam String code,@RequestParam String xlName) { | |
| 336 | - return scheduleRealInfoService.account(line, date, code,xlName); | |
| 335 | + @RequestParam String code,@RequestParam String xlName, @RequestParam String type) { | |
| 336 | + return scheduleRealInfoService.account(line, date, code, xlName, type); | |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | @RequestMapping(value = "/correctForm") | ... | ... |
src/main/java/com/bsth/repository/realcontrol/ScheduleRealInfoRepository.java
| ... | ... | @@ -71,7 +71,7 @@ public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealI |
| 71 | 71 | @Query(value="select count(jName) from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 and sflj != 0") |
| 72 | 72 | int findLjbc(String jName,String clZbh,String lpName); |
| 73 | 73 | |
| 74 | - @Query(value="SELECT c.company,r.request_code,FROM_UNIXTIME(r.timestamp/1000,'%Y-%m-%d %T') FROM bsth_v_report_80 r LEFT JOIN bsth_c_cars c ON c.equipment_code = r.device_id where FROM_UNIXTIME(r.timestamp/1000,'%Y-%m-%d') = ?2 and r.line_id = ?1 and c.inside_code = ?3",nativeQuery=true) | |
| 74 | + @Query(value="SELECT c.company,r.request_code,FROM_UNIXTIME(r.timestamp/1000,'%Y-%m-%d %T'),c.inside_code FROM bsth_v_report_80 r LEFT JOIN bsth_c_cars c ON c.equipment_code = r.device_id where FROM_UNIXTIME(r.timestamp/1000,'%Y-%m-%d') = ?2 and r.line_id = ?1 and c.inside_code = ?3",nativeQuery=true) | |
| 75 | 75 | List<Object[]> account(String line,String date,String code); |
| 76 | 76 | |
| 77 | 77 | @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDate >= str_to_date(?2,'%Y-%m-%d') " | ... | ... |
src/main/java/com/bsth/service/realcontrol/ScheduleRealInfoService.java
| ... | ... | @@ -65,7 +65,7 @@ public interface ScheduleRealInfoService extends BaseService<ScheduleRealInfo, L |
| 65 | 65 | |
| 66 | 66 | List<Map<String,Object>> dailyInfo(String line,String date,String type); |
| 67 | 67 | |
| 68 | - List<Object[]> historyMessage(String line,String date,String code); | |
| 68 | + List<Object[]> historyMessage(String line,String date,String code, String type); | |
| 69 | 69 | |
| 70 | 70 | Map<Integer, Integer> trustStatus(String lineCodes); |
| 71 | 71 | |
| ... | ... | @@ -93,7 +93,7 @@ public interface ScheduleRealInfoService extends BaseService<ScheduleRealInfo, L |
| 93 | 93 | |
| 94 | 94 | List<Map<String,String>> findLpName(String lpName); |
| 95 | 95 | |
| 96 | - List<Map<String,Object>> account(String line,String date,String code,String xlName); | |
| 96 | + List<Map<String,Object>> account(String line,String date,String code,String xlName, String type); | |
| 97 | 97 | |
| 98 | 98 | List<ScheduleRealInfo> correctForm(String line,String startDate,String endDate,String lpName,String code); |
| 99 | 99 | ... | ... |
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
| ... | ... | @@ -617,7 +617,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 617 | 617 | } |
| 618 | 618 | |
| 619 | 619 | @Override |
| 620 | - public List<Object[]> historyMessage(String line, String date, String code) { | |
| 620 | + public List<Object[]> historyMessage(String line, String date, String code, String type) { | |
| 621 | 621 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| 622 | 622 | long d= 0; |
| 623 | 623 | long t=0; |
| ... | ... | @@ -639,6 +639,36 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 639 | 639 | obj[4] = BasicData.lineCode2NameMap.get(line); |
| 640 | 640 | } |
| 641 | 641 | } |
| 642 | + | |
| 643 | + if(type != null && type.length() != 0 && type.equals("export")){ | |
| 644 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | |
| 645 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | |
| 646 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | |
| 647 | + Map<String,Object> m = new HashMap<String, Object>(); | |
| 648 | + ReportUtils ee = new ReportUtils(); | |
| 649 | + List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>(); | |
| 650 | + for(int i = 0; i < list.size(); i++){ | |
| 651 | + Map<String, Object> map = new HashMap<String, Object>(); | |
| 652 | + Object[] obj = list.get(i); | |
| 653 | + map.put("num", i + 1); | |
| 654 | + map.put("line", obj[4]); | |
| 655 | + map.put("clZbh", obj[0]); | |
| 656 | + map.put("sender", obj[1]); | |
| 657 | + map.put("date", obj[3]); | |
| 658 | + map.put("text", obj[2]); | |
| 659 | + newList.add(map); | |
| 660 | + } | |
| 661 | + try { | |
| 662 | + listI.add(newList.iterator()); | |
| 663 | + String path = this.getClass().getResource("/").getPath()+"static\\pages\\forms\\"; | |
| 664 | + ee.excelReplace(listI, new Object[] { m }, path+"mould\\historyMessage.xls", | |
| 665 | + path+"export\\调度历史消息" + sdfSimple.format(sdfMonth.parse(date)) + ".xls"); | |
| 666 | + } catch (Exception e) { | |
| 667 | + // TODO: handle exception | |
| 668 | + e.printStackTrace(); | |
| 669 | + } | |
| 670 | + } | |
| 671 | + | |
| 642 | 672 | return list; |
| 643 | 673 | } |
| 644 | 674 | |
| ... | ... | @@ -1218,13 +1248,15 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 1218 | 1248 | |
| 1219 | 1249 | @Override |
| 1220 | 1250 | public List<Map<String, Object>> account(String line, String date, |
| 1221 | - String code,String xlName) { | |
| 1251 | + String code,String xlName, String type) { | |
| 1222 | 1252 | List<Object[]> lsitObj = scheduleRealInfoRepository.account(line,date,code); |
| 1223 | 1253 | List<Map<String,Object>> listMap = new ArrayList<Map<String,Object>>(); |
| 1224 | 1254 | Map<String,Object> map; |
| 1255 | + int i = 1; | |
| 1225 | 1256 | for(Object[] obj : lsitObj){ |
| 1226 | 1257 | if(obj != null){ |
| 1227 | 1258 | map = new HashMap<String,Object>(); |
| 1259 | + map.put("num", i++); | |
| 1228 | 1260 | map.put("xlName", xlName); |
| 1229 | 1261 | map.put("clZbh", obj[3]); |
| 1230 | 1262 | map.put("company", obj[0]); |
| ... | ... | @@ -1233,6 +1265,38 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 1233 | 1265 | listMap.add(map); |
| 1234 | 1266 | } |
| 1235 | 1267 | } |
| 1268 | + | |
| 1269 | + if(type != null && type.length() != 0 && type.equals("export")){ | |
| 1270 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | |
| 1271 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | |
| 1272 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | |
| 1273 | + Map<String,Object> m = new HashMap<String, Object>(); | |
| 1274 | + ReportUtils ee = new ReportUtils(); | |
| 1275 | + Map<String, Object> typeMap = new HashMap<String, Object>(); | |
| 1276 | + typeMap.put("0xA1", "请求恢复运营"); | |
| 1277 | + typeMap.put("0xA2", "申请调档"); | |
| 1278 | + typeMap.put("0xA3", "出场请求"); | |
| 1279 | + typeMap.put("0xA5", "进场请求"); | |
| 1280 | + typeMap.put("0xA7", "加油请求"); | |
| 1281 | + typeMap.put("0x50", "车辆故障"); | |
| 1282 | + typeMap.put("0x70", "路阻报告"); | |
| 1283 | + typeMap.put("0x60", "事故报告"); | |
| 1284 | + typeMap.put("0x11", "扣证纠纷"); | |
| 1285 | + typeMap.put("0x12", "报警"); | |
| 1286 | + for(Map<String, Object> map1 : listMap){ | |
| 1287 | + map1.put("requestText", typeMap.get(map1.get("requestType"))); | |
| 1288 | + } | |
| 1289 | + try { | |
| 1290 | + listI.add(listMap.iterator()); | |
| 1291 | + String path = this.getClass().getResource("/").getPath()+"static\\pages\\forms\\"; | |
| 1292 | + ee.excelReplace(listI, new Object[] { m }, path+"mould\\account.xls", | |
| 1293 | + path+"export\\驾驶员请求台账" + sdfSimple.format(sdfMonth.parse(date)) + ".xls"); | |
| 1294 | + } catch (Exception e) { | |
| 1295 | + // TODO: handle exception | |
| 1296 | + e.printStackTrace(); | |
| 1297 | + } | |
| 1298 | + } | |
| 1299 | + | |
| 1236 | 1300 | return listMap; |
| 1237 | 1301 | } |
| 1238 | 1302 | ... | ... |
src/main/resources/static/pages/forms/statement/account.html
| ... | ... | @@ -41,7 +41,7 @@ |
| 41 | 41 | </div> |
| 42 | 42 | <div class="form-group"> |
| 43 | 43 | <input class="btn btn-default" type="button" id="query" value="筛选"/> |
| 44 | -<!-- <input class="btn btn-default" type="button" id="export" value="导出"/> --> | |
| 44 | + <input class="btn btn-default" type="button" id="export" value="导出"/> | |
| 45 | 45 | </div> |
| 46 | 46 | </form> |
| 47 | 47 | </div> |
| ... | ... | @@ -70,6 +70,9 @@ |
| 70 | 70 | |
| 71 | 71 | <script> |
| 72 | 72 | $(function(){ |
| 73 | + $("#export").attr('disabled',"true"); | |
| 74 | + | |
| 75 | + | |
| 73 | 76 | var reqCodeMap = {"0xA1": '请求恢复运营', "0xA2": '申请调档', "0xA3": '出场请求', "0xA5": '进场请求', "0xA7": '加油请求', "0x50": '车辆故障', "0x70": '路阻报告', "0x60": '事故报告', "0x11": '扣证纠纷', "0x12" : '报警'}; |
| 74 | 77 | // 关闭左侧栏 |
| 75 | 78 | if (!$('body').hasClass('page-sidebar-closed')) |
| ... | ... | @@ -130,14 +133,19 @@ |
| 130 | 133 | } |
| 131 | 134 | } |
| 132 | 135 | }); |
| 133 | - | |
| 136 | + | |
| 137 | + var line = $("#line").val(); | |
| 138 | + var xlName = $("#select2-line-container").html(); | |
| 139 | + var date = $("#date").val(); | |
| 140 | + var code = $("#code").val(); | |
| 134 | 141 | $("#query").on("click",function(){ |
| 135 | - var line = $("#line").val(); | |
| 136 | - var xlName = $("#select2-line-container").html(); | |
| 137 | - var date = $("#date").val(); | |
| 138 | - var code = $("#code").val(); | |
| 142 | + line = $("#line").val(); | |
| 143 | + xlName = $("#select2-line-container").html(); | |
| 144 | + date = $("#date").val(); | |
| 145 | + code = $("#code").val(); | |
| 146 | + var type = "query"; | |
| 139 | 147 | $(".hidden").removeClass("hidden"); |
| 140 | - $post('/realSchedule/account',{line:line,date:date,code:code,xlName:xlName},function(result){ | |
| 148 | + $post('/realSchedule/account',{line:line,date:date,code:code,xlName:xlName,type:type},function(result){ | |
| 141 | 149 | $.each(result, function(i, obj) { |
| 142 | 150 | obj.requestType = reqCodeMap[obj.requestType]; |
| 143 | 151 | }); |
| ... | ... | @@ -145,8 +153,22 @@ |
| 145 | 153 | var tbodyHtml = template('list_account',{list:result}); |
| 146 | 154 | // 把渲染好的模版html文本追加到表格中 |
| 147 | 155 | $('#forms tbody').html(tbodyHtml); |
| 156 | + | |
| 157 | + if(result.length == 0) | |
| 158 | + $("#export").attr('disabled',"true"); | |
| 159 | + else | |
| 160 | + $("#export").removeAttr("disabled"); | |
| 161 | + | |
| 148 | 162 | }); |
| 149 | - }); | |
| 163 | + }); | |
| 164 | + | |
| 165 | + $("#export").on("click",function(){ | |
| 166 | + var type = "export"; | |
| 167 | + $get('/realSchedule/account', {line:line,date:date,code:code,xlName:xlName,type:type}, function(result){ | |
| 168 | + window.open("/downloadFile/download?fileName=驾驶员请求台账"+moment(date).format("YYYYMMDD")); | |
| 169 | + }); | |
| 170 | + }); | |
| 171 | + | |
| 150 | 172 | }); |
| 151 | 173 | </script> |
| 152 | 174 | <script type="text/html" id="list_account"> | ... | ... |
src/main/resources/static/pages/forms/statement/historyMessage.html
| ... | ... | @@ -41,7 +41,7 @@ |
| 41 | 41 | </div> |
| 42 | 42 | <div class="form-group"> |
| 43 | 43 | <input class="btn btn-default" type="button" id="query" value="筛选"/> |
| 44 | -<!-- <input class="btn btn-default" type="button" id="export" value="导出"/> --> | |
| 44 | + <input class="btn btn-default" type="button" id="export" value="导出"/> | |
| 45 | 45 | </div> |
| 46 | 46 | </form> |
| 47 | 47 | </div> |
| ... | ... | @@ -69,7 +69,9 @@ |
| 69 | 69 | </div> |
| 70 | 70 | |
| 71 | 71 | <script> |
| 72 | - $(function(){ | |
| 72 | + $(function(){ | |
| 73 | + $('#export').attr('disabled', "true"); | |
| 74 | + | |
| 73 | 75 | // 关闭左侧栏 |
| 74 | 76 | if (!$('body').hasClass('page-sidebar-closed')) |
| 75 | 77 | $('.menu-toggler.sidebar-toggler').click(); |
| ... | ... | @@ -127,21 +129,35 @@ |
| 127 | 129 | } |
| 128 | 130 | } |
| 129 | 131 | }); |
| 130 | - | |
| 132 | + | |
| 133 | + var line = $("#line").val(); | |
| 134 | + var date = $("#date").val(); | |
| 135 | + var code = $("#code").val(); | |
| 131 | 136 | $("#query").on("click",function(){ |
| 132 | - var line = $("#line").val(); | |
| 133 | - var date = $("#date").val(); | |
| 134 | - var code = $("#code").val(); | |
| 137 | + line = $("#line").val(); | |
| 138 | + date = $("#date").val(); | |
| 139 | + code = $("#code").val(); | |
| 140 | + var type = "query"; | |
| 135 | 141 | $(".hidden").removeClass("hidden"); |
| 136 | 142 | $get('/realSchedule/historyMessage',{line:line,date:date,code:code},function(result){ |
| 137 | 143 | // 把数据填充到模版中 |
| 138 | 144 | var tbodyHtml = template('list_history',{list:result}); |
| 139 | 145 | // 把渲染好的模版html文本追加到表格中 |
| 140 | 146 | $('#forms tbody').html(tbodyHtml); |
| 147 | + | |
| 148 | + if(result.length == 0) | |
| 149 | + $("#export").attr('disabled',"true"); | |
| 150 | + else | |
| 151 | + $("#export").removeAttr("disabled"); | |
| 152 | + | |
| 141 | 153 | }); |
| 142 | 154 | }); |
| 155 | + | |
| 143 | 156 | $("#export").on("click",function(){ |
| 144 | - $('#forms').tableExport({ type: 'excel', escape: 'false',filename:'(2016-02-29_2016-03-06)'}); | |
| 157 | + var type = "export"; | |
| 158 | + $get('/realSchedule/historyMessage', {line:line,date:date,code:code,type:type}, function(result){ | |
| 159 | + window.open("/downloadFile/download?fileName=调度历史消息"+moment(date).format("YYYYMMDD")); | |
| 160 | + }); | |
| 145 | 161 | }); |
| 146 | 162 | |
| 147 | 163 | }); | ... | ... |