Commit 4c0aef88aec6119f9e35f1ad08c0816b959094b2
1 parent
790463e4
车辆报废,释放设备编号后在设备管理里添加一条设备替换记录
Showing
3 changed files
with
56 additions
and
5 deletions
src/main/java/com/bsth/repository/schedule/CarConfigInfoRepository.java
| @@ -50,4 +50,7 @@ public interface CarConfigInfoRepository extends BaseRepository<CarConfigInfo, L | @@ -50,4 +50,7 @@ public interface CarConfigInfoRepository extends BaseRepository<CarConfigInfo, L | ||
| 50 | 50 | ||
| 51 | @EntityGraph(value = "carConfigInfo_xl_cl", type = EntityGraph.EntityGraphType.FETCH) | 51 | @EntityGraph(value = "carConfigInfo_xl_cl", type = EntityGraph.EntityGraphType.FETCH) |
| 52 | List<CarConfigInfo> findByXlId(Integer xlid); | 52 | List<CarConfigInfo> findByXlId(Integer xlid); |
| 53 | + | ||
| 54 | + @EntityGraph(value = "carConfigInfo_xl_cl", type = EntityGraph.EntityGraphType.FETCH) | ||
| 55 | + List<CarConfigInfo> findByClId(Integer clid); | ||
| 53 | } | 56 | } |
| 54 | \ No newline at end of file | 57 | \ No newline at end of file |
src/main/java/com/bsth/service/schedule/impl/CarsServiceImpl.java
| 1 | package com.bsth.service.schedule.impl; | 1 | package com.bsth.service.schedule.impl; |
| 2 | 2 | ||
| 3 | +import com.bsth.entity.CarDevice; | ||
| 3 | import com.bsth.entity.Cars; | 4 | import com.bsth.entity.Cars; |
| 5 | +import com.bsth.entity.schedule.CarConfigInfo; | ||
| 6 | +import com.bsth.repository.schedule.CarConfigInfoRepository; | ||
| 7 | +import com.bsth.service.schedule.CarDeviceService; | ||
| 4 | import com.bsth.service.schedule.CarsService; | 8 | import com.bsth.service.schedule.CarsService; |
| 5 | import com.bsth.service.schedule.exception.ScheduleException; | 9 | import com.bsth.service.schedule.exception.ScheduleException; |
| 6 | import com.bsth.service.schedule.utils.DataToolsFile; | 10 | import com.bsth.service.schedule.utils.DataToolsFile; |
| @@ -12,7 +16,9 @@ import org.springframework.transaction.annotation.Transactional; | @@ -12,7 +16,9 @@ import org.springframework.transaction.annotation.Transactional; | ||
| 12 | import org.springframework.util.CollectionUtils; | 16 | import org.springframework.util.CollectionUtils; |
| 13 | 17 | ||
| 14 | import java.io.File; | 18 | import java.io.File; |
| 19 | +import java.util.Date; | ||
| 15 | import java.util.HashMap; | 20 | import java.util.HashMap; |
| 21 | +import java.util.List; | ||
| 16 | import java.util.Map; | 22 | import java.util.Map; |
| 17 | 23 | ||
| 18 | /** | 24 | /** |
| @@ -24,6 +30,48 @@ public class CarsServiceImpl extends BServiceImpl<Cars, Integer> implements Cars | @@ -24,6 +30,48 @@ public class CarsServiceImpl extends BServiceImpl<Cars, Integer> implements Cars | ||
| 24 | @Qualifier(value = "cars_dataTool") | 30 | @Qualifier(value = "cars_dataTool") |
| 25 | private DataToolsService dataToolsService; | 31 | private DataToolsService dataToolsService; |
| 26 | 32 | ||
| 33 | + @Autowired | ||
| 34 | + @Qualifier(value = "carDeviceServiceImpl_sc") | ||
| 35 | + private CarDeviceService carDeviceService; | ||
| 36 | + | ||
| 37 | + @Autowired | ||
| 38 | + private CarConfigInfoRepository carConfigInfoRepository; | ||
| 39 | + | ||
| 40 | + @Override | ||
| 41 | + public Cars save(Cars cars) { | ||
| 42 | + if (cars.getId() != null && cars.getScrapState()) { // 更新车辆信息,报废车辆 | ||
| 43 | + // 1、作废的车辆,修改报废号 | ||
| 44 | + String eCode = cars.getEquipmentCode(); | ||
| 45 | + cars.setEquipmentCode("BF-" + eCode); | ||
| 46 | + cars.setScrapCode("BF-" + cars.getEquipmentCode()); | ||
| 47 | + // 2、添加一条相关的设备替换记录 | ||
| 48 | + // 查找在哪条线路上 | ||
| 49 | + List<CarConfigInfo> carConfigInfoList = carConfigInfoRepository.findByClId(cars.getId()); | ||
| 50 | + for (CarConfigInfo carConfigInfo : carConfigInfoList) { | ||
| 51 | + CarDevice carDevice = new CarDevice(); | ||
| 52 | + carDevice.setGsName(cars.getCompany()); | ||
| 53 | + carDevice.setCompany(cars.getBusinessCode()); | ||
| 54 | + carDevice.setBrancheCompany(cars.getBrancheCompanyCode()); | ||
| 55 | + carDevice.setCl(cars.getId()); | ||
| 56 | + carDevice.setClZbh(cars.getInsideCode()); | ||
| 57 | + carDevice.setXl(carConfigInfo.getXl().getId()); | ||
| 58 | + carDevice.setXlName(carConfigInfo.getXl().getName()); | ||
| 59 | + carDevice.setXlBm(carConfigInfo.getXl().getLineCode()); | ||
| 60 | + carDevice.setOldDeviceNo(eCode); | ||
| 61 | + carDevice.setNewDeviceNo("BF-" + eCode); | ||
| 62 | + carDevice.setIsCancel(false); | ||
| 63 | + | ||
| 64 | + carDevice.setCreateBy(cars.getCreateBy()); | ||
| 65 | + carDevice.setUpdateBy(cars.getUpdateBy()); | ||
| 66 | + carDevice.setCreateDate(new Date()); | ||
| 67 | + carDevice.setUpdateDate(new Date()); | ||
| 68 | + carDeviceService.save(carDevice); | ||
| 69 | + } | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + return super.save(cars); | ||
| 73 | + } | ||
| 74 | + | ||
| 27 | @Override | 75 | @Override |
| 28 | public void importData(File file, Map<String, Object> params) throws ScheduleException { | 76 | public void importData(File file, Map<String, Object> params) throws ScheduleException { |
| 29 | dataToolsService.importData(file, params); | 77 | dataToolsService.importData(file, params); |
src/main/resources/static/pages/scheduleApp/module/basicInfo/busInfoManage/module.js
| @@ -294,11 +294,11 @@ angular.module('ScheduleApp').controller( | @@ -294,11 +294,11 @@ angular.module('ScheduleApp').controller( | ||
| 294 | self.submit = function() { | 294 | self.submit = function() { |
| 295 | console.log(self.busInfoForSave); | 295 | console.log(self.busInfoForSave); |
| 296 | 296 | ||
| 297 | - // 报废的车辆,修改原来的车辆终端号 | ||
| 298 | - if (self.busInfoForSave.scrapState == true) { | ||
| 299 | - self.busInfoForSave.equipmentCode = "BF-" + self.busInfoForSave.equipmentCode; | ||
| 300 | - self.busInfoForSave.scrapCode = "BF-" + self.busInfoForSave.equipmentCode; | ||
| 301 | - } | 297 | + // // 报废的车辆,修改原来的车辆终端号 |
| 298 | + // if (self.busInfoForSave.scrapState == true) { | ||
| 299 | + // self.busInfoForSave.equipmentCode = "BF-" + self.busInfoForSave.equipmentCode; | ||
| 300 | + // self.busInfoForSave.scrapCode = "BF-" + self.busInfoForSave.equipmentCode; | ||
| 301 | + // } | ||
| 302 | 302 | ||
| 303 | 303 | ||
| 304 | // 保存或者更新 | 304 | // 保存或者更新 |