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'},