|
|
@@ -20,12 +20,16 @@ import com.uas.platform.b2c.prod.commodity.constant.ModifyConstant;
|
|
|
import com.uas.platform.b2c.prod.commodity.constant.ShortConstant;
|
|
|
import com.uas.platform.b2c.prod.commodity.constant.UploadConstant;
|
|
|
import com.uas.platform.b2c.prod.commodity.dao.GoodsDao;
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.PCBDao;
|
|
|
+import com.uas.platform.b2c.prod.commodity.dao.PcbPropertyvalueDao;
|
|
|
import com.uas.platform.b2c.prod.commodity.dao.ProductDao;
|
|
|
import com.uas.platform.b2c.prod.commodity.dao.ProductPersonDao;
|
|
|
import com.uas.platform.b2c.prod.commodity.dao.ProductPrivateDao;
|
|
|
import com.uas.platform.b2c.prod.commodity.dao.ReleaseProductByBatchDao;
|
|
|
import com.uas.platform.b2c.prod.commodity.model.Goods;
|
|
|
import com.uas.platform.b2c.prod.commodity.model.GoodsQtyPrice;
|
|
|
+import com.uas.platform.b2c.prod.commodity.model.PCB;
|
|
|
+import com.uas.platform.b2c.prod.commodity.model.PCBPropertyValue;
|
|
|
import com.uas.platform.b2c.prod.commodity.model.Product;
|
|
|
import com.uas.platform.b2c.prod.commodity.model.ProductPerson;
|
|
|
import com.uas.platform.b2c.prod.commodity.model.ProductPrivate;
|
|
|
@@ -37,6 +41,7 @@ import com.uas.platform.b2c.prod.commodity.util.SheetUtil;
|
|
|
import com.uas.platform.b2c.prod.product.common.service.CreateNumberService;
|
|
|
import com.uas.platform.b2c.prod.product.kind.dao.KindInfoDao;
|
|
|
import com.uas.platform.b2c.prod.product.kind.model.KindInfo;
|
|
|
+import com.uas.platform.b2c.prod.product.property.dao.PropertyDao;
|
|
|
import com.uas.platform.b2c.prod.store.model.StoreIn;
|
|
|
import com.uas.platform.b2c.prod.store.model.StoreStatus;
|
|
|
import com.uas.platform.b2c.prod.store.service.StoreInService;
|
|
|
@@ -70,6 +75,7 @@ import javax.persistence.criteria.CriteriaQuery;
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
import javax.persistence.criteria.Root;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
+import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFCell;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
|
@@ -134,6 +140,20 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
@Autowired
|
|
|
private KindInfoDao kindInfoDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private PCBDao pcbDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PropertyDao propertyDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PcbPropertyvalueDao pcbPropertyvalueDao;
|
|
|
+
|
|
|
+ private static final String SIZE = "尺寸";
|
|
|
+ private static final String COLOR = "颜色";
|
|
|
+ private static final String THICKCOPPER = "铜厚";
|
|
|
+ private static final String THICK = "厚度";
|
|
|
+
|
|
|
@Value("#{sys.productServiceIp}")
|
|
|
private String productServiceIp;
|
|
|
|
|
|
@@ -251,7 +271,13 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
}
|
|
|
}
|
|
|
commonDao.save(addList, ReleaseProductByBatch.class);
|
|
|
- releaseProductByBatchDao.callValidProcedure(enUU, batch);
|
|
|
+
|
|
|
+ if (isPcb) {
|
|
|
+ releaseProductByBatchDao.callValidProcedurePcb(enUU, batch);
|
|
|
+ } else {
|
|
|
+ releaseProductByBatchDao.callValidProcedure(enUU, batch);
|
|
|
+ }
|
|
|
+
|
|
|
Integer filter = releaseProductByBatchDao.getCountOfImportFail(userUU, batch, failCode);
|
|
|
Integer failure = releaseProductByBatchDao.getCountPublisherUuAndBatchAndReleaseCode(userUU, batch, ReleaseStatus.failure.value());
|
|
|
Integer success = releaseProductByBatchDao.getCountPublisherUuAndBatchAndReleaseCode(userUU, batch, ReleaseStatus.success.value());
|
|
|
@@ -1584,14 +1610,14 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public String publishByBatch(String batch) {
|
|
|
-
|
|
|
+ public String publishByBatch(String batch, boolean isPcb) {
|
|
|
List<ReleaseProductByBatch> releaseProductByBatchList =
|
|
|
releaseProductByBatchDao.findByRelbatchid(batch);
|
|
|
List<Long> productIds = null;
|
|
|
List<ProductPrivate> productPrivateList = null;
|
|
|
if (!CollectionUtils.isEmpty(releaseProductByBatchList)) {
|
|
|
- List<com.uas.ps.entity.Product> products = convertProduct(releaseProductByBatchList,false);
|
|
|
+ Map<String, Object> map = convertProduct(releaseProductByBatchList,false, isPcb);
|
|
|
+ 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();
|
|
|
productIds = JSON.parseArray(result, Long.class);
|
|
|
@@ -1607,6 +1633,40 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
productPrivates.add(productPrivate);
|
|
|
}
|
|
|
productPrivateList = productPrivateDao.save(productPrivates);
|
|
|
+
|
|
|
+ if (isPcb) {
|
|
|
+ List<PCB> pcbList = new ArrayList<>();
|
|
|
+ List<PCBPropertyValue> propertyValueList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (Long prId : idSet) {
|
|
|
+ Product product = productDao.findOne(prId);
|
|
|
+ if (product != null) {
|
|
|
+ List<PCB> pcbs = pcbDao.findByProductid(prId);
|
|
|
+ if (CollectionUtils.isEmpty(pcbs)) {
|
|
|
+ PCB pcb = new PCB();
|
|
|
+ pcb.setProductid(prId);
|
|
|
+ pcb.setBrandid(product.getPbrandid());
|
|
|
+ pcb.setKindid(product.getKindid());
|
|
|
+ pcbList.add(pcb);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<PCBPropertyValue> propertyValues = (List<PCBPropertyValue>) map.get(product.getEnUU().toString().concat(product.getProdNum()));
|
|
|
+ if (CollectionUtils.isNotEmpty(propertyValues)) {
|
|
|
+ for (PCBPropertyValue propertyValue : propertyValues) {
|
|
|
+ propertyValue.setProductid(prId);
|
|
|
+ propertyValueList.add(propertyValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(pcbList)) {
|
|
|
+ pcbDao.save(pcbList);
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(propertyValueList)) {
|
|
|
+ pcbPropertyvalueDao.save(propertyValueList);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
Enterprise enterprise = SystemSession.getUser().getEnterprise();
|
|
|
final Object[] obj = new Object[]{enterprise.getUu(), enterprise.getEnName(), batch};
|
|
|
@@ -1670,11 +1730,25 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
}
|
|
|
|
|
|
|
|
|
- private List<com.uas.ps.entity.Product> convertProduct (List<ReleaseProductByBatch> releaseProductByBatchList, boolean isAPerson ) {
|
|
|
+ private Map<String, Object> convertProduct (List<ReleaseProductByBatch> releaseProductByBatchList, boolean isAPerson , boolean isPcb) {
|
|
|
if (CollectionUtils.isEmpty(releaseProductByBatchList)) {
|
|
|
return null;
|
|
|
}
|
|
|
+ Map<String, Object> map = new HashedMap();
|
|
|
List<com.uas.ps.entity.Product> products = new ArrayList<>();
|
|
|
+ Map<String, List<PCBPropertyValue>> propertyMap = new HashedMap();
|
|
|
+
|
|
|
+ Long sizeProId = null;
|
|
|
+ Long colorProId = null;
|
|
|
+ Long thickCopperProId = null;
|
|
|
+ Long thickProId = null;
|
|
|
+ if (isPcb) {
|
|
|
+ sizeProId = propertyDao.findIdByLabelCn(SIZE);
|
|
|
+ colorProId = propertyDao.findIdByLabelCn(COLOR);
|
|
|
+ thickCopperProId = propertyDao.findIdByLabelCn(THICKCOPPER);
|
|
|
+ thickProId = propertyDao.findIdByLabelCn(THICK);
|
|
|
+ }
|
|
|
+
|
|
|
for (ReleaseProductByBatch releaseProductByBatch : releaseProductByBatchList) {
|
|
|
if (releaseProductByBatch.getReleaseCode().equals(ReleaseStatus.failure.value()) ||
|
|
|
releaseProductByBatch.getReleaseCode().equals(ReleaseStatus.success.value())) {
|
|
|
@@ -1703,10 +1777,36 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
}
|
|
|
String batchCode = "PNUM" + createNumberService.getTimeNumber("trade$product_import_num", 8);
|
|
|
product.setCode(batchCode);
|
|
|
+
|
|
|
+ if (isPcb) {
|
|
|
+ List<PCBPropertyValue> propertyValues = new ArrayList<>();
|
|
|
+ if (!StringUtils.isEmpty(releaseProductByBatch.getSize())) {
|
|
|
+ PCBPropertyValue propertyValue = new PCBPropertyValue(sizeProId, releaseProductByBatch.getSize());
|
|
|
+ propertyValues.add(propertyValue);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(releaseProductByBatch.getColor())) {
|
|
|
+ PCBPropertyValue propertyValue = new PCBPropertyValue(colorProId, releaseProductByBatch.getColor());
|
|
|
+ propertyValues.add(propertyValue);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(releaseProductByBatch.getThickCopper())) {
|
|
|
+ PCBPropertyValue propertyValue = new PCBPropertyValue(thickCopperProId, releaseProductByBatch.getThickCopper());
|
|
|
+ propertyValues.add(propertyValue);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(releaseProductByBatch.getThick())) {
|
|
|
+ PCBPropertyValue propertyValue = new PCBPropertyValue(thickProId, releaseProductByBatch.getThick());
|
|
|
+ propertyValues.add(propertyValue);
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(propertyValues)) {
|
|
|
+ propertyMap.put(product.getEnUU().toString().concat(product.getCode()), propertyValues);
|
|
|
+ }
|
|
|
+ }
|
|
|
products.add(product);
|
|
|
}
|
|
|
}
|
|
|
- return products;
|
|
|
+
|
|
|
+ map.put("products", products);
|
|
|
+ map.put("propertyvalues", propertyMap);
|
|
|
+ return map;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -1714,7 +1814,8 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
List<ReleaseProductByBatch> releaseProductByBatchList =
|
|
|
releaseProductByBatchDao.findByRelbatchid(batch);
|
|
|
if (!CollectionUtils.isEmpty(releaseProductByBatchList)) {
|
|
|
- List<com.uas.ps.entity.Product> products = convertProduct(releaseProductByBatchList,true);
|
|
|
+ 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);
|