Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
patzn-cloud-service-hmhj
Overview
Overview
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
wangweidong
patzn-cloud-service-hmhj
Commits
6a29d50b
Commit
6a29d50b
authored
Jul 20, 2021
by
ghxdhr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
批量导入合同
parent
6e4eec01
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
119 additions
and
8 deletions
+119
-8
ContractSampleController.java
...ervice/lims/hmhj/controller/ContractSampleController.java
+8
-0
IContractSampleService.java
...oud/service/lims/hmhj/service/IContractSampleService.java
+3
-0
ContractSampleServiceImpl.java
...ice/lims/hmhj/service/impl/ContractSampleServiceImpl.java
+108
-8
No files found.
src/main/java/com/patzn/cloud/service/lims/hmhj/controller/ContractSampleController.java
View file @
6a29d50b
...
...
@@ -16,6 +16,8 @@ import io.swagger.annotations.Api;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
...
...
@@ -595,4 +597,10 @@ public class ContractSampleController extends ServiceController {
return
success
(
contractSampleService
.
addJudgementType
(
ids
,
judgement
,
getAccount
()));
}
@ApiOperation
(
"批量导入报检单"
)
@PostMapping
(
"/batch_import"
)
public
RestResult
<
Boolean
>
batchImport
(
@RequestPart
MultipartFile
file
)
{
return
success
(
contractSampleService
.
batchImport
(
file
,
getAccount
()));
}
}
src/main/java/com/patzn/cloud/service/lims/hmhj/service/IContractSampleService.java
View file @
6a29d50b
...
...
@@ -7,6 +7,7 @@ import com.patzn.cloud.service.hmhj.dto.ContractSampleDTO;
import
com.patzn.cloud.service.hmhj.dto.ContractSampleVODTO
;
import
com.patzn.cloud.service.hmhj.entity.ContractSample
;
import
com.patzn.cloud.service.hmhj.vo.ContractSampleVO
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.List
;
...
...
@@ -71,4 +72,6 @@ public interface IContractSampleService extends IBaseService<ContractSample> {
Page
<
ContractSample
>
pageOutReg
(
Page
<
ContractSample
>
page
,
ContractSample
contractSample
);
boolean
isOutEntrustData
(
Long
contractSampleId
);
boolean
batchImport
(
MultipartFile
file
,
Account
account
);
}
src/main/java/com/patzn/cloud/service/lims/hmhj/service/impl/ContractSampleServiceImpl.java
View file @
6a29d50b
package
com
.
patzn
.
cloud
.
service
.
lims
.
hmhj
.
service
.
impl
;
import
com.baomidou.mybatisplus.mapper.Condition
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.baomidou.mybatisplus.mapper.Wrapper
;
import
com.baomidou.mybatisplus.plugins.Page
;
import
com.baomidou.mybatisplus.toolkit.CollectionUtils
;
import
com.patzn.cloud.commons.api.RestAssert
;
import
com.patzn.cloud.commons.controller.Account
;
import
com.patzn.cloud.commons.service.impl.BaseServiceImpl
;
import
com.patzn.cloud.commons.toolkit.DateUtils
;
import
com.patzn.cloud.service.hmhj.dto.ContractSampleDTO
;
import
com.patzn.cloud.service.hmhj.dto.ContractSampleVODTO
;
import
com.patzn.cloud.service.hmhj.entity.ContractSample
;
...
...
@@ -15,20 +20,26 @@ import com.patzn.cloud.service.hmhj.enums.EntrustSampleStatusEnum;
import
com.patzn.cloud.service.hmhj.vo.ContractSampleVO
;
import
com.patzn.cloud.service.lims.common.service.ILmsMsgService
;
import
com.patzn.cloud.service.lims.hmhj.mapper.ContractSampleMapper
;
import
com.patzn.cloud.service.lims.hmhj.service.*
;
import
com.patzn.cloud.commons.service.impl.BaseServiceImpl
;
import
com.patzn.cloud.service.lims.hmhj.service.IContractSampleItemService
;
import
com.patzn.cloud.service.lims.hmhj.service.IContractSampleRecordService
;
import
com.patzn.cloud.service.lims.hmhj.service.IContractSampleService
;
import
com.patzn.cloud.service.lims.hmhj.service.IEntrustSampleService
;
import
org.apache.commons.lang3.ArrayUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.poi.xssf.usermodel.XSSFRow
;
import
org.apache.poi.xssf.usermodel.XSSFSheet
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.jfree.data.DataUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.baomidou.mybatisplus.mapper.Wrapper
;
import
com.baomidou.mybatisplus.plugins.Page
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -425,5 +436,94 @@ public class ContractSampleServiceImpl extends BaseServiceImpl<ContractSampleMap
return
null
!=
contractSample
&&
null
!=
contractSample
.
getType
()
&&
1
==
contractSample
.
getType
().
intValue
()
?
true
:
false
;
}
@Override
public
boolean
batchImport
(
MultipartFile
file
,
Account
account
)
{
XSSFWorkbook
workbook
=
null
;
try
{
InputStream
is
=
file
.
getInputStream
();
workbook
=
new
XSSFWorkbook
(
is
);
}
catch
(
IOException
e
)
{
RestAssert
.
fail
(
"文件读取失败"
);
}
int
sheetCount
=
workbook
.
getNumberOfSheets
();
for
(
int
i
=
0
;
i
<
sheetCount
;
i
++)
{
XSSFSheet
sheet
=
workbook
.
getSheetAt
(
i
);
if
(
null
==
sheet
)
{
continue
;
}
// 固定开始行和开始列
int
beginRowNum
=
5
,
beginColumnNum
=
1
;
// 最后一行
int
lastRowNum
=
sheet
.
getLastRowNum
();
if
(
lastRowNum
<
beginRowNum
)
{
RestAssert
.
fail
(
"导入文件中没有有效数据"
);
}
short
lastCellNum
=
sheet
.
getRow
(
5
).
getLastCellNum
();
ArrayList
<
ContractSample
>
contractSamples
=
new
ArrayList
<>();
for
(
int
j
=
5
;
j
<=
lastRowNum
;
j
++)
{
XSSFRow
row
=
sheet
.
getRow
(
j
);
ContractSample
sample
=
new
ContractSample
();
for
(
int
k
=
beginColumnNum
;
k
<
lastCellNum
;
k
++)
{
if
(
sheet
.
getRow
(
beginRowNum
-
1
).
getCell
(
k
).
getStringCellValue
().
equals
(
"合同编号"
))
{
sample
.
setCode
(
row
.
getCell
(
k
).
getStringCellValue
());
continue
;
}
if
(
sheet
.
getRow
(
beginRowNum
-
1
).
getCell
(
k
).
getStringCellValue
().
equals
(
"订单号"
))
{
sample
.
setOrderNo
(
row
.
getCell
(
k
).
getStringCellValue
());
continue
;
}
if
(
sheet
.
getRow
(
beginRowNum
-
1
).
getCell
(
k
).
getStringCellValue
().
equals
(
"供货单位"
))
{
sample
.
setSupplier
(
row
.
getCell
(
k
).
getStringCellValue
());
continue
;
}
if
(
sheet
.
getRow
(
beginRowNum
-
1
).
getCell
(
k
).
getStringCellValue
().
equals
(
"物资编码"
))
{
sample
.
setMaterialCode
(
row
.
getCell
(
k
).
getStringCellValue
());
continue
;
}
if
(
sheet
.
getRow
(
beginRowNum
-
1
).
getCell
(
k
).
getStringCellValue
().
equals
(
"物资名称"
))
{
sample
.
setMaterialName
(
row
.
getCell
(
k
).
getStringCellValue
());
continue
;
}
if
(
sheet
.
getRow
(
beginRowNum
-
1
).
getCell
(
k
).
getStringCellValue
().
equals
(
"规格型号"
))
{
sample
.
setSpec
(
row
.
getCell
(
k
).
getStringCellValue
());
continue
;
}
if
(
sheet
.
getRow
(
beginRowNum
-
1
).
getCell
(
k
).
getStringCellValue
().
equals
(
"单位"
))
{
sample
.
setUnit
(
row
.
getCell
(
k
).
getStringCellValue
());
continue
;
}
if
(
sheet
.
getRow
(
beginRowNum
-
1
).
getCell
(
k
).
getStringCellValue
().
equals
(
"数量"
))
{
sample
.
setArrivalQuantity
(((
Double
)
row
.
getCell
(
k
).
getNumericCellValue
()).
toString
());
continue
;
}
if
(
sheet
.
getRow
(
beginRowNum
-
1
).
getCell
(
k
).
getStringCellValue
().
equals
(
"货位"
))
{
sample
.
setDetailPlace
(
row
.
getCell
(
k
).
getStringCellValue
());
continue
;
}
if
(
sheet
.
getRow
(
beginRowNum
-
1
).
getCell
(
k
).
getStringCellValue
().
equals
(
"到货时间"
))
{
String
time
=
row
.
getCell
(
k
).
getStringCellValue
();
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy.MM.dd"
);
Date
date
=
null
;
try
{
date
=
dateFormat
.
parse
(
time
);
}
catch
(
ParseException
e
)
{
RestAssert
.
fail
(
"解析时间出错"
);
}
sample
.
setArrivalTime
(
date
);
continue
;
}
if
(
sheet
.
getRow
(
beginRowNum
-
1
).
getCell
(
k
).
getStringCellValue
().
equals
(
"采购员"
))
{
sample
.
setBuyer
(
row
.
getCell
(
k
).
getStringCellValue
());
continue
;
}
}
contractSamples
.
add
(
sample
);
}
this
.
saveBatch
(
contractSamples
);
}
return
true
;
}
}
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