| | |
| | | import com.zy.asrs.entity.ReviewDetl; |
| | | import com.zy.asrs.service.ReviewDetlService; |
| | | import com.zy.asrs.service.ReviewService; |
| | | import com.zy.system.entity.Config; |
| | | import com.zy.system.service.ConfigService; |
| | | import lombok.SneakyThrows; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.transaction.PlatformTransactionManager; |
| | |
| | | private final Long userId; |
| | | private TransactionStatus transactionStatus; |
| | | |
| | | private ConfigService configService; |
| | | |
| | | /** |
| | | * 如果使用了spring,请使用这个构造方法。每次创建Listener的时候需要把spring管理的类传进来 |
| | | */ |
| | | public ImportReviewListener(PlatformTransactionManager transactionManager, ReviewService reviewService, ReviewDetlService reviewDetlService, SnowflakeIdWorker snowflakeIdWorker, Long userId) { |
| | | public ImportReviewListener(ConfigService configService, PlatformTransactionManager transactionManager, ReviewService reviewService, ReviewDetlService reviewDetlService, SnowflakeIdWorker snowflakeIdWorker, Long userId) { |
| | | this.transactionManager = transactionManager; |
| | | this.reviewService = reviewService; |
| | | this.reviewDetlService = reviewDetlService; |
| | | this.snowflakeIdWorker = snowflakeIdWorker; |
| | | this.userId = userId; |
| | | this.configService = configService; |
| | | } |
| | | |
| | | private Set<String> uniquePackNos = new HashSet<>(); // 用于去重包装组号 |
| | |
| | | // 首次出现,记录并处理 |
| | | uniquePackNos.add(data.getColumn1()); |
| | | |
| | | String orderNo = ""; |
| | | Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "orderNo")); |
| | | if (config != null && config.getStatus() == 1 && config.getValue() != null) { |
| | | orderNo = config.getValue(); |
| | | } |
| | | |
| | | String time = DateUtils.convert(new Date(), DateUtils.yyyyMMddHHmmss_F); |
| | | Review review = reviewService.selectOne(new EntityWrapper<Review>().eq("order_no", data.getColumn1())); |
| | | if (review == null) { |
| | | review = new Review(); |
| | | review.setUuid(String.valueOf(snowflakeIdWorker.nextId())); |
| | | review.setOrderNo(data.getColumn1()); |
| | | review.setOrderNo(orderNo + data.getColumn1()); |
| | | review.setOrderTime(time); |
| | | review.setDefNumber("Excel导入"); |
| | | review.setSettle(1L); |
| | | review.setStatus(1); |
| | | review.setCreateBy(userId); |