| | |
| | | package com.zy.asrs.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.CheckTaskListParam; |
| | | import com.zy.asrs.mapper.CheckOrderMapper; |
| | | import com.zy.asrs.service.*; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.zy.common.model.LocDto; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | |
| | | |
| | | @Autowired |
| | | private StaDescService staDescService; |
| | | |
| | | @Autowired |
| | | private WrkMastService wrkMastService; |
| | | |
| | | @Autowired |
| | | private WrkDetlService wrkDetlService; |
| | | |
| | | @Override |
| | | public void remove(Long orderId) { |
| | |
| | | return locDtos; |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public List<CheckOrderDetl> getTaskList(String barcode) { |
| | | List<CheckOrderDetl> checkOrderDetls = new ArrayList<>(); |
| | | |
| | | WrkMast wrkMast = wrkMastService.selectByBarcode(barcode); |
| | | if (Cools.isEmpty(wrkMast)) { |
| | | throw new CoolException("未找到任务"); |
| | | } |
| | | |
| | | List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkMast.getWrkNo()); |
| | | if (Cools.isEmpty(wrkDetls)) { |
| | | throw new CoolException("未找到任务明细"); |
| | | } |
| | | |
| | | for (WrkDetl wrkDetl : wrkDetls) { |
| | | if(Cools.isEmpty(wrkDetl.getOrderNo())){ |
| | | throw new CoolException("明细数据有误,无订单号数据"); |
| | | } |
| | | CheckOrderDetl checkOrderDetl = checkOrderDetlService.selectOne(new EntityWrapper<CheckOrderDetl>() |
| | | .eq("loc_no", wrkMast.getSourceLocNo()) |
| | | .eq("matnr", wrkDetl.getMatnr()) |
| | | .eq("batch", wrkDetl.getBatch()) |
| | | .eq("order_no", wrkDetl.getOrderNo())); |
| | | if(Cools.isEmpty(checkOrderDetl)){ |
| | | throw new CoolException("明细数据有误,未找到盘点单数据"); |
| | | } |
| | | if (checkOrderDetl.getStatus().equals(2)){ |
| | | checkOrderDetls.add(checkOrderDetl); |
| | | } |
| | | |
| | | } |
| | | if (Cools.isEmpty(checkOrderDetls)) { |
| | | throw new CoolException("该容器已完成盘点"); |
| | | } |
| | | |
| | | return checkOrderDetls; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R pdaComplete(CheckTaskListParam checkTaskListParam) { |
| | | |
| | | WrkMast wrkMast = wrkMastService.selectByBarcode(checkTaskListParam.getBarcode()); |
| | | if (Cools.isEmpty(wrkMast)) { |
| | | throw new CoolException("未找到任务"); |
| | | } |
| | | |
| | | for (CheckOrderDetl checkOrderDetl: checkTaskListParam.getCheckOrderDetlList()){ |
| | | checkOrderDetl.setStatus(3); |
| | | if (!checkOrderDetlService.updateById(checkOrderDetl)){ |
| | | throw new CoolException("更新盘点状态失败"); |
| | | } |
| | | } |
| | | CheckOrder checkOrder = this.selectOne(new EntityWrapper<CheckOrder>().eq("order_no", checkTaskListParam.getCheckOrderDetlList().get(0).getOrderNo())); |
| | | List<CheckOrderDetl> checkOrderDetls = checkOrderDetlService.selectList(new EntityWrapper<CheckOrderDetl>().eq("order_id", checkOrder.getId())); |
| | | boolean is = checkOrderDetls.stream().allMatch(item -> item.getStatus().equals(3)); |
| | | if (is){ |
| | | checkOrder.setSettle(4L); |
| | | if (!this.updateById(checkOrder)){ |
| | | throw new CoolException("更新盘点主单状态失败"); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | return R.ok(); |
| | | } |
| | | } |