|
|
@@ -118,6 +118,8 @@ public class ProductServiceImpl implements ProductService {
|
|
|
ModelMap map = new ModelMap();
|
|
|
int success = 0;
|
|
|
List<Product> nonStandardList = productDao.findByEnUUAndStandard(enUU, ProductConstant.NON_STANDARD);
|
|
|
+ productMatchResultDao.deleteByEnUU(enUU);
|
|
|
+ // TODO 可以考虑用List保存,然后再批量保存
|
|
|
for (Product product : nonStandardList) {
|
|
|
success += matchOne(product, enUU);
|
|
|
}
|
|
|
@@ -170,24 +172,25 @@ public class ProductServiceImpl implements ProductService {
|
|
|
String codeUrl = "http://192.168.253.129:8080/platform-b2c/api/product/component/byCode?code=" + product.getpCmpCode();
|
|
|
String componentJson = restTemplate.getForEntity(codeUrl, String.class).getBody();
|
|
|
List<ComponentInfo> componentInfoList = JSON.parseArray(componentJson, ComponentInfo.class);
|
|
|
- Set<ProductMatchResult> productMatchResults = convertComponentToResult(componentInfoList, enUU);
|
|
|
+ Set<ProductMatchResult> productMatchResults = convertComponentToResult(product.getId(), componentInfoList, enUU);
|
|
|
if (CollectionUtils.isNotEmpty(productMatchResults)) {
|
|
|
- product.setMatchResults(productMatchResults);
|
|
|
- productDao.save(product);
|
|
|
+ productMatchResultDao.save(productMatchResults);
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 器件转化为ProductMatchResult list
|
|
|
+ * @param id 产品id
|
|
|
* @param componentInfoList 器件list
|
|
|
* @param enUU 企业uu
|
|
|
* @return
|
|
|
*/
|
|
|
- private Set<ProductMatchResult> convertComponentToResult(List<ComponentInfo> componentInfoList, Long enUU) {
|
|
|
+ private Set<ProductMatchResult> convertComponentToResult(Long id, List<ComponentInfo> componentInfoList, Long enUU) {
|
|
|
Set<ProductMatchResult> resultSet = new HashSet<>(componentInfoList.size());
|
|
|
for (ComponentInfo info : componentInfoList) {
|
|
|
ProductMatchResult result = convertOneInfoToResult(info, enUU);
|
|
|
+ result.setProductId(id);
|
|
|
resultSet.add(result);
|
|
|
}
|
|
|
return resultSet;
|