| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.param.OpenApiStockOutParam; |
| | | import com.zy.asrs.service.LocDetlService; |
| | | import com.zy.asrs.entity.Order; |
| | | import com.zy.asrs.entity.param.OpenOrderPakinParam; |
| | | import com.zy.asrs.service.OrderDetlService; |
| | | import com.zy.asrs.service.OrderService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | |
| | | /** |
| | | * Created by vincent on 2021/3/19 |
| | | * Created by vincent on 2022/4/8 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/open/api") |
| | | @RequestMapping("open/asrs/") |
| | | public class OpenController { |
| | | |
| | | @Autowired |
| | | private LocDetlService locDetlService; |
| | | private OrderService orderService; |
| | | @Autowired |
| | | private OrderDetlService orderDetlService; |
| | | |
| | | @PostMapping("/stockOut") |
| | | @Transactional |
| | | public R stockOut(@RequestBody List<OpenApiStockOutParam> params){ |
| | | if (!Cools.isEmpty(params)) { |
| | | for (OpenApiStockOutParam param : params) { |
| | | Double sumAnfme = Optional.ofNullable(locDetlService.getSumAnfme(param.getMatnr())).orElse(0.0D); |
| | | if (sumAnfme < param.getAnfme()) { |
| | | throw new CoolException(param.getMatnr() + "物料数量不足,缺货数量:" + (param.getAnfme() - sumAnfme)); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | /** |
| | | * 添加入库单 |
| | | */ |
| | | @PostMapping("order/pakin/default/v1") |
| | | public synchronized R orderCreate(@RequestBody OpenOrderPakinParam param) { |
| | | if (Cools.isEmpty(param)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | |
| | | if (Cools.isEmpty(param.getOrderNo())) { |
| | | return R.error("单据编号[orderNo]不能为空"); |
| | | } |
| | | if (Cools.isEmpty(param.getOrderType())) { |
| | | return R.error("单据类型[orderType]错误"); |
| | | } |
| | | if (Cools.isEmpty(param.getOrderDetails())) { |
| | | return R.error("单据明细[orderDetails]不能为空"); |
| | | } |
| | | Order order = orderService.selectByNo(param.getOrderNo()); |
| | | if (!Cools.isEmpty(order)) { |
| | | return R.error(param.getOrderNo() + "单据已存在,请勿重复提交"); |
| | | } |
| | | |
| | | return R.ok(); |
| | | } |