Commit 66d75254869fbdd10478b257ec9b223060d5bdd7

Authored by 娄高锋
1 parent 6f8c052c

添加接口:首班车因缺人而烂班(早未到)

src/main/java/com/bsth/server_rs/bigdata/BigscreenService.java
@@ -24,7 +24,6 @@ import javax.ws.rs.Path; @@ -24,7 +24,6 @@ import javax.ws.rs.Path;
24 import javax.ws.rs.PathParam; 24 import javax.ws.rs.PathParam;
25 import javax.ws.rs.Produces; 25 import javax.ws.rs.Produces;
26 import javax.ws.rs.core.MediaType; 26 import javax.ws.rs.core.MediaType;
27 -import javax.ws.rs.ext.MessageBodyWriter;  
28 27
29 import org.apache.commons.lang.StringUtils; 28 import org.apache.commons.lang.StringUtils;
30 import org.slf4j.Logger; 29 import org.slf4j.Logger;
@@ -2753,6 +2752,146 @@ public class BigscreenService { @@ -2753,6 +2752,146 @@ public class BigscreenService {
2753 return resList; 2752 return resList;
2754 } 2753 }
2755 2754
  2755 + /** 按日期查询出车的早未到情况 */
  2756 + @GET
  2757 + @Path("/selectData/getNotYet/{date}")
  2758 + public Map<String, Object> getNotYet(@PathParam("date") String date){
  2759 + Map<String, Object> resMap = new HashMap<String, Object>();
  2760 +
  2761 + String yyxlSql="SELECT line_code from bsth_c_line "
  2762 + + " where nature in ('yxl','cgxl','gjxl','csbs','cctxl')";
  2763 + List<Map<String, Object>> yyxlList=jdbcTemplate.query(yyxlSql,
  2764 + new RowMapper<Map<String, Object>>(){
  2765 + @Override
  2766 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  2767 + Map<String, Object> m=new HashMap<String,Object>();
  2768 + m.put("lineCode", rs.getString("line_code"));
  2769 + return m;
  2770 + }
  2771 + });
  2772 + Set<String> yyLine = new HashSet<String>();
  2773 + for(Map<String, Object> t : yyxlList){
  2774 + if(t.get("lineCode") != null){
  2775 + yyLine.add(t.get("lineCode").toString());
  2776 + }
  2777 + }
  2778 +
  2779 + String sqlMinYysj="select line, start_opt from bsth_c_line_config where "
  2780 + + " id in (select max(id) from bsth_c_line_config group by line)";
  2781 + List<Map<String, Object>> minfcsjList = jdbcTemplate.query(sqlMinYysj,
  2782 + new RowMapper<Map<String, Object>>(){
  2783 + @Override
  2784 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  2785 + Map<String, Object> map = new HashMap<String, Object>();
  2786 + map.put("line", rs.getString("line")!=null?rs.getString("line"):"");
  2787 + map.put("minfcsj", rs.getString("start_opt")!=null?rs.getString("start_opt"):"02:00");
  2788 + return map;
  2789 + }
  2790 + });
  2791 +
  2792 + Map<String, Object> minfcsjMap = new HashMap<String, Object>();
  2793 + for(Map<String, Object> map : minfcsjList){
  2794 + minfcsjMap.put(map.get("line").toString(), map.get("minfcsj").toString());
  2795 + }
  2796 +
  2797 + SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
  2798 + String format = sdf.format(new Date());
  2799 +
  2800 + List<ScheduleRealInfo> findAll = scheduleRealInfoRepository.findAll(date);
  2801 + List<ScheduleRealInfo> list_s = new ArrayList<ScheduleRealInfo>();
  2802 + Map<String, ScheduleRealInfo> scheduleMap = new HashMap<String, ScheduleRealInfo>();
  2803 + for(ScheduleRealInfo s : findAll){
  2804 + if(s.getXlBm() != null && yyLine.contains(s.getXlBm())){//营运线路
  2805 + Set<ChildTaskPlan> cts = s.getcTasks();
  2806 + if (cts != null && cts.size() > 0) {
  2807 + list_s.add(s);
  2808 + } else if (s.getZdsjActual() != null && s.getFcsjActual() != null) {
  2809 + list_s.add(s);
  2810 + } else if(s.getStatus() != 0){
  2811 + list_s.add(s);
  2812 + }
  2813 + }
  2814 + }
  2815 +
  2816 + for(ScheduleRealInfo s : list_s){
  2817 + if(!(isInOut(s)) && !s.isCcService()){
  2818 + String[] split = s.getFcsj().split(":");
  2819 + Long time = Long.valueOf(split[0]) * 60 + Long.valueOf(split[1]);
  2820 + String minfcsj = minfcsjMap.get(s.getXlBm())!=null?minfcsjMap.get(s.getXlBm()).toString():"02:00";
  2821 + String[] split_min = minfcsj.trim().split(":");
  2822 + Long min = Long.valueOf(split_min[0]) * 60 + Long.valueOf(split_min[1]);
  2823 + if(time < min){
  2824 + time += 1440;
  2825 + }
  2826 + s.setFcsjT(time);
  2827 + String cl = s.getClZbh();
  2828 + if(scheduleMap.containsKey(cl)){
  2829 + ScheduleRealInfo s2 = scheduleMap.get(cl);
  2830 + if(time < s2.getFcsjT()){
  2831 + scheduleMap.put(cl, s);
  2832 + }
  2833 + } else {
  2834 + scheduleMap.put(cl, s);
  2835 + }
  2836 + }
  2837 + }
  2838 +
  2839 + long sum = scheduleMap.keySet().size(), zwd = 0;//早未到数
  2840 + long yg_z = 0, sn_z = 0, jg_z = 0, nh_z = 0;
  2841 + long yg_zwd = 0, sn_zwd = 0, jg_zwd = 0, nh_zwd = 0;
  2842 + for(String key : scheduleMap.keySet()){
  2843 + ScheduleRealInfo s = scheduleMap.get(key);
  2844 + if("05".equals(s.getGsBm())){
  2845 + yg_z += 1;
  2846 + } else if("55".equals(s.getGsBm())){
  2847 + sn_z += 1;
  2848 + } else if("22".equals(s.getGsBm())){
  2849 + jg_z += 1;
  2850 + } else if("26".equals(s.getGsBm())){
  2851 + nh_z += 1;
  2852 + }
  2853 + if("缺人".equals(s.getAdjustExps())){
  2854 + List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>();
  2855 + list.add(s);
  2856 + BigDecimal sjgl = new BigDecimal(culateSjgl(list));
  2857 + BigDecimal ljgl = new BigDecimal(culateLjgl(list));
  2858 + BigDecimal zero = new BigDecimal(0.0);
  2859 + if(sjgl.compareTo(zero) == 0 && ljgl.compareTo(zero) == 0){
  2860 + zwd += 1;
  2861 + if("05".equals(s.getGsBm())){
  2862 + yg_zwd += 1;
  2863 + } else if("55".equals(s.getGsBm())){
  2864 + sn_zwd += 1;
  2865 + } else if("22".equals(s.getGsBm())){
  2866 + jg_zwd += 1;
  2867 + } else if("26".equals(s.getGsBm())){
  2868 + nh_zwd += 1;
  2869 + }
  2870 + }
  2871 + }
  2872 + }
  2873 +
  2874 + resMap.put("sum", sum);
  2875 + resMap.put("notYet", zwd);
  2876 + resMap.put("sum_05", yg_z);
  2877 + resMap.put("notYet_05", yg_zwd);
  2878 + resMap.put("sum_55", sn_z);
  2879 + resMap.put("notYet_55", sn_zwd);
  2880 + resMap.put("sum_22", jg_z);
  2881 + resMap.put("notYet_22", jg_zwd);
  2882 + resMap.put("sum_26", nh_z);
  2883 + resMap.put("notYet_26", nh_zwd);
  2884 + return resMap;
  2885 + }
  2886 +
  2887 + public static void main(String[] args){
  2888 + double a = 0.10;
  2889 + double b = 0.0;
  2890 + BigDecimal a1 = new BigDecimal(a);
  2891 + BigDecimal b1 = new BigDecimal(b);
  2892 + System.out.println(a1.compareTo(b1));
  2893 + }
  2894 +
2756 public List<Map<String, Object>> createMap(String type, String[] dates){ 2895 public List<Map<String, Object>> createMap(String type, String[] dates){
2757 List<Map<String, Object>> mapList = new ArrayList<Map<String, Object>>(); 2896 List<Map<String, Object>> mapList = new ArrayList<Map<String, Object>>();
2758 2897
@@ -2810,7 +2949,6 @@ public class BigscreenService { @@ -2810,7 +2949,6 @@ public class BigscreenService {
2810 }else{ 2949 }else{
2811 sjgl=Arith.add(sjgl,jhlc); 2950 sjgl=Arith.add(sjgl,jhlc);
2812 } 2951 }
2813 -  
2814 } 2952 }
2815 }else{ 2953 }else{
2816 Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); 2954 Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
@@ -2826,7 +2964,7 @@ public class BigscreenService { @@ -2826,7 +2964,7 @@ public class BigscreenService {
2826 } 2964 }
2827 } 2965 }
2828 } 2966 }
2829 - } 2967 + }
2830 } 2968 }
2831 } 2969 }
2832 return sjgl; 2970 return sjgl;