|
|
|
@ -52,6 +52,8 @@ import org.springframework.http.ResponseEntity; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
import org.springframework.util.LinkedMultiValueMap; |
|
|
|
import org.springframework.util.MultiValueMap; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
import org.springframework.web.client.RestTemplate; |
|
|
|
|
|
|
|
@ -5084,6 +5086,8 @@ public class ScheduleServiceImpl implements ScheduleService { |
|
|
|
body.put("process", workCenterNo); |
|
|
|
body.put("rollLabels", rollNos); |
|
|
|
body.put("machineNo", resourceId); |
|
|
|
logger.info("TID分卷校验请求: site={}, orderNo={}, seqNo={}", |
|
|
|
inData.getSite(), inData.getOrderNo(), inData.getSeqNo()); |
|
|
|
postMesLogs("/checkRolls", body, "TID分卷校验"); |
|
|
|
scheduleMapper.updateTidPassFlag(inData.getSite(), inData.getSeqNo(), rollNos); |
|
|
|
} |
|
|
|
@ -5177,11 +5181,22 @@ public class ScheduleServiceImpl implements ScheduleService { |
|
|
|
private void postMesLogs(String path, Map<String, Object> body, String failLabel) { |
|
|
|
HttpHeaders headers = new HttpHeaders(); |
|
|
|
headers.setBasicAuth(mesLogsUsername, mesLogsPassword, StandardCharsets.UTF_8); |
|
|
|
headers.setContentType(MediaType.APPLICATION_JSON); |
|
|
|
headers.setContentType(MediaType.MULTIPART_FORM_DATA); |
|
|
|
MultiValueMap<String, Object> form = new LinkedMultiValueMap<>(); |
|
|
|
Map<String, String> formLog = new LinkedHashMap<>(); |
|
|
|
if (body != null) { |
|
|
|
for (Map.Entry<String, Object> entry : body.entrySet()) { |
|
|
|
String fieldValue = toMesFormFieldValue(entry.getValue()); |
|
|
|
form.add(entry.getKey(), fieldValue); |
|
|
|
formLog.put(entry.getKey(), fieldValue); |
|
|
|
} |
|
|
|
} |
|
|
|
String requestUrl = buildMesLogsUrl(path); |
|
|
|
logger.info("{}请求: url={}, contentType=multipart/form-data, form={}", |
|
|
|
failLabel, requestUrl, JSON.toJSONString(formLog)); |
|
|
|
ResponseEntity<String> response; |
|
|
|
try { |
|
|
|
response = restTemplate.exchange(requestUrl, HttpMethod.POST, new HttpEntity<>(body, headers), String.class); |
|
|
|
response = restTemplate.exchange(requestUrl, HttpMethod.POST, new HttpEntity<>(form, headers), String.class); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("{}调用失败", failLabel, e); |
|
|
|
throw new XJException(failLabel + "失败: " + e.getMessage()); |
|
|
|
@ -5218,6 +5233,16 @@ public class ScheduleServiceImpl implements ScheduleService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private String toMesFormFieldValue(Object value) { |
|
|
|
if (value == null) { |
|
|
|
return ""; |
|
|
|
} |
|
|
|
if (value instanceof CharSequence || value instanceof Number || value instanceof Boolean) { |
|
|
|
return String.valueOf(value); |
|
|
|
} |
|
|
|
return JSON.toJSONString(value); |
|
|
|
} |
|
|
|
|
|
|
|
private String buildMesLogsUrl(String path) { |
|
|
|
String baseUrl = StringUtils.hasText(mesLogsBaseUrl) ? mesLogsBaseUrl.trim() : "http://logs.bt.in/api/logs"; |
|
|
|
if (baseUrl.endsWith("/")) { |
|
|
|
|