Commit 612d668a6136851859c74aa10658cc399add0ff2
1 parent
235171cb
LGF 导出
Showing
5 changed files
with
45 additions
and
9 deletions
src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
| @@ -340,8 +340,9 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, | @@ -340,8 +340,9 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, | ||
| 340 | } | 340 | } |
| 341 | 341 | ||
| 342 | @RequestMapping(value="/statisticsDaily") | 342 | @RequestMapping(value="/statisticsDaily") |
| 343 | - public List<Map<String,Object>> statisticsDaily(@RequestParam String line,@RequestParam String date,@RequestParam String xlName){ | ||
| 344 | - return scheduleRealInfoService.statisticsDaily(line, date,xlName); | 343 | + public List<Map<String,Object>> statisticsDaily(@RequestParam String line, @RequestParam String date, |
| 344 | + @RequestParam String xlName, @RequestParam String type){ | ||
| 345 | + return scheduleRealInfoService.statisticsDaily(line, date, xlName, type); | ||
| 345 | } | 346 | } |
| 346 | 347 | ||
| 347 | @RequestMapping(value="/MapById",method = RequestMethod.GET) | 348 | @RequestMapping(value="/MapById",method = RequestMethod.GET) |
src/main/java/com/bsth/service/realcontrol/ScheduleRealInfoService.java
| @@ -107,7 +107,7 @@ public interface ScheduleRealInfoService extends BaseService<ScheduleRealInfo, L | @@ -107,7 +107,7 @@ public interface ScheduleRealInfoService extends BaseService<ScheduleRealInfo, L | ||
| 107 | 107 | ||
| 108 | Map<String, Object> removeChildTask(Long taskId); | 108 | Map<String, Object> removeChildTask(Long taskId); |
| 109 | 109 | ||
| 110 | - List<Map<String,Object>> statisticsDaily(String line,String date,String xlName); | 110 | + List<Map<String,Object>> statisticsDaily(String line, String date, String xlName, String type); |
| 111 | 111 | ||
| 112 | //List<Object> scheduleDaily(String line,String date); | 112 | //List<Object> scheduleDaily(String line,String date); |
| 113 | 113 |
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
| @@ -1378,7 +1378,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | @@ -1378,7 +1378,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | ||
| 1378 | 1378 | ||
| 1379 | @Override | 1379 | @Override |
| 1380 | public List<Map<String, Object>> statisticsDaily(String line, String date, | 1380 | public List<Map<String, Object>> statisticsDaily(String line, String date, |
| 1381 | - String xlName) { | 1381 | + String xlName, String type) { |
| 1382 | List<ScheduleRealInfo> list = scheduleRealInfoRepository.scheduleByDateAndLine(line, date); | 1382 | List<ScheduleRealInfo> list = scheduleRealInfoRepository.scheduleByDateAndLine(line, date); |
| 1383 | List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>(); | 1383 | List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>(); |
| 1384 | DecimalFormat format = new DecimalFormat("0.00"); | 1384 | DecimalFormat format = new DecimalFormat("0.00"); |
| @@ -1545,6 +1545,24 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | @@ -1545,6 +1545,24 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf | ||
| 1545 | map.put("djg_a", djg_a); | 1545 | map.put("djg_a", djg_a); |
| 1546 | map.put("djg_time", djg_time); | 1546 | map.put("djg_time", djg_time); |
| 1547 | lMap.add(map); | 1547 | lMap.add(map); |
| 1548 | + | ||
| 1549 | + if(type != null && type.length() != 0 && type.equals("export")){ | ||
| 1550 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 1551 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 1552 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 1553 | + Map<String,Object> m = new HashMap<String, Object>(); | ||
| 1554 | + ReportUtils ee = new ReportUtils(); | ||
| 1555 | + try { | ||
| 1556 | + listI.add(lMap.iterator()); | ||
| 1557 | + String path = this.getClass().getResource("/").getPath()+"static\\pages\\forms\\"; | ||
| 1558 | + ee.excelReplace(listI, new Object[] { m }, path+"mould\\statisticsDaily_.xls", | ||
| 1559 | + path+"export\\统计日报" + sdfSimple.format(sdfMonth.parse(date))+".xls"); | ||
| 1560 | + } catch (Exception e) { | ||
| 1561 | + // TODO: handle exception | ||
| 1562 | + e.printStackTrace(); | ||
| 1563 | + } | ||
| 1564 | + } | ||
| 1565 | + | ||
| 1548 | return lMap; | 1566 | return lMap; |
| 1549 | } | 1567 | } |
| 1550 | 1568 |
src/main/resources/static/pages/forms/mould/statisticsDaily_.xls
No preview for this file type
src/main/resources/static/pages/forms/statement/statisticsDaily .html
| @@ -37,7 +37,7 @@ | @@ -37,7 +37,7 @@ | ||
| 37 | </div> | 37 | </div> |
| 38 | <div class="form-group"> | 38 | <div class="form-group"> |
| 39 | <input class="btn btn-default" type="button" id="query" value="查询"/> | 39 | <input class="btn btn-default" type="button" id="query" value="查询"/> |
| 40 | -<!-- <input class="btn btn-default" type="button" id="export" value="导出"/> --> | 40 | + <input class="btn btn-default" type="button" id="export" value="导出"/> |
| 41 | </div> | 41 | </div> |
| 42 | </form> | 42 | </form> |
| 43 | </div> | 43 | </div> |
| @@ -156,6 +156,8 @@ | @@ -156,6 +156,8 @@ | ||
| 156 | 156 | ||
| 157 | <script> | 157 | <script> |
| 158 | $(function(){ | 158 | $(function(){ |
| 159 | + $('#export').attr('disabled', "true"); | ||
| 160 | + | ||
| 159 | // 关闭左侧栏 | 161 | // 关闭左侧栏 |
| 160 | if (!$('body').hasClass('page-sidebar-closed')) | 162 | if (!$('body').hasClass('page-sidebar-closed')) |
| 161 | $('.menu-toggler.sidebar-toggler').click(); | 163 | $('.menu-toggler.sidebar-toggler').click(); |
| @@ -176,17 +178,32 @@ | @@ -176,17 +178,32 @@ | ||
| 176 | }) | 178 | }) |
| 177 | 179 | ||
| 178 | 180 | ||
| 181 | + var line = $("#line").val(); | ||
| 182 | + var xlName = $("#select2-line-container").html(); | ||
| 183 | + var date = $("#date").val(); | ||
| 179 | $("#query").on("click",function(){ | 184 | $("#query").on("click",function(){ |
| 180 | - var line = $("#line").val(); | ||
| 181 | - var xlName = $("#select2-line-container").html(); | ||
| 182 | - var date = $("#date").val(); | ||
| 183 | - $get('/realSchedule/statisticsDaily',{line:line,date:date,xlName:xlName},function(result){ | 185 | + line = $("#line").val(); |
| 186 | + xlName = $("#select2-line-container").html(); | ||
| 187 | + date = $("#date").val(); | ||
| 188 | + $get('/realSchedule/statisticsDaily',{line:line,date:date,xlName:xlName,type:"query"},function(result){ | ||
| 184 | // 把数据填充到模版中 | 189 | // 把数据填充到模版中 |
| 185 | var tbodyHtml = template('statisticsDaily',{list:result}); | 190 | var tbodyHtml = template('statisticsDaily',{list:result}); |
| 186 | // 把渲染好的模版html文本追加到表格中 | 191 | // 把渲染好的模版html文本追加到表格中 |
| 187 | $('#forms .statisticsDaily').html(tbodyHtml); | 192 | $('#forms .statisticsDaily').html(tbodyHtml); |
| 193 | + | ||
| 194 | + if(result.length == 0) | ||
| 195 | + $("#export").attr('disabled',"true"); | ||
| 196 | + else | ||
| 197 | + $("#export").removeAttr("disabled"); | ||
| 188 | }); | 198 | }); |
| 189 | }); | 199 | }); |
| 200 | + | ||
| 201 | + $("#export").on("click",function(){ | ||
| 202 | + $get('/realSchedule/statisticsDaily',{line:line,date:date,xlName:xlName,type:"export"},function(result){ | ||
| 203 | + window.open("/downloadFile/download?fileName=统计日报"+moment(date).format("YYYYMMDD")); | ||
| 204 | + }); | ||
| 205 | + }); | ||
| 206 | + | ||
| 190 | }); | 207 | }); |
| 191 | </script> | 208 | </script> |
| 192 | <script type="text/html" id="statisticsDaily"> | 209 | <script type="text/html" id="statisticsDaily"> |