代码重构
This commit is contained in:
@@ -1,4 +0,0 @@
|
||||
package org.nl.acs.ext;
|
||||
|
||||
public class T {
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package org.nl.acs.ext.erp.service;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
* Created by ZZ on 2021/9/23.
|
||||
*/
|
||||
public interface AcsToErpService {
|
||||
/**
|
||||
* ACS向WMS申请任务
|
||||
*
|
||||
* @param device_code 条件
|
||||
* @return JSONObject
|
||||
*/
|
||||
JSONObject sendDeviceToWms(String device_code);
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package org.nl.acs.ext.erp.service.impl;
|
||||
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.config.AcsConfig;
|
||||
import org.nl.acs.config.server.AcsConfigService;
|
||||
import org.nl.acs.ext.erp.service.AcsToErpService;
|
||||
import org.nl.exception.BadRequestException;
|
||||
import org.nl.wql.core.bean.WQLObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* Created by ZZ on 2021/9/23.
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AcsToErpServiceImpl implements AcsToErpService {
|
||||
@Autowired
|
||||
AcsConfigService acsConfigService;
|
||||
|
||||
@Override
|
||||
public JSONObject sendDeviceToWms(String device_code) {
|
||||
log.info("sendDeviceToWms----输入参数是:{}", device_code);
|
||||
JSONObject resultJson = new JSONObject();
|
||||
JSONObject erp_map = WQLObject.getWQLObject("acs_device_erpmapping").query("device_code = '" + device_code + "'").uniqueResult(0);
|
||||
if (erp_map == null) {
|
||||
throw new BadRequestException("该设备:" + device_code + "未找到对应的ERP设备!");
|
||||
}
|
||||
String erp_code = erp_map.getString("erp_code");
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("device_code", erp_code);
|
||||
log.info("sendDeviceToWms----erp_code是:{}", erp_code);
|
||||
String result2 = "";
|
||||
try {
|
||||
String url = acsConfigService.findConfigFromCache().get(AcsConfig.ERPURL).toString();
|
||||
result2 = HttpRequest.post(url)
|
||||
.body(jo.toString())
|
||||
.execute().body();
|
||||
System.out.println(result2);
|
||||
resultJson.put("code", HttpStatus.OK);
|
||||
resultJson.put("message", "发送成功");
|
||||
} catch (Exception e) {
|
||||
String msg = e.getMessage();
|
||||
//网络不通
|
||||
System.out.println(msg);
|
||||
resultJson.put("code", HttpStatus.BAD_REQUEST);
|
||||
resultJson.put("message", msg);
|
||||
}
|
||||
return resultJson;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user