Commit 2d39ce9ecaaed230110a158a3438f08f60bd8762
1 parent
601fcdb5
优化车辆信息
Showing
6 changed files
with
106 additions
and
20 deletions
trash-unit/src/main/java/com/trash/carInfo/controller/CarInfoController.java
| ... | ... | @@ -16,20 +16,18 @@ import org.springframework.web.bind.annotation.*; |
| 16 | 16 | import org.springframework.web.multipart.MultipartFile; |
| 17 | 17 | |
| 18 | 18 | import java.io.IOException; |
| 19 | -import java.util.List; | |
| 20 | -import java.util.Objects; | |
| 19 | +import java.util.*; | |
| 21 | 20 | import java.util.stream.Collectors; |
| 22 | 21 | |
| 23 | 22 | /** |
| 24 | 23 | * 运输车辆管理Controller |
| 25 | - * | |
| 24 | + * | |
| 26 | 25 | * @author trash |
| 27 | 26 | * @date 2023-11-21 |
| 28 | 27 | */ |
| 29 | 28 | @RestController |
| 30 | 29 | @RequestMapping("/unit/carInfo") |
| 31 | -public class CarInfoController extends BaseController | |
| 32 | -{ | |
| 30 | +public class CarInfoController extends BaseController { | |
| 33 | 31 | @Autowired |
| 34 | 32 | private ICarInfoService carInfoService; |
| 35 | 33 | |
| ... | ... | @@ -38,21 +36,20 @@ public class CarInfoController extends BaseController |
| 38 | 36 | */ |
| 39 | 37 | @PreAuthorize("@ss.hasPermi('unit:carInfo:list')") |
| 40 | 38 | @GetMapping("/list") |
| 41 | - public TableDataInfo list(CarInfoVo carInfo) | |
| 42 | - { | |
| 39 | + public TableDataInfo list(CarInfoVo carInfo) { | |
| 43 | 40 | startPage(); |
| 44 | 41 | carInfo.setIsDel(1); |
| 45 | 42 | List<CarInfoVo> list = carInfoService.selectCarInfoList(carInfo); |
| 46 | 43 | TableDataInfo data = getDataTable(list); |
| 47 | - if(CollectionUtils.isNotEmpty(list)){ | |
| 48 | - list = list.stream().map(car->{ | |
| 49 | - if(Objects.equals(car.getCarType(),"轻型货车")){ | |
| 44 | + if (CollectionUtils.isNotEmpty(list)) { | |
| 45 | + list = list.stream().map(car -> { | |
| 46 | + if (Objects.equals(car.getCarType(), "轻型货车")) { | |
| 50 | 47 | car.setCarLeft("car_1.png"); |
| 51 | 48 | car.setRemark("箱体长2.6m,宽1.7m,高1.5m;最多可容纳约90袋装修垃圾(75cm*5cm每袋)"); |
| 52 | - }else if(Objects.equals(car.getCarType(),"中型货车")){ | |
| 49 | + } else if (Objects.equals(car.getCarType(), "中型货车")) { | |
| 53 | 50 | car.setCarLeft("car_2.png"); |
| 54 | 51 | car.setRemark("箱体长3.2m,宽1.5m,高1.5m;最多可容纳约110袋装修垃圾(75cm*45cm每袋)"); |
| 55 | - }else if(Objects.equals(car.getCarType(),"大中型货车")){ | |
| 52 | + } else if (Objects.equals(car.getCarType(), "大中型货车")) { | |
| 56 | 53 | car.setCarLeft("car_3.png"); |
| 57 | 54 | car.setRemark("箱体长3.2m,宽1.9m,高1.9m;最多可容纳约150袋装修垃圾(75cm*45cm每袋)"); |
| 58 | 55 | } |
| ... | ... | @@ -63,14 +60,54 @@ public class CarInfoController extends BaseController |
| 63 | 60 | return data; |
| 64 | 61 | } |
| 65 | 62 | |
| 63 | + @GetMapping("/list/group/by/carType") | |
| 64 | + public TableDataInfo listGroupByCarType(CarInfoVo carInfo) { | |
| 65 | + | |
| 66 | + carInfo.setIsDel(1); | |
| 67 | + List<CarInfoVo> list = carInfoService.selectCarInfoListFront(carInfo); | |
| 68 | + TableDataInfo data = getDataTable(list); | |
| 69 | + if (CollectionUtils.isNotEmpty(list)) { | |
| 70 | + Map<String, List<CarInfoVo>> carMap = list.stream().map(car -> { | |
| 71 | + if (Objects.equals(car.getCarType(), "轻型货车")) { | |
| 72 | + car.setCarLeft("car_1.png"); | |
| 73 | + car.setRemark("箱体长2.6m,宽1.7m,高1.5m;最多可容纳约90袋装修垃圾(75cm*5cm每袋)"); | |
| 74 | + } else if (Objects.equals(car.getCarType(), "中型货车")) { | |
| 75 | + car.setCarLeft("car_2.png"); | |
| 76 | + car.setRemark("箱体长3.2m,宽1.5m,高1.5m;最多可容纳约110袋装修垃圾(75cm*45cm每袋)"); | |
| 77 | + } else if (Objects.equals(car.getCarType(), "大中型货车")) { | |
| 78 | + car.setCarLeft("car_3.png"); | |
| 79 | + car.setRemark("箱体长3.2m,宽1.9m,高1.9m;最多可容纳约150袋装修垃圾(75cm*45cm每袋)"); | |
| 80 | + } | |
| 81 | + return car; | |
| 82 | + }).collect(Collectors.groupingBy(CarInfoVo::getCarType)); | |
| 83 | + | |
| 84 | + List<CarInfoVo> carList = new ArrayList<>(); | |
| 85 | + for (Map.Entry<String, List<CarInfoVo>> entry : carMap.entrySet()) { | |
| 86 | + if (CollectionUtils.isNotEmpty(entry.getValue())) { | |
| 87 | + Optional<CarInfoVo> opt = entry.getValue().stream().filter(car -> Objects.equals(car.getCarEquipment(), "4") || Objects.equals(car.getCarEquipment(), "6") || Objects.equals(car.getCarEquipment(), "8")).findFirst(); | |
| 88 | + if (opt.isPresent()) { | |
| 89 | + carList.add(opt.get()); | |
| 90 | + } else { | |
| 91 | + carList.add(entry.getValue().get(0)); | |
| 92 | + } | |
| 93 | + | |
| 94 | + } | |
| 95 | + } | |
| 96 | + carList = carList.stream().sorted(Comparator.comparing(CarInfoVo::convertContainerVolumeDefaultMaxValue)).collect(Collectors.toList()); | |
| 97 | + | |
| 98 | + data.setRows(carList); | |
| 99 | + } | |
| 100 | + | |
| 101 | + return data; | |
| 102 | + } | |
| 103 | + | |
| 66 | 104 | /** |
| 67 | 105 | * 导出运输车辆管理列表 |
| 68 | 106 | */ |
| 69 | 107 | @PreAuthorize("@ss.hasPermi('unit:carInfo:export')") |
| 70 | 108 | @Log(title = "运输车辆管理", businessType = BusinessType.EXPORT) |
| 71 | 109 | @GetMapping("/export") |
| 72 | - public AjaxResult export(CarInfoVo carInfo) | |
| 73 | - { | |
| 110 | + public AjaxResult export(CarInfoVo carInfo) { | |
| 74 | 111 | List<CarInfoVo> list = carInfoService.selectCarInfoList(carInfo); |
| 75 | 112 | ExcelUtil<CarInfoVo> util = new ExcelUtil<CarInfoVo>(CarInfoVo.class); |
| 76 | 113 | return util.exportExcel(list, "carInfo"); |
| ... | ... | @@ -81,8 +118,7 @@ public class CarInfoController extends BaseController |
| 81 | 118 | */ |
| 82 | 119 | @PreAuthorize("@ss.hasPermi('unit:carInfo:query')") |
| 83 | 120 | @GetMapping(value = "/{id}") |
| 84 | - public AjaxResult getInfo(@PathVariable("id") Long id) | |
| 85 | - { | |
| 121 | + public AjaxResult getInfo(@PathVariable("id") Long id) { | |
| 86 | 122 | return AjaxResult.success(carInfoService.selectCarInfoById(id)); |
| 87 | 123 | } |
| 88 | 124 | |
| ... | ... | @@ -123,9 +159,8 @@ public class CarInfoController extends BaseController |
| 123 | 159 | */ |
| 124 | 160 | @PreAuthorize("@ss.hasPermi('unit:carInfo:remove')") |
| 125 | 161 | @Log(title = "运输车辆管理", businessType = BusinessType.DELETE) |
| 126 | - @DeleteMapping("/{ids}") | |
| 127 | - public AjaxResult remove(@PathVariable Long[] ids) | |
| 128 | - { | |
| 162 | + @DeleteMapping("/{ids}") | |
| 163 | + public AjaxResult remove(@PathVariable Long[] ids) { | |
| 129 | 164 | return toAjax(carInfoService.deleteCarInfoByIds(ids)); |
| 130 | 165 | } |
| 131 | 166 | } | ... | ... |
trash-unit/src/main/java/com/trash/carInfo/domain/vo/CarInfoVo.java
| 1 | 1 | package com.trash.carInfo.domain.vo; |
| 2 | 2 | |
| 3 | 3 | import com.trash.carInfo.domain.CarInfo; |
| 4 | +import com.trash.common.utils.StringUtils; | |
| 5 | + | |
| 6 | +import java.util.Objects; | |
| 4 | 7 | |
| 5 | 8 | public class CarInfoVo extends CarInfo { |
| 6 | 9 | private String companyName; |
| ... | ... | @@ -24,4 +27,12 @@ public class CarInfoVo extends CarInfo { |
| 24 | 27 | this.driversName = driversName; |
| 25 | 28 | } |
| 26 | 29 | |
| 30 | + public Integer convertContainerVolumeDefaultMaxValue(){ | |
| 31 | + try { | |
| 32 | + return StringUtils.isEmpty(org.apache.commons.lang3.StringUtils.trim(this.getContainerVolume())) ? Integer.MAX_VALUE : Integer.parseInt(this.getContainerVolume()); | |
| 33 | + }catch (Exception e){ | |
| 34 | + return Integer.MAX_VALUE; | |
| 35 | + } | |
| 36 | + } | |
| 37 | + | |
| 27 | 38 | } | ... | ... |
trash-unit/src/main/java/com/trash/carInfo/mapper/CarInfoMapper.java
| ... | ... | @@ -31,6 +31,8 @@ public interface CarInfoMapper |
| 31 | 31 | */ |
| 32 | 32 | List<CarInfoVo> selectCarInfoList(CarInfoVo carInfo); |
| 33 | 33 | |
| 34 | + List<CarInfoVo> selectCarInfoListFront(CarInfoVo carInfo); | |
| 35 | + | |
| 34 | 36 | List<CarInfoVo> selectByCompanyId(@Param("companyId") Long companyId); |
| 35 | 37 | |
| 36 | 38 | /** | ... | ... |
trash-unit/src/main/java/com/trash/carInfo/service/ICarInfoService.java
trash-unit/src/main/java/com/trash/carInfo/service/impl/CarInfoServiceImpl.java
| ... | ... | @@ -59,6 +59,12 @@ public class CarInfoServiceImpl implements ICarInfoService |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | @Override |
| 62 | + public List<CarInfoVo> selectCarInfoListFront(CarInfoVo carInfo) | |
| 63 | + { | |
| 64 | + return carInfoMapper.selectCarInfoListFront(carInfo); | |
| 65 | + } | |
| 66 | + | |
| 67 | + @Override | |
| 62 | 68 | public List<CarInfoVo> selectByCompanyId(Long companyId) { |
| 63 | 69 | return carInfoMapper.selectByCompanyId(companyId); |
| 64 | 70 | } | ... | ... |
trash-unit/src/main/resources/mapper/unit/CarInfoMapper.xml
| ... | ... | @@ -143,7 +143,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| 143 | 143 | <if test="drivers != null and drivers != ''"> and drivers = #{drivers}</if> |
| 144 | 144 | <if test="status != null "> and car.status = #{status}</if> |
| 145 | 145 | <if test="creditStatus != null and creditStatus != ''"> and car.credit_status = #{creditStatus}</if> |
| 146 | - <if test="isDel != null"> and car.is_del = #{isDel}</if> | |
| 146 | + <if test="isDel != null"> and car.is_del = #{isDel}</if> | |
| 147 | + </where> | |
| 148 | + </select> | |
| 149 | + | |
| 150 | + <select id="selectCarInfoListFront" parameterType="CarInfoVo" resultMap="CarInfoVoResult"> | |
| 151 | + <include refid="selectCarInfoForCompanyVo"/> | |
| 152 | + <where> | |
| 153 | + <if test="companyName != null and companyName != ''"> and c.name like concat('%',#{companyName},'%')</if> | |
| 154 | + <if test="carType != null and carType != ''"> and car_type = #{carType}</if> | |
| 155 | + <if test="carCode != null and carCode != ''"> and car_code like concat('%',#{carCode},'%')</if> | |
| 156 | + <if test="carBrank != null and carBrank != ''"> and car_brank like concat('%',#{carBrank},'%')</if> | |
| 157 | + <if test="emissionStandard != null and emissionStandard != ''"> and emission_standard = #{emissionStandard}</if> | |
| 158 | + <if test="roadTransportDate != null "> and road_transport_date = #{roadTransportDate}</if> | |
| 159 | + <if test="drivingLicenseDate != null "> and driving_license_date = #{drivingLicenseDate}</if> | |
| 160 | + <if test="enterDate != null "> and enter_date = #{enterDate}</if> | |
| 161 | + <if test="farmeNumber != null and farmeNumber != ''"> and farme_number = #{farmeNumber}</if> | |
| 162 | + <if test="carIdentification != null and carIdentification != ''"> and car_identification = #{carIdentification}</if> | |
| 163 | + <if test="containerVolume != null and containerVolume != ''"> and container_volume = #{containerVolume}</if> | |
| 164 | + <if test="carColor != null and carColor != ''"> and car_color = #{carColor}</if> | |
| 165 | + <if test="carEquipment != null and carEquipment != ''"> and car_equipment = #{carEquipment}</if> | |
| 166 | + <if test="roadTransport != null and roadTransport != ''"> and road_transport = #{roadTransport}</if> | |
| 167 | + <if test="drivingLicense != null and drivingLicense != ''"> and driving_license = #{drivingLicense}</if> | |
| 168 | + <if test="carFront != null and carFront != ''"> and car_front = #{carFront}</if> | |
| 169 | + <if test="carLeft != null and carLeft != ''"> and car_left = #{carLeft}</if> | |
| 170 | + <if test="carBehind != null and carBehind != ''"> and car_behind = #{carBehind}</if> | |
| 171 | + <if test="carRight != null and carRight != ''"> and car_right = #{carRight}</if> | |
| 172 | + <if test="drivers != null and drivers != ''"> and drivers = #{drivers}</if> | |
| 173 | + <if test="status != null "> and car.status = #{status}</if> | |
| 174 | + <if test="creditStatus != null and creditStatus != ''"> and car.credit_status = #{creditStatus}</if> | |
| 175 | + <if test="isDel != null"> and car.is_del = #{isDel}</if> | |
| 176 | + <if test="companyId != null"> and car.company_id = #{companyId}</if> | |
| 147 | 177 | </where> |
| 148 | 178 | </select> |
| 149 | 179 | ... | ... |