Commit 49e234cd authored by renchao's avatar renchao

炮孔设计模块代码编写

parent 28ae1e11
......@@ -5,6 +5,7 @@ import cn.wise.sc.acquisition.business.model.query.TSampleLaboratorysheetQuery;
import cn.wise.sc.acquisition.business.service.ITSampleLaboratorysheetService;
import com.baomidou.mybatisplus.extension.api.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -40,6 +41,9 @@ public class TSampleLaboratorysheetController {
*/
@ApiOperation(value = "根据样号查看分析结果")
@RequestMapping(value = "/getByYh", method = RequestMethod.GET)
@ApiImplicitParam(
name = "Yh", value = "样号", required = true, dataType="String"
)
public R getByYh(TSampleLaboratorysheetQuery tSampleLaboratorysheetQuery) {
return itSampleLaboratorysheetService.getByYh(tSampleLaboratorysheetQuery);
}
......
......@@ -29,7 +29,7 @@ import java.util.Optional;
* 服务实现类
* </p>
*
* @author ztw
* @author renchao
* @since 2021-04-22
*/
@Service
......
......@@ -30,7 +30,7 @@ public class ImageUtil {
* 将文件转化为字节
*/
public static byte[] transformByte(MultipartFile file) {
if (file == null) throw new RuntimeException("文件为空");
if (file == null) throw new RuntimeException("transformByte method:file is null");
try {
byte[] pictureData = new byte[(int) file.getSize()];
InputStream inputStream = file.getInputStream();
......@@ -39,7 +39,7 @@ public class ImageUtil {
return pictureData;
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException("图片转化失败");
throw new RuntimeException("file transform picture is failed");
}
}
......@@ -47,7 +47,8 @@ public class ImageUtil {
* 将字节转化为文件,并下载
*/
public static void transformImage(byte[] data, final HttpServletResponse response) {
if (data.length == 0) throw new RuntimeException("图片数据为空");
if (data.length == 0) throw new RuntimeException("transformImage method:byte[] data is null");
if (response == null) throw new RuntimeException("transformImage method:HttpServletResponse response is null");
response.setContentType("image/jpeg");
response.setCharacterEncoding("UTF-8");
OutputStream outputSream;
......@@ -58,7 +59,7 @@ public class ImageUtil {
outputSream.close();
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException("图片下载失败");
throw new RuntimeException("picture download is failed");
}
}
......@@ -67,7 +68,7 @@ public class ImageUtil {
* 将多个文件转化为字节
*/
public static byte[] transformByteMore(MultipartFile[] files) {
if (files == null || files.length == 0) throw new RuntimeException("文件为空");
if (files == null || files.length == 0) throw new RuntimeException("transformByteMore method:files is null");
try {
//创建字节流数组
List<byte[]> bytes = new ArrayList<>();
......@@ -88,7 +89,7 @@ public class ImageUtil {
return data;
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException("图片转化失败");
throw new RuntimeException("files transform picture is failed");
}
}
......@@ -97,7 +98,8 @@ public class ImageUtil {
* 将字节转化为文件,并下载
*/
public static void transformImageMore(byte[] data, final HttpServletResponse response) {
if (data == null || data.length == 0) throw new RuntimeException("图片数据为空");
if (data == null || data.length == 0) throw new RuntimeException("transformImageMore method:byte[] data is null");
if (response == null) throw new RuntimeException("transformImageMore method:HttpServletResponse response is null");
response.setContentType("image/jpeg");
response.setCharacterEncoding("UTF-8");
OutputStream outputSream = null;
......@@ -114,7 +116,7 @@ public class ImageUtil {
}
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException("图片下载失败");
throw new RuntimeException("files transform picture is failed");
}
}
......@@ -122,9 +124,9 @@ public class ImageUtil {
* 根据obj类型获取图片
*/
public static void getImage(Integer imageType, Object obj, final HttpServletResponse response) {
if (imageType == null || imageType.intValue() == 0) throw new RuntimeException("下载图片时imageType为空");
if (obj == null) throw new RuntimeException("下载图片时obj为空");
if (response == null) throw new RuntimeException("下载图片时response为空");
if (imageType == null || imageType.intValue() == 0) throw new RuntimeException("getImage method:imageType is null");
if (obj == null) throw new RuntimeException("getImage method:Object obj is null");
if (response == null) throw new RuntimeException("getImage method:HttpServletResponse response is null");
byte[] data = null;
if (obj instanceof TSampleList) {
......@@ -152,6 +154,10 @@ public class ImageUtil {
* 根据类型保存并转化文件为图片 需要请求参数ImageType 保存的实体TSampleList 以及file
*/
public static void setImage(Integer imageType, Object obj, MultipartFile file) {
if (imageType == null || imageType.intValue() == 0) throw new RuntimeException("getImage method:imageType is null");
if (obj == null) throw new RuntimeException("getImage method:Object obj is null");
if (file == null) throw new RuntimeException("getImage method:MultipartFile file is null");
if (obj instanceof TSampleList) {
TSampleList tSampleList = (TSampleList) obj;
//判断保存二维码还是记录形式
......@@ -174,7 +180,7 @@ public class ImageUtil {
* @param content
*/
public static byte[] QRCodeGenerator(String content) {
if (StringUtils.isEmpty(content)) throw new RuntimeException("二维码转化内容为空");
if (StringUtils.isEmpty(content)) throw new RuntimeException("QRCodeGenerator method:String content is null");
ByteArrayOutputStream stream = new ByteArrayOutputStream();
BufferedImage bufferedImage = QrCodeUtil.generate(content, 200, 200);
try {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment