新火炬后端单体项目初始化代码
zhangherong
8 天以前 a5aa9503efd20103df066219c512b47b7f65e363
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
66
67
68
69
70
71
72
73
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
 * @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("-", "");
    }
}