Commit 201b32799ecf06ff92f8498b71d4d8ab9d43a205
1 parent
e2a404b6
1.
Showing
2 changed files
with
869 additions
and
811 deletions
src/main/java/com/bsth/server_rs/dks/BusMileage.java
| 1 | -package com.bsth.server_rs.dks; | |
| 2 | - | |
| 3 | -public class BusMileage { | |
| 4 | - | |
| 5 | - /** | |
| 6 | - * | |
| 7 | - */ | |
| 8 | - private String scheduleDate; | |
| 9 | - | |
| 10 | - /** | |
| 11 | - * 内部编码 | |
| 12 | - */ | |
| 13 | - private String nbbm; | |
| 14 | - | |
| 15 | - /** | |
| 16 | - * 计划里程 | |
| 17 | - */ | |
| 18 | - private Double jhlc; | |
| 19 | - | |
| 20 | - /** | |
| 21 | - * 实际计划里程 | |
| 22 | - */ | |
| 23 | - private Double sjjhlc; | |
| 24 | - | |
| 25 | - /** | |
| 26 | - * 实际出场里程 | |
| 27 | - */ | |
| 28 | - private Double sjcclc; | |
| 29 | - | |
| 30 | - /** | |
| 31 | - * 实际进场里程 | |
| 32 | - */ | |
| 33 | - private Double sjjclc; | |
| 34 | - | |
| 35 | - /** | |
| 36 | - * 营运里程 | |
| 37 | - */ | |
| 38 | - private Double yylc; | |
| 39 | - | |
| 40 | - /** | |
| 41 | - * 空驶里程 | |
| 42 | - */ | |
| 43 | - private Double kslc; | |
| 44 | - | |
| 45 | - /** | |
| 46 | - * 抽减里程 | |
| 47 | - */ | |
| 48 | - private Double cjlc; | |
| 49 | - | |
| 50 | - /** | |
| 51 | - * 烂班里程 | |
| 52 | - */ | |
| 53 | - private Double lblc; | |
| 54 | - | |
| 55 | - /** | |
| 56 | - * 增加里程 | |
| 57 | - */ | |
| 58 | - private Double zjlc; | |
| 59 | - | |
| 60 | - /** | |
| 61 | - * 总里程 | |
| 62 | - */ | |
| 63 | - private Double zlc; | |
| 64 | - | |
| 65 | - /** | |
| 66 | - * 油耗 | |
| 67 | - */ | |
| 68 | - private Double yh; | |
| 69 | - | |
| 70 | - /** | |
| 71 | - * 电耗 | |
| 72 | - */ | |
| 73 | - private Double dh; | |
| 74 | - | |
| 75 | - public String getScheduleDate() { | |
| 76 | - return scheduleDate; | |
| 77 | - } | |
| 78 | - | |
| 79 | - public void setScheduleDate(String scheduleDate) { | |
| 80 | - this.scheduleDate = scheduleDate; | |
| 81 | - } | |
| 82 | - | |
| 83 | - public String getNbbm() { | |
| 84 | - return nbbm; | |
| 85 | - } | |
| 86 | - | |
| 87 | - public void setNbbm(String nbbm) { | |
| 88 | - this.nbbm = nbbm; | |
| 89 | - } | |
| 90 | - | |
| 91 | - public Double getJhlc() { | |
| 92 | - return jhlc; | |
| 93 | - } | |
| 94 | - | |
| 95 | - public void setJhlc(Double jhlc) { | |
| 96 | - this.jhlc = jhlc; | |
| 97 | - } | |
| 98 | - | |
| 99 | - public Double getSjjhlc() { | |
| 100 | - return sjjhlc; | |
| 101 | - } | |
| 102 | - | |
| 103 | - public void setSjjhlc(Double sjjhlc) { | |
| 104 | - this.sjjhlc = sjjhlc; | |
| 105 | - } | |
| 106 | - | |
| 107 | - public Double getSjcclc() { | |
| 108 | - return sjcclc; | |
| 109 | - } | |
| 110 | - | |
| 111 | - public void setSjcclc(Double sjcclc) { | |
| 112 | - this.sjcclc = sjcclc; | |
| 113 | - } | |
| 114 | - | |
| 115 | - public Double getSjjclc() { | |
| 116 | - return sjjclc; | |
| 117 | - } | |
| 118 | - | |
| 119 | - public void setSjjclc(Double sjjclc) { | |
| 120 | - this.sjjclc = sjjclc; | |
| 121 | - } | |
| 122 | - | |
| 123 | - public Double getYylc() { | |
| 124 | - return yylc; | |
| 125 | - } | |
| 126 | - | |
| 127 | - public void setYylc(Double yylc) { | |
| 128 | - this.yylc = yylc; | |
| 129 | - } | |
| 130 | - | |
| 131 | - public Double getKslc() { | |
| 132 | - return kslc; | |
| 133 | - } | |
| 134 | - | |
| 135 | - public void setKslc(Double kslc) { | |
| 136 | - this.kslc = kslc; | |
| 137 | - } | |
| 138 | - | |
| 139 | - public Double getCjlc() { | |
| 140 | - return cjlc; | |
| 141 | - } | |
| 142 | - | |
| 143 | - public void setCjlc(Double cjlc) { | |
| 144 | - this.cjlc = cjlc; | |
| 145 | - } | |
| 146 | - | |
| 147 | - public Double getLblc() { | |
| 148 | - return lblc; | |
| 149 | - } | |
| 150 | - | |
| 151 | - public void setLblc(Double lblc) { | |
| 152 | - this.lblc = lblc; | |
| 153 | - } | |
| 154 | - | |
| 155 | - public Double getZjlc() { | |
| 156 | - return zjlc; | |
| 157 | - } | |
| 158 | - | |
| 159 | - public void setZjlc(Double zjlc) { | |
| 160 | - this.zjlc = zjlc; | |
| 161 | - } | |
| 162 | - | |
| 163 | - public Double getZlc() { | |
| 164 | - return zlc; | |
| 165 | - } | |
| 166 | - | |
| 167 | - public void setZlc(Double zlc) { | |
| 168 | - this.zlc = zlc; | |
| 169 | - } | |
| 170 | - | |
| 171 | - public Double getYh() { | |
| 172 | - return yh; | |
| 173 | - } | |
| 174 | - | |
| 175 | - public void setYh(Double yh) { | |
| 176 | - this.yh = yh; | |
| 177 | - } | |
| 178 | - | |
| 179 | - public Double getDh() { | |
| 180 | - return dh; | |
| 181 | - } | |
| 182 | - | |
| 183 | - public void setDh(Double dh) { | |
| 184 | - this.dh = dh; | |
| 185 | - } | |
| 186 | -} | |
| 1 | +package com.bsth.server_rs.dks; | |
| 2 | + | |
| 3 | +public class BusMileage { | |
| 4 | + | |
| 5 | + /** | |
| 6 | + * | |
| 7 | + */ | |
| 8 | + private String scheduleDate; | |
| 9 | + | |
| 10 | + /** | |
| 11 | + * 内部编码 | |
| 12 | + */ | |
| 13 | + private String nbbm; | |
| 14 | + | |
| 15 | + /** | |
| 16 | + * 计划里程 | |
| 17 | + */ | |
| 18 | + private Double jhlc; | |
| 19 | + | |
| 20 | + /** | |
| 21 | + * 实际计划里程 | |
| 22 | + */ | |
| 23 | + private Double sjjhlc; | |
| 24 | + | |
| 25 | + /** | |
| 26 | + * 实际出场里程 | |
| 27 | + */ | |
| 28 | + private Double sjcclc; | |
| 29 | + | |
| 30 | + /** | |
| 31 | + * 实际进场里程 | |
| 32 | + */ | |
| 33 | + private Double sjjclc; | |
| 34 | + | |
| 35 | + /** | |
| 36 | + * 营运里程 | |
| 37 | + */ | |
| 38 | + private Double yylc; | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * 空驶里程 | |
| 42 | + */ | |
| 43 | + private Double kslc; | |
| 44 | + | |
| 45 | + /** | |
| 46 | + * 抽减里程 | |
| 47 | + */ | |
| 48 | + private Double cjlc; | |
| 49 | + | |
| 50 | + /** | |
| 51 | + * 烂班里程 | |
| 52 | + */ | |
| 53 | + private Double lblc; | |
| 54 | + | |
| 55 | + /** | |
| 56 | + * 增加里程 | |
| 57 | + */ | |
| 58 | + private Double zjlc; | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * 总里程 | |
| 62 | + */ | |
| 63 | + private Double zlc; | |
| 64 | + | |
| 65 | + /** | |
| 66 | + * 油耗 | |
| 67 | + */ | |
| 68 | + private Double yh; | |
| 69 | + | |
| 70 | + /** | |
| 71 | + * 电耗 | |
| 72 | + */ | |
| 73 | + private Double dh; | |
| 74 | + | |
| 75 | + /** | |
| 76 | + * | |
| 77 | + */ | |
| 78 | + private String company; | |
| 79 | + | |
| 80 | + /** | |
| 81 | + * | |
| 82 | + */ | |
| 83 | + private String companyCode; | |
| 84 | + | |
| 85 | + public String getScheduleDate() { | |
| 86 | + return scheduleDate; | |
| 87 | + } | |
| 88 | + | |
| 89 | + public void setScheduleDate(String scheduleDate) { | |
| 90 | + this.scheduleDate = scheduleDate; | |
| 91 | + } | |
| 92 | + | |
| 93 | + public String getNbbm() { | |
| 94 | + return nbbm; | |
| 95 | + } | |
| 96 | + | |
| 97 | + public void setNbbm(String nbbm) { | |
| 98 | + this.nbbm = nbbm; | |
| 99 | + } | |
| 100 | + | |
| 101 | + public Double getJhlc() { | |
| 102 | + return jhlc; | |
| 103 | + } | |
| 104 | + | |
| 105 | + public void setJhlc(Double jhlc) { | |
| 106 | + this.jhlc = jhlc; | |
| 107 | + } | |
| 108 | + | |
| 109 | + public Double getSjjhlc() { | |
| 110 | + return sjjhlc; | |
| 111 | + } | |
| 112 | + | |
| 113 | + public void setSjjhlc(Double sjjhlc) { | |
| 114 | + this.sjjhlc = sjjhlc; | |
| 115 | + } | |
| 116 | + | |
| 117 | + public Double getSjcclc() { | |
| 118 | + return sjcclc; | |
| 119 | + } | |
| 120 | + | |
| 121 | + public void setSjcclc(Double sjcclc) { | |
| 122 | + this.sjcclc = sjcclc; | |
| 123 | + } | |
| 124 | + | |
| 125 | + public Double getSjjclc() { | |
| 126 | + return sjjclc; | |
| 127 | + } | |
| 128 | + | |
| 129 | + public void setSjjclc(Double sjjclc) { | |
| 130 | + this.sjjclc = sjjclc; | |
| 131 | + } | |
| 132 | + | |
| 133 | + public Double getYylc() { | |
| 134 | + return yylc; | |
| 135 | + } | |
| 136 | + | |
| 137 | + public void setYylc(Double yylc) { | |
| 138 | + this.yylc = yylc; | |
| 139 | + } | |
| 140 | + | |
| 141 | + public Double getKslc() { | |
| 142 | + return kslc; | |
| 143 | + } | |
| 144 | + | |
| 145 | + public void setKslc(Double kslc) { | |
| 146 | + this.kslc = kslc; | |
| 147 | + } | |
| 148 | + | |
| 149 | + public Double getCjlc() { | |
| 150 | + return cjlc; | |
| 151 | + } | |
| 152 | + | |
| 153 | + public void setCjlc(Double cjlc) { | |
| 154 | + this.cjlc = cjlc; | |
| 155 | + } | |
| 156 | + | |
| 157 | + public Double getLblc() { | |
| 158 | + return lblc; | |
| 159 | + } | |
| 160 | + | |
| 161 | + public void setLblc(Double lblc) { | |
| 162 | + this.lblc = lblc; | |
| 163 | + } | |
| 164 | + | |
| 165 | + public Double getZjlc() { | |
| 166 | + return zjlc; | |
| 167 | + } | |
| 168 | + | |
| 169 | + public void setZjlc(Double zjlc) { | |
| 170 | + this.zjlc = zjlc; | |
| 171 | + } | |
| 172 | + | |
| 173 | + public Double getZlc() { | |
| 174 | + return zlc; | |
| 175 | + } | |
| 176 | + | |
| 177 | + public void setZlc(Double zlc) { | |
| 178 | + this.zlc = zlc; | |
| 179 | + } | |
| 180 | + | |
| 181 | + public Double getYh() { | |
| 182 | + return yh; | |
| 183 | + } | |
| 184 | + | |
| 185 | + public void setYh(Double yh) { | |
| 186 | + this.yh = yh; | |
| 187 | + } | |
| 188 | + | |
| 189 | + public Double getDh() { | |
| 190 | + return dh; | |
| 191 | + } | |
| 192 | + | |
| 193 | + public void setDh(Double dh) { | |
| 194 | + this.dh = dh; | |
| 195 | + } | |
| 196 | + | |
| 197 | + public String getCompany() { | |
| 198 | + return company; | |
| 199 | + } | |
| 200 | + | |
| 201 | + public void setCompany(String company) { | |
| 202 | + this.company = company; | |
| 203 | + } | |
| 204 | + | |
| 205 | + public String getCompanyCode() { | |
| 206 | + return companyCode; | |
| 207 | + } | |
| 208 | + | |
| 209 | + public void setCompanyCode(String companyCode) { | |
| 210 | + this.companyCode = companyCode; | |
| 211 | + } | |
| 212 | +} | ... | ... |
src/main/java/com/bsth/server_rs/dks/DksRestService.java
| 1 | -package com.bsth.server_rs.dks; | |
| 2 | - | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 4 | -import com.bsth.entity.ElecInfo; | |
| 5 | -import com.bsth.entity.OilInfo; | |
| 6 | -import com.bsth.entity.SchedulePlanInfo; | |
| 7 | -import com.bsth.entity.ScheduleRealInfo; | |
| 8 | -import com.bsth.redis.ElecRedisService; | |
| 9 | -import com.bsth.redis.OilRedisService; | |
| 10 | -import com.bsth.redis.ScheduleRedisService; | |
| 11 | -import com.bsth.repository.SchedulePlanInfoRepository; | |
| 12 | -import com.bsth.repository.ScheduleRealInfoRepository; | |
| 13 | -import com.bsth.server_rs.base_info.line.Line; | |
| 14 | -import com.bsth.server_rs.base_info.line.buffer.LineBufferData; | |
| 15 | -import com.bsth.server_ws.util.ScheduleCalculator; | |
| 16 | -import com.bsth.util.Arith; | |
| 17 | -import com.google.common.collect.ArrayListMultimap; | |
| 18 | -import org.joda.time.DateTime; | |
| 19 | -import org.joda.time.format.DateTimeFormat; | |
| 20 | -import org.slf4j.Logger; | |
| 21 | -import org.slf4j.LoggerFactory; | |
| 22 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 23 | -import org.springframework.jdbc.core.BatchPreparedStatementSetter; | |
| 24 | -import org.springframework.jdbc.core.BeanPropertyRowMapper; | |
| 25 | -import org.springframework.jdbc.core.JdbcTemplate; | |
| 26 | -import org.springframework.jdbc.datasource.DataSourceTransactionManager; | |
| 27 | -import org.springframework.scheduling.annotation.EnableScheduling; | |
| 28 | -import org.springframework.scheduling.annotation.Scheduled; | |
| 29 | -import org.springframework.stereotype.Component; | |
| 30 | -import org.springframework.transaction.TransactionDefinition; | |
| 31 | -import org.springframework.transaction.TransactionStatus; | |
| 32 | -import org.springframework.transaction.support.DefaultTransactionDefinition; | |
| 33 | -import org.springframework.util.StringUtils; | |
| 34 | - | |
| 35 | -import javax.ws.rs.*; | |
| 36 | -import javax.ws.rs.core.MediaType; | |
| 37 | -import java.sql.PreparedStatement; | |
| 38 | -import java.sql.SQLException; | |
| 39 | -import java.util.*; | |
| 40 | - | |
| 41 | -/** | |
| 42 | - * @author Hill | |
| 43 | - * @date 2021-09 | |
| 44 | - */ | |
| 45 | -@Component | |
| 46 | -@EnableScheduling | |
| 47 | -@Path("/dks") | |
| 48 | -@Produces({MediaType.APPLICATION_JSON}) | |
| 49 | -public class DksRestService { | |
| 50 | - | |
| 51 | - private final static Logger log = LoggerFactory.getLogger(DksRestService.class); | |
| 52 | - | |
| 53 | - @Autowired | |
| 54 | - private JdbcTemplate jdbcTemplate; | |
| 55 | - | |
| 56 | - @Autowired | |
| 57 | - private ScheduleRealInfoRepository scheduleRealInfoRepository; | |
| 58 | - | |
| 59 | - @Autowired | |
| 60 | - private SchedulePlanInfoRepository schedulePlanInfoRepository; | |
| 61 | - | |
| 62 | - @Autowired | |
| 63 | - private ScheduleRedisService scheduleRedisService; | |
| 64 | - | |
| 65 | - @Autowired | |
| 66 | - private OilRedisService oilRedisService; | |
| 67 | - | |
| 68 | - @Autowired | |
| 69 | - private ElecRedisService elecRedisService; | |
| 70 | - | |
| 71 | - /** | |
| 72 | - * 根据日期统计数据重新计算 | |
| 73 | - * @param rq | |
| 74 | - */ | |
| 75 | - @GET | |
| 76 | - @Path("/reCompute/{rq}") | |
| 77 | - public void reStatisticalComputation(@PathParam("rq") String rq) { | |
| 78 | - DateTime dateTime = DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime(rq); | |
| 79 | - planComputation(dateTime); | |
| 80 | - realComputation(dateTime); | |
| 81 | - carMileageComputation(dateTime); | |
| 82 | - } | |
| 83 | - | |
| 84 | - /** | |
| 85 | - * | |
| 86 | - */ | |
| 87 | - private List<LineServiceConfigVo> reGroup(List<LineServiceConfig> configs, String month) { | |
| 88 | - List<LineServiceConfigVo> result = new ArrayList<>(); | |
| 89 | - String oldLineCode = ""; | |
| 90 | - LineServiceConfigVo vo = null; | |
| 91 | - for (int i = 0, len = configs.size();i < len;i++) { | |
| 92 | - LineServiceConfig config = configs.get(i); | |
| 93 | - if (i == 0) { | |
| 94 | - oldLineCode = config.getLineCode(); | |
| 95 | - vo = new LineServiceConfigVo(); | |
| 96 | - vo.setLineName(config.getLineName()); | |
| 97 | - vo.setMonth(month); | |
| 98 | - vo.setConductorFirstCount(config.getConductorCount()); | |
| 99 | - vo.setDriverFirstCount(config.getDriverCount()); | |
| 100 | - } else if (i == len - 1) { | |
| 101 | - result.add(vo); | |
| 102 | - } else { | |
| 103 | - if (!oldLineCode.equals(config.getLineCode())) { | |
| 104 | - oldLineCode = config.getLineCode(); | |
| 105 | - result.add(vo); | |
| 106 | - vo = new LineServiceConfigVo(); | |
| 107 | - vo.setLineName(config.getLineName()); | |
| 108 | - vo.setMonth(month); | |
| 109 | - vo.setConductorFirstCount(config.getConductorCount()); | |
| 110 | - vo.setDriverFirstCount(config.getDriverCount()); | |
| 111 | - } | |
| 112 | - } | |
| 113 | - vo.setConductorLastCount(config.getConductorCount()); | |
| 114 | - vo.setDriverLastCount(config.getDriverCount()); | |
| 115 | - } | |
| 116 | - | |
| 117 | - return result; | |
| 118 | - } | |
| 119 | - | |
| 120 | - /** | |
| 121 | - * 计划司售配档数 | |
| 122 | - * @param month | |
| 123 | - */ | |
| 124 | - @GET | |
| 125 | - @Path("/plan/{month}") | |
| 126 | - public List<LineServiceConfigVo> plan(@PathParam("month") String month) { | |
| 127 | - List<LineServiceConfig> configs = jdbcTemplate.query("select * from control_interface.bsth_t_plan where schedule_date like CONCAT(?, '%') order by line_code, schedule_date", new Object[]{ month }, BeanPropertyRowMapper.newInstance(LineServiceConfig.class)); | |
| 128 | - return reGroup(configs, month); | |
| 129 | - } | |
| 130 | - | |
| 131 | - /** | |
| 132 | - * 实际司售配档数 | |
| 133 | - * @param month | |
| 134 | - */ | |
| 135 | - @GET | |
| 136 | - @Path("/actual/{month}") | |
| 137 | - public List<LineServiceConfigVo> actual(@PathParam("month") String month) { | |
| 138 | - List<LineServiceConfig> configs = jdbcTemplate.query("select * from control_interface.bsth_t_real where schedule_date like CONCAT(?, '%') order by line_code, schedule_date", new Object[]{ month }, BeanPropertyRowMapper.newInstance(LineServiceConfig.class)); | |
| 139 | - return reGroup(configs, month); | |
| 140 | - } | |
| 141 | - | |
| 142 | - /** | |
| 143 | - * 实际配车数 | |
| 144 | - * @param month | |
| 145 | - */ | |
| 146 | - @GET | |
| 147 | - @Path("/bus/{month}") | |
| 148 | - public List<BusVo> bus(@PathParam("month") String month) { | |
| 149 | - List<LineServiceConfig> configs = jdbcTemplate.query("select * from control_interface.bsth_t_real where schedule_date like CONCAT(?, '%') order by line_code, schedule_date", new Object[]{ month }, BeanPropertyRowMapper.newInstance(LineServiceConfig.class)); | |
| 150 | - List<BusVo> result = new ArrayList<>(); | |
| 151 | - String oldLineCode = ""; | |
| 152 | - BusVo vo = null; | |
| 153 | - int max = 0; | |
| 154 | - for (int i = 0, len = configs.size();i < len;i++) { | |
| 155 | - LineServiceConfig config = configs.get(i); | |
| 156 | - if (i == 0) { | |
| 157 | - oldLineCode = config.getLineCode(); | |
| 158 | - vo = new BusVo(); | |
| 159 | - vo.setLineName(config.getLineName()); | |
| 160 | - vo.setMonth(month); | |
| 161 | - vo.setBusFirstCount(config.getCarCount()); | |
| 162 | - } else if (!oldLineCode.equals(config.getLineCode())) { | |
| 163 | - oldLineCode = config.getLineCode(); | |
| 164 | - vo.setBusMaxCount(max); | |
| 165 | - result.add(vo); | |
| 166 | - max = 0; | |
| 167 | - vo = new BusVo(); | |
| 168 | - vo.setLineName(config.getLineName()); | |
| 169 | - vo.setMonth(month); | |
| 170 | - vo.setBusFirstCount(config.getCarCount()); | |
| 171 | - } | |
| 172 | - max = Math.max(max, config.getCarCount()); | |
| 173 | - if (i == len - 1) { | |
| 174 | - vo.setBusMaxCount(max); | |
| 175 | - result.add(vo); | |
| 176 | - } | |
| 177 | - vo.setBusLastCount(config.getCarCount()); | |
| 178 | - } | |
| 179 | - | |
| 180 | - return result; | |
| 181 | - } | |
| 182 | - | |
| 183 | - /** | |
| 184 | - * 车辆公里、油耗数据 | |
| 185 | - * @param month | |
| 186 | - */ | |
| 187 | - @GET | |
| 188 | - @Path("/mileage/{month}") | |
| 189 | - public List<BusMileageVo> mileage(@PathParam("month") String month) { | |
| 190 | - List<BusMileage> mileages = jdbcTemplate.query("select nbbm, schedule_month schedule_date, sum(zlc) zlc, sum(yh) yh, sum(dh) dh from control_interface.bsth_t_mileage where schedule_month = ? group by nbbm, schedule_month", new Object[]{ month }, BeanPropertyRowMapper.newInstance(BusMileage.class)); | |
| 191 | - List<BusMileageVo> result = new ArrayList<>(); | |
| 192 | - for (BusMileage mileage : mileages) { | |
| 193 | - BusMileageVo vo = new BusMileageVo(); | |
| 194 | - vo.setMonth(mileage.getScheduleDate()); | |
| 195 | - vo.setInsideCode(mileage.getNbbm()); | |
| 196 | - vo.setTotalMileage(mileage.getZlc()); | |
| 197 | - vo.setOilConsume(mileage.getYh()); | |
| 198 | - vo.setElectricConsume(mileage.getDh()); | |
| 199 | - | |
| 200 | - result.add(vo); | |
| 201 | - } | |
| 202 | - | |
| 203 | - return result; | |
| 204 | - } | |
| 205 | - | |
| 206 | - @Scheduled(cron = "0 0/25 23 * * ?") | |
| 207 | - public void statisticalComputation() { | |
| 208 | - log.info("执行电科所接口数据统计计算"); | |
| 209 | - DateTime dateTime = DateTime.now().plusDays(1); | |
| 210 | - try { | |
| 211 | - for (int i = 0;i < 3;i++) { | |
| 212 | - dateTime = dateTime.minusDays(1); | |
| 213 | - planComputation(dateTime); | |
| 214 | - realComputation(dateTime); | |
| 215 | - carMileageComputation(dateTime); | |
| 216 | - } | |
| 217 | - } catch (Exception e) { | |
| 218 | - e.printStackTrace(); | |
| 219 | - } | |
| 220 | - } | |
| 221 | - | |
| 222 | - /** | |
| 223 | - * 计划排班中的线路司售配档数 | |
| 224 | - */ | |
| 225 | - private void planComputation(DateTime dateTime) { | |
| 226 | - // 记录实际线路司售配档情况 | |
| 227 | - List<SchedulePlanInfo> schedulePlanInfos = schedulePlanInfoRepository.findByDate(DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime(dateTime.toString("yyyy-MM-dd")).toDate()); | |
| 228 | - Set<String> lineCodes = new HashSet<>(); | |
| 229 | - Map<String, Set<String>> line2conductors = new HashMap<>(), line2drivers = new HashMap<>(); | |
| 230 | - final List<LineServiceConfig> objects = new ArrayList<>(); | |
| 231 | - for (SchedulePlanInfo schedulePlanInfo : schedulePlanInfos) { | |
| 232 | - String lineCode = schedulePlanInfo.getXlBm(); | |
| 233 | - lineCodes.add(lineCode); | |
| 234 | - Set<String> conductors = line2conductors.get(lineCode), drivers = line2drivers.get(lineCode); | |
| 235 | - if (conductors == null) { | |
| 236 | - conductors = new HashSet<>(); | |
| 237 | - line2conductors.put(lineCode, conductors); | |
| 238 | - } | |
| 239 | - if (drivers == null) { | |
| 240 | - drivers = new HashSet<>(); | |
| 241 | - line2drivers.put(lineCode, drivers); | |
| 242 | - } | |
| 243 | - if (!StringUtils.isEmpty(schedulePlanInfo.getsGh())) { | |
| 244 | - conductors.add(schedulePlanInfo.getsGh()); | |
| 245 | - } | |
| 246 | - drivers.add(schedulePlanInfo.getjGh()); | |
| 247 | - } | |
| 248 | - for (String lineCode : lineCodes) { | |
| 249 | - LineServiceConfig object = new LineServiceConfig(); | |
| 250 | - Line line = LineBufferData.findOne(lineCode); | |
| 251 | - object.setLineCode(lineCode); | |
| 252 | - object.setLineName(line == null ? "" : line.getName()); | |
| 253 | - object.setScheduleDate(dateTime.toString("yyyy-MM-dd")); | |
| 254 | - object.setConductorCount(line2conductors.get(lineCode).size()); | |
| 255 | - object.setDriverCount(line2drivers.get(lineCode).size()); | |
| 256 | - | |
| 257 | - objects.add(object); | |
| 258 | - } | |
| 259 | - | |
| 260 | - //编程式事务 | |
| 261 | - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); | |
| 262 | - DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | |
| 263 | - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | |
| 264 | - TransactionStatus status = tran.getTransaction(def); | |
| 265 | - | |
| 266 | - try { | |
| 267 | - jdbcTemplate.update("delete from control_interface.bsth_t_plan where schedule_date = ?", new Object[]{ dateTime.toString("yyyy-MM-dd") }); | |
| 268 | - jdbcTemplate.batchUpdate("insert into control_interface.bsth_t_plan (line_code, line_name, schedule_date, conductor_count, driver_count) values (?,?,?,?,?)", new BatchPreparedStatementSetter() { | |
| 269 | - @Override | |
| 270 | - public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 271 | - LineServiceConfig object = objects.get(i); | |
| 272 | - ps.setString(1, object.getLineCode()); | |
| 273 | - ps.setString(2, object.getLineName()); | |
| 274 | - ps.setString(3, object.getScheduleDate()); | |
| 275 | - ps.setInt(4, object.getConductorCount()); | |
| 276 | - ps.setInt(5, object.getDriverCount()); | |
| 277 | - } | |
| 278 | - | |
| 279 | - @Override | |
| 280 | - public int getBatchSize() { | |
| 281 | - return objects.size(); | |
| 282 | - } | |
| 283 | - }); | |
| 284 | - tran.commit(status); | |
| 285 | - } catch (Exception e) { | |
| 286 | - tran.rollback(status); | |
| 287 | - } | |
| 288 | - } | |
| 289 | - | |
| 290 | - /** | |
| 291 | - * 实际排班中的线路司售配档数 | |
| 292 | - */ | |
| 293 | - private void realComputation(DateTime dateTime) { | |
| 294 | - // 记录实际线路司售配档情况 | |
| 295 | - List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.findAll(dateTime.toString("yyyy-MM-dd")); | |
| 296 | - Set<String> lineCodes = new HashSet<>(); | |
| 297 | - Map<String, Set<String>> line2conductors = new HashMap<>(), line2drivers = new HashMap<>(), line2cars = new HashMap<>(); | |
| 298 | - final List<LineServiceConfig> objects = new ArrayList<>(); | |
| 299 | - for (ScheduleRealInfo scheduleRealInfo : scheduleRealInfos) { | |
| 300 | - // 烂班班次不计入配档数 | |
| 301 | - if (scheduleRealInfo.getStatus() == -1) { continue; } | |
| 302 | - String lineCode = scheduleRealInfo.getXlBm(); | |
| 303 | - lineCodes.add(lineCode); | |
| 304 | - Set<String> conductors = line2conductors.get(lineCode), drivers = line2drivers.get(lineCode), cars = line2cars.get(lineCode); | |
| 305 | - if (conductors == null) { | |
| 306 | - conductors = new HashSet<>(); | |
| 307 | - line2conductors.put(lineCode, conductors); | |
| 308 | - } | |
| 309 | - if (drivers == null) { | |
| 310 | - drivers = new HashSet<>(); | |
| 311 | - line2drivers.put(lineCode, drivers); | |
| 312 | - } | |
| 313 | - if (cars == null) { | |
| 314 | - cars = new HashSet<>(); | |
| 315 | - line2cars.put(lineCode, cars); | |
| 316 | - } | |
| 317 | - if (!StringUtils.isEmpty(scheduleRealInfo.getsGh())) { | |
| 318 | - conductors.add(scheduleRealInfo.getsGh()); | |
| 319 | - } | |
| 320 | - drivers.add(scheduleRealInfo.getjGh()); | |
| 321 | - cars.add(scheduleRealInfo.getClZbh()); | |
| 322 | - } | |
| 323 | - for (String lineCode : lineCodes) { | |
| 324 | - LineServiceConfig object = new LineServiceConfig(); | |
| 325 | - Line line = LineBufferData.findOne(lineCode); | |
| 326 | - object.setLineCode(lineCode); | |
| 327 | - object.setLineName(line == null ? "" : line.getName()); | |
| 328 | - object.setScheduleDate(dateTime.toString("yyyy-MM-dd")); | |
| 329 | - object.setConductorCount(line2conductors.get(lineCode).size()); | |
| 330 | - object.setDriverCount(line2drivers.get(lineCode).size()); | |
| 331 | - object.setCarCount(line2cars.get(lineCode).size()); | |
| 332 | - | |
| 333 | - objects.add(object); | |
| 334 | - } | |
| 335 | - | |
| 336 | - //编程式事务 | |
| 337 | - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); | |
| 338 | - DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | |
| 339 | - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | |
| 340 | - TransactionStatus status = tran.getTransaction(def); | |
| 341 | - try { | |
| 342 | - jdbcTemplate.update("delete from control_interface.bsth_t_real where schedule_date = ?", new Object[]{ dateTime.toString("yyyy-MM-dd") }); | |
| 343 | - jdbcTemplate.batchUpdate("insert into control_interface.bsth_t_real (line_code, line_name, schedule_date, conductor_count, driver_count, car_count) values (?,?,?,?,?,?)", new BatchPreparedStatementSetter() { | |
| 344 | - @Override | |
| 345 | - public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 346 | - LineServiceConfig object = objects.get(i); | |
| 347 | - ps.setString(1, object.getLineCode()); | |
| 348 | - ps.setString(2, object.getLineName()); | |
| 349 | - ps.setString(3, object.getScheduleDate()); | |
| 350 | - ps.setInt(4, object.getConductorCount()); | |
| 351 | - ps.setInt(5, object.getDriverCount()); | |
| 352 | - ps.setInt(6, object.getCarCount()); | |
| 353 | - } | |
| 354 | - | |
| 355 | - @Override | |
| 356 | - public int getBatchSize() { | |
| 357 | - return objects.size(); | |
| 358 | - } | |
| 359 | - }); | |
| 360 | - tran.commit(status); | |
| 361 | - } catch (Exception e) { | |
| 362 | - tran.rollback(status); | |
| 363 | - } | |
| 364 | - } | |
| 365 | - | |
| 366 | - private void carMileageComputation(final DateTime dateTime) { | |
| 367 | - String rq = dateTime.toString("yyyy-MM-dd"); | |
| 368 | - // 实际排班信息 | |
| 369 | - ArrayListMultimap<String, ScheduleRealInfo> nbbm2schedules = scheduleRedisService.findByDate(rq); | |
| 370 | - // 油耗信息 | |
| 371 | - ArrayListMultimap<String, OilInfo> oilInfoMap = oilRedisService.findByNbbmGroup1(nbbm2schedules.keySet(), rq); | |
| 372 | - //电耗信息 | |
| 373 | - ArrayListMultimap<String, ElecInfo> elecInfoMap = elecRedisService.findByNbbmGroup1(nbbm2schedules.keySet(), rq); | |
| 374 | - Set<String> nbbms = nbbm2schedules.keySet(); | |
| 375 | - final List<BusMileage> busMileages = new ArrayList<>(); | |
| 376 | - for (String nbbm : nbbms) { | |
| 377 | - List<ScheduleRealInfo> scheduleRealInfos = nbbm2schedules.get(nbbm); | |
| 378 | - if (scheduleRealInfos.size() == 0) { | |
| 379 | - continue; | |
| 380 | - } | |
| 381 | - BusMileage busMileage = new BusMileage(); | |
| 382 | - busMileage.setScheduleDate(rq); | |
| 383 | - busMileage.setNbbm(nbbm); | |
| 384 | - busMileage.setJhlc(ScheduleCalculator.calcJHLC(scheduleRealInfos)); | |
| 385 | - busMileage.setSjjhlc(ScheduleCalculator.calcSJLC(scheduleRealInfos)); | |
| 386 | - busMileage.setSjcclc(ScheduleCalculator.calcCCLC(scheduleRealInfos)); | |
| 387 | - busMileage.setSjjclc(ScheduleCalculator.calcJCLC(scheduleRealInfos)); | |
| 388 | - busMileage.setYylc(ScheduleCalculator.calcYYLC(scheduleRealInfos)); | |
| 389 | - busMileage.setKslc(ScheduleCalculator.calcKSLC(scheduleRealInfos)); | |
| 390 | - busMileage.setCjlc(ScheduleCalculator.calcCJLC(scheduleRealInfos)); | |
| 391 | - busMileage.setLblc(ScheduleCalculator.calcLBLC(scheduleRealInfos)); | |
| 392 | - busMileage.setZjlc(ScheduleCalculator.calcZJLC(scheduleRealInfos)); | |
| 393 | - busMileage.setZlc(ScheduleCalculator.calcZLC(scheduleRealInfos)); | |
| 394 | - List<OilInfo> oilInfos = oilInfoMap.get(nbbm); | |
| 395 | - List<ElecInfo> elecInfos = elecInfoMap.get(nbbm); | |
| 396 | - Double yh = 0.0, dh = 0.0; | |
| 397 | - for (OilInfo oilInfo : oilInfos) { | |
| 398 | - yh = Arith.add(yh, oilInfo.getYh()); | |
| 399 | - } | |
| 400 | - for (ElecInfo elecInfo : elecInfos) { | |
| 401 | - dh = Arith.add(yh, elecInfo.getHd()); | |
| 402 | - } | |
| 403 | - busMileage.setYh(yh); | |
| 404 | - busMileage.setDh(dh); | |
| 405 | - | |
| 406 | - busMileages.add(busMileage); | |
| 407 | - } | |
| 408 | - | |
| 409 | - //编程式事务 | |
| 410 | - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); | |
| 411 | - DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | |
| 412 | - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | |
| 413 | - TransactionStatus status = tran.getTransaction(def); | |
| 414 | - try { | |
| 415 | - jdbcTemplate.update("delete from control_interface.bsth_t_mileage where schedule_date = ?", new Object[]{ dateTime.toString("yyyy-MM-dd") }); | |
| 416 | - jdbcTemplate.batchUpdate("insert into control_interface.bsth_t_mileage (schedule_date,nbbm,jhlc,sjjhlc,sjcclc,sjjclc,yylc,kslc,cjlc,lblc,zjlc,zlc,yh,dh,schedule_month) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", new BatchPreparedStatementSetter() { | |
| 417 | - @Override | |
| 418 | - public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 419 | - BusMileage busMileage = busMileages.get(i); | |
| 420 | - ps.setString(1, busMileage.getScheduleDate()); | |
| 421 | - ps.setString(2, busMileage.getNbbm()); | |
| 422 | - ps.setDouble(3, busMileage.getJhlc()); | |
| 423 | - ps.setDouble(4, busMileage.getSjjhlc()); | |
| 424 | - ps.setDouble(5, busMileage.getSjcclc()); | |
| 425 | - ps.setDouble(6, busMileage.getSjjclc()); | |
| 426 | - ps.setDouble(7, busMileage.getYylc()); | |
| 427 | - ps.setDouble(8, busMileage.getKslc()); | |
| 428 | - ps.setDouble(9, busMileage.getCjlc()); | |
| 429 | - ps.setDouble(10, busMileage.getLblc()); | |
| 430 | - ps.setDouble(11, busMileage.getZjlc()); | |
| 431 | - ps.setDouble(12, busMileage.getZlc()); | |
| 432 | - ps.setDouble(13, busMileage.getYh()); | |
| 433 | - ps.setDouble(14, busMileage.getDh()); | |
| 434 | - ps.setString(15, dateTime.toString("yyyy-MM")); | |
| 435 | - } | |
| 436 | - | |
| 437 | - @Override | |
| 438 | - public int getBatchSize() { | |
| 439 | - return busMileages.size(); | |
| 440 | - } | |
| 441 | - }); | |
| 442 | - tran.commit(status); | |
| 443 | - } catch (Exception e) { | |
| 444 | - tran.rollback(status); | |
| 445 | - } | |
| 446 | - } | |
| 447 | - | |
| 448 | - /** | |
| 449 | - * 线路司售配档对象 | |
| 450 | - */ | |
| 451 | - private final static class LineServiceConfigVo { | |
| 452 | - | |
| 453 | - private String lineName; | |
| 454 | - | |
| 455 | - private String month; | |
| 456 | - | |
| 457 | - private Integer driverFirstCount; | |
| 458 | - | |
| 459 | - private Integer driverLastCount; | |
| 460 | - | |
| 461 | - private Integer conductorFirstCount; | |
| 462 | - | |
| 463 | - private Integer conductorLastCount; | |
| 464 | - | |
| 465 | - public String getLineName() { | |
| 466 | - return lineName; | |
| 467 | - } | |
| 468 | - | |
| 469 | - public void setLineName(String lineName) { | |
| 470 | - this.lineName = lineName; | |
| 471 | - } | |
| 472 | - | |
| 473 | - public String getMonth() { | |
| 474 | - return month; | |
| 475 | - } | |
| 476 | - | |
| 477 | - public void setMonth(String month) { | |
| 478 | - this.month = month; | |
| 479 | - } | |
| 480 | - | |
| 481 | - public Integer getDriverFirstCount() { | |
| 482 | - return driverFirstCount; | |
| 483 | - } | |
| 484 | - | |
| 485 | - public void setDriverFirstCount(Integer driverFirstCount) { | |
| 486 | - this.driverFirstCount = driverFirstCount; | |
| 487 | - } | |
| 488 | - | |
| 489 | - public Integer getDriverLastCount() { | |
| 490 | - return driverLastCount; | |
| 491 | - } | |
| 492 | - | |
| 493 | - public void setDriverLastCount(Integer driverLastCount) { | |
| 494 | - this.driverLastCount = driverLastCount; | |
| 495 | - } | |
| 496 | - | |
| 497 | - public Integer getConductorFirstCount() { | |
| 498 | - return conductorFirstCount; | |
| 499 | - } | |
| 500 | - | |
| 501 | - public void setConductorFirstCount(Integer conductorFirstCount) { | |
| 502 | - this.conductorFirstCount = conductorFirstCount; | |
| 503 | - } | |
| 504 | - | |
| 505 | - public Integer getConductorLastCount() { | |
| 506 | - return conductorLastCount; | |
| 507 | - } | |
| 508 | - | |
| 509 | - public void setConductorLastCount(Integer conductorLastCount) { | |
| 510 | - this.conductorLastCount = conductorLastCount; | |
| 511 | - } | |
| 512 | - } | |
| 513 | - | |
| 514 | - /** | |
| 515 | - * 车辆配档对象 | |
| 516 | - */ | |
| 517 | - private final static class BusVo { | |
| 518 | - | |
| 519 | - private String lineName; | |
| 520 | - | |
| 521 | - private String month; | |
| 522 | - | |
| 523 | - private Integer busFirstCount; | |
| 524 | - | |
| 525 | - private Integer busLastCount; | |
| 526 | - | |
| 527 | - private Integer busMaxCount; | |
| 528 | - | |
| 529 | - public String getLineName() { | |
| 530 | - return lineName; | |
| 531 | - } | |
| 532 | - | |
| 533 | - public void setLineName(String lineName) { | |
| 534 | - this.lineName = lineName; | |
| 535 | - } | |
| 536 | - | |
| 537 | - public String getMonth() { | |
| 538 | - return month; | |
| 539 | - } | |
| 540 | - | |
| 541 | - public void setMonth(String month) { | |
| 542 | - this.month = month; | |
| 543 | - } | |
| 544 | - | |
| 545 | - public Integer getBusFirstCount() { | |
| 546 | - return busFirstCount; | |
| 547 | - } | |
| 548 | - | |
| 549 | - public void setBusFirstCount(Integer busFirstCount) { | |
| 550 | - this.busFirstCount = busFirstCount; | |
| 551 | - } | |
| 552 | - | |
| 553 | - public Integer getBusLastCount() { | |
| 554 | - return busLastCount; | |
| 555 | - } | |
| 556 | - | |
| 557 | - public void setBusLastCount(Integer busLastCount) { | |
| 558 | - this.busLastCount = busLastCount; | |
| 559 | - } | |
| 560 | - | |
| 561 | - public Integer getBusMaxCount() { | |
| 562 | - return busMaxCount; | |
| 563 | - } | |
| 564 | - | |
| 565 | - public void setBusMaxCount(Integer busMaxCount) { | |
| 566 | - this.busMaxCount = busMaxCount; | |
| 567 | - } | |
| 568 | - } | |
| 569 | - | |
| 570 | - /** | |
| 571 | - * 车辆公里、油耗对象 | |
| 572 | - */ | |
| 573 | - private final static class BusMileageVo { | |
| 574 | - | |
| 575 | - private String insideCode; | |
| 576 | - | |
| 577 | - private String month; | |
| 578 | - | |
| 579 | - private Double totalMileage; | |
| 580 | - | |
| 581 | - private Double oilConsume; | |
| 582 | - | |
| 583 | - private Double electricConsume; | |
| 584 | - | |
| 585 | - public String getInsideCode() { | |
| 586 | - return insideCode; | |
| 587 | - } | |
| 588 | - | |
| 589 | - public void setInsideCode(String insideCode) { | |
| 590 | - this.insideCode = insideCode; | |
| 591 | - } | |
| 592 | - | |
| 593 | - public String getMonth() { | |
| 594 | - return month; | |
| 595 | - } | |
| 596 | - | |
| 597 | - public void setMonth(String month) { | |
| 598 | - this.month = month; | |
| 599 | - } | |
| 600 | - | |
| 601 | - public Double getTotalMileage() { | |
| 602 | - return totalMileage; | |
| 603 | - } | |
| 604 | - | |
| 605 | - public void setTotalMileage(Double totalMileage) { | |
| 606 | - this.totalMileage = totalMileage; | |
| 607 | - } | |
| 608 | - | |
| 609 | - public Double getOilConsume() { | |
| 610 | - return oilConsume; | |
| 611 | - } | |
| 612 | - | |
| 613 | - public void setOilConsume(Double oilConsume) { | |
| 614 | - this.oilConsume = oilConsume; | |
| 615 | - } | |
| 616 | - | |
| 617 | - public Double getElectricConsume() { | |
| 618 | - return electricConsume; | |
| 619 | - } | |
| 620 | - | |
| 621 | - public void setElectricConsume(Double electricConsume) { | |
| 622 | - this.electricConsume = electricConsume; | |
| 623 | - } | |
| 624 | - } | |
| 625 | -} | |
| 1 | +package com.bsth.server_rs.dks; | |
| 2 | + | |
| 3 | +import com.alibaba.fastjson.JSON; | |
| 4 | +import com.bsth.entity.ElecInfo; | |
| 5 | +import com.bsth.entity.OilInfo; | |
| 6 | +import com.bsth.entity.SchedulePlanInfo; | |
| 7 | +import com.bsth.entity.ScheduleRealInfo; | |
| 8 | +import com.bsth.redis.ElecRedisService; | |
| 9 | +import com.bsth.redis.OilRedisService; | |
| 10 | +import com.bsth.redis.ScheduleRedisService; | |
| 11 | +import com.bsth.repository.SchedulePlanInfoRepository; | |
| 12 | +import com.bsth.repository.ScheduleRealInfoRepository; | |
| 13 | +import com.bsth.server_rs.base_info.line.Line; | |
| 14 | +import com.bsth.server_rs.base_info.line.buffer.LineBufferData; | |
| 15 | +import com.bsth.server_ws.util.ScheduleCalculator; | |
| 16 | +import com.bsth.util.Arith; | |
| 17 | +import com.google.common.collect.ArrayListMultimap; | |
| 18 | +import org.joda.time.DateTime; | |
| 19 | +import org.joda.time.format.DateTimeFormat; | |
| 20 | +import org.slf4j.Logger; | |
| 21 | +import org.slf4j.LoggerFactory; | |
| 22 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 23 | +import org.springframework.jdbc.core.BatchPreparedStatementSetter; | |
| 24 | +import org.springframework.jdbc.core.BeanPropertyRowMapper; | |
| 25 | +import org.springframework.jdbc.core.JdbcTemplate; | |
| 26 | +import org.springframework.jdbc.datasource.DataSourceTransactionManager; | |
| 27 | +import org.springframework.scheduling.annotation.EnableScheduling; | |
| 28 | +import org.springframework.scheduling.annotation.Scheduled; | |
| 29 | +import org.springframework.stereotype.Component; | |
| 30 | +import org.springframework.transaction.TransactionDefinition; | |
| 31 | +import org.springframework.transaction.TransactionStatus; | |
| 32 | +import org.springframework.transaction.support.DefaultTransactionDefinition; | |
| 33 | +import org.springframework.util.StringUtils; | |
| 34 | + | |
| 35 | +import javax.ws.rs.*; | |
| 36 | +import javax.ws.rs.core.MediaType; | |
| 37 | +import java.sql.PreparedStatement; | |
| 38 | +import java.sql.SQLException; | |
| 39 | +import java.util.*; | |
| 40 | + | |
| 41 | +/** | |
| 42 | + * @author Hill | |
| 43 | + * @date 2021-09 | |
| 44 | + */ | |
| 45 | +@Component | |
| 46 | +@EnableScheduling | |
| 47 | +@Path("/dks") | |
| 48 | +@Produces({MediaType.APPLICATION_JSON}) | |
| 49 | +public class DksRestService { | |
| 50 | + | |
| 51 | + private final static Logger log = LoggerFactory.getLogger(DksRestService.class); | |
| 52 | + | |
| 53 | + @Autowired | |
| 54 | + private JdbcTemplate jdbcTemplate; | |
| 55 | + | |
| 56 | + @Autowired | |
| 57 | + private ScheduleRealInfoRepository scheduleRealInfoRepository; | |
| 58 | + | |
| 59 | + @Autowired | |
| 60 | + private SchedulePlanInfoRepository schedulePlanInfoRepository; | |
| 61 | + | |
| 62 | + @Autowired | |
| 63 | + private ScheduleRedisService scheduleRedisService; | |
| 64 | + | |
| 65 | + @Autowired | |
| 66 | + private OilRedisService oilRedisService; | |
| 67 | + | |
| 68 | + @Autowired | |
| 69 | + private ElecRedisService elecRedisService; | |
| 70 | + | |
| 71 | + /** | |
| 72 | + * 根据日期统计数据重新计算 | |
| 73 | + * @param rq | |
| 74 | + */ | |
| 75 | + @GET | |
| 76 | + @Path("/reCompute/{rq}") | |
| 77 | + public void reStatisticalComputation(@PathParam("rq") String rq) { | |
| 78 | + DateTime dateTime = DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime(rq); | |
| 79 | + planComputation(dateTime); | |
| 80 | + realComputation(dateTime); | |
| 81 | + carMileageComputation(dateTime); | |
| 82 | + } | |
| 83 | + | |
| 84 | + /** | |
| 85 | + * | |
| 86 | + */ | |
| 87 | + private List<LineServiceConfigVo> reGroup(List<LineServiceConfig> configs, String month) { | |
| 88 | + List<LineServiceConfigVo> result = new ArrayList<>(); | |
| 89 | + String oldLineCode = ""; | |
| 90 | + LineServiceConfigVo vo = null; | |
| 91 | + for (int i = 0, len = configs.size();i < len;i++) { | |
| 92 | + LineServiceConfig config = configs.get(i); | |
| 93 | + if (i == 0) { | |
| 94 | + oldLineCode = config.getLineCode(); | |
| 95 | + vo = new LineServiceConfigVo(); | |
| 96 | + vo.setLineName(config.getLineName()); | |
| 97 | + vo.setMonth(month); | |
| 98 | + vo.setConductorFirstCount(config.getConductorCount()); | |
| 99 | + vo.setDriverFirstCount(config.getDriverCount()); | |
| 100 | + } else if (i == len - 1) { | |
| 101 | + result.add(vo); | |
| 102 | + } else { | |
| 103 | + if (!oldLineCode.equals(config.getLineCode())) { | |
| 104 | + oldLineCode = config.getLineCode(); | |
| 105 | + result.add(vo); | |
| 106 | + vo = new LineServiceConfigVo(); | |
| 107 | + vo.setLineName(config.getLineName()); | |
| 108 | + vo.setMonth(month); | |
| 109 | + vo.setConductorFirstCount(config.getConductorCount()); | |
| 110 | + vo.setDriverFirstCount(config.getDriverCount()); | |
| 111 | + } | |
| 112 | + } | |
| 113 | + vo.setConductorLastCount(config.getConductorCount()); | |
| 114 | + vo.setDriverLastCount(config.getDriverCount()); | |
| 115 | + } | |
| 116 | + | |
| 117 | + return result; | |
| 118 | + } | |
| 119 | + | |
| 120 | + /** | |
| 121 | + * 计划司售配档数 | |
| 122 | + * @param month | |
| 123 | + */ | |
| 124 | + @GET | |
| 125 | + @Path("/plan/{month}") | |
| 126 | + public List<LineServiceConfigVo> plan(@PathParam("month") String month) { | |
| 127 | + List<LineServiceConfig> configs = jdbcTemplate.query("select * from control_interface.bsth_t_plan where schedule_date like CONCAT(?, '%') order by line_code, schedule_date", new Object[]{ month }, BeanPropertyRowMapper.newInstance(LineServiceConfig.class)); | |
| 128 | + return reGroup(configs, month); | |
| 129 | + } | |
| 130 | + | |
| 131 | + /** | |
| 132 | + * 实际司售配档数 | |
| 133 | + * @param month | |
| 134 | + */ | |
| 135 | + @GET | |
| 136 | + @Path("/actual/{month}") | |
| 137 | + public List<LineServiceConfigVo> actual(@PathParam("month") String month) { | |
| 138 | + List<LineServiceConfig> configs = jdbcTemplate.query("select * from control_interface.bsth_t_real where schedule_date like CONCAT(?, '%') order by line_code, schedule_date", new Object[]{ month }, BeanPropertyRowMapper.newInstance(LineServiceConfig.class)); | |
| 139 | + return reGroup(configs, month); | |
| 140 | + } | |
| 141 | + | |
| 142 | + /** | |
| 143 | + * 实际配车数 | |
| 144 | + * @param month | |
| 145 | + */ | |
| 146 | + @GET | |
| 147 | + @Path("/bus/{month}") | |
| 148 | + public List<BusVo> bus(@PathParam("month") String month) { | |
| 149 | + List<LineServiceConfig> configs = jdbcTemplate.query("select * from control_interface.bsth_t_real where schedule_date like CONCAT(?, '%') order by line_code, schedule_date", new Object[]{ month }, BeanPropertyRowMapper.newInstance(LineServiceConfig.class)); | |
| 150 | + List<BusVo> result = new ArrayList<>(); | |
| 151 | + String oldLineCode = ""; | |
| 152 | + BusVo vo = null; | |
| 153 | + int max = 0; | |
| 154 | + for (int i = 0, len = configs.size();i < len;i++) { | |
| 155 | + LineServiceConfig config = configs.get(i); | |
| 156 | + if (i == 0) { | |
| 157 | + oldLineCode = config.getLineCode(); | |
| 158 | + vo = new BusVo(); | |
| 159 | + vo.setLineName(config.getLineName()); | |
| 160 | + vo.setMonth(month); | |
| 161 | + vo.setBusFirstCount(config.getCarCount()); | |
| 162 | + } else if (!oldLineCode.equals(config.getLineCode())) { | |
| 163 | + oldLineCode = config.getLineCode(); | |
| 164 | + vo.setBusMaxCount(max); | |
| 165 | + result.add(vo); | |
| 166 | + max = 0; | |
| 167 | + vo = new BusVo(); | |
| 168 | + vo.setLineName(config.getLineName()); | |
| 169 | + vo.setMonth(month); | |
| 170 | + vo.setBusFirstCount(config.getCarCount()); | |
| 171 | + } | |
| 172 | + max = Math.max(max, config.getCarCount()); | |
| 173 | + if (i == len - 1) { | |
| 174 | + vo.setBusMaxCount(max); | |
| 175 | + result.add(vo); | |
| 176 | + } | |
| 177 | + vo.setBusLastCount(config.getCarCount()); | |
| 178 | + } | |
| 179 | + | |
| 180 | + return result; | |
| 181 | + } | |
| 182 | + | |
| 183 | + /** | |
| 184 | + * 车辆公里、油耗数据 | |
| 185 | + * @param month | |
| 186 | + */ | |
| 187 | + @GET | |
| 188 | + @Path("/mileage/{month}") | |
| 189 | + public List<BusMileageVo> mileage(@PathParam("month") String month) { | |
| 190 | + List<BusMileage> mileages = jdbcTemplate.query("select company, company_code, nbbm, schedule_month schedule_date, sum(zlc) zlc, sum(yh) yh, sum(dh) dh from control_interface.bsth_t_mileage where schedule_month = ? group by company, company_code, nbbm, schedule_month", new Object[]{ month }, BeanPropertyRowMapper.newInstance(BusMileage.class)); | |
| 191 | + List<BusMileageVo> result = new ArrayList<>(); | |
| 192 | + for (BusMileage mileage : mileages) { | |
| 193 | + BusMileageVo vo = new BusMileageVo(); | |
| 194 | + vo.setMonth(mileage.getScheduleDate()); | |
| 195 | + vo.setInsideCode(mileage.getNbbm()); | |
| 196 | + vo.setTotalMileage(mileage.getZlc()); | |
| 197 | + vo.setOilConsume(mileage.getYh()); | |
| 198 | + vo.setElectricConsume(mileage.getDh()); | |
| 199 | + vo.setCompany(mileage.getCompany()); | |
| 200 | + vo.setCompanyCode(mileage.getCompanyCode()); | |
| 201 | + | |
| 202 | + result.add(vo); | |
| 203 | + } | |
| 204 | + | |
| 205 | + return result; | |
| 206 | + } | |
| 207 | + | |
| 208 | + @Scheduled(cron = "0 0/25 23 * * ?") | |
| 209 | + public void statisticalComputation() { | |
| 210 | + log.info("执行电科所接口数据统计计算"); | |
| 211 | + DateTime dateTime = DateTime.now().plusDays(1); | |
| 212 | + try { | |
| 213 | + for (int i = 0;i < 3;i++) { | |
| 214 | + dateTime = dateTime.minusDays(1); | |
| 215 | + planComputation(dateTime); | |
| 216 | + realComputation(dateTime); | |
| 217 | + carMileageComputation(dateTime); | |
| 218 | + } | |
| 219 | + } catch (Exception e) { | |
| 220 | + e.printStackTrace(); | |
| 221 | + } | |
| 222 | + } | |
| 223 | + | |
| 224 | + /** | |
| 225 | + * 计划排班中的线路司售配档数 | |
| 226 | + */ | |
| 227 | + private void planComputation(DateTime dateTime) { | |
| 228 | + // 记录实际线路司售配档情况 | |
| 229 | + List<SchedulePlanInfo> schedulePlanInfos = schedulePlanInfoRepository.findByDate(DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime(dateTime.toString("yyyy-MM-dd")).toDate()); | |
| 230 | + Set<String> lineCodes = new HashSet<>(); | |
| 231 | + Map<String, Set<String>> line2conductors = new HashMap<>(), line2drivers = new HashMap<>(); | |
| 232 | + final List<LineServiceConfig> objects = new ArrayList<>(); | |
| 233 | + for (SchedulePlanInfo schedulePlanInfo : schedulePlanInfos) { | |
| 234 | + String lineCode = schedulePlanInfo.getXlBm(); | |
| 235 | + lineCodes.add(lineCode); | |
| 236 | + Set<String> conductors = line2conductors.get(lineCode), drivers = line2drivers.get(lineCode); | |
| 237 | + if (conductors == null) { | |
| 238 | + conductors = new HashSet<>(); | |
| 239 | + line2conductors.put(lineCode, conductors); | |
| 240 | + } | |
| 241 | + if (drivers == null) { | |
| 242 | + drivers = new HashSet<>(); | |
| 243 | + line2drivers.put(lineCode, drivers); | |
| 244 | + } | |
| 245 | + if (!StringUtils.isEmpty(schedulePlanInfo.getsGh())) { | |
| 246 | + conductors.add(schedulePlanInfo.getsGh()); | |
| 247 | + } | |
| 248 | + drivers.add(schedulePlanInfo.getjGh()); | |
| 249 | + } | |
| 250 | + for (String lineCode : lineCodes) { | |
| 251 | + LineServiceConfig object = new LineServiceConfig(); | |
| 252 | + Line line = LineBufferData.findOne(lineCode); | |
| 253 | + object.setLineCode(lineCode); | |
| 254 | + object.setLineName(line == null ? "" : line.getName()); | |
| 255 | + object.setScheduleDate(dateTime.toString("yyyy-MM-dd")); | |
| 256 | + object.setConductorCount(line2conductors.get(lineCode).size()); | |
| 257 | + object.setDriverCount(line2drivers.get(lineCode).size()); | |
| 258 | + | |
| 259 | + objects.add(object); | |
| 260 | + } | |
| 261 | + | |
| 262 | + //编程式事务 | |
| 263 | + DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); | |
| 264 | + DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | |
| 265 | + def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | |
| 266 | + TransactionStatus status = tran.getTransaction(def); | |
| 267 | + | |
| 268 | + try { | |
| 269 | + jdbcTemplate.update("delete from control_interface.bsth_t_plan where schedule_date = ?", new Object[]{ dateTime.toString("yyyy-MM-dd") }); | |
| 270 | + jdbcTemplate.batchUpdate("insert into control_interface.bsth_t_plan (line_code, line_name, schedule_date, conductor_count, driver_count) values (?,?,?,?,?)", new BatchPreparedStatementSetter() { | |
| 271 | + @Override | |
| 272 | + public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 273 | + LineServiceConfig object = objects.get(i); | |
| 274 | + ps.setString(1, object.getLineCode()); | |
| 275 | + ps.setString(2, object.getLineName()); | |
| 276 | + ps.setString(3, object.getScheduleDate()); | |
| 277 | + ps.setInt(4, object.getConductorCount()); | |
| 278 | + ps.setInt(5, object.getDriverCount()); | |
| 279 | + } | |
| 280 | + | |
| 281 | + @Override | |
| 282 | + public int getBatchSize() { | |
| 283 | + return objects.size(); | |
| 284 | + } | |
| 285 | + }); | |
| 286 | + tran.commit(status); | |
| 287 | + } catch (Exception e) { | |
| 288 | + tran.rollback(status); | |
| 289 | + } | |
| 290 | + } | |
| 291 | + | |
| 292 | + /** | |
| 293 | + * 实际排班中的线路司售配档数 | |
| 294 | + */ | |
| 295 | + private void realComputation(DateTime dateTime) { | |
| 296 | + // 记录实际线路司售配档情况 | |
| 297 | + List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.findAll(dateTime.toString("yyyy-MM-dd")); | |
| 298 | + Set<String> lineCodes = new HashSet<>(); | |
| 299 | + Map<String, Set<String>> line2conductors = new HashMap<>(), line2drivers = new HashMap<>(), line2cars = new HashMap<>(); | |
| 300 | + final List<LineServiceConfig> objects = new ArrayList<>(); | |
| 301 | + for (ScheduleRealInfo scheduleRealInfo : scheduleRealInfos) { | |
| 302 | + // 烂班班次不计入配档数 | |
| 303 | + if (scheduleRealInfo.getStatus() == -1) { continue; } | |
| 304 | + String lineCode = scheduleRealInfo.getXlBm(); | |
| 305 | + lineCodes.add(lineCode); | |
| 306 | + Set<String> conductors = line2conductors.get(lineCode), drivers = line2drivers.get(lineCode), cars = line2cars.get(lineCode); | |
| 307 | + if (conductors == null) { | |
| 308 | + conductors = new HashSet<>(); | |
| 309 | + line2conductors.put(lineCode, conductors); | |
| 310 | + } | |
| 311 | + if (drivers == null) { | |
| 312 | + drivers = new HashSet<>(); | |
| 313 | + line2drivers.put(lineCode, drivers); | |
| 314 | + } | |
| 315 | + if (cars == null) { | |
| 316 | + cars = new HashSet<>(); | |
| 317 | + line2cars.put(lineCode, cars); | |
| 318 | + } | |
| 319 | + if (!StringUtils.isEmpty(scheduleRealInfo.getsGh())) { | |
| 320 | + conductors.add(scheduleRealInfo.getsGh()); | |
| 321 | + } | |
| 322 | + drivers.add(scheduleRealInfo.getjGh()); | |
| 323 | + cars.add(scheduleRealInfo.getClZbh()); | |
| 324 | + } | |
| 325 | + for (String lineCode : lineCodes) { | |
| 326 | + LineServiceConfig object = new LineServiceConfig(); | |
| 327 | + Line line = LineBufferData.findOne(lineCode); | |
| 328 | + object.setLineCode(lineCode); | |
| 329 | + object.setLineName(line == null ? "" : line.getName()); | |
| 330 | + object.setScheduleDate(dateTime.toString("yyyy-MM-dd")); | |
| 331 | + object.setConductorCount(line2conductors.get(lineCode).size()); | |
| 332 | + object.setDriverCount(line2drivers.get(lineCode).size()); | |
| 333 | + object.setCarCount(line2cars.get(lineCode).size()); | |
| 334 | + | |
| 335 | + objects.add(object); | |
| 336 | + } | |
| 337 | + | |
| 338 | + //编程式事务 | |
| 339 | + DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); | |
| 340 | + DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | |
| 341 | + def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | |
| 342 | + TransactionStatus status = tran.getTransaction(def); | |
| 343 | + try { | |
| 344 | + jdbcTemplate.update("delete from control_interface.bsth_t_real where schedule_date = ?", new Object[]{ dateTime.toString("yyyy-MM-dd") }); | |
| 345 | + jdbcTemplate.batchUpdate("insert into control_interface.bsth_t_real (line_code, line_name, schedule_date, conductor_count, driver_count, car_count) values (?,?,?,?,?,?)", new BatchPreparedStatementSetter() { | |
| 346 | + @Override | |
| 347 | + public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 348 | + LineServiceConfig object = objects.get(i); | |
| 349 | + ps.setString(1, object.getLineCode()); | |
| 350 | + ps.setString(2, object.getLineName()); | |
| 351 | + ps.setString(3, object.getScheduleDate()); | |
| 352 | + ps.setInt(4, object.getConductorCount()); | |
| 353 | + ps.setInt(5, object.getDriverCount()); | |
| 354 | + ps.setInt(6, object.getCarCount()); | |
| 355 | + } | |
| 356 | + | |
| 357 | + @Override | |
| 358 | + public int getBatchSize() { | |
| 359 | + return objects.size(); | |
| 360 | + } | |
| 361 | + }); | |
| 362 | + tran.commit(status); | |
| 363 | + } catch (Exception e) { | |
| 364 | + tran.rollback(status); | |
| 365 | + } | |
| 366 | + } | |
| 367 | + | |
| 368 | + private void carMileageComputation(final DateTime dateTime) { | |
| 369 | + String rq = dateTime.toString("yyyy-MM-dd"); | |
| 370 | + // 实际排班信息 | |
| 371 | + ArrayListMultimap<String, ScheduleRealInfo> nbbm2schedules = scheduleRedisService.findByDate(rq); | |
| 372 | + // 油耗信息 | |
| 373 | + ArrayListMultimap<String, OilInfo> oilInfoMap = oilRedisService.findByNbbmGroup1(nbbm2schedules.keySet(), rq); | |
| 374 | + //电耗信息 | |
| 375 | + ArrayListMultimap<String, ElecInfo> elecInfoMap = elecRedisService.findByNbbmGroup1(nbbm2schedules.keySet(), rq); | |
| 376 | + Set<String> nbbms = nbbm2schedules.keySet(); | |
| 377 | + final List<BusMileage> busMileages = new ArrayList<>(); | |
| 378 | + for (String nbbm : nbbms) { | |
| 379 | + List<ScheduleRealInfo> scheduleRealInfos = nbbm2schedules.get(nbbm); | |
| 380 | + if (scheduleRealInfos.size() == 0) { | |
| 381 | + continue; | |
| 382 | + } | |
| 383 | + BusMileage busMileage = new BusMileage(); | |
| 384 | + busMileage.setScheduleDate(rq); | |
| 385 | + busMileage.setNbbm(nbbm); | |
| 386 | + busMileage.setJhlc(ScheduleCalculator.calcJHLC(scheduleRealInfos)); | |
| 387 | + busMileage.setSjjhlc(ScheduleCalculator.calcSJLC(scheduleRealInfos)); | |
| 388 | + busMileage.setSjcclc(ScheduleCalculator.calcCCLC(scheduleRealInfos)); | |
| 389 | + busMileage.setSjjclc(ScheduleCalculator.calcJCLC(scheduleRealInfos)); | |
| 390 | + busMileage.setYylc(ScheduleCalculator.calcYYLC(scheduleRealInfos)); | |
| 391 | + busMileage.setKslc(ScheduleCalculator.calcKSLC(scheduleRealInfos)); | |
| 392 | + busMileage.setCjlc(ScheduleCalculator.calcCJLC(scheduleRealInfos)); | |
| 393 | + busMileage.setLblc(ScheduleCalculator.calcLBLC(scheduleRealInfos)); | |
| 394 | + busMileage.setZjlc(ScheduleCalculator.calcZJLC(scheduleRealInfos)); | |
| 395 | + busMileage.setZlc(ScheduleCalculator.calcZLC(scheduleRealInfos)); | |
| 396 | + busMileage.setCompany(scheduleRealInfos.get(0).getGsName()); | |
| 397 | + busMileage.setCompanyCode(scheduleRealInfos.get(0).getGsBm()); | |
| 398 | + List<OilInfo> oilInfos = oilInfoMap.get(nbbm); | |
| 399 | + List<ElecInfo> elecInfos = elecInfoMap.get(nbbm); | |
| 400 | + Double yh = 0.0, dh = 0.0; | |
| 401 | + for (OilInfo oilInfo : oilInfos) { | |
| 402 | + yh = Arith.add(yh, oilInfo.getYh()); | |
| 403 | + } | |
| 404 | + for (ElecInfo elecInfo : elecInfos) { | |
| 405 | + dh = Arith.add(yh, elecInfo.getHd()); | |
| 406 | + } | |
| 407 | + busMileage.setYh(yh); | |
| 408 | + busMileage.setDh(dh); | |
| 409 | + | |
| 410 | + busMileages.add(busMileage); | |
| 411 | + } | |
| 412 | + | |
| 413 | + //编程式事务 | |
| 414 | + DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); | |
| 415 | + DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | |
| 416 | + def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | |
| 417 | + TransactionStatus status = tran.getTransaction(def); | |
| 418 | + try { | |
| 419 | + jdbcTemplate.update("delete from control_interface.bsth_t_mileage where schedule_date = ?", new Object[]{ dateTime.toString("yyyy-MM-dd") }); | |
| 420 | + jdbcTemplate.batchUpdate("insert into control_interface.bsth_t_mileage (schedule_date,nbbm,jhlc,sjjhlc,sjcclc,sjjclc,yylc,kslc,cjlc,lblc,zjlc,zlc,yh,dh,schedule_month,company,company_code) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", new BatchPreparedStatementSetter() { | |
| 421 | + @Override | |
| 422 | + public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 423 | + BusMileage busMileage = busMileages.get(i); | |
| 424 | + ps.setString(1, busMileage.getScheduleDate()); | |
| 425 | + ps.setString(2, busMileage.getNbbm()); | |
| 426 | + ps.setDouble(3, busMileage.getJhlc()); | |
| 427 | + ps.setDouble(4, busMileage.getSjjhlc()); | |
| 428 | + ps.setDouble(5, busMileage.getSjcclc()); | |
| 429 | + ps.setDouble(6, busMileage.getSjjclc()); | |
| 430 | + ps.setDouble(7, busMileage.getYylc()); | |
| 431 | + ps.setDouble(8, busMileage.getKslc()); | |
| 432 | + ps.setDouble(9, busMileage.getCjlc()); | |
| 433 | + ps.setDouble(10, busMileage.getLblc()); | |
| 434 | + ps.setDouble(11, busMileage.getZjlc()); | |
| 435 | + ps.setDouble(12, busMileage.getZlc()); | |
| 436 | + ps.setDouble(13, busMileage.getYh()); | |
| 437 | + ps.setDouble(14, busMileage.getDh()); | |
| 438 | + ps.setString(15, dateTime.toString("yyyy-MM")); | |
| 439 | + ps.setString(16, busMileage.getCompany()); | |
| 440 | + ps.setString(17, busMileage.getCompanyCode()); | |
| 441 | + } | |
| 442 | + | |
| 443 | + @Override | |
| 444 | + public int getBatchSize() { | |
| 445 | + return busMileages.size(); | |
| 446 | + } | |
| 447 | + }); | |
| 448 | + tran.commit(status); | |
| 449 | + } catch (Exception e) { | |
| 450 | + tran.rollback(status); | |
| 451 | + } | |
| 452 | + } | |
| 453 | + | |
| 454 | + /** | |
| 455 | + * 线路司售配档对象 | |
| 456 | + */ | |
| 457 | + private final static class LineServiceConfigVo { | |
| 458 | + | |
| 459 | + private String lineName; | |
| 460 | + | |
| 461 | + private String month; | |
| 462 | + | |
| 463 | + private Integer driverFirstCount; | |
| 464 | + | |
| 465 | + private Integer driverLastCount; | |
| 466 | + | |
| 467 | + private Integer conductorFirstCount; | |
| 468 | + | |
| 469 | + private Integer conductorLastCount; | |
| 470 | + | |
| 471 | + public String getLineName() { | |
| 472 | + return lineName; | |
| 473 | + } | |
| 474 | + | |
| 475 | + public void setLineName(String lineName) { | |
| 476 | + this.lineName = lineName; | |
| 477 | + } | |
| 478 | + | |
| 479 | + public String getMonth() { | |
| 480 | + return month; | |
| 481 | + } | |
| 482 | + | |
| 483 | + public void setMonth(String month) { | |
| 484 | + this.month = month; | |
| 485 | + } | |
| 486 | + | |
| 487 | + public Integer getDriverFirstCount() { | |
| 488 | + return driverFirstCount; | |
| 489 | + } | |
| 490 | + | |
| 491 | + public void setDriverFirstCount(Integer driverFirstCount) { | |
| 492 | + this.driverFirstCount = driverFirstCount; | |
| 493 | + } | |
| 494 | + | |
| 495 | + public Integer getDriverLastCount() { | |
| 496 | + return driverLastCount; | |
| 497 | + } | |
| 498 | + | |
| 499 | + public void setDriverLastCount(Integer driverLastCount) { | |
| 500 | + this.driverLastCount = driverLastCount; | |
| 501 | + } | |
| 502 | + | |
| 503 | + public Integer getConductorFirstCount() { | |
| 504 | + return conductorFirstCount; | |
| 505 | + } | |
| 506 | + | |
| 507 | + public void setConductorFirstCount(Integer conductorFirstCount) { | |
| 508 | + this.conductorFirstCount = conductorFirstCount; | |
| 509 | + } | |
| 510 | + | |
| 511 | + public Integer getConductorLastCount() { | |
| 512 | + return conductorLastCount; | |
| 513 | + } | |
| 514 | + | |
| 515 | + public void setConductorLastCount(Integer conductorLastCount) { | |
| 516 | + this.conductorLastCount = conductorLastCount; | |
| 517 | + } | |
| 518 | + } | |
| 519 | + | |
| 520 | + /** | |
| 521 | + * 车辆配档对象 | |
| 522 | + */ | |
| 523 | + private final static class BusVo { | |
| 524 | + | |
| 525 | + private String lineName; | |
| 526 | + | |
| 527 | + private String month; | |
| 528 | + | |
| 529 | + private Integer busFirstCount; | |
| 530 | + | |
| 531 | + private Integer busLastCount; | |
| 532 | + | |
| 533 | + private Integer busMaxCount; | |
| 534 | + | |
| 535 | + public String getLineName() { | |
| 536 | + return lineName; | |
| 537 | + } | |
| 538 | + | |
| 539 | + public void setLineName(String lineName) { | |
| 540 | + this.lineName = lineName; | |
| 541 | + } | |
| 542 | + | |
| 543 | + public String getMonth() { | |
| 544 | + return month; | |
| 545 | + } | |
| 546 | + | |
| 547 | + public void setMonth(String month) { | |
| 548 | + this.month = month; | |
| 549 | + } | |
| 550 | + | |
| 551 | + public Integer getBusFirstCount() { | |
| 552 | + return busFirstCount; | |
| 553 | + } | |
| 554 | + | |
| 555 | + public void setBusFirstCount(Integer busFirstCount) { | |
| 556 | + this.busFirstCount = busFirstCount; | |
| 557 | + } | |
| 558 | + | |
| 559 | + public Integer getBusLastCount() { | |
| 560 | + return busLastCount; | |
| 561 | + } | |
| 562 | + | |
| 563 | + public void setBusLastCount(Integer busLastCount) { | |
| 564 | + this.busLastCount = busLastCount; | |
| 565 | + } | |
| 566 | + | |
| 567 | + public Integer getBusMaxCount() { | |
| 568 | + return busMaxCount; | |
| 569 | + } | |
| 570 | + | |
| 571 | + public void setBusMaxCount(Integer busMaxCount) { | |
| 572 | + this.busMaxCount = busMaxCount; | |
| 573 | + } | |
| 574 | + } | |
| 575 | + | |
| 576 | + /** | |
| 577 | + * 车辆公里、油耗对象 | |
| 578 | + */ | |
| 579 | + private final static class BusMileageVo { | |
| 580 | + | |
| 581 | + private String insideCode; | |
| 582 | + | |
| 583 | + private String month; | |
| 584 | + | |
| 585 | + private Double totalMileage; | |
| 586 | + | |
| 587 | + private Double oilConsume; | |
| 588 | + | |
| 589 | + private Double electricConsume; | |
| 590 | + | |
| 591 | + /** | |
| 592 | + * | |
| 593 | + */ | |
| 594 | + private String company; | |
| 595 | + | |
| 596 | + /** | |
| 597 | + * | |
| 598 | + */ | |
| 599 | + private String companyCode; | |
| 600 | + | |
| 601 | + public String getInsideCode() { | |
| 602 | + return insideCode; | |
| 603 | + } | |
| 604 | + | |
| 605 | + public void setInsideCode(String insideCode) { | |
| 606 | + this.insideCode = insideCode; | |
| 607 | + } | |
| 608 | + | |
| 609 | + public String getMonth() { | |
| 610 | + return month; | |
| 611 | + } | |
| 612 | + | |
| 613 | + public void setMonth(String month) { | |
| 614 | + this.month = month; | |
| 615 | + } | |
| 616 | + | |
| 617 | + public Double getTotalMileage() { | |
| 618 | + return totalMileage; | |
| 619 | + } | |
| 620 | + | |
| 621 | + public void setTotalMileage(Double totalMileage) { | |
| 622 | + this.totalMileage = totalMileage; | |
| 623 | + } | |
| 624 | + | |
| 625 | + public Double getOilConsume() { | |
| 626 | + return oilConsume; | |
| 627 | + } | |
| 628 | + | |
| 629 | + public void setOilConsume(Double oilConsume) { | |
| 630 | + this.oilConsume = oilConsume; | |
| 631 | + } | |
| 632 | + | |
| 633 | + public Double getElectricConsume() { | |
| 634 | + return electricConsume; | |
| 635 | + } | |
| 636 | + | |
| 637 | + public void setElectricConsume(Double electricConsume) { | |
| 638 | + this.electricConsume = electricConsume; | |
| 639 | + } | |
| 640 | + | |
| 641 | + public String getCompany() { | |
| 642 | + return company; | |
| 643 | + } | |
| 644 | + | |
| 645 | + public void setCompany(String company) { | |
| 646 | + this.company = company; | |
| 647 | + } | |
| 648 | + | |
| 649 | + public String getCompanyCode() { | |
| 650 | + return companyCode; | |
| 651 | + } | |
| 652 | + | |
| 653 | + public void setCompanyCode(String companyCode) { | |
| 654 | + this.companyCode = companyCode; | |
| 655 | + } | |
| 656 | + } | |
| 657 | +} | ... | ... |