From c14c261181c9afb2e0d07c714e06c81a6417c8cd Mon Sep 17 00:00:00 2001 From: 野心家 <1051256694@qq.com> Date: 星期四, 05 六月 2025 16:10:51 +0800 Subject: [PATCH] 对接mes物料信息 --- src/main/webapp/static/js/locDetl/locDetl.js | 12 ++-- src/main/java/com/zy/asrs/entity/Mat.java | 24 ++++---- src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java | 5 + src/main/java/com/zy/asrs/controller/MatController.java | 101 ++++++++++++++++++++++++++++++++- src/main/webapp/static/js/common.js | 14 ++-- src/main/resources/application.yml | 1 6 files changed, 128 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/zy/asrs/controller/MatController.java b/src/main/java/com/zy/asrs/controller/MatController.java index 53e9135..51a04b9 100644 --- a/src/main/java/com/zy/asrs/controller/MatController.java +++ b/src/main/java/com/zy/asrs/controller/MatController.java @@ -2,6 +2,7 @@ import com.alibaba.excel.EasyExcel; import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.mapper.EntityWrapper; @@ -10,20 +11,21 @@ import com.core.annotations.ManagerAuth; import com.core.common.*; 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.*; import com.zy.asrs.entity.param.EmptyPlateOutParam; import com.zy.asrs.entity.result.KeyValueVo; +import com.zy.asrs.service.ApiLogService; import com.zy.asrs.service.MatService; import com.zy.asrs.utils.MatExcelListener; import com.zy.common.CodeRes; import com.zy.common.config.AdminInterceptor; import com.zy.common.entity.MatExcel; import com.zy.common.utils.BarcodeUtils; +import com.zy.common.utils.HttpHandler; import com.zy.common.utils.QrCode; import com.zy.common.web.BaseController; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -42,6 +44,12 @@ private MatService matService; @Autowired private SnowflakeIdWorker snowflakeIdWorker; + @Value("${mes.address.url}") + private String url; + @Value("${mes.address.cxaddress}") + private String cxaddress; + @Autowired + private ApiLogService apiLogService; @RequestMapping(value = "/mat/auto/matnr/auth") public R autoMatnr(){ @@ -80,7 +88,92 @@ @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)){ + LinkedHashMap<String,Object> map = new LinkedHashMap<>(); + LinkedHashMap<String,Object> YongHuCanShu=new LinkedHashMap<>(); + YongHuCanShu.put("QianMingId",""); + map.put("YongHuCanShu",YongHuCanShu); + LinkedHashMap<String,Object> QiTaCanShu=new LinkedHashMap<>(); + QiTaCanShu.put("GnBm","bopp_TM302D12"); + QiTaCanShu.put("pagesize",50); + QiTaCanShu.put("pageindex",1); + QiTaCanShu.put("Operation","1"); + + List<LinkedHashMap<String,Object>> XhJiHes=new ArrayList<>(); + LinkedHashMap<String,Object> XhJiHe=new LinkedHashMap<>(); + XhJiHe.put("Xh1","1"); + XhJiHe.put("Xh2",2); + XhJiHes.add(XhJiHe); + QiTaCanShu.put("XhJiHe",XhJiHes); + QiTaCanShu.put("鏉′欢涓�"," and t1.tm_xj like ##"+"%"+matnr+"%"+"##"); + map.put("QiTaCanShu",QiTaCanShu); + + + HashMap<String,Object>hashMap=new HashMap<String,Object>(); + hashMap.put("Quanjucanshu","%7B%22XiTongCanShu%22%3A%7B%22xt_id%22%3A%2230077%22%2C%22xt_bm%22%3A%22undefined%22%2C%22xt_yhid%22%3A%22156%22%2C%22xt_yhms%22%3A%22%E7%B3%BB%E7%BB%9F%E7%AE%A1%E7%90%86%E5%91%98%22%2C%22xt_yhbm%22%3A%22admin%22%2C%22xt_qyms%22%3A%221%22%2C%22xt_qyjc%22%3A%221%22%2C%22xt_jsms%22%3A%22%E7%AE%A1%E7%90%86%E5%91%98%22%2C%22xt_yuyan%22%3A%22%22%7D%2C%22NeiBuCanShu%22%3A%7B%7D%7D"); + + String jsonString = JSON.toJSONString(map); + HashMap<String,Object>CanShuJi=new HashMap<String,Object>(); + CanShuJi.put("CanShuJi",jsonString); + System.out.println(JSON.toJSONString(CanShuJi)); + String response = ""; + boolean success = false; + try { + response = new HttpHandler.Builder() + .setHeaders(hashMap) + .setUri(url) + .setPath(cxaddress) + .setParams(CanShuJi) + .build() + .doPost(); + JSONObject jsonObject = JSON.parseObject(response); + if (jsonObject.getString("BianHao").equals("0000")) { + Object jieGuo = jsonObject.get("JieGuo"); + JSONObject jsonString1 = JSON.parseObject(jieGuo.toString()); + JSONObject jsonString2 = JSON.parseObject(jsonString1.get("peizhidingyicanshu").toString()); + JSONArray sqlyujujg = JSON.parseArray(jsonString2.get("sqlyujujg").toString()); + JSONObject jsonString3 = JSON.parseObject(sqlyujujg.get(0).toString()); + //娣诲姞鐗╂枡妗f + Mat mat1=new Mat(); + mat1.setMatnr(jsonString3.getString("鐢熶骇鎵瑰彿")); + mat1.setMaktx(jsonString3.getString("浜у搧鍚嶇О")); + mat1.setSpecs(jsonString3.getString("浜у搧瑙勬牸")); + mat1.setUnit(jsonString3.getString("鍗曚綅")); + mat1.setModel(jsonString3.getString("鍒跺崟浜�")); + mat1.setColor(jsonString3.getString("鐘舵��")); + mat1.setPrice(jsonString3.getDouble("鐢熶骇鏁伴噺")); + mat1.setSku(jsonString3.getString("鐢熶骇鎵瑰彿")); + mat1.setOrigin(jsonString3.getString("鑳堕噺")); + mat1.setBarcode(jsonString3.getString("鏉$爜")); + mat1.setManu(jsonString3.getString("璐ㄩ噺鐘舵��")); + matService.insert(mat1); + mat=mat1; + success=true; + + } else { + throw new CoolException("wms璇锋眰mes鏌ヨ鐗╂枡淇℃伅澶辫触"); + } + } catch (Exception e) { + return R.error(e.getMessage()); + } finally { + try { + // 淇濆瓨鎺ュ彛鏃ュ織 + apiLogService.save( + "wms璇锋眰mes鏌ヨ鐗╂枡淇℃伅", + url+"/"+cxaddress, + null, + "127.0.0.1", + JSON.toJSONString(map), + response, + success + ); + } catch (Exception e) { + R.error(e.toString()); + } + } + } + return R.ok(mat); } @RequestMapping(value = "/mat/list/auth") diff --git a/src/main/java/com/zy/asrs/entity/Mat.java b/src/main/java/com/zy/asrs/entity/Mat.java index bee0346..a6ab9a3 100644 --- a/src/main/java/com/zy/asrs/entity/Mat.java +++ b/src/main/java/com/zy/asrs/entity/Mat.java @@ -88,15 +88,15 @@ /** * 鍨嬪彿 */ - @ApiModelProperty(value= "鍨嬪彿") - @ExcelProperty(value = "鍨嬪彿") + @ApiModelProperty(value= "鍒跺崟浜�") + @ExcelProperty(value = "鍒跺崟浜�") private String model; /** * 棰滆壊 */ - @ApiModelProperty(value= "棰滆壊") - @ExcelProperty(value = "棰滆壊") + @ApiModelProperty(value= "鐘舵��") + @ExcelProperty(value = "鐘舵��") private String color; /** @@ -116,15 +116,15 @@ /** * 鍗曚环 */ - @ApiModelProperty(value= "鍗曚环") - @ExcelProperty(value = "鍗曚环") + @ApiModelProperty(value= "鐢熶骇鏁伴噺") + @ExcelProperty(value = "鐢熶骇鏁伴噺") private Double price; /** * sku */ - @ApiModelProperty(value= "sku") - @ExcelProperty(value = "sku") + @ApiModelProperty(value= "鐢熶骇鎵瑰彿") + @ExcelProperty(value = "鐢熶骇鎵瑰彿") private String sku; /** @@ -144,15 +144,15 @@ /** * 浜у湴 */ - @ApiModelProperty(value= "浜у湴") - @ExcelProperty(value = "浜у湴") + @ApiModelProperty(value= "鑳堕噺") + @ExcelProperty(value = "鑳堕噺") private String origin; /** * 鍘傚 */ - @ApiModelProperty(value= "鍘傚") - @ExcelProperty(value = "鍘傚") + @ApiModelProperty(value= "璐ㄩ噺鐘舵��") + @ExcelProperty(value = "璐ㄩ噺鐘舵��") private String manu; /** diff --git a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java index bf83a51..dc2c5be 100644 --- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java @@ -100,6 +100,11 @@ if (param.getCombMats().size()>1){ throw new CoolException("涓嶅厑璁告贩鏂�===>>" + param.getBarcode()); } + Mat mat1 = matService.selectByMatnr(param.getCombMats().get(0).getMatnr()); + if(!Cools.isEmpty(mat1)){ + param.getCombMats().get(0).setBatch(mat1.getMatnr()); + param.getCombMats().get(0).setAnfme(mat1.getPrice()); + } if(Cools.isEmpty(param.getCombMats().get(0).getBatch())){ throw new CoolException("鎵瑰彿锛堝敮涓�鐮侊級涓嶈兘涓虹┖===>>" + param.getBarcode()); } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 9d0d342..0f4ab7b 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -90,6 +90,7 @@ address: url: http://220.189.244.250:10082 outaddressSave: hmxtapi/Yh_SP/TiJiaoShuJu_AnNui + cxaddress: hmxtapi/Yh_SP/d12_0102 #erp瀵规帴 diff --git a/src/main/webapp/static/js/common.js b/src/main/webapp/static/js/common.js index 054399e..de2366d 100644 --- a/src/main/webapp/static/js/common.js +++ b/src/main/webapp/static/js/common.js @@ -225,21 +225,21 @@ {field: 'matnr', align: 'center',title: '鍟嗗搧缂栧彿锛堝搧鍙凤級', sort:true} ,{field: 'maktx', align: 'center',title: '鍟嗗搧鍚嶇О锛堝搧鍚嶏級', sort:true} ,{field: 'orderNo', align: 'center',title: '鍗曟嵁缂栧彿', hide: false} - ,{field: 'batch', align: 'center',title: '璐у搧鐗瑰緛', sort:true} - ,{field: 'anfme', align: 'center',title: '鏁伴噺', hide: false} + ,{field: 'batch', align: 'center',title: '鐢熶骇鎵瑰彿', sort:true} + ,{field: 'anfme', align: 'center',title: '鐢熶骇鏁伴噺', hide: false} ,{field: 'zpallet', align: 'center',title: '鎵樼洏鏉$爜', hide: false} - ,{field: 'specs', align: 'center',title: '瑙勬牸', hide: false} - ,{field: 'model', align: 'center',title: '浠g爜', hide: true} - ,{field: 'color', align: 'center',title: '棰滆壊', hide: true} + ,{field: 'specs', align: 'center',title: '浜у搧瑙勬牸', hide: false} + ,{field: 'model', align: 'center',title: '鍒跺崟浜�', hide: false} + ,{field: 'color', align: 'center',title: '鐘舵��', hide: false} ,{field: 'brand', align: 'center',title: '鍝佺墝', hide: true} ,{field: 'unit', align: 'center',title: '鍗曚綅', hide: false} ,{field: 'price', align: 'center',title: '鍗曚环', hide: true} ,{field: 'sku', align: 'center',title: 'sku', hide: true} ,{field: 'units', align: 'center',title: '鍗曚綅閲�', hide: true} ,{field: 'barcode', align: 'center',title: '鏉$爜', hide: true} - ,{field: 'origin', align: 'center',title: '浜у湴', hide: true} - ,{field: 'manu', align: 'center',title: '鍘傚', hide: true} + ,{field: 'origin', align: 'center',title: '鑳堕噺', hide: false} + ,{field: 'manu', align: 'center',title: '璐ㄩ噺鐘舵��', hide: false} ,{field: 'manuDate', align: 'center',title: '鐢熶骇鏃ユ湡', hide: true} ,{field: 'itemNum', align: 'center',title: '鍝侀」鏁�', hide: true} ,{field: 'safeQty', align: 'center',title: '瀹夊叏搴撳瓨閲�', hide: true} diff --git a/src/main/webapp/static/js/locDetl/locDetl.js b/src/main/webapp/static/js/locDetl/locDetl.js index 88c7bf5..a774315 100644 --- a/src/main/webapp/static/js/locDetl/locDetl.js +++ b/src/main/webapp/static/js/locDetl/locDetl.js @@ -9,17 +9,17 @@ ,{field: 'batch', align: 'center',title: '鎵瑰彿', width: 300, sort:true} ,{field: 'anfme', align: 'center',title: '鏁伴噺'} ,{field: 'zpallet', align: 'center',title: '鎵樼洏鏉$爜'} - ,{field: 'specs', align: 'center',title: '瑙勬牸'} - ,{field: 'model', align: 'center',title: '浠g爜', hide: true} - ,{field: 'color', align: 'center',title: '棰滆壊', hide: true} + ,{field: 'specs', align: 'center',title: '浜у搧瑙勬牸'} + ,{field: 'model', align: 'center',title: '鍒跺崟浜�', hide: false} + ,{field: 'color', align: 'center',title: '鐘舵��', hide: false} ,{field: 'brand', align: 'center',title: '鍝佺墝', hide: true} - ,{field: 'unit', align: 'center',title: '鍗曚綅', hide: true} + ,{field: 'unit', align: 'center',title: '鍗曚綅', hide: false} ,{field: 'price', align: 'center',title: '鍗曚环', hide: true} ,{field: 'sku', align: 'center',title: 'sku', hide: true} ,{field: 'units', align: 'center',title: '鍗曚綅閲�', hide: true} ,{field: 'barcode', align: 'center',title: '鏉$爜', hide: true} - ,{field: 'origin', align: 'center',title: '浜у湴', hide: true} - ,{field: 'manu', align: 'center',title: '鍘傚', hide: true} + ,{field: 'origin', align: 'center',title: '鑳堕噺', hide: false} + ,{field: 'manu', align: 'center',title: '璐ㄩ噺鐘舵��', hide: false} ,{field: 'manuDate', align: 'center',title: '鐢熶骇鏃ユ湡', hide: true} ,{field: 'itemNum', align: 'center',title: '鍝侀」鏁�', hide: true} ,{field: 'safeQty', align: 'center',title: '瀹夊叏搴撳瓨閲�', hide: true} -- Gitblit v1.9.1