阳光采购平台修改
parent
b92bf62fd8
commit
00160d2a5d
@ -1,23 +1,51 @@
|
|||||||
package com.glxp.udi.admin.controller.udidl;
|
package com.glxp.udi.admin.controller.udidl;
|
||||||
|
|
||||||
import com.glxp.udi.admin.annotation.AuthRuleAnnotation;
|
import com.glxp.udi.admin.annotation.AuthRuleAnnotation;
|
||||||
|
import com.glxp.udi.admin.config.GlobalConfig;
|
||||||
import com.glxp.udi.admin.req.feign.BaseParam;
|
import com.glxp.udi.admin.req.feign.BaseParam;
|
||||||
|
import com.glxp.udi.admin.req.feign.UdplatGoodsParam;
|
||||||
import com.glxp.udi.admin.service.udidl.UdidlService;
|
import com.glxp.udi.admin.service.udidl.UdidlService;
|
||||||
|
import com.glxp.udi.admin.service.udidl.UdidlServiceRun;
|
||||||
import com.glxp.udi.common.res.BaseResponse;
|
import com.glxp.udi.common.res.BaseResponse;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class UdplatGoodsController {
|
public class UdplatGoodsController {
|
||||||
@Resource
|
@Resource
|
||||||
UdidlService udidlService;
|
UdidlService udidlService;
|
||||||
|
@Autowired
|
||||||
|
UdidlServiceRun udidlServiceRun;
|
||||||
|
@Autowired
|
||||||
|
GlobalConfig globalConfig;
|
||||||
|
|
||||||
@AuthRuleAnnotation("")
|
@AuthRuleAnnotation("")
|
||||||
@PostMapping("/udplat/goods/list")
|
@PostMapping("/udplat/goods/list")
|
||||||
public BaseResponse getList(@RequestBody BaseParam param){
|
public BaseResponse getList(@RequestBody UdplatGoodsParam param){
|
||||||
return udidlService.udplatGoods_getList(param);
|
return udidlService.udplatGoods_getList(param);
|
||||||
}
|
}
|
||||||
|
@AuthRuleAnnotation("")
|
||||||
|
@PostMapping("udplat/goods/export")
|
||||||
|
public BaseResponse export(@RequestBody UdplatGoodsParam param){
|
||||||
|
BaseResponse res = udidlService.udplatGoods_export(param);
|
||||||
|
if(res.getCode()!=20000)
|
||||||
|
return res;
|
||||||
|
String url=globalConfig.getUDI_SERVER_URL()+ res.getData();
|
||||||
|
res.setData(url);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
/* public void export(HttpServletResponse response){
|
||||||
|
udidlServiceRun.udplatGoods_export(response);
|
||||||
|
}*/
|
||||||
|
@AuthRuleAnnotation("")
|
||||||
|
@PostMapping("/udplat/goods/detail")
|
||||||
|
public BaseResponse detail(Integer id){
|
||||||
|
return udidlService.udplatGoods_detail(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.glxp.udi.admin.req.feign;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UdplatGoodsParam extends BaseParam{
|
||||||
|
private String manufactureName;//生产企业
|
||||||
|
private String distributorName;//配送企业
|
||||||
|
private String regNum;//注册证号
|
||||||
|
private String model;//型号
|
||||||
|
private String spec;//规格
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
package com.glxp.udi.admin.service.udidl;
|
||||||
|
|
||||||
|
import com.glxp.udi.admin.config.GlobalConfig;
|
||||||
|
import com.glxp.udi.admin.req.feign.BaseParam;
|
||||||
|
import com.glxp.udi.admin.util.HttpClient;
|
||||||
|
import com.glxp.udi.common.res.BaseResponse;
|
||||||
|
import feign.RequestLine;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
import javax.servlet.ServletOutputStream;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.BufferedOutputStream;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class UdidlServiceRun {
|
||||||
|
@Autowired
|
||||||
|
GlobalConfig globalConfig;
|
||||||
|
public void udplatManufacture_export(HttpServletResponse response){
|
||||||
|
export(response,"/udplat/manufacture/export","manufacture");
|
||||||
|
}
|
||||||
|
public void udplatGoods_export(HttpServletResponse response) {
|
||||||
|
export(response,"/udplat/goods/export","udplatGoods");
|
||||||
|
}
|
||||||
|
public void udplatDistributor_export(HttpServletResponse response) {
|
||||||
|
export(response,"/udplat/distributor/export","distributor");
|
||||||
|
}
|
||||||
|
public void udplatHospital_export(HttpServletResponse response) {
|
||||||
|
export(response,"/udplat/hospital/export","hospital");
|
||||||
|
}
|
||||||
|
private void export(HttpServletResponse response,String url,String fileName){
|
||||||
|
String fullUrl=globalConfig.getUDI_SERVER_URL()+url;
|
||||||
|
Map<String,String> headerMap = new HashMap<>();
|
||||||
|
headerMap.put("key",globalConfig.getUDI_SERVER_Key());
|
||||||
|
ResponseEntity<byte[]> res = HttpClient.getFile(fullUrl,headerMap);
|
||||||
|
response.setCharacterEncoding("utf-8");
|
||||||
|
response.setContentType("application/octet-stream");
|
||||||
|
response.setHeader("content-type","application/octet-stream");
|
||||||
|
response.addHeader("Content-Disposition","attachment;filename="+fileName+".json");
|
||||||
|
BufferedOutputStream buff=null;
|
||||||
|
ServletOutputStream outStr = null;
|
||||||
|
try{
|
||||||
|
outStr = response.getOutputStream();
|
||||||
|
buff = new BufferedOutputStream(outStr);
|
||||||
|
buff.write(res.getBody());
|
||||||
|
buff.flush();
|
||||||
|
buff.close();
|
||||||
|
}catch (Exception e){
|
||||||
|
|
||||||
|
}finally {
|
||||||
|
try{
|
||||||
|
buff.close();;
|
||||||
|
outStr.close();
|
||||||
|
}catch (Exception e){}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue