Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
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
项目统一框架
amos-boot-biz
Commits
9e326fe7
Commit
9e326fe7
authored
Nov 16, 2023
by
tianyiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
两个规定-三项制度统计优化
parent
8fc4bbc7
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
246 additions
and
237 deletions
+246
-237
ThreeSystemsMapper.java
...n/amos/boot/module/tcm/api/mapper/ThreeSystemsMapper.java
+3
-1
ThreeSystemsMapper.xml
...-tcm-api/src/main/resources/mapper/ThreeSystemsMapper.xml
+8
-9
ThreeSystemsController.java
...oot/module/tcm/biz/controller/ThreeSystemsController.java
+1
-1
ThreeSystemsServiceImpl.java
.../module/tcm/biz/service/impl/ThreeSystemsServiceImpl.java
+233
-226
TzsTwoStaffingServiceImpl.java
...odule/tcm/biz/service/impl/TzsTwoStaffingServiceImpl.java
+1
-0
No files found.
amos-boot-system-tzs/amos-boot-module-tcm/amos-boot-module-tcm-api/src/main/java/com/yeejoin/amos/boot/module/tcm/api/mapper/ThreeSystemsMapper.java
View file @
9e326fe7
...
...
@@ -15,7 +15,9 @@ import java.util.List;
*/
public
interface
ThreeSystemsMapper
extends
BaseMapper
<
ThreeSystems
>
{
List
<
ThreeSystemsDto
>
getCompanyThreeSystemsStatisticsList
(
@Param
(
"type"
)
Integer
type
,
@Param
(
"startDay"
)
String
startDay
,
@Param
(
"endDay"
)
String
endDay
);
List
<
ThreeSystemsDto
>
getCompanyThreeSystemsStatisticsList
(
@Param
(
"staticTableName"
)
String
staticTableName
,
@Param
(
"startDay"
)
String
startDay
,
@Param
(
"endDay"
)
String
endDay
);
void
saveOrUpdateBatch
(
@Param
(
"resultList"
)
List
<
ThreeSystems
>
resultList
);
...
...
amos-boot-system-tzs/amos-boot-module-tcm/amos-boot-module-tcm-api/src/main/resources/mapper/ThreeSystemsMapper.xml
View file @
9e326fe7
...
...
@@ -10,27 +10,26 @@
ei.supervise_org_code supervisoryUnitOrgCode,
ei.unit_type unitType,
CASE
WHEN (
SELECT COUNT
( 1 )
FROM
amos_tzs_biz.p_plan_task
pt
${staticTableName}
pt
WHERE
pt.finish_status = '2'
AND ppt.use_code = pt.use_code
AND pt.check_date BETWEEN #{startDay}
pt.not_start = 0
AND pt.time_out = 0
AND (pt.risk_end > 0 or pt.no_risk_end > 0)
AND psd.unit_code = pt.unit_code
AND pt.check_time BETWEEN #{startDay}
AND #{endDay}
AND pt.plan_type = #{type}
) > 0 THEN
1 ELSE 0
END AS checkStatus
FROM
amos_tzs_biz.
tz_base_enterprise_info ei
LEFT JOIN
amos_tzs_biz.p_plan_task ppt ON ei.use_code = ppt.use
_code
tz_base_enterprise_info ei
LEFT JOIN
${staticTableName} psd ON ei.use_code = psd.unit
_code
GROUP BY
ei.use_code
</select>
<select
id=
"saveOrUpdateBatch"
>
...
...
amos-boot-system-tzs/amos-boot-module-tcm/amos-boot-module-tcm-biz/src/main/java/com/yeejoin/amos/boot/module/tcm/biz/controller/ThreeSystemsController.java
View file @
9e326fe7
...
...
@@ -24,7 +24,7 @@ import java.util.LinkedHashMap;
import
java.util.List
;
@RestController
@Api
(
tags
=
"三个
规定
统计"
)
@Api
(
tags
=
"三个
制度
统计"
)
@RequestMapping
(
value
=
"/threeProvisions"
)
public
class
ThreeSystemsController
<
string
>
extends
BaseController
{
private
static
final
String
REGULATOR_UNIT_TREE
=
"REGULATOR_UNIT_TREE"
;
...
...
amos-boot-system-tzs/amos-boot-module-tcm/amos-boot-module-tcm-biz/src/main/java/com/yeejoin/amos/boot/module/tcm/biz/service/impl/ThreeSystemsServiceImpl.java
View file @
9e326fe7
...
...
@@ -103,230 +103,236 @@ public class ThreeSystemsServiceImpl extends BaseService<ThreeSystemsDto, ThreeS
}
@Override
public
void
getThreeSystemsStatistics
(
String
type
)
{
if
(
type
.
equals
(
"1"
))
{
createDayThreeSystemsStatistics
();
}
else
if
(
type
.
equals
(
"2"
))
{
createWeekThreeSystemsStatistics
();
}
else
if
(
type
.
equals
(
"3"
))
{
createMonthThreeSystemsStatistics
();
}
}
@Scheduled
(
cron
=
"0 0 2,13 * * ?"
)
@SchedulerLock
(
name
=
"createDayThreeSystemsStatistics"
,
lockAtMostFor
=
"PT1H"
)
public
void
createDayThreeSystemsStatistics
()
{
createThreeSystemsStatistics
(
1
,
false
);
}
@Scheduled
(
cron
=
"0 0 2,13 * * ?"
)
@SchedulerLock
(
name
=
"createWeekThreeSystemsStatistics"
,
lockAtMostFor
=
"PT1H"
)
public
void
createWeekThreeSystemsStatistics
()
{
Date
nowDay
=
new
Date
();
String
day
=
DateUtils
.
convertDateToString
(
nowDay
,
DateUtils
.
DATE_HOUR_PATTERN
);
Calendar
c
=
DateUtils
.
getCalendar
();
c
.
set
(
Calendar
.
DAY_OF_WEEK
,
Calendar
.
MONDAY
);
String
monday
=
DateUtils
.
convertDateToString
(
c
.
getTime
(),
DateUtils
.
DATE_HOUR_PATTERN
);
Boolean
flag
=
false
;
//判断今天是否本周第一天凌晨2点,如果是则最后一次更新上月数据
if
(
day
.
equals
(
monday
))
{
flag
=
true
;
}
createThreeSystemsStatistics
(
2
,
flag
);
}
@Scheduled
(
cron
=
"0 0 2,13 * * ?"
)
@SchedulerLock
(
name
=
"createMonthThreeSystemsStatistics"
,
lockAtMostFor
=
"PT1H"
)
public
void
createMonthThreeSystemsStatistics
()
{
Date
nowDay
=
new
Date
();
String
day
=
DateUtils
.
convertDateToString
(
nowDay
,
DateUtils
.
DATE_HOUR_PATTERN
);
String
monthday
=
DateUtils
.
convertDateToString
(
nowDay
,
DateUtils
.
MONTH_PATTERN
)
+
"-01 02"
;
Boolean
flag
=
false
;
//判断今天是否本月第一天凌晨2点,如果是则最后一次更新上月数据
if
(
day
.
equals
(
monthday
))
{
flag
=
true
;
}
createThreeSystemsStatistics
(
3
,
flag
);
}
private
void
createThreeSystemsStatistics
(
Integer
type
,
Boolean
isFirstDay
)
{
// 所有监管单位列表
List
<
LinkedHashMap
<
String
,
Object
>>
supervisionList
=
tzsTwoStaffingService
.
getSupervisionList
();
List
<
ThreeSystems
>
resultList
;
// 所有企业排查情况列表(昨天/上周/上月)
List
<
ThreeSystemsDto
>
oldStaffingCompanyList
;
// 所有企业排查情况列表(今天/本周/本月)
List
<
ThreeSystemsDto
>
newStaffingCompanyList
;
String
start
=
" 00:00:00"
;
String
end
=
" 23:59:59"
;
Date
nowDay
=
new
Date
();
String
day
=
DateUtils
.
getDateNowShortStr
();
String
hour
=
DateUtils
.
convertDateToString
(
nowDay
,
DateUtils
.
DATE_HOUR_PATTERN
);
String
startDay
=
""
;
String
endDay
=
""
;
String
lastStart
=
""
;
String
lastEnd
=
""
;
// 根据类型设置不同的时间
if
(
1
==
type
)
{
startDay
=
day
+
start
;
endDay
=
day
+
end
;
if
(
hour
.
endsWith
(
"02"
))
{
LocalDate
today
=
LocalDate
.
now
();
// 获取昨天日期
LocalDate
yesterday
=
today
.
minusDays
(
1
);
lastStart
=
yesterday
+
start
;
lastEnd
=
yesterday
+
end
;
}
}
else
if
(
2
==
type
)
{
//获取当前周第一天:
Calendar
c
=
DateUtils
.
getCalendar
();
c
.
set
(
Calendar
.
DAY_OF_WEEK
,
Calendar
.
MONDAY
);
startDay
=
DateUtils
.
convertDateToString
(
c
.
getTime
(),
DateUtils
.
DATE_PATTERN
)
+
start
;
//获取当前周最后一天
c
.
add
(
Calendar
.
DAY_OF_WEEK
,
6
);
endDay
=
DateUtils
.
convertDateToString
(
c
.
getTime
(),
DateUtils
.
DATE_PATTERN
)
+
end
;
if
(
isFirstDay
)
{
//获取上前周第一天
c
.
add
(
Calendar
.
DAY_OF_WEEK
,
-
13
);
lastStart
=
DateUtils
.
convertDateToString
(
c
.
getTime
(),
DateUtils
.
DATE_PATTERN
)
+
start
;
//获取上前周最后一天
c
.
add
(
Calendar
.
DAY_OF_WEEK
,
6
);
lastEnd
=
DateUtils
.
convertDateToString
(
c
.
getTime
(),
DateUtils
.
DATE_PATTERN
)
+
end
;
}
}
else
{
//获取当前月第一天:
Calendar
c
=
DateUtils
.
getCalendar
();
c
.
add
(
Calendar
.
MONTH
,
0
);
c
.
set
(
Calendar
.
DAY_OF_MONTH
,
1
);
//设置为1号,当前日期既为本月第一天
startDay
=
DateUtils
.
convertDateToString
(
c
.
getTime
(),
DateUtils
.
DATE_PATTERN
)
+
start
;
//获取当前月最后一天
c
.
set
(
Calendar
.
DAY_OF_MONTH
,
c
.
getActualMaximum
(
Calendar
.
DAY_OF_MONTH
));
endDay
=
DateUtils
.
convertDateToString
(
c
.
getTime
(),
DateUtils
.
DATE_PATTERN
)
+
end
;
if
(
isFirstDay
)
{
//获取上月第一天
c
.
add
(
Calendar
.
MONTH
,
-
1
);
c
.
set
(
Calendar
.
DAY_OF_MONTH
,
1
);
//设置为1号,当前日期既为本月第一天
lastStart
=
DateUtils
.
convertDateToString
(
c
.
getTime
(),
DateUtils
.
DATE_PATTERN
)
+
start
;
//获取上月最后一天
c
.
set
(
Calendar
.
DAY_OF_MONTH
,
c
.
getActualMaximum
(
Calendar
.
DAY_OF_MONTH
));
lastEnd
=
DateUtils
.
convertDateToString
(
c
.
getTime
(),
DateUtils
.
DATE_PATTERN
)
+
end
;
}
}
//获取当天、本周、本月新的数据
newStaffingCompanyList
=
threeSystemsMapper
.
getCompanyThreeSystemsStatisticsList
(
type
,
startDay
,
endDay
);
//调用三项制度统计方法处理数据
resultList
=
getThreeSystems
(
supervisionList
,
newStaffingCompanyList
,
type
,
startDay
,
true
);
//将新数据存入统计表中
threeSystemsMapper
.
saveOrUpdateBatch
(
resultList
);
List
<
ThreeSystems
>
oldList
;
//根据lastStart和lastEnd判断是否需要更新日/周/月的历史数据(为空不更新)
if
(!
""
.
equals
(
lastStart
)
&&
!
""
.
equals
(
lastEnd
))
{
//获取日/周/月的历史数据
oldStaffingCompanyList
=
threeSystemsMapper
.
getOldCompanyThreeSystemsStatisticsList
(
type
,
DateUtils
.
dateToString
(
lastStart
));
//获取日/周/月历史数据的最新状态数据
List
<
ThreeSystemsDto
>
oldNewStaffingCompanyList
=
threeSystemsMapper
.
getCompanyThreeSystemsStatisticsList
(
type
,
lastStart
,
lastEnd
);
if
(!
ValidationUtil
.
isEmpty
(
oldNewStaffingCompanyList
))
{
// 调用三项制度统计方法处理数据
oldList
=
ValidationUtil
.
isEmpty
(
oldStaffingCompanyList
)
?
getThreeSystems
(
supervisionList
,
oldNewStaffingCompanyList
,
type
,
lastStart
,
true
)
:
getThreeSystems
(
supervisionList
,
oldNewStaffingCompanyList
,
type
,
lastStart
,
false
);
//如果历史数据不为空,更新历史数据实体
if
(!
ValidationUtil
.
isEmpty
(
oldStaffingCompanyList
))
{
if
(!
ValidationUtil
.
isEmpty
(
oldList
))
{
for
(
ThreeSystems
e
:
oldList
)
{
ThreeSystemsDto
threeSystemsDto
=
oldStaffingCompanyList
.
stream
().
filter
(
i
->
i
.
getSupervisoryUnitOrgCode
().
equals
(
e
.
getSupervisoryUnitOrgCode
())
&&
i
.
getCheckDate
().
equals
(
e
.
getCheckDate
())).
collect
(
Collectors
.
toList
()).
get
(
0
);
e
.
setSequenceNbr
(
threeSystemsDto
.
getSequenceNbr
());
}
}
}
//更新统计表历史数据
threeSystemsMapper
.
saveOrUpdateBatch
(
oldList
);
}
}
}
/**
* 三项制度统计数据方法
* @param supervisionList 行政区划列表
* @param StaffingCompanyList 需要统计处理的数据列表
* @param type 统计类型
* @param date 统计日期,做筛选用,日统计传当天日期,周统计传周一日期,月统计传月一号日期
* @param isNew 是否新数据,新数据会生成主键
* @return
*/
private
List
<
ThreeSystems
>
getThreeSystems
(
List
<
LinkedHashMap
<
String
,
Object
>>
supervisionList
,
List
<
ThreeSystemsDto
>
StaffingCompanyList
,
Integer
type
,
String
date
,
boolean
isNew
)
{
List
<
ThreeSystems
>
resultList
=
new
ArrayList
<>();
supervisionList
.
forEach
(
i
->
{
ThreeSystemsDto
nowDayThreeSystemsDto
=
new
ThreeSystemsDto
();
//对应orgCode下所有注册企业列表
List
<
ThreeSystemsDto
>
allUnit
=
StaffingCompanyList
.
stream
().
filter
(
ii
->
ii
.
getSupervisoryUnitOrgCode
().
startsWith
(
i
.
get
(
"orgCode"
).
toString
())).
collect
(
Collectors
.
toList
());
//对应注册企业下所有应排查的企业列表
List
<
ThreeSystemsDto
>
shouldCheckUnit
=
allUnit
.
stream
().
filter
(
ii
->
!(
ii
.
getUnitType
().
contains
(
"个人主体"
)
||
ii
.
getUnitType
().
equals
(
"检验检测机构"
))).
collect
(
Collectors
.
toList
());
//应排查的企业下已排查完成的企业列表
List
<
ThreeSystemsDto
>
checkCompleteUnit
=
shouldCheckUnit
.
stream
().
filter
(
ii
->
"1"
.
equals
(
ii
.
getCheckStatus
())).
collect
(
Collectors
.
toList
());
if
(
isNew
)
{
try
{
nowDayThreeSystemsDto
.
setSequenceNbr
(
IdWorker
.
getFlowIdWorkerInstance
().
nextId
());
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
}
nowDayThreeSystemsDto
.
setRecDate
(
new
Date
());
nowDayThreeSystemsDto
.
setRecUserId
(
amosRequestContext
.
getUserId
());
nowDayThreeSystemsDto
.
setRecUserName
(
amosRequestContext
.
getUserName
());
nowDayThreeSystemsDto
.
setIsDelete
(
false
);
nowDayThreeSystemsDto
.
setSupervisoryUnitId
(
i
.
get
(
"sequenceNbr"
).
toString
());
nowDayThreeSystemsDto
.
setSupervisoryUnitLevel
(
i
.
get
(
"level"
).
toString
());
nowDayThreeSystemsDto
.
setSupervisoryUnitName
(
i
.
get
(
"companyName"
).
toString
());
nowDayThreeSystemsDto
.
setRegisteredNum
(
allUnit
.
size
());
nowDayThreeSystemsDto
.
setCheckNum
(
shouldCheckUnit
.
size
());
nowDayThreeSystemsDto
.
setFinishCheckNum
(
checkCompleteUnit
.
size
());
nowDayThreeSystemsDto
.
setSupervisoryUnitOrgCode
(
i
.
get
(
"orgCode"
).
toString
());
nowDayThreeSystemsDto
.
setPlanType
(
1
==
type
?
"1"
:
2
==
type
?
"2"
:
"3"
);
nowDayThreeSystemsDto
.
setCheckDate
(
DateUtils
.
dateToString
(
date
));
if
(
shouldCheckUnit
.
size
()
==
0
)
{
nowDayThreeSystemsDto
.
setProportion
(
"0%"
);
}
else
{
DecimalFormat
decimalFormat
=
new
DecimalFormat
(
"0.##"
);
BigDecimal
result
=
new
BigDecimal
(
checkCompleteUnit
.
size
()).
divide
(
new
BigDecimal
(
shouldCheckUnit
.
size
()),
4
,
RoundingMode
.
HALF_UP
);
nowDayThreeSystemsDto
.
setProportion
(
decimalFormat
.
format
(
result
.
multiply
(
new
BigDecimal
(
100
)))
+
"%"
);
}
ThreeSystems
threeSystems
=
new
ThreeSystems
();
BeanUtils
.
copyProperties
(
nowDayThreeSystemsDto
,
threeSystems
);
resultList
.
add
(
threeSystems
);
});
return
resultList
;
}
@Override
public
void
getThreeSystemsStatistics
(
String
type
)
{
if
(
type
.
equals
(
"1"
))
{
createDayThreeSystemsStatistics
();
}
else
if
(
type
.
equals
(
"2"
))
{
createWeekThreeSystemsStatistics
();
}
else
if
(
type
.
equals
(
"3"
))
{
createMonthThreeSystemsStatistics
();
}
}
@Scheduled
(
cron
=
"0 0 2,13 * * ?"
)
@SchedulerLock
(
name
=
"createDayThreeSystemsStatistics"
,
lockAtMostFor
=
"PT1H"
)
public
void
createDayThreeSystemsStatistics
()
{
createThreeSystemsStatistics
(
1
,
false
);
}
@Scheduled
(
cron
=
"0 0 2,13 * * ?"
)
@SchedulerLock
(
name
=
"createWeekThreeSystemsStatistics"
,
lockAtMostFor
=
"PT1H"
)
public
void
createWeekThreeSystemsStatistics
()
{
Date
nowDay
=
new
Date
();
String
day
=
DateUtils
.
convertDateToString
(
nowDay
,
DateUtils
.
DATE_HOUR_PATTERN
);
Calendar
c
=
DateUtils
.
getCalendar
();
c
.
set
(
Calendar
.
DAY_OF_WEEK
,
Calendar
.
MONDAY
);
String
monday
=
DateUtils
.
convertDateToString
(
c
.
getTime
(),
DateUtils
.
DATE_HOUR_PATTERN
);
Boolean
flag
=
false
;
//判断今天是否本周第一天凌晨2点,如果是则最后一次更新上月数据
if
(
day
.
equals
(
monday
))
{
flag
=
true
;
}
createThreeSystemsStatistics
(
2
,
flag
);
}
@Scheduled
(
cron
=
"0 0 2,13 * * ?"
)
@SchedulerLock
(
name
=
"createMonthThreeSystemsStatistics"
,
lockAtMostFor
=
"PT1H"
)
public
void
createMonthThreeSystemsStatistics
()
{
Date
nowDay
=
new
Date
();
String
day
=
DateUtils
.
convertDateToString
(
nowDay
,
DateUtils
.
DATE_HOUR_PATTERN
);
String
monthday
=
DateUtils
.
convertDateToString
(
nowDay
,
DateUtils
.
MONTH_PATTERN
)
+
"-01 02"
;
Boolean
flag
=
false
;
//判断今天是否本月第一天凌晨2点,如果是则最后一次更新上月数据
if
(
day
.
equals
(
monthday
))
{
flag
=
true
;
}
createThreeSystemsStatistics
(
3
,
flag
);
}
private
void
createThreeSystemsStatistics
(
Integer
type
,
Boolean
isFirstDay
)
{
// 所有监管单位列表
List
<
LinkedHashMap
<
String
,
Object
>>
supervisionList
=
tzsTwoStaffingService
.
getSupervisionList
();
List
<
ThreeSystems
>
resultList
;
// 所有企业排查情况列表(昨天/上周/上月)
List
<
ThreeSystemsDto
>
oldStaffingCompanyList
;
// 所有企业排查情况列表(今天/本周/本月)
List
<
ThreeSystemsDto
>
newStaffingCompanyList
;
String
start
=
" 00:00:00"
;
String
end
=
" 23:59:59"
;
Date
nowDay
=
new
Date
();
String
day
=
DateUtils
.
getDateNowShortStr
();
String
hour
=
DateUtils
.
convertDateToString
(
nowDay
,
DateUtils
.
DATE_HOUR_PATTERN
);
String
startDay
=
""
;
String
endDay
=
""
;
String
lastStart
=
""
;
String
lastEnd
=
""
;
// 根据类型设置不同的时间
if
(
1
==
type
)
{
startDay
=
day
+
start
;
endDay
=
day
+
end
;
if
(
hour
.
endsWith
(
"02"
))
{
LocalDate
today
=
LocalDate
.
now
();
// 获取昨天日期
LocalDate
yesterday
=
today
.
minusDays
(
1
);
lastStart
=
yesterday
+
start
;
lastEnd
=
yesterday
+
end
;
}
}
else
if
(
2
==
type
)
{
//获取当前周第一天:
Calendar
c
=
DateUtils
.
getCalendar
();
c
.
set
(
Calendar
.
DAY_OF_WEEK
,
Calendar
.
MONDAY
);
startDay
=
DateUtils
.
convertDateToString
(
c
.
getTime
(),
DateUtils
.
DATE_PATTERN
)
+
start
;
//获取当前周最后一天
c
.
add
(
Calendar
.
DAY_OF_WEEK
,
6
);
endDay
=
DateUtils
.
convertDateToString
(
c
.
getTime
(),
DateUtils
.
DATE_PATTERN
)
+
end
;
if
(
isFirstDay
)
{
//获取上前周第一天
c
.
add
(
Calendar
.
DAY_OF_WEEK
,
-
13
);
lastStart
=
DateUtils
.
convertDateToString
(
c
.
getTime
(),
DateUtils
.
DATE_PATTERN
)
+
start
;
//获取上前周最后一天
c
.
add
(
Calendar
.
DAY_OF_WEEK
,
6
);
lastEnd
=
DateUtils
.
convertDateToString
(
c
.
getTime
(),
DateUtils
.
DATE_PATTERN
)
+
end
;
}
}
else
{
//获取当前月第一天:
Calendar
c
=
DateUtils
.
getCalendar
();
c
.
add
(
Calendar
.
MONTH
,
0
);
c
.
set
(
Calendar
.
DAY_OF_MONTH
,
1
);
//设置为1号,当前日期既为本月第一天
startDay
=
DateUtils
.
convertDateToString
(
c
.
getTime
(),
DateUtils
.
DATE_PATTERN
)
+
start
;
//获取当前月最后一天
c
.
set
(
Calendar
.
DAY_OF_MONTH
,
c
.
getActualMaximum
(
Calendar
.
DAY_OF_MONTH
));
endDay
=
DateUtils
.
convertDateToString
(
c
.
getTime
(),
DateUtils
.
DATE_PATTERN
)
+
end
;
if
(
isFirstDay
)
{
//获取上月第一天
c
.
add
(
Calendar
.
MONTH
,
-
1
);
c
.
set
(
Calendar
.
DAY_OF_MONTH
,
1
);
//设置为1号,当前日期既为本月第一天
lastStart
=
DateUtils
.
convertDateToString
(
c
.
getTime
(),
DateUtils
.
DATE_PATTERN
)
+
start
;
//获取上月最后一天
c
.
set
(
Calendar
.
DAY_OF_MONTH
,
c
.
getActualMaximum
(
Calendar
.
DAY_OF_MONTH
));
lastEnd
=
DateUtils
.
convertDateToString
(
c
.
getTime
(),
DateUtils
.
DATE_PATTERN
)
+
end
;
}
}
// todo 此处统计表名通过接口查询得到 接口暂未实现
String
planType
=
type
.
toString
();
String
staticTableName
=
"p_static_day"
;
//获取当天、本周、本月新的数据
newStaffingCompanyList
=
threeSystemsMapper
.
getCompanyThreeSystemsStatisticsList
(
staticTableName
,
startDay
,
endDay
);
//调用三项制度统计方法处理数据
resultList
=
getThreeSystems
(
supervisionList
,
newStaffingCompanyList
,
type
,
startDay
,
true
);
//将新数据存入统计表中
threeSystemsMapper
.
saveOrUpdateBatch
(
resultList
);
List
<
ThreeSystems
>
oldList
;
//根据lastStart和lastEnd判断是否需要更新日/周/月的历史数据(为空不更新)
if
(!
""
.
equals
(
lastStart
)
&&
!
""
.
equals
(
lastEnd
))
{
//获取日/周/月的历史数据
oldStaffingCompanyList
=
threeSystemsMapper
.
getOldCompanyThreeSystemsStatisticsList
(
type
,
DateUtils
.
dateToString
(
lastStart
));
//获取日/周/月历史数据的最新状态数据
// todo 此处统计表名通过接口查询得到 接口暂未实现
List
<
ThreeSystemsDto
>
oldNewStaffingCompanyList
=
threeSystemsMapper
.
getCompanyThreeSystemsStatisticsList
(
staticTableName
,
lastStart
,
lastEnd
);
if
(!
ValidationUtil
.
isEmpty
(
oldNewStaffingCompanyList
))
{
// 调用三项制度统计方法处理数据
oldList
=
ValidationUtil
.
isEmpty
(
oldStaffingCompanyList
)
?
getThreeSystems
(
supervisionList
,
oldNewStaffingCompanyList
,
type
,
lastStart
,
true
)
:
getThreeSystems
(
supervisionList
,
oldNewStaffingCompanyList
,
type
,
lastStart
,
false
);
//如果历史数据不为空,更新历史数据实体
if
(!
ValidationUtil
.
isEmpty
(
oldStaffingCompanyList
))
{
if
(!
ValidationUtil
.
isEmpty
(
oldList
))
{
for
(
ThreeSystems
e
:
oldList
)
{
ThreeSystemsDto
threeSystemsDto
=
oldStaffingCompanyList
.
stream
().
filter
(
i
->
i
.
getSupervisoryUnitOrgCode
().
equals
(
e
.
getSupervisoryUnitOrgCode
())
&&
i
.
getCheckDate
().
equals
(
e
.
getCheckDate
())).
collect
(
Collectors
.
toList
()).
get
(
0
);
e
.
setSequenceNbr
(
threeSystemsDto
.
getSequenceNbr
());
}
}
}
//更新统计表历史数据
threeSystemsMapper
.
saveOrUpdateBatch
(
oldList
);
}
}
}
/**
* 三项制度统计数据方法
*
* @param supervisionList 行政区划列表
* @param StaffingCompanyList 需要统计处理的数据列表
* @param type 统计类型
* @param date 统计日期,做筛选用,日统计传当天日期,周统计传周一日期,月统计传月一号日期
* @param isNew 是否新数据,新数据会生成主键
* @return
*/
private
List
<
ThreeSystems
>
getThreeSystems
(
List
<
LinkedHashMap
<
String
,
Object
>>
supervisionList
,
List
<
ThreeSystemsDto
>
StaffingCompanyList
,
Integer
type
,
String
date
,
boolean
isNew
)
{
List
<
ThreeSystems
>
resultList
=
new
ArrayList
<>();
supervisionList
.
forEach
(
i
->
{
ThreeSystemsDto
nowDayThreeSystemsDto
=
new
ThreeSystemsDto
();
//对应orgCode下所有注册企业列表
List
<
ThreeSystemsDto
>
allUnit
=
StaffingCompanyList
.
stream
().
filter
(
ii
->
ii
.
getSupervisoryUnitOrgCode
().
startsWith
(
i
.
get
(
"orgCode"
).
toString
())).
collect
(
Collectors
.
toList
());
//对应注册企业下所有应排查的企业列表
List
<
ThreeSystemsDto
>
shouldCheckUnit
=
allUnit
.
stream
().
filter
(
ii
->
!(
ii
.
getUnitType
().
contains
(
"个人主体"
)
||
ii
.
getUnitType
().
equals
(
"检验检测机构"
))).
collect
(
Collectors
.
toList
());
//应排查的企业下已排查完成的企业列表
List
<
ThreeSystemsDto
>
checkCompleteUnit
=
shouldCheckUnit
.
stream
().
filter
(
ii
->
"1"
.
equals
(
ii
.
getCheckStatus
())).
collect
(
Collectors
.
toList
());
if
(
isNew
)
{
try
{
nowDayThreeSystemsDto
.
setSequenceNbr
(
IdWorker
.
getFlowIdWorkerInstance
().
nextId
());
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
}
nowDayThreeSystemsDto
.
setRecDate
(
new
Date
());
nowDayThreeSystemsDto
.
setRecUserId
(
amosRequestContext
.
getUserId
());
nowDayThreeSystemsDto
.
setRecUserName
(
amosRequestContext
.
getUserName
());
nowDayThreeSystemsDto
.
setIsDelete
(
false
);
nowDayThreeSystemsDto
.
setSupervisoryUnitId
(
i
.
get
(
"sequenceNbr"
).
toString
());
nowDayThreeSystemsDto
.
setSupervisoryUnitLevel
(
i
.
get
(
"level"
).
toString
());
nowDayThreeSystemsDto
.
setSupervisoryUnitName
(
i
.
get
(
"companyName"
).
toString
());
nowDayThreeSystemsDto
.
setRegisteredNum
(
allUnit
.
size
());
nowDayThreeSystemsDto
.
setCheckNum
(
shouldCheckUnit
.
size
());
nowDayThreeSystemsDto
.
setFinishCheckNum
(
checkCompleteUnit
.
size
());
nowDayThreeSystemsDto
.
setSupervisoryUnitOrgCode
(
i
.
get
(
"orgCode"
).
toString
());
nowDayThreeSystemsDto
.
setPlanType
(
1
==
type
?
"1"
:
2
==
type
?
"2"
:
"3"
);
nowDayThreeSystemsDto
.
setCheckDate
(
DateUtils
.
dateToString
(
date
));
if
(
shouldCheckUnit
.
size
()
==
0
)
{
nowDayThreeSystemsDto
.
setProportion
(
"0%"
);
}
else
{
DecimalFormat
decimalFormat
=
new
DecimalFormat
(
"0.##"
);
BigDecimal
result
=
new
BigDecimal
(
checkCompleteUnit
.
size
()).
divide
(
new
BigDecimal
(
shouldCheckUnit
.
size
()),
4
,
RoundingMode
.
HALF_UP
);
nowDayThreeSystemsDto
.
setProportion
(
decimalFormat
.
format
(
result
.
multiply
(
new
BigDecimal
(
100
)))
+
"%"
);
}
ThreeSystems
threeSystems
=
new
ThreeSystems
();
BeanUtils
.
copyProperties
(
nowDayThreeSystemsDto
,
threeSystems
);
resultList
.
add
(
threeSystems
);
});
return
resultList
;
}
}
\ No newline at end of file
amos-boot-system-tzs/amos-boot-module-tcm/amos-boot-module-tcm-biz/src/main/java/com/yeejoin/amos/boot/module/tcm/biz/service/impl/TzsTwoStaffingServiceImpl.java
View file @
9e326fe7
...
...
@@ -156,6 +156,7 @@ public class TzsTwoStaffingServiceImpl extends BaseService<TzsTwoStaffingDto, Tz
companyDto
.
setCheckStartTime
(
ObjectUtils
.
isEmpty
(
companyDto
.
getCheckStartTime
())
?
startDay
:
companyDto
.
getCheckStartTime
());
companyDto
.
setCheckEndTime
(
ObjectUtils
.
isEmpty
(
companyDto
.
getCheckEndTime
())
?
endDay
:
companyDto
.
getCheckEndTime
());
// todo 此处统计表名通过接口查询得到 接口暂未实现
String
planType
=
companyDto
.
getPlanType
();
String
staticTableName
=
"p_static_day"
;
return
tzsTwoStaffingMapper
.
getCompanyCheckList
(
page
,
orgCode
,
staticTableName
,
companyDto
);
}
...
...
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