Commit 7eb5c34b9f8c588192894ee5f854f8a9a7ac024e

Authored by 潘钊
1 parent 933d77af

update...

src/main/java/com/bsth/common/BasicData.java
1 1 package com.bsth.common;
2 2  
3 3 import com.bsth.Application;
  4 +import org.joda.time.format.DateTimeFormat;
  5 +import org.joda.time.format.DateTimeFormatter;
4 6 import org.springframework.beans.factory.annotation.Autowired;
5 7 import org.springframework.boot.CommandLineRunner;
6 8 import org.springframework.core.annotation.Order;
... ... @@ -37,6 +39,10 @@ public class BasicData implements CommandLineRunner {
37 39 Application.mainServices.scheduleWithFixedDelay(basicDataLoader, 60 * 10, 60 * 10, TimeUnit.SECONDS);
38 40 }
39 41  
  42 + private static DateTimeFormatter fmtHHmm = DateTimeFormat.forPattern("HH:mm");
  43 + private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyyMMdd");
  44 + private static DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm");
  45 + private final static long DAY_TIME = 1000 * 60 * 60 * 24L;
40 46  
41 47 @Component
42 48 public static class BasicDataLoader extends Thread {
... ... @@ -54,6 +60,7 @@ public class BasicData implements CommandLineRunner {
54 60 Map<String, String> lineStartTimeMapCopy = new HashMap<>();
55 61  
56 62 String sql = "select START_OPT,t2.LINE_CODE from bsth_c_line_config t1 INNER JOIN bsth_c_line t2 on t1.line=t2.id where t2.line_code is not null";
  63 + //String cts = fmtHHmm.print(System.currentTimeMillis());
57 64  
58 65 List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
59 66 String lineCode, startTime;
... ... @@ -69,7 +76,12 @@ public class BasicData implements CommandLineRunner {
69 76 }
70 77  
71 78 private String calcScheduleDate(String startDate){
72   - return "20170831";
  79 + long t = System.currentTimeMillis();
  80 +
  81 + if(fmtHHmm.print(t).compareTo(startDate) < 0)
  82 + t += DAY_TIME;
  83 +
  84 + return fmtyyyyMMdd.print(t);
73 85 }
74 86 }
75 87 }
... ...
src/main/java/com/bsth/controller/UserController.java 0 → 100644
  1 +package com.bsth.controller;
  2 +
  3 +import com.bsth.service.UserService;
  4 +import org.springframework.beans.factory.annotation.Autowired;
  5 +import org.springframework.web.bind.annotation.RequestMapping;
  6 +import org.springframework.web.bind.annotation.RestController;
  7 +
  8 +/**
  9 + * Created by panzhao on 2017/9/4.
  10 + */
  11 +@RestController
  12 +@RequestMapping("/line2System")
  13 +public class UserController {
  14 +
  15 + @Autowired
  16 + UserService userService;
  17 +
  18 + @RequestMapping("load_db_data")
  19 + private void loadDbData(){
  20 + userService.loadData();
  21 + }
  22 +}
... ...
src/main/java/com/bsth/server_rs/schedule/dto/ScheduleInOut.java
... ... @@ -37,6 +37,24 @@ public class ScheduleInOut implements Serializable {
37 37  
38 38 ScheduleInOut(ScheduleRealInfo sch){
39 39 this.id = sch.getId();
  40 + this.scheduleDateStr = sch.getScheduleDateStr();
  41 + this.lineCode = sch.getXlBm();
  42 + this.lineName = sch.getXlName();
  43 + this.lpName = sch.getLpName();
  44 + this.nbbm = sch.getClZbh();
  45 + this.jsy = sch.getjGh() + "/" + sch.getjName();
  46 + this.spy = sch.getsGh() + "/" + sch.getsName();
  47 + this.upDown = Integer.parseInt(sch.getXlDir());
  48 + this.qdzCode = sch.getQdzCode();
  49 + this.qdzName = sch.getQdzName();
  50 + this.zdzCode = sch.getZdzCode();
  51 + this.zdzName = sch.getZdzName();
  52 + this.dfsjT = sch.getDfsjT();
  53 + this.zdsjT = sch.getZdsjT();
  54 + this.fcsjActualTime = sch.getFcsjActualTime();
  55 + this.zdsjActualTime = sch.getZdsjActualTime();
  56 + this.sflj = sch.isSflj();
  57 + this.remarks = sch.getRemarks();
40 58 }
41 59  
42 60 private Long id;
... ...
src/main/java/com/bsth/service/UserService.java
... ... @@ -8,4 +8,6 @@ import com.bsth.entity.PasswordUser;
8 8 public interface UserService {
9 9  
10 10 PasswordUser get(String pwd);
  11 +
  12 + void loadData();
11 13 }
... ...
src/main/java/com/bsth/service/impl/UserServiceImpl.java
... ... @@ -29,7 +29,8 @@ public class UserServiceImpl implements UserService , CommandLineRunner {
29 29 return pwd2UserMap.get(pwd);
30 30 }
31 31  
32   - private void loadData(){
  32 + @Override
  33 + public void loadData(){
33 34 Map<String, PasswordUser> map = new HashMap<>();
34 35 Iterator<PasswordUser> iterator = userRepository.findAll().iterator();
35 36 PasswordUser user;
... ... @@ -38,6 +39,8 @@ public class UserServiceImpl implements UserService , CommandLineRunner {
38 39 map.put(user.getPwd(), user);
39 40 }
40 41 pwd2UserMap = map;
  42 +
  43 + System.out.println("加载user size:" + pwd2UserMap.size());
41 44 }
42 45  
43 46 @Override
... ...