| | |
| | | import com.alibaba.excel.event.AnalysisEventListener; |
| | | import com.alibaba.excel.exception.ExcelAnalysisException; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.SnowflakeIdWorker; |
| | | import com.zy.asrs.entity.DocType; |
| | |
| | | public void invoke(ImportOrderDto data, AnalysisContext context) { |
| | | log.info("解析到第 {} 条数据:{}", ++count, JSON.toJSONString(data)); |
| | | list.add(data); |
| | | if (context.getCurrentRowNum() == 3) { |
| | | if (context.getCurrentRowNum() == 5) { |
| | | String time = DateUtils.convert(new Date(),DateUtils.yyyyMMddHHmmss_F); |
| | | Order order2 = orderService.selectByNo(list.get(0).getColumn2()); |
| | | Order order2 = orderService.selectByNo(list.get(0).getColumn2()); // 订单号 |
| | | if(order2 != null) { |
| | | throw new ExcelAnalysisException("单据已存在!"); |
| | | } |
| | | DocType docType = docTypeService.selectOrAdd(list.get(1).getColumn2(), Boolean.FALSE); |
| | | DocType docType = docTypeService.selectOrAdd(list.get(1).getColumn2(), Boolean.FALSE); // 订单类型 |
| | | if (docType == null) { |
| | | throw new ExcelAnalysisException("单据类型错误:" + list.get(1).getColumn2()); |
| | | } |
| | |
| | | order.setOrderNo(orderNo); |
| | | order.setOrderTime(time); |
| | | order.setDocType(docType.getDocId()); |
| | | order.setCstmrName(Cools.isEmpty(list.get(2).getColumn2()) ? "" : list.get(2).getColumn2()); // 客户名称 |
| | | order.setMemo(Cools.isEmpty(list.get(3).getColumn2()) ? "" : list.get(3).getColumn2()); // 备注 |
| | | order.setSettle(1L); |
| | | order.setStatus(1); |
| | | order.setCreateBy(userId); |