Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
K
klck
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
位宇华
klck
Commits
a7d70ed9
Commit
a7d70ed9
authored
May 27, 2024
by
刘_震
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
工资-后端接口代码的实现
parent
bd6b582b
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
531 additions
and
170 deletions
+531
-170
ruoyi-wages/src/main/java/com/ruoyi/system/controller/WagesCalculateConversionController.java
...system/controller/WagesCalculateConversionController.java
+20
-11
ruoyi-wages/src/main/java/com/ruoyi/system/mapper/WagesCalculateConversionMapper.java
...m/ruoyi/system/mapper/WagesCalculateConversionMapper.java
+0
-12
ruoyi-wages/src/main/java/com/ruoyi/system/mapper/WagesDetailsOriginalDataMapper.java
...m/ruoyi/system/mapper/WagesDetailsOriginalDataMapper.java
+11
-0
ruoyi-wages/src/main/java/com/ruoyi/system/mapper/WagesOverviewOriginalDateMapper.java
.../ruoyi/system/mapper/WagesOverviewOriginalDateMapper.java
+11
-0
ruoyi-wages/src/main/java/com/ruoyi/system/model/wages/dao/WagesOverviewOriginalExcelDAO.java
...system/model/wages/dao/WagesOverviewOriginalExcelDAO.java
+22
-22
ruoyi-wages/src/main/java/com/ruoyi/system/model/wages/dto/WagesFormulaListDto.java
...com/ruoyi/system/model/wages/dto/WagesFormulaListDto.java
+5
-5
ruoyi-wages/src/main/java/com/ruoyi/system/model/wages/vo/WagesFormulaListVo.java
...a/com/ruoyi/system/model/wages/vo/WagesFormulaListVo.java
+28
-28
ruoyi-wages/src/main/java/com/ruoyi/system/model/wages/vo/WagesFormulaVo.java
.../java/com/ruoyi/system/model/wages/vo/WagesFormulaVo.java
+30
-0
ruoyi-wages/src/main/java/com/ruoyi/system/service/WagesCalculateConversionService.java
...ruoyi/system/service/WagesCalculateConversionService.java
+10
-1
ruoyi-wages/src/main/java/com/ruoyi/system/service/impl/WagesCalculateConversionServiceImpl.java
...tem/service/impl/WagesCalculateConversionServiceImpl.java
+254
-80
ruoyi-wages/src/main/resources/mapper/system/WagesCalculateConversionMapper.xml
...esources/mapper/system/WagesCalculateConversionMapper.xml
+0
-11
ruoyi-wages/src/main/resources/mapper/system/WagesDetailsOriginalDataMapper.xml
...esources/mapper/system/WagesDetailsOriginalDataMapper.xml
+101
-0
ruoyi-wages/src/main/resources/mapper/system/WagesOverviewOriginalDataMapper.xml
...sources/mapper/system/WagesOverviewOriginalDataMapper.xml
+39
-0
No files found.
ruoyi-wages/src/main/java/com/ruoyi/system/controller/WagesCalculateConversionController.java
View file @
a7d70ed9
package
com.ruoyi.system.controller
;
import
com.ruoyi.common.core.domain.AjaxResult
;
import
com.ruoyi.system.model.wages.dto.WagesConversionDataDto
;
import
com.ruoyi.system.model.wages.dto.WagesFormulaDto
;
import
com.ruoyi.system.model.wages.dto.WagesFormulaListDto
;
import
com.ruoyi.system.model.wages.vo.WagesFormulaVo
;
import
com.ruoyi.system.model.wages.vo.WagesOverviewOriginalDataVO
;
import
com.ruoyi.system.service.WagesCalculateConversionService
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
/**
* 2024/5/21
*/
@RestController
@Api
(
tags
=
"工资转化模版"
)
@RequestMapping
(
"/wages/calculate"
)
@RequiredArgsConstructor
public
class
WagesCalculateConversionController
{
private
WagesCalculateConversionService
wagesCalculateConversionService
;
private
WagesCalculateConversionController
(
WagesCalculateConversionService
wagesCalculateConversionService
){
this
.
wagesCalculateConversionService
=
wagesCalculateConversionService
;
}
private
final
WagesCalculateConversionService
wagesCalculateConversionService
;
/**
* 唐山矿转换表
*/
@RequestMapping
(
"/surface"
)
public
AjaxResult
conversionSurface
(
@RequestBody
WagesFormulaListDto
wagesFormulaListDto
)
{
return
new
AjaxResult
(
200
,
"成功"
,
wagesCalculateConversionService
.
conversionSurface
(
wagesFormulaListDto
));
@PostMapping
(
value
=
"/surface"
)
@ApiOperation
(
value
=
"唐山矿转换表"
)
public
AjaxResult
conversionSurface
(
@RequestBody
WagesFormulaListDto
wagesFormulaListDto
)
throws
NoSuchFieldException
,
IllegalAccessException
{
List
<
WagesFormulaVo
>
data
=
wagesCalculateConversionService
.
conversionSurface
(
wagesFormulaListDto
);
return
new
AjaxResult
(
200
,
"成功"
,
data
);
}
}
ruoyi-wages/src/main/java/com/ruoyi/system/mapper/WagesCalculateConversionMapper.java
deleted
100644 → 0
View file @
bd6b582b
package
com.ruoyi.system.mapper
;
import
java.util.List
;
/**
* @author haiwe
* @date 2024/5/22
*/
public
interface
WagesCalculateConversionMapper
{
List
<
Object
>
select
(
String
year
);
}
ruoyi-wages/src/main/java/com/ruoyi/system/mapper/WagesDetailsOriginalDataMapper.java
0 → 100644
View file @
a7d70ed9
package
com.ruoyi.system.mapper
;
import
com.ruoyi.system.model.wages.dao.WagesDetailsOriginalExcelDAO
;
import
java.util.List
;
public
interface
WagesDetailsOriginalDataMapper
{
List
<
WagesDetailsOriginalExcelDAO
>
selectAll
();
}
\ No newline at end of file
ruoyi-wages/src/main/java/com/ruoyi/system/mapper/WagesOverviewOriginalDateMapper.java
0 → 100644
View file @
a7d70ed9
package
com.ruoyi.system.mapper
;
import
com.ruoyi.system.model.wages.dao.WagesOverviewOriginalExcelDAO
;
import
java.util.List
;
public
interface
WagesOverviewOriginalDateMapper
{
List
<
WagesOverviewOriginalExcelDAO
>
selectAll
();
}
\ No newline at end of file
ruoyi-wages/src/main/java/com/ruoyi/system/model/wages/dao/WagesOverviewOriginalExcelDAO.java
View file @
a7d70ed9
...
...
@@ -20,25 +20,25 @@ public class WagesOverviewOriginalExcelDAO {
private
String
unitCode
;
// 单位名称
@ExcelProperty
(
index
=
3
)
private
String
U
nitName
;
private
String
u
nitName
;
// 工人人数
@ExcelProperty
(
index
=
4
)
private
Integer
W
orkerCount
;
private
Integer
w
orkerCount
;
// 工人应付工资
@ExcelProperty
(
index
=
5
)
private
BigDecimal
W
orkerWagesPayable
;
private
BigDecimal
w
orkerWagesPayable
;
// 干部人数
@ExcelProperty
(
index
=
6
)
private
Integer
C
adreCount
;
private
Integer
c
adreCount
;
// 干部应付工资
@ExcelProperty
(
index
=
7
)
private
BigDecimal
C
adreWagesPayable
;
private
BigDecimal
c
adreWagesPayable
;
// 人数合计
@ExcelProperty
(
index
=
8
)
private
Integer
T
otalCount
;
private
Integer
t
otalCount
;
// 应付工资合计
@ExcelProperty
(
index
=
9
)
private
BigDecimal
T
otalWagesPayable
;
private
BigDecimal
t
otalWagesPayable
;
public
String
getYear
()
{
return
year
;
...
...
@@ -65,58 +65,58 @@ public class WagesOverviewOriginalExcelDAO {
}
public
String
getUnitName
()
{
return
U
nitName
;
return
u
nitName
;
}
public
void
setUnitName
(
String
unitName
)
{
U
nitName
=
unitName
;
this
.
u
nitName
=
unitName
;
}
public
Integer
getWorkerCount
()
{
return
W
orkerCount
;
return
w
orkerCount
;
}
public
void
setWorkerCount
(
Integer
workerCount
)
{
W
orkerCount
=
workerCount
;
this
.
w
orkerCount
=
workerCount
;
}
public
BigDecimal
getWorkerWagesPayable
()
{
return
W
orkerWagesPayable
;
return
w
orkerWagesPayable
;
}
public
void
setWorkerWagesPayable
(
BigDecimal
workerWagesPayable
)
{
W
orkerWagesPayable
=
workerWagesPayable
;
this
.
w
orkerWagesPayable
=
workerWagesPayable
;
}
public
Integer
getCadreCount
()
{
return
C
adreCount
;
return
c
adreCount
;
}
public
void
setCadreCount
(
Integer
cadreCount
)
{
C
adreCount
=
cadreCount
;
this
.
c
adreCount
=
cadreCount
;
}
public
BigDecimal
getCadreWagesPayable
()
{
return
C
adreWagesPayable
;
return
c
adreWagesPayable
;
}
public
void
setCadreWagesPayable
(
BigDecimal
cadreWagesPayable
)
{
C
adreWagesPayable
=
cadreWagesPayable
;
this
.
c
adreWagesPayable
=
cadreWagesPayable
;
}
public
Integer
getTotalCount
()
{
return
T
otalCount
;
return
t
otalCount
;
}
public
void
setTotalCount
(
Integer
totalCount
)
{
T
otalCount
=
totalCount
;
this
.
t
otalCount
=
totalCount
;
}
public
BigDecimal
getTotalWagesPayable
()
{
return
T
otalWagesPayable
;
return
t
otalWagesPayable
;
}
public
void
setTotalWagesPayable
(
BigDecimal
totalWagesPayable
)
{
T
otalWagesPayable
=
totalWagesPayable
;
this
.
t
otalWagesPayable
=
totalWagesPayable
;
}
}
}
\ No newline at end of file
ruoyi-wages/src/main/java/com/ruoyi/system/model/wages/dto/WagesFormulaListDto.java
View file @
a7d70ed9
...
...
@@ -9,7 +9,7 @@ import java.util.List;
public
class
WagesFormulaListDto
{
// 日期
private
String
date
;
private
List
<
WagesFormulaDto
>
wagesFormulaDtoList
;
private
List
<
WagesFormulaDto
>
data
;
public
String
getDate
()
{
return
date
;
...
...
@@ -19,11 +19,11 @@ public class WagesFormulaListDto {
this
.
date
=
date
;
}
public
List
<
WagesFormulaDto
>
get
WagesFormulaDtoList
()
{
return
wagesFormulaDtoList
;
public
List
<
WagesFormulaDto
>
get
Data
()
{
return
data
;
}
public
void
set
WagesFormulaDtoList
(
List
<
WagesFormulaDto
>
wagesFormulaDtoList
)
{
this
.
wagesFormulaDtoList
=
wagesFormulaDtoList
;
public
void
set
Data
(
List
<
WagesFormulaDto
>
data
)
{
this
.
data
=
data
;
}
}
ruoyi-wages/src/main/java/com/ruoyi/system/model/wages/vo/WagesFormulaListVo.java
View file @
a7d70ed9
package
com.ruoyi.system.model.wages.vo
;
import
java.util.List
;
/**
* 2024/5/22
*/
public
class
WagesFormulaListVo
{
// 部门
private
String
dep
;
private
List
<
WagesFormulaVo
>
list
;
public
String
getDep
()
{
return
dep
;
}
public
void
setDep
(
String
dep
)
{
this
.
dep
=
dep
;
}
public
List
<
WagesFormulaVo
>
getList
()
{
return
list
;
}
public
void
setList
(
List
<
WagesFormulaVo
>
list
)
{
this
.
list
=
list
;
}
}
//
package com.ruoyi.system.model.wages.vo;
//
//
import java.util.List;
//
/
//
**
//
* 2024/5/22
//
*/
//
public class WagesFormulaListVo {
//
// 部门
//
private String dep;
//
private List<WagesFormulaVo> list;
//
//
public String getDep() {
//
return dep;
//
}
//
//
public void setDep(String dep) {
//
this.dep = dep;
//
}
//
//
public List<WagesFormulaVo> getList() {
//
return list;
//
}
//
//
public void setList(List<WagesFormulaVo> list) {
//
this.list = list;
//
}
//
}
\ No newline at end of file
ruoyi-wages/src/main/java/com/ruoyi/system/model/wages/vo/WagesFormulaVo.java
View file @
a7d70ed9
...
...
@@ -4,12 +4,18 @@ package com.ruoyi.system.model.wages.vo;
* 2024/5/22
*/
public
class
WagesFormulaVo
{
//部门名
private
String
dep
;
// 页面展示字段
private
String
label
;
// 列数
private
String
c
;
// 值
private
String
value
;
//工人
private
String
worker
;
//干部
private
String
cadre
;
public
String
getLabel
()
{
return
label
;
...
...
@@ -34,4 +40,28 @@ public class WagesFormulaVo {
public
void
setValue
(
String
value
)
{
this
.
value
=
value
;
}
public
String
getWorker
()
{
return
worker
;
}
public
void
setWorker
(
String
worker
)
{
this
.
worker
=
worker
;
}
public
String
getCadre
()
{
return
cadre
;
}
public
void
setCadre
(
String
cadre
)
{
this
.
cadre
=
cadre
;
}
public
String
getDep
()
{
return
dep
;
}
public
void
setDep
(
String
dep
)
{
this
.
dep
=
dep
;
}
}
ruoyi-wages/src/main/java/com/ruoyi/system/service/WagesCalculateConversionService.java
View file @
a7d70ed9
package
com.ruoyi.system.service
;
import
com.ruoyi.system.model.wages.dto.WagesFormulaListDto
;
import
com.ruoyi.system.model.wages.vo.WagesFormulaVo
;
import
com.ruoyi.system.model.wages.vo.WagesOverviewOriginalDataVO
;
import
java.util.List
;
/**
* 2024/5/21
*/
public
interface
WagesCalculateConversionService
{
Object
conversionSurface
(
WagesFormulaListDto
wagesFormulaListDto
);
/**
*
* @param wagesFormulaListDto
* @return
*/
List
<
WagesFormulaVo
>
conversionSurface
(
WagesFormulaListDto
wagesFormulaListDto
)
throws
NoSuchFieldException
,
IllegalAccessException
;
}
ruoyi-wages/src/main/java/com/ruoyi/system/service/impl/WagesCalculateConversionServiceImpl.java
View file @
a7d70ed9
package
com.ruoyi.system.service.impl
;
import
cn.hutool.core.util.ReUtil
;
import
com.ruoyi.system.mapper.WagesCalculateConversionMapper
;
import
com.google.common.collect.Lists
;
import
com.ruoyi.system.mapper.WagesDetailsOriginalDataMapper
;
import
com.ruoyi.system.mapper.WagesOverviewOriginalDateMapper
;
import
com.ruoyi.system.model.wages.dao.WagesDetailsOriginalExcelDAO
;
import
com.ruoyi.system.model.wages.dao.WagesOverviewOriginalExcelDAO
;
import
com.ruoyi.system.model.wages.dto.WagesFormulaDto
;
import
com.ruoyi.system.model.wages.dto.WagesFormulaListDto
;
import
com.ruoyi.system.model.wages.vo.WagesFormulaListVo
;
import
com.ruoyi.system.model.wages.vo.WagesFormulaVo
;
import
com.ruoyi.system.service.WagesCalculateConversionService
;
import
lombok.RequiredArgsConstructor
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Service
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.lang.reflect.Array
;
import
java.lang.reflect.Field
;
import
java.math.BigDecimal
;
import
java.util.*
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
java.util.stream.Collectors
;
/**
* 2024/5/21
...
...
@@ -21,110 +29,276 @@ import java.util.List;
@RequiredArgsConstructor
public
class
WagesCalculateConversionServiceImpl
implements
WagesCalculateConversionService
{
private
final
WagesCalculateConversionMapper
wagesCalculateConversionMapper
;
private
final
WagesDetailsOriginalDataMapper
detailsOriginalDataMapper
;
private
final
WagesOverviewOriginalDateMapper
originalDateMapper
;
private
static
final
List
<
Character
>
FH
=
Arrays
.
asList
(
'+'
,
'-'
,
'*'
,
'/'
);
@Override
public
Object
conversionSurface
(
WagesFormulaListDto
wagesFormulaListDto
)
{
WagesFormulaListVo
listVo
=
new
WagesFormulaListVo
();
List
<
WagesFormulaVo
>
wagesFormulaVoList
=
new
ArrayList
<>();
public
List
<
WagesFormulaVo
>
conversionSurface
(
WagesFormulaListDto
wagesFormulaListDto
)
{
//根据中文映射相应的实体类字段
Map
<
String
,
String
>
fieldMapping
=
new
HashMap
<>();
fieldMapping
.
put
(
"年"
,
"year"
);
fieldMapping
.
put
(
"月"
,
"month"
);
fieldMapping
.
put
(
"单位名称"
,
"unitName"
);
fieldMapping
.
put
(
"人数"
,
"peopleCount"
);
fieldMapping
.
put
(
"应付工资"
,
"wagesPayable"
);
fieldMapping
.
put
(
"房租"
,
"houseRent"
);
fieldMapping
.
put
(
"住宿"
,
"accommodation"
);
fieldMapping
.
put
(
"暖气费"
,
"heatingFee"
);
fieldMapping
.
put
(
"工会会费"
,
"tradeUnionDues"
);
fieldMapping
.
put
(
"赔偿扣款"
,
"compensationDeduction"
);
fieldMapping
.
put
(
"其他扣款"
,
"otherDeductions"
);
fieldMapping
.
put
(
"互助医疗"
,
"mutualMedicalAid"
);
fieldMapping
.
put
(
"通讯费"
,
"communicationFee"
);
fieldMapping
.
put
(
"税金1"
,
"tax1"
);
fieldMapping
.
put
(
"税金2"
,
"tax2"
);
fieldMapping
.
put
(
"养老保险"
,
"pensionInsurance"
);
fieldMapping
.
put
(
"失业保险"
,
"unemploymentInsurance"
);
fieldMapping
.
put
(
"医疗保险"
,
"medicalInsurance"
);
fieldMapping
.
put
(
"年金"
,
"annuity"
);
fieldMapping
.
put
(
"住房公积金"
,
"housingProvidentFund"
);
fieldMapping
.
put
(
"企业公积金"
,
"enterpriseFund"
);
fieldMapping
.
put
(
"年金个税"
,
"annuityIncomeTax"
);
fieldMapping
.
put
(
"代扣合计"
,
"totalWithholding"
);
fieldMapping
.
put
(
"净支工资"
,
"netSalary"
);
fieldMapping
.
put
(
"一孩费"
,
"oneChildFee"
);
fieldMapping
.
put
(
"医疗补贴"
,
"medicalSubsidy"
);
fieldMapping
.
put
(
"保健费"
,
"healthCareFee"
);
fieldMapping
.
put
(
"班中餐"
,
"classMealFee"
);
fieldMapping
.
put
(
"肥皂费"
,
"soapFee"
);
fieldMapping
.
put
(
"护理费"
,
"nursingFee"
);
fieldMapping
.
put
(
"防暑补贴"
,
"heatstrokePreventionSubsidy"
);
fieldMapping
.
put
(
"取暖补贴"
,
"heatingSubsidy"
);
fieldMapping
.
put
(
"稿费"
,
"manuscriptFee"
);
fieldMapping
.
put
(
"司机出车补贴"
,
"driverAllowance"
);
fieldMapping
.
put
(
"毕业生安家费"
,
"graduateSettlementFee"
);
fieldMapping
.
put
(
"一次性伤残补助"
,
"oneTimeDisabilitySubsidy"
);
fieldMapping
.
put
(
"讲课考务费"
,
"lectureAndExamFee"
);
fieldMapping
.
put
(
"其他补贴"
,
"otherSubsidies"
);
fieldMapping
.
put
(
"代付合计"
,
"totalPayment"
);
fieldMapping
.
put
(
"工资总支款"
,
"totalSalaryDisbursement"
);
Map
<
String
,
String
>
fieldMapper
=
new
HashMap
<>();
fieldMapper
.
put
(
"应付工资"
,
"totalWagesPayable"
);
List
<
WagesFormulaDto
>
wagesFormulaDtoList
=
wagesFormulaListDto
.
getWagesFormulaDtoList
();
//获取传过来的值(date - 格式为:xxxx-MM)
//定义一个集合用来,存储返回的字段
List
<
WagesFormulaVo
>
voList
=
new
ArrayList
<>();
// 从数据库中获取数据
String
date
=
wagesFormulaListDto
.
getDate
();
String
[]
parts
=
date
.
split
(
"-"
);
String
year
=
parts
[
0
];
//根据时间去数据库中查询,得到每一条的list集合
List
<
Object
>
wagesList
=
wagesCalculateConversionMapper
.
select
(
year
);
Object
dep
=
wagesList
.
get
(
3
);
double
result
=
calculateFormula
(
wagesList
,
wagesFormulaDtoList
);
String
month
=
parts
[
1
];
// 获取前端传过来的集合(label, c, value)
//详细表
List
<
WagesDetailsOriginalExcelDAO
>
wagesDetails
=
detailsOriginalDataMapper
.
selectAll
();
//略表
List
<
WagesOverviewOriginalExcelDAO
>
wagesList
=
originalDateMapper
.
selectAll
();
List
<
String
>
unitList
=
wagesList
.
parallelStream
().
map
(
WagesOverviewOriginalExcelDAO:
:
getUnitName
).
collect
(
Collectors
.
toList
());
// 设置部门信息
listVo
.
setDep
(
String
.
valueOf
(
dep
));
// 构建WagesFormulaVo对象并添加到列表中
if
(
wagesList
.
size
()
==
0
)
{
return
null
;
}
List
<
WagesFormulaDto
>
wagesFormulaDtoList
=
wagesFormulaListDto
.
getData
();
for
(
WagesFormulaDto
wagesFormulaDto
:
wagesFormulaDtoList
)
{
WagesFormulaVo
formulaVo
=
new
WagesFormulaVo
();
formulaVo
.
setLabel
(
wagesFormulaDto
.
getLabel
());
formulaVo
.
setC
(
wagesFormulaDto
.
getC
());
formulaVo
.
setValue
(
String
.
valueOf
(
result
));
String
value
=
wagesFormulaDto
.
getValue
();
String
value1
=
value
;
//解析公式value
Map
<
String
,
List
<
String
>>
operandsMap
=
extractOperands
(
value
);
//只含公式中的字段
List
<
String
>
formula
=
operandsMap
.
get
(
"operands"
);
try
{
if
(
wagesFormulaDto
.
getValue
().
contains
(
"应付工资"
))
{
for
(
WagesOverviewOriginalExcelDAO
dao
:
wagesList
)
{
Optional
<
WagesDetailsOriginalExcelDAO
>
first
=
wagesDetails
.
parallelStream
().
filter
(
v
->
v
.
getUnitName
().
equals
(
dao
.
getUnitName
())).
findFirst
();
WagesFormulaVo
vo
=
new
WagesFormulaVo
();
if
(
first
.
isPresent
())
{
vo
.
setLabel
(
wagesFormulaDto
.
getLabel
());
vo
.
setDep
(
first
.
get
().
getUnitName
());
vo
.
setWorker
(
dao
.
getWorkerWagesPayable
().
toString
());
vo
.
setCadre
(
dao
.
getCadreWagesPayable
().
toString
());
vo
.
setC
(
wagesFormulaDto
.
getC
());
for
(
String
s
:
formula
)
{
if
(
fieldMapper
.
containsKey
(
s
))
{
String
sqlResult
=
fieldMapper
.
get
(
s
);
Field
wagesField
=
WagesOverviewOriginalExcelDAO
.
class
.
getDeclaredField
(
sqlResult
);
wagesField
.
setAccessible
(
true
);
Object
fieldValue
=
wagesField
.
get
(
dao
);
value
=
StringUtils
.
replaceOnce
(
value
,
s
,
fieldValue
.
toString
());
}
else
if
(
fieldMapping
.
containsKey
(
s
))
{
String
sqlResult
=
fieldMapping
.
get
(
s
);
Field
wagesField
=
WagesDetailsOriginalExcelDAO
.
class
.
getDeclaredField
(
sqlResult
);
wagesField
.
setAccessible
(
true
);
Object
fieldValue
=
wagesField
.
get
(
first
.
get
());
value
=
StringUtils
.
replaceOnce
(
value
,
s
,
fieldValue
.
toString
());
}
else
{
// 如果传入的是数字而不是映射的字段,直接将数字作为 fieldValue 传递
value
=
StringUtils
.
replaceOnce
(
value
,
s
,
s
);
}
}
vo
.
setValue
(
count
(
value
));
voList
.
add
(
vo
);
value
=
value1
;
}
}
List
<
WagesDetailsOriginalExcelDAO
>
collect
=
wagesDetails
.
parallelStream
().
filter
(
v
->
!
unitList
.
contains
(
v
.
getUnitName
())).
collect
(
Collectors
.
toList
());
for
(
WagesDetailsOriginalExcelDAO
wagesDetail
:
collect
)
{
WagesFormulaVo
vo
=
new
WagesFormulaVo
();
vo
.
setLabel
(
wagesFormulaDto
.
getLabel
());
vo
.
setDep
(
wagesDetail
.
getUnitName
());
vo
.
setWorker
(
"0"
);
vo
.
setCadre
(
"0"
);
vo
.
setC
(
wagesFormulaDto
.
getC
());
for
(
String
s
:
formula
)
{
String
sqlResult
=
fieldMapping
.
get
(
s
);
if
(
sqlResult
==
null
)
{
continue
;
}
Field
wagesField
=
WagesDetailsOriginalExcelDAO
.
class
.
getDeclaredField
(
sqlResult
);
wagesField
.
setAccessible
(
true
);
Object
fieldValue
=
wagesField
.
get
(
wagesDetail
);
value
=
StringUtils
.
replaceOnce
(
value
,
s
,
fieldValue
.
toString
());
}
vo
.
setValue
(
count
(
value
));
voList
.
add
(
vo
);
value
=
value1
;
}
}
else
{
for
(
WagesDetailsOriginalExcelDAO
wagesDetail
:
wagesDetails
)
{
WagesFormulaVo
vo
=
new
WagesFormulaVo
();
vo
.
setLabel
(
wagesFormulaDto
.
getLabel
());
vo
.
setDep
(
wagesDetail
.
getUnitName
());
vo
.
setWorker
(
"0"
);
vo
.
setCadre
(
"0"
);
vo
.
setC
(
wagesFormulaDto
.
getC
());
for
(
String
s
:
formula
)
{
String
sqlResult
=
fieldMapping
.
get
(
s
);
Field
wagesField
=
null
;
wagesField
=
WagesDetailsOriginalExcelDAO
.
class
.
getDeclaredField
(
sqlResult
);
wagesField
.
setAccessible
(
true
);
Object
fieldValue
=
wagesField
.
get
(
wagesDetail
);
value
=
StringUtils
.
replaceOnce
(
value
,
s
,
fieldValue
.
toString
());
}
vo
.
setValue
(
count
(
value
));
voList
.
add
(
vo
);
value
=
value1
;
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
wagesFormulaVoList
.
add
(
formulaVo
);
}
return
listVo
;
return
voList
;
}
private
double
calculateFormula
(
List
<
Object
>
wagesList
,
List
<
WagesFormulaDto
>
wagesFormulaDtoList
)
{
double
result
=
0.0
;
for
(
WagesFormulaDto
wagesFormulaDto
:
wagesFormulaDtoList
)
{
String
value
=
wagesFormulaDto
.
getValue
();
String
formula
=
extractOperands
(
value
);
double
operand
=
evaluateExpression
(
wagesList
,
formula
);
result
+=
operand
;
private
String
count
(
String
value
)
{
value
=
value
.
replaceAll
(
" "
,
""
);
char
sta
=
value
.
charAt
(
0
);
char
end
=
value
.
charAt
(
value
.
length
()
-
1
);
if
(
sta
<
48
||
sta
>
57
)
{
return
"公式填写有误"
;
}
return
result
;
if
(
end
<
48
||
end
>
57
)
{
return
"公式填写有误"
;
}
return
count1
(
value
);
}
private
double
evaluateExpression
(
List
<
Object
>
wagesList
,
String
formula
)
{
String
[]
tokens
=
formula
.
split
(
" "
);
double
result
=
Double
.
parseDouble
(
tokens
[
0
]);
for
(
int
i
=
1
;
i
<
tokens
.
length
-
1
;
i
+=
2
)
{
String
operator
=
tokens
[
i
];
double
operand
=
Double
.
parseDouble
(
tokens
[
i
+
1
]);
switch
(
operator
)
{
case
"+"
:
result
+=
operand
;
break
;
case
"-"
:
result
-=
operand
;
break
;
case
"*"
:
result
*=
operand
;
break
;
case
"/"
:
result
/=
operand
;
break
;
default
:
break
;
private
String
count1
(
String
value
)
{
Pattern
pattern
=
Pattern
.
compile
(
"^-?\\d+(\\.\\d+)?$"
);
if
(
pattern
.
matcher
(
value
).
matches
())
{
return
value
;
}
boolean
a
=
true
;
boolean
b
=
true
;
int
a1
=
-
1
;
int
b1
=
-
1
;
for
(
int
i
=
0
;
i
<
value
.
length
();
i
++)
{
char
charAt
=
value
.
charAt
(
i
);
if
(
FH
.
contains
(
charAt
)
&&
!
a
&&
b
)
{
b
=
false
;
b1
=
i
;
break
;
}
if
(
FH
.
contains
(
charAt
)
&&
a
)
{
a
=
false
;
a1
=
i
;
}
}
return
result
;
if
(
b
)
{
String
sta
=
value
.
substring
(
0
,
a1
);
String
end
=
value
.
substring
(
a1
+
1
);
char
charAt
=
value
.
substring
(
a1
,
a1
+
1
).
charAt
(
0
);
if
(
charAt
==
42
)
{
//*
return
new
BigDecimal
(
sta
).
multiply
(
new
BigDecimal
(
end
)).
toString
();
}
else
if
(
charAt
==
43
)
{
// +
return
new
BigDecimal
(
sta
).
add
(
new
BigDecimal
(
end
)).
toString
();
}
else
if
(
charAt
==
45
)
{
// -
return
new
BigDecimal
(
sta
).
subtract
(
new
BigDecimal
(
end
)).
toString
();
}
else
if
(
charAt
==
47
)
{
// /
return
new
BigDecimal
(
sta
).
divide
(
new
BigDecimal
(
end
)).
toString
();
}
}
else
{
String
sta
=
value
.
substring
(
0
,
a1
);
String
end
=
value
.
substring
(
a1
+
1
,
b1
);
char
charAt
=
value
.
substring
(
a1
,
a1
+
1
).
charAt
(
0
);
String
jg
=
""
;
if
(
charAt
==
42
)
{
//*
jg
=
new
BigDecimal
(
sta
).
multiply
(
new
BigDecimal
(
end
)).
toString
();
}
else
if
(
charAt
==
43
)
{
// +
jg
=
new
BigDecimal
(
sta
).
add
(
new
BigDecimal
(
end
)).
toString
();
}
else
if
(
charAt
==
45
)
{
// -
jg
=
new
BigDecimal
(
sta
).
subtract
(
new
BigDecimal
(
end
)).
toString
();
}
else
if
(
charAt
==
47
)
{
// /
jg
=
new
BigDecimal
(
sta
).
divide
(
new
BigDecimal
(
end
)).
toString
();
}
String
s
=
StringUtils
.
replaceOnce
(
value
,
value
.
substring
(
0
,
b1
),
jg
);
value
=
count1
(
s
);
}
return
value
;
}
private
String
extractOperands
(
String
value
)
{
//解析公式
private
Map
<
String
,
List
<
String
>>
extractOperands
(
String
value
)
{
Map
<
String
,
List
<
String
>>
operandsMap
=
new
HashMap
<>();
List
<
String
>
operands
=
new
ArrayList
<>();
StringBuilder
currentOperand
=
new
StringBuilder
();
List
<
String
>
operators
=
new
ArrayList
<>
();
for
(
int
i
=
0
;
i
<
value
.
length
();
i
++)
{
char
c
=
value
.
charAt
(
i
);
if
(
Character
.
isDigit
(
c
)
||
c
==
'.'
)
{
currentOperand
.
append
(
c
);
}
else
if
(
isOperator
(
c
))
{
String
operand
=
currentOperand
.
toString
().
trim
();
if
(!
operand
.
isEmpty
())
{
operands
.
add
(
operand
);
StringBuilder
operandBuilder
=
new
StringBuilder
();
for
(
char
c
:
value
.
toCharArray
())
{
if
(
isOperator
(
c
))
{
if
(
operandBuilder
.
length
()
>
0
)
{
operands
.
add
(
operandBuilder
.
toString
().
trim
());
operandBuilder
=
new
StringBuilder
();
}
currentOperand
=
new
StringBuilder
();
operands
.
add
(
String
.
valueOf
(
c
));
operators
.
add
(
String
.
valueOf
(
c
));
}
else
{
operandBuilder
.
append
(
c
);
}
}
String
lastOperand
=
currentOperand
.
toString
().
trim
();
if
(!
lastOperand
.
isEmpty
())
{
operands
.
add
(
lastOperand
);
if
(
operandBuilder
.
length
()
>
0
)
{
operands
.
add
(
operandBuilder
.
toString
().
trim
());
}
String
result
=
String
.
join
(
" "
,
operands
);
return
result
;
operandsMap
.
put
(
"operands"
,
operands
);
operandsMap
.
put
(
"operators"
,
operators
);
return
operandsMap
;
}
//判断是否是操作符
private
boolean
isOperator
(
char
c
)
{
return
c
==
'+'
||
c
==
'-'
||
c
==
'*'
||
c
==
'/'
;
}
...
...
ruoyi-wages/src/main/resources/mapper/system/WagesCalculateConversionMapper.xml
deleted
100644 → 0
View file @
bd6b582b
<?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.ruoyi.system.mapper.WagesCalculateConversionMapper"
>
<select
id=
"select"
resultType=
"java.lang.Object"
parameterType=
"java.lang.String"
>
select * from wages_details_original_data where year = #{year}
</select>
</mapper>
\ No newline at end of file
ruoyi-wages/src/main/resources/mapper/system/WagesDetailsOriginalDataMapper.xml
0 → 100644
View file @
a7d70ed9
<?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.ruoyi.system.mapper.WagesDetailsOriginalDataMapper"
>
<resultMap
type=
"com.ruoyi.system.model.wages.dao.WagesDetailsOriginalExcelDAO"
id=
"WagesDetailsOriginalDataResult"
>
<result
property=
"id"
column=
"id"
/>
<result
property=
"year"
column=
"year"
/>
<result
property=
"month"
column=
"month"
/>
<result
property=
"unitName"
column=
"unit_name"
/>
<result
property=
"peopleCount"
column=
"people_count"
/>
<result
property=
"totalWithholding"
column=
"total_withholding"
/>
<result
property=
"netSalary"
column=
"net_salary"
/>
<result
property=
"oneChildFee"
column=
"one_child_fee"
/>
<result
property=
"medicalSubsidy"
column=
"medical_subsidy"
/>
<result
property=
"healthCareFee"
column=
"health_care_fee"
/>
<result
property=
"classMealFee"
column=
"class_meal_fee"
/>
<result
property=
"soapFee"
column=
"soap_fee"
/>
<result
property=
"nursingFee"
column=
"nursing_fee"
/>
<result
property=
"heatstrokePreventionSubsidy"
column=
"heatstroke_prevention_subsidy"
/>
<result
property=
"heatingSubsidy"
column=
"heating_subsidy"
/>
<result
property=
"manuscriptFee"
column=
"manuscript_fee"
/>
<result
property=
"driverAllowance"
column=
"driver_allowance"
/>
<result
property=
"graduateSettlementFee"
column=
"graduate_settlement_fee"
/>
<result
property=
"oneTimeDisabilitySubsidy"
column=
"one_time_disability_subsidy"
/>
<result
property=
"lectureAndExamFee"
column=
"lecture_and_exam_fee"
/>
<result
property=
"otherSubsidies"
column=
"other_subsidies"
/>
<result
property=
"houseRent"
column=
"house_rent"
/>
<result
property=
"wagesPayable"
column=
"Wages_payable"
/>
<result
property=
"accommodation"
column=
"accommodation"
/>
<result
property=
"heatingFee"
column=
"heating_fee"
/>
<result
property=
"tradeUnionDues"
column=
"trade_union_dues"
/>
<result
property=
"compensationDeduction"
column=
"compensation_deduction"
/>
<result
property=
"otherDeductions"
column=
"other_deductions"
/>
<result
property=
"mutualMedicalAid"
column=
"mutual_medical_aid"
/>
<result
property=
"communicationFee"
column=
"communication_fee"
/>
<result
property=
"tax1"
column=
"tax1"
/>
<result
property=
"tax2"
column=
"tax2"
/>
<result
property=
"pensionInsurance"
column=
"pension_insurance"
/>
<result
property=
"unemploymentInsurance"
column=
"unemployment_insurance"
/>
<result
property=
"medicalInsurance"
column=
"medical_insurance"
/>
<result
property=
"annuity"
column=
"annuity"
/>
<result
property=
"housingProvidentFund"
column=
"housing_provident_fund"
/>
<result
property=
"enterpriseFund"
column=
"enterprise_fund"
/>
<result
property=
"annuityIncomeTax"
column=
"annuity_income_tax"
/>
<result
property=
"totalPayment"
column=
"total_payment"
/>
<result
property=
"totalSalaryDisbursement"
column=
"total_salary_disbursement"
/>
</resultMap>
<sql
id=
"selectWagesDetailsOriginalDataVo"
>
select id, ssk_id, year, month, unit_name, people_count, total_withholding, net_salary, one_child_fee, medical_subsidy, health_care_fee, class_meal_fee, soap_fee, nursing_fee, heatstroke_prevention_subsidy, heating_subsidy, manuscript_fee, driver_allowance, graduate_settlement_fee, one_time_disability_subsidy, lecture_and_exam_fee, other_subsidies, house_rent, Wages_payable, accommodation, heating_fee, trade_union_dues, compensation_deduction, other_deductions, mutual_medical_aid, communication_fee, tax1, tax2, pension_insurance, unemployment_insurance, medical_insurance, annuity, housing_provident_fund, enterprise_fund, annuity_income_tax, total_payment, total_salary_disbursement from wages_details_original_data
</sql>
<select
id=
"selectAll"
parameterType=
"com.ruoyi.system.model.wages.dao.WagesDetailsOriginalExcelDAO"
resultMap=
"WagesDetailsOriginalDataResult"
>
<include
refid=
"selectWagesDetailsOriginalDataVo"
/>
<where>
<if
test=
"sskId != null and sskId != ''"
>
and ssk_id = #{sskId}
</if>
<if
test=
"year != null and year != ''"
>
and year = #{year}
</if>
<if
test=
"month != null and month != ''"
>
and month = #{month}
</if>
<if
test=
"unitName != null and unitName != ''"
>
and unit_name like concat('%', #{unitName}, '%')
</if>
<if
test=
"peopleCount != null "
>
and people_count = #{peopleCount}
</if>
<if
test=
"totalWithholding != null "
>
and total_withholding = #{totalWithholding}
</if>
<if
test=
"netSalary != null "
>
and net_salary = #{netSalary}
</if>
<if
test=
"oneChildFee != null "
>
and one_child_fee = #{oneChildFee}
</if>
<if
test=
"medicalSubsidy != null "
>
and medical_subsidy = #{medicalSubsidy}
</if>
<if
test=
"healthCareFee != null "
>
and health_care_fee = #{healthCareFee}
</if>
<if
test=
"classMealFee != null "
>
and class_meal_fee = #{classMealFee}
</if>
<if
test=
"soapFee != null "
>
and soap_fee = #{soapFee}
</if>
<if
test=
"nursingFee != null "
>
and nursing_fee = #{nursingFee}
</if>
<if
test=
"heatstrokePreventionSubsidy != null "
>
and heatstroke_prevention_subsidy = #{heatstrokePreventionSubsidy}
</if>
<if
test=
"heatingSubsidy != null "
>
and heating_subsidy = #{heatingSubsidy}
</if>
<if
test=
"manuscriptFee != null "
>
and manuscript_fee = #{manuscriptFee}
</if>
<if
test=
"driverAllowance != null "
>
and driver_allowance = #{driverAllowance}
</if>
<if
test=
"graduateSettlementFee != null "
>
and graduate_settlement_fee = #{graduateSettlementFee}
</if>
<if
test=
"oneTimeDisabilitySubsidy != null "
>
and one_time_disability_subsidy = #{oneTimeDisabilitySubsidy}
</if>
<if
test=
"lectureAndExamFee != null "
>
and lecture_and_exam_fee = #{lectureAndExamFee}
</if>
<if
test=
"otherSubsidies != null "
>
and other_subsidies = #{otherSubsidies}
</if>
<if
test=
"houseRent != null "
>
and house_rent = #{houseRent}
</if>
<if
test=
"wagesPayable != null "
>
and Wages_payable = #{wagesPayable}
</if>
<if
test=
"accommodation != null "
>
and accommodation = #{accommodation}
</if>
<if
test=
"heatingFee != null "
>
and heating_fee = #{heatingFee}
</if>
<if
test=
"tradeUnionDues != null "
>
and trade_union_dues = #{tradeUnionDues}
</if>
<if
test=
"compensationDeduction != null "
>
and compensation_deduction = #{compensationDeduction}
</if>
<if
test=
"otherDeductions != null "
>
and other_deductions = #{otherDeductions}
</if>
<if
test=
"mutualMedicalAid != null "
>
and mutual_medical_aid = #{mutualMedicalAid}
</if>
<if
test=
"communicationFee != null "
>
and communication_fee = #{communicationFee}
</if>
<if
test=
"tax1 != null "
>
and tax1 = #{tax1}
</if>
<if
test=
"tax2 != null "
>
and tax2 = #{tax2}
</if>
<if
test=
"pensionInsurance != null "
>
and pension_insurance = #{pensionInsurance}
</if>
<if
test=
"unemploymentInsurance != null "
>
and unemployment_insurance = #{unemploymentInsurance}
</if>
<if
test=
"medicalInsurance != null "
>
and medical_insurance = #{medicalInsurance}
</if>
<if
test=
"annuity != null "
>
and annuity = #{annuity}
</if>
<if
test=
"housingProvidentFund != null "
>
and housing_provident_fund = #{housingProvidentFund}
</if>
<if
test=
"enterpriseFund != null "
>
and enterprise_fund = #{enterpriseFund}
</if>
<if
test=
"annuityIncomeTax != null "
>
and annuity_income_tax = #{annuityIncomeTax}
</if>
<if
test=
"totalPayment != null "
>
and total_payment = #{totalPayment}
</if>
<if
test=
"totalSalaryDisbursement != null "
>
and total_salary_disbursement = #{totalSalaryDisbursement}
</if>
</where>
</select>
</mapper>
\ No newline at end of file
ruoyi-wages/src/main/resources/mapper/system/WagesOverviewOriginalDataMapper.xml
0 → 100644
View file @
a7d70ed9
<?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.ruoyi.system.mapper.WagesOverviewOriginalDateMapper"
>
<resultMap
type=
"com.ruoyi.system.model.wages.dao.WagesOverviewOriginalExcelDAO"
id=
"WagesOverviewOriginalDataResult"
>
<result
property=
"year"
column=
"year"
/>
<result
property=
"month"
column=
"month"
/>
<result
property=
"unitCode"
column=
"unit_code"
/>
<result
property=
"unitName"
column=
"unit_name"
/>
<result
property=
"workerCount"
column=
"worker_count"
/>
<result
property=
"workerWagesPayable"
column=
"worker_wages_payable"
/>
<result
property=
"cadreCount"
column=
"cadre_count"
/>
<result
property=
"cadreWagesPayable"
column=
"cadre_wages_payable"
/>
<result
property=
"totalCount"
column=
"total_count"
/>
<result
property=
"totalWagesPayable"
column=
"total_wages_payable"
/>
</resultMap>
<sql
id=
"selectWagesOverviewOriginalDataVo"
>
select id, year, month, unit_code, unit_name, worker_count, worker_wages_payable, cadre_count, cadre_wages_payable, total_count, total_wages_payable from wages_overview_original_data
</sql>
<select
id=
"selectAll"
parameterType=
"com.ruoyi.system.model.wages.dao.WagesOverviewOriginalExcelDAO"
resultMap=
"WagesOverviewOriginalDataResult"
>
<include
refid=
"selectWagesOverviewOriginalDataVo"
/>
<where>
<if
test=
"year != null and year != ''"
>
and year = #{year}
</if>
<if
test=
"month != null and month != ''"
>
and month = #{month}
</if>
<if
test=
"unitCode != null and unitCode != ''"
>
and unit_code = #{unitCode}
</if>
<if
test=
"unitName != null and unitName != ''"
>
and unit_name like concat('%', #{unitName}, '%')
</if>
<if
test=
"workerCount != null "
>
and worker_count = #{workerCount}
</if>
<if
test=
"workerWagesPayable != null "
>
and worker_wages_payable = #{workerWagesPayable}
</if>
<if
test=
"cadreCount != null "
>
and cadre_count = #{cadreCount}
</if>
<if
test=
"cadreWagesPayable != null "
>
and cadre_wages_payable = #{cadreWagesPayable}
</if>
<if
test=
"totalCount != null "
>
and total_count = #{totalCount}
</if>
<if
test=
"totalWagesPayable != null "
>
and total_wages_payable = #{totalWagesPayable}
</if>
</where>
</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