From 1eefb88049771407e0d0f9c8711bd473e44a1ba6 Mon Sep 17 00:00:00 2001
From: zhangherong <571457620@qq.com>
Date: 星期四, 07 八月 2025 16:36:19 +0800
Subject: [PATCH] art: SAP 生产订单报工、投料、关闭接口初始代码

---
 src/main/java/org/jeecg/modules/mes/service/impl/MesProductionOrderServiceImpl.java |   58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 57 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..19c42ec 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,74 @@
 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.mdc.util.DateUtils;
 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) {
+        Map<String, MesProductionOrder> resultMap = new HashMap<>();
+        for (ProductionOrderDTO productionOrderDTO : productionOrderDTOList) {
+            MesProductionOrder updated = getByOrderCode(productionOrderDTO.getAUFNR());
+            if (updated == null) {
+                updated = new MesProductionOrder(productionOrderDTO);
+                resultMap.put(updated.getOrderCode(), updated);
+                this.getBaseMapper().insert(updated);
+            } else {
+                updated.updateEntity(productionOrderDTO);
+                resultMap.put(updated.getOrderCode(), updated);
+                this.getBaseMapper().updateById(updated);
+            }
+        }
+        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;
+    }
+
+    @Override
+    public String getLastSyncCreateDate() {
+        String lastSyncDate = this.getBaseMapper().getLastSyncCreateDate();
+        if(lastSyncDate == null){
+            return null;
+        }
+        return lastSyncDate.replaceAll("-", "");
+    }
+
+    @Override
+    public String getLastSyncUpdateDate() {
+        String lastSyncDate = this.getBaseMapper().getLastSyncUpdateDate();
+        if(lastSyncDate == null){
+            return null;
+        }
+        return lastSyncDate.replaceAll("-", "");
+    }
 }

--
Gitblit v1.9.3