From 21d0e7ab9d5c7316225a3e9eecf465cd37c9bd85 Mon Sep 17 00:00:00 2001
From: zhang <zc857179121@qq.com>
Date: 星期四, 05 六月 2025 14:15:07 +0800
Subject: [PATCH] 123

---
 src/main/java/com/zy/asrs/controller/MatController.java |   90 ++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 80 insertions(+), 10 deletions(-)

diff --git a/src/main/java/com/zy/asrs/controller/MatController.java b/src/main/java/com/zy/asrs/controller/MatController.java
index c8ef714..bc0e15f 100644
--- a/src/main/java/com/zy/asrs/controller/MatController.java
+++ b/src/main/java/com/zy/asrs/controller/MatController.java
@@ -12,8 +12,12 @@
 import com.core.exception.CoolException;
 import com.zy.asrs.entity.Mat;
 import com.zy.asrs.entity.MatPrint;
+import com.zy.asrs.entity.OrderDetl;
+import com.zy.asrs.entity.dto.OrderDetlWithSum;
 import com.zy.asrs.entity.result.KeyValueVo;
+import com.zy.asrs.service.LocDetlService;
 import com.zy.asrs.service.MatService;
+import com.zy.asrs.utils.MatExcel2Listener;
 import com.zy.asrs.utils.MatExcelListener;
 import com.zy.common.CodeRes;
 import com.zy.common.config.AdminInterceptor;
@@ -30,6 +34,8 @@
 import javax.servlet.http.HttpServletResponse;
 import java.awt.image.BufferedImage;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
 import java.util.*;
 
@@ -40,6 +46,9 @@
     private MatService matService;
     @Autowired
     private SnowflakeIdWorker snowflakeIdWorker;
+
+    @Autowired
+    private LocDetlService locDetlService;
 
     @RequestMapping(value = "/mat/auto/matnr/auth")
     public R autoMatnr(){
@@ -56,12 +65,23 @@
         return R.ok().add(mats);
     }
 
+    @RequestMapping(value = "/mat/list/pda/page/auth")
+    @ManagerAuth
+    public R pdaPageList(@RequestParam(required = true)Long tagId,
+                         @RequestParam(defaultValue = "1")Integer curr,
+                         @RequestParam(defaultValue = "10")Integer limit){
+        EntityWrapper<Mat> wrapper = new EntityWrapper<>();
+        wrapper.eq("tag_id", tagId);
+        wrapper.orderBy("create_time", false);
+        return R.ok().add(matService.selectPage(new Page<>(curr, limit), wrapper));
+    }
+
     @RequestMapping(value = "/mat/search/pda/auth")
     @ManagerAuth
     public R pdaSearch(@RequestParam(required = false)String condition){
         EntityWrapper<Mat> wrapper = new EntityWrapper<>();
         if (!Cools.isEmpty(condition)) {
-            wrapper.like("matnr", condition).or().like("maktx", condition);
+            wrapper.like("matnr", condition).or().like("maktx", condition).or().like("specs", condition);
         }
         wrapper.orderBy("create_time", false);
         List<Mat> mats = matService.selectList(wrapper);
@@ -74,10 +94,14 @@
         return R.ok(matService.selectById(String.valueOf(id)));
     }
 
-    @RequestMapping(value = "/matCode/auth0")
+    @RequestMapping(value = "/mat/auth")
     @ManagerAuth
     public R find(@RequestParam("matnr") String matnr) {
-        return R.ok(matService.selectOne(new EntityWrapper<Mat>().eq("matnr", matnr)));
+        Mat mat = matService.selectOne(new EntityWrapper<Mat>().eq("matnr", matnr));
+        if(Cools.isEmpty(mat)){
+            return R.error("鐗╂枡鏁版嵁涓嶅瓨鍦紝璇锋鏌ョ墿鏂欐。妗�");
+        }
+        return R.ok(mat);
     }
 
     @RequestMapping(value = "/mat/list/auth")
@@ -94,7 +118,10 @@
         return R.ok(matService.getPage(new Page<>(curr, limit)
                 , String.valueOf(tagId)
                 , param.get("matnr")
-                , param.get("maktx"))
+                , param.get("maktx")
+                , param.get("specs")
+                , param.get("mat_type")
+                )
         );
 
     }
@@ -130,8 +157,8 @@
         return R.ok();
     }
 
-	@RequestMapping(value = "/mat/update/auth")
-	@ManagerAuth
+    @RequestMapping(value = "/mat/update/auth")
+    @ManagerAuth
     public R update(Mat mat){
         if (Cools.isEmpty(mat) || null==mat.getId()){
             return R.error();
@@ -194,6 +221,23 @@
         return R.ok();
     }
 
+    @RequestMapping(value = "/mat/covert/{id}/auth")
+    @ManagerAuth
+    public R covert(@PathVariable("id") String id) throws UnsupportedEncodingException{
+        byte[] decode = Base64.getDecoder().decode(id);
+        String id2 = new String(decode, "utf-8");
+        Mat mat = matService.selectByMatnr(id2);
+        if (mat == null) {
+            return R.ok();
+        }
+//        OrderDetlWithSum orderDetl = new OrderDetlWithSum();
+        OrderDetl orderDetl = new OrderDetl();
+        orderDetl.sync(mat);
+        orderDetl.setAnfme(0.0D);
+//        orderDetl.setSum(locDetlService.selectSumByMatnr(mat.getMatnr()));
+        return R.ok().add(orderDetl);
+    }
+
     /*************************************** 鎵撳嵃鐩稿叧 ***********************************************/
 
     @RequestMapping(value = "/mac/code/auth")
@@ -229,6 +273,9 @@
         List<MatPrint> res = new ArrayList<>();
         for (String matnr : param){
             Mat mat = matService.selectByMatnr(matnr);
+            if(Cools.isEmpty(mat)) {
+                continue;
+            }
             // 鎵撳嵃鏁版嵁娉ㄥ叆
             MatPrint print = new MatPrint();
             print.setMatnr(mat.getMatnr());
@@ -271,21 +318,44 @@
         return R.ok("鎴愬姛鍚屾"+listener.getTotal()+"鏉″晢鍝佹暟鎹�");
     }
 
+    // 鏂板晢鍝佺紪鍙峰悓姝�
+    @PostMapping(value = "/mat/excel/importNewMatnr/auth")
+    @ManagerAuth(memo = "鏂板晢鍝佺紪鍙峰悓姝�")
+    @Transactional
+    public R matExcelImportNewMatnr(MultipartFile file) throws IOException {
+        MatExcel2Listener listener = new MatExcel2Listener(getUserId());
+        EasyExcel.read(file.getInputStream(), MatExcel.class, listener).sheet().doRead();
+        return R.ok("鎴愬姛鍚屾"+listener.getTotal()+"鏉″晢鍝佹暟鎹�");
+    }
+
+    @RequestMapping(value = "/mat/excel/export/auth")
+    @ManagerAuth(memo = "鍟嗗搧妗f鏁版嵁瀵煎嚭")
+    @Transactional
+    public void matExcelExport(@RequestParam Map<String, Object> param, HttpServletResponse response) throws IOException {
+        List<Mat> data = matService.exportData(param.get("matnr"), param.get("maktx"), param.get("specs"));
+        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+        response.setCharacterEncoding("utf-8");
+        // 杩欓噷URLEncoder.encode鍙互闃叉涓枃涔辩爜 褰撶劧鍜宔asyexcel娌℃湁鍏崇郴
+        String fileName = URLEncoder.encode("娴嬭瘯", "UTF-8").replaceAll("\\+", "%20");
+        response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
+        EasyExcel.write(response.getOutputStream(), Mat.class).sheet("妯℃澘").doWrite(data);
+    }
+
     /*************************************** xm-select ***********************************************/
 
     // xm-select 鎼滅储鍟嗗搧鍒楄〃
-    @RequestMapping("/mat/all/get/kv0") // todo:luxiaotao
+    @RequestMapping("/mat/all/get/kv")
     @ManagerAuth
     public R getMatDataKV(@RequestParam(required = false) String condition) {
         Wrapper<Mat> wrapper = new EntityWrapper<Mat>()
-                .andNew().like("matnr", condition).or().like("maktx", condition)
+                .andNew().like("matnr", condition).or().like("maktx", condition).or().like("specs", condition)
                 .orderBy("create_time", false);
         List<Mat> mats = matService.selectPage(new Page<>(1, 30), wrapper).getRecords();
         List<KeyValueVo> valueVos = new ArrayList<>();
         for (Mat mat : mats) {
             KeyValueVo vo = new KeyValueVo();
-            vo.setName(mat.getMatnr() + " - " + mat.getMaktx());
-            vo.setValue(mat.getId());
+            vo.setName(mat.getSpecs() + "-" + mat.getMaktx() + " - " + mat.getMatnr());
+            vo.setValue(mat.getMatnr());
             valueVos.add(vo);
         }
         return R.ok().add(valueVos);

--
Gitblit v1.9.1