Commit d0d05b4d55efe5d5d8dd2059ec347e0cc16820ad

Authored by 廖磊
1 parent b27fab8e

报表

Too many changes to show.

To preserve performance only 11 of 20 files are displayed.

src/main/java/com/bsth/controller/oil/CwjyController.java 0 → 100644
  1 +package com.bsth.controller.oil;
  2 +
  3 +
  4 +import java.util.Date;
  5 +import java.util.Map;
  6 +
  7 +import org.springframework.beans.factory.annotation.Autowired;
  8 +import org.springframework.web.bind.annotation.PathVariable;
  9 +import org.springframework.web.bind.annotation.RequestMapping;
  10 +import org.springframework.web.bind.annotation.RequestMethod;
  11 +import org.springframework.web.bind.annotation.RequestParam;
  12 +import org.springframework.web.bind.annotation.RestController;
  13 +
  14 +import com.bsth.controller.BaseController;
  15 +import com.bsth.entity.oil.Cwjy;
  16 +import com.bsth.entity.oil.Ylxxb;
  17 +import com.bsth.entity.sys.SysUser;
  18 +import com.bsth.security.util.SecurityUtils;
  19 +import com.bsth.service.oil.CwjyService;
  20 +import com.bsth.util.PageObject;
  21 +
  22 +@RestController
  23 +@RequestMapping("cwjy")
  24 +public class CwjyController extends BaseController<Cwjy, Integer>{
  25 + @Autowired
  26 + private CwjyService service;
  27 + @RequestMapping(method = RequestMethod.POST)
  28 + public Map<String, Object> save(Cwjy t){
  29 + SysUser sysUser = SecurityUtils.getCurrentUser();
  30 + t.setCreateDate(new Date());
  31 + t.setXgr(sysUser.getUserName());
  32 + return service.save(t);
  33 + }
  34 +
  35 + @RequestMapping(value = "/pagequery",method = RequestMethod.GET)
  36 + public PageObject<Ylxxb> pagequery(@RequestParam Map<String, Object> map){
  37 + PageObject<Ylxxb> pagequery=null;
  38 + map.put("curPage", map.get("page").toString());
  39 + map.put("pageData","10");
  40 + pagequery=service.Pagequery(map);
  41 + return pagequery;
  42 + }
  43 +
  44 + @RequestMapping(value="/bynbbm",method = RequestMethod.GET)
  45 + public Ylxxb bynbbm(@RequestParam Map<String, Object> map){
  46 +
  47 + return service.bynbbm(map);
  48 + }
  49 +
  50 + /**
  51 + *
  52 + * @Title: save
  53 + * @Description: TODO(持久化对象)
  54 + * @param @param t
  55 + * @param @return 设定文件
  56 + * @return Map<String,Object> {status: 1(成功),-1(失败)}
  57 + * @throws
  58 + */
  59 + @RequestMapping(value="/savejzl",method = RequestMethod.POST)
  60 + public Map<String, Object> savejzl(Ylxxb t){
  61 + Map<String, Object> map=service.savejzl(t);
  62 + return map;
  63 + }
  64 +
  65 +
  66 +}
... ...
src/main/java/com/bsth/controller/report/ReportController.java 0 → 100644
  1 +package com.bsth.controller.report;
  2 +
  3 +import java.util.List;
  4 +import java.util.Map;
  5 +
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.web.bind.annotation.RequestMapping;
  8 +import org.springframework.web.bind.annotation.RequestMethod;
  9 +import org.springframework.web.bind.annotation.RequestParam;
  10 +import org.springframework.web.bind.annotation.RestController;
  11 +
  12 +import com.bsth.entity.excep.ArrivalInfo;
  13 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  14 +import com.bsth.service.report.ReportService;
  15 +
  16 +@RestController
  17 +@RequestMapping("report")
  18 +public class ReportController {
  19 +
  20 + @Autowired
  21 + ReportService service;
  22 +
  23 + @RequestMapping(value="/queryListBczx" ,method = RequestMethod.POST)
  24 + public List<ScheduleRealInfo> queryListBczx(@RequestParam String clzbh,@RequestParam String line,@RequestParam String date){
  25 + return service.queryListBczx(line,date,clzbh);
  26 + }
  27 +
  28 + @RequestMapping(value="/queryListZdxx" ,method = RequestMethod.POST)
  29 + public List<ArrivalInfo> queryListZdxx(@RequestParam String clzbh,@RequestParam String line,
  30 + @RequestParam String date,@RequestParam String fcsj,@RequestParam String ddsj){
  31 + return service.queryListZdxx(line,date,clzbh,fcsj,ddsj);
  32 + }
  33 + @RequestMapping(value="/queryListClzd" ,method = RequestMethod.POST)
  34 + public List<ArrivalInfo> queryListClzd(@RequestParam String zd,@RequestParam String line,
  35 + @RequestParam String zdlx,@RequestParam String fcsj,@RequestParam String ddsj){
  36 + return service.queryListClzd(line,zd,zdlx,fcsj,ddsj);
  37 + }
  38 +
  39 + @RequestMapping(value = "/sreachZd", method = RequestMethod.GET)
  40 + public List<Map<String, String>> sreachPersonnel(@RequestParam String line,@RequestParam int zdlx,@RequestParam String zd) {
  41 + return service.sreachZd(line,zdlx, zd);
  42 + }
  43 +
  44 +}
... ...
src/main/java/com/bsth/entity/excep/ArrivalInfo.java 0 → 100644
  1 +package com.bsth.entity.excep;
  2 +
  3 +import java.text.SimpleDateFormat;
  4 +import java.util.Date;
  5 +
  6 +import com.bsth.data.BasicData;
  7 +
  8 +/**
  9 + *
  10 + * @ClassName: ArrivalEntity
  11 + * @Description: TODO(进出站实体)
  12 + * @author PanZhao
  13 + * @date 2016年8月19日 上午9:32:20
  14 + *
  15 + */
  16 +public class ArrivalInfo {
  17 +
  18 + /** 设备号*/
  19 + private String deviceId;
  20 +
  21 + private String nbbm;
  22 +
  23 + /** 站点名称 */
  24 + private String stopName;
  25 +
  26 + /** 时间戳*/
  27 + private Long ts;
  28 +
  29 + /** 线路编码*/
  30 + private String lineCode;
  31 +
  32 + /** 上下行*/
  33 + private Integer upDown;
  34 +
  35 + /**站点编码*/
  36 + private String stopNo;
  37 +
  38 + /** 0: 进 1:出*/
  39 + private Integer inOut;
  40 +
  41 + private Long createDate;
  42 +
  43 + /** 是否有效 */
  44 + private boolean enable;
  45 +
  46 + /**分区字段,当年的第几周*/
  47 + private Integer weeksYear;
  48 +
  49 + private boolean tcc;
  50 +
  51 + //是否被纠正
  52 + private boolean correct;
  53 +
  54 + private String correctText;
  55 +
  56 +
  57 + private String czsj;
  58 +
  59 + private String jzsj;
  60 + /** -1 则信号有效,但程序标记为不使用 */
  61 + private int flag = 0;
  62 +
  63 + public ArrivalInfo(){}
  64 +
  65 + public ArrivalInfo(String deviceId, long ts, String lineCode, int upDown, String stopNo, int inOut, long createDate,
  66 + int weeksYear, String stopName) {
  67 +
  68 + this.deviceId = deviceId;
  69 + this.ts = ts;
  70 + this.lineCode = lineCode;
  71 + this.upDown = upDown;
  72 + this.stopNo = stopNo;
  73 + this.stopName = stopName;
  74 + this.inOut = inOut;
  75 + this.createDate = createDate;
  76 + }
  77 +
  78 +/* @Override
  79 + public boolean equals(Object obj) {
  80 + ArrivalEntity a2 = (ArrivalEntity)obj;
  81 +
  82 + return this.toString().equals(a2.toString())
  83 + && Math.abs(this.ts - a2.ts) < EQ_RANGE;
  84 + }
  85 +
  86 + @Override
  87 + public int hashCode() {
  88 + return this.toString().hashCode();
  89 + }*/
  90 +
  91 +
  92 + @Override
  93 + public String toString() {
  94 + try {
  95 + SimpleDateFormat sdfHHmm = new SimpleDateFormat("HH:mm");
  96 + return "["+BasicData.deviceId2NbbmMap.get(this.deviceId)+", "+sdfHHmm.format(new Date(this.ts))
  97 + +","+(this.getUpDown()==0?"上行":"下行")+","+(this.inOut==0?"进":"出")+","+this.stopNo+" ("+this.stopName+")]";
  98 + } catch (Exception e) {
  99 + return "";
  100 + }
  101 + }
  102 +
  103 + public String getLineCode() {
  104 + return lineCode;
  105 + }
  106 +
  107 + public void setLineCode(String lineCode) {
  108 + this.lineCode = lineCode;
  109 + }
  110 +
  111 + public Integer getUpDown() {
  112 + return upDown;
  113 + }
  114 +
  115 + public void setUpDown(Integer upDown) {
  116 + this.upDown = upDown;
  117 + }
  118 +
  119 + public String getStopNo() {
  120 + return stopNo;
  121 + }
  122 +
  123 + public void setStopNo(String stopNo) {
  124 + this.stopNo = stopNo;
  125 + }
  126 +
  127 + public Integer getInOut() {
  128 + return inOut;
  129 + }
  130 +
  131 + public void setInOut(Integer inOut) {
  132 + this.inOut = inOut;
  133 + }
  134 +
  135 + public Long getCreateDate() {
  136 + return createDate;
  137 + }
  138 +
  139 + public void setCreateDate(Long createDate) {
  140 + this.createDate = createDate;
  141 + }
  142 +
  143 + public Integer getWeeksYear() {
  144 + return weeksYear;
  145 + }
  146 +
  147 + public void setWeeksYear(Integer weeksYear) {
  148 + this.weeksYear = weeksYear;
  149 + }
  150 +
  151 + public String getDeviceId() {
  152 + return deviceId;
  153 + }
  154 +
  155 + public void setDeviceId(String deviceId) {
  156 + this.deviceId = deviceId;
  157 + }
  158 +
  159 + public Long getTs() {
  160 + return ts;
  161 + }
  162 +
  163 + public void setTs(Long ts) {
  164 + this.ts = ts;
  165 + }
  166 +
  167 + public String getStopName() {
  168 + return stopName;
  169 + }
  170 +
  171 + public void setStopName(String stopName) {
  172 + this.stopName = stopName;
  173 + }
  174 +
  175 + public String getId(){
  176 + return this.deviceId + "_" + this.ts;
  177 + }
  178 +
  179 + public String getNbbm() {
  180 + return nbbm;
  181 + }
  182 +
  183 + public void setNbbm(String nbbm) {
  184 + this.nbbm = nbbm;
  185 + }
  186 +
  187 + public boolean isEnable() {
  188 + return enable;
  189 + }
  190 +
  191 + public void setEnable(boolean enable) {
  192 + this.enable = enable;
  193 + }
  194 +
  195 + public boolean isTcc() {
  196 + return tcc;
  197 + }
  198 +
  199 + public void setTcc(boolean tcc) {
  200 + this.tcc = tcc;
  201 + }
  202 +
  203 + public boolean isOutTcc() {
  204 + return isTcc() && inOut == 1;
  205 + }
  206 +
  207 + public boolean isCorrect() {
  208 + return correct;
  209 + }
  210 +
  211 + public void setCorrect(boolean correct) {
  212 + this.correct = correct;
  213 + }
  214 +
  215 + public String getCorrectText() {
  216 + return correctText;
  217 + }
  218 +
  219 + public void setCorrectText(String correctText) {
  220 + this.correctText = correctText;
  221 + }
  222 +
  223 + public Integer getFlag() {
  224 + return flag;
  225 + }
  226 +
  227 + public void setFlag(Integer flag) {
  228 + this.flag = flag;
  229 + }
  230 +
  231 + public String getCzsj() {
  232 + return czsj;
  233 + }
  234 +
  235 + public void setCzsj(String czsj) {
  236 + this.czsj = czsj;
  237 + }
  238 +
  239 + public String getJzsj() {
  240 + return jzsj;
  241 + }
  242 +
  243 + public void setJzsj(String jzsj) {
  244 + this.jzsj = jzsj;
  245 + }
  246 +
  247 +
  248 +
  249 +}
... ...
src/main/java/com/bsth/entity/oil/Cwjy.java 0 → 100644
  1 +package com.bsth.entity.oil;
  2 +
  3 +import java.util.Date;
  4 +
  5 +import javax.persistence.Entity;
  6 +import javax.persistence.GeneratedValue;
  7 +import javax.persistence.Id;
  8 +import javax.persistence.Table;
  9 +
  10 +@Entity
  11 +@Table(name = "bsth_c_cwjy")
  12 +public class Cwjy {
  13 + @Id
  14 + @GeneratedValue
  15 + private Integer id;
  16 +
  17 + private String gsdm;
  18 +
  19 + private String fgsdm;
  20 +
  21 + private String nbbm;
  22 +
  23 + private String xgr;
  24 +
  25 + private Date createDate;
  26 +
  27 + public Integer getId() {
  28 + return id;
  29 + }
  30 +
  31 + public void setId(Integer id) {
  32 + this.id = id;
  33 + }
  34 +
  35 + public String getGsdm() {
  36 + return gsdm;
  37 + }
  38 +
  39 + public void setGsdm(String gsdm) {
  40 + this.gsdm = gsdm;
  41 + }
  42 +
  43 + public String getFgsdm() {
  44 + return fgsdm;
  45 + }
  46 +
  47 + public void setFgsdm(String fgsdm) {
  48 + this.fgsdm = fgsdm;
  49 + }
  50 +
  51 + public String getNbbm() {
  52 + return nbbm;
  53 + }
  54 +
  55 + public void setNbbm(String nbbm) {
  56 + this.nbbm = nbbm;
  57 + }
  58 +
  59 + public String getXgr() {
  60 + return xgr;
  61 + }
  62 +
  63 + public void setXgr(String xgr) {
  64 + this.xgr = xgr;
  65 + }
  66 +
  67 + public Date getCreateDate() {
  68 + return createDate;
  69 + }
  70 +
  71 + public void setCreateDate(Date createDate) {
  72 + this.createDate = createDate;
  73 + }
  74 +
  75 +
  76 +}
... ...
src/main/java/com/bsth/repository/oil/CwjyRepository.java 0 → 100644
  1 +package com.bsth.repository.oil;
  2 +
  3 +
  4 +import java.util.List;
  5 +import java.util.Map;
  6 +
  7 +import org.springframework.data.jpa.repository.Modifying;
  8 +import org.springframework.data.jpa.repository.Query;
  9 +import org.springframework.stereotype.Repository;
  10 +import org.springframework.transaction.annotation.Transactional;
  11 +
  12 +import com.bsth.entity.oil.Cwjy;
  13 +import com.bsth.entity.oil.Ylxxb;
  14 +import com.bsth.repository.BaseRepository;
  15 +
  16 +@Repository
  17 +public interface CwjyRepository extends BaseRepository<Cwjy, Integer>{
  18 + /**
  19 + * 当天手动添加的加油信息
  20 + * @param rq
  21 + * @return
  22 + */
  23 + @Transactional
  24 + @Modifying
  25 + @Query(value="SELECT a.gsdm as gsdm,a.nbbm as nbbm,b.jsy as jsy,b.jzl as jzl ,b.stationid as stationid,"
  26 + + "b.nylx as nylx,b.yj as yj,b.bz as bz,c.jsy as ldgh FROM bsth_c_cwjy a "+
  27 + " left join ( select * from bsth_c_ylxxb b where to_days(b.yyrq)=to_days(?1) and jylx=1) b " +
  28 + " on a.nbbm=b.nbbm left join (select nbbm,group_concat(jsy) as jsy from bsth_c_ylb where to_days(rq)= to_days(?1 ) group by nbbm "+
  29 + " ) c on a.nbbm=c.nbbm where a.nbbm like %?2% ",nativeQuery=true)
  30 + List<Object[]> obtainCwjycl(String rq,String nbbm);
  31 +
  32 +}
... ...
src/main/java/com/bsth/repository/realcontrol/ScheduleRealInfoRepository.java
... ... @@ -29,10 +29,15 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI
29 29 @Query(value="select s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 order by bcs")
30 30 List<ScheduleRealInfo> exportWaybill(String jName,String clZbh,String lpName);
31 31  
32   - @Query(value="select new map(clZbh as clZbh,jGh as jGh,jName as jName,sum(jhlc) as zgl,sum(addMileage) as ksgl,count(jName) as bcs) from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 group by clZbh,jGh")
  32 + @Query(value="select new map(clZbh as clZbh,jGh as jGh,jName as jName,sum(jhlc) as zgl,"
  33 + + "sum(addMileage) as ksgl,count(jName) as bcs) from ScheduleRealInfo s where"
  34 + + " s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 group by clZbh,jGh,jName")
33 35 List<Map<String, Object>> dailyInfo(String line,String date);
34 36  
35   - @Query(value="SELECT r.xl_name,r.lp_name,r.cl_zbh,d.sender,d.timestamp,d.txt_content FROM bsth_c_s_sp_info_real r RIGHT JOIN bsth_v_directive_60 d ON r.id = d.sch WHERE d.is_dispatch = 1 AND r.xl_bm = ?1 AND r.schedule_date = ?2 and r.cl_zbh = ?3 order by d.timestamp",nativeQuery=true)
  37 + @Query(value="SELECT r.xl_name,r.lp_name,r.cl_zbh,d.sender,d.timestamp,"
  38 + + " d.txt_content FROM bsth_c_s_sp_info_real r RIGHT JOIN bsth_v_directive_60 "
  39 + + "d ON r.id = d.sch WHERE d.is_dispatch = 1 AND r.xl_bm like %?1% AND "
  40 + + "r.schedule_date like %?2% and r.cl_zbh like %?3% order by d.timestamp",nativeQuery=true)
36 41 List<Object[]> historyMessage(String line,String date,String code);
37 42  
38 43 @Query(value = "select max(id) from ScheduleRealInfo")
... ... @@ -45,6 +50,10 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI
45 50 @Query(value = "select s from ScheduleRealInfo s where s.scheduleDateStr = ?1")
46 51 List<ScheduleRealInfo> findByDate(String dateStr);
47 52  
  53 + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
  54 + @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 and cl_zbh=?3 order by bcs")
  55 + List<ScheduleRealInfo> findByDate2(String line,String date,String clzbh);
  56 +
48 57 @Query(value="select count(jName) from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 and s.status = -1")
49 58 int findCjbc(String jName,String clZbh,String lpName);
50 59  
... ... @@ -54,8 +63,10 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI
54 63 @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)
55 64 List<Object[]> account(String line,String date,String code);
56 65  
57   - @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDate >= str_to_date(?2,'%Y-%m-%d') and s.scheduleDate <= str_to_date(?3,'%Y-%m-%d') and s.lpName = ?4 order by s.fcsj")
58   - List<ScheduleRealInfo> correctForm(String line,String startDate,String endDate,String lpName);
  66 + @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDate >= str_to_date(?2,'%Y-%m-%d') "
  67 + + " and s.scheduleDate <= str_to_date(?3,'%Y-%m-%d') and s.lpName like %?4% "
  68 + + " and clZbh like %?5% order by s.fcsj")
  69 + List<ScheduleRealInfo> correctForm(String line,String startDate,String endDate,String lpName,String code);
59 70  
60 71 @Query(value="select s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 and s.scheduleDate = str_to_date(?4,'%Y-%m-%d') order by bcs")
61 72 List<ScheduleRealInfo> queryListWaybill(String jName,String clZbh,String lpName,String date);
... ... @@ -78,7 +89,8 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI
78 89 @Query(value = "delete ScheduleRealInfo s where s.xlBm=?1 and s.scheduleDateStr=?2")
79 90 void deleteByLineCodeAndDate(String xlBm, String schDate);
80 91  
81   - @Query(value="select s from ScheduleRealInfo s where (s.xlBm = ?1 or s.xlBm is not null) and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2")
  92 + //去掉了 xlBm is not null
  93 + @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2")
82 94 List<ScheduleRealInfo> scheduleByDateAndLine(String line,String date);
83 95  
84 96 @Query(value="select new map(s.scheduleDate as scheduleDate,s.xlBm as xlBm,s.clZbh as clZbh,s.jGh as jGh) from ScheduleRealInfo s where (s.xlBm = ?1 or s.xlBm is not null) and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 GROUP BY xlBm,clZbh,jGh ORDER BY xlBm,clZbh,realExecDate,fcsjActual")
... ...
src/main/java/com/bsth/service/oil/CwjyService.java 0 → 100644
  1 +package com.bsth.service.oil;
  2 +
  3 +
  4 +import java.util.Map;
  5 +
  6 +import com.bsth.entity.oil.Cwjy;
  7 +import com.bsth.entity.oil.Ylxxb;
  8 +import com.bsth.service.BaseService;
  9 +import com.bsth.util.PageObject;
  10 +
  11 +public interface CwjyService extends BaseService<Cwjy, Integer>{
  12 + PageObject<Ylxxb> Pagequery(Map<String, Object> map) ;
  13 + Ylxxb bynbbm(Map<String, Object> map);
  14 +
  15 + Map<String, Object> savejzl(Ylxxb t);
  16 +}
... ...
src/main/java/com/bsth/service/oil/impl/CwjyServiceImpl.java 0 → 100644
  1 +package com.bsth.service.oil.impl;
  2 +
  3 +import java.text.ParseException;
  4 +import java.text.SimpleDateFormat;
  5 +import java.util.ArrayList;
  6 +import java.util.HashMap;
  7 +import java.util.List;
  8 +import java.util.Map;
  9 +
  10 +import org.springframework.beans.factory.annotation.Autowired;
  11 +import org.springframework.stereotype.Service;
  12 +
  13 +import com.bsth.common.ResponseCode;
  14 +import com.bsth.entity.oil.Cwjy;
  15 +import com.bsth.entity.oil.Ylxxb;
  16 +import com.bsth.repository.oil.CwjyRepository;
  17 +import com.bsth.repository.oil.YlxxbRepository;
  18 +import com.bsth.service.impl.BaseServiceImpl;
  19 +import com.bsth.service.oil.CwjyService;
  20 +import com.bsth.util.PageHelper;
  21 +import com.bsth.util.PageObject;
  22 +
  23 +@Service
  24 +public class CwjyServiceImpl extends BaseServiceImpl<Cwjy,Integer> implements CwjyService
  25 +{
  26 + @Autowired
  27 + CwjyRepository repository;
  28 + @Autowired
  29 + YlxxbRepository ylxxbRepository;
  30 +
  31 + @SuppressWarnings("unchecked")
  32 + public PageObject<Ylxxb> Pagequery(Map<String, Object> map) {
  33 + // TODO Auto-generated method stub
  34 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
  35 + List<Ylxxb> yList=new ArrayList<Ylxxb>();
  36 + String rq=map.get("rq").toString();
  37 + String nbbm="";
  38 + if(map.get("nbbm")!=null){
  39 + nbbm=map.get("nbbm").toString();
  40 + }
  41 + List<Object[]> list=repository.obtainCwjycl(rq,nbbm);
  42 + for (int i = 0; i < list.size(); i++) {
  43 + Ylxxb y=new Ylxxb();
  44 + y.setGsdm(list.get(i)[0]==null?"":list.get(i)[0].toString());
  45 + y.setNbbm(list.get(i)[1]==null?"":list.get(i)[1].toString());
  46 + y.setJsy(list.get(i)[2]==null?"":list.get(i)[2].toString());
  47 + y.setJzl(list.get(i)[3]==null?0.0:Double.parseDouble(list.get(i)[3].toString()));
  48 + y.setStationid(list.get(i)[4]==null?"":list.get(i)[4].toString());
  49 + y.setNylx(list.get(i)[5]==null?0:Integer.parseInt(list.get(i)[5].toString()));
  50 + y.setYj(list.get(i)[6]==null?0.0:Double.parseDouble(list.get(i)[6].toString()));
  51 + y.setBz(list.get(i)[7]==null?"":list.get(i)[7].toString());
  52 + y.setLdgh(list.get(i)[8]==null?"":list.get(i)[8].toString());
  53 + try {
  54 + y.setYyrq(sdf.parse(rq));
  55 + } catch (ParseException e) {
  56 + // TODO Auto-generated catch block
  57 + e.printStackTrace();
  58 + }
  59 + yList.add(y);
  60 + }
  61 + PageHelper pageHelper = new PageHelper(yList.size(), map);
  62 + pageHelper.getMap();
  63 + PageObject<Ylxxb> pageObject=pageHelper.getPageObject();
  64 + pageObject.setDataList(yList);
  65 + return pageObject;
  66 + }
  67 +
  68 + @Override
  69 + public Ylxxb bynbbm(Map<String, Object> map) {
  70 + // TODO Auto-generated method stub
  71 + // TODO Auto-generated method stub
  72 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  73 + String rq = map.get("rq").toString();
  74 + String nbbm = "";
  75 + if (map.get("nbbm") != null) {
  76 + nbbm = map.get("nbbm").toString();
  77 + }
  78 + List<Object[]> list = repository.obtainCwjycl(rq, nbbm);
  79 + Ylxxb y = new Ylxxb();
  80 + if (list.size() > 0) {
  81 + y.setGsdm(list.get(0)[0] == null ? "" : list.get(0)[0].toString());
  82 + y.setNbbm(list.get(0)[1] == null ? "" : list.get(0)[1].toString());
  83 + y.setJsy(list.get(0)[2] == null ? "" : list.get(0)[2].toString());
  84 + y.setJzl(list.get(0)[3] == null ? 0.0 : Double.parseDouble(list.get(0)[3].toString()));
  85 + y.setStationid(list.get(0)[4] == null ? "" : list.get(0)[4].toString());
  86 + y.setNylx(list.get(0)[5] == null ? 0 : Integer.parseInt(list.get(0)[5].toString()));
  87 + y.setYj(list.get(0)[6] == null ? 0.0 : Double.parseDouble(list.get(0)[6].toString()));
  88 + y.setBz(list.get(0)[7] == null ? "" : list.get(0)[7].toString());
  89 + y.setLdgh(list.get(0)[8] == null ? "" : list.get(0)[8].toString());
  90 + try {
  91 + y.setYyrq(sdf.parse(rq));
  92 + } catch (ParseException e) {
  93 + // TODO Auto-generated catch block
  94 + e.printStackTrace();
  95 + }
  96 + }
  97 + return y;
  98 + }
  99 +
  100 + @Override
  101 + public Map<String, Object> savejzl(Ylxxb t) {
  102 + // TODO Auto-generated method stub
  103 + Map<String, Object> map=new HashMap<String,Object>();
  104 + try {
  105 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  106 + String rq = sdf.format(t.getYyrq());
  107 + String nbbm=t.getNbbm();
  108 + List<Ylxxb> yList=ylxxbRepository.obtainYlxx2(rq,nbbm);
  109 + if(yList.size()>0){
  110 + t.setId(yList.get(0).getId());
  111 + ylxxbRepository.save(t);
  112 + }else{
  113 + ylxxbRepository.save(t);
  114 + }
  115 + map.put("status", ResponseCode.SUCCESS);
  116 + } catch (Exception e) {
  117 + map.put("status", ResponseCode.ERROR);
  118 + e.printStackTrace();
  119 + // TODO: handle exception
  120 + }
  121 + return map;
  122 + }
  123 +
  124 +}
... ...
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
... ... @@ -1158,7 +1158,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1158 1158 @Override
1159 1159 public List<ScheduleRealInfo> correctForm(String line, String startDate,
1160 1160 String endDate, String lpName, String code) {
1161   - List<ScheduleRealInfo> list = scheduleRealInfoRepository.correctForm(line,startDate,endDate,lpName);
  1161 + List<ScheduleRealInfo> list = scheduleRealInfoRepository.correctForm(line,startDate,endDate,lpName,code);
1162 1162 return list;
1163 1163 }
1164 1164  
... ... @@ -1215,25 +1215,25 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1215 1215 sjgl += tempJhlc;
1216 1216 }else if(scheduleRealInfo.getStatus() == -1){
1217 1217 ssgl += tempJhlc;
1218   - if(scheduleRealInfo.getRemarks().indexOf("路阻") != -1){
  1218 + if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("路阻") != -1){
1219 1219 ssgl_lz += tempJhlc;
1220   - }else if(scheduleRealInfo.getRemarks().indexOf("吊慢") != -1){
  1220 + }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("吊慢") != -1){
1221 1221 ssgl_dm += tempJhlc;
1222   - }else if(scheduleRealInfo.getRemarks().indexOf("故障") != -1){
  1222 + }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("故障") != -1){
1223 1223 ssgl_gz += tempJhlc;
1224   - }else if(scheduleRealInfo.getRemarks().indexOf("纠纷") != -1){
  1224 + }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("纠纷") != -1){
1225 1225 ssgl_jf += tempJhlc;
1226   - }else if(scheduleRealInfo.getRemarks().indexOf("肇事") != -1){
  1226 + }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("肇事") != -1){
1227 1227 ssgl_zs += tempJhlc;
1228   - }else if(scheduleRealInfo.getRemarks().indexOf("缺人") != -1){
  1228 + }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("缺人") != -1){
1229 1229 ssgl_qr += tempJhlc;
1230   - }else if(scheduleRealInfo.getRemarks().indexOf("缺车") != -1){
  1230 + }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("缺车") != -1){
1231 1231 ssgl_qc += tempJhlc;
1232   - }else if(scheduleRealInfo.getRemarks().indexOf("客稀") != -1){
  1232 + }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("客稀") != -1){
1233 1233 ssgl_kx += tempJhlc;
1234   - }else if(scheduleRealInfo.getRemarks().indexOf("气候") != -1){
  1234 + }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("气候") != -1){
1235 1235 ssgl_qh += tempJhlc;
1236   - }else if(scheduleRealInfo.getRemarks().indexOf("援外") != -1){
  1236 + }else if((scheduleRealInfo.getRemarks()==null?"":scheduleRealInfo.getRemarks()).indexOf("援外") != -1){
1237 1237 ssgl_yw += tempJhlc;
1238 1238 }else{
1239 1239 ssgl_other += tempJhlc;
... ...
src/main/java/com/bsth/service/report/ReportService.java 0 → 100644
  1 +package com.bsth.service.report;
  2 +
  3 +import java.util.List;
  4 +import java.util.Map;
  5 +
  6 +import com.bsth.entity.excep.ArrivalInfo;
  7 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  8 +
  9 +
  10 +public interface ReportService {
  11 +
  12 + List<ScheduleRealInfo> queryListBczx(String line,String date,String clzbh);
  13 +
  14 + List<ArrivalInfo> queryListZdxx(String line,String date,String clzbh,String sjfc,String sjdd);
  15 +
  16 + List<ArrivalInfo> queryListClzd(String line,String zd,String zdlx,String fcsj,String ddsj);
  17 +
  18 + List<Map<String, String>> sreachZd(String line,int zdlx,String zd);
  19 +}
... ...
src/main/java/com/bsth/service/report/impl/ReportServiceImpl.java 0 → 100644
  1 +package com.bsth.service.report.impl;
  2 +import java.sql.Connection;
  3 +import java.sql.PreparedStatement;
  4 +import java.sql.ResultSet;
  5 +import java.sql.SQLException;
  6 +import java.text.ParseException;
  7 +import java.text.SimpleDateFormat;
  8 +import java.util.ArrayList;
  9 +import java.util.Calendar;
  10 +import java.util.Date;
  11 +import java.util.HashMap;
  12 +import java.util.List;
  13 +import java.util.Map;
  14 +
  15 +import org.slf4j.Logger;
  16 +import org.slf4j.LoggerFactory;
  17 +import org.springframework.beans.factory.annotation.Autowired;
  18 +import org.springframework.jdbc.core.JdbcTemplate;
  19 +import org.springframework.stereotype.Service;
  20 +
  21 +import com.bsth.data.BasicData;
  22 +import com.bsth.entity.StationRoute;
  23 +import com.bsth.entity.excep.ArrivalInfo;
  24 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  25 +import com.bsth.repository.StationRouteRepository;
  26 +import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;
  27 +import com.bsth.service.report.ReportService;
  28 +import com.bsth.util.db.DBUtils_MS;
  29 +
  30 +@Service
  31 +public class ReportServiceImpl implements ReportService{
  32 +
  33 +
  34 + private Logger logger = LoggerFactory.getLogger(this.getClass());
  35 +
  36 + @Autowired
  37 + JdbcTemplate jdbcTemplate;
  38 +
  39 + @Autowired
  40 + ScheduleRealInfoRepository scheduleRealInfoRepository;
  41 + @Autowired
  42 + StationRouteRepository stationRoutRepository;
  43 + @Override
  44 + public List<ScheduleRealInfo> queryListBczx(String line, String date,String clzbh) {
  45 + // TODO Auto-generated method stub
  46 + List<ScheduleRealInfo> list=scheduleRealInfoRepository.findByDate2(line,date,clzbh);
  47 +
  48 +// jdbcTemplate.query("select * from bsth_c_s_sp_info_real where line=?1 "
  49 +// + "and DATE_FORMAT(schedule_date,'%Y-%m-%d')=?2 and cl_zbl=?3",
  50 +// new Object[]{line,date,clzbh},
  51 +// new RowMapper(){
  52 +// @Override
  53 +// public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
  54 +// ScheduleRealInfo s = new ScheduleRealInfo();
  55 +//// s.
  56 +// return s;
  57 +// }
  58 +// });
  59 +
  60 + return list;
  61 + }
  62 + @Override
  63 + public List<ArrivalInfo> queryListZdxx(String line, String date, String clzbh, String sjfc, String sjdd) {
  64 + // TODO Auto-generated method stub
  65 + List<ArrivalInfo> list=new ArrayList<ArrivalInfo>();
  66 + try {
  67 + String sbbb=BasicData.deviceId2NbbmMap.inverse().get(clzbh);
  68 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  69 + SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
  70 + Long date1=simpleDateFormat.parse(date+" "+sjfc+":00").getTime();
  71 + Long date2=simpleDateFormat.parse(date+" "+sjdd+":00").getTime();
  72 + Date dates=simpleDateFormat.parse(date+" 00:00:00");
  73 + List<ArrivalInfo> lists=load(line,sbbb,date1,date2,dates);
  74 +
  75 + for(int i=0;i<lists.size();i++){
  76 + ArrivalInfo t1=lists.get(i);
  77 + if(t1.getInOut()==0){
  78 + t1.setJzsj(sdf.format(new Date(t1.getTs())));
  79 + for(int j=0;j<lists.size();j++){
  80 + ArrivalInfo t2=lists.get(j);
  81 + if(t2.getInOut()==1 && t2.getDeviceId().equals(t1.getDeviceId()) && t2.getStopNo().equals(t1.getStopNo())){
  82 + t1.setCzsj(sdf.format(new Date(t2.getTs())));
  83 + }
  84 + }
  85 + list.add(t1);
  86 + }
  87 +
  88 + }
  89 +
  90 +
  91 + } catch (ParseException e) {
  92 + // TODO Auto-generated catch block
  93 + e.printStackTrace();
  94 + }
  95 +
  96 + return list;
  97 + }
  98 +
  99 +
  100 + public List<ArrivalInfo> load(String line,String sbbb,Long date1,Long date2,Date dates){
  101 + List<ArrivalInfo> list = null;
  102 + Calendar cal = Calendar.getInstance();
  103 + cal.setTime(dates);
  104 + //周数,表分区字段
  105 + int weeks_year = cal.get(Calendar.WEEK_OF_YEAR);
  106 +
  107 + Connection conn = null;
  108 + PreparedStatement ps = null;
  109 + ResultSet rs = null;
  110 +
  111 + String sql = "select * from bsth_c_arrival_info where device_id=? AND line_id=? AND weeks_year=? AND ts > ? AND ts <=? order by ts";
  112 + try{
  113 + conn = DBUtils_MS.getConnection();
  114 + ps = conn.prepareStatement(sql);
  115 + ps.setString(1, sbbb);
  116 + ps.setString(2,line);
  117 + ps.setInt(3, weeks_year);
  118 + ps.setLong(4, date1);
  119 + ps.setLong(5, date2);
  120 + rs = ps.executeQuery();
  121 +
  122 + list = resultSet2Set(rs);
  123 + }catch(Exception e){
  124 + logger.error("", e);
  125 + }finally {
  126 + DBUtils_MS.close(rs, ps, conn);
  127 + }
  128 + return list;
  129 + }
  130 +
  131 + public List<ArrivalInfo> resultSet2Set(ResultSet rs) throws SQLException{
  132 + List<ArrivalInfo> list = new ArrayList<>();
  133 +
  134 + ArrivalInfo arr;
  135 + while(rs.next()){
  136 + arr = new ArrivalInfo();
  137 + arr.setDeviceId(rs.getString("device_id"));
  138 + arr.setNbbm(BasicData.deviceId2NbbmMap.get(arr.getDeviceId()));
  139 + if(null == arr.getNbbm()){
  140 + logger.warn("未注册的设备号," + arr.getDeviceId());
  141 + continue;
  142 + }
  143 +
  144 + arr.setTs(rs.getLong("ts"));
  145 + arr.setLineCode(rs.getString("line_id"));
  146 + arr.setUpDown(rs.getInt("up_down"));
  147 + arr.setStopNo(rs.getString("stop_no"));
  148 + arr.setStopName(BasicData.stationCode2NameMap.get(arr.getStopNo()));
  149 + arr.setInOut(rs.getInt("in_out"));
  150 + arr.setCreateDate(rs.getLong("create_timestamp"));
  151 + arr.setWeeksYear(rs.getInt("weeks_year"));
  152 + arr.setEnable(true);
  153 +
  154 + list.add(arr);
  155 + }
  156 + return list;
  157 + }
  158 + @Override
  159 + public List<ArrivalInfo> queryListClzd(String line, String zd, String zdlx, String fcsj, String ddsj) {
  160 + // TODO Auto-generated method stub
  161 + List<ArrivalInfo> list=new ArrayList<ArrivalInfo>();
  162 + try {
  163 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  164 + SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
  165 + Long date1=simpleDateFormat.parse(fcsj+" 00:00:00").getTime();
  166 + Long date2=simpleDateFormat.parse(ddsj+" 23:59:59").getTime();
  167 + Date dates1=simpleDateFormat.parse(fcsj+" 00:00:00");
  168 + Date dates2=simpleDateFormat.parse(ddsj+" 00:00:00");
  169 + List<ArrivalInfo> lists=load2(line,date1,date2,dates1,dates2,zd,zdlx);
  170 +
  171 + for(int i=0;i<lists.size();i++){
  172 + ArrivalInfo t1=lists.get(i);
  173 + if(t1.getInOut()==0){
  174 + t1.setJzsj(sdf.format(new Date(t1.getTs())));
  175 + for(int j=0;j<lists.size();j++){
  176 + ArrivalInfo t2=lists.get(j);
  177 + if(t2.getInOut()==1 && t2.getDeviceId().equals(t1.getDeviceId())
  178 + && t2.getStopNo().equals(t1.getStopNo())
  179 + && t2.getTs()>t1.getTs()){
  180 + t1.setCzsj(sdf.format(new Date(t2.getTs())));
  181 + break;
  182 + }
  183 + }
  184 + list.add(t1);
  185 + }
  186 +
  187 + }
  188 +
  189 +
  190 + } catch (ParseException e) {
  191 + // TODO Auto-generated catch block
  192 + e.printStackTrace();
  193 + }
  194 +
  195 + return list;
  196 + }
  197 +
  198 +
  199 + public List<ArrivalInfo> load2(String line,Long date1,Long date2,Date dates1,Date dates2,String zd,String zdlx){
  200 + List<ArrivalInfo> list = null;
  201 + Calendar cal = Calendar.getInstance();
  202 + cal.setTime(dates1);
  203 + //周数,表分区字段
  204 + int weeks_year1 = cal.get(Calendar.WEEK_OF_YEAR);
  205 + cal.setTime(dates2);
  206 + int weeks_year2 = cal.get(Calendar.WEEK_OF_YEAR);
  207 + Connection conn = null;
  208 + PreparedStatement ps = null;
  209 + ResultSet rs = null;
  210 +
  211 + String sql = "select * from bsth_c_arrival_info where line_id=? AND weeks_year>=? "
  212 + + " AND weeks_year<=? AND ts > ? AND ts <=? AND up_down=? AND stop_no like ? order by ts";
  213 + try{
  214 + conn = DBUtils_MS.getConnection();
  215 + ps = conn.prepareStatement(sql);
  216 + ps.setString(1, line);
  217 + ps.setInt(2, weeks_year1);
  218 + ps.setInt(3, weeks_year2);
  219 + ps.setLong(4, date1);
  220 + ps.setLong(5, date2);
  221 + ps.setString(6, zdlx);
  222 + ps.setString(7, "%"+zd+"%");
  223 + rs = ps.executeQuery();
  224 +
  225 + list = resultSet2Set(rs);
  226 + }catch(Exception e){
  227 + logger.error("", e);
  228 + }finally {
  229 + DBUtils_MS.close(rs, ps, conn);
  230 + }
  231 + return list;
  232 + }
  233 + @Override
  234 + public List<Map<String, String>> sreachZd(String line, int zdlx,String zd) {
  235 + List<Map<String, String>> list = new ArrayList<>();
  236 + // TODO Auto-generated method stub
  237 + List<StationRoute> listSr=stationRoutRepository.findByLine(line,zdlx);
  238 + for (int i = 0; i < listSr.size(); i++) {
  239 + StationRoute t=listSr.get(i);
  240 + if(t.getStationName().indexOf(zd)!=-1){
  241 + Map<String, String> newMap=new HashMap<String,String>();
  242 + newMap.put("id",t.getStationCode());
  243 + newMap.put("text", t.getStationName());
  244 + list.add(newMap);
  245 + }
  246 + }
  247 + return list;
  248 + }
  249 +
  250 +}
... ...