Browse Source

add: 车检记录模板

zhongwei
liwen 8 months ago
parent
commit
52ffb6052a
  1. 14
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CarCheckTemplateEntity.java
  2. 10
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/CarController.java
  3. 10
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarCheckTemplateMapper.java
  4. 5
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarCheckTemplateMapper.xml
  5. 14
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICarCheckTemplateService.java
  6. 64
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckRecordServiceImpl.java
  7. 21
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckTemplateServiceImpl.java

14
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 {
}

10
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)

10
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<CarCheckTemplateEntity> {
}

5
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarCheckTemplateMapper.xml

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnac.hzims.safeproduct.mapper.CarCheckTemplateMapper">
</mapper>

14
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<CarCheckTemplateEntity> {
boolean saveCarCheckTemplate();
}

64
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<CarCheckRecordMapper,
carCheckRecordEntity.setCode(code);
// 若新增车检记录成功,新增相关检查项数据
boolean saveRecord = this.save(carCheckRecordEntity);
if (saveRecord) {
CarCheckRecordEntity recordEntity = getCarCheckRecordByCode(code);
List<CarCheckItemEntity> 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<CarCheckItemEntity> itemList = carCheckRecordDTO.getItemList();
itemList.forEach(x -> x.setCarCheckRecordId(recordEntity.getId()));
return carCheckItemService.saveBatch(itemList);
}
/**
@ -104,7 +105,19 @@ public class CarCheckRecordServiceImpl extends ServiceImpl<CarCheckRecordMapper,
}
// 拼装检查列表
List<CarCheckItemEntity> itemList = carCheckItemService.getListByCarCheckRecordId(id);
carCheckRecordDetailVO.setCheckItemList(itemList);
List<CarCheckItemEntity> 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<CarCheckRecordMapper,
@Transactional(rollbackFor = Exception.class)
@Override
public boolean updateCarCheckRecord(CarCheckRecordDTO carCheckRecordDTO) {
boolean deleteFlag = carCheckItemService.removeRelativeCarCheckItem(carCheckRecordDTO.getId());
if (!deleteFlag){
return false;
// 修改车检记录
CarCheckRecordEntity carCheckRecordEntity = new CarCheckRecordEntity();
BeanUtil.copyProperties(carCheckRecordDTO, carCheckRecordEntity);
boolean updateRecord = this.updateById(carCheckRecordEntity);
if (!updateRecord) {
throw new ServiceException("车检记录更新失败");
}
// 更新检查项
List<CarCheckItemEntity> 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<CarCheckItemEntity> 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<CarCheckRecordMapper,
@Override
public boolean removeCarCheckRecord(Long id) {
boolean remove = this.removeById(id);
if (remove) {
return carCheckItemService.removeRelativeCarCheckItem(id);
if (!remove) {
throw new ServiceException("车检记录删除失败");
}
return false;
return carCheckItemService.removeRelativeCarCheckItem(id);
}
/**

21
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CarCheckTemplateServiceImpl.java

@ -0,0 +1,21 @@
package com.hnac.hzims.safeproduct.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.safeproduct.entity.CarCheckTemplateEntity;
import com.hnac.hzims.safeproduct.mapper.CarCheckTemplateMapper;
import com.hnac.hzims.safeproduct.service.ICarCheckTemplateService;
import org.springframework.stereotype.Service;
/**
* 车检模板服务实现类
*
* @date 2024-05-28
*/
@Service
public class CarCheckTemplateServiceImpl extends ServiceImpl<CarCheckTemplateMapper, CarCheckTemplateEntity> implements ICarCheckTemplateService {
@Override
public boolean saveCarCheckTemplate() {
return false;
}
}
Loading…
Cancel
Save