Commit ef1a7e8c194894e67fed94c5c19840f88d6682fd
1 parent
4cd76de3
报表 YLB定时添加
Showing
4 changed files
with
304 additions
and
2 deletions
src/main/java/com/bsth/data/schedule/thread/SubmitToTrafficManage.java
| 1 | 1 | package com.bsth.data.schedule.thread; |
| 2 | 2 | |
| 3 | 3 | import com.bsth.service.TrafficManageService; |
| 4 | +import com.bsth.service.oil.YlbService; | |
| 5 | + | |
| 4 | 6 | import org.slf4j.Logger; |
| 5 | 7 | import org.slf4j.LoggerFactory; |
| 6 | 8 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | ... | @@ -17,10 +19,19 @@ public class SubmitToTrafficManage extends Thread{ |
| 17 | 19 | |
| 18 | 20 | @Autowired |
| 19 | 21 | TrafficManageService trafficManageService; |
| 22 | + | |
| 23 | + @Autowired | |
| 24 | + YlbService YlbService; | |
| 20 | 25 | |
| 21 | 26 | @Override |
| 22 | 27 | public void run() { |
| 23 | 28 | logger.info("开始提交数据到运管处..."); |
| 29 | + try{ | |
| 30 | + YlbService.obtainDsq(); | |
| 31 | + } catch(Exception e){ | |
| 32 | + logger.error("计算路单里程加注量失败",e); | |
| 33 | + } | |
| 34 | + | |
| 24 | 35 | try { |
| 25 | 36 | //路单 |
| 26 | 37 | trafficManageService.setLD(); | ... | ... |
src/main/java/com/bsth/service/oil/YlbService.java
| ... | ... | @@ -8,7 +8,7 @@ import com.bsth.service.BaseService; |
| 8 | 8 | |
| 9 | 9 | public interface YlbService extends BaseService<Ylb, Integer>{ |
| 10 | 10 | Map<String, Object> obtain(String rq); |
| 11 | - | |
| 11 | + String obtainDsq(); | |
| 12 | 12 | Map<String, Object> sort(Map<String, Object> map); |
| 13 | 13 | |
| 14 | 14 | Map<String, Object> outAndIn(Map<String, Object> map); | ... | ... |
src/main/java/com/bsth/service/oil/impl/YlbServiceImpl.java
| 1 | 1 | package com.bsth.service.oil.impl; |
| 2 | 2 | |
| 3 | +import java.sql.ResultSet; | |
| 4 | +import java.sql.SQLException; | |
| 3 | 5 | import java.text.DecimalFormat; |
| 4 | 6 | import java.text.ParseException; |
| 5 | 7 | import java.text.SimpleDateFormat; |
| 6 | 8 | import java.util.ArrayList; |
| 9 | +import java.util.Calendar; | |
| 7 | 10 | import java.util.Date; |
| 8 | 11 | import java.util.HashMap; |
| 9 | 12 | import java.util.Iterator; |
| ... | ... | @@ -17,6 +20,8 @@ import org.slf4j.LoggerFactory; |
| 17 | 20 | import org.springframework.beans.factory.annotation.Autowired; |
| 18 | 21 | import org.springframework.data.domain.Sort; |
| 19 | 22 | import org.springframework.data.domain.Sort.Direction; |
| 23 | +import org.springframework.jdbc.core.JdbcTemplate; | |
| 24 | +import org.springframework.jdbc.core.RowMapper; | |
| 20 | 25 | import org.springframework.stereotype.Service; |
| 21 | 26 | |
| 22 | 27 | import com.bsth.common.ResponseCode; |
| ... | ... | @@ -46,9 +51,100 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 46 | 51 | @Autowired |
| 47 | 52 | ScheduleRealInfoService scheduleRealInfoService; |
| 48 | 53 | |
| 54 | + @Autowired | |
| 55 | + JdbcTemplate jdbcTemplate; | |
| 56 | + | |
| 49 | 57 | Logger logger = LoggerFactory.getLogger(this.getClass()); |
| 50 | 58 | |
| 51 | 59 | |
| 60 | + | |
| 61 | + /** | |
| 62 | + * 获取进存油信息 | |
| 63 | + * @Transactional 回滚事物 | |
| 64 | + */ | |
| 65 | + @Transactional | |
| 66 | + @Override | |
| 67 | + public String obtainDsq() { | |
| 68 | + String result = "failure"; | |
| 69 | + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); | |
| 70 | + Date dNow = new Date(); //当前时间 | |
| 71 | + Date dBefore = new Date(); | |
| 72 | + Calendar calendar = Calendar.getInstance(); //得到日历 | |
| 73 | + calendar.setTime(dNow);//把当前时间赋给日历 | |
| 74 | + calendar.add(Calendar.DAY_OF_MONTH, -1); //设置为前一天 | |
| 75 | + dBefore = calendar.getTime(); //得到前一天的时间 | |
| 76 | + String rq=sdf.format(dBefore); | |
| 77 | + //保留两位小数 | |
| 78 | + DecimalFormat df = new DecimalFormat("#.00"); | |
| 79 | + // TODO Auto-generated method stub | |
| 80 | + Map<String, Object> newMap=new HashMap<String,Object>(); | |
| 81 | + //当天YLB信息 | |
| 82 | + List<Ylb> ylList=repository.obtainYl(rq); | |
| 83 | + //当天YLXXB信息 | |
| 84 | +// List<Ylxxb> ylxxList=ylxxbRepository.obtainYlxx(rq); | |
| 85 | + //前一天所有车辆最后进场班次信息 | |
| 86 | + List<Ylb> ylListBe=repository.obtainYlbefore(rq); | |
| 87 | + //从排班表中计算出行驶的总里程 | |
| 88 | + List<Map<String,Object>> listpb=scheduleRealInfoService.yesterdayDataList("1024",rq); | |
| 89 | + | |
| 90 | + for(int x=0;x<listpb.size();x++){ | |
| 91 | + | |
| 92 | + Map<String, Object> map=listpb.get(x); | |
| 93 | + | |
| 94 | + //判断驾驶员驾驶的该车辆是否已经存入了(查出的结果集中日期是相同的,根据驾驶员、内部编号、线路编码判断) | |
| 95 | + Ylb t=new Ylb(); | |
| 96 | + for(int k=0;k<ylList.size();k++){ | |
| 97 | + Ylb t1=ylList.get(k); | |
| 98 | + if(t1.getNbbm().equals(map.get("clZbh").toString()) | |
| 99 | + &&t1.getJsy().equals(map.get("jGh").toString()) | |
| 100 | + &&t1.getXlbm().equals(map.get("xlBm").toString())) | |
| 101 | + { | |
| 102 | + t=t1; | |
| 103 | + } | |
| 104 | + } | |
| 105 | + try { | |
| 106 | + //当日的第一个班次,出场油量等于前一天的最后一个班次的进场油量 | |
| 107 | + if(map.get("seqNumber").toString().equals("1")){ | |
| 108 | + for (int y = 0; y < ylListBe.size(); y++) { | |
| 109 | + Ylb ylb=ylListBe.get(y); | |
| 110 | + if(map.get("clZbh").toString().equals(ylb.getNbbm())){ | |
| 111 | + t.setCzyl(ylb.getJzyl()); | |
| 112 | + break; | |
| 113 | + }else{ | |
| 114 | + t.setCzyl(0.0); | |
| 115 | + } | |
| 116 | + } | |
| 117 | + } | |
| 118 | + | |
| 119 | + /*Double jzl=0.0; | |
| 120 | + //把当天的YLXXB的加注量设置为当天YLB的加注量(根据车号,驾驶员判断) | |
| 121 | + for(int j=0;j<ylxxList.size();j++){ | |
| 122 | + Ylxxb ylxxb= ylxxList.get(j); | |
| 123 | + if(map.get("clZbh").toString().equals(ylxxb.getNbbm()) &&map.get("jGh").toString().equals(ylxxb.getJsy())){ | |
| 124 | + jzl+=ylxxb.getJzl(); | |
| 125 | + } | |
| 126 | + } | |
| 127 | + t.setJzl(jzl);*/ | |
| 128 | + t.setNbbm(map.get("clZbh").toString()); | |
| 129 | + t.setJsy(map.get("jGh")==null?"":map.get("jGh").toString()); | |
| 130 | + t.setZlc(map.get("totalKilometers")==null?0.0:Double.parseDouble(df.format(Double.parseDouble(map.get("totalKilometers").toString())))); | |
| 131 | + t.setXlbm(map.get("xlBm")==null?"":map.get("xlBm").toString()); | |
| 132 | + t.setJcsx(Integer.parseInt(map.get("seqNumber").toString())); | |
| 133 | + t.setSsgsdm(map.get("company")==null?"":map.get("company").toString()); | |
| 134 | + t.setRq(dBefore); | |
| 135 | + repository.save(t); | |
| 136 | + result = "success"; | |
| 137 | + } catch (Exception e) { | |
| 138 | + // TODO Auto-generated catch block | |
| 139 | + e.printStackTrace(); | |
| 140 | + }finally{ | |
| 141 | + logger.info("setDDRB:"+result); | |
| 142 | + } | |
| 143 | + } | |
| 144 | + | |
| 145 | + return result; | |
| 146 | + } | |
| 147 | + | |
| 52 | 148 | /** |
| 53 | 149 | * 获取进存油信息 |
| 54 | 150 | * @Transactional 回滚事物 |
| ... | ... | @@ -394,8 +490,36 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 394 | 490 | |
| 395 | 491 | @Override |
| 396 | 492 | public List<Ylb> oilListMonth(String line, String date) { |
| 493 | + String date2=date.substring(0, 8)+"01"; | |
| 494 | + String lineStr=""; | |
| 495 | + if(line !=null && !line.equals("")){ | |
| 496 | + lineStr =" and xlbm= '"+ line +"'"; | |
| 497 | + } | |
| 498 | + String sql="select a.nbbm,a.rq,a.jzyl from (" + | |
| 499 | + " select x.nbbm,max(x.rq) as rq,max(x.jcsx) as jcsx from " | |
| 500 | + + "(select nbbm,rq,max(jcsx) as jcsx from bsth_c_ylb where rq between '" | |
| 501 | + + date2 +"' and '" + date+"' "+lineStr | |
| 502 | + + "group by nbbm,rq) x group by x.nbbm ) b" | |
| 503 | + + " left join (select nbbm,rq,jzyl,jcsx FROM bsth_c_ylb " | |
| 504 | + + " where rq between '" | |
| 505 | + + date2 +"' and '" + date+"' "+lineStr | |
| 506 | + + ") a " | |
| 507 | + + " on a.nbbm =b.nbbm and a.jcsx=b.jcsx and a.rq=b.rq " | |
| 508 | + + " where a.nbbm is not null order by a.nbbm"; | |
| 509 | + | |
| 397 | 510 | // TODO Auto-generated method stub |
| 398 | - return null; | |
| 511 | + List<Ylb> list =jdbcTemplate.query(sql, | |
| 512 | + new RowMapper<Ylb>(){ | |
| 513 | + @Override | |
| 514 | + public Ylb mapRow(ResultSet rs, int rowNum) throws SQLException { | |
| 515 | + Ylb s = new Ylb(); | |
| 516 | + s.setNbbm(rs.getString("nbbm")); | |
| 517 | + s.setRq(rs.getDate("rq")); | |
| 518 | + s.setJzyl(rs.getDouble("jzyl")); | |
| 519 | + return s; | |
| 520 | + } | |
| 521 | + }); | |
| 522 | + return list; | |
| 399 | 523 | } |
| 400 | 524 | |
| 401 | 525 | ... | ... |
src/main/resources/static/pages/report/oil/oilListMonth.html
0 → 100644
| 1 | +<style type="text/css"> | |
| 2 | + .table-bordered { | |
| 3 | + border: 1px solid; } | |
| 4 | + .table-bordered > thead > tr > th, | |
| 5 | + .table-bordered > thead > tr > td, | |
| 6 | + .table-bordered > tbody > tr > th, | |
| 7 | + .table-bordered > tbody > tr > td, | |
| 8 | + .table-bordered > tfoot > tr > th, | |
| 9 | + .table-bordered > tfoot > tr > td { | |
| 10 | + border: 1px solid; } | |
| 11 | + .table-bordered > thead > tr > th, | |
| 12 | + .table-bordered > thead > tr > td { | |
| 13 | + border-bottom-width: 2px; } | |
| 14 | + | |
| 15 | + .table > tbody + tbody { | |
| 16 | + border-top: 1px solid; } | |
| 17 | +</style> | |
| 18 | + | |
| 19 | +<div class="page-head"> | |
| 20 | + <div class="page-title"> | |
| 21 | + <h1>月存油报表</h1> | |
| 22 | + </div> | |
| 23 | +</div> | |
| 24 | + | |
| 25 | +<div class="row"> | |
| 26 | + <div class="col-md-12"> | |
| 27 | + <div class="portlet light porttlet-fit bordered"> | |
| 28 | + <div class="portlet-title"> | |
| 29 | + <form class="form-inline" action=""> | |
| 30 | + <div style="display: inline-block;"> | |
| 31 | + <span class="item-label" style="width: 80px;">时间: </span> | |
| 32 | + <input class="form-control" type="text" id="date" style="width: 180px;"/> | |
| 33 | + </div> | |
| 34 | + <div style="display: inline-block;margin-left: 15px;"> | |
| 35 | + <span class="item-label" style="width: 80px;">线路: </span> | |
| 36 | + <select class="form-control" name="line" id="line" style="width: 180px;"></select> | |
| 37 | + </div> | |
| 38 | + <div class="form-group"> | |
| 39 | + <input class="btn btn-default" type="button" id="query" value="查询"/> | |
| 40 | + <input class="btn btn-default" type="button" id="export" value="导出"/> | |
| 41 | + </div> | |
| 42 | + </form> | |
| 43 | + </div> | |
| 44 | + <div class="portlet-body"> | |
| 45 | + <div class="table-container" style="margin-top: 10px;overflow:auto;min-width: 906px"> | |
| 46 | + <table class="table table-bordered table-hover table-checkable" id="forms"> | |
| 47 | + <thead> | |
| 48 | + <tr> | |
| 49 | + <td>序号</td> | |
| 50 | + <td>车号</td> | |
| 51 | + <td>日期</td> | |
| 52 | + <td>存油</td> | |
| 53 | + | |
| 54 | + <td>序号</td> | |
| 55 | + <td>车号</td> | |
| 56 | + <td>日期</td> | |
| 57 | + <td>存油</td> | |
| 58 | + | |
| 59 | + <td>序号</td> | |
| 60 | + <td>车号</td> | |
| 61 | + <td>日期</td> | |
| 62 | + <td>存油</td> | |
| 63 | + | |
| 64 | + <td>序号</td> | |
| 65 | + <td>车号</td> | |
| 66 | + <td>日期</td> | |
| 67 | + <td>存油</td> | |
| 68 | + | |
| 69 | + <td>序号</td> | |
| 70 | + <td>车号</td> | |
| 71 | + <td>日期</td> | |
| 72 | + <td>存油</td> | |
| 73 | + </tr> | |
| 74 | + </thead> | |
| 75 | + | |
| 76 | + <tbody > | |
| 77 | + | |
| 78 | + </tbody> | |
| 79 | + </table> | |
| 80 | + </div> | |
| 81 | + </div> | |
| 82 | + </div> | |
| 83 | + </div> | |
| 84 | +</div> | |
| 85 | + | |
| 86 | +<script> | |
| 87 | + $(function(){ | |
| 88 | + // 关闭左侧栏 | |
| 89 | + if (!$('body').hasClass('page-sidebar-closed')) | |
| 90 | + $('.menu-toggler.sidebar-toggler').click(); | |
| 91 | + | |
| 92 | + $("#date").datetimepicker({ | |
| 93 | + format : 'YYYY-MM-DD', | |
| 94 | + locale : 'zh-cn' | |
| 95 | + }); | |
| 96 | + | |
| 97 | + $('#line').select2({ | |
| 98 | + ajax: { | |
| 99 | + url: '/realSchedule/findLine', | |
| 100 | + dataType: 'json', | |
| 101 | + delay: 150, | |
| 102 | + data: function(params){ | |
| 103 | + return{line: params.term}; | |
| 104 | + }, | |
| 105 | + processResults: function (data) { | |
| 106 | + return { | |
| 107 | + results: data | |
| 108 | + }; | |
| 109 | + }, | |
| 110 | + cache: true | |
| 111 | + }, | |
| 112 | + templateResult: function(repo){ | |
| 113 | + if (repo.loading) return repo.text; | |
| 114 | + var h = '<span>'+repo.text+'</span>'; | |
| 115 | + return h; | |
| 116 | + }, | |
| 117 | + escapeMarkup: function (markup) { return markup; }, | |
| 118 | + minimumInputLength: 1, | |
| 119 | + templateSelection: function(repo){ | |
| 120 | + return repo.text; | |
| 121 | + }, | |
| 122 | + language: { | |
| 123 | + noResults: function(){ | |
| 124 | + return '<span style="color:red;font-size: 12px;">没有搜索到线路!</span>'; | |
| 125 | + }, | |
| 126 | + inputTooShort : function(e) { | |
| 127 | + return '<span style="color:gray;font-size: 12px;"><i class="fa fa-search"></i> 输入线路搜索线路</span>'; | |
| 128 | + }, | |
| 129 | + searching : function() { | |
| 130 | + return '<span style="color:gray;font-size: 12px;"> 正在搜索线路...</span>'; | |
| 131 | + } | |
| 132 | + } | |
| 133 | + }); | |
| 134 | + | |
| 135 | + //查询 | |
| 136 | + $("#query").on('click',function(){ | |
| 137 | + var line = $("#line").val(); | |
| 138 | + var date = $("#date").val(); | |
| 139 | + $get('/ylb/oilListMonth',{line:line,date:date},function(result){ | |
| 140 | + $.each(result, function(i, obj) { | |
| 141 | + obj.rq = moment(obj.rq).format("DD"); | |
| 142 | + }); | |
| 143 | + var oilListMonth = template('oilListMonth',{list:result}); | |
| 144 | + $('#forms tbody').html(oilListMonth); | |
| 145 | + }); | |
| 146 | + }); | |
| 147 | + }); | |
| 148 | +</script> | |
| 149 | +<script type="text/html" id="oilListMonth"> | |
| 150 | + {{each list as obj i}} | |
| 151 | + {{if i%5 == 0}} | |
| 152 | + <tr> | |
| 153 | + {{/if}} | |
| 154 | + <td>{{i+1}}</td> | |
| 155 | + <td>{{obj.nbbm}}</td> | |
| 156 | + <td>{{obj.rq}}</td> | |
| 157 | + <td>{{obj.jzyl}}</td> | |
| 158 | + {{if (i+1)%5 == 0}} | |
| 159 | + </tr> | |
| 160 | + {{/if}} | |
| 161 | + {{/each}} | |
| 162 | + {{if list.length == 0}} | |
| 163 | + <tr> | |
| 164 | + <td colspan="15"><h6 class="muted">没有找到相关数据</h6></td> | |
| 165 | + </tr> | |
| 166 | + {{/if}} | |
| 167 | +</script> | |
| 0 | 168 | \ No newline at end of file | ... | ... |