Commit e70a91570643c9ea174ba2f391945a568f23fa2e
1 parent
c35c5652
增加平库库存导入功能
Showing
3 changed files
with
218 additions
and
7 deletions
ant-design-vue-jeecg/src/views/system/inventory/SimpleInventoryDetailList.vue
... | ... | @@ -141,6 +141,15 @@ |
141 | 141 | :action="importExcelUrl" |
142 | 142 | @change="handleImportExcel"><a-button type="primary" icon="import">导入</a-button> |
143 | 143 | </a-upload> |
144 | + <a-upload | |
145 | + v-has="'inventoryDetail:import'" | |
146 | + name="file" | |
147 | + :showUploadList="false" | |
148 | + :multiple="false" | |
149 | + :headers="tokenHeader" | |
150 | + :action="importPinkuUrl" | |
151 | + @change="handleImportExcel"><a-button type="primary" icon="import">平库库存导入</a-button> | |
152 | + </a-upload> | |
144 | 153 | <a-button v-has="'inventoryDetail:controller'" @click='controller()' type='primary'>冻结</a-button> |
145 | 154 | <a-button v-has="'inventoryDetail:releaseController'" @click='releaseController()' type='primary'>释放冻结</a-button> |
146 | 155 | <a-button v-has="'inventoryHeader:quickShipmentInventoryHeader'" @click='quickShipment()' type='primary'>快速出库</a-button> |
... | ... | @@ -274,6 +283,9 @@ import Pagination from '@/components/jeecgbiz/Pagination' |
274 | 283 | import ellipsis from "@comp/Ellipsis"; |
275 | 284 | import ExpressStorageModal from "@views/system/monitor/modules/ExpressStorageModal.vue"; //引入 Pagination组件 |
276 | 285 | import ExpressDeliveryModal from "@views/system/monitor/modules/ExpressDeliveryModal"; |
286 | +import Vue from "vue"; | |
287 | +import {ACCESS_TOKEN} from "@/store/mutation-types"; | |
288 | +import store from "@/store"; | |
277 | 289 | |
278 | 290 | export default { |
279 | 291 | name: 'SimpleInventoryDetailList', |
... | ... | @@ -470,6 +482,7 @@ export default { |
470 | 482 | deleteBatch: '/inventory/inventoryDetail/deleteBatch', |
471 | 483 | exportXlsUrl: '/inventory/inventoryDetail/exportXls', |
472 | 484 | importExcelUrl: 'inventory/inventoryDetail/importExcel', |
485 | + importPinkuUrl: 'inventory/inventoryDetail/importPinku', | |
473 | 486 | controller: 'inventory/inventoryHeader/controller', |
474 | 487 | quickShipment: 'inventory/inventoryHeader/quickShipment', |
475 | 488 | releaseController: 'inventory/inventoryHeader/releaseController', |
... | ... | @@ -485,6 +498,57 @@ export default { |
485 | 498 | this.loadFrom() |
486 | 499 | this.getSuperFieldList() |
487 | 500 | }, |
501 | + handleImportPinku(info) { | |
502 | + this.loading = true; | |
503 | + if (info.file.status !== 'uploading') { | |
504 | + console.log(info.file, info.fileList); | |
505 | + } | |
506 | + if (info.file.status === 'done') { | |
507 | + this.loading = false; | |
508 | + if (info.file.response.success) { | |
509 | + // this.$message.success(`${info.file.name} 文件上传成功`); | |
510 | + if (info.file.response.code === 201) { | |
511 | + let {message, result: {msg, fileUrl, fileName}} = info.file.response | |
512 | + let href = window._CONFIG['domianURL'] + fileUrl | |
513 | + this.$warning({ | |
514 | + title: message, | |
515 | + content: (<div> | |
516 | + <span>{msg}</span><br/> | |
517 | + <span>具体详情请 <a href={href} target="_blank" download={fileName}>点击下载</a> </span> | |
518 | + </div> | |
519 | + ) | |
520 | + }) | |
521 | + } else { | |
522 | + this.$message.success(info.file.response.message || `${info.file.name} 文件上传成功`) | |
523 | + } | |
524 | + this.loadData() | |
525 | + } else { | |
526 | + this.$message.error(`${info.file.name} ${info.file.response.message}.`); | |
527 | + } | |
528 | + } else if (info.file.status === 'error') { | |
529 | + this.loading = false; | |
530 | + if (info.file.response.status === 500) { | |
531 | + let data = info.file.response | |
532 | + const token = Vue.ls.get(ACCESS_TOKEN) | |
533 | + if (token && data.message.includes("Token失效")) { | |
534 | + this.$error({ | |
535 | + title: '登录已过期', | |
536 | + content: '很抱歉,登录已过期,请重新登录', | |
537 | + okText: '重新登录', | |
538 | + mask: false, | |
539 | + onOk: () => { | |
540 | + store.dispatch('Logout').then(() => { | |
541 | + Vue.ls.remove(ACCESS_TOKEN) | |
542 | + window.location.reload(); | |
543 | + }) | |
544 | + } | |
545 | + }) | |
546 | + } | |
547 | + } else { | |
548 | + this.$message.error(`文件上传失败: ${info.file.msg} `); | |
549 | + } | |
550 | + } | |
551 | + }, | |
488 | 552 | mounted() { |
489 | 553 | if(this.firstLoad == 0) { |
490 | 554 | this.firstLoad = 1; |
... | ... | @@ -503,6 +567,9 @@ export default { |
503 | 567 | computed: { |
504 | 568 | importExcelUrl: function () { |
505 | 569 | return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}` |
570 | + }, | |
571 | + importPinkuUrl: function () { | |
572 | + return `${window._CONFIG['domianURL']}/${this.url.importPinkuUrl}` | |
506 | 573 | } |
507 | 574 | }, |
508 | 575 | methods: { |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/material/controller/MaterialController.java
1 | 1 | package org.jeecg.modules.wms.config.material.controller; |
2 | 2 | |
3 | -import java.util.ArrayList; | |
4 | -import java.util.Arrays; | |
5 | -import java.util.List; | |
3 | +import java.io.IOException; | |
4 | +import java.util.*; | |
5 | +import java.util.stream.Collectors; | |
6 | 6 | |
7 | 7 | import javax.servlet.http.HttpServletRequest; |
8 | 8 | import javax.servlet.http.HttpServletResponse; |
... | ... | @@ -16,8 +16,12 @@ import org.jeecg.modules.wms.config.material.entity.Material; |
16 | 16 | import org.jeecg.modules.wms.config.material.entity.SearchDomain; |
17 | 17 | import org.jeecg.modules.wms.config.material.service.IMaterialService; |
18 | 18 | import org.jeecg.utils.HuahengJwtUtil; |
19 | +import org.jeecgframework.poi.excel.ExcelImportUtil; | |
20 | +import org.jeecgframework.poi.excel.entity.ImportParams; | |
19 | 21 | import org.springframework.beans.factory.annotation.Autowired; |
20 | 22 | import org.springframework.web.bind.annotation.*; |
23 | +import org.springframework.web.multipart.MultipartFile; | |
24 | +import org.springframework.web.multipart.MultipartHttpServletRequest; | |
21 | 25 | import org.springframework.web.servlet.ModelAndView; |
22 | 26 | |
23 | 27 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
... | ... | @@ -171,7 +175,59 @@ public class MaterialController extends JeecgController<Material, IMaterialServi |
171 | 175 | @RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
172 | 176 | @RequiresPermissions("material:import") |
173 | 177 | public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { |
174 | - return super.importExcel(request, response, Material.class); | |
178 | + MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest)request; | |
179 | + Map<String, MultipartFile> fileMap = multipartRequest.getFileMap(); | |
180 | + Iterator var6 = fileMap.entrySet().iterator(); | |
181 | + if (var6.hasNext()) { | |
182 | + Map.Entry<String, MultipartFile> entity = (Map.Entry)var6.next(); | |
183 | + MultipartFile file = (MultipartFile)entity.getValue(); | |
184 | + ImportParams params = new ImportParams(); | |
185 | + params.setTitleRows(2); | |
186 | + params.setHeadRows(1); | |
187 | + params.setNeedSave(true); | |
188 | + | |
189 | + try { | |
190 | + String warehouseCode = HuahengJwtUtil.getWarehouseCodeByToken(request); | |
191 | + List<Material> list = ExcelImportUtil.importExcel(file.getInputStream(), Material.class, params); | |
192 | + long start = System.currentTimeMillis(); | |
193 | + List<Material> materialList = materialService.list(); | |
194 | + List<String> materialCodeList = materialList.stream().map(Material::getCode).collect(Collectors.toList()); | |
195 | + List<Material> removeMaterialList = new ArrayList<>(); | |
196 | + for (Material material : list) { | |
197 | + if (materialCodeList.contains(material.getCode())) { | |
198 | + removeMaterialList.add(material); | |
199 | + } | |
200 | + material.setWarehouseCode(warehouseCode); | |
201 | + } | |
202 | + list.removeAll(removeMaterialList); | |
203 | + if (!list.isEmpty()) { | |
204 | + this.service.saveBatch(list); | |
205 | + } | |
206 | + log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒"); | |
207 | + Result var13 = Result.ok("文件导入成功!数据行数:" + list.size()); | |
208 | + return var13; | |
209 | + } catch (Exception var24) { | |
210 | + String msg = var24.getMessage(); | |
211 | + log.error(msg, var24); | |
212 | + Result var12; | |
213 | + if (msg != null && msg.indexOf("Duplicate entry") >= 0) { | |
214 | + var12 = Result.error("文件导入失败:有重复数据!"); | |
215 | + return var12; | |
216 | + } else { | |
217 | + var12 = Result.error("文件导入失败:" + var24.getMessage()); | |
218 | + return var12; | |
219 | + } | |
220 | + } finally { | |
221 | + try { | |
222 | + file.getInputStream().close(); | |
223 | + } catch (IOException var23) { | |
224 | + var23.printStackTrace(); | |
225 | + } | |
226 | + | |
227 | + } | |
228 | + } else { | |
229 | + return Result.error("文件导入失败!"); | |
230 | + } | |
175 | 231 | } |
176 | 232 | |
177 | 233 | /** |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryDetail/controller/InventoryDetailController.java
1 | 1 | package org.jeecg.modules.wms.inventory.inventoryDetail.controller; |
2 | 2 | |
3 | +import java.io.IOException; | |
3 | 4 | import java.math.BigDecimal; |
4 | -import java.util.Arrays; | |
5 | -import java.util.Date; | |
6 | -import java.util.List; | |
5 | +import java.util.*; | |
7 | 6 | import java.util.stream.Collectors; |
8 | 7 | |
9 | 8 | import javax.annotation.Resource; |
... | ... | @@ -14,14 +13,26 @@ import org.jeecg.common.api.vo.Result; |
14 | 13 | import org.jeecg.common.aspect.annotation.AutoLog; |
15 | 14 | import org.jeecg.common.system.base.controller.JeecgController; |
16 | 15 | import org.jeecg.common.system.query.QueryGenerator; |
16 | +import org.jeecg.modules.wms.api.mobile.entity.QuickReceiptBean; | |
17 | +import org.jeecg.modules.wms.config.material.entity.Material; | |
17 | 18 | import org.jeecg.modules.wms.config.zone.entity.Zone; |
18 | 19 | import org.jeecg.modules.wms.config.zone.service.IZoneService; |
20 | +import org.jeecg.modules.wms.framework.service.IHuahengMultiHandlerService; | |
19 | 21 | import org.jeecg.modules.wms.inventory.inventoryHeader.entity.InventoryDetail; |
20 | 22 | import org.jeecg.modules.wms.inventory.inventoryHeader.service.IInventoryDetailService; |
23 | +import org.jeecg.modules.wms.receipt.receiptHeader.entity.ReceiptDetail; | |
24 | +import org.jeecg.modules.wms.receipt.receiving.controller.ReceiveController; | |
25 | +import org.jeecg.modules.wms.receipt.receiving.domain.Receive; | |
26 | +import org.jeecg.modules.wms.receipt.receiving.service.IReceiveService; | |
21 | 27 | import org.jeecg.utils.HuahengJwtUtil; |
22 | 28 | import org.jeecg.utils.StringUtils; |
29 | +import org.jeecg.utils.constant.QuantityConstant; | |
30 | +import org.jeecgframework.poi.excel.ExcelImportUtil; | |
31 | +import org.jeecgframework.poi.excel.entity.ImportParams; | |
23 | 32 | import org.springframework.beans.factory.annotation.Autowired; |
24 | 33 | import org.springframework.web.bind.annotation.*; |
34 | +import org.springframework.web.multipart.MultipartFile; | |
35 | +import org.springframework.web.multipart.MultipartHttpServletRequest; | |
25 | 36 | import org.springframework.web.servlet.ModelAndView; |
26 | 37 | |
27 | 38 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
... | ... | @@ -50,6 +61,10 @@ public class InventoryDetailController extends JeecgController<InventoryDetail, |
50 | 61 | |
51 | 62 | @Resource |
52 | 63 | private IZoneService zoneService; |
64 | + @Resource | |
65 | + private IReceiveService receiveService; | |
66 | + @Resource | |
67 | + private IHuahengMultiHandlerService huahengMultiHandlerService; | |
53 | 68 | |
54 | 69 | /** |
55 | 70 | * 分页列表查询 |
... | ... | @@ -257,6 +272,79 @@ public class InventoryDetailController extends JeecgController<InventoryDetail, |
257 | 272 | } |
258 | 273 | |
259 | 274 | /** |
275 | + * 通过excel导入平库库存数据 | |
276 | + * @param request | |
277 | + * @param response | |
278 | + * @return | |
279 | + */ | |
280 | + @RequestMapping(value = "/importPinku", method = RequestMethod.POST) | |
281 | + public Result<?> importPinku(HttpServletRequest request, HttpServletResponse response) { | |
282 | + MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest)request; | |
283 | + Map<String, MultipartFile> fileMap = multipartRequest.getFileMap(); | |
284 | + Iterator var6 = fileMap.entrySet().iterator(); | |
285 | + if (var6.hasNext()) { | |
286 | + Map.Entry<String, MultipartFile> entity = (Map.Entry)var6.next(); | |
287 | + MultipartFile file = (MultipartFile)entity.getValue(); | |
288 | + ImportParams params = new ImportParams(); | |
289 | + params.setTitleRows(2); | |
290 | + params.setHeadRows(1); | |
291 | + params.setNeedSave(true); | |
292 | + | |
293 | + try { | |
294 | + long start = System.currentTimeMillis(); | |
295 | + String warehouseCode = HuahengJwtUtil.getWarehouseCodeByToken(request); | |
296 | + List<InventoryDetail> inventoryDetailList = ExcelImportUtil.importExcel(file.getInputStream(), InventoryDetail.class, params); | |
297 | + if (!inventoryDetailList.isEmpty()) { | |
298 | + inventoryDetailList = inventoryDetailList.stream().filter(x->x.getZoneType().equals(QuantityConstant.ZONE_TYPE_FLAT)).collect(Collectors.toList()); | |
299 | + } | |
300 | + for (InventoryDetail inventoryDetail : inventoryDetailList) { | |
301 | + List<ReceiptDetail> receiptDetailList = new ArrayList<>(); | |
302 | + ReceiptDetail receiptDetail = new ReceiptDetail(); | |
303 | + receiptDetail.setBatch(inventoryDetail.getBatch()); | |
304 | + receiptDetail.setQty(inventoryDetail.getQty()); | |
305 | + receiptDetail.setInventoryStatus(inventoryDetail.getInventoryStatus()); | |
306 | + receiptDetail.setMaterialCode(inventoryDetail.getMaterialCode()); | |
307 | + receiptDetail.setMaterialName(inventoryDetail.getMaterialName()); | |
308 | + receiptDetail.setMaterialUnit(inventoryDetail.getMaterialUnit()); | |
309 | + receiptDetail.setMaterialSpec(inventoryDetail.getMaterialSpec()); | |
310 | + receiptDetailList.add(receiptDetail); | |
311 | + QuickReceiptBean quickReceiptBean = new QuickReceiptBean(); | |
312 | + quickReceiptBean.setWarehouseCode(warehouseCode); | |
313 | + quickReceiptBean.setContainerCode(inventoryDetail.getContainerCode()); | |
314 | + quickReceiptBean.setLocationCode(inventoryDetail.getLocationCode()); | |
315 | + quickReceiptBean.setCompanyCode(inventoryDetail.getCompanyCode()); | |
316 | + quickReceiptBean.setReceiptType(QuantityConstant.RECEIPT_BILL_TYPE_QTR); | |
317 | + quickReceiptBean.setReceiptDetails(receiptDetailList); | |
318 | + huahengMultiHandlerService.quickReceiptService(quickReceiptBean, warehouseCode); | |
319 | + } | |
320 | + log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒"); | |
321 | + Result var13 = Result.ok("文件导入成功!数据行数:" + inventoryDetailList.size()); | |
322 | + return var13; | |
323 | + } catch (Exception var24) { | |
324 | + String msg = var24.getMessage(); | |
325 | + log.error(msg, var24); | |
326 | + Result var12; | |
327 | + if (msg != null && msg.indexOf("Duplicate entry") >= 0) { | |
328 | + var12 = Result.error("文件导入失败:有重复数据!"); | |
329 | + return var12; | |
330 | + } else { | |
331 | + var12 = Result.error("文件导入失败:" + var24.getMessage()); | |
332 | + return var12; | |
333 | + } | |
334 | + } finally { | |
335 | + try { | |
336 | + file.getInputStream().close(); | |
337 | + } catch (IOException var23) { | |
338 | + var23.printStackTrace(); | |
339 | + } | |
340 | + | |
341 | + } | |
342 | + } else { | |
343 | + return Result.error("文件导入失败!"); | |
344 | + } | |
345 | + } | |
346 | + | |
347 | + /** | |
260 | 348 | * 根据多个库存头id分页列表查询 |
261 | 349 | */ |
262 | 350 | @ApiOperation(value = "盘点库存-根据多个库存头id分页列表查询", notes = "盘点库存-根据多个库存头id分页列表查询") |
... | ... |