自动化立体仓库 - WMS系统
1
dubin
1 天以前 4eb4b44397f0121ddb9000157ce618dfe6e53025
1
5个文件已修改
2个文件已添加
180 ■■■■■ 已修改文件
pom.xml 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/controller/ImagePreviewController.java 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/controller/LocDetlController.java 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/utils/ImagePreviewUtils.java 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/static/js/locDetl/locDetl.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/views/pakStore/locDetlQuery.html 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pom.xml
@@ -108,18 +108,15 @@
            <artifactId>truelicense-core</artifactId>
            <version>1.33</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
<!--        <finalName>rqdzasrs</finalName>-->
        <finalName>czkhasrs</finalName>
        <plugins>
            <plugin>
src/main/java/com/zy/asrs/controller/ImagePreviewController.java
New file
@@ -0,0 +1,80 @@
package com.zy.asrs.controller;
import com.zy.asrs.utils.ImagePreviewUtils;
import com.zy.common.web.BaseController;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
@RestController
@RequestMapping()
public class ImagePreviewController extends BaseController {
    //上传图片
    @ApiResponses({@ApiResponse(code = 200, message = "上传成功"), @ApiResponse(code = 400, message = "上传失败"), @ApiResponse(code = 500, message = "服务器内部错误")})
    @RequestMapping(value = "/saveImage", method = RequestMethod.POST)
    public Map<String, Object> saveImage(@RequestParam("files") MultipartFile[] files) {
        Map<String, Object> map = new HashMap<>();
        List<String> list = new ArrayList<>();
        for (int i = 0; i < files.length; i++) {
            MultipartFile mfile = files[i];
            //获取文件后缀
            String suffixName = ImagePreviewUtils.getSaveImagePath(mfile);
            //生成新文件名称
            String newFileName = ImagePreviewUtils.getNewImageFileName(suffixName);
            //保存文件
            File file = new File(ImagePreviewUtils.getNewImagePath(newFileName));
            boolean state = ImagePreviewUtils.saveImage(mfile, file);
            if (state) {
//                 list.add(ImageUtil.getNewImagePath(newFileName));
                //保存数据库的图片路径为  相对路径
                list.add("uploadimage/" + newFileName);
            }
        }
        map.put("imgList", list);
        return map;
    }
    //预览图片
    @RequestMapping("previewImage")
    @ApiOperation(value = "根据文件名实现预览功能")
    public void previewFile(
            HttpServletResponse response) throws IOException {
        showImg("D:\\"+"images\\"+"20251022efda188c-56b3-4c38-9940-78d0b61b43a1.png", response);
    }
    public static void showImg(String path, HttpServletResponse response){
        if(path!=null&&!path.equals("")){
            try {
                FileInputStream fis = new FileInputStream(path);
                ServletOutputStream os = response.getOutputStream();
                byte [] b = new byte[1024*8];
                while(fis.read(b)!=-1){
                    os.write(b);
                }
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
src/main/java/com/zy/asrs/controller/LocDetlController.java
@@ -13,12 +13,9 @@
import com.core.common.DateUtils;
import com.core.common.R;
import com.zy.asrs.entity.LocDetl;
import com.zy.asrs.entity.ManLocDetl;
import com.zy.asrs.entity.Mat;
import com.zy.asrs.entity.StockStatisDTO;
import com.zy.asrs.mapper.LocDetlMapper;
import com.zy.asrs.service.LocDetlService;
import com.zy.asrs.service.ManLocDetlService;
import com.zy.asrs.service.MatService;
import com.zy.common.web.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
@@ -60,11 +57,27 @@
        if (!locNos.isEmpty()) {
            List<LocDetl> res = new ArrayList<>();
            for (String locNo : new HashSet<>(locNos)) {
                List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", locNo));
                if (!locDetls.isEmpty()) {
                    res.addAll(locDetls);
                    List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", locNo));
                    if (!locDetls.isEmpty()) {
                        res.addAll(locDetls);
                    }
                }
            }
            return R.ok().add(res);
        }
        return R.parse(BaseRes.EMPTY);
    }
    @RequestMapping(value = "/locDetlOut/auth")
    @ManagerAuth
    public R stockOutListAll(@RequestParam(value = "matnrs[]",required = false) List<String> matnrs){
        if (!matnrs.isEmpty()) {
            List<LocDetl> res = new ArrayList<>();
                for (String matnr : new HashSet<>(matnrs)) {
                    List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("matnr",matnr));
                    if (!locDetls.isEmpty()) {
                        res.addAll(locDetls);
                    }
                }
            return R.ok().add(res);
        }
        return R.parse(BaseRes.EMPTY);
src/main/java/com/zy/asrs/utils/ImagePreviewUtils.java
New file
@@ -0,0 +1,48 @@
package com.zy.asrs.utils;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;
public class ImagePreviewUtils {
    private final static String SAVE_IMAGE_PATH ="D:/images/";
    //返回文件后缀
    public static String getSaveImagePath(MultipartFile file){
        String originalFilename = file.getOriginalFilename();//获取原文件名
        int indexOf = originalFilename.indexOf(".");
        return originalFilename.substring(indexOf,originalFilename.length());
    }
    //保存图片
    public static boolean saveImage(MultipartFile multipartFile, File file){
        //判断文件夹是否存在  不存在则创建
        if (!file.getParentFile().exists()){
            file.getParentFile().mkdirs();
        }
        try {
            //使用此方法保存必须要绝对路径且文件夹必须已存在  否则报错
            multipartFile.transferTo(file);
            return true;
        }catch (IllegalStateException | IOException e){
            e.printStackTrace();
        }
        return false;
    }
    //新文件名
    public static String getNewImageFileName(String suffix){
        SimpleDateFormat adf = new SimpleDateFormat("yyyyMMdd");
        String date = adf.format(new Date());
        return date + UUID.randomUUID() + suffix;
    }
    //返回图片保存地址
    public static String getNewImagePath(String name){
        return SAVE_IMAGE_PATH + name;
    }
}
src/main/resources/application.yml
@@ -24,6 +24,9 @@
    multipart:
      maxFileSize: 100MB
      maxRequestSize: 100MB
      enabled: true
      file-size-threshold: 0B
      location: D:\
mybatis-plus:
  mapper-locations: classpath:mapper/*.xml
src/main/webapp/static/js/locDetl/locDetl.js
@@ -17,7 +17,7 @@
        ,{field: 'brand', align: 'center',title: '品牌', hide: true}
        ,{field: 'unit', align: 'center',title: '单位', hide: true}
        ,{field: 'price', align: 'center',title: '单价', hide: true}
        ,{field: 'sku', align: 'center',title: '简图', hide: true}
        ,{field: 'sku', align: 'center',title: '简图', hide: false}
        ,{field: 'units', align: 'center',title: '单位量', hide: true}
        ,{field: 'barcode', align: 'center',title: '条码', hide: true}
        ,{field: 'origin', align: 'center',title: '产地', hide: true}
src/main/webapp/views/pakStore/locDetlQuery.html
@@ -64,7 +64,7 @@
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline">
                <input class="layui-input" type="text" name="matnr" placeholder="商品编号"  autocomplete="off">
                <input class="layui-input" type="text" name="matnr" placeholder="商品模具名称"  autocomplete="off">
            </div>
        </div>
        <div class="layui-inline">
@@ -192,14 +192,17 @@
                        layer.msg("请选择数据", {icon: 2});
                        return;
                    }
                    let locNos = [];
                    data.forEach(function(elem) {
                        locNos.push(elem.locNo);
                    });
                    // let locNos = [];
                    let matnrs = [];
                    // data.forEach(function(elem) {
                    //     // locNos.push(elem.locNo);
                    //     matnrs.push(elem.matnr);
                    // });
                    $.ajax({
                        url: baseUrl+"/locDetl/auth",
                        url: baseUrl+"/locDetlOut/auth",
                        headers: {'token': localStorage.getItem('token')},
                        data: {locNos:locNos},
                        // data: {locNos:locNos,matnrs:matnrs},
                        data: {matnrs},
                        method: 'POST',
                        async: false,
                        success: function (res) {