Commit 4ebd99b19517bb60ae6deb8c7ab96c365a743083

Authored by zlz
1 parent 5e705681

批量上传站级数据

src/main/java/com/bsth/controller/schedule/TrafficManageController.java
... ... @@ -30,6 +30,15 @@ public class TrafficManageController {
30 30 }
31 31 }
32 32  
  33 + @RequestMapping(value = "/setXLByInUse", method = RequestMethod.GET)
  34 + public String setXLByInUse(@RequestParam("inUse") String inUse) throws Exception {
  35 + try {
  36 + return trManageService.setXLByInUse(inUse);
  37 + } catch (Exception exp) {
  38 + throw new Exception(exp.getCause());
  39 + }
  40 + }
  41 +
33 42 @RequestMapping(value = "/setCL", method = RequestMethod.GET)
34 43 public String setCL() throws Exception {
35 44 try {
... ...
src/main/java/com/bsth/service/TrafficManageService.java
... ... @@ -27,6 +27,13 @@ public interface TrafficManageService {
27 27 String setXL(String ids);
28 28  
29 29 /**
  30 + * 上传线路信息
  31 + *
  32 + * @return 调用接口返回信息
  33 + */
  34 + String setXLByInUse(String ids);
  35 +
  36 + /**
30 37 * 上传车辆信息
31 38 *
32 39 * @return 调用接口返回信息
... ...
src/main/java/com/bsth/service/impl/TrafficManageServiceImpl.java
... ... @@ -160,6 +160,9 @@ public class TrafficManageServiceImpl implements TrafficManageService{
160 160 String[] idArray = ids.split(",");
161 161 try {
162 162 for (String id : idArray) {
  163 + if(id == null || id.trim().equals("")){
  164 + continue;
  165 + }
163 166 Map<String,Object> map = new HashMap<>();
164 167 map.put("lineCode_eq", id);
165 168 Line line ;
... ... @@ -237,6 +240,42 @@ public class TrafficManageServiceImpl implements TrafficManageService{
237 240 }
238 241  
239 242 /**
  243 + * 上传线路信息(按in_use上传)
  244 + */
  245 + @Override
  246 + public String setXLByInUse(String inUse) {
  247 + String result = "failure";
  248 + try {
  249 + Map<String,Object> map = new HashMap<>();
  250 + if(inUse != null && inUse.equals("1")){
  251 + map.put("inUse_eq", inUse);
  252 + }
  253 + List<Line> lines ;
  254 + Line line;
  255 + lines = lineRepository.findAll(new CustomerSpecs<Line>(map));
  256 + String[] ids ;
  257 + if(lines != null && lines.size() > 0){
  258 + ids = new String[lines.size()];
  259 + for(int i = 0 ; i < lines.size() ; i ++){
  260 + line = lines.get(i);
  261 + if(line != null && line.getId() != null){
  262 + ids[i] = String.valueOf(line.getId());
  263 + }
  264 + }
  265 + if(ids != null && ids.length > 0 ){
  266 + System.out.println(ids.length);
  267 + setXL(StringUtils.join(ids,","));
  268 + }
  269 + }
  270 + } catch (Exception e) {
  271 + result = "failure";
  272 + logger.error("setXLByInUse:",e);
  273 + e.printStackTrace();
  274 + }
  275 + return result;
  276 + }
  277 +
  278 + /**
240 279 * 上传车辆信息
241 280 */
242 281 @Override
... ...