diff --git a/src/main/java/com/dreamchaser/depository_manage/controller/ExcelController.java b/src/main/java/com/dreamchaser/depository_manage/controller/ExcelController.java index 1d2a6692..d070b66c 100644 --- a/src/main/java/com/dreamchaser/depository_manage/controller/ExcelController.java +++ b/src/main/java/com/dreamchaser/depository_manage/controller/ExcelController.java @@ -3,12 +3,11 @@ package com.dreamchaser.depository_manage.controller; import com.dreamchaser.depository_manage.service.ExcelService; import com.dreamchaser.depository_manage.utils.ResultVo; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; +import java.util.Map; + /** * 用于excel导入的控制器 */ @@ -20,21 +19,23 @@ public class ExcelController { /** * 用于物料的导入 + * * @param excel * @return */ @PostMapping("/importExcelByMaterial") public ResultVo importExcelByMaterial(@RequestParam("file") MultipartFile excel) { - return excelService.importExcelMaterial(excel,"material"); + return excelService.importExcelMaterial(excel, "material"); } /** * 用于物料类型的导入 + * * @param excel * @return */ @PostMapping("/importExcelByMT") - public ResultVo importExcelByMT(@RequestParam("file") MultipartFile excel){ + public ResultVo importExcelByMT(@RequestParam("file") MultipartFile excel) { return excelService.importExcelMaterialType(excel); } @@ -43,10 +44,19 @@ public class ExcelController { * 用于库存信息的导入 */ @PostMapping("/importInventory") - public ResultVo importInventory(@RequestParam("file") MultipartFile excel){ + public ResultVo importInventory(@RequestParam("file") MultipartFile excel) { return excelService.importExcelInventory(excel); } + @PostMapping("/realImportInventory") + public void realImportInventory(@RequestBody Map map) { + String s = map.get("result"); + if ("yes".equals(s)) { + excelService.executeImportForInventory(); + }else{ + excelService.clearImportFileData(); + } + } } diff --git a/src/main/java/com/dreamchaser/depository_manage/listener/ExcelListener.java b/src/main/java/com/dreamchaser/depository_manage/listener/ExcelListener.java index 06ad7098..be9b92f4 100644 --- a/src/main/java/com/dreamchaser/depository_manage/listener/ExcelListener.java +++ b/src/main/java/com/dreamchaser/depository_manage/listener/ExcelListener.java @@ -87,7 +87,7 @@ public class ExcelListener extends AnalysisEventListener { log.error("第{}行,第{}列解析异常,数据为:{}", excelDataConvertException.getRowIndex() + 1, excelDataConvertException.getColumnIndex() + 1, result); } - String msg = "第"+errRow+"行,第"+errColumn+"列解析异常,数据为:"+result; + String msg = "第"+errRow+"行,第"+errColumn+"列解析异常,数据为:"+result+",问题为:"+exception.getMessage(); errMsg.add(msg); } diff --git a/src/main/java/com/dreamchaser/depository_manage/service/ExcelService.java b/src/main/java/com/dreamchaser/depository_manage/service/ExcelService.java index e1080ce2..1e6f7a9d 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/ExcelService.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/ExcelService.java @@ -43,5 +43,15 @@ public interface ExcelService { List writeExcelForPrint(Integer id, Integer pageSize, UserByPort userToken); + /** + * 用于执行库存导入方法 + */ + void executeImportForInventory(); + + /** + * 用于清空导入的数据 + */ + public void clearImportFileData(); } + 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 a40c1736..2e7a96e2 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 @@ -12,8 +12,6 @@ import com.dreamchaser.depository_manage.entity.*; import com.dreamchaser.depository_manage.mapper.ConstructionUnitMapper; import com.dreamchaser.depository_manage.mapper.DepositoryRecordMapper; import com.dreamchaser.depository_manage.mapper.MaterialMapper; -import com.dreamchaser.depository_manage.pojo.InventoryP; -import com.dreamchaser.depository_manage.pojo.MaterialP; import com.dreamchaser.depository_manage.service.*; import com.dreamchaser.depository_manage.utils.*; import lombok.extern.slf4j.Slf4j; @@ -25,12 +23,10 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; -import javax.servlet.http.HttpServletResponse; import java.io.File; import java.io.IOException; -import java.math.BigDecimal; import java.util.*; -import java.util.concurrent.Future; +import java.util.concurrent.*; import static com.dreamchaser.depository_manage.utils.FileUtil.uploadFile; @@ -65,6 +61,11 @@ public class ExcelServiceImpl implements ExcelService { @Autowired ConstructionUnitMapper constructionUnitMapper; + + List excelVosForInventory = new ArrayList<>(); + + + /** * 用于导入物料名称 * @@ -259,187 +260,65 @@ public class ExcelServiceImpl implements ExcelService { return ResultVoUtil.error("上传Excel文件为空"); } - List excelVos = new ArrayList<>(); - - // 用于保存当前库位下的存储数量 - Map placeToQuantity = new HashMap<>(); - - // 判断当前库位码是否正确,并存入库位中 - for (int i = 0; i < excelInfoByInventories.size(); i++) { - // 获取当前库存记录 - ExcelInfoByInventory excelInfoByInventory = excelInfoByInventories.get(i); - - // 获取库存明细名称 - String mname = excelInfoByInventory.getMname(); - // 获取当前库存明细规格 - String version = excelInfoByInventory.getVersion(); - // 用于查询当前物料中是否存在该记录 - Map map = new HashMap<>(); - map.put("mname", mname); - map.put("version", version); - List materialPByCondition = materialService.findMaterialPByConditionForTable(map); - if (materialPByCondition.size() == 0) { - Material materialByCode = null; - if (excelInfoByInventory.getCode() != null && !"".equals(excelInfoByInventory.getCode())) { - materialByCode = materialService.findMaterialByCode(excelInfoByInventory.getCode()); - } - if (materialByCode == null) { - // 如果没有当前物料 - String s = dataIndex.get(i); - String msg = s + "出现异常:" + excelInfoByInventory.getMname() + " 系统中并未存在该物料"; - errMsg.add(msg); - continue; + // 获取当前总数 + int totalVal = excelInfoByInventories.size(); + + if(totalVal > 0){ + // 定义分页数量 + double size = 10.0; + + // 定义线程数 + int threadSize = (int) Math.ceil(totalVal / size); + + // 定义开启线程数目 + int openThreadSize = 0; + // 开启对应数量的线程 + ExecutorService exs = Executors.newFixedThreadPool(threadSize); + // 线程结果集 + List>> futureList = new ArrayList>>(); + + // 1.定义CompletionService + CompletionService> completionService = new ExecutorCompletionService<>(exs); + + // 定义组合id列表 + List excelInfoByInventoryList = new ArrayList<>(); + List dataIndexList = new ArrayList<>(); + for (int i = 0; i < excelInfoByInventories.size(); i++) { + if (((i + 1) % 100) == 0) { // 如果有10个开启线程进行处理 + excelInfoByInventoryList.add(excelInfoByInventories.get(i)); + dataIndexList.add(dataIndex.get(i)); + Future> future = completionService.submit(new disposeImportInventoryFileData(excelInfoByInventoryList,dataIndexList)); + openThreadSize++; + futureList.add(future); // 添加到结果集 + excelInfoByInventoryList = new ArrayList<>(); // 情况列表 + dataIndexList = new ArrayList<>(); + } else { + // 添加id到列表中 + excelInfoByInventoryList.add(excelInfoByInventories.get(i)); + dataIndexList.add(dataIndex.get(i)); } - } - String placeCode = excelInfoByInventory.getDepositoryCode(); - Integer depositoryId = excelInfoByInventory.getDepositoryId(); - // 如果导入时输入库位信息 - if (placeCode != null && !placeCode.isEmpty()) { - Map placeMap = new HashMap<>(); - placeMap.put("did", depositoryId); - placeMap.put("kingdeecode", placeCode); - // 根据仓库及库位码获取库位 - List placeByCondition = placeService.findPlaceByCondition(placeMap); - if (placeByCondition.size() > 0) { - // 如果有库位 - Place place = placeByCondition.get(0); - // 如果库位有物料且该库位存放的物料为当前物料 - int quantity = (int) (ObjectFormatUtil.toDouble(excelInfoByInventory.getQuantity()) * 100); - // 获取当前库位的剩余存储量 - Integer pQuantity = placeToQuantity.get(place.getId()); - if (pQuantity == null) { - pQuantity = place.getMax() - place.getQuantity(); - } - if (quantity > pQuantity) { - // 如果当前库位无法放下 - String s = dataIndex.get(i); - String msg = s + "出现异常:" + excelInfoByInventory.getDepositoryCode() + " 该库位无法存放当前数目的物料"; - errMsg.add(msg); - continue; - } else { - excelVos.add(excelInfoByInventory); - pQuantity -= quantity; - placeToQuantity.put(place.getId(), pQuantity); - } + if (excelInfoByInventoryList.size() > 0) { + // 如果有剩余,开启线程进行处理 + Future> future = completionService.submit(new disposeImportInventoryFileData(excelInfoByInventoryList,dataIndexList)); + futureList.add(future); + openThreadSize++; + } - } else { - String s = dataIndex.get(i); - String msg = s + "出现异常:" + excelInfoByInventory.getDepositoryCode() + " 该仓库没有该库位"; - errMsg.add(msg); - continue; + for (int i = 0; i < openThreadSize; i++) { + List strings = new ArrayList<>(); + try { + strings = completionService.take().get(); + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); } - } else { // 否则直接加入 - excelInfoByInventory.setDepositoryCode("0"); // 设置默认库位 - excelVos.add(excelInfoByInventory); + errMsg.addAll(strings); } } - readResult.put("dataList", excelVos); - // 4.通过线程池开启一个线程去执行数据库操作,主线程继续往下执行 - // 4.1开启一个线程 - TaskCenterUtil taskCenterUtil = TaskCenterUtil.getTaskCenterUtil(); - Future objectFuture = taskCenterUtil.submitTask(() -> { - List success = new ArrayList<>(); - Map returnResult = new HashMap<>(); - for (ExcelInfoByInventory excelInfoByInventory : excelVos) { - Map insert = new HashMap<>(); - insert.put("mname", excelInfoByInventory.getMname()); - insert.put("version", excelInfoByInventory.getVersion()); - - - Material material = materialService.findMaterialByMnameAndVersion(insert); - if (material == null) { - String code = excelInfoByInventory.getCode(); - if (code != null && !"".equals(code)) { - material = materialService.findMaterialByCode(code); - } else { - material = materialMapper.findMaterialByCondition(insert).get(0); - } - } - - // 添加库存记录 - Integer depositoryId = excelInfoByInventory.getDepositoryId(); - Double quantity = ObjectFormatUtil.toDouble(excelInfoByInventory.getQuantity()); - insert.put("tempPlaceCode", excelInfoByInventory.getDepositoryCode()); - insert.put("quantity", String.valueOf(quantity)); - insert.put("depositoryId", depositoryId); - insert.put("depositoryCode", excelInfoByInventory.getDepositoryCode()); - insert.put("mid", material.getId()); - // 插入库存记录 - materialService.insertInventoryForImport(insert); + readResult.put("dataList", excelVosForInventory); - // 将该物料同时放入默认库位中 - String placeCode = excelInfoByInventory.getDepositoryCode(); - Place placeById = null; - Boolean isNew = (Boolean) insert.get("isNew"); - if (isNew) { - SplitInfo baseSplitInfoForMid = splitUnitService.findBaseSplitInfoForMid(material.getId()); - double quantity_residue = 0; - if (baseSplitInfoForMid != null) { - quantity_residue = quantity - Math.floor(quantity); - quantity = quantity - quantity_residue; - } - MaterialAndPlace placeAndMaterialByMidAndPid = null; - // 如果是新插入物料 - if (placeCode == null || placeCode.isEmpty() || "0".equals(placeCode) || "0000".equals(placeCode) || "000000".equals(placeCode)) { // 如果没有输入库位 - Map param = new HashMap<>(); - // 获取默认库位 - placeById = placeService.findPlaceById(0); - // 修改默认库位库存 - placeById.setQuantity(placeById.getQuantity() + (int) (quantity * 100)); - placeService.UpdatePlace(placeById); - // 添加库位与物料的映射 - param.put("mid", insert.get("id")); - param.put("pid", 0); - param.put("quantity", (int) (quantity * 100)); - placeService.addMaterialOnPlace(param); - placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialById(ObjectFormatUtil.toInteger(param.get("id"))); - } else { - // 如果输入的库位不是默认库位 - Map param = new HashMap<>(); - param.put("did", depositoryId); - param.put("kingdeecode", placeCode); - // 获取要导入的库位 - placeById = placeService.findPlaceByCondition(param).get(0); - // 修改库位物料数量 - - placeById.setQuantity(placeById.getQuantity() + (int) (quantity * 100)); - placeService.UpdatePlace(placeById); - - // 如果没有对应关系 - param.put("pid", placeById.getId()); - param.put("mid", insert.get("id")); - param.put("quantity", (int) (quantity * 100)); - // 添加对应关系 - placeService.addMaterialOnPlace(param); - placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialById(ObjectFormatUtil.toInteger(param.get("id"))); - } - - if (baseSplitInfoForMid != null) { - Map insertForSplitInfoStringObjectMap = new HashMap<>(); - insertForSplitInfoStringObjectMap.put("depositoryId", depositoryId); - insertForSplitInfoStringObjectMap.put("quantity", quantity_residue); - insertForSplitInfoStringObjectMap.put("placeId", placeById.getId().toString()); - insertForSplitInfoStringObjectMap.put("mid", material.getId()); - insertForSplitInfoStringObjectMap.put("unit", baseSplitInfoForMid.getNewUnit()); - SplitInventory splitInventoryByIidAndSid = splitUnitService.findSplitInventoryByIidAndSid(placeAndMaterialByMidAndPid.getId(), baseSplitInfoForMid.getId()); - int splitInfoScaleQuantity = splitUnitService.findSplitInfoScaleQuantity(baseSplitInfoForMid, -1); - splitUnitService.realInInventoryToDepository(quantity_residue * splitInfoScaleQuantity, splitInventoryByIidAndSid, insertForSplitInfoStringObjectMap, baseSplitInfoForMid, placeAndMaterialByMidAndPid, true); - if (insertForSplitInfoStringObjectMap.containsKey("applicationInId")) { - depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(insertForSplitInfoStringObjectMap.get("applicationInId"))); - } - } - - } - success.add(excelInfoByInventory); - } - log.info("【批量添加】批量添加数据:{}", JSON.toJSONString(excelVos)); - returnResult.put("success", success); - returnResult.put("errMsg", errMsg); - return ResultVoUtil.returnResultVo(200, returnResult, "结果"); - }); // 4.2删除临时文件 boolean deleteFile = FileUtil.deleteFile(new File(filePath)); if (!deleteFile) { @@ -632,4 +511,240 @@ public class ExcelServiceImpl implements ExcelService { } return fileNameList; } + + + /** + * 用于执行库存导入方法 + */ + public void executeImportForInventory(){ + TaskCenterUtil taskCenterUtil = TaskCenterUtil.getTaskCenterUtil(); + Future objectFuture = taskCenterUtil.submitTask(() -> { + List success = new ArrayList<>(); + Map returnResult = new HashMap<>(); + for (ExcelInfoByInventory excelInfoByInventory : excelVosForInventory) { + Map insert = new HashMap<>(); + insert.put("mname", excelInfoByInventory.getMname()); + insert.put("version", excelInfoByInventory.getVersion()); + + + Material material = materialService.findMaterialByMnameAndVersion(insert); + if (material == null) { + String code = excelInfoByInventory.getCode(); + if (code != null && !"".equals(code)) { + material = materialService.findMaterialByCode(code); + } else { + material = materialMapper.findMaterialByCondition(insert).get(0); + } + } + + // 添加库存记录 + Integer depositoryId = excelInfoByInventory.getDepositoryId(); + Double quantity = ObjectFormatUtil.toDouble(excelInfoByInventory.getQuantity()); + insert.put("tempPlaceCode", excelInfoByInventory.getDepositoryCode()); + insert.put("quantity", String.valueOf(quantity)); + insert.put("depositoryId", depositoryId); + insert.put("depositoryCode", excelInfoByInventory.getDepositoryCode()); + insert.put("mid", material.getId()); + + // 插入库存记录 + materialService.insertInventoryForImport(insert); + + // 将该物料同时放入默认库位中 + String placeCode = excelInfoByInventory.getDepositoryCode(); + Place placeById = null; + Boolean isNew = (Boolean) insert.get("isNew"); + if (isNew) { + SplitInfo baseSplitInfoForMid = splitUnitService.findBaseSplitInfoForMid(material.getId()); + double quantity_residue = 0; + if (baseSplitInfoForMid != null) { + quantity_residue = quantity - Math.floor(quantity); + quantity = quantity - quantity_residue; + } + MaterialAndPlace placeAndMaterialByMidAndPid = null; + // 如果是新插入物料 + if (placeCode == null || placeCode.isEmpty() || "0".equals(placeCode) || "0000".equals(placeCode) || "000000".equals(placeCode)) { // 如果没有输入库位 + Map param = new HashMap<>(); + // 获取默认库位 + placeById = placeService.findPlaceById(0); + // 修改默认库位库存 + placeById.setQuantity(placeById.getQuantity() + (int) (quantity * 100)); + placeService.UpdatePlace(placeById); + // 添加库位与物料的映射 + param.put("mid", insert.get("id")); + param.put("pid", 0); + param.put("quantity", (int) (quantity * 100)); + placeService.addMaterialOnPlace(param); + placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialById(ObjectFormatUtil.toInteger(param.get("id"))); + } else { + // 如果输入的库位不是默认库位 + Map param = new HashMap<>(); + param.put("did", depositoryId); + param.put("kingdeecode", placeCode); + // 获取要导入的库位 + placeById = placeService.findPlaceByCondition(param).get(0); + // 修改库位物料数量 + + placeById.setQuantity(placeById.getQuantity() + (int) (quantity * 100)); + placeService.UpdatePlace(placeById); + + // 如果没有对应关系 + param.put("pid", placeById.getId()); + param.put("mid", insert.get("id")); + param.put("quantity", (int) (quantity * 100)); + // 添加对应关系 + placeService.addMaterialOnPlace(param); + placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialById(ObjectFormatUtil.toInteger(param.get("id"))); + } + + if (baseSplitInfoForMid != null) { + Map insertForSplitInfoStringObjectMap = new HashMap<>(); + insertForSplitInfoStringObjectMap.put("depositoryId", depositoryId); + insertForSplitInfoStringObjectMap.put("quantity", quantity_residue); + insertForSplitInfoStringObjectMap.put("placeId", placeById.getId().toString()); + insertForSplitInfoStringObjectMap.put("mid", material.getId()); + insertForSplitInfoStringObjectMap.put("unit", baseSplitInfoForMid.getNewUnit()); + SplitInventory splitInventoryByIidAndSid = splitUnitService.findSplitInventoryByIidAndSid(placeAndMaterialByMidAndPid.getId(), baseSplitInfoForMid.getId()); + int splitInfoScaleQuantity = splitUnitService.findSplitInfoScaleQuantity(baseSplitInfoForMid, -1); + splitUnitService.realInInventoryToDepository(quantity_residue * splitInfoScaleQuantity, splitInventoryByIidAndSid, insertForSplitInfoStringObjectMap, baseSplitInfoForMid, placeAndMaterialByMidAndPid, true); + if (insertForSplitInfoStringObjectMap.containsKey("applicationInId")) { + depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(insertForSplitInfoStringObjectMap.get("applicationInId"))); + } + } + + } + success.add(excelInfoByInventory); + } + log.info("【批量添加】批量添加数据:{}", JSON.toJSONString(excelVosForInventory)); + returnResult.put("success", success); + excelVosForInventory = new ArrayList<>(); +// returnResult.put("errMsg", errMsg); + return ResultVoUtil.returnResultVo(200, returnResult, "结果"); + }); + } + + + /** + * 用于执行物料类型导入方法 + */ + public void executeImportForMaterialType(){ + + } + + /** + * 用于清空导入的数据 + */ + public void clearImportFileData(){ + excelVosForInventory = new ArrayList<>(); + } + + + /** + * 用于处理导入的库存数据 + */ + class disposeImportInventoryFileData implements Callable> { + + /** + * 待处理数据 + */ + List excelInfoByInventories; + + /** + * 待处理数据对应在excel中的位置 + */ + List dataIndex; + + + + public disposeImportInventoryFileData(List excelInfoByInventories, List dataIndex) { + this.excelInfoByInventories = excelInfoByInventories; + this.dataIndex = dataIndex; + } + + @Override + public List call() throws Exception { + /** + * 定义错误信息 + */ + List errMsg = new ArrayList<>(); + + // 用于保存当前库位下的存储数量 + Map placeToQuantity = new HashMap<>(); + // 判断当前库位码是否正确,并存入库位中 + for (int i = 0; i < excelInfoByInventories.size(); i++) { + // 获取当前库存记录 + ExcelInfoByInventory excelInfoByInventory = excelInfoByInventories.get(i); + + // 获取库存明细名称 + String mname = excelInfoByInventory.getMname(); + // 获取当前库存明细规格 + String version = excelInfoByInventory.getVersion(); + // 用于查询当前物料中是否存在该记录 + Map map = new HashMap<>(); + map.put("mname", mname); + map.put("version", version); + List materialPByCondition = materialService.findMaterialPByConditionForTable(map); + if (materialPByCondition.size() == 0) { + Material materialByCode = null; + if (excelInfoByInventory.getCode() != null && !"".equals(excelInfoByInventory.getCode())) { + materialByCode = materialService.findMaterialByCode(excelInfoByInventory.getCode()); + } + if (materialByCode == null) { + // 如果没有当前物料 + String s = dataIndex.get(i); + String msg = s + "出现异常:" + excelInfoByInventory.getMname() + " 系统中并未存在该物料"; + errMsg.add(msg); + continue; + } + + } + String placeCode = excelInfoByInventory.getDepositoryCode(); + Integer depositoryId = excelInfoByInventory.getDepositoryId(); + // 如果导入时输入库位信息 + if (placeCode != null && !placeCode.isEmpty()) { + Map placeMap = new HashMap<>(); + placeMap.put("did", depositoryId); + placeMap.put("kingdeecode", placeCode); + // 根据仓库及库位码获取库位 + List placeByCondition = placeService.findPlaceByCondition(placeMap); + if (placeByCondition.size() > 0) { + // 如果有库位 + Place place = placeByCondition.get(0); + // 如果库位有物料且该库位存放的物料为当前物料 + int quantity = (int) (ObjectFormatUtil.toDouble(excelInfoByInventory.getQuantity()) * 100); + // 获取当前库位的剩余存储量 + Integer pQuantity = placeToQuantity.get(place.getId()); + if (pQuantity == null) { + pQuantity = place.getMax() - place.getQuantity(); + } + if (quantity > pQuantity) { + // 如果当前库位无法放下 + String s = dataIndex.get(i); + String msg = s + "出现异常:" + excelInfoByInventory.getDepositoryCode() + " 该库位无法存放当前数目的物料"; + errMsg.add(msg); + } else { + excelVosForInventory.add(excelInfoByInventory); + pQuantity -= quantity; + placeToQuantity.put(place.getId(), pQuantity); + } + + } else { + String s = dataIndex.get(i); + String msg = s + "出现异常:" + excelInfoByInventory.getDepositoryCode() + " 该仓库没有该库位"; + errMsg.add(msg); + } + } else { // 否则直接加入 + excelInfoByInventory.setDepositoryCode("0"); // 设置默认库位 + excelVosForInventory.add(excelInfoByInventory); + } + } + return errMsg; + } + } + + + + + + + } diff --git a/src/main/resources/templates/pages/depository/table-stock.html b/src/main/resources/templates/pages/depository/table-stock.html index e9a3f703..4e311652 100644 --- a/src/main/resources/templates/pages/depository/table-stock.html +++ b/src/main/resources/templates/pages/depository/table-stock.html @@ -200,7 +200,7 @@ // 用于计量单位的添加 for (let k = 0; k < placeKingdeeCode.length; k++) { if (placeKingdeeCode[k] !== "") { - $(aItem).append('') + $(aItem).append('') } } @@ -471,7 +471,7 @@ if (res.code === 200) { var re = ""; for (let i = 0; i < res.data.errMsg.length; i++) { - var show = "

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

"; + var show = "

" + res.data.errMsg[i] + "

"; re += show } for (let i = 0; i < res.data.dataList.length; i++) { @@ -479,16 +479,45 @@ 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 + ":成功" + "

"; + var show = "

" + code + ", " + mname + ", " + version + ", 数量为" + quantity + ":通过" + "

"; re += show } layer.open({ - type: 1, - skin: 'layui-layer-rim', //加上边框 - area: ['500px', '500px'], //宽高 - content: re - }) + type: 1 + , title: false //不显示标题栏 + , closeBtn: false + , area: ['500px', '500px'] + , shade: 0.8 + , id: 'LAY_layuipro' //设定一个id,防止重复弹出 + , resize: false + , btn: ['导入', '取消'] + , btnAlign: 'c' + , moveType: 1 //拖拽模式,0或者1 + , content: re + , yes: function (index, layero) { + //按钮【按钮一】的回调 + $.ajax({ + url:"/excel/realImportInventory", + type: "post", + data: JSON.stringify({"result":"yes"}), + dataType: "json", + contentType: "application/json;charset=utf-8" + }); + layer.close(index);//关闭当前页 + + } + , btn2: function (index, layero) { + //按钮【按钮二】的回调 + $.ajax({ + url:"/excel/realImportInventory", + type: "post", + data: JSON.stringify({"result":"no"}), + dataType: "json", + contentType: "application/json;charset=utf-8" + }) + } + }); } else { layer.msg(res.msg) } diff --git a/target/classes/templates/pages/depository/table-stock.html b/target/classes/templates/pages/depository/table-stock.html index e9a3f703..4e311652 100644 --- a/target/classes/templates/pages/depository/table-stock.html +++ b/target/classes/templates/pages/depository/table-stock.html @@ -200,7 +200,7 @@ // 用于计量单位的添加 for (let k = 0; k < placeKingdeeCode.length; k++) { if (placeKingdeeCode[k] !== "") { - $(aItem).append('') + $(aItem).append('') } } @@ -471,7 +471,7 @@ if (res.code === 200) { var re = ""; for (let i = 0; i < res.data.errMsg.length; i++) { - var show = "

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

"; + var show = "

" + res.data.errMsg[i] + "

"; re += show } for (let i = 0; i < res.data.dataList.length; i++) { @@ -479,16 +479,45 @@ 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 + ":成功" + "

"; + var show = "

" + code + ", " + mname + ", " + version + ", 数量为" + quantity + ":通过" + "

"; re += show } layer.open({ - type: 1, - skin: 'layui-layer-rim', //加上边框 - area: ['500px', '500px'], //宽高 - content: re - }) + type: 1 + , title: false //不显示标题栏 + , closeBtn: false + , area: ['500px', '500px'] + , shade: 0.8 + , id: 'LAY_layuipro' //设定一个id,防止重复弹出 + , resize: false + , btn: ['导入', '取消'] + , btnAlign: 'c' + , moveType: 1 //拖拽模式,0或者1 + , content: re + , yes: function (index, layero) { + //按钮【按钮一】的回调 + $.ajax({ + url:"/excel/realImportInventory", + type: "post", + data: JSON.stringify({"result":"yes"}), + dataType: "json", + contentType: "application/json;charset=utf-8" + }); + layer.close(index);//关闭当前页 + + } + , btn2: function (index, layero) { + //按钮【按钮二】的回调 + $.ajax({ + url:"/excel/realImportInventory", + type: "post", + data: JSON.stringify({"result":"no"}), + dataType: "json", + contentType: "application/json;charset=utf-8" + }) + } + }); } else { layer.msg(res.msg) }