|
@@ -1,6 +1,5 @@
|
|
|
package com.uas.platform.b2c.prod.commodity.service.impl;
|
|
package com.uas.platform.b2c.prod.commodity.service.impl;
|
|
|
|
|
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.uas.platform.b2c.common.account.model.Enterprise;
|
|
import com.uas.platform.b2c.common.account.model.Enterprise;
|
|
|
import com.uas.platform.b2c.common.base.dao.CommonDao;
|
|
import com.uas.platform.b2c.common.base.dao.CommonDao;
|
|
|
import com.uas.platform.b2c.core.config.SysConf;
|
|
import com.uas.platform.b2c.core.config.SysConf;
|
|
@@ -17,6 +16,7 @@ import com.uas.platform.b2c.prod.commodity.dao.*;
|
|
|
import com.uas.platform.b2c.prod.commodity.model.*;
|
|
import com.uas.platform.b2c.prod.commodity.model.*;
|
|
|
import com.uas.platform.b2c.prod.commodity.service.GoodsService;
|
|
import com.uas.platform.b2c.prod.commodity.service.GoodsService;
|
|
|
import com.uas.platform.b2c.prod.commodity.service.ProductPrivateService;
|
|
import com.uas.platform.b2c.prod.commodity.service.ProductPrivateService;
|
|
|
|
|
+import com.uas.platform.b2c.prod.commodity.service.ProductService;
|
|
|
import com.uas.platform.b2c.prod.commodity.service.ReleaseProductByBatchService;
|
|
import com.uas.platform.b2c.prod.commodity.service.ReleaseProductByBatchService;
|
|
|
import com.uas.platform.b2c.prod.commodity.util.GoodsUtil;
|
|
import com.uas.platform.b2c.prod.commodity.util.GoodsUtil;
|
|
|
import com.uas.platform.b2c.prod.commodity.util.SheetUtil;
|
|
import com.uas.platform.b2c.prod.commodity.util.SheetUtil;
|
|
@@ -46,8 +46,11 @@ import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
+import org.springframework.dao.DataAccessException;
|
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
|
|
+import org.springframework.jdbc.core.StatementCallback;
|
|
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.ui.ModelMap;
|
|
import org.springframework.ui.ModelMap;
|
|
@@ -59,6 +62,9 @@ import javax.persistence.criteria.CriteriaQuery;
|
|
|
import javax.persistence.criteria.Predicate;
|
|
import javax.persistence.criteria.Predicate;
|
|
|
import javax.persistence.criteria.Root;
|
|
import javax.persistence.criteria.Root;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
|
+import java.sql.ResultSet;
|
|
|
|
|
+import java.sql.SQLException;
|
|
|
|
|
+import java.sql.Statement;
|
|
|
import java.text.DateFormat;
|
|
import java.text.DateFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -123,6 +129,9 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private V_ProductPrivateDao v_productPrivateDao;
|
|
private V_ProductPrivateDao v_productPrivateDao;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ProductService productService;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 控制任务提交速度的线程池
|
|
* 控制任务提交速度的线程池
|
|
|
*/
|
|
*/
|
|
@@ -143,6 +152,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
@Value("#{sys.productServiceIp}")
|
|
@Value("#{sys.productServiceIp}")
|
|
|
private String productServiceIp;
|
|
private String productServiceIp;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
public ReleaseProductByBatchServiceImpl(NamedParameterJdbcTemplate namedJdbcTemplate, ProductPrivateService productPrivateService) {
|
|
public ReleaseProductByBatchServiceImpl(NamedParameterJdbcTemplate namedJdbcTemplate, ProductPrivateService productPrivateService) {
|
|
|
this.namedJdbcTemplate = namedJdbcTemplate;
|
|
this.namedJdbcTemplate = namedJdbcTemplate;
|
|
|
this.productPrivateService = productPrivateService;
|
|
this.productPrivateService = productPrivateService;
|
|
@@ -241,13 +251,12 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
System.out.println("获取订单信息缺失");
|
|
System.out.println("获取订单信息缺失");
|
|
|
long l1 = System.currentTimeMillis();
|
|
long l1 = System.currentTimeMillis();
|
|
|
System.err.println("l1--------------l testyuj" + (l1 - l));
|
|
System.err.println("l1--------------l testyuj" + (l1 - l));
|
|
|
- Long userUU = SystemSession.getUser().getUserUU();
|
|
|
|
|
Long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
Long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
if (!isAPerson) {
|
|
if (!isAPerson) {
|
|
|
//1:比较品牌、型号、自定义标签是否重复,2:比较六要素是否重复
|
|
//1:比较品牌、型号、自定义标签是否重复,2:比较六要素是否重复
|
|
|
for(int i = releaseProductByBatchs.size() - 1; i > -1; i--) {
|
|
for(int i = releaseProductByBatchs.size() - 1; i > -1; i--) {
|
|
|
ReleaseProductByBatch releaseProductByBatch = releaseProductByBatchs.get(i);
|
|
ReleaseProductByBatch releaseProductByBatch = releaseProductByBatchs.get(i);
|
|
|
- for(int j = i - 1; j > 0; j--) {
|
|
|
|
|
|
|
+ for(int j = i - 1; j > -1; j--) {
|
|
|
ReleaseProductByBatch byBatch = releaseProductByBatchs.get(j);
|
|
ReleaseProductByBatch byBatch = releaseProductByBatchs.get(j);
|
|
|
if(releaseProductByBatch.compareSameProductTagInfo(byBatch)) {
|
|
if(releaseProductByBatch.compareSameProductTagInfo(byBatch)) {
|
|
|
releaseProductByBatch.setTag("");
|
|
releaseProductByBatch.setTag("");
|
|
@@ -256,17 +265,24 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
releaseProductByBatch.addErrmsg(ErrorInfoConstant.REPEAT_IN_EXCEL.getInfo());
|
|
releaseProductByBatch.addErrmsg(ErrorInfoConstant.REPEAT_IN_EXCEL.getInfo());
|
|
|
releaseProductByBatch.setReleaseStatus(ReleaseStatus.had_exists.getPhrase());
|
|
releaseProductByBatch.setReleaseStatus(ReleaseStatus.had_exists.getPhrase());
|
|
|
releaseProductByBatch.setReleaseCode(ReleaseStatus.had_exists.value());
|
|
releaseProductByBatch.setReleaseCode(ReleaseStatus.had_exists.value());
|
|
|
|
|
+ if (!StringUtilB2C.isEmpty(releaseProductByBatch.getErrmsg())) {
|
|
|
|
|
+ if (releaseProductByBatch.getErrmsg().substring(0, 1).equals(",")) {
|
|
|
|
|
+ releaseProductByBatch.setErrmsg(releaseProductByBatch.getErrmsg().substring(1));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ long l2 = System.currentTimeMillis();
|
|
|
|
|
+ System.err.println("l2--------------l1 testyuj" + (l2 - l1));
|
|
|
commonDao.save(releaseProductByBatchs, ReleaseProductByBatch.class);
|
|
commonDao.save(releaseProductByBatchs, ReleaseProductByBatch.class);
|
|
|
- long l2 = System.currentTimeMillis();
|
|
|
|
|
- System.err.println("l2--------------l1 testyuj" + (l2 - l1));
|
|
|
|
|
- releaseProductByBatchDao.callReleaseExistValidProcedure(batch, isAPerson, enUU);
|
|
|
|
|
long l3 = System.currentTimeMillis();
|
|
long l3 = System.currentTimeMillis();
|
|
|
- System.err.println("l3--------------l2 testyuj" + (l3 - l2));
|
|
|
|
|
|
|
+ System.err.println("l3--------------l2 testyuj" + (l3 - l2));
|
|
|
|
|
+ releaseProductByBatchDao.callReleaseExistValidProcedure(batch, isAPerson, enUU);
|
|
|
|
|
+ long l4 = System.currentTimeMillis();
|
|
|
|
|
+ System.err.println("l4--------------l3 testyuj" + (l4 - l3));
|
|
|
if (isAPerson) {
|
|
if (isAPerson) {
|
|
|
for (ReleaseProductByBatch releaseProductByBatch : releaseProductByBatchs) {
|
|
for (ReleaseProductByBatch releaseProductByBatch : releaseProductByBatchs) {
|
|
|
Long productid = releaseProductByBatch.getProductid();
|
|
Long productid = releaseProductByBatch.getProductid();
|
|
@@ -281,13 +297,11 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- Long l4 = 0l;
|
|
|
|
|
|
|
+ Long l5 = 0l;
|
|
|
String strCount = "";
|
|
String strCount = "";
|
|
|
if (isPcb) {
|
|
if (isPcb) {
|
|
|
strCount = releaseProductByBatchDao.callValidProcedurePcb(enUU, batch);
|
|
strCount = releaseProductByBatchDao.callValidProcedurePcb(enUU, batch);
|
|
|
} else {
|
|
} else {
|
|
|
- // final Object[] obj = new Object[]{enUU, batch};
|
|
|
|
|
-// final Object[] obj = new Object[]{enUU, batch};
|
|
|
|
|
final Object[] obj = new Object[]{enUU, batch};
|
|
final Object[] obj = new Object[]{enUU, batch};
|
|
|
String sql = "/*#mycat:db_type=master*/ set @enuu = %s; set @batch = '%s'; call PRODUCT_RELEASE_VALID_V5(@enuu, @batch, @out); select @out";
|
|
String sql = "/*#mycat:db_type=master*/ set @enuu = %s; set @batch = '%s'; call PRODUCT_RELEASE_VALID_V5(@enuu, @batch, @out); select @out";
|
|
|
final String updateSql = String.format(sql, obj);
|
|
final String updateSql = String.format(sql, obj);
|
|
@@ -305,15 +319,23 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
return "0";
|
|
return "0";
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
- l4 = System.currentTimeMillis();
|
|
|
|
|
- System.err.println("l4--------------l3 testyuj" + (l4 - l3));
|
|
|
|
|
|
|
+ l5 = System.currentTimeMillis();
|
|
|
|
|
+ System.err.println("l5--------------l4 testyuj" + (l5 - l4));
|
|
|
}
|
|
}
|
|
|
Integer filter = 0, failure = 0, success = 0;
|
|
Integer filter = 0, failure = 0, success = 0;
|
|
|
if (!StringUtilB2C.isEmpty(strCount)) {
|
|
if (!StringUtilB2C.isEmpty(strCount)) {
|
|
|
String[] split = strCount.split(SplitChar.HYPHEN);
|
|
String[] split = strCount.split(SplitChar.HYPHEN);
|
|
|
- filter = Integer.valueOf(split[0]);
|
|
|
|
|
- failure = Integer.valueOf(split[1]);
|
|
|
|
|
- success = Integer.valueOf(split[2]);
|
|
|
|
|
|
|
+ if (split.length == 3) {
|
|
|
|
|
+ filter = Integer.valueOf(split[0]);
|
|
|
|
|
+ failure = Integer.valueOf(split[1]);
|
|
|
|
|
+ success = Integer.valueOf(split[2]);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ //便于测试上执行
|
|
|
|
|
+ Long userUU = SystemSession.getUser().getUserUU();
|
|
|
|
|
+ filter = releaseProductByBatchDao.getCountOfImportFail(userUU, batch, failCode);
|
|
|
|
|
+ failure = releaseProductByBatchDao.getCountPublisherUuAndBatchAndReleaseCode(userUU, batch, ReleaseStatus.failure.value());
|
|
|
|
|
+ success = releaseProductByBatchDao.getCountPublisherUuAndBatchAndReleaseCode(userUU, batch, ReleaseStatus.success.value());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
modelMap.put("total", total);
|
|
modelMap.put("total", total);
|
|
@@ -1692,22 +1714,14 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
Map<String, Object> map = convertProduct(releaseProductByBatchList, false, isPcb);
|
|
Map<String, Object> map = convertProduct(releaseProductByBatchList, false, isPcb);
|
|
|
long l2 = System.currentTimeMillis();
|
|
long l2 = System.currentTimeMillis();
|
|
|
System.err.println("l2 -------------------l1 " + (l2 - l1));
|
|
System.err.println("l2 -------------------l1 " + (l2 - l1));
|
|
|
- List<com.uas.ps.entity.Product> products = (List<com.uas.ps.entity.Product>) map.get("products");
|
|
|
|
|
- // TODO 什么接口
|
|
|
|
|
- String result = restTemplate.postForEntity(productServiceIp + "/product/update", products, String.class).getBody();
|
|
|
|
|
- long l3 = System.currentTimeMillis();
|
|
|
|
|
- System.err.println("l3 -------------------l2 " + (l3 - l2));
|
|
|
|
|
- List<Long> productIds = JSON.parseArray(result, Long.class);
|
|
|
|
|
- Set<Long> idSet = new HashSet<>(productIds);
|
|
|
|
|
|
|
+ Set<Long> idSet = (Set<Long>) map.get("prIds");
|
|
|
if (isPcb) {
|
|
if (isPcb) {
|
|
|
savePcbInfo(idSet, map);
|
|
savePcbInfo(idSet, map);
|
|
|
}
|
|
}
|
|
|
long l8 = System.currentTimeMillis();
|
|
long l8 = System.currentTimeMillis();
|
|
|
Enterprise enterprise = SystemSession.getUser().getEnterprise();
|
|
Enterprise enterprise = SystemSession.getUser().getEnterprise();
|
|
|
- long l8 = System.currentTimeMillis();
|
|
|
|
|
- Enterprise enterprise = SystemSession.getUser().getEnterprise();
|
|
|
|
|
final Object[] obj = new Object[]{enterprise.getUu(), enterprise.getEnName(), batch};
|
|
final Object[] obj = new Object[]{enterprise.getUu(), enterprise.getEnName(), batch};
|
|
|
- String sql = "/*#mycat:db_type=master*/ set @enuu = %s; set @enName = '%s'; set @batch = '%s'; call RELEASE_TO_GOODS_V3(@enuu, @enName, @batch, @out); select @out";
|
|
|
|
|
|
|
+ String sql = "/*#mycat:db_type=master*/ set @enuu = %s; set @enName = '%s'; set @batch = '%s'; call RELEASE_TO_GOODS_V4(@enuu, @enName, @batch, @out); select @out";
|
|
|
final String updateSql = String.format(sql, obj);
|
|
final String updateSql = String.format(sql, obj);
|
|
|
String num = jdbcTemplate.execute(new StatementCallback<String>() {
|
|
String num = jdbcTemplate.execute(new StatementCallback<String>() {
|
|
|
|
|
|
|
@@ -1724,7 +1738,9 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
});
|
|
});
|
|
|
long l9 = System.currentTimeMillis();
|
|
long l9 = System.currentTimeMillis();
|
|
|
System.err.println("l9 -------------------l8 " + (l9 - l8));
|
|
System.err.println("l9 -------------------l8 " + (l9 - l8));
|
|
|
- afterPublishToGoodsDo(productIds);
|
|
|
|
|
|
|
+ ArrayList<Long> list = new ArrayList<>();
|
|
|
|
|
+ list.addAll((Set<Long>)map.get("prIds"));
|
|
|
|
|
+ afterPublishToGoodsDo(list, (Set<Long>)map.get("reIds"));
|
|
|
return StringUtilB2C.getStr(num);
|
|
return StringUtilB2C.getStr(num);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1775,7 +1791,9 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
Map<String, Object> map = new HashedMap();
|
|
Map<String, Object> map = new HashedMap();
|
|
|
- List<com.uas.ps.entity.Product> products = new ArrayList<>();
|
|
|
|
|
|
|
+ List<Product> products = new ArrayList<>();
|
|
|
|
|
+ Set<Long> prIds = new HashSet<>();
|
|
|
|
|
+ Set<Long> reIds = new HashSet<>();
|
|
|
Map<String, List<PCBPropertyValue>> propertyMap = new HashedMap();
|
|
Map<String, List<PCBPropertyValue>> propertyMap = new HashedMap();
|
|
|
|
|
|
|
|
Long sizeProId = null;
|
|
Long sizeProId = null;
|
|
@@ -1794,34 +1812,24 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
}
|
|
}
|
|
|
String time = importNum.substring(IntegerConstant.NO_SHORT, (IntegerConstant.TIME_LENGTH - 1));
|
|
String time = importNum.substring(IntegerConstant.NO_SHORT, (IntegerConstant.TIME_LENGTH - 1));
|
|
|
Integer num = Integer.valueOf(importNum.substring(IntegerConstant.TIME_LENGTH));
|
|
Integer num = Integer.valueOf(importNum.substring(IntegerConstant.TIME_LENGTH));
|
|
|
- String batchCode = null;
|
|
|
|
|
|
|
+ String prodNum = null;
|
|
|
for (ReleaseProductByBatch releaseProductByBatch : releaseProductByBatchList) {
|
|
for (ReleaseProductByBatch releaseProductByBatch : releaseProductByBatchList) {
|
|
|
if (releaseProductByBatch.getReleaseCode().equals(ReleaseStatus.failure.value()) ||
|
|
if (releaseProductByBatch.getReleaseCode().equals(ReleaseStatus.failure.value()) ||
|
|
|
releaseProductByBatch.getReleaseCode().equals(ReleaseStatus.success.value())) {
|
|
releaseProductByBatch.getReleaseCode().equals(ReleaseStatus.success.value())) {
|
|
|
- com.uas.ps.entity.Product product = new com.uas.ps.entity.Product();
|
|
|
|
|
- // releaseProductByBatch.getCode(); 在公有库生成
|
|
|
|
|
- product.setMinPack(releaseProductByBatch.getMinPackage());
|
|
|
|
|
- product.setCmpImg(releaseProductByBatch.getImg());
|
|
|
|
|
- product.setEnUU(SystemSession.getUser().getEnterprise().getUu());
|
|
|
|
|
- product.setBrand(releaseProductByBatch.getBrandNameEn());
|
|
|
|
|
- product.setCmpCode(releaseProductByBatch.getCode());
|
|
|
|
|
- product.setCmpUuid(releaseProductByBatch.getComponentUuId());
|
|
|
|
|
- product.setKind(releaseProductByBatch.getKindName());
|
|
|
|
|
- product.setKindId(releaseProductByBatch.getKindUuid());
|
|
|
|
|
- product.setpCmpCode(releaseProductByBatch.getB2cCode());
|
|
|
|
|
- product.setpBrand(releaseProductByBatch.getB2cBrandcn());
|
|
|
|
|
- product.setpBrandEn(releaseProductByBatch.getB2cBranden());
|
|
|
|
|
- product.setpBrandId(releaseProductByBatch.getBrandId());
|
|
|
|
|
- product.setpBrandUuid(releaseProductByBatch.getBranduuid());
|
|
|
|
|
- product.setStandard(releaseProductByBatch.getComponentUuId() == null ? (short)0 : (short)1);
|
|
|
|
|
- product.setCmpUuid(releaseProductByBatch.getComponentUuId());
|
|
|
|
|
- product.setCreateTime(new Date(System.currentTimeMillis()));
|
|
|
|
|
- product.setSpec(releaseProductByBatch.getSpec());
|
|
|
|
|
- // 产品导入默认可销售
|
|
|
|
|
- product.setIsSale((short) 1);
|
|
|
|
|
-
|
|
|
|
|
- batchCode = "PNUM" + time + CreateNumberServiceImpl.formatIntToStr(num++, 8);
|
|
|
|
|
- product.setCode(batchCode);
|
|
|
|
|
|
|
+ if (releaseProductByBatch.getProductid() == null) {
|
|
|
|
|
+ Product product = new Product();
|
|
|
|
|
+ product.setReleaseByBatch(releaseProductByBatch);
|
|
|
|
|
+ // releaseProductByBatch.getCode(); 在公有库生成
|
|
|
|
|
+ prodNum = "PNUM" + time + CreateNumberServiceImpl.formatIntToStr(num++, 8);
|
|
|
|
|
+ product.setProdNum(prodNum);
|
|
|
|
|
+ products.add(product);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ //对于已经存在于物料库的信息,如果规格信息已存在,则做更新,如果是
|
|
|
|
|
+ prIds.add(releaseProductByBatch.getProductid());
|
|
|
|
|
+ if (!StringUtilB2C.isEmpty(releaseProductByBatch.getSpec())) {
|
|
|
|
|
+ reIds.add(releaseProductByBatch.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if (isPcb) {
|
|
if (isPcb) {
|
|
|
List<PCBPropertyValue> propertyValues = new ArrayList<>();
|
|
List<PCBPropertyValue> propertyValues = new ArrayList<>();
|
|
@@ -1842,14 +1850,21 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
propertyValues.add(propertyValue);
|
|
propertyValues.add(propertyValue);
|
|
|
}
|
|
}
|
|
|
if (CollectionUtils.isNotEmpty(propertyValues)) {
|
|
if (CollectionUtils.isNotEmpty(propertyValues)) {
|
|
|
- propertyMap.put(product.getEnUU().toString().concat(product.getCode()), propertyValues);
|
|
|
|
|
|
|
+ propertyMap.put(SystemSession.getUser().getEnterprise().getUu().toString().concat(prodNum), propertyValues);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- products.add(product);
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- map.put("products", products);
|
|
|
|
|
|
|
+ List<Product> products1 = productDao.save(products);
|
|
|
|
|
+ for (Product product : products1) {
|
|
|
|
|
+ prIds.add(product.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (reIds.size() < 1) {
|
|
|
|
|
+ map.put("reIds", prIds);
|
|
|
|
|
+ }
|
|
|
|
|
+ map.put("prIds", prIds);
|
|
|
map.put("propertyvalues", propertyMap);
|
|
map.put("propertyvalues", propertyMap);
|
|
|
return map;
|
|
return map;
|
|
|
}
|
|
}
|
|
@@ -1860,30 +1875,15 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
releaseProductByBatchDao.findByRelbatchid(batch);
|
|
releaseProductByBatchDao.findByRelbatchid(batch);
|
|
|
if (!CollectionUtils.isEmpty(releaseProductByBatchList)) {
|
|
if (!CollectionUtils.isEmpty(releaseProductByBatchList)) {
|
|
|
Map<String, Object> map = convertProduct(releaseProductByBatchList,false, false);
|
|
Map<String, Object> map = convertProduct(releaseProductByBatchList,false, false);
|
|
|
- List<com.uas.ps.entity.Product> products = (List<com.uas.ps.entity.Product>) map.get("products");
|
|
|
|
|
- // TODO 什么接口
|
|
|
|
|
- String result = restTemplate.postForEntity(productServiceIp + "/product/update", products, String.class).getBody();
|
|
|
|
|
- List<Long> productIds = JSON.parseArray(result, Long.class);
|
|
|
|
|
|
|
+ Set<Long> prIds = (Set<Long>) map.get("prIds");
|
|
|
|
|
+ List<Long> productIds = new ArrayList<>();
|
|
|
|
|
+ productIds.addAll(prIds);
|
|
|
//添加个人关系
|
|
//添加个人关系
|
|
|
String res = restTemplate.postForEntity(productServiceIp + "/product/assign/batch?userUU=" + SystemSession.getUser().getUserUU(), productIds, String.class).getBody();
|
|
String res = restTemplate.postForEntity(productServiceIp + "/product/assign/batch?userUU=" + SystemSession.getUser().getUserUU(), productIds, String.class).getBody();
|
|
|
// 默认为b2c Enable开启
|
|
// 默认为b2c Enable开启
|
|
|
- List<ProductPrivate> productPrivates = new ArrayList<>();
|
|
|
|
|
- Set<Long> idSet = new HashSet<>(productIds);
|
|
|
|
|
- for (Long prId : idSet) {
|
|
|
|
|
- ProductPrivate productPrivate = productPrivateService.findByPrId(prId);
|
|
|
|
|
- if (null == productPrivate) {
|
|
|
|
|
- productPrivate = new ProductPrivate();
|
|
|
|
|
- productPrivate.setPrId(prId);
|
|
|
|
|
- }
|
|
|
|
|
- productPrivate.setB2cEnabled(IntegerConstant.YES_SHORT);
|
|
|
|
|
- // 统计现在有多少在售信息
|
|
|
|
|
- int batchCount = goodsDao.findCountByProductid(prId);
|
|
|
|
|
- productPrivate.setBatchCount(batchCount);
|
|
|
|
|
- productPrivates.add(productPrivate);
|
|
|
|
|
- }
|
|
|
|
|
- productPrivateDao.save(productPrivates);
|
|
|
|
|
|
|
+ productPrivateService.newProductPrivateIfNotExist(productIds);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ return "sucesss";
|
|
|
// User user = SystemSession.getUser();
|
|
// User user = SystemSession.getUser();
|
|
|
// Enterprise enterprise = SystemSession.getUser().getEnterprise();
|
|
// Enterprise enterprise = SystemSession.getUser().getEnterprise();
|
|
|
// final Object[] obj = new Object[]{enterprise.getUu(), user.getUserUU(), enterprise.getEnName(), batch};
|
|
// final Object[] obj = new Object[]{enterprise.getUu(), user.getUserUU(), enterprise.getEnName(), batch};
|
|
@@ -1902,57 +1902,38 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
// return "0";
|
|
// return "0";
|
|
|
// }
|
|
// }
|
|
|
// });
|
|
// });
|
|
|
- return null;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 批量发布之后,需要做的事情,内部使用线程,不需要让用户等结果
|
|
* 批量发布之后,需要做的事情,内部使用线程,不需要让用户等结果
|
|
|
*/
|
|
*/
|
|
|
- public void afterPublishToGoodsDo(final List<Long> productIds) {
|
|
|
|
|
|
|
+ public void afterPublishToGoodsDo(final List<Long> productIds, final Set<Long> reIds) {
|
|
|
if (CollectionUtils.isEmpty(productIds)) {
|
|
if (CollectionUtils.isEmpty(productIds)) {
|
|
|
return ;
|
|
return ;
|
|
|
}
|
|
}
|
|
|
final Runnable afterPublishToGoodsRunnable = new Runnable() {
|
|
final Runnable afterPublishToGoodsRunnable = new Runnable() {
|
|
|
@Override
|
|
@Override
|
|
|
public void run() {
|
|
public void run() {
|
|
|
- List<ProductPrivate> productPrivates = new ArrayList<ProductPrivate>();
|
|
|
|
|
- List<ProductPrivate> privateList = productPrivateService.findByPrIds(productIds);
|
|
|
|
|
- Boolean isExist = false;
|
|
|
|
|
- ProductPrivate productPrivate = null;
|
|
|
|
|
- int batchCount = 0;
|
|
|
|
|
- Map<Long, Integer> goodsCountByProductId = goodsService.batchGetCountByProductId(productIds);
|
|
|
|
|
- for (Long productId : productIds) {
|
|
|
|
|
- isExist = false;
|
|
|
|
|
- batchCount = 0;
|
|
|
|
|
- if (goodsCountByProductId != null) {
|
|
|
|
|
- batchCount = goodsCountByProductId.get(productId);
|
|
|
|
|
|
|
+ //创建物料的私有信息
|
|
|
|
|
+ productPrivateService.newProductPrivateIfNotExist(productIds);
|
|
|
|
|
+
|
|
|
|
|
+ if ((reIds != null) && (reIds.size() != 0)) {
|
|
|
|
|
+ List<ReleaseProductByBatch> productByBatches = releaseProductByBatchDao.findAll(reIds);
|
|
|
|
|
+ List<Long> prIds = new ArrayList<>();
|
|
|
|
|
+ for (ReleaseProductByBatch productByBatch : productByBatches) {
|
|
|
|
|
+ prIds.add(productByBatch.getProductid());
|
|
|
}
|
|
}
|
|
|
- for (ProductPrivate productPri : privateList) {
|
|
|
|
|
- if (productPri.getPrId().longValue() == productId.longValue()) {
|
|
|
|
|
- isExist = true;
|
|
|
|
|
- if ((productPri.getB2cEnabled() == null) || (productPri.getB2cEnabled().intValue() != IntegerConstant.YES_SHORT.intValue()) || (productPri.getBatchCount() == null) || (productPri.getBatchCount().intValue() != batchCount)) {
|
|
|
|
|
- productPri.setB2cEnabled(IntegerConstant.YES_SHORT);
|
|
|
|
|
- productPri.setBatchCount(batchCount);
|
|
|
|
|
- productPrivates.add(productPri);
|
|
|
|
|
|
|
+ List<Product> products = productService.findByProductId(prIds);
|
|
|
|
|
+ for (Product product : products) {
|
|
|
|
|
+ for (ReleaseProductByBatch productByBatch : productByBatches) {
|
|
|
|
|
+ if ((productByBatch.getProductid() != null ) && (product.getId().longValue() == productByBatch.getProductid().longValue())) {
|
|
|
|
|
+ product.setSpec(productByBatch.getSpec());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if (!isExist) {
|
|
|
|
|
- productPrivate = new ProductPrivate();
|
|
|
|
|
- productPrivate.setPrId(productId);
|
|
|
|
|
- productPrivate.setBatchCount(batchCount);
|
|
|
|
|
- productPrivate.setB2cEnabled(IntegerConstant.YES_SHORT);
|
|
|
|
|
- productPrivates.add(productPrivate);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ List<Goods> goodses = goodsDao.findByProductIds(prIds);
|
|
|
|
|
+ goodsService.updateSpecByProducts(products, goodses);
|
|
|
}
|
|
}
|
|
|
- if (CollectionUtils.isNotEmpty(productPrivates)) {
|
|
|
|
|
- productPrivateService.saveProductPrivate(productPrivates);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //根据更新的规格信息,更新在售产品的信息
|
|
|
|
|
- List<V_ProductPrivate> v_productPrivates = v_productPrivateDao.findProductInIdAndSpecIsNotNull(productIds);
|
|
|
|
|
- List<Goods> goodses = goodsDao.findByProductIds(productIds);
|
|
|
|
|
- goodsService.updateSpecByProducts(v_productPrivates, goodses);
|
|
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
try {
|
|
try {
|