Commit 4e714e4182fc1492d09cb7db7befcb727f8baa02
1 parent
932f1bde
update...
Showing
6 changed files
with
270 additions
and
2 deletions
src/main/java/com/bsth/CXFConfig.java
| @@ -14,6 +14,7 @@ import com.bsth.server_rs.gps.GpsRestService; | @@ -14,6 +14,7 @@ import com.bsth.server_rs.gps.GpsRestService; | ||
| 14 | import com.bsth.server_rs.logs.RealLogRestService; | 14 | import com.bsth.server_rs.logs.RealLogRestService; |
| 15 | import com.bsth.server_rs.schedule.plan.SchedulePlanService; | 15 | import com.bsth.server_rs.schedule.plan.SchedulePlanService; |
| 16 | import com.bsth.server_rs.schedule.real.ScheduleRealService; | 16 | import com.bsth.server_rs.schedule.real.ScheduleRealService; |
| 17 | +import com.bsth.server_rs.schedule.real.StaffViewRealService; | ||
| 17 | import com.bsth.server_ws.attendance.AttendanceServiceSoap; | 18 | import com.bsth.server_ws.attendance.AttendanceServiceSoap; |
| 18 | import com.bsth.server_ws.electric_oil.OilServiceSoap; | 19 | import com.bsth.server_ws.electric_oil.OilServiceSoap; |
| 19 | import com.bsth.server_ws.park_station.CompanyServiceSoap; | 20 | import com.bsth.server_ws.park_station.CompanyServiceSoap; |
| @@ -104,6 +105,8 @@ public class CXFConfig { | @@ -104,6 +105,8 @@ public class CXFConfig { | ||
| 104 | LD_RoadSpeedRestService ld_roadSpeedRestService; | 105 | LD_RoadSpeedRestService ld_roadSpeedRestService; |
| 105 | @Autowired | 106 | @Autowired |
| 106 | ElectricService electricService; | 107 | ElectricService electricService; |
| 108 | + @Autowired | ||
| 109 | + StaffViewRealService staffViewRealService; | ||
| 107 | 110 | ||
| 108 | @Bean | 111 | @Bean |
| 109 | public Server rsServer() { | 112 | public Server rsServer() { |
| @@ -122,7 +125,8 @@ public class CXFConfig { | @@ -122,7 +125,8 @@ public class CXFConfig { | ||
| 122 | realLogRestService, | 125 | realLogRestService, |
| 123 | directiveRestService, | 126 | directiveRestService, |
| 124 | ld_roadSpeedRestService, | 127 | ld_roadSpeedRestService, |
| 125 | - electricService)); | 128 | + electricService, |
| 129 | + staffViewRealService)); | ||
| 126 | endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(), new AesExceptionMapper())); | 130 | endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(), new AesExceptionMapper())); |
| 127 | //endpoint.setFeatures(Arrays.asList(new Swagger2Feature())); | 131 | //endpoint.setFeatures(Arrays.asList(new Swagger2Feature())); |
| 128 | endpoint.getInInterceptors().add(new AuthorizeInterceptor_IN()); | 132 | endpoint.getInInterceptors().add(new AuthorizeInterceptor_IN()); |
src/main/java/com/bsth/server_rs/base_info/station/buffer/StationRefreshThread.java
| @@ -35,7 +35,7 @@ public class StationRefreshThread extends Thread{ | @@ -35,7 +35,7 @@ public class StationRefreshThread extends Thread{ | ||
| 35 | StationBufferData.replaceAll(stationList); | 35 | StationBufferData.replaceAll(stationList); |
| 36 | 36 | ||
| 37 | //站点路由信息 | 37 | //站点路由信息 |
| 38 | - List<StationRotue> routeList = jdbcTemplate.query("select id, line, station_route_code, line_code,station_code,station_mark,distances, to_time,directions from bsth_c_stationroute where destroy=0", | 38 | + List<StationRotue> routeList = jdbcTemplate.query("select id, line, station_route_code, line_code,station_code,station_mark,distances, to_time,directions,station_name from bsth_c_stationroute where destroy=0", |
| 39 | BeanPropertyRowMapper.newInstance(StationRotue.class)); | 39 | BeanPropertyRowMapper.newInstance(StationRotue.class)); |
| 40 | 40 | ||
| 41 | for(StationRotue sr : routeList){ | 41 | for(StationRotue sr : routeList){ |
src/main/java/com/bsth/server_rs/base_info/station/entity/StationRotue.java
| @@ -13,6 +13,8 @@ public class StationRotue { | @@ -13,6 +13,8 @@ public class StationRotue { | ||
| 13 | 13 | ||
| 14 | private String stationCode; | 14 | private String stationCode; |
| 15 | 15 | ||
| 16 | + private String stationName; | ||
| 17 | + | ||
| 16 | private Station station; | 18 | private Station station; |
| 17 | 19 | ||
| 18 | /** | 20 | /** |
| @@ -129,4 +131,12 @@ public class StationRotue { | @@ -129,4 +131,12 @@ public class StationRotue { | ||
| 129 | public void setStationCode(String stationCode) { | 131 | public void setStationCode(String stationCode) { |
| 130 | this.stationCode = stationCode; | 132 | this.stationCode = stationCode; |
| 131 | } | 133 | } |
| 134 | + | ||
| 135 | + public String getStationName() { | ||
| 136 | + return stationName; | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + public void setStationName(String stationName) { | ||
| 140 | + this.stationName = stationName; | ||
| 141 | + } | ||
| 132 | } | 142 | } |
src/main/java/com/bsth/server_rs/schedule/plan/SchedulePlanService.java
| @@ -22,6 +22,7 @@ import java.text.DateFormat; | @@ -22,6 +22,7 @@ import java.text.DateFormat; | ||
| 22 | import java.text.SimpleDateFormat; | 22 | import java.text.SimpleDateFormat; |
| 23 | import java.util.ArrayList; | 23 | import java.util.ArrayList; |
| 24 | import java.util.List; | 24 | import java.util.List; |
| 25 | +import java.util.Map; | ||
| 25 | 26 | ||
| 26 | /** | 27 | /** |
| 27 | * Created by panzhao on 2017/8/24. | 28 | * Created by panzhao on 2017/8/24. |
| @@ -65,4 +66,11 @@ public class SchedulePlanService { | @@ -65,4 +66,11 @@ public class SchedulePlanService { | ||
| 65 | List<AttendancePlanDay> list = jdbcTemplate.query("SELECT j_gh,j_name,s_gh,s_name,DATE_FORMAT(schedule_date,'%Y-%m-%d') as schedule_date FROM bsth_c_s_sp_info WHERE gs_bm='"+company+"' and schedule_date LIKE '"+month+"-%' GROUP BY j_gh,j_name,s_gh,s_name,DATE_FORMAT(schedule_date,'%Y-%m-%d')", BeanPropertyRowMapper.newInstance(AttendancePlanDay.class)); | 66 | List<AttendancePlanDay> list = jdbcTemplate.query("SELECT j_gh,j_name,s_gh,s_name,DATE_FORMAT(schedule_date,'%Y-%m-%d') as schedule_date FROM bsth_c_s_sp_info WHERE gs_bm='"+company+"' and schedule_date LIKE '"+month+"-%' GROUP BY j_gh,j_name,s_gh,s_name,DATE_FORMAT(schedule_date,'%Y-%m-%d')", BeanPropertyRowMapper.newInstance(AttendancePlanDay.class)); |
| 66 | return AttendancePlanMonth.getMultiInstance(month, list); | 67 | return AttendancePlanMonth.getMultiInstance(month, list); |
| 67 | } | 68 | } |
| 69 | + | ||
| 70 | + @GET | ||
| 71 | + @Path("/plan_inout/{rq}/{lineCode}") | ||
| 72 | + public List<Map<String, Object>> findInOutPlan(@PathParam("rq") String rq,@PathParam("lineCode") String lineCode){ | ||
| 73 | + List<Map<String, Object>> rs = jdbcTemplate.queryForList("select schedule_date,xl_bm,xl_name,lp_name,cl_zbh,fcsj,j_gh,j_name,s_gh,s_name,bc_type,(select user_name from bsth_c_sys_user where id=create_by) as c_user,(select user_name from bsth_c_sys_user where id=update_by) as u_user,create_date,update_date,fcno from bsth_c_s_sp_info where schedule_date=? and xl_bm=? and bc_type in ('in', 'out')",rq,lineCode); | ||
| 74 | + return rs; | ||
| 75 | + } | ||
| 68 | } | 76 | } |
src/main/java/com/bsth/server_rs/schedule/real/StaffViewRealService.java
0 → 100644
| 1 | +package com.bsth.server_rs.schedule.real; | ||
| 2 | + | ||
| 3 | +import com.bsth.common.BasicData; | ||
| 4 | +import com.bsth.entity.OilInfo; | ||
| 5 | +import com.bsth.entity.SchedulePlanInfo; | ||
| 6 | +import com.bsth.entity.ScheduleRealInfo; | ||
| 7 | +import com.bsth.redis.ScheduleRedisService; | ||
| 8 | +import com.bsth.repository.ScheduleRealInfoRepository; | ||
| 9 | +import com.bsth.server_rs.schedule.dto.ScheduleInOut; | ||
| 10 | +import com.bsth.server_ws.park_station.dto.LsLcPb; | ||
| 11 | +import com.bsth.server_ws.util.ControlHttpUtils; | ||
| 12 | +import com.bsth.server_ws.util.WSDataConver; | ||
| 13 | +import com.bsth.util.ConvertUtil; | ||
| 14 | +import com.google.common.collect.ArrayListMultimap; | ||
| 15 | +import org.joda.time.format.DateTimeFormat; | ||
| 16 | +import org.joda.time.format.DateTimeFormatter; | ||
| 17 | +import org.slf4j.Logger; | ||
| 18 | +import org.slf4j.LoggerFactory; | ||
| 19 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 20 | +import org.springframework.jdbc.core.BeanPropertyRowMapper; | ||
| 21 | +import org.springframework.jdbc.core.JdbcTemplate; | ||
| 22 | +import org.springframework.stereotype.Component; | ||
| 23 | + | ||
| 24 | +import javax.ws.rs.GET; | ||
| 25 | +import javax.ws.rs.Path; | ||
| 26 | +import javax.ws.rs.PathParam; | ||
| 27 | +import javax.ws.rs.Produces; | ||
| 28 | +import javax.ws.rs.core.MediaType; | ||
| 29 | +import java.util.*; | ||
| 30 | + | ||
| 31 | +/** | ||
| 32 | + * 场站查询机,相关 rest 接口 | ||
| 33 | + */ | ||
| 34 | +@Component | ||
| 35 | +@Path("/staff_view") | ||
| 36 | +@Produces({MediaType.APPLICATION_JSON}) | ||
| 37 | +public class StaffViewRealService { | ||
| 38 | + | ||
| 39 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 40 | + | ||
| 41 | + @Autowired | ||
| 42 | + JdbcTemplate jdbcTemplate; | ||
| 43 | + | ||
| 44 | + @Autowired | ||
| 45 | + ScheduleRealInfoRepository scheduleRealInfoRepository; | ||
| 46 | + | ||
| 47 | + @Autowired | ||
| 48 | + ScheduleRedisService redisService; | ||
| 49 | + | ||
| 50 | + private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd"); | ||
| 51 | + | ||
| 52 | + /** | ||
| 53 | + * 根据工号查询当日进出场排班(打印出门证用 -直接连调度系统,快速响应实时数据) | ||
| 54 | + * | ||
| 55 | + * @param workId | ||
| 56 | + * @return | ||
| 57 | + */ | ||
| 58 | + @GET | ||
| 59 | + @Path("currentDayPlan_out/{workId}") | ||
| 60 | + public List<ScheduleInOut> currentDayPlan(@PathParam("workId") String workId) { | ||
| 61 | + | ||
| 62 | + try { | ||
| 63 | + String[] arr = workId.split("-"); | ||
| 64 | + | ||
| 65 | + List<ScheduleRealInfo> list = ControlHttpUtils.getCurrentDayPlan(arr[0], arr[1]); | ||
| 66 | + | ||
| 67 | + //签到接口 -只给出场班次 | ||
| 68 | + List<ScheduleInOut> list2 = new ArrayList<>(); | ||
| 69 | + | ||
| 70 | + for (ScheduleRealInfo sch : list) { | ||
| 71 | + if (sch.getStatus() != -1 && sch.getBcType().equals("out")) | ||
| 72 | + list2.add(new ScheduleInOut(sch)); | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + | ||
| 76 | + return list2; | ||
| 77 | + } catch (Exception e) { | ||
| 78 | + logger.error("", e); | ||
| 79 | + } | ||
| 80 | + return null; | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + /** | ||
| 84 | + * 查询今日排班 | ||
| 85 | + * | ||
| 86 | + * @param workId | ||
| 87 | + * @return | ||
| 88 | + */ | ||
| 89 | + @GET | ||
| 90 | + @Path("querySchedule/{workId}") | ||
| 91 | + public List<ScheduleRealInfo> querySchedule(@PathParam("workId") String workId) { | ||
| 92 | + try { | ||
| 93 | + String date = fmtyyyyMMdd.print(new Date().getTime() - (1000 * 60 * 60 * 24)); | ||
| 94 | + List<ScheduleRealInfo> list = jdbcTemplate.query("select * from bsth_c_s_sp_info_real where j_gh='" + workId + "' and schedule_date_str>='" + date + "'", BeanPropertyRowMapper.newInstance(ScheduleRealInfo.class)); | ||
| 95 | + | ||
| 96 | + if (null == list || list.size() == 0) | ||
| 97 | + return null; | ||
| 98 | + | ||
| 99 | + //计算真实执行日期 和 时间戳 | ||
| 100 | + String st = BasicData.lineStartTimeMap.get(list.get(0).getXlBm()); | ||
| 101 | + for (ScheduleRealInfo sch : list) { | ||
| 102 | + redisService.calcRealDate(st, sch); | ||
| 103 | + } | ||
| 104 | + //按日期分组,取日期大的list 就是当日排班 | ||
| 105 | + ArrayListMultimap<String, ScheduleRealInfo> multimap = | ||
| 106 | + new ConvertUtil<ScheduleRealInfo>().groupMultiList(list, "_", ScheduleRealInfo.class.getDeclaredField("scheduleDateStr")); | ||
| 107 | + | ||
| 108 | + Set<String> ks = multimap.keySet(); | ||
| 109 | + | ||
| 110 | + String fd = null; | ||
| 111 | + for (String k : ks) { | ||
| 112 | + | ||
| 113 | + if (null == fd || k.compareTo(fd) > 0) | ||
| 114 | + fd = k; | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + | ||
| 118 | + return multimap.get(fd); | ||
| 119 | + } catch (Exception e) { | ||
| 120 | + logger.error("", e); | ||
| 121 | + } | ||
| 122 | + return null; | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + /** | ||
| 126 | + * 综合查询 | ||
| 127 | + * | ||
| 128 | + * @param company | ||
| 129 | + * @param workId | ||
| 130 | + * @param month | ||
| 131 | + * @return | ||
| 132 | + */ | ||
| 133 | + @GET | ||
| 134 | + @Path("queryLSLC_PB/{company}/{workId}/{month}") | ||
| 135 | + public List<LsLcPb> queryLSLC_PB(@PathParam("company") String company, @PathParam("workId") String workId, @PathParam("month") String month) { | ||
| 136 | + List<LsLcPb> rs = new ArrayList<>(); | ||
| 137 | + | ||
| 138 | + try { | ||
| 139 | + //实际排班 | ||
| 140 | + List<ScheduleRealInfo> schList = | ||
| 141 | + jdbcTemplate.query("select * from bsth_c_s_sp_info_real where gs_bm='" + company + "' and j_gh='" + workId + "' and schedule_date_str like '" + month + "-%'", | ||
| 142 | + BeanPropertyRowMapper.newInstance(ScheduleRealInfo.class)); | ||
| 143 | + | ||
| 144 | + //计划排班 | ||
| 145 | + List<SchedulePlanInfo> planList = | ||
| 146 | + jdbcTemplate.query("select * from bsth_c_s_sp_info where gs_bm='" + company + "' and j_gh='" + workId + "' and schedule_date>sysdate() and schedule_date like '" + month + "-%' order by bcs", | ||
| 147 | + BeanPropertyRowMapper.newInstance(SchedulePlanInfo.class)); | ||
| 148 | + | ||
| 149 | + //油耗 | ||
| 150 | + List<OilInfo> oilList = | ||
| 151 | + jdbcTemplate.query("select * from bsth_c_ylb where jsy='" + workId + "' and rq like '" + month + "-%'", | ||
| 152 | + BeanPropertyRowMapper.newInstance(OilInfo.class)); | ||
| 153 | + | ||
| 154 | + rs = WSDataConver.to_getLSLC_PB_list(month, schList, oilList, planList); | ||
| 155 | + } catch (Exception e) { | ||
| 156 | + logger.error("", e); | ||
| 157 | + } | ||
| 158 | + return rs; | ||
| 159 | + } | ||
| 160 | +} |
src/main/java/com/bsth/server_ws/util/WSDataConver.java
| @@ -728,6 +728,92 @@ public class WSDataConver { | @@ -728,6 +728,92 @@ public class WSDataConver { | ||
| 728 | } | 728 | } |
| 729 | 729 | ||
| 730 | /** | 730 | /** |
| 731 | + * 将排班和油耗转换成综合查询需要的数据 | ||
| 732 | + * @param schList | ||
| 733 | + * @param oilList | ||
| 734 | + * @return | ||
| 735 | + */ | ||
| 736 | + public static List<LsLcPb> to_getLSLC_PB_list(String fdate, List<ScheduleRealInfo> schList, List<OilInfo> oilList, List<SchedulePlanInfo> planList) { | ||
| 737 | + List<LsLcPb> rs = new ArrayList<>(); | ||
| 738 | + try { | ||
| 739 | + //按日期分组数据 | ||
| 740 | + ArrayListMultimap<String, ScheduleRealInfo> schMultimap = | ||
| 741 | + new ConvertUtil().groupMultiList(schList, "_", ScheduleRealInfo.class.getDeclaredField("scheduleDateStr")); | ||
| 742 | + | ||
| 743 | + ArrayListMultimap<String, OilInfo> oilMultimap = | ||
| 744 | + new ConvertUtil().groupMultiList(oilList, "_", OilInfo.class.getDeclaredField("rq")); | ||
| 745 | + | ||
| 746 | + ArrayListMultimap<String, SchedulePlanInfo> planMultimap = | ||
| 747 | + new ConvertUtil().groupMultiList(planList, "_", SchedulePlanInfo.class.getDeclaredField("scheduleDate")); | ||
| 748 | + | ||
| 749 | + | ||
| 750 | + //月份有多少天 | ||
| 751 | + int year = Integer.parseInt(fdate.substring(0, 4)); | ||
| 752 | + int month = Integer.parseInt(fdate.substring(5, 7)); | ||
| 753 | + Calendar cal = Calendar.getInstance(); | ||
| 754 | + cal.set(Calendar.YEAR,year); | ||
| 755 | + cal.set(Calendar.MONTH,month - 1);//从0开始 | ||
| 756 | + int maxDate = cal.getActualMaximum(Calendar.DATE); | ||
| 757 | + | ||
| 758 | + LsLcPb lcPb; | ||
| 759 | + List<ScheduleRealInfo> pbList; | ||
| 760 | + List<SchedulePlanInfo> jhList; | ||
| 761 | + List<OilInfo> yhList; | ||
| 762 | + String rq,rq2; | ||
| 763 | + SchedulePlanInfo outPlan; | ||
| 764 | + int currentDay = cal.get(Calendar.DAY_OF_MONTH); | ||
| 765 | + for(int i = 1; i <= maxDate; i++){ | ||
| 766 | + lcPb = new LsLcPb(); | ||
| 767 | + lcPb.setDay(i); | ||
| 768 | + | ||
| 769 | + rq = fdate + "-" + (i < 10?"0":"") + i; | ||
| 770 | + rq2 = rq.replaceAll("-", ""); | ||
| 771 | + | ||
| 772 | + pbList = schMultimap.get(rq); | ||
| 773 | + yhList = oilMultimap.get(rq2); | ||
| 774 | + jhList = planMultimap.get(rq2); | ||
| 775 | + | ||
| 776 | + if(i < currentDay){ | ||
| 777 | + if(pbList == null || pbList.size() == 0) | ||
| 778 | + lcPb.setType(4);//休息 | ||
| 779 | + else{ | ||
| 780 | + lcPb.setType(1); | ||
| 781 | + lcPb.setLckq(""); | ||
| 782 | + if(yhList != null && yhList.size() > 0){ | ||
| 783 | + lcPb.setLcyh(yhList.get(0).getYh()); | ||
| 784 | + } | ||
| 785 | + lcPb.setLcyylc(ScheduleCalculator.calcYYLC(pbList)); | ||
| 786 | + lcPb.setLcfyylc(ScheduleCalculator.calcKSLC(pbList)); | ||
| 787 | + } | ||
| 788 | + } | ||
| 789 | + else if (i == currentDay) | ||
| 790 | + lcPb.setType(3);//今天 | ||
| 791 | + else { | ||
| 792 | + if(jhList == null || jhList.size() == 0) | ||
| 793 | + lcPb.setType(4);//休息 | ||
| 794 | + else{ | ||
| 795 | + lcPb.setType(2); | ||
| 796 | + outPlan = getOutSch(jhList); | ||
| 797 | + if(null != outPlan){ | ||
| 798 | + lcPb.setPbxl(outPlan.getXlName()); | ||
| 799 | + lcPb.setPblp(outPlan.getLpName()); | ||
| 800 | + lcPb.setPbbd(minusMinute(outPlan.getFcsj(), 15)); | ||
| 801 | + lcPb.setPbyc(outPlan.getClZbh()); | ||
| 802 | + } | ||
| 803 | + else | ||
| 804 | + lcPb.setType(4);//休息 | ||
| 805 | + } | ||
| 806 | + } | ||
| 807 | + | ||
| 808 | + rs.add(lcPb); | ||
| 809 | + } | ||
| 810 | + } catch (NoSuchFieldException e) { | ||
| 811 | + logger.error("", e); | ||
| 812 | + } | ||
| 813 | + return rs; | ||
| 814 | + } | ||
| 815 | + | ||
| 816 | + /** | ||
| 731 | * HH:mm 格式时间减分钟 | 817 | * HH:mm 格式时间减分钟 |
| 732 | * @param dfsj | 818 | * @param dfsj |
| 733 | * @param i | 819 | * @param i |