From 2ddb01132c0d74dedd36feb058a8484dba60bb00 Mon Sep 17 00:00:00 2001 From: liwen Date: Wed, 31 Jan 2024 14:25:32 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E8=BD=A6=E8=BE=86=E6=9C=AA=E5=88=A0=E9=99=A4=E6=89=80=E6=9C=89?= =?UTF-8?q?=E5=85=B3=E8=81=94=E6=95=B0=E6=8D=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hnac/hzims/safeproduct/entity/CarEntity.java | 2 -- .../service/ICarAnnualInspectionService.java | 8 ++++++ .../safeproduct/service/ICarInsuranceService.java | 7 +++++ .../impl/CarAnnualInspectionServiceImpl.java | 17 ++++++++++++ .../service/impl/CarInsuranceServiceImpl.java | 19 ++++++++++++- .../safeproduct/service/impl/CarServiceImpl.java | 32 ++++++++++++++++------ 6 files changed, 74 insertions(+), 11 deletions(-) diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CarEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CarEntity.java index 706093a..5bc6403 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CarEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CarEntity.java @@ -64,12 +64,10 @@ public class CarEntity extends BaseEntity { @ApiModelProperty("下期年检时间") private Date nextAnnualInspectionTime; - @NotNull @Size(max = 50, message = "年检状态长度不能超过50") @ApiModelProperty("年检状态") private String annualInspectionStatus; - @NotNull @Size(max = 50, message = "保险状态长度不能超过50") @ApiModelProperty("保险状态") private String insuranceStatus; diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarAnnualInspectionService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarAnnualInspectionService.java index 0ed28d1..a1f7099 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarAnnualInspectionService.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarAnnualInspectionService.java @@ -37,4 +37,12 @@ public interface ICarAnnualInspectionService extends IService getCarAnnualInspectionPage(Map param, Query query); + + /** + * 删除关联年检记录 + * @param carId 车辆id + * @return true-成功,false-失败 + */ + boolean removeRelativeCarAnnualInspection(Long carId); + } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarInsuranceService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarInsuranceService.java index d2be60e..4c8405a 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarInsuranceService.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarInsuranceService.java @@ -38,4 +38,11 @@ public interface ICarInsuranceService extends IService { * @return 车保记录数据 */ IPage getCarInsurancePage(Map param, Query query); + + /** + * 删除关联车保记录 + * @param carId 车辆id + * @return true-成功,false-失败 + */ + boolean removeRelativeCarInsurance(Long carId); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarAnnualInspectionServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarAnnualInspectionServiceImpl.java index 10be8b6..8f1e765 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarAnnualInspectionServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarAnnualInspectionServiceImpl.java @@ -22,6 +22,7 @@ import org.springframework.transaction.annotation.Transactional; import java.util.Date; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * 年检记录服务实现类 @@ -93,6 +94,22 @@ public class CarAnnualInspectionServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(CarAnnualInspectionEntity::getCarId, carId); + List list = this.list(queryWrapper); + // 若无关联年检记录,返回true + if (CollectionUtils.isEmpty(list)) { + return true; + } + List ids = list.stream().map(CarAnnualInspectionEntity::getId).collect(Collectors.toList()); + return this.removeByIds(ids); + } + + /** * 查询是否存在同月编号 * @param currentMonth 当月 * @return 存在则返回上一编号,否则返回null diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarInsuranceServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarInsuranceServiceImpl.java index cd132ef..17ce3bc 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarInsuranceServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarInsuranceServiceImpl.java @@ -21,6 +21,7 @@ import org.springframework.stereotype.Service; import java.util.Date; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * 车保记录服务实现类 @@ -55,7 +56,7 @@ public class CarInsuranceServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(CarInsuranceEntity::getCarId, carId); + List list = this.list(queryWrapper); + // 若无关联用车记录,返回true + if (CollectionUtils.isEmpty(list)) { + return true; + } + List ids = list.stream().map(CarInsuranceEntity::getId).collect(Collectors.toList()); + return this.removeByIds(ids); + } + + /** * 查询是否存在同月编号 * @param currentMonth 当月 * @return 存在则返回上一编号,否则返回null diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarServiceImpl.java index df4619c..88a67ed 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarServiceImpl.java @@ -12,12 +12,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.safeproduct.dto.CarMilesYearDTO; import com.hnac.hzims.safeproduct.entity.CarEntity; -import com.hnac.hzims.safeproduct.enums.CarMaintenanceStatusEnum; import com.hnac.hzims.safeproduct.mapper.CarMapper; -import com.hnac.hzims.safeproduct.service.ICarCheckRecordService; -import com.hnac.hzims.safeproduct.service.ICarMaintenanceService; -import com.hnac.hzims.safeproduct.service.ICarService; -import com.hnac.hzims.safeproduct.service.ICarUsedRecordService; +import com.hnac.hzims.safeproduct.service.*; import com.hnac.hzims.safeproduct.vo.CarMilesYearVO; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.support.Query; @@ -55,6 +51,12 @@ public class CarServiceImpl extends ServiceImpl implements @Autowired ICarCheckRecordService carCheckRecordService; + @Autowired + ICarInsuranceService carInsuranceService; + + @Autowired + ICarAnnualInspectionService carAnnualInspectionService; + /** * 年度里程数页面 */ @@ -195,15 +197,29 @@ public class CarServiceImpl extends ServiceImpl implements // 删除关联维保记录 boolean removeCarMaintenance = carMaintenanceService.removeRelativeCarMaintenance(id); if (!removeCarMaintenance) { - return false; + throw new ServiceException("关联维保记录删除失败"); } // 删除关联用车记录 boolean removeCarUsedRecord = carUsedRecordService.removeRelativeCarUsedRecord(id); if (!removeCarUsedRecord) { - return false; + throw new ServiceException("关联用车记录删除失败"); } // 删除关联车检记录 - return carCheckRecordService.removeRelativeCarCheckRecord(id); + boolean removeCarCheckRecord = carCheckRecordService.removeRelativeCarCheckRecord(id); + if (!removeCarCheckRecord) { + throw new ServiceException("关联车检记录删除失败"); + } + // 删除关联年检记录 + boolean removeCarAnnualInspection = carAnnualInspectionService.removeRelativeCarAnnualInspection(id); + if (!removeCarAnnualInspection) { + throw new ServiceException("关联年检记录删除失败"); + } + // 删除关联车保记录 + boolean removeCarInsurance = carInsuranceService.removeRelativeCarInsurance(id); + if (!removeCarInsurance) { + throw new ServiceException("关联车保记录删除失败"); + } + return true; } return false; } From c1d13643c8d65cfea114114dd388780222e6c1f9 Mon Sep 17 00:00:00 2001 From: liwen Date: Wed, 31 Jan 2024 14:43:01 +0800 Subject: [PATCH 2/3] =?UTF-8?q?update:=20=E5=A2=9E=E5=8A=A0=E7=89=B9?= =?UTF-8?q?=E7=A7=8D=E8=AE=BE=E5=A4=87=E6=A3=80=E9=AA=8C=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E7=9A=84=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hnac/hzims/safeproduct/entity/SpecialDeviceInspectionEntity.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/SpecialDeviceInspectionEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/SpecialDeviceInspectionEntity.java index 697de96..b4ad10a 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/SpecialDeviceInspectionEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/SpecialDeviceInspectionEntity.java @@ -33,11 +33,9 @@ public class SpecialDeviceInspectionEntity extends BaseEntity { @ApiModelProperty("检验照片") private String imgPath; - @TableField(exist = false) @ApiModelProperty("下次检验时间") private Date nextInspectionTime; - @TableField(exist = false) @ApiModelProperty("上次检验时间") private Date lastInspectionTime; } From f18ae6356140af40315ad66818f622bd18b516a9 Mon Sep 17 00:00:00 2001 From: liwen Date: Wed, 31 Jan 2024 15:44:22 +0800 Subject: [PATCH 3/3] =?UTF-8?q?docs:=20=E6=9B=B4=E6=96=B0sql=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../safeproduct/src/main/resources/db/1.0.2.sql | 44 +++++++++++++++------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/hzims-service/safeproduct/src/main/resources/db/1.0.2.sql b/hzims-service/safeproduct/src/main/resources/db/1.0.2.sql index 29c9f3e..8d9b1b0 100644 --- a/hzims-service/safeproduct/src/main/resources/db/1.0.2.sql +++ b/hzims-service/safeproduct/src/main/resources/db/1.0.2.sql @@ -98,6 +98,7 @@ CREATE TABLE `hzims_test` ( `subject` varchar(50) NOT NULL COMMENT '考试科目', `proctor` varchar(20) NOT NULL COMMENT '监考人', `people_name` varchar(1000) DEFAULT '' COMMENT '参考人员', + `test_method` varchar(50) NOT NULL COMMENT '考试方式', `img_path` varchar(1000) NOT NULL DEFAULT '' COMMENT '考试图片', `file_path` varchar(1000) NOT NULL DEFAULT '' COMMENT '考试附件', `create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人', @@ -208,6 +209,7 @@ CREATE TABLE `hzims_hygiene_record` ( `code` varchar(50) NOT NULL COMMENT '编号', `actual_start_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '实际开始时间', `actual_end_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '实际结束时间', + `check_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '检查时间', `check_user` varchar(20) NOT NULL DEFAULT '' COMMENT '检查人', `hygiene_zone_ids` varchar(1000) NOT NULL COMMENT '卫生自查区域id', `check_result` mediumtext NOT NULL COMMENT '检查结果', @@ -231,16 +233,16 @@ CREATE TABLE `hzims_car` ( `car_type` varchar(50) NOT NULL COMMENT '型号', `plate_number` varchar(50) NOT NULL COMMENT '车牌号', `registration_time` date NOT NULL COMMENT '上牌时间', - `insurance_pay_last_time` date NOT NULL COMMENT '上期缴车保时间', - `insurance_pay_next_time` date NOT NULL COMMENT '下期缴车保时间', - `insurance_status` varchar(50) NOT NULL COMMENT '保险状态', - `last_annual_inspection_time` date NOT NULL COMMENT '上期年检时间', - `next_annual_inspection_time` date NOT NULL COMMENT '下期年检时间', - `annual_inspection_status` varchar(50) NOT NULL COMMENT '年检状态', + `insurance_pay_last_time` date DEFAULT NULL COMMENT '上期缴车保时间', + `insurance_pay_next_time` date DEFAULT NULL COMMENT '下期缴车保时间', + `insurance_status` varchar(50) NOT NULL DEFAULT 'UNINSURED' COMMENT '保险状态', + `last_annual_inspection_time` date DEFAULT NULL COMMENT '上期年检时间', + `next_annual_inspection_time` date DEFAULT NULL COMMENT '下期年检时间', + `annual_inspection_status` varchar(50) NOT NULL DEFAULT 'UNFINISHED' COMMENT '年检状态', `maintenance_last_time` date DEFAULT NULL COMMENT '上期保养时间', `maintenance_next_time` date DEFAULT NULL COMMENT '下期保养时间', `maintenance_mileage` decimal(10, 2) DEFAULT NULL COMMENT '保养里程', - `maintenance_status` varchar(50) DEFAULT NULL COMMENT '保养状态', + `maintenance_status` varchar(50) NOT NULL DEFAULT 'UNMAINTAINED' COMMENT '保养状态', `manager_id` bigint(20) DEFAULT NULL COMMENT '车辆管理人id', `manager` varchar(50) NOT NULL COMMENT '车辆管理人', `img_path` varchar(1000) NOT NULL DEFAULT '' COMMENT '车辆图片', @@ -288,7 +290,7 @@ CREATE TABLE `hzims_car_used_record` ( `unit` varchar(50) NOT NULL COMMENT '用车单位', `used_location` varchar(255) NOT NULL COMMENT '使用地点', `user` varchar(20) NOT NULL COMMENT '使用人', - `remark` mediumtext DEFAULT NULL COMMENT '使用详情', + `remark` mediumtext COMMENT '使用详情', `start_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '使用时间', `end_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '收车时间', `start_miles` decimal(10, 2) NOT NULL COMMENT '出车公里数', @@ -346,9 +348,8 @@ CREATE TABLE `hzims_car_annual_inspection` ( `car_id` bigint(20) NOT NULL COMMENT '车辆id', `code` varchar(50) NOT NULL COMMENT '编号', `annual_inspection_time` date NOT NULL COMMENT '年检时间', + `next_annual_inspection_time` date NOT NULL COMMENT '下次年检时间', `location` varchar(255) NOT NULL DEFAULT '' COMMENT '年检地点', - `cost` bigint(20) NOT NULL COMMENT '年检费用', - `inspection_manager` varchar(50) NOT NULL DEFAULT '' COMMENT '年检负责人', `img_path` varchar(1000) NOT NULL DEFAULT '' COMMENT '年检图片', `create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人', `create_dept` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建部门', @@ -365,9 +366,8 @@ CREATE TABLE `hzims_car_insurance` ( `car_id` bigint(20) NOT NULL COMMENT '车辆id', `code` varchar(50) NOT NULL COMMENT '编号', `insurance_time` date NOT NULL COMMENT '车保时间', + `next_insurance_time` date NOT NULL COMMENT '下次车保时间', `location` varchar(255) NOT NULL DEFAULT '' COMMENT '车保地点', - `cost` bigint(20) NOT NULL COMMENT '车保费用', - `insurance_manager` varchar(50) NOT NULL DEFAULT '' COMMENT '车保负责人', `img_path` varchar(1000) NOT NULL DEFAULT '' COMMENT '车保图片', `create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人', `create_dept` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建部门', @@ -394,7 +394,25 @@ CREATE TABLE `hzims_device` ( `inspection_last_time` date DEFAULT NULL COMMENT '上次检验日期', `manager_id` bigint(20) DEFAULT NULL COMMENT '设备管理人id', `manager` varchar(50) NOT NULL DEFAULT '' COMMENT '设备管理人', - `device_status` varchar(20) NOT NULL DEFAULT 'NORMAL' COMMENT '设备状态', + `device_status` varchar(20) NOT NULL DEFAULT 'EXPIRED' COMMENT '设备状态', + `create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人', + `create_dept` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建部门', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_user` bigint(20) DEFAULT '-1' COMMENT '更新人', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间', + `status` int(2) NOT NULL DEFAULT '1' COMMENT '状态', + `is_deleted` int(2) NOT NULL DEFAULT '0' COMMENT '逻辑删除状态:0-未删除,1-删除', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=INNODB CHARACTER SET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='特种设备表' ROW_FORMAT=Dynamic; + +CREATE TABLE `hzims_device_inspection` ( + `id` bigint(20) NOT NULL COMMENT '主键id', + `device_id` bigint(20) NOT NULL COMMENT '设备id', + `inspection_time` date NOT NULL COMMENT '设备检验时间', + `last_inspection_time` date NOT NULL COMMENT '上次检验时间', + `next_inspection_time` date NOT NULL COMMENT '下次检验时间', + `location` varchar(255) NOT NULL DEFAULT '' COMMENT '设备检验地点', + `img_path` varchar(1000) NOT NULL DEFAULT '' COMMENT '设备检验图片', `create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人', `create_dept` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建部门', `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',