|
@@ -23,6 +23,7 @@ import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 产品信息备案表Service实现类
|
|
* 产品信息备案表Service实现类
|
|
@@ -182,21 +183,30 @@ public class GoodsProductServiceImpl implements GoodsProductService {
|
|
dto.setOperateFlag(operateFlag);
|
|
dto.setOperateFlag(operateFlag);
|
|
goodsProductDtoList.add(dto);
|
|
goodsProductDtoList.add(dto);
|
|
}
|
|
}
|
|
|
|
+ boolean isPass = true;
|
|
try {
|
|
try {
|
|
ResponseMessage result = requestOmsProduct(goodsProductDtoList);
|
|
ResponseMessage result = requestOmsProduct(goodsProductDtoList);
|
|
|
|
+ if (!"0".equals(result.getCode())) {
|
|
|
|
+ isPass = false;
|
|
|
|
+ }
|
|
|
|
+ rollbackHandler(goodsProductDtoList, isPass);
|
|
return result.getMsg();
|
|
return result.getMsg();
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
|
|
+ isPass = false;
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
LOGGER.error(e.getMessage());
|
|
LOGGER.error(e.getMessage());
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ rollbackHandler(goodsProductDtoList, isPass);
|
|
return "请求失败,请联系管理员";
|
|
return "请求失败,请联系管理员";
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
public String sendAllProduct(String operateFlag) {
|
|
public String sendAllProduct(String operateFlag) {
|
|
- List<GoodsProductEntity> goodsProductEntityList = goodsProductDao.queryList(new HashMap<>());// 查询所有
|
|
|
|
|
|
+ // 查询所有发送失败或者未发送的
|
|
|
|
+ Map<String, Object> condition = new HashMap<>();
|
|
|
|
+ condition.put("isSend", "0,2");
|
|
|
|
+ List<GoodsProductEntity> goodsProductEntityList = goodsProductDao.queryList(condition);
|
|
if (goodsProductEntityList == null || goodsProductEntityList.size()==0){
|
|
if (goodsProductEntityList == null || goodsProductEntityList.size()==0){
|
|
return "无数据,请添加数据";
|
|
return "无数据,请添加数据";
|
|
}
|
|
}
|
|
@@ -212,13 +222,20 @@ public class GoodsProductServiceImpl implements GoodsProductService {
|
|
dto.setOperateFlag(operateFlag);
|
|
dto.setOperateFlag(operateFlag);
|
|
goodsProductDtoList.add(dto);
|
|
goodsProductDtoList.add(dto);
|
|
}
|
|
}
|
|
|
|
+ boolean isPass = true;
|
|
try {
|
|
try {
|
|
ResponseMessage result = requestOmsProduct(goodsProductDtoList);
|
|
ResponseMessage result = requestOmsProduct(goodsProductDtoList);
|
|
|
|
+ if (!"0".equals(result.getCode())) {
|
|
|
|
+ isPass = false;
|
|
|
|
+ }
|
|
|
|
+ rollbackHandler(goodsProductDtoList, isPass);
|
|
return result.getMsg();
|
|
return result.getMsg();
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
|
|
+ isPass = false;
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
LOGGER.error(e.getMessage());
|
|
LOGGER.error(e.getMessage());
|
|
}
|
|
}
|
|
|
|
+ rollbackHandler(goodsProductDtoList, isPass);
|
|
return "请求失败,请联系管理员";
|
|
return "请求失败,请联系管理员";
|
|
}
|
|
}
|
|
|
|
|
|
@@ -232,6 +249,20 @@ public class GoodsProductServiceImpl implements GoodsProductService {
|
|
return goodsProductDao.selectByBarcode(barCode);
|
|
return goodsProductDao.selectByBarcode(barCode);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public int updateSendOmsPassStatus(List<String> skuList) {
|
|
|
|
+ Map<String, Object> param = new HashMap<>();
|
|
|
|
+ param.put("isSend", 1);
|
|
|
|
+ return goodsProductDao.updateStatusBySkuBatch(skuList, param);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public int updateSendOmsFailStatus(List<String> skuList) {
|
|
|
|
+ Map<String, Object> param = new HashMap<>();
|
|
|
|
+ param.put("isSend", 2);
|
|
|
|
+ return goodsProductDao.updateStatusBySkuBatch(skuList, param);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
private ResponseMessage requestOmsProduct(List<GoodsProductDto> goodsProductDtoList){
|
|
private ResponseMessage requestOmsProduct(List<GoodsProductDto> goodsProductDtoList){
|
|
Map<String, String> sParaTemp = new TreeMap<String, String>();
|
|
Map<String, String> sParaTemp = new TreeMap<String, String>();
|
|
@@ -273,6 +304,15 @@ public class GoodsProductServiceImpl implements GoodsProductService {
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void rollbackHandler(List<GoodsProductDto> goodsProductDtoList, boolean pass){
|
|
|
|
+ List<String> skuList = goodsProductDtoList.stream().map(GoodsProductDto::getSku).collect(Collectors.toList());
|
|
|
|
+ if (pass) {
|
|
|
|
+ this.updateSendOmsPassStatus(skuList);
|
|
|
|
+ } else {
|
|
|
|
+ this.updateSendOmsFailStatus(skuList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|