|
@@ -11,8 +11,8 @@ import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@@ -43,9 +43,18 @@ public class AcqGoodsOnSeatCusData implements CusData {
|
|
|
|
|
|
List<CusAcqGoodsSeat06> cusList = (List<CusAcqGoodsSeat06>) list;
|
|
|
|
|
|
+ // 新增库存list
|
|
|
+ List<CusAcqGoodsSeat06> insertList = new ArrayList<>();
|
|
|
+ // 修改库存list
|
|
|
+ List<CusAcqGoodsSeat06> updateList = new ArrayList<>();
|
|
|
+
|
|
|
List<String> gUnitNameList = Lists.newArrayList();
|
|
|
cusList.forEach(i -> gUnitNameList.add(i.getgUnit()));
|
|
|
|
|
|
+ // 查询已有库存信息表对应sku数据
|
|
|
+ List<CusAcqGoodsSeat06> listgoodsSeat = cusAcqGoodsSeatService06.listCusAcqGoodsSeat(cusList);
|
|
|
+ Map<String, String> exitGoodsSeat = listgoodsSeat.stream().collect(Collectors.toMap(k->k.getSkuNo()+k.getSeatNo(), v->v.getLocalEmsNo()));
|
|
|
+
|
|
|
List<OmsCusUnitCode> codeList = omsCusUnitCodeMapper.getOmsCusUnitCodeList(gUnitNameList);
|
|
|
Map<String,OmsCusUnitCode> omsCusUnitCodeMap = codeList.stream().collect(Collectors.toMap(k->k.getgUnitName(), v->v));
|
|
|
|
|
@@ -54,13 +63,30 @@ public class AcqGoodsOnSeatCusData implements CusData {
|
|
|
if(omsProductInfo != null) {
|
|
|
seat.setgUnit(omsProductInfo.getgUnitCode());
|
|
|
}
|
|
|
+
|
|
|
+ String key = seat.getSkuNo() + seat.getSeatNo();
|
|
|
+ if (exitGoodsSeat.containsKey(key)) {
|
|
|
+ // 存在, 则更新
|
|
|
+ updateList.add(seat);
|
|
|
+ } else {
|
|
|
+ // 不存在, 则插入
|
|
|
+ insertList.add(seat);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- int result = cusAcqGoodsSeatService06.addCusAcqGoodsSeat06(cusList);
|
|
|
+ int insertResult = 0;
|
|
|
+ int updateResult = 0;
|
|
|
+
|
|
|
+ if (insertList.size() > 0) {
|
|
|
+ insertResult = cusAcqGoodsSeatService06.addCusAcqGoodsSeat06(insertList);
|
|
|
+ }
|
|
|
+ if (updateList.size() > 0) {
|
|
|
+ updateResult = cusAcqGoodsSeatService06.updateCusAcqGoodsSeat06(updateList);
|
|
|
+ }
|
|
|
|
|
|
- logger.info("---【" + DATA_TYPE_INFO + "】写入监控数据:{} 条", result);
|
|
|
+ logger.info("---【" + DATA_TYPE_INFO + "】写入监控数据:{} 条, 更新监控数据:{}条", insertResult, updateResult);
|
|
|
|
|
|
logger.info("---------- 库位货物数据::写入本次监控数据结束 --------------------");
|
|
|
- return result;
|
|
|
+ return insertResult + updateResult;
|
|
|
}
|
|
|
}
|