From 0bbd986930e4b41e0741fd07c4287208da398330 Mon Sep 17 00:00:00 2001 From: zhangherong <571457620@qq.com> Date: 星期五, 01 八月 2025 17:03:37 +0800 Subject: [PATCH] art: 生产订单同步定时任务 --- src/main/java/org/jeecg/modules/mes/service/impl/MesProductionOrderServiceImpl.java | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 48 insertions(+), 1 deletions(-) diff --git a/src/main/java/org/jeecg/modules/mes/service/impl/MesProductionOrderServiceImpl.java b/src/main/java/org/jeecg/modules/mes/service/impl/MesProductionOrderServiceImpl.java index ed8e452..0b0f002 100644 --- a/src/main/java/org/jeecg/modules/mes/service/impl/MesProductionOrderServiceImpl.java +++ b/src/main/java/org/jeecg/modules/mes/service/impl/MesProductionOrderServiceImpl.java @@ -1,18 +1,65 @@ package org.jeecg.modules.mes.service.impl; +import cn.hutool.core.collection.CollectionUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.jeecg.common.constant.CommonConstant; import org.jeecg.modules.mes.entity.MesProductionOrder; import org.jeecg.modules.mes.mapper.MesProductionOrderMapper; import org.jeecg.modules.mes.service.IMesProductionOrderService; +import org.jeecg.modules.sap.dto.ProductionOrderDTO; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; /** * @Description: SAP鐢熶骇璁㈠崟 * @Author: jeecg-boot - * @Date: 2025-07-04 + * @Date: 2025-07-04 * @Version: V1.0 */ @Service public class MesProductionOrderServiceImpl extends ServiceImpl<MesProductionOrderMapper, MesProductionOrder> implements IMesProductionOrderService { + @Override + @Transactional(rollbackFor = Exception.class) + public Map<String, MesProductionOrder> saveOrUpdateProductionOrder(List<ProductionOrderDTO> productionOrderDTOList) { + List<MesProductionOrder> addList = new ArrayList<>(); + List<MesProductionOrder> updateList = new ArrayList<>(); + Map<String, MesProductionOrder> resultMap = new HashMap<>(); + for (ProductionOrderDTO productionOrderDTO : productionOrderDTOList) { + MesProductionOrder updated = getByOrderCode(productionOrderDTO.getAUFNR()); + if (updated == null) { + updated = new MesProductionOrder(productionOrderDTO); + addList.add(updated); + resultMap.put(updated.getOrderCode(), updated); + } else { + updated.updateEntity(productionOrderDTO); + updateList.add(updated); + resultMap.put(updated.getOrderCode(), updated); + } + } + if(CollectionUtil.isEmpty(addList)){ + super.saveBatch(addList); + } + if(CollectionUtil.isEmpty(updateList)){ + super.updateBatchById(updateList); + } + return resultMap; + } + + @Override + public MesProductionOrder getByOrderCode(String orderCode) { + LambdaQueryWrapper<MesProductionOrder> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(MesProductionOrder::getOrderCode, orderCode); + queryWrapper.eq(MesProductionOrder::getDelFlag, CommonConstant.DEL_FLAG_0); + List<MesProductionOrder> list = super.list(queryWrapper); + if (CollectionUtil.isNotEmpty(list)) { + return list.get(0); + } + return null; + } + + } -- Gitblit v1.9.3