| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.R; |
| | | import com.zy.asrs.framework.exception.CoolException; |
| | | import com.zy.asrs.wms.asrs.entity.*; |
| | | import com.zy.asrs.wms.asrs.entity.template.WaitPakinTemplate; |
| | | import com.zy.asrs.wms.asrs.service.*; |
| | | import com.zy.asrs.wms.common.annotation.OperationLog; |
| | | import com.zy.asrs.wms.common.domain.BaseParam; |
| | |
| | | import com.zy.asrs.wms.utils.ExcelUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.*; |
| | |
| | | |
| | | @Autowired |
| | | private WaitPakinService waitPakinService; |
| | | @Autowired |
| | | private OrderService orderService; |
| | | @Autowired |
| | | private OrderDetlService orderDetlService; |
| | | |
| | | @PreAuthorize("hasAuthority('asrs:waitPakin:list')") |
| | | @PostMapping("/waitPakin/page") |
| | |
| | | ExcelUtil.build(ExcelUtil.create(waitPakinService.list(), WaitPakin.class), response); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('asrs:waitPakin:list')") |
| | | @PostMapping("/waitPakin/exportTemplate") |
| | | public void exportTemplate(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | ArrayList<WaitPakinTemplate> list = new ArrayList<>(); |
| | | ExcelUtil.build(ExcelUtil.create(list, WaitPakinTemplate.class), response); |
| | | } |
| | | |
| | | @PostMapping("/waitPakin/upload") |
| | | public R upload(@RequestParam("file") MultipartFile file) { |
| | | List<WaitPakinTemplate> list = ExcelUtil.parseExcelFile(file, WaitPakinTemplate.class); |
| | | for (WaitPakinTemplate waitPakinTemplate : list) { |
| | | Order order = orderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderNo, waitPakinTemplate.getOrderNo()).eq(Order::getStatus, 1)); |
| | | if (order == null) { |
| | | throw new CoolException("订单不存在"); |
| | | } |
| | | |
| | | LambdaQueryWrapper<OrderDetl> wrapper = new LambdaQueryWrapper<OrderDetl>().eq(OrderDetl::getOrderId, order.getId()); |
| | | if (!Cools.isEmpty(waitPakinTemplate.getBatch())) { |
| | | wrapper.eq(OrderDetl::getBatch, waitPakinTemplate.getBatch()); |
| | | } |
| | | List<OrderDetl> orderDetls = orderDetlService.list(wrapper); |
| | | if (orderDetls.isEmpty()) { |
| | | throw new CoolException("订单明细不存在"); |
| | | } |
| | | |
| | | Long detlId = null; |
| | | for (OrderDetl orderDetl : orderDetls) { |
| | | Mat mat = orderDetl.getMat$(); |
| | | if (mat.getMatnr().equals(waitPakinTemplate.getMatnr())) { |
| | | detlId = orderDetl.getId(); |
| | | } |
| | | } |
| | | |
| | | if (detlId == null) { |
| | | throw new CoolException("订单明细不存在"); |
| | | } |
| | | |
| | | WaitPakin waitPakin = new WaitPakin(); |
| | | waitPakin.setOrderId(order.getId()); |
| | | waitPakin.setOrderNo(order.getOrderNo()); |
| | | waitPakin.setAnfme(waitPakinTemplate.getAnfme()); |
| | | waitPakin.setBarcode(waitPakinTemplate.getBarcode()); |
| | | waitPakin.setDetlId(detlId); |
| | | waitPakinService.comb(waitPakin); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |