From b29a1cb6fbca3cf8cf1d307c4c519ae2047c9b18 Mon Sep 17 00:00:00 2001 From: zhangherong <571457620@qq.com> Date: 星期四, 04 九月 2025 15:43:13 +0800 Subject: [PATCH] art: 物料台账-相关接口修改 --- src/main/java/org/jeecg/modules/lsw/vo/MaterialInventoryStatisticsVO.java | 15 + src/main/java/org/jeecg/modules/lsw/mapper/LswMaterialMapper.java | 6 src/main/java/org/jeecg/modules/lsw/mapper/xml/LswMaterialMapper.xml | 15 - src/main/java/org/jeecg/modules/lsw/controller/LswMaterialController.java | 93 ---------- src/main/java/org/jeecg/modules/lsw/service/ILswMaterialInventoryService.java | 16 src/main/java/org/jeecg/modules/lsw/mapper/xml/LswMaterialInventoryMapper.xml | 22 +- /dev/null | 78 -------- src/main/java/org/jeecg/modules/lsw/controller/LswMaterialInventoryController.java | 193 +++++--------------- src/main/java/org/jeecg/modules/lsw/service/ILswMaterialService.java | 5 src/main/java/org/jeecg/modules/lsw/entity/LswMaterialInventory.java | 9 src/main/java/org/jeecg/modules/lsw/service/impl/LswMaterialInventoryServiceImpl.java | 11 src/main/java/org/jeecg/modules/lsw/service/impl/LswMaterialServiceImpl.java | 42 ---- src/main/java/org/jeecg/modules/lsw/mapper/LswMaterialInventoryMapper.java | 24 - 13 files changed, 109 insertions(+), 420 deletions(-) diff --git a/src/main/java/org/jeecg/modules/lsw/controller/LswMaterialController.java b/src/main/java/org/jeecg/modules/lsw/controller/LswMaterialController.java index 222c87a..40bf0cb 100644 --- a/src/main/java/org/jeecg/modules/lsw/controller/LswMaterialController.java +++ b/src/main/java/org/jeecg/modules/lsw/controller/LswMaterialController.java @@ -8,39 +8,22 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.apache.shiro.SecurityUtils; import org.jeecg.common.api.vo.Result; import org.jeecg.common.aspect.annotation.AutoLog; import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.exception.JeecgBootException; import org.jeecg.common.system.query.QueryGenerator; -import org.jeecg.common.system.vo.LoginUser; -import org.jeecg.common.util.oConvertUtils; import org.jeecg.modules.base.entity.Factory; -import org.jeecg.modules.base.entity.LineSideWarehouse; import org.jeecg.modules.base.enums.ProductionTypeEnum; import org.jeecg.modules.base.service.IFactoryService; -import org.jeecg.modules.base.service.ILineSideWarehouseService; import org.jeecg.modules.lsw.entity.LswMaterial; -import org.jeecg.modules.lsw.entity.LswMaterialInventory; import org.jeecg.modules.lsw.enums.MaterialCategoryEnum; -import org.jeecg.modules.lsw.service.ILswMaterialInventoryService; import org.jeecg.modules.lsw.service.ILswMaterialService; -import org.jeecg.modules.lsw.vo.LswMaterialPage; -import org.jeecgframework.poi.excel.def.NormalExcelConstants; -import org.jeecgframework.poi.excel.entity.ExportParams; -import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; -import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; -import java.util.ArrayList; -import java.util.Arrays; import java.util.List; -import java.util.Map; /** * @Description: 绾胯竟搴撶墿鏂欎俊鎭� @@ -55,10 +38,6 @@ public class LswMaterialController { @Autowired private ILswMaterialService lswMaterialService; - @Autowired - private ILswMaterialInventoryService lswMaterialInventoryService; - @Autowired - private ILineSideWarehouseService lineSideWarehouseService; @Autowired private IFactoryService factoryService; @@ -147,27 +126,6 @@ } - /** - * 閫氳繃id鏌ヨ - * - * @param id - * @return - */ - //@AutoLog(value = "鐗╂枡搴撳瓨淇℃伅閫氳繃涓昏〃ID鏌ヨ") - @ApiOperation(value = "鐗╂枡搴撳瓨淇℃伅涓昏〃ID鏌ヨ", notes = "鐗╂枡搴撳瓨淇℃伅-閫氫富琛↖D鏌ヨ") - @GetMapping(value = "/queryLswMaterialInventoryByMainId") - public Result<List<LswMaterialInventory>> queryLswMaterialInventoryListByMainId(@RequestParam(name = "id", required = true) String id) { - List<LswMaterialInventory> lswMaterialInventoryList = lswMaterialInventoryService.selectByMainId(id); - for (LswMaterialInventory lswMaterialInventory : lswMaterialInventoryList) { - if (StringUtils.isNotEmpty(lswMaterialInventory.getWarehouseId())) { - String warehouseId = lswMaterialInventory.getWarehouseId(); - LineSideWarehouse warehouse = lineSideWarehouseService.getById(warehouseId); - lswMaterialInventory.setWarehouseName(warehouse.getWarehouseName()); - } - } - return Result.OK(lswMaterialInventoryList); - } - @AutoLog(value = "绾胯竟搴撶墿鏂欎俊鎭�-閫氳繃浜х嚎绫诲瀷鏌ヨ绾胯竟搴撶墿鏂�") @ApiOperation(value = "绾胯竟搴撶墿鏂欎俊鎭�-閫氳繃浜х嚎绫诲瀷鏌ヨ绾胯竟搴撶墿鏂�", notes = "绾胯竟搴撶墿鏂欎俊鎭�-閫氳繃浜х嚎绫诲瀷鏌ヨ绾胯竟搴撶墿鏂�") @GetMapping(value = "/queryLswMaterialByProductionType") @@ -206,55 +164,4 @@ } return Result.OK(lswMaterialList); } - - /** - * 瀵煎嚭excel - * - * @param request - * @param lswMaterial - */ - //@RequiresPermissions("org.jeecg.modules:lsw_material:exportXls") - @RequestMapping(value = "/exportXls") - public ModelAndView exportXls(HttpServletRequest request, LswMaterial lswMaterial) { - // Step.1 缁勮鏌ヨ鏉′欢鏌ヨ鏁版嵁 - QueryWrapper<LswMaterial> queryWrapper = QueryGenerator.initQueryWrapper(lswMaterial, request.getParameterMap()); - LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - - //閰嶇疆閫変腑鏁版嵁鏌ヨ鏉′欢 - String selections = request.getParameter("selections"); - if (oConvertUtils.isNotEmpty(selections)) { - List<String> selectionList = Arrays.asList(selections.split(",")); - queryWrapper.in("id", selectionList); - } - //Step.2 鑾峰彇瀵煎嚭鏁版嵁 - List<LswMaterial> lswMaterialList = lswMaterialService.list(queryWrapper); - - // Step.3 缁勮pageList - List<LswMaterialPage> pageList = new ArrayList<LswMaterialPage>(); - for (LswMaterial main : lswMaterialList) { - LswMaterialPage vo = new LswMaterialPage(); - BeanUtils.copyProperties(main, vo); - List<LswMaterialInventory> lswMaterialInventoryList = lswMaterialInventoryService.selectByMainId(main.getId()); - vo.setLswMaterialInventoryList(lswMaterialInventoryList); - pageList.add(vo); - } - - // Step.4 AutoPoi 瀵煎嚭Excel - ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); - mv.addObject(NormalExcelConstants.FILE_NAME, "绾胯竟搴撶墿鏂欎俊鎭垪琛�"); - mv.addObject(NormalExcelConstants.CLASS, LswMaterialPage.class); - mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("绾胯竟搴撶墿鏂欎俊鎭暟鎹�", "瀵煎嚭浜�:" + sysUser.getRealname(), "绾胯竟搴撶墿鏂欎俊鎭�")); - mv.addObject(NormalExcelConstants.DATA_LIST, pageList); - return mv; - } - - @GetMapping(value = "/searchlikeQuery") - public Result<?> searchlikeQuery(LswMaterial lswMaterial, - @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, - @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, - HttpServletRequest req) { - IPage<Map<String, Object>> pageList = lswMaterialService.getLswMaterialListData(pageNo, pageSize, req); - return Result.OK(pageList); - } - } diff --git a/src/main/java/org/jeecg/modules/lsw/controller/LswMaterialInventoryController.java b/src/main/java/org/jeecg/modules/lsw/controller/LswMaterialInventoryController.java index 2a2f162..b24ab65 100644 --- a/src/main/java/org/jeecg/modules/lsw/controller/LswMaterialInventoryController.java +++ b/src/main/java/org/jeecg/modules/lsw/controller/LswMaterialInventoryController.java @@ -1,161 +1,74 @@ package org.jeecg.modules.lsw.controller; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import cn.hutool.core.collection.CollectionUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.jeecg.common.api.vo.Result; -import org.jeecg.common.aspect.annotation.AutoLog; import org.jeecg.common.system.base.controller.JeecgController; -import org.jeecg.common.system.query.QueryGenerator; import org.jeecg.modules.lsw.entity.LswMaterialInventory; +import org.jeecg.modules.lsw.enums.MaterialInventoryStatusEnum; import org.jeecg.modules.lsw.service.ILswMaterialInventoryService; +import org.jeecg.modules.lsw.vo.MaterialInventoryStatisticsVO; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.servlet.ModelAndView; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.util.Arrays; +import java.util.List; /** -* @Description: 鐗╂枡搴撳瓨淇℃伅 -* @Author: jeecg-boot -* @Date: 2025-06-30 -* @Version: V1.0 -*/ -@Api(tags="鐗╂枡搴撳瓨淇℃伅") + * @Description: 鐗╂枡搴撳瓨淇℃伅 + * @Author: jeecg-boot + * @Date: 2025-06-30 + * @Version: V1.0 + */ +@Api(tags = "鐗╂枡搴撳瓨淇℃伅") @RestController -@RequestMapping("/lswmaterialinventory/lswMaterialInventory") +@RequestMapping("/lsw/materialInventory") @Slf4j public class LswMaterialInventoryController extends JeecgController<LswMaterialInventory, ILswMaterialInventoryService> { - @Autowired - private ILswMaterialInventoryService lswMaterialInventoryService; + @Autowired + private ILswMaterialInventoryService lswMaterialInventoryService; - /** - * 鍒嗛〉鍒楄〃鏌ヨ - * - * @param lswMaterialInventory - * @param pageNo - * @param pageSize - * @param req - * @return - */ - //@AutoLog(value = "鐗╂枡搴撳瓨淇℃伅-鍒嗛〉鍒楄〃鏌ヨ") - @ApiOperation(value="鐗╂枡搴撳瓨淇℃伅-鍒嗛〉鍒楄〃鏌ヨ", notes="鐗╂枡搴撳瓨淇℃伅-鍒嗛〉鍒楄〃鏌ヨ") - @GetMapping(value = "/list") - public Result<IPage<LswMaterialInventory>> queryPageList(LswMaterialInventory lswMaterialInventory, - @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, - @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, - HttpServletRequest req) { - QueryWrapper<LswMaterialInventory> queryWrapper = QueryGenerator.initQueryWrapper(lswMaterialInventory, req.getParameterMap()); - Page<LswMaterialInventory> page = new Page<LswMaterialInventory>(pageNo, pageSize); - IPage<LswMaterialInventory> pageList = lswMaterialInventoryService.page(page, queryWrapper); - return Result.OK(pageList); - } + /** + * 鍒嗛〉鍒楄〃鏌ヨ + * + * @param materialId + * @param pageNo + * @param pageSize + * @return + */ + @ApiOperation(value = "鐗╂枡搴撳瓨淇℃伅-鍒嗛〉鍒楄〃鏌ヨ", notes = "鐗╂枡搴撳瓨淇℃伅-鍒嗛〉鍒楄〃鏌ヨ") + @GetMapping(value = "/list") + public Result<IPage<LswMaterialInventory>> queryPageList(@RequestParam(name = "materialId") String materialId, + @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { + LambdaQueryWrapper<LswMaterialInventory> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(LswMaterialInventory::getMaterialId, materialId); + queryWrapper.eq(LswMaterialInventory::getInventoryStatus, MaterialInventoryStatusEnum.NORMAL.name()); + queryWrapper.orderByDesc(LswMaterialInventory::getCreateTime); + Page<LswMaterialInventory> page = new Page<LswMaterialInventory>(pageNo, pageSize); + IPage<LswMaterialInventory> pageList = lswMaterialInventoryService.page(page, queryWrapper); + return Result.OK(pageList); + } - /** - * 娣诲姞 - * - * @param lswMaterialInventory - * @return - */ - @AutoLog(value = "鐗╂枡搴撳瓨淇℃伅-娣诲姞") - @ApiOperation(value="鐗╂枡搴撳瓨淇℃伅-娣诲姞", notes="鐗╂枡搴撳瓨淇℃伅-娣诲姞") - //@RequiresPermissions("org.jeecg.modules:lsw_material_inventory:add") - @PostMapping(value = "/add") - public Result<String> add(@RequestBody LswMaterialInventory lswMaterialInventory) { - lswMaterialInventoryService.save(lswMaterialInventory); - return Result.OK("娣诲姞鎴愬姛锛�"); - } - - /** - * 缂栬緫 - * - * @param lswMaterialInventory - * @return - */ - @AutoLog(value = "鐗╂枡搴撳瓨淇℃伅-缂栬緫") - @ApiOperation(value="鐗╂枡搴撳瓨淇℃伅-缂栬緫", notes="鐗╂枡搴撳瓨淇℃伅-缂栬緫") - //@RequiresPermissions("org.jeecg.modules:lsw_material_inventory:edit") - @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) - public Result<String> edit(@RequestBody LswMaterialInventory lswMaterialInventory) { - lswMaterialInventoryService.updateById(lswMaterialInventory); - return Result.OK("缂栬緫鎴愬姛!"); - } - - /** - * 閫氳繃id鍒犻櫎 - * - * @param id - * @return - */ - @AutoLog(value = "鐗╂枡搴撳瓨淇℃伅-閫氳繃id鍒犻櫎") - @ApiOperation(value="鐗╂枡搴撳瓨淇℃伅-閫氳繃id鍒犻櫎", notes="鐗╂枡搴撳瓨淇℃伅-閫氳繃id鍒犻櫎") - //@RequiresPermissions("org.jeecg.modules:lsw_material_inventory:delete") - @DeleteMapping(value = "/delete") - public Result<String> delete(@RequestParam(name="id",required=true) String id) { - lswMaterialInventoryService.removeById(id); - return Result.OK("鍒犻櫎鎴愬姛!"); - } - - /** - * 鎵归噺鍒犻櫎 - * - * @param ids - * @return - */ - @AutoLog(value = "鐗╂枡搴撳瓨淇℃伅-鎵归噺鍒犻櫎") - @ApiOperation(value="鐗╂枡搴撳瓨淇℃伅-鎵归噺鍒犻櫎", notes="鐗╂枡搴撳瓨淇℃伅-鎵归噺鍒犻櫎") - //@RequiresPermissions("org.jeecg.modules:lsw_material_inventory:deleteBatch") - @DeleteMapping(value = "/deleteBatch") - public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) { - this.lswMaterialInventoryService.removeByIds(Arrays.asList(ids.split(","))); - return Result.OK("鎵归噺鍒犻櫎鎴愬姛!"); - } - - /** - * 閫氳繃id鏌ヨ - * - * @param id - * @return - */ - //@AutoLog(value = "鐗╂枡搴撳瓨淇℃伅-閫氳繃id鏌ヨ") - @ApiOperation(value="鐗╂枡搴撳瓨淇℃伅-閫氳繃id鏌ヨ", notes="鐗╂枡搴撳瓨淇℃伅-閫氳繃id鏌ヨ") - @GetMapping(value = "/queryById") - public Result<LswMaterialInventory> queryById(@RequestParam(name="id",required=true) String id) { - LswMaterialInventory lswMaterialInventory = lswMaterialInventoryService.getById(id); - if(lswMaterialInventory==null) { - return Result.error("鏈壘鍒板搴旀暟鎹�"); - } - return Result.OK(lswMaterialInventory); - } - - /** - * 瀵煎嚭excel - * - * @param request - * @param lswMaterialInventory - */ - //@RequiresPermissions("org.jeecg.modules:lsw_material_inventory:exportXls") - @RequestMapping(value = "/exportXls") - public ModelAndView exportXls(HttpServletRequest request, LswMaterialInventory lswMaterialInventory) { - return super.exportXls(request, lswMaterialInventory, LswMaterialInventory.class, "鐗╂枡搴撳瓨淇℃伅"); - } - - /** - * 閫氳繃excel瀵煎叆鏁版嵁 - * - * @param request - * @param response - * @return - */ - //@RequiresPermissions("lsw_material_inventory:importExcel") - @RequestMapping(value = "/importExcel", method = RequestMethod.POST) - public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { - return super.importExcel(request, response, LswMaterialInventory.class); - } - + @ApiOperation(value = "鐗╂枡搴撳瓨淇℃伅-缁熻鍚勭嚎杈瑰簱鐗╂枡涓暟", notes = "鐗╂枡搴撳瓨淇℃伅-缁熻鍚勭嚎杈瑰簱鐗╂枡涓暟") + @GetMapping(value = "/statisticsInventory") + public Result<String> statisticsInventory(@RequestParam(name = "materialId") String materialId) { + //搴撳瓨缁熻鏁伴噺 + List<MaterialInventoryStatisticsVO> list = lswMaterialInventoryService.statisticsInventory(materialId); + if(CollectionUtil.isEmpty(list)){ + return Result.OK("0"); + } + StringBuilder sb = new StringBuilder(); + for(MaterialInventoryStatisticsVO vo : list){ + sb.append(vo.getWarehouseName()).append(": ").append(vo.getMaterialQuantity().stripTrailingZeros().toPlainString()).append(" | "); + } + return Result.OK(sb.toString()); + } } diff --git a/src/main/java/org/jeecg/modules/lsw/entity/LswMaterialInventory.java b/src/main/java/org/jeecg/modules/lsw/entity/LswMaterialInventory.java index 73d6730..3d2a8ba 100644 --- a/src/main/java/org/jeecg/modules/lsw/entity/LswMaterialInventory.java +++ b/src/main/java/org/jeecg/modules/lsw/entity/LswMaterialInventory.java @@ -60,22 +60,21 @@ /**搴撳瓨绫诲瀷*/ @Excel(name = "搴撳瓨绫诲瀷", width = 15) @ApiModelProperty(value = "搴撳瓨绫诲瀷") + @Dict(dicCode = "material_inventory_category") private String inventoryCategory; /**鏁伴噺*/ @Excel(name = "鏁伴噺", width = 15) @ApiModelProperty(value = "鏁伴噺") private BigDecimal quantity; /**搴撳瓨鍦癐D*/ - @Excel(name = "搴撳瓨鍦癐D", width = 15) + @Excel(name = "搴撳瓨鍦�", width = 15) @Dict(dictTable = "base_line_side_warehouse", dicCode = "id", dicText = "warehouse_name") - @ApiModelProperty(value = "搴撳瓨鍦癐D") - private String warehouseId; - @TableField(exist = false) @ApiModelProperty(value = "搴撳瓨鍦�") - private String warehouseName; + private String warehouseId; /**搴撳瓨鐘舵��*/ @Excel(name = "搴撳瓨鐘舵��", width = 15) @ApiModelProperty(value = "搴撳瓨鐘舵��") + @Dict(dicCode = "material_inventory_status") private String inventoryStatus; public LswMaterialInventory(){} diff --git a/src/main/java/org/jeecg/modules/lsw/mapper/LswMaterialInventoryMapper.java b/src/main/java/org/jeecg/modules/lsw/mapper/LswMaterialInventoryMapper.java index b755fe5..ff096c2 100644 --- a/src/main/java/org/jeecg/modules/lsw/mapper/LswMaterialInventoryMapper.java +++ b/src/main/java/org/jeecg/modules/lsw/mapper/LswMaterialInventoryMapper.java @@ -4,6 +4,7 @@ import org.apache.ibatis.annotations.Param; import org.jeecg.modules.lsw.entity.LswMaterialInventory; import org.jeecg.modules.lsw.vo.LswMaterialInventoryVo; +import org.jeecg.modules.lsw.vo.MaterialInventoryStatisticsVO; import java.util.List; @@ -15,22 +16,13 @@ */ public interface LswMaterialInventoryMapper extends BaseMapper<LswMaterialInventory> { - /** - * 閫氳繃涓昏〃id鍒犻櫎瀛愯〃鏁版嵁 - * - * @param mainId 涓昏〃id - * @return boolean - */ - public boolean deleteByMainId(@Param("mainId") String mainId); - - /** - * 閫氳繃涓昏〃id鏌ヨ瀛愯〃鏁版嵁 - * - * @param mainId 涓昏〃id - * @return List<LswMaterialInventory> - */ - public List<LswMaterialInventory> selectByMainId(@Param("mainId") String mainId); - List<LswMaterialInventoryVo> selectLineSideMaterialInventoryByMaterialNumber(@Param("materialNumberList") List<String> bomMaterialNumberList, @Param("factoryId") String factoryId); + + /** + * 搴撳瓨缁熻 + * @param materialId + * @return + */ + List<MaterialInventoryStatisticsVO> statisticsInventory(@Param("materialId") String materialId); } diff --git a/src/main/java/org/jeecg/modules/lsw/mapper/LswMaterialMapper.java b/src/main/java/org/jeecg/modules/lsw/mapper/LswMaterialMapper.java index 194b9c9..db4a787 100644 --- a/src/main/java/org/jeecg/modules/lsw/mapper/LswMaterialMapper.java +++ b/src/main/java/org/jeecg/modules/lsw/mapper/LswMaterialMapper.java @@ -1,11 +1,7 @@ package org.jeecg.modules.lsw.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import org.apache.ibatis.annotations.Param; import org.jeecg.modules.lsw.entity.LswMaterial; - -import java.util.Map; /** * @Description: 绾胯竟搴撶墿鏂欎俊鎭� @@ -14,5 +10,5 @@ * @Version: V1.0 */ public interface LswMaterialMapper extends BaseMapper<LswMaterial> { - IPage<Map<String, Object>> getLswMaterialListData(IPage<Map> pageData, @Param("params")Map<String, String> paramMap); + } diff --git a/src/main/java/org/jeecg/modules/lsw/mapper/xml/LswMaterialInventoryMapper.xml b/src/main/java/org/jeecg/modules/lsw/mapper/xml/LswMaterialInventoryMapper.xml index ef93fbc..e7ca719 100644 --- a/src/main/java/org/jeecg/modules/lsw/mapper/xml/LswMaterialInventoryMapper.xml +++ b/src/main/java/org/jeecg/modules/lsw/mapper/xml/LswMaterialInventoryMapper.xml @@ -1,18 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="org.jeecg.modules.lsw.mapper.LswMaterialInventoryMapper"> - - <delete id="deleteByMainId" parameterType="java.lang.String"> - DELETE - FROM lsw_material_inventory - WHERE - material_id = #{mainId} </delete> - - <select id="selectByMainId" parameterType="java.lang.String" resultType="org.jeecg.modules.lsw.entity.LswMaterialInventory"> - SELECT * - FROM lsw_material_inventory - WHERE - material_id = #{mainId} </select> <select id="selectLineSideMaterialInventoryByMaterialNumber" resultType="org.jeecg.modules.lsw.vo.LswMaterialInventoryVo"> SELECT @@ -31,4 +19,14 @@ t1.material_number, t1.material_name </select> + <select id="statisticsInventory" resultType="org.jeecg.modules.lsw.vo.MaterialInventoryStatisticsVO"> + select m1.warehouse_id, m2.warehouse_name, m1.materialQuantity + from (select warehouse_id, SUM(quantity) as materialQuantity + from lsw_material_inventory + where material_id = #{materialId} + and inventory_status = 'NORMAL' + group by warehouse_id) m1 + left join base_line_side_warehouse m2 on m1.warehouse_id = m2.id + + </select> </mapper> diff --git a/src/main/java/org/jeecg/modules/lsw/mapper/xml/LswMaterialMapper.xml b/src/main/java/org/jeecg/modules/lsw/mapper/xml/LswMaterialMapper.xml index 3b6fcef..885483d 100644 --- a/src/main/java/org/jeecg/modules/lsw/mapper/xml/LswMaterialMapper.xml +++ b/src/main/java/org/jeecg/modules/lsw/mapper/xml/LswMaterialMapper.xml @@ -1,19 +1,4 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="org.jeecg.modules.lsw.mapper.LswMaterialMapper"> - <select id="getLswMaterialListData" parameterType="Map" resultType="Map"> - select * from lsw_material WHERE 1=1 - <if test="params.materialNumber != null and params.materialNumber != ''"> - AND material_number LIKE CONCAT('%', #{params.materialNumber}, '%') - </if> - <if test="params.materialName != null and params.materialName != ''"> - AND material_name LIKE CONCAT('%', #{params.materialName}, '%') - </if> - <if test="params.materialModel != null and params.materialModel != ''"> - AND material_model LIKE CONCAT('%', #{params.materialModel}, '%') - </if> - <if test="params.materialCategory != null and params.materialCategory != ''"> - AND material_category = #{params.materialCategory} - </if> - </select> </mapper> \ No newline at end of file diff --git a/src/main/java/org/jeecg/modules/lsw/service/ILswMaterialInventoryService.java b/src/main/java/org/jeecg/modules/lsw/service/ILswMaterialInventoryService.java index b7601f8..0dd1bf4 100644 --- a/src/main/java/org/jeecg/modules/lsw/service/ILswMaterialInventoryService.java +++ b/src/main/java/org/jeecg/modules/lsw/service/ILswMaterialInventoryService.java @@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import org.jeecg.modules.lsw.entity.LswMaterialInventory; import org.jeecg.modules.lsw.vo.LswMaterialInventoryVo; +import org.jeecg.modules.lsw.vo.MaterialInventoryStatisticsVO; import java.util.List; @@ -13,14 +14,13 @@ * @Version: V1.0 */ public interface ILswMaterialInventoryService extends IService<LswMaterialInventory> { - - /** - * 閫氳繃涓昏〃id鏌ヨ瀛愯〃鏁版嵁 - * - * @param mainId 涓昏〃id - * @return List<LswMaterialInventory> - */ - public List<LswMaterialInventory> selectByMainId(String mainId); /** 閫氳繃鐗╂枡缂栫爜鍜岀嚎杈瑰簱id鏌ヨ鐗╂枡搴撳瓨 */ List<LswMaterialInventoryVo> selectLineSideMaterialInventoryByMaterialNumber(List<String> bomMaterialNumberList, String factoryId); + + /** + * 搴撳瓨缁熻 + * @param materialId 鐗╂枡ID + * @return + */ + List<MaterialInventoryStatisticsVO> statisticsInventory(String materialId); } diff --git a/src/main/java/org/jeecg/modules/lsw/service/ILswMaterialService.java b/src/main/java/org/jeecg/modules/lsw/service/ILswMaterialService.java index ab49739..0698d51 100644 --- a/src/main/java/org/jeecg/modules/lsw/service/ILswMaterialService.java +++ b/src/main/java/org/jeecg/modules/lsw/service/ILswMaterialService.java @@ -1,12 +1,10 @@ package org.jeecg.modules.lsw.service; -import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import org.jeecg.modules.lsw.entity.LswMaterial; import org.jeecg.modules.mes.entity.MesProductionOrder; import org.jeecg.modules.sap.dto.OrderBomDTO; -import javax.servlet.http.HttpServletRequest; import java.util.List; import java.util.Map; @@ -17,9 +15,6 @@ * @Version: V1.0 */ public interface ILswMaterialService extends IService<LswMaterial> { - - - IPage<Map<String, Object>> getLswMaterialListData(Integer pageNo, Integer pageSize, HttpServletRequest req); /** * 缂栬緫鐗╂枡淇℃伅 diff --git a/src/main/java/org/jeecg/modules/lsw/service/impl/LswMaterialInventoryServiceImpl.java b/src/main/java/org/jeecg/modules/lsw/service/impl/LswMaterialInventoryServiceImpl.java index fc0a4da..127cfb7 100644 --- a/src/main/java/org/jeecg/modules/lsw/service/impl/LswMaterialInventoryServiceImpl.java +++ b/src/main/java/org/jeecg/modules/lsw/service/impl/LswMaterialInventoryServiceImpl.java @@ -5,6 +5,7 @@ import org.jeecg.modules.lsw.mapper.LswMaterialInventoryMapper; import org.jeecg.modules.lsw.service.ILswMaterialInventoryService; import org.jeecg.modules.lsw.vo.LswMaterialInventoryVo; +import org.jeecg.modules.lsw.vo.MaterialInventoryStatisticsVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -22,14 +23,14 @@ @Autowired private LswMaterialInventoryMapper lswMaterialInventoryMapper; - - @Override - public List<LswMaterialInventory> selectByMainId(String mainId) { - return lswMaterialInventoryMapper.selectByMainId(mainId); - } @Override public List<LswMaterialInventoryVo> selectLineSideMaterialInventoryByMaterialNumber(List<String> bomMaterialNumberList, String factoryId) { return lswMaterialInventoryMapper.selectLineSideMaterialInventoryByMaterialNumber(bomMaterialNumberList, factoryId); } + + @Override + public List<MaterialInventoryStatisticsVO> statisticsInventory(String materialId) { + return lswMaterialInventoryMapper.statisticsInventory(materialId); + } } diff --git a/src/main/java/org/jeecg/modules/lsw/service/impl/LswMaterialServiceImpl.java b/src/main/java/org/jeecg/modules/lsw/service/impl/LswMaterialServiceImpl.java index 3590878..f9f93f1 100644 --- a/src/main/java/org/jeecg/modules/lsw/service/impl/LswMaterialServiceImpl.java +++ b/src/main/java/org/jeecg/modules/lsw/service/impl/LswMaterialServiceImpl.java @@ -2,28 +2,21 @@ import cn.hutool.core.collection.CollectionUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.apache.commons.lang.StringUtils; import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.exception.JeecgBootException; import org.jeecg.modules.lsw.entity.LswMaterial; -import org.jeecg.modules.lsw.entity.LswMaterialInventory; -import org.jeecg.modules.lsw.mapper.LswMaterialInventoryMapper; import org.jeecg.modules.lsw.mapper.LswMaterialMapper; import org.jeecg.modules.lsw.service.ILswMaterialService; import org.jeecg.modules.mes.entity.MesProductionOrder; -import org.jeecg.modules.pms.entity.PmsProcessBillMaterials; import org.jeecg.modules.sap.dto.OrderBomDTO; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import javax.servlet.http.HttpServletRequest; -import java.io.Serializable; -import java.util.*; -import java.util.stream.Collectors; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * @Description: 绾胯竟搴撶墿鏂欎俊鎭� @@ -33,33 +26,6 @@ */ @Service public class LswMaterialServiceImpl extends ServiceImpl<LswMaterialMapper, LswMaterial> implements ILswMaterialService { - - @Autowired - private LswMaterialMapper lswMaterialMapper; - @Autowired - private LswMaterialInventoryMapper lswMaterialInventoryMapper; - - @Override - public IPage<Map<String, Object>> getLswMaterialListData(Integer pageNo, Integer pageSize, HttpServletRequest req) { - IPage<Map> pageData = new Page<Map>(pageNo, pageSize); - Map<String, String> paramMap = new HashMap<String, String>(); - Map<String, String[]> parameterMap = req.getParameterMap(); - if (null != parameterMap) { - if (parameterMap.containsKey("materialNumber") && StringUtils.isNotBlank(parameterMap.get("materialNumber")[0])) { - paramMap.put("materialNumber", parameterMap.get("materialNumber")[0]); - } - if (parameterMap.containsKey("materialName") && StringUtils.isNotBlank(parameterMap.get("materialName")[0])) { - paramMap.put("materialName", parameterMap.get("materialName")[0].trim()); - } - if (parameterMap.containsKey("materialModel") && StringUtils.isNotBlank(parameterMap.get("materialModel")[0])) { - paramMap.put("materialModel", parameterMap.get("materialModel")[0].trim()); - } - if (parameterMap.containsKey("materialCategory") && StringUtils.isNotBlank(parameterMap.get("materialCategory")[0])) { - paramMap.put("materialCategory", parameterMap.get("materialCategory")[0].trim()); - } - } - return super.getBaseMapper().getLswMaterialListData(pageData, paramMap); - } @Override @Transactional(rollbackFor = Exception.class) diff --git a/src/main/java/org/jeecg/modules/lsw/vo/LswMaterialPage.java b/src/main/java/org/jeecg/modules/lsw/vo/LswMaterialPage.java deleted file mode 100644 index 44d8f6c..0000000 --- a/src/main/java/org/jeecg/modules/lsw/vo/LswMaterialPage.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.jeecg.modules.lsw.vo; - -import com.fasterxml.jackson.annotation.JsonFormat; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import org.jeecg.common.aspect.annotation.Dict; -import org.jeecg.modules.lsw.entity.LswMaterialInventory; -import org.jeecgframework.poi.excel.annotation.Excel; -import org.jeecgframework.poi.excel.annotation.ExcelCollection; -import org.springframework.format.annotation.DateTimeFormat; - -import java.util.Date; -import java.util.List; - -/** - * @Description: 绾胯竟搴撶墿鏂欎俊鎭� - * @Author: jeecg-boot - * @Date: 2025-06-30 - * @Version: V1.0 - */ -@Data -@ApiModel(value="lsw_materialPage瀵硅薄", description="绾胯竟搴撶墿鏂欎俊鎭�") -public class LswMaterialPage { - - /**涓婚敭*/ - @ApiModelProperty(value = "涓婚敭") - private String id; - /**鍒涘缓浜�*/ - @ApiModelProperty(value = "鍒涘缓浜�") - private String createBy; - /**鍒涘缓鏃ユ湡*/ - @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") - @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") - @ApiModelProperty(value = "鍒涘缓鏃ユ湡") - private Date createTime; - /**鏇存柊浜�*/ - @ApiModelProperty(value = "鏇存柊浜�") - private String updateBy; - /**鏇存柊鏃ユ湡*/ - @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") - @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") - @ApiModelProperty(value = "鏇存柊鏃ユ湡") - private Date updateTime; - /**鎵�灞為儴闂�*/ - @ApiModelProperty(value = "鎵�灞為儴闂�") - private String sysOrgCode; - /**鍒犻櫎鏍囪*/ - @Excel(name = "鍒犻櫎鏍囪", width = 15) - @ApiModelProperty(value = "鍒犻櫎鏍囪") - private Integer delFlag; - /**鐗╂枡缂栫爜*/ - @Excel(name = "鐗╂枡缂栫爜", width = 15) - @ApiModelProperty(value = "鐗╂枡缂栫爜") - private String materialNumber; - /**鐗╂枡鍚嶇О*/ - @Excel(name = "鐗╂枡鍚嶇О", width = 15) - @ApiModelProperty(value = "鐗╂枡鍚嶇О") - private String materialName; - /**鐗╂枡鍨嬪彿*/ - @Excel(name = "鐗╂枡鍨嬪彿", width = 15) - @ApiModelProperty(value = "鐗╂枡鍨嬪彿") - private String materialModel; - /**鐗╂枡绫诲瀷*/ - @Excel(name = "鐗╂枡绫诲瀷", width = 15, dicCode = "material_category") - @Dict(dicCode = "material_category") - @ApiModelProperty(value = "鐗╂枡绫诲瀷") - private String materialCategory; - /**鍗曚綅*/ - @Excel(name = "鍗曚綅", width = 15) - @ApiModelProperty(value = "鍗曚綅") - private String materialUnit; - - @ExcelCollection(name="鐗╂枡搴撳瓨淇℃伅") - @ApiModelProperty(value = "鐗╂枡搴撳瓨淇℃伅") - private List<LswMaterialInventory> lswMaterialInventoryList; - -} diff --git a/src/main/java/org/jeecg/modules/lsw/vo/MaterialInventoryStatisticsVO.java b/src/main/java/org/jeecg/modules/lsw/vo/MaterialInventoryStatisticsVO.java new file mode 100644 index 0000000..d85ccc8 --- /dev/null +++ b/src/main/java/org/jeecg/modules/lsw/vo/MaterialInventoryStatisticsVO.java @@ -0,0 +1,15 @@ +package org.jeecg.modules.lsw.vo; + +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class MaterialInventoryStatisticsVO { + //搴撳瓨鍦癐D + private String warehouseId; + //搴撳瓨鍦板悕绉� + private String warehouseName; + //搴撳瓨鎬绘暟 + private BigDecimal materialQuantity; +} -- Gitblit v1.9.3