Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dsk-operate-sys-cscec
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
fulixin
dsk-operate-sys-cscec
Commits
e0c88ce3
Commit
e0c88ce3
authored
Feb 06, 2024
by
lcl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
73a0c9d3
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
429 additions
and
131 deletions
+429
-131
ExcelUtils.java
...common/src/main/java/com/dsk/common/excel/ExcelUtils.java
+141
-4
CbQuantitySummaryController.java
...com/dsk/cscec/controller/CbQuantitySummaryController.java
+55
-7
CbQuantitySummary.java
...src/main/java/com/dsk/cscec/domain/CbQuantitySummary.java
+20
-1
CbProjectBaseBo.java
...rc/main/java/com/dsk/cscec/domain/bo/CbProjectBaseBo.java
+22
-0
ProjectCostMeasureImportListener.java
.../dsk/cscec/listener/ProjectCostMeasureImportListener.java
+118
-118
CbQuantitySummaryMapper.java
...in/java/com/dsk/cscec/mapper/CbQuantitySummaryMapper.java
+11
-0
ICbQuantitySummaryService.java
...java/com/dsk/cscec/service/ICbQuantitySummaryService.java
+8
-0
CbQuantitySummaryServiceImpl.java
.../dsk/cscec/service/impl/CbQuantitySummaryServiceImpl.java
+30
-1
CbQuantitySummaryMapper.xml
...c/main/resources/mapper/cscec/CbQuantitySummaryMapper.xml
+24
-0
No files found.
dsk-common/src/main/java/com/dsk/common/excel/ExcelUtils.java
View file @
e0c88ce3
...
@@ -3,6 +3,7 @@ package com.dsk.common.excel;
...
@@ -3,6 +3,7 @@ package com.dsk.common.excel;
import
cn.hutool.core.convert.Convert
;
import
cn.hutool.core.convert.Convert
;
import
com.dsk.common.annotation.Excel
;
import
com.dsk.common.annotation.Excel
;
import
com.dsk.common.core.domain.AjaxResult
;
import
com.dsk.common.core.domain.AjaxResult
;
import
com.dsk.common.exception.ServiceException
;
import
com.dsk.common.exception.UtilException
;
import
com.dsk.common.exception.UtilException
;
import
com.dsk.common.utils.DateUtils
;
import
com.dsk.common.utils.DateUtils
;
import
com.dsk.common.utils.DictUtils
;
import
com.dsk.common.utils.DictUtils
;
...
@@ -40,6 +41,8 @@ import java.time.LocalDate;
...
@@ -40,6 +41,8 @@ import java.time.LocalDate;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
java.util.stream.IntStream
;
import
java.util.stream.Stream
;
/**
/**
* Excel相关处理
* Excel相关处理
...
@@ -207,6 +210,7 @@ public class ExcelUtils<T> {
...
@@ -207,6 +210,7 @@ public class ExcelUtils<T> {
sheet
.
addMergedRegion
(
new
CellRangeAddress
(
titleRow
.
getRowNum
(),
titleRow
.
getRowNum
(),
titleRow
.
getRowNum
(),
titleLastCol
));
sheet
.
addMergedRegion
(
new
CellRangeAddress
(
titleRow
.
getRowNum
(),
titleRow
.
getRowNum
(),
titleRow
.
getRowNum
(),
titleLastCol
));
}
}
}
}
public
void
createExportMessage
()
{
public
void
createExportMessage
()
{
if
(
dateStatus
)
{
if
(
dateStatus
)
{
subMergedFirstRowNum
++;
subMergedFirstRowNum
++;
...
@@ -226,6 +230,7 @@ public class ExcelUtils<T> {
...
@@ -226,6 +230,7 @@ public class ExcelUtils<T> {
rownum
++;
rownum
++;
}
}
}
}
public
void
createExportDate
()
{
public
void
createExportDate
()
{
if
(
dateStatus
)
{
if
(
dateStatus
)
{
subMergedFirstRowNum
++;
subMergedFirstRowNum
++;
...
@@ -330,8 +335,8 @@ public class ExcelUtils<T> {
...
@@ -330,8 +335,8 @@ public class ExcelUtils<T> {
exportExcel
(
response
);
exportExcel
(
response
);
}
}
public
ByteArrayOutputStream
exportExcel
(
List
<
T
>
list
,
String
sheetName
,
String
title
,
boolean
dateStatus
)
{
public
ByteArrayOutputStream
exportExcel
(
List
<
T
>
list
,
String
sheetName
,
String
title
,
boolean
dateStatus
)
{
ByteArrayOutputStream
ba
=
new
ByteArrayOutputStream
();
ByteArrayOutputStream
ba
=
new
ByteArrayOutputStream
();
this
.
init
(
list
,
sheetName
,
title
,
Excel
.
Type
.
EXPORT
,
dateStatus
);
this
.
init
(
list
,
sheetName
,
title
,
Excel
.
Type
.
EXPORT
,
dateStatus
);
try
{
try
{
writeSheet
();
writeSheet
();
...
@@ -356,11 +361,11 @@ public class ExcelUtils<T> {
...
@@ -356,11 +361,11 @@ public class ExcelUtils<T> {
* @param dateStatus 是否添加导出时间
* @param dateStatus 是否添加导出时间
* @return
* @return
*/
*/
public
String
localInit
(
List
<
T
>
list
,
String
sheetName
,
String
title
,
boolean
dateStatus
)
{
public
String
localInit
(
List
<
T
>
list
,
String
sheetName
,
String
title
,
boolean
dateStatus
)
{
String
fileName
=
title
+
"-"
+
System
.
currentTimeMillis
()
+
".xlsx"
;
String
fileName
=
title
+
"-"
+
System
.
currentTimeMillis
()
+
".xlsx"
;
this
.
init
(
list
,
sheetName
,
title
,
Excel
.
Type
.
EXPORT
,
dateStatus
);
this
.
init
(
list
,
sheetName
,
title
,
Excel
.
Type
.
EXPORT
,
dateStatus
);
writeSheet
();
writeSheet
();
try
(
FileOutputStream
fileOutputStream
=
new
FileOutputStream
(
FILE_PATH
.
concat
(
fileName
))){
try
(
FileOutputStream
fileOutputStream
=
new
FileOutputStream
(
FILE_PATH
.
concat
(
fileName
)))
{
wb
.
write
(
fileOutputStream
);
wb
.
write
(
fileOutputStream
);
return
fileName
;
return
fileName
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -1493,4 +1498,136 @@ public class ExcelUtils<T> {
...
@@ -1493,4 +1498,136 @@ public class ExcelUtils<T> {
return
list
;
return
list
;
}
}
/**
* 对excel表单指定表格索引名转换成list
*
* @param titleNum 标题占用行数
* @param is 输入流
* @param keyName 主要键名称(NULL则不判断)
* @return 转换后集合
*/
public
List
<
T
>
importExcelAllSheet
(
InputStream
is
,
int
titleNum
,
String
keyName
)
throws
Exception
{
this
.
type
=
Excel
.
Type
.
IMPORT
;
this
.
wb
=
WorkbookFactory
.
create
(
is
);
List
<
T
>
list
=
new
ArrayList
<
T
>();
int
sheetCount
=
wb
.
getNumberOfSheets
();
System
.
out
.
println
(
"工作表个数为:"
+
sheetCount
);
IntStream
.
rangeClosed
(
0
,
sheetCount
-
1
).
parallel
().
forEach
(
sheetNum
->
{
Sheet
sheet
=
wb
.
getSheetAt
(
sheetNum
);
if
(
sheet
==
null
)
{
throw
new
ServiceException
(
sheet
.
getSheetName
()
+
"为空表!"
);
}
boolean
isXSSFWorkbook
=
!(
wb
instanceof
HSSFWorkbook
);
Map
<
String
,
PictureData
>
pictures
;
if
(
isXSSFWorkbook
)
{
pictures
=
getSheetPictures07
((
XSSFSheet
)
sheet
,
(
XSSFWorkbook
)
wb
);
}
else
{
pictures
=
getSheetPictures03
((
HSSFSheet
)
sheet
,
(
HSSFWorkbook
)
wb
);
}
// 获取最后一个非空行的行下标,比如总行数为n,则返回的为n-1
int
rows
=
sheet
.
getLastRowNum
();
if
(
rows
>
0
)
{
// 定义一个map用于存放excel列的序号和field.
Map
<
String
,
Integer
>
cellMap
=
new
HashMap
<
String
,
Integer
>();
// 获取表头
Row
heard
=
sheet
.
getRow
(
titleNum
);
for
(
int
i
=
0
;
i
<
heard
.
getPhysicalNumberOfCells
();
i
++)
{
Cell
cell
=
heard
.
getCell
(
i
);
if
(
ObjectUtils
.
isEmpty
(
cell
))
{
cellMap
.
put
(
null
,
i
);
}
else
{
String
value
=
this
.
getCellValue
(
heard
,
i
).
toString
();
cellMap
.
put
(
value
,
i
);
}
}
// 有数据时才处理 得到类的所有field.
List
<
Object
[]>
fields
=
this
.
getFields
();
Map
<
Integer
,
Object
[]>
fieldsMap
=
new
HashMap
<
Integer
,
Object
[]>();
for
(
Object
[]
objects
:
fields
)
{
Excel
attr
=
(
Excel
)
objects
[
1
];
Integer
column
=
cellMap
.
get
(
attr
.
name
());
if
(
column
!=
null
)
{
fieldsMap
.
put
(
column
,
objects
);
}
}
try
{
for
(
int
i
=
titleNum
+
1
;
i
<=
rows
;
i
++)
{
// 从第2行开始取数据,默认第一行是表头.
Row
row
=
sheet
.
getRow
(
i
);
// 判断当前行是否是空行
if
(
isRowEmpty
(
row
))
{
continue
;
}
T
entity
=
null
;
for
(
Map
.
Entry
<
Integer
,
Object
[]>
entry
:
fieldsMap
.
entrySet
())
{
Object
val
=
this
.
getCellValue
(
row
,
entry
.
getKey
());
// 如果不存在实例则新建.
entity
=
(
entity
==
null
?
clazz
.
newInstance
()
:
entity
);
// 从map中得到对应列的field.
Field
field
=
(
Field
)
entry
.
getValue
()[
0
];
Excel
attr
=
(
Excel
)
entry
.
getValue
()[
1
];
// 取得类型,并根据对象类型设置值.
Class
<?>
fieldType
=
field
.
getType
();
if
(
String
.
class
==
fieldType
)
{
String
s
=
Convert
.
toStr
(
val
);
if
(
StringUtils
.
endsWith
(
s
,
".0"
))
{
val
=
StringUtils
.
substringBefore
(
s
,
".0"
);
}
else
{
String
dateFormat
=
field
.
getAnnotation
(
Excel
.
class
).
dateFormat
();
if
(
StringUtils
.
isNotEmpty
(
dateFormat
))
{
val
=
parseDateToStr
(
dateFormat
,
val
);
}
else
{
val
=
Convert
.
toStr
(
val
);
}
}
}
else
if
((
Integer
.
TYPE
==
fieldType
||
Integer
.
class
==
fieldType
)
&&
StringUtils
.
isNumeric
(
Convert
.
toStr
(
val
)))
{
val
=
Convert
.
toInt
(
val
);
}
else
if
((
Long
.
TYPE
==
fieldType
||
Long
.
class
==
fieldType
)
&&
StringUtils
.
isNumeric
(
Convert
.
toStr
(
val
)))
{
val
=
Convert
.
toLong
(
val
);
}
else
if
(
Double
.
TYPE
==
fieldType
||
Double
.
class
==
fieldType
)
{
val
=
Convert
.
toDouble
(
val
);
}
else
if
(
Float
.
TYPE
==
fieldType
||
Float
.
class
==
fieldType
)
{
val
=
Convert
.
toFloat
(
val
);
}
else
if
(
BigDecimal
.
class
==
fieldType
)
{
val
=
Convert
.
toBigDecimal
(
val
);
}
else
if
(
Date
.
class
==
fieldType
)
{
if
(
val
instanceof
String
)
{
val
=
DateUtils
.
parseDate
(
val
);
}
else
if
(
val
instanceof
Double
)
{
val
=
DateUtil
.
getJavaDate
((
Double
)
val
);
}
}
else
if
(
Boolean
.
TYPE
==
fieldType
||
Boolean
.
class
==
fieldType
)
{
val
=
Convert
.
toBool
(
val
,
false
);
}
if
(!
ObjectUtils
.
isEmpty
(
fieldType
))
{
String
propertyName
=
field
.
getName
();
if
(
StringUtils
.
isNotEmpty
(
attr
.
targetAttr
()))
{
propertyName
=
field
.
getName
()
+
"."
+
attr
.
targetAttr
();
}
else
if
(
StringUtils
.
isNotEmpty
(
attr
.
readConverterExp
()))
{
val
=
reverseByExp
(
Convert
.
toStr
(
val
),
attr
.
readConverterExp
(),
attr
.
separator
());
}
else
if
(
StringUtils
.
isNotEmpty
(
attr
.
dictType
()))
{
val
=
reverseDictByExp
(
Convert
.
toStr
(
val
),
attr
.
dictType
(),
attr
.
separator
());
}
else
if
(!
attr
.
handler
().
equals
(
ExcelHandlerAdapter
.
class
))
{
val
=
dataFormatHandlerAdapter
(
val
,
attr
);
}
ReflectUtils
.
invokeSetter
(
entity
,
propertyName
,
val
);
}
}
list
.
add
(
entity
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
});
return
list
;
}
}
}
dsk-module/dsk-biz-api/src/main/java/com/dsk/cscec/controller/CbQuantitySummaryController.java
View file @
e0c88ce3
...
@@ -2,11 +2,23 @@ package com.dsk.cscec.controller;
...
@@ -2,11 +2,23 @@ package com.dsk.cscec.controller;
import
com.dsk.common.core.controller.BaseController
;
import
com.dsk.common.core.controller.BaseController
;
import
com.dsk.common.core.domain.R
;
import
com.dsk.common.excel.ExcelUtils
;
import
com.dsk.common.exception.ServiceException
;
import
com.dsk.cscec.domain.CbQuantitySummary
;
import
com.dsk.cscec.domain.bo.CbProjectBaseBo
;
import
com.dsk.cscec.service.ICbQuantitySummaryService
;
import
com.dsk.cscec.service.ICbQuantitySummaryService
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
com.dsk.system.domain.vo.SysUserImportVo
;
import
org.springframework.web.bind.annotation.RestController
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
sun.reflect.generics.tree.Tree
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.TreeMap
;
import
java.util.stream.Collectors
;
/**
/**
* 成本-工料汇总基本表(CbQuantitySummary)表控制层
* 成本-工料汇总基本表(CbQuantitySummary)表控制层
...
@@ -15,14 +27,50 @@ import javax.annotation.Resource;
...
@@ -15,14 +27,50 @@ import javax.annotation.Resource;
* @since 2024-02-05 11:06:56
* @since 2024-02-05 11:06:56
*/
*/
@RestController
@RestController
@RequiredArgsConstructor
@RequestMapping
(
"/cb/quantity/summary"
)
@RequestMapping
(
"/cb/quantity/summary"
)
public
class
CbQuantitySummaryController
extends
BaseController
{
public
class
CbQuantitySummaryController
extends
BaseController
{
private
final
ICbQuantitySummaryService
baseService
;
/**
/**
* 服务对象
* 工料汇总科目树
* @return
*/
*/
@Resource
@GetMapping
(
value
=
"/subjectTree"
)
private
ICbQuantitySummaryService
baseService
;
public
R
<
Map
<
String
,
Object
>>
subjectTree
(
@PathVariable
CbProjectBaseBo
bo
){
return
R
.
ok
(
baseService
.
subjectTree
(
bo
));
}
/**
* 已记录月份集合
*/
@GetMapping
(
value
=
"/monthList"
)
public
R
<
List
<
String
>>
monthList
(
@PathVariable
CbProjectBaseBo
bo
){
return
R
.
ok
(
baseService
.
monthList
(
bo
));
}
/**
* 数据导入
*/
@PostMapping
(
value
=
"/importData"
)
public
R
<
Void
>
importFile
(
@RequestPart
(
"file"
)
MultipartFile
file
)
throws
Exception
{
//识别Excel内容
List
<
CbQuantitySummary
>
importList
=
new
ExcelUtils
<>(
CbQuantitySummary
.
class
).
importExcelAllSheet
(
file
.
getInputStream
(),
1
,
"cbSubjectName"
);
if
(
importList
.
isEmpty
())
{
throw
new
ServiceException
(
"表格中不存在待导入数据!"
);
}
importList
=
importList
.
stream
().
parallel
()
.
filter
(
item
->
!
ObjectUtils
.
isEmpty
(
item
.
getCbName
()))
.
peek
(
item
->
{
item
.
setProjectId
(
1L
);
item
.
setCbStage
(
0
);
}).
collect
(
Collectors
.
toList
());
if
(
importList
.
isEmpty
())
{
throw
new
ServiceException
(
"表格中不存在有效数据数据!"
);
}
return
toAjax
(
baseService
.
saveBatch
(
importList
));
}
}
}
dsk-module/dsk-biz-api/src/main/java/com/dsk/cscec/domain/CbQuantitySummary.java
View file @
e0c88ce3
...
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
...
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
com.dsk.common.annotation.Excel
;
import
lombok.Data
;
import
lombok.Data
;
/**
/**
...
@@ -30,6 +31,7 @@ public class CbQuantitySummary implements Serializable {
...
@@ -30,6 +31,7 @@ public class CbQuantitySummary implements Serializable {
/**
/**
* 序号
* 序号
*/
*/
@Excel
(
name
=
"序号"
)
private
String
number
;
private
String
number
;
/**
/**
* 成本阶段(0:标前成本 1:标后成本 2:转固成本)
* 成本阶段(0:标前成本 1:标后成本 2:转固成本)
...
@@ -38,6 +40,7 @@ public class CbQuantitySummary implements Serializable {
...
@@ -38,6 +40,7 @@ public class CbQuantitySummary implements Serializable {
/**
/**
* 成本科目名称(合约规划)
* 成本科目名称(合约规划)
*/
*/
@Excel
(
name
=
"成本科目"
)
private
String
cbSubjectName
;
private
String
cbSubjectName
;
/**
/**
* 成本科目编号(合约规划编号)
* 成本科目编号(合约规划编号)
...
@@ -46,66 +49,82 @@ public class CbQuantitySummary implements Serializable {
...
@@ -46,66 +49,82 @@ public class CbQuantitySummary implements Serializable {
/**
/**
* 公司编码
* 公司编码
*/
*/
@Excel
(
name
=
"编码"
)
private
String
companyNo
;
private
String
companyNo
;
/**
/**
* 集团编码
* 集团编码
*/
*/
@Excel
(
name
=
"集团编码"
)
private
String
orgNo
;
private
String
orgNo
;
/**
/**
* 成本名称
* 成本名称
*/
*/
@Excel
(
name
=
"名称"
)
private
String
cbName
;
private
String
cbName
;
/**
/**
* 工作内容
* 工作内容
*/
*/
@Excel
(
name
=
"工作内容"
)
private
String
jobContent
;
private
String
jobContent
;
/**
/**
* 计算规则
* 计算规则
*/
*/
@Excel
(
name
=
"计算规则"
)
private
String
calculationRule
;
private
String
calculationRule
;
/**
/**
* 计量单位
* 计量单位
*/
*/
@Excel
(
name
=
"单位"
)
private
String
unit
;
private
String
unit
;
/**
/**
* 材料说明
* 材料说明
*/
*/
@Excel
(
name
=
"甲供材料说明"
)
private
String
materialDescription
;
private
String
materialDescription
;
/**
/**
* 指导价格
* 指导价格
*/
*/
@Excel
(
name
=
"指导价格"
)
private
String
guidePrice
;
private
String
guidePrice
;
/**
/**
* 投标选用单价(不含税)
* 投标选用单价(不含税)
*/
*/
@Excel
(
name
=
"投标选用单价(不含税)"
)
private
Double
bidUnitPrice
;
private
Double
bidUnitPrice
;
/**
/**
* 单价差额
* 单价差额
*/
*/
@Excel
(
name
=
"单价差额"
)
private
Double
unitPriceDifference
;
private
Double
unitPriceDifference
;
/**
/**
* 数量
* 数量
*/
*/
@Excel
(
name
=
"数量"
)
private
Double
quantity
;
private
Double
quantity
;
/**
/**
* 合价
(不含税)
* 合价
(不含税)
*/
*/
@Excel
(
name
=
"合价(不含税)"
)
private
Double
combinedPrice
;
private
Double
combinedPrice
;
/**
/**
* 合价(含税)
* 合价(含税)
*/
*/
@Excel
(
name
=
"合价(含税)"
)
private
Double
combinedPriceTax
;
private
Double
combinedPriceTax
;
/**
/**
* 品牌名称
* 品牌名称
*/
*/
@Excel
(
name
=
"品牌名称"
)
private
String
brandName
;
private
String
brandName
;
/**
/**
* 投标选用来源
* 投标选用来源
*/
*/
@Excel
(
name
=
"投标选用来源"
)
private
String
bidSource
;
private
String
bidSource
;
/**
/**
* 备注
* 备注
*/
*/
@Excel
(
name
=
"备注"
)
private
String
remark
;
private
String
remark
;
/**
/**
* 创建时间
* 创建时间
...
...
dsk-module/dsk-biz-api/src/main/java/com/dsk/cscec/domain/bo/CbProjectBaseBo.java
0 → 100644
View file @
e0c88ce3
package
com
.
dsk
.
cscec
.
domain
.
bo
;
import
lombok.Data
;
/**
* 项目成本基础参数
*
* @Author lcl
* @Data 2024/2/6 9:24
*/
@Data
public
class
CbProjectBaseBo
{
/**
* 项目id
*/
private
Long
projectId
;
/**
* 成本阶段(0:标前成本 1:标后成本 2:转固成本)
*/
private
Integer
cbStage
;
}
dsk-module/dsk-biz-api/src/main/java/com/dsk/cscec/listener/ProjectCostMeasureImportListener.java
View file @
e0c88ce3
package
com
.
dsk
.
cscec
.
listener
;
//package com.dsk.cscec.listener;
//
import
cn.dev33.satoken.secure.BCrypt
;
//import cn.dev33.satoken.secure.BCrypt;
import
cn.hutool.core.bean.BeanUtil
;
//import cn.hutool.core.bean.BeanUtil;
import
cn.hutool.core.util.ObjectUtil
;
//import cn.hutool.core.util.ObjectUtil;
import
com.alibaba.excel.context.AnalysisContext
;
//import com.alibaba.excel.context.AnalysisContext;
import
com.alibaba.excel.event.AnalysisEventListener
;
//import com.alibaba.excel.event.AnalysisEventListener;
import
com.dsk.common.excel.ExcelListener
;
//import com.dsk.common.excel.ExcelListener;
import
com.dsk.common.excel.ExcelResult
;
//import com.dsk.common.excel.ExcelResult;
import
com.dsk.common.exception.ServiceException
;
//import com.dsk.common.exception.ServiceException;
import
com.dsk.common.helper.LoginHelper
;
//import com.dsk.common.helper.LoginHelper;
import
com.dsk.common.utils.ValidatorUtils
;
//import com.dsk.common.utils.ValidatorUtils;
import
com.dsk.common.utils.spring.SpringUtils
;
//import com.dsk.common.utils.spring.SpringUtils;
import
com.dsk.cscec.domain.vo.ProjectMeasuresImportVo
;
//import com.dsk.cscec.domain.vo.ProjectMeasuresImportVo;
import
com.dsk.system.domain.SysUser
;
//import com.dsk.system.domain.SysUser;
import
com.dsk.system.domain.vo.SysUserImportVo
;
//import com.dsk.system.domain.vo.SysUserImportVo;
import
com.dsk.system.service.ISysConfigService
;
//import com.dsk.system.service.ISysConfigService;
import
com.dsk.system.service.ISysUserService
;
//import com.dsk.system.service.ISysUserService;
import
lombok.extern.slf4j.Slf4j
;
//import lombok.extern.slf4j.Slf4j;
//
import
java.util.List
;
//import java.util.List;
//
/**
///**
* 系统用户自定义导入
// * 系统用户自定义导入
*
// *
* @author Lion Li
// * @author Lion Li
*/
// */
@Slf4j
//@Slf4j
public
class
ProjectCostMeasureImportListener
extends
AnalysisEventListener
<
ProjectMeasuresImportVo
>
implements
ExcelListener
<
ProjectMeasuresImportVo
>
{
//public class ProjectCostMeasureImportListener extends AnalysisEventListener<ProjectMeasuresImportVo> implements ExcelListener<ProjectMeasuresImportVo> {
//
// private final ISysUserService userService;
//// private final ISysUserService userService;
//
// private final String password;
//// private final String password;
//
private
final
Boolean
isUpdateSupport
;
// private final Boolean isUpdateSupport;
//
private
final
String
operName
;
// private final String operName;
//
private
int
successNum
=
0
;
// private int successNum = 0;
private
int
failureNum
=
0
;
// private int failureNum = 0;
private
final
StringBuilder
successMsg
=
new
StringBuilder
();
// private final StringBuilder successMsg = new StringBuilder();
private
final
StringBuilder
failureMsg
=
new
StringBuilder
();
// private final StringBuilder failureMsg = new StringBuilder();
//
public
ProjectCostMeasureImportListener
(
Boolean
isUpdateSupport
)
{
// public ProjectCostMeasureImportListener(Boolean isUpdateSupport) {
// String initPassword = SpringUtils.getBean(ISysConfigService.class).selectConfigByKey("sys.user.initPassword");
//// String initPassword = SpringUtils.getBean(ISysConfigService.class).selectConfigByKey("sys.user.initPassword");
// this.userService = SpringUtils.getBean(ISysUserService.class);
//// this.userService = SpringUtils.getBean(ISysUserService.class);
// this.password = BCrypt.hashpw(initPassword);
//// this.password = BCrypt.hashpw(initPassword);
this
.
isUpdateSupport
=
isUpdateSupport
;
// this.isUpdateSupport = isUpdateSupport;
this
.
operName
=
LoginHelper
.
getUsername
();
// this.operName = LoginHelper.getUsername();
}
// }
//
@Override
// @Override
public
void
invoke
(
ProjectMeasuresImportVo
userVo
,
AnalysisContext
context
)
{
// public void invoke(ProjectMeasuresImportVo userVo, AnalysisContext context) {
// SysUser user = this.userService.selectUserByUserName(userVo.getUserName());
//// SysUser user = this.userService.selectUserByUserName(userVo.getUserName());
// try {
//// try {
// // 验证是否存在这个用户
//// // 验证是否存在这个用户
// if (ObjectUtil.isNull(user)) {
//// if (ObjectUtil.isNull(user)) {
// user = BeanUtil.toBean(userVo, SysUser.class);
//// user = BeanUtil.toBean(userVo, SysUser.class);
// ValidatorUtils.validate(user);
//// ValidatorUtils.validate(user);
// user.setPassword(password);
//// user.setPassword(password);
// user.setCreateBy(operName);
//// user.setCreateBy(operName);
// userService.insertUser(user);
//// userService.insertUser(user);
// successNum++;
//// successNum++;
// successMsg.append("<br/>").append(successNum).append("、账号 ").append(user.getUserName()).append(" 导入成功");
//// successMsg.append("<br/>").append(successNum).append("、账号 ").append(user.getUserName()).append(" 导入成功");
// } else if (isUpdateSupport) {
//// } else if (isUpdateSupport) {
// Long userId = user.getUserId();
//// Long userId = user.getUserId();
// user = BeanUtil.toBean(userVo, SysUser.class);
//// user = BeanUtil.toBean(userVo, SysUser.class);
// user.setUserId(userId);
//// user.setUserId(userId);
// ValidatorUtils.validate(user);
//// ValidatorUtils.validate(user);
// userService.checkUserAllowed(user);
//// userService.checkUserAllowed(user);
// userService.checkUserDataScope(user.getUserId());
//// userService.checkUserDataScope(user.getUserId());
// user.setUpdateBy(operName);
//// user.setUpdateBy(operName);
// userService.updateUser(user);
//// userService.updateUser(user);
// successNum++;
//// successNum++;
// successMsg.append("<br/>").append(successNum).append("、账号 ").append(user.getUserName()).append(" 更新成功");
//// successMsg.append("<br/>").append(successNum).append("、账号 ").append(user.getUserName()).append(" 更新成功");
//// } else {
//// failureNum++;
//// failureMsg.append("<br/>").append(failureNum).append("、账号 ").append(user.getUserName()).append(" 已存在");
//// }
//// } catch (Exception e) {
//// failureNum++;
//// String msg = "<br/>" + failureNum + "、账号 " + user.getUserName() + " 导入失败:";
//// failureMsg.append(msg).append(e.getMessage());
//// log.error(msg, e);
//// }
// }
//
// @Override
// public void doAfterAllAnalysed(AnalysisContext context) {
//
// }
//
// @Override
// public ExcelResult<ProjectMeasuresImportVo> getExcelResult() {
// return new ExcelResult<ProjectMeasuresImportVo>() {
//
// @Override
// public String getAnalysis() {
// if (failureNum > 0) {
// failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
// throw new ServiceException(failureMsg.toString());
// } else {
// } else {
// failureNum++;
// successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
// failureMsg.append("<br/>").append(failureNum).append("、账号 ").append(user.getUserName()).append(" 已存在");
// }
// return successMsg.toString();
// }
//
// @Override
// public List<ProjectMeasuresImportVo> getList() {
// return null;
// }
//
// @Override
// public List<String> getErrorList() {
// return null;
// }
// }
// } catch (Exception e) {
// };
// failureNum++;
// String msg = "<br/>" + failureNum + "、账号 " + user.getUserName() + " 导入失败:";
// failureMsg.append(msg).append(e.getMessage());
// log.error(msg, e);
// }
// }
}
//}
@Override
public
void
doAfterAllAnalysed
(
AnalysisContext
context
)
{
}
@Override
public
ExcelResult
<
ProjectMeasuresImportVo
>
getExcelResult
()
{
return
new
ExcelResult
<
ProjectMeasuresImportVo
>()
{
@Override
public
String
getAnalysis
()
{
if
(
failureNum
>
0
)
{
failureMsg
.
insert
(
0
,
"很抱歉,导入失败!共 "
+
failureNum
+
" 条数据格式不正确,错误如下:"
);
throw
new
ServiceException
(
failureMsg
.
toString
());
}
else
{
successMsg
.
insert
(
0
,
"恭喜您,数据已全部导入成功!共 "
+
successNum
+
" 条,数据如下:"
);
}
return
successMsg
.
toString
();
}
@Override
public
List
<
ProjectMeasuresImportVo
>
getList
()
{
return
null
;
}
@Override
public
List
<
String
>
getErrorList
()
{
return
null
;
}
};
}
}
dsk-module/dsk-biz-api/src/main/java/com/dsk/cscec/mapper/CbQuantitySummaryMapper.java
View file @
e0c88ce3
...
@@ -2,6 +2,12 @@ package com.dsk.cscec.mapper;
...
@@ -2,6 +2,12 @@ package com.dsk.cscec.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.dsk.cscec.domain.CbQuantitySummary
;
import
com.dsk.cscec.domain.CbQuantitySummary
;
import
com.dsk.cscec.domain.bo.CbProjectBaseBo
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* 成本-工料汇总基本表(CbQuantitySummary)表数据库访问层
* 成本-工料汇总基本表(CbQuantitySummary)表数据库访问层
...
@@ -11,5 +17,10 @@ import com.dsk.cscec.domain.CbQuantitySummary;
...
@@ -11,5 +17,10 @@ import com.dsk.cscec.domain.CbQuantitySummary;
*/
*/
public
interface
CbQuantitySummaryMapper
extends
BaseMapper
<
CbQuantitySummary
>
{
public
interface
CbQuantitySummaryMapper
extends
BaseMapper
<
CbQuantitySummary
>
{
List
<
Map
<
String
,
Object
>>
selectSubject
(
CbProjectBaseBo
bo
);
int
selectOtherSubjectCount
(
CbProjectBaseBo
bo
);
}
}
dsk-module/dsk-biz-api/src/main/java/com/dsk/cscec/service/ICbQuantitySummaryService.java
View file @
e0c88ce3
...
@@ -2,6 +2,10 @@ package com.dsk.cscec.service;
...
@@ -2,6 +2,10 @@ package com.dsk.cscec.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.dsk.cscec.domain.CbQuantitySummary
;
import
com.dsk.cscec.domain.CbQuantitySummary
;
import
com.dsk.cscec.domain.bo.CbProjectBaseBo
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* 成本-工料汇总基本表(CbQuantitySummary)表服务接口
* 成本-工料汇总基本表(CbQuantitySummary)表服务接口
...
@@ -11,5 +15,9 @@ import com.dsk.cscec.domain.CbQuantitySummary;
...
@@ -11,5 +15,9 @@ import com.dsk.cscec.domain.CbQuantitySummary;
*/
*/
public
interface
ICbQuantitySummaryService
extends
IService
<
CbQuantitySummary
>
{
public
interface
ICbQuantitySummaryService
extends
IService
<
CbQuantitySummary
>
{
Map
<
String
,
Object
>
subjectTree
(
CbProjectBaseBo
bo
);
List
<
String
>
monthList
(
CbProjectBaseBo
bo
);
}
}
dsk-module/dsk-biz-api/src/main/java/com/dsk/cscec/service/impl/CbQuantitySummaryServiceImpl.java
View file @
e0c88ce3
package
com
.
dsk
.
cscec
.
service
.
impl
;
package
com
.
dsk
.
cscec
.
service
.
impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.dsk.cscec.mapper.CbQuantitySummaryMapper
;
import
com.dsk.cscec.domain.CbQuantitySummary
;
import
com.dsk.cscec.domain.CbQuantitySummary
;
import
com.dsk.cscec.domain.bo.CbProjectBaseBo
;
import
com.dsk.cscec.mapper.CbQuantitySummaryMapper
;
import
com.dsk.cscec.service.ICbQuantitySummaryService
;
import
com.dsk.cscec.service.ICbQuantitySummaryService
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
/**
* 成本-工料汇总基本表(CbQuantitySummary)表服务实现类
* 成本-工料汇总基本表(CbQuantitySummary)表服务实现类
...
@@ -15,5 +22,27 @@ import org.springframework.stereotype.Service;
...
@@ -15,5 +22,27 @@ import org.springframework.stereotype.Service;
@Service
@Service
public
class
CbQuantitySummaryServiceImpl
extends
ServiceImpl
<
CbQuantitySummaryMapper
,
CbQuantitySummary
>
implements
ICbQuantitySummaryService
{
public
class
CbQuantitySummaryServiceImpl
extends
ServiceImpl
<
CbQuantitySummaryMapper
,
CbQuantitySummary
>
implements
ICbQuantitySummaryService
{
@Override
public
Map
<
String
,
Object
>
subjectTree
(
CbProjectBaseBo
bo
)
{
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<>();
List
<
Map
<
String
,
Object
>>
list
=
baseMapper
.
selectSubject
(
bo
);
if
(!
ObjectUtils
.
isEmpty
(
list
))
{
Map
<
String
,
Map
<
String
,
Map
<
String
,
List
<
Map
<
String
,
Object
>>>>>
map
=
list
.
stream
().
collect
(
Collectors
.
groupingBy
(
item
->
item
.
get
(
"one"
).
toString
(),
Collectors
.
groupingBy
(
item
->
item
.
get
(
"two"
).
toString
(),
Collectors
.
groupingBy
(
item
->
item
.
get
(
"three"
).
toString
()))));
resultMap
.
put
(
"房建类成本科目"
,
map
);
}
int
otherSubjectCount
=
baseMapper
.
selectOtherSubjectCount
(
bo
);
if
(
otherSubjectCount
>
0
)
{
resultMap
.
put
(
"未归类项目"
,
"other"
);
}
return
resultMap
;
}
@Override
public
List
<
String
>
monthList
(
CbProjectBaseBo
bo
)
{
return
null
;
}
}
}
dsk-module/dsk-biz-api/src/main/resources/mapper/cscec/CbQuantitySummaryMapper.xml
0 → 100644
View file @
e0c88ce3
<?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=
"com.dsk.cscec.mapper.CbQuantitySummaryMapper"
>
<select
id=
"selectSubject"
resultType=
"java.util.Map"
>
select
cs1.cb_subject_name as one, cs2.cb_subject_name as two, cs3.cb_subject_name as three
from cb_subject cs1
join cb_subject cs2 on (cs2.cb_subject_no like concat(cs1.cb_subject_no,'%') and cs2.`level` = 2 )
join cb_subject cs3 on (cs3.cb_subject_no like concat(cs2.cb_subject_no,'%') and cs3.`level` = 3 )
join cb_quantity_summary cqs on (cqs.cb_subject_name = cs3.cb_subject_name and cqs.project_id = #{projectId} and cqs.cb_stage = #{cbStage})
where cs1.`level` = 1
group by cs1.cb_subject_name,cs2.cb_subject_name,cs3.cb_subject_name
</select>
<select
id=
"selectOtherSubjectCount"
resultType=
"java.lang.Integer"
>
select
count(cqs.id)
from cb_quantity_summary cqs
left join cb_subject cs1 on cqs.cb_subject_name = cs1.cb_subject_name
where cqs.project_id = #{projectId} and cqs.cb_stage = #{cbStage} and cs1.id is null
</select>
</mapper>
\ No newline at end of file
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