| | |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | |
| | | @TableField(exist = false) |
| | | private Boolean hasProductionRecord; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | @ApiModelProperty("创建时间") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private LocalDateTime createTime; |
| | | |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | // 构建返回信息 |
| | | StringBuilder message = new StringBuilder(); |
| | | if (!unmatchedRecords.isEmpty()) { |
| | | message.append("导入成功 " + successCount + " 条记录,以下产品未找到匹配项:\n"); |
| | | if (successCount > 0 && unmatchedRecords.isEmpty()) { |
| | | return R.ok("导入成功 " + successCount + " 条记录"); |
| | | } else if (successCount > 0 && !unmatchedRecords.isEmpty()) { |
| | | StringBuilder message = new StringBuilder(); |
| | | message.append("导入成功 " + successCount + " 条记录,以下产品未找到匹配项,未导入:\n"); |
| | | for (String record : unmatchedRecords) { |
| | | message.append(record).append("\n"); |
| | | } |
| | | return R.ok(message.toString()); |
| | | return R.fail(message.toString()); |
| | | } else if (!unmatchedRecords.isEmpty()) { |
| | | StringBuilder message = new StringBuilder(); |
| | | message.append("导入失败,以下产品未找到匹配项:\n"); |
| | | for (String record : unmatchedRecords) { |
| | | message.append(record).append("\n"); |
| | | } |
| | | return R.fail(message.toString()); |
| | | } else { |
| | | return R.fail("未找到可导入的库存数据,请检查导入表格中的产品名称和型号是否正确"); |
| | | } |
| | | |
| | | return R.ok("导入成功,共处理 " + successCount + " 条记录"); |
| | | } catch (Exception e) { |
| | | log.error("导入库存失败", e); |
| | | return R.fail("导入失败:" + e.getMessage()); |