新火炬后端单体项目初始化代码
zhangherong
6 天以前 0bbd986930e4b41e0741fd07c4287208da398330
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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
 * @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;
    }
 
 
}