From 57e4c84559bd9fc7fe2bd9319e9e19fb855eb988 Mon Sep 17 00:00:00 2001 From: pengyongcheng <pyc_1215@163.com> Date: Thu, 22 Feb 2024 15:05:47 +0800 Subject: [PATCH] 报表:库存分类报表 --- ant-design-vue-jeecg/src/views/system/report/ReportInventoryClassificationList.vue | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/mapper/InventoryDetailMapper.java | 12 ++++++++++-- huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/mapper/xml/InventoryDetailMapper.xml | 24 ++++++++++++++++++++---- huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/service/IInventoryDetailService.java | 12 +++++++++++- huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/service/impl/InventoryDetailServiceImpl.java | 6 ++++++ huaheng-wms-core/src/main/java/org/jeecg/modules/wms/report/controller/ReportController.java | 24 ++++++++++++++++++++++++ huaheng-wms-core/src/main/java/org/jeecg/modules/wms/report/dto/ReportInventoryClassificationDto.java | 28 ++++++++++++++++++++++++++++ 7 files changed, 267 insertions(+), 7 deletions(-) create mode 100644 ant-design-vue-jeecg/src/views/system/report/ReportInventoryClassificationList.vue create mode 100644 huaheng-wms-core/src/main/java/org/jeecg/modules/wms/report/dto/ReportInventoryClassificationDto.java diff --git a/ant-design-vue-jeecg/src/views/system/report/ReportInventoryClassificationList.vue b/ant-design-vue-jeecg/src/views/system/report/ReportInventoryClassificationList.vue new file mode 100644 index 0000000..445569b --- /dev/null +++ b/ant-design-vue-jeecg/src/views/system/report/ReportInventoryClassificationList.vue @@ -0,0 +1,168 @@ +<template> + <a-card :bordered="false"> + <!-- 查询区域 --> + <div class="table-page-search-wrapper"> + <a-form layout="inline" @keyup.enter.native="searchQuery"> + <a-row :gutter="24"> + <a-col :xl="6" :lg="7" :md="8" :sm="24"> + <a-form-item label="物料类别"> + <a-select + show-search + placeholder="请选择物料类别" + option-filter-prop="children" + v-model="queryParam.materialTypeCode"> + <a-select-option v-for="item in materialTypeList" :key="item.code" :value="item.code"> + {{ item.code }} {{ item.name }} + </a-select-option> + </a-select> + </a-form-item> + </a-col> + <a-col :xl="6" :lg="7" :md="8" :sm="24"> + <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons"> + <a-button id="search" type="primary" @click="searchQuery" icon="search">查询</a-button> + <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button> + </span> + </a-col> + </a-row> + </a-form> + </div> + <!-- 查询区域-END --> + <!-- table区域-begin --> + <div> + <a-table + ref="table" + size="middle" + :scroll="{x:true}" + bordered + rowKey="id" + :columns="columns" + :dataSource="dataSource" + :pagination="ipagination" + :loading="loading" + class="j-table-force-nowrap" + @change="handleTableChange"> + + <span slot="zoneCode" slot-scope="zoneCode"> + <a-tag :key="zoneCode" color="blue"> + {{ solutionZoneCode(zoneCode) }} + </a-tag> + </span> + <template slot="htmlSlot" slot-scope="text"> + <div v-html="text"></div> + </template> + </a-table> + </div> + </a-card> +</template> + +<script> + +import '@/assets/less/TableExpand.less' +import {mixinDevice} from '@/utils/mixin' +import {JeecgListMixin} from '@/mixins/JeecgListMixin' +import {getMaterialTypeList, getZoneList} from '@/api/api' + +export default { + name: 'ReportInventoryClassificationList', + mixins: [JeecgListMixin, mixinDevice], + components: {}, + data() { + return { + description: '库存分类报表页面', + zoneList: [], + zoneOptions: [], + materialTypeList: [], + firstLoad: 0, + // 表头 + columns: [ + { + title: '#', + dataIndex: '', + key: 'rowIndex', + width: 60, + align: 'center', + customRender: function (t, r, index) { + return parseInt(index) + 1 + } + }, + { + title: '库存分类编码', + align: "center", + dataIndex: 'materialTypeCode' + }, + { + title: '库存分类名称', + align: "center", + dataIndex: 'materialTypeName' + }, + { + title: '库存数量', + align: "center", + dataIndex: 'qty' + } + ], + url: { + list: "/report/listInventoryClassification", + }, + } + }, + created() { + this.loadFrom(); + }, + mounted() { + if (this.firstLoad === 0) { + this.firstLoad = 1; + return; + } + //页面没加载完,此时methods里的方法找不到,使用定时器模拟点击 + let timeSearch = setInterval(() => { + let eleSearch = document.getElementById("search"); + if (eleSearch != null) { + //调用成功,清除定时器 + clearInterval(timeSearch) + eleSearch.click(); + } + }, 200) + }, + computed: { + importExcelUrl: function () { + return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`; + }, + }, + methods: { + loadFrom() { + getMaterialTypeList().then((res) => { + if (res.success) { + this.materialTypeList = res.result + } + }); + getZoneList().then((res) => { + if (res.success) { + this.zoneList = res.result + //延迟半秒执行,避免组件未加载完,数据已经加载完 + setTimeout(() => { + //slice可以在数组的任何位置进行删除/添加操作 + this.zoneOptions.splice(0, 1); + for (const element of res.result) { + this.zoneOptions.push({value: element.code, text: element.name}) + } + }, 500) + } + }); + }, + solutionZoneCode(value) { + let actions = [] + Object.keys(this.zoneList).some(key => { + if (this.zoneList[key].code === '' + value) { + actions.push(this.zoneList[key].name) + return true + } + }) + return actions.join('') + } + } +} +</script> +<style scoped> +@import '~@assets/less/common.less'; +</style> \ No newline at end of file diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/mapper/InventoryDetailMapper.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/mapper/InventoryDetailMapper.java index 212ab6d..aee2119 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/mapper/InventoryDetailMapper.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/mapper/InventoryDetailMapper.java @@ -4,6 +4,7 @@ import java.util.List; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Param; import org.jeecg.modules.wms.inventory.inventoryHeader.entity.InventoryDetail; +import org.jeecg.modules.wms.report.dto.ReportInventoryClassificationDto; /** * @Description: 库存详情 @@ -13,8 +14,15 @@ import org.jeecg.modules.wms.inventory.inventoryHeader.entity.InventoryDetail; */ public interface InventoryDetailMapper extends BaseMapper<InventoryDetail> { - public boolean deleteByMainId(@Param("mainId") String mainId); + boolean deleteByMainId(@Param("mainId") String mainId); - public List<InventoryDetail> selectByMainId(@Param("mainId") String mainId); + List<InventoryDetail> selectByMainId(@Param("mainId") String mainId); + /** + * 库存分类报表查询 + * + * @param materialTypeCode 物料类别编码 + * @return 库存分类报表信息 + */ + List<ReportInventoryClassificationDto> selectReportClassification(@Param("materialTypeCode") String materialTypeCode); } diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/mapper/xml/InventoryDetailMapper.xml b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/mapper/xml/InventoryDetailMapper.xml index ac6b46a..af717b1 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/mapper/xml/InventoryDetailMapper.xml +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/mapper/xml/InventoryDetailMapper.xml @@ -4,13 +4,29 @@ <delete id="deleteByMainId" parameterType="java.lang.String"> DELETE - FROM inventory_detail - WHERE inventory_header_id = #{mainId} + FROM inventory_detail + WHERE inventory_header_id = #{mainId} </delete> <select id="selectByMainId" parameterType="java.lang.String" resultType="org.jeecg.modules.wms.inventory.inventoryHeader.entity.InventoryDetail"> SELECT * - FROM inventory_detail - WHERE inventory_header_id = #{mainId} + FROM inventory_detail + WHERE inventory_header_id = #{mainId} + </select> + + <select id="selectReportClassification" + resultType="org.jeecg.modules.wms.report.dto.ReportInventoryClassificationDto"> + SELECT + material_type.code as materialTypeCode, + material_type.name as materialTypeName, + SUM(inventory_detail.qty) as qty + FROM + inventory_detail + LEFT JOIN material ON material.`code` = inventory_detail.material_code + LEFT JOIN material_type ON material.type = material_type.code + <if test="materialTypeCode != null and materialTypeCode != ''"> + WHERE material.type = #{materialTypeCode} + </if> + GROUP BY type </select> </mapper> diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/service/IInventoryDetailService.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/service/IInventoryDetailService.java index 096c013..4319517 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/service/IInventoryDetailService.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/service/IInventoryDetailService.java @@ -2,6 +2,7 @@ package org.jeecg.modules.wms.inventory.inventoryHeader.service; import java.math.BigDecimal; import java.util.List; +import java.util.Map; import org.jeecg.common.api.vo.Result; import org.jeecg.modules.wms.inventory.inventoryHeader.entity.InventoryDetail; @@ -10,6 +11,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.modules.wms.report.dto.ReportInventoryClassificationDto; /** * @Description: 库存详情 @@ -19,7 +21,7 @@ import com.baomidou.mybatisplus.extension.service.IService; */ public interface IInventoryDetailService extends IService<InventoryDetail> { - public List<InventoryDetail> selectByMainId(String mainId); + List<InventoryDetail> selectByMainId(String mainId); List<InventoryDetail> getInventoryDetailListByInventoryHeaderId(Integer inventoryHeaderId); @@ -130,4 +132,12 @@ public interface IInventoryDetailService extends IService<InventoryDetail> { * @return */ Result reduceInventoryDetail(InventoryDetail inventoryDetail, BigDecimal qty); + + /** + * 库存分类报表查询 + * + * @param materialTypeCode 物料类别编码 + * @return 库存分类报表信息 + */ + List<ReportInventoryClassificationDto> getInventoryClassifyReport(String materialTypeCode); } diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/service/impl/InventoryDetailServiceImpl.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/service/impl/InventoryDetailServiceImpl.java index 49d732c..b97ede7 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/service/impl/InventoryDetailServiceImpl.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/service/impl/InventoryDetailServiceImpl.java @@ -22,6 +22,7 @@ import org.jeecg.modules.wms.inventory.inventoryHeader.entity.InventoryDetail; import org.jeecg.modules.wms.inventory.inventoryHeader.mapper.InventoryDetailMapper; import org.jeecg.modules.wms.inventory.inventoryHeader.service.IInventoryDetailService; import org.jeecg.modules.wms.inventory.inventoryHeader.service.IInventoryHeaderService; +import org.jeecg.modules.wms.report.dto.ReportInventoryClassificationDto; import org.jeecg.modules.wms.task.taskHeader.entity.TaskHeader; import org.jeecg.modules.wms.task.taskHeader.service.ITaskHeaderService; import org.jeecg.utils.StringUtils; @@ -488,4 +489,9 @@ public class InventoryDetailServiceImpl extends ServiceImpl<InventoryDetailMappe } return Result.OK("调整库存,托盘:" + containerCode + "调整库存成功"); } + + @Override + public List<ReportInventoryClassificationDto> getInventoryClassifyReport(String materialTypeCode) { + return super.baseMapper.selectReportClassification(materialTypeCode); + } } diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/report/controller/ReportController.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/report/controller/ReportController.java index 309e411..07bf5ad 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/report/controller/ReportController.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/report/controller/ReportController.java @@ -13,6 +13,9 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import org.jeecg.common.api.vo.Result; import org.jeecg.common.system.base.controller.JeecgController; import org.jeecg.common.system.query.QueryGenerator; @@ -20,9 +23,14 @@ import org.jeecg.modules.wms.config.location.entity.Location; import org.jeecg.modules.wms.config.location.service.ILocationService; import org.jeecg.modules.wms.config.material.entity.Material; import org.jeecg.modules.wms.config.material.service.IMaterialService; +import org.jeecg.modules.wms.config.materialType.entity.MaterialType; +import org.jeecg.modules.wms.config.materialType.service.IMaterialTypeService; import org.jeecg.modules.wms.config.parameterConfiguration.service.IParameterConfigurationService; +import org.jeecg.modules.wms.inventory.inventoryHeader.entity.InventoryDetail; +import org.jeecg.modules.wms.inventory.inventoryHeader.service.IInventoryDetailService; import org.jeecg.modules.wms.inventory.inventoryTransaction.entity.InventoryTransaction; import org.jeecg.modules.wms.inventory.inventoryTransaction.service.IInventoryTransactionService; +import org.jeecg.modules.wms.report.dto.ReportInventoryClassificationDto; import org.jeecg.utils.HuahengJwtUtil; import org.jeecg.utils.StringUtils; import org.jeecg.utils.constant.QuantityConstant; @@ -54,7 +62,11 @@ public class ReportController extends JeecgController<InventoryTransaction, IInv @Resource private IMaterialService materialService; @Resource + private IMaterialTypeService materialTypeService; + @Resource private ILocationService locationService; + @Resource + private IInventoryDetailService inventoryDetailService; /** * 分页列表查询 @@ -192,4 +204,16 @@ public class ReportController extends JeecgController<InventoryTransaction, IInv page.setRecords(inventoryTransactionReportList); return Result.OK(page); } + + /** + * 库存分类报表列表查询 + */ + @GetMapping(value = "/listInventoryClassification") + public Result listInventoryClassification(String materialTypeCode, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) { + List<ReportInventoryClassificationDto> inventoryClassifyReportList = inventoryDetailService.getInventoryClassifyReport(materialTypeCode); + Page<ReportInventoryClassificationDto> page = new Page<>(pageNo, pageSize); + page.setRecords(inventoryClassifyReportList); + return Result.OK(page); + } } diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/report/dto/ReportInventoryClassificationDto.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/report/dto/ReportInventoryClassificationDto.java new file mode 100644 index 0000000..a4c0813 --- /dev/null +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/report/dto/ReportInventoryClassificationDto.java @@ -0,0 +1,28 @@ +package org.jeecg.modules.wms.report.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 库存分类报表Dto类 + */ +@Data +public class ReportInventoryClassificationDto implements Serializable { + + /** + * 物料分类编码 + */ + private String materialTypeCode; + + /** + * 物料分类名称 + */ + private String materialTypeName; + + /** + * 总数量 + */ + private BigDecimal qty; +} -- libgit2 0.22.2