| | |
| | | |
| | | 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.LocMast; |
| | | import com.zy.asrs.entity.OrderDetl; |
| | | import com.zy.asrs.entity.param.StockOutParam; |
| | | import com.zy.asrs.service.*; |
| | | 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 String cstmrName = 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(); |
| | | // String cstmrName = excel.getCstmrName(); |
| | | String memo = excel.getMemo(); |
| | | if (Cools.isEmpty(orderOneNo)){ |
| | | if (!Cools.isEmpty(excel.getOrderNo())){ |
| | | orderOneNo = excel.getOrderNo(); |
| | | } else { |
| | | 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); |
| | | total++; |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public void doAfterAllAnalysed(AnalysisContext ctx) { |
| | | log.info("生成{}条出库任务!", total); |
| | | if (!Cools.isEmpty(OutLocBoxCs) && OutLocBoxCs.size() != 0) { |
| | | LocDetlService locDetlService = SpringUtils.getBean(LocDetlService.class); |
| | | LocMastService locMastService = SpringUtils.getBean(LocMastService.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]+" 未查询到数据!!!"); |
| | | } |
| | | 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); |
| | | locDtos.add(locDto); |
| | | } |
| | | |
| | | StockOutParam param = new StockOutParam(); |
| | | ArrayList<StockOutParam.LocDetl> locDetls = new ArrayList<>(); |
| | | List<LocDto> locDtosList = new ArrayList<>(); |
| | | List<String> batchList = new ArrayList<>(); |
| | | for (LocDto locDto : locDtos) { |
| | | if (!batchList.contains(locDto.getBatch())){ |
| | | batchList.add(locDto.getBatch()); |
| | | locDtosList.add(locDto); |
| | | } |
| | | } |
| | | for (LocDto locDto:locDtosList){ |
| | | 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()); |
| | | locDetl.setMemo(locDto.getMemo()); |
| | | |
| | | locDetls.add(locDetl); |
| | | } |
| | | param.setLocDetls(locDetls); |
| | | param.setOrderNo(orderOneNo); |
| | | param.setCstmrName(cstmrName); |
| | | |
| | | if (total>0){ |
| | | workService.startupFullTakeStoreOrder(param,9999L); |
| | | } |
| | | |
| | | } |
| | | |
| | | log.info("出库{}条箱号!", total); |
| | | } |
| | | |
| | | public int getTotal() { |