diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/CarMainController.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/CarMainController.java index 613be64a..4010dcdb 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/CarMainController.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/CarMainController.java @@ -4,6 +4,7 @@ import cn.iocoder.yudao.module.custom.entity.CarMain; import cn.iocoder.yudao.module.custom.service.CarMainService; import cn.iocoder.yudao.module.custom.vo.CarMainReqVO; import cn.iocoder.yudao.module.custom.vo.CarMainRespVO; +import cn.iocoder.yudao.module.custom.vo.CustomerMainSaveReqVO; import com.baomidou.mybatisplus.core.metadata.IPage; import org.springframework.web.bind.annotation.*; @@ -121,7 +122,7 @@ public class CarMainController { */ @GetMapping("/export-excel") @Operation(summary = "导出车辆信息 Excel") - @PreAuthorize("@ss.hasPermission('base:car-main:export')") + @PreAuthorize("@ss.hasPermission('base:car-main:customer')") @ApiAccessLog(operateType = EXPORT) public void exportCarMainExcel(CarMainReqVO pageReqVO, HttpServletResponse response) throws IOException { pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); @@ -131,4 +132,18 @@ public class CarMainController { BeanUtils.toBean(list, CarMainRespVO.class)); } + /** + * 绑定用户 + * + * @param saveReqVO CustomerMainSaveReqVO + * @return cn.iocoder.yudao.framework.common.pojo.CommonResult + **/ + @PostMapping("/bindCustomerCar") + @Operation(summary = "绑定用户") + @PreAuthorize("@ss.hasPermission('base:car-main:bindCustomer')") + public CommonResult bindCustomerCar(@RequestBody CustomerMainSaveReqVO saveReqVO) { + carMainService.bindCustomAndCar(saveReqVO); + return success(true); + } + } \ No newline at end of file diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/mapper/CarMainMapper.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/mapper/CarMainMapper.java index ee4fdf9c..e69e856f 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/mapper/CarMainMapper.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/mapper/CarMainMapper.java @@ -29,14 +29,7 @@ public interface CarMainMapper extends BaseMapper { */ IPage findPage(Page page, @Param("dto") CarMainReqVO pageReqVO); - /** - * 通过客户id查询车辆信息 - * @author PQZ - * @date 15:19 2024/8/3 - * @param cusId 客户id - * @return java.util.List - **/ - List selectListByCusId( @Param("cusId") String cusId); + /** * 车牌号,车架号,发动机号码 查重 diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/mapper/CustomerCarMapper.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/mapper/CustomerCarMapper.java index 5cd2e5cb..852e89e3 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/mapper/CustomerCarMapper.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/mapper/CustomerCarMapper.java @@ -1,8 +1,13 @@ package cn.iocoder.yudao.module.custom.mapper; import cn.iocoder.yudao.module.custom.entity.CustomerCar; +import cn.iocoder.yudao.module.custom.vo.CarMainRespVO; +import cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 客户车辆管理关联Mapper @@ -12,5 +17,21 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface CustomerCarMapper extends BaseMapper { + /** + * 通过客户id查询车辆信息 + * @author PQZ + * @date 15:19 2024/8/3 + * @param cusId 客户id + * @return java.util.List + **/ + List selectCarListByCusId(@Param("cusId") String cusId); + + /** + * 通过车辆id查询客户信息 + * + * @param carId 车辆id + * @return java.util.List + **/ + List selectCusListByCarId(@Param("carId") String carId); } \ No newline at end of file diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CarMainService.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CarMainService.java index 1b48753e..8dbf9ec2 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CarMainService.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CarMainService.java @@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.module.custom.entity.CarMain; import cn.iocoder.yudao.module.custom.vo.CarMainReqVO; import cn.iocoder.yudao.module.custom.vo.CarMainRespVO; +import cn.iocoder.yudao.module.custom.vo.CustomerMainSaveReqVO; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; @@ -58,4 +59,11 @@ public interface CarMainService extends IService { IPage getCarMainPage(CarMainReqVO pageReqVO); + /** + * 绑定车辆信息 + * + * @param saveReqVO CustomerMainSaveReqVO实体 + * @return void + **/ + void bindCustomAndCar(CustomerMainSaveReqVO saveReqVO); } \ No newline at end of file diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CarMainServiceImpl.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CarMainServiceImpl.java index 2d218ada..2e801f00 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CarMainServiceImpl.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CarMainServiceImpl.java @@ -1,21 +1,37 @@ package cn.iocoder.yudao.module.custom.service.impl; import cn.hutool.core.util.ObjectUtil; +import cn.hutool.json.JSONUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.module.custom.entity.CarMain; +import cn.iocoder.yudao.module.custom.entity.CustomerCar; +import cn.iocoder.yudao.module.custom.entity.CustomerItem; +import cn.iocoder.yudao.module.custom.entity.CustomerMain; import cn.iocoder.yudao.module.custom.mapper.CarMainMapper; +import cn.iocoder.yudao.module.custom.mapper.CustomerCarMapper; import cn.iocoder.yudao.module.custom.service.CarMainService; +import cn.iocoder.yudao.module.custom.service.CustomerCarService; import cn.iocoder.yudao.module.custom.vo.CarMainReqVO; import cn.iocoder.yudao.module.custom.vo.CarMainRespVO; +import cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO; +import cn.iocoder.yudao.module.custom.vo.CustomerMainSaveReqVO; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import javax.annotation.Resource; +import java.util.ArrayList; import java.util.List; +import static cn.iocoder.yudao.common.BaseConstants.CUS_SIGN_CAR; +import static cn.iocoder.yudao.common.BaseConstants.CUS_SIGN_CUSTOMER; + /** * 车辆信息 Service 实现类 * @@ -24,6 +40,12 @@ import java.util.List; @Service public class CarMainServiceImpl extends ServiceImpl implements CarMainService{ + @Autowired + private CustomerCarMapper customerCarMapper; + + @Autowired + private CustomerCarService customerCarService; + /** * 创建车辆信息 * @@ -97,9 +119,16 @@ public class CarMainServiceImpl extends ServiceImpl impl * @return */ @Override - public CarMain getCarMain(String id) { + public CarMainRespVO getCarMain(String id) { //数据单查 - return baseMapper.selectById(id); + CarMain carMain = baseMapper.selectById(id); + CarMainRespVO result = BeanUtils.toBean(carMain, CarMainRespVO.class); + + //联查客户信息 + List cusList = customerCarMapper.selectCusListByCarId(id); + result.setCusList(cusList); + + return result; } /** @@ -116,6 +145,29 @@ public class CarMainServiceImpl extends ServiceImpl impl return baseMapper.findPage(page,pageReqVO); } + /** + * 绑定客户信息 + * + * @param saveReqVO CustomerMainSaveReqVO实体 + * @return void + **/ + @Override + public void bindCustomAndCar(CustomerMainSaveReqVO saveReqVO) { + List customerCars = new ArrayList<>(); + List cusList = saveReqVO.getCusList(); + if (ObjectUtil.isNotEmpty(cusList)){ + //组装数据 + cusList.forEach(item -> { + CustomerCar customerCar = new CustomerCar(); + customerCar.setCarId(saveReqVO.getId()); + customerCar.setCusId(item.getId()); + customerCar.setIsOwner(item.getIsOwner()); + customerCars.add(customerCar); + }); + } + customerCarService.bindCustomerCar(saveReqVO.getId(),CUS_SIGN_CAR,customerCars); + } + /** * 车牌号,车架号,发动机号码 查重 * @param reqVO @@ -192,4 +244,5 @@ public class CarMainServiceImpl extends ServiceImpl impl } + } \ No newline at end of file diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerCarServiceImpl.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerCarServiceImpl.java index aa3cda8d..015b7c9b 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerCarServiceImpl.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerCarServiceImpl.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.custom.service.impl; +import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.module.custom.entity.CustomerCar; import cn.iocoder.yudao.module.custom.mapper.CustomerCarMapper; @@ -11,6 +12,7 @@ import org.springframework.validation.annotation.Validated; import java.util.List; +import static cn.iocoder.yudao.common.BaseConstants.CUS_SIGN_CAR; import static cn.iocoder.yudao.common.BaseConstants.CUS_SIGN_CUSTOMER; /** @@ -41,13 +43,15 @@ public class CustomerCarServiceImpl extends ServiceImpl { //防止主键重复 item.setId(null); diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerMainServiceImpl.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerMainServiceImpl.java index 87a137b5..c1b5d9bd 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerMainServiceImpl.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerMainServiceImpl.java @@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.custom.entity.CustomerCar; import cn.iocoder.yudao.module.custom.entity.CustomerItem; import cn.iocoder.yudao.module.custom.entity.CustomerMain; import cn.iocoder.yudao.module.custom.mapper.CarMainMapper; +import cn.iocoder.yudao.module.custom.mapper.CustomerCarMapper; import cn.iocoder.yudao.module.custom.mapper.CustomerMainMapper; import cn.iocoder.yudao.module.custom.service.CarMainService; import cn.iocoder.yudao.module.custom.service.CustomerCarService; @@ -52,6 +53,8 @@ public class CustomerMainServiceImpl extends ServiceImpl itemList = customerItemService.list(lambdaQueryWrapper); /*3、车辆信息*/ - List carList = carMainMapper.selectListByCusId(id); + List carList = customerCarMapper.selectCarListByCusId(id); CustomerMainRespVO result = JSONUtil.toBean(JSONUtil.parseObj(main).toJSONString(0), CustomerMainRespVO.class); result.setItemList(itemList); result.setCarList(carList); diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CarBrandReqVO.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CarBrandReqVO.java index 77f85f80..129f2082 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CarBrandReqVO.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CarBrandReqVO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.custom.vo; +import com.alibaba.excel.annotation.ExcelProperty; import lombok.*; import java.util.*; import io.swagger.v3.oas.annotations.media.Schema; @@ -16,6 +17,9 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @ToString(callSuper = true) public class CarBrandReqVO extends PageParam { + @Schema(description = "主键标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "8714") + private String id; + @Schema(description = "品牌名称", example = "李四") private String brandName; diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CarMainRespVO.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CarMainRespVO.java index a3f8fd0e..49e46ca5 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CarMainRespVO.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CarMainRespVO.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.custom.vo; import cn.iocoder.yudao.module.custom.entity.CarMain; +import cn.iocoder.yudao.module.custom.entity.CustomerMain; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import java.util.*; @@ -15,79 +16,20 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @ExcelIgnoreUnannotated public class CarMainRespVO extends CarMain { - @Schema(description = "主键标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "8714") - @ExcelProperty("主键标识") - private String id; - - @Schema(description = "发动机号码", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("发动机号码") - private String engineNumber; - - @Schema(description = "车架号", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("车架号") - private String vin; - - @Schema(description = "车牌号", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("车牌号") - private String licenseNumber; - - @Schema(description = "车辆型号") - @ExcelProperty("车辆型号") - private String carModel; - - @Schema(description = "保养日期") - @ExcelProperty("保养日期") - private LocalDateTime maintenanceDate; - - @Schema(description = "保养里程") - @ExcelProperty("保养里程") - private String maintenanceMileage; - - @Schema(description = "年检日期", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("年检日期") - private LocalDateTime inspectionDate; - - @Schema(description = "保险日期") - @ExcelProperty("保险日期") - private LocalDateTime insuranceDate; - - @Schema(description = "二级维护时间") - @ExcelProperty("二级维护时间") - private LocalDateTime checkDate; - - @Schema(description = "车辆品牌", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("车辆品牌") - private String carBrand; - - @Schema(description = "车辆性质:营运 非营运等", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("车辆性质") - private String carNature; - - @Schema(description = "车辆类别:私家车 货车 教练车 公务车 出租车") - @ExcelProperty("车辆类别") - private String carCategory; - - @Schema(description = "车辆注册日期", requiredMode = Schema.RequiredMode.REQUIRED) - @ExcelProperty("车辆注册日期") - private LocalDateTime carRegisterDate; - - @Schema(description = "行驶证图片") - @ExcelProperty("行驶证图片") - private String carLicenseImg; - - @Schema(description = "最近办理业务") - @ExcelProperty("最近办理业务") - private String recentlyHandledBusiness; - - @Schema(description = "最近办理业务的时间") - @ExcelProperty("最近办理业务的时间") - private LocalDateTime recentlyHandleBusinessTime; @Schema(description = "创建时间") @ExcelProperty("创建时间") private LocalDateTime createTime; /**是否车主(0否1是)*/ + @Schema(description = "是否车主(0否1是)") private String isOwner; + @Schema(description = "创建时间") + private List cusList; + + + + + } \ No newline at end of file diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CarModelReqVO.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CarModelReqVO.java index 52c64c77..1781f598 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CarModelReqVO.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CarModelReqVO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.custom.vo; +import com.alibaba.excel.annotation.ExcelProperty; import lombok.*; import java.util.*; import io.swagger.v3.oas.annotations.media.Schema; @@ -16,6 +17,9 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @ToString(callSuper = true) public class CarModelReqVO extends PageParam { + @Schema(description = "主键标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "8714") + private String id; + @Schema(description = "排序") private Integer sort; diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CustomerMainRespVO.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CustomerMainRespVO.java index ae99f744..90df7a00 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CustomerMainRespVO.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CustomerMainRespVO.java @@ -27,4 +27,7 @@ public class CustomerMainRespVO extends CustomerMain { /**标签信息*/ List labelList; + /**是否车主(0否1是)*/ + private String isOwner; + } \ No newline at end of file diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CustomerMainSaveReqVO.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CustomerMainSaveReqVO.java index 1989cd30..97efbd47 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CustomerMainSaveReqVO.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CustomerMainSaveReqVO.java @@ -16,6 +16,8 @@ public class CustomerMainSaveReqVO extends CustomerMain { private List itemList; /**客户绑定车辆信息*/ private List carList; + /**客户绑定车辆信息*/ + private List cusList; /**标签信息*/ List labelList; diff --git a/dl-module-base/src/main/resources/mapper/custom/CarMainMapper.xml b/dl-module-base/src/main/resources/mapper/custom/CarMainMapper.xml index 9f6a472f..f9fd3c5a 100644 --- a/dl-module-base/src/main/resources/mapper/custom/CarMainMapper.xml +++ b/dl-module-base/src/main/resources/mapper/custom/CarMainMapper.xml @@ -89,18 +89,5 @@ - + \ No newline at end of file diff --git a/dl-module-base/src/main/resources/mapper/custom/CustomerCarMapper.xml b/dl-module-base/src/main/resources/mapper/custom/CustomerCarMapper.xml index 9351a626..7ecdf257 100644 --- a/dl-module-base/src/main/resources/mapper/custom/CustomerCarMapper.xml +++ b/dl-module-base/src/main/resources/mapper/custom/CustomerCarMapper.xml @@ -2,4 +2,92 @@ + + tbcarm.id, + tbcarm.engine_number, + tbcarm.vin, + tbcarm.license_number, + tbcarm.car_model, + tbcarm.maintenance_date, + tbcarm.maintenance_mileage, + tbcarm.inspection_date, + tbcarm.insurance_date, + tbcarm.check_date, + tbcarm.next_maintenance_date, + tbcarm.next_maintenance_mileage, + tbcarm.next_inspection_date, + tbcarm.insurance_expiry_date, + tbcarm.next_check_date, + tbcarm.car_brand, + tbcarm.car_nature, + tbcarm.car_category, + tbcarm.car_register_date, + tbcarm.car_license_img, + tbcarm.recently_handled_business, + tbcarm.recently_handle_business_time, + tbcarm.deleted, + tbcarm.creator, + tbcarm.create_time, + tbcarm.updater, + tbcarm.update_time + + + + tbcusm.id, + tbcusm.user_id, + tbcusm.type_code, + tbcusm.dept_code, + tbcusm.cus_name, + tbcusm.phone_number, + tbcusm.birthday, + tbcusm.address, + tbcusm.sex, + tbcusm.id_card, + tbcusm.id_card_image, + tbcusm.data_from, + tbcusm.near_do_time, + tbcusm.near_do_content, + tbcusm.inviter, + tbcusm.inviter_type, + tbcusm.status, + tbcusm.tenant_id, + tbcusm.deleted, + tbcusm.creator, + tbcusm.create_time, + tbcusm.updater, + tbcusm.update_time + + + + + + \ No newline at end of file diff --git a/dl-module-base/src/main/resources/mapper/custom/CustomerMainMapper.xml b/dl-module-base/src/main/resources/mapper/custom/CustomerMainMapper.xml index e6064cb1..0d48b8a8 100644 --- a/dl-module-base/src/main/resources/mapper/custom/CustomerMainMapper.xml +++ b/dl-module-base/src/main/resources/mapper/custom/CustomerMainMapper.xml @@ -50,6 +50,12 @@ AND item.system_code = #{entity.systemCode} + + AND main.phoneNumber LIKE concat('%',#{entity.phoneNumber},'%') + + + AND main.idCard LIKE concat('%',#{entity.idCard},'%') + GROUP BY main.id ORDER BY main.create_time DESC