Commit 848b672b11bb108561d84dc5babda369209612b4
1 parent
40aba46a
报表:库存日报
Showing
2 changed files
with
306 additions
and
5 deletions
ant-design-vue-jeecg/src/views/system/report/ReportInventoryDailyList.vue
0 → 100644
1 | +<template> | |
2 | + <a-card :bordered="false"> | |
3 | + <!-- 查询区域 --> | |
4 | + <div class="table-page-search-wrapper"> | |
5 | + <a-form layout="inline" @keyup.enter.native="searchQuery"> | |
6 | + <a-row :gutter="24"> | |
7 | + <a-col :xl="6" :lg="7" :md="8" :sm="24"> | |
8 | + <a-form-item label="物料编码"> | |
9 | + <a-input placeholder="请输入物料编码" v-model="queryParam.materialCode"></a-input> | |
10 | + </a-form-item> | |
11 | + </a-col> | |
12 | + <a-col :xl="6" :lg="7" :md="8" :sm="24"> | |
13 | + <a-form-item label="物料名称"> | |
14 | + <a-input placeholder="请输入物料名称" v-model="queryParam.materialName"></a-input> | |
15 | + </a-form-item> | |
16 | + </a-col> | |
17 | + <a-col :xl="6" :lg="7" :md="8" :sm="24"> | |
18 | + <a-form-item label="物料规格"> | |
19 | + <a-input placeholder="请输入物料规格" v-model="queryParam.materialSpec"></a-input> | |
20 | + </a-form-item> | |
21 | + </a-col> | |
22 | + <a-col :xl="6" :lg="7" :md="8" :sm="24"> | |
23 | + <a-form-item label="物料单位"> | |
24 | + <a-input placeholder="请输入物料单位" v-model="queryParam.materialUnit"></a-input> | |
25 | + </a-form-item> | |
26 | + </a-col> | |
27 | + <a-col :xl="6" :lg="7" :md="8" :sm="24"> | |
28 | + <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons"> | |
29 | + <a-button id="search" type="primary" @click="searchQuery" icon="search">查询</a-button> | |
30 | + <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button> | |
31 | + </span> | |
32 | + </a-col> | |
33 | + </a-row> | |
34 | + </a-form> | |
35 | + </div> | |
36 | + <!-- 查询区域-END --> | |
37 | + <!-- table区域-begin --> | |
38 | + <div> | |
39 | + <a-table | |
40 | + ref="table" | |
41 | + size="middle" | |
42 | + :scroll="{x:true}" | |
43 | + bordered | |
44 | + rowKey="id" | |
45 | + :columns="columns" | |
46 | + :dataSource="dataSource" | |
47 | + :pagination="ipagination" | |
48 | + :loading="loading" | |
49 | + class="j-table-force-nowrap" | |
50 | + @change="handleTableChange"> | |
51 | + | |
52 | + <span slot="inventoryStatus_dictText" slot-scope="inventoryStatus_dictText"> | |
53 | + <a-tag :key="inventoryStatus_dictText" :color="getStatusColor(inventoryStatus_dictText)"> | |
54 | + {{ inventoryStatus_dictText }} | |
55 | + </a-tag> | |
56 | + </span> | |
57 | + | |
58 | + <span slot="companyCode" slot-scope="companyCode"> | |
59 | + <a-tag :key="companyCode" color=blue> | |
60 | + {{ solutionCompany(companyCode) }} | |
61 | + </a-tag> | |
62 | + </span> | |
63 | + | |
64 | + <span slot="zoneCode" slot-scope="zoneCode"> | |
65 | + <a-tag :key="zoneCode" color="blue"> | |
66 | + {{ solutionZoneCode(zoneCode) }} | |
67 | + </a-tag> | |
68 | + </span> | |
69 | + <template slot="htmlSlot" slot-scope="text"> | |
70 | + <div v-html="text"></div> | |
71 | + </template> | |
72 | + </a-table> | |
73 | + </div> | |
74 | + <inventory-transaction-modal ref="modalForm" @ok="modalFormOk"></inventory-transaction-modal> | |
75 | + </a-card> | |
76 | +</template> | |
77 | + | |
78 | +<script> | |
79 | + | |
80 | +import '@/assets/less/TableExpand.less' | |
81 | +import {mixinDevice} from '@/utils/mixin' | |
82 | +import {JeecgListMixin} from '@/mixins/JeecgListMixin' | |
83 | +import {getCompanyList, getZoneList} from '@/api/api' | |
84 | + | |
85 | +export default { | |
86 | + name: 'ReportInventoryDailyList', | |
87 | + mixins: [JeecgListMixin, mixinDevice], | |
88 | + components: {}, | |
89 | + data() { | |
90 | + return { | |
91 | + description: '库存日报报表页面', | |
92 | + companyList: [], | |
93 | + zoneList: [], | |
94 | + zoneOptions: [], | |
95 | + firstLoad: 0, | |
96 | + // 表头 | |
97 | + columns: [ | |
98 | + { | |
99 | + title: '#', | |
100 | + dataIndex: '', | |
101 | + key: 'rowIndex', | |
102 | + width: 60, | |
103 | + align: 'center', | |
104 | + customRender: function (t, r, index) { | |
105 | + return parseInt(index) + 1 | |
106 | + } | |
107 | + }, | |
108 | + { | |
109 | + title: '物料编码', | |
110 | + align: "center", | |
111 | + dataIndex: 'materialCode' | |
112 | + }, | |
113 | + { | |
114 | + title: '物料名称', | |
115 | + align: "center", | |
116 | + dataIndex: 'materialName' | |
117 | + }, | |
118 | + { | |
119 | + title: '物料规格', | |
120 | + align: "center", | |
121 | + dataIndex: 'materialSpec' | |
122 | + }, | |
123 | + { | |
124 | + title: '物料单位', | |
125 | + align: "center", | |
126 | + dataIndex: 'materialUnit' | |
127 | + }, | |
128 | + { | |
129 | + title: '出入库总数', | |
130 | + align: "center", | |
131 | + dataIndex: 'qty' | |
132 | + }, | |
133 | + { | |
134 | + title: '入库数量', | |
135 | + align: "center", | |
136 | + dataIndex: 'receiptQty' | |
137 | + }, | |
138 | + { | |
139 | + title: '出库数量', | |
140 | + align: "center", | |
141 | + dataIndex: 'shipmentQty' | |
142 | + } | |
143 | + ], | |
144 | + url: { | |
145 | + list: "/report/listInventoryDaily", | |
146 | + }, | |
147 | + dictOptions: {}, | |
148 | + superFieldList: [], | |
149 | + } | |
150 | + }, | |
151 | + created() { | |
152 | + this.getSuperFieldList(); | |
153 | + this.loadFrom(); | |
154 | + }, | |
155 | + mounted() { | |
156 | + if (this.firstLoad === 0) { | |
157 | + this.firstLoad = 1; | |
158 | + return; | |
159 | + } | |
160 | + //页面没加载完,此时methods里的方法找不到,使用定时器模拟点击 | |
161 | + let timeSearch = setInterval(() => { | |
162 | + let eleSearch = document.getElementById("search"); | |
163 | + if (eleSearch != null) { | |
164 | + //调用成功,清除定时器 | |
165 | + clearInterval(timeSearch) | |
166 | + eleSearch.click(); | |
167 | + } | |
168 | + }, 200) | |
169 | + }, | |
170 | + computed: { | |
171 | + importExcelUrl: function () { | |
172 | + return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`; | |
173 | + }, | |
174 | + }, | |
175 | + methods: { | |
176 | + getStatusColor(status) { | |
177 | + const colors = { | |
178 | + '良品': 'green', | |
179 | + '报废品': 'purple', | |
180 | + '待确认 ': 'grey', | |
181 | + '次品': 'red', | |
182 | + default: 'blue' | |
183 | + }; | |
184 | + return colors[status] || colors.default; | |
185 | + }, | |
186 | + initDictConfig() { | |
187 | + }, | |
188 | + loadFrom() { | |
189 | + getZoneList().then((res) => { | |
190 | + if (res.success) { | |
191 | + this.zoneList = res.result | |
192 | + //延迟半秒执行,避免组件未加载完,数据已经加载完 | |
193 | + setTimeout(() => { | |
194 | + //slice可以在数组的任何位置进行删除/添加操作 | |
195 | + this.zoneOptions.splice(0, 1); | |
196 | + for (const element of res.result) { | |
197 | + this.zoneOptions.push({value: element.code, text: element.name}) | |
198 | + } | |
199 | + }, 500) | |
200 | + } | |
201 | + }); | |
202 | + getCompanyList().then((res) => { | |
203 | + if (res.success) { | |
204 | + this.companyList = res.result | |
205 | + } | |
206 | + }); | |
207 | + }, | |
208 | + solutionZoneCode(value) { | |
209 | + let actions = [] | |
210 | + Object.keys(this.zoneList).some(key => { | |
211 | + if (this.zoneList[key].code === '' + value) { | |
212 | + actions.push(this.zoneList[key].name) | |
213 | + return true | |
214 | + } | |
215 | + }) | |
216 | + return actions.join('') | |
217 | + }, | |
218 | + solutionCompany(value) { | |
219 | + let actions = [] | |
220 | + Object.keys(this.companyList).some((key) => { | |
221 | + if (this.companyList[key].code === ('' + value)) { | |
222 | + actions.push(this.companyList[key].name) | |
223 | + return true | |
224 | + } | |
225 | + }) | |
226 | + return actions.join('') | |
227 | + }, | |
228 | + getSuperFieldList() { | |
229 | + let fieldList = []; | |
230 | + fieldList.push({type: 'string', value: 'companyCode', text: '货主', dictCode: ''}) | |
231 | + fieldList.push({type: 'string', value: 'containerCode', text: '容器编码', dictCode: ''}) | |
232 | + fieldList.push({type: 'string', value: 'locationCode', text: '库位编码', dictCode: ''}) | |
233 | + fieldList.push({type: 'int', value: 'type', text: '交易类型', dictCode: 'inventory_transaction_type'}) | |
234 | + fieldList.push({type: 'string', value: 'materialCode', text: '物料编码', dictCode: ''}) | |
235 | + fieldList.push({type: 'string', value: 'materialName', text: '物料名称', dictCode: ''}) | |
236 | + fieldList.push({type: 'string', value: 'materialSpec', text: '物料规格', dictCode: ''}) | |
237 | + fieldList.push({type: 'string', value: 'materialUnit', text: '物料单位', dictCode: ''}) | |
238 | + fieldList.push({type: 'string', value: 'inventoryStatus', text: '库存状态', dictCode: 'inventory_status'}) | |
239 | + fieldList.push({type: 'BigDecimal', value: 'qty', text: '数量', dictCode: ''}) | |
240 | + fieldList.push({type: 'string', value: 'batch', text: '批次', dictCode: ''}) | |
241 | + fieldList.push({type: 'string', value: 'createBy', text: '创建人', dictCode: ''}) | |
242 | + fieldList.push({type: 'datetime', value: 'createTime', text: '创建日期'}) | |
243 | + fieldList.push({type: 'string', value: 'updateBy', text: '更新人', dictCode: ''}) | |
244 | + fieldList.push({type: 'datetime', value: 'updateTime', text: '更新日期'}) | |
245 | + this.superFieldList = fieldList | |
246 | + } | |
247 | + } | |
248 | +} | |
249 | +</script> | |
250 | +<style scoped> | |
251 | +@import '~@assets/less/common.less'; | |
252 | +</style> | |
0 | 253 | \ No newline at end of file |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/report/controller/ReportController.java
1 | 1 | package org.jeecg.modules.wms.report.controller; |
2 | 2 | |
3 | 3 | import java.math.BigDecimal; |
4 | +import java.time.LocalDate; | |
5 | +import java.time.LocalDateTime; | |
6 | +import java.time.LocalTime; | |
4 | 7 | import java.util.ArrayList; |
5 | 8 | import java.util.List; |
6 | 9 | import java.util.Map; |
... | ... | @@ -9,6 +12,7 @@ import java.util.stream.Collectors; |
9 | 12 | import javax.annotation.Resource; |
10 | 13 | import javax.servlet.http.HttpServletRequest; |
11 | 14 | |
15 | +import cn.hutool.core.util.ObjectUtil; | |
12 | 16 | import org.jeecg.common.api.vo.Result; |
13 | 17 | import org.jeecg.common.system.base.controller.JeecgController; |
14 | 18 | import org.jeecg.common.system.query.QueryGenerator; |
... | ... | @@ -43,15 +47,11 @@ import lombok.extern.slf4j.Slf4j; |
43 | 47 | @RequestMapping("/report") |
44 | 48 | @Slf4j |
45 | 49 | public class ReportController extends JeecgController<InventoryTransaction, IInventoryTransactionService> { |
50 | + | |
46 | 51 | @Autowired |
47 | 52 | private IInventoryTransactionService inventoryTransactionService; |
48 | 53 | |
49 | 54 | @Resource |
50 | - private HuahengJwtUtil huahengJwtUtil; | |
51 | - | |
52 | - @Resource | |
53 | - private IParameterConfigurationService parameterConfigurationService; | |
54 | - @Resource | |
55 | 55 | private IMaterialService materialService; |
56 | 56 | @Resource |
57 | 57 | private ILocationService locationService; |
... | ... | @@ -143,4 +143,53 @@ public class ReportController extends JeecgController<InventoryTransaction, IInv |
143 | 143 | page.setRecords(locations); |
144 | 144 | return Result.OK(page); |
145 | 145 | } |
146 | + | |
147 | + /** | |
148 | + * 库存日报列表查询 | |
149 | + */ | |
150 | + @GetMapping(value = "/listInventoryDaily") | |
151 | + public Result listInventoryDaily(InventoryTransaction inventoryTransaction, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, | |
152 | + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) { | |
153 | + // 查询当天的入库、出库交易记录 | |
154 | + QueryWrapper<InventoryTransaction> queryWrapper = QueryGenerator.initQueryWrapper(inventoryTransaction, req.getParameterMap()); | |
155 | + queryWrapper.ge("create_time", LocalDateTime.of(LocalDate.now(), LocalTime.MIN)) | |
156 | + .and(wrapper -> wrapper.eq("type", QuantityConstant.INVENTORY_TRANSACTION_RECEIPT) | |
157 | + .or().eq("type", QuantityConstant.INVENTORY_TRANSACTION_SHIPMENT)); | |
158 | + List<InventoryTransaction> inventoryTransactionList = inventoryTransactionService.list(queryWrapper); | |
159 | + // 交易记录根据物料编码进行分组 | |
160 | + Map<String, List<InventoryTransaction>> groupByMaterialCodeMap = inventoryTransactionList.stream().collect(Collectors.groupingBy(InventoryTransaction::getMaterialCode)); | |
161 | + List<InventoryTransaction> inventoryTransactionReportList = new ArrayList<>(); | |
162 | + for (Map.Entry<String, List<InventoryTransaction>> entry : groupByMaterialCodeMap.entrySet()) { | |
163 | + String materialCode = entry.getKey(); | |
164 | + Material material = materialService.getMaterialByCode(materialCode); | |
165 | + InventoryTransaction inventoryTransactionReport = new InventoryTransaction(); | |
166 | + if (material != null) { | |
167 | + inventoryTransactionReport.setMaterialName(material.getName()); | |
168 | + inventoryTransactionReport.setMaterialUnit(material.getUnit()); | |
169 | + inventoryTransactionReport.setMaterialSpec(material.getSpec()); | |
170 | + } | |
171 | + inventoryTransactionReport.setMaterialCode(materialCode); | |
172 | + List<InventoryTransaction> inventoryTransactions = entry.getValue(); | |
173 | + // 求和 数量、入库数量、出库数量 | |
174 | + BigDecimal qtySum = inventoryTransactions.stream() | |
175 | + .map(InventoryTransaction::getQty) | |
176 | + .filter(ObjectUtil::isNotEmpty) | |
177 | + .reduce(BigDecimal.ZERO, BigDecimal::add); | |
178 | + BigDecimal receiptQtySum = inventoryTransactions.stream() | |
179 | + .map(InventoryTransaction::getReceiptQty) | |
180 | + .filter(ObjectUtil::isNotEmpty) | |
181 | + .reduce(BigDecimal.ZERO, BigDecimal::add); | |
182 | + BigDecimal shipmentQtySum = inventoryTransactions.stream() | |
183 | + .map(InventoryTransaction::getShipmentQty) | |
184 | + .filter(ObjectUtil::isNotEmpty) | |
185 | + .reduce(BigDecimal.ZERO, BigDecimal::add); | |
186 | + inventoryTransactionReport.setQty(qtySum); | |
187 | + inventoryTransactionReport.setReceiptQty(receiptQtySum); | |
188 | + inventoryTransactionReport.setShipmentQty(shipmentQtySum); | |
189 | + inventoryTransactionReportList.add(inventoryTransactionReport); | |
190 | + } | |
191 | + Page<InventoryTransaction> page = new Page<>(pageNo, pageSize); | |
192 | + page.setRecords(inventoryTransactionReportList); | |
193 | + return Result.OK(page); | |
194 | + } | |
146 | 195 | } |
... | ... |