|
|
|
@ -1,8 +1,11 @@ |
|
|
|
|
package digital.laboratory.platform.reagent.controller; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
|
import cn.hutool.core.io.file.FileNameUtil; |
|
|
|
|
import cn.hutool.json.JSONObject; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
import digital.laboratory.platform.common.core.util.R; |
|
|
|
@ -25,8 +28,11 @@ import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
import javax.activation.MimetypesFileTypeMap; |
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
import java.io.ByteArrayInputStream; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.io.InputStream; |
|
|
|
|
import java.security.Principal; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
@ -147,6 +153,7 @@ public class SupplierInformationController { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 上传供应人照片 |
|
|
|
|
* |
|
|
|
@ -155,9 +162,9 @@ public class SupplierInformationController { |
|
|
|
|
*/ |
|
|
|
|
@ApiOperation(value = "上传供应人照片", notes = "上传供应人照片/供应商信息") |
|
|
|
|
@SysLog("修改服务商/供应商信息") |
|
|
|
|
@PostMapping("/upload") |
|
|
|
|
@PostMapping("/upload/{id}") |
|
|
|
|
// @PreAuthorize("@pms.hasPermission('reagent_supplier_information_add')" )
|
|
|
|
|
public R<SupplierInformation> putUpdateById(String id, @RequestPart(value = "file", required = false) MultipartFile file, HttpServletRequest theHttpServletRequest, HttpServletResponse httpServletResponse) throws Exception { |
|
|
|
|
public R<SupplierInformation> putUpdateById(@PathVariable("id") String id, @RequestPart(value = "file") MultipartFile file, HttpServletRequest theHttpServletRequest, HttpServletResponse httpServletResponse) throws Exception { |
|
|
|
|
|
|
|
|
|
Principal principal = theHttpServletRequest.getUserPrincipal(); |
|
|
|
|
|
|
|
|
@ -165,6 +172,8 @@ public class SupplierInformationController { |
|
|
|
|
|
|
|
|
|
SupplierInformation supplierInformation = supplierInformationService.getById(id); |
|
|
|
|
|
|
|
|
|
if (supplierInformation != null) { |
|
|
|
|
|
|
|
|
|
String path = "reagen_managment" + "/" + "supplierInformation" + "/" + supplierInformation.getId(); |
|
|
|
|
String fileName = FileNameUtil.getName(file.getOriginalFilename()); |
|
|
|
|
boolean r = ossFile.fileUpload(file, path); |
|
|
|
@ -182,8 +191,10 @@ public class SupplierInformationController { |
|
|
|
|
return R.ok(supplierInformation, "上传成功"); |
|
|
|
|
} else return R.failed("上传失败"); |
|
|
|
|
|
|
|
|
|
} else return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "上传资质文件", notes = "上传资质文件") |
|
|
|
|
@SysLog("上传资质文件") |
|
|
|
|
@PostMapping("/uploadQd") |
|
|
|
@ -268,7 +279,66 @@ public class SupplierInformationController { |
|
|
|
|
return R.ok(supplierInformation); |
|
|
|
|
|
|
|
|
|
} else return R.failed(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 录入样品时上传图片,使用fastjson 解析json 对象 |
|
|
|
|
* |
|
|
|
|
* @param id |
|
|
|
|
* @param jsonParam |
|
|
|
|
* @return |
|
|
|
|
* @throws Exception |
|
|
|
|
*/ |
|
|
|
|
@ApiOperation(value = "上传供应商图片,使用fastjson 解析json 对象", |
|
|
|
|
notes = "上传供应商图片,使用fastjson 解析json 对象") |
|
|
|
|
@SysLog("上传供应商图片,使用fastjson 解析json 对象") |
|
|
|
|
@PostMapping(value = "/picture_base64/{id}") |
|
|
|
|
// @PreAuthorize("@pms.hasAnyPermission('HairJobSampleCreate')")
|
|
|
|
|
public R uploadPictureBase64(@PathVariable("id") String id, @RequestBody JSONObject jsonParam) throws Exception { |
|
|
|
|
// System.out.println(String.format("uploadPhotoObj: hairSampleId=%s jsonParam.size()=%d", hairSampleId, jsonParam.size()));
|
|
|
|
|
SupplierInformation byId = supplierInformationService.getById(id); |
|
|
|
|
if (byId != null) { |
|
|
|
|
String image = jsonParam.getStr("image"); |
|
|
|
|
//System.out.println(String.format("image=%s", image));
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(image)) { |
|
|
|
|
try { |
|
|
|
|
String suffix = image.substring(11, image.indexOf(";")); |
|
|
|
|
String fileName = DateUtil.format(new Date(), "yyyyMMddHHmmss") + "." + suffix; |
|
|
|
|
System.out.println(String.format("fileName=[%s]", fileName)); |
|
|
|
|
|
|
|
|
|
//去掉头信息
|
|
|
|
|
String imgBase64 = image.substring(image.indexOf(",") + 1); |
|
|
|
|
byte[] decoded = org.apache.commons.codec.binary.Base64.decodeBase64(imgBase64); |
|
|
|
|
InputStream is = new ByteArrayInputStream(decoded); |
|
|
|
|
|
|
|
|
|
// 生成存储路径
|
|
|
|
|
String path = "reagen_managment" + "/" + "supplierInformation" + "/" + byId.getId(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, String> ResultData = new HashMap<>(); |
|
|
|
|
ResultData.put("fileName", fileName); |
|
|
|
|
ResultData.put("path", path); |
|
|
|
|
|
|
|
|
|
boolean r = ossFile.fileSave(path + "/" + fileName, is); |
|
|
|
|
if (r) { |
|
|
|
|
|
|
|
|
|
byId.setPhotograph(fileName); |
|
|
|
|
byId.setPhotographOfSupplier(path); |
|
|
|
|
supplierInformationService.updateById(byId); |
|
|
|
|
return R.ok(ResultData, "上传成功"); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
return R.failed("上传失败"); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
return R.failed("上传失败"); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
return R.failed("上传的数据中没有图像"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return R.failed("不存在这个供应商"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|