From 50b1b07bfa382c3f19c6b23f1cff4dfa50294f07 Mon Sep 17 00:00:00 2001 From: 石广澎 <shiguangpeng@163.com> Date: 星期四, 30 十一月 2023 10:58:38 +0800 Subject: [PATCH] feat: 库存管理 增加加载状态 --- consum-base/src/main/java/com/consum/base/controller/LWhFormTransferController.java | 122 ++++++++++++++++++++++++++++++++-------- 1 files changed, 98 insertions(+), 24 deletions(-) diff --git a/consum-base/src/main/java/com/consum/base/controller/LWhFormTransferController.java b/consum-base/src/main/java/com/consum/base/controller/LWhFormTransferController.java index a78ab43..dab1821 100644 --- a/consum-base/src/main/java/com/consum/base/controller/LWhFormTransferController.java +++ b/consum-base/src/main/java/com/consum/base/controller/LWhFormTransferController.java @@ -1,17 +1,22 @@ package com.consum.base.controller; +import cn.afterturn.easypoi.excel.ExcelExportUtil; +import cn.afterturn.easypoi.excel.entity.TemplateExportParams; +import cn.hutool.core.util.ReflectUtil; import com.consum.base.BaseController; +import com.consum.base.core.utils.CommonUtil; import com.consum.base.core.utils.IdUtil; import com.consum.base.core.utils.MapUtils; import com.consum.base.core.utils.MapperUtil; import com.consum.base.pojo.GoodsUseRecordVO; import com.consum.base.pojo.LWhFormTransferGoodsInfoParam; -import com.consum.base.pojo.request.ProcureModelInfoParam; import com.consum.base.pojo.RecordUserInfoVO; import com.consum.base.pojo.UseRecordSkuVO; import com.consum.base.pojo.dto.UseRecordDTO; import com.consum.base.pojo.query.TransferQry; import com.consum.base.pojo.request.LWhFormTransferParam; +import com.consum.base.pojo.request.ProcureModelInfoParam; +import com.consum.base.pojo.request.RecordInfoParam; import com.consum.base.pojo.response.FormTransferVO; import com.consum.base.pojo.response.FromTransferTemplateInfoVO; import com.consum.base.pojo.response.LWHFromTransferExtendVO; @@ -28,7 +33,6 @@ import com.consum.model.po.LWhFormTransfer; import com.consum.model.po.LWhProcureModelUser; import com.consum.model.po.LWhProcureModelUserRecord; -import com.consum.model.vo.LWhFormOutputVo; import com.iplatform.model.po.S_user_core; import com.walker.db.page.GenericPager; import com.walker.infrastructure.utils.CollectionUtils; @@ -38,19 +42,23 @@ import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import java.io.IOException; +import java.io.OutputStream; import java.lang.reflect.Field; +import java.net.URLEncoder; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.stream.Collectors; +import javax.servlet.http.HttpServletResponse; import org.apache.commons.compress.utils.Lists; +import org.apache.poi.ss.usermodel.Workbook; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -85,7 +93,12 @@ @ApiOperation(value = "鍗曟嵁鏂板", notes = "鍗曟嵁鏂板") @ApiImplicitParam(name = "param", value = "鍗曟嵁鏂板", required = true, dataType = "LWhFormTransferParam") @PostMapping("/add") - public ResponseValue add(@RequestBody LWhFormTransferParam param) throws Exception { + public ResponseValue add() throws Exception { + LWhFormTransferParam param = CommonUtil.getObjFromReqBody(LWhFormTransferParam.class); + LWhFormTransferParam param2 = new LWhFormTransferParam(); + CommonUtil.copyProperties(param, param2); + param = param2; + S_user_core currentUser = this.getCurrentUser(); if (currentUser == null) { return ResponseValue.error("鐧诲綍鐢ㄦ埛淇℃伅涓嶅瓨鍦�"); @@ -94,11 +107,32 @@ if (CollectionUtils.isEmpty(transferGoods)) { return ResponseValue.error("璋冩嫧鍗曚笉鑳戒负绌�"); } - int result = this.lWhFormTransferService.add(param, this.getSysInfo()); - if (result > 0) { - return ResponseValue.success(); + long id = this.lWhFormTransferService.add(param, this.getSysInfo()); + + Integer transferBusinessType = param.getTransferBusinessType(); + //閮ㄩ棬鍒嗗彂涓氬姟闇�瑕佸鐞� + if (transferBusinessType == 1) { + // 鍏堝嚭搴擄紝鍐嶅叆搴� + // 鍑哄簱鍓� 璁剧疆鍑哄簱浠撳簱 + FinSysTenantUser sysTenantUser = this.getSysInfo(); + String agencyId = sysTenantUser.getTenantId(); + List<BaseWarehouse> baseWarehouseList = baseWarehouseService.getByAgencyId(Long.valueOf(agencyId), (short) 1, (short) 1); + if (CollectionUtils.isEmpty(baseWarehouseList)) { + return ResponseValue.error("鏈烘瀯鏃犻粯璁や粨搴擄紒"); + } + BaseWarehouse baseWarehouse = baseWarehouseList.get(0); + Long wareHouseId = baseWarehouse.getId(); + String warehouseName = baseWarehouse.getWarehouseName(); + LWhFormTransfer lWhFormTransfer = new LWhFormTransfer(id); + lWhFormTransfer.setOutWarehouseId(wareHouseId); + lWhFormTransfer.setOutWarehouseName(warehouseName); + lWhFormTransferService.update(lWhFormTransfer); + lWhFormTransferCoreService.doTransferOutPut(id, getCurrentUser()); + + lWhFormTransferCoreService.doTransferInPut(id, getCurrentUser()); } - return ResponseValue.error("鏂板澶辫触锛�"); + + return ResponseValue.success(); } /** @@ -117,7 +151,12 @@ @ApiImplicitParam(name = "param", value = "鏉′欢鍙傛暟", required = true, dataType = "TransferQry"), }) @GetMapping("/list") - public ResponseValue queryFormTransferList(TransferQry param) { + public ResponseValue queryFormTransferList() { + TransferQry param = CommonUtil.getObjFromReq(TransferQry.class); + TransferQry param2 = new TransferQry(); + CommonUtil.copyProperties(param, param2); + param = param2; + S_user_core currentUser = this.getCurrentUser(); if (currentUser == null) { return ResponseValue.error("鐧诲綍鐢ㄦ埛淇℃伅涓嶅瓨鍦�"); @@ -152,8 +191,10 @@ } try { Field fieldDatas = GenericPager.class.getDeclaredField("datas"); - fieldDatas.setAccessible(true); - fieldDatas.set(genericPager, result); +// fieldDatas.setAccessible(true); +// fieldDatas.set(genericPager, result); + ReflectUtil.setFieldValue(genericPager, fieldDatas, result); + } catch (Exception e) { e.printStackTrace(); } @@ -183,7 +224,12 @@ @ApiImplicitParam(name = "param", value = "鏉′欢", required = true, dataType = "TransferQry"), }) @GetMapping("/detail/list") - public ResponseValue queryFormTransferDetailList(TransferQry param) { + public ResponseValue queryFormTransferDetailList() { + TransferQry param = CommonUtil.getObjFromReq(TransferQry.class); + TransferQry param2 = new TransferQry(); + CommonUtil.copyProperties(param, param2); + param = param2; + FinSysTenantUser sysInfo = this.getSysInfo(); if (sysInfo == null) { return ResponseValue.error("鐧诲綍鐢ㄦ埛淇℃伅涓嶅瓨鍦�"); @@ -263,19 +309,25 @@ * @Date 2023/10/31 */ @GetMapping("/export") - public ResponseValue export(Long id) { - if (id == null) { - return ResponseValue.error("璋冩嫧鍗昳d涓虹┖"); + public void export(Long id, HttpServletResponse response) throws IOException { + + TemplateExportParams params = new TemplateExportParams("import/璋冩嫧鍏ュ簱鍗�.xlsx"); + Map<String, Object> map = this.lWhFormTransferService.export(id); + + Workbook workbook = ExcelExportUtil.exportExcel(params, map); + try (OutputStream outputStream = response.getOutputStream()) { + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"); + response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode("璋冩嫧鍏ュ簱鍗�.xlsx", "utf-8")); + workbook.write(outputStream); + workbook.close(); } - LWhFormOutputVo vo = this.lWhFormTransferService.export(id, this.getCurrentUser()); - return ResponseValue.success(vo); } /** * 閮ㄩ棬鐗╁搧鍒嗗彂鍒楄〃鏄庣粏 * - * @param transferQry + * @param * @return */ @ApiOperation(value = "閮ㄩ棬鐗╁搧鍒嗗彂鍒楄〃鏄庣粏", notes = "閮ㄩ棬鐗╁搧鍒嗗彂鍒楄〃鏄庣粏") @@ -283,13 +335,17 @@ @ApiImplicitParam(name = "transferQryDto", value = "璋冩嫧鍗曟煡璇㈡潯浠�", required = true) }) @GetMapping("/department/list") - public ResponseValue departmentTransferList(TransferQry transferQry) { + public ResponseValue departmentTransferList() { + TransferQry param = CommonUtil.getObjFromReq(TransferQry.class); + TransferQry param2 = new TransferQry(); + CommonUtil.copyProperties(param, param2); + param = param2; S_user_core currentUser = this.getCurrentUser(); if (currentUser == null) { return ResponseValue.error("鐧诲綍鐢ㄦ埛淇℃伅涓嶅瓨鍦�"); } - GenericPager<Map<String, Object>> transferInfoDetailsVoGenericPager = this.lWhFormTransferService.queryTransferInfo(transferQry); + GenericPager<Map<String, Object>> transferInfoDetailsVoGenericPager = this.lWhFormTransferService.queryTransferInfo(param); return ResponseValue.success(transferInfoDetailsVoGenericPager); } @@ -299,17 +355,22 @@ @ApiImplicitParam(name = "procureModelInfoDto", value = "浣跨敤淇℃伅", required = true) }) @PostMapping("/useInfo/update") - public ResponseValue infoUpdate(@RequestBody List<ProcureModelInfoParam> procureModelInfoParam) { + public ResponseValue infoUpdate() { + + RecordInfoParam param = CommonUtil.getObjFromReqBody(RecordInfoParam.class); + RecordInfoParam recordInfoParam = new RecordInfoParam(); + CommonUtil.copyProperties(param, recordInfoParam); + param = recordInfoParam; S_user_core currentUser = this.getCurrentUser(); if (currentUser == null) { return ResponseValue.error("鐧诲綍鐢ㄦ埛淇℃伅涓嶅瓨鍦�"); } - if (CollectionUtils.isEmpty(procureModelInfoParam)) { + if (CollectionUtils.isEmpty(param.getRecordInfoList())) { return ResponseValue.error("鍙傛暟閿欒"); } - Map<Long, List<ProcureModelInfoParam>> collect = procureModelInfoParam.stream() + Map<Long, List<ProcureModelInfoParam>> collect = param.getRecordInfoList().stream() .collect(Collectors.groupingBy(ProcureModelInfoParam::getBaseGoodModelId)); for (Map.Entry<Long, List<ProcureModelInfoParam>> entry : collect.entrySet()) { Long baseGoodModelId = entry.getKey(); @@ -328,7 +389,7 @@ lWhProcureModelUserRecordService.insert(lWhProcureModelUserRecord); List<LWhProcureModelUser> procureModelUserList = Lists.newArrayList(); - if (CollectionUtils.isEmpty(procureModelInfoList)) { + if (!CollectionUtils.isEmpty(procureModelInfoList)) { for (ProcureModelInfoParam item : procureModelInfoList) { LWhProcureModelUser lWhProcureModelUser = new LWhProcureModelUser(); lWhProcureModelUser.setId(IdUtil.generateId()); @@ -425,4 +486,17 @@ lWhFormTransferService.queryDepartmentTransferOrder(); return ResponseValue.success(transferInfoVO); } + + @ApiOperation(value = "鏌ヨ閮ㄩ棬涓嬬殑鍒嗗彂鍗�", notes = "鏌ヨ閮ㄩ棬涓嬬殑鍒嗗彂鍗�") + @ApiImplicitParams({ + @ApiImplicitParam(name = "agencyId", value = "鏈烘瀯id", required = true, dataType = "Long", paramType = "query") + }) + @GetMapping("/query/transfList") + public ResponseValue queryDepartmentTransferOrderList() { + + TransferInfoVO transferInfoVO = new TransferInfoVO(); + + lWhFormTransferService.queryDepartmentTransferOrder(); + return ResponseValue.success(transferInfoVO); + } } -- Gitblit v1.9.1