|
|
@@ -68,7 +68,6 @@ import org.springframework.jdbc.core.StatementCallback;
|
|
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
@@ -725,6 +724,7 @@ public class ProductServiceImpl implements ProductService {
|
|
|
*/
|
|
|
@Override
|
|
|
public ResultMap matchNonStandardProduct() {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
final Long uu = SystemSession.getUser().getUserUU();
|
|
|
final Long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
ProductStoreStatus status = productStoreStatusDao.findByEnuu(enUU);
|
|
|
@@ -751,16 +751,25 @@ public class ProductServiceImpl implements ProductService {
|
|
|
status = productStoreStatusDao.save(storeStatus);
|
|
|
}
|
|
|
|
|
|
-// int total = productDao.getCountByEnuuAndStatusAndEnabled(enUU, ShortConstant.NO_SHORT, IntegerConstant.YES_SHORT);
|
|
|
- int total = productDao.getCountByEnuuAndStatus(enUU, ShortConstant.NO_SHORT);
|
|
|
+ int total = productDao.getCountByEnuuAndStatusAndEnabled(enUU, ShortConstant.NO_SHORT, IntegerConstant.YES_SHORT);
|
|
|
int success = 0;
|
|
|
int fail = 0;
|
|
|
- Map<String, Long> queryMap = new HashMap<>();
|
|
|
- queryMap.put("enUU", enUU);
|
|
|
- String successUrl = productServiceIp + "/product/match/nonProduct";
|
|
|
- String result = restTemplate.postForEntity(successUrl, queryMap, String.class).getBody();
|
|
|
- ModelMap map = FastjsonUtils.fromJson(result, ModelMap.class);
|
|
|
- fail = total - (int) map.get("success");
|
|
|
+
|
|
|
+ String sql = "/*#mycat:db_type=master*/ call PRODUCT_MATCHES_V1(%s, %s, @out); select @out";
|
|
|
+ final String formatSql = String.format(sql, enUU, uu);
|
|
|
+ success = jdbcTemplate.execute(new StatementCallback<Integer>() {
|
|
|
+ @Override
|
|
|
+ public Integer doInStatement(Statement statement) throws SQLException, DataAccessException {
|
|
|
+ statement.execute(formatSql);
|
|
|
+ ResultSet rs = statement.getResultSet();
|
|
|
+ if (null != rs) {
|
|
|
+ rs.next();
|
|
|
+ return rs.getInt(1);
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ fail = total - success;
|
|
|
|
|
|
status.setStatus(Status.FINISH.value());
|
|
|
productStoreStatusDao.save(status);
|
|
|
@@ -819,10 +828,10 @@ public class ProductServiceImpl implements ProductService {
|
|
|
if (result == null) {
|
|
|
return new ResultMap(CodeType.NO_INFO, "匹配结果信息丢失");
|
|
|
}
|
|
|
- List<Product> standardList = productDao.findProductByPcmpcodeAndPbrandenAndEnUUAndStandard(result.getCmpcode(), result.getBranden(), enUU, IntegerConstant.YES_SHORT);
|
|
|
+ List<V_ProductPrivate> standardList = v_productPrivateDao.findProductByPcmpcodeAndPbrandenAndEnUUAndStandard(result.getCmpcode(), result.getBranden(), enUU, IntegerConstant.YES_SHORT, IntegerConstant.YES_SHORT);
|
|
|
Product standardProduct = null;
|
|
|
if (!CollectionUtils.isEmpty(standardList)) {
|
|
|
- standardProduct = standardList.get(0);
|
|
|
+ standardProduct = productDao.findOne(standardList.get(0).getId());
|
|
|
}
|
|
|
List<List<Goods>> repeatList = new ArrayList<>();
|
|
|
// 已有对应标准信息,需要判断在售商品是否重复
|
|
|
@@ -864,7 +873,8 @@ public class ProductServiceImpl implements ProductService {
|
|
|
productPrivate.setBatchCount(0);
|
|
|
productPrivateDao.save(productPrivate);
|
|
|
}
|
|
|
- restTemplate.postForEntity(productServiceIp + "/product/update", afterProduct, String.class);
|
|
|
+// restTemplate.postForEntity(productServiceIp + "/product/update", afterProduct, String.class);
|
|
|
+ productDao.save(afterProduct);
|
|
|
updateInfoAfterTurnStandard(matchId, standardProduct);
|
|
|
return ResultMap.success(null);
|
|
|
}
|