ny
昨天 b6f169fe43a2b13f351aefc152374fc7f0bc8cb7
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
package jnpf.base.util;
 
import com.baomidou.dynamic.datasource.annotation.DS;
import jnpf.base.*;
import jnpf.base.entity.DictionaryDataEntity;
import jnpf.database.model.dbfield.DbFieldModel;
import jnpf.database.model.dbfield.base.DbFieldModelBase;
import jnpf.database.model.dbtable.DbTableFieldModel;
import jnpf.database.model.entity.DbLinkEntity;
import jnpf.permission.*;
import jnpf.permission.entity.*;
import jnpf.util.JsonUtil;
import jnpf.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
 
import static jnpf.util.Constants.ADMIN_KEY;
 
/**
 * @author :JNPF开发平台组
 * @version: V3.1.0
 * @copyright 引迈信息技术有限公司
 * @date :2022/4/9 13:28
 */
@Component
@DS("")
public class ServiceBaseUtil {
 
    @Autowired
    private DataSourceApi dblinkService;
    @Autowired
    private DataModelApi dbTableService;
    @Autowired
    private UserApi userService;
    @Autowired
    private OrganizeApi organizeService;
    @Autowired
    private PositionApi positionService;
    @Autowired
    private BillRuleApi billRuleService;
    @Autowired
    private DataInterFaceApi dataInterfaceService;
 
    //--------------------------------数据连接------------------------------
    public DbLinkEntity getDbLink(String dbLink) {
        DbLinkEntity link = StringUtil.isNotEmpty(dbLink) ? dblinkService.getInfo(dbLink) : null;
        return link;
    }
 
    public boolean isExistTable(String dbLinkId, String table) throws Exception {
        return dbTableService.isExistTable(dbLinkId, table);
    }
 
    public void createTable(List<DbTableFieldModel> dbTable) throws Exception {
        dbTableService.createTable(dbTable);
    }
 
    public void addField(DbTableFieldModel dbTable) throws Exception {
        dbTableService.addField(dbTable);
    }
 
    /**
     * 获取所有字段
     *
     * @param linkId 链接名
     * @param table  表名
     * @return
     * @throws Exception
     */
    public List<DbFieldModel> getFieldList(String linkId, String table) throws Exception {
        List<DbFieldModelBase> fieldList = dbTableService.getDbTableModel(linkId, table);
        List<DbFieldModel> list = JsonUtil.getJsonToList(fieldList, DbFieldModel.class);
        return list;
    }
 
 
    //--------------------------------用户------------------------------
 
    public UserEntity getUserInfo(String id) {
        UserEntity entity = null;
        if (StringUtil.isNotEmpty(id)) {
            entity = id.equalsIgnoreCase(ADMIN_KEY) ? userService.getInfoByAccount(id) : userService.getInfoById(id);
        }
        return entity;
    }
 
 
    //--------------------------------单据规则------------------------------
    public String getBillNumber(String enCode) {
        String billNo = "";
        try {
            billNo = billRuleService.getBillNumber(enCode).getData();
        } catch (Exception e) {
 
        }
        return billNo;
    }
 
 
    //--------------------------------组织------------------------------
    public String getOrganizeName(String idStr) {
        return organizeService.getNameByIdStr(idStr);
    }
 
    public OrganizeEntity getOrganizeInfo(String id) {
        OrganizeEntity entity = StringUtil.isNotEmpty(id) ? organizeService.getInfoById(id) : null;
        return entity;
    }
 
    public List<OrganizeEntity> getOrganizeId(String organizeId) {
        List<OrganizeEntity> organizeList = organizeService.getOrganizeId(organizeId);
        Collections.reverse(organizeList);
        return organizeList;
    }
 
    //--------------------------------岗位------------------------------
    public String getPositionName(String idStr) {
        return positionService.getNameByIdStr(idStr);
    }
 
    //--------------------------------远端------------------------------
    public void infoToId(String interId, Map<String, String> parameterMap) {
        dataInterfaceService.infoToIdById(interId, parameterMap);
    }
 
}