SchedulePlanInfo.java 15 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581
package com.bsth.entity.schedule;

import com.bsth.entity.Line;
import com.bsth.entity.sys.SysUser;
import com.bsth.service.schedule.rules.shiftloop.ScheduleResult_output;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

/**
 * 排班计划明细。
 * 内部字段全冗余,无关联对象(外键关联关系),
 * 可以单独存在,其余表要关联此对象/表,必须使用中间对象/表。
 */
@Entity
@Table(name = "bsth_c_s_sp_info")
public class SchedulePlanInfo {

    /** 主键Id */
    @Id
    @GeneratedValue
    private Long id;

    /** 排班计划日期 */
    @Column(nullable = false)
    private Date scheduleDate;

    /** 关联的公司名称 */
    private String gsName;
    /** 关联的公司编码 */
    private String gsBm;
    /** 关联的分公司名称 */
    private String fgsName;
    /** 关联的分公司编码 */
    private String fgsBm;
    /** 出场顺序号 */
    private Integer ccno;

    /** 关联 bsth_c_line 主键,不做mapping */
    @Column(nullable = false)
    private Integer xl;
    /** 线路名称 */
    @Column(nullable = false)
    private String xlName;
    /** 线路编码 */
    @Column(nullable = false)
    private String xlBm;

    /** 关联 bsth_c_s_gbi 主键,不做mapping */
    @Column(nullable = false)
    private Long lp;
    /** 路牌名称 */
    @Column(nullable = false)
    private String lpName;

    /** 关联 bsth_c_cars 主键,不做mapping */
    @Column(nullable = false)
    private Integer cl;
    /** 车辆自编号 */
    @Column(nullable = false)
    private String clZbh;

    /** 当分班的时候,驾驶员会不一样,具体根据规则,还有时刻表决定 */
    /** 报道时间(格式 HH:mm) */
    private String bdTime;
    /** 出场时间(格式 HH:mm) */
    private String ccTime;
    /** 关联的驾驶员 bsth_c_personnel 主键,不做mapping */
    @Column(nullable = false)
    private Integer j;
    /** 驾驶员工号 */
    @Column(nullable = false)
    private String jGh;
    /** 驾驶员名字 */
    @Column(nullable = false)
    private String jName;
    /** 关联的售票员 bsth_c_personnel 主键,不做mapping */
    private Integer s;
    /** 售票员工号 */
    private String sGh;
    /** 售票员名字 */
    private String sName;

    // 冗余的时刻明细信息,不做mapping
    /** 线路方向(TODO:上下行,上行,下行,这个以后用枚举还是字典再议,现在先用文字) */
    @Column(nullable = false)
    private String xlDir;
    /** 起点站id,根据班次类型,会关联 bsth_c_station,或 bsth_c_car_park,不做mapping */
    @Column(nullable = false)
    private Integer qdz;
    /** 起点站code */
    private String qdzCode;
    /** 起点站名字 */
    @Column(nullable = false)
    private String qdzName;
    /** 终点站id,根据班次类型,会关联 bsth_c_station,或 bsth_c_car_park,不做mapping */
    @Column(nullable = false)
    private Integer zdz;
    /** 终点站code */
    private String zdzCode;
    /** 终点站名字 */
    @Column(nullable = false)
    private String zdzName;

    /** 发车时间(格式 HH:mm) */
    @Column(nullable = false)
    private String fcsj;
    /** 发车顺序号 */
    @Column(nullable = false)
    private Integer fcno;
    /** 对应班次数 */
    @Column(nullable = false)
    private Integer bcs;
    /** 计划里程 */
    private Double jhlc;
    /** 班次历时 */
    private Integer bcsj;

    /** 班次类型 字典type=ScheduleType */
    @Column(nullable = false)
    private String bcType;

    // 重要的新增字段
    /** 关联的时刻表id */
    private Long ttInfo;
    /** 关联的时刻表名字 */
    private String ttInfoName;


    /** 创建人 */
    @ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
    private SysUser createBy;
    /** 修改人 */
    @ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
    private SysUser updateBy;
    /** 创建日期 */
    @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
    private Date createDate;
    /** 修改日期 */
    @Column(name = "update_date", columnDefinition = "TIMESTAMP  DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
    private Date updateDate;


    @ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
    @JoinTable(
            name = "bsth_c_s_sp_r_info",
            joinColumns = @JoinColumn(name = "sp_info_id"),
            inverseJoinColumns = @JoinColumn(name = "sp_id")
    )
    private SchedulePlan schedulePlan;

    public SchedulePlanInfo() {}

    public SchedulePlanInfo(
            Line xl,
            ScheduleResult_output scheduleResult_output,
            TTInfoDetail ttInfoDetail,
            CarConfigInfo carConfigInfo,
            List<EmployeeConfigInfo> employeeConfigInfoList,
            SchedulePlan schedulePlan) {

        // TODO:关联的公司名称
        // TODO:关联的公司编码
        // TODO:关联的分公司名称
        // TODO:关联的分公司编码
        // TODO:关联的出场顺序号

        // 关联的排班计划
        this.schedulePlan = schedulePlan;

        // 排班计划时间
        this.scheduleDate = scheduleResult_output.getSd().toDate();

        // 关联的线路信息
        this.xl = xl.getId(); // 线路id
        this.xlBm = xl.getLineCode(); // 线路编码
        this.xlName = xl.getName(); // 线路名称

        // 关联的路牌
        this.lp = ttInfoDetail.getLp().getId();
        this.lpName = ttInfoDetail.getLp().getLpName();

        // 关联的车辆信息
        this.cl = carConfigInfo.getCl().getId(); // 车辆id
        this.clZbh = carConfigInfo.getCl().getInsideCode(); // 自编号/内部编号

        // TODO:报道时间,出场时间没有
        // 关联的驾驶员
        EmployeeConfigInfo employeeConfigInfo = null;
        if (ttInfoDetail.getIsFB()) {
            if (employeeConfigInfoList.size() > 1) {
                employeeConfigInfo = employeeConfigInfoList.get(1);
            } else {
                employeeConfigInfo = employeeConfigInfoList.get(0);
            }
        } else {
            employeeConfigInfo = employeeConfigInfoList.get(0);
        }

        this.j = employeeConfigInfo.getJsy().getId();
        this.jGh = employeeConfigInfo.getJsy().getJobCode();
        this.jName = employeeConfigInfo.getJsy().getPersonnelName();
        // 关联的售票员
        if (employeeConfigInfo.getSpy() != null) {
            this.s = employeeConfigInfo.getSpy().getId();
            this.sGh = employeeConfigInfo.getSpy().getJobCode();
            this.sName = employeeConfigInfo.getSpy().getPersonnelName();
        }

        // 时刻明细数据
        this.xlDir = ttInfoDetail.getXlDir(); // 线路上下行
        this.bcType = ttInfoDetail.getBcType(); // 班次类型
        if ("out".equals(this.bcType)) { // 出场班次
            this.qdz = ttInfoDetail.getTcc().getId(); // 起点站-停车场id
            this.qdzCode = ttInfoDetail.getTcc().getParkCode(); // 起点站-停车场code
            this.qdzName = ttInfoDetail.getTcc().getParkName(); // 起点站-停车场name
            this.zdz = ttInfoDetail.getZdz().getId(); // 终点站id
            this.zdzCode = ttInfoDetail.getZdz().getStationCod(); // 终点站code
            this.zdzName = ttInfoDetail.getZdz().getStationName(); // 终点站name
        } else if ("in".equals(this.bcType)) { // 进场班次
            this.qdz = ttInfoDetail.getQdz().getId(); // 起点站id
            this.qdzCode = ttInfoDetail.getQdz().getStationCod(); // 起点站code
            this.qdzName = ttInfoDetail.getQdz().getStationName(); // 起点站name
            this.zdz = ttInfoDetail.getTcc().getId(); // 终点站-停车场id
            this.zdzCode = ttInfoDetail.getTcc().getParkCode(); // 终点站-停车场code
            this.zdzName = ttInfoDetail.getTcc().getParkName(); // 终点站-停车场name
        } else { // 其他班次
            this.qdz = ttInfoDetail.getQdz().getId(); // 起点站id
            this.qdzCode = ttInfoDetail.getQdz().getStationCod(); // 起点站code
            this.qdzName = ttInfoDetail.getQdz().getStationName(); // 起点站name
            this.zdz = ttInfoDetail.getZdz().getId(); // 终点站id
            this.zdzCode = ttInfoDetail.getZdz().getStationCod(); // 终点站code
            this.zdzName = ttInfoDetail.getZdz().getStationName(); // 终点站name
        }

        this.fcsj = ttInfoDetail.getFcsj(); // 发车时间
        this.fcno = ttInfoDetail.getFcno(); // 发车顺序号
        this.bcs = ttInfoDetail.getBcs(); // 班次数
        this.jhlc = ttInfoDetail.getJhlc(); // 计划里程
        this.bcsj = ttInfoDetail.getBcsj(); // 班次时间

    }


    public Integer getS() {
        return s;
    }

    public void setS(Integer s) {
        this.s = s;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Date getScheduleDate() {
        return scheduleDate;
    }

    public void setScheduleDate(Date scheduleDate) {
        this.scheduleDate = scheduleDate;
    }

    public Integer getXl() {
        return xl;
    }

    public void setXl(Integer xl) {
        this.xl = xl;
    }

    public String getXlName() {
        return xlName;
    }

    public void setXlName(String xlName) {
        this.xlName = xlName;
    }

    public String getXlBm() {
        return xlBm;
    }

    public void setXlBm(String xlBm) {
        this.xlBm = xlBm;
    }

    public Long getLp() {
        return lp;
    }

    public void setLp(Long lp) {
        this.lp = lp;
    }

    public String getLpName() {
        return lpName;
    }

    public void setLpName(String lpName) {
        this.lpName = lpName;
    }

    public Integer getCl() {
        return cl;
    }

    public void setCl(Integer cl) {
        this.cl = cl;
    }

    public String getClZbh() {
        return clZbh;
    }

    public void setClZbh(String clZbh) {
        this.clZbh = clZbh;
    }

    public String getBdTime() {
        return bdTime;
    }

    public void setBdTime(String bdTime) {
        this.bdTime = bdTime;
    }

    public String getCcTime() {
        return ccTime;
    }

    public void setCcTime(String ccTime) {
        this.ccTime = ccTime;
    }

    public Integer getJ() {
        return j;
    }

    public void setJ(Integer j) {
        this.j = j;
    }

    public String getjGh() {
        return jGh;
    }

    public void setjGh(String jGh) {
        this.jGh = jGh;
    }

    public String getjName() {
        return jName;
    }

    public void setjName(String jName) {
        this.jName = jName;
    }

    public String getsGh() {
        return sGh;
    }

    public void setsGh(String sGh) {
        this.sGh = sGh;
    }

    public String getsName() {
        return sName;
    }

    public void setsName(String sName) {
        this.sName = sName;
    }

    public String getXlDir() {
        return xlDir;
    }

    public void setXlDir(String xlDir) {
        this.xlDir = xlDir;
    }

    public Integer getQdz() {
        return qdz;
    }

    public void setQdz(Integer qdz) {
        this.qdz = qdz;
    }

    public String getQdzName() {
        return qdzName;
    }

    public void setQdzName(String qdzName) {
        this.qdzName = qdzName;
    }

    public Integer getZdz() {
        return zdz;
    }

    public void setZdz(Integer zdz) {
        this.zdz = zdz;
    }

    public String getZdzName() {
        return zdzName;
    }

    public void setZdzName(String zdzName) {
        this.zdzName = zdzName;
    }

    public String getFcsj() {
        return fcsj;
    }

    public void setFcsj(String fcsj) {
        this.fcsj = fcsj;
    }

    public Integer getFcno() {
        return fcno;
    }

    public void setFcno(Integer fcno) {
        this.fcno = fcno;
    }

    public Integer getBcs() {
        return bcs;
    }

    public void setBcs(Integer bcs) {
        this.bcs = bcs;
    }

    public Double getJhlc() {
        return jhlc;
    }

    public void setJhlc(Double jhlc) {
        this.jhlc = jhlc;
    }

    public Integer getBcsj() {
        return bcsj;
    }

    public void setBcsj(Integer bcsj) {
        this.bcsj = bcsj;
    }

    public String getBcType() {
        return bcType;
    }

    public void setBcType(String bcType) {
        this.bcType = bcType;
    }

    public SysUser getCreateBy() {
        return createBy;
    }

    public void setCreateBy(SysUser createBy) {
        this.createBy = createBy;
    }

    public SysUser getUpdateBy() {
        return updateBy;
    }

    public void setUpdateBy(SysUser updateBy) {
        this.updateBy = updateBy;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public Date getUpdateDate() {
        return updateDate;
    }

    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }

    public String getQdzCode() {
        return qdzCode;
    }

    public void setQdzCode(String qdzCode) {
        this.qdzCode = qdzCode;
    }

    public String getZdzCode() {
        return zdzCode;
    }

    public void setZdzCode(String zdzCode) {
        this.zdzCode = zdzCode;
    }

    public String getGsName() {
        return gsName;
    }

    public void setGsName(String gsName) {
        this.gsName = gsName;
    }

    public String getGsBm() {
        return gsBm;
    }

    public void setGsBm(String gsBm) {
        this.gsBm = gsBm;
    }

    public String getFgsName() {
        return fgsName;
    }

    public void setFgsName(String fgsName) {
        this.fgsName = fgsName;
    }

    public String getFgsBm() {
        return fgsBm;
    }

    public void setFgsBm(String fgsBm) {
        this.fgsBm = fgsBm;
    }

    public Integer getCcno() {
        return ccno;
    }

    public void setCcno(Integer ccno) {
        this.ccno = ccno;
    }

    public SchedulePlan getSchedulePlan() {
        return schedulePlan;
    }

    public void setSchedulePlan(SchedulePlan schedulePlan) {
        this.schedulePlan = schedulePlan;
    }

    public Long getTtInfo() {
        return ttInfo;
    }

    public void setTtInfo(Long ttInfo) {
        this.ttInfo = ttInfo;
    }

    public String getTtInfoName() {
        return ttInfoName;
    }

    public void setTtInfoName(String ttInfoName) {
        this.ttInfoName = ttInfoName;
    }
}