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
e2d64218
Commit
e2d64218
authored
Oct 24, 2023
by
李秀明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(JCS#14822|#14821) 人员更换单位、执勤人员换车导致排班历史数据被修改
parent
24b24622
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
1160 additions
and
215 deletions
+1160
-215
DutyCarExcelDto.java
...join/amos/boot/module/common/api/dto/DutyCarExcelDto.java
+2
-34
DutyPersonExcelDto.java
...n/amos/boot/module/common/api/dto/DutyPersonExcelDto.java
+22
-22
TemplateDutyCarExcelDto.java
...s/boot/module/common/api/dto/TemplateDutyCarExcelDto.java
+67
-0
TemplateDutyPersonExcelDto.java
...oot/module/common/api/dto/TemplateDutyPersonExcelDto.java
+59
-0
DutyPersonShiftLog.java
...mos/boot/module/common/api/entity/DutyPersonShiftLog.java
+71
-0
DutyPersonShiftLogMapper.java
...ot/module/common/api/mapper/DutyPersonShiftLogMapper.java
+17
-0
DutyPersonShiftMapper.java
.../boot/module/common/api/mapper/DutyPersonShiftMapper.java
+3
-0
OrgUsrMapper.java
...join/amos/boot/module/common/api/mapper/OrgUsrMapper.java
+2
-0
IDutyCarService.java
.../amos/boot/module/common/api/service/IDutyCarService.java
+3
-0
IDutyCommonService.java
...os/boot/module/common/api/service/IDutyCommonService.java
+1
-0
IDutyPersonService.java
...os/boot/module/common/api/service/IDutyPersonService.java
+2
-0
DutyPersonShiftLogMapper.xml
...pi/src/main/resources/mapper/DutyPersonShiftLogMapper.xml
+46
-0
DutyPersonShiftMapper.xml
...n-api/src/main/resources/mapper/DutyPersonShiftMapper.xml
+19
-3
OrgUsrMapper.xml
...ule-common-api/src/main/resources/mapper/OrgUsrMapper.xml
+26
-0
DutyCarController.java
.../boot/module/common/biz/controller/DutyCarController.java
+12
-0
DutyPersonController.java
...ot/module/common/biz/controller/DutyPersonController.java
+10
-1
DutyCarServiceImpl.java
...ot/module/common/biz/service/impl/DutyCarServiceImpl.java
+350
-65
DutyCommonServiceImpl.java
...module/common/biz/service/impl/DutyCommonServiceImpl.java
+72
-22
DutyPersonServiceImpl.java
...module/common/biz/service/impl/DutyPersonServiceImpl.java
+277
-29
ExcelServiceImpl.java
...os/boot/module/jcs/biz/service/impl/ExcelServiceImpl.java
+70
-37
jcs-1.0.0.0.xml
...ystem-jcs/src/main/resources/db/changelog/jcs-1.0.0.0.xml
+27
-0
pom.xml
pom.xml
+2
-2
No files found.
amos-boot-module/amos-boot-module-api/amos-boot-module-common-api/src/main/java/com/yeejoin/amos/boot/module/common/api/dto/DutyCarExcelDto.java
View file @
e2d64218
...
...
@@ -2,8 +2,6 @@ package com.yeejoin.amos.boot.module.common.api.dto;
import
com.alibaba.excel.annotation.ExcelIgnore
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
com.yeejoin.amos.boot.module.common.api.excel.ExplicitConstraint
;
import
com.yeejoin.amos.boot.module.common.api.excel.CommonExplicitConstraint
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
...
...
@@ -28,40 +26,10 @@ public class DutyCarExcelDto implements Serializable {
private
Integer
number
;
@ExcelIgnore
@ApiModelProperty
(
value
=
"消防队伍id"
)
private
String
teamId
;
@ExcelProperty
(
value
=
"消防队伍"
,
index
=
1
)
@ApiModelProperty
(
value
=
"消防队伍名称"
)
private
String
teamName
;
@ExcelIgnore
@ApiModelProperty
(
value
=
"用户id"
)
private
String
userId
;
@ExcelProperty
(
value
=
"姓名"
,
index
=
2
)
@ApiModelProperty
(
value
=
"用户名称"
)
private
String
userName
;
@ExcelIgnore
@ApiModelProperty
(
value
=
"岗位id"
)
private
String
postType
;
@ExcelProperty
(
value
=
"岗位"
,
index
=
3
)
@ApiModelProperty
(
value
=
"岗位名称"
)
private
String
postTypeName
;
@ExcelIgnore
@ApiModelProperty
(
value
=
"车辆id"
)
private
String
carId
;
@ExplicitConstraint
(
indexNum
=
4
,
sourceClass
=
CommonExplicitConstraint
.
class
,
method
=
"getCarList"
)
//固定下拉内容
@ExcelProperty
(
value
=
"车辆名称(车牌)"
,
index
=
4
)
@ExcelProperty
(
value
=
"车辆名称"
,
index
=
1
)
@ApiModelProperty
(
value
=
"车辆名称"
)
private
String
carName
;
// 需求 958 新增值班区域 值班区域id 字段 导出字段 by kongfm 2021-09-15
@ExplicitConstraint
(
indexNum
=
5
,
sourceClass
=
CommonExplicitConstraint
.
class
,
method
=
"getDutyArea"
)
//固定下拉内容
@ExcelProperty
(
value
=
"值班区域"
,
index
=
5
)
@ApiModelProperty
(
value
=
"值班区域"
)
private
String
dutyArea
;
}
}
amos-boot-module/amos-boot-module-api/amos-boot-module-common-api/src/main/java/com/yeejoin/amos/boot/module/common/api/dto/DutyPersonExcelDto.java
View file @
e2d64218
...
...
@@ -34,26 +34,26 @@ public class DutyPersonExcelDto implements Serializable {
@ExcelProperty
(
value
=
"姓名"
,
index
=
2
)
@ApiModelProperty
(
value
=
"用户名称"
)
private
String
userName
;
@ExcelIgnore
@ApiModelProperty
(
value
=
"部门id"
)
private
String
deptId
;
@ExcelProperty
(
value
=
"单位/部门"
,
index
=
3
)
@ApiModelProperty
(
value
=
"部门名称"
)
private
String
deptName
;
@ExcelIgnore
@ApiModelProperty
(
value
=
"岗位id"
)
private
String
postType
;
@ExplicitConstraint
(
type
=
"DUTY_POST_TYPE"
,
indexNum
=
4
,
sourceClass
=
CommonExplicitConstraint
.
class
)
//动态下拉内容
@ExcelProperty
(
value
=
"岗位"
,
index
=
4
)
@ApiModelProperty
(
value
=
"岗位名称"
)
private
String
postTypeName
;
// 需求 958 新增值班区域 值班区域id 字段 导出字段 by kongfm 2021-09-15
@ExplicitConstraint
(
indexNum
=
5
,
sourceClass
=
CommonExplicitConstraint
.
class
,
method
=
"getDutyArea"
)
//固定下拉内容
@ExcelProperty
(
value
=
"值班区域"
,
index
=
5
)
@ApiModelProperty
(
value
=
"值班区域"
)
private
String
dutyArea
;
//
//
@ExcelIgnore
//
@ApiModelProperty(value = "部门id")
//
private String deptId;
//
//
@ExcelProperty(value = "单位/部门", index = 3)
//
@ApiModelProperty(value = "部门名称")
//
private String deptName;
//
//
@ExcelIgnore
//
@ApiModelProperty(value = "岗位id")
//
private String postType;
//
//
@ExplicitConstraint(type = "DUTY_POST_TYPE", indexNum = 4, sourceClass = CommonExplicitConstraint.class) //动态下拉内容
//
@ExcelProperty(value = "岗位", index = 4)
//
@ApiModelProperty(value = "岗位名称")
//
private String postTypeName;
//
// 需求 958 新增值班区域 值班区域id 字段 导出字段 by kongfm 2021-09-15
//
@ExplicitConstraint(indexNum = 5, sourceClass = CommonExplicitConstraint.class, method = "getDutyArea") //固定下拉内容
//
@ExcelProperty(value = "值班区域", index = 5)
//
@ApiModelProperty(value = "值班区域")
//
private String dutyArea;
}
amos-boot-module/amos-boot-module-api/amos-boot-module-common-api/src/main/java/com/yeejoin/amos/boot/module/common/api/dto/TemplateDutyCarExcelDto.java
0 → 100644
View file @
e2d64218
package
com
.
yeejoin
.
amos
.
boot
.
module
.
common
.
api
.
dto
;
import
com.alibaba.excel.annotation.ExcelIgnore
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
com.yeejoin.amos.boot.module.common.api.excel.ExplicitConstraint
;
import
com.yeejoin.amos.boot.module.common.api.excel.CommonExplicitConstraint
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* 值班班次
*
* @author system_generator
* @date 2021-07-06
*/
@Data
@ApiModel
(
value
=
"TemplateDutyCarExcelDto"
,
description
=
"值班车辆"
)
public
class
TemplateDutyCarExcelDto
implements
Serializable
{
@ExcelIgnore
private
static
final
long
serialVersionUID
=
1L
;
@ExcelProperty
(
value
=
"序号"
,
index
=
0
)
@ApiModelProperty
(
value
=
"序号"
)
private
Integer
number
;
@ExcelIgnore
@ApiModelProperty
(
value
=
"消防队伍id"
)
private
String
teamId
;
@ExcelProperty
(
value
=
"消防队伍"
,
index
=
1
)
@ApiModelProperty
(
value
=
"消防队伍名称"
)
private
String
teamName
;
@ExcelIgnore
@ApiModelProperty
(
value
=
"用户id"
)
private
String
userId
;
@ExcelProperty
(
value
=
"姓名"
,
index
=
2
)
@ApiModelProperty
(
value
=
"用户名称"
)
private
String
userName
;
@ExcelIgnore
@ApiModelProperty
(
value
=
"岗位id"
)
private
String
postType
;
@ExcelProperty
(
value
=
"岗位"
,
index
=
3
)
@ApiModelProperty
(
value
=
"岗位名称"
)
private
String
postTypeName
;
@ExcelIgnore
@ApiModelProperty
(
value
=
"车辆id"
)
private
String
carId
;
@ExplicitConstraint
(
indexNum
=
4
,
sourceClass
=
CommonExplicitConstraint
.
class
,
method
=
"getCarList"
)
//固定下拉内容
@ExcelProperty
(
value
=
"车辆名称(车牌)"
,
index
=
4
)
@ApiModelProperty
(
value
=
"车辆名称"
)
private
String
carName
;
// 需求 958 新增值班区域 值班区域id 字段 导出字段 by kongfm 2021-09-15
@ExplicitConstraint
(
indexNum
=
5
,
sourceClass
=
CommonExplicitConstraint
.
class
,
method
=
"getDutyArea"
)
//固定下拉内容
@ExcelProperty
(
value
=
"值班区域"
,
index
=
5
)
@ApiModelProperty
(
value
=
"值班区域"
)
private
String
dutyArea
;
}
amos-boot-module/amos-boot-module-api/amos-boot-module-common-api/src/main/java/com/yeejoin/amos/boot/module/common/api/dto/TemplateDutyPersonExcelDto.java
0 → 100644
View file @
e2d64218
package
com
.
yeejoin
.
amos
.
boot
.
module
.
common
.
api
.
dto
;
import
com.alibaba.excel.annotation.ExcelIgnore
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
com.yeejoin.amos.boot.module.common.api.excel.ExplicitConstraint
;
import
com.yeejoin.amos.boot.module.common.api.excel.CommonExplicitConstraint
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* 值班班次
*
* @author system_generator
* @date 2021-07-06
*/
@Data
@ApiModel
(
value
=
"TemplateDutyPersonExcelDto"
,
description
=
"值班人"
)
public
class
TemplateDutyPersonExcelDto
implements
Serializable
{
@ExcelIgnore
private
static
final
long
serialVersionUID
=
1L
;
@ExcelProperty
(
value
=
"序号"
,
index
=
0
)
@ApiModelProperty
(
value
=
"序号"
)
private
Integer
number
;
@ExcelProperty
(
value
=
"用户ID"
,
index
=
1
)
@ApiModelProperty
(
value
=
"用户id"
)
private
String
userId
;
@ExcelProperty
(
value
=
"姓名"
,
index
=
2
)
@ApiModelProperty
(
value
=
"用户名称"
)
private
String
userName
;
@ExcelIgnore
@ApiModelProperty
(
value
=
"部门id"
)
private
String
deptId
;
@ExcelProperty
(
value
=
"单位/部门"
,
index
=
3
)
@ApiModelProperty
(
value
=
"部门名称"
)
private
String
deptName
;
@ExcelIgnore
@ApiModelProperty
(
value
=
"岗位id"
)
private
String
postType
;
@ExplicitConstraint
(
type
=
"DUTY_POST_TYPE"
,
indexNum
=
4
,
sourceClass
=
CommonExplicitConstraint
.
class
)
//动态下拉内容
@ExcelProperty
(
value
=
"岗位"
,
index
=
4
)
@ApiModelProperty
(
value
=
"岗位名称"
)
private
String
postTypeName
;
// 需求 958 新增值班区域 值班区域id 字段 导出字段 by kongfm 2021-09-15
@ExplicitConstraint
(
indexNum
=
5
,
sourceClass
=
CommonExplicitConstraint
.
class
,
method
=
"getDutyArea"
)
//固定下拉内容
@ExcelProperty
(
value
=
"值班区域"
,
index
=
5
)
@ApiModelProperty
(
value
=
"值班区域"
)
private
String
dutyArea
;
}
amos-boot-module/amos-boot-module-api/amos-boot-module-common-api/src/main/java/com/yeejoin/amos/boot/module/common/api/entity/DutyPersonShiftLog.java
0 → 100644
View file @
e2d64218
package
com
.
yeejoin
.
amos
.
boot
.
module
.
common
.
api
.
entity
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.yeejoin.amos.boot.biz.common.entity.BaseEntity
;
import
lombok.Data
;
import
lombok.experimental.Accessors
;
import
java.util.Date
;
/**
* 值班人员日期日志表
*/
@Data
@Accessors
(
chain
=
true
)
@TableName
(
"cb_duty_person_shift_log"
)
public
class
DutyPersonShiftLog
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 实例ID
*/
@TableField
(
"instance_id"
)
private
Long
instanceId
;
/**
* 值班日期
*/
@TableField
(
"duty_date"
)
private
Date
dutyDate
;
/**
* 分组类型
*/
@TableField
(
"group_code"
)
private
String
groupCode
;
/**
* 消防队伍
*/
@TableField
(
"dept_name"
)
private
String
deptName
;
/**
* 值班人
*/
@TableField
(
"duty_user_id"
)
private
String
dutyUserId
;
/**
* 值班人
*/
@TableField
(
"duty_user"
)
private
String
dutyUser
;
/**
* 岗位
*/
@TableField
(
"post_type_name"
)
private
String
postTypeName
;
/**
* 值班区域
*/
@TableField
(
"duty_area"
)
private
String
dutyArea
;
/**
* 值班类型
*/
@TableField
(
"shift_name"
)
private
String
shiftName
;
/**
* 车辆名称
*/
@TableField
(
"car_name"
)
private
String
carName
;
}
amos-boot-module/amos-boot-module-api/amos-boot-module-common-api/src/main/java/com/yeejoin/amos/boot/module/common/api/mapper/DutyPersonShiftLogMapper.java
0 → 100644
View file @
e2d64218
package
com
.
yeejoin
.
amos
.
boot
.
module
.
common
.
api
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.yeejoin.amos.boot.module.common.api.entity.DutyPersonShiftLog
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
import
java.util.Map
;
/**
* 值班人员日期日志表 Mapper 接口
*/
public
interface
DutyPersonShiftLogMapper
extends
BaseMapper
<
DutyPersonShiftLog
>
{
List
<
Map
<
String
,
String
>>
selectSpecificDateLogForCar
(
@Param
(
"dutyDate"
)
String
dutyDate
);
List
<
Map
<
String
,
String
>>
selectSpecificDateLogForPerson
(
@Param
(
"dutyDate"
)
String
dutyDate
);
List
<
Map
<
String
,
String
>>
selectSpecificDateLogForPersonGroupByPostTypeName
(
@Param
(
"dutyDate"
)
String
dutyDate
);
}
amos-boot-module/amos-boot-module-api/amos-boot-module-common-api/src/main/java/com/yeejoin/amos/boot/module/common/api/mapper/DutyPersonShiftMapper.java
View file @
e2d64218
...
...
@@ -11,6 +11,7 @@ import org.apache.poi.ss.formula.functions.T;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
/**
* 值班人员日期关联关系表 Mapper 接口
...
...
@@ -153,6 +154,8 @@ public interface DutyPersonShiftMapper extends BaseMapper<DutyPersonShift> {
List
<
Map
<
String
,
Object
>>
queryByCompanyNew
(
String
bizOrgName
);
List
<
DutyPersonShift
>
getOldDutyPersonShifts
(
String
groupCode
);
List
<
Map
<
String
,
Object
>>
getNewEquipmentForSpecifyDate
(
String
dutyDate
,
String
groupCode
,
String
equipmentId
,
String
equipmentName
,
String
groupByName
);
...
...
amos-boot-module/amos-boot-module-api/amos-boot-module-common-api/src/main/java/com/yeejoin/amos/boot/module/common/api/mapper/OrgUsrMapper.java
View file @
e2d64218
...
...
@@ -137,4 +137,6 @@ public interface OrgUsrMapper extends BaseMapper<OrgUsr> {
List
<
DynamicFormInstance
>
checkCertificatesNumber
(
String
certificatesNumber
,
Long
orgUserId
);
OrgUsr
queryByCompanyCode
(
@Param
(
"companyCode"
)
String
companyCode
);
List
<
Map
<
String
,
String
>>
selectUserDeptMap
(
@Param
(
"ids"
)
List
<
Long
>
userIds
);
}
amos-boot-module/amos-boot-module-api/amos-boot-module-common-api/src/main/java/com/yeejoin/amos/boot/module/common/api/service/IDutyCarService.java
View file @
e2d64218
...
...
@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.common.api.service;
import
com.alibaba.fastjson.JSONObject
;
import
com.yeejoin.amos.boot.module.common.api.dto.DutyCarDto
;
import
java.text.ParseException
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -39,4 +40,6 @@ public interface IDutyCarService extends IDutyCommonService {
//查询今日值班车辆
List
<
Map
<
String
,
String
>>
getDutyCar
();
void
writeHistoryDutyLog
();
}
amos-boot-module/amos-boot-module-api/amos-boot-module-common-api/src/main/java/com/yeejoin/amos/boot/module/common/api/service/IDutyCommonService.java
View file @
e2d64218
package
com
.
yeejoin
.
amos
.
boot
.
module
.
common
.
api
.
service
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.yeejoin.amos.boot.module.common.api.dto.DutyCarDto
;
import
com.yeejoin.amos.boot.module.common.api.dto.DutyPersonShiftDto
;
import
java.text.ParseException
;
...
...
amos-boot-module/amos-boot-module-api/amos-boot-module-common-api/src/main/java/com/yeejoin/amos/boot/module/common/api/service/IDutyPersonService.java
View file @
e2d64218
...
...
@@ -37,4 +37,6 @@ public interface IDutyPersonService extends IDutyCommonService {
List
<
Map
<
String
,
Object
>>
queryByCompanyId
(
List
<
String
>
bizNames
);
List
<
Map
<
String
,
Object
>>
queryByCompanyNew
(
String
bizOrgName
);
void
writeHistoryDutyLog
();
}
amos-boot-module/amos-boot-module-api/amos-boot-module-common-api/src/main/resources/mapper/DutyPersonShiftLogMapper.xml
0 → 100644
View file @
e2d64218
<?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.yeejoin.amos.boot.module.common.api.mapper.DutyPersonShiftLogMapper"
>
<select
id=
"selectSpecificDateLogForCar"
resultType=
"java.util.Map"
>
select
car_name AS carName,
dept_name AS teamName,
post_type_name as postTypeName,
group_concat(duty_user) AS dutyUsers
from
cb_duty_person_shift_log
where
group_code = 'dutyCar'
and duty_date = #{dutyDate}
group by
car_name, dept_name, post_type_name
</select>
<select
id=
"selectSpecificDateLogForPerson"
resultType=
"java.util.Map"
>
select
dept_name as deptName,
post_type_name as postTypeName,
group_concat(duty_user) AS dutyUsers
from
cb_duty_person_shift_log
where
group_code = 'dutyPerson'
and duty_date = #{dutyDate}
group by
dept_name, post_type_name
</select>
<select
id=
"selectSpecificDateLogForPersonGroupByPostTypeName"
resultType=
"java.util.Map"
>
select
post_type_name as postTypeName,
group_concat(duty_user) AS dutyUsers
from
cb_duty_person_shift_log
where
group_code = 'dutyPerson'
and duty_date = #{dutyDate}
group by
post_type_name
</select>
</mapper>
amos-boot-module/amos-boot-module-api/amos-boot-module-common-api/src/main/resources/mapper/DutyPersonShiftMapper.xml
View file @
e2d64218
...
...
@@ -245,7 +245,6 @@
cd.FIELD_VALUE
END
) AS #{teamName}
FROM
cb_dynamic_form_instance cd
LEFT JOIN (
...
...
@@ -267,6 +266,20 @@
</if>
</select>
<select
id=
"getOldDutyPersonShifts"
resultType=
'com.yeejoin.amos.boot.module.common.api.entity.DutyPersonShift'
>
SELECT
DISTINCT dp.duty_date AS dutyDate
FROM
cb_duty_person_shift dp
LEFT JOIN cb_dynamic_form_instance cd ON dp.instance_id = cd.instance_id
AND cd.group_code = #{groupCode}
AND cd.instance_id IS NOT NULL
AND dp.instance_id IS NOT NULL
AND cd.is_delete = 0
AND dp.is_delete = 0
ORDER BY dp.duty_date DESC
</select>
<select
id=
'getNewEquipmentForSpecifyDate'
resultType=
'map'
>
select *,
(SELECT
...
...
@@ -295,13 +308,16 @@
WHEN cd.FIELD_CODE = #{equipmentName} THEN
cd.FIELD_VALUE
END
) AS #{equipmentName}
) AS #{equipmentName},
cds.instance_row AS instanceRow
FROM
cb_dynamic_form_instance cd
LEFT JOIN (
SELECT
dp.instance_id,
ds.`name`
ds.`name`,
dp.instance_row
FROM
cb_duty_person_shift dp
LEFT JOIN cb_duty_shift ds ON dp.shift_id = ds.sequence_nbr
...
...
amos-boot-module/amos-boot-module-api/amos-boot-module-common-api/src/main/resources/mapper/OrgUsrMapper.xml
View file @
e2d64218
...
...
@@ -1100,5 +1100,31 @@ LEFT JOIN (
cb_org_usr.is_delete=0 AND cb_org_usr.amos_org_id IS NOT NULL AND cb_org_usr.amos_org_id !=''
</select>
<select
id=
"selectUserDeptMap"
resultType=
"map"
>
-- 根据人员的id列表查询人员所属部门名称,根据parent_id查询。 返回map,人员名称对应人员部门
SELECT
u.biz_org_name AS userName,
(
SELECT
biz_org_name
FROM
cb_org_usr
WHERE
sequence_nbr = u.parent_id
) AS deptName
FROM
cb_org_usr u
<where>
u.biz_org_type = 'PERSON'
AND u.is_delete = 0
<if
test=
"ids != null and ids.size > 0"
>
AND u.sequence_nbr IN
<foreach
collection=
"ids"
item=
"item"
open=
"("
close=
")"
separator=
","
>
#{item}
</foreach>
</if>
</where>
</select>
</mapper>
amos-boot-module/amos-boot-module-biz/amos-boot-module-common-biz/src/main/java/com/yeejoin/amos/boot/module/common/biz/controller/DutyCarController.java
View file @
e2d64218
...
...
@@ -186,4 +186,15 @@ public class DutyCarController extends BaseController {
public
ResponseModel
<
List
<
Map
<
String
,
Object
>>>
theCarDutyPerson
(
@RequestParam
Long
carId
){
return
ResponseHelper
.
buildResponse
(
iDutyCarService
.
theCarDutyPerson
(
carId
));
}
/**
* 写入历史展板数据到日志表
*/
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@GetMapping
(
"/write-history-duty-log"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"历史值班数据写入日志表"
,
notes
=
"历史值班数据写入日志表"
)
public
ResponseModel
writeHistoryDutyLog
()
{
iDutyCarService
.
writeHistoryDutyLog
();
return
ResponseHelper
.
buildResponse
(
"running..."
);
}
}
\ No newline at end of file
amos-boot-module/amos-boot-module-biz/amos-boot-module-common-biz/src/main/java/com/yeejoin/amos/boot/module/common/biz/controller/DutyPersonController.java
View file @
e2d64218
...
...
@@ -250,5 +250,14 @@ public class DutyPersonController extends BaseController {
// return ResponseHelper.buildResponse(iDutyPersonService.queryByCompanyId(companyId));
// }
/**
* 写入历史展板数据到日志表
*/
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@GetMapping
(
"/write-history-duty-log"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"历史值班数据写入日志表"
,
notes
=
"历史值班数据写入日志表"
)
public
ResponseModel
writeHistoryDutyLog
()
{
iDutyPersonService
.
writeHistoryDutyLog
();
return
ResponseHelper
.
buildResponse
(
"running..."
);
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-common-biz/src/main/java/com/yeejoin/amos/boot/module/common/biz/service/impl/DutyCarServiceImpl.java
View file @
e2d64218
package
com
.
yeejoin
.
amos
.
boot
.
module
.
common
.
biz
.
service
.
impl
;
import
java.util.ArrayList
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.yeejoin.amos.boot.biz.common.dao.mapper.DataDictionaryMapper
;
import
com.yeejoin.amos.boot.module.common.api.dto.DutyPersonShiftDto
;
import
com.yeejoin.amos.boot.module.common.api.entity.*
;
import
com.yeejoin.amos.boot.module.common.api.mapper.OrgUsrMapper
;
import
com.yeejoin.amos.boot.module.common.biz.enums.ActionStatus
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.support.TransactionSynchronization
;
import
org.springframework.transaction.support.TransactionSynchronizationManager
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
org.typroject.tyboot.core.foundation.utils.Bean
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
...
...
@@ -20,9 +26,6 @@ import com.alibaba.fastjson.JSONObject;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.yeejoin.amos.boot.biz.common.utils.DateUtils
;
import
com.yeejoin.amos.boot.module.common.api.dto.DutyCarDto
;
import
com.yeejoin.amos.boot.module.common.api.entity.DynamicFormColumn
;
import
com.yeejoin.amos.boot.module.common.api.entity.DynamicFormInstance
;
import
com.yeejoin.amos.boot.module.common.api.entity.Firefighters
;
import
com.yeejoin.amos.boot.module.common.api.feign.EquipFeignClient
;
import
com.yeejoin.amos.boot.module.common.api.mapper.DutyPersonShiftMapper
;
import
com.yeejoin.amos.boot.module.common.api.mapper.FirefightersMapper
;
...
...
@@ -51,6 +54,12 @@ public class DutyCarServiceImpl extends DutyCommonServiceImpl implements IDutyCa
@Autowired
DutyPersonShiftMapper
dutyPersonShiftMapper
;
@Autowired
DataDictionaryMapper
dataDictionaryMapper
;
@Autowired
OrgUsrMapper
orgUsrMapper
;
@Override
public
String
getGroupCode
()
{
return
"dutyCar"
;
...
...
@@ -76,8 +85,15 @@ public class DutyCarServiceImpl extends DutyCommonServiceImpl implements IDutyCa
// 修改操作动态表单的方法,修改人陈浩 -------------start 2021-09-28
Long
instanceId
=
excuteDynamicFormInstance
(
dutyCarDto
.
getUserId
(),
map
,
this
.
getGroupCode
());
saveDutyPersonShiftDetail
(
instanceId
,
dutyCarDto
.
getDutyShift
(),
dutyCarDto
.
getStartTime
());
TransactionSynchronizationManager
.
registerSynchronization
(
new
TransactionSynchronization
()
{
@Override
public
void
afterCommit
()
{
insertPersonShift
(
instanceId
,
dutyCarDto
.
getDutyShift
(),
ActionStatus
.
METHOD_ADD
.
getCode
());
}
});
// 修改操作动态表单的方法,修改人陈浩 -------------end 2021-09-28
// 生成变更日志
createDutyPersonShiftLog
(
dutyCarDto
,
false
,
ActionStatus
.
METHOD_UPDATE
.
getCode
());
// 3.返回保存后的数据
return
dutyCarDto
;
...
...
@@ -85,15 +101,87 @@ public class DutyCarServiceImpl extends DutyCommonServiceImpl implements IDutyCa
@Override
public
DutyCarDto
update
(
Long
instanceId
,
DutyCarDto
dutyCarDto
)
{
// 修改操作动态表单修改的逻辑方法,陈浩 start ----2021-09-28
updateDynamicFormInstance
(
this
.
getGroupCode
(),
instanceId
,
Bean
.
BeantoMap
(
dutyCarDto
));
// 修改操作动态表单修改的逻辑方法,陈浩 end ----2021-09-28
// 5.更新值班信息人日期数据
insertPersonShift
(
instanceId
,
dutyCarDto
.
getDutyShift
(),
ActionStatus
.
METHOD_UPDATE
.
getCode
());
// 生成变更日志
createDutyPersonShiftLog
(
dutyCarDto
,
false
,
ActionStatus
.
METHOD_UPDATE
.
getCode
());
return
dutyCarDto
;
}
public
void
insertPersonShift
(
Long
instanceId
,
List
<
DutyPersonShiftDto
>
dutyShiftList
,
String
type
)
{
//1.查询已有数据
List
<
DynamicFormInstance
>
instances
=
dynamicFormInstanceService
.
list
(
new
LambdaQueryWrapper
<
DynamicFormInstance
>().
eq
(
DynamicFormInstance:
:
getInstanceId
,
instanceId
));
Map
<
Object
,
DynamicFormInstance
>
instanceMap
=
Bean
.
listToMap
(
instances
,
"fieldCode"
,
DynamicFormInstance
.
class
);
dutyPersonService
.
dataCheck
(
dutyShiftList
,
instanceId
,
type
);
Set
<
DutyPersonShift
>
personShiftList
=
dutyShiftList
.
stream
().
map
(
dto
->
{
// 根据instanceId 和 日期查找 如果有则更新
DutyPersonShift
dutyPersonShift
=
dutyPersonShiftService
.
getOne
(
new
LambdaQueryWrapper
<
DutyPersonShift
>().
eq
(
DutyPersonShift:
:
getInstanceId
,
instanceId
).
eq
(
DutyPersonShift:
:
getDutyDate
,
dto
.
getDutyDate
()));
if
(
dutyPersonShift
==
null
)
{
dutyPersonShift
=
new
DutyPersonShift
();
}
dto
.
setInstanceId
(
instanceId
);
Bean
.
copyExistPropertis
(
dto
,
dutyPersonShift
);
dutyPersonShift
.
setAppKey
(
RequestContext
.
getAppKey
());
return
dutyPersonShift
;
}).
collect
(
Collectors
.
toSet
());
if
(!
personShiftList
.
isEmpty
())
{
dutyPersonShiftService
.
saveOrUpdateBatch
(
personShiftList
);
}
}
@Override
public
Object
getDutyPersonShiftLogData
(
String
dutyDay
,
String
fieldCode
){
List
<
Map
<
String
,
Object
>>
equipmentList
=
dutyPersonShiftMapper
.
getEquipmentForSpecifyDate
(
dutyDay
,
this
.
getGroupCode
(),
"carId"
,
"carName"
,
"teamName"
,
"result.carId"
);
if
(
equipmentList
==
null
||
equipmentList
.
isEmpty
()
||
equipmentList
.
get
(
0
)
==
null
)
{
return
null
;
}
List
<
Object
>
detailList
=
new
ArrayList
<>();
for
(
Map
<
String
,
Object
>
map
:
equipmentList
)
{
List
<
Map
<
String
,
Object
>>
resultList
=
new
ArrayList
<>();
LinkedHashMap
<
String
,
Object
>
titleMap_1
=
new
LinkedHashMap
<>();
if
(
map
.
containsKey
(
"carName"
)
&&
map
.
get
(
"carName"
)
!=
null
)
{
titleMap_1
.
put
(
"消防车辆"
,
map
.
get
(
"carName"
).
toString
());
}
resultList
.
add
(
titleMap_1
);
LinkedHashMap
<
String
,
Object
>
titleMap_2
=
new
LinkedHashMap
<>();
if
(
map
.
containsKey
(
"teamName"
)
&&
map
.
get
(
"teamName"
)
!=
null
)
{
titleMap_2
.
put
(
"单位/部门"
,
map
.
get
(
"teamName"
).
toString
());
}
resultList
.
add
(
titleMap_2
);
String
carId
=
map
.
get
(
"carId"
).
toString
();
Map
<
String
,
Object
>
instanceMap
=
dutyPersonShiftMapper
.
getInstanceIdForSpecifyDateAndEquipment
(
dutyDay
,
this
.
getGroupCode
(),
carId
);
if
(
instanceMap
==
null
)
{
continue
;
}
String
instanceId
=
instanceMap
.
get
(
"instanceIds"
).
toString
();
if
(
StringUtils
.
isNotBlank
(
instanceId
))
{
String
[]
instanceIds
=
instanceId
.
split
(
","
);
List
<
Map
<
String
,
Object
>>
specifyDateList
=
dutyPersonShiftMapper
.
getPositionStaffDutyForSpecifyDate
(
dutyDay
,
this
.
getGroupCode
(),
instanceIds
,
null
,
fieldCode
);
if
(!
specifyDateList
.
isEmpty
())
{
for
(
Map
<
String
,
Object
>
specify
:
specifyDateList
)
{
LinkedHashMap
<
String
,
Object
>
infoMap_2
=
new
LinkedHashMap
<>();
if
(
specify
.
containsKey
(
"postTypeName"
)
&&
specify
.
get
(
"postTypeName"
)
!=
null
&&
specify
.
containsKey
(
"userName"
)
&&
specify
.
get
(
"userName"
)
!=
null
)
{
infoMap_2
.
put
(
specify
.
get
(
"postTypeName"
).
toString
(),
specify
.
get
(
"userName"
).
toString
());
resultList
.
add
(
infoMap_2
);
}
}
}
}
detailList
.
add
(
resultList
);
}
return
detailList
;
}
private
void
buildFormInstanceData
(
Long
instanceId
,
Map
<
String
,
Object
>
map
,
DynamicFormColumn
column
,
DynamicFormInstance
formInstance
)
{
fillFormInstanceData
(
instanceId
,
map
,
column
,
formInstance
,
sequence
.
nextId
());
...
...
@@ -144,71 +232,83 @@ public class DutyCarServiceImpl extends DutyCommonServiceImpl implements IDutyCa
}
public
Object
getSchedulingDutyForSpecifyDate
(
String
dutyDay
,
Long
shiftId
,
String
postType
,
String
fieldCode
)
{
List
<
Map
<
String
,
Object
>>
equipmentList
=
dutyPersonShiftMapper
.
getEquipmentForSpecifyDate
(
dutyDay
,
this
.
getGroupCode
(),
"carId"
,
"carName"
,
"teamName"
,
"result.carId"
);
if
(
equipmentList
==
null
||
equipmentList
.
size
()<
1
||
equipmentList
.
get
(
0
)==
null
)
{
return
null
;
}
List
<
Object
>
detailList
=
new
ArrayList
<
Object
>();
for
(
Map
<
String
,
Object
>
map
:
equipmentList
)
{
List
<
Map
<
String
,
Object
>>
resultList
=
new
ArrayList
<
Map
<
String
,
Object
>>();
LinkedHashMap
<
String
,
Object
>
titleMap_1
=
new
LinkedHashMap
<
String
,
Object
>();
titleMap_1
.
put
(
"消防车辆"
,
map
.
get
(
"carName"
).
toString
());
if
(
map
.
containsKey
(
"carName"
)
&&
map
.
get
(
"carName"
)
!=
null
){
titleMap_1
.
put
(
"消防车辆"
,
map
.
get
(
"carName"
).
toString
());
}
resultList
.
add
(
titleMap_1
);
LinkedHashMap
<
String
,
Object
>
titleMap_2
=
new
LinkedHashMap
<
String
,
Object
>();
//titleMap_2.put("单位/部门", map.get("teamName").toString());
if
(
map
.
containsKey
(
"teamName"
)
&&
map
.
get
(
"teamName"
)
!=
null
){
titleMap_2
.
put
(
"单位/部门"
,
map
.
get
(
"teamName"
).
toString
());
}
resultList
.
add
(
titleMap_2
);
String
carId
=
map
.
get
(
"carId"
).
toString
();
Map
<
String
,
Object
>
instanceMap
=
dutyPersonShiftMapper
.
getInstanceIdForSpecifyDateAndEquipment
(
dutyDay
,
this
.
getGroupCode
(),
carId
);
if
(
instanceMap
==
null
)
{
List
<
List
<
Map
<
String
,
String
>>>
result
=
new
ArrayList
<>();
List
<
Map
<
String
,
String
>>
dutyCarLogs
=
dutyPersonShiftLogMapper
.
selectSpecificDateLogForCar
(
dutyDay
);
// 按照车辆分组
dutyCarLogs
=
dutyCarLogs
.
stream
().
filter
(
v
->
Objects
.
nonNull
(
v
.
get
(
"carName"
))).
collect
(
Collectors
.
toList
());
Map
<
String
,
List
<
Map
<
String
,
String
>>>
dutyCarLogGroups
=
dutyCarLogs
.
stream
().
collect
(
Collectors
.
groupingBy
(
v
->
v
.
get
(
"carName"
)));
// 按照车辆排序
// 1. 获取排序 BizOrgName: 部门名称,OrgExpandAttr1: 排序字段
List
<
OrgUsr
>
orgUserSortRules
=
orgUsrMapper
.
selectList
(
Wrappers
.<
OrgUsr
>
lambdaQuery
()
.
select
(
OrgUsr:
:
getBizOrgName
,
OrgUsr:
:
getOrgExpandAttr1
)
.
isNotNull
(
OrgUsr:
:
getOrgExpandAttr1
)
.
ne
(
OrgUsr:
:
getOrgExpandAttr1
,
""
)
);
// 2. dutyCarLogGroups.keySet() 为车辆名称,根据车辆名称获取部门值班列表。获取车辆下第一个部门,按照此部门对dutyCarLogGroups进行排序,排序后的结果保存到一个有序的LinkedHashMap中.
// sortNum为数字类型,数字越小越靠前 | 车辆对应的部门列表可能为空,注意判空,无法排序的车辆放到最后
Map
<
String
,
List
<
Map
<
String
,
String
>>>
sortedDutyCarLogGroups
=
new
LinkedHashMap
<>();
Map
<
String
,
Integer
>
dutyCarSortNumMap
=
new
HashMap
<>();
for
(
String
carName
:
dutyCarLogGroups
.
keySet
())
{
List
<
Map
<
String
,
String
>>
dutyCarLogGroup
=
dutyCarLogGroups
.
get
(
carName
);
Map
<
String
,
String
>
team
=
dutyCarLogGroup
.
get
(
0
);
if
(
Objects
.
isNull
(
team
))
{
continue
;
}
String
instanceId
=
instanceMap
.
get
(
"instanceIds"
).
toString
();
if
(
StringUtils
.
isNotBlank
(
instanceId
))
{
String
[]
instanceIds
=
instanceId
.
split
(
","
);
// List<Map<String, Object>> dutyList = dutyPersonShiftMapper.getDutyForSpecifyDate(dutyDay);
// if(dutyList!=null && dutyList.size()>0) {
// for (Map<String, Object> dutyDetail : dutyList) {
// if(!dutyDetail.containsKey("name")) {
// continue;
// }
// 获取当前装备ID下的排版数据
List
<
Map
<
String
,
Object
>>
specifyDateList
=
dutyPersonShiftMapper
.
getPositionStaffDutyForSpecifyDate
(
dutyDay
,
this
.
getGroupCode
(),
instanceIds
,
null
,
fieldCode
);
/*if(specifyDateList==null || specifyDateList.size() < 1 || specifyDateList.get(0)==null) {
continue;
}*/
LinkedHashMap
<
String
,
Object
>
infoMap_1
=
new
LinkedHashMap
<
String
,
Object
>();
//取消掉班次的显示---2022-01-16 by chenhao ---start
//infoMap_1.put(dutyDetail.get("name").toString(), "");
//resultList.add(infoMap_1);
//取消掉班次的显示---2022-01-16 by chenhao ---end
if
(
specifyDateList
.
size
()>
0
&&
specifyDateList
!=
null
)
{
for
(
Map
<
String
,
Object
>
specify
:
specifyDateList
)
{
LinkedHashMap
<
String
,
Object
>
infoMap_2
=
new
LinkedHashMap
<
String
,
Object
>();
// infoMap_2.put(specify.get("postTypeName").toString(),specify.get("userName").toString());
// resultList.add(infoMap_2);
if
(
specify
.
containsKey
(
"postTypeName"
)
&&
specify
.
get
(
"postTypeName"
)
!=
null
&&
specify
.
containsKey
(
"userName"
)
&&
specify
.
get
(
"userName"
)
!=
null
)
{
infoMap_2
.
put
(
specify
.
get
(
"postTypeName"
).
toString
(),
specify
.
get
(
"userName"
).
toString
());
resultList
.
add
(
infoMap_2
);
String
teamName
=
team
.
get
(
"teamName"
);
// 根据teamName从orgUserSortRules中获取排序号
Optional
<
OrgUsr
>
orgUsrOptional
=
orgUserSortRules
.
stream
().
filter
(
v
->
Objects
.
equals
(
v
.
getBizOrgName
(),
teamName
)).
findFirst
();
if
(
orgUsrOptional
.
isPresent
())
{
OrgUsr
orgUsr
=
orgUsrOptional
.
get
();
String
sortNum
=
orgUsr
.
getOrgExpandAttr1
();
dutyCarSortNumMap
.
put
(
carName
,
Integer
.
parseInt
(
sortNum
));
}
}
// 根据dutyCarSortNumMap对dutyCarLogGroups进行排序
List
<
Map
.
Entry
<
String
,
List
<
Map
<
String
,
String
>>>>
dutyCarLogGroupEntries
=
new
ArrayList
<>(
dutyCarLogGroups
.
entrySet
());
dutyCarLogGroupEntries
.
sort
((
o1
,
o2
)
->
{
Integer
sortNum1
=
dutyCarSortNumMap
.
getOrDefault
(
o1
.
getKey
(),
Integer
.
MAX_VALUE
);
Integer
sortNum2
=
dutyCarSortNumMap
.
getOrDefault
(
o2
.
getKey
(),
Integer
.
MAX_VALUE
);
return
sortNum1
.
compareTo
(
sortNum2
);
});
for
(
Map
.
Entry
<
String
,
List
<
Map
<
String
,
String
>>>
entry
:
dutyCarLogGroupEntries
)
{
sortedDutyCarLogGroups
.
put
(
entry
.
getKey
(),
entry
.
getValue
());
}
// }
//}
// 3. 根据排序后的sortedDutyCarLogGroups生成返回结果
Set
<
Map
.
Entry
<
String
,
List
<
Map
<
String
,
String
>>>>
entries
=
sortedDutyCarLogGroups
.
entrySet
();
for
(
Map
.
Entry
<
String
,
List
<
Map
<
String
,
String
>>>
entry
:
entries
)
{
String
key
=
entry
.
getKey
();
List
<
Map
<
String
,
String
>>
value
=
entry
.
getValue
();
List
<
Map
<
String
,
String
>>
list
=
new
ArrayList
<>();
Map
<
String
,
String
>
item1
=
new
HashMap
<
String
,
String
>()
{{
this
.
put
(
"消防车辆"
,
key
);
}};
list
.
add
(
item1
);
Map
<
String
,
String
>
item2
=
new
HashMap
<
String
,
String
>()
{{
this
.
put
(
"单位/部门"
,
value
.
get
(
0
).
getOrDefault
(
"teamName"
,
""
));
}};
list
.
add
(
item2
);
// value 是一个部门的值班列表,按照postTypeName的字符串排序
List
<
Map
<
String
,
String
>>
posts
=
new
LinkedList
<>();
for
(
Map
<
String
,
String
>
val
:
value
)
{
Map
<
String
,
String
>
itemN
=
new
HashMap
<
String
,
String
>()
{{
this
.
put
(
val
.
getOrDefault
(
"postTypeName"
,
""
),
val
.
getOrDefault
(
"dutyUsers"
,
""
));
}};
posts
.
add
(
itemN
);
}
detailList
.
add
(
resultList
);
posts
.
sort
((
o1
,
o2
)
->
{
String
postTypeName1
=
o1
.
keySet
().
iterator
().
next
();
String
postTypeName2
=
o2
.
keySet
().
iterator
().
next
();
return
postTypeName1
.
compareTo
(
postTypeName2
);
});
list
.
addAll
(
posts
);
result
.
add
(
list
);
}
return
detailLis
t
;
return
result
.
isEmpty
()
?
this
.
getDutyPersonShiftLogData
(
dutyDay
,
fieldCode
)
:
resul
t
;
}
@Override
public
int
getDutyCarCount
(
Long
carId
)
{
List
<
Map
<
String
,
Object
>>
equipmentList
=
dutyPersonShiftMapper
.
getEquipmentForSpecifyDate
(
DateUtils
.
getDateNowShortStr
(),
...
...
@@ -258,4 +358,189 @@ public class DutyCarServiceImpl extends DutyCommonServiceImpl implements IDutyCa
return
instanceMap
;
}
@Override
public
void
writeHistoryDutyLog
()
{
List
<
Map
<
String
,
Object
>>
list
;
try
{
list
=
this
.
list
(
null
,
"1980-01-01"
,
"9999-12-12"
);
}
catch
(
ParseException
e
)
{
throw
new
RuntimeException
(
e
);
}
for
(
Map
<
String
,
Object
>
map
:
list
)
{
DutyCarDto
dutyCarDto
=
(
DutyCarDto
)
Bean
.
mapToBean
(
map
,
DutyCarDto
.
class
);
this
.
createDutyPersonShiftLog
(
dutyCarDto
,
true
,
null
);
}
}
public
Map
<
String
,
List
<
DutyPersonShiftLog
>>
getDownloadData
(
String
beginDate
,
String
endDate
)
throws
ParseException
{
Map
<
String
,
List
<
DutyPersonShiftLog
>>
resultSortedMap
=
new
LinkedHashMap
<>();
List
<
DutyPersonShiftLog
>
dutyCarLogs
=
dutyPersonShiftLogMapper
.
selectList
(
Wrappers
.<
DutyPersonShiftLog
>
lambdaQuery
()
.
ge
(
DutyPersonShiftLog:
:
getDutyDate
,
beginDate
)
.
le
(
DutyPersonShiftLog:
:
getDutyDate
,
endDate
)
.
eq
(
DutyPersonShiftLog:
:
getGroupCode
,
"dutyCar"
)
.
eq
(
DutyPersonShiftLog:
:
getIsDelete
,
false
)
);
Map
<
String
,
List
<
DutyPersonShiftLog
>>
unsortedMap
=
dutyCarLogs
.
stream
()
.
filter
(
v
->
Objects
.
nonNull
(
v
.
getCarName
()))
.
collect
(
Collectors
.
groupingBy
(
DutyPersonShiftLog:
:
getCarName
));
// 获取排序 BizOrgName: 部门名称,OrgExpandAttr1: 排序字段
List
<
OrgUsr
>
orgUserSortRules
=
orgUsrMapper
.
selectList
(
Wrappers
.<
OrgUsr
>
lambdaQuery
()
.
select
(
OrgUsr:
:
getBizOrgName
,
OrgUsr:
:
getOrgExpandAttr1
)
.
isNotNull
(
OrgUsr:
:
getOrgExpandAttr1
)
.
ne
(
OrgUsr:
:
getOrgExpandAttr1
,
""
)
).
stream
().
sorted
(
Comparator
.
comparing
(
v
->
Integer
.
parseInt
(
v
.
getOrgExpandAttr1
()))).
collect
(
Collectors
.
toList
());
// map的key为车辆名称,根据车辆名称获取部门值班列表。获取车辆下第一个部门,按照此部门对map进行排序,排序后的结果保存到一个有序的LinkedHashMap中.
// sortNum为数字类型,数字越小越靠前 | 车辆对应的部门列表可能为空,注意判空,无法排序的车辆放到最后
Map
<
String
,
List
<
DutyPersonShiftLog
>>
sortedMap
=
new
LinkedHashMap
<>();
Map
<
String
,
Integer
>
dutyCarSortNumMap
=
new
HashMap
<>();
for
(
String
carName
:
unsortedMap
.
keySet
())
{
List
<
DutyPersonShiftLog
>
dutyCarLogGroup
=
unsortedMap
.
get
(
carName
);
DutyPersonShiftLog
dutyPersonShiftLog
=
dutyCarLogGroup
.
get
(
0
);
if
(
Objects
.
isNull
(
dutyPersonShiftLog
))
{
continue
;
}
String
teamName
=
dutyPersonShiftLog
.
getDeptName
();
// 根据teamName从orgUserSortRules中获取排序号
Optional
<
OrgUsr
>
orgUsrOptional
=
orgUserSortRules
.
stream
().
filter
(
v
->
Objects
.
equals
(
v
.
getBizOrgName
(),
teamName
)).
findFirst
();
if
(
orgUsrOptional
.
isPresent
())
{
OrgUsr
orgUsr
=
orgUsrOptional
.
get
();
String
sortNum
=
orgUsr
.
getOrgExpandAttr1
();
dutyCarSortNumMap
.
put
(
carName
,
Integer
.
parseInt
(
sortNum
));
}
}
// 根据dutyCarSortNumMap对map进行排序
List
<
Map
.
Entry
<
String
,
List
<
DutyPersonShiftLog
>>>
dutyCarLogGroupEntries
=
new
ArrayList
<>(
unsortedMap
.
entrySet
());
dutyCarLogGroupEntries
.
sort
((
o1
,
o2
)
->
{
Integer
sortNum1
=
dutyCarSortNumMap
.
getOrDefault
(
o1
.
getKey
(),
Integer
.
MAX_VALUE
);
Integer
sortNum2
=
dutyCarSortNumMap
.
getOrDefault
(
o2
.
getKey
(),
Integer
.
MAX_VALUE
);
return
sortNum1
.
compareTo
(
sortNum2
);
});
for
(
Map
.
Entry
<
String
,
List
<
DutyPersonShiftLog
>>
entry
:
dutyCarLogGroupEntries
)
{
sortedMap
.
put
(
entry
.
getKey
(),
entry
.
getValue
());
}
// 根据排序后的sortedMap生成返回结果
Set
<
Map
.
Entry
<
String
,
List
<
DutyPersonShiftLog
>>>
entries
=
sortedMap
.
entrySet
();
for
(
Map
.
Entry
<
String
,
List
<
DutyPersonShiftLog
>>
entry
:
entries
)
{
String
key
=
entry
.
getKey
();
List
<
DutyPersonShiftLog
>
value
=
entry
.
getValue
();
resultSortedMap
.
put
(
key
,
value
);
}
return
resultSortedMap
;
}
@SuppressWarnings
(
"Duplicates"
)
public
void
createDutyPersonShiftLog
(
DutyCarDto
dutyCarDto
,
boolean
isInit
,
String
actionCode
)
{
TransactionSynchronizationManager
.
registerSynchronization
(
new
TransactionSynchronization
()
{
@Override
public
void
afterCommit
()
{
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
List
<
DutyPersonShiftDto
>
dutyPersonShift
=
dutyCarDto
.
getDutyShift
();
final
String
groupCode
=
"dutyCar"
;
// 新建/更新排班时处理跨月数据
if
(!
isInit
&&
StringUtils
.
isNotBlank
(
actionCode
))
{
if
(
Objects
.
nonNull
(
dutyPersonShift
)
&&
!
dutyPersonShift
.
isEmpty
())
{
// 拿到排班月份 yyyy-MM
String
dutyDate
=
dateFormat
.
format
(
dutyPersonShift
.
get
(
0
).
getDutyDate
());
dutyDate
=
dutyDate
.
substring
(
0
,
7
);
String
today
=
dateFormat
.
format
(
new
Date
());
if
(
today
.
substring
(
0
,
7
).
equals
(
dutyDate
))
{
dutyDate
=
today
;
}
else
{
dutyDate
+=
"-01"
;
}
dutyPersonShiftLogMapper
.
delete
(
Wrappers
.<
DutyPersonShiftLog
>
lambdaQuery
()
.
eq
(
DutyPersonShiftLog:
:
getGroupCode
,
groupCode
)
.
eq
(
DutyPersonShiftLog:
:
getDutyUser
,
dutyCarDto
.
getUserName
())
.
ge
(
DutyPersonShiftLog:
:
getDutyDate
,
dutyDate
)
.
ge
(
DutyPersonShiftLog:
:
getDutyDate
,
dateFormat
.
format
(
new
Date
()))
.
eq
(
DutyPersonShiftLog:
:
getIsDelete
,
false
)
);
}
dutyPersonShift
.
clear
();
try
{
List
<
Map
<
String
,
Object
>>
list
=
list
(
null
,
dateFormat
.
format
(
new
Date
()),
"9999-12-12"
);
list
=
list
.
stream
().
filter
(
map
->
Objects
.
equals
(
map
.
get
(
"userName"
),
dutyCarDto
.
getUserName
())).
collect
(
Collectors
.
toList
());
for
(
Map
<
String
,
Object
>
map
:
list
)
{
DutyCarDto
dutyCarDto
=
(
DutyCarDto
)
Bean
.
mapToBean
(
map
,
DutyCarDto
.
class
);
List
<
DutyPersonShiftDto
>
dutyShifts
=
dutyCarDto
.
getDutyShift
().
stream
().
filter
(
v
->
isAfterToday
(
v
.
getDutyDate
())).
collect
(
Collectors
.
toList
());
dutyPersonShift
.
addAll
(
dutyShifts
);
}
}
catch
(
ParseException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
Set
<
String
>
dutyDates
=
dutyPersonShift
.
stream
().
map
(
v
->
dateFormat
.
format
(
v
.
getDutyDate
())).
collect
(
Collectors
.
toSet
());
if
(
dutyDates
.
isEmpty
())
{
return
;
}
Map
<
Date
,
List
<
DutyPersonShiftLog
>>
dutyLogGroups
=
dutyPersonShiftLogMapper
.
selectList
(
Wrappers
.<
DutyPersonShiftLog
>
lambdaQuery
()
.
in
(
DutyPersonShiftLog:
:
getDutyDate
,
dutyDates
)
.
eq
(
DutyPersonShiftLog:
:
getGroupCode
,
groupCode
)
.
eq
(
DutyPersonShiftLog:
:
getDutyUser
,
dutyCarDto
.
getUserName
())
.
eq
(
DutyPersonShiftLog:
:
getIsDelete
,
false
)
).
stream
().
collect
(
Collectors
.
groupingBy
(
DutyPersonShiftLog:
:
getDutyDate
));
for
(
DutyPersonShiftDto
dutyPersonShiftDto
:
dutyPersonShift
)
{
// 非初始化非历史数据禁止修改
if
(!
isAfterToday
(
dutyPersonShiftDto
.
getDutyDate
())
&&
!
isInit
)
{
continue
;
}
List
<
DutyPersonShiftLog
>
dutyPersonShiftLogs
=
dutyLogGroups
.
get
(
dutyPersonShiftDto
.
getDutyDate
());
DutyPersonShiftLog
dutyPersonShiftLog
=
Objects
.
nonNull
(
dutyPersonShiftLogs
)
&&
!
dutyPersonShiftLogs
.
isEmpty
()
?
dutyPersonShiftLogs
.
get
(
0
)
:
null
;
// 日志不存在:新建
if
(
Objects
.
isNull
(
dutyPersonShiftLog
))
{
dutyPersonShiftLog
=
new
DutyPersonShiftLog
();
dutyPersonShiftLog
.
setInstanceId
(
dutyPersonShiftDto
.
getInstanceId
());
dutyPersonShiftLog
.
setDutyDate
(
dutyPersonShiftDto
.
getDutyDate
());
dutyPersonShiftLog
.
setGroupCode
(
groupCode
);
dutyPersonShiftLog
.
setDeptName
(
dutyCarDto
.
getTeamName
());
dutyPersonShiftLog
.
setDutyUserId
(
dutyCarDto
.
getUserId
());
dutyPersonShiftLog
.
setDutyUser
(
dutyCarDto
.
getUserName
());
dutyPersonShiftLog
.
setPostTypeName
(
dutyCarDto
.
getPostTypeName
());
dutyPersonShiftLog
.
setDutyArea
(
dutyCarDto
.
getDutyArea
());
dutyPersonShiftLog
.
setCarName
(
dutyCarDto
.
getCarName
());
String
shiftName
=
dutyPersonShiftDto
.
getShiftName
();
if
(
StringUtils
.
isBlank
(
shiftName
)
&&
Objects
.
nonNull
(
dutyPersonShiftDto
.
getShiftId
()))
{
DutyShift
dutyShift
=
dutyShiftService
.
getById
(
dutyPersonShiftDto
.
getShiftId
());
dutyPersonShiftDto
.
setShiftName
(
dutyShift
.
getName
());
}
dutyPersonShiftLog
.
setShiftName
(
dutyPersonShiftDto
.
getShiftName
());
dutyPersonShiftLogMapper
.
insert
(
dutyPersonShiftLog
);
continue
;
}
// 日志存在:更新
if
(
isAfterToday
(
dutyPersonShiftDto
.
getDutyDate
()))
{
dutyPersonShiftLog
.
setInstanceId
(
dutyPersonShiftDto
.
getInstanceId
());
dutyPersonShiftLog
.
setDeptName
(
dutyCarDto
.
getTeamName
());
dutyPersonShiftLog
.
setPostTypeName
(
dutyCarDto
.
getPostTypeName
());
dutyPersonShiftLog
.
setDutyArea
(
dutyCarDto
.
getDutyArea
());
dutyPersonShiftLog
.
setCarName
(
dutyCarDto
.
getCarName
());
String
shiftName
=
dutyPersonShiftDto
.
getShiftName
();
if
(
StringUtils
.
isBlank
(
shiftName
)
&&
Objects
.
nonNull
(
dutyPersonShiftDto
.
getShiftId
()))
{
DutyShift
dutyShift
=
dutyShiftService
.
getById
(
dutyPersonShiftDto
.
getShiftId
());
dutyPersonShiftDto
.
setShiftName
(
dutyShift
.
getName
());
}
dutyPersonShiftLog
.
setShiftName
(
dutyPersonShiftDto
.
getShiftName
());
dutyPersonShiftLogMapper
.
update
(
dutyPersonShiftLog
,
Wrappers
.<
DutyPersonShiftLog
>
lambdaUpdate
()
.
eq
(
DutyPersonShiftLog:
:
getDutyDate
,
dutyPersonShiftDto
.
getDutyDate
())
.
eq
(
DutyPersonShiftLog:
:
getGroupCode
,
groupCode
)
.
eq
(
DutyPersonShiftLog:
:
getDutyUser
,
dutyCarDto
.
getUserName
())
.
eq
(
DutyPersonShiftLog:
:
getIsDelete
,
false
)
);
}
}
}
});
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-common-biz/src/main/java/com/yeejoin/amos/boot/module/common/biz/service/impl/DutyCommonServiceImpl.java
View file @
e2d64218
...
...
@@ -3,21 +3,34 @@ package com.yeejoin.amos.boot.module.common.biz.service.impl;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDate
;
import
java.time.Period
;
import
java.time.temporal.ChronoUnit
;
import
java.util.*
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.function.Consumer
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
import
javax.servlet.http.HttpServletRequest
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.yeejoin.amos.boot.module.common.api.entity.*
;
import
com.yeejoin.amos.boot.module.common.api.mapper.DutyPersonShiftLogMapper
;
import
com.yeejoin.amos.boot.module.common.biz.enums.DynamicGroupCode
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.joda.time.DateTime
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.TransactionManager
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.support.TransactionSynchronization
;
import
org.springframework.transaction.support.TransactionSynchronizationManager
;
import
org.springframework.util.ObjectUtils
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
org.typroject.tyboot.core.foundation.utils.Bean
;
...
...
@@ -34,11 +47,6 @@ import com.yeejoin.amos.boot.module.common.api.dto.DutyFirstAidDto;
import
com.yeejoin.amos.boot.module.common.api.dto.DutyPersonDto
;
import
com.yeejoin.amos.boot.module.common.api.dto.DutyPersonShiftDto
;
import
com.yeejoin.amos.boot.module.common.api.dto.DutyShiftDto
;
import
com.yeejoin.amos.boot.module.common.api.entity.DutyPersonShift
;
import
com.yeejoin.amos.boot.module.common.api.entity.DutyShift
;
import
com.yeejoin.amos.boot.module.common.api.entity.DynamicFormColumn
;
import
com.yeejoin.amos.boot.module.common.api.entity.DynamicFormInstance
;
import
com.yeejoin.amos.boot.module.common.api.entity.OrgUsr
;
import
com.yeejoin.amos.boot.module.common.api.enums.DutyViewTypeEnum
;
import
com.yeejoin.amos.boot.module.common.api.mapper.DutyPersonShiftMapper
;
import
com.yeejoin.amos.boot.module.common.api.service.IDutyCommonService
;
...
...
@@ -76,6 +84,9 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
@Autowired
DutyPersonShiftMapper
dutyPersonShiftMapper
;
@Autowired
DutyPersonShiftLogMapper
dutyPersonShiftLogMapper
;
/**
* 每天单个班次执勤人数全部小于等于3人
*/
...
...
@@ -343,7 +354,18 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
if
(
StringUtils
.
isNotBlank
(
fieldCode
))
{
return
dutyPersonShiftService
.
getBaseMapper
().
newStationViewDataByFieldCode
(
dutyDate
,
this
.
getGroupCode
(),
fieldCode
);
}
return
dutyPersonShiftService
.
getBaseMapper
().
newStationViewData
(
dutyDate
,
this
.
getGroupCode
());
// return dutyPersonShiftService.getBaseMapper().newStationViewData(dutyDate, this.getGroupCode());
List
<
Map
<
String
,
String
>>
dutyLogs
=
dutyPersonShiftLogMapper
.
selectSpecificDateLogForPersonGroupByPostTypeName
(
dutyDate
);
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<>();
for
(
Map
<
String
,
String
>
dutyLog
:
dutyLogs
)
{
Map
<
String
,
Object
>
item
=
new
HashMap
<
String
,
Object
>()
{{
this
.
put
(
"postTypeName"
,
dutyLog
.
getOrDefault
(
"postTypeName"
,
""
));
this
.
put
(
"total"
,
dutyLog
.
getOrDefault
(
"dutyUsers"
,
""
).
split
(
","
).
length
);
}};
result
.
add
(
item
);
}
return
result
;
}
/**
* 车辆值班人员左侧的统计: 只有几辆车
...
...
@@ -351,22 +373,21 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
* @return
*/
public
Object
getCarPostTypeNameAndCount
(
String
dutyDate
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
int
station
=
0
;
int
person
=
0
;
List
<
Map
<
String
,
Object
>>
equipmentList
=
dutyPersonShiftMapper
.
getEquipmentForSpecifyDate
(
dutyDate
,
this
.
getGroupCode
(),
"carId"
,
"carName"
,
"teamName"
,
"result.carId"
);
if
(
equipmentList
==
null
||
equipmentList
.
size
()<
1
||
equipmentList
.
get
(
0
)==
null
)
{
station
=
0
;
}
else
{
station
=
equipmentList
.
size
();
}
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
List
<
DutyPersonShiftLog
>
dutyCarLogs
=
dutyPersonShiftLogMapper
.
selectList
(
Wrappers
.<
DutyPersonShiftLog
>
lambdaQuery
()
.
select
(
DutyPersonShiftLog:
:
getCarName
)
.
eq
(
DutyPersonShiftLog:
:
getDutyDate
,
dutyDate
)
.
eq
(
DutyPersonShiftLog:
:
getGroupCode
,
"dutyCar"
)
.
eq
(
DutyPersonShiftLog:
:
getIsDelete
,
false
)
);
dutyCarLogs
=
dutyCarLogs
.
stream
().
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toList
());
Map
<
String
,
List
<
DutyPersonShiftLog
>>
logsMap
=
dutyCarLogs
.
stream
().
collect
(
Collectors
.
groupingBy
(
DutyPersonShiftLog:
:
getCarName
));
int
station
=
logsMap
.
size
();
map
.
put
(
"station"
,
station
);
List
<
Map
<
String
,
Object
>>
list
=
dutyPersonShiftService
.
getBaseMapper
().
newStationViewData
(
dutyDate
,
this
.
getGroupCode
());
for
(
Map
<
String
,
Object
>
map2
:
list
)
{
person
=
person
+
Integer
.
parseInt
(
map2
.
get
(
"total"
).
toString
());
}
map
.
put
(
"person"
,
person
);
map
.
put
(
"person"
,
dutyCarLogs
.
size
());
return
map
;
}
...
...
@@ -634,6 +655,13 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
//dynamicFormInstanceService.remove(new LambdaQueryWrapper<DynamicFormInstance>().eq(DynamicFormInstance::getInstanceId, instanceId));
dutyPersonShiftService
.
remove
(
new
LambdaQueryWrapper
<
DutyPersonShift
>().
ge
(
DutyPersonShift:
:
getDutyDate
,
startTime
).
le
(
DutyPersonShift:
:
getDutyDate
,
endTime
).
eq
(
DutyPersonShift:
:
getInstanceId
,
instanceId
));
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
dutyPersonShiftLogMapper
.
delete
(
Wrappers
.<
DutyPersonShiftLog
>
lambdaQuery
()
.
eq
(
DutyPersonShiftLog:
:
getInstanceId
,
instanceId
)
.
ge
(
DutyPersonShiftLog:
:
getDutyDate
,
dateFormat
.
format
(
new
Date
()))
.
le
(
DutyPersonShiftLog:
:
getDutyDate
,
endTime
)
);
return
true
;
}
...
...
@@ -802,8 +830,8 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
dutyPersonShiftService
.
saveOrUpdateBatch
(
dutyShiftList
);
}
}
public
void
insertPersonShift
(
Long
instanceId
,
List
<
DutyPersonShiftDto
>
dutyShiftList
,
String
type
)
{
public
void
insertPersonShift
(
Long
instanceId
,
List
<
DutyPersonShiftDto
>
dutyShiftList
,
String
type
)
{
dutyPersonService
.
dataCheck
(
dutyShiftList
,
instanceId
,
type
);
Set
<
DutyPersonShift
>
personShiftList
=
dutyShiftList
.
stream
().
map
(
dto
->
{
// BUG 2807 修改时发现BUG 车辆保存有问题 by kongfm 2021-09-14
...
...
@@ -822,9 +850,31 @@ public class DutyCommonServiceImpl implements IDutyCommonService {
}
}
/**
* 判断是否是历史值班日
* @param dutyDate 值班日期
*/
public
boolean
isAfterToday
(
Date
dutyDate
)
{
// 获取今天的开始时间
Calendar
todayStart
=
Calendar
.
getInstance
();
todayStart
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
todayStart
.
set
(
Calendar
.
MINUTE
,
0
);
todayStart
.
set
(
Calendar
.
SECOND
,
0
);
todayStart
.
set
(
Calendar
.
MILLISECOND
,
0
);
Calendar
duty
=
Calendar
.
getInstance
();
duty
.
setTime
(
dutyDate
);
return
duty
.
after
(
todayStart
)
||
duty
.
equals
(
todayStart
);
}
@Override
public
Object
getSchedulingDutyForSpecifyDate
(
String
dutyDay
,
Long
shiftId
,
String
postType
,
String
fieldCode
)
{
// TODO Auto-generated method stub
return
null
;
}
public
Object
getDutyPersonShiftLogData
(
String
dutyDay
,
String
fieldCode
){
return
null
;
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-common-biz/src/main/java/com/yeejoin/amos/boot/module/common/biz/service/impl/DutyPersonServiceImpl.java
View file @
e2d64218
package
com
.
yeejoin
.
amos
.
boot
.
module
.
common
.
biz
.
service
.
impl
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.concurrent.atomic.AtomicReference
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.stream.Collectors
;
import
com.yeejoin.amos.boot.biz.common.dao.mapper.DataDictionaryMapper
;
import
com.yeejoin.amos.boot.biz.common.entity.DataDictionary
;
import
com.yeejoin.amos.boot.module.common.api.dto.DutyCarDto
;
import
com.yeejoin.amos.boot.module.common.api.entity.*
;
import
com.yeejoin.amos.boot.module.common.api.mapper.DutyPersonShiftLogMapper
;
import
com.yeejoin.amos.boot.module.common.api.mapper.OrgUsrMapper
;
import
org.springframework.transaction.support.TransactionSynchronization
;
import
org.springframework.transaction.support.TransactionSynchronizationManager
;
import
com.alibaba.fastjson.JSON
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.yeejoin.amos.boot.module.common.api.dto.DutyPersonShiftDto
;
import
com.yeejoin.amos.boot.module.common.api.mapper.DutyPersonShiftMapper
;
import
com.yeejoin.amos.boot.module.common.biz.enums.ActionStatus
;
...
...
@@ -13,7 +27,6 @@ import org.springframework.stereotype.Service;
import
org.springframework.util.ObjectUtils
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
org.typroject.tyboot.core.foundation.utils.Bean
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
import
org.typroject.tyboot.core.restful.exception.instance.BadRequest
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
...
...
@@ -21,9 +34,6 @@ import com.alibaba.fastjson.JSONArray;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.yeejoin.amos.boot.biz.common.utils.DateUtils
;
import
com.yeejoin.amos.boot.module.common.api.dto.DutyPersonDto
;
import
com.yeejoin.amos.boot.module.common.api.entity.DutyPersonShift
;
import
com.yeejoin.amos.boot.module.common.api.entity.DynamicFormColumn
;
import
com.yeejoin.amos.boot.module.common.api.entity.DynamicFormInstance
;
import
com.yeejoin.amos.boot.module.common.api.feign.EquipFeignClient
;
import
com.yeejoin.amos.boot.module.common.api.service.IDutyPersonService
;
...
...
@@ -37,6 +47,14 @@ public class DutyPersonServiceImpl extends DutyCommonServiceImpl implements IDut
EquipFeignClient
equipFeign
;
@Autowired
DutyPersonShiftMapper
dutyPersonShiftMapper
;
@Autowired
DutyPersonShiftLogMapper
dutyPersonShiftLogMapper
;
@Autowired
DataDictionaryMapper
dataDictionaryMapper
;
@Autowired
OrgUsrMapper
orgUsrMapper
;
@Override
...
...
@@ -121,11 +139,10 @@ public class DutyPersonServiceImpl extends DutyCommonServiceImpl implements IDut
}
//2.保存值班信息
insertPersonShift
(
instanceId
,
dutyPersonDto
,
ActionStatus
.
METHOD_ADD
.
getCode
());
// 生成变更日志
createDutyPersonShiftLog
(
dutyPersonDto
,
false
,
ActionStatus
.
METHOD_ADD
.
getCode
());
//3.返回保存后的数据
return
dutyPersonDto
;
}
@Override
...
...
@@ -158,6 +175,8 @@ public class DutyPersonServiceImpl extends DutyCommonServiceImpl implements IDut
}
//5.更新值班信息人日期数据
insertPersonShift
(
instanceId
,
dutyPersonDto
,
ActionStatus
.
METHOD_UPDATE
.
getCode
());
// 生成变更日志
createDutyPersonShiftLog
(
dutyPersonDto
,
false
,
ActionStatus
.
METHOD_UPDATE
.
getCode
());
return
dutyPersonDto
;
}
...
...
@@ -179,7 +198,6 @@ public class DutyPersonServiceImpl extends DutyCommonServiceImpl implements IDut
}
}
public
void
dataCheck
(
List
<
DutyPersonShiftDto
>
dutyShiftList
,
Long
instanceId
,
String
type
){
try
{
//获取排班月份的最大及最小日期
...
...
@@ -336,15 +354,85 @@ public Object BuildScheduleDetails(String dutyDay, Long shiftId, String postType
public
Object
getSchedulingDutyForSpecifyDate
(
String
dutyDay
,
Long
shiftId
,
String
postType
,
String
fieldCode
)
{
List
<
Map
<
String
,
String
>>
dutyLogs
=
dutyPersonShiftLogMapper
.
selectSpecificDateLogForPerson
(
dutyDay
);
Map
<
String
,
List
<
Map
<
String
,
String
>>>
dutyLogGroups
=
dutyLogs
.
stream
().
collect
(
Collectors
.
groupingBy
(
v
->
v
.
get
(
"deptName"
)));
List
<
Object
>
result
=
new
ArrayList
<>();
// 获取排序规则: BizOrgName: 部门名称,OrgExpandAttr1: 排序字段
List
<
OrgUsr
>
orgUserSortRules
=
orgUsrMapper
.
selectList
(
Wrappers
.<
OrgUsr
>
lambdaQuery
()
.
select
(
OrgUsr:
:
getBizOrgName
,
OrgUsr:
:
getOrgExpandAttr1
)
.
isNotNull
(
OrgUsr:
:
getOrgExpandAttr1
)
.
ne
(
OrgUsr:
:
getOrgExpandAttr1
,
""
)
).
stream
().
sorted
(
Comparator
.
comparing
(
v
->
Integer
.
parseInt
(
v
.
getOrgExpandAttr1
()))).
collect
(
Collectors
.
toList
());
// orgUserSortRules中的BizOrgName对应dutyLogGroups的key, 按照OrgExpandAttr1排序, OrgExpandAttr1值越小越靠前,否则靠后。
Map
<
String
,
List
<
Map
<
String
,
String
>>>
sortedDutyLogGroups
=
new
LinkedHashMap
<>();
for
(
OrgUsr
orgUsr
:
orgUserSortRules
)
{
String
bizOrgName
=
orgUsr
.
getBizOrgName
();
if
(
dutyLogGroups
.
containsKey
(
bizOrgName
))
{
sortedDutyLogGroups
.
put
(
bizOrgName
,
dutyLogGroups
.
get
(
bizOrgName
));
}
}
for
(
Map
.
Entry
<
String
,
List
<
Map
<
String
,
String
>>>
entry
:
dutyLogGroups
.
entrySet
())
{
String
key
=
entry
.
getKey
();
if
(!
sortedDutyLogGroups
.
containsKey
(
key
))
{
sortedDutyLogGroups
.
put
(
key
,
entry
.
getValue
());
}
}
// 岗位排序规则 name: 岗位名称,sortNum: 排序字段
List
<
DataDictionary
>
postSortRules
=
dataDictionaryMapper
.
selectList
(
Wrappers
.<
DataDictionary
>
lambdaQuery
()
.
select
(
DataDictionary:
:
getName
,
DataDictionary:
:
getSortNum
)
.
eq
(
DataDictionary:
:
getType
,
"DUTY_POST_TYPE"
)
.
eq
(
DataDictionary:
:
getIsDelete
,
false
)
).
stream
().
sorted
(
Comparator
.
comparing
(
DataDictionary:
:
getSortNum
)).
collect
(
Collectors
.
toList
());
// 组装数据
for
(
Map
.
Entry
<
String
,
List
<
Map
<
String
,
String
>>>
entry
:
sortedDutyLogGroups
.
entrySet
())
{
List
<
Object
>
items
=
new
ArrayList
<>();
String
key
=
entry
.
getKey
();
List
<
Map
<
String
,
String
>>
value
=
entry
.
getValue
();
items
.
add
(
key
);
// postSortRules的name对应value的postTypeName,按照sortNum排序,sortNum值越小越靠前,否则靠后。
Map
<
String
,
String
>
sortedValue
=
new
LinkedHashMap
<>();
for
(
DataDictionary
dataDictionary
:
postSortRules
)
{
String
name
=
dataDictionary
.
getName
();
for
(
Map
<
String
,
String
>
map
:
value
)
{
if
(
name
.
equals
(
map
.
get
(
"postTypeName"
)))
{
sortedValue
.
put
(
name
,
map
.
getOrDefault
(
"dutyUsers"
,
""
));
}
}
}
// 未匹配到的数据,按照原有顺序放到最后
for
(
Map
<
String
,
String
>
map
:
value
)
{
String
postTypeName
=
map
.
get
(
"postTypeName"
);
if
(!
sortedValue
.
containsKey
(
postTypeName
))
{
sortedValue
.
put
(
postTypeName
,
map
.
getOrDefault
(
"dutyUsers"
,
""
));
}
}
for
(
Map
.
Entry
<
String
,
String
>
sortedEntry
:
sortedValue
.
entrySet
())
{
Map
<
String
,
String
>
itemN
=
new
HashMap
<
String
,
String
>()
{{
this
.
put
(
sortedEntry
.
getKey
(),
sortedEntry
.
getValue
());
}};
items
.
add
(
itemN
);
}
result
.
add
(
items
);
}
return
result
;
}
public
Object
getDutyPersonShiftLogData
(
String
dutyDay
,
String
fieldCode
)
{
List
<
Map
<
String
,
Object
>>
equipmentList
=
dutyPersonShiftMapper
.
getNewEquipmentForSpecifyDate
(
dutyDay
,
this
.
getGroupCode
(),
"deptId"
,
"deptName"
,
"result.deptId"
);
if
(
equipmentList
==
null
||
equipmentList
.
size
()
<
1
||
equipmentList
.
get
(
0
)
==
null
)
{
if
(
equipmentList
==
null
||
equipmentList
.
isEmpty
()
||
equipmentList
.
get
(
0
)
==
null
)
{
return
null
;
}
List
<
Object
>
detailList
=
new
ArrayList
<
Object
>();
List
<
Object
>
detailList
=
new
ArrayList
<
>();
for
(
Map
<
String
,
Object
>
map
:
equipmentList
)
{
List
<
Object
>
resultList
=
new
ArrayList
<
Object
>();
LinkedHashMap
<
String
,
Object
>
titleMap_2
=
new
LinkedHashMap
<
String
,
Object
>();
List
<
Object
>
resultList
=
new
ArrayList
<>();
if
(
map
.
containsKey
(
"deptName"
)
&&
map
.
get
(
"deptName"
)
!=
null
){
resultList
.
add
(
map
.
get
(
"deptName"
).
toString
());
}
...
...
@@ -362,11 +450,11 @@ public Object BuildScheduleDetails(String dutyDay, Long shiftId, String postType
List
<
Map
<
String
,
Object
>>
specifyDateList
=
dutyPersonShiftMapper
.
getPositionStaffDutyForSpecifyDate
(
dutyDay
,
this
.
getGroupCode
(),
instanceIds
,
null
,
fieldCode
);
if
(
specifyDateList
==
null
||
specifyDateList
.
size
()
<
1
||
specifyDateList
.
get
(
0
)
==
null
)
{
if
(
specifyDateList
==
null
||
specifyDateList
.
isEmpty
()
||
specifyDateList
.
get
(
0
)
==
null
)
{
continue
;
}
for
(
Map
<
String
,
Object
>
specify
:
specifyDateList
)
{
LinkedHashMap
<
String
,
Object
>
infoMap_2
=
new
LinkedHashMap
<
String
,
Object
>();
LinkedHashMap
<
String
,
Object
>
infoMap_2
=
new
LinkedHashMap
<
>();
if
(
specify
.
containsKey
(
"postTypeName"
)&&
specify
.
get
(
"postTypeName"
)!=
null
&&
specify
.
containsKey
(
"userName"
)&&
specify
.
get
(
"userName"
)!=
null
)
{
infoMap_2
.
put
(
specify
.
get
(
"postTypeName"
).
toString
(),
specify
.
get
(
"userName"
).
toString
());
resultList
.
add
(
infoMap_2
);
...
...
@@ -378,21 +466,181 @@ public Object BuildScheduleDetails(String dutyDay, Long shiftId, String postType
return
detailList
;
}
@Override
public
void
writeHistoryDutyLog
()
{
List
<
Map
<
String
,
Object
>>
list
;
try
{
list
=
this
.
list
(
null
,
"1980-01-01"
,
"9999-12-12"
);
}
catch
(
ParseException
e
)
{
throw
new
RuntimeException
(
e
);
}
for
(
Map
<
String
,
Object
>
map
:
list
)
{
DutyPersonDto
dutyPersonDto
=
(
DutyPersonDto
)
Bean
.
mapToBean
(
map
,
DutyPersonDto
.
class
);
this
.
createDutyPersonShiftLog
(
dutyPersonDto
,
true
,
null
);
}
}
public
Map
<
String
,
List
<
DutyPersonShiftLog
>>
getDownloadData
(
String
beginDate
,
String
endDate
)
throws
ParseException
{
Map
<
String
,
List
<
DutyPersonShiftLog
>>
resultSortedMap
=
new
LinkedHashMap
<>();
List
<
DutyPersonShiftLog
>
dutyCarLogs
=
dutyPersonShiftLogMapper
.
selectList
(
Wrappers
.<
DutyPersonShiftLog
>
lambdaQuery
()
.
ge
(
DutyPersonShiftLog:
:
getDutyDate
,
beginDate
)
.
le
(
DutyPersonShiftLog:
:
getDutyDate
,
endDate
)
.
eq
(
DutyPersonShiftLog:
:
getGroupCode
,
"dutyPerson"
)
.
eq
(
DutyPersonShiftLog:
:
getIsDelete
,
false
)
);
if
(
dutyCarLogs
.
isEmpty
())
{
return
resultSortedMap
;
}
List
<
Long
>
userIds
=
dutyCarLogs
.
stream
().
map
(
v
->
Long
.
valueOf
(
v
.
getDutyUserId
())).
distinct
().
collect
(
Collectors
.
toList
());
// 获取人员姓名与人员部门的关系
List
<
Map
<
String
,
String
>>
userDeptMapList
=
orgUsrMapper
.
selectUserDeptMap
(
userIds
);
// userDeptMapList 转为 Map, key: userName, value
Map
<
String
,
String
>
userDeptMap
=
new
HashMap
<>();
for
(
Map
<
String
,
String
>
map
:
userDeptMapList
)
{
userDeptMap
.
put
(
map
.
get
(
"userName"
),
map
.
get
(
"deptName"
));
}
Map
<
String
,
List
<
DutyPersonShiftLog
>>
unsortedMap
=
dutyCarLogs
.
stream
().
collect
(
Collectors
.
groupingBy
(
DutyPersonShiftLog:
:
getDutyUser
));
// 先按照人员所属部门排序, 部门相同的情况下按照人员岗位排序即可
// 获取人员部门排序规则: BizOrgName: 部门名称,OrgExpandAttr1: 排序字段
List
<
OrgUsr
>
orgUserSortRules
=
orgUsrMapper
.
selectList
(
Wrappers
.<
OrgUsr
>
lambdaQuery
()
.
select
(
OrgUsr:
:
getBizOrgName
,
OrgUsr:
:
getOrgExpandAttr1
)
.
isNotNull
(
OrgUsr:
:
getOrgExpandAttr1
)
.
ne
(
OrgUsr:
:
getOrgExpandAttr1
,
""
)
).
stream
().
sorted
(
Comparator
.
comparing
(
v
->
Integer
.
parseInt
(
v
.
getOrgExpandAttr1
()))).
collect
(
Collectors
.
toList
());
// 进行排序:按照人员部门排序 userDeptMap为人员与所属部门映射,orgUserSortRules为部门排序规则。orgUserSortRules中部门的顺序即为部门排序规则
for
(
OrgUsr
orgUsr
:
orgUserSortRules
)
{
String
bizOrgName
=
orgUsr
.
getBizOrgName
();
for
(
Map
.
Entry
<
String
,
List
<
DutyPersonShiftLog
>>
entry
:
unsortedMap
.
entrySet
())
{
String
userName
=
entry
.
getKey
();
List
<
DutyPersonShiftLog
>
dutyPersonShiftLogs
=
entry
.
getValue
();
if
(
userDeptMap
.
containsKey
(
userName
)
&&
userDeptMap
.
get
(
userName
).
equals
(
bizOrgName
))
{
resultSortedMap
.
put
(
userName
,
dutyPersonShiftLogs
);
}
}
}
// 未匹配到的数据,按照原有顺序放到最后
for
(
Map
.
Entry
<
String
,
List
<
DutyPersonShiftLog
>>
entry
:
unsortedMap
.
entrySet
())
{
String
userName
=
entry
.
getKey
();
List
<
DutyPersonShiftLog
>
dutyPersonShiftLogs
=
entry
.
getValue
();
if
(!
resultSortedMap
.
containsKey
(
userName
))
{
resultSortedMap
.
put
(
userName
,
dutyPersonShiftLogs
);
}
}
return
resultSortedMap
;
}
@SuppressWarnings
(
"Duplicates"
)
public
void
createDutyPersonShiftLog
(
DutyPersonDto
dutyPersonDto
,
boolean
isInit
,
String
actionCode
)
{
TransactionSynchronizationManager
.
registerSynchronization
(
new
TransactionSynchronization
()
{
@Override
public
void
afterCommit
()
{
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
List
<
DutyPersonShiftDto
>
dutyPersonShift
=
dutyPersonDto
.
getDutyShift
();
final
String
groupCode
=
"dutyPerson"
;
// 新建/更新排班时处理跨月数据
if
(!
isInit
&&
StringUtils
.
isNotBlank
(
actionCode
))
{
if
(
Objects
.
nonNull
(
dutyPersonShift
)
&&
!
dutyPersonShift
.
isEmpty
())
{
// 拿到排班月份 yyyy-MM
String
dutyDate
=
dateFormat
.
format
(
dutyPersonShift
.
get
(
0
).
getDutyDate
());
dutyDate
=
dutyDate
.
substring
(
0
,
7
);
String
today
=
dateFormat
.
format
(
new
Date
());
if
(
today
.
substring
(
0
,
7
).
equals
(
dutyDate
))
{
dutyDate
=
today
;
}
else
{
dutyDate
+=
"-01"
;
}
dutyPersonShiftLogMapper
.
delete
(
Wrappers
.<
DutyPersonShiftLog
>
lambdaQuery
()
.
eq
(
DutyPersonShiftLog:
:
getGroupCode
,
groupCode
)
.
eq
(
DutyPersonShiftLog:
:
getDutyUser
,
dutyPersonDto
.
getUserName
())
.
ge
(
DutyPersonShiftLog:
:
getDutyDate
,
dutyDate
)
.
ge
(
DutyPersonShiftLog:
:
getDutyDate
,
dateFormat
.
format
(
new
Date
()))
.
eq
(
DutyPersonShiftLog:
:
getIsDelete
,
false
)
);
}
dutyPersonShift
.
clear
();
try
{
List
<
Map
<
String
,
Object
>>
list
=
list
(
null
,
dateFormat
.
format
(
new
Date
()),
"9999-12-12"
);
list
=
list
.
stream
().
filter
(
map
->
Objects
.
equals
(
map
.
get
(
"userName"
),
dutyPersonDto
.
getUserName
())).
collect
(
Collectors
.
toList
());
for
(
Map
<
String
,
Object
>
map
:
list
)
{
DutyCarDto
dutyCarDto
=
(
DutyCarDto
)
Bean
.
mapToBean
(
map
,
DutyCarDto
.
class
);
List
<
DutyPersonShiftDto
>
dutyShifts
=
dutyCarDto
.
getDutyShift
().
stream
().
filter
(
v
->
isAfterToday
(
v
.
getDutyDate
())).
collect
(
Collectors
.
toList
());
dutyPersonShift
.
addAll
(
dutyShifts
);
}
}
catch
(
ParseException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
Set
<
String
>
dutyDates
=
dutyPersonShift
.
stream
().
map
(
v
->
dateFormat
.
format
(
v
.
getDutyDate
())).
collect
(
Collectors
.
toSet
());
if
(
dutyDates
.
isEmpty
())
{
return
;
}
Map
<
Date
,
List
<
DutyPersonShiftLog
>>
dutyLogGroups
=
dutyPersonShiftLogMapper
.
selectList
(
Wrappers
.<
DutyPersonShiftLog
>
lambdaQuery
()
.
in
(
DutyPersonShiftLog:
:
getDutyDate
,
dutyDates
)
.
eq
(
DutyPersonShiftLog:
:
getGroupCode
,
groupCode
)
.
eq
(
DutyPersonShiftLog:
:
getDutyUser
,
dutyPersonDto
.
getUserName
())
.
eq
(
DutyPersonShiftLog:
:
getIsDelete
,
false
)
).
stream
().
collect
(
Collectors
.
groupingBy
(
DutyPersonShiftLog:
:
getDutyDate
));
for
(
DutyPersonShiftDto
dutyPersonShiftDto
:
dutyPersonShift
)
{
// 非初始化非历史数据禁止修改
if
(!
isAfterToday
(
dutyPersonShiftDto
.
getDutyDate
())
&&
!
isInit
)
{
continue
;
}
List
<
DutyPersonShiftLog
>
dutyPersonShiftLogs
=
dutyLogGroups
.
get
(
dutyPersonShiftDto
.
getDutyDate
());
DutyPersonShiftLog
dutyPersonShiftLog
=
Objects
.
nonNull
(
dutyPersonShiftLogs
)
&&
!
dutyPersonShiftLogs
.
isEmpty
()
?
dutyPersonShiftLogs
.
get
(
0
)
:
null
;
// 日志不存在:新建
if
(
Objects
.
isNull
(
dutyPersonShiftLog
))
{
dutyPersonShiftLog
=
new
DutyPersonShiftLog
();
dutyPersonShiftLog
.
setInstanceId
(
dutyPersonShiftDto
.
getInstanceId
());
dutyPersonShiftLog
.
setDutyDate
(
dutyPersonShiftDto
.
getDutyDate
());
dutyPersonShiftLog
.
setGroupCode
(
groupCode
);
dutyPersonShiftLog
.
setDeptName
(
dutyPersonDto
.
getDeptName
());
dutyPersonShiftLog
.
setDutyUserId
(
dutyPersonDto
.
getUserId
());
dutyPersonShiftLog
.
setDutyUser
(
dutyPersonDto
.
getUserName
());
dutyPersonShiftLog
.
setPostTypeName
(
dutyPersonDto
.
getPostTypeName
());
dutyPersonShiftLog
.
setDutyArea
(
dutyPersonDto
.
getDutyArea
());
String
shiftName
=
dutyPersonShiftDto
.
getShiftName
();
if
(
StringUtils
.
isBlank
(
shiftName
)
&&
Objects
.
nonNull
(
dutyPersonShiftDto
.
getShiftId
()))
{
DutyShift
dutyShift
=
dutyShiftService
.
getById
(
dutyPersonShiftDto
.
getShiftId
());
dutyPersonShiftDto
.
setShiftName
(
dutyShift
.
getName
());
}
dutyPersonShiftLog
.
setShiftName
(
dutyPersonShiftDto
.
getShiftName
());
dutyPersonShiftLogMapper
.
insert
(
dutyPersonShiftLog
);
continue
;
}
if
(
isAfterToday
(
dutyPersonShiftDto
.
getDutyDate
()))
{
dutyPersonShiftLog
.
setInstanceId
(
dutyPersonShiftDto
.
getInstanceId
());
dutyPersonShiftLog
.
setDeptName
(
dutyPersonDto
.
getDeptName
());
dutyPersonShiftLog
.
setPostTypeName
(
dutyPersonDto
.
getPostTypeName
());
dutyPersonShiftLog
.
setDutyArea
(
dutyPersonDto
.
getDutyArea
());
String
shiftName
=
dutyPersonShiftDto
.
getShiftName
();
if
(
StringUtils
.
isBlank
(
shiftName
)
&&
Objects
.
nonNull
(
dutyPersonShiftDto
.
getShiftId
()))
{
DutyShift
dutyShift
=
dutyShiftService
.
getById
(
dutyPersonShiftDto
.
getShiftId
());
dutyPersonShiftDto
.
setShiftName
(
dutyShift
.
getName
());
}
dutyPersonShiftLog
.
setShiftName
(
dutyPersonShiftDto
.
getShiftName
());
dutyPersonShiftLogMapper
.
update
(
dutyPersonShiftLog
,
Wrappers
.<
DutyPersonShiftLog
>
lambdaUpdate
()
.
eq
(
DutyPersonShiftLog:
:
getDutyDate
,
dutyPersonShiftDto
.
getDutyDate
())
.
eq
(
DutyPersonShiftLog:
:
getGroupCode
,
groupCode
)
.
eq
(
DutyPersonShiftLog:
:
getDutyUser
,
dutyPersonDto
.
getUserName
())
.
eq
(
DutyPersonShiftLog:
:
getIsDelete
,
false
)
);
}
}
;
}
});
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-jcs-biz/src/main/java/com/yeejoin/amos/boot/module/jcs/biz/service/impl/ExcelServiceImpl.java
View file @
e2d64218
...
...
@@ -13,7 +13,9 @@ import javax.servlet.http.HttpServletResponse;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yeejoin.amos.boot.module.common.api.dto.*
;
import
com.yeejoin.amos.boot.module.common.api.entity.*
;
import
com.yeejoin.amos.boot.module.common.api.excel.ExplicitConstraint
;
import
com.yeejoin.amos.boot.module.common.api.mapper.DutyPersonShiftLogMapper
;
import
com.yeejoin.amos.boot.module.common.api.mapper.OrgUsrMapper
;
import
com.yeejoin.amos.boot.module.jcs.api.dto.SignDto
;
import
com.yeejoin.amos.boot.module.jcs.api.dto.SinStaticDto
;
...
...
@@ -52,21 +54,6 @@ import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import
com.yeejoin.amos.boot.biz.common.utils.QRCodeUtil
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisKey
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.amos.boot.module.common.api.entity.DynamicFormColumn
;
import
com.yeejoin.amos.boot.module.common.api.entity.DynamicFormInstance
;
import
com.yeejoin.amos.boot.module.common.api.entity.FireChemical
;
import
com.yeejoin.amos.boot.module.common.api.entity.FireExperts
;
import
com.yeejoin.amos.boot.module.common.api.entity.FireStation
;
import
com.yeejoin.amos.boot.module.common.api.entity.FireTeam
;
import
com.yeejoin.amos.boot.module.common.api.entity.Firefighters
;
import
com.yeejoin.amos.boot.module.common.api.entity.FirefightersContacts
;
import
com.yeejoin.amos.boot.module.common.api.entity.FirefightersEducation
;
import
com.yeejoin.amos.boot.module.common.api.entity.FirefightersPost
;
import
com.yeejoin.amos.boot.module.common.api.entity.FirefightersWorkexperience
;
import
com.yeejoin.amos.boot.module.common.api.entity.MaintenanceCompany
;
import
com.yeejoin.amos.boot.module.common.api.entity.OrgUsr
;
import
com.yeejoin.amos.boot.module.common.api.entity.RescueEquipment
;
import
com.yeejoin.amos.boot.module.common.api.entity.SpecialPositionStaff
;
import
com.yeejoin.amos.boot.module.common.api.excel.ExcelUtil
;
import
com.yeejoin.amos.boot.module.common.api.service.IDutyFireFightingService
;
import
com.yeejoin.amos.boot.module.common.api.service.IDutyFirstAidService
;
...
...
@@ -193,6 +180,9 @@ public class ExcelServiceImpl {
@Autowired
SignServiceImpl
signServiceImpl
;
@Autowired
DutyPersonShiftLogMapper
dutyPersonShiftLogMapper
;
public
void
templateExport
(
HttpServletResponse
response
,
ExcelDto
excelDto
)
throws
ClassNotFoundException
{
String
url
=
excelDto
.
getClassUrl
();
Class
<?>
clz
=
Class
.
forName
(
url
);
...
...
@@ -1784,6 +1774,12 @@ public class ExcelServiceImpl {
dataList
.
add
(
dutyCarDtoMap
);
}
}
// 生成变更日志
dataList
.
forEach
(
v
->
{
DutyCarDto
dutyCarDto
=
(
DutyCarDto
)
Bean
.
mapToBean
(
v
,
DutyCarDto
.
class
);
dutyCarService
.
createDutyPersonShiftLog
(
dutyCarDto
,
false
,
null
);
});
}
private
void
initDutyPersonData
(
XSSFSheet
sheet
,
List
<
Map
<
String
,
Object
>>
dataList
,
List
<
Date
>
dayByMonth
)
{
...
...
@@ -1848,6 +1844,12 @@ public class ExcelServiceImpl {
dataList
.
add
(
dutyPersonDtoMap
);
}
}
// 生成变更日志
dataList
.
forEach
(
v
->
{
DutyPersonDto
dutyPersonDto
=
(
DutyPersonDto
)
Bean
.
mapToBean
(
v
,
DutyPersonDto
.
class
);
dutyPersonService
.
createDutyPersonShiftLog
(
dutyPersonDto
,
false
,
null
);
});
}
private
void
initDutyFireFightingData
(
XSSFSheet
sheet
,
List
<
Map
<
String
,
Object
>>
dataList
,
List
<
Date
>
dayByMonth
)
{
...
...
@@ -1956,8 +1958,10 @@ public class ExcelServiceImpl {
String
ids
)
{
List
<
List
<
Object
>>
data
=
new
ArrayList
<>();
if
(
ExcelEnums
.
CLZQ
.
getType
().
equals
(
excelDto
.
getType
()))
{
excelDto
.
setClassUrl
(
"com.yeejoin.amos.boot.module.common.api.dto.TemplateDutyCarExcelDto"
);
data
=
initDutyCarTemplate
(
ids
);
}
else
if
(
ExcelEnums
.
RYZB
.
getType
().
equals
(
excelDto
.
getType
()))
{
excelDto
.
setClassUrl
(
"com.yeejoin.amos.boot.module.common.api.dto.TemplateDutyPersonExcelDto"
);
data
=
initDutyPersonTemplate
(
ids
);
}
else
if
(
ExcelEnums
.
WXXFZB
.
getType
().
equals
(
excelDto
.
getType
()))
{
data
=
initDutyDutyFireFightingTemplate
(
ids
);
...
...
@@ -2170,28 +2174,45 @@ public class ExcelServiceImpl {
private
List
<
List
<
Object
>>
initDutyCarInfo
(
String
beginDate
,
String
endDate
,
List
<
String
>
dayByMonth
)
throws
ParseException
{
// 查询已值班数据
List
<
DutyCarDto
>
contentList
=
dutyCarService
.
downloadList
(
beginDate
,
endDate
);
Map
<
String
,
List
<
DutyPersonShiftLog
>>
dutyPersonShiftLogs
=
dutyCarService
.
getDownloadData
(
beginDate
,
endDate
);
List
<
List
<
Object
>>
data
=
new
ArrayList
<>();
List
<
String
>
monthDays
=
getMonthDays
(
beginDate
);
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
// 组装导出数据
if
(!
contentList
.
isEmpty
())
{
if
(!
dutyPersonShiftLogs
.
isEmpty
())
{
AtomicInteger
row
=
new
AtomicInteger
(
1
);
contentList
.
forEach
(
o
->
{
for
(
Map
.
Entry
<
String
,
List
<
DutyPersonShiftLog
>>
entry
:
dutyPersonShiftLogs
.
entrySet
())
{
String
carName
=
entry
.
getKey
();
List
<
DutyPersonShiftLog
>
shiftLogs
=
entry
.
getValue
();
Map
<
String
,
List
<
DutyPersonShiftLog
>>
shiftLogsMap
=
shiftLogs
.
stream
().
collect
(
Collectors
.
groupingBy
(
v
->
formatter
.
format
(
v
.
getDutyDate
())));
ArrayList
<
Object
>
list
=
new
ArrayList
<>();
list
.
add
(
row
.
getAndIncrement
());
list
.
add
(
o
.
getTeamName
());
list
.
add
(
o
.
getUserName
());
list
.
add
(
o
.
getPostTypeName
());
list
.
add
(
o
.
getCarName
());
list
.
add
(
o
.
getDutyArea
());
List
<
DutyPersonShiftDto
>
dutyShift
=
o
.
getDutyShift
();
initDutyShift
(
dayByMonth
,
dutyShift
,
list
);
list
.
add
(
carName
);
for
(
String
monthDay
:
monthDays
)
{
List
<
DutyPersonShiftLog
>
targetLogs
=
shiftLogsMap
.
get
(
monthDay
);
if
(
Objects
.
isNull
(
targetLogs
)
||
targetLogs
.
isEmpty
())
{
list
.
add
(
""
);
continue
;
}
DutyPersonShiftLog
shiftLog
=
targetLogs
.
get
(
0
);
String
deptName
=
shiftLog
.
getDeptName
();
String
dutyUsers
=
targetLogs
.
stream
().
map
(
DutyPersonShiftLog:
:
getDutyUser
).
distinct
().
collect
(
Collectors
.
joining
(
","
));
String
value
=
String
.
format
(
"%s|%s"
,
deptName
,
dutyUsers
);
list
.
add
(
value
);
}
data
.
add
(
list
);
}
);
}
}
return
data
;
}
private
List
<
String
>
getMonthDays
(
String
date
)
{
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
return
DateUtils
.
getDayByMonth
(
date
).
stream
().
map
(
formatter:
:
format
).
collect
(
Collectors
.
toList
());
}
private
void
initDutyShift
(
List
<
String
>
dayByMonth
,
List
<
DutyPersonShiftDto
>
dutyShift
,
ArrayList
<
Object
>
list
)
{
HashMap
<
String
,
String
>
dutyShiftMap
=
new
HashMap
<>();
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
...
...
@@ -2209,24 +2230,36 @@ public class ExcelServiceImpl {
private
List
<
List
<
Object
>>
initDutyPersonInfo
(
String
beginDate
,
String
endDate
,
List
<
String
>
dayByMonth
)
throws
ParseException
{
// 查询已值班数据
List
<
DutyPersonDto
>
contentList
=
iDutyPersonService
.
downloadList
(
beginDate
,
endDate
);
Map
<
String
,
List
<
DutyPersonShiftLog
>>
dutyPersonShiftLogs
=
dutyPersonService
.
getDownloadData
(
beginDate
,
endDate
);
List
<
List
<
Object
>>
data
=
new
ArrayList
<>();
List
<
String
>
monthDays
=
getMonthDays
(
beginDate
);
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
// 组装导出数据
if
(!
contentList
.
isEmpty
())
{
if
(!
dutyPersonShiftLogs
.
isEmpty
())
{
AtomicInteger
row
=
new
AtomicInteger
(
1
);
contentList
.
forEach
(
o
->
{
for
(
Map
.
Entry
<
String
,
List
<
DutyPersonShiftLog
>>
entry
:
dutyPersonShiftLogs
.
entrySet
())
{
String
userName
=
entry
.
getKey
();
List
<
DutyPersonShiftLog
>
shiftLogs
=
entry
.
getValue
();
shiftLogs
=
shiftLogs
.
stream
().
sorted
(
Comparator
.
comparing
(
DutyPersonShiftLog:
:
getDutyDate
)).
collect
(
Collectors
.
toList
());
DutyPersonShiftLog
dutyPersonShiftLog
=
shiftLogs
.
get
(
0
);
ArrayList
<
Object
>
list
=
new
ArrayList
<>();
list
.
add
(
row
.
getAndIncrement
());
list
.
add
(
o
.
getUserId
());
list
.
add
(
o
.
getUserName
());
list
.
add
(
o
.
getDeptName
());
list
.
add
(
o
.
getPostTypeName
());
list
.
add
(
o
.
getDutyArea
());
List
<
DutyPersonShiftDto
>
dutyShift
=
o
.
getDutyShift
();
initDutyShift
(
dayByMonth
,
dutyShift
,
list
);
list
.
add
(
dutyPersonShiftLog
.
getDutyUserId
());
list
.
add
(
userName
);
for
(
String
monthDay
:
monthDays
)
{
List
<
DutyPersonShiftLog
>
targetLogs
=
shiftLogs
.
stream
().
filter
(
v
->
Objects
.
equals
(
monthDay
,
formatter
.
format
(
v
.
getDutyDate
()))).
collect
(
Collectors
.
toList
());
if
(
targetLogs
.
isEmpty
())
{
list
.
add
(
NOT_DUTY
);
continue
;
}
DutyPersonShiftLog
shiftLog
=
targetLogs
.
get
(
0
);
String
value
=
String
.
format
(
"%s|%s|%s|%s"
,
shiftLog
.
getDeptName
(),
shiftLog
.
getPostTypeName
(),
Objects
.
isNull
(
shiftLog
.
getDutyArea
())
?
"无"
:
shiftLog
.
getDutyArea
(),
shiftLog
.
getShiftName
());
list
.
add
(
value
);
}
data
.
add
(
list
);
}
);
}
}
return
data
;
}
...
...
amos-boot-system-jcs/src/main/resources/db/changelog/jcs-1.0.0.0.xml
View file @
e2d64218
...
...
@@ -3643,6 +3643,33 @@
</sql>
</changeSet>
<changeSet
author=
"lixiuming"
id=
"2023-10-24-01"
>
<preConditions
onFail=
"MARK_RAN"
>
<tableExists
tableName=
"cb_duty_person_shift_log"
/>
</preConditions>
<comment>
create table cb_duty_person_shift_log 值班人员日期变更日志表
</comment>
<sql>
CREATE TABLE `cb_duty_person_shift_log` (
`sequence_nbr` bigint NOT NULL COMMENT '物理主键',
`instance_id` bigint COMMENT '实例ID',
`duty_date` date COMMENT '值班日期',
`group_code` varchar(255) COMMENT '分组code',
`dept_name` varchar(255) COMMENT '单位/部门',
`duty_user_id` varchar(255) COMMENT '值班人ID',
`duty_user` varchar(255) COMMENT '值班人',
`post_type_name` varchar(255) COMMENT '岗位',
`duty_area` varchar(255) COMMENT '值班区域',
`shift_name` varchar(255) COMMENT '值班类型',
`car_name` varchar(255) COMMENT '车辆名称(车辆特有)',
`rec_user_id` bigint NULL DEFAULT NULL COMMENT '更新人员id',
`rec_user_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '更新人员',
`rec_date` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
`is_delete` bit(1) NULL DEFAULT b'0' COMMENT '是否删除',
PRIMARY KEY (`sequence_nbr`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '值班人员日期变更日志表' ROW_FORMAT = Dynamic;
</sql>
</changeSet>
...
...
pom.xml
View file @
e2d64218
...
...
@@ -313,12 +313,12 @@
<repository>
<id>
Releases
</id>
<name>
Releases
</name>
<url>
http://
36.46.149.14
:8081/nexus/content/repositories/releases/
</url>
<url>
http://
113.142.68.105
:8081/nexus/content/repositories/releases/
</url>
</repository>
<repository>
<id>
Snapshots
</id>
<name>
Snapshots
</name>
<url>
http://
36.46.149.14
:8081/nexus/content/repositories/snapshots/
</url>
<url>
http://
113.142.68.105
:8081/nexus/content/repositories/snapshots/
</url>
</repository>
<repository>
<id>
com.e-iceblue
</id>
...
...
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