Commit 759061a76deead8a2469adfcd9d1abd2ea807dbf
1 parent
71df7cff
更新入库单数量、更新出库单数量
Showing
10 changed files
with
132 additions
and
15 deletions
jeecg-boot-master/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/wms/receipt/receiptContainerHeader/service/impl/ReceiptContainerHeaderServiceImpl.java
... | ... | @@ -292,10 +292,12 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
292 | 292 | return false; |
293 | 293 | } |
294 | 294 | int receiptContainerStatus = receiptContainerHeader.getStatus(); |
295 | - if(receiptContainerStatus == QuantityConstant.RECEIPT_CONTAINER_TASK) { | |
296 | - throw new ServiceException("取消入库任务时, "); | |
295 | + if(receiptContainerStatus != QuantityConstant.RECEIPT_CONTAINER_TASK) { | |
296 | + throw new ServiceException("取消入库任务时, 任务状态不为生成任务状态"); | |
297 | 297 | } |
298 | 298 | receiptContainerHeader.setStatus(QuantityConstant.RECEIPT_CONTAINER_BUILD); |
299 | + // 取消任务后,不指定组盘库位 | |
300 | + receiptContainerHeader.setToLocationCode(QuantityConstant.EMPTY_STRING); | |
299 | 301 | boolean success = receiptContainerHeaderService.updateById(receiptContainerHeader); |
300 | 302 | if(!success) { |
301 | 303 | throw new ServiceException("取消入库任务时, 更新入库组盘头失败"); |
... | ... |
jeecg-boot-master/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/wms/receipt/receiptHeader/controller/ReceiptHeaderController.java
1 | 1 | package org.jeecg.modules.wms.receipt.receiptHeader.controller; |
2 | 2 | |
3 | +import com.aliyun.oss.ServiceException; | |
3 | 4 | import org.jeecg.common.system.query.QueryGenerator; |
4 | 5 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
5 | 6 | import com.baomidou.mybatisplus.core.metadata.IPage; |
... | ... | @@ -219,7 +220,25 @@ public class ReceiptHeaderController extends JeecgController<ReceiptHeader, IRec |
219 | 220 | @ApiOperation(value="入库单详情-通过id删除", notes="入库单详情-通过id删除") |
220 | 221 | @DeleteMapping(value = "/deleteReceiptDetail") |
221 | 222 | public Result<String> deleteReceiptDetail(@RequestParam(name="id",required=true) String id) { |
222 | - receiptDetailService.removeById(id); | |
223 | + ReceiptDetail receiptDetail = receiptDetailService.getById(id); | |
224 | + if(receiptDetail == null) { | |
225 | + return Result.error("删除失败, 没有找到入库单详情"); | |
226 | + } | |
227 | + ReceiptHeader receiptHeader = receiptHeaderService.getById(receiptDetail.getReceiptId()); | |
228 | + if(receiptHeader == null) { | |
229 | + return Result.error("删除失败, 没有找到入库单"); | |
230 | + } | |
231 | + if(receiptHeader.getFirstStatus().intValue() != QuantityConstant.RECEIPT_HEADER_BUILD) { | |
232 | + return Result.error("删除失败, 入库单必须是新建状态才能删除详情"); | |
233 | + } | |
234 | + boolean success = receiptDetailService.removeById(id); | |
235 | + if(!success) { | |
236 | + throw new ServiceException("删除详情失败"); | |
237 | + } | |
238 | + success = receiptHeaderService.updateReceiptHeader(receiptDetail.getReceiptId()); | |
239 | + if(!success) { | |
240 | + throw new ServiceException("更新入库单头数量失败"); | |
241 | + } | |
223 | 242 | return Result.OK("删除成功!"); |
224 | 243 | } |
225 | 244 | |
... | ... |
jeecg-boot-master/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/wms/receipt/receiptHeader/service/IReceiptHeaderService.java
... | ... | @@ -31,4 +31,8 @@ public interface IReceiptHeaderService extends IService<ReceiptHeader> { |
31 | 31 | public String createCode(String receiptType); |
32 | 32 | |
33 | 33 | public boolean updateReceiptHeaderStatus(Integer id); |
34 | + | |
35 | + public boolean updateReceiptHeader(Integer id); | |
36 | + | |
37 | + | |
34 | 38 | } |
... | ... |
jeecg-boot-master/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/wms/receipt/receiptHeader/service/impl/ReceiptDetailServiceImpl.java
1 | 1 | package org.jeecg.modules.wms.receipt.receiptHeader.service.impl; |
2 | 2 | |
3 | +import com.aliyun.oss.ServiceException; | |
3 | 4 | import org.jeecg.common.api.vo.Result; |
4 | 5 | import org.jeecg.modules.wms.config.material.entity.Material; |
5 | 6 | import org.jeecg.modules.wms.config.material.service.IMaterialService; |
... | ... | @@ -47,6 +48,9 @@ public class ReceiptDetailServiceImpl extends ServiceImpl<ReceiptDetailMapper, R |
47 | 48 | if(receiptHeader == null) { |
48 | 49 | return Result.error("添加失败,没有找到入库单头"); |
49 | 50 | } |
51 | + if(receiptHeader.getFirstStatus().intValue() != QuantityConstant.RECEIPT_HEADER_BUILD) { | |
52 | + return Result.error("添加失败,入库单非创建状态不能新增详情"); | |
53 | + } | |
50 | 54 | String receiptCode = receiptHeader.getCode(); |
51 | 55 | if(StringUtils.isEmpty(receiptCode)) { |
52 | 56 | return Result.error("添加失败,没有找到入库单编码"); |
... | ... | @@ -68,9 +72,13 @@ public class ReceiptDetailServiceImpl extends ServiceImpl<ReceiptDetailMapper, R |
68 | 72 | receiptDetail.setMaterialSpec(materialSpec); |
69 | 73 | receiptDetail.setMaterialUnit(materialUnit); |
70 | 74 | receiptDetail.setStatus(QuantityConstant.RECEIPT_HEADER_BUILD); |
71 | - boolean result = receiptDetailService.save(receiptDetail); | |
72 | - if(!result) { | |
73 | - return Result.error("添加失败, 保存入库单详情的时候报错"); | |
75 | + boolean success = receiptDetailService.save(receiptDetail); | |
76 | + if(!success) { | |
77 | + throw new ServiceException("添加失败, 保存入库单详情的时候报错"); | |
78 | + } | |
79 | + success = receiptHeaderService.updateReceiptHeader(receiptDetail.getReceiptId()); | |
80 | + if(!success) { | |
81 | + throw new ServiceException("添加失败, 保存入库单详失败"); | |
74 | 82 | } |
75 | 83 | return Result.OK("添加成功!"); |
76 | 84 | } |
... | ... |
jeecg-boot-master/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/wms/receipt/receiptHeader/service/impl/ReceiptHeaderServiceImpl.java
... | ... | @@ -23,6 +23,7 @@ import org.springframework.transaction.annotation.Transactional; |
23 | 23 | |
24 | 24 | import javax.annotation.Resource; |
25 | 25 | import java.io.Serializable; |
26 | +import java.math.BigDecimal; | |
26 | 27 | import java.text.SimpleDateFormat; |
27 | 28 | import java.util.Date; |
28 | 29 | import java.util.List; |
... | ... | @@ -166,4 +167,28 @@ public class ReceiptHeaderServiceImpl extends ServiceImpl<ReceiptHeaderMapper, R |
166 | 167 | boolean result = receiptHeaderService.updateById(receiptHeader); |
167 | 168 | return result; |
168 | 169 | } |
170 | + | |
171 | + @Override | |
172 | + public boolean updateReceiptHeader(Integer id) { | |
173 | + LambdaQueryWrapper<ReceiptDetail> receiptDetailLambdaQueryWrapper = Wrappers.lambdaQuery(); | |
174 | + receiptDetailLambdaQueryWrapper.eq(ReceiptDetail::getReceiptId, id); | |
175 | + List<ReceiptDetail> receiptDetailList = receiptDetailService.list(receiptDetailLambdaQueryWrapper); | |
176 | + ReceiptHeader receiptHeader = receiptHeaderService.getById(id); | |
177 | + if(receiptHeader == null) { | |
178 | + return false; | |
179 | + } | |
180 | + BigDecimal totalQty = new BigDecimal(0); | |
181 | + int totalLines = 0; | |
182 | + for(ReceiptDetail receiptDetail : receiptDetailList) { | |
183 | + totalLines++; | |
184 | + totalQty = totalQty.add(receiptDetail.getQty()); | |
185 | + } | |
186 | + receiptHeader.setTotalqty(totalQty); | |
187 | + receiptHeader.setTotallines(totalLines); | |
188 | + if (!receiptHeaderService.updateById(receiptHeader)){ | |
189 | + return false; | |
190 | + } | |
191 | + return true; | |
192 | + } | |
193 | + | |
169 | 194 | } |
... | ... |
jeecg-boot-master/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/wms/shipment/shipmentHeader/controller/ShipmentHeaderController.java
1 | 1 | package org.jeecg.modules.wms.shipment.shipmentHeader.controller; |
2 | 2 | |
3 | +import com.aliyun.oss.ServiceException; | |
3 | 4 | import org.jeecg.common.system.query.QueryGenerator; |
4 | 5 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
5 | 6 | import com.baomidou.mybatisplus.core.metadata.IPage; |
... | ... | @@ -8,11 +9,14 @@ import lombok.extern.slf4j.Slf4j; |
8 | 9 | import org.jeecg.common.system.base.controller.JeecgController; |
9 | 10 | import org.jeecg.common.api.vo.Result; |
10 | 11 | import org.jeecg.common.system.util.JwtUtil; |
12 | +import org.jeecg.modules.wms.receipt.receiptHeader.entity.ReceiptDetail; | |
13 | +import org.jeecg.modules.wms.receipt.receiptHeader.entity.ReceiptHeader; | |
11 | 14 | import org.jeecg.modules.wms.shipment.shipmentHeader.entity.ShipmentDetail; |
12 | 15 | import org.jeecg.modules.wms.shipment.shipmentHeader.entity.ShipmentHeader; |
13 | 16 | import org.jeecg.modules.wms.shipment.shipmentHeader.service.IShipmentDetailService; |
14 | 17 | import org.jeecg.modules.wms.shipment.shipmentHeader.service.IShipmentHeaderService; |
15 | 18 | import org.jeecg.utils.StringUtils; |
19 | +import org.jeecg.utils.constant.QuantityConstant; | |
16 | 20 | import org.springframework.beans.factory.annotation.Autowired; |
17 | 21 | import org.springframework.web.bind.annotation.*; |
18 | 22 | import javax.servlet.http.HttpServletRequest; |
... | ... | @@ -206,7 +210,25 @@ public class ShipmentHeaderController extends JeecgController<ShipmentHeader, IS |
206 | 210 | @ApiOperation(value="出库单详情-通过id删除", notes="出库单详情-通过id删除") |
207 | 211 | @DeleteMapping(value = "/deleteShipmentDetail") |
208 | 212 | public Result<String> deleteShipmentDetail(@RequestParam(name="id",required=true) String id) { |
209 | - shipmentDetailService.removeById(id); | |
213 | + ShipmentDetail shipmentDetail = shipmentDetailService.getById(id); | |
214 | + if(shipmentDetail == null) { | |
215 | + return Result.error("删除失败, 没有找到出库单详情"); | |
216 | + } | |
217 | + ShipmentHeader shipmentHeader = shipmentHeaderService.getById(shipmentDetail.getShipmentId()); | |
218 | + if(shipmentHeader == null) { | |
219 | + return Result.error("删除失败, 没有找到出库单"); | |
220 | + } | |
221 | + if(shipmentHeader.getFirstStatus().intValue() != QuantityConstant.SHIPMENT_HEADER_BUILD) { | |
222 | + return Result.error("删除失败, 出库单必须是新建状态才能删除详情"); | |
223 | + } | |
224 | + boolean success = shipmentDetailService.removeById(id); | |
225 | + if(!success) { | |
226 | + throw new ServiceException("删除详情失败"); | |
227 | + } | |
228 | + success = shipmentHeaderService.updateShipmentHeader(shipmentDetail.getShipmentId()); | |
229 | + if(!success) { | |
230 | + throw new ServiceException("更新出库单头数量失败"); | |
231 | + } | |
210 | 232 | return Result.OK("删除成功!"); |
211 | 233 | } |
212 | 234 | |
... | ... |
jeecg-boot-master/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/wms/shipment/shipmentHeader/service/IShipmentDetailService.java
... | ... | @@ -18,4 +18,6 @@ public interface IShipmentDetailService extends IService<ShipmentDetail> { |
18 | 18 | public List<ShipmentDetail> selectByMainId(String mainId); |
19 | 19 | |
20 | 20 | public Result saveShipmentDetail(ShipmentDetail shipmentDetail); |
21 | + | |
22 | + public List<ShipmentDetail> getShipmentDetailListByShipmentId(Integer id); | |
21 | 23 | } |
... | ... |
jeecg-boot-master/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/wms/shipment/shipmentHeader/service/IShipmentHeaderService.java
jeecg-boot-master/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/wms/shipment/shipmentHeader/service/impl/ShipmentDetailServiceImpl.java
1 | 1 | package org.jeecg.modules.wms.shipment.shipmentHeader.service.impl; |
2 | 2 | |
3 | +import com.aliyun.oss.ServiceException; | |
4 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
5 | +import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
3 | 6 | import org.jeecg.common.api.vo.Result; |
4 | 7 | import org.jeecg.modules.wms.config.material.entity.Material; |
5 | 8 | import org.jeecg.modules.wms.config.material.service.IMaterialService; |
... | ... | @@ -69,10 +72,22 @@ public class ShipmentDetailServiceImpl extends ServiceImpl<ShipmentDetailMapper, |
69 | 72 | shipmentDetail.setMaterialSpec(materialSpec); |
70 | 73 | shipmentDetail.setMaterialUnit(materialUnit); |
71 | 74 | shipmentDetail.setStatus(QuantityConstant.RECEIPT_HEADER_BUILD); |
72 | - boolean result = shipmentDetailService.save(shipmentDetail); | |
73 | - if(!result) { | |
74 | - return Result.error("添加失败, 保存出库单详情的时候报错"); | |
75 | + boolean success = shipmentDetailService.save(shipmentDetail); | |
76 | + if(!success) { | |
77 | + throw new ServiceException("添加失败, 保存出库单详情的时候报错"); | |
78 | + } | |
79 | + success = shipmentHeaderService.updateShipmentHeader(shipmentHeader.getId()); | |
80 | + if(!success) { | |
81 | + throw new ServiceException("添加失败, 更新出库单失败"); | |
75 | 82 | } |
76 | 83 | return Result.OK("添加成功!"); |
77 | 84 | } |
85 | + | |
86 | + @Override | |
87 | + public List<ShipmentDetail> getShipmentDetailListByShipmentId(Integer id) { | |
88 | + LambdaQueryWrapper<ShipmentDetail> shipmentDetailLambdaQueryWrapper = Wrappers.lambdaQuery(); | |
89 | + shipmentDetailLambdaQueryWrapper.eq(ShipmentDetail::getShipmentId, id); | |
90 | + List<ShipmentDetail> shipmentDetailList = shipmentDetailService.list(shipmentDetailLambdaQueryWrapper); | |
91 | + return shipmentDetailList; | |
92 | + } | |
78 | 93 | } |
... | ... |
jeecg-boot-master/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/wms/shipment/shipmentHeader/service/impl/ShipmentHeaderServiceImpl.java
... | ... | @@ -152,11 +152,9 @@ public class ShipmentHeaderServiceImpl extends ServiceImpl<ShipmentHeaderMapper, |
152 | 152 | } |
153 | 153 | |
154 | 154 | @Override |
155 | - public boolean updateShipmentHeaderStatus(Integer id) { | |
156 | - LambdaQueryWrapper<ShipmentDetail> shipmentDetailLambdaQueryWrapper = Wrappers.lambdaQuery(); | |
157 | - shipmentDetailLambdaQueryWrapper.eq(ShipmentDetail::getShipmentId, id); | |
158 | - List<ShipmentDetail> shipmentDetailList = shipmentDetailService.list(shipmentDetailLambdaQueryWrapper); | |
159 | - ShipmentHeader shipmentHeader = shipmentHeaderService.getById(id); | |
155 | + public boolean updateShipmentHeaderStatus(Integer shipmentId) { | |
156 | + List<ShipmentDetail> shipmentDetailList = shipmentDetailService.getShipmentDetailListByShipmentId(shipmentId); | |
157 | + ShipmentHeader shipmentHeader = shipmentHeaderService.getById(shipmentId); | |
160 | 158 | if(shipmentHeader == null) { |
161 | 159 | return false; |
162 | 160 | } |
... | ... | @@ -185,4 +183,25 @@ public class ShipmentHeaderServiceImpl extends ServiceImpl<ShipmentHeaderMapper, |
185 | 183 | return result; |
186 | 184 | } |
187 | 185 | |
186 | + @Override | |
187 | + public boolean updateShipmentHeader(Integer shipmentId) { | |
188 | + List<ShipmentDetail> shipmentDetailList = shipmentDetailService.getShipmentDetailListByShipmentId(shipmentId); | |
189 | + ShipmentHeader shipmentHeader = shipmentHeaderService.getById(shipmentId); | |
190 | + if(shipmentHeader == null) { | |
191 | + return false; | |
192 | + } | |
193 | + BigDecimal totalQty = new BigDecimal(0); | |
194 | + int totalLines = 0; | |
195 | + for(ShipmentDetail shipmentDetail : shipmentDetailList) { | |
196 | + totalLines++; | |
197 | + totalQty = totalQty.add(shipmentDetail.getQty()); | |
198 | + } | |
199 | + shipmentHeader.setTotalQty(totalQty); | |
200 | + shipmentHeader.setTotalLines(totalLines); | |
201 | + if (!shipmentHeaderService.updateById(shipmentHeader)){ | |
202 | + return false; | |
203 | + } | |
204 | + return true; | |
205 | + } | |
206 | + | |
188 | 207 | } |
... | ... |