ERPServiceImpl.java
1.92 KB
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
package com.huaheng.api.erp.service;
import com.alibaba.fastjson.JSON;
import com.huaheng.api.erp.domain.jind.ERPLoginResult;
import com.huaheng.api.erp.domain.jind.ErpLogin;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.common.utils.http.OkHttpUtils;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.framework.web.service.ConfigService;
import com.huaheng.pc.config.address.service.AddressService;
import com.huaheng.pc.system.config.domain.Config;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/***
* @author tongzonghao
*
*/
@Service
public class ERPServiceImpl implements ERPService {
@Resource
private AddressService addressService;
@Resource
private ConfigService configService;
@Override
public AjaxResult innerLoginERP() {
ErpLogin erpLogin = new ErpLogin();
erpLogin.setAcctID(QuantityConstant.ERP_AcctID);
erpLogin.setAppID(QuantityConstant.ERP_AppID);
erpLogin.setAppSec(QuantityConstant.ERP_AppSec);
erpLogin.setUserName(QuantityConstant.ERP_UserName);
erpLogin.setPassword(QuantityConstant.ERP_PASSWORD);
erpLogin.setLCID(QuantityConstant.ERP_LCID);
String url = addressService.selectAddress(QuantityConstant.ERP_K3CLOUD_LOGIN,
QuantityConstant.DEFAULT_WAREHOUSE, "");
String jsonParam = JSON.toJSONString(erpLogin);
String result = OkHttpUtils.bodypost(url, jsonParam);
ERPLoginResult erpLoginResult = JSON.parseObject(result, ERPLoginResult.class);
String sessionId = erpLoginResult.getKDSVCSessionId();
Config config1 = new Config();
config1.setConfigKey(QuantityConstant.ERP_SESSION_ID);
Config config = configService.selectConfigList(config1).get(0);
config.setConfigValue(sessionId);
int ret = configService.updateConfig(config);
return AjaxResult.success();
}
}