|
|
|
@ -31,6 +31,7 @@ import com.op.system.api.domain.quality.*;
|
|
|
|
|
import com.op.system.api.domain.sap.SapCloseOrderQuery;
|
|
|
|
|
import com.op.system.api.domain.sap.SapRFW;
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
import org.apache.http.HttpResponse;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
@ -41,8 +42,15 @@ import org.springframework.web.context.request.RequestContextHolder;
|
|
|
|
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.net.HttpURLConnection;
|
|
|
|
|
import java.net.URL;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
|
@ -64,13 +72,17 @@ public class OpenServiceImpl implements OpenService {
|
|
|
|
|
@Value("${OA.url}")
|
|
|
|
|
private String oa_url;
|
|
|
|
|
|
|
|
|
|
@Value("${OA.getnodeInfo}")
|
|
|
|
|
private String getnodeInfo;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private OpenMapper openMapper;
|
|
|
|
|
|
|
|
|
|
// @Autowired
|
|
|
|
|
// private RemoteSapService remoteSapService;
|
|
|
|
|
|
|
|
|
|
/**下一工序机台集合获取
|
|
|
|
|
/**
|
|
|
|
|
* 下一工序机台集合获取
|
|
|
|
|
* JSON
|
|
|
|
|
* {
|
|
|
|
|
* "reqCode": "eb7f8e9f-d1e8-499e-9bcb-e72d3ac195b0", //请求ID
|
|
|
|
@ -78,7 +90,7 @@ public class OpenServiceImpl implements OpenService {
|
|
|
|
|
* "rfidNo": "r12345" //rfid编号
|
|
|
|
|
* "factory"
|
|
|
|
|
* }
|
|
|
|
|
*
|
|
|
|
|
* <p>
|
|
|
|
|
* JSON
|
|
|
|
|
* {
|
|
|
|
|
* "reqCode": "eb7f8e9f-d1e8-499e-9bcb-e72d3ac195b0", //请求ID
|
|
|
|
@ -103,6 +115,7 @@ public class OpenServiceImpl implements OpenService {
|
|
|
|
|
* }
|
|
|
|
|
* ],
|
|
|
|
|
* }
|
|
|
|
|
*
|
|
|
|
|
* @param wcsdto
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
@ -377,10 +390,26 @@ public class OpenServiceImpl implements OpenService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public AjaxResult OAInspection(Map<String, Object> paramMap) {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// 从paramMap中提取需要的参数
|
|
|
|
|
String user = paramMap.get("user").toString();
|
|
|
|
|
String requestLevel = paramMap.get("requestLevel").toString();
|
|
|
|
|
String requestName = paramMap.get("requestName").toString();
|
|
|
|
|
String workflowId = paramMap.get("workflowId").toString();
|
|
|
|
|
String mainObject = paramMap.get("mainObject").toString();
|
|
|
|
|
|
|
|
|
|
String result = HttpUtils.sendPostOA(oa_url, convertJsonToUrlParams(JSONObject.toJSONString(paramMap)));
|
|
|
|
|
// Building the postData string using StringBuilder
|
|
|
|
|
StringBuilder postDataBuilder = new StringBuilder();
|
|
|
|
|
postDataBuilder.append("user=").append(user)
|
|
|
|
|
.append("&requestLevel=").append(requestLevel)
|
|
|
|
|
.append("&requestName=").append(URLEncoder.encode(requestName, StandardCharsets.UTF_8.toString()))
|
|
|
|
|
.append("&workflowId=").append(workflowId)
|
|
|
|
|
.append("&mainObject=").append(URLEncoder.encode(mainObject, StandardCharsets.UTF_8.toString()));
|
|
|
|
|
if (Constants.WORKFLOWID_ZL0020.equals(workflowId)) {
|
|
|
|
|
postDataBuilder.append("&details=").append(URLEncoder.encode(mainObject, StandardCharsets.UTF_8.toString()));
|
|
|
|
|
}
|
|
|
|
|
String postData = postDataBuilder.toString();
|
|
|
|
|
String result = HttpUtils.sendPostOA(oa_url, postData);
|
|
|
|
|
System.out.println(result);
|
|
|
|
|
//返回示例{"result":"0","info":"成功","requestid":"2193799"}
|
|
|
|
|
Map resultMap=JSONObject.parseObject(result);
|
|
|
|
@ -389,62 +418,25 @@ public class OpenServiceImpl implements OpenService {
|
|
|
|
|
}else {
|
|
|
|
|
return error(resultMap.get("info").toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
return error(e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public AjaxResult OAProcessInspection(Map<String, Object> paramMap) {
|
|
|
|
|
try {
|
|
|
|
|
String result = HttpUtils.sendPostOA(oa_url, convertJsonToUrlParams(JSONObject.toJSONString(paramMap)));
|
|
|
|
|
System.out.println(result);
|
|
|
|
|
//返回示例{"result":"0","info":"成功","requestid":"2193799"}
|
|
|
|
|
Map resultMap=JSONObject.parseObject(result);
|
|
|
|
|
if (resultMap.get("result").equals(Constants.LOGIN_SUCCESS_STATUS)){
|
|
|
|
|
return success(resultMap.get("info").toString(),resultMap.get("requestid").toString());
|
|
|
|
|
}else {
|
|
|
|
|
return error(resultMap.get("info").toString());
|
|
|
|
|
}
|
|
|
|
|
public AjaxResult GetOaNodeInfo(String requestId) {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
String result = HttpUtils.sendGet(getnodeInfo,"requestId="+requestId);
|
|
|
|
|
return success(result);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
return error(e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String convertJsonToUrlParams(String json) throws IOException {
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
JsonNode jsonNode = objectMapper.readTree(json);
|
|
|
|
|
|
|
|
|
|
StringBuilder urlParams = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
Iterator<String> fieldNames = jsonNode.fieldNames();
|
|
|
|
|
while (fieldNames.hasNext()) {
|
|
|
|
|
String fieldName = fieldNames.next();
|
|
|
|
|
JsonNode fieldValue = jsonNode.get(fieldName);
|
|
|
|
|
|
|
|
|
|
if (urlParams.length() > 0) {
|
|
|
|
|
urlParams.append("&");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
urlParams.append(fieldName).append("=").append(fieldValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return urlParams.toString();
|
|
|
|
|
}
|
|
|
|
|
public static void main(String args[]){
|
|
|
|
|
Map<String, Object> paramMap =new HashMap<>();
|
|
|
|
|
paramMap.put("A","B");
|
|
|
|
|
paramMap.put("C","D");
|
|
|
|
|
paramMap.put("E","F");
|
|
|
|
|
System.out.println(JSONObject.toJSONString(paramMap));
|
|
|
|
|
// DateTimeFormatter ymdhms = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
// LocalDate today = LocalDate.now();
|
|
|
|
|
// LocalDate lastMonth3 = today.plus(-3, ChronoUnit.MONTHS);
|
|
|
|
|
//
|
|
|
|
|
// System.out.println("7天之前的日期为:"+lastMonth3.getYear());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|