Jelajahi Sumber

Merge branch 'master' of http://39.108.216.210:3000/zhuwei/bladex

huangtf 4 bulan lalu
induk
melakukan
59690baf31

+ 50 - 0
blade-service-api/blade-meter-api/src/main/java/org/springblade/meter/dto/MaterialMeterBatchImportDTO.java

@@ -0,0 +1,50 @@
+package org.springblade.meter.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springblade.meter.entity.AttachmentForm;
+
+import javax.validation.constraints.NotNull;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * @Param   材料计量单附件批量导入
+ * @Author wangwl
+ * @Date 2024/7/26 10:49
+ **/
+@Data
+public class MaterialMeterBatchImportDTO {
+
+    @ApiModelProperty(value = "材料集合")
+    @NotNull(message = "没有文件数据!")
+    private List<NewBladeFile> files;
+
+    @ApiModelProperty(value = "项目id")
+    @NotNull(message = "请传入项目id!")
+    private Long projectId;
+
+    @ApiModelProperty(value = "合同段id")
+    @NotNull(message = "请传入合同段id!")
+    private Long contractId;
+
+    @ApiModelProperty(value = "材料计量单id集合")
+    @NotNull(message = "没有计量单id数据!")
+    private String materialMeterFormIds;
+
+    @Data
+    public static class NewBladeFile{
+        private String link;
+        private String pdfUrl;
+        private String originalName;
+        @ApiModelProperty(value = "附件大小带符号")
+        private String fileSizeName;
+
+        @ApiModelProperty(value = "附件后缀")
+        private String fileSuffix;
+
+        @ApiModelProperty(value = "附件上传时间")
+        private LocalDateTime fileDate;
+    }
+}

+ 12 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/controller/MaterialMeterFormController.java

@@ -25,6 +25,7 @@ import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
+import org.springblade.meter.dto.MaterialMeterBatchImportDTO;
 import org.springblade.meter.dto.MaterialMeterFormDTO;
 import org.springblade.meter.vo.MaterialMeterFormVO;
 import org.springframework.jdbc.core.JdbcTemplate;
@@ -134,6 +135,17 @@ public class MaterialMeterFormController extends BladeController {
 		return materialMeterFormService.importExcel(file,projectId,contractId,meterPeriodId);
 	}
 
+	/**
+	 * 附件批量导入 材料计量单
+	 */
+	@PostMapping("/batchImportFile")
+	@ApiOperationSupport(order = 8)
+	@ApiOperation(value = "附件批量导入", notes = "传入文件集合,计量单id集合")
+	public R batchImportFile(@Valid @RequestBody MaterialMeterBatchImportDTO dto) {
+		materialMeterFormService.batchImportFile(dto);
+		return R.success("批量导入成功");
+	}
+
 
 
 }

+ 3 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/service/IMaterialMeterFormService.java

@@ -19,6 +19,7 @@ package org.springblade.meter.service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.api.R;
+import org.springblade.meter.dto.MaterialMeterBatchImportDTO;
 import org.springblade.meter.dto.MaterialMeterFormDTO;
 import org.springblade.meter.entity.MaterialMeterForm;
 import org.springblade.core.mp.base.BaseService;
@@ -47,4 +48,6 @@ public interface IMaterialMeterFormService extends BaseService<MaterialMeterForm
     void delete(List<Long> ids);
 
     R<String> importExcel(MultipartFile file, Long projectId, Long contractId,Long meterPeriodId);
+
+    void batchImportFile(MaterialMeterBatchImportDTO dto);
 }

+ 28 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/MaterialMeterFormServiceImpl.java

@@ -27,7 +27,9 @@ import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.BeanUtil;
+import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.ObjectUtil;
+import org.springblade.meter.dto.MaterialMeterBatchImportDTO;
 import org.springblade.meter.dto.MaterialMeterFormDTO;
 import org.springblade.meter.entity.*;
 import org.springblade.meter.excel.MaterialMeterFormExcel;
@@ -42,6 +44,8 @@ import org.springframework.web.multipart.MultipartFile;
 
 import java.math.BigDecimal;
 import java.math.RoundingMode;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -256,4 +260,28 @@ public class MaterialMeterFormServiceImpl extends BaseServiceImpl<MaterialMeterF
         }
 
     }
+
+    @Override
+    public void batchImportFile(MaterialMeterBatchImportDTO dto) {
+        String materialMeterFormIds = dto.getMaterialMeterFormIds();
+        List<Long> ids = Func.toLongList(materialMeterFormIds);
+        List<MaterialMeterBatchImportDTO.NewBladeFile> files = dto.getFiles();
+        List<AttachmentForm> fileList = new ArrayList<>();
+        for (MaterialMeterBatchImportDTO.NewBladeFile file : files) {
+            for (Long id : ids) {
+                AttachmentForm form = new AttachmentForm();
+                form.setProjectId(dto.getProjectId());
+                form.setContractId(dto.getContractId());
+                form.setMasterId(id);
+                form.setFileName(file.getOriginalName());
+                form.setFileUrl(file.getLink());
+                form.setFilePdfUrl(file.getPdfUrl());
+                form.setFileSuffix(file.getFileSuffix());
+                form.setFileSizeName(file.getFileSizeName());
+                form.setFileUpTime(LocalDateTime.now());
+                fileList.add(form);
+            }
+        }
+        attachmentFormService.saveBatch(fileList);
+    }
 }