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

master
yinq 2 months ago
parent 97a0b60001
commit f2e9ac83f2

@ -1,6 +1,9 @@
package com.hw.wms.service.impl; package com.hw.wms.service.impl;
import com.alibaba.fastjson2.JSONObject; 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.SecurityConstants;
import com.hw.common.core.constant.WmsConstants; import com.hw.common.core.constant.WmsConstants;
import com.hw.common.core.domain.R; import com.hw.common.core.domain.R;
@ -134,21 +137,45 @@ public class WmsErpScheduledTaskServiceImpl implements IWmsErpScheduledTaskServi
String params = data.toJSONString(); String params = data.toJSONString();
try { try {
R<AjaxResult> paramsResult = remoteJindieService.savePurchaseStorage(params, SecurityConstants.INNER); R<AjaxResult> paramsResult = remoteJindieService.savePurchaseStorage(params, SecurityConstants.INNER);
String paramsResultData = paramsResult.getMsg(); Gson gson = new Gson();
JSONObject jsonObject = JSONObject.parseObject(paramsResultData); String paramsResulJson = gson.toJson(paramsResult);
Boolean isSuccess = (Boolean) jsonObject.get("IsSuccess"); 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) { if (isSuccess) {
result++; result++;
log.info("synchronizeInventoryInformationToERP同步原材料入库成功:" + paramsResult.toString()); log.info("synchronizeInventoryInformationToERP同步原材料入库成功:" + paramsResulJson);
} else { } else {
log.error("synchronizeInventoryInformationToERP同步原材料入库失败:" + paramsResult.toString()); updateWmsRawInStockWithoutRollback(wmsRawInstockList);
throw new ServiceException("同步原材料入库失败" + paramsResult.toString()); log.error("synchronizeInventoryInformationToERP同步原材料入库失败:" + paramsResulJson);
throw new ServiceException("同步原材料入库失败" + paramsResulJson);
} }
} catch (Exception e) { } catch (Exception e) {
log.error("同步原材料入库失败" + e.getMessage()); updateWmsRawInStockWithoutRollback(wmsRawInstockList);
throw new ServiceException("同步原材料入库失败" + e.getMessage()); 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