change - 以独立事务方式更新WMS原材料入库单状态

master
yinq 2 months ago
parent 97a0b60001
commit f2e9ac83f2

@ -1,6 +1,9 @@
package com.hw.wms.service.impl;
import com.alibaba.fastjson2.JSONObject;
import com.alibaba.nacos.shaded.com.google.gson.Gson;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.hw.common.core.constant.SecurityConstants;
import com.hw.common.core.constant.WmsConstants;
import com.hw.common.core.domain.R;
@ -134,21 +137,45 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
String params = data.toJSONString();
try {
R<AjaxResult> paramsResult = remoteJindieService.savePurchaseStorage(params, SecurityConstants.INNER);
String paramsResultData = paramsResult.getMsg();
JSONObject jsonObject = JSONObject.parseObject(paramsResultData);
Boolean isSuccess = (Boolean) jsonObject.get("IsSuccess");
Gson gson = new Gson();
String paramsResulJson = gson.toJson(paramsResult);
log.info("+++++++++paramsResult+++++++" + paramsResulJson);
ObjectMapper mapper = new ObjectMapper();
JsonNode rootNode = mapper.readTree(paramsResulJson);
String msgStr = rootNode.path("data").path("msg").asText();
log.info("+++++++++msgStr+++++++" + msgStr);
JsonNode msgNode = mapper.readTree(msgStr);
boolean isSuccess = msgNode.path("IsSuccess").asBoolean();
log.info("+++++++++isSuccess+++++++" + isSuccess);
if (isSuccess) {
result++;
log.info("synchronizeInventoryInformationToERP同步原材料入库成功:" + paramsResult.toString());
log.info("synchronizeInventoryInformationToERP同步原材料入库成功:" + paramsResulJson);
} else {
log.error("synchronizeInventoryInformationToERP同步原材料入库失败:" + paramsResult.toString());
throw new ServiceException("同步原材料入库失败" + paramsResult.toString());
updateWmsRawInStockWithoutRollback(wmsRawInstockList);
log.error("synchronizeInventoryInformationToERP同步原材料入库失败:" + paramsResulJson);
throw new ServiceException("同步原材料入库失败" + paramsResulJson);
}
} catch (Exception e) {
log.error("同步原材料入库失败" + e.getMessage());
throw new ServiceException("同步原材料入库失败" + e.getMessage());
updateWmsRawInStockWithoutRollback(wmsRawInstockList);
log.error("同步原材料入库失败:" + e);
throw new ServiceException("同步原材料入库失败::" + e);
}
}
/**
* WMS
* 使REQUIRES_NEW使
*
* @param wmsRawInstockList
*/
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void updateWmsRawInStockWithoutRollback(List<WmsRawInstock> wmsRawInstockList) {
for (WmsRawInstock rawInstock : wmsRawInstockList) {
rawInstock.setErpStatus("0");//同步ERP状态(0:失败,1成功)
rawInstock.setErpAmount(rawInstock.getInstockAmount());
rawInstock.setUpdateDate(DateUtils.getNowDate());
wmsRawInstockMapper.updateWmsRawInstock(rawInstock);
}
}
/**

Loading…
Cancel
Save