Commit 7e2614a6d171dfeb4ede2aad1cac4993cc98c35f

Authored by 谭毅彬
1 parent 76142b76

库存查询添加库龄数据,出库配盘页面优化

Signed-off-by: TanYibin <5491541@qq.com>
ant-design-vue-jeecg/src/views/system/shipment/modules/ShipmentDetailCombineModal.vue
... ... @@ -7,46 +7,50 @@
7 7 switchFullscreen
8 8 @ok="handleOk"
9 9 @cancel="handleCancel"
10   - cancelText="关闭">
  10 + cancelText="关闭"
  11 + >
11 12 <a-spin :spinning="confirmLoading">
12 13 <a-form-model ref="form" :model="model" :rules="validatorRules">
13 14 <a-row>
14 15 <a-col :span="24">
15 16 <a-form-model-item label="物料编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="materialCode">
16   - <a-input v-model="model.materialCode" placeholder="请输入物料编码" style="width: 100%"/>
  17 + <a-input v-model="model.materialCode" placeholder="请输入物料编码" style="width: 100%" />
17 18 </a-form-model-item>
18 19 </a-col>
19 20 <a-col :span="24">
20 21 <a-form-model-item label="物料名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="materialName">
21   - <a-input v-model="model.materialName" placeholder="请输入物料名称" style="width: 100%"/>
  22 + <a-input v-model="model.materialName" placeholder="请输入物料名称" style="width: 100%" />
22 23 </a-form-model-item>
23 24 </a-col>
24 25 <a-col :span="24">
25 26 <a-form-model-item label="可出数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qty">
26   - <a-input-number v-model="model.qty" placeholder="请输入可出数量" style="width: 100%"/>
  27 + <a-input-number v-model="model.qty" placeholder="请输入可出数量" style="width: 100%" />
27 28 </a-form-model-item>
28 29 </a-col>
29 30 <a-col :span="24">
30 31 <a-form-model-item label="出库数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="taskQty">
31   - <a-input-number v-model="model.taskQty" placeholder="请输入出库数量" style="width: 100%"/>
  32 + <a-input-number v-model="model.taskQty" placeholder="请输入出库数量" style="width: 100%" />
32 33 </a-form-model-item>
33 34 </a-col>
34 35 </a-row>
35 36 </a-form-model>
36 37 </a-spin>
37   -
38 38 <!-- table区域-begin -->
39 39 <div>
40   -
41 40 <a-table
42 41 ref="table"
43 42 rowKey="id"
44 43 size="middle"
  44 + bordered
  45 + class="j-table-force-nowrap"
  46 + :scroll="{x:true}"
45 47 :columns="columns"
46 48 :dataSource="dataSource"
47   - :pagination="false">
48   - <span slot="action" slot-scope="text, record">
49   - <a-button @click="combine(record)" type="primary">配盘</a-button>
  49 + :pagination="false"
  50 + :loading="loading"
  51 + >
  52 + <span slot="action" slot-scope="text, record">
  53 + <a-button @click="combine(record)" type="primary">配盘</a-button>
50 54 </span>
51 55 </a-table>
52 56 </div>
... ... @@ -54,19 +58,18 @@
54 58 </template>
55 59  
56 60 <script>
57   -
58   -import {JeecgListMixin} from '@/mixins/JeecgListMixin'
59   -import {httpAction} from '@/api/manage'
60   -import {validateDuplicateValue} from '@/utils/util'
61   -import {searchMaterialByCode, getInventoryFromShipmentDetail} from '@/api/api'
62   -import {listShipmentByShipmentDetailId, combination} from '@/api/api'
63   -import {filterObj} from '@/utils/util';
64   -import {deleteAction, getAction, downFile, getFileAccessHttpUrl} from '@/api/manage'
  61 +import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  62 +import { httpAction } from '@/api/manage'
  63 +import { validateDuplicateValue } from '@/utils/util'
  64 +import { searchMaterialByCode, getInventoryFromShipmentDetail } from '@/api/api'
  65 +import { listShipmentByShipmentDetailId, combination } from '@/api/api'
  66 +import { filterObj } from '@/utils/util'
  67 +import { deleteAction, getAction, downFile, getFileAccessHttpUrl } from '@/api/manage'
65 68  
66 69 export default {
67   - name: "ShipmentDetailCombineModal",
  70 + name: 'ShipmentDetailCombineModal',
68 71 components: {
69   - JeecgListMixin,
  72 + JeecgListMixin
70 73 },
71 74 props: {
72 75 mainId: {
... ... @@ -77,15 +80,15 @@ export default {
77 80 },
78 81 data() {
79 82 return {
80   - title: "操作",
  83 + title: '操作',
81 84 width: 1000,
82 85 /* 分页参数 */
83 86 ipagination: {
84 87 current: 1,
85   - pageSize: 10,
  88 + pageSize: 100,
86 89 pageSizeOptions: ['10', '20', '30'],
87 90 showTotal: (total, range) => {
88   - return range[0] + "-" + range[1] + " 共" + total + "条"
  91 + return range[0] + '-' + range[1] + ' 共' + total + '条'
89 92 },
90 93 showQuickJumper: true,
91 94 showSizeChanger: true,
... ... @@ -117,144 +120,148 @@ export default {
117 120 superQueryMatchType: 'and',
118 121 model: {},
119 122 labelCol: {
120   - xs: {span: 24},
121   - sm: {span: 5},
  123 + xs: { span: 24 },
  124 + sm: { span: 5 }
122 125 },
123 126 wrapperCol: {
124   - xs: {span: 24},
125   - sm: {span: 16},
  127 + xs: { span: 24 },
  128 + sm: { span: 16 }
126 129 },
127 130 // 表头
128 131 columns: [
129 132 {
130 133 title: '容器编码',
131   - align: "center",
  134 + align: 'center',
132 135 dataIndex: 'containerCode'
133 136 },
134 137 {
135 138 title: '库位编码',
136   - align: "center",
  139 + align: 'center',
137 140 dataIndex: 'locationCode'
138 141 },
139 142 {
140 143 title: '物料编码',
141   - align: "center",
  144 + align: 'center',
142 145 dataIndex: 'materialCode'
143 146 },
144 147 {
145 148 title: '物料名称',
146   - align: "center",
  149 + align: 'center',
147 150 dataIndex: 'materialName'
148 151 },
149 152 {
150 153 title: '库存数量',
151   - align: "center",
  154 + align: 'center',
152 155 dataIndex: 'qty'
153 156 },
154 157 {
155 158 title: '锁定数量',
156   - align: "center",
  159 + align: 'center',
157 160 dataIndex: 'taskQty'
158 161 },
159 162 {
160 163 title: '库存状态',
161   - align: "center",
162   - dataIndex: 'inventoryStatus_dictText',
  164 + align: 'center',
  165 + dataIndex: 'inventoryStatus'
163 166 },
164 167 {
165 168 title: '批次',
166   - align: "center",
  169 + align: 'center',
167 170 dataIndex: 'batch'
168 171 },
169 172 {
170 173 title: '创建人',
171   - align: "center",
  174 + align: 'center',
172 175 dataIndex: 'createBy'
173 176 },
174 177 {
175 178 title: '创建日期',
176   - align: "center",
  179 + align: 'center',
177 180 dataIndex: 'createTime'
178 181 },
179 182 {
180 183 title: '操作',
181 184 dataIndex: 'action',
182   - align: "center",
183   - fixed: "right",
  185 + align: 'center',
  186 + fixed: 'right',
184 187 width: 147,
185   - scopedSlots: {customRender: 'action'},
  188 + scopedSlots: { customRender: 'action' }
186 189 }
187 190 ],
188 191 confirmLoading: false,
189 192 validatorRules: {},
190 193 url: {
191   - add: "/shipment/shipmentHeader/addShipmentDetail",
192   - edit: "/shipment/shipmentHeader/editShipmentDetail",
193   - list: "/shipment/shipmentCombination/getInventoryFromShipmentDetail"
  194 + add: '/shipment/shipmentHeader/addShipmentDetail',
  195 + edit: '/shipment/shipmentHeader/editShipmentDetail',
  196 + list: '/shipment/shipmentCombination/getInventoryFromShipmentDetail'
194 197 }
195   -
196 198 }
197 199 },
198 200 created() {
199 201 //备份model原始值
200   - this.modelDefault = JSON.parse(JSON.stringify(this.model));
201   - this.searchMaterial();
  202 + this.modelDefault = JSON.parse(JSON.stringify(this.model))
  203 + this.searchMaterial()
202 204 },
203 205 methods: {
  206 + getSuperFieldList() {
  207 + let fieldList = []
  208 + fieldList.push({ type: 'string', value: 'inventoryStatus', text: '库存状态', dictCode: 'inventory_status' })
  209 + this.superFieldList = fieldList
  210 + },
204 211 add() {
205   - this.edit(this.modelDefault);
206   - this.model.inventoryStatus = "good";
  212 + this.edit(this.modelDefault)
  213 + this.model.inventoryStatus = 'good'
207 214 },
208 215 edit(record) {
209 216 // this.model = Object.assign({}, record);
210   - this.shipmentParam = record;
211   - this.searchShipment();
  217 + this.shipmentParam = record
  218 + this.searchShipment()
212 219 },
213 220 close() {
214   - this.$emit('close');
215   - this.visible = false;
216   - this.$refs.form.clearValidate();
  221 + this.$emit('close')
  222 + this.visible = false
  223 + this.$refs.form.clearValidate()
217 224 },
218 225 combine(record) {
219   - const that = this;
220   - that.querySource = record;
221   - this.combineParam.shipmentDetailID = this.model.id;
222   - this.combineParam.inventoryDetailID = record.id;
223   - this.combineParam.shipQty = this.model.taskQty;
224   - combination(this.combineParam).then((res) => {
  226 + const that = this
  227 + that.querySource = record
  228 + this.combineParam.shipmentDetailID = this.model.id
  229 + this.combineParam.inventoryDetailID = record.id
  230 + this.combineParam.shipQty = this.model.taskQty
  231 + combination(this.combineParam).then(res => {
225 232 if (res.success) {
226 233 // this.model = res.result;
227   - this.$message.success(res.message);
228   - this.searchShipment();
  234 + this.$message.success(res.message)
  235 + this.searchShipment()
229 236 } else {
230 237 this.$message.warning(res.message)
231 238 }
232   - });
  239 + })
233 240 },
234 241 searchShipment() {
235   - const that = this;
236   - that.querySource = this.shipmentParam;
237   - listShipmentByShipmentDetailId(that.querySource).then((res) => {
  242 + const that = this
  243 + that.querySource = this.shipmentParam
  244 + listShipmentByShipmentDetailId(that.querySource).then(res => {
238 245 if (res.success) {
239   - this.model = res.result;
240   - this.visible = true;
241   - this.searchInventory(that.querySource);
  246 + this.model = res.result
  247 + this.visible = true
  248 + this.searchInventory(that.querySource)
242 249 } else {
243 250 this.$message.warning(res.message)
244 251 }
245   - });
  252 + })
246 253 },
247 254 searchInventory(record) {
248   - const that = this;
249   - that.querySource = record;
250   - console.log("searchInventory");
  255 + const that = this
  256 + that.querySource = record
  257 + console.log('searchInventory')
251 258 // getInventoryFromShipmentDetail(that.querySource).then((res) => {
252 259 // this.dataSource = res.result;
253 260 // });
254   - this.searchQuery();
  261 + this.searchQuery()
255 262 },
256 263 searchQuery() {
257   - this.loadData(1);
  264 + this.loadData(1)
258 265 // 点击查询清空列表选中行
259 266 // https://gitee.com/jeecg/jeecg-boot/issues/I4KTU1
260 267 // this.selectedRowKeys = []
... ... @@ -262,39 +269,41 @@ export default {
262 269 },
263 270 loadData(arg) {
264 271 if (!this.url.list) {
265   - this.$message.error("请设置url.list属性!")
  272 + this.$message.error('请设置url.list属性!')
266 273 return
267 274 }
268 275 //加载数据 若传入参数1则加载第一页的内容
269 276 if (arg === 1) {
270   - this.ipagination.current = 1;
  277 + this.ipagination.current = 1
271 278 }
272   - var params = this.getQueryParams();//查询条件
273   - this.loading = true;
274   - getAction(this.url.list, params).then((res) => {
275   - if (res.success) {
276   - //update-begin---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------
277   - this.dataSource = res.result.records || res.result;
278   - if (res.result.total) {
279   - this.ipagination.total = res.result.total;
  279 + var params = this.getQueryParams() //查询条件
  280 + this.loading = true
  281 + getAction(this.url.list, params)
  282 + .then(res => {
  283 + if (res.success) {
  284 + //update-begin---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------
  285 + this.dataSource = res.result.records || res.result
  286 + if (res.result.total) {
  287 + this.ipagination.total = res.result.total
  288 + } else {
  289 + this.ipagination.total = 0
  290 + }
  291 + //update-end---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------
280 292 } else {
281   - this.ipagination.total = 0;
  293 + this.$message.warning(res.message)
282 294 }
283   - //update-end---author:zhangyafei Date:20201118 for:适配不分页的数据列表------------
284   - } else {
285   - this.$message.warning(res.message)
286   - }
287   - }).finally(() => {
288   - this.loading = false
289   - })
  295 + })
  296 + .finally(() => {
  297 + this.loading = false
  298 + })
290 299 },
291 300 getQueryField() {
292 301 //TODO 字段权限控制
293   - var str = "id,";
294   - this.columns.forEach(function (value) {
295   - str += "," + value.dataIndex;
296   - });
297   - return str;
  302 + var str = 'id,'
  303 + this.columns.forEach(function(value) {
  304 + str += ',' + value.dataIndex
  305 + })
  306 + return str
298 307 },
299 308 getQueryParams() {
300 309 //获取查询条件
... ... @@ -303,16 +312,16 @@ export default {
303 312 sqp['superQueryParams'] = encodeURI(this.superQueryParams)
304 313 sqp['superQueryMatchType'] = this.superQueryMatchType
305 314 }
306   - this.queryParam.id = this.model.id;
307   - var param = Object.assign(sqp, this.queryParam, this.isorter, this.filters);
308   - param.field = this.getQueryField();
309   - param.pageNo = this.ipagination.current;
310   - param.pageSize = this.ipagination.pageSize;
311   - return filterObj(param);
  315 + this.queryParam.id = this.model.id
  316 + var param = Object.assign(sqp, this.queryParam, this.isorter, this.filters)
  317 + param.field = this.getQueryField()
  318 + param.pageNo = this.ipagination.current
  319 + param.pageSize = this.ipagination.pageSize
  320 + return filterObj(param)
312 321 },
313 322 handleOk() {
314   - const that = this;
315   - that.close();
  323 + const that = this
  324 + that.close()
316 325 // 触发表单验证
317 326 // this.$refs.form.validate(valid => {
318 327 // if (valid) {
... ... @@ -347,14 +356,13 @@ export default {
347 356 this.close()
348 357 },
349 358 searchMaterial() {
350   - const that = this;
351   - that.querySource.materialCode = that.model.materialCode;
352   - console.log("model.materialCode:" + that.model.materialCode);
353   - searchMaterialByCode(that.querySource).then((res) => {
354   - that.materialList = res.result;
  359 + const that = this
  360 + that.querySource.materialCode = that.model.materialCode
  361 + console.log('model.materialCode:' + that.model.materialCode)
  362 + searchMaterialByCode(that.querySource).then(res => {
  363 + that.materialList = res.result
355 364 })
356   - },
357   -
  365 + }
358 366 }
359 367 }
360 368 </script>
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/InventoryMaterialSummary/controller/InventoryMaterialSummaryController.java
... ... @@ -12,6 +12,7 @@ import org.jeecg.common.system.base.controller.JeecgController;
12 12 import org.jeecg.common.system.query.QueryGenerator;
13 13 import org.jeecg.modules.wms.inventory.InventoryMaterialSummary.service.IInventoryMaterialSummaryService;
14 14 import org.jeecg.modules.wms.inventory.inventoryHeader.entity.InventoryDetail;
  15 +import org.jeecg.modules.wms.inventory.inventoryHeader.service.IInventoryDetailService;
15 16 import org.jeecg.modules.wms.inventory.inventoryHeader.service.impl.InventoryDetailServiceImpl;
16 17 import org.jeecg.utils.HuahengJwtUtil;
17 18 import org.jeecg.utils.StringUtils;
... ... @@ -39,7 +40,8 @@ import lombok.extern.slf4j.Slf4j;
39 40 @Slf4j
40 41 public class InventoryMaterialSummaryController extends JeecgController<InventoryDetail, IInventoryMaterialSummaryService> {
41 42 @Resource
42   - private InventoryDetailServiceImpl inventoryDetailServiceImpl;
  43 + private IInventoryDetailService inventoryDetailService;
  44 +
43 45 @Resource
44 46 private IInventoryMaterialSummaryService inventoryMaterialSummaryService;
45 47  
... ... @@ -57,11 +59,9 @@ public class InventoryMaterialSummaryController extends JeecgController&lt;Inventor
57 59 HuahengJwtUtil.setWarehouseCode(req, inventoryDetail);
58 60 QueryWrapper<InventoryDetail> queryWrapper = QueryGenerator.initQueryWrapper(inventoryDetail, req.getParameterMap());
59 61 Page<InventoryDetail> page = new Page<InventoryDetail>(pageNo, pageSize);
60   - IPage<InventoryDetail> pageList = inventoryDetailServiceImpl.page(page, queryWrapper);
  62 + IPage<InventoryDetail> pageList = inventoryDetailService.page(page, queryWrapper);
61 63 // 筛选库存汇总数据的专用方法
62   - List<InventoryDetail> details = inventoryMaterialSummaryService.duplicateRemoval(pageList.getRecords());
63   - pageList.setRecords(null);
64   - pageList.setRecords(details);
  64 + pageList.setRecords(inventoryMaterialSummaryService.duplicateRemoval(pageList.getRecords()));
65 65 return Result.OK(pageList);
66 66 }
67 67  
... ... @@ -77,15 +77,15 @@ public class InventoryMaterialSummaryController extends JeecgController&lt;Inventor
77 77 public Result<IPage<InventoryDetail>> inventoryMaterialSummaryChild(InventoryDetail inventoryDetail,
78 78 @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
79 79 HttpServletRequest req) {
80   - inventoryDetail = inventoryDetailServiceImpl.getById(inventoryDetail.getId());
  80 + inventoryDetail = inventoryDetailService.getById(inventoryDetail.getId());
81 81 LambdaQueryWrapper<InventoryDetail> queryWrapper = new LambdaQueryWrapper<>();
82 82 queryWrapper.eq(InventoryDetail::getMaterialCode, inventoryDetail.getMaterialCode()).eq(InventoryDetail::getMaterialName, inventoryDetail.getMaterialName())
83 83 .eq(StringUtils.isNotEmpty(inventoryDetail.getMaterialSpec()), InventoryDetail::getMaterialSpec, inventoryDetail.getMaterialSpec())
84 84 .eq(StringUtils.isNotEmpty(inventoryDetail.getMaterialUnit()), InventoryDetail::getMaterialUnit, inventoryDetail.getMaterialUnit());
85 85  
86 86 Page<InventoryDetail> page = new Page<InventoryDetail>(pageNo, pageSize);
87   - IPage<InventoryDetail> pageList = inventoryDetailServiceImpl.page(page, queryWrapper);
88   -
  87 + IPage<InventoryDetail> pageList = inventoryDetailService.page(page, queryWrapper);
  88 + inventoryDetailService.calculateInventoryAge(pageList.getRecords());// 计算库龄
89 89 return Result.OK(pageList);
90 90 }
91 91  
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryDetail/controller/InventoryDetailController.java
... ... @@ -54,7 +54,9 @@ public class InventoryDetailController extends JeecgController&lt;InventoryDetail,
54 54 HuahengJwtUtil.setWarehouseCode(req, inventoryDetail);
55 55 QueryWrapper<InventoryDetail> queryWrapper = QueryGenerator.initQueryWrapper(inventoryDetail, req.getParameterMap());
56 56 Page<InventoryDetail> page = new Page<InventoryDetail>(pageNo, pageSize);
57   - return Result.OK(inventoryDetailService.queryPage(page, queryWrapper));
  57 + IPage<InventoryDetail> pageList = inventoryDetailService.page(page, queryWrapper);
  58 + inventoryDetailService.calculateInventoryAge(pageList.getRecords());// 计算库龄
  59 + return Result.OK(pageList);
58 60 }
59 61  
60 62 /**
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/controller/InventoryHeaderController.java
... ... @@ -178,7 +178,9 @@ public class InventoryHeaderController extends JeecgController&lt;InventoryHeader,
178 178 HuahengJwtUtil.setWarehouseCode(request, inventoryDetail);
179 179 QueryWrapper<InventoryDetail> queryWrapper = QueryGenerator.initQueryWrapper(inventoryDetail, request.getParameterMap());
180 180 Page<InventoryDetail> page = new Page<InventoryDetail>(pageNo, pageSize);
181   - return Result.OK(inventoryDetailService.queryPage(page, queryWrapper));
  181 + IPage<InventoryDetail> pageList = inventoryDetailService.page(page, queryWrapper);
  182 + inventoryDetailService.calculateInventoryAge(pageList.getRecords());// 计算库龄
  183 + return Result.OK(pageList);
182 184 }
183 185  
184 186 /**
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/service/IInventoryDetailService.java
... ... @@ -51,4 +51,12 @@ public interface IInventoryDetailService extends IService&lt;InventoryDetail&gt; {
51 51 boolean updateQtyAndTaskQtyAndLocationCode(BigDecimal qty, BigDecimal taskQty, String locationCode, int id);
52 52  
53 53 boolean updateBatchLocationCodeById(List<InventoryDetail> inventoryDetailList);
  54 +
  55 + /**
  56 + * 计算库龄
  57 + * @author TanYibin
  58 + * @createDate 2023年7月6日
  59 + * @param inventoryDetailList
  60 + */
  61 + void calculateInventoryAge(List<InventoryDetail> inventoryDetailList);
54 62 }
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/service/impl/InventoryDetailServiceImpl.java
... ... @@ -3,6 +3,7 @@ package org.jeecg.modules.wms.inventory.inventoryHeader.service.impl;
3 3 import java.math.BigDecimal;
4 4 import java.math.RoundingMode;
5 5 import java.util.ArrayList;
  6 +import java.util.Date;
6 7 import java.util.List;
7 8 import java.util.Map;
8 9 import java.util.function.Function;
... ... @@ -27,6 +28,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
27 28 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
28 29 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
29 30  
  31 +import cn.hutool.core.date.DateUtil;
  32 +
30 33 /**
31 34 * @Description: 库存详情
32 35 * @Author: jeecg-boot
... ... @@ -174,4 +177,16 @@ public class InventoryDetailServiceImpl extends ServiceImpl&lt;InventoryDetailMappe
174 177 }
175 178 }
176 179 }
  180 +
  181 + @Override
  182 + public void calculateInventoryAge(List<InventoryDetail> inventoryDetailList) {
  183 + if (inventoryDetailList != null && inventoryDetailList.size() > 0) {
  184 + Date nowDate = new Date();
  185 + for (InventoryDetail inventoryDetail : inventoryDetailList) {
  186 + if (inventoryDetail.getCreateTime() != null) {
  187 + inventoryDetail.setInventoryAge((int)DateUtil.betweenDay(inventoryDetail.getCreateTime(), nowDate, true));
  188 + }
  189 + }
  190 + }
  191 + }
177 192 }
... ...