|
@@ -44,46 +44,46 @@ public class ProductServiceImpl implements IProductService {
|
|
|
/**
|
|
|
* 新增产品
|
|
|
*
|
|
|
- * @param productDTO 新增产品的前端传输DTO类对象
|
|
|
+ * @param productDTO 新增产品的前端传输DTO数据对象
|
|
|
* @param files 产品附件
|
|
|
*/
|
|
|
@Override
|
|
|
public void addProduct(ProductDTO productDTO, List<MultipartFile> files) {
|
|
|
- log.info("开始处理【新增产品】的业务,参数为产品信息:{}, 产品附件:{}", productDTO, files);
|
|
|
+ log.info("开始处理【新增产品】的业务,参数为:{}, {}", productDTO, files);
|
|
|
|
|
|
//DTO赋值给产品表实体类
|
|
|
Product product = new Product();
|
|
|
BeanUtils.copyProperties(productDTO, product);
|
|
|
- //获取登陆人信息
|
|
|
+ //获取当前登陆人信息
|
|
|
PersonnelVO personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
- //登陆人id和姓名赋值给产品表实体类
|
|
|
+ //给实体类赋值登陆人id和姓名
|
|
|
product.setCreatePersonId(personnelVO.getId())
|
|
|
.setCreatePersonName(personnelVO.getName());
|
|
|
|
|
|
- //检查当前报告是否已创建产品 (一个报告只能创建一个产品,根据报告id查询产品)
|
|
|
+ //1.检查当前报告产品是否已存在 (根据报告reportId统计数量)
|
|
|
Integer reportId = product.getReportId();
|
|
|
- log.info("检查当前报告是否已创建产品");
|
|
|
+ log.info("检查当前报告产品是否已存在");
|
|
|
int count = productMapper.countByReportId(reportId);
|
|
|
if (count > 0) {
|
|
|
- String message = "新增产品失败,当前报告产品已创建产品";
|
|
|
+ String message = "新增产品失败,当前报告产品已存在";
|
|
|
log.info("{}", message);
|
|
|
throw new XiaoShiException(message);
|
|
|
}
|
|
|
|
|
|
- //1.数据入产品表
|
|
|
+ //2.数据入产品表
|
|
|
log.info("数据入产品表");
|
|
|
int rows = productMapper.insert(product);
|
|
|
if (rows != 1) {
|
|
|
String message = "新增产品失败,服务器忙请稍后再试";
|
|
|
- log.info("{}", message);
|
|
|
+ log.info("数据入产品表失败,{}", message);
|
|
|
throw new XiaoShiException(message);
|
|
|
}
|
|
|
|
|
|
- //2.数据入报告系统文件表(并返回附件的id集合)
|
|
|
+ //3.数据入报告系统文件表(并返回附件的id集合)
|
|
|
if (files != null && files.size() != 0) {
|
|
|
log.info("数据入报告系统文件表");
|
|
|
List<Integer> fileIds = reportFileService.uploadFiles(files);
|
|
|
- //3.数据入产品文件关联表
|
|
|
+ //4.数据入产品文件关联表
|
|
|
Integer productId = product.getId();
|
|
|
//之前是直接调用产品文件关联的Service层业务:assoProductFileService.addAsso(productId, fileIds); 现在自己敲👇
|
|
|
ArrayList<AssoProductFile> assoProductFiles = new ArrayList<>();
|
|
@@ -98,7 +98,7 @@ public class ProductServiceImpl implements IProductService {
|
|
|
rows = assoProductFileMapper.insertBatch(assoProductFiles);
|
|
|
if (rows != fileIds.size()) {
|
|
|
String message = "新增产品失败,服务器忙请稍后再试";
|
|
|
- log.info("{}", message);
|
|
|
+ log.info("数据入产品文件关联表失败,{}", message);
|
|
|
throw new XiaoShiException(message);
|
|
|
}
|
|
|
}
|
|
@@ -110,12 +110,13 @@ public class ProductServiceImpl implements IProductService {
|
|
|
/**
|
|
|
* 修改产品
|
|
|
*
|
|
|
- * @param productIncludeFilesDTO 产品新数据
|
|
|
- * @param files 新附件
|
|
|
+ * @param productIncludeFilesDTO 修改产品的前端传输DTO数据对象
|
|
|
+ * @param files 产品附件
|
|
|
*/
|
|
|
@Override
|
|
|
public void updateProduct(ProductIncludeFilesDTO productIncludeFilesDTO, List<MultipartFile> files) {
|
|
|
log.info("开始处理【修改产品】的业务,参数为:{}, {}", productIncludeFilesDTO, files);
|
|
|
+
|
|
|
//产品关联附件的前端传输DTO类赋值给产品实体类
|
|
|
Product product = new Product();
|
|
|
BeanUtils.copyProperties(productIncludeFilesDTO, product);
|