diff --git a/src/main/java/com/dreamchaser/depository_manage/entity/ExcelInfo.java b/src/main/java/com/dreamchaser/depository_manage/entity/ExcelInfo.java index 1c814bbe..fad6b0bf 100644 --- a/src/main/java/com/dreamchaser/depository_manage/entity/ExcelInfo.java +++ b/src/main/java/com/dreamchaser/depository_manage/entity/ExcelInfo.java @@ -39,6 +39,10 @@ public class ExcelInfo { @ExcelProperty("编码") private String code; + /**单价**/ + @ExcelProperty(value = "单价") + private String price; + /** 规格型号 */ @ExcelProperty("规格型号") private String version; diff --git a/src/main/java/com/dreamchaser/depository_manage/service/impl/ExcelServiceImpl.java b/src/main/java/com/dreamchaser/depository_manage/service/impl/ExcelServiceImpl.java index 9120d9b8..b5c01ab8 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/impl/ExcelServiceImpl.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/impl/ExcelServiceImpl.java @@ -86,18 +86,18 @@ public class ExcelServiceImpl implements ExcelService { taskCenterUtil.submitTask(() -> { List success = new ArrayList<>(); Map returnResult = new HashMap<>(); - - for (int i = 0; i < excelVos.size(); i++) { + for (ExcelInfo excelVo : excelVos) { Map param = new HashMap<>(); - param.put("mname", excelVos.get(i).getMname()); - param.put("code", excelVos.get(i).getCode()); - param.put("unit", excelVos.get(i).getUnit()); - param.put("version", excelVos.get(i).getVersion()); - param.put("texture", excelVos.get(i).getTexture()); - param.put("materialTypeId", excelVos.get(i).getTypeId()); - param.put("id", excelVos.get(i).getId()); + param.put("mname", excelVo.getMname()); + param.put("code", excelVo.getCode()); + param.put("unit", excelVo.getUnit()); + param.put("version", excelVo.getVersion()); + param.put("texture", excelVo.getTexture()); + param.put("materialTypeId", excelVo.getTypeId()); + param.put("id", excelVo.getId()); + param.put("price",excelVo.getPrice() == null ? "0" : excelVo.getPrice()); materialService.insertMaterial(param); - success.add(excelVos.get(i)); + success.add(excelVo); } log.info("【批量添加】批量添加数据:{}", JSON.toJSONString(excelVos)); diff --git a/src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java b/src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java index 3b496d15..8fe35df8 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/impl/MaterialServiceImpl.java @@ -80,11 +80,9 @@ public class MaterialServiceImpl implements MaterialService { @Transactional(rollbackFor = Exception.class) @Override public Integer insertMaterial(Map map) { - if (map.containsKey("quantity") && map.containsKey("price")) { - int quantity = (int) Math.round(Double.parseDouble(map.get("quantity").toString())); + if (map.containsKey("price")) { int price = (int) (Double.parseDouble(map.get("price").toString()) * 100); map.put("price", price); - map.put("amounts", quantity * price); } // 判断是否有保质期 Integer shelfLife = 0; @@ -214,10 +212,10 @@ public class MaterialServiceImpl implements MaterialService { map.put("state", state); List list = materialMapper.findMaterialByCondition(map); for (Material material : list) { - if(material.getPrice() != null){ + if (material.getPrice() != null) { - material.setPrice(material.getPrice() / 100); - }else{ + material.setPrice(material.getPrice() / 100); + } else { material.setPrice(0.0); } material.setAmounts(material.getPrice() * material.getQuantity()); @@ -267,9 +265,9 @@ public class MaterialServiceImpl implements MaterialService { } map.put("state", state); List materialByCondition = materialMapper.findMaterialByCondition(map); - for (Material material:materialByCondition - ) { - if(material.getPrice() != null){ + for (Material material : materialByCondition + ) { + if (material.getPrice() != null) { material.setPrice(material.getPrice() / 100); } } @@ -373,7 +371,7 @@ public class MaterialServiceImpl implements MaterialService { } List list = materialMapper.findMaterialByCondition(map); for (Material material : list) { - if(material.getPrice() == null){ + if (material.getPrice() == null) { material.setPrice(0.0); } material.setPrice(material.getPrice() / 100); @@ -441,7 +439,7 @@ public class MaterialServiceImpl implements MaterialService { public List findMaterialAll() { List materialList = materialMapper.findMaterialByCondition(new HashMap()); for (Material material : materialList) { - if(material.getPrice() == null){ + if (material.getPrice() == null) { material.setPrice(0.0); } material.setPrice(material.getPrice() / 100); @@ -461,10 +459,10 @@ public class MaterialServiceImpl implements MaterialService { Material material = materialMapper.findMaterialById(id); MaterialType materialTypeByOldId = materialTypeMapper.findMaterialTypeByOldId(material.getMaterialTypeId()); material.setTypeName(materialTypeByOldId.getTname()); - if(material.getPrice() != null){ + if (material.getPrice() != null) { - material.setPrice(material.getPrice() / 100); - }else{ + material.setPrice(material.getPrice() / 100); + } else { material.setPrice(0.0); } material.setAmounts(material.getPrice() * material.getQuantity()); @@ -501,13 +499,13 @@ public class MaterialServiceImpl implements MaterialService { for (Inventory inventory : inventoryByMid) { MaterialType materialTypeByOldId = materialTypeMapper.findMaterialTypeByOldId(inventory.getMaterialTypeId()); inventory.setTypeName(materialTypeByOldId.getTname()); - if(inventory.getPlaceCode() != null){ + if (inventory.getPlaceCode() != null) { - inventory.setPrice(inventory.getPrice() / 100); - }else{ + inventory.setPrice(inventory.getPrice() / 100); + } else { inventory.setPrice(0.0); } - inventory.setAmounts(inventory.getPrice() * inventory.getQuantity()); + inventory.setAmounts(inventory.getPrice() * inventory.getQuantity()); } return inventoryByMid; } @@ -621,10 +619,10 @@ public class MaterialServiceImpl implements MaterialService { public List findMaterialByIds(List ids) { List materialList = materialMapper.findInventoryByIds(ids); for (Inventory material : materialList) { - if(material.getPrice() != null){ + if (material.getPrice() != null) { - material.setPrice(material.getPrice() / 100); - }else{ + material.setPrice(material.getPrice() / 100); + } else { material.setPrice(0.0); } @@ -820,7 +818,7 @@ public class MaterialServiceImpl implements MaterialService { splitInventoryForUnit.put(splitInfo.getNewUnit(), saveQuantity); } - if(inventory.getPrice() == null){ + if (inventory.getPrice() == null) { inventory.setPrice(0.0); } BigDecimal bigDecimal = BigDecimal.valueOf(inventory.getPrice() / splitInfo.getQuantity()); @@ -1095,7 +1093,7 @@ public class MaterialServiceImpl implements MaterialService { if (materialAndBarCode.getIid() != null) { Inventory inventoryByMid = materialMapper.findInventoryById(materialAndBarCode.getIid()); if (inventoryByMid != null) { - if(inventoryByMid.getPrice() == null){ + if (inventoryByMid.getPrice() == null) { inventoryByMid.setPrice(0.0); } materialAndBarCode.setPrice(inventoryByMid.getPrice() / 100); @@ -1537,7 +1535,7 @@ public class MaterialServiceImpl implements MaterialService { Map insertForSplitInventory = new HashMap<>(); insertForSplitInventory.put("mid", inventoryByMid.getMid()); insertForSplitInventory.put("mcode", inventoryByMid.getCode()); - if(inventoryByMid.getPrice() == null){ + if (inventoryByMid.getPrice() == null) { inventoryByMid.setPrice(0.0); } insertForSplitInventory.put("price", inventoryByMid.getPrice() / scale); @@ -1555,7 +1553,7 @@ public class MaterialServiceImpl implements MaterialService { // 定义进制时算法需要的参数 Map paramForNewMap = new HashMap<>(); paramForNewMap.put("mid", inventoryByMid.getMid()); - if(inventoryByMid.getPrice() == null){ + if (inventoryByMid.getPrice() == null) { inventoryByMid.setPrice(0.0); } paramForNewMap.put("price", String.valueOf(inventoryByMid.getPrice() / 100)); @@ -1594,13 +1592,13 @@ public class MaterialServiceImpl implements MaterialService { SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(splitInfo.getParentId()); splitUnitService.updateSplitInfoSaveQuantity(parentSplitInfo, dispose, pidAndMidForAfter.getId(), paramForNewMap, quantity, splitInfo); } else { - if(inventoryByMid.getPrice() == null){ + if (inventoryByMid.getPrice() == null) { inventoryByMid.setPrice(0.0); } paramForNewMap.put("price", Double.toString(inventoryByMid.getPrice() / 100)); paramForNewMap.put("realQuantity", String.valueOf(dispose)); paramForNewMap.put("quantity", String.valueOf(dispose)); - depositoryRecordService.applicationInPlace(paramForNewMap,false); + depositoryRecordService.applicationInPlace(paramForNewMap, false); depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(paramForNewMap.get("id"))); } // 调用新算法 @@ -1641,13 +1639,13 @@ public class MaterialServiceImpl implements MaterialService { SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(splitInfo.getParentId()); splitUnitService.updateSplitInfoSaveQuantity(parentSplitInfo, dispose, pidAndMidForAfter.getId(), paramForNewMap, quantity, splitInfo); } else { - if(inventoryByMid.getPrice() == null){ + if (inventoryByMid.getPrice() == null) { inventoryByMid.setPrice(0.0); } paramForNewMap.put("price", Double.toString(inventoryByMid.getPrice() / 100)); paramForNewMap.put("realQuantity", String.valueOf(dispose)); paramForNewMap.put("quantity", String.valueOf(dispose)); - depositoryRecordService.applicationInPlace(paramForNewMap,false); + depositoryRecordService.applicationInPlace(paramForNewMap, false); depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(paramForNewMap.get("id"))); } } else { @@ -1690,13 +1688,13 @@ public class MaterialServiceImpl implements MaterialService { SplitInfo parentSplitInfo = splitUnitMapper.findSplitInfoById(splitInfo.getParentId()); splitUnitService.updateSplitInfoSaveQuantity(parentSplitInfo, dispose, ObjectFormatUtil.toInteger(insertForSplitInventory.get("id")), paramForNewMap, quantity, splitInfo); } else { - if(inventoryByMid.getPrice() == null){ + if (inventoryByMid.getPrice() == null) { inventoryByMid.setPrice(0.0); } paramForNewMap.put("price", Double.toString(inventoryByMid.getPrice() / 100)); paramForNewMap.put("realQuantity", String.valueOf(dispose)); paramForNewMap.put("quantity", String.valueOf(dispose)); - depositoryRecordService.applicationInPlace(paramForNewMap,false); + depositoryRecordService.applicationInPlace(paramForNewMap, false); depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(paramForNewMap.get("id"))); } @@ -2419,7 +2417,6 @@ public class MaterialServiceImpl implements MaterialService { } - // 构造树形组件数据模板 public Map InitTreeMenus_New(MaterialType mt, List children) { if (mt != null) { @@ -2585,6 +2582,7 @@ public class MaterialServiceImpl implements MaterialService { /** * 获取当前仓库列表下的库存数量 + * * @param depositoryIds 待查询仓库列表 * @return */ diff --git a/src/main/resources/static/upload/materialImport.xlsx b/src/main/resources/static/upload/materialImport.xlsx index 0284b9e4..2e4ef159 100644 Binary files a/src/main/resources/static/upload/materialImport.xlsx and b/src/main/resources/static/upload/materialImport.xlsx differ diff --git a/src/main/resources/templates/pages/depository/table-stock.html b/src/main/resources/templates/pages/depository/table-stock.html index 348a422a..0fef16fb 100644 --- a/src/main/resources/templates/pages/depository/table-stock.html +++ b/src/main/resources/templates/pages/depository/table-stock.html @@ -30,19 +30,22 @@
- +
- +
- +
@@ -92,6 +95,10 @@ function changeUnit() { } + function bindTableToolbarFunction() { + + } + layui.use(['form', 'table', 'upload'], function () { var $ = layui.jquery, form = layui.form, @@ -197,7 +204,7 @@ }); - + bindTableToolbarFunction(); } }); @@ -247,7 +254,7 @@ if (data.code !== '') { req.mcode = data.code.trim(); } - if(data.version !== ''){ + if (data.version !== '') { req.version = data.version.trim(); } //执行搜索重载 @@ -332,8 +339,8 @@ layer.full(index); }); return false; - }else if (obj.event === 'downloadFile') { - window.open("/download/inventoryImportDownload","_self"); + } else if (obj.event === 'downloadFile') { + window.open("/download/inventoryImportDownload", "_self"); } }); @@ -376,7 +383,7 @@ // 获取当前showQuantity 的长度 let length = Object.getOwnPropertyNames(showQuantity).length; - if (length> 0) { + if (length > 0) { if (clickNum < length) { @@ -451,52 +458,55 @@ }; //用于导入数据 - var upLoader = upload.render({ - elem: "#u_fileUpload", // 绑定元素 - url: '/excel/importInventory', // 上传接口 - accept: 'file', // 允许上传的格式, - before: function (obj) { //obj参数包含的信息,跟 choose回调完全一致,可参见上文。 - layer.load(); //上传loading - }, - exts: 'xls|xlsx|csv', - done: function (res) { - layer.closeAll('loading'); //关闭loading - //如果上传成功 - if (res.code === 200) { - var re = ""; - for (let i = 0; i < res.data.errMsg.length; i++) { - var show = "

" + res.data.errMsg[i] + ":错误" + "

"; - re += show - } - for (let i = 0; i < res.data.dataList.length; i++) { - var code = res.data.dataList[i]["code"] === null ? '' : res.data.dataList[i]["code"]; - var mname = res.data.dataList[i]["mname"]; - var version = res.data.dataList[i]["version"] === null ? '' : res.data.dataList[i]["version"]; - var quantity = res.data.dataList[i]["quantity"]; - var show = "

" + code + ", " + mname + ", " + version + ", 数量为" + quantity + ":成功" + "

"; - re += show + function bindTableToolbarFunction() { + var upLoader = upload.render({ + elem: "#u_fileUpload", // 绑定元素 + url: '/excel/importInventory', // 上传接口 + accept: 'file', // 允许上传的格式, + before: function (obj) { //obj参数包含的信息,跟 choose回调完全一致,可参见上文。 + layer.load(); //上传loading + }, + exts: 'xls|xlsx|csv', + done: function (res) { + layer.closeAll('loading'); //关闭loading + //如果上传成功 + if (res.code === 200) { + var re = ""; + for (let i = 0; i < res.data.errMsg.length; i++) { + var show = "

" + res.data.errMsg[i] + ":错误" + "

"; + re += show + } + for (let i = 0; i < res.data.dataList.length; i++) { + var code = res.data.dataList[i]["code"] === null ? '' : res.data.dataList[i]["code"]; + var mname = res.data.dataList[i]["mname"]; + var version = res.data.dataList[i]["version"] === null ? '' : res.data.dataList[i]["version"]; + var quantity = res.data.dataList[i]["quantity"]; + var show = "

" + code + ", " + mname + ", " + version + ", 数量为" + quantity + ":成功" + "

"; + re += show + } + + layer.open({ + type: 1, + skin: 'layui-layer-rim', //加上边框 + area: ['500px', '500px'], //宽高 + content: re + }) + } else { + layer.msg(res.msg) } - layer.open({ - type: 1, - skin: 'layui-layer-rim', //加上边框 - area: ['500px', '500px'], //宽高 - content: re + }, + error: function () { + layer.closeAll('loading'); //关闭loading + var demoText = $('#demoText'); + demoText.html('上传失败 重试'); + demoText.find('.demo-reload').on('click', function () { + upLoader.upload() }) - } else { - layer.msg(res.msg) } + }) + } - }, - error: function () { - layer.closeAll('loading'); //关闭loading - var demoText = $('#demoText'); - demoText.html('上传失败 重试'); - demoText.find('.demo-reload').on('click', function () { - upLoader.upload() - }) - } - }) }); diff --git a/src/main/resources/templates/pages/material/material-out.html b/src/main/resources/templates/pages/material/material-out.html index b5494059..87668265 100644 --- a/src/main/resources/templates/pages/material/material-out.html +++ b/src/main/resources/templates/pages/material/material-out.html @@ -104,6 +104,9 @@ @@ -83,6 +89,9 @@