|  |  | 
 |  |  |  | 
 |  |  | import com.alibaba.excel.context.AnalysisContext; | 
 |  |  | import com.alibaba.excel.event.AnalysisEventListener; | 
 |  |  | import com.baomidou.mybatisplus.mapper.EntityWrapper; | 
 |  |  | import com.core.common.BaseRes; | 
 |  |  | import com.core.common.Cools; | 
 |  |  | import com.core.common.R; | 
 |  |  | import com.core.common.SpringUtils; | 
 |  |  | import com.core.exception.CoolException; | 
 |  |  | import com.zy.asrs.entity.LocDetl; | 
 |  |  | import com.zy.asrs.entity.OrderDetl; | 
 |  |  | import com.zy.asrs.entity.param.StockOutParam; | 
 |  |  | import com.zy.asrs.service.LocDetlService; | 
 |  |  | import com.zy.asrs.service.OrderDetlService; | 
 |  |  | import com.zy.asrs.service.TagService; | 
 |  |  | import com.zy.asrs.service.WorkService; | 
 |  |  | import com.zy.common.entity.OutLocBoxExcel; | 
 |  |  | import com.zy.common.model.LocDto; | 
 |  |  | import lombok.extern.slf4j.Slf4j; | 
 |  |  |  | 
 |  |  | import java.util.ArrayList; | 
 |  |  | 
 |  |  | public class OutLocBoxExcelListener extends AnalysisEventListener<OutLocBoxExcel> { | 
 |  |  |  | 
 |  |  |     private int total = 0; | 
 |  |  |     private String orderOneNo = null; | 
 |  |  |     private Long userId; | 
 |  |  |     List<String> batchs = new ArrayList<>(); | 
 |  |  |     List<String[]> OutLocBoxCs = new ArrayList<>(); | 
 |  |  |  | 
 |  |  |     public OutLocBoxExcelListener() { | 
 |  |  |     } | 
 |  |  | 
 |  |  |     @Override | 
 |  |  |     public void invoke(OutLocBoxExcel excel, AnalysisContext ctx) { | 
 |  |  |         String batch = excel.getBatch(); | 
 |  |  |         batchs.add(batch); | 
 |  |  |         String orderNo = excel.getOrderNo(); | 
 |  |  |         if (Cools.isEmpty(orderOneNo)){ | 
 |  |  |             if (!Cools.isEmpty(excel.getOrderNo())){ | 
 |  |  |                 orderOneNo = excel.getOrderNo(); | 
 |  |  |             } else { | 
 |  |  |                 throw new CoolException("订单号参数为空"); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         String[] s=new String[2]; | 
 |  |  |         s[0] = batch; | 
 |  |  |         s[1] = orderOneNo; | 
 |  |  |         OutLocBoxCs.add(s); | 
 |  |  |         total++; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public void doAfterAllAnalysed(AnalysisContext ctx) { | 
 |  |  |         log.info("生成{}条出库任务!", total); | 
 |  |  |         if (!Cools.isEmpty(OutLocBoxCs) && OutLocBoxCs.size() != 0) { | 
 |  |  |             LocDetlService locDetlService = SpringUtils.getBean(LocDetlService.class); | 
 |  |  |             WorkService workService = SpringUtils.getBean(WorkService.class); | 
 |  |  |             List<LocDto> locDtos = new ArrayList<>(); | 
 |  |  |             List<String[]> outLocBoxCList = new ArrayList<>(); | 
 |  |  |             List<String> outLocBoxCNew = new ArrayList<>(); | 
 |  |  |             for (String[] outLocBoxC:OutLocBoxCs){ | 
 |  |  |                 total--; | 
 |  |  |                 if (!outLocBoxCNew.contains(outLocBoxC[0])){ | 
 |  |  |                     LocDetl locDetlSou = locDetlService.selectOne(new EntityWrapper<LocDetl>().eq("batch", outLocBoxC[0])); | 
 |  |  |                     if (Cools.isEmpty(locDetlSou)){ | 
 |  |  |                         throw new CoolException("箱号:"+outLocBoxC[0]+" 未查询到数据!!!"); | 
 |  |  |                     } | 
 |  |  |                     List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>() | 
 |  |  |                             .eq("loc_no", locDetlSou.getLocNo()).eq("origin", locDetlSou.getOrigin())); | 
 |  |  |                     for (LocDetl locDetl:locDetls){ | 
 |  |  |                         total++; | 
 |  |  |                         String[] locDetlNow=new String[2]; | 
 |  |  |                         locDetlNow[0] = locDetl.getBatch(); | 
 |  |  |                         locDetlNow[1] = outLocBoxC[1]; | 
 |  |  |                         outLocBoxCList.add(locDetlNow); | 
 |  |  |                         outLocBoxCNew.add(outLocBoxC[0]); | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |             for (String[] outLocBoxC:outLocBoxCList){ | 
 |  |  |                 LocDetl locDetl = locDetlService.selectOne(new EntityWrapper<LocDetl>().eq("batch", outLocBoxC[0])); | 
 |  |  |                 if (Cools.isEmpty(locDetl)){ | 
 |  |  |                     total--; | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  | //                LocDto locDto = new LocDto(locDetl.getManu(), locDetl.getMatnr(), locDetl.getMaktx(),locDetl.getModel(),locDetl.getSpecs(), | 
 |  |  | //                        locDetl.getBatch(),locDetl.getBrand(),locDetl.getBarcode(), outLocBoxC[1],locDetl.getAnfme()); | 
 |  |  | //                locDto.setOrigin(locDetl.getOrigin()); | 
 |  |  | //                locDto.setWeight(locDetl.getWeight()); | 
 |  |  |                 LocDto locDto = new LocDto(locDetl); | 
 |  |  |                 locDtos.add(locDto); | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             StockOutParam param = new StockOutParam(); | 
 |  |  |             ArrayList<StockOutParam.LocDetl> locDetls = new ArrayList<>(); | 
 |  |  |             for (LocDto locDto:locDtos){ | 
 |  |  |                 StockOutParam.LocDetl locDetl = new StockOutParam.LocDetl(); | 
 |  |  |                 locDetl.setBrand(locDto.getBrand()); | 
 |  |  |                 locDetl.setLocNo(locDto.getLocNo()); | 
 |  |  |                 locDetl.setAnfme(locDto.getAnfme()); | 
 |  |  |                 locDetl.setMatnr(locDto.getMatnr()); | 
 |  |  |                 locDetl.setBatch(locDto.getBatch()); | 
 |  |  |                 locDetl.setModel(locDto.getModel()); | 
 |  |  |                 locDetl.setSpecs(locDto.getSpecs()); | 
 |  |  |                 locDetl.setZpallet(locDto.getZpallet()); | 
 |  |  |                 locDetl.setOrigin(locDto.getOrigin()); | 
 |  |  |                 locDetl.setWeight(locDto.getWeight()); | 
 |  |  |  | 
 |  |  |                 locDetls.add(locDetl); | 
 |  |  |             } | 
 |  |  |             param.setLocDetls(locDetls); | 
 |  |  |             param.setOrderNo(orderOneNo); | 
 |  |  |  | 
 |  |  |             if (total>0){ | 
 |  |  |                 workService.startupFullTakeStoreOrder(param,9999L); | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         log.info("出库{}条箱号!", total); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public int getTotal() { |