From 4d325fbd79635731ebad006b1a79beb0cde4fdb9 Mon Sep 17 00:00:00 2001
From: whyclxw <810412026@qq.com>
Date: 星期五, 13 六月 2025 17:59:46 +0800
Subject: [PATCH] 产品验收管理

---
 src/main/java/com/whyc/pojo/BomAcceptance.java                 |   90 ++++++++++++++++++
 src/main/java/com/whyc/mapper/BomAcceptanceMapper.java         |    6 +
 src/main/java/com/whyc/service/BomAcceptanceService.java       |  134 ++++++++++++++++++++++++++
 src/main/java/com/whyc/controller/BomAcceptanceController.java |   42 ++++++++
 4 files changed, 272 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/whyc/controller/BomAcceptanceController.java b/src/main/java/com/whyc/controller/BomAcceptanceController.java
new file mode 100644
index 0000000..59e096f
--- /dev/null
+++ b/src/main/java/com/whyc/controller/BomAcceptanceController.java
@@ -0,0 +1,42 @@
+package com.whyc.controller;
+
+import com.whyc.dto.Response;
+import com.whyc.pojo.AttachLock;
+import com.whyc.pojo.BOMFeedback;
+import com.whyc.pojo.BomAcceptance;
+import com.whyc.service.AttachLockService;
+import com.whyc.service.BomAcceptanceService;
+import com.whyc.util.ActionUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
+import java.util.List;
+
+@Api(tags = "浜у搧楠屾敹绠$悊")
+@RestController
+@RequestMapping("acceptance")
+public class BomAcceptanceController {
+
+    @Autowired
+    private BomAcceptanceService service;
+
+
+    @ApiOperation(value = "涓婁紶浜у搧楠屾敹淇℃伅")
+    @PostMapping("uploadBomAcceptance")
+    public Response uploadBomAcceptance(@RequestParam(required = false) MultipartFile fileLeft,@RequestParam(required = false) MultipartFile fileRight
+            ,@RequestParam(required = false) MultipartFile fileFront,@RequestParam(required = false) MultipartFile fileBack,
+            @RequestPart(required = false) List<MultipartFile> multipartFileList, @RequestParam String feedbackJson) throws IOException {
+        BomAcceptance bomAcceptance = ActionUtil.getGson().fromJson(feedbackJson, BomAcceptance.class);
+        return service.uploadBomAcceptance(fileLeft,fileRight,fileFront,fileBack,multipartFileList,bomAcceptance);
+    }
+
+    @ApiOperation("鏌ヨ浜у搧楠屾敹淇℃伅")
+    @PostMapping("getBomAcceptance")
+    public Response getBomAcceptance(@RequestBody BomAcceptance bomAcceptance,@RequestParam int pageNum,@RequestParam int pageSize){
+        return service.getBomAcceptance(bomAcceptance,pageNum,pageSize);
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/com/whyc/mapper/BomAcceptanceMapper.java b/src/main/java/com/whyc/mapper/BomAcceptanceMapper.java
new file mode 100644
index 0000000..6c9532f
--- /dev/null
+++ b/src/main/java/com/whyc/mapper/BomAcceptanceMapper.java
@@ -0,0 +1,6 @@
+package com.whyc.mapper;
+
+import com.whyc.pojo.BomAcceptance;
+
+public interface BomAcceptanceMapper extends CustomMapper<BomAcceptance>{
+}
\ No newline at end of file
diff --git a/src/main/java/com/whyc/pojo/BomAcceptance.java b/src/main/java/com/whyc/pojo/BomAcceptance.java
new file mode 100644
index 0000000..57ee34d
--- /dev/null
+++ b/src/main/java/com/whyc/pojo/BomAcceptance.java
@@ -0,0 +1,90 @@
+package com.whyc.pojo;
+
+import com.baomidou.mybatisplus.annotation.*;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * <p>
+ * 浜у搧楠屾敹淇℃伅琛�
+ * </p>
+ *
+ * @author lxw
+ * @since 2025-06-13
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@TableName("tb_bom_acceptance")
+@ApiModel(value="BomAcceptance瀵硅薄", description="浜у搧楠屾敹淇℃伅琛�")
+public class BomAcceptance implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "num", type = IdType.AUTO)
+    private Integer num;
+
+    @ApiModelProperty(value = "鐮斿彂璐熻矗浜�")
+    private String directName;
+
+    @ApiModelProperty(value = "浜у搧绯诲垪")
+    private String bomSeries;
+
+    @ApiModelProperty(value = "浜у搧鍨嬪彿")
+    private String bomModel;
+
+    @ApiModelProperty(value = "璁惧鐪熷疄鍙傛暟锛堢數鍘嬬數娴佽寖鍥存斁寮�鍚庣殑鍙傛暟锛�")
+    private String devParam;
+
+    @ApiModelProperty(value = "鏍囧噯鏈哄弬鏁帮紙瀵瑰鐨勶級")
+    private String standParam;
+
+    @ApiModelProperty(value = "闀縳瀹絰楂�(mm)")
+    private String bomSize;
+
+    @ApiModelProperty(value = "涓绘満鍑�閲�(KG)")
+    private String devWeight;
+
+    @ApiModelProperty(value = "鏁存満鍏ㄩ噸(鍚寘瑁呯锛岄厤浠�)(KG)")
+    private String devWeightAll;
+
+    @ApiModelProperty(value = "宸︿晶鍥�")
+    private String devPicleft;
+
+    @ApiModelProperty(value = "鍙充晶鍥�")
+    private String devPicright;
+
+    @ApiModelProperty(value = "姝i潰鍥�")
+    private String devPicfront;
+
+    @ApiModelProperty(value = "鍚庨潰鍥�")
+    private String devPicback;
+
+    @ApiModelProperty(value = "閰嶄欢鍥�")
+    private String sparePicpart;
+
+    @TableField(exist = false)
+    private List<String> nameList;
+
+    @ApiModelProperty(value = "閰嶄欢鍨嬪彿瑙勬牸")
+    private String sparePartmodel;
+
+    @ApiModelProperty("鍒涘缓鏃堕棿")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+    private Date createTime;
+
+    @ApiModelProperty("鍒涘缓鏃堕棿")
+    @TableField(exist = false)
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+    private Date createTime1;
+
+
+}
diff --git a/src/main/java/com/whyc/service/BomAcceptanceService.java b/src/main/java/com/whyc/service/BomAcceptanceService.java
new file mode 100644
index 0000000..0d91747
--- /dev/null
+++ b/src/main/java/com/whyc/service/BomAcceptanceService.java
@@ -0,0 +1,134 @@
+package com.whyc.service;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.whyc.dto.Response;
+import com.whyc.mapper.BomAcceptanceMapper;
+import com.whyc.pojo.BOMFeedback;
+import com.whyc.pojo.BomAcceptance;
+import com.whyc.pojo.DefectiveProducts;
+import com.whyc.util.CommonUtil;
+import com.whyc.util.FileUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Date;
+import java.util.List;
+
+import static com.whyc.util.ActionUtil.createFilefolderIFNotExist;
+
+@Service
+public class BomAcceptanceService {
+    @Autowired(required = false)
+    private BomAcceptanceMapper mapper;
+
+    //涓婁紶浜у搧楠屾敹淇℃伅
+    public Response uploadBomAcceptance(MultipartFile fileLeft, MultipartFile fileRight, MultipartFile fileFront, MultipartFile fileBack, List<MultipartFile> multipartFileList, BomAcceptance bomAcceptance) throws IOException {
+        Date date = new Date();
+        long time = date.getTime();
+        String rootFile = CommonUtil.getRootFile();
+        //閰嶄欢瀛樺偍
+        if(multipartFileList!=null && multipartFileList.size()!=0){
+            String spareDirSuffix = "acceptance_bom" + File.separator + time + File.separator+ "spare" + File.separator;
+            String spareDir = rootFile + spareDirSuffix;
+            File fileDir = new File(spareDir);
+            if (!fileDir.exists()) {
+                fileDir.mkdirs();
+            }
+            for (int i = 0; i < multipartFileList.size(); i++) {
+                MultipartFile multipartFile = multipartFileList.get(i);
+                //瀛樺偍鏂囦欢
+                String originalFilename = multipartFile.getOriginalFilename();
+                String fileName = originalFilename.substring(0, originalFilename.lastIndexOf("."));
+                String suffix = originalFilename.substring(originalFilename.lastIndexOf("."));
+                String sparePath = spareDir + fileName + suffix;
+                File file = new File(sparePath);
+                multipartFile.transferTo(file);
+            }
+            bomAcceptance.setSparePicpart(spareDirSuffix);
+        }
+        String devDirSuffix = "acceptance_bom" + File.separator + time + File.separator+ "dev" + File.separator;
+        String devDir = rootFile + devDirSuffix;
+        //宸﹁鍥�
+        if(fileLeft!=null){
+            //瀛樺偍鏂囦欢
+            String originalFilename = fileLeft.getOriginalFilename();
+            String fileName = originalFilename.substring(0, originalFilename.lastIndexOf("."));
+            String suffix = originalFilename.substring(originalFilename.lastIndexOf("."));
+            String path = devDir + fileName + suffix;
+            createFilefolderIFNotExist(path);
+            fileLeft.transferTo(new File(path));
+            bomAcceptance.setDevPicleft("doc_file" + File.separator + devDirSuffix+originalFilename);
+        }
+        //鍙宠鍥�
+        if(fileRight!=null){
+            //瀛樺偍鏂囦欢
+            String originalFilename = fileRight.getOriginalFilename();
+            String fileName = originalFilename.substring(0, originalFilename.lastIndexOf("."));
+            String suffix = originalFilename.substring(originalFilename.lastIndexOf("."));
+            String path = devDir + fileName + suffix;
+            createFilefolderIFNotExist(path);
+            fileRight.transferTo(new File(path));
+            bomAcceptance.setDevPicright("doc_file" + File.separator + devDirSuffix+originalFilename);
+        }
+        //姝i潰鍥�
+        if(fileFront!=null){
+            //瀛樺偍鏂囦欢
+            String originalFilename = fileFront.getOriginalFilename();
+            String fileName = originalFilename.substring(0, originalFilename.lastIndexOf("."));
+            String suffix = originalFilename.substring(originalFilename.lastIndexOf("."));
+            String path = devDir + fileName + suffix;
+            createFilefolderIFNotExist(path);
+            fileFront.transferTo(new File(path));
+            bomAcceptance.setDevPicfront("doc_file" + File.separator + devDirSuffix+originalFilename);
+        }
+        //宸﹁鍥�
+        if(fileBack!=null){
+            //瀛樺偍鏂囦欢
+            String originalFilename = fileBack.getOriginalFilename();
+            String fileName = originalFilename.substring(0, originalFilename.lastIndexOf("."));
+            String suffix = originalFilename.substring(originalFilename.lastIndexOf("."));
+            String path = devDir + fileName + suffix;
+            createFilefolderIFNotExist(path);
+            fileBack.transferTo(new File(path));
+            bomAcceptance.setDevPicback("doc_file" + File.separator + devDirSuffix+originalFilename);
+        }
+        mapper.insert(bomAcceptance);
+        return new Response().set(1,true,"涓婁紶鎴愬姛");
+    }
+    //鏌ヨ浜у搧楠屾敹淇℃伅
+    public Response getBomAcceptance(BomAcceptance bomAcceptance, int pageNum, int pageSize) {
+        PageHelper.startPage(pageNum,pageSize);
+        QueryWrapper wrapper=new QueryWrapper();
+        if(bomAcceptance.getDirectName()!=null){
+            wrapper.like("direct_name",bomAcceptance.getDirectName());
+        }
+        if(bomAcceptance.getBomSeries()!=null){
+            wrapper.like("bom_series",bomAcceptance.getBomSeries());
+        }
+        if(bomAcceptance.getBomModel()!=null){
+            wrapper.like("bom_model",bomAcceptance.getBomModel());
+        }
+        if(bomAcceptance.getCreateTime()!=null){
+            wrapper.ge("create_time",bomAcceptance.getCreateTime());
+        }
+        if(bomAcceptance.getCreateTime1()!=null){
+            wrapper.le("create_time",bomAcceptance.getCreateTime1());
+        }
+        List<BomAcceptance> list = mapper.selectList(wrapper);
+        String rootFile = CommonUtil.getRootFile();//涓昏矾寰�
+        if(list!=null&&list.size()>0){
+            for (BomAcceptance acceptance:list) {
+                String filePath=rootFile+acceptance.getSparePicpart();
+                //鑾峰彇鏂囦欢澶逛笅鎵�鏈夌殑鍥剧墖鍚�
+                acceptance.setNameList(FileUtil.getFileNameWithOutDirectory(filePath));
+            }
+        }
+        PageInfo  pageInfo=new PageInfo(list);
+        return new Response().setII(1,list.size()>0,pageInfo,"鏌ヨ浜у搧楠屾敹淇℃伅");
+    }
+}
\ No newline at end of file

--
Gitblit v1.9.1