mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
新增添加余料板、提交保存优化结果文件、开始开料 接口
This commit is contained in:
+7
@@ -3,9 +3,11 @@ package com.cf.imes.module.infra.api.file;
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.module.infra.api.file.dto.FileCreateReqDTO;
|
||||
import com.cf.imes.module.infra.enums.ApiConstants;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -57,4 +59,9 @@ public interface FileApi {
|
||||
@Operation(summary = "保存文件,并返回文件的访问路径")
|
||||
CommonResult<String> createFile(@Valid @RequestBody FileCreateReqDTO createReqDTO);
|
||||
|
||||
@DeleteMapping(PREFIX + "/deleteFileByPath")
|
||||
@Operation(summary = "根据文件地址删除文件")
|
||||
@Parameter(name = "path", description = "文件地址", example = "url", required = true)
|
||||
CommonResult<Boolean> deleteFileByPath(String path);
|
||||
|
||||
}
|
||||
|
||||
+1
@@ -31,6 +31,7 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode FILE_PATH_EXISTS = new ErrorCode(1_001_003_000, "文件路径已存在");
|
||||
ErrorCode FILE_NOT_EXISTS = new ErrorCode(1_001_003_001, "文件不存在");
|
||||
ErrorCode FILE_IS_EMPTY = new ErrorCode(1_001_003_002, "文件为空");
|
||||
ErrorCode FILE_REMOVE_FAIL = new ErrorCode(1_001_003_003, "文件删除失败");
|
||||
|
||||
// ========== 代码生成器 1-001-004-000 ==========
|
||||
ErrorCode CODEGEN_TABLE_EXISTS = new ErrorCode(1_003_001_000, "表定义已经存在");
|
||||
|
||||
+5
@@ -23,4 +23,9 @@ public class FileApiImpl implements FileApi {
|
||||
createReqDTO.getContent()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> deleteFileByPath(String path) {
|
||||
return success(fileService.deleteFileByPath(path));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+6
@@ -45,4 +45,10 @@ public interface FileService {
|
||||
*/
|
||||
byte[] getFileContent(Long configId, String path) throws Exception;
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
* @param path 文件地址
|
||||
* @return
|
||||
*/
|
||||
Boolean deleteFileByPath(String path);
|
||||
}
|
||||
|
||||
+25
@@ -6,6 +6,7 @@ import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.common.util.io.FileUtils;
|
||||
import com.cf.imes.framework.file.core.client.FileClient;
|
||||
import com.cf.imes.framework.file.core.utils.FileTypeUtils;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.module.infra.controller.admin.file.vo.file.FilePageReqVO;
|
||||
import com.cf.imes.module.infra.dal.dataobject.file.FileDO;
|
||||
import com.cf.imes.module.infra.dal.mysql.file.FileMapper;
|
||||
@@ -14,8 +15,11 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.module.infra.enums.ErrorCodeConstants.FILE_NOT_EXISTS;
|
||||
import static com.cf.imes.module.infra.enums.ErrorCodeConstants.FILE_REMOVE_FAIL;
|
||||
|
||||
/**
|
||||
* 文件 Service 实现类
|
||||
@@ -95,4 +99,25 @@ public class FileServiceImpl implements FileService {
|
||||
return client.getContent(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteFileByPath(String path) {
|
||||
// 校验存在
|
||||
FileDO fileDO = fileMapper.selectOne(new LambdaQueryWrapperX<FileDO>().eq(FileDO::getPath, path));
|
||||
if(Objects.isNull(fileDO)) {
|
||||
throw exception(FILE_NOT_EXISTS);
|
||||
}
|
||||
// 从文件存储器中删除
|
||||
FileClient client = fileConfigService.getFileClient(fileDO.getConfigId());
|
||||
Assert.notNull(client, "客户端({}) 不能为空", fileDO.getConfigId());
|
||||
try {
|
||||
client.delete(path);
|
||||
} catch (Exception e) {
|
||||
throw exception(FILE_REMOVE_FAIL);
|
||||
}
|
||||
|
||||
// 删除记录
|
||||
fileMapper.deleteById(fileDO.getId());
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+29
-4
@@ -1,18 +1,20 @@
|
||||
package com.cf.imes.module.executor.controller.admin.plan;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.module.executor.controller.admin.plan.vo.AddRemainReqVO;
|
||||
import com.cf.imes.module.executor.controller.admin.plan.vo.PlateOptimize;
|
||||
import com.cf.imes.module.executor.controller.admin.plan.vo.SavePlanPlateResult;
|
||||
import com.cf.imes.module.executor.service.optimizeplan.OptimizePlanService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -21,6 +23,7 @@ import java.util.List;
|
||||
@RestController
|
||||
@RequestMapping("/executor/optimize-plan")
|
||||
@Tag(name= "优化排单")
|
||||
@Validated
|
||||
public class OptimizePlanController {
|
||||
|
||||
@Resource
|
||||
@@ -33,4 +36,26 @@ public class OptimizePlanController {
|
||||
return CommonResult.success(optimizePlanService.getPlateListByPlanId(planId));
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/addRemain")
|
||||
@Operation(summary = "添加余料板")
|
||||
@PreAuthorize("@ss.hasPermission('executor:optimize-plate:create')")
|
||||
public CommonResult<Boolean> addRemain(@RequestBody @Valid AddRemainReqVO vo){
|
||||
return CommonResult.success(optimizePlanService.addRemain(vo));
|
||||
}
|
||||
|
||||
@PostMapping("savePlanPlateResult")
|
||||
@Operation(summary = "提交保存优化结果文件")
|
||||
@PreAuthorize("@ss.hasPermission('executor:optimize-plate:create')")
|
||||
public CommonResult<Boolean> savePlanPlateResult(SavePlanPlateResult result) {
|
||||
return CommonResult.success(optimizePlanService.savePlanPlateResult(result));
|
||||
}
|
||||
|
||||
@GetMapping("commit")
|
||||
@Operation(summary = "开始开料")
|
||||
@PreAuthorize("@ss.hasPermission('executor:optimize-plate:create')")
|
||||
public CommonResult<Boolean> commit(@RequestParam @Valid @NotNull(message = "排单id不能空") Long planId) {
|
||||
return CommonResult.success(optimizePlanService.commit(planId));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+4
-5
@@ -133,13 +133,12 @@ public class PlanController {
|
||||
@Operation(summary = "导出板材 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('executor:plan:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportPlateExcel(@Valid PlanPageReqVO pageReqVO,
|
||||
public void exportPlateExcel(@Valid GetPlateByPlanIdVO vo,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<PlanRespVO> list = planService.getPlanPage(pageReqVO).getList();
|
||||
List<PlateResList> plateByPlanId = planService.getPlateByPlanId(vo);
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "排单.xls", "数据", PlanRespVO.class,
|
||||
BeanUtils.toBean(list, PlanRespVO.class));
|
||||
ExcelUtils.write(response, "排单板材.xls", "数据", PlateResList.class,
|
||||
BeanUtils.toBean(plateByPlanId, PlateResList.class));
|
||||
}
|
||||
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package com.cf.imes.module.executor.controller.admin.plan.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author Beal
|
||||
*/
|
||||
@Data
|
||||
public class AddRemainReqVO {
|
||||
|
||||
@Schema(description = "排单id")
|
||||
private Long planId;
|
||||
|
||||
@NotNull(message = "宽 不能空")
|
||||
@Schema(description = "宽")
|
||||
private BigDecimal width;
|
||||
|
||||
@NotNull(message = "长 不能空")
|
||||
@Schema(description = "长")
|
||||
private BigDecimal length;
|
||||
|
||||
@NotNull(message = "数量 不能空")
|
||||
@Schema(description = "数量")
|
||||
private Integer count;
|
||||
|
||||
@Schema(description = "商品id")
|
||||
private String goodsId;
|
||||
|
||||
@Schema(description = "商品名称")
|
||||
private String goodsName;
|
||||
|
||||
@Schema(description = "材料")
|
||||
private String material;
|
||||
|
||||
@Schema(description = "颜色")
|
||||
private String color;
|
||||
|
||||
}
|
||||
+2
@@ -20,6 +20,8 @@ import java.util.List;
|
||||
public class PlateOptimize {
|
||||
@Schema(description = "是否已排")
|
||||
private Boolean isPlan;
|
||||
@Schema(description = "商品id")
|
||||
private String goodsId;
|
||||
@Schema(description = "商品名称")
|
||||
private String goodsName;
|
||||
@Schema(description = "商品材质")
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.cf.imes.module.executor.controller.admin.plan.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author Beal
|
||||
*/
|
||||
@Data
|
||||
public class SavePlanPlateResult {
|
||||
|
||||
@NotNull(message = "排单id")
|
||||
@Schema(description = "排单id")
|
||||
private Long planId;
|
||||
|
||||
@NotNull(message = "文件附件不能为空")
|
||||
private MultipartFile placeOrder;
|
||||
|
||||
@NotNull(message = "文件附件不能为空")
|
||||
private MultipartFile placeData;
|
||||
}
|
||||
|
||||
+8
-1
@@ -61,7 +61,14 @@ public class PlanDO extends BaseDO {
|
||||
* 生产单号
|
||||
*/
|
||||
private String orderNos;
|
||||
|
||||
/**
|
||||
* 排单优化文件地址
|
||||
*/
|
||||
private String placeDateFileUrl;
|
||||
/**
|
||||
* 排单优化文件地址
|
||||
*/
|
||||
private String placeOrderFileUrl;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.cf.imes.module.executor.dal.mysql.remainplaten;
|
||||
|
||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.module.executor.dal.dataobject.remainplaten.RemainPlateDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface RemainPlateMapper extends BaseMapperX<RemainPlateDO> {
|
||||
|
||||
}
|
||||
+3626
File diff suppressed because one or more lines are too long
+2
-1
@@ -1,5 +1,6 @@
|
||||
package com.cf.imes.module.executor.framework.rpc.config;
|
||||
|
||||
import com.cf.imes.module.infra.api.file.FileApi;
|
||||
import com.cf.imes.module.system.api.machine.MachineApi;
|
||||
import com.cf.imes.module.system.api.user.AdminUserApi;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
@@ -9,6 +10,6 @@ import org.springframework.context.annotation.Configuration;
|
||||
* @author there
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableFeignClients(clients = {AdminUserApi.class, MachineApi.class})
|
||||
@EnableFeignClients(clients = {AdminUserApi.class, MachineApi.class, FileApi.class})
|
||||
public class RpcConfiguration {
|
||||
}
|
||||
|
||||
+8
@@ -1,9 +1,17 @@
|
||||
package com.cf.imes.module.executor.service.optimizeplan;
|
||||
|
||||
import com.cf.imes.module.executor.controller.admin.plan.vo.AddRemainReqVO;
|
||||
import com.cf.imes.module.executor.controller.admin.plan.vo.PlateOptimize;
|
||||
import com.cf.imes.module.executor.controller.admin.plan.vo.SavePlanPlateResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface OptimizePlanService {
|
||||
List<PlateOptimize> getPlateListByPlanId(Long planId);
|
||||
|
||||
Boolean addRemain(AddRemainReqVO vo);
|
||||
|
||||
Boolean savePlanPlateResult(SavePlanPlateResult result);
|
||||
|
||||
Boolean commit(Long planId);
|
||||
}
|
||||
|
||||
+91
-1
@@ -1,23 +1,113 @@
|
||||
package com.cf.imes.module.executor.service.optimizeplan;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.cf.imes.module.executor.controller.admin.plan.vo.AddRemainReqVO;
|
||||
import com.cf.imes.module.executor.controller.admin.plan.vo.PlateOptimize;
|
||||
import com.cf.imes.module.executor.controller.admin.plan.vo.SavePlanPlateResult;
|
||||
import com.cf.imes.module.executor.dal.dataobject.plan.PlanDO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.remainplaten.RemainPlateDO;
|
||||
import com.cf.imes.module.executor.dal.mysql.plan.PlanMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.remainplaten.RemainPlateMapper;
|
||||
import com.cf.imes.module.infra.api.file.FileApi;
|
||||
import com.cf.imes.module.infra.api.file.dto.FileCreateReqDTO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.enums.GlobalErrorCodeConstants.UNKNOWN;
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.PLAN_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* @author there
|
||||
*/
|
||||
@Service
|
||||
public class OptimizePlanServiceImpl implements OptimizePlanService{
|
||||
public class OptimizePlanServiceImpl implements OptimizePlanService {
|
||||
|
||||
@Resource
|
||||
private PlanMapper planMapper;
|
||||
|
||||
@Resource
|
||||
private RemainPlateMapper remainPlateMapper;
|
||||
|
||||
@Resource
|
||||
private FileApi fileApi;
|
||||
|
||||
@Override
|
||||
public List<PlateOptimize> getPlateListByPlanId(Long planId) {
|
||||
return planMapper.selectPlateListByPlanId(planId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean addRemain(AddRemainReqVO vo) {
|
||||
PlanDO planDO = planMapper.selectById(vo.getPlanId());
|
||||
if (Objects.isNull(planDO)) {
|
||||
throw exception(PLAN_NOT_EXISTS);
|
||||
}
|
||||
RemainPlateDO remainPlateDO = RemainPlateDO.builder()
|
||||
.width(vo.getWidth())
|
||||
.length(vo.getLength())
|
||||
.planId(vo.getPlanId())
|
||||
.initPlanId(vo.getPlanId())
|
||||
.goodsId(vo.getGoodsId())
|
||||
.name(vo.getGoodsName())
|
||||
.material(vo.getMaterial())
|
||||
.color(vo.getColor())
|
||||
.count(vo.getCount())
|
||||
.build();
|
||||
remainPlateMapper.insert(remainPlateDO);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean savePlanPlateResult(SavePlanPlateResult result) {
|
||||
PlanDO planDO = planMapper.selectById(result.getPlanId());
|
||||
if (Objects.isNull(planDO)) {
|
||||
throw exception(PLAN_NOT_EXISTS);
|
||||
}
|
||||
try {
|
||||
String placeDateFileUrlSource = planDO.getPlaceDateFileUrl();
|
||||
String placeOrderFileUrlSource = planDO.getPlaceOrderFileUrl();
|
||||
if (StrUtil.isNotBlank(placeDateFileUrlSource)) {
|
||||
fileApi.deleteFileByPath(placeDateFileUrlSource).checkError();
|
||||
}
|
||||
if (StrUtil.isNotBlank(placeOrderFileUrlSource)) {
|
||||
fileApi.deleteFileByPath(placeOrderFileUrlSource).checkError();
|
||||
}
|
||||
FileCreateReqDTO fileCreateReqDTO = new FileCreateReqDTO();
|
||||
|
||||
fileCreateReqDTO.setContent(result.getPlaceData().getBytes());
|
||||
String placeDateFileUrl = fileApi.createFile(fileCreateReqDTO).getCheckedData();
|
||||
|
||||
fileCreateReqDTO.setContent(result.getPlaceOrder().getBytes());
|
||||
String placeOrderFileUrl = fileApi.createFile(fileCreateReqDTO).getCheckedData();
|
||||
|
||||
PlanDO updateDO = PlanDO.builder()
|
||||
.id(result.getPlanId())
|
||||
.placeDateFileUrl(placeOrderFileUrl)
|
||||
.placeOrderFileUrl(placeDateFileUrl)
|
||||
.build();
|
||||
planMapper.insert(updateDO);
|
||||
|
||||
} catch (IOException e) {
|
||||
throw exception(UNKNOWN);
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean commit(Long planId) {
|
||||
PlanDO planDO = planMapper.selectById(planId);
|
||||
if (Objects.isNull(planDO)) {
|
||||
throw exception(PLAN_NOT_EXISTS);
|
||||
}
|
||||
planMapper.updateById(PlanDO.builder()
|
||||
.id(planId)
|
||||
.status(2)
|
||||
.build());
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -21,13 +21,13 @@
|
||||
|
||||
<select id="selectPlateListByPlanId"
|
||||
resultType="com.cf.imes.module.executor.controller.admin.plan.vo.PlateOptimize">
|
||||
select a.goods_name, a.material, a.color, a.width, a.height, a.thickness, count(b.id) as plateNum, d.*
|
||||
select a.goods_id, a.goods_name, a.material, a.color, a.width, a.height, a.thickness, count(b.id) as plateNum, d.*
|
||||
from order_goods a
|
||||
left join order_plate b on a.goods_id = b.goods_id
|
||||
left join prod_plan_order c on c.order_id = b.order_id
|
||||
left join order_remain_plate d on a.goods_id = d.goods_id and d.plan_id = c.plan_id
|
||||
GROUP BY a.id, d.id
|
||||
where c.plan_id = #{planId}
|
||||
GROUP BY a.id, d.id
|
||||
|
||||
</select>
|
||||
</mapper>
|
||||
+38
-7
@@ -1,23 +1,29 @@
|
||||
package com.cf.imes.module.executor.service.zlib;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.nacos.shaded.io.grpc.netty.shaded.io.netty.handler.codec.compression.JdkZlibDecoder;
|
||||
import com.alibaba.nacos.shaded.io.grpc.netty.shaded.io.netty.handler.codec.compression.ZlibDecoder;
|
||||
import com.cf.imes.module.executor.util.ZLibUtils;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.client.RestClientException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.*;
|
||||
import java.net.URI;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.zip.Inflater;
|
||||
|
||||
public class ZlibTest {
|
||||
@@ -105,4 +111,29 @@ public class ZlibTest {
|
||||
byte[] Data;
|
||||
long CompanyID;
|
||||
}
|
||||
|
||||
@Test
|
||||
void getRes() throws IOException {
|
||||
//创建url路径
|
||||
String url = "https://chenfeng.tech:777/api/v1/OrderBlockPlan/GetPlanOrderData";
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
|
||||
//接口参数
|
||||
map.add("id",1306667105);
|
||||
//头部类型
|
||||
headers.set("Cookie", ".AspNetCore.Cookies=CfDJ8CGzP7BhamtAnTFO8HhkPcxGBkdd4sCOIjQMV-nb37GAFKr4y6C0JA0B3JzRsDAckabiUgBXQaWyDNjCqVTvBNYwbHwVbI5b-eKdXwkIFqsJZObZA-RoLdsu1d9yy1LwBLQwJxDGKTSQzFtrs_eHDeDEuG8CWEF1Iq96X0goR_cFMn0EHWVeRnOlThmDzLkmTMhysVSludR6qV0HrD54GOv5MQvBzzcE-WlsrKTo5Uf0hT8z1fGMY8Hofa6UDh8yyJsz2LFTQTy4NpmklvyXIkwv0fw9bOynHLllUh5ToF0wgrxYFU3Rzgf863uAdtfRP1DY2Rqvf-51uvQHip-SIT_b5p7TaSRiG-M7pZTlI0oOVPZRhng7k-NeIJRdYQmj0h3G3WJHCTH7g1-YQjAGbYQkJFcZdAsZpR-kjOlp3sHpNCDUe0NucYrLNp4tTXesCL_-t8X5GsXMYGlX-oKU10I");
|
||||
//构造实体对象
|
||||
HttpEntity<MultiValueMap<String, Object>> param = new HttpEntity<>(map, headers);
|
||||
//发起请求,服务地址,请求参数,返回消息体的数据类型
|
||||
ResponseEntity<Resource> response = restTemplate.postForEntity(url, param, Resource.class);
|
||||
//body
|
||||
InputStream inputStream = response.getBody().getInputStream();
|
||||
BufferedOutputStream out = FileUtil.getOutputStream("C:\\Users\\Beal\\Desktop\\新建文件夹\\xx.txt");
|
||||
long copySize = IoUtil.copy(inputStream, out, IoUtil.DEFAULT_BUFFER_SIZE);
|
||||
IoUtil.close(inputStream);
|
||||
IoUtil.close(out);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user