feat(wms/attendance): 新增考勤连续旷工天数计算功能,为保证速度把步骤拆分成两步
1. 前端新增“计算连续旷工”按钮,调用后端重算接口并优化加载状态管理 2. 后端新增recalcContinuousAbsent方法及接口,支持按指定员工或时间范围重算连续旷工天数 3. 优化考勤检查页面按钮布局,明确“生成考勤结果”操作
This commit is contained in:
@@ -51,3 +51,12 @@ export function generateAttendanceCheck(data) {
|
|||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 重算连续旷工天数
|
||||||
|
export function recalcContinuousAbsent(data) {
|
||||||
|
return request({
|
||||||
|
url: '/wms/attendanceCheck/recalcContinuousAbsent',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -425,7 +425,8 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
<div slot="footer" class="dialog-footer">
|
<div slot="footer" class="dialog-footer">
|
||||||
<el-button :loading="checkLoading" type="primary" @click="submitCheck">确 定</el-button>
|
<el-button :loading="recalcLoading" type="warning" @click="submitRecalc">计算连续旷工</el-button>
|
||||||
|
<el-button :loading="checkLoading" type="primary" @click="submitCheck">确 定(生成考勤结果)</el-button>
|
||||||
<el-button @click="cancelCheck">取 消</el-button>
|
<el-button @click="cancelCheck">取 消</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
@@ -433,7 +434,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listAttendanceCheck, getAttendanceCheck, delAttendanceCheck, generateAttendanceCheck, updateAttendanceCheck } from "@/api/wms/attendanceCheck";
|
import { listAttendanceCheck, getAttendanceCheck, delAttendanceCheck, generateAttendanceCheck, updateAttendanceCheck, recalcContinuousAbsent } from "@/api/wms/attendanceCheck";
|
||||||
import TimeRangePicker from "@/views/wms/report/components/timeRangePicker";
|
import TimeRangePicker from "@/views/wms/report/components/timeRangePicker";
|
||||||
import { listOutRequest } from "@/api/wms/outRequest";
|
import { listOutRequest } from "@/api/wms/outRequest";
|
||||||
import { listLeaveRequest } from "@/api/wms/leaveRequest";
|
import { listLeaveRequest } from "@/api/wms/leaveRequest";
|
||||||
@@ -450,6 +451,7 @@ export default {
|
|||||||
return {
|
return {
|
||||||
loading: true,
|
loading: true,
|
||||||
checkLoading: false,
|
checkLoading: false,
|
||||||
|
recalcLoading: false,
|
||||||
showSearch: true,
|
showSearch: true,
|
||||||
attendanceData: [],
|
attendanceData: [],
|
||||||
dateList: [],
|
dateList: [],
|
||||||
@@ -759,13 +761,13 @@ export default {
|
|||||||
|
|
||||||
Object.values(dataMap).forEach(employeeData => {
|
Object.values(dataMap).forEach(employeeData => {
|
||||||
const dates = Object.keys(employeeData).filter(key => key !== 'employeeName' && key !== 'employeeId').sort()
|
const dates = Object.keys(employeeData).filter(key => key !== 'employeeName' && key !== 'employeeId').sort()
|
||||||
|
|
||||||
dates.forEach((date, index) => {
|
dates.forEach((date, index) => {
|
||||||
const currentRecord = employeeData[date]
|
const currentRecord = employeeData[date]
|
||||||
if (currentRecord && currentRecord.shiftName === '生产倒班夜班') {
|
if (currentRecord && currentRecord.shiftName === '生产倒班夜班') {
|
||||||
const nextDate = dayjs(date).add(1, 'day').format('YYYY-MM-DD')
|
const nextDate = dayjs(date).add(1, 'day').format('YYYY-MM-DD')
|
||||||
const nextRecord = employeeData[nextDate]
|
const nextRecord = employeeData[nextDate]
|
||||||
|
|
||||||
if (nextRecord && nextRecord.shiftName === '夜转白') {
|
if (nextRecord && nextRecord.shiftName === '夜转白') {
|
||||||
currentRecord.p1EndTime = ''
|
currentRecord.p1EndTime = ''
|
||||||
currentRecord.p1LastCheck = ''
|
currentRecord.p1LastCheck = ''
|
||||||
@@ -875,6 +877,8 @@ export default {
|
|||||||
|
|
||||||
cancelCheck() {
|
cancelCheck() {
|
||||||
this.checkOpen = false
|
this.checkOpen = false
|
||||||
|
this.checkLoading = false
|
||||||
|
this.recalcLoading = false
|
||||||
this.checkForm = { startDate: undefined, endDate: undefined }
|
this.checkForm = { startDate: undefined, endDate: undefined }
|
||||||
this.selectedUserIds = []
|
this.selectedUserIds = []
|
||||||
this.checkDept = ''
|
this.checkDept = ''
|
||||||
@@ -907,6 +911,24 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
submitRecalc() {
|
||||||
|
this.$refs["checkForm"].validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
this.recalcLoading = true
|
||||||
|
const params = {
|
||||||
|
...this.checkForm,
|
||||||
|
userIds: this.selectedUserIds
|
||||||
|
}
|
||||||
|
recalcContinuousAbsent(params).then(response => {
|
||||||
|
this.$modal.msgSuccess("重算成功")
|
||||||
|
this.getList()
|
||||||
|
}).finally(() => {
|
||||||
|
this.recalcLoading = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
handleUpdate() {
|
handleUpdate() {
|
||||||
if (this.currentDetail) {
|
if (this.currentDetail) {
|
||||||
const checkId = this.currentDetail.checkId
|
const checkId = this.currentDetail.checkId
|
||||||
@@ -1207,4 +1229,4 @@ export default {
|
|||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -58,6 +58,13 @@ public class WmsAttendanceCheckController extends BaseController {
|
|||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Log(title = "重算连续旷工", businessType = BusinessType.UPDATE)
|
||||||
|
@PostMapping("/recalcContinuousAbsent")
|
||||||
|
public R<Void> recalcContinuousAbsent(@Validated @RequestBody AttendanceCheckBo bo) {
|
||||||
|
iWmsAttendanceCheckService.recalcContinuousAbsent(bo);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
@Log(title = "考勤比对", businessType = BusinessType.UPDATE)
|
@Log(title = "考勤比对", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody WmsAttendanceCheckBo bo) {
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody WmsAttendanceCheckBo bo) {
|
||||||
|
|||||||
@@ -21,5 +21,7 @@ public interface IWmsAttendanceCheckService {
|
|||||||
|
|
||||||
void checkAttendance(AttendanceCheckBo bo);
|
void checkAttendance(AttendanceCheckBo bo);
|
||||||
|
|
||||||
|
void recalcContinuousAbsent(AttendanceCheckBo bo);
|
||||||
|
|
||||||
Boolean updateByBo(WmsAttendanceCheckBo bo);
|
Boolean updateByBo(WmsAttendanceCheckBo bo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,9 +124,9 @@ public class WmsAttendanceCheckServiceImpl implements IWmsAttendanceCheckService
|
|||||||
// 获取当前有效的考勤规则
|
// 获取当前有效的考勤规则
|
||||||
WmsAttendanceRule rule = getActiveRule();
|
WmsAttendanceRule rule = getActiveRule();
|
||||||
|
|
||||||
// 将日期转换为LocalDate类型
|
// // 将日期转换为LocalDate类型
|
||||||
LocalDate startLocal = toLocalDate(bo.getStartDate());
|
// LocalDate startLocal = toLocalDate(bo.getStartDate());
|
||||||
LocalDate endLocal = toLocalDate(bo.getEndDate());
|
// LocalDate endLocal = toLocalDate(bo.getEndDate());
|
||||||
|
|
||||||
// 创建待处理的考勤计划列表
|
// 创建待处理的考勤计划列表
|
||||||
List<WmsAttendanceScheduleVo> toProcess = new ArrayList<>();
|
List<WmsAttendanceScheduleVo> toProcess = new ArrayList<>();
|
||||||
@@ -205,8 +205,26 @@ public class WmsAttendanceCheckServiceImpl implements IWmsAttendanceCheckService
|
|||||||
|
|
||||||
// 批量插入考勤检查记录
|
// 批量插入考勤检查记录
|
||||||
baseMapper.insertBatch(checksToInsert, BATCH_SIZE);
|
baseMapper.insertBatch(checksToInsert, BATCH_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
// 更新连续缺勤记录
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void recalcContinuousAbsent(AttendanceCheckBo bo) {
|
||||||
|
LocalDate startLocal = toLocalDate(bo.getStartDate());
|
||||||
|
LocalDate endLocal = toLocalDate(bo.getEndDate());
|
||||||
|
Set<Long> affectedUserIds;
|
||||||
|
if (bo.getUserIds() != null && !bo.getUserIds().isEmpty()) {
|
||||||
|
affectedUserIds = new HashSet<>(bo.getUserIds());
|
||||||
|
} else {
|
||||||
|
List<WmsAttendanceCheck> checks = baseMapper.selectList(Wrappers.<WmsAttendanceCheck>lambdaQuery()
|
||||||
|
.select(WmsAttendanceCheck::getUserId)
|
||||||
|
.ge(WmsAttendanceCheck::getWorkDate, toDate(startLocal.atStartOfDay()))
|
||||||
|
.le(WmsAttendanceCheck::getWorkDate, toDate(endLocal.atTime(LocalTime.of(23, 59, 59))))
|
||||||
|
.eq(WmsAttendanceCheck::getDelFlag, 0));
|
||||||
|
affectedUserIds = checks.stream()
|
||||||
|
.map(WmsAttendanceCheck::getUserId)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
}
|
||||||
updateContinuousAbsent(startLocal, endLocal, affectedUserIds);
|
updateContinuousAbsent(startLocal, endLocal, affectedUserIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user