Commit f40fd0cd by kk

刷数据:16319-图案设计数据导出:2. 指定账号+品牌刷brand id 根据附件提供的数据刷brand id字段

parent 4ba9028d
......@@ -18,13 +18,13 @@ import java.util.Collections;
*/
public class CodeGenerator {
private static final String DB_URL = "jdbc:mysql://120.77.232.73:3306/java_visual?useUnicode=true&characterEncoding=utf8&useSSL=true";
private static final String DB_USERNAME = "yswg_it_java";
private static final String DB_PASSWORD = "Yswg@inv-java241011427";
//private static final String DB_URL = "jdbc:mysql://120.77.232.73:3306/java_visual?useUnicode=true&characterEncoding=utf8&useSSL=true";
//private static final String DB_USERNAME = "yswg_it_java";
//private static final String DB_PASSWORD = "Yswg@inv-java241011427";
// private static final String DB_URL = "jdbc:mysql://192.168.0.59:3309/visual_0516?useUnicode=true&characterEncoding=utf8&useSSL=true";
// private static final String DB_USERNAME = "root";
// private static final String DB_PASSWORD = "root";
private static final String DB_URL = "jdbc:mysql://mydb.com:3306/visual_0102?useUnicode=true&characterEncoding=utf8&useSSL=true";
private static final String DB_USERNAME = "root";
private static final String DB_PASSWORD = "root";
public static final String DIR = System.getProperty("user.dir");
......@@ -54,7 +54,7 @@ public class CodeGenerator {
.strategyConfig(builder -> {
builder
// 设置需要生成的表名
.addInclude("visual_communication_design")
.addInclude("brand_record_tool")
//entity策略配置
.entityBuilder()
......
package cn.kk.spring_simple_operation.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 品牌备案工具 前端控制器
* </p>
*
* @author guokunkun
* @since 2025-04-01
*/
@RestController
@RequestMapping("/spring_simple_operation/brand-record-tool")
public class BrandRecordToolController {
}
package cn.kk.spring_simple_operation.mapper;
import cn.kk.spring_simple_operation.entity.BrandRecordTool;
import cn.kk.spring_simple_operation.model.dto.BrandAccountDto;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* 品牌备案工具 Mapper 接口
* </p>
*
* @author guokunkun
* @since 2025-04-01
*/
@Mapper
public interface BrandRecordToolMapper extends BaseMapper<BrandRecordTool> {
List<BrandRecordTool> getByBrandAndAccount(@Param("list") List<BrandAccountDto> list);
}
package cn.kk.spring_simple_operation.model.dto;
import cn.kk.spring_simple_operation.utils.Excel;
import lombok.Data;
/**
* @author kk
* @date 2025/4/1
*/
@Data
public class BrandAccountDto {
@Excel(name = "备案品牌")
private String brand;
@Excel(name = "账号")
private String account;
@Excel(name = "brand id")
private String brandId;
}
package cn.kk.spring_simple_operation.service;
import cn.kk.spring_simple_operation.entity.BrandRecordTool;
import cn.kk.spring_simple_operation.model.dto.BrandAccountDto;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* <p>
* 品牌备案工具 服务类
* </p>
*
* @author guokunkun
* @since 2025-04-01
*/
public interface BrandRecordToolService extends IService<BrandRecordTool> {
void updateBrandId(List<BrandAccountDto> list);
}
package cn.kk.spring_simple_operation.service.impl;
import cn.kk.spring_simple_operation.entity.BrandRecordTool;
import cn.kk.spring_simple_operation.mapper.BrandRecordToolMapper;
import cn.kk.spring_simple_operation.model.dto.BrandAccountDto;
import cn.kk.spring_simple_operation.service.BrandRecordToolService;
import cn.kk.spring_simple_operation.service.VisualDesignLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* <p>
* 品牌备案工具 服务实现类
* </p>
*
* @author guokunkun
* @since 2025-04-01
*/
@Service
public class BrandRecordToolServiceImpl extends ServiceImpl<BrandRecordToolMapper, BrandRecordTool> implements BrandRecordToolService {
@Resource
private VisualDesignLogService visualDesignLogService;
@Override
public void updateBrandId(List<BrandAccountDto> list) {
List<BrandRecordTool> recordTools = baseMapper.getByBrandAndAccount(list);
Map<String, BrandRecordTool> recordToolMap = recordTools.stream().collect(Collectors.toMap(t -> t.getAccount() + "-" + t.getRecordBrand(), Function.identity(), (a, b) -> b));
AtomicInteger count = new AtomicInteger(0);
list.forEach(dto -> {
BrandRecordTool brandRecordTool = recordToolMap.get(dto.getAccount() + "-" + dto.getBrand());
if (Objects.isNull(brandRecordTool) || StringUtils.isBlank(dto.getBrandId())) return;
if (dto.getBrandId().equals(brandRecordTool.getBrandId())) return;
visualDesignLogService.addLog("brand_record_tool", String.format("brand id 由 [%s] 更新为 [%s] (刷数据)", brandRecordTool.getBrandId(), dto.getBrandId()), brandRecordTool.getId());
brandRecordTool.setBrandId(dto.getBrandId());
this.updateById(brandRecordTool);
count.incrementAndGet();
});
System.out.printf("更新 %d 条品牌备案工具的品牌 ID%n", count.get());
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.kk.spring_simple_operation.mapper.BrandRecordToolMapper">
<select id="getByBrandAndAccount" resultType="cn.kk.spring_simple_operation.entity.BrandRecordTool">
select id, account, record_brand, brand_id
from brand_record_tool
where is_delete = 0
and ( account, record_brand) in
<foreach collection="list" item="item" open="(" separator="," close=")">
(#{item.account}, #{item.brand})
</foreach>
</select>
</mapper>
package cn.kk.spring_simple_operation;
import cn.kk.spring_simple_operation.mapper.VisualVideoPlanMapper;
import cn.kk.spring_simple_operation.model.dto.BrandAccountDto;
import cn.kk.spring_simple_operation.model.dto.SkuPeopleNameDto;
import cn.kk.spring_simple_operation.model.dto.SkuSiteDTO;
import cn.kk.spring_simple_operation.service.*;
import cn.kk.spring_simple_operation.utils.ExcelUtil;
import org.junit.jupiter.api.Test;
......@@ -10,11 +9,7 @@ import org.springframework.boot.test.context.SpringBootTest;
import javax.annotation.Resource;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.Files;
import java.util.LinkedList;
import java.util.List;
/**
......@@ -36,30 +31,42 @@ public class ApplicationTest {
@Resource
private APlusProductService aPlusProductService;
@Resource
private BrandRecordToolService brandRecordToolService;
@Test
void contextLoads() throws Exception {
//visualPhotographerAPlusService.brushDataForExecutor();
//setUploadStatusIsDeleted();
setAPlusProductUploadInfo();
}
//setAPlusProductUploadInfo();
private void setUploadStatusIsDeleted() throws Exception {
File file = new File("已删除页面直接调整视频状态.xlsx");
ExcelUtil<SkuSiteDTO> util = new ExcelUtil<SkuSiteDTO>(SkuSiteDTO.class);
List<SkuSiteDTO> list = util.importExcel("精细视频", Files.newInputStream(file.toPath()));
videoProductService.setUploadStatusIsDeleted(list);
list = util.importExcel("简易视频", Files.newInputStream(file.toPath()));
photoProgressService.setUploadStatusIsDeleted(list);
updateBrandId();
}
private void setAPlusProductUploadInfo() throws Exception {
File file = new File("简版A+ AB测试.xlsx");
ExcelUtil<SkuPeopleNameDto> util = new ExcelUtil<>(SkuPeopleNameDto.class);
List<SkuPeopleNameDto> list = util.importExcel(Files.newInputStream(file.toPath()));
aPlusProductService.setAPlusProductUploadInfo(list);
}
//private void setUploadStatusIsDeleted() throws Exception {
// File file = new File("已删除页面直接调整视频状态.xlsx");
// ExcelUtil<SkuSiteDTO> util = new ExcelUtil<SkuSiteDTO>(SkuSiteDTO.class);
// List<SkuSiteDTO> list = util.importExcel("精细视频", Files.newInputStream(file.toPath()));
// videoProductService.setUploadStatusIsDeleted(list);
// list = util.importExcel("简易视频", Files.newInputStream(file.toPath()));
// photoProgressService.setUploadStatusIsDeleted(list);
//}
//private void setAPlusProductUploadInfo() throws Exception {
// File file = new File("简版A+ AB测试.xlsx");
// ExcelUtil<SkuPeopleNameDto> util = new ExcelUtil<>(SkuPeopleNameDto.class);
// List<SkuPeopleNameDto> list = util.importExcel(Files.newInputStream(file.toPath()));
// aPlusProductService.setAPlusProductUploadInfo(list);
//}
private void updateBrandId() throws Exception {
File file = new File("2025-04-01_vpq0_品牌Brand ID核对.xlsx");
ExcelUtil<BrandAccountDto> util = new ExcelUtil<>(BrandAccountDto.class);
List<BrandAccountDto> list = util.importExcel(Files.newInputStream(file.toPath()));
brandRecordToolService.updateBrandId(list);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment