Commit bc505004d697c05a5ab095b4da9505a56c3379e4
1 parent
4138aa95
盘点完成调整库存 生成交易记录
Showing
7 changed files
with
128 additions
and
28 deletions
ant-design-vue-jeecg/src/components/jeecgbiz/JButtonBizComponent/JSelectBizComponentModal.vue
ant-design-vue-jeecg/src/views/system/stocktaking/modules/AdjustmentDocModal.vue
1 | +<script src="../../../../components/jeecgbiz/JButtonBizComponent/util.js"></script> | |
1 | 2 | <template> |
2 | 3 | <j-modal |
3 | 4 | :title="title" |
... | ... | @@ -26,6 +27,7 @@ |
26 | 27 | |
27 | 28 | import {createManyEmptyIn} from '@/api/api' |
28 | 29 | import {confirmGapQty} from "../../../../api/api"; |
30 | +import Utils from '../../../../components/jeecgbiz/JButtonBizComponent/util.js'; | |
29 | 31 | |
30 | 32 | export default { |
31 | 33 | name: "AdjustmentDocModal", |
... | ... | @@ -95,6 +97,7 @@ export default { |
95 | 97 | that.$emit('ok'); |
96 | 98 | that.model.containerCode = ''; |
97 | 99 | that.model.toLocationCode = ''; |
100 | + Utils.$emit('methodB',res.result); | |
98 | 101 | } else { |
99 | 102 | that.$message.warning(res.message); |
100 | 103 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/stocktaking/cycleCountDetail/entity/CycleCountDetail.java
... | ... | @@ -2,6 +2,7 @@ package org.jeecg.modules.wms.stocktaking.cycleCountDetail.entity; |
2 | 2 | |
3 | 3 | import java.io.Serializable; |
4 | 4 | import java.io.UnsupportedEncodingException; |
5 | +import java.math.BigDecimal; | |
5 | 6 | import java.util.Date; |
6 | 7 | import com.baomidou.mybatisplus.annotation.IdType; |
7 | 8 | import com.baomidou.mybatisplus.annotation.TableId; |
... | ... | @@ -74,15 +75,15 @@ public class CycleCountDetail implements Serializable { |
74 | 75 | /**系统数量*/ |
75 | 76 | @Excel(name = "系统数量", width = 15) |
76 | 77 | @ApiModelProperty(value = "系统数量") |
77 | - private Integer systemQty; | |
78 | + private BigDecimal systemQty; | |
78 | 79 | /**实盘数量*/ |
79 | 80 | @Excel(name = "实盘数量", width = 15) |
80 | 81 | @ApiModelProperty(value = "实盘数量") |
81 | - private Integer countedQty; | |
82 | + private BigDecimal countedQty; | |
82 | 83 | /**差异数量*/ |
83 | 84 | @Excel(name = "差异数量", width = 15) |
84 | 85 | @ApiModelProperty(value = "差异数量") |
85 | - private Integer gapQty; | |
86 | + private BigDecimal gapQty; | |
86 | 87 | /**失败原因*/ |
87 | 88 | @Excel(name = "失败原因", width = 15) |
88 | 89 | @ApiModelProperty(value = "失败原因") |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/stocktaking/cycleCountDetail/service/impl/CycleCountDetailChildServiceImpl.java
... | ... | @@ -2,7 +2,10 @@ package org.jeecg.modules.wms.stocktaking.cycleCountDetail.service.impl; |
2 | 2 | |
3 | 3 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
4 | 4 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
5 | +import org.apache.shiro.SecurityUtils; | |
5 | 6 | import org.jeecg.common.api.vo.Result; |
7 | +import org.jeecg.common.system.vo.LoginUser; | |
8 | +import org.jeecg.modules.system.entity.SysThirdAccount; | |
6 | 9 | import org.jeecg.modules.wms.stocktaking.cycleCountDetail.entity.CycleCountDetail; |
7 | 10 | import org.jeecg.modules.wms.stocktaking.cycleCountDetail.entity.CycleCountDetailChild; |
8 | 11 | import org.jeecg.modules.wms.stocktaking.cycleCountDetail.mapper.CycleCountDetailChildMapper; |
... | ... | @@ -51,29 +54,53 @@ public class CycleCountDetailChildServiceImpl extends ServiceImpl<CycleCountDeta |
51 | 54 | if(StringUtils.isNull(countDetailChild)){ |
52 | 55 | return Result.error("明细子单不存在!"); |
53 | 56 | } |
57 | + | |
58 | + | |
59 | + | |
54 | 60 | CycleCountDetail cycleCountDetail = cycleCountDetailService.getById(countDetailChild.getCycleCountDetailid()); |
55 | 61 | if(StringUtils.isNull(cycleCountDetail)){ |
56 | 62 | return Result.error("盘点明细不存在。"); |
57 | 63 | } |
58 | 64 | //任务完成后再实盘登记 |
59 | - /* if(countDetailChild.getChildStatus() < QuantityConstant.CYCLECOUNT_STATUS_EXECUTING){ | |
60 | - return AjaxResult.error("盘点任务未执行不能登记数量!"); | |
61 | - }*/ | |
65 | +// if(countDetailChild.getChildStatus() < QuantityConstant.CYCLECOUNT_STATUS_EXECUTING){ | |
66 | +// return AjaxResult.error("盘点任务未执行不能登记数量!"); | |
67 | +// } | |
62 | 68 | |
63 | 69 | if(countDetailChild.getChildStatus() >= QuantityConstant.CYCLECOUNT_STATUS_COMPLETED){ |
64 | 70 | return Result.error("盘点任务完成后不能再登记数量!"); |
65 | 71 | } |
72 | + | |
73 | + | |
66 | 74 | //实盘登记后差异数量 |
67 | 75 | BigDecimal adjQty = qty.subtract(countDetailChild.getSystemQty()); |
68 | 76 | countDetailChild.setGapQty(adjQty); |
69 | 77 | countDetailChild.setCountedQty(qty); |
70 | 78 | countDetailChild.setChildStatus(QuantityConstant.CYCLECOUNT_STATUS_REGISTERED); |
71 | -// countDetailChild.setCountedBy(ShiroUtils.getLoginName()); | |
72 | 79 | this.updateById(countDetailChild); |
80 | + | |
81 | + | |
82 | + | |
83 | + LambdaQueryWrapper<CycleCountDetailChild> cycleCountDetailChildLambdaQueryWrapper = new LambdaQueryWrapper<>(); | |
84 | + cycleCountDetailChildLambdaQueryWrapper.eq(CycleCountDetailChild::getCycleCountDetailid,cycleCountDetail.getId()); | |
85 | + List<CycleCountDetailChild> cycleCountDetailChildren = this.list(cycleCountDetailChildLambdaQueryWrapper); | |
86 | + | |
87 | + BigDecimal counted_qty=new BigDecimal(0); | |
88 | + BigDecimal ystem_qty=new BigDecimal(0); | |
89 | + BigDecimal gap_qty=new BigDecimal(0); | |
90 | + for(CycleCountDetailChild cycleCountDetailChild:cycleCountDetailChildren) | |
91 | + { | |
92 | + counted_qty=counted_qty.add(cycleCountDetailChild.getCountedQty()); | |
93 | + ystem_qty=ystem_qty.add(cycleCountDetailChild.getSystemQty()); | |
94 | + gap_qty=gap_qty.add(cycleCountDetailChild.getGapQty()); | |
95 | + } | |
73 | 96 | //修改明细单状态 |
74 | 97 | cycleCountDetail.setEnableStatus(QuantityConstant.CYCLECOUNT_STATUS_REGISTERED); |
75 | - cycleCountDetailService.updateById(cycleCountDetail); | |
98 | + cycleCountDetail.setCountedQty(counted_qty); | |
99 | + cycleCountDetail.setSystemQty(ystem_qty); | |
100 | + cycleCountDetail.setGapQty(gap_qty); | |
76 | 101 | |
102 | + cycleCountDetailService.updateById(cycleCountDetail); | |
103 | + LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); | |
77 | 104 | //修改主单状态 |
78 | 105 | CycleCountHeader tmp = new CycleCountHeader(); |
79 | 106 | tmp.setCode(countDetailChild.getCyclecountheadcode()); |
... | ... | @@ -81,8 +108,12 @@ public class CycleCountDetailChildServiceImpl extends ServiceImpl<CycleCountDeta |
81 | 108 | LambdaQueryWrapper<CycleCountHeader> lambdaQueryWrapper = Wrappers.lambdaQuery(tmp); |
82 | 109 | CycleCountHeader cycleCountHeader = cycleCountHeaderService.getOne(lambdaQueryWrapper); |
83 | 110 | cycleCountHeader.setStatusCyc(QuantityConstant.CYCLECOUNT_STATUS_REGISTERED); |
84 | -// cycleCountHeaderService.updataHeaderStatus(cycleCountHeader.getCode()); | |
111 | + cycleCountHeader.setStocktakingAc(sysUser.getUsername()); | |
85 | 112 | |
86 | - return Result.ok("调整成功"); | |
113 | + Result result = new Result(); | |
114 | + result.setCode(200); | |
115 | + result.setMessage("调整成功"); | |
116 | + result.setResult(cycleCountHeader.getId()); | |
117 | + return result; | |
87 | 118 | } |
88 | 119 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/stocktaking/cycleCountDetail/service/impl/CycleCountDetailServiceImpl.java
... | ... | @@ -119,17 +119,14 @@ public class CycleCountDetailServiceImpl extends ServiceImpl<CycleCountDetailMap |
119 | 119 | inventoryDetailLambdaQueryWrapper.eq(InventoryDetail::getInventoryHeaderId,taskId); |
120 | 120 | List<InventoryDetail> inventoryDetails = inventoryDetailService.list(inventoryDetailLambdaQueryWrapper); |
121 | 121 | |
122 | - LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery(); | |
123 | - locationLambdaQueryWrapper.eq(Location::getCode, inventoryDetails.get(0).getLocationCode()) | |
124 | - .eq(Location::getWarehouseCode, inventoryDetails.get(0).getWarehouseCode()) | |
125 | - .ne(Location::getStatus, QuantityConstant.STATUS_LOCATION_LOCK); | |
126 | - Location location = locationService.getOne(locationLambdaQueryWrapper); | |
127 | - if (StringUtils.isNull(location)) { | |
128 | - return Result.error("库位已锁定!"); | |
129 | - } | |
130 | - | |
131 | - LambdaQueryWrapper<CycleCountDetail> cycleCountDetailLambdaQueryWrapper = Wrappers.lambdaQuery(); | |
132 | - | |
122 | +// LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery(); | |
123 | +// locationLambdaQueryWrapper.eq(Location::getCode, inventoryDetails.get(0).getLocationCode()) | |
124 | +// .eq(Location::getWarehouseCode, inventoryDetails.get(0).getWarehouseCode()) | |
125 | +// .ne(Location::getStatus, QuantityConstant.STATUS_LOCATION_LOCK); | |
126 | +// Location location = locationService.getOne(locationLambdaQueryWrapper); | |
127 | +// if (StringUtils.isNull(location)) { | |
128 | +// return Result.error("库位已锁定!"); | |
129 | +// } | |
133 | 130 | |
134 | 131 | CycleCountDetail cycleCountDetail = new CycleCountDetail(); |
135 | 132 | cycleCountDetail.setCycleCountHeadId(headerId); |
... | ... | @@ -143,9 +140,9 @@ public class CycleCountDetailServiceImpl extends ServiceImpl<CycleCountDetailMap |
143 | 140 | cycleCountDetail.setInventoryHeaderId(inventoryDetails.get(0).getInventoryHeaderId()); |
144 | 141 | cycleCountDetail.setLocationCode(inventoryDetails.get(0).getLocationCode()); |
145 | 142 | cycleCountDetail.setInventorySts(inventoryDetails.get(0).getInventoryStatus()); |
146 | - cycleCountDetail.setSystemQty(inventoryDetails.size()); | |
147 | - cycleCountDetail.setCountedQty(0); | |
148 | - cycleCountDetail.setGapQty(0); | |
143 | + cycleCountDetail.setSystemQty(BigDecimal.ZERO); | |
144 | + cycleCountDetail.setCountedQty(BigDecimal.ZERO); | |
145 | + cycleCountDetail.setGapQty(BigDecimal.ZERO); | |
149 | 146 | cycleCountDetail.setEnableStatus(QuantityConstant.CYCLECOUNT_STATUS_BUILD); |
150 | 147 | this.save(cycleCountDetail); |
151 | 148 | |
... | ... | @@ -293,6 +290,7 @@ public class CycleCountDetailServiceImpl extends ServiceImpl<CycleCountDetailMap |
293 | 290 | result.setCode(200); |
294 | 291 | result.setMessage("盘点任务生成成功"); |
295 | 292 | |
293 | + | |
296 | 294 | return result; |
297 | 295 | } |
298 | 296 | |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/stocktaking/cycleCountHeader/entity/CycleCountHeader.java
... | ... | @@ -75,7 +75,7 @@ public class CycleCountHeader implements Serializable { |
75 | 75 | /**总物料数*/ |
76 | 76 | @Excel(name = "总物料数", width = 15) |
77 | 77 | @ApiModelProperty(value = "总物料数") |
78 | - private Integer totalItems; | |
78 | + private BigDecimal totalItems; | |
79 | 79 | /**审核人*/ |
80 | 80 | @Excel(name = "审核人", width = 15) |
81 | 81 | @ApiModelProperty(value = "审核人") |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/impl/TaskHeaderServiceImpl.java
... | ... | @@ -11,6 +11,7 @@ import java.util.stream.Collectors; |
11 | 11 | |
12 | 12 | import javax.annotation.Resource; |
13 | 13 | |
14 | +import org.apache.poi.hpsf.Decimal; | |
14 | 15 | import org.apache.shiro.SecurityUtils; |
15 | 16 | import org.jeecg.common.api.vo.Result; |
16 | 17 | import org.jeecg.common.system.vo.LoginUser; |
... | ... | @@ -1547,6 +1548,8 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1547 | 1548 | //3.单据list如果差异数量+生成入库单,差异数-生成出库单进行回传类型其他出库单 |
1548 | 1549 | |
1549 | 1550 | |
1551 | + InventoryHeader inventoryHeader = inventoryHeaderService.getById(cycleCountDetail.getInventoryHeaderId()); | |
1552 | + | |
1550 | 1553 | int outboundOrderId=0; |
1551 | 1554 | String outboundOrderCode=null; |
1552 | 1555 | int warehousingOrderId=0; |
... | ... | @@ -1555,6 +1558,17 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1555 | 1558 | |
1556 | 1559 | for (CycleCountDetailChild child : children) |
1557 | 1560 | { |
1561 | + InventoryDetail inventoryDetail = inventoryDetailService.getById(child.getInventoryDetaiId()); | |
1562 | + if (inventoryDetail==null) | |
1563 | + { | |
1564 | + return Result.error("盘点还没完成 库存明细单据就不存在了 可能出现了问题或者所容器没成功"); | |
1565 | + } | |
1566 | + | |
1567 | + inventoryHeader.setTotalQty(inventoryHeader.getTotalQty().add(child.getGapQty())); | |
1568 | + | |
1569 | + inventoryDetail.setQty(child.getCountedQty()); | |
1570 | + inventoryDetailService.updateById(inventoryDetail); | |
1571 | + | |
1558 | 1572 | child.setChildStatus(QuantityConstant.CYCLECOUNT_STATUS_COMPLETED); |
1559 | 1573 | if (child.getGapQty().compareTo(BigDecimal.ZERO) == 1) |
1560 | 1574 | { |
... | ... | @@ -1582,7 +1596,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1582 | 1596 | receiptDetail.setReceiptId(warehousingOrderId); |
1583 | 1597 | receiptDetail.setReceiptCode(warehousingOrderCode); |
1584 | 1598 | receiptDetail.setWarehouseCode(taskHeader.getWarehouseCode()); |
1585 | - receiptDetail.setCompanyCode(null); | |
1599 | + receiptDetail.setCompanyCode(taskHeader.getCompanyCode()); | |
1586 | 1600 | receiptDetail.setMaterialCode(child.getMaterialCode()); |
1587 | 1601 | receiptDetail.setMaterialName(child.getMaterialName()); |
1588 | 1602 | receiptDetail.setMaterialSpec(child.getMaterialSpec()); |
... | ... | @@ -1595,10 +1609,38 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1595 | 1609 | receiptDetail.setStatus(QuantityConstant.RECEIPT_HEADER_COMPLETED); |
1596 | 1610 | receiptDetailService.save(receiptDetail); |
1597 | 1611 | |
1612 | + //增加库存交易记录 | |
1613 | + InventoryTransaction inventoryTransaction=new InventoryTransaction(); | |
1614 | + inventoryTransaction.setWarehouseCode(taskHeader.getWarehouseCode()); | |
1615 | + inventoryTransaction.setCompanyCode(taskHeader.getCompanyCode()); | |
1616 | + inventoryTransaction.setContainerCode(child.getContainerCode()); | |
1617 | + inventoryTransaction.setToLocationCode(child.getLocationCode()); | |
1618 | + inventoryTransaction.setType(QuantityConstant.INVENTORY_TRANSACTION_CYCLEINTO); | |
1619 | + inventoryTransaction.setReceiptId(warehousingOrderId); | |
1620 | + inventoryTransaction.setReceiptDetailId(receiptDetail.getReceiptId()); | |
1621 | + inventoryTransaction.setMaterialCode(child.getMaterialCode()); | |
1622 | + inventoryTransaction.setMaterialName(child.getMaterialName()); | |
1623 | + inventoryTransaction.setMaterialSpec(child.getMaterialSpec()); | |
1624 | + inventoryTransaction.setMaterialUnit(child.getMaterialUnit()); | |
1625 | + inventoryTransaction.setInventoryStatus(child.getInventoryStatus()); | |
1626 | + inventoryTransaction.setQty(child.getCountedQty()); | |
1627 | + inventoryTransaction.setBatch(child.getBatch()); | |
1628 | + inventoryTransaction.setLot(child.getLot()); | |
1629 | + inventoryTransactionService.save(inventoryTransaction); | |
1630 | + | |
1598 | 1631 | } |
1599 | 1632 | |
1633 | + | |
1634 | + | |
1600 | 1635 | if (child.getGapQty().compareTo(BigDecimal.ZERO) == -1) |
1601 | 1636 | { |
1637 | + | |
1638 | + if (child.getGapQty().abs().compareTo(child.getSystemQty()) > -1) | |
1639 | + { | |
1640 | + inventoryDetailService.removeById(child.getInventoryDetaiId()); | |
1641 | + } | |
1642 | + | |
1643 | + | |
1602 | 1644 | if (outboundOrderId==0) |
1603 | 1645 | { |
1604 | 1646 | ShipmentHeader shipmentHeader = new ShipmentHeader(); |
... | ... | @@ -1624,7 +1666,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1624 | 1666 | shipmentDetail.setShipmentId(outboundOrderId); |
1625 | 1667 | shipmentDetail.setShipmentCode(outboundOrderCode); |
1626 | 1668 | shipmentDetail.setWarehouseCode(taskHeader.getWarehouseCode()); |
1627 | - shipmentDetail.setCompanyCode(null); | |
1669 | + shipmentDetail.setCompanyCode(taskHeader.getCompanyCode()); | |
1628 | 1670 | shipmentDetail.setMaterialCode(child.getMaterialCode()); |
1629 | 1671 | shipmentDetail.setMaterialName(child.getMaterialName()); |
1630 | 1672 | shipmentDetail.setMaterialSpec(child.getMaterialSpec()); |
... | ... | @@ -1636,11 +1678,35 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1636 | 1678 | shipmentDetail.setLot(child.getLot()); |
1637 | 1679 | shipmentDetail.setStatus(QuantityConstant.RECEIPT_HEADER_COMPLETED); |
1638 | 1680 | shipmentDetailService.save(shipmentDetail); |
1681 | + | |
1682 | + InventoryTransaction inventoryTransaction=new InventoryTransaction(); | |
1683 | + inventoryTransaction.setWarehouseCode(taskHeader.getWarehouseCode()); | |
1684 | + inventoryTransaction.setCompanyCode(taskHeader.getCompanyCode()); | |
1685 | + inventoryTransaction.setContainerCode(child.getContainerCode()); | |
1686 | + inventoryTransaction.setFromLocationCode(child.getLocationCode()); | |
1687 | + inventoryTransaction.setType(QuantityConstant.INVENTORY_TRANSACTION_CYCLEOUT); | |
1688 | + inventoryTransaction.setShipmentId(outboundOrderId); | |
1689 | + inventoryTransaction.setShipmentDetailId(shipmentDetail.getId()); | |
1690 | + inventoryTransaction.setMaterialCode(child.getMaterialCode()); | |
1691 | + inventoryTransaction.setMaterialName(child.getMaterialName()); | |
1692 | + inventoryTransaction.setMaterialSpec(child.getMaterialSpec()); | |
1693 | + inventoryTransaction.setMaterialUnit(child.getMaterialUnit()); | |
1694 | + inventoryTransaction.setInventoryStatus(child.getInventoryStatus()); | |
1695 | + inventoryTransaction.setQty(child.getCountedQty()); | |
1696 | + inventoryTransaction.setBatch(child.getBatch()); | |
1697 | + inventoryTransaction.setLot(child.getLot()); | |
1698 | + inventoryTransactionService.save(inventoryTransaction); | |
1639 | 1699 | } |
1640 | 1700 | cycleCountDetailChildService.updateById(child); |
1641 | 1701 | } |
1642 | 1702 | |
1643 | 1703 | |
1704 | + if (inventoryHeader.getTotalQty().compareTo(BigDecimal.ZERO)<1) | |
1705 | + { | |
1706 | + inventoryHeaderService.removeById(inventoryHeader); | |
1707 | + } | |
1708 | + | |
1709 | + inventoryHeaderService.updateById(inventoryHeader); | |
1644 | 1710 | |
1645 | 1711 | //4.完成当前任务 |
1646 | 1712 | if (!taskHeaderService.saveOrUpdate(taskHeader)) { |
... | ... | @@ -1658,6 +1724,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1658 | 1724 | //释放库位 |
1659 | 1725 | locationService.updateStatus(cycleCountDetail.getLocationCode(), |
1660 | 1726 | QuantityConstant.STATUS_LOCATION_EMPTY, taskHeader.getWarehouseCode()); |
1727 | + | |
1661 | 1728 | return Result.OK("完成盘点任务成功"); |
1662 | 1729 | } |
1663 | 1730 | |
... | ... |