jiazx0107
2026-01-05 2fcf73e5783a7a06dd4d4e6f412b9f759a7230c1
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
package com.fzzy.igds;
 
import com.bstek.dorado.annotation.DataProvider;
import com.bstek.dorado.annotation.DataResolver;
import com.bstek.dorado.annotation.Expose;
import com.fzzy.igds.data.IgdsBaseParam;
import com.fzzy.igds.domain.Depot;
import com.fzzy.igds.domain.PledgeContract;
import com.fzzy.igds.service.DepotService;
import com.fzzy.igds.service.PledgeContractService;
import com.fzzy.igds.utils.ContextUtil;
import com.ruoyi.common.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
 
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
 
/**
 * @Description
 * @Author CZT
 * @Date 2025/11/27 13:57
 */
@Slf4j
@Component
public class DepotPR {
 
    @Resource
    private DepotService depotService;
 
    @Resource
    private PledgeContractService pledgeContractService;
 
    /**
     * depotPR#getData
     *
     * @return
     */
    @DataProvider
    public List<Depot> getData(String parentId) {
        if (StringUtils.isNotEmpty(parentId)) {
            return depotService.getData(null, parentId, false);
        }
        return depotService.getData(null, ContextUtil.subDeptId(null), false);
    }
 
    /**
     *
     * TODO 当前方法取消,逻辑调整为在提交时候验证是否是银行监管仓,默认获取相应的列表
     * depotPR#getDataByBankId
     *
     * @return
     */
    @DataProvider
    public List<Depot> getDataByBankId(String bankId) {
        if (StringUtils.isNotEmpty(bankId)) {
            //查询银行对应的监管仓库
            IgdsBaseParam baseParam = new IgdsBaseParam();
            baseParam.setBankId(bankId);
            List<PledgeContract> pledgeContracts = pledgeContractService.listAll(baseParam);
 
            // 提取所有 PledgeContract 中 depot_ids 字段包含的 depot ID
            List<String> validDepotIds = new ArrayList<>();
            for (PledgeContract contract : pledgeContracts) {
                if (StringUtils.isNotEmpty(contract.getDepotIds())) {
                    // 将逗号分隔的 depot_ids 转换为 Set
                    String[] ids = contract.getDepotIds().split(",");
                    for (String id : ids) {
                        if (StringUtils.isNotEmpty(id.trim())) {
                            validDepotIds.add(id.trim());
                        }
                    }
                }
            }
            List<Depot> allData = depotService.getData(null, ContextUtil.subDeptId(null), false);
            if (!validDepotIds.isEmpty()) {
                // 过滤出在 PledgeContract.depot_ids 中出现的 depot
                List<Depot> filteredData = new ArrayList<>();
 
                for (Depot allDatum : allData) {
                    if (validDepotIds.contains(allDatum.getId())) {
                        filteredData.add(allDatum);
                    }
                }
                return filteredData;
            }
            return new ArrayList<>();
 
        }
        return depotService.getData(null, ContextUtil.subDeptId(null), false);
    }
 
    /**
     * depotPR#saveOrUpdate
     *
     * @param data
     * @return
     */
    @DataResolver
    @Transactional
    public String saveOrUpdate(Depot data) {
 
        Depot depot = new Depot();
        BeanUtils.copyProperties(data, depot);
        depotService.saveDepot(depot);
        return null;
    }
 
    /**
     * depotPR#deleteDepot
     *
     * @param data
     */
    @Expose
    @Transactional
    public void deleteDepot(Depot data) {
        Depot depot = new Depot();
        BeanUtils.copyProperties(data, depot);
        depotService.deleteDepot(depot);
    }
 
    /**
     * depotPR#flushCache
     */
    @Expose
    public void flushCache() {
        depotService.flushCache(null);
    }
 
    /**
     * ${dorado.getDataProvider("depotPR#getAllCache").getResult()}
     *
     * @return
     */
    @DataProvider
    public List<Depot> getAllCache() {
        return depotService.getCacheDepotList(null, ContextUtil.subDeptId(null));
    }
 
    /**
     * depotPR#ajaxGetAllCache
     *
     * @return
     */
    @Expose
    public List<Depot> ajaxGetAllCache() {
        return depotService.getCacheDepotList(null, ContextUtil.subDeptId(null));
    }
 
    /**
     * depotPR#getDataByCompanyId
     *
     * @return
     */
    @DataProvider
    public List<Depot> getDataByCompanyId() {
        return depotService.getData(null, null, false);
    }
 
    /**
     * depotPR#getDepot 获取仓库信息
     *
     * @param depotId
     * @return
     */
    @Expose
    public Depot getDepot(String depotId) {
        return depotService.getCacheDepot(null, depotId);
    }
 
}