Bladeren bron

no message

仰望星空〃 8 maanden geleden
bovenliggende
commit
41d806be36

+ 9 - 0
bus-biz/src/main/java/bus/service/impl/BBusInfoServiceImpl.java

@@ -5,11 +5,13 @@ import bus.model.dto.BBusInfoDto;
 import bus.model.dto.BBusTrackInfoDto;
 import bus.model.dto.BBusTrackTreeDto;
 import bus.model.dto.page.BBusInfoPageDto;
+import bus.model.po.BCourseBusPo;
 import bus.model.vo.BBusInfoVo;
 import bus.model.po.BBusInfoPo;
 import bus.mapper.BBusInfoMapper;
 
 import bus.service.BBusInfoService;
+import bus.service.BCourseBusService;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.PhoneUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -39,6 +41,9 @@ public class BBusInfoServiceImpl extends ServiceImpl<BBusInfoMapper,BBusInfoPo>
 
     @Autowired
     private BBusInfoMapper bBusInfoMapper;
+
+    @Autowired
+    private BCourseBusService bCourseBusService;
     @Resource
     private SnowflakeUtil snowflakeUtil;
 
@@ -187,6 +192,10 @@ public class BBusInfoServiceImpl extends ServiceImpl<BBusInfoMapper,BBusInfoPo>
      */
     @Override
     public BBusTrackInfoDto getTrackInfo(String busId) {
+       QueryWrapper<BCourseBusPo> queryWrapper = new QueryWrapper<>();
+       queryWrapper.eq("bus_id", busId);
+       queryWrapper.eq("is_delete", 0);
+       BCourseBusPo one = bCourseBusService.getOne(queryWrapper);
 
         return null;
     }

+ 82 - 88
bus-biz/src/main/java/bus/service/impl/BCourseInfoServiceImpl.java

@@ -163,25 +163,7 @@ public class BCourseInfoServiceImpl extends ServiceImpl<BCourseInfoMapper, BCour
         //处理时刻
         List<BCourseTimeDto> bCourseTimeList = dto.getBCourseTimeList();
         po.setFirstBusSpace(bCourseTimeList.get(0).getBusSpace());
-        List<BCourseTimePo> bCourseTimePoList = new ArrayList<>();
-        for (int i = 0; i < bCourseTimeList.size(); i++) {
-            BCourseTimeDto bCourseTimeDto = bCourseTimeList.get(i);
-            BCourseTimePo bCourseTimePo = BeanUtil.toBean(bCourseTimeDto, BCourseTimePo.class);
-            bCourseTimePo.setId(snowflakeUtil.snowflakeId());
-            bCourseTimePo.setCourseId(po.getId());
-            bCourseTimePo.setCreateTime(new Date());
-            bCourseTimePo.setUpdateTime(new Date());
-            bCourseTimePo.setCreatorId(extInfo.getUserId());
-            bCourseTimePo.setUpdaterId(extInfo.getUserId());
-            bCourseTimePo.setCreatorName(extInfo.getUserName());
-            bCourseTimePo.setUpdaterName(extInfo.getUserName());
-            if (i == 0) {
-                bCourseTimePo.setType("0");
-            }else {
-                bCourseTimePo.setType("1");
-            }
-            bCourseTimePoList.add(bCourseTimePo);
-        }
+        List<BCourseTimePo> bCourseTimePoList = handleCourseTime(bCourseTimeList, extInfo, po.getId(), false);
         bCourseTimeService.saveBatch(bCourseTimePoList);
         //处理标志点
         List<BCourseStationDto> bCourseStationList = dto.getBCourseStationList();
@@ -196,42 +178,13 @@ public class BCourseInfoServiceImpl extends ServiceImpl<BCourseInfoMapper, BCour
         po.setLastStationName(byId1.getName());
         po.setLastStationId(stationId1);
 
-        List<BCourseStationPo> bCourseStationPoList =new ArrayList<>();
-        for(int i = 0; i < bCourseStationList.size(); i++) {
-            BCourseStationDto bCourseStationDto = bCourseStationList.get(i);
-            BCourseStationPo bCourseStationPo = BeanUtil.toBean(bCourseStationDto, BCourseStationPo.class);
-            bCourseStationPo.setId(snowflakeUtil.snowflakeId());
-            bCourseStationPo.setCourseId(po.getId());
-            bCourseStationPo.setCreateTime(new Date());
-            bCourseStationPo.setUpdateTime(new Date());
-            bCourseStationPo.setCreatorId(extInfo.getUserId());
-            bCourseStationPo.setUpdaterId(extInfo.getUserId());
-            bCourseStationPo.setCreatorName(extInfo.getUserName());
-            bCourseStationPo.setUpdaterName(extInfo.getUserName());
-            if (i == 0) {
-                bCourseStationPo.setType("0");
-            }else if(i == bCourseStationList.size()-1) {
-                bCourseStationPo.setType("2");
-            }else{
-                bCourseStationPo.setType("1");
-            }
-            bCourseStationPoList.add(bCourseStationPo);
-        }
-        bCourseStationService.saveBatch(bCourseStationPoList);
+        List<BCourseStationPo> bCourseStationPos = handleCourseStation(bCourseStationList, extInfo, po.getId(), true);
+        bCourseStationService.saveBatch(bCourseStationPos);
+
         //处理车辆
         List<BCourseBusDto> bCourseBusList = dto.getBCourseBusList();
-        List<BCourseBusPo> bCourseBusPoList = BeanUtil.copyToList(bCourseBusList, BCourseBusPo.class);
-        bCourseBusPoList.forEach(bCourseBusPo -> {
-            bCourseBusPo.setId(snowflakeUtil.snowflakeId());
-            bCourseBusPo.setCourseId(po.getId());
-            bCourseBusPo.setCreateTime(new Date());
-            bCourseBusPo.setUpdateTime(new Date());
-            bCourseBusPo.setCreatorId(extInfo.getUserId());
-            bCourseBusPo.setUpdaterId(extInfo.getUserId());
-            bCourseBusPo.setCreatorName(extInfo.getUserName());
-            bCourseBusPo.setUpdaterName(extInfo.getUserName());
-        });
-        bCourseBusService.saveBatch(bCourseBusPoList);
+        List<BCourseBusPo> bCourseBusPos = handleCourseBus(bCourseBusList, extInfo, po.getId(), true);
+        bCourseBusService.saveBatch(bCourseBusPos);
         this.bCourseInfoMapper.insert(po);
     }
 
@@ -266,17 +219,44 @@ public class BCourseInfoServiceImpl extends ServiceImpl<BCourseInfoMapper, BCour
         bCourseTimeService.deleteByCourseId(po.getId());
         List<BCourseTimeDto> bCourseTimeList = dto.getBCourseTimeList();
         po.setFirstBusSpace(bCourseTimeList.get(0).getBusSpace());
+        List<BCourseTimePo> bCourseTimePoList = handleCourseTime(bCourseTimeList, extInfo, po.getId(), false);
+        bCourseTimeService.saveBatch(bCourseTimePoList);
+        //处理标志点
+        bCourseStationService.deleteByCourseId(po.getId());
+        List<BCourseStationDto> bCourseStationList = dto.getBCourseStationList();
+        String stationName= bCourseStationList.get(0).getName();
+        po.setFirstStationName(stationName);
+        String stationName1 = bCourseStationList.get(bCourseStationList.size()-1).getName();
+        po.setLastStationName(stationName1);
+
+        List<BCourseStationPo> bCourseStationPos = handleCourseStation(bCourseStationList, extInfo, po.getId(),false);
+        bCourseStationService.saveBatch(bCourseStationPos);
+        //处理车辆
+        bCourseBusService.deleteByCourseId(po.getId());
+        List<BCourseBusDto> bCourseBusList = dto.getBCourseBusList();
+        List<BCourseBusPo> bCourseBusPos = handleCourseBus(bCourseBusList, extInfo, po.getId(), false);
+        bCourseBusService.saveBatch(bCourseBusPos);
+        this.bCourseInfoMapper.updateById(po);
+    }
+
+
+    private List<BCourseTimePo> handleCourseTime(List<BCourseTimeDto> timeList,
+                                                 ExtInfo extInfo,
+                                                 String courseId,
+                                                 Boolean isCreate) {
         List<BCourseTimePo> bCourseTimePoList = new ArrayList<>();
-        for (int i = 0; i < bCourseTimeList.size(); i++) {
-            BCourseTimeDto bCourseTimeDto = bCourseTimeList.get(i);
+        for (int i = 0; i < timeList.size(); i++) {
+            BCourseTimeDto bCourseTimeDto = timeList.get(i);
             BCourseTimePo bCourseTimePo = BeanUtil.toBean(bCourseTimeDto, BCourseTimePo.class);
             bCourseTimePo.setId(snowflakeUtil.snowflakeId());
-            bCourseTimePo.setCourseId(po.getId());
-            bCourseTimePo.setCreateTime(new Date());
+            bCourseTimePo.setCourseId(courseId);
+            if(isCreate){
+                bCourseTimePo.setCreateTime(new Date());
+                bCourseTimePo.setCreatorId(extInfo.getUserId());
+                bCourseTimePo.setCreatorName(extInfo.getUserName());
+            }
             bCourseTimePo.setUpdateTime(new Date());
-            bCourseTimePo.setCreatorId(extInfo.getUserId());
             bCourseTimePo.setUpdaterId(extInfo.getUserId());
-            bCourseTimePo.setCreatorName(extInfo.getUserName());
             bCourseTimePo.setUpdaterName(extInfo.getUserName());
             if (i == 0) {
                 bCourseTimePo.setType("0");
@@ -285,55 +265,67 @@ public class BCourseInfoServiceImpl extends ServiceImpl<BCourseInfoMapper, BCour
             }
             bCourseTimePoList.add(bCourseTimePo);
         }
-        bCourseTimeService.saveBatch(bCourseTimePoList);
-        //处理标志点
-        bCourseStationService.deleteByCourseId(po.getId());
-        List<BCourseStationDto> bCourseStationList = dto.getBCourseStationList();
-        String stationName= bCourseStationList.get(0).getName();
-        po.setFirstStationName(stationName);
-        String stationName1 = bCourseStationList.get(bCourseStationList.size()-1).getName();
-        po.setLastStationName(stationName1);
+        return bCourseTimePoList;
+    }
+    /**
+     * 处理站点信息
+     */
 
-        List<BCourseStationPo> bCourseStationPoList =new ArrayList<>();
-        for(int i = 0; i < bCourseStationList.size(); i++) {
-            BCourseStationDto bCourseStationDto = bCourseStationList.get(i);
+    private List<BCourseStationPo> handleCourseStation(List<BCourseStationDto> stationList,
+                                                       ExtInfo extInfo,
+                                                       String courseId,
+                                                       Boolean isCreate) {
+        List<BCourseStationPo> poList = new ArrayList<>();
+        for (int i = 0; i < stationList.size(); i++) {
+            BCourseStationDto bCourseStationDto = stationList.get(i);
             BCourseStationPo bCourseStationPo = BeanUtil.toBean(bCourseStationDto, BCourseStationPo.class);
             bCourseStationPo.setId(snowflakeUtil.snowflakeId());
-            bCourseStationPo.setCourseId(po.getId());
-            bCourseStationPo.setCreateTime(new Date());
+            bCourseStationPo.setCourseId(courseId);
+            if(isCreate){
+                bCourseStationPo.setCreateTime(new Date());
+                bCourseStationPo.setCreatorId(extInfo.getUserId());
+                bCourseStationPo.setCreatorName(extInfo.getUserName());
+            }
             bCourseStationPo.setUpdateTime(new Date());
-            bCourseStationPo.setCreatorId(extInfo.getUserId());
             bCourseStationPo.setUpdaterId(extInfo.getUserId());
-            bCourseStationPo.setCreatorName(extInfo.getUserName());
             bCourseStationPo.setUpdaterName(extInfo.getUserName());
             if (i == 0) {
                 bCourseStationPo.setType("0");
-            }else if(i == bCourseStationList.size()-1) {
+            }else if(i == stationList.size()-1) {
                 bCourseStationPo.setType("2");
             }else{
                 bCourseStationPo.setType("1");
             }
-            bCourseStationPoList.add(bCourseStationPo);
+            poList.add(bCourseStationPo);
         }
-        bCourseStationService.saveBatch(bCourseStationPoList);
-        //处理车辆
-        bCourseBusService.deleteByCourseId(po.getId());
-        List<BCourseBusDto> bCourseBusList = dto.getBCourseBusList();
-        List<BCourseBusPo> bCourseBusPoList = BeanUtil.copyToList(bCourseBusList, BCourseBusPo.class);
-        bCourseBusPoList.forEach(bCourseBusPo -> {
+        return poList;
+    }
+
+    private List<BCourseBusPo> handleCourseBus(List<BCourseBusDto> busList,
+                                               ExtInfo extInfo,
+                                               String courseId,
+                                               Boolean isCreate) {
+        List<BCourseBusPo> poList = BeanUtil.copyToList(busList, BCourseBusPo.class);
+        poList.forEach(bCourseBusPo -> {
+            bCourseBusPo.setCourseId(courseId);
             bCourseBusPo.setId(snowflakeUtil.snowflakeId());
-            bCourseBusPo.setCourseId(po.getId());
-            bCourseBusPo.setCreateTime(new Date());
+            bCourseBusPo.setCourseId(courseId);
+            if(isCreate){
+                bCourseBusPo.setCreateTime(new Date());
+                bCourseBusPo.setCreatorId(extInfo.getUserId());
+                bCourseBusPo.setCreatorName(extInfo.getUserName());
+            }
             bCourseBusPo.setUpdateTime(new Date());
-            bCourseBusPo.setCreatorId(extInfo.getUserId());
             bCourseBusPo.setUpdaterId(extInfo.getUserId());
-            bCourseBusPo.setCreatorName(extInfo.getUserName());
             bCourseBusPo.setUpdaterName(extInfo.getUserName());
         });
-        bCourseBusService.saveBatch(bCourseBusPoList);
-        this.bCourseInfoMapper.updateById(po);
+
+        return poList;
+
     }
 
+
+
     /**
      * 删除
      * @param id
@@ -445,4 +437,6 @@ public class BCourseInfoServiceImpl extends ServiceImpl<BCourseInfoMapper, BCour
         s = s * 6378137; // 地球半径
         return s;
     }
+
+
 }