物料消耗与完工入库的定时器每个请求送10笔数据

This commit is contained in:
彭枝刚 2025-01-17 10:59:49 +08:00
parent 4136c43e60
commit 4464bb88d5
3 changed files with 26 additions and 11 deletions

View File

@ -15,6 +15,7 @@ import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.AllArgsConstructor;
import org.apache.commons.collections4.ListUtils;
import org.springframework.stereotype.Component;
import java.time.LocalDate;
@ -65,7 +66,7 @@ public class SapMaterialConsumptionJob {
ZLotMaterialConsumptionTransaction::getSite, site).ne(
ZLotMaterialConsumptionTransaction::getSyncStatus, "S")
.gt(ZLotMaterialConsumptionTransaction::getDateCreate, startDate)
.lt(ZLotMaterialConsumptionTransaction::getDateCreate, endDate));
.lt(ZLotMaterialConsumptionTransaction::getDateCreate, endDate).orderByAsc(ZLotMaterialConsumptionTransaction::getDateCreate));
if (CollectionUtils.isEmpty(zLotMaterialConsumptionTransactionList)) {
XxlJobHelper.log("WARN:没有需要同步的261物料消耗数据!!!");
return ReturnT.SUCCESS;
@ -73,10 +74,16 @@ public class SapMaterialConsumptionJob {
if (StringUtils.isEmpty(postingDate)) {
postingDate = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
}
InvokeResponse invokeResponse = lotMaterialDealSendSapService.callLotMaterialConsumption(zLotMaterialConsumptionTransactionList, true, postingDate);
if (!"S".equals(invokeResponse.getResult())) {
XxlJobHelper.log("WARN:同步261物料消耗数据失败!!!" + invokeResponse.getMessageContent());
return ReturnT.FAIL;
// 10笔10的送
if(zLotMaterialConsumptionTransactionList.size()>0){
List<List<ZLotMaterialConsumptionTransaction>> splitList = ListUtils.partition(zLotMaterialConsumptionTransactionList,10);
for (int i = 0; i < splitList.size(); i++) {
InvokeResponse invokeResponse = lotMaterialDealSendSapService.callLotMaterialConsumption(splitList.get(i), true, postingDate);
if (!"S".equals(invokeResponse.getResult())) {
XxlJobHelper.log("WARN:同步261物料消耗数据失败!!!" + invokeResponse.getMessageContent());
// return ReturnT.FAIL;
}
}
}
return ReturnT.SUCCESS;
}

View File

@ -9,12 +9,14 @@ import com.foreverwin.iep.integration.domain.InvokeResponse;
import com.foreverwin.iep.integration.service.LotMaterialDealSendSapService;
import com.foreverwin.iep.integration.utils.JS;
import com.foreverwin.iep.prd.entity.ZLotMaterialCompleteTransaction;
import com.foreverwin.iep.prd.entity.ZLotMaterialConsumptionTransaction;
import com.foreverwin.iep.prd.mapper.ZLotMaterialCompleteTransactionMapper;
import com.foreverwin.mom.common.data.tenant.TenantContextHolder;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.AllArgsConstructor;
import org.apache.commons.collections4.ListUtils;
import org.springframework.stereotype.Component;
import java.time.LocalDate;
@ -66,7 +68,7 @@ public class SapShopOrderCompleteJob {
ZLotMaterialCompleteTransaction::getSite, site).ne(
ZLotMaterialCompleteTransaction::getSyncStatus, "S")
.gt(ZLotMaterialCompleteTransaction::getDateCreate, startDate)
.lt(ZLotMaterialCompleteTransaction::getDateCreate, endDate));
.lt(ZLotMaterialCompleteTransaction::getDateCreate, endDate).orderByAsc(ZLotMaterialCompleteTransaction::getDateCreate));
if (CollectionUtils.isEmpty(zLotMaterialCompleteTransactionList)) {
XxlJobHelper.log("WARN:没有需要同步的101或531完工入库数据!!!");
return ReturnT.SUCCESS;
@ -74,10 +76,16 @@ public class SapShopOrderCompleteJob {
if (StringUtils.isEmpty(postingDate)) {
postingDate = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
}
InvokeResponse invokeResponse = lotMaterialDealSendSapService.callLotMaterialComplete(zLotMaterialCompleteTransactionList, true, postingDate);
if (!"S".equals(invokeResponse.getResult())) {
XxlJobHelper.log("WARN:同步101或531完工入库数据失败!!!" + invokeResponse.getMessageContent());
return ReturnT.FAIL;
// 10笔10的送
if(zLotMaterialCompleteTransactionList.size()>0){
List<List<ZLotMaterialCompleteTransaction>> splitList = ListUtils.partition(zLotMaterialCompleteTransactionList,10);
for (int i = 0; i < splitList.size(); i++) {
InvokeResponse invokeResponse = lotMaterialDealSendSapService.callLotMaterialComplete(splitList.get(i), true, postingDate);
if (!"S".equals(invokeResponse.getResult())) {
XxlJobHelper.log("WARN:同步101或531完工入库数据失败!!!" + invokeResponse.getMessageContent());
// return ReturnT.FAIL;
}
}
}
return ReturnT.SUCCESS;
}

View File

@ -199,7 +199,7 @@ public class LotMaterialDealSendSapServiceImpl implements LotMaterialDealSendSap
for (ZLotMaterialConsumptionTransaction consumptionTransaction : zLotMaterialConsumptionTransactions) {
// 重新校验一遍是否已经报过工,防止重复报工
ZLotMaterialConsumptionTransaction targetObj = zLotMaterialConsumptionTransactionMapper.selectById(consumptionTransaction.getSid());
if ("S".equals(targetObj.getSyncStatus())) {
if ("S".equals(targetObj.getSyncStatus()) && !isPass) {
throw BusinessException.build("批次" + targetObj.getLotNo() + "消耗已经报工,不可重复报工");
} else {
if (StringUtils.isEmpty(postingDate)) {