|
|
@ -17,7 +17,7 @@ import com.gaotao.modules.shopOrder.entity.OperatorData; |
|
|
import com.gaotao.modules.sys.controller.AbstractController; |
|
|
import com.gaotao.modules.sys.controller.AbstractController; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.core.io.ByteArrayResource; |
|
|
|
|
|
|
|
|
import org.springframework.core.io.InputStreamResource; |
|
|
import org.springframework.http.HttpEntity; |
|
|
import org.springframework.http.HttpEntity; |
|
|
import org.springframework.http.HttpHeaders; |
|
|
import org.springframework.http.HttpHeaders; |
|
|
import org.springframework.http.HttpMethod; |
|
|
import org.springframework.http.HttpMethod; |
|
|
@ -35,6 +35,7 @@ import org.springframework.web.client.RestTemplate; |
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
import org.springframework.web.util.UriComponentsBuilder; |
|
|
import org.springframework.web.util.UriComponentsBuilder; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
import java.nio.charset.StandardCharsets; |
|
|
import java.nio.charset.StandardCharsets; |
|
|
import java.text.ParseException; |
|
|
import java.text.ParseException; |
|
|
import java.util.HashMap; |
|
|
import java.util.HashMap; |
|
|
@ -2452,15 +2453,7 @@ public class ScheduleController extends AbstractController { |
|
|
body.add("date", date); |
|
|
body.add("date", date); |
|
|
body.add("shift", shift); |
|
|
body.add("shift", shift); |
|
|
body.add("operatorNo", operatorNo); |
|
|
body.add("operatorNo", operatorNo); |
|
|
|
|
|
|
|
|
final byte[] fileBytes = log.getBytes(); |
|
|
|
|
|
final String fileName = StringUtils.hasText(log.getOriginalFilename()) ? log.getOriginalFilename() : "upload.log"; |
|
|
|
|
|
body.add("log", new ByteArrayResource(fileBytes) { |
|
|
|
|
|
@Override |
|
|
|
|
|
public String getFilename() { |
|
|
|
|
|
return fileName; |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
body.add("log", buildMultipartFileResource(log, "upload.log")); |
|
|
|
|
|
|
|
|
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(body, headers); |
|
|
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(body, headers); |
|
|
ResponseEntity<String> response = restTemplate.exchange( |
|
|
ResponseEntity<String> response = restTemplate.exchange( |
|
|
@ -2555,15 +2548,7 @@ public class ScheduleController extends AbstractController { |
|
|
MultiValueMap<String, Object> body = new LinkedMultiValueMap<>(); |
|
|
MultiValueMap<String, Object> body = new LinkedMultiValueMap<>(); |
|
|
body.add("machineNo", machineNo); |
|
|
body.add("machineNo", machineNo); |
|
|
body.add("date", date); |
|
|
body.add("date", date); |
|
|
|
|
|
|
|
|
final byte[] fileBytes = log.getBytes(); |
|
|
|
|
|
final String fileName = StringUtils.hasText(log.getOriginalFilename()) ? log.getOriginalFilename() : "upload_mt.log"; |
|
|
|
|
|
body.add("log", new ByteArrayResource(fileBytes) { |
|
|
|
|
|
@Override |
|
|
|
|
|
public String getFilename() { |
|
|
|
|
|
return fileName; |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
body.add("log", buildMultipartFileResource(log, "upload_mt.log")); |
|
|
|
|
|
|
|
|
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(body, headers); |
|
|
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(body, headers); |
|
|
ResponseEntity<String> response = restTemplate.exchange( |
|
|
ResponseEntity<String> response = restTemplate.exchange( |
|
|
@ -2585,6 +2570,22 @@ public class ScheduleController extends AbstractController { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private InputStreamResource buildMultipartFileResource(MultipartFile file, String defaultFileName) throws IOException { |
|
|
|
|
|
final String fileName = StringUtils.hasText(file.getOriginalFilename()) ? file.getOriginalFilename() : defaultFileName; |
|
|
|
|
|
final long fileSize = file.getSize(); |
|
|
|
|
|
return new InputStreamResource(file.getInputStream()) { |
|
|
|
|
|
@Override |
|
|
|
|
|
public String getFilename() { |
|
|
|
|
|
return fileName; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public long contentLength() { |
|
|
|
|
|
return fileSize; |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private String buildMesApiUrl(String path) { |
|
|
private String buildMesApiUrl(String path) { |
|
|
String baseUrl = StringUtils.hasText(mesLogsBaseUrl) ? mesLogsBaseUrl.trim() : "http://logs.bt.in/api/logs"; |
|
|
String baseUrl = StringUtils.hasText(mesLogsBaseUrl) ? mesLogsBaseUrl.trim() : "http://logs.bt.in/api/logs"; |
|
|
if (baseUrl.endsWith("/")) { |
|
|
if (baseUrl.endsWith("/")) { |
|
|
|