新火炬后端单体项目初始化代码
Lius
8 天以前 9af27ed8da6b5710025fb080f96a7dd9e80467a4
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
75
76
77
78
79
80
81
package org.jeecg.modules.tms.service.impl;
 
import org.apache.commons.beanutils.BeanUtils;
import org.jeecg.modules.tms.entity.TmsToolInbound;
import org.jeecg.modules.tms.entity.TmsToolInboundDetail;
import org.jeecg.modules.tms.mapper.TmsToolInboundDetailMapper;
import org.jeecg.modules.tms.mapper.TmsToolInboundMapper;
import org.jeecg.modules.tms.service.ITmsToolInboundDetailService;
import org.jeecg.modules.tms.service.ITmsToolInboundService;
import org.jeecg.modules.tms.vo.TmsToolInboundRequest;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Collection;
 
/**
 * @Description: 工装入库
 * @Author: jeecg-boot
 * @Date:   2025-07-28
 * @Version: V1.0
 */
@Service
public class TmsToolInboundServiceImpl extends ServiceImpl<TmsToolInboundMapper, TmsToolInbound> implements ITmsToolInboundService {
 
    @Autowired
    private TmsToolInboundMapper tmsToolInboundMapper;
    @Autowired
    private TmsToolInboundDetailMapper tmsToolInboundDetailMapper;
    @Autowired
    private ITmsToolInboundDetailService tmsToolInboundDetailService;
    
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delMain(String id) {
        tmsToolInboundDetailMapper.deleteByMainId(id);
        tmsToolInboundMapper.deleteById(id);
    }
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delBatchMain(Collection<? extends Serializable> idList) {
        for(Serializable id:idList) {
            tmsToolInboundDetailMapper.deleteByMainId(id.toString());
            tmsToolInboundMapper.deleteById(id);
        }
    }
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void add(TmsToolInboundRequest tmsToolInboundRequest) throws InvocationTargetException, IllegalAccessException {
        TmsToolInbound tmsToolInbound = new TmsToolInbound();
        BeanUtils.copyProperties(tmsToolInbound, tmsToolInboundRequest);
        save(tmsToolInbound);
        List<TmsToolInboundDetail> tmsToolInboundDetailList = tmsToolInboundRequest.getTmsToolInboundDetailList();
        tmsToolInboundDetailList.forEach(tmsToolInboundDetail -> {
            tmsToolInboundDetail.setId(null);
            tmsToolInboundDetail.setOrderId(tmsToolInbound.getId());
        });
        tmsToolInboundDetailService.saveBatch(tmsToolInboundDetailList);
    }
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void update(TmsToolInboundRequest tmsToolInboundRequest) throws InvocationTargetException, IllegalAccessException {
        tmsToolInboundDetailMapper.deleteByMainId(tmsToolInboundRequest.getId());
        TmsToolInbound toolInboundUpdate = new TmsToolInbound();
        BeanUtils.copyProperties(toolInboundUpdate, tmsToolInboundRequest);
        updateById(toolInboundUpdate);
        List<TmsToolInboundDetail> tmsToolInboundDetailList = tmsToolInboundRequest.getTmsToolInboundDetailList();
        tmsToolInboundDetailList.forEach(tmsToolInboundDetail -> {
            tmsToolInboundDetail.setId(null);
            tmsToolInboundDetail.setOrderId(tmsToolInboundRequest.getId());
        });
        tmsToolInboundDetailService.saveBatch(tmsToolInboundDetailList);
    }
 
}