From 1db41cd326a09fc176c724eb5762c5cddb4c7893 Mon Sep 17 00:00:00 2001 From: liwenxuan <1298531568@qq.com> Date: Thu, 7 Sep 2023 13:52:03 +0800 Subject: [PATCH] =?UTF-8?q?1.mysql=E5=90=8C=E6=AD=A5redis15=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=202.=E7=89=A9=E6=96=99=E6=9F=A5=E8=AF=A2PC?= =?UTF-8?q?=E7=AB=AF=E5=88=97=E8=A1=A8=E5=A2=9E=E5=8A=A0=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=9D=A1=E5=BD=A2=E7=A0=81=E6=95=B0=E5=AD=97=E5=92=8C=E5=9B=BE?= =?UTF-8?q?=E7=89=87PC=E7=AB=AF,=E5=9B=BE=E7=89=87=E5=8F=AF=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E6=94=BE=E5=A4=A7=E6=9F=A5=E7=9C=8B=203.=E7=89=A9?= =?UTF-8?q?=E6=96=99=E6=9F=A5=E8=AF=A2=E6=89=8B=E6=9C=BA=E7=AB=AF=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=BB=98=E8=AE=A4=E6=98=BE=E7=A4=BA=E6=9D=A1=E5=BD=A2?= =?UTF-8?q?=E7=A0=81=E5=9B=BE=E7=89=87,=E5=A2=9E=E5=8A=A0=E5=A4=8D?= =?UTF-8?q?=E5=88=B6=E6=9D=A1=E5=BD=A2=E7=A0=81=E6=8C=89=E9=92=AE.=204.?= =?UTF-8?q?=E7=89=A9=E6=96=99=E6=9F=A5=E8=AF=A2=E5=8F=AA=E6=9C=89=E6=89=8B?= =?UTF-8?q?=E6=9C=BA=E7=AB=AF=E7=9A=84=E8=AF=A6=E6=83=85=E9=A1=B5=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E4=BF=AE=E6=94=B9=E6=8C=89=E9=92=AE=E8=BF=9B=E5=85=A5?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E9=A1=B5=E9=9D=A2=E6=89=8D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?=E7=BC=96=E7=A0=81=E4=BD=9C=E4=B8=BA=E7=89=A9=E6=96=99=E7=9A=84?= =?UTF-8?q?=E6=9D=A1=E5=BD=A2=E7=A0=81.=E6=98=AF=E5=90=A6=E7=A1=AE?= =?UTF-8?q?=E5=AE=9A=E7=94=9F=E6=88=90=3F=205.=E5=BA=93=E5=AD=98=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=90=9C=E7=B4=A2=E6=9D=A1=E4=BB=B6=E4=B8=AD=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E4=B8=80=E4=B8=AA=E5=BC=80=E5=85=B3(=E4=B8=8D?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=BA=93=E5=AD=98=E6=80=BB=E6=95=B0=E4=B8=BA?= =?UTF-8?q?0),=E5=BC=80=E5=90=AF=E6=97=B6=E4=B8=8D=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=BA=93=E5=AD=98=E6=80=BB=E6=95=B0=E4=B8=BA0,=E5=85=B3?= =?UTF-8?q?=E9=97=AD=E6=97=B6=E8=BF=98=E6=98=AF=E6=98=BE=E7=A4=BA(?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=BC=80=E5=90=AF),pc=E6=89=8B=E6=9C=BA?= =?UTF-8?q?=E7=AB=AF=E5=9D=87=E5=B7=B2=E5=A2=9E=E5=8A=A0.=206.=E5=BA=93?= =?UTF-8?q?=E5=AD=98=E6=9F=A5=E8=AF=A2=E5=88=97=E8=A1=A8=E4=B8=AD=E5=BA=93?= =?UTF-8?q?=E5=AD=98=E6=80=BB=E6=95=B0=E7=94=B3=E8=AF=B7=E6=80=BB=E6=95=B0?= =?UTF-8?q?=E8=A1=A8=E5=A4=B4=E5=A2=9E=E5=8A=A0=E6=8E=92=E5=BA=8F=E5=8A=9F?= =?UTF-8?q?=E8=83=BD(pc=E7=AB=AF)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/MaterialController.java | 91 ++++++++- .../controller/PageController.java | 26 ++- .../depository_mapper/MaterialMapper.java | 21 +- .../depository_mapper/MaterialMapper.xml | 176 ++++++++++++++++- .../depository_mapper/QrCodeMapper.java | 7 + .../depository_mapper/QrCodeMapper.xml | 8 +- .../depository_manage/entity/Material.java | 10 + .../entity/MaterialAndBarCode.java | 4 + .../entity/MaterialWithBarCode.java | 179 ++++++++++++++++++ .../service/MaterialService.java | 9 + .../service/impl/MaterialServiceImpl.java | 49 ++++- .../pages/depository/table-stock.html | 17 +- .../pages/depository/table-stock_mobile.html | 11 ++ .../pages/material/material-out.html | 31 +++ .../pages/material/material-out_mobile.html | 1 + .../pages/material/material-view.html | 51 ++++- .../materialBarCode/materialBarCode_out.html | 58 +++++- .../pages/warehouse/depository-out.html | 2 +- 18 files changed, 729 insertions(+), 22 deletions(-) create mode 100644 src/main/java/com/dreamchaser/depository_manage/entity/MaterialWithBarCode.java diff --git a/src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java b/src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java index 330aee10..5c0115bc 100644 --- a/src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java +++ b/src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java @@ -14,6 +14,7 @@ import com.dreamchaser.depository_manage.utils.CrudUtil; import com.dreamchaser.depository_manage.utils.DateUtil; import com.dreamchaser.depository_manage.utils.ObjectFormatUtil; import org.apache.commons.collections4.CollectionUtils; +import org.redisson.misc.Hash; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -69,7 +70,23 @@ public class MaterialController { map.put("materialTypeIds", childForMaterialTypeByParent); map.remove("materialTypeId"); } - List materialPByCondition = materialService.findMaterialPByConditionForTable(map); + List materialPByCondition = materialService.findMaterialPWithBarCodeByConditionForTable(map); + for(MaterialWithBarCode item :materialPByCondition){//物料查询电脑端列表不显示barCodeFlag=2的(二维码) + // System.out.println(item.getBarCode()); + if(item.getBarCode()!=null){ + if(item.getBarCodeFlag().equals("2")){ + item.setBarCode(""); + }else{ + try { + Map barCodeImgObjMap = (Map)RestResponse.CreateBarCode(item.getBarCode(), item.getMname()).getData(); + item.setQrCode64(barCodeImgObjMap.get("qrCode")); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + } return new RestResponse(materialPByCondition, materialService.findCountByCondition(map), 200); } @@ -187,9 +204,13 @@ public class MaterialController { } } + if(map.get("excludeZeroSwitch")==null){//默认不显示库存为0 + map.put("excludeZeroSwitch","1"); + } + list = materialService.findInventory(map); total = materialService.findInventoryCount(map); - + //如果开了隐藏开关,在此循环过滤掉库存为0的 return new RestResponse(list, total, 200); } @@ -771,9 +792,10 @@ public class MaterialController { // 构造物料二维码 - @PostMapping("/createQrCode") - public RestResponse createQrCode(@RequestBody Map map) { + @PostMapping("/createQrCodeOld") + public RestResponse createQrCodeOld(@RequestBody Map map) { // 通过雪花算法计算随机数 + Snowflake snowflake = new Snowflake(10, 10, true); String qrCode = snowflake.nextIdStr(); @@ -799,6 +821,42 @@ public class MaterialController { } + + /** + * 生成物料条码(将物料编号作为条形码数字) + * 查询是否已有flag=1的barCode + * 如果有就不能生成 + * 没有则生成flag=1的barCode + * @param map + * @return + */ + @PostMapping("/createQrCode") + public RestResponse createQrCode(@RequestBody Map map) { + + String qrCode = ""; + + Long mid = ObjectFormatUtil.toLong(map.get("mid")); + Material material = materialService.findMaterialById(mid); + + String qrCodeByMcode = materialService.findQrCodeByMcodeFlag1(material.getCode()); + + if (qrCodeByMcode == null) {// + Map param = new HashMap<>(); + param.put("mcode", material.getCode()); + param.put("qrCode", material.getCode()); + materialService.addQrCodeByMaterial(param); + } else {//已经有了条码 + qrCode = qrCodeByMcode; + } + try { + // 二维码保存信息 + return RestResponse.CreateBarCode(qrCode, material.getMname()); + } catch (IOException e) { + return new RestResponse("err: " + e.getMessage(), 678, new StatusInfo("失败", "请联系开发人员")); + } + + } + // 将扫描结果数据暂存到redis中 @PostMapping("/temporaryValue") public RestResponse temporaryValue(@RequestBody Map map, HttpServletRequest request) { @@ -1527,6 +1585,31 @@ public class MaterialController { } } + + // 删除条形码与物料编码的对应关系 + @PostMapping("/delBarCodeByMaterialAndFlag") + public RestResponse delBarCodeByMaterialAndFlag(@RequestBody Map map, HttpServletRequest request) { + + Integer res = 0; + if (map.containsKey("ids")) { + //List ids = ObjectFormatUtil.objToList(map.get("ids"),Integer.class); + List toDelList = (List) map.get("ids"); + + for (HashMap delItem : toDelList) { + HashMap map1 = new HashMap<>(); + map1.put("id", delItem.get("id")); + map1.put("flag", delItem.get("flag")); + res += materialService.delBarCodeByMaterial(map1); + } + return CrudUtil.deleteHandle(res, toDelList.size()); + } else if (map.containsKey("id")) { + res += materialService.delBarCodeByMaterial(map); + return CrudUtil.deleteHandle(res, 1); + } else { + throw new MyException("所需请求参数缺失!"); + } + } + // 用于盘点时获取物料 @PostMapping("/findMaterialForTaking") public RestResponse findMaterialForTaking(@RequestBody Map map, HttpServletRequest request) { diff --git a/src/main/java/com/dreamchaser/depository_manage/controller/PageController.java b/src/main/java/com/dreamchaser/depository_manage/controller/PageController.java index f32087f9..bc41c673 100644 --- a/src/main/java/com/dreamchaser/depository_manage/controller/PageController.java +++ b/src/main/java/com/dreamchaser/depository_manage/controller/PageController.java @@ -729,8 +729,32 @@ public class PageController { mv.addObject("display", "none"); } List materialByBarCodeByCondition = materialService.findMaterialByBarCodeByCondition(map); - mv.addObject("record", materialService.findMaterialAndTypeById(id)); + Material materialWithBase64 = materialService.findMaterialAndTypeById(id); + + //mv.addObject("record", materialService.findMaterialAndTypeById(id)); mv.addObject("barCodeList", materialByBarCodeByCondition); + //在此添加图片对象,(flag=1的) + String qrCode = ""; + if(materialByBarCodeByCondition.size()==0){//没有flag=1的barCode数据 + + }else{//有 + for(MaterialAndBarCode m:materialByBarCodeByCondition){ + if(m.getFlag()==1){// + qrCode = m.getBmcode(); + break; + } + } + try { + Map barCodeImgObjMap = (Map)RestResponse.CreateBarCode(qrCode, material.getMname()).getData(); + materialWithBase64.setQrCode64(barCodeImgObjMap.get("qrCode")); + materialWithBase64.setQrCodeValue(barCodeImgObjMap.get("codeValue")); + //mv.addObject("barCodeImgObj", barCodeImgObj); + } catch (IOException e) { + e.printStackTrace(); + } + } + mv.addObject("record", materialWithBase64); + } else { throw new MyException("缺少必要参数!"); } diff --git a/src/main/java/com/dreamchaser/depository_manage/depository_mapper/MaterialMapper.java b/src/main/java/com/dreamchaser/depository_manage/depository_mapper/MaterialMapper.java index d13e0275..9b91f996 100644 --- a/src/main/java/com/dreamchaser/depository_manage/depository_mapper/MaterialMapper.java +++ b/src/main/java/com/dreamchaser/depository_manage/depository_mapper/MaterialMapper.java @@ -131,6 +131,14 @@ public interface MaterialMapper { */ List findMaterialByCondition(Map map); + /** + * 根据条件查询符合条件的库存信息(带条形码) + * + * @param map 条件map + * @return 符合条件的库存信息 + */ + List findMaterialWithBarCodeByCondition(Map map); + /** * 根据条件查询物料总数 @@ -329,17 +337,28 @@ public interface MaterialMapper { */ Integer findMaterialByDepositoryCount(Map map); + /** + * 通过条形码获取物料信息(带flag) + * + * @param map + * @return + */ + //List findMaterialByBarCodeByCondition(Map map); + List findMaterialWithFlagByBarCodeByCondition(Map map); + /** * 通过条形码获取物料信息 * * @param map * @return */ - List findMaterialByBarCodeByCondition(Map map); + List findMaterialByBarCodeByCondition(Map map); Material findMaterialByCode(String code); + + /** * 通过条件获取条形码与物料的对应关系数量 * diff --git a/src/main/java/com/dreamchaser/depository_manage/depository_mapper/MaterialMapper.xml b/src/main/java/com/dreamchaser/depository_manage/depository_mapper/MaterialMapper.xml index ff04142c..c42c9a0f 100644 --- a/src/main/java/com/dreamchaser/depository_manage/depository_mapper/MaterialMapper.xml +++ b/src/main/java/com/dreamchaser/depository_manage/depository_mapper/MaterialMapper.xml @@ -28,6 +28,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -122,6 +146,25 @@ + + + + + + + + + + + + + + + + + + + m.id, m.depository_id, m.mname, m.quantity, m.price, m.type_id,m.state,m.code ,m.version ,m.amounts ,m.unit ,m.texture,m.depositoryCode,m.number_of_temporary,m.shelfLife,m.producedDate,m.productionPlace,m.brand,m.remark @@ -136,6 +179,10 @@ id,depository_id,mname,quantity,price,type_id,state,tname,dname,version ,unit ,texture,code,depositoryCode,producedDate,shelfLife,productionPlace,brand,remark + + + findMaterial.id,depository_id,mname,quantity,price,type_id,state,tname,dname,version ,unit ,texture,code,depositoryCode,producedDate,shelfLife,productionPlace,brand,remark,barCode,qrcodeandmaterial.flag + id,mid,depositoryId,mname,quantity,price,mtid,mstate,tname,dname,version ,unit , @@ -151,6 +198,11 @@ id,bmcode,mcode,mid,depositoryId,mname,mtid,version,texture,unit,tname,price,shelfLife + + + + id,bmcode,mcode,mid,depositoryId,mname,mtid,version,texture,unit,tname,price,shelfLife,codeFlag + - - + + + + + + + + + + + +
+
+ +
+ +
+
+ +
@@ -142,7 +148,7 @@
- +
@@ -167,7 +173,9 @@
+ @@ -54,6 +56,46 @@ upload = layui.upload; var mid = $("#mid").val(); + + createQrCode = function () { + var indexConfirm = layer.confirm('物料无条形码可扫描录入时可以生成,生成是将本物料的物料编码作为物料的条形码.是否确定生成?', {icon: 3}, function(){ + //layer.msg('点击确定的回调', {icon: 1}); + var req = {}; + req.mid = mid; + $.ajax({ + url: "/material/createQrCode", + type: 'post', + dataType: 'json', + contentType: "application/json;charset=utf-8", + data: JSON.stringify(req), + beforeSend: function () { + this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']}); + }, + success: function (d) { + var data = d.data; + if(data.codeValue!=""){ + alert("已有条形码,如需更换请先删除!") + } + layer.close(this.layerIndex); + + table.reloadData('currentTableId', { + url: '/material/findMaterialBarCode', + page: { + curr: 1 + }, + where: {"mid": mid} + }); + } + }) + layer.close(indexConfirm); + }, function(){ + + }); + + + } + + table.render({ elem: "#currentTableId", url: '/material/findMaterialBarCode', @@ -91,7 +133,7 @@ {field: 'version', width: 200, title: '规格型号', sort: false}, {field: 'texture', width: 100, title: '材质'}, {field: 'unit', width: 150, title: '计量单位'}, - {title: '操作', minWidth: 200, toolbar: '#currentTableBar', align: "center"} + /*{title: '操作', minWidth: 200, toolbar: '#currentTableBar', align: "center"}*/ ] ], limits: [10, 15, 20, 25, 50,100], @@ -204,13 +246,21 @@ , data = checkStatus.data; var req = {}; req.ids = []; + //console.log(data); for (i = 0, len = data.length; i < len; i++) { - req.ids[i] = data[i].id; + //liwenxuan + var delItem = {}; + delItem.id = data[i].id; + delItem.flag = data[i].flag; + req.ids.push(delItem); + + //req.ids[i] = data[i].id; } if (req.ids.length > 0) { + console.log(req) layer.confirm('真的删除么', {icon: 2, title: '提示'}, function (index) { $.ajax({ - url: '/material/delBarCodeByMaterial', + url: '/material/delBarCodeByMaterialAndFlag', dataType: 'json', type: 'POST', contentType: "application/json;charset=utf-8", diff --git a/src/main/resources/templates/pages/warehouse/depository-out.html b/src/main/resources/templates/pages/warehouse/depository-out.html index 86c5c874..9b46101e 100644 --- a/src/main/resources/templates/pages/warehouse/depository-out.html +++ b/src/main/resources/templates/pages/warehouse/depository-out.html @@ -150,7 +150,7 @@ {field: 'cname', width: 200, title: '所处公司'}, {field: 'adminorgName', width: 150, title: '所属部门'}, {field: 'address', width: 120, title: '仓库地址'}, - {field: 'introduce', width: 200, title: '仓库介绍11111'}, + {field: 'introduce', width: 200, title: '仓库介绍'}, {field: 'maxNumber', width: 200, title: '最大存储量', sort: true}, {field: 'minNumber', width: 200, title: '最小存储量', sort: true}, {field: 'state', title: '状态', minWidth: 80, templet: '#switchTpl'},