|
@@ -3,15 +3,19 @@ package com.kmall.admin.service.impl;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.google.common.collect.ImmutableBiMap;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Maps;
|
|
|
+import com.google.gson.Gson;
|
|
|
import com.kmall.admin.dao.*;
|
|
|
import com.kmall.admin.dto.GoodsDetailsDto;
|
|
|
import com.kmall.admin.dto.GoodsDto;
|
|
|
import com.kmall.admin.dto.GoodsPanoramaDto;
|
|
|
import com.kmall.admin.entity.*;
|
|
|
+import com.kmall.admin.entity.kmall2eccs.KtoEccsEntity;
|
|
|
import com.kmall.admin.entity.mk.MkActivitiesEntity;
|
|
|
import com.kmall.admin.entity.shop.ShopErrorPriceRecordEntity;
|
|
|
import com.kmall.admin.service.*;
|
|
|
+import com.kmall.admin.service.kmall2eccs.KtoEccsService;
|
|
|
import com.kmall.admin.service.mk.MkActivitiesService;
|
|
|
import com.kmall.admin.service.mk.MkActivityFormService;
|
|
|
import com.kmall.admin.service.GoodsService;
|
|
@@ -112,6 +116,9 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
@Autowired
|
|
|
private ShopErrorPriceRecordService shopErrorPriceRecordService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private KtoEccsService ktoEccsService;
|
|
|
+
|
|
|
@Override
|
|
|
public GoodsEntity queryObject(Integer id) {
|
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
@@ -764,6 +771,20 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
List<String> failGoodsSnList = new ArrayList<>();
|
|
|
List<String> failGoodsTypeList = new ArrayList<>();
|
|
|
// List<String> failFreightList = new ArrayList<>();
|
|
|
+
|
|
|
+
|
|
|
+ // 定义需要批量插入的list
|
|
|
+ List<ProductEntity> insertProductList = new LinkedList<>();
|
|
|
+ List<GoodsSpecificationEntity> insertSpecificationList = new LinkedList<>();
|
|
|
+ List<MngChangeEntity> insertMngChangeList = new LinkedList<>();
|
|
|
+ List<GoodsEntity> insertGoodsList = new LinkedList<>();
|
|
|
+ List<SupplierEntity> insertSupplierList = new LinkedList<>();
|
|
|
+
|
|
|
+ // 定义需要批量修改的list
|
|
|
+ List<ProductEntity> updateProductList = new LinkedList<>();
|
|
|
+ List<GoodsSpecificationEntity> updateSpecificationList = new LinkedList<>();
|
|
|
+ List<GoodsEntity> updateGoodsList = new LinkedList<>();
|
|
|
+
|
|
|
if (goodsEntityList != null && goodsEntityList.size() > 0) {
|
|
|
for (int i = 0; i < goodsEntityList.size(); i++) {
|
|
|
GoodsDto goodsDto = goodsEntityList.get(i);
|
|
@@ -880,7 +901,10 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
supplierEntity.setChildSupplierFlag(goodsDto.getSupplierFlag());
|
|
|
supplierEntity.setIsShow("0");
|
|
|
|
|
|
- supplierDao.save(supplierEntity);
|
|
|
+ // TODO 这里改成批量插入 SupplierEntity
|
|
|
+ insertSupplierList.add(supplierEntity);
|
|
|
+
|
|
|
+// supplierDao.save(supplierEntity);
|
|
|
// supplierEntity = supplierDao.queryObjectByName(goodsDto.getSupplierName(), thirdMerchantBizEntity.getMerchSn(),thirdMerchantBizEntity.getThirdPartyMerchCode());
|
|
|
goodsEntity.setSupplierId(supplierEntity.getId());
|
|
|
} else {
|
|
@@ -986,25 +1010,32 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
mngChangeEntity.setValidNum(goods.getGoodsNumber() + Integer.parseInt(goodsDto.getGoodsNumber()));//可用数
|
|
|
mngChangeEntity.setChangeNum(Integer.parseInt(goodsDto.getGoodsNumber()));//变化数
|
|
|
mngChangeEntity.setChangeType(Dict.changeType.item_3.getItem());
|
|
|
- mngChangeEntity.setGoodsId(Integer.parseInt(String.valueOf(goods.getId())));
|
|
|
+ mngChangeEntity.setGoodsId(goods.getId().intValue());
|
|
|
|
|
|
goodsEntity.setId(goods.getId());
|
|
|
goodsEntity.setGoodsNumber(goods.getGoodsNumber()+Integer.parseInt(goodsDto.getGoodsNumber()));
|
|
|
- goodsDao.update(goodsEntity);
|
|
|
+
|
|
|
+ // TODO 这里改成批量修改 GoodsEntity
|
|
|
+ updateGoodsList.add(goodsEntity);
|
|
|
+// goodsDao.update(goodsEntity);
|
|
|
}else{
|
|
|
mngChangeEntity.setOriginalNum(0);//原库存数
|
|
|
mngChangeEntity.setValidNum(Integer.parseInt(goodsDto.getGoodsNumber()));//可用数
|
|
|
mngChangeEntity.setChangeNum(Integer.parseInt(goodsDto.getGoodsNumber()));//变化数
|
|
|
mngChangeEntity.setChangeType(Dict.changeType.item_2.getItem());
|
|
|
|
|
|
+ // TODO 这里改成批量插入 GoodsEntity
|
|
|
+
|
|
|
goodsDao.save(goodsEntity);
|
|
|
+ insertGoodsList.add(goodsEntity);
|
|
|
mngChangeEntity.setGoodsId(goodsEntity.getId().intValue());
|
|
|
}
|
|
|
|
|
|
|
|
|
+ // TODO 这里改成批量插入 MngChangeEntity
|
|
|
|
|
|
-
|
|
|
- mngChangeDao.save(mngChangeEntity);
|
|
|
+// mngChangeDao.save(mngChangeEntity);
|
|
|
+ insertMngChangeList.add(mngChangeEntity);
|
|
|
// // 保税商品修改各个门店商品价格
|
|
|
// if (!Dict.orderBizType.item_11.getItem().equals(goodsDto.getGoodsBizType())) {
|
|
|
// List<ProductStoreRelaEntity> productStoreRelaEntityList = productStoreRelaDao.queryByGoodsId(goodsDto.getId());
|
|
@@ -1028,11 +1059,18 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
goodsSpecification.setGoodsId(goodsEntity.getId());
|
|
|
goodsSpecification.setValue(goodsEntity.getCiqProdModel());
|
|
|
goodsSpecification.setSpecificationId(1);
|
|
|
+
|
|
|
+
|
|
|
+ // TODO 这里改成批量插入 GoodsSpecificationEntity
|
|
|
goodsSpecificationDao.save(goodsSpecification);
|
|
|
+// insertSpecificationList.add(goodsSpecification);
|
|
|
}else {
|
|
|
goodsSpecification.setValue(goodsDto.getCiqProdModel());
|
|
|
goodsSpecification.setId(specificationEntity.getId());
|
|
|
- goodsSpecificationDao.update(goodsSpecification);
|
|
|
+
|
|
|
+ // TODO 这里改成批量更新 GoodsSpecificationEntity
|
|
|
+// goodsSpecificationDao.update(goodsSpecification);
|
|
|
+ updateSpecificationList.add(goodsSpecification);
|
|
|
}
|
|
|
if(product == null){
|
|
|
product = new ProductEntity();
|
|
@@ -1042,15 +1080,98 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
product.setGoodsNumber(goodsEntity.getGoodsNumber());
|
|
|
product.setGoodsSpecificationNameValue(goodsSpecification.getValue());
|
|
|
product.setGoodsSpecificationIds(goodsSpecification.getId().toString());
|
|
|
- productDao.save(product);
|
|
|
+
|
|
|
+ // TODO 这里改成批量插入 ProductEntity
|
|
|
+ insertProductList.add(product);
|
|
|
+// productDao.save(product);
|
|
|
}else{
|
|
|
product.setGoodsSpecificationIds(goodsSpecification.getId().toString());
|
|
|
product.setGoodsSpecificationNameValue(goodsSpecification.getValue());
|
|
|
- productDao.update(product);
|
|
|
+
|
|
|
+ // TODO 这里改成批量更新 ProductEntity
|
|
|
+ updateProductList.add(product);
|
|
|
+// productDao.update(product);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 批量插入数据
|
|
|
+ if(insertProductList != null && insertProductList.size() > 0) {
|
|
|
+ // 长度限制,如果大于50,就分多次插入
|
|
|
+ if(insertProductList.size() > 50){
|
|
|
+ List<List<ProductEntity>> partition = Lists.partition(insertProductList, 50);
|
|
|
+ for (List<ProductEntity> productEntities : partition) {
|
|
|
+ productDao.saveBatch(productEntities);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ productDao.saveBatch(insertProductList);;
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+// if(insertSpecificationList != null && insertSpecificationList.size() > 0) {
|
|
|
+// goodsSpecificationDao.saveBatch(insertSpecificationList);
|
|
|
+// }
|
|
|
+ if(insertMngChangeList != null && insertMngChangeList.size() > 0 ){
|
|
|
+ if(insertMngChangeList.size() > 50){
|
|
|
+ List<List<MngChangeEntity>> partition = Lists.partition(insertMngChangeList, 50);
|
|
|
+ for (List<MngChangeEntity> mngChangeEntities : partition) {
|
|
|
+ mngChangeDao.saveBatch(mngChangeEntities);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ mngChangeDao.saveBatch(insertMngChangeList);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+// if(insertGoodsList != null && insertGoodsList.size() > 0 ){
|
|
|
+// goodsDao.saveBatch(insertGoodsList);
|
|
|
+// }
|
|
|
+ if(insertSupplierList != null && insertSupplierList.size() > 0 ){
|
|
|
+ if(insertSupplierList.size() > 50){
|
|
|
+ List<List<SupplierEntity>> partition = Lists.partition(insertSupplierList, 50);
|
|
|
+ for (List<SupplierEntity> supplierEntities : partition) {
|
|
|
+ supplierDao.saveBatch(supplierEntities);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ supplierDao.saveBatch(insertSupplierList);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 批量更新数据
|
|
|
+ if(updateProductList != null && updateProductList.size() > 0 ){
|
|
|
+
|
|
|
+ if(updateProductList.size() > 50){
|
|
|
+ List<List<ProductEntity>> partition = Lists.partition(updateProductList, 50);
|
|
|
+ for (List<ProductEntity> productEntities : partition) {
|
|
|
+ productDao.updateBatch(productEntities);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ productDao.updateBatch(updateProductList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(updateSpecificationList != null && updateSpecificationList.size() > 0 ){
|
|
|
+ if(updateSpecificationList.size() > 50){
|
|
|
+ List<List<GoodsSpecificationEntity>> partition = Lists.partition(updateSpecificationList, 50);
|
|
|
+ for (List<GoodsSpecificationEntity> goodsSpecificationEntities : partition) {
|
|
|
+ goodsSpecificationDao.updateBatch(goodsSpecificationEntities);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ goodsSpecificationDao.updateBatch(updateSpecificationList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(updateGoodsList != null && updateGoodsList.size() > 0 ){
|
|
|
+ if(updateGoodsList.size() > 50){
|
|
|
+ List<List<GoodsEntity>> partition = Lists.partition(updateGoodsList, 50);
|
|
|
+ for (List<GoodsEntity> goodsEntities : partition) {
|
|
|
+ goodsDao.updateBatch(goodsEntities);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ goodsDao.updateBatch(updateGoodsList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
ExportExceptionDataEntity exportExceptionDataEntity = new ExportExceptionDataEntity();
|
|
|
exportExceptionDataEntity.setCreaterSn(user.getUserId().toString());
|
|
|
exportExceptionDataEntity.setUserId(user.getUserId().intValue());
|
|
@@ -1137,6 +1258,38 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
goodsUtils.save(exportExceptionDataEntity);
|
|
|
throw new RRException("导入数据异常,异常信息请在商品管理》》商品导入异常数据中查看检查");
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ // 将插入的商品和更新的商品放到一个list中
|
|
|
+ List<GoodsEntity> goodsEntities = new LinkedList<>();
|
|
|
+ goodsEntities.addAll(insertGoodsList);
|
|
|
+ goodsEntities.addAll(updateGoodsList);
|
|
|
+
|
|
|
+ List<KtoEccsEntity> ktoEccsEntities = new LinkedList<>();
|
|
|
+ if(goodsEntities.size() > 0){
|
|
|
+ for (GoodsEntity goodsEntity : goodsEntities) {
|
|
|
+ KtoEccsEntity ktoEccsEntity = new KtoEccsEntity();
|
|
|
+ ktoEccsEntity.setRequestData(JSON.toJSONString(goodsEntity));
|
|
|
+ ktoEccsEntity.setRequestType("01");
|
|
|
+ ktoEccsEntity.setSendStatus("00");
|
|
|
+ ktoEccsEntity.setCreaterSn(user.getUserId()+"");
|
|
|
+ ktoEccsEntity.setCreateTime(new Date());
|
|
|
+
|
|
|
+ ktoEccsEntities.add(ktoEccsEntity);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if(ktoEccsEntities.size() > 0){
|
|
|
+ if(ktoEccsEntities.size() > 50){
|
|
|
+ List<List<KtoEccsEntity>> partition = Lists.partition(ktoEccsEntities, 50);
|
|
|
+ for (List<KtoEccsEntity> ktoEccs : partition) {
|
|
|
+ ktoEccsService.saveBatch(ktoEccs);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ ktoEccsService.saveBatch(ktoEccsEntities);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}else{
|
|
|
throw new RRException("导入数据为空,或者检查商品编码数据是否为空");
|
|
|
}
|
|
@@ -1932,6 +2085,11 @@ public class GoodsServiceImpl implements GoodsService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<GoodsEntity> queryAllList() {
|
|
|
+ return goodsDao.queryAllList();
|
|
|
+ }
|
|
|
+
|
|
|
private void calculeatePromotion(SysUserEntity user, GoodsEntity goods, List<Map<String, String>> errorPriceSkuList, List<ShopErrorPriceRecordEntity> shopErrorPriceRecordEntities) {
|
|
|
String prodBarcode = goods.getProdBarcode();
|
|
|
String storeId = goods.getStoreId()+"";
|