自动化立体仓库 - WMS系统
dubin
1 天以前 dd76858f35bb4fdd76d5976465e9bd96267b0f0b
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
package com.zy.erp.ghln;
 
import com.alibaba.fastjson.JSON;
import com.zy.common.utils.HttpHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
 
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
 
/**
 * @author pang.jiabao
 * @description
 * @createDate 2024/7/10 19:46
 */
public class GhlnErp {
 
    public static final String servelUrl = "http://192.168.16.7/K3Cloud";
 
    private static Logger logger = LoggerFactory.getLogger(GhlnErp.class);
 
    private static String dbid ;  //测试环境TEST3为6353684490aa2b   正式环境为 655f026e8f0a03  TEST1测试环境为63985a1d80ae72
 
    private static String userName="Administrator";  //测试环境和正式环境都是一样的
 
    private static String passWord="a123456.";  //测试环境和正式环境都是一样的
    private static int  lang=2052;
 
    static {
        boolean addressEnabled = false;  //获取正式环境数据为true  测试环境就为false
        if(addressEnabled){
            dbid="655f026e8f0a03";
        }else{
            dbid="63985a1d80ae72";
        }
    }
 
 
//    @Scheduled(fixedRate=200000)
    public static String login() throws IOException {
        logger.info("dbid"+dbid);
        // id号  用户名 和 密码
        // String loginParam = buildLogin("6269114ac9aeb1", "demo", "a123456.", 2052);   高科测试  6295eb8010ec7f    正式环境账套ID  62de03297091ce
        String loginParam = buildLogin(dbid, userName, passWord, lang);
        System.out.println(loginParam);
        String url = "/Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser.common.kdsvc";
        String response= new HttpHandler.Builder()
                .setUri(servelUrl)
                .setPath(url)
                .setJson(loginParam)
                .build()
                .doPost();
//                HttpUtil.httpPost(url, loginParam);
        String login_cookie="";
//        if(response.getStatusCode()== HttpStatus.OK) {
//            Set<String> keys=response.getHeaders().keySet();
//            for(String key:keys){
//                if (key.equalsIgnoreCase("Set-Cookie")) {
//                    List<String> cookies = response.getHeaders().get(key);
//                    for(String cookie:cookies){
//                        if(cookie.startsWith("kdservice-sessionid")){
//                            login_cookie=cookie;
//                            RedisUtils.setCacheObject("loginedcookies", login_cookie,10, TimeUnit.MINUTES);
//
//                            System.out.println("登录K3成功啦:"+login_cookie);
//                            break;
//                        }
//                    }
//                }
//            }
//            System.out.println( response.getBody());
//        }
        return login_cookie;
    }
 
    public static void main(String[] args) throws IOException {
        String login = GhlnErp.login();
        System.out.println(login);
    }
 
    public static String buildLogin(String dbid, String userName, String password, int lang){
        Map<String,Object> param = new HashMap<>(4);
        param.put("acctID",dbid);
        param.put("username",userName);
        param.put("password",password);
        param.put("lcid",lang);
        return JSON.toJSONString(param);
    }
 
//    获取半成品母卷查询接口:
//    public static ArrayList<ObtainInforMasterRollMaterVo> GetJxFMaterialIdByFMaterialName(){
//        Long beginTime = new Date().getTime();
//        ArrayList<ObtainInforMasterRollMaterVo> masterlist= new ArrayList<>();
//        try{
//            String url = servelUrl+"/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.ExecuteBillQuery.common.kdsvc";
//            String  formId="BD_MATERIAL";
//            String cookie=""
////                    RedisUtils.getCacheObject("loginedcookies");
//            if( cookie == null){
//                cookie = login();
//            }
//            String residuelength="{\n" +
//                    "    \"FormId\": \"BD_MATERIAL\",\n" +
//                    "    \"FieldKeys\": \"FNumber,FName,FSpecification,FUseOrgId.fnumber,FDocumentStatus,FBaseUnitId.fnumber\",\n" +
//                    "    \"FilterString\": \"FUseOrgId.fnumber='10004' and fnumber like '02%'\",\n" +
//                    "    \"OrderString\": \"\",\n" +
//                    "    \"TopRowCount\": 0,\n" +
//                    "    \"StartRow\": 0,\n" +
//                    "    \"Limit\": 2000,\n" +
//                    "    \"SubSystemId\": \"\"\n" +
//                    "}";
//            String queryinfo = "";
////                    buildMaterial(residuelength,formId) ;
//            Map<String, Object> header = new HashMap<>();
//            header.put("Cookie",cookie);
//            String results =
//                    HttpUtil.httpPost(url, header, queryinfo);
//            String[] tempstr=null;
//            if(!"[]".equals(results)) {
//                String[] returnstr=results.split("],");
//                if (returnstr.length > 0) {
//                    for(int i=0; i<returnstr.length;i++){
//                        ObtainInforMasterRollMaterVo obtaininfor=new ObtainInforMasterRollMaterVo();
//                        tempstr = returnstr[i].split(",");
//                        if (i == 0) {
//                            obtaininfor.setMaterialNo(tempstr[0].substring(2, tempstr[0].length()));  //物料编码
//                        } else {
//                            obtaininfor.setMaterialNo(tempstr[0].substring(1, tempstr[0].length()));  //物料编码
//                        }
//                        obtaininfor.setFmaterialName(tempstr[1]); //  物料名称
//                        obtaininfor.setFSpecification(tempstr[2]); //  规格
//                        obtaininfor.setFUseOrgId(tempstr[3]);  //  使用组织
//                        obtaininfor.setFDocumentStatus(tempstr[4]);  // 数据状态
//                        if (returnstr.length == 1) {
//                            obtaininfor.setFBaseUnitId(tempstr[5].substring(0, tempstr[5].length() - 2));  // 基本单位
//                        } else if (returnstr.length > 1) {
//                            if (i == returnstr.length - 1) {
//                                obtaininfor.setFBaseUnitId(tempstr[5].substring(0, tempstr[5].length() - 2));
//
//                            } else {
//                                obtaininfor.setFBaseUnitId(tempstr[5].substring(0, tempstr[5].length()));
//                            }
//                        }
//                        StringUtils.removeReg(obtaininfor);
//                        masterlist.add(obtaininfor);
//                    }
//                }
//            }
//        }catch (Exception e){
//            logger.error("调用物料查询接口获取母卷物料信息报错--JX");
//            logger.error(e.getMessage());
//            throw new RuntimeException("调用物料查询接口获取母卷物料信息报错--JX");
//        }
//        Long opetime =new Date().getTime()-beginTime;
//        logger.info("调用物料查询接口获取母卷物料信息--jx 调用接口耗时 "+opetime);
//        return masterlist;
//    }
//
//    public static  String  GetJxFMaterialIdByFMaterialName(String  materialno){
//        Long beginTime = new Date().getTime();
//        String matername="";
//        try{
//            String url = servelUrl+"/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.ExecuteBillQuery.common.kdsvc";
//            String  formId="BD_MATERIAL";
//            String cookie=RedisUtils.getCacheObject("loginedcookies");
//            if( cookie == null){
//                cookie = login();
//            }
//            String residuelength="{\n" +
//                    "    \"FormId\": \"BD_MATERIAL\",\n" +
//                    "    \"FieldKeys\": \"FName\",\n" +
//                    "    \"FilterString\": \"FUseOrgId.fnumber='10004' and fnumber='"+materialno+"'\",\n" +
//                    "    \"OrderString\": \"\",\n" +
//                    "    \"TopRowCount\": 0,\n" +
//                    "    \"StartRow\": 0,\n" +
//                    "    \"Limit\": 2000,\n" +
//                    "    \"SubSystemId\": \"\"\n" +
//                    "}";
//            String queryinfo =  buildMaterial(residuelength,formId) ;
//            Map<String, Object> header = new HashMap<>();
//            header.put("Cookie",cookie);
//            String results = HttpUtil.httpPost(url, header, queryinfo);
//            String[] tempstr=null;
//            if(!"[]".equals(results)) {
//                String[] returnstr=results.split("],");
//                if (returnstr.length > 0) {
//                    for(int i=0; i<returnstr.length;i++){
//                        ObtainInforMasterRollMaterVo obtaininfor=new ObtainInforMasterRollMaterVo();
//                        tempstr = returnstr[i].split(",");
//                        if (i == 0) {
//                            matername=tempstr[0].substring(2, tempstr[0].length()-2);  //物料名称
//                        }
//                        break;
//                        StringUtils.removeReg(matername);
//                    }
//                }
//            }
//        }catch (Exception e){
//            logger.error("调用物料查询接口获取母卷物料信息报错--JX");
//            logger.error(e.getMessage());
//            throw new RuntimeException("调用物料查询接口获取母卷物料信息报错--JX");
//        }
//        Long opetime =new Date().getTime()-beginTime;
//        logger.info("调用物料查询接口获取母卷物料信息--jx 调用接口耗时 "+opetime);
//        return matername;
//    }
 
}