|
|
@ -18,6 +18,7 @@ import com.hnac.hzims.safeproduct.service.ICarCheckRecordService; |
|
|
|
import com.hnac.hzims.safeproduct.utils.BaseUtil; |
|
|
|
import com.hnac.hzims.safeproduct.utils.BaseUtil; |
|
|
|
import com.hnac.hzims.safeproduct.vo.CarCheckRecordDetailVO; |
|
|
|
import com.hnac.hzims.safeproduct.vo.CarCheckRecordDetailVO; |
|
|
|
import com.hnac.hzims.safeproduct.vo.CarCheckRecordPageVO; |
|
|
|
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.mp.support.Query; |
|
|
|
import org.springblade.core.tool.utils.BeanUtil; |
|
|
|
import org.springblade.core.tool.utils.BeanUtil; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
@ -70,14 +71,14 @@ public class CarCheckRecordServiceImpl extends ServiceImpl<CarCheckRecordMapper, |
|
|
|
carCheckRecordEntity.setCode(code); |
|
|
|
carCheckRecordEntity.setCode(code); |
|
|
|
// 若新增车检记录成功,新增相关检查项数据
|
|
|
|
// 若新增车检记录成功,新增相关检查项数据
|
|
|
|
boolean saveRecord = this.save(carCheckRecordEntity); |
|
|
|
boolean saveRecord = this.save(carCheckRecordEntity); |
|
|
|
if (saveRecord) { |
|
|
|
if (!saveRecord) { |
|
|
|
|
|
|
|
throw new ServiceException("车检记录新增失败"); |
|
|
|
|
|
|
|
} |
|
|
|
CarCheckRecordEntity recordEntity = getCarCheckRecordByCode(code); |
|
|
|
CarCheckRecordEntity recordEntity = getCarCheckRecordByCode(code); |
|
|
|
List<CarCheckItemEntity> itemList = carCheckRecordDTO.getItemList(); |
|
|
|
List<CarCheckItemEntity> itemList = carCheckRecordDTO.getItemList(); |
|
|
|
itemList.forEach(x -> x.setCarCheckRecordId(recordEntity.getId())); |
|
|
|
itemList.forEach(x -> x.setCarCheckRecordId(recordEntity.getId())); |
|
|
|
return carCheckItemService.saveBatch(itemList); |
|
|
|
return carCheckItemService.saveBatch(itemList); |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 车检记录详情 |
|
|
|
* 车检记录详情 |
|
|
@ -104,7 +105,19 @@ public class CarCheckRecordServiceImpl extends ServiceImpl<CarCheckRecordMapper, |
|
|
|
} |
|
|
|
} |
|
|
|
// 拼装检查列表
|
|
|
|
// 拼装检查列表
|
|
|
|
List<CarCheckItemEntity> itemList = carCheckItemService.getListByCarCheckRecordId(id); |
|
|
|
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 carCheckRecordDetailVO; |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
return null; |
|
|
@ -157,22 +170,25 @@ public class CarCheckRecordServiceImpl extends ServiceImpl<CarCheckRecordMapper, |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean updateCarCheckRecord(CarCheckRecordDTO carCheckRecordDTO) { |
|
|
|
public boolean updateCarCheckRecord(CarCheckRecordDTO carCheckRecordDTO) { |
|
|
|
boolean deleteFlag = carCheckItemService.removeRelativeCarCheckItem(carCheckRecordDTO.getId()); |
|
|
|
// 修改车检记录
|
|
|
|
if (!deleteFlag){ |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 更新检查项
|
|
|
|
|
|
|
|
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(); |
|
|
|
CarCheckRecordEntity carCheckRecordEntity = new CarCheckRecordEntity(); |
|
|
|
BeanUtil.copyProperties(carCheckRecordDTO, carCheckRecordEntity); |
|
|
|
BeanUtil.copyProperties(carCheckRecordDTO, carCheckRecordEntity); |
|
|
|
return this.updateById(carCheckRecordEntity); |
|
|
|
boolean updateRecord = this.updateById(carCheckRecordEntity); |
|
|
|
|
|
|
|
if (!updateRecord) { |
|
|
|
|
|
|
|
throw new ServiceException("车检记录更新失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
// 删除旧的检查项
|
|
|
|
|
|
|
|
boolean deleteItem = carCheckItemService.removeRelativeCarCheckItem(carCheckRecordDTO.getId()); |
|
|
|
|
|
|
|
if (!deleteItem) { |
|
|
|
|
|
|
|
throw new ServiceException("旧的车检记录检查项删除失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 新增新的检查项
|
|
|
|
|
|
|
|
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 |
|
|
|
@Override |
|
|
|
public boolean removeCarCheckRecord(Long id) { |
|
|
|
public boolean removeCarCheckRecord(Long id) { |
|
|
|
boolean remove = this.removeById(id); |
|
|
|
boolean remove = this.removeById(id); |
|
|
|
if (remove) { |
|
|
|
if (!remove) { |
|
|
|
return carCheckItemService.removeRelativeCarCheckItem(id); |
|
|
|
throw new ServiceException("车检记录删除失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
return carCheckItemService.removeRelativeCarCheckItem(id); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|