Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
data-acquisition
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
竹天卫
data-acquisition
Commits
e7ff4f1e
Commit
e7ff4f1e
authored
Apr 26, 2021
by
renchao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
送验单模块代码编写
parent
9f046286
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
927 additions
and
46 deletions
+927
-46
TSampleLaboratorysheetController.java
...business/controller/TSampleLaboratorysheetController.java
+79
-0
TSampleListController.java
...cquisition/business/controller/TSampleListController.java
+52
-10
TSampleLaboratorysheet.java
...c/acquisition/business/entity/TSampleLaboratorysheet.java
+131
-0
TSampleList.java
...a/cn/wise/sc/acquisition/business/entity/TSampleList.java
+4
-3
ProjectEnum.java
...n/wise/sc/acquisition/business/enumation/ProjectEnum.java
+123
-0
TSampleLaboratorysheetMapper.java
...isition/business/mapper/TSampleLaboratorysheetMapper.java
+16
-0
TSampleLaboratorysheetMapper.xml
...tion/business/mapper/xml/TSampleLaboratorysheetMapper.xml
+5
-0
TSampleLaboratorysheetQuery.java
...ion/business/model/query/TSampleLaboratorysheetQuery.java
+126
-0
TSampleListQuery.java
...sc/acquisition/business/model/query/TSampleListQuery.java
+14
-6
ITSampleLaboratorysheetService.java
...tion/business/service/ITSampleLaboratorysheetService.java
+25
-0
ITSampleListService.java
.../sc/acquisition/business/service/ITSampleListService.java
+9
-0
TSampleLaboratorysheetServiceImpl.java
...iness/service/impl/TSampleLaboratorysheetServiceImpl.java
+109
-0
TSampleListServiceImpl.java
...isition/business/service/impl/TSampleListServiceImpl.java
+119
-27
ImageUtil.java
.../java/cn/wise/sc/acquisition/business/util/ImageUtil.java
+110
-0
TSampleLaboratorysheetMapper.xml
...uisition/business/mapper/TSampleLaboratorysheetMapper.xml
+5
-0
No files found.
acquisition-business/src/main/java/cn/wise/sc/acquisition/business/controller/TSampleLaboratorysheetController.java
0 → 100644
View file @
e7ff4f1e
package
cn
.
wise
.
sc
.
acquisition
.
business
.
controller
;
import
cn.wise.sc.acquisition.business.model.query.TSampleLaboratorysheetQuery
;
import
cn.wise.sc.acquisition.business.service.impl.TSampleLaboratorysheetServiceImpl
;
import
com.baomidou.mybatisplus.extension.api.R
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* <p>
* 前端控制器
* </p>
*
* @author renchao
* @since 2021-04-25
*/
@RestController
@RequestMapping
(
"/business/t-sample-laboratorysheet"
)
public
class
TSampleLaboratorysheetController
{
@Autowired
private
TSampleLaboratorysheetServiceImpl
tSampleLaboratorysheetService
;
/**
* 根据样号查看分析结果
*
* @param tSampleLaboratorysheetQuery
* @return
*/
@RequestMapping
(
value
=
"/getByYh"
,
method
=
RequestMethod
.
GET
)
public
R
getByYh
(
TSampleLaboratorysheetQuery
tSampleLaboratorysheetQuery
)
{
return
tSampleLaboratorysheetService
.
getByYh
(
tSampleLaboratorysheetQuery
);
}
/**
* 根据样号修改分析结果
*
* @param tSampleLaboratorysheetQuery
* @return
*/
@RequestMapping
(
value
=
"/updateByYh"
,
method
=
RequestMethod
.
POST
)
public
R
updateByYh
(
@RequestBody
TSampleLaboratorysheetQuery
tSampleLaboratorysheetQuery
)
{
return
tSampleLaboratorysheetService
.
updateByYh
(
tSampleLaboratorysheetQuery
);
}
/**
* 根据样号删除分析结果
*
* @param tSampleLaboratorysheetQuery
* @return
*/
@RequestMapping
(
value
=
"/deleteByYh"
,
method
=
RequestMethod
.
POST
)
public
R
deleteByYh
(
@RequestBody
TSampleLaboratorysheetQuery
tSampleLaboratorysheetQuery
)
{
return
tSampleLaboratorysheetService
.
deleteByYh
(
tSampleLaboratorysheetQuery
);
}
/**
* 根据样号删除分析结果
*
* @param tSampleLaboratorysheetQuery
* @return
*/
@RequestMapping
(
value
=
"/insertTSampleLaboratorysheet"
,
method
=
RequestMethod
.
POST
)
public
R
insertTSampleLaboratorysheet
(
@RequestBody
TSampleLaboratorysheetQuery
tSampleLaboratorysheetQuery
)
{
return
tSampleLaboratorysheetService
.
insertTSampleLaboratorysheet
(
tSampleLaboratorysheetQuery
);
}
}
acquisition-business/src/main/java/cn/wise/sc/acquisition/business/controller/TSampleListController.java
View file @
e7ff4f1e
...
@@ -6,10 +6,11 @@ import cn.wise.sc.acquisition.business.service.impl.TSampleListServiceImpl;
...
@@ -6,10 +6,11 @@ import cn.wise.sc.acquisition.business.service.impl.TSampleListServiceImpl;
import
cn.wise.sc.acquisition.business.wrapper.page.Query
;
import
cn.wise.sc.acquisition.business.wrapper.page.Query
;
import
com.baomidou.mybatisplus.extension.api.R
;
import
com.baomidou.mybatisplus.extension.api.R
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.
RequestMapping
;
import
org.springframework.web.bind.annotation.
*
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletResponse
;
/**
/**
* <p>
* <p>
...
@@ -34,22 +35,63 @@ public class TSampleListController {
...
@@ -34,22 +35,63 @@ public class TSampleListController {
*/
*/
@RequestMapping
(
value
=
"/getPage"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/getPage"
,
method
=
RequestMethod
.
GET
)
public
R
getPage
(
TSampleListQuery
tSampleListQuery
,
Query
query
)
{
public
R
getPage
(
TSampleListQuery
tSampleListQuery
,
Query
query
)
{
return
R
.
ok
(
tSampleListService
.
getPage
(
tSampleListQuery
,
query
)
);
return
tSampleListService
.
getPage
(
tSampleListQuery
,
query
);
}
}
/**
* 根据炮孔编号修改送验单
*
* @param tSampleListQuery
* @return
*/
@RequestMapping
(
value
=
"/updateByHolesID"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/updateByHolesID"
,
method
=
RequestMethod
.
POST
)
public
R
updateByHolesID
(
TSampleListQuery
tSampleListQuery
)
{
public
R
updateByHolesID
(
@RequestBody
TSampleListQuery
tSampleListQuery
)
{
return
R
.
ok
(
tSampleListService
.
updateByHolesID
(
tSampleListQuery
)
);
return
tSampleListService
.
updateByHolesID
(
tSampleListQuery
);
}
}
/**
* 增加送验单
*
* @param tSampleListQuery
* @return
*/
@RequestMapping
(
value
=
"/insertSampleList"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/insertSampleList"
,
method
=
RequestMethod
.
POST
)
public
R
insertSampleList
(
TSampleListQuery
tSampleListQuery
)
{
public
R
insertSampleList
(
@RequestBody
TSampleListQuery
tSampleListQuery
)
{
return
R
.
ok
(
tSampleListService
.
insertSampleList
(
tSampleListQuery
)
);
return
tSampleListService
.
insertSampleList
(
tSampleListQuery
);
}
}
/**
* 根据炮孔编号删除送验单
*
* @param tSampleListQuery
* @return
*/
@RequestMapping
(
value
=
"/deleteByHolesID"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/deleteByHolesID"
,
method
=
RequestMethod
.
POST
)
public
R
deleteByHolesID
(
TSampleListQuery
tSampleListQuery
)
{
public
R
deleteByHolesID
(
@RequestBody
TSampleListQuery
tSampleListQuery
)
{
return
R
.
ok
(
tSampleListService
.
deleteByHolesID
(
tSampleListQuery
));
return
tSampleListService
.
deleteByHolesID
(
tSampleListQuery
);
}
/**
* 保存图片
*
* @return
*/
@RequestMapping
(
value
=
"/saveImage"
,
method
=
RequestMethod
.
POST
)
public
R
saveImage
(
TSampleListQuery
query
,
@RequestParam
(
value
=
"file"
,
required
=
true
)
MultipartFile
file
){
return
tSampleListService
.
saveImage
(
query
,
file
);
}
/**
* 下载图片
*
* @return
*/
@RequestMapping
(
value
=
"/getImage"
,
method
=
RequestMethod
.
GET
)
public
R
getImage
(
TSampleListQuery
query
,
final
HttpServletResponse
response
){
return
tSampleListService
.
getImage
(
query
,
response
);
}
}
}
}
...
...
acquisition-business/src/main/java/cn/wise/sc/acquisition/business/entity/TSampleLaboratorysheet.java
0 → 100644
View file @
e7ff4f1e
package
cn
.
wise
.
sc
.
acquisition
.
business
.
entity
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
java.time.LocalDateTime
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
java.io.Serializable
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
/**
* <p>
*
* </p>
*
* @author renchao
* @since 2021-04-25
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@Accessors
(
chain
=
true
)
@TableName
(
"T_Sample_LaboratorySheet"
)
public
class
TSampleLaboratorysheet
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 样号
*/
@TableId
(
"Yh"
)
private
String
Yh
;
/**
* 二维码
*/
@TableField
(
"QRCode"
)
private
byte
[]
QRCode
;
/**
* 化验室编号
*/
@TableField
(
"LaboratoryID"
)
private
String
LaboratoryID
;
/**
* 副品存放位置
*/
@TableField
(
"Fpcfwz"
)
private
String
Fpcfwz
;
/**
* 氧化钙
*/
@TableField
(
"Cao"
)
private
Float
Cao
;
/**
* 氧化镁
*/
@TableField
(
"MgO"
)
private
Float
MgO
;
/**
* 三氧化二铝
*/
@TableField
(
"Al2O3"
)
private
Float
Al2O3
;
/**
* 二氧化硅
*/
@TableField
(
"SiO2"
)
private
Float
SiO2
;
/**
* 三氧化二铁
*/
@TableField
(
"Fe2O3"
)
private
Float
Fe2O3
;
/**
* 氧化钾
*/
@TableField
(
"K2O"
)
private
Float
k2o
;
/**
* 氧化钠
*/
@TableField
(
"Na2O"
)
private
Float
Na2O
;
/**
* 三氧化硫
*/
@TableField
(
"SO3"
)
private
Float
so3
;
/**
* 氯离子
*/
@TableField
(
"Cl"
)
private
Float
Cl
;
/**
* 烧失量
*/
@TableField
(
"Ssl"
)
private
Float
Ssl
;
/**
* 收样时间
*/
@TableField
(
"Sysj"
)
private
LocalDateTime
Sysj
;
/**
* 化验人
*/
@TableField
(
"Hyr"
)
private
String
Hyr
;
/**
* 化验时间
*/
@TableField
(
"Hysj"
)
private
LocalDateTime
Hysj
;
}
acquisition-business/src/main/java/cn/wise/sc/acquisition/business/entity/TSampleList.java
View file @
e7ff4f1e
package
cn
.
wise
.
sc
.
acquisition
.
business
.
entity
;
package
cn
.
wise
.
sc
.
acquisition
.
business
.
entity
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.Data
;
...
@@ -29,11 +30,11 @@ public class TSampleList implements Serializable {
...
@@ -29,11 +30,11 @@ public class TSampleList implements Serializable {
/**
/**
* 样号
* 样号
*/
*/
@Table
Fiel
d
(
"Yh"
)
@Table
I
d
(
"Yh"
)
private
String
Yh
;
private
String
Yh
;
/**
/**
* 二维码
* 二维码
因为是字节,很长,不查询这个字段
*/
*/
@TableField
(
"QRCode"
)
@TableField
(
"QRCode"
)
private
byte
[]
QRCode
;
private
byte
[]
QRCode
;
...
@@ -99,7 +100,7 @@ public class TSampleList implements Serializable {
...
@@ -99,7 +100,7 @@ public class TSampleList implements Serializable {
private
String
RecordName
;
private
String
RecordName
;
/**
/**
* 记录形式
* 记录形式
因为是字节,很长,不查询这个字段
*/
*/
@TableField
(
"RecordCode"
)
@TableField
(
"RecordCode"
)
private
byte
[]
RecordCode
;
private
byte
[]
RecordCode
;
...
...
acquisition-business/src/main/java/cn/wise/sc/acquisition/business/enumation/ProjectEnum.java
0 → 100644
View file @
e7ff4f1e
package
cn
.
wise
.
sc
.
acquisition
.
business
.
enumation
;
import
org.apache.commons.lang3.StringUtils
;
/**
* Author:renchao
* 送验单模块枚举
*/
public
class
ProjectEnum
{
/**
* 保存图片类型判断 1.记录形式 2.二维码
*/
public
enum
ImageType
{
RECORD_CODE
(
1
,
"RecordCode"
,
"记录形式"
),
QR_CODE
(
2
,
"QRCode"
,
"二维码"
);
// 成员变量
private
int
value
;
private
String
label
;
private
String
explain
;
// 构造方法
ImageType
(
int
value
,
String
label
,
String
explain
)
{
this
.
value
=
value
;
this
.
label
=
label
;
this
.
explain
=
explain
;
}
/**
* 根据value,获取label
*/
public
static
String
getLabel
(
int
value
)
{
for
(
ImageType
c
:
ImageType
.
values
())
{
if
(
c
.
value
==
value
)
{
return
c
.
label
;
}
}
return
ImageType
.
RECORD_CODE
.
label
;
}
/**
* 根据label,获取value
*/
public
static
int
getValue
(
String
label
)
{
for
(
ImageType
c
:
ImageType
.
values
())
{
if
(
StringUtils
.
equalsIgnoreCase
(
label
,
c
.
label
))
{
return
c
.
value
;
}
}
return
ImageType
.
RECORD_CODE
.
value
;
}
public
int
getValue
()
{
return
value
;
}
public
String
getLabel
()
{
return
label
;
}
}
/**
* 保存图片类型判断 1.记录形式 2.二维码
*/
public
enum
TSampleListType
{
YH
(
1
,
"Yh"
,
"样号"
),
HOLES_ID
(
2
,
"HolesID"
,
"炮孔编号"
);
// 成员变量
private
int
value
;
private
String
label
;
private
String
explain
;
// 构造方法
TSampleListType
(
int
value
,
String
label
,
String
explain
)
{
this
.
value
=
value
;
this
.
label
=
label
;
this
.
explain
=
explain
;
}
/**
* 根据value,获取label
*/
public
static
String
getLabel
(
int
value
)
{
for
(
ImageType
c
:
ImageType
.
values
())
{
if
(
c
.
value
==
value
)
{
return
c
.
label
;
}
}
return
ImageType
.
RECORD_CODE
.
label
;
}
/**
* 根据label,获取value
*/
public
static
int
getValue
(
String
label
)
{
for
(
ImageType
c
:
ImageType
.
values
())
{
if
(
StringUtils
.
equalsIgnoreCase
(
label
,
c
.
label
))
{
return
c
.
value
;
}
}
return
ImageType
.
RECORD_CODE
.
value
;
}
public
int
getValue
()
{
return
value
;
}
public
String
getLabel
()
{
return
label
;
}
}
}
acquisition-business/src/main/java/cn/wise/sc/acquisition/business/mapper/TSampleLaboratorysheetMapper.java
0 → 100644
View file @
e7ff4f1e
package
cn
.
wise
.
sc
.
acquisition
.
business
.
mapper
;
import
cn.wise.sc.acquisition.business.entity.TSampleLaboratorysheet
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
/**
* <p>
* Mapper 接口
* </p>
*
* @author renchao
* @since 2021-04-25
*/
public
interface
TSampleLaboratorysheetMapper
extends
BaseMapper
<
TSampleLaboratorysheet
>
{
}
acquisition-business/src/main/java/cn/wise/sc/acquisition/business/mapper/xml/TSampleLaboratorysheetMapper.xml
0 → 100644
View file @
e7ff4f1e
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"cn.wise.sc.acquisition.business.mapper.TSampleLaboratorysheetMapper"
>
</mapper>
acquisition-business/src/main/java/cn/wise/sc/acquisition/business/model/query/TSampleLaboratorysheetQuery.java
0 → 100644
View file @
e7ff4f1e
package
cn
.
wise
.
sc
.
acquisition
.
business
.
model
.
query
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.time.LocalDateTime
;
/**
* <p>
*
* </p>
*
* @author renchao
* @since 2021-04-25
*/
@Data
@ApiModel
(
"样品化验单"
)
public
class
TSampleLaboratorysheetQuery
implements
Serializable
{
/**
* 样号
*/
@ApiModelProperty
(
"Yh"
)
private
String
Yh
;
/**
* 二维码
*/
@ApiModelProperty
(
"QRCode"
)
private
byte
[]
QRCode
;
/**
* 化验室编号
*/
@ApiModelProperty
(
"LaboratoryID"
)
private
String
LaboratoryID
;
/**
* 副品存放位置
*/
@ApiModelProperty
(
"Fpcfwz"
)
private
String
Fpcfwz
;
/**
* 氧化钙
*/
@ApiModelProperty
(
"Cao"
)
private
Float
Cao
;
/**
* 氧化镁
*/
@ApiModelProperty
(
"MgO"
)
private
Float
MgO
;
/**
* 三氧化二铝
*/
@ApiModelProperty
(
"Al2O3"
)
private
Float
Al2O3
;
/**
* 二氧化硅
*/
@ApiModelProperty
(
"SiO2"
)
private
Float
SiO2
;
/**
* 三氧化二铁
*/
@ApiModelProperty
(
"Fe2O3"
)
private
Float
Fe2O3
;
/**
* 氧化钾
*/
@ApiModelProperty
(
"K2O"
)
private
Float
k2o
;
/**
* 氧化钠
*/
@ApiModelProperty
(
"Na2O"
)
private
Float
Na2O
;
/**
* 三氧化硫
*/
@ApiModelProperty
(
"SO3"
)
private
Float
so3
;
/**
* 氯离子
*/
@ApiModelProperty
(
"Cl"
)
private
Float
Cl
;
/**
* 烧失量
*/
@ApiModelProperty
(
"Ssl"
)
private
Float
Ssl
;
/**
* 收样时间
*/
@ApiModelProperty
(
"Sysj"
)
private
LocalDateTime
Sysj
;
/**
* 化验人
*/
@ApiModelProperty
(
"Hyr"
)
private
String
Hyr
;
/**
* 化验时间
*/
@ApiModelProperty
(
"Hysj"
)
private
LocalDateTime
Hysj
;
}
acquisition-business/src/main/java/cn/wise/sc/acquisition/business/model/query/TSampleListQuery.java
View file @
e7ff4f1e
package
cn
.
wise
.
sc
.
acquisition
.
business
.
model
.
query
;
package
cn
.
wise
.
sc
.
acquisition
.
business
.
model
.
query
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
/**
/**
* <p>
* <p>
*
*
* </p>
* </p>
*
*
* @author renchao
* @author renchao
...
@@ -30,6 +25,13 @@ public class TSampleListQuery implements Serializable {
...
@@ -30,6 +25,13 @@ public class TSampleListQuery implements Serializable {
@ApiModelProperty
(
"搜索字段"
)
@ApiModelProperty
(
"搜索字段"
)
private
String
search
;
private
String
search
;
/**
* 图片保存下载类型
*/
@ApiModelProperty
(
"图片保存下载类型"
)
private
Integer
imageType
;
/**
/**
* 样号
* 样号
*/
*/
...
@@ -108,4 +110,10 @@ public class TSampleListQuery implements Serializable {
...
@@ -108,4 +110,10 @@ public class TSampleListQuery implements Serializable {
*/
*/
@ApiModelProperty
(
"记录形式"
)
@ApiModelProperty
(
"记录形式"
)
private
byte
[]
RecordCode
;
private
byte
[]
RecordCode
;
public
TSampleListQuery
(){}
public
TSampleListQuery
(
String
yh
)
{
this
.
Yh
=
yh
;
}
}
}
acquisition-business/src/main/java/cn/wise/sc/acquisition/business/service/ITSampleLaboratorysheetService.java
0 → 100644
View file @
e7ff4f1e
package
cn
.
wise
.
sc
.
acquisition
.
business
.
service
;
import
cn.wise.sc.acquisition.business.entity.TSampleLaboratorysheet
;
import
cn.wise.sc.acquisition.business.model.query.TSampleLaboratorysheetQuery
;
import
com.baomidou.mybatisplus.extension.api.R
;
import
com.baomidou.mybatisplus.extension.service.IService
;
/**
* <p>
* 服务类
* </p>
*
* @author renchao
* @since 2021-04-25
*/
public
interface
ITSampleLaboratorysheetService
extends
IService
<
TSampleLaboratorysheet
>
{
R
getByYh
(
TSampleLaboratorysheetQuery
tSampleLaboratorysheetQuery
);
R
updateByYh
(
TSampleLaboratorysheetQuery
tSampleLaboratorysheetQuery
);
R
deleteByYh
(
TSampleLaboratorysheetQuery
tSampleLaboratorysheetQuery
);
R
insertTSampleLaboratorysheet
(
TSampleLaboratorysheetQuery
tSampleLaboratorysheetQuery
);
}
acquisition-business/src/main/java/cn/wise/sc/acquisition/business/service/ITSampleListService.java
View file @
e7ff4f1e
...
@@ -5,6 +5,9 @@ import cn.wise.sc.acquisition.business.model.query.TSampleListQuery;
...
@@ -5,6 +5,9 @@ import cn.wise.sc.acquisition.business.model.query.TSampleListQuery;
import
cn.wise.sc.acquisition.business.wrapper.page.Query
;
import
cn.wise.sc.acquisition.business.wrapper.page.Query
;
import
com.baomidou.mybatisplus.extension.api.R
;
import
com.baomidou.mybatisplus.extension.api.R
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletResponse
;
/**
/**
...
@@ -24,4 +27,10 @@ public interface ITSampleListService extends IService<TSampleList> {
...
@@ -24,4 +27,10 @@ public interface ITSampleListService extends IService<TSampleList> {
R
deleteByHolesID
(
TSampleListQuery
tSampleListQuery
);
R
deleteByHolesID
(
TSampleListQuery
tSampleListQuery
);
R
insertSampleList
(
TSampleListQuery
tSampleListQuery
);
R
insertSampleList
(
TSampleListQuery
tSampleListQuery
);
R
saveImage
(
TSampleListQuery
query
,
MultipartFile
file
);
R
getImage
(
TSampleListQuery
query
,
final
HttpServletResponse
response
);
R
getByYh
(
TSampleListQuery
query
);
}
}
acquisition-business/src/main/java/cn/wise/sc/acquisition/business/service/impl/TSampleLaboratorysheetServiceImpl.java
0 → 100644
View file @
e7ff4f1e
package
cn
.
wise
.
sc
.
acquisition
.
business
.
service
.
impl
;
import
cn.wise.sc.acquisition.business.constant.Rcode
;
import
cn.wise.sc.acquisition.business.entity.TSampleLaboratorysheet
;
import
cn.wise.sc.acquisition.business.mapper.TSampleLaboratorysheetMapper
;
import
cn.wise.sc.acquisition.business.model.query.TSampleLaboratorysheetQuery
;
import
cn.wise.sc.acquisition.business.model.query.TSampleListQuery
;
import
cn.wise.sc.acquisition.business.service.ITSampleLaboratorysheetService
;
import
com.alibaba.fastjson.JSON
;
import
com.baomidou.mybatisplus.extension.api.R
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
/**
* <p>
* 服务实现类
* </p>
*
* @author renchao
* @since 2021-04-25
*/
@Service
@Slf4j
public
class
TSampleLaboratorysheetServiceImpl
extends
ServiceImpl
<
TSampleLaboratorysheetMapper
,
TSampleLaboratorysheet
>
implements
ITSampleLaboratorysheetService
{
@Autowired
private
TSampleListServiceImpl
tSampleListService
;
@Override
public
R
getByYh
(
TSampleLaboratorysheetQuery
tSampleLaboratorysheetQuery
)
{
log
.
info
(
JSON
.
toJSONString
(
tSampleLaboratorysheetQuery
));
//参数校验
Rcode
.
NOT_PARAM
.
assertNotEmpty
(
tSampleLaboratorysheetQuery
.
getYh
());
TSampleLaboratorysheet
tSampleLaboratorysheet
=
baseMapper
.
selectById
(
tSampleLaboratorysheetQuery
.
getYh
());
return
R
.
ok
(
tSampleLaboratorysheet
);
}
@Override
public
R
updateByYh
(
TSampleLaboratorysheetQuery
tSampleLaboratorysheetQuery
)
{
log
.
info
(
JSON
.
toJSONString
(
tSampleLaboratorysheetQuery
));
//参数校验
Rcode
.
NOT_PARAM
.
assertNotEmpty
(
tSampleLaboratorysheetQuery
.
getYh
());
//封装
TSampleLaboratorysheet
tSampleLaboratorysheet
=
new
TSampleLaboratorysheet
();
BeanUtils
.
copyProperties
(
tSampleLaboratorysheetQuery
,
tSampleLaboratorysheet
);
int
update
=
baseMapper
.
updateById
(
tSampleLaboratorysheet
);
if
(
update
>
0
)
{
return
R
.
ok
(
"修改成功"
);
}
else
{
log
.
info
(
JSON
.
toJSONString
(
tSampleLaboratorysheet
));
return
R
.
failed
(
"修改失败"
);
}
}
@Override
public
R
deleteByYh
(
TSampleLaboratorysheetQuery
tSampleLaboratorysheetQuery
)
{
log
.
info
(
JSON
.
toJSONString
(
tSampleLaboratorysheetQuery
));
//参数校验
Rcode
.
NOT_PARAM
.
assertNotEmpty
(
tSampleLaboratorysheetQuery
.
getYh
());
//删除
int
delete
=
baseMapper
.
deleteById
(
tSampleLaboratorysheetQuery
.
getYh
());
if
(
delete
>
0
)
{
return
R
.
ok
(
"修改成功"
);
}
else
{
return
R
.
failed
(
"修改失败"
);
}
}
@Override
public
R
insertTSampleLaboratorysheet
(
TSampleLaboratorysheetQuery
tSampleLaboratorysheetQuery
)
{
log
.
info
(
JSON
.
toJSONString
(
tSampleLaboratorysheetQuery
));
//参数校验
Rcode
.
NOT_PARAM
.
assertNotEmpty
(
tSampleLaboratorysheetQuery
.
getYh
());
//判断是否存在送样号
R
r
=
tSampleListService
.
getByYh
(
new
TSampleListQuery
(
tSampleLaboratorysheetQuery
.
getYh
()));
if
(
r
.
getData
()
==
null
)
{
return
R
.
failed
(
"送验单不存在,样号:"
+
tSampleLaboratorysheetQuery
.
getYh
());
}
//继续判断参数
Rcode
.
NOT_PARAM
.
assertNotEmpty
(
tSampleLaboratorysheetQuery
.
getLaboratoryID
());
Rcode
.
NOT_PARAM
.
assertNotNull
(
tSampleLaboratorysheetQuery
.
getSysj
());
Rcode
.
NOT_PARAM
.
assertNotNull
(
tSampleLaboratorysheetQuery
.
getHysj
());
Rcode
.
NOT_PARAM
.
assertNotEmpty
(
tSampleLaboratorysheetQuery
.
getHyr
());
Rcode
.
NOT_PARAM
.
assertNotEmpty
(
tSampleLaboratorysheetQuery
.
getFpcfwz
());
Rcode
.
NOT_PARAM
.
assertNotNull
(
tSampleLaboratorysheetQuery
.
getCao
());
Rcode
.
NOT_PARAM
.
assertNotNull
(
tSampleLaboratorysheetQuery
.
getMgO
());
Rcode
.
NOT_PARAM
.
assertNotNull
(
tSampleLaboratorysheetQuery
.
getSiO2
());
Rcode
.
NOT_PARAM
.
assertNotNull
(
tSampleLaboratorysheetQuery
.
getAl2O3
());
Rcode
.
NOT_PARAM
.
assertNotNull
(
tSampleLaboratorysheetQuery
.
getFe2O3
());
Rcode
.
NOT_PARAM
.
assertNotNull
(
tSampleLaboratorysheetQuery
.
getK2o
());
Rcode
.
NOT_PARAM
.
assertNotNull
(
tSampleLaboratorysheetQuery
.
getNa2O
());
Rcode
.
NOT_PARAM
.
assertNotNull
(
tSampleLaboratorysheetQuery
.
getSo3
());
Rcode
.
NOT_PARAM
.
assertNotNull
(
tSampleLaboratorysheetQuery
.
getCl
());
Rcode
.
NOT_PARAM
.
assertNotNull
(
tSampleLaboratorysheetQuery
.
getSsl
());
//封装
TSampleLaboratorysheet
tSampleLaboratorysheet
=
new
TSampleLaboratorysheet
();
BeanUtils
.
copyProperties
(
tSampleLaboratorysheetQuery
,
tSampleLaboratorysheet
);
int
insert
=
baseMapper
.
insert
(
tSampleLaboratorysheet
);
if
(
insert
>
0
)
{
return
R
.
ok
(
"添加成功"
);
}
else
{
log
.
info
(
JSON
.
toJSONString
(
tSampleLaboratorysheet
));
return
R
.
failed
(
"添加失败"
);
}
}
}
acquisition-business/src/main/java/cn/wise/sc/acquisition/business/service/impl/TSampleListServiceImpl.java
View file @
e7ff4f1e
...
@@ -2,9 +2,11 @@ package cn.wise.sc.acquisition.business.service.impl;
...
@@ -2,9 +2,11 @@ package cn.wise.sc.acquisition.business.service.impl;
import
cn.wise.sc.acquisition.business.constant.Rcode
;
import
cn.wise.sc.acquisition.business.constant.Rcode
;
import
cn.wise.sc.acquisition.business.entity.TSampleList
;
import
cn.wise.sc.acquisition.business.entity.TSampleList
;
import
cn.wise.sc.acquisition.business.enumation.ProjectEnum
;
import
cn.wise.sc.acquisition.business.mapper.TSampleListMapper
;
import
cn.wise.sc.acquisition.business.mapper.TSampleListMapper
;
import
cn.wise.sc.acquisition.business.model.query.TSampleListQuery
;
import
cn.wise.sc.acquisition.business.model.query.TSampleListQuery
;
import
cn.wise.sc.acquisition.business.service.ITSampleListService
;
import
cn.wise.sc.acquisition.business.service.ITSampleListService
;
import
cn.wise.sc.acquisition.business.util.ImageUtil
;
import
cn.wise.sc.acquisition.business.wrapper.page.Query
;
import
cn.wise.sc.acquisition.business.wrapper.page.Query
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
...
@@ -16,9 +18,10 @@ import org.apache.commons.lang3.StringUtils;
...
@@ -16,9 +18,10 @@ import org.apache.commons.lang3.StringUtils;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletResponse
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.Optional
;
/**
/**
...
@@ -39,11 +42,15 @@ public class TSampleListServiceImpl extends ServiceImpl<TSampleListMapper, TSamp
...
@@ -39,11 +42,15 @@ public class TSampleListServiceImpl extends ServiceImpl<TSampleListMapper, TSamp
//参数校验
//参数校验
//分页
//分页
Page
<
TSampleList
>
page
=
new
Page
<>(
query
.
getPageNum
(),
query
.
getPageSize
());
Page
<
TSampleList
>
page
=
new
Page
<>(
query
.
getPageNum
(),
query
.
getPageSize
());
//条件封装
//条件封装
因为图片字节太长,排除QR_CODE,RECORD_CODE
QueryWrapper
<
TSampleList
>
queryWrapper
=
new
QueryWrapper
<>();
QueryWrapper
<
TSampleList
>
queryWrapper
=
new
QueryWrapper
<>();
queryWrapper
.
like
(
StringUtils
.
isNotBlank
(
tSampleListQuery
.
getSearch
()),
"Yh"
,
tSampleListQuery
.
getSearch
())
queryWrapper
.
select
(
TSampleList
.
class
,
info
->
!
info
.
getColumn
().
equals
(
ProjectEnum
.
ImageType
.
QR_CODE
.
getLabel
())
&&
!
info
.
getColumn
().
equals
(
ProjectEnum
.
ImageType
.
RECORD_CODE
.
getLabel
()))
.
like
(
StringUtils
.
isNotBlank
(
tSampleListQuery
.
getSearch
()),
ProjectEnum
.
TSampleListType
.
YH
.
getLabel
(),
tSampleListQuery
.
getSearch
())
.
or
()
.
or
()
.
like
(
StringUtils
.
isNotBlank
(
tSampleListQuery
.
getSearch
()),
"HolesID"
,
tSampleListQuery
.
getSearch
());
.
like
(
StringUtils
.
isNotBlank
(
tSampleListQuery
.
getSearch
()),
ProjectEnum
.
TSampleListType
.
HOLES_ID
.
getLabel
()
,
tSampleListQuery
.
getSearch
());
//查询
//查询
Page
<
TSampleList
>
tSampleListPage
=
baseMapper
.
selectPage
(
page
,
queryWrapper
);
Page
<
TSampleList
>
tSampleListPage
=
baseMapper
.
selectPage
(
page
,
queryWrapper
);
return
R
.
ok
(
tSampleListPage
);
return
R
.
ok
(
tSampleListPage
);
...
@@ -52,23 +59,34 @@ public class TSampleListServiceImpl extends ServiceImpl<TSampleListMapper, TSamp
...
@@ -52,23 +59,34 @@ public class TSampleListServiceImpl extends ServiceImpl<TSampleListMapper, TSamp
@Override
@Override
@Transactional
@Transactional
public
R
updateByHolesID
(
TSampleListQuery
tSampleListQuery
)
{
public
R
getByYh
(
TSampleListQuery
query
)
{
log
.
info
(
JSON
.
toJSONString
(
tSampleListQuery
));
log
.
info
(
JSON
.
toJSONString
(
query
));
//参数校验
Rcode
.
NOT_PARAM
.
assertNotEmpty
(
query
.
getYh
());
//查询并且返回
return
R
.
ok
(
baseMapper
.
selectById
(
query
.
getYh
()));
}
@Override
@Transactional
public
R
updateByHolesID
(
TSampleListQuery
query
)
{
log
.
info
(
JSON
.
toJSONString
(
query
));
//参数校验
//参数校验
Rcode
.
NOT_PARAM
.
assertNot
Null
(
tSampleListQuery
.
getHolesID
());
Rcode
.
NOT_PARAM
.
assertNot
Empty
(
query
.
getYh
());
//条件封装
//条件封装
TSampleList
tSampleList
=
new
TSampleList
();
TSampleList
tSampleList
=
new
TSampleList
();
BeanUtils
.
copyProperties
(
tSampleListQ
uery
,
tSampleList
);
BeanUtils
.
copyProperties
(
q
uery
,
tSampleList
);
QueryWrapper
<
TSampleList
>
queryWrapper
=
new
QueryWrapper
<>();
QueryWrapper
<
TSampleList
>
queryWrapper
=
new
QueryWrapper
<>();
queryWrapper
.
eq
(
"HolesID"
,
tSampleListQuery
.
getHolesID
());
queryWrapper
.
eq
(
ProjectEnum
.
TSampleListType
.
YH
.
getLabel
(),
query
.
getYh
());
//修改
//修改
int
update
=
baseMapper
.
update
(
tSampleList
,
queryWrapper
);
int
update
=
baseMapper
.
update
(
tSampleList
,
queryWrapper
);
if
(
update
>
0
)
{
if
(
update
>
0
)
{
return
R
.
ok
(
"修改成功"
);
return
R
.
ok
(
"修改成功"
);
}
else
{
}
else
{
log
.
info
(
JSON
.
toJSONString
(
tSampleList
));
log
.
info
(
JSON
.
toJSONString
(
tSampleList
));
return
R
.
ok
(
"修改失败"
);
return
R
.
failed
(
"修改失败"
);
}
}
}
}
...
@@ -76,34 +94,32 @@ public class TSampleListServiceImpl extends ServiceImpl<TSampleListMapper, TSamp
...
@@ -76,34 +94,32 @@ public class TSampleListServiceImpl extends ServiceImpl<TSampleListMapper, TSamp
@Override
@Override
@Transactional
@Transactional
public
R
insertSampleList
(
TSampleListQuery
tSampleListQ
uery
)
{
public
R
insertSampleList
(
TSampleListQuery
q
uery
)
{
log
.
info
(
JSON
.
toJSONString
(
tSampleListQ
uery
));
log
.
info
(
JSON
.
toJSONString
(
q
uery
));
//参数校验
//参数校验
Rcode
.
NOT_PARAM
.
assertNotNull
(
tSampleListQuery
.
getHolesID
());
Rcode
.
NOT_PARAM
.
assertNotEmpty
(
query
.
getHolesID
());
Rcode
.
NOT_PARAM
.
assertNotNull
(
tSampleListQuery
.
getYh
());
Rcode
.
NOT_PARAM
.
assertNotEmpty
(
query
.
getYh
());
Rcode
.
NOT_PARAM
.
assertNotNull
(
tSampleListQuery
.
getStart
());
Rcode
.
NOT_PARAM
.
assertNotEmpty
(
query
.
getStart
());
Rcode
.
NOT_PARAM
.
assertNotNull
(
tSampleListQuery
.
getEndTo
());
Rcode
.
NOT_PARAM
.
assertNotEmpty
(
query
.
getEndTo
());
Rcode
.
NOT_PARAM
.
assertNotNull
(
tSampleListQuery
.
getRecordName
());
Rcode
.
NOT_PARAM
.
assertNotEmpty
(
query
.
getRecordName
());
Rcode
.
NOT_PARAM
.
assertNotNull
(
tSampleListQuery
.
getRecordCode
());
Rcode
.
NOT_PARAM
.
assertNotEmpty
(
query
.
getBz
());
Rcode
.
NOT_PARAM
.
assertNotNull
(
tSampleListQuery
.
getBz
());
Rcode
.
NOT_PARAM
.
assertNotEmpty
(
query
.
getSyr
());
Rcode
.
NOT_PARAM
.
assertNotNull
(
tSampleListQuery
.
getSyr
());
Rcode
.
NOT_PARAM
.
assertNotNull
(
tSampleListQuery
.
getQRCode
());
//条件封装
//条件封装
TSampleList
tSampleList
=
new
TSampleList
();
TSampleList
tSampleList
=
new
TSampleList
();
BeanUtils
.
copyProperties
(
tSampleListQ
uery
,
tSampleList
);
BeanUtils
.
copyProperties
(
q
uery
,
tSampleList
);
//若时间送样为空,创建当前时间
//若时间送样为空,创建当前时间
Optional
<
LocalDateTime
>
ofNullable
=
Optional
.
ofNullable
(
tSampleList
.
getSyrq
());
Optional
<
LocalDateTime
>
ofNullable
=
Optional
.
ofNullable
(
tSampleList
.
getSyrq
());
if
(!
ofNullable
.
isPresent
())
{
if
(!
ofNullable
.
isPresent
())
{
tSampleList
.
setSyrq
(
LocalDateTime
.
now
());
tSampleList
.
setSyrq
(
LocalDateTime
.
now
());
}
}
//
修改
//
增加
log
.
info
(
JSON
.
toJSONString
(
tSampleList
));
log
.
info
(
JSON
.
toJSONString
(
tSampleList
));
int
insert
=
baseMapper
.
insert
(
tSampleList
);
int
insert
=
baseMapper
.
insert
(
tSampleList
);
if
(
insert
>
0
)
{
if
(
insert
>
0
)
{
return
R
.
ok
(
"增加成功"
);
return
R
.
ok
(
"增加成功"
);
}
else
{
}
else
{
log
.
info
(
JSON
.
toJSONString
(
tSampleList
));
log
.
info
(
JSON
.
toJSONString
(
tSampleList
));
return
R
.
ok
(
"增加失败"
);
return
R
.
failed
(
"增加失败"
);
}
}
}
}
...
@@ -114,14 +130,90 @@ public class TSampleListServiceImpl extends ServiceImpl<TSampleListMapper, TSamp
...
@@ -114,14 +130,90 @@ public class TSampleListServiceImpl extends ServiceImpl<TSampleListMapper, TSamp
public
R
deleteByHolesID
(
TSampleListQuery
tSampleListQuery
)
{
public
R
deleteByHolesID
(
TSampleListQuery
tSampleListQuery
)
{
log
.
info
(
JSON
.
toJSONString
(
tSampleListQuery
));
log
.
info
(
JSON
.
toJSONString
(
tSampleListQuery
));
//参数校验
//参数校验
Rcode
.
NOT_PARAM
.
assertNot
Null
(
tSampleListQuery
.
getHolesID
());
Rcode
.
NOT_PARAM
.
assertNot
Empty
(
tSampleListQuery
.
getYh
());
//删除
//删除
int
delete
=
baseMapper
.
delete
(
new
QueryWrapper
<
TSampleList
>().
eq
(
"HolesID"
,
tSampleListQuery
.
getHolesID
()));
int
delete
=
baseMapper
.
delete
(
new
QueryWrapper
<
TSampleList
>().
eq
(
ProjectEnum
.
TSampleListType
.
YH
.
getLabel
(),
tSampleListQuery
.
getYh
()));
if
(
delete
>
0
)
{
if
(
delete
>
0
)
{
return
R
.
ok
(
"删除成功"
);
return
R
.
ok
(
"删除成功"
);
}
else
{
}
else
{
return
R
.
ok
(
"删除失败"
);
return
R
.
failed
(
"删除失败"
);
}
}
@Override
@Transactional
public
R
saveImage
(
TSampleListQuery
query
,
MultipartFile
file
)
{
log
.
info
(
JSON
.
toJSONString
(
query
));
//参加校验
Rcode
.
NOT_PARAM
.
assertNotNull
(
query
);
Rcode
.
NOT_PARAM
.
assertNotEmpty
(
query
.
getYh
());
Rcode
.
NOT_PARAM
.
assertNotNull
(
file
);
Rcode
.
NOT_PARAM
.
assertNotNull
(
query
.
getImageType
());
//封装
TSampleList
tSampleList
=
new
TSampleList
();
BeanUtils
.
copyProperties
(
query
,
tSampleList
);
//转化图片
setImage
(
query
,
tSampleList
,
file
);
//保存
int
update
=
baseMapper
.
updateById
(
tSampleList
);
if
(
update
>
0
)
{
return
R
.
ok
(
"保存成功"
);
}
else
{
return
R
.
failed
(
"保存失败"
);
}
}
}
}
/**
* 私有方法,根据类型保存并转化文件为图片 需要请求参数ImageType 保存的实体TSampleList 以及file
*/
private
void
setImage
(
TSampleListQuery
query
,
TSampleList
tSampleList
,
MultipartFile
file
)
{
//判断保存二维码还是记录形式
Optional
<
Integer
>
ofNullable
=
Optional
.
ofNullable
(
query
.
getImageType
());
ofNullable
.
ifPresent
(
e
->
{
if
(
ProjectEnum
.
ImageType
.
getLabel
(
query
.
getImageType
()).
equals
(
ProjectEnum
.
ImageType
.
RECORD_CODE
.
getLabel
()))
{
tSampleList
.
setRecordCode
(
ImageUtil
.
transformByte
(
file
));
}
if
(
ProjectEnum
.
ImageType
.
getLabel
(
query
.
getImageType
()).
equals
(
ProjectEnum
.
ImageType
.
QR_CODE
.
getLabel
()))
{
tSampleList
.
setQRCode
(
ImageUtil
.
transformByte
(
file
));
}
});
}
/**
* 获取图片二维码
*
* @param query
* @param response
*/
@Override
@Transactional
public
R
getImage
(
TSampleListQuery
query
,
final
HttpServletResponse
response
)
{
log
.
info
(
JSON
.
toJSONString
(
query
));
//参加校验
Rcode
.
NOT_PARAM
.
assertNotNull
(
query
);
Rcode
.
NOT_PARAM
.
assertNotEmpty
(
query
.
getYh
());
Rcode
.
NOT_PARAM
.
assertNotNull
(
query
.
getImageType
());
TSampleList
tSampleList
=
baseMapper
.
selectById
(
query
.
getYh
());
//判断获取二维码还是记录形式
Optional
<
Integer
>
ofNullable
=
Optional
.
ofNullable
(
query
.
getImageType
());
ofNullable
.
ifPresent
(
e
->
{
byte
[]
data
=
null
;
if
(
ProjectEnum
.
ImageType
.
getLabel
(
query
.
getImageType
()).
equals
(
ProjectEnum
.
ImageType
.
RECORD_CODE
.
getLabel
()))
{
data
=
tSampleList
.
getRecordCode
();
}
if
(
ProjectEnum
.
ImageType
.
getLabel
(
query
.
getImageType
()).
equals
(
ProjectEnum
.
ImageType
.
QR_CODE
.
getLabel
()))
{
data
=
tSampleList
.
getQRCode
();
}
if
(
data
!=
null
)
{
//下载图片
ImageUtil
.
transformImage
(
data
,
response
);
}
});
return
R
.
failed
(
"该条数据没有图片"
);
}
}
}
acquisition-business/src/main/java/cn/wise/sc/acquisition/business/util/ImageUtil.java
0 → 100644
View file @
e7ff4f1e
package
cn
.
wise
.
sc
.
acquisition
.
business
.
util
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.TypeReference
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.*
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* Author renchao
* 文件上传下载转化工具类
*/
public
class
ImageUtil
{
/**
* 将文件转化为字节
*/
public
static
byte
[]
transformByte
(
MultipartFile
file
)
{
if
(
file
==
null
)
throw
new
RuntimeException
(
"文件为空"
);
try
{
byte
[]
pictureData
=
new
byte
[(
int
)
file
.
getSize
()];
InputStream
inputStream
=
file
.
getInputStream
();
inputStream
.
read
(
pictureData
);
inputStream
.
close
();
return
pictureData
;
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
throw
new
RuntimeException
(
"图片转化失败"
);
}
}
/**
* 将字节转化为文件,并下载
*/
public
static
void
transformImage
(
byte
[]
data
,
final
HttpServletResponse
response
)
{
if
(
data
.
length
==
0
)
throw
new
RuntimeException
(
"图片数据为空"
);
response
.
setContentType
(
"image/jpeg"
);
response
.
setCharacterEncoding
(
"UTF-8"
);
OutputStream
outputSream
;
try
{
outputSream
=
response
.
getOutputStream
();
outputSream
.
write
(
data
);
outputSream
.
flush
();
outputSream
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
throw
new
RuntimeException
(
"图片下载失败"
);
}
}
/**
* 将多个文件转化为字节
*/
public
static
byte
[]
transformByteMore
(
MultipartFile
[]
files
)
{
if
(
files
==
null
||
files
.
length
==
0
)
throw
new
RuntimeException
(
"文件为空"
);
try
{
//创建字节流数组
List
<
byte
[]>
bytes
=
new
ArrayList
<>();
InputStream
inputStream
=
null
;
//循环读取文件
for
(
MultipartFile
file
:
files
)
{
byte
[]
pictureData
=
new
byte
[(
int
)
file
.
getSize
()];
inputStream
=
file
.
getInputStream
();
inputStream
.
read
(
pictureData
);
bytes
.
add
(
pictureData
);
}
//关流
if
(
inputStream
!=
null
)
{
inputStream
.
close
();
}
//将数组转化为字节
byte
[]
data
=
JSON
.
toJSONString
(
bytes
,
true
).
getBytes
();
return
data
;
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
throw
new
RuntimeException
(
"图片转化失败"
);
}
}
/**
* 将字节转化为文件,并下载
*/
public
static
void
transformImageMore
(
byte
[]
data
,
final
HttpServletResponse
response
)
{
if
(
data
==
null
||
data
.
length
==
0
)
throw
new
RuntimeException
(
"图片数据为空"
);
response
.
setContentType
(
"image/jpeg"
);
response
.
setCharacterEncoding
(
"UTF-8"
);
OutputStream
outputSream
=
null
;
try
{
List
<
byte
[]>
bytes
=
JSON
.
parseObject
(
new
String
(
data
),
new
TypeReference
<
List
<
byte
[]>>()
{});
outputSream
=
response
.
getOutputStream
();
for
(
byte
[]
picture:
bytes
){
outputSream
.
write
(
picture
);
}
outputSream
.
flush
();
if
(
outputSream
!=
null
){
outputSream
.
close
();
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
throw
new
RuntimeException
(
"图片下载失败"
);
}
}
}
acquisition-business/target/classes/cn/wise/sc/acquisition/business/mapper/TSampleLaboratorysheetMapper.xml
0 → 100644
View file @
e7ff4f1e
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"cn.wise.sc.acquisition.business.mapper.TSampleLaboratorysheetMapper"
>
</mapper>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment