This commit is contained in:
GYJ 2025-03-17 09:17:15 +08:00
parent 2ff33b9c00
commit 0571be26d9
16 changed files with 377 additions and 3 deletions

View File

@ -90,6 +90,13 @@
<artifactId>fastjson2</artifactId>
<version>2.0.54</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>4.0.3</version>
</dependency>
</dependencies>
<build>

View File

@ -18,8 +18,8 @@ public class CodeGen {
private final static String DATABASE = "czg_cashier_test";
private final static String OLD_DATABASE = "fycashier";
// private final static boolean IS_OLD_VERSION = false;
private final static boolean IS_OLD_VERSION = true;
private final static boolean IS_OLD_VERSION = false;
// private final static boolean IS_OLD_VERSION = true;
public static void main(String[] args) {
//配置数据源
@ -81,7 +81,7 @@ public class CodeGen {
//设置表前缀和只生成哪些表setGenerateTable 未配置时生成所有表
globalConfig.getStrategyConfig()
.setTablePrefix("tb_")
.setGenerateTable("tb_shop_share_record", "tb_shop_share", "tb_shop_song_order", "tb_shop_song");
.setGenerateTable("tb_picture_classify", "tb_picture_gallery");
EntityConfig entityConfig = globalConfig.getEntityConfig();
if (IS_OLD_VERSION) {

View File

@ -34,6 +34,14 @@ public class ShopInfoController {
@Resource
private CurShopShareService curShopShareService;
@Resource
private CurPictureGalleryService curPictureGalleryService;
@RequestMapping("/picture")
public CzgResult<String> gallery() {
return curPictureGalleryService.mergePicture();
}
@RequestMapping("/share")
public CzgResult<String> share() {
return curShopShareService.mergeShopShare();

View File

@ -0,0 +1,70 @@
package com.czg.mergedata.cur.entity;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.io.Serial;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 图片分类 实体类
*
* @author mac
* @since 2025-03-15
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table("tb_picture_classify")
public class CurPictureClassify implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* id
*/
@Id(keyType = KeyType.Auto)
private Long id;
/**
* 店铺id
*/
private Long shopId;
/**
* 分类名称
*/
private String name;
/**
* 排序值
*/
private Integer sort;
/**
* 单位来源 1-系统预设 0-商家创建
*/
private Integer isSystem;
/**
* 创建时间
*/
@Column(onInsertValue = "now()")
private LocalDateTime createTime;
/**
* 逻辑删除 1- 0-
*/
private Integer isDel;
}

View File

@ -0,0 +1,65 @@
package com.czg.mergedata.cur.entity;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.io.Serial;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 图库 实体类
*
* @author mac
* @since 2025-03-15
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table("tb_picture_gallery")
public class CurPictureGallery implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* id
*/
@Id(keyType = KeyType.Auto)
private Long id;
/**
* 店铺id
*/
private Long shopId;
/**
* 图片分类id
*/
private Long pictureClassifyId;
/**
* 图片URL地址
*/
private String url;
/**
* 创建时间
*/
@Column(onInsertValue = "now()")
private LocalDateTime createTime;
/**
* 逻辑删除 1- 0-
*/
private Integer isDel;
}

View File

@ -0,0 +1,16 @@
package com.czg.mergedata.cur.mapper;
import com.mybatisflex.core.BaseMapper;
import com.czg.mergedata.cur.entity.CurPictureClassify;
import org.apache.ibatis.annotations.Select;
/**
* 图片分类 映射层
*
* @author mac
* @since 2025-03-15
*/
public interface CurPictureClassifyMapper extends BaseMapper<CurPictureClassify> {
@Select("truncate tb_picture_classify")
void truncateTable();
}

View File

@ -0,0 +1,16 @@
package com.czg.mergedata.cur.mapper;
import com.mybatisflex.core.BaseMapper;
import com.czg.mergedata.cur.entity.CurPictureGallery;
import org.apache.ibatis.annotations.Select;
/**
* 图库 映射层
*
* @author mac
* @since 2025-03-15
*/
public interface CurPictureGalleryMapper extends BaseMapper<CurPictureGallery> {
@Select("truncate tb_picture_gallery")
void truncateTable();
}

View File

@ -0,0 +1,14 @@
package com.czg.mergedata.cur.service;
import com.mybatisflex.core.service.IService;
import com.czg.mergedata.cur.entity.CurPictureClassify;
/**
* 图片分类 服务层
*
* @author mac
* @since 2025-03-15
*/
public interface CurPictureClassifyService extends IService<CurPictureClassify> {
}

View File

@ -0,0 +1,16 @@
package com.czg.mergedata.cur.service;
import com.czg.mergedata.common.resp.CzgResult;
import com.mybatisflex.core.service.IService;
import com.czg.mergedata.cur.entity.CurPictureGallery;
/**
* 图库 服务层
*
* @author mac
* @since 2025-03-15
*/
public interface CurPictureGalleryService extends IService<CurPictureGallery> {
CzgResult<String> mergePicture();
}

View File

@ -0,0 +1,18 @@
package com.czg.mergedata.cur.service.impl;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.czg.mergedata.cur.entity.CurPictureClassify;
import com.czg.mergedata.cur.mapper.CurPictureClassifyMapper;
import com.czg.mergedata.cur.service.CurPictureClassifyService;
import org.springframework.stereotype.Service;
/**
* 图片分类 服务层实现
*
* @author mac
* @since 2025-03-15
*/
@Service
public class CurPictureClassifyServiceImpl extends ServiceImpl<CurPictureClassifyMapper, CurPictureClassify> implements CurPictureClassifyService{
}

View File

@ -0,0 +1,123 @@
package com.czg.mergedata.cur.service.impl;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.read.builder.ExcelReaderBuilder;
import com.czg.mergedata.common.resp.CzgResult;
import com.czg.mergedata.cur.entity.CurPictureClassify;
import com.czg.mergedata.cur.entity.CurPictureGallery;
import com.czg.mergedata.cur.mapper.CurPictureClassifyMapper;
import com.czg.mergedata.cur.mapper.CurPictureGalleryMapper;
import com.czg.mergedata.cur.service.CurPictureClassifyService;
import com.czg.mergedata.cur.service.CurPictureGalleryService;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 图库 服务层实现
*
* @author mac
* @since 2025-03-15
*/
@Service
public class CurPictureGalleryServiceImpl extends ServiceImpl<CurPictureGalleryMapper, CurPictureGallery> implements CurPictureGalleryService {
@Resource
private CurPictureClassifyMapper curPictureClassifyMapper;
@Resource
private CurPictureClassifyService curPictureClassifyService;
@Override
@Transactional
public CzgResult<String> mergePicture() {
getMapper().truncateTable();
curPictureClassifyMapper.truncateTable();
execClassify();
execGallery();
return CzgResult.success("合并成功");
}
private void execClassify() {
String property = System.getProperty("user.dir");
String path = property + "/src/main/resources/file/ims_ybo2ov2_img_category.xls";
ExcelReaderBuilder builder = EasyExcel.read(path);
List<Map<Integer, String>> listMap = builder.sheet().doReadSync();
List<CurPictureClassify> curPictureClassifyList = new ArrayList<>();
for (Map<Integer, String> map : listMap) {
CurPictureClassify curPictureClassify = new CurPictureClassify();
curPictureClassify.setId(Long.valueOf(map.get(0)));
curPictureClassify.setShopId(1L);
curPictureClassify.setName(String.valueOf(map.get(1)));
curPictureClassify.setSort(1);
curPictureClassify.setIsSystem(1);
curPictureClassify.setIsDel(0);
curPictureClassifyList.add(curPictureClassify);
}
curPictureClassifyService.saveBatch(curPictureClassifyList);
}
private void execGallery() {
String property = System.getProperty("user.dir");
String path = property + "/src/main/resources/file/ims_ybo2ov2_img_file.xls";
ExcelReaderBuilder builder = EasyExcel.read(path);
List<Map<Integer, String>> listMap = builder.sheet().doReadSync();
Map<Long, Long> shopCategoryIdMap = new HashMap<>();
List<CurPictureGallery> curPictureGalleryList = new ArrayList<>();
for (Map<Integer, String> map : listMap) {
long deleted = Long.parseLong(map.get(5));
CurPictureGallery curPictureGallery = new CurPictureGallery();
curPictureGallery.setUrl(String.valueOf(map.get(3)));
curPictureGallery.setIsDel(deleted == 0L ? 0 : 1);
Long shopId = Long.parseLong(map.get(1));
if (shopId == 0L) {
curPictureGallery.setShopId(1L);
long categoryId = Long.parseLong(map.get(2));
curPictureGallery.setPictureClassifyId(categoryId);
} else {
curPictureGallery.setShopId(shopId);
Long categoryId = shopCategoryIdMap.get(shopId);
if (categoryId == null) {
CurPictureClassify curPictureClassify = new CurPictureClassify();
curPictureClassify.setShopId(shopId);
curPictureClassify.setName("默认分类");
curPictureClassify.setSort(1);
curPictureClassify.setIsSystem(0);
curPictureClassify.setIsDel(0);
curPictureClassifyService.save(curPictureClassify);
categoryId = curPictureClassify.getId();
shopCategoryIdMap.put(shopId, categoryId);
}
curPictureGallery.setPictureClassifyId(categoryId);
}
curPictureGalleryList.add(curPictureGallery);
}
saveBatch(curPictureGalleryList);
}
}

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,7 @@
<?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="com.czg.mergedata.cur.mapper.CurPictureClassifyMapper">
</mapper>

View File

@ -0,0 +1,7 @@
<?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="com.czg.mergedata.cur.mapper.CurPictureGalleryMapper">
</mapper>

View File

@ -185,4 +185,11 @@
- tb_shop_song_order 表
### 27. 图库
> /merge/shopInfo/picture
#### 执行表
- tb_picture_gallery 表
- tb_picture_classify 表