Commit 8629bc5077a3e470f540be194793c2bb8331bda9

Authored by 王通
1 parent bee85d6c

1.维修上报报表完成

src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
@@ -25,6 +25,7 @@ import com.bsth.data.BasicData; @@ -25,6 +25,7 @@ import com.bsth.data.BasicData;
25 import com.bsth.data.schedule.DayOfSchedule; 25 import com.bsth.data.schedule.DayOfSchedule;
26 import com.bsth.data.schedule.edit_logs.service.dto.SchEditInfoDto; 26 import com.bsth.data.schedule.edit_logs.service.dto.SchEditInfoDto;
27 import com.bsth.entity.realcontrol.ScheduleRealInfo; 27 import com.bsth.entity.realcontrol.ScheduleRealInfo;
  28 +import com.bsth.entity.report.RepairReport;
28 import com.bsth.entity.schedule.SchedulePlanInfo; 29 import com.bsth.entity.schedule.SchedulePlanInfo;
29 import com.bsth.service.realcontrol.ScheduleRealInfoService; 30 import com.bsth.service.realcontrol.ScheduleRealInfoService;
30 31
@@ -718,5 +719,8 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, @@ -718,5 +719,8 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo,
718 return scheduleRealInfoService.repairReport(param, true); 719 return scheduleRealInfoService.repairReport(param, true);
719 } 720 }
720 721
721 - 722 + @RequestMapping(value = "wxsb", method = RequestMethod.GET)
  723 + public List<RepairReport> repairReportList(@RequestParam String line, @RequestParam String date, @RequestParam String code, @RequestParam String type){
  724 + return scheduleRealInfoService.repairReportList(line, date, code, type);
  725 + }
722 } 726 }
src/main/java/com/bsth/entity/report/RepairReport.java
@@ -6,6 +6,7 @@ import javax.persistence.Entity; @@ -6,6 +6,7 @@ import javax.persistence.Entity;
6 import javax.persistence.GeneratedValue; 6 import javax.persistence.GeneratedValue;
7 import javax.persistence.Id; 7 import javax.persistence.Id;
8 import javax.persistence.Table; 8 import javax.persistence.Table;
  9 +import javax.persistence.Transient;
9 10
10 /** 11 /**
11 ** 维修上报信息 12 ** 维修上报信息
@@ -19,6 +20,10 @@ public class RepairReport { @@ -19,6 +20,10 @@ public class RepairReport {
19 @Id 20 @Id
20 @GeneratedValue 21 @GeneratedValue
21 private Integer id; 22 private Integer id;
  23 + // 线路编码
  24 + private String lineId;
  25 + // 线路名称
  26 + private String lineName;
22 // 上报用户名 27 // 上报用户名
23 private String reportUser; 28 private String reportUser;
24 // 上报姓名 29 // 上报姓名
@@ -33,8 +38,14 @@ public class RepairReport { @@ -33,8 +38,14 @@ public class RepairReport {
33 private String repairType; 38 private String repairType;
34 // 报修时间 39 // 报修时间
35 private Date reportDate; 40 private Date reportDate;
  41 + // 格式化的时间字符串
  42 + @Transient
  43 + private String reportDateStr;
36 // 报修状态 0 不报 1上报成功 -1上报失败 44 // 报修状态 0 不报 1上报成功 -1上报失败
37 private int reportState; 45 private int reportState;
  46 + // 格式化的时间字符串
  47 + @Transient
  48 + private String reportStateStr;
38 49
39 public Integer getId() { 50 public Integer getId() {
40 return id; 51 return id;
@@ -44,6 +55,22 @@ public class RepairReport { @@ -44,6 +55,22 @@ public class RepairReport {
44 this.id = id; 55 this.id = id;
45 } 56 }
46 57
  58 + public String getLineId() {
  59 + return lineId;
  60 + }
  61 +
  62 + public void setLineId(String lineId) {
  63 + this.lineId = lineId;
  64 + }
  65 +
  66 + public String getLineName() {
  67 + return lineName;
  68 + }
  69 +
  70 + public void setLineName(String lineName) {
  71 + this.lineName = lineName;
  72 + }
  73 +
47 public String getReportUser() { 74 public String getReportUser() {
48 return reportUser; 75 return reportUser;
49 } 76 }
@@ -100,6 +127,14 @@ public class RepairReport { @@ -100,6 +127,14 @@ public class RepairReport {
100 this.reportDate = reportDate; 127 this.reportDate = reportDate;
101 } 128 }
102 129
  130 + public String getReportDateStr() {
  131 + return reportDateStr;
  132 + }
  133 +
  134 + public void setReportDateStr(String reportDateStr) {
  135 + this.reportDateStr = reportDateStr;
  136 + }
  137 +
103 public int getReportState() { 138 public int getReportState() {
104 return reportState; 139 return reportState;
105 } 140 }
@@ -107,4 +142,12 @@ public class RepairReport { @@ -107,4 +142,12 @@ public class RepairReport {
107 public void setReportState(int reportState) { 142 public void setReportState(int reportState) {
108 this.reportState = reportState; 143 this.reportState = reportState;
109 } 144 }
  145 +
  146 + public String getReportStateStr() {
  147 + return reportStateStr;
  148 + }
  149 +
  150 + public void setReportStateStr(String reportStateStr) {
  151 + this.reportStateStr = reportStateStr;
  152 + }
110 } 153 }
src/main/java/com/bsth/repository/RepairReportRepository.java
1 package com.bsth.repository; 1 package com.bsth.repository;
2 2
  3 +import java.util.Date;
  4 +import java.util.List;
  5 +
  6 +import org.springframework.data.jpa.repository.Query;
3 import org.springframework.stereotype.Repository; 7 import org.springframework.stereotype.Repository;
4 8
5 import com.bsth.entity.report.RepairReport; 9 import com.bsth.entity.report.RepairReport;
@@ -23,4 +27,8 @@ import com.bsth.entity.report.RepairReport; @@ -23,4 +27,8 @@ import com.bsth.entity.report.RepairReport;
23 @Repository 27 @Repository
24 public interface RepairReportRepository extends BaseRepository<RepairReport, Integer> { 28 public interface RepairReportRepository extends BaseRepository<RepairReport, Integer> {
25 29
  30 + @Query(value="select r from "
  31 + + " RepairReport r where r.lineId = ?1 and r.reportDate between ?2 and "
  32 + + "?3 and r.incode like ?4%")
  33 + List<RepairReport> repairReportList(String lineId,Date start,Date end,String incode);
26 } 34 }
src/main/java/com/bsth/service/realcontrol/ScheduleRealInfoService.java
@@ -4,6 +4,7 @@ import com.bsth.controller.realcontrol.dto.ChangePersonCar; @@ -4,6 +4,7 @@ import com.bsth.controller.realcontrol.dto.ChangePersonCar;
4 import com.bsth.controller.realcontrol.dto.DfsjChange; 4 import com.bsth.controller.realcontrol.dto.DfsjChange;
5 import com.bsth.data.schedule.edit_logs.service.dto.SchEditInfoDto; 5 import com.bsth.data.schedule.edit_logs.service.dto.SchEditInfoDto;
6 import com.bsth.entity.realcontrol.ScheduleRealInfo; 6 import com.bsth.entity.realcontrol.ScheduleRealInfo;
  7 +import com.bsth.entity.report.RepairReport;
7 import com.bsth.entity.schedule.SchedulePlanInfo; 8 import com.bsth.entity.schedule.SchedulePlanInfo;
8 import com.bsth.service.BaseService; 9 import com.bsth.service.BaseService;
9 import org.springframework.stereotype.Service; 10 import org.springframework.stereotype.Service;
@@ -196,4 +197,6 @@ public interface ScheduleRealInfoService extends BaseService&lt;ScheduleRealInfo, L @@ -196,4 +197,6 @@ public interface ScheduleRealInfoService extends BaseService&lt;ScheduleRealInfo, L
196 Integer isCircleQdz(String clzbh,String sdr,String xlbm,String qdzCode); 197 Integer isCircleQdz(String clzbh,String sdr,String xlbm,String qdzCode);
197 198
198 Map<String, Object> repairReport(Map<String, Object> map, boolean isActive); 199 Map<String, Object> repairReport(Map<String, Object> map, boolean isActive);
  200 +
  201 + List<RepairReport> repairReportList(String line,String date,String code, String type);
199 } 202 }
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
@@ -6126,6 +6126,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -6126,6 +6126,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
6126 } 6126 }
6127 // 持久化此次上报记录 6127 // 持久化此次上报记录
6128 RepairReport rr = new RepairReport(); 6128 RepairReport rr = new RepairReport();
  6129 + rr.setLineId(sch.getXlBm());
  6130 + rr.setLineName(sch.getXlName());
6129 rr.setReportUser(reportUser); 6131 rr.setReportUser(reportUser);
6130 rr.setReportName(reportName); 6132 rr.setReportName(reportName);
6131 rr.setSchId(id); 6133 rr.setSchId(id);
@@ -6139,6 +6141,92 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -6139,6 +6141,92 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
6139 6141
6140 return res; 6142 return res;
6141 } 6143 }
  6144 +
  6145 + @Override
  6146 + public List<RepairReport> repairReportList(String lineId, String date, String incode, String type) {
  6147 + List<RepairReport> result = new ArrayList<RepairReport>();
  6148 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  6149 +
  6150 + Date start = null, end = null;
  6151 + if (date.length() > 0) {
  6152 + try {
  6153 + start = sdf.parse(date + " 00:00:00");
  6154 + end = sdf.parse(date + " 23:59:59");
  6155 + } catch (ParseException e) {
  6156 + // TODO Auto-generated catch block
  6157 + e.printStackTrace();
  6158 + }
  6159 +
  6160 + }
  6161 +
  6162 + result = repairReportRepository.repairReportList(lineId, start, end, incode);
  6163 + Map<String, Object> dMap=new HashMap<>();
  6164 + dMap.put("dGroup", "repairtype");
  6165 + Map<String, String> code2name = new HashMap<String, String>();
  6166 + for (Dictionary dic : dictionaryService.list(dMap)) {
  6167 + code2name.put(dic.getdCode(), dic.getdName());
  6168 + }
  6169 + for (RepairReport rr : result) {
  6170 + String repairType = rr.getRepairType();
  6171 + String[] types = repairType.split(";");
  6172 + StringBuilder sb = new StringBuilder();
  6173 +
  6174 + for (String t : types) {
  6175 + sb.append(code2name.get(t)).append(";");
  6176 + }
  6177 +
  6178 + rr.setRepairType(sb.toString());
  6179 + rr.setReportDateStr(sdf.format(rr.getReportDate()));
  6180 + switch (rr.getReportState()) {
  6181 + case 0:
  6182 + rr.setReportStateStr("不报");
  6183 + break;
  6184 + case 1:
  6185 + rr.setReportStateStr("上报成功");
  6186 + break;
  6187 + case -1:
  6188 + rr.setReportStateStr("上报失败");
  6189 + break;
  6190 + default:
  6191 + break;
  6192 + }
  6193 + }
  6194 +
  6195 + if ("export".equals(type)) {
  6196 + String lineName = BasicData.lineCode2NameMap.get(lineId);
  6197 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
  6198 + sdfSimple = new SimpleDateFormat("yyyyMMdd");
  6199 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  6200 + Map<String, Object> m = new HashMap<String, Object>();
  6201 + ReportUtils ee = new ReportUtils();
  6202 + List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>();
  6203 + for (int i = 0; i < result.size(); i++) {
  6204 + Map<String, Object> map = new HashMap<String, Object>();
  6205 + RepairReport rr = result.get(i);
  6206 + map.put("row", i + 1);
  6207 + map.put("lineId", rr.getLineName());
  6208 + map.put("incode", rr.getIncode());
  6209 + map.put("departureTime", rr.getDepartureTime());
  6210 + map.put("reportUser", rr.getReportUser());
  6211 + map.put("reportDateStr", rr.getReportDate());
  6212 + map.put("repairType", rr.getRepairType());
  6213 + map.put("reportStateStr", rr.getReportStateStr());
  6214 + newList.add(map);
  6215 + }
  6216 + try {
  6217 + listI.add(newList.iterator());
  6218 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  6219 + ee.excelReplace(listI, new Object[]{m}, path + "mould/repairReport.xls",
  6220 + path + "export/" + sdfSimple.format(sdfMonth.parse(date))
  6221 + + "-" + lineName + "-维修上报记录.xls");
  6222 + } catch (Exception e) {
  6223 + // TODO: handle exception
  6224 + e.printStackTrace();
  6225 + }
  6226 + }
  6227 +
  6228 + return result;
  6229 + }
6142 } 6230 }
6143 6231
6144 class AccountMap implements Comparator<Map<String, Object>> { 6232 class AccountMap implements Comparator<Map<String, Object>> {
src/main/resources/static/pages/forms/mould/repairReport.xls 0 → 100644
No preview for this file type
src/main/resources/static/pages/forms/statement/repairReport.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 id="history" class="form-inline" action="">
  30 + <div style="display: inline-block;">
  31 + <span class="item-label" style="width: 80px;">线路: </span>
  32 + <select class="form-control" name="line" id="line" style="width: 180px;"></select>
  33 + </div>
  34 + <div style="display: inline-block;margin-left: 15px;">
  35 + <span class="item-label" style="width: 80px;">时间: </span>
  36 + <input class="form-control" type="text" id="date" style="width: 180px;"/>
  37 + </div>
  38 + <div style="display: inline-block;margin-left: 15px">
  39 + <span class="item-label" style="width: 140px;">车辆编码: </span>
  40 + <select class="form-control" name="code" id="code" style="width: 180px;"></select>
  41 + </div>
  42 + <div class="form-group">
  43 + <input class="btn btn-default" type="button" id="query" value="筛选"/>
  44 + <input class="btn btn-default" type="button" id="export" value="导出"/>
  45 + </div>
  46 + </form>
  47 + </div>
  48 + <div class="portlet-body">
  49 + <div class="table-container" style="margin-top: 10px;overflow:auto;min-width: 906px;">
  50 + <table class="table table-bordered table-hover table-checkable" id="forms">
  51 + <thead>
  52 + <tr class="hidden">
  53 + <th>序号</th>
  54 + <th>线路</th>
  55 + <th>车辆编码</th>
  56 + <th>发车时间</th>
  57 + <th>上报人</th>
  58 + <th>上报时间</th>
  59 + <th>维修类型</th>
  60 + <th>上报状态</th>
  61 + </tr>
  62 + </thead>
  63 + <tbody>
  64 +
  65 + </tbody>
  66 + </table>
  67 + </div>
  68 + </div>
  69 + </div>
  70 + </div>
  71 +</div>
  72 +
  73 +<script>
  74 + $(function(){
  75 + $('#export').attr('disabled', "true");
  76 +
  77 + // 关闭左侧栏
  78 + if (!$('body').hasClass('page-sidebar-closed'))
  79 + $('.menu-toggler.sidebar-toggler').click();
  80 +
  81 + $("#date").datetimepicker({
  82 + format : 'YYYY-MM-DD',
  83 + locale : 'zh-cn'
  84 + });
  85 +
  86 + $.get('/report/lineList',function(xlList){
  87 + var data = [];
  88 + $.get('/user/companyData', function(result){
  89 + debugger;
  90 + for(var i = 0; i < result.length; i++){
  91 + var companyCode = result[i].companyCode;
  92 + var children = result[i].children;
  93 + for(var j = 0; j < children.length; j++){
  94 + var code = children[j].code;
  95 + for(var k=0;k < xlList.length;k++ ){
  96 + if(xlList[k]["fgsbm"]==code && xlList[k]["gsbm"]==companyCode){
  97 + data.push({id: xlList[k]["xlbm"], text: xlList[k]["xlname"]});
  98 + }
  99 + }
  100 + }
  101 + }
  102 + initPinYinSelect2('#line',data,'');
  103 +
  104 + });
  105 + });
  106 +
  107 +
  108 + $('#code').select2({
  109 + ajax: {
  110 + url: '/realSchedule/sreachVehic',
  111 + dataType: 'json',
  112 + delay: 150,
  113 + data: function(params){
  114 + return{nbbm: params.term};
  115 + },
  116 + processResults: function (data) {
  117 + return {
  118 + results: data
  119 + };
  120 + },
  121 + cache: true
  122 + },
  123 + templateResult: function(repo){
  124 + if (repo.loading) return repo.text;
  125 + var h = '<span>'+repo.text+'</span>';
  126 + h += (repo.lineName?'&nbsp;<span class="select2-desc">'+repo.lineName+'</span>':'');
  127 + return h;
  128 + },
  129 + escapeMarkup: function (markup) { return markup; },
  130 + minimumInputLength: 1,
  131 + templateSelection: function(repo){
  132 + return repo.text;
  133 + },
  134 + language: {
  135 + noResults: function(){
  136 + return '<span style="color:red;font-size: 12px;">没有搜索到车辆!</span>';
  137 + },
  138 + inputTooShort : function(e) {
  139 + return '<span style="color:gray;font-size: 12px;"><i class="fa fa-search"></i> 输入自编号搜索车辆</span>';
  140 + },
  141 + searching : function() {
  142 + return '<span style="color:gray;font-size: 12px;"> 正在搜索车辆...</span>';
  143 + }
  144 + }
  145 + });
  146 +
  147 + var line = $("#line").val();
  148 + var date = $("#date").val();
  149 + var code = $("#code").val();
  150 + var lineName = $('#line option:selected').text();
  151 + $("#query").on("click",function(){
  152 + if($("#date").val() == null || $("#date").val().trim().length == 0){
  153 + layer.msg("请选择时间");
  154 + return;
  155 + }
  156 + line = $("#line").val();
  157 + date = $("#date").val();
  158 + code = $("#code").val();
  159 + lineName = $('#line option:selected').text();
  160 + var type = "query";
  161 + $(".hidden").removeClass("hidden");
  162 + var i = layer.load(2);
  163 + $get('/realSchedule/wxsb',{line:line,date:date,code:code,type:type},function(result){
  164 + // 把数据填充到模版中
  165 + var tbodyHtml = template('list_repair',{list:result});
  166 + // 把渲染好的模版html文本追加到表格中
  167 + $('#forms tbody').html(tbodyHtml);
  168 + layer.close(i);
  169 +
  170 + if(result.length == 0)
  171 + $("#export").attr('disabled',"true");
  172 + else
  173 + $("#export").removeAttr("disabled");
  174 +
  175 + });
  176 + });
  177 +
  178 + $("#export").on("click",function(){
  179 + var type = "export";
  180 + var i = layer.load(2);
  181 + $get('/realSchedule/wxsb', {line:line,date:date,code:code,type:type}, function(result){
  182 + window.open("/downloadFile/download?fileName="
  183 + +moment(date).format("YYYYMMDD")
  184 + +"-"+lineName+"-维修上报记录");
  185 + layer.close(i);
  186 + });
  187 + });
  188 +
  189 + });
  190 +</script>
  191 +<script type="text/html" id="list_repair">
  192 + {{each list as obj i}}
  193 + <tr>
  194 + <td>{{i+1}}</td>
  195 + <td>{{obj.lineName}}</td>
  196 + <td>{{obj.incode}}</td>
  197 + <td>{{obj.departureTime}}</td>
  198 + <td>{{obj.reportUser}}</td>
  199 + <td>{{obj.reportDateStr}}</td>
  200 + <td>{{obj.repairType}}</td>
  201 + <td>{{obj.reportStateStr}}</td>
  202 + </tr>
  203 + {{/each}}
  204 + {{if list.length == 0}}
  205 + <tr>
  206 + <td colspan="8"><h6 class="muted">没有找到相关数据</h6></td>
  207 + </tr>
  208 + {{/if}}
  209 +</script>
0 \ No newline at end of file 210 \ No newline at end of file