|
|
@@ -9,9 +9,7 @@ import com.uas.eis.entity.vwms.req.*;
|
|
|
import com.uas.eis.entity.vwms.resp.BaseVastResp;
|
|
|
import com.uas.eis.service.DocCommonService;
|
|
|
import com.uas.eis.service.ERPService;
|
|
|
-import com.uas.eis.utils.CollectionUtil;
|
|
|
-import com.uas.eis.utils.HttpUtil;
|
|
|
-import com.uas.eis.utils.StringUtil;
|
|
|
+import com.uas.eis.utils.*;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -788,6 +786,69 @@ public class ERPServiceImpl implements ERPService {
|
|
|
return retMap;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> sendStockData(String master, String emCode) {
|
|
|
+ Map<String, Object> resMap = new HashMap<>();
|
|
|
+ resMap.put("sucess",true);
|
|
|
+ logger.info("sendStockData-Begin master {} emCode {} ",master,emCode);
|
|
|
+ List<StockData> stockDataList = baseDao.getJdbcTemplate().query("SELECT * FROM "+master+".SCM_KCZLB_WMS_VIEW ",
|
|
|
+ new BeanPropertyRowMapper<>(StockData.class));
|
|
|
+ String dataNo = "";
|
|
|
+ if(!CollectionUtil.isEmpty(stockDataList)){
|
|
|
+ // 每1000条分批处理
|
|
|
+ int batchSize = 1000;
|
|
|
+ int totalSize = stockDataList.size();
|
|
|
+ int batchCount = (totalSize + batchSize - 1) / batchSize;
|
|
|
+
|
|
|
+ for (int i = 0; i < batchCount; i++) {
|
|
|
+ int fromIndex = i * batchSize;
|
|
|
+ int toIndex = Math.min((i + 1) * batchSize, totalSize);
|
|
|
+ String outBizCode = "erpStockData-"+ DateUtil.currentDateString(Constant.YMD_HMS);
|
|
|
+ if(!StringUtil.hasText(dataNo)){
|
|
|
+ dataNo = outBizCode;
|
|
|
+ }
|
|
|
+ // 获取当前批次数据
|
|
|
+ InventorySyncReq inventorySyncReq = new InventorySyncReq();
|
|
|
+ inventorySyncReq.setDataNo(dataNo);
|
|
|
+ inventorySyncReq.setWarehouseCode(vwmsConfig.getWarehouseCode());
|
|
|
+ inventorySyncReq.setOwnerCode(vwmsConfig.getOwnerCode());
|
|
|
+ inventorySyncReq.setOutBizCode(outBizCode);
|
|
|
+ InventorySyncReq.StockDataItems items = new InventorySyncReq.StockDataItems();
|
|
|
+ items.setItem(stockDataList.subList(fromIndex, toIndex));
|
|
|
+ inventorySyncReq.setItems(items);
|
|
|
+ BaseReq<InventorySyncReq> req = new BaseReq();
|
|
|
+ req.setRequest(inventorySyncReq);
|
|
|
+ try {
|
|
|
+ String json = objectMapper.writeValueAsString(req);
|
|
|
+ // 处理当前批次数据
|
|
|
+ String errTip = docCommonService.sendToWms(json, "openapi.inventory.foreign.synchronize");
|
|
|
+ if (errTip!=null) {
|
|
|
+ resMap.put("success", false);
|
|
|
+ resMap.put("message", "同步第" + (fromIndex) + "~"+toIndex+"行数据失败:" + errTip);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ resMap.put("success", false);
|
|
|
+ resMap.put("message", "同步第" + (fromIndex) + "~"+toIndex+"行数据失败:JSON转换失败" );
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resMap.put("message", "库存数据同步成功,共处理" + totalSize + "条数据");
|
|
|
+ }
|
|
|
+ if("JOB".equals(emCode)){
|
|
|
+ //记录日志
|
|
|
+ baseDao.execute("Insert into " + master + ".MESSAGELOG (ML_ID,ML_DATE,ML_MAN,ML_CONTENT,ML_RESULT,ML_SEARCH,CODE) " +
|
|
|
+ "values (" + master + ".MESSAGELOG_seq.nextval,sysdate,'定时任务','同步库存至WMS(自动)','同步"
|
|
|
+ +("true".equals(resMap.get("success")) ? "成功:":"失败")+": "+resMap.get("message")
|
|
|
+ +"','InventoryToWms|emCode=" + emCode + "','" + emCode + "')");
|
|
|
+ }
|
|
|
+ logger.info("sendStockData-End-success master {} emCode {} ",master,emCode);
|
|
|
+ return resMap;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
private OrderVastRequest.OrdersRequest<OrderCancel> getOrderCancelOrdersRequest(String cancelReason, ProdInout prodInOut) {
|
|
|
OrderVastRequest.OrdersRequest<OrderCancel> orders = new OrderVastRequest.OrdersRequest<OrderCancel>();
|
|
|
OrderCancel cancelOrder = new OrderCancel();
|