sgj
8 天以前 71fe4f1f6a75c86640a726b9c230e8aaae2a28e7
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package com.fzzy.igds.service;
 
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fzzy.igds.data.BaseResp;
import com.fzzy.igds.data.IgdsBaseParam;
import com.fzzy.igds.domain.PledgeContractDepot;
import com.fzzy.igds.mapper.PledgeContractDepotMapper;
import com.fzzy.igds.utils.ContextUtil;
import com.ruoyi.common.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
 
@Slf4j
@Service
public class PledgeContractDepotService {
 
    @Resource
    private PledgeContractDepotMapper pledgeContractDepotMapper;
 
 
    /**
     * 查询质押合同下得质押仓库
     *
     * @param param
     * @author sgj
     * @since 2026/03/20
     */
    public List<PledgeContractDepot> listAll(IgdsBaseParam param) {
        if (null == param) param = new IgdsBaseParam();
 
        if (StringUtils.isEmpty(param.getCompanyId())) {
            param.setCompanyId(ContextUtil.getCompanyId());
        }
        QueryWrapper<PledgeContractDepot> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("company_id", param.getCompanyId());
        if (StringUtils.isNotEmpty(param.getParentId())) {
            queryWrapper.eq("pledge_id", param.getParentId());
        }
 
        queryWrapper.orderByDesc("update_time");
 
        return pledgeContractDepotMapper.selectList(queryWrapper);
    }
 
 
    /**
     * 批量新增质押仓库
     *
     * @param pledgeContractList
     * @author sgj
     * @since 2026/03/20
     */
    public BaseResp addDataByList(List<PledgeContractDepot> pledgeContractList) {
        if (pledgeContractList.isEmpty()) {
            return BaseResp.success();
        }
        boolean PledgeIdflag = true;
        for (PledgeContractDepot pledgeContractDepot : pledgeContractList) {
            pledgeContractDepot.setCompanyId(ContextUtil.getCompanyId());
            pledgeContractDepot.setUpdateBy(ContextUtil.getLoginUserName());
            pledgeContractDepot.setUpdateTime(new Date());
            pledgeContractDepot.setCreateBy(ContextUtil.getLoginUserName());
            pledgeContractDepot.setCreateTime(new Date());
            if (StringUtils.isEmpty(pledgeContractDepot.getPledgeId())) {
                PledgeIdflag = false;
                break;
            }
            if (StringUtils.isEmpty(pledgeContractDepot.getId())) {
                pledgeContractDepot.setId(ContextUtil.generateId());
                pledgeContractDepotMapper.insert(pledgeContractDepot);
            }
        }
        if (!PledgeIdflag) {
            return BaseResp.error("添加失败——质押合同Id不能为空");
        }
        return BaseResp.success();
    }
 
    /**
     * 删除质押仓库
     *
     * @param pledgeContractDepot
     * @author sgj
     * @since 2026/03/20
     */
    public BaseResp deleteData(PledgeContractDepot pledgeContractDepot) {
        return pledgeContractDepotMapper.deleteById(pledgeContractDepot) > 0 ? BaseResp.success() : BaseResp.error("删除失败");
    }
 
}