Commit 322f42a9e9cb263eb4c26acaf49bc3ccdb9eb2f2
1 parent
38dc728e
1. 完善盘点代码
2. 分配库位 优先低库位 然后高库位, 优先低层 然后高层
Showing
4 changed files
with
126 additions
and
108 deletions
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/controller/WcsController.java
1 | 1 | package org.jeecg.modules.wms.api.wcs.controller; |
2 | 2 | |
3 | -import java.net.SocketException; | |
4 | - | |
5 | 3 | import javax.annotation.Resource; |
6 | 4 | import javax.servlet.http.HttpServletRequest; |
7 | 5 | |
... | ... | @@ -40,7 +38,7 @@ public class WcsController extends HuahengBaseController { |
40 | 38 | @ResponseBody |
41 | 39 | @ApiOperation("仓位分配") |
42 | 40 | @ApiLogger(apiName = "仓位分配", from = "WCS") |
43 | - @AccessLimit(seconds = 5, maxCount = 5) | |
41 | + @AccessLimit(seconds = 5, maxCount = 10) | |
44 | 42 | public Result warecellAllocation(@RequestBody WarecellDomain warecellDomain, HttpServletRequest req) { |
45 | 43 | String warehouseCode = warecellDomain.getWarehouseCode(); |
46 | 44 | String taskNo = warecellDomain.getTaskNo(); |
... | ... | @@ -51,7 +49,7 @@ public class WcsController extends HuahengBaseController { |
51 | 49 | if (StringUtils.isEmpty(taskNo)) { |
52 | 50 | return Result.error("仓位分配, 任务号为空"); |
53 | 51 | } |
54 | - if (StringUtils.isEmpty(warecellDomain.getZoneCode())) { | |
52 | + if (StringUtils.isEmpty(zoneCode)) { | |
55 | 53 | return Result.error("仓位分配, 目的区域为空"); |
56 | 54 | } |
57 | 55 | if (StringUtils.isEmpty(warecellDomain.getHeight())) { |
... | ... | @@ -146,7 +144,7 @@ public class WcsController extends HuahengBaseController { |
146 | 144 | @ResponseBody |
147 | 145 | @ApiOperation("WCS任务完成") |
148 | 146 | @ApiLogger(apiName = "WCS任务完成", from = "WCS") |
149 | - @AccessLimit(seconds = 5, maxCount = 5) | |
147 | + @AccessLimit(seconds = 5, maxCount = 10) | |
150 | 148 | public Result completeTaskByWMS(@RequestBody TaskEntity taskEntity) { |
151 | 149 | String taskNo = taskEntity.getTaskNo(); |
152 | 150 | String lockKey = taskNo; |
... | ... | @@ -182,7 +180,7 @@ public class WcsController extends HuahengBaseController { |
182 | 180 | @ResponseBody |
183 | 181 | @ApiOperation("到达拣选台") |
184 | 182 | @ApiLogger(apiName = "到达拣选台", from = "WCS") |
185 | - @AccessLimit(seconds = 5, maxCount = 5) | |
183 | + @AccessLimit(seconds = 5, maxCount = 10) | |
186 | 184 | public Result arrivedNotice(@RequestBody ArriveEntity arriveEntity) { |
187 | 185 | String taskNo = arriveEntity.getTaskNo(); |
188 | 186 | String port = arriveEntity.getPort(); |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/LocationAllocationServiceImpl.java
... | ... | @@ -25,7 +25,6 @@ import org.jeecg.utils.StringUtils; |
25 | 25 | import org.jeecg.utils.constant.QuantityConstant; |
26 | 26 | import org.springframework.stereotype.Service; |
27 | 27 | import org.springframework.transaction.annotation.Transactional; |
28 | -import org.springframework.util.StopWatch; | |
29 | 28 | |
30 | 29 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
31 | 30 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
... | ... | @@ -106,7 +105,7 @@ public class LocationAllocationServiceImpl implements LocationAllocationService |
106 | 105 | if (StringUtils.isNotEmpty(value)) { |
107 | 106 | searchNumber = Integer.parseInt(value); |
108 | 107 | } |
109 | - String lastString = "ORDER BY layer asc, id asc limit " + searchNumber; | |
108 | + String lastString = "ORDER BY high asc, layer asc, id asc limit " + searchNumber; | |
110 | 109 | List<Integer> removeRoadWays = new ArrayList<>(); |
111 | 110 | // 寻找可用巷道,空闲的空库位低于设定值,那么这个巷道就不能用来分配库位 |
112 | 111 | for (Integer roadWay : roadWays) { |
... | ... | @@ -176,12 +175,13 @@ public class LocationAllocationServiceImpl implements LocationAllocationService |
176 | 175 | List<Location> locationList = locationService.getLocationListByZoneCode(zoneCode, warehouseCode); |
177 | 176 | roadWays = locationList.stream().map(Location::getRoadWay).distinct().collect(toList()); |
178 | 177 | } |
178 | + String lastString = "ORDER BY high asc, layer asc, id asc limit 1"; | |
179 | 179 | Integer roadWay = locationAllocationService.getRoadWay(roadWays, warehouseCode); |
180 | 180 | LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery(); |
181 | 181 | locationLambdaQueryWrapper.eq(Location::getZoneCode, zoneCode).eq(Location::getWarehouseCode, warehouseCode).eq(Location::getRoadWay, roadWay) |
182 | 182 | .eq(Location::getStatus, QuantityConstant.STATUS_LOCATION_EMPTY).ge(Location::getHigh, high) |
183 | 183 | .eq(StringUtils.isNotEmpty(materialAreaCode), Location::getMaterialAreaCode, materialAreaCode).in(Location::getLocationTypeCode, locationTypeCodeList) |
184 | - .eq(Location::getContainerCode, QuantityConstant.EMPTY_STRING).last("ORDER BY layer asc, id asc limit 1"); | |
184 | + .eq(Location::getContainerCode, QuantityConstant.EMPTY_STRING).last(lastString); | |
185 | 185 | // 单伸位逻辑简单,只需要找到一个空闲库位 |
186 | 186 | Location location = locationService.getOne(locationLambdaQueryWrapper); |
187 | 187 | if (location == null) { |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/stocktaking/cycleCountHeader/service/impl/CycleCountHeaderServiceImpl.java
1 | 1 | package org.jeecg.modules.wms.stocktaking.cycleCountHeader.service.impl; |
2 | 2 | |
3 | -import org.jeecg.common.exception.JeecgBootException; | |
4 | -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
5 | -import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
3 | +import java.text.SimpleDateFormat; | |
4 | +import java.util.Comparator; | |
5 | +import java.util.Date; | |
6 | +import java.util.List; | |
7 | +import java.util.stream.Collectors; | |
8 | + | |
9 | +import javax.annotation.Resource; | |
10 | + | |
6 | 11 | import org.jeecg.common.api.vo.Result; |
7 | -import org.jeecg.modules.wms.config.receiptType.entity.ReceiptType; | |
8 | -import org.jeecg.modules.wms.receipt.receiptHeader.entity.ReceiptHeader; | |
12 | +import org.jeecg.common.exception.JeecgBootException; | |
9 | 13 | import org.jeecg.modules.wms.stocktaking.cycleCountDetail.entity.CycleCountDetail; |
10 | 14 | import org.jeecg.modules.wms.stocktaking.cycleCountDetail.service.impl.CycleCountDetailServiceImpl; |
11 | 15 | import org.jeecg.modules.wms.stocktaking.cycleCountHeader.entity.CycleCountHeader; |
... | ... | @@ -14,29 +18,21 @@ import org.jeecg.modules.wms.stocktaking.cycleCountHeader.service.ICycleCountHea |
14 | 18 | import org.jeecg.utils.StringUtils; |
15 | 19 | import org.jeecg.utils.constant.QuantityConstant; |
16 | 20 | import org.springframework.stereotype.Service; |
17 | - | |
18 | -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |
19 | 21 | import org.springframework.transaction.annotation.Transactional; |
20 | 22 | |
21 | -import javax.annotation.Resource; | |
22 | -import java.text.SimpleDateFormat; | |
23 | -import java.util.Comparator; | |
24 | -import java.util.Date; | |
25 | -import java.util.List; | |
26 | -import java.util.stream.Collectors; | |
23 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
24 | +import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
25 | +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |
27 | 26 | |
28 | 27 | /** |
29 | 28 | * @Description: 盘点主表 |
30 | - * @Author: jeecg-boot | |
31 | - * @Date: 2023-01-30 | |
32 | - * @Version: V1.0 | |
29 | + * @Author: jeecg-boot | |
30 | + * @Date: 2023-01-30 | |
31 | + * @Version: V1.0 | |
33 | 32 | */ |
34 | 33 | @Service |
35 | 34 | public class CycleCountHeaderServiceImpl extends ServiceImpl<CycleCountHeaderMapper, CycleCountHeader> implements ICycleCountHeaderService { |
36 | 35 | |
37 | - | |
38 | - | |
39 | - | |
40 | 36 | @Resource |
41 | 37 | private CycleCountDetailServiceImpl cycleCountDetailService; |
42 | 38 | |
... | ... | @@ -56,55 +52,54 @@ public class CycleCountHeaderServiceImpl extends ServiceImpl<CycleCountHeaderMap |
56 | 52 | } |
57 | 53 | |
58 | 54 | @Override |
55 | + @Transactional | |
59 | 56 | public void updataHeaderStatus(String cycleCountHeaderCode) { |
60 | - //查询明细单状态,然后更新主单状态 | |
61 | - //执行中时,对比主单状态,比主单数值小的不改变主单,明细单大于主单状态时改变主单状态到和明细单相同 | |
62 | - //完成时在全部单据都完成后才能修改主单状态为完成 | |
63 | - //当其中一条明细有差异时,主单为有差异状态 | |
57 | + // 查询明细单状态,然后更新主单状态 | |
58 | + // 执行中时,对比主单状态,比主单数值小的不改变主单,明细单大于主单状态时改变主单状态到和明细单相同 | |
59 | + // 完成时在全部单据都完成后才能修改主单状态为完成 | |
60 | + // 当其中一条明细有差异时,主单为有差异状态 | |
64 | 61 | CycleCountHeader cyclecountHeader = new CycleCountHeader(); |
65 | 62 | cyclecountHeader.setCode(cycleCountHeaderCode); |
66 | 63 | // cyclecountHeader.setWarehouseCode(ShiroUtils.getWarehouseCode()); |
67 | 64 | LambdaQueryWrapper<CycleCountHeader> lamb = Wrappers.lambdaQuery(cyclecountHeader); |
68 | 65 | cyclecountHeader = this.getOne(lamb); |
69 | - if(StringUtils.isNull(cyclecountHeader)){ | |
66 | + if (StringUtils.isNull(cyclecountHeader)) { | |
70 | 67 | throw new JeecgBootException("没有找到盘点主单!"); |
71 | 68 | } |
72 | 69 | CycleCountDetail temp = new CycleCountDetail(); |
73 | 70 | temp.setCycleCountHeadCode(cyclecountHeader.getCode()); |
74 | 71 | temp.setWarehouseCode(cyclecountHeader.getWarehouseCode()); |
75 | - //temp.setCompanyCode(cyclecountHeader.getCompanyCode()); | |
72 | + // temp.setCompanyCode(cyclecountHeader.getCompanyCode()); | |
76 | 73 | LambdaQueryWrapper<CycleCountDetail> lam = Wrappers.lambdaQuery(temp); |
77 | 74 | List<CycleCountDetail> list = cycleCountDetailService.list(lam); |
78 | - if(list.size() < 1){ | |
75 | + if (list.size() < 1) { | |
79 | 76 | throw new JeecgBootException("明细为空!"); |
80 | 77 | } |
81 | - //当有子单的状态为100时触发主单的完成状态 | |
82 | - //100状态只有全部完成才写入主单 | |
83 | - long count100 = list.stream().filter(t-> t.getEnableStatus().equals(QuantityConstant.CYCLECOUNT_STATUS_COMPLETED)).count(); //明细已完成的条数 | |
84 | - if(count100 == list.size() ){ | |
78 | + // 当有子单的状态为100时触发主单的完成状态 | |
79 | + // 100状态只有全部完成才写入主单 | |
80 | + long count100 = list.stream().filter(t -> t.getEnableStatus().equals(QuantityConstant.CYCLECOUNT_STATUS_COMPLETED)).count(); // 明细已完成的条数 | |
81 | + if (count100 == list.size()) { | |
85 | 82 | cyclecountHeader.setStatusCyc(QuantityConstant.CYCLECOUNT_STATUS_COMPLETED); |
86 | 83 | this.updateById(cyclecountHeader); |
87 | 84 | } |
88 | - //有任何子单没有完成则主单不修改为100 | |
89 | - //有到100的子单时,主单的状态一定是100的前一个状态,所以状态不变 | |
90 | - if(count100 == 0){ | |
91 | - //所有子单状态比较主单状态,只有在明细单大于主单状态时才更改主单状态 | |
85 | + // 有任何子单没有完成则主单不修改为100 | |
86 | + // 有到100的子单时,主单的状态一定是100的前一个状态,所以状态不变 | |
87 | + if (count100 == 0) { | |
88 | + // 所有子单状态比较主单状态,只有在明细单大于主单状态时才更改主单状态 | |
92 | 89 | int headerStatus = cyclecountHeader.getStatusCyc(); |
93 | - long count = list.stream().filter(t->t.getEnableStatus() > headerStatus).count(); | |
94 | - if(count > 0 ){ | |
95 | - //stream流取出明细状态中最大的值,赋给主单状态 | |
96 | - List<CycleCountDetail> cycleCountDetailList = list.stream().sorted( | |
97 | - Comparator.comparing(CycleCountDetail::getEnableStatus).reversed()).collect(Collectors.toList()); | |
90 | + long count = list.stream().filter(t -> t.getEnableStatus() > headerStatus).count(); | |
91 | + if (count > 0) { | |
92 | + // stream流取出明细状态中最大的值,赋给主单状态 | |
93 | + List<CycleCountDetail> cycleCountDetailList = | |
94 | + list.stream().sorted(Comparator.comparing(CycleCountDetail::getEnableStatus).reversed()).collect(Collectors.toList()); | |
98 | 95 | cyclecountHeader.setStatusCyc(cycleCountDetailList.get(0).getEnableStatus()); |
99 | 96 | this.updateById(cyclecountHeader); |
100 | 97 | } |
101 | 98 | |
102 | 99 | } |
103 | 100 | |
104 | - | |
105 | 101 | } |
106 | 102 | |
107 | - | |
108 | 103 | @Transactional |
109 | 104 | public String createCode(String receiptType) { |
110 | 105 | String code = null; |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/impl/TaskHeaderServiceImpl.java
... | ... | @@ -1767,6 +1767,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1767 | 1767 | * 盘点完成,传入任务主单,查出任务明细,通过任务明细查找盘点的明细单, |
1768 | 1768 | * 完成任务同时,修改盘点细单和主单的状态,完成后库存锁复位 |
1769 | 1769 | */ |
1770 | + log.info("开始完成盘点任务"); | |
1770 | 1771 | String warehouseCode = taskHeader.getWarehouseCode(); |
1771 | 1772 | String containerCode = taskHeader.getContainerCode(); |
1772 | 1773 | String fromLocationCode = taskHeader.getFromLocationCode(); |
... | ... | @@ -1778,44 +1779,52 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1778 | 1779 | if (StringUtils.isEmpty(toLocationCode)) { |
1779 | 1780 | return Result.error("完成盘点任务时,目标库位号为空"); |
1780 | 1781 | } |
1781 | -// LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal(); | |
1782 | + if (StringUtils.isEmpty(containerCode)) { | |
1783 | + return Result.error("完成盘点任务时,托盘号为空"); | |
1784 | + } | |
1785 | + if (StringUtils.isEmpty(warehouseCode)) { | |
1786 | + return Result.error("完成盘点任务时,仓库编码为空"); | |
1787 | + } | |
1782 | 1788 | taskHeader.setStatus(QuantityConstant.TASK_STATUS_COMPLETED); |
1783 | 1789 | |
1784 | 1790 | // 1.先拿到盘点单主单据 |
1785 | 1791 | CycleCountDetail cycleCountDetail = cycleCountDetailService.getById(taskHeader.getShipmentContainerHeaderId()); |
1786 | - | |
1787 | - if (cycleCountDetail.getGapQty().compareTo(BigDecimal.ZERO) == 0) { | |
1788 | - return Result.error("盘点单据系统实盘数量跟差异数量0,不能完成 单据号" + cycleCountDetail.getCycleCountHeadCode()); | |
1792 | + if (cycleCountDetail == null) { | |
1793 | + return Result.error("完成盘点任务时,盘点单详情为空" + taskHeader.getShipmentContainerHeaderId()); | |
1789 | 1794 | } |
1795 | +// if (cycleCountDetail.getGapQty().compareTo(BigDecimal.ZERO) == 0) { | |
1796 | +// return Result.error("完成盘点任务时,盘点单据系统实盘数量跟差异数量0,不能完成 单据号" + cycleCountDetail.getCycleCountHeadCode()); | |
1797 | +// } | |
1790 | 1798 | |
1791 | 1799 | // 2.盘点单主单据查明细单据list |
1792 | 1800 | LambdaQueryWrapper<CycleCountDetailChild> childLambdaQueryWrapper = new LambdaQueryWrapper<CycleCountDetailChild>(); |
1793 | 1801 | childLambdaQueryWrapper.eq(CycleCountDetailChild::getCycleCountDetailid, cycleCountDetail.getId()); |
1794 | 1802 | List<CycleCountDetailChild> children = cycleCountDetailChildService.list(childLambdaQueryWrapper); |
1795 | - | |
1803 | + if (children.size() == 0) { | |
1804 | + return Result.error("完成盘点任务时,盘点单详情明细为空" + cycleCountDetail.getId()); | |
1805 | + } | |
1796 | 1806 | // 3.单据list如果差异数量+生成入库单,差异数-生成出库单进行回传类型其他出库单 |
1797 | - | |
1798 | 1807 | InventoryHeader inventoryHeader = inventoryHeaderService.getById(cycleCountDetail.getInventoryHeaderId()); |
1799 | - | |
1808 | + if (inventoryHeader == null) { | |
1809 | + return Result.error("完成盘点任务时,没有找到库存头" + cycleCountDetail.getInventoryHeaderId()); | |
1810 | + } | |
1800 | 1811 | int outboundOrderId = 0; |
1801 | 1812 | String outboundOrderCode = null; |
1802 | 1813 | int warehousingOrderId = 0; |
1803 | 1814 | String warehousingOrderCode = null; |
1804 | - | |
1805 | 1815 | for (CycleCountDetailChild child : children) { |
1806 | 1816 | if (!child.getChildStatus().equals(QuantityConstant.CYCLECOUNT_STATUS_REGISTERED)) { |
1807 | 1817 | throw new JeecgBootException("当前任务里面还有没有进行登记的数据,不能完成任务"); |
1808 | 1818 | } |
1809 | - | |
1810 | 1819 | if (child.getInventoryDetaiId() != null) { |
1811 | 1820 | InventoryDetail inventoryDetail = inventoryDetailService.getById(child.getInventoryDetaiId()); |
1812 | 1821 | if (inventoryDetail == null) { |
1813 | 1822 | throw new JeecgBootException("盘点还没完成 库存明细单据就不存在了 可能出现了问题或者所容器没成功"); |
1814 | 1823 | } |
1815 | - inventoryHeader.setLocationCode(toLocationCode); | |
1816 | - inventoryHeader.setTotalQty(inventoryHeader.getTotalQty().add(child.getGapQty())); | |
1817 | - inventoryDetail.setQty(child.getCountedQty()); | |
1818 | - inventoryDetailService.updateById(inventoryDetail); | |
1824 | + success = inventoryDetailService.updateQtyAndTaskQtyAndLocationCode(child.getCountedQty(), BigDecimal.ZERO, toLocationCode, inventoryDetail.getId()); | |
1825 | + if (!success) { | |
1826 | + throw new JeecgBootException("完成盘点任务时, 更新库存详情失败"); | |
1827 | + } | |
1819 | 1828 | } else { |
1820 | 1829 | InventoryDetail inventoryDetail = new InventoryDetail(); |
1821 | 1830 | inventoryDetail.setInventoryHeaderId(inventoryHeader.getId()); |
... | ... | @@ -1832,7 +1841,10 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1832 | 1841 | inventoryDetail.setTaskQty(BigDecimal.ZERO); |
1833 | 1842 | inventoryDetail.setInventoryStatus(child.getInventoryStatus()); |
1834 | 1843 | inventoryDetail.setBatch(child.getBatch()); |
1835 | - inventoryDetailService.save(inventoryDetail); | |
1844 | + success = inventoryDetailService.save(inventoryDetail); | |
1845 | + if (!success) { | |
1846 | + throw new JeecgBootException("完成盘点任务时, 保存库存详情失败"); | |
1847 | + } | |
1836 | 1848 | child.setInventoryDetaiId(inventoryDetail.getId()); |
1837 | 1849 | } |
1838 | 1850 | |
... | ... | @@ -1845,12 +1857,15 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1845 | 1857 | receiptHeader.setType(QuantityConstant.RECEIPT_BILL_TYPE_QTR); |
1846 | 1858 | receiptHeader.setRemark("盘盈 单号" + cycleCountDetail.getCycleCountHeadCode()); |
1847 | 1859 | Result result = receiptHeaderService.saveReceiptHeader(receiptHeader); |
1848 | - if (result.getCode() != 200) { | |
1860 | + if (!result.isSuccess()) { | |
1849 | 1861 | return result; |
1850 | 1862 | } |
1851 | 1863 | receiptHeader.setFirstStatus(QuantityConstant.RECEIPT_HEADER_COMPLETED); |
1852 | 1864 | receiptHeader.setLastStatus(QuantityConstant.RECEIPT_HEADER_COMPLETED); |
1853 | - receiptHeaderService.updateById(receiptHeader); | |
1865 | + success = receiptHeaderService.updateById(receiptHeader); | |
1866 | + if (!success) { | |
1867 | + throw new JeecgBootException("完成盘点任务时, 更新入库表单头失败"); | |
1868 | + } | |
1854 | 1869 | // 生成入库单并且赋值给warehousingOrderId |
1855 | 1870 | warehousingOrderId = receiptHeader.getId(); |
1856 | 1871 | warehousingOrderCode = receiptHeader.getCode(); |
... | ... | @@ -1872,8 +1887,10 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1872 | 1887 | receiptDetail.setBatch(child.getBatch()); |
1873 | 1888 | receiptDetail.setLot(child.getLot()); |
1874 | 1889 | receiptDetail.setStatus(QuantityConstant.RECEIPT_HEADER_COMPLETED); |
1875 | - receiptDetailService.save(receiptDetail); | |
1876 | - | |
1890 | + success = receiptDetailService.save(receiptDetail); | |
1891 | + if (!success) { | |
1892 | + throw new JeecgBootException("完成盘点任务时, 新增入库表单详情失败"); | |
1893 | + } | |
1877 | 1894 | // 增加库存交易记录 |
1878 | 1895 | InventoryTransaction inventoryTransaction = new InventoryTransaction(); |
1879 | 1896 | inventoryTransaction.setWarehouseCode(taskHeader.getWarehouseCode()); |
... | ... | @@ -1891,14 +1908,19 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1891 | 1908 | inventoryTransaction.setQty(child.getCountedQty()); |
1892 | 1909 | inventoryTransaction.setBatch(child.getBatch()); |
1893 | 1910 | inventoryTransaction.setLot(child.getLot()); |
1894 | - inventoryTransactionService.save(inventoryTransaction); | |
1895 | - | |
1911 | + success = inventoryTransactionService.save(inventoryTransaction); | |
1912 | + if (!success) { | |
1913 | + throw new JeecgBootException("完成盘点任务时, 新增库存交易详情失败"); | |
1914 | + } | |
1896 | 1915 | } |
1897 | 1916 | |
1898 | 1917 | if (child.getGapQty().compareTo(BigDecimal.ZERO) == -1) { |
1899 | 1918 | |
1900 | 1919 | if (child.getGapQty().abs().compareTo(child.getSystemQty()) > -1) { |
1901 | - inventoryDetailService.removeById(child.getInventoryDetaiId()); | |
1920 | + success = inventoryDetailService.removeById(child.getInventoryDetaiId()); | |
1921 | + if (!success) { | |
1922 | + throw new JeecgBootException("完成盘点任务时, 删除库存详情失败"); | |
1923 | + } | |
1902 | 1924 | } |
1903 | 1925 | |
1904 | 1926 | if (outboundOrderId == 0) { |
... | ... | @@ -1908,12 +1930,15 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1908 | 1930 | shipmentHeader.setType(QuantityConstant.SHIPMENT_BILL_TYPE_QTC); |
1909 | 1931 | shipmentHeader.setRemark("盘亏 单号" + cycleCountDetail.getCycleCountHeadCode()); |
1910 | 1932 | Result result = shipmentHeaderService.saveShipmentHeader(shipmentHeader); |
1911 | - if (result.getCode() != 200) { | |
1933 | + if (!result.isSuccess()) { | |
1912 | 1934 | return result; |
1913 | 1935 | } |
1914 | 1936 | shipmentHeader.setFirstStatus(QuantityConstant.RECEIPT_HEADER_COMPLETED); |
1915 | 1937 | shipmentHeader.setLastStatus(QuantityConstant.RECEIPT_HEADER_COMPLETED); |
1916 | - shipmentHeaderService.updateById(shipmentHeader); | |
1938 | + success = shipmentHeaderService.updateById(shipmentHeader); | |
1939 | + if (!success) { | |
1940 | + throw new JeecgBootException("完成盘点任务时, 更新出库单详情失败"); | |
1941 | + } | |
1917 | 1942 | // 生成出库单并且赋值给outboundOrderId |
1918 | 1943 | outboundOrderId = shipmentHeader.getId(); |
1919 | 1944 | outboundOrderCode = shipmentHeader.getCode(); |
... | ... | @@ -1935,8 +1960,10 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1935 | 1960 | shipmentDetail.setBatch(child.getBatch()); |
1936 | 1961 | shipmentDetail.setLot(child.getLot()); |
1937 | 1962 | shipmentDetail.setStatus(QuantityConstant.RECEIPT_HEADER_COMPLETED); |
1938 | - shipmentDetailService.save(shipmentDetail); | |
1939 | - | |
1963 | + success = shipmentDetailService.save(shipmentDetail); | |
1964 | + if (!success) { | |
1965 | + throw new JeecgBootException("完成盘点任务时, 保存出库单详情失败"); | |
1966 | + } | |
1940 | 1967 | InventoryTransaction inventoryTransaction = new InventoryTransaction(); |
1941 | 1968 | inventoryTransaction.setWarehouseCode(taskHeader.getWarehouseCode()); |
1942 | 1969 | inventoryTransaction.setCompanyCode(taskHeader.getCompanyCode()); |
... | ... | @@ -1953,51 +1980,49 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1953 | 1980 | inventoryTransaction.setQty(child.getCountedQty()); |
1954 | 1981 | inventoryTransaction.setBatch(child.getBatch()); |
1955 | 1982 | inventoryTransaction.setLot(child.getLot()); |
1956 | - inventoryTransactionService.save(inventoryTransaction); | |
1983 | + success = inventoryTransactionService.save(inventoryTransaction); | |
1984 | + if (!success) { | |
1985 | + throw new JeecgBootException("完成盘点任务时, 保存出库单详情失败"); | |
1986 | + } | |
1987 | + } | |
1988 | + success = cycleCountDetailChildService.updateById(child); | |
1989 | + if (!success) { | |
1990 | + throw new JeecgBootException("完成盘点任务时, 更新盘点详情失败"); | |
1957 | 1991 | } |
1958 | - cycleCountDetailChildService.updateById(child); | |
1959 | 1992 | } |
1960 | 1993 | |
1961 | 1994 | if (inventoryHeader.getTotalQty().compareTo(BigDecimal.ZERO) < 1) { |
1962 | - inventoryHeaderService.removeById(inventoryHeader); | |
1995 | + success = inventoryHeaderService.removeById(inventoryHeader); | |
1996 | + if (!success) { | |
1997 | + throw new JeecgBootException("完成盘点任务时, 删除库存头失败"); | |
1998 | + } | |
1999 | + } else { | |
2000 | + success = inventoryHeaderService.updateLocationCodeById(toLocationCode, cycleCountDetail.getInventoryHeaderId()); | |
2001 | + if (!success) { | |
2002 | + throw new JeecgBootException("完成盘点任务时, 更新库存头失败"); | |
2003 | + } | |
1963 | 2004 | } |
1964 | 2005 | |
1965 | - inventoryHeaderService.updateById(inventoryHeader); | |
1966 | - | |
1967 | - // 4.完成当前任务 | |
1968 | - if (!taskHeaderService.saveOrUpdate(taskHeader)) { | |
1969 | - throw new JeecgBootException("盘点任务单据状态更新失败!"); | |
1970 | - } | |
1971 | 2006 | // 盘点明细状态 |
1972 | 2007 | cycleCountDetail.setEnableStatus(QuantityConstant.CYCLECOUNT_STATUS_COMPLETED); |
1973 | 2008 | cycleCountDetail.setCompletedAt(new Date()); |
1974 | - cycleCountDetailService.updateById(cycleCountDetail); | |
2009 | + success = cycleCountDetailService.updateById(cycleCountDetail); | |
2010 | + if (!success) { | |
2011 | + throw new JeecgBootException("完成盘点任务时, 更新盘点单详情失败"); | |
2012 | + } | |
1975 | 2013 | // 更新主单状态 |
1976 | 2014 | cycleCountHeaderService.updataHeaderStatus(cycleCountDetail.getCycleCountHeadCode()); |
1977 | 2015 | |
1978 | - // 释放库位 | |
1979 | - locationService.updateContainerCodeAndStatus(fromLocationCode, QuantityConstant.EMPTY_STRING, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode); | |
1980 | - | |
1981 | - locationService.updateContainerCodeAndStatus(toLocationCode, containerCode, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode); | |
1982 | - | |
1983 | -// // 还原容器状态 | |
1984 | -// containerService.restoreContainer(cycleCountDetail.getContainerCode(), taskHeader.getWarehouseCode()); | |
1985 | - List<InventoryDetail> inventoryDetailList = inventoryDetailService.getInventoryDetailListByContainerCode(containerCode, warehouseCode); | |
1986 | - if (inventoryDetailList.size() != 0) { | |
1987 | - if (fromLocationCode.equals(toLocationCode)) { | |
1988 | - success = containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode); | |
1989 | - } else { | |
1990 | - success = containerService.updateLocationCodeAndStatus(containerCode, toLocationCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode); | |
1991 | - } | |
1992 | - if (!success) { | |
1993 | - throw new JeecgBootException("完成出库查看任务时,更新容器状态失败"); | |
1994 | - } | |
1995 | - } else { | |
1996 | - success = containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode); | |
1997 | - if (!success) { | |
1998 | - throw new JeecgBootException("完成出库查看任务时,更新容器状态失败"); | |
1999 | - } | |
2016 | + Result result = taskHeaderService.completeTaskUnLockContainerAndLocation(taskHeader.getContainerFillStatus(), QuantityConstant.TASK_TYPE_CHECK_OUT, | |
2017 | + containerCode, fromLocationCode, toLocationCode, warehouseCode); | |
2018 | + if (!result.isSuccess()) { | |
2019 | + throw new JeecgBootException(result.getMessage()); | |
2020 | + } | |
2021 | + success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId()); | |
2022 | + if (!success) { | |
2023 | + throw new JeecgBootException("完成盘点任务时, 更新任务失败"); | |
2000 | 2024 | } |
2025 | + log.info("完成盘点任务"); | |
2001 | 2026 | return Result.OK("完成盘点任务成功"); |
2002 | 2027 | } |
2003 | 2028 | |
... | ... | @@ -2045,10 +2070,10 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
2045 | 2070 | throw new JeecgBootException(result.getMessage()); |
2046 | 2071 | } |
2047 | 2072 | boolean success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId()); |
2048 | - log.info("完成空托盘出库任务" + taskHeader.getId()); | |
2049 | 2073 | if (!success) { |
2050 | 2074 | throw new JeecgBootException("完成空托盘出库任务时, 更新任务失败"); |
2051 | 2075 | } |
2076 | + log.info("完成空托盘出库任务" + taskHeader.getId()); | |
2052 | 2077 | return Result.OK("完成空托盘出库成功"); |
2053 | 2078 | } |
2054 | 2079 | |
... | ... |