| | |
| | | import com.alibaba.excel.event.AnalysisEventListener; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.SpringUtils; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.LocDetl; |
| | | import com.zy.asrs.entity.LocMast; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.StockOutParam; |
| | | import com.zy.asrs.service.LocDetlService; |
| | | import com.zy.asrs.service.LocMastService; |
| | | import com.zy.asrs.service.WorkService; |
| | | import com.zy.common.entity.OutLocBoxExcel; |
| | | import com.zy.common.entity.OrderGiftProofreadingExcel; |
| | | import com.zy.common.model.DetlDto; |
| | | import com.zy.common.model.LocDto; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | * Created by vincent on 2019-11-25 |
| | | */ |
| | | @Slf4j |
| | | public class OrderGiftProofreadingExcelListener extends AnalysisEventListener<OutLocBoxExcel> { |
| | | public class OrderGiftProofreadingExcelListener extends AnalysisEventListener<OrderGiftProofreadingExcel> { |
| | | |
| | | private int total = 0; |
| | | private String orderOneNo = null; |
| | | private String cstmrName = null; |
| | | private Long userId; |
| | | List<String[]> OutLocBoxCs = new ArrayList<>(); |
| | | List<OrderGiftProofreadingExcel> OrderGiftProofreadingCs = new ArrayList<>(); |
| | | |
| | | public OrderGiftProofreadingExcelListener() { |
| | | } |
| | |
| | | */ |
| | | private static final int BATCH_COUNT = 50; |
| | | |
| | | private final List<OutLocBoxExcel> list = new ArrayList<>(); |
| | | private final List<OrderGiftProofreadingExcel> list = new ArrayList<>(); |
| | | |
| | | /** |
| | | * 这里会一行行的返回头 |
| | |
| | | * 这个每一条数据解析都会来调用 |
| | | */ |
| | | @Override |
| | | public void invoke(OutLocBoxExcel excel, AnalysisContext ctx) { |
| | | String batch = excel.getBatch(); |
| | | String orderNo = excel.getOrderNo(); |
| | | // String cstmrName = excel.getCstmrName(); |
| | | String memo = excel.getMemo(); |
| | | public void invoke(OrderGiftProofreadingExcel excel, AnalysisContext ctx) { |
| | | if (Cools.isEmpty(orderOneNo)){ |
| | | if (!Cools.isEmpty(excel.getOrderNo())){ |
| | | orderOneNo = excel.getOrderNo(); |
| | |
| | | throw new CoolException("订单号参数为空"); |
| | | } |
| | | } |
| | | if (Cools.isEmpty(cstmrName)){ |
| | | if (!Cools.isEmpty(excel.getCstmrName())){ |
| | | cstmrName = excel.getCstmrName(); |
| | | } else { |
| | | throw new CoolException("客户名称参数为空"); |
| | | } |
| | | } |
| | | String[] s=new String[4]; |
| | | s[0] = batch; |
| | | s[1] = orderOneNo; |
| | | s[2] = cstmrName; |
| | | s[3] = memo; |
| | | OutLocBoxCs.add(s); |
| | | OrderGiftProofreadingCs.add(excel); |
| | | total++; |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public void doAfterAllAnalysed(AnalysisContext ctx) { |
| | | if (!Cools.isEmpty(OutLocBoxCs) && OutLocBoxCs.size() != 0) { |
| | | LocDetlService locDetlService = SpringUtils.getBean(LocDetlService.class); |
| | | LocMastService locMastService = SpringUtils.getBean(LocMastService.class); |
| | | if (!Cools.isEmpty(OrderGiftProofreadingCs) && !OrderGiftProofreadingCs.isEmpty()) { |
| | | 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]+" 未查询到数据!!!"); |
| | | } |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locDetlSou.getLocNo())); |
| | | if (Cools.isEmpty(locMast)){ |
| | | throw new CoolException("箱号:"+outLocBoxC[0]+" 所在库位不满足出库条件!!!未查询到此箱号所在库位"); |
| | | } |
| | | if (!locMast.getLocSts().equals("F")){ |
| | | throw new CoolException("箱号:"+outLocBoxC[0]+" 所在库位不满足出库条件!!!库位状态不为F!!!库位状态:"+locMast.getLocSts$()); |
| | | } |
| | | 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[4]; |
| | | locDetlNow[0] = locDetl.getBatch(); |
| | | locDetlNow[1] = outLocBoxC[1]; |
| | | locDetlNow[2] = outLocBoxC[2]; |
| | | locDetlNow[3] = outLocBoxC[3]; |
| | | 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()); |
| | | locDetl.setMemo(outLocBoxC[3]); |
| | | LocDto locDto = new LocDto(locDetl); |
| | | for (OrderGiftProofreadingExcel orderGiftProofreadingExcel:OrderGiftProofreadingCs){ |
| | | LocDto locDto = new LocDto(orderGiftProofreadingExcel); |
| | | locDtos.add(locDto); |
| | | } |
| | | |
| | |
| | | locDetl.setOrigin(locDto.getOrigin()); |
| | | locDetl.setWeight(locDto.getWeight()); |
| | | locDetl.setMemo(locDto.getMemo()); |
| | | |
| | | locDetl.setVolume(locDto.getVolume()); |
| | | locDetl.setPrice(locDto.getPrice()); |
| | | locDetls.add(locDetl); |
| | | } |
| | | param.setLocDetls(locDetls); |
| | | param.setOrderNo(orderOneNo); |
| | | param.setCstmrName(cstmrName); |
| | | |
| | | if (total>0){ |
| | | workService.startupFullTakeStoreOrder(param,9999L); |
| | | workService.startupFullTakeStoreOrderGift(param,9999L); |
| | | } |
| | | |
| | | } |
| | | |
| | | log.info("出库{}条箱号!", total); |
| | | log.info("导入{}条核对单据明细!", total); |
| | | } |
| | | |
| | | public int getTotal() { |