diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CarCheckTemplateEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CarCheckTemplateEntity.java new file mode 100644 index 0000000..95eaf33 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CarCheckTemplateEntity.java @@ -0,0 +1,14 @@ +package com.hnac.hzims.safeproduct.entity; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.mp.base.BaseEntity; + +/** + * @date 2024-05-28 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class CarCheckTemplateEntity extends BaseEntity { + +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/CarController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/CarController.java index 2f1c8c8..781b214 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/CarController.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/CarController.java @@ -54,6 +54,8 @@ public class CarController extends BladeController { private final ICarInsuranceService carInsuranceService; + private final ICarCheckTemplateService carCheckTemplateService; + @PostMapping("/saveCar") @ApiOperation(value = "新增车辆") @ApiOperationSupport(order = 1) @@ -272,17 +274,17 @@ public class CarController extends BladeController { // @ApiOperation(value = "新增车检记录模板") // @ApiOperationSupport(order = 39) // public R saveCarCheckRecordTemplate() { -// +// return R.status(carCheckTemplateService.saveCarCheckTemplate()); // } -// + // @ApiOperationSupport(order = 40) // public R updateCarCheckRecordTemplate() { -// +// return R.status(carCheckTemplateService.updateCarCheckTemplate()); // } // // @ApiOperationSupport(order = 41) // public R removeCarCheckRecordTemplate() { -// +// return R.status(carCheckTemplateService.removeCarCheckTemplate()); // } // // @ApiOperationSupport(order = 42) diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarCheckTemplateMapper.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarCheckTemplateMapper.java new file mode 100644 index 0000000..d813c0c --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarCheckTemplateMapper.java @@ -0,0 +1,10 @@ +package com.hnac.hzims.safeproduct.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.safeproduct.entity.CarCheckTemplateEntity; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface CarCheckTemplateMapper extends BaseMapper { + +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarCheckTemplateMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarCheckTemplateMapper.xml new file mode 100644 index 0000000..7b5b718 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarCheckTemplateMapper.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarCheckTemplateService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarCheckTemplateService.java new file mode 100644 index 0000000..7fcc1da --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarCheckTemplateService.java @@ -0,0 +1,14 @@ +package com.hnac.hzims.safeproduct.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.hzims.safeproduct.entity.CarCheckTemplateEntity; + +/** + * 车检模板服务类 + * + * @date 2024-05-28 + */ +public interface ICarCheckTemplateService extends IService { + + boolean saveCarCheckTemplate(); +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckRecordServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckRecordServiceImpl.java index 864dd53..a9b131d 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckRecordServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckRecordServiceImpl.java @@ -18,6 +18,7 @@ import com.hnac.hzims.safeproduct.service.ICarCheckRecordService; import com.hnac.hzims.safeproduct.utils.BaseUtil; import com.hnac.hzims.safeproduct.vo.CarCheckRecordDetailVO; import com.hnac.hzims.safeproduct.vo.CarCheckRecordPageVO; +import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.utils.BeanUtil; import org.springframework.beans.factory.annotation.Autowired; @@ -70,13 +71,13 @@ public class CarCheckRecordServiceImpl extends ServiceImpl itemList = carCheckRecordDTO.getItemList(); - itemList.forEach(x -> x.setCarCheckRecordId(recordEntity.getId())); - return carCheckItemService.saveBatch(itemList); + if (!saveRecord) { + throw new ServiceException("车检记录新增失败"); } - return false; + CarCheckRecordEntity recordEntity = getCarCheckRecordByCode(code); + List itemList = carCheckRecordDTO.getItemList(); + itemList.forEach(x -> x.setCarCheckRecordId(recordEntity.getId())); + return carCheckItemService.saveBatch(itemList); } /** @@ -104,7 +105,19 @@ public class CarCheckRecordServiceImpl extends ServiceImpl itemList = carCheckItemService.getListByCarCheckRecordId(id); - carCheckRecordDetailVO.setCheckItemList(itemList); + List checkItemList = new ArrayList<>(); + itemList.forEach(item -> { + String[] contents = item.getCheckContent().split(",|,"); + String[] results = item.getCheckResult().split(",|,"); + for (int i = 0; i < contents.length; i++) { + CarCheckItemEntity carCheckItemEntity = new CarCheckItemEntity(); + carCheckItemEntity.setCheckItem(item.getCheckItem()); + carCheckItemEntity.setCheckContent(contents[i]); + carCheckItemEntity.setCheckResult(results[i]); + checkItemList.add(carCheckItemEntity); + } + }); + carCheckRecordDetailVO.setCheckItemList(checkItemList); return carCheckRecordDetailVO; } return null; @@ -157,22 +170,25 @@ public class CarCheckRecordServiceImpl extends ServiceImpl itemList = carCheckRecordDTO.getItemList(); - itemList.forEach(x -> {x.setCarCheckRecordId(carCheckRecordDTO.getId()); - x.setId(null);}); - boolean b = carCheckItemService.saveBatch(itemList); - if (b) { - // 若更新检查项成功,则更新车检记录 - CarCheckRecordEntity carCheckRecordEntity = new CarCheckRecordEntity(); - BeanUtil.copyProperties(carCheckRecordDTO, carCheckRecordEntity); - return this.updateById(carCheckRecordEntity); + // 删除旧的检查项 + boolean deleteItem = carCheckItemService.removeRelativeCarCheckItem(carCheckRecordDTO.getId()); + if (!deleteItem) { + throw new ServiceException("旧的车检记录检查项删除失败"); } - return false; + // 新增新的检查项 + List itemList = carCheckRecordDTO.getItemList(); + itemList.forEach(x -> { + x.setCarCheckRecordId(carCheckRecordDTO.getId()); +// x.setId(null); + }); + return carCheckItemService.saveBatch(itemList); } /** @@ -182,10 +198,10 @@ public class CarCheckRecordServiceImpl extends ServiceImpl implements ICarCheckTemplateService { + + @Override + public boolean saveCarCheckTemplate() { + return false; + } +}