From ab4fab389f57a5b21578690882c0dbeacf5defca Mon Sep 17 00:00:00 2001 From: xiaoning <1097449274@qq.com> Date: Fri, 17 May 2024 16:41:10 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=89=B9=E9=87=8F=E7=BB=B4=E6=8A=A4BOM?= =?UTF-8?q?=E7=9A=84=E5=9D=A1=E5=8F=A3=E5=AE=9A=E9=A2=9D=E5=B7=A5=E6=97=B6?= =?UTF-8?q?/=E6=89=93=E7=A3=A8=E5=AE=9A=E9=A2=9D=E5=B7=A5=E6=97=B6/?= =?UTF-8?q?=E6=9B=B2=E5=AE=9A=E9=A2=9D=E5=B7=A5=E6=97=B6=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=EF=BC=9B=202.=E6=A0=B9=E6=8D=AE=E5=B0=8F=E6=B1=A0=E6=95=B0?= =?UTF-8?q?=E6=8D=AE,=E5=8F=8D=E5=86=99BOM=E5=8F=8A=E5=88=87=E5=89=B2?= =?UTF-8?q?=E6=B4=BE=E5=B7=A5=E5=8D=95=E7=9A=84=E5=AE=9E=E9=99=85=E5=88=92?= =?UTF-8?q?=E7=BA=BF/=E5=88=87=E5=89=B2=E9=95=BF=E5=BA=A6=EF=BC=8C?= =?UTF-8?q?=E5=88=92=E7=BA=BF/=E5=88=87=E5=89=B2=E5=AE=9E=E5=8A=A8?= =?UTF-8?q?=E5=B7=A5=E6=97=B6=E7=AD=89=E5=AD=97=E6=AE=B5=EF=BC=9B=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E6=89=A7=E8=A1=8C=EF=BC=9B=203.=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E5=A5=97=E6=96=99=E5=9B=BEPDF=E6=97=B6=EF=BC=8C=E5=B0=86?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0=E5=88=B0=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=99=A8=EF=BC=8C=E5=B9=B6=E4=BF=9D=E5=AD=98=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E5=88=B0=E6=95=B0=E6=8D=AE=E5=BA=93=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/dsic/gj_erp/bean/jcsj/DmBom.java | 5 ++ .../com/dsic/gj_erp/bean/jcsj/DmTltpdf.java | 3 ++ .../com/dsic/gj_erp/bean/pgd/PgdQgjh.java | 4 ++ .../controller/jcsj/DmBomController.java | 16 ++++++ .../gj_erp/mapper/xiaochi/CutPlanMapper.java | 2 + .../service/xiaochi/XiaoChiService.java | 11 ++++ .../java/com/dsic/gj_erp/util/FileUtil.java | 50 +++++++++++++++++++ .../mappers/xiaochi/CutPlanMapper.xml | 8 +++ 8 files changed, 99 insertions(+) create mode 100644 src/main/java/com/dsic/gj_erp/util/FileUtil.java diff --git a/src/main/java/com/dsic/gj_erp/bean/jcsj/DmBom.java b/src/main/java/com/dsic/gj_erp/bean/jcsj/DmBom.java index e4add63..d5610e6 100644 --- a/src/main/java/com/dsic/gj_erp/bean/jcsj/DmBom.java +++ b/src/main/java/com/dsic/gj_erp/bean/jcsj/DmBom.java @@ -9,6 +9,7 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.annotation.Id; import java.io.Serializable; import java.math.BigDecimal; @@ -81,8 +82,12 @@ public class DmBom implements Serializable { @ApiModelProperty(value = "切割长度") private BigDecimal qgcd; + @ApiModelProperty(value = "实际切割长度") + private BigDecimal fkqgcd; @ApiModelProperty(value = "划线长度") private BigDecimal hxcd; + @ApiModelProperty(value = "实际划线长度") + private BigDecimal fkhxcd; @ApiModelProperty(value = "图纸编号") private String tzbh; diff --git a/src/main/java/com/dsic/gj_erp/bean/jcsj/DmTltpdf.java b/src/main/java/com/dsic/gj_erp/bean/jcsj/DmTltpdf.java index b811b02..d5447c9 100644 --- a/src/main/java/com/dsic/gj_erp/bean/jcsj/DmTltpdf.java +++ b/src/main/java/com/dsic/gj_erp/bean/jcsj/DmTltpdf.java @@ -47,5 +47,8 @@ public class DmTltpdf implements Serializable { @TableId(value = "id", type = IdType.ASSIGN_UUID) private String id; + @ApiModelProperty(value = "保存路径") + private String filePath; + } diff --git a/src/main/java/com/dsic/gj_erp/bean/pgd/PgdQgjh.java b/src/main/java/com/dsic/gj_erp/bean/pgd/PgdQgjh.java index 88e83b4..a7403a0 100644 --- a/src/main/java/com/dsic/gj_erp/bean/pgd/PgdQgjh.java +++ b/src/main/java/com/dsic/gj_erp/bean/pgd/PgdQgjh.java @@ -73,6 +73,8 @@ public class PgdQgjh implements Serializable { @ApiModelProperty(value = "划线长度") private Double hxcd; + @ApiModelProperty(value = "实际划线长度") + private Double fkhxcd; @ApiModelProperty(value = "划线空程长度") private Double hxkccd; @@ -82,6 +84,8 @@ public class PgdQgjh implements Serializable { @ApiModelProperty(value = "切割长度") private String qgcd; + @ApiModelProperty(value = "实际切割长度") + private String fkqgcd; @ApiModelProperty(value = "切割空程长度") private Double qgkccd; diff --git a/src/main/java/com/dsic/gj_erp/controller/jcsj/DmBomController.java b/src/main/java/com/dsic/gj_erp/controller/jcsj/DmBomController.java index 7f1978c..1f9473f 100644 --- a/src/main/java/com/dsic/gj_erp/controller/jcsj/DmBomController.java +++ b/src/main/java/com/dsic/gj_erp/controller/jcsj/DmBomController.java @@ -14,6 +14,7 @@ import com.dsic.gj_erp.service.jcsj.DmBomService; import com.dsic.gj_erp.service.jcsj.DmTltpdfService; import com.dsic.gj_erp.service.jcsj.impl.BomUploadServiceImpl; import com.dsic.gj_erp.service.sy.SYService; +import com.dsic.gj_erp.util.FileUtil; import io.swagger.annotations.Authorization; import org.apache.commons.lang3.StringUtils; import org.apache.pdfbox.pdmodel.PDDocument; @@ -55,12 +56,26 @@ public class DmBomController { @Autowired DmTltpdfService tltpdfService; + @PostMapping("/saveDegs") + @AuthFunction + public ResultBean saveDegs( @RequestBody List list ){ + for (DmBom bom : list) { + dmBomService.update(new UpdateWrapper().eq("idd",bom.getIdd()) + .set("pkgs",bom.getPkgs()) + .set("dmgs",bom.getDmgs()) + .set("qgs",bom.getQgs()) + ); + } + return new ResultBean(); + } @PostMapping("/uploadPDF") @Authorization("") @Transactional @ResponseBody public ResultBean uploadPDF(@RequestParam("file") MultipartFile[] fileList)throws IOException { + for (MultipartFile file : fileList) { + String url= FileUtil.handlerUpload(file,"/tltpdf"); PDDocument document = PDDocument.load(file.getInputStream()); int pageNum = document.getNumberOfPages(); PDFTextStripper stripper = new PDFTextStripper(); @@ -95,6 +110,7 @@ public class DmBomController { tltpdf.setPageNum(i +"/"+pageNum); tltpdf.setRows((j+1) +"/"+a.length); tltpdf.setContent(a[j]); + tltpdf.setFilePath(url); list.add(tltpdf); // System.out.println("第 " + (j+1) +"/"+a.length+ " 行 :"); // System.out.println(a[j]); diff --git a/src/main/java/com/dsic/gj_erp/mapper/xiaochi/CutPlanMapper.java b/src/main/java/com/dsic/gj_erp/mapper/xiaochi/CutPlanMapper.java index 2e660bf..994be3f 100644 --- a/src/main/java/com/dsic/gj_erp/mapper/xiaochi/CutPlanMapper.java +++ b/src/main/java/com/dsic/gj_erp/mapper/xiaochi/CutPlanMapper.java @@ -7,4 +7,6 @@ import java.util.List; public interface CutPlanMapper extends BaseMapper { List getCutPlanList(String st,String ed); + + void synBom_qgPgd(); } diff --git a/src/main/java/com/dsic/gj_erp/service/xiaochi/XiaoChiService.java b/src/main/java/com/dsic/gj_erp/service/xiaochi/XiaoChiService.java index 9a7e0d7..38e4fc6 100644 --- a/src/main/java/com/dsic/gj_erp/service/xiaochi/XiaoChiService.java +++ b/src/main/java/com/dsic/gj_erp/service/xiaochi/XiaoChiService.java @@ -90,4 +90,15 @@ public class XiaoChiService{ }); CronUtil.start(); } + +// @PostConstruct + public void synBom_qgPgd(){ + //每天凌晨一点,同步前一天数据 +// CronUtil.schedule("0 1 * * *", (Task) () -> { + CronUtil.schedule("*/1 * * * * *", (Task) () -> { + mapper.synBom_qgPgd(); + }); + CronUtil.start(); + } + } diff --git a/src/main/java/com/dsic/gj_erp/util/FileUtil.java b/src/main/java/com/dsic/gj_erp/util/FileUtil.java new file mode 100644 index 0000000..873759a --- /dev/null +++ b/src/main/java/com/dsic/gj_erp/util/FileUtil.java @@ -0,0 +1,50 @@ +package com.dsic.gj_erp.util; + +import org.springframework.lang.NonNull; +import org.springframework.web.multipart.MultipartFile; + +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Optional; +import java.util.UUID; +import java.util.concurrent.atomic.AtomicReference; + +public class FileUtil { + + public static String handlerUpload(MultipartFile multipartFile,@NonNull String path) { + String originalFilename = multipartFile.getOriginalFilename(); + AtomicReference url = new AtomicReference<>(""); + Optional.ofNullable(originalFilename).ifPresent(name -> { +// String suffix = name.substring(name.lastIndexOf(".")); +// String suffix = name.substring(name.lastIndexOf("/")); + File filePath = new File("./static/upload" + path); + if (!filePath.exists()) { + filePath.mkdirs(); + } + String fileName = name.substring(name.lastIndexOf("/")); + String tmpUrl = path + fileName; + url.set(tmpUrl); + FileUtil.saveToDisk("./static/upload" + tmpUrl, multipartFile); + }); + return url.get(); + } + + public static void saveToDisk(String filePath, MultipartFile multipartFile) { + try (BufferedOutputStream bos = new BufferedOutputStream(Files.newOutputStream(Paths.get(filePath)))) { + FileInputStream fileInputStream = (FileInputStream) multipartFile.getInputStream(); + byte[] bs = new byte[1024]; + int len; + while ((len = fileInputStream.read(bs)) != -1) { + bos.write(bs, 0, len); + } + bos.flush(); + } catch (IOException e) { + e.printStackTrace(); + throw new RuntimeException("上传失败"); + } + } +} diff --git a/src/main/resources/mappers/xiaochi/CutPlanMapper.xml b/src/main/resources/mappers/xiaochi/CutPlanMapper.xml index ac0bac8..b5d0096 100644 --- a/src/main/resources/mappers/xiaochi/CutPlanMapper.xml +++ b/src/main/resources/mappers/xiaochi/CutPlanMapper.xml @@ -24,4 +24,12 @@ and (b.qgksrq is null or qgjsrq is null ) ) + + + +