Commit 228c6760656d5605aff11c812f9aaac3ec342971
1 parent
6c165032
出库单详情编辑和删除移到service
Showing
3 changed files
with
63 additions
and
43 deletions
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentHeader/controller/ShipmentHeaderController.java
@@ -252,27 +252,8 @@ public class ShipmentHeaderController extends JeecgController<ShipmentHeader, IS | @@ -252,27 +252,8 @@ public class ShipmentHeaderController extends JeecgController<ShipmentHeader, IS | ||
252 | @ApiOperation(value = "出库单详情-编辑", notes = "出库单详情-编辑") | 252 | @ApiOperation(value = "出库单详情-编辑", notes = "出库单详情-编辑") |
253 | @RequiresPermissions("shipmentDetail:edit") | 253 | @RequiresPermissions("shipmentDetail:edit") |
254 | @RequestMapping(value = "/editShipmentDetail", method = {RequestMethod.PUT, RequestMethod.POST}) | 254 | @RequestMapping(value = "/editShipmentDetail", method = {RequestMethod.PUT, RequestMethod.POST}) |
255 | - public Result<String> editShipmentDetail(@RequestBody ShipmentDetail shipmentDetail) { | ||
256 | - if (shipmentDetail == null) { | ||
257 | - return Result.error("修改详情失败, 没有找到出库单详情"); | ||
258 | - } | ||
259 | - ShipmentHeader shipmentHeader = shipmentHeaderService.getById(shipmentDetail.getShipmentId()); | ||
260 | - if (shipmentHeader == null) { | ||
261 | - return Result.error("修改详情失败, 没有找到出库单"); | ||
262 | - } | ||
263 | - if (shipmentHeader.getFirstStatus().intValue() != QuantityConstant.SHIPMENT_HEADER_BUILD) { | ||
264 | - return Result.error("修改详情失败, 出库单必须是新建状态才能修改详情"); | ||
265 | - } | ||
266 | - boolean success = shipmentDetailService.updateById(shipmentDetail); | ||
267 | - if (!success) { | ||
268 | - throw new JeecgBootException("修改详情失败"); | ||
269 | - } | ||
270 | - success = shipmentHeaderService.updateShipmentHeader(shipmentDetail.getShipmentId()); | ||
271 | - if (!success) { | ||
272 | - throw new JeecgBootException("修改详情时,更新出库单头数量失败"); | ||
273 | - } | ||
274 | - LogRecordContext.putVariable("extraJsonString", JSON.toJSONString(Collections.singletonList(shipmentDetail)));// 操作日志收集 | ||
275 | - return Result.OK("编辑成功!"); | 255 | + public Result<?> editShipmentDetail(@RequestBody ShipmentDetail shipmentDetail) { |
256 | + return shipmentHeaderService.updateShipmentHeader(shipmentDetail); | ||
276 | } | 257 | } |
277 | 258 | ||
278 | /** | 259 | /** |
@@ -285,28 +266,8 @@ public class ShipmentHeaderController extends JeecgController<ShipmentHeader, IS | @@ -285,28 +266,8 @@ public class ShipmentHeaderController extends JeecgController<ShipmentHeader, IS | ||
285 | @RequiresPermissions("shipmentDetail:delete") | 266 | @RequiresPermissions("shipmentDetail:delete") |
286 | @DeleteMapping(value = "/deleteShipmentDetail") | 267 | @DeleteMapping(value = "/deleteShipmentDetail") |
287 | @OperationLog(bizId = "''", bizType = "'出库单追踪'", tag = "'详情删除'", extra = "#extraJsonString", msg = "''", recordReturnValue = true) | 268 | @OperationLog(bizId = "''", bizType = "'出库单追踪'", tag = "'详情删除'", extra = "#extraJsonString", msg = "''", recordReturnValue = true) |
288 | - public Result<String> deleteShipmentDetail(@RequestParam(name = "id", required = true) String id) { | ||
289 | - ShipmentDetail shipmentDetail = shipmentDetailService.getById(id); | ||
290 | - if (shipmentDetail == null) { | ||
291 | - return Result.error("删除失败, 没有找到出库单详情"); | ||
292 | - } | ||
293 | - ShipmentHeader shipmentHeader = shipmentHeaderService.getById(shipmentDetail.getShipmentId()); | ||
294 | - if (shipmentHeader == null) { | ||
295 | - return Result.error("删除失败, 没有找到出库单"); | ||
296 | - } | ||
297 | - if (shipmentHeader.getFirstStatus().intValue() != QuantityConstant.SHIPMENT_HEADER_BUILD) { | ||
298 | - return Result.error("删除失败, 出库单必须是新建状态才能删除详情"); | ||
299 | - } | ||
300 | - boolean success = shipmentDetailService.removeById(id); | ||
301 | - if (!success) { | ||
302 | - throw new JeecgBootException("删除详情失败"); | ||
303 | - } | ||
304 | - success = shipmentHeaderService.updateShipmentHeader(shipmentDetail.getShipmentId()); | ||
305 | - if (!success) { | ||
306 | - throw new JeecgBootException("更新出库单头数量失败"); | ||
307 | - } | ||
308 | - LogRecordContext.putVariable("extraJsonString", JSON.toJSONString(Collections.singletonList(shipmentDetail)));// 操作日志收集 | ||
309 | - return Result.OK("删除成功!"); | 269 | + public Result<?> deleteShipmentDetail(@RequestParam(name = "id", required = true) String id) { |
270 | + return shipmentHeaderService.deleteShipmentDetail(id); | ||
310 | } | 271 | } |
311 | 272 | ||
312 | /** | 273 | /** |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentHeader/service/IShipmentHeaderService.java
@@ -7,6 +7,7 @@ import java.util.List; | @@ -7,6 +7,7 @@ import java.util.List; | ||
7 | import org.jeecg.common.api.vo.Result; | 7 | import org.jeecg.common.api.vo.Result; |
8 | import org.jeecg.modules.wms.config.waveConfig.entity.WaveConfig; | 8 | import org.jeecg.modules.wms.config.waveConfig.entity.WaveConfig; |
9 | import org.jeecg.modules.wms.config.waveConfig.entity.WaveConfigDetail; | 9 | import org.jeecg.modules.wms.config.waveConfig.entity.WaveConfigDetail; |
10 | +import org.jeecg.modules.wms.shipment.shipmentHeader.entity.ShipmentDetail; | ||
10 | import org.jeecg.modules.wms.shipment.shipmentHeader.entity.ShipmentHeader; | 11 | import org.jeecg.modules.wms.shipment.shipmentHeader.entity.ShipmentHeader; |
11 | 12 | ||
12 | import com.baomidou.mybatisplus.extension.service.IService; | 13 | import com.baomidou.mybatisplus.extension.service.IService; |
@@ -50,4 +51,8 @@ public interface IShipmentHeaderService extends IService<ShipmentHeader> { | @@ -50,4 +51,8 @@ public interface IShipmentHeaderService extends IService<ShipmentHeader> { | ||
50 | Result autoShipmentAdvice(String shipmentCode, String warehouseCode); | 51 | Result autoShipmentAdvice(String shipmentCode, String warehouseCode); |
51 | 52 | ||
52 | Result createShipment(WaveConfig waveConfig, List<WaveConfigDetail> waveConfigDetailList); | 53 | Result createShipment(WaveConfig waveConfig, List<WaveConfigDetail> waveConfigDetailList); |
54 | + | ||
55 | + Result updateShipmentHeader(ShipmentDetail shipmentDetail); | ||
56 | + | ||
57 | + Result deleteShipmentDetail(String shipmentDetailId); | ||
53 | } | 58 | } |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentHeader/service/impl/ShipmentHeaderServiceImpl.java
@@ -4,12 +4,14 @@ import java.io.Serializable; | @@ -4,12 +4,14 @@ import java.io.Serializable; | ||
4 | import java.math.BigDecimal; | 4 | import java.math.BigDecimal; |
5 | import java.text.SimpleDateFormat; | 5 | import java.text.SimpleDateFormat; |
6 | import java.util.Collection; | 6 | import java.util.Collection; |
7 | +import java.util.Collections; | ||
7 | import java.util.Date; | 8 | import java.util.Date; |
8 | import java.util.List; | 9 | import java.util.List; |
9 | import java.util.stream.Collectors; | 10 | import java.util.stream.Collectors; |
10 | 11 | ||
11 | import javax.annotation.Resource; | 12 | import javax.annotation.Resource; |
12 | 13 | ||
14 | +import com.alibaba.fastjson.JSON; | ||
13 | import org.jeecg.common.api.vo.Result; | 15 | import org.jeecg.common.api.vo.Result; |
14 | import org.jeecg.common.exception.JeecgBootException; | 16 | import org.jeecg.common.exception.JeecgBootException; |
15 | import org.jeecg.modules.wms.config.container.service.IContainerService; | 17 | import org.jeecg.modules.wms.config.container.service.IContainerService; |
@@ -256,6 +258,7 @@ public class ShipmentHeaderServiceImpl extends ServiceImpl<ShipmentHeaderMapper, | @@ -256,6 +258,7 @@ public class ShipmentHeaderServiceImpl extends ServiceImpl<ShipmentHeaderMapper, | ||
256 | } | 258 | } |
257 | 259 | ||
258 | @Override | 260 | @Override |
261 | + @Transactional(rollbackFor = Exception.class) | ||
259 | public boolean updateShipmentHeader(Integer shipmentId) { | 262 | public boolean updateShipmentHeader(Integer shipmentId) { |
260 | List<ShipmentDetail> shipmentDetailList = shipmentDetailService.getShipmentDetailListByShipmentId(shipmentId); | 263 | List<ShipmentDetail> shipmentDetailList = shipmentDetailService.getShipmentDetailListByShipmentId(shipmentId); |
261 | ShipmentHeader shipmentHeader = shipmentHeaderService.getById(shipmentId); | 264 | ShipmentHeader shipmentHeader = shipmentHeaderService.getById(shipmentId); |
@@ -607,6 +610,57 @@ public class ShipmentHeaderServiceImpl extends ServiceImpl<ShipmentHeaderMapper, | @@ -607,6 +610,57 @@ public class ShipmentHeaderServiceImpl extends ServiceImpl<ShipmentHeaderMapper, | ||
607 | } | 610 | } |
608 | 611 | ||
609 | @Override | 612 | @Override |
613 | + @Transactional(rollbackFor = Exception.class) | ||
614 | + public Result updateShipmentHeader(ShipmentDetail shipmentDetail) { | ||
615 | + if (shipmentDetail == null) { | ||
616 | + return Result.error("修改详情失败, 没有找到出库单详情"); | ||
617 | + } | ||
618 | + ShipmentHeader shipmentHeader = shipmentHeaderService.getById(shipmentDetail.getShipmentId()); | ||
619 | + if (shipmentHeader == null) { | ||
620 | + return Result.error("修改详情失败, 没有找到出库单"); | ||
621 | + } | ||
622 | + if (shipmentHeader.getFirstStatus().intValue() != QuantityConstant.SHIPMENT_HEADER_BUILD) { | ||
623 | + return Result.error("修改详情失败, 出库单必须是新建状态才能修改详情"); | ||
624 | + } | ||
625 | + boolean success = shipmentDetailService.updateById(shipmentDetail); | ||
626 | + if (!success) { | ||
627 | + throw new JeecgBootException("修改详情失败"); | ||
628 | + } | ||
629 | + success = shipmentHeaderService.updateShipmentHeader(shipmentDetail.getShipmentId()); | ||
630 | + if (!success) { | ||
631 | + throw new JeecgBootException("修改详情时,更新出库单头数量失败"); | ||
632 | + } | ||
633 | + LogRecordContext.putVariable("extraJsonString", JSON.toJSONString(Collections.singletonList(shipmentDetail)));// 操作日志收集 | ||
634 | + return Result.OK("编辑成功!"); | ||
635 | + } | ||
636 | + | ||
637 | + @Override | ||
638 | + @Transactional(rollbackFor = Exception.class) | ||
639 | + public Result deleteShipmentDetail(String shipmentDetailId) { | ||
640 | + ShipmentDetail shipmentDetail = shipmentDetailService.getById(shipmentDetailId); | ||
641 | + if (shipmentDetail == null) { | ||
642 | + return Result.error("删除失败, 没有找到出库单详情"); | ||
643 | + } | ||
644 | + ShipmentHeader shipmentHeader = shipmentHeaderService.getById(shipmentDetail.getShipmentId()); | ||
645 | + if (shipmentHeader == null) { | ||
646 | + return Result.error("删除失败, 没有找到出库单"); | ||
647 | + } | ||
648 | + if (shipmentHeader.getFirstStatus().intValue() != QuantityConstant.SHIPMENT_HEADER_BUILD) { | ||
649 | + return Result.error("删除失败, 出库单必须是新建状态才能删除详情"); | ||
650 | + } | ||
651 | + boolean success = shipmentDetailService.removeById(shipmentDetailId); | ||
652 | + if (!success) { | ||
653 | + throw new JeecgBootException("删除详情失败"); | ||
654 | + } | ||
655 | + success = shipmentHeaderService.updateShipmentHeader(shipmentDetail.getShipmentId()); | ||
656 | + if (!success) { | ||
657 | + throw new JeecgBootException("更新出库单头数量失败"); | ||
658 | + } | ||
659 | + LogRecordContext.putVariable("extraJsonString", JSON.toJSONString(Collections.singletonList(shipmentDetail)));// 操作日志收集 | ||
660 | + return Result.OK("删除成功!"); | ||
661 | + } | ||
662 | + | ||
663 | + @Override | ||
610 | public boolean updateById(ShipmentHeader shipmentHeader) { | 664 | public boolean updateById(ShipmentHeader shipmentHeader) { |
611 | LambdaQueryWrapper<ShipmentHeader> shipmentHeaderLambdaQueryWrapper = Wrappers.lambdaQuery(); | 665 | LambdaQueryWrapper<ShipmentHeader> shipmentHeaderLambdaQueryWrapper = Wrappers.lambdaQuery(); |
612 | shipmentHeaderLambdaQueryWrapper.eq(ShipmentHeader::getId, shipmentHeader.getId()) | 666 | shipmentHeaderLambdaQueryWrapper.eq(ShipmentHeader::getId, shipmentHeader.getId()) |