| | |
| | | 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; |
| | | } |
| | | |
| | | |
| | | } |