Commit d525d33cb7fbe3af44e9a0351f31e083c267df17

Authored by 徐烜
1 parent 7faaa175

嘉定公交调度系统计划调度功能优化3

1、完成前置时刻表信息验证
2、时刻表测试框架建立,完成前置时刻表信息验证测试用例
Showing 29 changed files with 4792 additions and 2 deletions

Too many changes to show.

To preserve performance only 29 of 53 files are displayed.

@@ -34,7 +34,7 @@ @@ -34,7 +34,7 @@
34 <groupId>org.springframework.boot</groupId> 34 <groupId>org.springframework.boot</groupId>
35 <artifactId>spring-boot-starter-security</artifactId> 35 <artifactId>spring-boot-starter-security</artifactId>
36 </dependency> 36 </dependency>
37 - <!-- <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-config</artifactId> 37 + <!-- <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-config</artifactId>
38 </dependency> --> 38 </dependency> -->
39 <dependency> 39 <dependency>
40 <groupId>org.springframework.boot</groupId> 40 <groupId>org.springframework.boot</groupId>
@@ -302,7 +302,15 @@ @@ -302,7 +302,15 @@
302 <artifactId>plan_module-common</artifactId> 302 <artifactId>plan_module-common</artifactId>
303 <version>1.0-SNAPSHOT</version> 303 <version>1.0-SNAPSHOT</version>
304 </dependency> 304 </dependency>
305 - </dependencies> 305 +
  306 + <!-- lombok依赖 -->
  307 + <dependency>
  308 + <groupId>org.projectlombok</groupId>
  309 + <artifactId>lombok</artifactId>
  310 + <version>1.16.22</version>
  311 + </dependency>
  312 +
  313 + </dependencies>
306 314
307 <dependencyManagement> 315 <dependencyManagement>
308 <dependencies> 316 <dependencies>
src/main/java/com/bsth/service/schedule/plan/PlanConfig.java 0 → 100644
  1 +package com.bsth.service.schedule.plan;
  2 +
  3 +import org.kie.api.KieBase;
  4 +import org.kie.api.KieBaseConfiguration;
  5 +import org.kie.api.KieServices;
  6 +import org.kie.api.builder.*;
  7 +import org.kie.api.builder.model.KieBaseModel;
  8 +import org.kie.api.builder.model.KieModuleModel;
  9 +import org.kie.api.builder.model.KieSessionModel;
  10 +import org.kie.api.conf.EqualityBehaviorOption;
  11 +import org.kie.api.conf.EventProcessingOption;
  12 +import org.kie.api.runtime.KieContainer;
  13 +import org.kie.api.runtime.conf.ClockTypeOption;
  14 +import org.kie.internal.io.ResourceFactory;
  15 +import org.slf4j.Logger;
  16 +import org.slf4j.LoggerFactory;
  17 +import org.springframework.beans.factory.annotation.Autowired;
  18 +import org.springframework.boot.context.properties.EnableConfigurationProperties;
  19 +import org.springframework.context.annotation.Bean;
  20 +import org.springframework.context.annotation.Configuration;
  21 +
  22 +/**
  23 + * 计划配置类。
  24 + */
  25 +@Configuration
  26 +@EnableConfigurationProperties(PlanConfigProperties.class)
  27 +public class PlanConfig {
  28 + /** 日志记录器 */
  29 + private static final Logger LOGGER = LoggerFactory.getLogger(PlanConfig.class);
  30 +
  31 + /** 计划配置文件 */
  32 + @Autowired
  33 + private PlanConfigProperties planConfigProperties;
  34 +
  35 + /**
  36 + * 验证时刻表kieBase。
  37 + * @return
  38 + */
  39 + @Bean(name = "kBaseValidateTimetable")
  40 + public KieBase kBaseValidateTimetable() {
  41 + KieBase kieBase = this.generateKieBase(
  42 + "kBaseValidateTimetable",
  43 + new String[] {this.planConfigProperties.getValidateTimetable()}
  44 + );
  45 + LOGGER.info("初始化 KieBase[{}]成功", "前置验证相关时刻表信息");
  46 + return kieBase;
  47 + }
  48 +
  49 + /**
  50 + * 生成KieBase。
  51 + * @param kBaseName kBase名字
  52 + * @param drlClasspaths 规则类路径
  53 + */
  54 + private KieBase generateKieBase(String kBaseName, String[] drlClasspaths) {
  55 + // Drools 6开始引入kie统一接口(jboss的jbpm工作流也使用kie接口了),整个定义方式和5差别很大
  56 + // 这里使用全api方式配置知识库对象,不使用xml的方式,提供最大的灵活性
  57 +
  58 + // 1、创建kieservices
  59 + KieServices kieServices = KieServices.Factory.get();
  60 +
  61 + // 2、创建KieModuleModel,默认是由kmodule.xml的方式创建,这里使用api方式闯将
  62 + KieModuleModel kieModuleModel = kieServices.newKieModuleModel();
  63 + // 2.1、创建KieBaseModel,类似kmodule.xml中的kbase标签
  64 + KieBaseModel kieBaseModel1 = kieModuleModel.newKieBaseModel(kBaseName)
  65 + .setDefault(true)
  66 + .setEqualsBehavior(EqualityBehaviorOption.EQUALITY)
  67 + .setEventProcessingMode(EventProcessingOption.STREAM);
  68 + // 2.2、创建与kbase关联的KieSessionModel,类似kmodule.xml中的kbase内的ksession标签
  69 + kieBaseModel1.newKieSessionModel("KSession1")
  70 + .setDefault(true)
  71 + .setType(KieSessionModel.KieSessionType.STATEFUL)
  72 + .setClockType(ClockTypeOption.get("realtime"));
  73 +
  74 + // 3、创建KieFileSystem,将模型xml,drl等写入,TODO:以后考虑从数据库中获取
  75 + KieFileSystem kfs = kieServices.newKieFileSystem();
  76 + // 3.1、写入KieBaseModel(内部包含了KieSessionModel的内容了,注意之前的KieSessionModel的创建方式)
  77 + kfs.writeKModuleXML(kieModuleModel.toXML());
  78 + // 3.2、写入drl
  79 + // 这里使用文件的形式写入,TODO:以后考虑从数据库中读drl写入
  80 + // 注意kfs写的时候如果指定path,强制为src/main/resources/加上文件名,还有就是文件名不要重复否则会覆盖的
  81 +// kfs.write(ResourceFactory.newFileResource(new File(rules_root_path + kbase_validate_timetable_drl)));
  82 + for (String drlClasspath : drlClasspaths) {
  83 + kfs.write(ResourceFactory.newClassPathResource(drlClasspath));
  84 + }
  85 +
  86 + // 4、创建KieBuilder,使用KieFileSystem构建
  87 + KieBuilder kieBuilder = kieServices.newKieBuilder(kfs).buildAll();
  88 + Results results = kieBuilder.getResults();
  89 + if (results.hasMessages(Message.Level.ERROR))
  90 + throw new IllegalStateException("构建drools6错误:" + results.getMessages());
  91 +
  92 + // 5、获取KieContainer
  93 + // TODO:ReleaseId用处很大,以后再议
  94 + ReleaseId releaseId = kieServices.getRepository().getDefaultReleaseId();
  95 + KieContainer kieContainer = kieServices.newKieContainer(releaseId);
  96 +
  97 + // 6、创建kbase
  98 + KieBaseConfiguration kieBaseConfiguration = kieServices.newKieBaseConfiguration();
  99 + KieBase kieBase = kieContainer.newKieBase(kBaseName, kieBaseConfiguration);
  100 +
  101 + return kieBase;
  102 + }
  103 +}
src/main/java/com/bsth/service/schedule/plan/PlanConfigProperties.java 0 → 100644
  1 +package com.bsth.service.schedule.plan;
  2 +
  3 +import org.springframework.boot.context.properties.ConfigurationProperties;
  4 +
  5 +import javax.validation.constraints.NotNull;
  6 +
  7 +/**
  8 + * 排班计划相关配置文件。
  9 + */
  10 +@ConfigurationProperties(
  11 + locations = "classpath:drools/config.properties",
  12 + ignoreInvalidFields = true,
  13 + prefix = "drools.KBase"
  14 +)
  15 +public class PlanConfigProperties {
  16 +
  17 + /** 排班前置验证规则(时刻表)*/
  18 + @NotNull
  19 + private String validateTimetable;
  20 +
  21 + public String getValidateTimetable() {
  22 + return validateTimetable;
  23 + }
  24 +
  25 + public void setValidateTimetable(String validateTimetable) {
  26 + this.validateTimetable = validateTimetable;
  27 + }
  28 +}
src/main/java/com/bsth/service/schedule/plan/process/_1_validate/_1_timetable/PlanProcessValidateTimetableService.java 0 → 100644
  1 +package com.bsth.service.schedule.plan.process._1_validate._1_timetable;
  2 +
  3 +import com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools.KBaseValidateTimeTable_Result;
  4 +
  5 +import java.util.Date;
  6 +
  7 +/**
  8 + * 验证时刻表服务。
  9 + */
  10 +public interface PlanProcessValidateTimetableService {
  11 + /**
  12 + * 验证关联的时刻表信息。
  13 + * @param xlid 线路Id
  14 + * @param from 排班计划开始时间
  15 + * @param to 排班计划结束时间
  16 + * @return 验证输出
  17 + */
  18 + KBaseValidateTimeTable_Result validateTTInfovalidateTTInfo(Integer xlid, Date from, Date to);
  19 +}
src/main/java/com/bsth/service/schedule/plan/process/_1_validate/_1_timetable/PlanProcessValidateTimetableServiceDroolsImpl.java 0 → 100644
  1 +package com.bsth.service.schedule.plan.process._1_validate._1_timetable;
  2 +
  3 +import com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools.*;
  4 +import org.joda.time.DateTime;
  5 +import org.kie.api.KieBase;
  6 +import org.kie.api.runtime.KieSession;
  7 +import org.slf4j.Logger;
  8 +import org.slf4j.LoggerFactory;
  9 +import org.springframework.jdbc.core.JdbcTemplate;
  10 +import org.springframework.jdbc.core.RowMapper;
  11 +import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
  12 +
  13 +import java.sql.ResultSet;
  14 +import java.sql.SQLException;
  15 +import java.util.*;
  16 +
  17 +/**
  18 + * 验证时刻表服务drools实现。
  19 + */
  20 +public class PlanProcessValidateTimetableServiceDroolsImpl implements PlanProcessValidateTimetableService {
  21 + /** 日志记录器 */
  22 + private static final Logger LOGGER = LoggerFactory.getLogger(PlanProcessValidateTimetableServiceDroolsImpl.class);
  23 +
  24 + /** 验证时刻表drools kbase */
  25 + private KieBase validateTimetableKBase;
  26 +
  27 + /** 使用的jdbc服务 */
  28 + private JdbcTemplate jdbcTemplate;
  29 +
  30 + /** 线路查询SQL */
  31 + private static final String LINE_QUERY_SQL =
  32 + "select id, name from bsth_c_line line where line.id = ? and destroy = 0";
  33 + /** 时刻表查询SQL */
  34 + private static final String TTINFO_QUERY_SQL =
  35 + "select id, name, rule_days, special_days, line_version " +
  36 + "from bsth_c_s_ttinfo ttinfo " +
  37 + "where ttinfo.is_cancel = 0 and ttinfo.is_enable_dis_template = 1 and ttinfo.xl = ?";
  38 + /** 时刻表明细查询SQL(使用 NamedParameterJdbcTemplate) */
  39 + private static final String TTINFO_DETAIL_QUERY_SQL =
  40 + "select id, qdz_code, qdz_name, zdz_code, zdz_name, ttinfo, line_version, bc_type, bcsj " +
  41 + "from bsth_c_s_ttinfo_detail td " +
  42 + "where td.ttinfo in (:ttInfoIds)";
  43 +
  44 + @Override
  45 + public KBaseValidateTimeTable_Result validateTTInfovalidateTTInfo(final Integer xlid, Date from, Date to) {
  46 + LOGGER.info("KieBase[{}],线路id={},开始日期={},结束日期={} 开始验证",
  47 + "前置验证相关时刻表信息", xlid, from, to);
  48 +
  49 + // 构造drools session->载入数据->启动规则->计算->销毁session
  50 + // 创建session,内部配置的是stateful
  51 + KieSession session = validateTimetableKBase.newKieSession();
  52 + // 设置gloable对象,在drl中通过别名使用
  53 + session.setGlobal("LOGGER", LOGGER);
  54 +
  55 + KBaseValidateTimeTable_Result rs = new KBaseValidateTimeTable_Result(); // 输出gloable对象
  56 + session.setGlobal("rs", rs);
  57 +
  58 + // 载入数据,参数数据,线路数据,时刻表数据,时刻表明细数据
  59 + KBaseValidateTimeTable_Fact_CalcuParam calcuParam = new KBaseValidateTimeTable_Fact_CalcuParam(
  60 + new DateTime(from), new DateTime(to), xlid);
  61 + session.insert(calcuParam);
  62 +
  63 + // 载入线路dto
  64 + List<KBaseValidateTimeTable_Fact_Line> fact_lines = jdbcTemplate.query(
  65 + LINE_QUERY_SQL,
  66 + new Object[] {xlid},
  67 + new RowMapper<KBaseValidateTimeTable_Fact_Line>() {
  68 + @Override
  69 + public KBaseValidateTimeTable_Fact_Line mapRow(ResultSet rs, int rowNum) throws SQLException {
  70 + return KBaseValidateTimeTable_Fact_Line.builder()
  71 + .id(rs.getInt("id"))
  72 + .name(rs.getString("name"))
  73 + .build();
  74 + }
  75 + });
  76 + if (fact_lines.size() > 0) {
  77 + session.insert(fact_lines.get(0));
  78 + }
  79 +
  80 + // 载入时刻表dto
  81 + List<KBaseValidateTimeTable_Fact_TTInfo> fact_ttInfos = jdbcTemplate.query(
  82 + TTINFO_QUERY_SQL,
  83 + new Object[] {xlid},
  84 + new RowMapper<KBaseValidateTimeTable_Fact_TTInfo>() {
  85 + @Override
  86 + public KBaseValidateTimeTable_Fact_TTInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
  87 + return KBaseValidateTimeTable_Fact_TTInfo.getBuilder()
  88 + .setId(rs.getLong("id"))
  89 + .setName(rs.getString("name"))
  90 + .setRule_days(rs.getString("rule_days"))
  91 + .setWeekdayList(rs.getString("rule_days"))
  92 + .setSpecial_days(rs.getString("special_days"))
  93 + .setSpecialDayList(rs.getString("special_days"))
  94 + .setLineVersion(rs.getInt("line_version"))
  95 + .setXl(KBaseValidateTimeTable_Fact_Line.builder().id(xlid).build())
  96 + .build();
  97 + }
  98 + });
  99 + for (KBaseValidateTimeTable_Fact_TTInfo fact_ttInfo : fact_ttInfos) {
  100 + session.insert(fact_ttInfo);
  101 + }
  102 +
  103 + // 载入时刻表明细dto
  104 + Map<String, Object> param = new HashMap<>();
  105 + List<Long> ttInfoIds = new ArrayList<>();
  106 + param.put("ttInfoIds", ttInfoIds);
  107 + for (KBaseValidateTimeTable_Fact_TTInfo fact_ttInfo : fact_ttInfos) {
  108 + ttInfoIds.add(fact_ttInfo.getId());
  109 + }
  110 + if (ttInfoIds.size() > 0) {
  111 + NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
  112 + List<KBaseValidateTimeTable_Fact_TTInfoDetail> fact_ttInfoDetails = namedParameterJdbcTemplate.query(
  113 + TTINFO_DETAIL_QUERY_SQL,
  114 + param,
  115 + new RowMapper<KBaseValidateTimeTable_Fact_TTInfoDetail>() {
  116 + @Override
  117 + public KBaseValidateTimeTable_Fact_TTInfoDetail mapRow(ResultSet rs, int rowNum) throws SQLException {
  118 + return KBaseValidateTimeTable_Fact_TTInfoDetail.builder()
  119 + .id(rs.getLong("id"))
  120 + .qdzCode(rs.getString("qdz_code"))
  121 + .qdzName(rs.getString("qdz_name"))
  122 + .zdzCode(rs.getString("zdz_code"))
  123 + .zdzName(rs.getString("zdz_name"))
  124 + .ttinfo(KBaseValidateTimeTable_Fact_TTInfo.getBuilder().setId(rs.getLong("ttinfo")).build())
  125 + .lineVersion(rs.getInt("line_version"))
  126 + .bcType(rs.getString("bc_type"))
  127 + .bcsj(rs.getInt("bcsj"))
  128 + .build();
  129 + }
  130 + });
  131 + for (KBaseValidateTimeTable_Fact_TTInfoDetail fact_ttInfoDetail : fact_ttInfoDetails) {
  132 + session.insert(fact_ttInfoDetail);
  133 + }
  134 + }
  135 +
  136 + // 执行rule
  137 + session.fireAllRules();
  138 +
  139 + // 执行完毕销毁,有日志的也要关闭
  140 + session.dispose();
  141 +
  142 + LOGGER.info("KieBase[{}],线路id={},开始日期={},结束日期={} 完成验证",
  143 + "前置验证相关时刻表信息", xlid, from, to);
  144 +
  145 + return rs;
  146 + }
  147 +
  148 + private PlanProcessValidateTimetableServiceDroolsImpl() {}
  149 + private PlanProcessValidateTimetableServiceDroolsImpl(Builder builder) {
  150 + this.validateTimetableKBase = builder.validateTimetableKBase;
  151 + this.jdbcTemplate = builder.jdbcTemplate;
  152 +
  153 + }
  154 +
  155 + public static Builder getBuilder() {
  156 + return new Builder();
  157 + }
  158 +
  159 + public static class Builder {
  160 + /** 验证时刻表drools kbase */
  161 + private KieBase validateTimetableKBase;
  162 +
  163 + /** 使用的jdbc服务 */
  164 + private JdbcTemplate jdbcTemplate;
  165 +
  166 + public Builder setValidateTimetableKBase(KieBase validateTimetableKBase) {
  167 + this.validateTimetableKBase = validateTimetableKBase;
  168 + return this;
  169 + }
  170 +
  171 + public Builder setJdbcTemplate(JdbcTemplate jdbcTemplate) {
  172 + this.jdbcTemplate = jdbcTemplate;
  173 + return this;
  174 + }
  175 +
  176 + public PlanProcessValidateTimetableServiceDroolsImpl build() {
  177 + return new PlanProcessValidateTimetableServiceDroolsImpl(this);
  178 + }
  179 + }
  180 +}
src/main/java/com/bsth/service/schedule/plan/process/_1_validate/_1_timetable/drools/KBaseValidateTimeTable_Fact_CalcuParam.java 0 → 100644
  1 +package com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools;
  2 +
  3 +import lombok.AllArgsConstructor;
  4 +import lombok.Builder;
  5 +import lombok.Data;
  6 +import org.joda.time.DateTime;
  7 +
  8 +/**
  9 + * drools规则验证时刻表使用的参数fact对象。
  10 + */
  11 +@Data
  12 +@Builder
  13 +@AllArgsConstructor
  14 +public class KBaseValidateTimeTable_Fact_CalcuParam {
  15 + /** 开始计算时间 */
  16 + private DateTime fromDate;
  17 + /** 结束计算时间 */
  18 + private DateTime toDate;
  19 + /** 线路id */
  20 + private Integer xlId;
  21 +
  22 +}
src/main/java/com/bsth/service/schedule/plan/process/_1_validate/_1_timetable/drools/KBaseValidateTimeTable_Fact_Line.java 0 → 100644
  1 +package com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools;
  2 +
  3 +import lombok.AllArgsConstructor;
  4 +import lombok.Builder;
  5 +import lombok.Data;
  6 +
  7 +/**
  8 + * drools规则验证时刻表使用的线路fact对象。
  9 + */
  10 +@Data
  11 +@Builder
  12 +@AllArgsConstructor
  13 +public class KBaseValidateTimeTable_Fact_Line {
  14 + /** 主键id */
  15 + private Integer id;
  16 + /** 线路名称 */
  17 + private String name;
  18 +}
src/main/java/com/bsth/service/schedule/plan/process/_1_validate/_1_timetable/drools/KBaseValidateTimeTable_Fact_TTInfo.java 0 → 100644
  1 +package com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools;
  2 +
  3 +import org.apache.commons.lang3.StringUtils;
  4 +import org.apache.commons.lang3.time.DateFormatUtils;
  5 +import org.joda.time.DateTime;
  6 +
  7 +import java.text.ParseException;
  8 +import java.util.ArrayList;
  9 +import java.util.List;
  10 +
  11 +/**
  12 + * drools规则验证时刻表使用的时刻表fact对象。
  13 + */
  14 +public class KBaseValidateTimeTable_Fact_TTInfo {
  15 + /** 主键Id */
  16 + private Long id;
  17 +
  18 + /** 线路关联 */
  19 + private KBaseValidateTimeTable_Fact_Line xl;
  20 +
  21 + /** 时刻表名称 */
  22 + private String name;
  23 +
  24 + // TODO:原系统里的分别在,圈后圈进场,意思不知道,再议
  25 +
  26 + /** 常规有效日(1-7表示星期一到星期日,多个用逗号隔开) */
  27 + private String rule_days;
  28 + /** 特殊有效日期(格式:2001-01-01,多个用逗号隔开) */
  29 + private String special_days;
  30 +
  31 + /** 常规有效日(参照rule_days,1=true表示启用,0=false表示未启用,一个星期7天,保存7个元素) */
  32 + private List<Boolean> weekdayList = new ArrayList<>();
  33 + /** 特殊有效日期(参照special_days,1个日期保存1个元素) */
  34 + private List<DateTime> specialDayList = new ArrayList<>();
  35 +
  36 + /** 线路版本(bsth_c_line_versions表对应字段) */
  37 + private int lineVersion;
  38 +
  39 + public Long getId() {
  40 + return id;
  41 + }
  42 +
  43 + public void setId(Long id) {
  44 + this.id = id;
  45 + }
  46 +
  47 + public KBaseValidateTimeTable_Fact_Line getXl() {
  48 + return xl;
  49 + }
  50 +
  51 + public void setXl(KBaseValidateTimeTable_Fact_Line xl) {
  52 + this.xl = xl;
  53 + }
  54 +
  55 + public String getName() {
  56 + return name;
  57 + }
  58 +
  59 + public void setName(String name) {
  60 + this.name = name;
  61 + }
  62 +
  63 + public String getRule_days() {
  64 + return rule_days;
  65 + }
  66 +
  67 + public void setRule_days(String rule_days) {
  68 + this.rule_days = rule_days;
  69 + }
  70 +
  71 + public String getSpecial_days() {
  72 + return special_days;
  73 + }
  74 +
  75 + public void setSpecial_days(String special_days) {
  76 + this.special_days = special_days;
  77 + }
  78 +
  79 + public List<Boolean> getWeekdayList() {
  80 + return weekdayList;
  81 + }
  82 +
  83 + public void setWeekdayList(List<Boolean> weekdayList) {
  84 + this.weekdayList = weekdayList;
  85 + }
  86 +
  87 + public List<DateTime> getSpecialDayList() {
  88 + return specialDayList;
  89 + }
  90 +
  91 + public void setSpecialDayList(List<DateTime> specialDayList) {
  92 + this.specialDayList = specialDayList;
  93 + }
  94 +
  95 + public int getLineVersion() {
  96 + return lineVersion;
  97 + }
  98 +
  99 + public void setLineVersion(int lineVersion) {
  100 + this.lineVersion = lineVersion;
  101 + }
  102 +
  103 + public KBaseValidateTimeTable_Fact_TTInfo(Builder builder) {
  104 + this.id = builder.id;
  105 +
  106 + this.xl = builder.xl;
  107 +
  108 + this.name = builder.name;
  109 +
  110 + this.rule_days = builder.rule_days;
  111 + this.special_days = builder.special_days;
  112 + this.weekdayList = builder.weekdayList;
  113 + this.specialDayList = builder.specialDayList;
  114 +
  115 + this.lineVersion = builder.lineVersion;
  116 +
  117 + }
  118 +
  119 + //------------------- builder模式 -----------------//
  120 + public static Builder getBuilder() {
  121 + return new Builder();
  122 + }
  123 + public static class Builder {
  124 + /** 主键Id */
  125 + private Long id;
  126 +
  127 + /** 线路关联 */
  128 + private KBaseValidateTimeTable_Fact_Line xl;
  129 +
  130 + /** 时刻表名称 */
  131 + private String name;
  132 +
  133 + // TODO:原系统里的分别在,圈后圈进场,意思不知道,再议
  134 +
  135 + /** 常规有效日(1-7表示星期一到星期日,多个用逗号隔开) */
  136 + private String rule_days;
  137 + /** 特殊有效日期(格式:2001-01-01,多个用逗号隔开) */
  138 + private String special_days;
  139 +
  140 + /** 常规有效日(参照rule_days,1=true表示启用,0=false表示未启用,一个星期7天,保存7个元素) */
  141 + private List<Boolean> weekdayList = new ArrayList<>();
  142 + /** 特殊有效日期(参照special_days,1个日期保存1个元素) */
  143 + private List<DateTime> specialDayList = new ArrayList<>();
  144 +
  145 + /** 线路版本(bsth_c_line_versions表对应字段) */
  146 + private int lineVersion;
  147 +
  148 + public Builder() {
  149 + // 初始化 weekdayList,7个元素为FALSE
  150 + for (int i = 0; i < 7; i++) {
  151 + this.weekdayList.add(Boolean.FALSE);
  152 + }
  153 + }
  154 +
  155 + public Builder setId(Long id) {
  156 + this.id = id;
  157 + return this;
  158 + }
  159 +
  160 + public Builder setXl(KBaseValidateTimeTable_Fact_Line xl) {
  161 + this.xl = xl;
  162 + return this;
  163 + }
  164 +
  165 + public Builder setName(String name) {
  166 + this.name = name;
  167 + return this;
  168 + }
  169 +
  170 + public Builder setRule_days(String rule_days) {
  171 + this.rule_days = rule_days;
  172 + return this;
  173 + }
  174 +
  175 + public Builder setSpecial_days(String special_days) {
  176 + this.special_days = special_days;
  177 + return this;
  178 + }
  179 +
  180 + public Builder setWeekdayList(String rule_days) {
  181 + // 初始化weekday,全false
  182 + this.weekdayList = new ArrayList<>(7);
  183 + for (int i = 0; i < 7; i++) {
  184 + this.weekdayList.add(Boolean.FALSE);
  185 + }
  186 + // 1表示工作,其他表示不工作
  187 + if (StringUtils.isNotEmpty(rule_days)) {
  188 + String[] days = rule_days.split(",");
  189 + for (int i = 0; i < 7 && i < days.length; i++) {
  190 + if ("1".equals(days[i])) {
  191 + this.weekdayList.set(i, Boolean.TRUE);
  192 + } else {
  193 + this.weekdayList.set(i, Boolean.FALSE);
  194 + }
  195 + }
  196 + }
  197 + return this;
  198 + }
  199 +
  200 + public Builder setSpecialDayList(String special_days) {
  201 + this.specialDayList = new ArrayList<>();
  202 + if (StringUtils.isNotEmpty(special_days)) {
  203 + String[] days = special_days.split(",");
  204 + for (String day : days) {
  205 + try {
  206 + this.specialDayList.add(new DateTime(DateFormatUtils.ISO_DATE_FORMAT.parse(day)));
  207 + } catch (ParseException exp) {
  208 + throw new RuntimeException(exp);
  209 + }
  210 + }
  211 + }
  212 + return this;
  213 + }
  214 +
  215 + public Builder setLineVersion(int lineVersion) {
  216 + this.lineVersion = lineVersion;
  217 + return this;
  218 + }
  219 +
  220 + public KBaseValidateTimeTable_Fact_TTInfo build() {
  221 + return new KBaseValidateTimeTable_Fact_TTInfo(this);
  222 + }
  223 + }
  224 +
  225 +}
src/main/java/com/bsth/service/schedule/plan/process/_1_validate/_1_timetable/drools/KBaseValidateTimeTable_Fact_TTInfoDetail.java 0 → 100644
  1 +package com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools;
  2 +
  3 +import lombok.AllArgsConstructor;
  4 +import lombok.Builder;
  5 +import lombok.Data;
  6 +
  7 +/**
  8 + * drools规则验证时刻表使用的时刻表明细fact对象。
  9 + */
  10 +@Data
  11 +@Builder
  12 +@AllArgsConstructor
  13 +public class KBaseValidateTimeTable_Fact_TTInfoDetail {
  14 + /** 主健Id */
  15 + private Long id;
  16 + /** 时刻表主对象关联 */
  17 + private KBaseValidateTimeTable_Fact_TTInfo ttinfo;
  18 +
  19 + // 站点包括普通站点和停车场(站点编码不同,使用站点编码区分)
  20 + // 以后不需要再区分是站点还是停车场了
  21 + /** 起站点代码(bsth_c_station,bsth_c_car_park 里的编码) */
  22 + private String qdzCode;
  23 + /** 起站点名字(bsth_c_stationroute,bsth_c_car_park里的名字) */
  24 + private String qdzName;
  25 + /** 终点站代码(bsth_c_station,bsth_c_car_park 里的编码) */
  26 + private String zdzCode;
  27 + /** 终点站名字(bsth_c_stationroute,bsth_c_car_park里的名字) */
  28 + private String zdzName;
  29 +
  30 + /** 线路版本(bsth_c_line_versions表对应字段) */
  31 + private int lineVersion;
  32 +
  33 + /** 班次类型 字典type=ScheduleType */
  34 + private String bcType;
  35 +
  36 + /** 班次历时 */
  37 + private Integer bcsj;
  38 +
  39 +}
src/main/java/com/bsth/service/schedule/plan/process/_1_validate/_1_timetable/drools/KBaseValidateTimeTable_Function_AccumulateConflict.java 0 → 100644
  1 +package com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools;
  2 +
  3 +import com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools.KBaseValidateTimeTable_Result.StatInfo;
  4 +import org.apache.commons.lang3.StringUtils;
  5 +import org.kie.api.runtime.rule.AccumulateFunction;
  6 +import org.springframework.util.CollectionUtils;
  7 +
  8 +import java.io.*;
  9 +import java.util.ArrayList;
  10 +import java.util.HashMap;
  11 +import java.util.List;
  12 +import java.util.Map;
  13 +
  14 +/**
  15 + * 聚合时刻表冲突函数(去除重复的时刻表,优先提取冲突的时刻表)。
  16 + */
  17 +public class KBaseValidateTimeTable_Function_AccumulateConflict implements AccumulateFunction {
  18 + @Override
  19 + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
  20 + }
  21 + @Override
  22 + public void writeExternal(ObjectOutput out) throws IOException {
  23 + }
  24 +
  25 + protected static class AccumulateConflictData implements Serializable {
  26 + /** 聚合后的时刻表统计信息(key为时刻表Id) */
  27 + private Map<Long, StatInfo> statInfoGroupMap;
  28 + /** 聚合后的冲突描述信息(key为时刻表Id) */
  29 + private Map<Long, List<String>> conflictDescGroupMap;
  30 +
  31 + public AccumulateConflictData() {
  32 + statInfoGroupMap = new HashMap<>();
  33 + conflictDescGroupMap = new HashMap<>();
  34 + }
  35 +
  36 + public void remove(Long ttInfoId) {
  37 + statInfoGroupMap.remove(ttInfoId);
  38 + conflictDescGroupMap.remove(ttInfoId);
  39 + }
  40 +
  41 + public List<StatInfo> result() {
  42 + // 输出时,需要讲聚合后的冲突信息合并到时刻表统计信息中
  43 + List<StatInfo> rs = new ArrayList<>();
  44 + for (Long ttInfoId : statInfoGroupMap.keySet()) {
  45 + StatInfo statInfo = statInfoGroupMap.get(ttInfoId);
  46 + List<String> conflictDescList = conflictDescGroupMap.get(ttInfoId);
  47 + if (!CollectionUtils.isEmpty(conflictDescGroupMap)) {
  48 + // 使用逗号分隔
  49 + String conflictDesc = StringUtils.join(conflictDescList, ",");
  50 + statInfo.setConflictDesc(conflictDesc);
  51 + }
  52 + rs.add(statInfo);
  53 + }
  54 + return rs;
  55 + }
  56 + public void add(StatInfo statInfo) {
  57 + /**
  58 + * 聚合时刻表统计信息,
  59 + * 1、第一次直接添加时刻表统计信息
  60 + * 2、如果下一个时刻表统计信息中有冲突标识,则覆盖添加
  61 + */
  62 + Long ttInfoId = statInfo.getTtid();
  63 + boolean conflict = statInfo.getConflict();
  64 + if (statInfoGroupMap.get(ttInfoId) == null) {
  65 + statInfoGroupMap.put(ttInfoId, statInfo);
  66 + } else {
  67 + if (conflict) {
  68 + statInfoGroupMap.put(ttInfoId, statInfo);
  69 + }
  70 + }
  71 + /**
  72 + * 聚合时刻表冲突信息。
  73 + */
  74 + if (conflict) {
  75 + if (conflictDescGroupMap.get(ttInfoId) == null) {
  76 + conflictDescGroupMap.put(ttInfoId, new ArrayList<String>());
  77 + }
  78 + conflictDescGroupMap.get(ttInfoId).add(statInfo.getConflictDesc());
  79 + }
  80 +
  81 + }
  82 + }
  83 +
  84 + @Override
  85 + public Serializable createContext() {
  86 + return new AccumulateConflictData();
  87 + }
  88 +
  89 + @Override
  90 + public void init(Serializable context) throws Exception {
  91 + }
  92 +
  93 + @Override
  94 + public void accumulate(Serializable context, Object value) {
  95 + AccumulateConflictData accumulateConflictData = (AccumulateConflictData) context;
  96 + StatInfo statInfo = (StatInfo) value;
  97 + accumulateConflictData.add(statInfo);
  98 + }
  99 +
  100 + @Override
  101 + public void reverse(Serializable context, Object value) throws Exception {
  102 + AccumulateConflictData accumulateConflictData = (AccumulateConflictData) context;
  103 + StatInfo statInfo = (StatInfo) value;
  104 + accumulateConflictData.remove(statInfo.getTtid());
  105 + }
  106 +
  107 + @Override
  108 + public boolean supportsReverse() {
  109 + return true;
  110 + }
  111 +
  112 + @Override
  113 + public Class<?> getResultType() {
  114 + return List.class;
  115 + }
  116 +
  117 + @Override
  118 + public Object getResult(Serializable context) throws Exception {
  119 + AccumulateConflictData accumulateConflictData = (AccumulateConflictData) context;
  120 + return accumulateConflictData.result();
  121 + }
  122 +}
src/main/java/com/bsth/service/schedule/plan/process/_1_validate/_1_timetable/drools/KBaseValidateTimeTable_Function_ErrorBcCount.java 0 → 100644
  1 +package com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools;
  2 +
  3 +import org.apache.commons.lang3.StringUtils;
  4 +import org.kie.api.runtime.rule.AccumulateFunction;
  5 +
  6 +import java.io.*;
  7 +
  8 +/**
  9 + * drools规则验证时刻表用的函数(计算错误班次数量)
  10 + */
  11 +public class KBaseValidateTimeTable_Function_ErrorBcCount implements AccumulateFunction {
  12 + @Override
  13 + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
  14 + }
  15 +
  16 + @Override
  17 + public void writeExternal(ObjectOutput out) throws IOException {
  18 + }
  19 +
  20 + protected static class ErrorCountData implements Externalizable {
  21 + public long errorcount = 0;
  22 + public KBaseValidateTimeTable_Fact_TTInfoDetail ttInfoDetail;
  23 +
  24 + public ErrorCountData() {
  25 + }
  26 +
  27 + @Override
  28 + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
  29 + errorcount = in.readLong();
  30 + ttInfoDetail = (KBaseValidateTimeTable_Fact_TTInfoDetail) in.readObject();
  31 + }
  32 +
  33 + @Override
  34 + public void writeExternal(ObjectOutput out) throws IOException {
  35 + out.writeLong(errorcount);
  36 + out.writeObject(ttInfoDetail);
  37 + }
  38 + }
  39 +
  40 + @Override
  41 + public Serializable createContext() {
  42 + return new ErrorCountData();
  43 + }
  44 +
  45 + @Override
  46 + public void init(Serializable context) throws Exception {
  47 + ErrorCountData errorCountData = (ErrorCountData) context;
  48 + errorCountData.errorcount = 0;
  49 + }
  50 +
  51 + @Override
  52 + public void accumulate(Serializable context, Object value) {
  53 + ErrorCountData errorCountData = (ErrorCountData) context;
  54 + KBaseValidateTimeTable_Fact_TTInfoDetail ttInfoDetail = (KBaseValidateTimeTable_Fact_TTInfoDetail) value;
  55 +
  56 + if (ttInfoDetail.getTtinfo() == null) {
  57 + errorCountData.errorcount ++;
  58 + return;
  59 + }
  60 +
  61 + // 判定条件(数据库中的对应字段没有非空约束),与界面saTimeTable.js的validInfo方法对应
  62 + // 1、起点站编码,名字为空
  63 + // 2、终点站编码,名字为空
  64 + // 3、班次时间
  65 + // TODO:其他再议
  66 + if (StringUtils.isEmpty(ttInfoDetail.getQdzCode()) ||
  67 + StringUtils.isEmpty(ttInfoDetail.getQdzName()) ||
  68 + StringUtils.isEmpty(ttInfoDetail.getZdzCode()) ||
  69 + StringUtils.isEmpty(ttInfoDetail.getZdzName()) ||
  70 + (ttInfoDetail.getBcsj() == null) ) {
  71 +
  72 + errorCountData.errorcount ++;
  73 + }
  74 + }
  75 +
  76 + @Override
  77 + public void reverse(Serializable context, Object value) throws Exception {
  78 + ErrorCountData errorCountData = (ErrorCountData) context;
  79 + KBaseValidateTimeTable_Fact_TTInfoDetail ttInfoDetail = (KBaseValidateTimeTable_Fact_TTInfoDetail) value;
  80 +
  81 + if (ttInfoDetail.getTtinfo() == null) {
  82 + errorCountData.errorcount --;
  83 + return;
  84 + }
  85 +
  86 + if (StringUtils.isEmpty(ttInfoDetail.getQdzCode()) ||
  87 + StringUtils.isEmpty(ttInfoDetail.getQdzName()) ||
  88 + StringUtils.isEmpty(ttInfoDetail.getZdzCode()) ||
  89 + StringUtils.isEmpty(ttInfoDetail.getZdzName()) ) {
  90 +
  91 + errorCountData.errorcount --;
  92 + }
  93 +
  94 + }
  95 +
  96 + @Override
  97 + public Object getResult(Serializable context) throws Exception {
  98 + ErrorCountData errorCountData = (ErrorCountData) context;
  99 + return errorCountData.errorcount;
  100 + }
  101 +
  102 + @Override
  103 + public boolean supportsReverse() {
  104 + return true;
  105 + }
  106 +
  107 + @Override
  108 + public Class<?> getResultType() {
  109 + return Number.class;
  110 + }
  111 +}
src/main/java/com/bsth/service/schedule/plan/process/_1_validate/_1_timetable/drools/KBaseValidateTimeTable_Result.java 0 → 100644
  1 +package com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools;
  2 +
  3 +import java.util.ArrayList;
  4 +import java.util.List;
  5 +
  6 +/**
  7 + * drools规则验证时刻表输出结果。
  8 + */
  9 +public class KBaseValidateTimeTable_Result {
  10 + private List<StatInfo> infos = new ArrayList<>();
  11 +
  12 + public List<StatInfo> getInfos() {
  13 + return infos;
  14 + }
  15 +
  16 + public void setInfos(List<StatInfo> infos) {
  17 + this.infos = infos;
  18 + }
  19 +
  20 + public static class StatInfo {
  21 + /** 时刻表id */
  22 + private Long ttid;
  23 + /** 时刻表名字 */
  24 + private String ttname;
  25 + /** 线路版本 */
  26 + private Integer lineVersion;
  27 +
  28 + /** 所有班次数 */
  29 + private Long allbc;
  30 + /** 进场班次数 */
  31 + private Long inbc;
  32 + /** 出场班次数 */
  33 + private Long outbc;
  34 + /** 营运班次数 */
  35 + private Long yybc;
  36 +
  37 + /** 错误班次数 */
  38 + private Long errorbc;
  39 +
  40 + /** 是否冲突(同一天多张时刻表) */
  41 + private Boolean conflict;
  42 + /** 冲突描述(在drools规则中写入) */
  43 + private String conflictDesc;
  44 + /** 是否进行了冲突聚合计算(针对drools规则的聚合函数) */
  45 + private Boolean conflictAccumulate;
  46 +
  47 + public Long getTtid() {
  48 + return ttid;
  49 + }
  50 +
  51 + public void setTtid(Long ttid) {
  52 + this.ttid = ttid;
  53 + }
  54 +
  55 + public String getTtname() {
  56 + return ttname;
  57 + }
  58 +
  59 + public void setTtname(String ttname) {
  60 + this.ttname = ttname;
  61 + }
  62 +
  63 + public Long getAllbc() {
  64 + return allbc;
  65 + }
  66 +
  67 + public void setAllbc(Long allbc) {
  68 + this.allbc = allbc;
  69 + }
  70 +
  71 + public Long getInbc() {
  72 + return inbc;
  73 + }
  74 +
  75 + public void setInbc(Long inbc) {
  76 + this.inbc = inbc;
  77 + }
  78 +
  79 + public Long getOutbc() {
  80 + return outbc;
  81 + }
  82 +
  83 + public void setOutbc(Long outbc) {
  84 + this.outbc = outbc;
  85 + }
  86 +
  87 + public Long getYybc() {
  88 + return yybc;
  89 + }
  90 +
  91 + public void setYybc(Long yybc) {
  92 + this.yybc = yybc;
  93 + }
  94 +
  95 + public Long getErrorbc() {
  96 + return errorbc;
  97 + }
  98 +
  99 + public void setErrorbc(Long errorbc) {
  100 + this.errorbc = errorbc;
  101 + }
  102 +
  103 + public Integer getLineVersion() {
  104 + return lineVersion;
  105 + }
  106 +
  107 + public void setLineVersion(Integer lineVersion) {
  108 + this.lineVersion = lineVersion;
  109 + }
  110 +
  111 + public Boolean getConflict() {
  112 + return conflict;
  113 + }
  114 +
  115 + public void setConflict(Boolean conflict) {
  116 + this.conflict = conflict;
  117 + }
  118 +
  119 + public String getConflictDesc() {
  120 + return conflictDesc;
  121 + }
  122 +
  123 + public void setConflictDesc(String conflictDesc) {
  124 + this.conflictDesc = conflictDesc;
  125 + }
  126 +
  127 + public Boolean getConflictAccumulate() {
  128 + return conflictAccumulate;
  129 + }
  130 +
  131 + public void setConflictAccumulate(Boolean conflictAccumulate) {
  132 + this.conflictAccumulate = conflictAccumulate;
  133 + }
  134 + }
  135 +}
src/main/resources/drools/KBase/validate/timetable/KBase_validate_timetable.drl 0 → 100644
  1 +package com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools;
  2 +
  3 +import org.joda.time.*;
  4 +import org.joda.time.format.DateTimeFormat;
  5 +import java.util.*;
  6 +import org.apache.commons.lang3.StringUtils;
  7 +
  8 +import com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools.KBaseValidateTimeTable_Fact_CalcuParam;
  9 +import com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools.KBaseValidateTimeTable_Result;
  10 +import com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools.KBaseValidateTimeTable_Result.StatInfo;
  11 +
  12 +import com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools.KBaseValidateTimeTable_Fact_Line;
  13 +import com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools.KBaseValidateTimeTable_Fact_TTInfo;
  14 +import com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools.KBaseValidateTimeTable_Fact_TTInfoDetail;
  15 +
  16 +import org.slf4j.Logger;
  17 +
  18 +// 全局日志类(使用PlanPreValidateServiceImpl里定义的LOGGER)
  19 +global Logger LOGGER;
  20 +
  21 +// 输出
  22 +global KBaseValidateTimeTable_Result rs;
  23 +
  24 +/*
  25 + 规则说明:
  26 + 1、找出指定线路,指定时间范围的时刻表
  27 + 2、统计这些时刻表班次数据的情况
  28 + 3、统计时会计算同一天多张时刻表的情况
  29 +*/
  30 +
  31 +//-------------- 第一阶段、计算规则迭代数据(天数) ------------//
  32 +declare Calcu_iter_days_result
  33 + xlId: Integer // 线路Id
  34 + xlName: String // 线路名字
  35 +
  36 + // 迭代数据
  37 + calcu_day: Integer // 准备计算第几天
  38 + calcu_weekday: Integer // 准备计算星期几(1到7)
  39 + calcu_date: DateTime // 准备计算的具体日期
  40 +
  41 + // 范围数据
  42 + calcu_days: Integer // 总共需要计算的天数
  43 + calcu_start_date: DateTime // 开始计算日期
  44 + calcu_end_date: DateTime // 结束计算日期
  45 +
  46 + // 时刻表映射数据
  47 + ttinfomap: Map // 指定时间段内,用的时刻表id映射 Map<Long, Long>
  48 +end
  49 +
  50 +rule "calcu_iter_days"
  51 + salience 1900
  52 + when
  53 + KBaseValidateTimeTable_Fact_CalcuParam(
  54 + $xlId: xlId,
  55 + $fromDate: fromDate,
  56 + $toDate: toDate,
  57 + $fromDate.isBefore($toDate) || $fromDate.isEqual($toDate)
  58 + )
  59 + $line: KBaseValidateTimeTable_Fact_Line(id == $xlId)
  60 + then
  61 + // 构造Calcu_iter_days_result对象,进行下一步计算
  62 + Calcu_iter_days_result cidr = new Calcu_iter_days_result();
  63 + Period p = new Period($fromDate, $toDate, PeriodType.days());
  64 +
  65 + cidr.setXlId($xlId);
  66 + cidr.setXlName($line.getName());
  67 +
  68 + cidr.setCalcu_day(new Integer(1));
  69 + cidr.setCalcu_weekday(Integer.valueOf($fromDate.getDayOfWeek()));
  70 + cidr.setCalcu_date($fromDate);
  71 +
  72 + cidr.setCalcu_days(Integer.valueOf(p.getDays() + 1));
  73 + cidr.setCalcu_start_date($fromDate);
  74 + cidr.setCalcu_end_date($toDate);
  75 +
  76 + cidr.setTtinfomap(new HashMap());
  77 +
  78 + LOGGER.info(
  79 + "线路={}-id={},开始时间={},结束时间={},总共计算的天数={},将从开始时间迭代",
  80 + cidr.getXlName(),
  81 + cidr.getXlId(),
  82 + cidr.getCalcu_start_date(),
  83 + cidr.getCalcu_end_date(),
  84 + cidr.getCalcu_days()
  85 + );
  86 +
  87 + insert(cidr);
  88 +end
  89 +
  90 +//-------------- 第二阶段、时刻表的日期匹配 ------------//
  91 +declare TTInfoList_wrap // 时刻表封装对象
  92 + calcu_date: DateTime // 具体的日期
  93 + ttInfoNormalList: List // 时刻表列表-平日匹配 List<KBaseValidateTimeTable_Fact_TTInfo>
  94 + ttInfoSpecialList: List // 时刻表类标-特殊日期匹配 List<KBaseValidateTimeTable_Fact_TTInfo>
  95 +end
  96 +
  97 +rule "Calcu_iter_days_special_day" // 日期匹配
  98 + salience 800
  99 + when
  100 + $cid : Calcu_iter_days_result(
  101 + $calcu_date: calcu_date,
  102 + $calcu_weekday: calcu_weekday,
  103 + $calcu_day: calcu_day,
  104 + calcu_day <= calcu_days
  105 + )
  106 + $ttInfoSpecialList : ArrayList() from collect (
  107 + KBaseValidateTimeTable_Fact_TTInfo(
  108 + specialDayList contains $calcu_date
  109 + )
  110 + )
  111 + $ttInfoNormalList : ArrayList() from collect (
  112 + KBaseValidateTimeTable_Fact_TTInfo(
  113 + specialDayList not contains $calcu_date,
  114 + weekdayList[$calcu_weekday - 1] == Boolean.TRUE
  115 + )
  116 + )
  117 + then
  118 + LOGGER.debug("日期={}, 一般日期匹配时刻表数量={}, 特殊日期时刻表匹配数量={}",
  119 + $calcu_date, $ttInfoNormalList.size(), $ttInfoSpecialList.size());
  120 +
  121 + // 插入时刻表封装对象
  122 + TTInfoList_wrap fact = new TTInfoList_wrap();
  123 + fact.setCalcu_date(new DateTime($calcu_date));
  124 + // 注意:如果要赋值List,必须重新建ArrayList,直接用drools的变量有问题
  125 + List ttInfoNormalList = new ArrayList();
  126 + ttInfoNormalList.addAll($ttInfoNormalList);
  127 + fact.setTtInfoNormalList(ttInfoNormalList);
  128 + // 注意:如果要赋值List,必须重新建ArrayList,直接用drools的变量有问题
  129 + List ttInfoSpecialList = new ArrayList();
  130 + ttInfoSpecialList.addAll($ttInfoSpecialList);
  131 + fact.setTtInfoSpecialList(ttInfoSpecialList);
  132 +
  133 + insert(fact);
  134 +
  135 + // 更新迭代对象
  136 + Integer new_calcu_day = Integer.valueOf($calcu_day + 1);
  137 + $cid.setCalcu_day(new_calcu_day);
  138 + DateTime new_calcu_date = $calcu_date.plusDays(1);
  139 + $cid.setCalcu_date(new_calcu_date);
  140 + $cid.setCalcu_weekday(Integer.valueOf(new_calcu_date.getDayOfWeek()));
  141 +
  142 + update($cid);
  143 +end
  144 +
  145 +//----------------- 第三阶段、组装待处理时刻表统计信息 ----------------//
  146 +rule "Calcu_StatInfo_wrap_special_not_conflict" // 当天有特殊日期匹配的时刻表,只有一张
  147 + salience 750
  148 + when
  149 + TTInfoList_wrap(
  150 + ttInfoSpecialList.size == 1,
  151 + $calcu_date: calcu_date,
  152 + $ttInfoSpecialList: ttInfoSpecialList
  153 + )
  154 + $ttInfo: KBaseValidateTimeTable_Fact_TTInfo($tid: id, $tname: name, $lineVersion: lineVersion) from $ttInfoSpecialList
  155 + then
  156 + LOGGER.debug("特殊日期匹配,同一天单一时刻表:" +
  157 + "时刻表id={} 日期={}",
  158 + $tid, $calcu_date);
  159 +
  160 + StatInfo statInfo = new StatInfo();
  161 + statInfo.setTtid($tid);
  162 + statInfo.setTtname($tname);
  163 + statInfo.setLineVersion($lineVersion);
  164 + statInfo.setConflict(false);
  165 + statInfo.setConflictAccumulate(false);
  166 + insert(statInfo);
  167 +end
  168 +
  169 +rule "Calcu_StatInfo_wrap_special_conflict" // 当天有特殊日期匹配的时刻表, 多张时刻表
  170 + salience 740
  171 + when
  172 + TTInfoList_wrap(
  173 + ttInfoSpecialList.size > 1,
  174 + $calcu_date: calcu_date,
  175 + $ttInfoSpecialList: ttInfoSpecialList
  176 + )
  177 + $ttInfo: KBaseValidateTimeTable_Fact_TTInfo($tid: id, $tname: name, $lineVersion: lineVersion) from $ttInfoSpecialList
  178 + then
  179 + LOGGER.debug("特殊日期匹配,同一天多张时刻表:" +
  180 + "时刻表id={} 日期={}",
  181 + $tid, $calcu_date);
  182 +
  183 + StatInfo statInfo = new StatInfo();
  184 + statInfo.setTtid($tid);
  185 + statInfo.setTtname($tname);
  186 + statInfo.setLineVersion($lineVersion);
  187 + statInfo.setConflict(true);
  188 + statInfo.setConflictDesc("特殊日期冲突_" + $calcu_date.toString("yyyy-MM-dd"));
  189 + statInfo.setConflictAccumulate(false);
  190 + insert(statInfo);
  191 +end
  192 +
  193 +rule "Calcu_StatInfo_wrap_normal_not_conflict" // 当天一般日期匹配的时刻表,只有一张
  194 + salience 730
  195 + when
  196 + TTInfoList_wrap(
  197 + ttInfoSpecialList.size < 1,
  198 + ttInfoNormalList.size == 1,
  199 + $calcu_date: calcu_date,
  200 + $ttInfoNormalList: ttInfoNormalList
  201 + )
  202 + $ttInfo: KBaseValidateTimeTable_Fact_TTInfo($tid: id, $tname: name, $lineVersion: lineVersion) from $ttInfoNormalList
  203 + then
  204 + LOGGER.debug("一般日期匹配,同一天单一时刻表:" +
  205 + "时刻表id={} 日期={}",
  206 + $tid, $calcu_date);
  207 +
  208 + StatInfo statInfo = new StatInfo();
  209 + statInfo.setTtid($tid);
  210 + statInfo.setTtname($tname);
  211 + statInfo.setLineVersion($lineVersion);
  212 + statInfo.setConflict(false);
  213 + statInfo.setConflictAccumulate(false);
  214 + insert(statInfo);
  215 +end
  216 +
  217 +rule "Calcu_StatInfo_wrap_normal_conflict" // 当天一般日期匹配的时刻表,多张时刻表
  218 + salience 730
  219 + when
  220 + TTInfoList_wrap(
  221 + ttInfoSpecialList.size < 1,
  222 + ttInfoNormalList.size > 1,
  223 + $calcu_date: calcu_date,
  224 + $ttInfoNormalList: ttInfoNormalList
  225 + )
  226 + $ttInfo: KBaseValidateTimeTable_Fact_TTInfo($tid: id, $tname: name, $lineVersion: lineVersion) from $ttInfoNormalList
  227 + then
  228 + LOGGER.debug("一般日期匹配,同一天多张时刻表:" +
  229 + "时刻表id={} 日期={}",
  230 + $tid, $calcu_date);
  231 +
  232 + StatInfo statInfo = new StatInfo();
  233 + statInfo.setTtid($tid);
  234 + statInfo.setTtname($tname);
  235 + statInfo.setLineVersion($lineVersion);
  236 + statInfo.setConflict(true);
  237 + statInfo.setConflictDesc("一般日期冲突_" + $calcu_date.toString("yyyy-MM-dd"));
  238 + statInfo.setConflictAccumulate(false);
  239 + insert(statInfo);
  240 +end
  241 +
  242 +//-------------- 第四阶段、时刻表聚合统计 ------------//
  243 +rule "statinfo_accumulate_conflict" // 聚合统计
  244 + salience 300
  245 + no-loop
  246 + when
  247 + $accList: List() from accumulate (
  248 + $statInfo: StatInfo(conflictAccumulate == false),
  249 + ac($statInfo)
  250 + )
  251 + StatInfo(
  252 + $tid: ttid,
  253 + $tname: ttname,
  254 + $lineVersion: lineVersion,
  255 + $conflict: conflict,
  256 + $conflictDesc: ConflictDesc) from $accList
  257 + then
  258 + LOGGER.info("ttid={}, conflictDesc={}", $tid, $conflictDesc);
  259 +
  260 + StatInfo statInfo = new StatInfo();
  261 + statInfo.setTtid($tid);
  262 + statInfo.setTtname($tname);
  263 + statInfo.setLineVersion($lineVersion);
  264 + statInfo.setConflict($conflict);
  265 + statInfo.setConflictDesc($conflictDesc);
  266 + statInfo.setConflictAccumulate(true);
  267 + insert(statInfo);
  268 +end
  269 +
  270 +rule "statinfo_result" // 统计计算结果
  271 + salience 300
  272 + no-loop
  273 + when
  274 + $statInfo: StatInfo(conflictAccumulate == true, $tid: ttid, $lineVersion: lineVersion, $conflict: conflict, $conflictDesc: conflictDesc)
  275 + $bcInfoList : ArrayList() from collect (KBaseValidateTimeTable_Fact_TTInfoDetail(ttinfo.id == $tid))
  276 + $allbc: Long() from accumulate (KBaseValidateTimeTable_Fact_TTInfoDetail() from $bcInfoList, count())
  277 + $inbc: Long() from accumulate (KBaseValidateTimeTable_Fact_TTInfoDetail(bcType == "in") from $bcInfoList, count())
  278 + $outbc: Long() from accumulate (KBaseValidateTimeTable_Fact_TTInfoDetail(bcType == "out") from $bcInfoList, count())
  279 + $yybc: Long() from accumulate (KBaseValidateTimeTable_Fact_TTInfoDetail(bcType != "out", bcType != "in") from $bcInfoList, count())
  280 + $errorbc: Long() from accumulate ($ttd: KBaseValidateTimeTable_Fact_TTInfoDetail() from $bcInfoList, ecount($ttd))
  281 + then
  282 + LOGGER.info("时刻表={},id={},线路版本={},班次数={},进场={},出场={},营运={},错误={},是否冲突={},冲突描述={}",
  283 + $statInfo.getTtname(), $statInfo.getTtid(), $lineVersion, $allbc, $inbc, $outbc, $yybc, $errorbc, $conflict, $conflictDesc);
  284 +
  285 + $statInfo.setAllbc($allbc);
  286 + $statInfo.setInbc($inbc);
  287 + $statInfo.setOutbc($outbc);
  288 + $statInfo.setYybc($yybc);
  289 + $statInfo.setErrorbc($errorbc);
  290 +
  291 + rs.getInfos().add($statInfo);
  292 +end
  293 +
  294 +
  295 +/*
  296 +rule "test"
  297 + when
  298 + $test: TTInfoList_wrap(
  299 + $calcu_date: calcu_date,
  300 + $ttInfoNormalList: ttInfoNormalList,
  301 + $ttInfoSpecialList: ttInfoSpecialList
  302 + )
  303 + then
  304 + LOGGER.debug("日期={}, nsize={}, ssize={}", $calcu_date, $ttInfoNormalList.size(), $ttInfoSpecialList.size());
  305 +
  306 +end
  307 +*/
src/main/resources/drools/KBase/validate/timetable/KBase_validate_timetable_old.drl 0 → 100644
  1 +package com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools;
  2 +
  3 +import org.joda.time.*;
  4 +import org.joda.time.format.DateTimeFormat;
  5 +import java.util.*;
  6 +import org.apache.commons.lang3.StringUtils;
  7 +
  8 +import com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools.KBaseValidateTimeTable_Fact_CalcuParam;
  9 +import com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools.KBaseValidateTimeTable_Result;
  10 +import com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools.KBaseValidateTimeTable_Result.StatInfo;
  11 +
  12 +import com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools.KBaseValidateTimeTable_Fact_Line;
  13 +import com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools.KBaseValidateTimeTable_Fact_TTInfo;
  14 +import com.bsth.service.schedule.plan.process._1_validate._1_timetable.drools.KBaseValidateTimeTable_Fact_TTInfoDetail;
  15 +
  16 +import org.slf4j.Logger;
  17 +
  18 +// 全局日志类(使用PlanPreValidateServiceImpl里定义的LOGGER)
  19 +global Logger LOGGER;
  20 +
  21 +// 输出
  22 +global KBaseValidateTimeTable_Result rs;
  23 +
  24 +/*
  25 + 规则说明:
  26 + 1、找出指定线路,指定时间范围的时刻表
  27 + 2、统计这些时刻表班次数据的情况
  28 +*/
  29 +
  30 +//-------------- 第一阶段、计算规则迭代数据(天数) ------------//
  31 +declare Calcu_iter_days_result
  32 + xlId: Integer // 线路Id
  33 + xlName: String // 线路名字
  34 +
  35 + // 迭代数据
  36 + calcu_day: Integer // 准备计算第几天
  37 + calcu_weekday: Integer // 准备计算星期几(1到7)
  38 + calcu_date: DateTime // 准备计算的具体日期
  39 +
  40 + // 范围数据
  41 + calcu_days: Integer // 总共需要计算的天数
  42 + calcu_start_date: DateTime // 开始计算日期
  43 + calcu_end_date: DateTime // 结束计算日期
  44 +
  45 + // 时刻表映射数据
  46 + ttinfomap: Map // 指定时间段内,用的时刻表id映射 Map<Long, Long>
  47 +end
  48 +
  49 +rule "calcu_iter_days"
  50 + salience 1900
  51 + when
  52 + KBaseValidateTimeTable_Fact_CalcuParam(
  53 + $xlId: xlId,
  54 + $fromDate: fromDate,
  55 + $toDate: toDate,
  56 + $fromDate.isBefore($toDate) || $fromDate.isEqual($toDate)
  57 + )
  58 + $line: KBaseValidateTimeTable_Fact_Line(id == $xlId)
  59 + then
  60 + // 构造Calcu_iter_days_result对象,进行下一步计算
  61 + Calcu_iter_days_result cidr = new Calcu_iter_days_result();
  62 + Period p = new Period($fromDate, $toDate, PeriodType.days());
  63 +
  64 + cidr.setXlId($xlId);
  65 + cidr.setXlName($line.getName());
  66 +
  67 + cidr.setCalcu_day(new Integer(1));
  68 + cidr.setCalcu_weekday(Integer.valueOf($fromDate.getDayOfWeek()));
  69 + cidr.setCalcu_date($fromDate);
  70 +
  71 + cidr.setCalcu_days(Integer.valueOf(p.getDays() + 1));
  72 + cidr.setCalcu_start_date($fromDate);
  73 + cidr.setCalcu_end_date($toDate);
  74 +
  75 + cidr.setTtinfomap(new HashMap());
  76 +
  77 + LOGGER.info(
  78 + "线路={}-id={},开始时间={},结束时间={},总共计算的天数={},将从开始时间迭代",
  79 + cidr.getXlName(),
  80 + cidr.getXlId(),
  81 + cidr.getCalcu_start_date(),
  82 + cidr.getCalcu_end_date(),
  83 + cidr.getCalcu_days()
  84 + );
  85 +
  86 + insert(cidr);
  87 +end
  88 +
  89 +//-------------- 第二阶段、时刻表的日期匹配 ------------//
  90 +declare TTInfoDetails_wrap
  91 + ttInfoId: Long // 时刻表id
  92 + lineVersion: Integer // 线路版本
  93 + bcInfoList: List // 班次信息列表 List<KBaseValidateTimeTable_Fact_TTInfoDetail>
  94 +end
  95 +
  96 +rule "Calcu_iter_days_special_day" // 特殊日期匹配(并且不在StatInfo中)
  97 + salience 800
  98 + when
  99 + $cid : Calcu_iter_days_result(
  100 + $calcu_date: calcu_date,
  101 + $calcu_day: calcu_day,
  102 + calcu_day <= calcu_days
  103 + )
  104 + KBaseValidateTimeTable_Fact_TTInfo(
  105 + $tid: id,
  106 + $tname: name,
  107 + $lineVersion: lineVersion,
  108 + specialDayList contains $calcu_date
  109 + )
  110 + not StatInfo(ttid == $tid)
  111 + $bcInfoList : ArrayList() from collect (KBaseValidateTimeTable_Fact_TTInfoDetail(ttinfo.id == $tid))
  112 + then
  113 + // 更新迭代对象
  114 + Integer new_calcu_day = Integer.valueOf($calcu_day + 1);
  115 + $cid.setCalcu_day(new_calcu_day);
  116 + DateTime new_calcu_date = $calcu_date.plusDays(1);
  117 + $cid.setCalcu_date(new_calcu_date);
  118 + $cid.setCalcu_weekday(Integer.valueOf(new_calcu_date.getDayOfWeek()));
  119 +
  120 + LOGGER.debug("启用特殊日期时刻表(设置StatInfo):" +
  121 + "时刻表id={} 特殊日期={}",
  122 + $tid, $calcu_date);
  123 +
  124 + StatInfo statInfo = new StatInfo();
  125 + statInfo.setTtid($tid);
  126 + statInfo.setTtname($tname);
  127 + insert(statInfo);
  128 +
  129 + TTInfoDetails_wrap ttInfoDetails_wrap = new TTInfoDetails_wrap();
  130 + ttInfoDetails_wrap.setTtInfoId($tid);
  131 + ttInfoDetails_wrap.setBcInfoList($bcInfoList);
  132 + ttInfoDetails_wrap.setLineVersion($lineVersion);
  133 + insert(ttInfoDetails_wrap);
  134 +
  135 + update($cid);
  136 +
  137 +end
  138 +
  139 +rule "Calcu_iter_days_special_day_exist" // 特殊日期匹配(已经在StatInfo中)
  140 + salience 800
  141 + when
  142 + $cid : Calcu_iter_days_result(
  143 + $calcu_date: calcu_date,
  144 + $calcu_day: calcu_day,
  145 + calcu_day <= calcu_days
  146 + )
  147 + KBaseValidateTimeTable_Fact_TTInfo(
  148 + $tid: id,
  149 + $tname: name,
  150 + $lineVersion: lineVersion,
  151 + specialDayList contains $calcu_date
  152 + )
  153 + StatInfo(ttid == $tid)
  154 + then
  155 + // 更新迭代对象
  156 + Integer new_calcu_day = Integer.valueOf($calcu_day + 1);
  157 + $cid.setCalcu_day(new_calcu_day);
  158 + DateTime new_calcu_date = $calcu_date.plusDays(1);
  159 + $cid.setCalcu_date(new_calcu_date);
  160 + $cid.setCalcu_weekday(Integer.valueOf(new_calcu_date.getDayOfWeek()));
  161 +
  162 + LOGGER.debug("启用特殊日期时刻表(已经设置过StatInfo):" +
  163 + "时刻表id={} 特殊日期={}",
  164 + $tid, $calcu_date);
  165 +
  166 + update($cid);
  167 +
  168 +end
  169 +
  170 +rule "Calcu_iter_days_normal_day" // 平日匹配(并且不在StatInfo中)
  171 + salience 700
  172 + when
  173 + $cid : Calcu_iter_days_result(
  174 + $calcu_date: calcu_date,
  175 + $calcu_weekday: calcu_weekday,
  176 + $calcu_day: calcu_day,
  177 + calcu_day <= calcu_days
  178 + )
  179 + KBaseValidateTimeTable_Fact_TTInfo(
  180 + $tid: id,
  181 + $tname: name,
  182 + $lineVersion: lineVersion,
  183 + specialDayList not contains $calcu_date,
  184 + weekdayList[$calcu_weekday - 1] == Boolean.TRUE
  185 + )
  186 + not StatInfo(ttid == $tid)
  187 + $bcInfoList : ArrayList() from collect (KBaseValidateTimeTable_Fact_TTInfoDetail(ttinfo.id == $tid))
  188 + then
  189 + // 更新迭代对象
  190 + Integer new_calcu_day = Integer.valueOf($calcu_day + 1);
  191 + $cid.setCalcu_day(new_calcu_day);
  192 + DateTime new_calcu_date = $calcu_date.plusDays(1);
  193 + $cid.setCalcu_date(new_calcu_date);
  194 + $cid.setCalcu_weekday(Integer.valueOf(new_calcu_date.getDayOfWeek()));
  195 +
  196 +
  197 + LOGGER.debug("启用常规日期时刻表(设置StatInfo):" +
  198 + "时刻表id={} 常规日期={} 星期几={}",
  199 + $tid, $calcu_date, $calcu_weekday);
  200 +
  201 + StatInfo statInfo = new StatInfo();
  202 + statInfo.setTtid($tid);
  203 + statInfo.setTtname($tname);
  204 + insert(statInfo);
  205 +
  206 + TTInfoDetails_wrap ttInfoDetails_wrap = new TTInfoDetails_wrap();
  207 + ttInfoDetails_wrap.setTtInfoId($tid);
  208 + ttInfoDetails_wrap.setBcInfoList($bcInfoList);
  209 + ttInfoDetails_wrap.setLineVersion($lineVersion);
  210 + insert(ttInfoDetails_wrap);
  211 +
  212 + update($cid);
  213 +
  214 +end
  215 +
  216 +rule "Calcu_iter_days_normal_day_exist" // 平日匹配(已经在StatInfo中)
  217 + salience 700
  218 + when
  219 + $cid : Calcu_iter_days_result(
  220 + $calcu_date: calcu_date,
  221 + $calcu_weekday: calcu_weekday,
  222 + $calcu_day: calcu_day,
  223 + calcu_day <= calcu_days
  224 + )
  225 + KBaseValidateTimeTable_Fact_TTInfo(
  226 + $tid: id,
  227 + $tname: name,
  228 + $lineVersion: lineVersion,
  229 + specialDayList not contains $calcu_date,
  230 + weekdayList[$calcu_weekday - 1] == Boolean.TRUE
  231 + )
  232 + StatInfo(ttid == $tid)
  233 + then
  234 + // 更新迭代对象
  235 + Integer new_calcu_day = Integer.valueOf($calcu_day + 1);
  236 + $cid.setCalcu_day(new_calcu_day);
  237 + DateTime new_calcu_date = $calcu_date.plusDays(1);
  238 + $cid.setCalcu_date(new_calcu_date);
  239 + $cid.setCalcu_weekday(Integer.valueOf(new_calcu_date.getDayOfWeek()));
  240 +
  241 + LOGGER.debug("启用常规日期时刻表(已经设置过StatInfo):" +
  242 + "时刻表id={} 常规日期={} 星期几={}",
  243 + $tid, $calcu_date, $calcu_weekday);
  244 +
  245 + update($cid);
  246 +
  247 +end
  248 +
  249 +rule "Calcu_iter_days_other_day" // 都没有的情况下,匹配
  250 + salience 500
  251 + when
  252 + $cid : Calcu_iter_days_result(
  253 + $calcu_date: calcu_date,
  254 + $calcu_weekday: calcu_weekday,
  255 + $calcu_day: calcu_day,
  256 + calcu_day <= calcu_days
  257 + )
  258 + not KBaseValidateTimeTable_Fact_TTInfo(
  259 + (specialDayList contains $calcu_date) ||
  260 + (weekdayList[$calcu_weekday - 1] == Boolean.TRUE)
  261 + )
  262 + then
  263 + // 更新迭代对象
  264 + Integer new_calcu_day = Integer.valueOf($calcu_day + 1);
  265 + $cid.setCalcu_day(new_calcu_day);
  266 + DateTime new_calcu_date = $calcu_date.plusDays(1);
  267 + $cid.setCalcu_date(new_calcu_date);
  268 + $cid.setCalcu_weekday(Integer.valueOf(new_calcu_date.getDayOfWeek()));
  269 +
  270 + LOGGER.debug("当前日期没有匹配的时刻表:日期={} 星期几={}", $calcu_date, $calcu_weekday);
  271 +
  272 + update($cid);
  273 +
  274 +end
  275 +
  276 +//-------------- 第三阶段、时刻表明细统计值 ------------//
  277 +
  278 +rule "statinfo_result" // 统计计算结果
  279 + salience 300
  280 + no-loop
  281 + when
  282 + $statInfo: StatInfo($tid: ttid)
  283 + $ttInfoDetails_wrap: TTInfoDetails_wrap(ttInfoId == $tid)
  284 + $allbc: Long() from accumulate (KBaseValidateTimeTable_Fact_TTInfoDetail() from $ttInfoDetails_wrap.getBcInfoList(), count())
  285 + $inbc: Long() from accumulate (KBaseValidateTimeTable_Fact_TTInfoDetail(bcType == "in") from $ttInfoDetails_wrap.getBcInfoList(), count())
  286 + $outbc: Long() from accumulate (KBaseValidateTimeTable_Fact_TTInfoDetail(bcType == "out") from $ttInfoDetails_wrap.getBcInfoList(), count())
  287 + $yybc: Long() from accumulate (KBaseValidateTimeTable_Fact_TTInfoDetail(bcType != "out", bcType != "in") from $ttInfoDetails_wrap.getBcInfoList(), count())
  288 + $errorbc: Long() from accumulate ($ttd: KBaseValidateTimeTable_Fact_TTInfoDetail() from $ttInfoDetails_wrap.getBcInfoList(), ecount($ttd))
  289 + then
  290 + LOGGER.info("时刻表={},id={},班次数={},进场={},出场={},营运={},错误={}", $statInfo.getTtname(), $statInfo.getTtid(), $allbc, $inbc, $outbc, $yybc, $errorbc);
  291 +
  292 + $statInfo.setAllbc($allbc);
  293 + $statInfo.setInbc($inbc);
  294 + $statInfo.setOutbc($outbc);
  295 + $statInfo.setYybc($yybc);
  296 + $statInfo.setErrorbc($errorbc);
  297 +
  298 + int lineVersion = $ttInfoDetails_wrap.getLineVersion();
  299 + $statInfo.setLineVersion(lineVersion);
  300 +
  301 + rs.getInfos().add($statInfo);
  302 +
  303 +end
  304 +
  305 +
  306 +
  307 +
src/main/resources/drools/config.properties 0 → 100644
  1 +# drools各个kBase的drl路径配置
  2 +#kbase.root.path=/Users/xu/resource/project_code/bsth_project/bsth_control_parent/bsth-control_v2-plan_module-service-schedule_generate/src/main/resources/drools/
  3 +#kbase.root.classpath=drools/
  4 +
  5 +# 排班前置验证规则
  6 +#kbase.validate.timetable.drl=kBase/validate/timetable/kBase_validate_timetable.drl
  7 +#kbase.validate.rule.drl=kBase/validate/rule/kBase_validate_rule.drl
  8 +
  9 +# 排班生成 - 1、计算时刻表相关信息
  10 +#kbase.generate.calcu.timetable.drl=kBase/generate/calcu/timetable/kBase_generate_calcu_timetable.drl
  11 +# 排班生成 - 2、计算排班规则翻班信息
  12 +#kbase.generate.calcu.shiftloop.drl=kBase/generate/calcu/shiftloop/kBase_generate_calcu_shiftloop.drl
  13 +# 排班生成 - 3、组合排班数据
  14 +#kbase.generate.plan.drl=kBase/generate/plan/kBase_generate_plan.drl
  15 +# 排班生成 - 4、套跑规则修正排班数据
  16 +#kbase.generate.rerun.drl=kBase/generate/rerun/kBase_generate_rerun.drl
  17 +# 排班生成 - 5、验证排班数据
  18 +#kbase.validate.plan.drl=kBase/validate/plan/kBase_validate_plan.drl
  19 +
  20 +# 排班前置验证规则
  21 +# 时刻表验证
  22 +drools.KBase.validate_timetable=drools/KBase/validate/timetable/KBase_validate_timetable.drl
  23 +
  24 +
src/test/java/com/bsth/BaseTest_junit4.java 0 → 100644
  1 +package com.bsth;
  2 +
  3 +import ch.qos.logback.classic.LoggerContext;
  4 +import ch.qos.logback.classic.joran.JoranConfigurator;
  5 +import ch.qos.logback.core.util.StatusPrinter;
  6 +import org.apache.commons.lang3.StringUtils;
  7 +import org.dbunit.database.DatabaseConfig;
  8 +import org.dbunit.database.DatabaseConnection;
  9 +import org.dbunit.database.DatabaseSequenceFilter;
  10 +import org.dbunit.database.IDatabaseConnection;
  11 +import org.dbunit.dataset.FilteredDataSet;
  12 +import org.dbunit.dataset.IDataSet;
  13 +import org.dbunit.dataset.xml.FlatXmlDataSetBuilder;
  14 +import org.dbunit.ext.h2.H2DataTypeFactory;
  15 +import org.dbunit.operation.DatabaseOperation;
  16 +import org.junit.After;
  17 +import org.junit.Before;
  18 +import org.junit.BeforeClass;
  19 +import org.junit.Rule;
  20 +import org.junit.rules.TestName;
  21 +import org.slf4j.Logger;
  22 +import org.slf4j.LoggerFactory;
  23 +import org.springframework.beans.factory.annotation.Autowired;
  24 +import org.springframework.core.io.ClassPathResource;
  25 +import org.springframework.core.io.Resource;
  26 +
  27 +import javax.sql.DataSource;
  28 +import java.io.File;
  29 +import java.util.Map;
  30 +
  31 +/**
  32 + * junit4基础测试类。
  33 + */
  34 +public abstract class BaseTest_junit4 {
  35 + /** 日志记录器 */
  36 + public static final Logger LOG = LoggerFactory.getLogger(BaseTest_junit4.class);
  37 +
  38 + @Rule
  39 + public TestName name = new TestName();
  40 +
  41 + @BeforeClass
  42 + public static void initLogConfig() throws Exception {
  43 + File logFile = new File(BaseTest_junit4.class.getResource("/logback.xml").toURI());
  44 + LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
  45 + JoranConfigurator configurator = new JoranConfigurator();
  46 + configurator.setContext(lc);
  47 + lc.reset();
  48 + configurator.doConfigure(logFile);
  49 + StatusPrinter.printInCaseOfErrorsOrWarnings(lc);
  50 + }
  51 +
  52 + /**
  53 + * 获取DBUnit数据源。
  54 + * @return
  55 + */
  56 + private IDataSet getDataSet() throws Exception {
  57 + Map<String, String> dbFileMap = getDbunitTestDbFileClassPathMap();
  58 + String methodName = name.getMethodName();
  59 + String dbunitClassPath = dbFileMap.get(methodName);
  60 + if (StringUtils.isEmpty(dbunitClassPath)) {
  61 + LOG.info("dbunit测试xml为空,key={}", methodName);
  62 + }
  63 + Resource res = new ClassPathResource(dbunitClassPath);
  64 + FlatXmlDataSetBuilder builder = new FlatXmlDataSetBuilder();
  65 + builder.setColumnSensing(true);
  66 + return builder.build(res.getInputStream());
  67 + }
  68 +
  69 + /**
  70 + * 获取数据库连接。
  71 + * @return
  72 + */
  73 + private IDatabaseConnection getConnection() throws Exception {
  74 + DatabaseConnection conn = new DatabaseConnection(getDataSource().getConnection());
  75 + DatabaseConfig config = conn.getConfig();
  76 + config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new H2DataTypeFactory());
  77 + return conn;
  78 + }
  79 +
  80 + /**
  81 + * 初始化数据。
  82 + * @throws Exception
  83 + */
  84 + @Before
  85 + public void initDbunitDataSet() throws Exception {
  86 + LOG.info("junit setup:dbunit-载入测试数据!===>");
  87 + IDatabaseConnection connection = getConnection();
  88 + DatabaseOperation.CLEAN_INSERT.execute(connection, getDataSet());
  89 + connection.close();
  90 + }
  91 +
  92 + /**
  93 + * 销毁测试数据。
  94 + * @throws Exception
  95 + */
  96 + @After
  97 + public void afterDbunitDataSet() throws Exception {
  98 + LOG.info("===>junit teardown:dbunit-销毁测试数据!");
  99 + IDatabaseConnection connection = getConnection();
  100 + // 使用FilteredDataSet重新定义数据库,否则删除的时候会发生外健依赖错误
  101 + // 因为默认删除是按照表名字母顺序删除的,如果外健关联的表先删除,则发生外健约束错误
  102 + IDataSet fullDataSet = new FilteredDataSet(new DatabaseSequenceFilter(connection), connection.createDataSet());
  103 + DatabaseOperation.DELETE_ALL.execute(connection, fullDataSet);
  104 + connection.close();
  105 + }
  106 +
  107 + @Autowired
  108 + private DataSource dataSource;
  109 + /**
  110 + * 获取数据源。
  111 + * @return
  112 + */
  113 + public DataSource getDataSource() {
  114 + return dataSource;
  115 + }
  116 +
  117 + /**
  118 + * 获取Dbunit测试数据文件xml映射,key=测试方法名,value=dbunit测试文件classpath
  119 + * key:子类testCase方法名
  120 + * value:dbunit数据文件classpath(如:db/testdata/dbunit_testdata1.xml)
  121 + * @return
  122 + */
  123 + public abstract Map<String, String> getDbunitTestDbFileClassPathMap();
  124 +}
src/test/java/com/bsth/TestApplication.java 0 → 100644
  1 +package com.bsth;
  2 +
  3 +import org.springframework.boot.CommandLineRunner;
  4 +import org.springframework.boot.SpringApplication;
  5 +import org.springframework.boot.autoconfigure.SpringBootApplication;
  6 +import org.springframework.context.annotation.ComponentScan;
  7 +import org.springframework.context.annotation.FilterType;
  8 +import org.springframework.transaction.annotation.EnableTransactionManagement;
  9 +
  10 +/**
  11 + * 测试用的SpringBoot启动类。
  12 + */
  13 +@EnableTransactionManagement
  14 +@SpringBootApplication
  15 +@ComponentScan(excludeFilters = {
  16 + @ComponentScan.Filter(
  17 + type = FilterType.ASSIGNABLE_TYPE,
  18 + value = { Application.class, StartCommand.class, WebAppConfiguration.class, XDApplication.class }
  19 + ),
  20 + @ComponentScan.Filter(
  21 + type = FilterType.CUSTOM,
  22 + classes = { TestApplicationTypeFillter.class }
  23 + )
  24 +})
  25 +public class TestApplication implements CommandLineRunner {
  26 + @Override
  27 + public void run(String... args) throws Exception {
  28 + // TODO:其他初始化代码
  29 + }
  30 +
  31 + public static void main(String[] args) throws Exception {
  32 + SpringApplication.run(TestApplication.class, args);
  33 + }
  34 +}
src/test/java/com/bsth/TestApplicationTypeFillter.java 0 → 100644
  1 +package com.bsth;
  2 +
  3 +import org.springframework.core.io.Resource;
  4 +import org.springframework.core.type.AnnotationMetadata;
  5 +import org.springframework.core.type.ClassMetadata;
  6 +import org.springframework.core.type.classreading.MetadataReader;
  7 +import org.springframework.core.type.classreading.MetadataReaderFactory;
  8 +import org.springframework.core.type.filter.TypeFilter;
  9 +
  10 +import java.io.IOException;
  11 +
  12 +public class TestApplicationTypeFillter implements TypeFilter {
  13 + private ClassMetadata classMetadata;
  14 +
  15 + /**
  16 + * MetadataReader 读取到当前正在扫描类的信息
  17 + * MetadataReaderFactory 可以获取到其他任何类信息
  18 + */
  19 + @Override
  20 + public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException {
  21 + //获取当前类注解的信息
  22 + AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
  23 + //获取当前正在扫描的类信息
  24 + classMetadata = metadataReader.getClassMetadata();
  25 + //获取当前类资源(类的路径)
  26 + Resource resource = metadataReader.getResource();
  27 +
  28 + String className = classMetadata.getClassName();
  29 + System.out.println("----->" + className);
  30 + //当类包含Buy字符, 则匹配成功,返回true
  31 + //excludeFilters返回true---->会被过滤掉
  32 + //includeFilters返回true---->会通过
  33 +// if (className.contains("Buy")) {
  34 +// return false;
  35 +// }
  36 + if (className.contains("com.bsth.repository")) {
  37 + return false;
  38 + }
  39 + if (className.contains("com.bsth.service.schedule.plan")) {
  40 + return false;
  41 + }
  42 + return true;
  43 +
  44 + }
  45 +}
src/test/java/com/bsth/entity/Business.java 0 → 100644
  1 +package com.bsth.entity;
  2 +
  3 +import javax.persistence.*;
  4 +import java.util.Date;
  5 +
  6 +/**
  7 + *
  8 + * @ClassName : Business(公司实体类)
  9 + *
  10 + * @Author : bsth@lq
  11 + *
  12 + * @Description : TODO(公司信息)
  13 + *
  14 + * @Data : 2016-04-27
  15 + *
  16 + * @Version 公交调度系统BS版 0.1
  17 + *
  18 + */
  19 +
  20 +@Entity
  21 +@Table(name = "bsth_c_business")
  22 +public class Business {
  23 +
  24 + // ID
  25 + @Id
  26 + @GeneratedValue(strategy = GenerationType.IDENTITY)
  27 + private Integer id;
  28 +
  29 + // 企业<公司>名称
  30 + private String businessName;
  31 +
  32 + // 企业<公司>代码
  33 + private String businessCode;
  34 +
  35 + // 所属企业<公司>代码
  36 + private String upCode;
  37 +
  38 + // 描述
  39 + private String descriptions;
  40 +
  41 + // 创建日期
  42 +// @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
  43 + @Column(updatable = false, name = "create_date")
  44 + private Date createDate;
  45 +
  46 + // 修改日期
  47 +// @Column(name = "update_date", columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
  48 + @Column(name = "update_date")
  49 + private Date updateDate;
  50 + public Date getCreateDate() {
  51 + return createDate;
  52 + }
  53 +
  54 + public void setCreateDate(Date createDate) {
  55 + this.createDate = createDate;
  56 + }
  57 +
  58 + public Date getUpdateDate() {
  59 + return updateDate;
  60 + }
  61 +
  62 + public void setUpdateDate(Date updateDate) {
  63 + this.updateDate = updateDate;
  64 + }
  65 +
  66 + public Integer getId() {
  67 + return id;
  68 + }
  69 +
  70 + public void setId(Integer id) {
  71 + this.id = id;
  72 + }
  73 +
  74 + public String getBusinessName() {
  75 + return businessName;
  76 + }
  77 +
  78 + public void setBusinessName(String businessName) {
  79 + this.businessName = businessName;
  80 + }
  81 +
  82 + public String getBusinessCode() {
  83 + return businessCode;
  84 + }
  85 +
  86 + public void setBusinessCode(String businessCode) {
  87 + this.businessCode = businessCode;
  88 + }
  89 +
  90 + public String getUpCode() {
  91 + return upCode;
  92 + }
  93 +
  94 + public void setUpCode(String upCode) {
  95 + this.upCode = upCode;
  96 + }
  97 +
  98 + public String getDescriptions() {
  99 + return descriptions;
  100 + }
  101 +
  102 + public void setDescriptions(String descriptions) {
  103 + this.descriptions = descriptions;
  104 + }
  105 +}
src/test/java/com/bsth/entity/CarPark.java 0 → 100644
  1 +package com.bsth.entity;
  2 +
  3 +import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  4 +import org.hibernate.annotations.Formula;
  5 +
  6 +import javax.persistence.*;
  7 +import java.util.Date;
  8 +
  9 +
  10 +/**
  11 + *
  12 + * @ClassName: CarPark(停车场类)
  13 + *
  14 + * @Description: TODO(停车场)
  15 + *
  16 + * @Author bsth@lq
  17 + *
  18 + * @Date 2016-06-01 16:06:17
  19 + *
  20 + * @Version 公交调度系统BS版 0.1
  21 + *
  22 + */
  23 +
  24 +@Entity
  25 +@Table(name = "bsth_c_car_park")
  26 +@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"})
  27 +public class CarPark {
  28 +
  29 + @Id
  30 + @GeneratedValue
  31 + private Integer id;
  32 +
  33 + // 停车场编号
  34 + private String parkCode;
  35 +
  36 + // 停车场名称
  37 + private String parkName;
  38 +
  39 + // 地理位置(百度坐标)
  40 + private String bParkPoint;
  41 +
  42 + // 地理位置中心点(百度坐标)
  43 + private String bCenterPoint;
  44 +
  45 + // 地理位置(WGS坐标)
  46 + private String gParkPoint;
  47 +
  48 + // 地理位置中心点(WGS坐标)
  49 + private String gCenterPoint;
  50 +
  51 + /**
  52 + * 经纬坐标类型
  53 + *
  54 + * --------- b:百度坐标系
  55 + *
  56 + * --------- d:高德坐标系
  57 + */
  58 + private String dbType;
  59 +
  60 + /**
  61 + * 图形类型
  62 + *
  63 + * ------ r:圆形
  64 + *
  65 + * ------ p:多边形
  66 + */
  67 + private String shapesType;
  68 +
  69 + // 圆形半径
  70 + private Integer radius;
  71 +
  72 + // 面积
  73 + private double area;
  74 +
  75 + // 所属公司
  76 + private String company;
  77 +
  78 + // 分公司
  79 + private String brancheCompany;
  80 +
  81 + /** 组合公司分公司编码 */
  82 + @Formula(" concat(company, '_', branche_company) ")
  83 + private String cgsbm;
  84 +
  85 + // 是否撤销
  86 + private Integer destroy;
  87 +
  88 + // 版本号
  89 + private Integer versions;
  90 +
  91 + // 描述
  92 + private String descriptions;
  93 +
  94 + // 创建人
  95 + private Integer createBy;
  96 +
  97 + // 修改人
  98 + private Integer updateBy;
  99 +
  100 + // 创建日期
  101 +// @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
  102 + @Column(updatable = false, name = "create_date")
  103 + private Date createDate;
  104 +
  105 + // 修改日期
  106 +// @Column(name = "update_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
  107 + @Column(name = "update_date")
  108 + private Date updateDate;
  109 +
  110 + public String getCgsbm() {
  111 + return cgsbm;
  112 + }
  113 +
  114 + public void setCgsbm(String cgsbm) {
  115 + this.cgsbm = cgsbm;
  116 + }
  117 +
  118 + public Integer getId() {
  119 + return id;
  120 + }
  121 +
  122 + public void setId(Integer id) {
  123 + this.id = id;
  124 + }
  125 +
  126 + public String getParkCode() {
  127 + return parkCode;
  128 + }
  129 +
  130 + public void setParkCode(String parkCode) {
  131 + this.parkCode = parkCode;
  132 + }
  133 +
  134 + public String getParkName() {
  135 + return parkName;
  136 + }
  137 +
  138 + public void setParkName(String parkName) {
  139 + this.parkName = parkName;
  140 + }
  141 +
  142 + public String getbParkPoint() {
  143 + return bParkPoint;
  144 + }
  145 +
  146 + public void setbParkPoint(String bParkPoint) {
  147 + this.bParkPoint = bParkPoint;
  148 + }
  149 +
  150 + public String getbCenterPoint() {
  151 + return bCenterPoint;
  152 + }
  153 +
  154 + public void setbCenterPoint(String bCenterPoint) {
  155 + this.bCenterPoint = bCenterPoint;
  156 + }
  157 +
  158 + public String getgParkPoint() {
  159 + return gParkPoint;
  160 + }
  161 +
  162 + public void setgParkPoint(String gParkPoint) {
  163 + this.gParkPoint = gParkPoint;
  164 + }
  165 +
  166 + public String getDbType() {
  167 + return dbType;
  168 + }
  169 +
  170 + public void setDbType(String dbType) {
  171 + this.dbType = dbType;
  172 + }
  173 +
  174 + public String getShapesType() {
  175 + return shapesType;
  176 + }
  177 +
  178 + public void setShapesType(String shapesType) {
  179 + this.shapesType = shapesType;
  180 + }
  181 +
  182 + public Integer getRadius() {
  183 + return radius;
  184 + }
  185 +
  186 + public void setRadius(Integer radius) {
  187 + this.radius = radius;
  188 + }
  189 +
  190 + public String getgCenterPoint() {
  191 + return gCenterPoint;
  192 + }
  193 +
  194 + public void setgCenterPoint(String gCenterPoint) {
  195 + this.gCenterPoint = gCenterPoint;
  196 + }
  197 +
  198 + public double getArea() {
  199 + return area;
  200 + }
  201 +
  202 + public void setArea(double area) {
  203 + this.area = area;
  204 + }
  205 +
  206 + public String getBrancheCompany() {
  207 + return brancheCompany;
  208 + }
  209 +
  210 + public void setBrancheCompany(String brancheCompany) {
  211 + this.brancheCompany = brancheCompany;
  212 + }
  213 +
  214 + public String getCompany() {
  215 + return company;
  216 + }
  217 +
  218 + public void setCompany(String company) {
  219 + this.company = company;
  220 + }
  221 +
  222 + public Integer getDestroy() {
  223 + return destroy;
  224 + }
  225 +
  226 + public void setDestroy(Integer destroy) {
  227 + this.destroy = destroy;
  228 + }
  229 +
  230 + public Integer getVersions() {
  231 + return versions;
  232 + }
  233 +
  234 + public void setVersions(Integer versions) {
  235 + this.versions = versions;
  236 + }
  237 +
  238 + public String getDescriptions() {
  239 + return descriptions;
  240 + }
  241 +
  242 + public void setDescriptions(String descriptions) {
  243 + this.descriptions = descriptions;
  244 + }
  245 +
  246 + public Integer getCreateBy() {
  247 + return createBy;
  248 + }
  249 +
  250 + public void setCreateBy(Integer createBy) {
  251 + this.createBy = createBy;
  252 + }
  253 +
  254 + public Integer getUpdateBy() {
  255 + return updateBy;
  256 + }
  257 +
  258 + public void setUpdateBy(Integer updateBy) {
  259 + this.updateBy = updateBy;
  260 + }
  261 +
  262 + public Date getCreateDate() {
  263 + return createDate;
  264 + }
  265 +
  266 + public void setCreateDate(Date createDate) {
  267 + this.createDate = createDate;
  268 + }
  269 +
  270 + public Date getUpdateDate() {
  271 + return updateDate;
  272 + }
  273 +
  274 + public void setUpdateDate(Date updateDate) {
  275 + this.updateDate = updateDate;
  276 + }
  277 +
  278 +}
src/test/java/com/bsth/entity/Line.java 0 → 100644
  1 +package com.bsth.entity;
  2 +
  3 +import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  4 +import org.hibernate.annotations.Formula;
  5 +import org.springframework.format.annotation.DateTimeFormat;
  6 +
  7 +import javax.persistence.*;
  8 +import java.io.Serializable;
  9 +import java.util.Date;
  10 +
  11 +
  12 +/**
  13 + *
  14 + * @ClassName: Line(线路实体类)
  15 + *
  16 + * @Description: TODO(线路)
  17 + *
  18 + * @Author bsth@lq
  19 + *
  20 + * @Date 2016-4-11 16:06:17
  21 + *
  22 + * @Version 公交调度系统BS版 0.1
  23 + *
  24 + */
  25 +
  26 +@Entity
  27 +@Table(name = "bsth_c_line")
  28 +@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"})
  29 +public class Line implements Serializable {
  30 +
  31 + @Id
  32 + /** 线路ID 主键(唯一标识符) int length(11) */
  33 + private Integer id;
  34 +
  35 + /** 线路名称 varchar length(50) 不能为空 */
  36 + private String name;
  37 +
  38 + /** 线路编码 varchar length(50) 不能为空 */
  39 + private String lineCode;
  40 +
  41 + /** 英文名 varchar length(50) */
  42 + private String es;
  43 +
  44 + /** 简称 varchar length(50) */
  45 + private String shortName;
  46 +
  47 + /** 起始站名称 varchar length(50) 不能为空
  48 + * 该字段值会在规划线路站点操作时会去验证是否有值。如果为空,则用线路规划站点的起点站。默认使用该字段填写值 */
  49 + private String startStationName;
  50 +
  51 + /** 终点站名称 varchar length(50) 不能为空
  52 + * 该字段值会在规划线路站点操作时会去验证是否有值。如果为空,则用线路规划站点的起点站。默认使用该字段填写值 */
  53 + private String endStationName;
  54 +
  55 + /** 起始站首班车时间 00:00 上海公交APP中某个接口所需要的字段值 varchar length(50) 不能为空 */
  56 + private String startStationFirstTime;
  57 +
  58 + /** 起始站末班车时间 00:00 上海公交APP中某个接口所需要的字段值 varchar length(50) 不能为空 */
  59 + private String startStationEndTime;
  60 +
  61 + /** 终点站首班时间 00:00 上海公交APP中某个接口所需要的字段值 varchar length(50) 不能为空*/
  62 + private String endStationFirstTime;
  63 +
  64 + /** 终点站末班时间 00:00 上海公交APP中某个接口所需要的字段值 */
  65 + private String endStationEndTime;
  66 +
  67 + /** 所属公司 varchar length(50) */
  68 + private String company;
  69 +
  70 + /** 分公司 varchar length(50)*/
  71 + private String brancheCompany;
  72 +
  73 + /** 组合公司分公司编码 */
  74 + @Formula(" concat(company, '_', branche_company) ")
  75 + private String cgsbm;
  76 +
  77 + /** 性质(线路类型) varchar length(50) */
  78 + private String nature;
  79 +
  80 + /** 线路等级 varchar length(50) */
  81 + private String level;
  82 +
  83 + /** 线路长度 */
  84 + private double length;
  85 +
  86 + /** 线路负责人 varchar length(50) */
  87 + private String chargeName;
  88 +
  89 + /** 负责人电话 varchar length(50) */
  90 + private String telephone;
  91 +
  92 + /** 是否撤销 <1:是;0:否> bit length(50) */
  93 + private Integer destroy;
  94 +
  95 + /** 是否夜宵线 <1:是;0:否> bit length(50)*/
  96 + private Integer supperLine;
  97 +
  98 + /** 是否营运 <1:是;0:否> bit length(50)*/
  99 + private Integer sfyy;
  100 +
  101 + /** 线路区域 <0:区内,1:区外> bit length(1)*/
  102 + private Integer region;
  103 +
  104 + /** 起始调度电话 varchar length(50) */
  105 + private String startPhone;
  106 +
  107 + /** 终点调度电话 varchar length(50) */
  108 + private String endPhone;
  109 +
  110 + /** 开辟日期 date*/
  111 + @DateTimeFormat(pattern ="yyyy-MM-dd")
  112 + private Date openDate;
  113 +
  114 + /** 大间隔等级 */
  115 + private Integer spacGrade;
  116 +
  117 + /** 线路沿革 varchar length(50) */
  118 + private String history;
  119 +
  120 + /** 上海市线路编码 varchar length(50) */
  121 + private String shanghaiLinecode;
  122 +
  123 + /** 设备线路编码 varchar length(50) */
  124 + private String eqLinecode;
  125 +
  126 + /** 配置车辆总数 老版本系统字段, 新版本系统业务需求暂时没用到该字段 ,这里暂时留着 int length(11)*/
  127 + private Integer carSumNumber;
  128 +
  129 + /** 空调车辆数量 老版本系统字段, 新版本系统业务需求暂时没用到该字段 ,这里暂时留着 int length(11) */
  130 + private Integer hvacCarNumber;
  131 +
  132 + /** 普通车辆数量 老版本系统字段, 新版本系统业务需求暂时没用到该字段 ,这里暂时留着 int length(11) */
  133 + private Integer ordCarNumber;
  134 +
  135 + /** 权证车辆数量 报表需要的字段值 */
  136 + private Integer warrantCar;
  137 +
  138 + /** 权证配车启用日期 报表需要的字段值 */
  139 + private Integer warrantDate;
  140 +
  141 + /** 停车场编码 老版本系统字段, 新版本系统业务需求暂时没用到该字段 ,这里暂时留着 int length(11) */
  142 + private String carParkCode;
  143 +
  144 + /** 线路规划类型 <0:双向;1:环线> int length(11) 运管处接口需要的字段 不能为空 */
  145 + private Integer linePlayType;
  146 +
  147 + /** 描述 varchar length(255) */
  148 + private String descriptions;
  149 +
  150 + /** 创建人 int length(11) */
  151 + private Integer createBy;
  152 +
  153 + /** 修改人 int length(11) */
  154 + private Integer updateBy;
  155 +
  156 + /** 创建日期 timestamp */
  157 +// @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
  158 + @Column(updatable = false, name = "create_date")
  159 + private Date createDate;
  160 +
  161 + /** 修改日期 timestamp */
  162 +// @Column(name = "update_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
  163 + @Column(name = "update_date")
  164 + private Date updateDate;
  165 +
  166 + /** 是否在使用 <1:是;0:否> bit length(50) */
  167 + private Integer inUse;
  168 +
  169 + /**
  170 + * 逻辑删除标记 为 1:标识已删除
  171 + */
  172 + private Integer remove = 0;
  173 +
  174 + public Integer getSpacGrade() {
  175 + return spacGrade;
  176 + }
  177 +
  178 + public void setSpacGrade(Integer spacGrade) {
  179 + this.spacGrade = spacGrade;
  180 + }
  181 +
  182 + public Integer getWarrantCar() {
  183 + return warrantCar;
  184 + }
  185 +
  186 + public void setWarrantCar(Integer warrantCar) {
  187 + this.warrantCar = warrantCar;
  188 + }
  189 +
  190 + public Integer getWarrantDate() {
  191 + return warrantDate;
  192 + }
  193 +
  194 + public void setWarrantDate(Integer warrantDate) {
  195 + this.warrantDate = warrantDate;
  196 + }
  197 +
  198 + public Integer getLinePlayType() {
  199 + return linePlayType;
  200 + }
  201 +
  202 + public void setLinePlayType(Integer linePlayType) {
  203 + this.linePlayType = linePlayType;
  204 + }
  205 +
  206 + public Integer getId() {
  207 + return id;
  208 + }
  209 +
  210 + public void setId(Integer id) {
  211 + this.id = id;
  212 + }
  213 +
  214 + public String getLineCode() {
  215 + return lineCode;
  216 + }
  217 +
  218 + public void setLineCode(String lineCode) {
  219 + this.lineCode = lineCode;
  220 + }
  221 +
  222 + public String getName() {
  223 + return name;
  224 + }
  225 +
  226 + public void setName(String name) {
  227 + this.name = name;
  228 + }
  229 +
  230 + public String getEs() {
  231 + return es;
  232 + }
  233 +
  234 + public void setEs(String es) {
  235 + this.es = es;
  236 + }
  237 +
  238 + public String getShortName() {
  239 + return shortName;
  240 + }
  241 +
  242 + public void setShortName(String shortName) {
  243 + this.shortName = shortName;
  244 + }
  245 +
  246 + public Integer getCarSumNumber() {
  247 + return carSumNumber;
  248 + }
  249 +
  250 + public void setCarSumNumber(Integer carSumNumber) {
  251 + this.carSumNumber = carSumNumber;
  252 + }
  253 +
  254 + public Integer getHvacCarNumber() {
  255 + return hvacCarNumber;
  256 + }
  257 +
  258 + public void setHvacCarNumber(Integer hvacCarNumber) {
  259 + this.hvacCarNumber = hvacCarNumber;
  260 + }
  261 +
  262 + public Integer getOrdCarNumber() {
  263 + return ordCarNumber;
  264 + }
  265 +
  266 + public void setOrdCarNumber(Integer ordCarNumber) {
  267 + this.ordCarNumber = ordCarNumber;
  268 + }
  269 +
  270 + public String getCarParkCode() {
  271 + return carParkCode;
  272 + }
  273 +
  274 + public void setCarParkCode(String carParkCode) {
  275 + this.carParkCode = carParkCode;
  276 + }
  277 +
  278 + public String getStartStationName() {
  279 + return startStationName;
  280 + }
  281 +
  282 + public void setStartStationName(String startStationName) {
  283 + this.startStationName = startStationName;
  284 + }
  285 +
  286 + public String getStartStationFirstTime() {
  287 + return startStationFirstTime;
  288 + }
  289 +
  290 + public void setStartStationFirstTime(String startStationFirstTime) {
  291 + this.startStationFirstTime = startStationFirstTime;
  292 + }
  293 +
  294 + public String getStartStationEndTime() {
  295 + return startStationEndTime;
  296 + }
  297 +
  298 + public void setStartStationEndTime(String startStationEndTime) {
  299 + this.startStationEndTime = startStationEndTime;
  300 + }
  301 +
  302 + public String getEndStationName() {
  303 + return endStationName;
  304 + }
  305 +
  306 + public void setEndStationName(String endStationName) {
  307 + this.endStationName = endStationName;
  308 + }
  309 +
  310 + public String getEndStationFirstTime() {
  311 + return endStationFirstTime;
  312 + }
  313 +
  314 + public void setEndStationFirstTime(String endStationFirstTime) {
  315 + this.endStationFirstTime = endStationFirstTime;
  316 + }
  317 +
  318 + public String getEndStationEndTime() {
  319 + return endStationEndTime;
  320 + }
  321 +
  322 + public void setEndStationEndTime(String endStationEndTime) {
  323 + this.endStationEndTime = endStationEndTime;
  324 + }
  325 +
  326 + public String getCompany() {
  327 + return company;
  328 + }
  329 +
  330 + public void setCompany(String company) {
  331 + this.company = company;
  332 + }
  333 +
  334 + public String getBrancheCompany() {
  335 + return brancheCompany;
  336 + }
  337 +
  338 + public void setBrancheCompany(String brancheCompany) {
  339 + this.brancheCompany = brancheCompany;
  340 + }
  341 +
  342 + public String getNature() {
  343 + return nature;
  344 + }
  345 +
  346 + public void setNature(String nature) {
  347 + this.nature = nature;
  348 + }
  349 +
  350 + public String getLevel() {
  351 + return level;
  352 + }
  353 +
  354 + public void setLevel(String level) {
  355 + this.level = level;
  356 + }
  357 +
  358 + public double getLength() {
  359 + return length;
  360 + }
  361 +
  362 + public void setLength(double length) {
  363 + this.length = length;
  364 + }
  365 +
  366 + public String getChargeName() {
  367 + return chargeName;
  368 + }
  369 +
  370 + public void setChargeName(String chargeName) {
  371 + this.chargeName = chargeName;
  372 + }
  373 +
  374 + public String getTelephone() {
  375 + return telephone;
  376 + }
  377 +
  378 + public void setTelephone(String telephone) {
  379 + this.telephone = telephone;
  380 + }
  381 +
  382 + public Integer getDestroy() {
  383 + return destroy;
  384 + }
  385 +
  386 + public void setDestroy(Integer destroy) {
  387 + this.destroy = destroy;
  388 + }
  389 +
  390 + public Integer getSupperLine() {
  391 + return supperLine;
  392 + }
  393 +
  394 + public void setSupperLine(Integer supperLine) {
  395 + this.supperLine = supperLine;
  396 + }
  397 +
  398 + public String getStartPhone() {
  399 + return startPhone;
  400 + }
  401 +
  402 + public void setStartPhone(String startPhone) {
  403 + this.startPhone = startPhone;
  404 + }
  405 +
  406 + public String getEndPhone() {
  407 + return endPhone;
  408 + }
  409 +
  410 + public void setEndPhone(String endPhone) {
  411 + this.endPhone = endPhone;
  412 + }
  413 +
  414 + public Date getOpenDate() {
  415 + return openDate;
  416 + }
  417 +
  418 + public void setOpenDate(Date openDate) {
  419 + this.openDate = openDate;
  420 + }
  421 +
  422 + public String getHistory() {
  423 + return history;
  424 + }
  425 +
  426 + public void setHistory(String history) {
  427 + this.history = history;
  428 + }
  429 +
  430 + public String getShanghaiLinecode() {
  431 + return shanghaiLinecode;
  432 + }
  433 +
  434 + public void setShanghaiLinecode(String shanghaiLinecode) {
  435 + this.shanghaiLinecode = shanghaiLinecode;
  436 + }
  437 +
  438 + public String getEqLinecode() {
  439 + return eqLinecode;
  440 + }
  441 +
  442 + public void setEqLinecode(String eqLinecode) {
  443 + this.eqLinecode = eqLinecode;
  444 + }
  445 +
  446 + public String getDescriptions() {
  447 + return descriptions;
  448 + }
  449 +
  450 + public void setDescriptions(String descriptions) {
  451 + this.descriptions = descriptions;
  452 + }
  453 +
  454 + public Integer getCreateBy() {
  455 + return createBy;
  456 + }
  457 +
  458 + public void setCreateBy(Integer createBy) {
  459 + this.createBy = createBy;
  460 + }
  461 +
  462 + public Integer getUpdateBy() {
  463 + return updateBy;
  464 + }
  465 +
  466 + public void setUpdateBy(Integer updateBy) {
  467 + this.updateBy = updateBy;
  468 + }
  469 +
  470 + public Date getCreateDate() {
  471 + return createDate;
  472 + }
  473 +
  474 + public void setCreateDate(Date createDate) {
  475 + this.createDate = createDate;
  476 + }
  477 +
  478 + public Date getUpdateDate() {
  479 + return updateDate;
  480 + }
  481 +
  482 + public void setUpdateDate(Date updateDate) {
  483 + this.updateDate = updateDate;
  484 + }
  485 +
  486 + public Integer getInUse() { return inUse; }
  487 +
  488 + public void setInUse(Integer inUse) { this.inUse = inUse; }
  489 +
  490 + public String getCgsbm() {
  491 + return cgsbm;
  492 + }
  493 +
  494 + public void setCgsbm(String cgsbm) {
  495 + this.cgsbm = cgsbm;
  496 + }
  497 +
  498 + public Integer getSfyy() {
  499 + return sfyy;
  500 + }
  501 +
  502 + public void setSfyy(Integer sfyy) {
  503 + this.sfyy = sfyy;
  504 + }
  505 +
  506 + public Integer getRegion() {
  507 + return region;
  508 + }
  509 +
  510 + public void setRegion(Integer region) {
  511 + this.region = region;
  512 + }
  513 +
  514 + public Integer getRemove() {
  515 + return remove;
  516 + }
  517 +
  518 + public void setRemove(Integer remove) {
  519 + this.remove = remove;
  520 + }
  521 +}
src/test/java/com/bsth/entity/LineInformation.java 0 → 100644
  1 +package com.bsth.entity;
  2 +
  3 +import javax.persistence.*;
  4 +import java.util.Date;
  5 +
  6 +/**
  7 + *
  8 + * @ClassName: LineInformation(线路标准信息实体类)
  9 + *
  10 + * @Description: TODO(线路标准信息)
  11 + *
  12 + * @Author bsth@lq
  13 + *
  14 + * @Date 2016-4-12 9:34:39
  15 + *
  16 + * @Version 公交调度系统BS版 0.1
  17 + *
  18 + */
  19 +@Entity
  20 +@Table(name = "bsth_c_line_information")
  21 +public class LineInformation {
  22 +
  23 + @Id
  24 + @GeneratedValue(strategy = GenerationType.IDENTITY)
  25 + private Integer id;
  26 +
  27 + // 线路标准信息类型
  28 + private String type;
  29 +
  30 + // 标准总里程
  31 + private Double totalMileage;
  32 +
  33 + // 空放里程
  34 + private Double emptyMileage;
  35 +
  36 + // 上行里程
  37 + private Double upMileage;
  38 +
  39 + // 下行里程
  40 + private Double downMileage;
  41 +
  42 + // 上行行驶时间
  43 + private Double upTravelTime;
  44 +
  45 + // 下行行驶时间
  46 + private Double downTravelTime;
  47 +
  48 + // 早高峰开始时间 00:00
  49 + private String earlyStartTime;
  50 +
  51 + // 早高峰结束时间 00:00
  52 + private String earlyEndTime;
  53 +
  54 + // 晚高峰开始时间 00:00
  55 + private String lateStartTime;
  56 +
  57 + // 晚高峰结束时间 00:00
  58 + private String lateEndTime;
  59 +
  60 + // 小夜高峰开始时间 00:00
  61 + private String xygfkssj;
  62 +
  63 + // 小夜高峰结束时间 00:00
  64 + private String xygfjssj;
  65 +
  66 + // 早高峰上行行驶时间
  67 + private Double earlyUpTime;
  68 +
  69 + // 早高峰下行行驶时间
  70 + private Double earlyDownTime;
  71 +
  72 + // 晚高峰上行行驶时间
  73 + private Double lateUpTime;
  74 +
  75 + // 晚高峰下行行驶时间
  76 + private Double lateDownTime;
  77 +
  78 + // 小夜高峰上行行驶时间
  79 + private Double nightStartTime;
  80 +
  81 + // 小夜高峰下行行驶时间
  82 + private Double nightEndTime;
  83 +
  84 + // 低谷上行行驶时间
  85 + private Double troughUpTime;
  86 +
  87 + // 低谷下行行驶时间
  88 + private Double troughDownTime;
  89 +
  90 + // 停车场
  91 + private String carPark;
  92 +
  93 + // 上行进场时间
  94 + private Double upInTimer;
  95 +
  96 + // 上行出场时间
  97 + private Double upOutTimer;
  98 +
  99 + // 下行进场时间
  100 + private Double downInTimer;
  101 +
  102 + // 下行出场时间
  103 + private Double downOutTimer;
  104 +
  105 + // 上行进场里程
  106 + private Double upInMileage;
  107 +
  108 + // 上行出场里程
  109 + private Double upOutMileage;
  110 +
  111 + // 下行进场里程
  112 + private Double downInMileage;
  113 +
  114 + // 下行出场里程
  115 + private Double downOutMileage;
  116 +
  117 + // 早高峰大间隔(分钟)老调度系统字段,暂时保留
  118 + private Double earlyIntervalLg;
  119 +
  120 + // 晚高峰大间隔(分钟)老调度系统字段,暂时保留
  121 + private Double lateIntervalLg;
  122 +
  123 + // 平时大间隔(分钟)老调度系统字段,暂时保留
  124 + private Double intervalLg;
  125 +
  126 + // 限速(平时)老调度系统字段,暂时保留
  127 + private Double speedLimit;
  128 +
  129 + // 限速(雨天)老调度系统字段,暂时保留
  130 + private Double rainLimit;
  131 +
  132 + // 限速(大雾)老调度系统字段,暂时保留
  133 + private Double fogLimit;
  134 +
  135 + // 限速(冰雪)老调度系统字段,暂时保留
  136 + private Double snowLimit;
  137 +
  138 + // 限速(节庆)老调度系统字段,暂时保留
  139 + private Double festivalSpeedLimit;
  140 +
  141 + // 滞站
  142 + private Integer lagStation;
  143 +
  144 + // 越站
  145 + private Integer skip;
  146 +
  147 + // 超速
  148 + private Integer speeding;
  149 +
  150 + // 串线
  151 + private Integer crossedLine;
  152 +
  153 + // 越界
  154 + private Integer overflights;
  155 +
  156 + // 描述
  157 + private String descriptions;
  158 +
  159 + // 创建人
  160 + private Integer createBy;
  161 +
  162 + // 修改人
  163 + private Integer updateBy;
  164 +
  165 + // 创建日期
  166 +// @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
  167 + @Column(updatable = false, name = "create_date")
  168 + private Date createDate;
  169 +
  170 + // 修改日期
  171 +// @Column(name = "update_date", columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
  172 + @Column(name = "update_date")
  173 + private Date updateDate;
  174 +
  175 + @ManyToOne
  176 + private Line line;
  177 +
  178 + public String getXygfkssj() {
  179 + return xygfkssj;
  180 + }
  181 +
  182 + public void setXygfkssj(String xygfkssj) {
  183 + this.xygfkssj = xygfkssj;
  184 + }
  185 +
  186 + public String getXygfjssj() {
  187 + return xygfjssj;
  188 + }
  189 +
  190 + public void setXygfjssj(String xygfjssj) {
  191 + this.xygfjssj = xygfjssj;
  192 + }
  193 +
  194 + public Double getUpInTimer() {
  195 + return upInTimer;
  196 + }
  197 +
  198 + public void setUpInTimer(Double upInTimer) {
  199 + this.upInTimer = upInTimer;
  200 + }
  201 +
  202 + public Double getUpOutTimer() {
  203 + return upOutTimer;
  204 + }
  205 +
  206 + public void setUpOutTimer(Double upOutTimer) {
  207 + this.upOutTimer = upOutTimer;
  208 + }
  209 +
  210 + public Double getDownInTimer() {
  211 + return downInTimer;
  212 + }
  213 +
  214 + public void setDownInTimer(Double downInTimer) {
  215 + this.downInTimer = downInTimer;
  216 + }
  217 +
  218 + public Double getDownOutTimer() {
  219 + return downOutTimer;
  220 + }
  221 +
  222 + public void setDownOutTimer(Double downOutTimer) {
  223 + this.downOutTimer = downOutTimer;
  224 + }
  225 +
  226 + public Double getUpInMileage() {
  227 + return upInMileage;
  228 + }
  229 +
  230 + public void setUpInMileage(Double upInMileage) {
  231 + this.upInMileage = upInMileage;
  232 + }
  233 +
  234 + public Double getUpOutMileage() {
  235 + return upOutMileage;
  236 + }
  237 +
  238 + public void setUpOutMileage(Double upOutMileage) {
  239 + this.upOutMileage = upOutMileage;
  240 + }
  241 +
  242 + public Double getDownInMileage() {
  243 + return downInMileage;
  244 + }
  245 +
  246 + public void setDownInMileage(Double downInMileage) {
  247 + this.downInMileage = downInMileage;
  248 + }
  249 +
  250 + public Double getDownOutMileage() {
  251 + return downOutMileage;
  252 + }
  253 +
  254 + public void setDownOutMileage(Double downOutMileage) {
  255 + this.downOutMileage = downOutMileage;
  256 + }
  257 +
  258 + public Integer getId() {
  259 + return id;
  260 + }
  261 +
  262 + public void setId(Integer id) {
  263 + this.id = id;
  264 + }
  265 +
  266 + public String getType() {
  267 + return type;
  268 + }
  269 +
  270 + public void setType(String type) {
  271 + this.type = type;
  272 + }
  273 +
  274 + public Double getTotalMileage() {
  275 + return totalMileage;
  276 + }
  277 +
  278 + public void setTotalMileage(Double totalMileage) {
  279 + this.totalMileage = totalMileage;
  280 + }
  281 +
  282 + public Double getEmptyMileage() {
  283 + return emptyMileage;
  284 + }
  285 +
  286 + public void setEmptyMileage(Double emptyMileage) {
  287 + this.emptyMileage = emptyMileage;
  288 + }
  289 +
  290 + public Double getUpMileage() {
  291 + return upMileage;
  292 + }
  293 +
  294 + public void setUpMileage(Double upMileage) {
  295 + this.upMileage = upMileage;
  296 + }
  297 +
  298 + public Double getDownMileage() {
  299 + return downMileage;
  300 + }
  301 +
  302 + public void setDownMileage(Double downMileage) {
  303 + this.downMileage = downMileage;
  304 + }
  305 +
  306 + public Double getUpTravelTime() {
  307 + return upTravelTime;
  308 + }
  309 +
  310 + public void setUpTravelTime(Double upTravelTime) {
  311 + this.upTravelTime = upTravelTime;
  312 + }
  313 +
  314 + public Double getDownTravelTime() {
  315 + return downTravelTime;
  316 + }
  317 +
  318 + public void setDownTravelTime(Double downTravelTime) {
  319 + this.downTravelTime = downTravelTime;
  320 + }
  321 +
  322 + public String getEarlyStartTime() {
  323 + return earlyStartTime;
  324 + }
  325 +
  326 + public void setEarlyStartTime(String earlyStartTime) {
  327 + this.earlyStartTime = earlyStartTime;
  328 + }
  329 +
  330 + public String getEarlyEndTime() {
  331 + return earlyEndTime;
  332 + }
  333 +
  334 + public void setEarlyEndTime(String earlyEndTime) {
  335 + this.earlyEndTime = earlyEndTime;
  336 + }
  337 +
  338 + public String getLateStartTime() {
  339 + return lateStartTime;
  340 + }
  341 +
  342 + public void setLateStartTime(String lateStartTime) {
  343 + this.lateStartTime = lateStartTime;
  344 + }
  345 +
  346 + public String getLateEndTime() {
  347 + return lateEndTime;
  348 + }
  349 +
  350 + public void setLateEndTime(String lateEndTime) {
  351 + this.lateEndTime = lateEndTime;
  352 + }
  353 +
  354 + public Double getEarlyUpTime() {
  355 + return earlyUpTime;
  356 + }
  357 +
  358 + public void setEarlyUpTime(Double earlyUpTime) {
  359 + this.earlyUpTime = earlyUpTime;
  360 + }
  361 +
  362 + public Double getEarlyDownTime() {
  363 + return earlyDownTime;
  364 + }
  365 +
  366 + public void setEarlyDownTime(Double earlyDownTime) {
  367 + this.earlyDownTime = earlyDownTime;
  368 + }
  369 +
  370 + public Double getLateUpTime() {
  371 + return lateUpTime;
  372 + }
  373 +
  374 + public void setLateUpTime(Double lateUpTime) {
  375 + this.lateUpTime = lateUpTime;
  376 + }
  377 +
  378 + public Double getLateDownTime() {
  379 + return lateDownTime;
  380 + }
  381 +
  382 + public void setLateDownTime(Double lateDownTime) {
  383 + this.lateDownTime = lateDownTime;
  384 + }
  385 +
  386 + public Double getNightStartTime() {
  387 + return nightStartTime;
  388 + }
  389 +
  390 + public void setNightStartTime(Double nightStartTime) {
  391 + this.nightStartTime = nightStartTime;
  392 + }
  393 +
  394 + public Double getNightEndTime() {
  395 + return nightEndTime;
  396 + }
  397 +
  398 + public void setNightEndTime(Double nightEndTime) {
  399 + this.nightEndTime = nightEndTime;
  400 + }
  401 +
  402 + public Double getTroughUpTime() {
  403 + return troughUpTime;
  404 + }
  405 +
  406 + public void setTroughUpTime(Double troughUpTime) {
  407 + this.troughUpTime = troughUpTime;
  408 + }
  409 +
  410 + public Double getTroughDownTime() {
  411 + return troughDownTime;
  412 + }
  413 +
  414 + public void setTroughDownTime(Double troughDownTime) {
  415 + this.troughDownTime = troughDownTime;
  416 + }
  417 + public String getCarPark() {
  418 + return carPark;
  419 + }
  420 +
  421 + public void setCarPark(String carPark) {
  422 + this.carPark = carPark;
  423 + }
  424 + public Double getEarlyIntervalLg() {
  425 + return earlyIntervalLg;
  426 + }
  427 +
  428 + public void setEarlyIntervalLg(Double earlyIntervalLg) {
  429 + this.earlyIntervalLg = earlyIntervalLg;
  430 + }
  431 +
  432 + public Double getLateIntervalLg() {
  433 + return lateIntervalLg;
  434 + }
  435 +
  436 + public void setLateIntervalLg(Double lateIntervalLg) {
  437 + this.lateIntervalLg = lateIntervalLg;
  438 + }
  439 +
  440 + public Double getIntervalLg() {
  441 + return intervalLg;
  442 + }
  443 +
  444 + public void setIntervalLg(Double intervalLg) {
  445 + this.intervalLg = intervalLg;
  446 + }
  447 +
  448 + public Double getSpeedLimit() {
  449 + return speedLimit;
  450 + }
  451 +
  452 + public void setSpeedLimit(Double speedLimit) {
  453 + this.speedLimit = speedLimit;
  454 + }
  455 +
  456 + public Double getRainLimit() {
  457 + return rainLimit;
  458 + }
  459 +
  460 + public void setRainLimit(Double rainLimit) {
  461 + this.rainLimit = rainLimit;
  462 + }
  463 +
  464 + public Double getFogLimit() {
  465 + return fogLimit;
  466 + }
  467 +
  468 + public void setFogLimit(Double fogLimit) {
  469 + this.fogLimit = fogLimit;
  470 + }
  471 +
  472 + public Double getSnowLimit() {
  473 + return snowLimit;
  474 + }
  475 +
  476 + public void setSnowLimit(Double snowLimit) {
  477 + this.snowLimit = snowLimit;
  478 + }
  479 +
  480 + public Double getFestivalSpeedLimit() {
  481 + return festivalSpeedLimit;
  482 + }
  483 +
  484 + public void setFestivalSpeedLimit(Double festivalSpeedLimit) {
  485 + this.festivalSpeedLimit = festivalSpeedLimit;
  486 + }
  487 +
  488 + public Integer getLagStation() {
  489 + return lagStation;
  490 + }
  491 +
  492 + public void setLagStation(Integer lagStation) {
  493 + this.lagStation = lagStation;
  494 + }
  495 +
  496 + public Integer getSkip() {
  497 + return skip;
  498 + }
  499 +
  500 + public void setSkip(Integer skip) {
  501 + this.skip = skip;
  502 + }
  503 +
  504 + public Integer getSpeeding() {
  505 + return speeding;
  506 + }
  507 +
  508 + public void setSpeeding(Integer speeding) {
  509 + this.speeding = speeding;
  510 + }
  511 +
  512 + public Integer getCrossedLine() {
  513 + return crossedLine;
  514 + }
  515 +
  516 + public void setCrossedLine(Integer crossedLine) {
  517 + this.crossedLine = crossedLine;
  518 + }
  519 +
  520 + public Integer getOverflights() {
  521 + return overflights;
  522 + }
  523 +
  524 + public void setOverflights(Integer overflights) {
  525 + this.overflights = overflights;
  526 + }
  527 +
  528 + public String getDescriptions() {
  529 + return descriptions;
  530 + }
  531 +
  532 + public void setDescriptions(String descriptions) {
  533 + this.descriptions = descriptions;
  534 + }
  535 +
  536 + public Integer getCreateBy() {
  537 + return createBy;
  538 + }
  539 +
  540 + public void setCreateBy(Integer createBy) {
  541 + this.createBy = createBy;
  542 + }
  543 +
  544 + public Integer getUpdateBy() {
  545 + return updateBy;
  546 + }
  547 +
  548 + public void setUpdateBy(Integer updateBy) {
  549 + this.updateBy = updateBy;
  550 + }
  551 +
  552 + public Date getCreateDate() {
  553 + return createDate;
  554 + }
  555 +
  556 + public void setCreateDate(Date createDate) {
  557 + this.createDate = createDate;
  558 + }
  559 +
  560 + public Date getUpdateDate() {
  561 + return updateDate;
  562 + }
  563 +
  564 + public void setUpdateDate(Date updateDate) {
  565 + this.updateDate = updateDate;
  566 + }
  567 +
  568 + public Line getLine() {
  569 + return line;
  570 + }
  571 +
  572 + public void setLine(Line line) {
  573 + this.line = line;
  574 + }
  575 +}
src/test/java/com/bsth/entity/LineVersions.java 0 → 100644
  1 +package com.bsth.entity;
  2 +
  3 +import javax.persistence.*;
  4 +import java.util.Date;
  5 +
  6 +
  7 +/**
  8 + *
  9 + * @ClassName: LineVersions(线路版本实体类)
  10 + *
  11 + * @Description: TODO(线路版本)
  12 + *
  13 + * @Author bsth@lq
  14 + *
  15 + * @Version 公交调度系统BS版 0.1
  16 + *
  17 + */
  18 +
  19 +@Entity
  20 +@Table(name = "bsth_c_line_versions")
  21 +public class LineVersions{
  22 +
  23 + @Id
  24 + @GeneratedValue(strategy = GenerationType.IDENTITY)
  25 + /** ID 主键(唯一标识符) int length(11) */
  26 + private Integer id;
  27 +
  28 + /** 线路版本名字 varchar length(50)
  29 + * 给排版人员选版本使用
  30 + * */
  31 + private String name;
  32 +
  33 + /** 线路ID int length(11) */
  34 + @ManyToOne
  35 + private Line line;
  36 +
  37 + /** 线路编码 varchar length(50) */
  38 + private String lineCode;
  39 +
  40 + /** 版本号 int length(11) */
  41 + private int versions;
  42 +
  43 + /** 启用日期 timestamp */
  44 + private Date startDate;
  45 +
  46 + /** 终止日期 timestamp */
  47 + private Date endDate;
  48 +
  49 + /** 创建日期 timestamp */
  50 +// @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
  51 + @Column(updatable = false, name = "create_date")
  52 + private Date createDate;
  53 +
  54 + /** 修改日期 timestamp */
  55 +// @Column(name = "update_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
  56 + @Column(name = "update_date")
  57 + private Date updateDate;
  58 +
  59 + /** 备注 varchar length(50) */
  60 + private String remark;
  61 +
  62 + /** 版本状态 int length(11)
  63 + * 0(历史版本),1(当前版本),2(待更新版本)
  64 + */
  65 + private int status;
  66 +
  67 + /**
  68 + * 是否发布 int length(1)
  69 + * 0(没有),1(发布)
  70 + */
  71 + private int isupdate = 0;
  72 +
  73 + public Integer getId() {
  74 + return id;
  75 + }
  76 +
  77 + public void setId(Integer id) {
  78 + this.id = id;
  79 + }
  80 +
  81 + public String getName() {
  82 + return name;
  83 + }
  84 +
  85 + public void setName(String name) {
  86 + this.name = name;
  87 + }
  88 +
  89 + public Line getLine() {
  90 + return line;
  91 + }
  92 +
  93 + public void setLine(Line line) {
  94 + this.line = line;
  95 + }
  96 +
  97 + public String getLineCode() {
  98 + return lineCode;
  99 + }
  100 +
  101 + public void setLineCode(String lineCode) {
  102 + this.lineCode = lineCode;
  103 + }
  104 +
  105 + public int getVersions() {
  106 + return versions;
  107 + }
  108 +
  109 + public void setVersions(int versions) {
  110 + this.versions = versions;
  111 + }
  112 +
  113 + public Date getStartDate() {
  114 + return startDate;
  115 + }
  116 +
  117 + public void setStartDate(Date startDate) {
  118 + this.startDate = startDate;
  119 + }
  120 +
  121 + public Date getEndDate() {
  122 + return endDate;
  123 + }
  124 +
  125 + public void setEndDate(Date endDate) {
  126 + this.endDate = endDate;
  127 + }
  128 +
  129 + public Date getCreateDate() {
  130 + return createDate;
  131 + }
  132 +
  133 + public void setCreateDate(Date createDate) {
  134 + this.createDate = createDate;
  135 + }
  136 +
  137 + public Date getUpdateDate() {
  138 + return updateDate;
  139 + }
  140 +
  141 + public void setUpdateDate(Date updateDate) {
  142 + this.updateDate = updateDate;
  143 + }
  144 +
  145 + public String getRemark() {
  146 + return remark;
  147 + }
  148 +
  149 + public void setRemark(String remark) {
  150 + this.remark = remark;
  151 + }
  152 +
  153 + public int getStatus() {
  154 + return status;
  155 + }
  156 +
  157 + public void setStatus(int status) {
  158 + this.status = status;
  159 + }
  160 +
  161 + public int getIsupdate() {
  162 + return isupdate;
  163 + }
  164 +
  165 + public void setIsupdate(int isupdate) {
  166 + this.isupdate = isupdate;
  167 + }
  168 +
  169 +}
src/test/java/com/bsth/entity/LsSectionRoute.java 0 → 100644
  1 +package com.bsth.entity;
  2 +
  3 +import javax.persistence.*;
  4 +import java.util.Date;
  5 +
  6 +
  7 +/**
  8 + *
  9 + * @ClassName : SectionRoute(历史路段路由实体类)
  10 + *
  11 + * @Author : bsth@lq
  12 + *
  13 + * @Description : TODO(历史路段路由)
  14 + *
  15 + * @Version 公交调度系统BS版 0.1
  16 + *
  17 + */
  18 +
  19 +@Entity
  20 +@Table(name = "bsth_c_ls_sectionroute")
  21 +public class LsSectionRoute {
  22 +
  23 + @Id
  24 + @GeneratedValue(strategy = GenerationType.IDENTITY)
  25 + private Integer id;
  26 +
  27 + // 路段路由序号
  28 + private Integer sectionrouteCode;
  29 +
  30 + // 线路编号
  31 + private String lineCode;
  32 +
  33 + // 路段编号
  34 + private String sectionCode;
  35 +
  36 + // 路段路由方向
  37 + private Integer directions;
  38 +
  39 + // 版本号
  40 + private Integer versions;
  41 +
  42 + // 是否撤销
  43 + private Integer destroy;
  44 +
  45 + /** 是否有路段限速数据 <0:分段;1:未分段>*/
  46 + private Integer isRoadeSpeed;
  47 +
  48 + // 描述
  49 + private String descriptions;
  50 +
  51 + // 创建人
  52 + private Integer createBy;
  53 +
  54 + // 修改人
  55 + private Integer updateBy;
  56 +
  57 + // 创建日期
  58 +// @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
  59 + @Column(updatable = false, name = "create_date")
  60 + private Date createDate;
  61 +
  62 + // 修改日期
  63 +// @Column(name = "update_date", columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
  64 + @Column(name = "update_date")
  65 + private Date updateDate;
  66 +
  67 + // 路段信息
  68 + @OneToOne
  69 + private Section section;
  70 +
  71 + // 线路信息
  72 + @ManyToOne
  73 + private Line line;
  74 +
  75 + public Integer getIsRoadeSpeed() {
  76 + return isRoadeSpeed;
  77 + }
  78 +
  79 + public void setIsRoadeSpeed(Integer isRoadeSpeed) {
  80 + this.isRoadeSpeed = isRoadeSpeed;
  81 + }
  82 +
  83 + public Integer getId() {
  84 + return id;
  85 + }
  86 +
  87 + public void setId(Integer id) {
  88 + this.id = id;
  89 + }
  90 +
  91 + public Integer getSectionrouteCode() {
  92 + return sectionrouteCode;
  93 + }
  94 +
  95 + public void setSectionrouteCode(Integer sectionrouteCode) {
  96 + this.sectionrouteCode = sectionrouteCode;
  97 + }
  98 +
  99 + public String getLineCode() {
  100 + return lineCode;
  101 + }
  102 +
  103 + public void setLineCode(String lineCode) {
  104 + this.lineCode = lineCode;
  105 + }
  106 +
  107 + public String getSectionCode() {
  108 + return sectionCode;
  109 + }
  110 +
  111 + public void setSectionCode(String sectionCode) {
  112 + this.sectionCode = sectionCode;
  113 + }
  114 +
  115 + public Integer getDirections() {
  116 + return directions;
  117 + }
  118 +
  119 + public void setDirections(Integer directions) {
  120 + this.directions = directions;
  121 + }
  122 +
  123 + public Integer getVersions() {
  124 + return versions;
  125 + }
  126 +
  127 + public void setVersions(Integer versions) {
  128 + this.versions = versions;
  129 + }
  130 +
  131 + public Integer getDestroy() {
  132 + return destroy;
  133 + }
  134 +
  135 + public void setDestroy(Integer destroy) {
  136 + this.destroy = destroy;
  137 + }
  138 +
  139 + public String getDescriptions() {
  140 + return descriptions;
  141 + }
  142 +
  143 + public void setDescriptions(String descriptions) {
  144 + this.descriptions = descriptions;
  145 + }
  146 +
  147 + public Integer getCreateBy() {
  148 + return createBy;
  149 + }
  150 +
  151 + public void setCreateBy(Integer createBy) {
  152 + this.createBy = createBy;
  153 + }
  154 +
  155 + public Integer getUpdateBy() {
  156 + return updateBy;
  157 + }
  158 +
  159 + public void setUpdateBy(Integer updateBy) {
  160 + this.updateBy = updateBy;
  161 + }
  162 +
  163 + public Date getCreateDate() {
  164 + return createDate;
  165 + }
  166 +
  167 + public void setCreateDate(Date createDate) {
  168 + this.createDate = createDate;
  169 + }
  170 +
  171 + public Date getUpdateDate() {
  172 + return updateDate;
  173 + }
  174 +
  175 + public void setUpdateDate(Date updateDate) {
  176 + this.updateDate = updateDate;
  177 + }
  178 +
  179 + public Section getSection() {
  180 + return section;
  181 + }
  182 +
  183 + public void setSection(Section section) {
  184 + this.section = section;
  185 + }
  186 +
  187 + public Line getLine() {
  188 + return line;
  189 + }
  190 +
  191 + public void setLine(Line line) {
  192 + this.line = line;
  193 + }
  194 +}
src/test/java/com/bsth/entity/LsStationRoute.java 0 → 100644
  1 +package com.bsth.entity;
  2 +
  3 +import javax.persistence.*;
  4 +import java.util.Date;
  5 +
  6 +/**
  7 + *
  8 + * @ClassName : StationRoute(历史站点路由实体类)
  9 + *
  10 + * @Author : bsth@lq
  11 + *
  12 + * @Description : TODO(历史站点路由)
  13 + *
  14 + * @Version 公交调度系统BS版 0.1
  15 + *
  16 + */
  17 +
  18 +@Entity
  19 +@Table(name = "bsth_c_ls_stationroute")
  20 +@NamedEntityGraphs({
  21 + @NamedEntityGraph(name = "ls_stationRoute_station", attributeNodes = {
  22 + @NamedAttributeNode("station"),
  23 + @NamedAttributeNode("line")
  24 + })
  25 +})
  26 +public class LsStationRoute {
  27 +
  28 + //站点路由ID
  29 + @Id
  30 + @GeneratedValue(strategy = GenerationType.IDENTITY)
  31 + private Integer id;
  32 +
  33 + // 站点路由序号
  34 + private Integer stationRouteCode;
  35 +
  36 + // 站点编码
  37 + private String stationCode;
  38 +
  39 + // 站点名称
  40 + private String stationName;
  41 +
  42 + // 线路编码
  43 + private String lineCode;
  44 +
  45 + // 行业编码
  46 + private String industryCode;
  47 + /**
  48 + * 站点类型
  49 + *
  50 + * ------ B:起点站
  51 + *
  52 + * ------ Z:中途站
  53 + *
  54 + * ------ E:终点站
  55 + *
  56 + * ------ T:停车场
  57 + *
  58 + */
  59 + private String stationMark;
  60 +
  61 + // 站点路由出站序号
  62 + private Integer outStationNmber;
  63 +
  64 + // 站点路由到站距离
  65 + private Double distances;
  66 +
  67 + // 站点路由到站时间
  68 + private Double toTime;
  69 +
  70 + // 首班时间
  71 + private String firstTime;
  72 +
  73 + // 末班时间
  74 + private String endTime;
  75 +
  76 + // 站点路由方向
  77 + private Integer directions;
  78 +
  79 + // 版本号
  80 + private Integer versions;
  81 +
  82 + // 是否撤销
  83 + private Integer destroy;
  84 +
  85 + // 描述
  86 + private String descriptions;
  87 +
  88 + // 创建人
  89 + private Integer createBy;
  90 +
  91 + // 修改人
  92 + private Integer updateBy;
  93 +
  94 + // 创建日期
  95 +// @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
  96 + @Column(updatable = false, name = "create_date")
  97 + private Date createDate;
  98 +
  99 + // 修改日期
  100 +// @Column(name = "update_date", columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
  101 + @Column(name = "update_date")
  102 + private Date updateDate;
  103 +
  104 + // 站点信息
  105 + @ManyToOne(fetch = FetchType.LAZY)
  106 + private Station station;
  107 +
  108 + // 线路信息
  109 + @ManyToOne
  110 + private Line line;
  111 +
  112 + public Integer getId() {
  113 + return id;
  114 + }
  115 +
  116 + public void setId(Integer id) {
  117 + this.id = id;
  118 + }
  119 +
  120 + public Integer getStationRouteCode() {
  121 + return stationRouteCode;
  122 + }
  123 +
  124 + public void setStationRouteCode(Integer stationRouteCode) {
  125 + this.stationRouteCode = stationRouteCode;
  126 + }
  127 +
  128 + public String getStationCode() {
  129 + return stationCode;
  130 + }
  131 +
  132 + public void setStationCode(String stationCode) {
  133 + this.stationCode = stationCode;
  134 + }
  135 +
  136 + public String getStationName() {
  137 + return stationName;
  138 + }
  139 +
  140 + public void setStationName(String stationName) {
  141 + this.stationName = stationName;
  142 + }
  143 +
  144 + public String getLineCode() {
  145 + return lineCode;
  146 + }
  147 +
  148 + public void setLineCode(String lineCode) {
  149 + this.lineCode = lineCode;
  150 + }
  151 +
  152 + public String getIndustryCode() {
  153 + return industryCode;
  154 + }
  155 +
  156 + public void setIndustryCode(String industryCode) {
  157 + this.industryCode = industryCode;
  158 + }
  159 +
  160 + public String getStationMark() {
  161 + return stationMark;
  162 + }
  163 +
  164 + public void setStationMark(String stationMark) {
  165 + this.stationMark = stationMark;
  166 + }
  167 +
  168 + public Integer getOutStationNmber() {
  169 + return outStationNmber;
  170 + }
  171 +
  172 + public void setOutStationNmber(Integer outStationNmber) {
  173 + this.outStationNmber = outStationNmber;
  174 + }
  175 +
  176 + public Double getDistances() {
  177 + return distances;
  178 + }
  179 +
  180 + public void setDistances(Double distances) {
  181 + this.distances = distances;
  182 + }
  183 +
  184 + public Double getToTime() {
  185 + return toTime;
  186 + }
  187 +
  188 + public void setToTime(Double toTime) {
  189 + this.toTime = toTime;
  190 + }
  191 +
  192 + public String getFirstTime() {
  193 + return firstTime;
  194 + }
  195 +
  196 + public void setFirstTime(String firstTime) {
  197 + this.firstTime = firstTime;
  198 + }
  199 +
  200 + public String getEndTime() {
  201 + return endTime;
  202 + }
  203 +
  204 + public void setEndTime(String endTime) {
  205 + this.endTime = endTime;
  206 + }
  207 +
  208 + public Integer getDirections() {
  209 + return directions;
  210 + }
  211 +
  212 + public void setDirections(Integer directions) {
  213 + this.directions = directions;
  214 + }
  215 +
  216 + public Integer getVersions() {
  217 + return versions;
  218 + }
  219 +
  220 + public void setVersions(Integer versions) {
  221 + this.versions = versions;
  222 + }
  223 +
  224 + public Integer getDestroy() {
  225 + return destroy;
  226 + }
  227 +
  228 + public void setDestroy(Integer destroy) {
  229 + this.destroy = destroy;
  230 + }
  231 +
  232 + public String getDescriptions() {
  233 + return descriptions;
  234 + }
  235 +
  236 + public void setDescriptions(String descriptions) {
  237 + this.descriptions = descriptions;
  238 + }
  239 +
  240 + public Integer getCreateBy() {
  241 + return createBy;
  242 + }
  243 +
  244 + public void setCreateBy(Integer createBy) {
  245 + this.createBy = createBy;
  246 + }
  247 +
  248 + public Integer getUpdateBy() {
  249 + return updateBy;
  250 + }
  251 +
  252 + public void setUpdateBy(Integer updateBy) {
  253 + this.updateBy = updateBy;
  254 + }
  255 +
  256 + public Date getCreateDate() {
  257 + return createDate;
  258 + }
  259 +
  260 + public void setCreateDate(Date createDate) {
  261 + this.createDate = createDate;
  262 + }
  263 +
  264 + public Date getUpdateDate() {
  265 + return updateDate;
  266 + }
  267 +
  268 + public void setUpdateDate(Date updateDate) {
  269 + this.updateDate = updateDate;
  270 + }
  271 +
  272 + public Station getStation() {
  273 + return station;
  274 + }
  275 +
  276 + public void setStation(Station station) {
  277 + this.station = station;
  278 + }
  279 +
  280 + public Line getLine() {
  281 + return line;
  282 + }
  283 +
  284 + public void setLine(Line line) {
  285 + this.line = line;
  286 + }
  287 +}
src/test/java/com/bsth/entity/RoadSpeed.java 0 → 100644
  1 +package com.bsth.entity;
  2 +
  3 +import javax.persistence.*;
  4 +import java.util.Date;
  5 +
  6 +@Entity
  7 +@Table(name = "bsth_c_road_speed")
  8 +public class RoadSpeed {
  9 +
  10 + @Id
  11 + @GeneratedValue(strategy = GenerationType.IDENTITY)
  12 + private Integer id;
  13 +
  14 + // 路段名称
  15 + private String name;
  16 +
  17 + // 路段矢量(空间坐标点集合)--GPS坐标点
  18 + private String bRoadVector;
  19 +
  20 + // 路段矢量(空间坐标点集合)--百度坐标点
  21 + private String gRoadVector;
  22 +
  23 + // 限速 (km/h)
  24 + private Double speed;
  25 +
  26 + // 限速开始时间
  27 + private String speedStartDate;
  28 +
  29 + // 限速结束时间
  30 + private String speedEndDate;
  31 +
  32 + // 是否启用限速(0:启用、1:未启用)
  33 + private int isStart;
  34 +
  35 + // 预留字段(限速的线路)
  36 + private String line;
  37 +
  38 + // 创建日期 timestamp
  39 +// @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
  40 + @Column(updatable = false, name = "create_date")
  41 + private Date createDate;
  42 +
  43 + // 修改日期 timestamp
  44 +// @Column(name = "update_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
  45 + @Column(name = "update_date")
  46 + private Date updateDate;
  47 +
  48 + public Integer getId() {
  49 + return id;
  50 + }
  51 +
  52 + public String getName() {
  53 + return name;
  54 + }
  55 +
  56 + public String getbRoadVector() {
  57 + return bRoadVector;
  58 + }
  59 +
  60 + public String getgRoadVector() {
  61 + return gRoadVector;
  62 + }
  63 +
  64 + public Double getSpeed() {
  65 + return speed;
  66 + }
  67 +
  68 + public String getSpeedStartDate() {
  69 + return speedStartDate;
  70 + }
  71 +
  72 + public String getSpeedEndDate() {
  73 + return speedEndDate;
  74 + }
  75 +
  76 + public int getIsStart() {
  77 + return isStart;
  78 + }
  79 +
  80 + public String getLine() {
  81 + return line;
  82 + }
  83 +
  84 + public Date getCreateDate() {
  85 + return createDate;
  86 + }
  87 +
  88 + public Date getUpdateDate() {
  89 + return updateDate;
  90 + }
  91 +
  92 + public void setId(Integer id) {
  93 + this.id = id;
  94 + }
  95 +
  96 + public void setName(String name) {
  97 + this.name = name;
  98 + }
  99 +
  100 + public void setbRoadVector(String bRoadVector) {
  101 + this.bRoadVector = bRoadVector;
  102 + }
  103 +
  104 + public void setgRoadVector(String gRoadVector) {
  105 + this.gRoadVector = gRoadVector;
  106 + }
  107 +
  108 + public void setSpeed(Double speed) {
  109 + this.speed = speed;
  110 + }
  111 +
  112 + public void setSpeedStartDate(String speedStartDate) {
  113 + this.speedStartDate = speedStartDate;
  114 + }
  115 +
  116 + public void setSpeedEndDate(String speedEndDate) {
  117 + this.speedEndDate = speedEndDate;
  118 + }
  119 +
  120 + public void setIsStart(int isStart) {
  121 + this.isStart = isStart;
  122 + }
  123 +
  124 + public void setLine(String line) {
  125 + this.line = line;
  126 + }
  127 +
  128 + public void setCreateDate(Date createDate) {
  129 + this.createDate = createDate;
  130 + }
  131 +
  132 + public void setUpdateDate(Date updateDate) {
  133 + this.updateDate = updateDate;
  134 + }
  135 +
  136 + @Override
  137 + public String toString() {
  138 + return "RoadSpeed [id=" + id + ", name=" + name + ", bRoadVector=" + bRoadVector + ", gRoadVector="
  139 + + gRoadVector + ", speed=" + speed + ", speedStartDate=" + speedStartDate + ", speedEndDate="
  140 + + speedEndDate + ", isStart=" + isStart + ", line=" + line + ", createDate=" + createDate
  141 + + ", updateDate=" + updateDate + "]";
  142 + }
  143 +
  144 +
  145 +}
src/test/java/com/bsth/entity/Section.java 0 → 100644
  1 +package com.bsth.entity;
  2 +
  3 +import javax.persistence.Column;
  4 +import javax.persistence.Entity;
  5 +import javax.persistence.Id;
  6 +import javax.persistence.Table;
  7 +import java.util.Date;
  8 +
  9 +/**
  10 + *
  11 + * @ClassName : Section(路段实体类)
  12 + *
  13 + * @Author : bsth@lq
  14 + *
  15 + * @Description : TODO(路段)
  16 + *
  17 + * @Data :2016-04-21
  18 + *
  19 + * @Version 公交调度系统BS版 0.1
  20 + *
  21 + */
  22 +
  23 +@Entity
  24 +@Table(name = "bsth_c_section")
  25 +public class Section {
  26 +
  27 + @Id
  28 + /*@GeneratedValue(strategy = GenerationType.IDENTITY)*/
  29 + private Integer id;
  30 +
  31 + // 路段编码
  32 + private String sectionCode;
  33 +
  34 + // 道路编码
  35 + private String roadCoding;
  36 +
  37 + // 路段名称
  38 + private String sectionName;
  39 +
  40 + // 路段距离
  41 + private Double sectionDistance;
  42 +
  43 + // 路段时间
  44 + private Double sectionTime;
  45 +
  46 + // 经纬坐标类型
  47 + private String dbType;
  48 +
  49 + // 路段类型
  50 + private String sectionType;
  51 +
  52 + // 路段矢量(空间坐标点集合)--GPS坐标点
  53 + private String gsectionVector;
  54 +
  55 + // 路段矢量(空间坐标点集合)--百度原始坐标坐标点
  56 + private String bsectionVector;
  57 +
  58 + // 路段矢量(空间坐标点集合)--城建坐标点
  59 + private String csectionVector;
  60 +
  61 + // 交叉路
  62 + private String crosesRoad;
  63 +
  64 + // 起始节点
  65 + private String startNode;
  66 +
  67 + // 中间节点
  68 + private String middleNode;
  69 +
  70 + // 终止节点
  71 + private String endNode;
  72 +
  73 + // 限速
  74 + private Double speedLimit;
  75 +
  76 + // 版本号
  77 + private Integer versions;
  78 +
  79 + // 描述
  80 + private String descriptions;
  81 +
  82 + // 创建人
  83 + private Integer createBy;
  84 +
  85 + // 修改人
  86 + private Integer updateBy;
  87 +
  88 + // 创建日期
  89 +// @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
  90 + @Column(updatable = false, name = "create_date")
  91 + private Date createDate;
  92 +
  93 + // 修改日期
  94 +// @Column(name = "update_date", columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
  95 + @Column(name = "update_date")
  96 + private Date updateDate;
  97 +
  98 + public Integer getId() {
  99 + return id;
  100 + }
  101 +
  102 + public void setId(Integer id) {
  103 + this.id = id;
  104 + }
  105 +
  106 + public String getSectionCode() {
  107 + return sectionCode;
  108 + }
  109 +
  110 + public void setSectionCode(String sectionCode) {
  111 + this.sectionCode = sectionCode;
  112 + }
  113 +
  114 + public String getRoadCoding() {
  115 + return roadCoding;
  116 + }
  117 +
  118 + public void setRoadCoding(String roadCoding) {
  119 + this.roadCoding = roadCoding;
  120 + }
  121 +
  122 + public String getSectionName() {
  123 + return sectionName;
  124 + }
  125 +
  126 + public void setSectionName(String sectionName) {
  127 + this.sectionName = sectionName;
  128 + }
  129 +
  130 + public Double getSectionDistance() {
  131 + return sectionDistance;
  132 + }
  133 +
  134 + public void setSectionDistance(Double sectionDistance) {
  135 + this.sectionDistance = sectionDistance;
  136 + }
  137 +
  138 + public Double getSectionTime() {
  139 + return sectionTime;
  140 + }
  141 +
  142 + public void setSectionTime(Double sectionTime) {
  143 + this.sectionTime = sectionTime;
  144 + }
  145 +
  146 + public String getDbType() {
  147 + return dbType;
  148 + }
  149 +
  150 + public void setDbType(String dbType) {
  151 + this.dbType = dbType;
  152 + }
  153 +
  154 + public String getSectionType() {
  155 + return sectionType;
  156 + }
  157 +
  158 + public void setSectionType(String sectionType) {
  159 + this.sectionType = sectionType;
  160 + }
  161 +
  162 + public String getGsectionVector() {
  163 + return gsectionVector;
  164 + }
  165 +
  166 + public void setGsectionVector(String gsectionVector) {
  167 + this.gsectionVector = gsectionVector;
  168 + }
  169 +
  170 + public String getBsectionVector() {
  171 + return bsectionVector;
  172 + }
  173 +
  174 + public void setBsectionVector(String bsectionVector) {
  175 + this.bsectionVector = bsectionVector;
  176 + }
  177 +
  178 + public String getCsectionVector() {
  179 + return csectionVector;
  180 + }
  181 +
  182 + public void setCsectionVector(String csectionVector) {
  183 + this.csectionVector = csectionVector;
  184 + }
  185 +
  186 + public String getCrosesRoad() {
  187 + return crosesRoad;
  188 + }
  189 +
  190 + public void setCrosesRoad(String crosesRoad) {
  191 + this.crosesRoad = crosesRoad;
  192 + }
  193 +
  194 + public String getStartNode() {
  195 + return startNode;
  196 + }
  197 +
  198 + public void setStartNode(String startNode) {
  199 + this.startNode = startNode;
  200 + }
  201 +
  202 + public String getMiddleNode() {
  203 + return middleNode;
  204 + }
  205 +
  206 + public void setMiddleNode(String middleNode) {
  207 + this.middleNode = middleNode;
  208 + }
  209 +
  210 + public String getEndNode() {
  211 + return endNode;
  212 + }
  213 +
  214 + public void setEndNode(String endNode) {
  215 + this.endNode = endNode;
  216 + }
  217 +
  218 + public Double getSpeedLimit() {
  219 + return speedLimit;
  220 + }
  221 +
  222 + public void setSpeedLimit(Double speedLimit) {
  223 + this.speedLimit = speedLimit;
  224 + }
  225 +
  226 + public Integer getVersions() {
  227 + return versions;
  228 + }
  229 +
  230 + public void setVersions(Integer versions) {
  231 + this.versions = versions;
  232 + }
  233 +
  234 + public String getDescriptions() {
  235 + return descriptions;
  236 + }
  237 +
  238 + public void setDescriptions(String descriptions) {
  239 + this.descriptions = descriptions;
  240 + }
  241 +
  242 + public Integer getCreateBy() {
  243 + return createBy;
  244 + }
  245 +
  246 + public void setCreateBy(Integer createBy) {
  247 + this.createBy = createBy;
  248 + }
  249 +
  250 + public Integer getUpdateBy() {
  251 + return updateBy;
  252 + }
  253 +
  254 + public void setUpdateBy(Integer updateBy) {
  255 + this.updateBy = updateBy;
  256 + }
  257 +
  258 + public Date getCreateDate() {
  259 + return createDate;
  260 + }
  261 +
  262 + public void setCreateDate(Date createDate) {
  263 + this.createDate = createDate;
  264 + }
  265 +
  266 + public Date getUpdateDate() {
  267 + return updateDate;
  268 + }
  269 +
  270 + public void setUpdateDate(Date updateDate) {
  271 + this.updateDate = updateDate;
  272 + }
  273 +}
src/test/java/com/bsth/entity/SectionRoute.java 0 → 100644
  1 +package com.bsth.entity;
  2 +
  3 +import javax.persistence.*;
  4 +import java.util.Date;
  5 +
  6 +
  7 +/**
  8 + *
  9 + * @ClassName : SectionRoute(路段路由实体类)
  10 + *
  11 + * @Author : bsth@lq
  12 + *
  13 + * @Description : TODO(路段路由)
  14 + *
  15 + * @Data :2016-04-21
  16 + *
  17 + * @Version 公交调度系统BS版 0.1
  18 + *
  19 + */
  20 +
  21 +@Entity
  22 +@Table(name = "bsth_c_sectionroute")
  23 +public class SectionRoute {
  24 +
  25 + @Id
  26 + @GeneratedValue(strategy = GenerationType.IDENTITY)
  27 + private Integer id;
  28 +
  29 + // 路段路由序号
  30 + private Integer sectionrouteCode;
  31 +
  32 + // 线路编号
  33 + private String lineCode;
  34 +
  35 + // 路段编号
  36 + private String sectionCode;
  37 +
  38 + // 路段路由方向
  39 + private Integer directions;
  40 +
  41 + // 版本号
  42 + private Integer versions;
  43 +
  44 + // 是否撤销
  45 + private Integer destroy;
  46 +
  47 + /** 是否有路段限速数据 <0:分段;1:未分段>*/
  48 + private Integer isRoadeSpeed;
  49 +
  50 + // 描述
  51 + private String descriptions;
  52 +
  53 + // 创建人
  54 + private Integer createBy;
  55 +
  56 + // 修改人
  57 + private Integer updateBy;
  58 +
  59 + // 创建日期
  60 +// @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
  61 + @Column(updatable = false, name = "create_date")
  62 + private Date createDate;
  63 +
  64 + // 修改日期
  65 +// @Column(name = "update_date", columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
  66 + @Column(name = "update_date")
  67 + private Date updateDate;
  68 +
  69 + // 路段信息
  70 + @OneToOne
  71 + private Section section;
  72 +
  73 + // 线路信息
  74 + @ManyToOne
  75 + private Line line;
  76 +
  77 + public Integer getIsRoadeSpeed() {
  78 + return isRoadeSpeed;
  79 + }
  80 +
  81 + public void setIsRoadeSpeed(Integer isRoadeSpeed) {
  82 + this.isRoadeSpeed = isRoadeSpeed;
  83 + }
  84 +
  85 + public Integer getId() {
  86 + return id;
  87 + }
  88 +
  89 + public void setId(Integer id) {
  90 + this.id = id;
  91 + }
  92 +
  93 + public Integer getSectionrouteCode() {
  94 + return sectionrouteCode;
  95 + }
  96 +
  97 + public void setSectionrouteCode(Integer sectionrouteCode) {
  98 + this.sectionrouteCode = sectionrouteCode;
  99 + }
  100 +
  101 + public String getLineCode() {
  102 + return lineCode;
  103 + }
  104 +
  105 + public void setLineCode(String lineCode) {
  106 + this.lineCode = lineCode;
  107 + }
  108 +
  109 + public String getSectionCode() {
  110 + return sectionCode;
  111 + }
  112 +
  113 + public void setSectionCode(String sectionCode) {
  114 + this.sectionCode = sectionCode;
  115 + }
  116 +
  117 + public Integer getDirections() {
  118 + return directions;
  119 + }
  120 +
  121 + public void setDirections(Integer directions) {
  122 + this.directions = directions;
  123 + }
  124 +
  125 + public Integer getVersions() {
  126 + return versions;
  127 + }
  128 +
  129 + public void setVersions(Integer versions) {
  130 + this.versions = versions;
  131 + }
  132 +
  133 + public Integer getDestroy() {
  134 + return destroy;
  135 + }
  136 +
  137 + public void setDestroy(Integer destroy) {
  138 + this.destroy = destroy;
  139 + }
  140 +
  141 + public String getDescriptions() {
  142 + return descriptions;
  143 + }
  144 +
  145 + public void setDescriptions(String descriptions) {
  146 + this.descriptions = descriptions;
  147 + }
  148 +
  149 + public Integer getCreateBy() {
  150 + return createBy;
  151 + }
  152 +
  153 + public void setCreateBy(Integer createBy) {
  154 + this.createBy = createBy;
  155 + }
  156 +
  157 + public Integer getUpdateBy() {
  158 + return updateBy;
  159 + }
  160 +
  161 + public void setUpdateBy(Integer updateBy) {
  162 + this.updateBy = updateBy;
  163 + }
  164 +
  165 + public Date getCreateDate() {
  166 + return createDate;
  167 + }
  168 +
  169 + public void setCreateDate(Date createDate) {
  170 + this.createDate = createDate;
  171 + }
  172 +
  173 + public Date getUpdateDate() {
  174 + return updateDate;
  175 + }
  176 +
  177 + public void setUpdateDate(Date updateDate) {
  178 + this.updateDate = updateDate;
  179 + }
  180 +
  181 + public Section getSection() {
  182 + return section;
  183 + }
  184 +
  185 + public void setSection(Section section) {
  186 + this.section = section;
  187 + }
  188 +
  189 + public Line getLine() {
  190 + return line;
  191 + }
  192 +
  193 + public void setLine(Line line) {
  194 + this.line = line;
  195 + }
  196 +}
src/test/java/com/bsth/entity/SectionRouteCache.java 0 → 100644
  1 +package com.bsth.entity;
  2 +
  3 +import javax.persistence.*;
  4 +import java.util.Date;
  5 +
  6 +
  7 +/**
  8 + *
  9 + * @ClassName : SectionRoute(路段路由缓存实体类)
  10 + *
  11 + * @Author : bsth@lq
  12 + *
  13 + * @Description : TODO(路段路由)
  14 + *
  15 + * @Data :2016-04-21
  16 + *
  17 + * @Version 公交调度系统BS版 0.1
  18 + *
  19 + */
  20 +
  21 +@Entity
  22 +@Table(name = "bsth_c_sectionroute_cache")
  23 +public class SectionRouteCache {
  24 +
  25 + @Id
  26 + @GeneratedValue(strategy = GenerationType.IDENTITY)
  27 + private Integer id;
  28 +
  29 + // 路段路由序号
  30 + private Integer sectionrouteCode;
  31 +
  32 + // 线路编号
  33 + private String lineCode;
  34 +
  35 + // 路段编号
  36 + private String sectionCode;
  37 +
  38 + // 路段路由方向
  39 + private Integer directions;
  40 +
  41 + // 版本号
  42 + private Integer versions;
  43 +
  44 + // 是否撤销
  45 + private Integer destroy;
  46 +
  47 + /** 是否有路段限速数据 <0:分段;1:未分段>*/
  48 + private Integer isRoadeSpeed;
  49 +
  50 + // 描述
  51 + private String descriptions;
  52 +
  53 + // 创建人
  54 + private Integer createBy;
  55 +
  56 + // 修改人
  57 + private Integer updateBy;
  58 +
  59 + // 创建日期
  60 +// @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
  61 + @Column(updatable = false, name = "create_date")
  62 + private Date createDate;
  63 +
  64 + // 修改日期
  65 +// @Column(name = "update_date", columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
  66 + @Column(name = "update_date")
  67 + private Date updateDate;
  68 +
  69 + // 路段信息
  70 + @OneToOne
  71 + private Section section;
  72 +
  73 + // 线路信息
  74 + @ManyToOne
  75 + private Line line;
  76 +
  77 + public Integer getIsRoadeSpeed() {
  78 + return isRoadeSpeed;
  79 + }
  80 +
  81 + public void setIsRoadeSpeed(Integer isRoadeSpeed) {
  82 + this.isRoadeSpeed = isRoadeSpeed;
  83 + }
  84 +
  85 + public Integer getId() {
  86 + return id;
  87 + }
  88 +
  89 + public void setId(Integer id) {
  90 + this.id = id;
  91 + }
  92 +
  93 + public Integer getSectionrouteCode() {
  94 + return sectionrouteCode;
  95 + }
  96 +
  97 + public void setSectionrouteCode(Integer sectionrouteCode) {
  98 + this.sectionrouteCode = sectionrouteCode;
  99 + }
  100 +
  101 + public String getLineCode() {
  102 + return lineCode;
  103 + }
  104 +
  105 + public void setLineCode(String lineCode) {
  106 + this.lineCode = lineCode;
  107 + }
  108 +
  109 + public String getSectionCode() {
  110 + return sectionCode;
  111 + }
  112 +
  113 + public void setSectionCode(String sectionCode) {
  114 + this.sectionCode = sectionCode;
  115 + }
  116 +
  117 + public Integer getDirections() {
  118 + return directions;
  119 + }
  120 +
  121 + public void setDirections(Integer directions) {
  122 + this.directions = directions;
  123 + }
  124 +
  125 + public Integer getVersions() {
  126 + return versions;
  127 + }
  128 +
  129 + public void setVersions(Integer versions) {
  130 + this.versions = versions;
  131 + }
  132 +
  133 + public Integer getDestroy() {
  134 + return destroy;
  135 + }
  136 +
  137 + public void setDestroy(Integer destroy) {
  138 + this.destroy = destroy;
  139 + }
  140 +
  141 + public String getDescriptions() {
  142 + return descriptions;
  143 + }
  144 +
  145 + public void setDescriptions(String descriptions) {
  146 + this.descriptions = descriptions;
  147 + }
  148 +
  149 + public Integer getCreateBy() {
  150 + return createBy;
  151 + }
  152 +
  153 + public void setCreateBy(Integer createBy) {
  154 + this.createBy = createBy;
  155 + }
  156 +
  157 + public Integer getUpdateBy() {
  158 + return updateBy;
  159 + }
  160 +
  161 + public void setUpdateBy(Integer updateBy) {
  162 + this.updateBy = updateBy;
  163 + }
  164 +
  165 + public Date getCreateDate() {
  166 + return createDate;
  167 + }
  168 +
  169 + public void setCreateDate(Date createDate) {
  170 + this.createDate = createDate;
  171 + }
  172 +
  173 + public Date getUpdateDate() {
  174 + return updateDate;
  175 + }
  176 +
  177 + public void setUpdateDate(Date updateDate) {
  178 + this.updateDate = updateDate;
  179 + }
  180 +
  181 + public Section getSection() {
  182 + return section;
  183 + }
  184 +
  185 + public void setSection(Section section) {
  186 + this.section = section;
  187 + }
  188 +
  189 + public Line getLine() {
  190 + return line;
  191 + }
  192 +
  193 + public void setLine(Line line) {
  194 + this.line = line;
  195 + }
  196 +}