迁移 商品单位 规格
This commit is contained in:
parent
6a0fb8000e
commit
88df994553
|
|
@ -5,19 +5,21 @@ import com.alibaba.fastjson2.JSONArray;
|
|||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.mergedata.common.resp.CzgResult;
|
||||
import com.czg.mergedata.common.utils.PageUtils;
|
||||
import com.czg.mergedata.cur.service.CurShopIdRelationService;
|
||||
import com.czg.mergedata.cur.entity.CurShopProdSpec;
|
||||
import com.czg.mergedata.cur.mapper.CurShopProdSpecMapper;
|
||||
import com.czg.mergedata.cur.service.CurShopProdSpecService;
|
||||
import com.czg.mergedata.old.entity.OldProductSpec;
|
||||
import com.czg.mergedata.old.service.OldProductSpecService;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.mergedata.cur.entity.CurShopProdSpec;
|
||||
import com.czg.mergedata.cur.mapper.CurShopProdSpecMapper;
|
||||
import com.czg.mergedata.cur.service.CurShopProdSpecService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
|
@ -29,9 +31,6 @@ import java.util.stream.Collectors;
|
|||
@Service
|
||||
public class CurShopProdSpecServiceImpl extends ServiceImpl<CurShopProdSpecMapper, CurShopProdSpec> implements CurShopProdSpecService{
|
||||
|
||||
@Resource
|
||||
private CurShopIdRelationService curShopIdRelationService;
|
||||
|
||||
@Resource
|
||||
private OldProductSpecService oldProductSpecService;
|
||||
|
||||
|
|
@ -39,23 +38,22 @@ public class CurShopProdSpecServiceImpl extends ServiceImpl<CurShopProdSpecMappe
|
|||
@Transactional
|
||||
public CzgResult<String> mergeProductSpec() {
|
||||
getMapper().truncateTable();
|
||||
Map<Long, Long> oldAndCurShopIdMap = curShopIdRelationService.getOldShopIdRelation();
|
||||
|
||||
mergeProductSpec(oldAndCurShopIdMap);
|
||||
execProductSpec();
|
||||
return CzgResult.success("迁移成功");
|
||||
}
|
||||
|
||||
private void mergeProductSpec(Map<Long, Long> oldAndCurShopIdMap) {
|
||||
private void execProductSpec() {
|
||||
Page<OldProductSpec> page = oldProductSpecService.page(PageUtils.buildPage());
|
||||
|
||||
while (!page.getRecords().isEmpty()) {
|
||||
saveProdSpec(page.getRecords(), oldAndCurShopIdMap);
|
||||
saveProdSpec(page.getRecords());
|
||||
|
||||
page = oldProductSpecService.page(PageUtils.buildPage(page.getPageNumber() + 1));
|
||||
}
|
||||
}
|
||||
|
||||
private void saveProdSpec(List<OldProductSpec> oldProductSpecs, Map<Long, Long> oldAndCurShopIdMap) {
|
||||
private void saveProdSpec(List<OldProductSpec> oldProductSpecs) {
|
||||
List<CurShopProdSpec> firstSpecs = new ArrayList<>();
|
||||
|
||||
// 保存一级规格
|
||||
|
|
@ -66,9 +64,9 @@ public class CurShopProdSpecServiceImpl extends ServiceImpl<CurShopProdSpecMappe
|
|||
for (OldProductSpec oldProductSpec : oldProductSpecs) {
|
||||
CurShopProdSpec curShopProdSpec = new CurShopProdSpec();
|
||||
|
||||
Long curShopId = oldAndCurShopIdMap.get(Long.valueOf(oldProductSpec.getShopId()));
|
||||
Long curShopId = Long.valueOf(oldProductSpec.getShopId());
|
||||
curShopProdSpec.setId(Long.valueOf(oldProductSpec.getId()));
|
||||
curShopProdSpec.setShopId(curShopId == null ? 1L : curShopId);
|
||||
curShopProdSpec.setShopId(curShopId);
|
||||
curShopProdSpec.setLevel(1);
|
||||
curShopProdSpec.setPid(0L);
|
||||
curShopProdSpec.setPids(pids);
|
||||
|
|
|
|||
|
|
@ -3,14 +3,13 @@ package com.czg.mergedata.cur.service.impl;
|
|||
import cn.hutool.core.date.DateUtil;
|
||||
import com.czg.mergedata.common.resp.CzgResult;
|
||||
import com.czg.mergedata.common.utils.PageUtils;
|
||||
import com.czg.mergedata.cur.service.CurShopIdRelationService;
|
||||
import com.czg.mergedata.cur.entity.CurShopProdUnit;
|
||||
import com.czg.mergedata.cur.mapper.CurShopProdUnitMapper;
|
||||
import com.czg.mergedata.cur.service.CurShopProdUnitService;
|
||||
import com.czg.mergedata.old.entity.OldShopUnit;
|
||||
import com.czg.mergedata.old.service.OldShopUnitService;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.mergedata.cur.entity.CurShopProdUnit;
|
||||
import com.czg.mergedata.cur.mapper.CurShopProdUnitMapper;
|
||||
import com.czg.mergedata.cur.service.CurShopProdUnitService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
|
@ -18,7 +17,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 商品单位 服务层实现。
|
||||
|
|
@ -29,9 +27,6 @@ import java.util.Map;
|
|||
@Service
|
||||
public class CurShopProdUnitServiceImpl extends ServiceImpl<CurShopProdUnitMapper, CurShopProdUnit> implements CurShopProdUnitService {
|
||||
|
||||
@Resource
|
||||
private CurShopIdRelationService curShopIdRelationService;
|
||||
|
||||
@Resource
|
||||
private OldShopUnitService oldShopUnitService;
|
||||
|
||||
|
|
@ -40,34 +35,32 @@ public class CurShopProdUnitServiceImpl extends ServiceImpl<CurShopProdUnitMappe
|
|||
public CzgResult<String> mergeProductUnit() {
|
||||
getMapper().truncateTable();
|
||||
|
||||
Map<Long, Long> oldAndCurShopIdMap = curShopIdRelationService.getOldShopIdRelation();
|
||||
|
||||
mergeUnit(oldAndCurShopIdMap);
|
||||
return null;
|
||||
mergeUnit();
|
||||
return CzgResult.success("商品单位合并成功");
|
||||
}
|
||||
|
||||
private void mergeUnit(Map<Long, Long> oldAndCurShopIdMap) {
|
||||
private void mergeUnit() {
|
||||
Page<OldShopUnit> page = oldShopUnitService.page(PageUtils.buildPage());
|
||||
|
||||
while (!page.getRecords().isEmpty()) {
|
||||
saveUnitInfo(page.getRecords(), oldAndCurShopIdMap);
|
||||
saveUnitInfo(page.getRecords());
|
||||
page = oldShopUnitService.page(PageUtils.buildPage(page.getPageNumber() + 1));
|
||||
}
|
||||
}
|
||||
|
||||
private void saveUnitInfo(List<OldShopUnit> oldShopUnits, Map<Long, Long> oldAndCurShopIdMap) {
|
||||
private void saveUnitInfo(List<OldShopUnit> oldShopUnits) {
|
||||
List<CurShopProdUnit> curShopProdUnits = new ArrayList<>();
|
||||
for (OldShopUnit oldShopUnit : oldShopUnits) {
|
||||
CurShopProdUnit curShopProdUnit = new CurShopProdUnit();
|
||||
|
||||
Long shopId = oldAndCurShopIdMap.get(Long.valueOf(oldShopUnit.getShopId()));
|
||||
Long shopId = Long.valueOf(oldShopUnit.getShopId());
|
||||
|
||||
curShopProdUnit.setId(Long.valueOf(oldShopUnit.getId()));
|
||||
curShopProdUnit.setName(oldShopUnit.getName());
|
||||
curShopProdUnit.setUnitType(oldShopUnit.getUnitType());
|
||||
curShopProdUnit.setIsSystem("1".equals(oldShopUnit.getShopId()) ? 1 : 0);
|
||||
curShopProdUnit.setStatus(oldShopUnit.getStatus());
|
||||
curShopProdUnit.setShopId(shopId == null ? 1L : shopId);
|
||||
curShopProdUnit.setShopId(shopId);
|
||||
curShopProdUnit.setCreateTime(DateUtil.toLocalDateTime(oldShopUnit.getCreatedAt() == null ? new Date() : new Date(oldShopUnit.getCreatedAt())));
|
||||
|
||||
curShopProdUnits.add(curShopProdUnit);
|
||||
|
|
|
|||
|
|
@ -80,6 +80,15 @@
|
|||
- tb_call_queue 表
|
||||
- tb_call_table 表
|
||||
|
||||
### 10. 商品单位
|
||||
> /merge/product/mergeUnit
|
||||
#### 执行表
|
||||
- tb_shop_prod_unit 表
|
||||
|
||||
### 11. 商品规格
|
||||
> /merge/product/mergeSpec
|
||||
#### 执行表
|
||||
- tb_shop_prod_spec 表
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue