From 53dbbd7be6a6ed00d65276a8707680955f9912b9 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期五, 19 三月 2021 16:33:42 +0800
Subject: [PATCH] [import]修改库存数量修改顺序

---
 src/main/java/zy/cloud/wms/manager/controller/MatController.java |   67 ++++++++++++++++++++++++++++-----
 1 files changed, 56 insertions(+), 11 deletions(-)

diff --git a/src/main/java/zy/cloud/wms/manager/controller/MatController.java b/src/main/java/zy/cloud/wms/manager/controller/MatController.java
index 709ae2e..6f05bf6 100644
--- a/src/main/java/zy/cloud/wms/manager/controller/MatController.java
+++ b/src/main/java/zy/cloud/wms/manager/controller/MatController.java
@@ -12,10 +12,19 @@
 import com.core.common.R;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
+import zy.cloud.wms.common.CodeRes;
+import zy.cloud.wms.common.config.AdminInterceptor;
+import zy.cloud.wms.common.utils.BarcodeUtils;
+import zy.cloud.wms.common.utils.QrCode;
 import zy.cloud.wms.common.web.BaseController;
 import zy.cloud.wms.manager.entity.Mat;
+import zy.cloud.wms.manager.entity.MatPrint;
 import zy.cloud.wms.manager.service.MatService;
 
+import javax.imageio.ImageIO;
+import javax.servlet.http.HttpServletResponse;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -46,15 +55,6 @@
                   @RequestParam(required = false)String orderByField,
                   @RequestParam(required = false)String orderByType,
                   @RequestParam Map<String, Object> param){
-//        EntityWrapper<Mat> wrapper = new EntityWrapper<>();
-//        excludeTrash(param);
-//        convert(param, wrapper);
-//        if (!Cools.isEmpty(orderByField)){
-//            wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));
-//        }
-//        Page<Mat> page = matService.selectPage(new Page<>(curr, limit), wrapper);
-//
-//        return R.ok().add(page);
         Object tagId = param.get("tag_id");
         if (Cools.isEmpty(tagId)) {
             tagId = getOriginTag().getId();
@@ -125,13 +125,13 @@
     @ManagerAuth
     public R query(String condition) {
         EntityWrapper<Mat> wrapper = new EntityWrapper<>();
-        wrapper.like("id", condition);
+        wrapper.like("matnr", condition).or().like("maktx", condition);
         Page<Mat> page = matService.selectPage(new Page<>(0, 10), wrapper);
         List<Map<String, Object>> result = new ArrayList<>();
         for (Mat mat : page.getRecords()){
             Map<String, Object> map = new HashMap<>();
             map.put("id", mat.getId());
-            map.put("value", mat.getId());
+            map.put("value", mat.getMatnr() + "(" + mat.getMaktx() + ")");
             result.add(map);
         }
         return R.ok(result);
@@ -147,4 +147,49 @@
         return R.ok();
     }
 
+    @RequestMapping(value = "/mac/code/auth")
+//    @ManagerAuth(memo = "鐗╂枡缂栫爜鏉″舰鐮佽幏鍙�(type:1(鏉″舰鐮�);2(浜岀淮鐮�)")
+    public R matCodeBarcode(@RequestParam(defaultValue = "1") Integer type
+            , @RequestParam String param
+            , HttpServletResponse response) throws Exception {
+        AdminInterceptor.cors(response);
+        if (Cools.isEmpty(param)){
+            return R.parse(BaseRes.EMPTY);
+        }
+        BufferedImage img;
+        if (type == 1) {
+            img = BarcodeUtils.encode(param);
+        } else {
+            img = QrCode.createImg(param);
+        }
+        if (!ImageIO.write(img, "jpg", response.getOutputStream())) {
+            throw new IOException("Could not write an image of format jpg");
+        }
+        response.getOutputStream().flush();
+        response.getOutputStream().close();
+        return R.ok();
+    }
+
+    // 鎵撳嵃
+    @RequestMapping(value = "/mat/print/auth")
+    @ManagerAuth(memo = "鐗╂枡缂栫爜鎵撳嵃")
+    public R matCodePrint(@RequestParam(value = "param[]") String[] param) {
+        if(Cools.isEmpty(param)) {
+            return R.parse(CodeRes.EMPTY);
+        }
+        List<MatPrint> res = new ArrayList<>();
+        for (String matnr : param){
+            Mat mat = matService.selectByMatnr(matnr);
+            // 鎵撳嵃鏁版嵁娉ㄥ叆
+            MatPrint print = new MatPrint();
+            print.setMatnr(mat.getMatnr());
+            print.setBarcode(mat.getBarcode());
+            print.setMaktx(mat.getMaktx());
+            print.setSpecs(mat.getSpecs());
+            print.setUnit(mat.getUnit());
+            res.add(print);
+        }
+        return R.ok().add(res);
+    }
+
 }

--
Gitblit v1.9.1